@majoo-ui/react 2.0.1 → 2.1.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/charts.esm.js +3 -1453
- package/colors/Colors.esm.js +93 -0
- package/components/accordion/Accordion.esm.js +109 -0
- package/components/alertDialog/AlertDialog.esm.js +440 -0
- package/components/avatar/Avatar.esm.js +83 -0
- package/components/badge/Badge.esm.js +255 -0
- package/components/banner/Banner.esm.js +341 -0
- package/components/barChart/BarChart.esm.js +212 -0
- package/components/breadcrumb/Breadcrumb.esm.js +65 -0
- package/components/breadcrumb/index.esm.js +19 -0
- package/components/button/Button.esm.js +331 -0
- package/components/buttonGroup/ButtonGroup.esm.js +350 -0
- package/components/card/Card.esm.js +236 -0
- package/components/chart/assets/data_kosong.png.esm.js +3 -0
- package/components/chart/lineChart/LineChart.esm.js +358 -0
- package/components/chart/lineChart/components/Comparator.esm.js +82 -0
- package/components/chart/lineChart/components/ComparatorController.esm.js +112 -0
- package/components/chart/lineChart/components/ComparatorItem.esm.js +104 -0
- package/components/chart/lineChart/components/ProductList.esm.js +78 -0
- package/components/chart/lineChart/components/TitleLegend.esm.js +107 -0
- package/components/chart/lineChart/components/Tooltip.esm.js +90 -0
- package/components/chart/utils/index.esm.js +109 -0
- package/components/checkboxTable/CheckboxTable.esm.js +287 -0
- package/components/colorPicker/ColorPicker.esm.js +342 -0
- package/components/colorPicker/InputColorPicker.esm.js +120 -0
- package/components/colorPicker/assets/img_colormap.gif.esm.js +3 -0
- package/components/colorPicker/components/ColorFields.esm.js +144 -0
- package/components/colorPicker/components/ColorMap.esm.js +1188 -0
- package/components/contentEditor/ContentEditor.esm.js +251 -0
- package/components/contentEditor/assets/Inline-code-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Link-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/List-bulleted-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/List-numbered-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Redo-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Text-bold-filled.svg.esm.js +3 -0
- package/components/contentEditor/assets/Text-clear-format-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Text-italic-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Text-strikethrough-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Text-underline-outline.svg.esm.js +3 -0
- package/components/contentEditor/assets/Undo-outline.svg.esm.js +3 -0
- package/components/contextMenu/ContextMenu.esm.js +298 -0
- package/components/datePicker/AdvancedOption.esm.js +37 -0
- package/components/datePicker/CustomDatePicker.esm.js +121 -0
- package/components/datePicker/DatePicker.esm.js +244 -0
- package/components/datePicker/DatePickerMulti.esm.js +70 -0
- package/components/datePicker/InputDatePicker.esm.js +290 -0
- package/components/datePicker/InputDateRangePicker.esm.js +174 -0
- package/components/datePicker/components/Calendar.esm.js +654 -0
- package/components/datePicker/components/CalendarMulti.esm.js +407 -0
- package/components/datePicker/components/CalendarTimePicker.esm.js +104 -0
- package/components/datePicker/components/DateNumber.esm.js +89 -0
- package/components/datePicker/components/MobileCalendar.esm.js +522 -0
- package/components/datePicker/state/reducer.esm.js +286 -0
- package/components/datePicker/timePicker/InputTimePicker.esm.js +205 -0
- package/components/datePicker/timePicker/TimePicker.esm.js +481 -0
- package/components/devicePreview/DevicePreview.esm.js +631 -0
- package/components/devicePreview/deviceFrame/android-transparant.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/android-wide-transparant.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/bg-email.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/bg-notification.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/bg-sms.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/bg-whatsapp.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/desktop-transparant.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/ic-majoo-profpic.png.esm.js +3 -0
- package/components/devicePreview/deviceFrame/iphone-transparant.png.esm.js +3 -0
- package/components/dialog/Dialog.esm.js +106 -0
- package/components/drawer/Drawer.esm.js +294 -0
- package/components/dropdownMenu/DropdownMenu.esm.js +281 -0
- package/components/editableTable/EditableMobile.esm.js +361 -0
- package/components/editableTable/EditableTable.esm.js +618 -0
- package/components/editableTable/transition.esm.js +37 -0
- package/components/form/components/FormGroup/FormGroup.esm.js +142 -0
- package/components/form/components/FormHelper/Helper.esm.js +50 -0
- package/components/form/components/FormLabel/Label.esm.js +90 -0
- package/components/form/components/InputAddon/InputAddon.esm.js +105 -0
- package/components/form/components/InputCheckbox/CheckboxGroup.esm.js +60 -0
- package/components/form/components/InputCheckbox/InputCheckbox.esm.js +129 -0
- package/components/form/components/InputCheckbox/icon/CheckOutline.esm.js +33 -0
- package/components/form/components/InputCheckbox/icon/MinusOutline.esm.js +33 -0
- package/components/form/components/InputCombobox/InputCombobox.esm.js +169 -0
- package/components/form/components/InputCounter/InputCounter.esm.js +226 -0
- package/components/form/components/InputCreatable/InputCreatable.esm.js +229 -0
- package/components/form/components/InputDateRange/InputDateRange.esm.js +46 -0
- package/components/form/components/InputElement/InputElement.esm.js +35 -0
- package/components/form/components/InputGroup/InputGroup.esm.js +188 -0
- package/components/form/components/InputLetter/InputLetter.esm.js +68 -0
- package/components/form/components/InputNumber/InputNumber.esm.js +248 -0
- package/components/form/components/InputNumber/NumberFormat.esm.js +1263 -0
- package/components/form/components/InputOTP/InputOTP.esm.js +70 -0
- package/components/form/components/InputRadio/InputRadio.esm.js +273 -0
- package/components/form/components/InputRadio/InputRadioGroup.esm.js +35 -0
- package/components/form/components/InputRadio/context.esm.js +5 -0
- package/components/form/components/InputResourceList/InputResourceList.esm.js +429 -0
- package/components/form/components/InputSearchbox/CloseFilled.esm.js +34 -0
- package/components/form/components/InputSearchbox/InputSearchbox.esm.js +90 -0
- package/components/form/components/InputSearchbox/SearchOutline.esm.js +26 -0
- package/components/form/components/InputSelect/InputSelect.esm.js +964 -0
- package/components/form/components/InputSelectCheck/InputSelectCheck.esm.js +1388 -0
- package/components/form/components/InputSelectCheck/OptionGroupItem.esm.js +39 -0
- package/components/form/components/InputSelectCheck/icon/CheckOutline.esm.js +33 -0
- package/components/form/components/InputSelectTag/InputSelectTag.esm.js +62 -0
- package/components/form/components/InputSignature/InputSignature.esm.js +122 -0
- package/components/form/components/InputSignature/SignatureModal.esm.js +67 -0
- package/components/form/components/InputSwitch/InputSwitch.esm.js +96 -0
- package/components/form/components/InputSwitch/InputSwitchWithImage.esm.js +136 -0
- package/components/form/components/InputTags/InputTags.esm.js +268 -0
- package/components/form/components/InputText/InputText.esm.js +197 -0
- package/components/form/components/InputTextArea/InputTextArea.esm.js +77 -0
- package/components/heading/Heading.esm.js +64 -0
- package/components/iconButton/IconButton.esm.js +71 -0
- package/components/image/Image.esm.js +141 -0
- package/components/link/Link.esm.js +59 -0
- package/components/loadingBar/LoadingBar.esm.js +113 -0
- package/components/mapPicker/InputMapPicker.esm.js +160 -0
- package/components/mapPicker/MapPicker.esm.js +122 -0
- package/components/mapPicker/MapPicker.styles.esm.js +70 -0
- package/components/mapPicker/assets/images/Mapsicle.png.esm.js +3 -0
- package/components/mapPicker/components/AddressCard.esm.js +25 -0
- package/components/mapPicker/components/ButtonSelect.esm.js +46 -0
- package/components/mapPicker/components/ChangeView.esm.js +20 -0
- package/components/mapPicker/components/InputSearch.esm.js +74 -0
- package/components/mapPicker/components/MarkerIcon.esm.js +22 -0
- package/components/mapPicker/components/MarkerSvg.esm.js +62 -0
- package/components/mapPicker/components/ZoomControls.esm.js +36 -0
- package/components/mapPicker/hooks/useMapSearch.esm.js +161 -0
- package/components/modalDialog/ModalDialog.esm.js +247 -0
- package/components/notificationBadge/NotificationBadge.esm.js +149 -0
- package/components/pageDialog/PageDialog.esm.js +291 -0
- package/components/pageDialog/logo.svg.esm.js +3 -0
- package/components/pagination/Pagination.esm.js +94 -0
- package/components/pagination/PaginationButton.esm.js +346 -0
- package/components/pagination/PaginationInfo.esm.js +146 -0
- package/components/paper/Paper.esm.js +76 -0
- package/components/paragraph/Paragraph.esm.js +52 -0
- package/components/pieChart/PieChart.esm.js +287 -0
- package/components/popover/Popover.esm.js +142 -0
- package/components/progress/Progress.esm.js +170 -0
- package/components/progressIndicator/ProgressIndicator.esm.js +287 -0
- package/components/scrollSync/ScrollSync.esm.js +172 -0
- package/components/scrollSync/ScrollSyncNode.esm.js +87 -0
- package/components/scrollSync/utils.esm.js +9 -0
- package/components/separator/Separator.esm.js +43 -0
- package/components/skeleton/Skeleton.esm.js +131 -0
- package/components/slider/Slider.esm.js +345 -0
- package/components/stepWizard/StepWizard.esm.js +451 -0
- package/components/stepWizard/index.esm.js +14 -0
- package/components/table/MobileTable.esm.js +415 -0
- package/components/table/Table.esm.js +1472 -0
- package/components/table/components/columns/DateColumn.esm.js +26 -0
- package/components/table/components/columns/DecimalColumn.esm.js +36 -0
- package/components/table/components/columns/PriceColumn.esm.js +57 -0
- package/components/table/components/columns/RowDraggableColumn.esm.js +24 -0
- package/components/table/components/columns/RowExpanderColumn.esm.js +32 -0
- package/components/table/components/columns/RowExpanderMultipleColumn.esm.js +24 -0
- package/components/table/components/columns/RowMenuColumn.esm.js +101 -0
- package/components/table/components/columns/RowSelectionCallbackColumn.esm.js +38 -0
- package/components/table/components/columns/RowSelectionColumn.esm.js +34 -0
- package/components/table/images/img-emptydata.webp.esm.js +3 -0
- package/components/table/images/img-emptysearchdata.webp.esm.js +3 -0
- package/components/tableOfContent/TableOfContent.esm.js +267 -0
- package/components/tableOfContent/index.esm.js +18 -0
- package/components/tableOfContent/transition.esm.js +38 -0
- package/components/tabs/Tabs.esm.js +282 -0
- package/components/tag/Tag.esm.js +161 -0
- package/components/tagList/TagList.esm.js +90 -0
- package/components/tagStatus/TagStatus.esm.js +134 -0
- package/components/text/Text.esm.js +140 -0
- package/components/toast/Toast.esm.js +297 -0
- package/components/toast/ToastContainer.esm.js +73 -0
- package/components/toast/context/ToastContext.esm.js +5 -0
- package/components/toast/context/ToastProvider.esm.js +96 -0
- package/components/tooltip/Tooltip.esm.js +175 -0
- package/components/upload/Upload.esm.js +1103 -0
- package/components/upload/utils/canvasPreview.esm.js +39 -0
- package/components/upload/utils/imgPreview.esm.js +21 -0
- package/config/stitches.config.esm.js +216 -0
- package/editor.esm.js +1 -264
- package/hooks/useListOption/useListOption.esm.js +56 -0
- package/hooks/useToggle/useToggle.esm.js +8 -0
- package/index.esm.js +106 -42293
- package/layout/box/Box.esm.js +24 -0
- package/layout/flex/Flex.esm.js +135 -0
- package/layout/grid/Grid.esm.js +270 -0
- package/layout/pageContainer/PageContainer.esm.js +60 -0
- package/majoo-provider/MajooProvider.esm.js +42 -0
- package/majoo-provider/ThemeProvider.esm.js +41 -0
- package/majoo-provider/globalStyles.esm.js +242 -0
- package/majoo-provider/styles/modern-normalize.esm.js +95 -0
- package/map.esm.js +2 -734
- package/package.json +8 -4
- package/utils/calendar.esm.js +26 -0
- package/utils/element.esm.js +21 -0
- package/utils/object.esm.js +12 -0
- package/utils/request.esm.js +74 -0
- package/utils/strings.esm.js +6 -0
- package/{useMediaQuery.esm.js → utils/useMediaQuery.esm.js} +1 -1
- package/utils/useNavigatorOnline.esm.js +19 -0
- package/utils/variant.esm.js +12 -0
- package/wrapper/ConditionalWrapper.esm.js +9 -0
- package/ModalDialog.esm.js +0 -2669
- package/Separator.esm.js +0 -3002
- package/stitches.config.esm.js +0 -2284
- package/{index.esm.css → charts.esm.css} +4 -4
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useEffect, useReducer } from 'react';
|
|
3
|
+
import { CalendarOutline } from '@majoo-ui/icons';
|
|
4
|
+
import Box from '../../layout/box/Box.esm.js';
|
|
5
|
+
import useMediaQuery from '../../utils/useMediaQuery.esm.js';
|
|
6
|
+
import { Drawer, DrawerContent } from '../drawer/Drawer.esm.js';
|
|
7
|
+
import { InputGroup } from '../form/components/InputGroup/InputGroup.esm.js';
|
|
8
|
+
import { InputLeftElement } from '../form/components/InputElement/InputElement.esm.js';
|
|
9
|
+
import { InputText } from '../form/components/InputText/InputText.esm.js';
|
|
10
|
+
import { AdvancedOption } from './AdvancedOption.esm.js';
|
|
11
|
+
import { SINGLE_PICKER, WEEKLY, DatePicker, DATE_RANGE_PICKER, ADVANCE_PICKER } from './DatePicker.esm.js';
|
|
12
|
+
import { pickerReducer, UPDATE_PICKER, advancePickerDate, advancePickerOptionsId, advancePickerOptionsEn } from './state/reducer.esm.js';
|
|
13
|
+
import moment from 'moment';
|
|
14
|
+
import { ContainerDateRangePicker, InputDateRangePicker } from './InputDateRangePicker.esm.js';
|
|
15
|
+
import { ConditionalWrapper } from '../../wrapper/ConditionalWrapper.esm.js';
|
|
16
|
+
import { useTranslation } from 'react-i18next';
|
|
17
|
+
import { Popover, PopoverTrigger, PopoverContent } from '../popover/Popover.esm.js';
|
|
18
|
+
|
|
19
|
+
const getInputPickerValue = (type, date, isTimePicker) => {
|
|
20
|
+
if (!date) return '';
|
|
21
|
+
if (type === SINGLE_PICKER) {
|
|
22
|
+
return `${moment(date).format(isTimePicker ? 'DD MMMM YYYY, HH:mm' : 'DD MMMM YYYY')}`;
|
|
23
|
+
} else {
|
|
24
|
+
return `${moment(date[0]).format('DD MMM YYYY')} - ${moment(date[1]).format('DD MMM YYYY')}`;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
function InputDatePicker({
|
|
28
|
+
type = SINGLE_PICKER,
|
|
29
|
+
showRangeControl,
|
|
30
|
+
rangePickerType = WEEKLY,
|
|
31
|
+
placeholder,
|
|
32
|
+
size = 'sm',
|
|
33
|
+
disabled,
|
|
34
|
+
onChange,
|
|
35
|
+
onDateSelected,
|
|
36
|
+
defaultValue: defaultDateValue,
|
|
37
|
+
value: dateValue,
|
|
38
|
+
defaultDate,
|
|
39
|
+
date,
|
|
40
|
+
advanceView,
|
|
41
|
+
placement = 'bottom-start',
|
|
42
|
+
css,
|
|
43
|
+
showTimePicker,
|
|
44
|
+
timePickerProps,
|
|
45
|
+
minDate,
|
|
46
|
+
maxDate,
|
|
47
|
+
readOnly,
|
|
48
|
+
isInvalid,
|
|
49
|
+
allowReset,
|
|
50
|
+
portalled,
|
|
51
|
+
portalledMobile = false,
|
|
52
|
+
onClose,
|
|
53
|
+
mobileOnly,
|
|
54
|
+
desktopOnly,
|
|
55
|
+
drawerCss,
|
|
56
|
+
drawerContentCss = {},
|
|
57
|
+
isMobile = false,
|
|
58
|
+
maxRange
|
|
59
|
+
}) {
|
|
60
|
+
const {
|
|
61
|
+
t,
|
|
62
|
+
i18n
|
|
63
|
+
} = useTranslation('MajooUI/datePicker');
|
|
64
|
+
const [value, setValue] = useState(date || dateValue);
|
|
65
|
+
const [defaultValue, setDefaultValue] = useState(defaultDate || defaultDateValue);
|
|
66
|
+
const language = i18n.language;
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
setValue(date || dateValue);
|
|
69
|
+
}, [date, dateValue]);
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
setDefaultValue(defaultDate || defaultDateValue);
|
|
72
|
+
}, [defaultDate, defaultDateValue]);
|
|
73
|
+
const [{
|
|
74
|
+
selectedDate
|
|
75
|
+
}, dispatch] = useReducer(pickerReducer, {
|
|
76
|
+
selectedDate: defaultValue !== null && defaultValue !== void 0 ? defaultValue : value
|
|
77
|
+
});
|
|
78
|
+
const [openPicker, setOpenPicker] = useState(false);
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (value) {
|
|
81
|
+
dispatch({
|
|
82
|
+
type: UPDATE_PICKER,
|
|
83
|
+
payload: value
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}, [value]);
|
|
87
|
+
const isMobileView = useMediaQuery(`(max-width: ${type === SINGLE_PICKER ? '480px' : '1090px'})`);
|
|
88
|
+
function handleChange() {
|
|
89
|
+
if (!disabled && !readOnly) {
|
|
90
|
+
setOpenPicker(!openPicker);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function handleRangeChange(type) {
|
|
94
|
+
if (selectedDate && !disabled && !readOnly && !isInvalid) {
|
|
95
|
+
const actionType = rangePickerType === 'monthly' ? 'MONTH' : 'WEEK';
|
|
96
|
+
if (type === 'prev') {
|
|
97
|
+
dispatch({
|
|
98
|
+
type: 'UPDATE',
|
|
99
|
+
payload: advancePickerDate('PREV_' + actionType, selectedDate)
|
|
100
|
+
});
|
|
101
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(advancePickerDate('PREV_' + actionType, selectedDate));
|
|
102
|
+
} else {
|
|
103
|
+
dispatch({
|
|
104
|
+
type: 'UPDATE',
|
|
105
|
+
payload: advancePickerDate('NEXT_' + actionType, selectedDate)
|
|
106
|
+
});
|
|
107
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(advancePickerDate('NEXT_' + actionType, selectedDate));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const renderInputGroup = () => {
|
|
112
|
+
if (!showRangeControl) {
|
|
113
|
+
return jsxs(InputGroup, {
|
|
114
|
+
disabled: disabled,
|
|
115
|
+
readOnly: readOnly,
|
|
116
|
+
onClick: handleChange,
|
|
117
|
+
size: size,
|
|
118
|
+
isInvalid: isInvalid,
|
|
119
|
+
mobileOnly: mobileOnly,
|
|
120
|
+
desktopOnly: desktopOnly,
|
|
121
|
+
children: [jsx(InputLeftElement, {
|
|
122
|
+
children: jsx(CalendarOutline, {
|
|
123
|
+
color: "currentColor"
|
|
124
|
+
})
|
|
125
|
+
}), jsx(InputText, {
|
|
126
|
+
placeholder: placeholder || t('datePickerPlaceholder', 'Pilih Tanggal'),
|
|
127
|
+
value: getInputPickerValue(type, selectedDate, showTimePicker),
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
129
|
+
onChange: () => {},
|
|
130
|
+
isPicker: true,
|
|
131
|
+
autoComplete: "false"
|
|
132
|
+
})]
|
|
133
|
+
});
|
|
134
|
+
} else {
|
|
135
|
+
return jsx(InputDateRangePicker, {
|
|
136
|
+
value: getInputPickerValue(ADVANCE_PICKER, selectedDate, false),
|
|
137
|
+
placeholder: placeholder || t('datePickerPlaceholder', 'Pilih Tanggal'),
|
|
138
|
+
disabled: disabled,
|
|
139
|
+
readOnly: readOnly,
|
|
140
|
+
size: size,
|
|
141
|
+
isInvalid: isInvalid,
|
|
142
|
+
onClick: handleChange,
|
|
143
|
+
mobileOnly: mobileOnly,
|
|
144
|
+
desktopOnly: desktopOnly
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const renderDatePicker = () => {
|
|
149
|
+
const handleDatePickerChange = value => {
|
|
150
|
+
if (showRangeControl || type === 'range_picker') {
|
|
151
|
+
if (rangePickerType === 'monthly') {
|
|
152
|
+
dispatch({
|
|
153
|
+
type: 'UPDATE',
|
|
154
|
+
payload: advancePickerDate('RANGE_MONTH', value)
|
|
155
|
+
});
|
|
156
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(advancePickerDate('RANGE_MONTH', value));
|
|
157
|
+
} else {
|
|
158
|
+
dispatch({
|
|
159
|
+
type: 'UPDATE',
|
|
160
|
+
payload: advancePickerDate('RANGE_WEEK', value)
|
|
161
|
+
});
|
|
162
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(advancePickerDate('RANGE_WEEK', value));
|
|
163
|
+
}
|
|
164
|
+
} else {
|
|
165
|
+
dispatch({
|
|
166
|
+
type: 'UPDATE',
|
|
167
|
+
payload: value
|
|
168
|
+
});
|
|
169
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
return jsx(DatePicker, {
|
|
173
|
+
advanceView: type === ADVANCE_PICKER && (!advanceView ? jsx(AdvancedOption, {
|
|
174
|
+
options: language === 'id' ? advancePickerOptionsId : advancePickerOptionsEn,
|
|
175
|
+
disabled: disabled,
|
|
176
|
+
optionHandler: value => {
|
|
177
|
+
const reducedResult = advancePickerDate(value, undefined);
|
|
178
|
+
const dateAsString = moment(reducedResult[1]).format('YYYY-MM-DD');
|
|
179
|
+
const payload = [reducedResult[0], moment(`${dateAsString} 23:59`, 'YYYY-MM-DD HH:mm').toDate()];
|
|
180
|
+
dispatch({
|
|
181
|
+
type: 'UPDATE',
|
|
182
|
+
payload
|
|
183
|
+
});
|
|
184
|
+
if (onChange) onChange(payload);
|
|
185
|
+
setOpenPicker(false);
|
|
186
|
+
}
|
|
187
|
+
}) : {
|
|
188
|
+
advanceView
|
|
189
|
+
}),
|
|
190
|
+
type: showRangeControl ? DATE_RANGE_PICKER : type,
|
|
191
|
+
disabled: disabled,
|
|
192
|
+
date: value ? value === null || value === void 0 ? void 0 : value[1] : selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate[1],
|
|
193
|
+
selected: selectedDate,
|
|
194
|
+
isMultiDatePicker: type !== SINGLE_PICKER || showRangeControl,
|
|
195
|
+
onChange: handleDatePickerChange,
|
|
196
|
+
onDateSelected: e => onDateSelected === null || onDateSelected === void 0 ? void 0 : onDateSelected(e),
|
|
197
|
+
onClose: () => {
|
|
198
|
+
setOpenPicker(false);
|
|
199
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
200
|
+
},
|
|
201
|
+
showTimePicker: showTimePicker,
|
|
202
|
+
timePickerProps: timePickerProps,
|
|
203
|
+
minDate: minDate,
|
|
204
|
+
maxDate: maxDate,
|
|
205
|
+
allowReset: allowReset,
|
|
206
|
+
maxRange: maxRange
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
return !isMobile && !isMobileView ? jsxs(Popover, {
|
|
210
|
+
flip: false,
|
|
211
|
+
open: openPicker,
|
|
212
|
+
onOpenChange: setOpenPicker,
|
|
213
|
+
onClose: onClose,
|
|
214
|
+
placement: placement,
|
|
215
|
+
children: [disabled || readOnly ? jsx(Box, {
|
|
216
|
+
css: css,
|
|
217
|
+
children: jsx(ConditionalWrapper, {
|
|
218
|
+
condition: showRangeControl,
|
|
219
|
+
wrapper: children => jsx(ContainerDateRangePicker, {
|
|
220
|
+
disabled: disabled,
|
|
221
|
+
readOnly: readOnly,
|
|
222
|
+
isInvalid: isInvalid,
|
|
223
|
+
onRangeChange: handleRangeChange,
|
|
224
|
+
mobileOnly: mobileOnly,
|
|
225
|
+
desktopOnly: desktopOnly,
|
|
226
|
+
children: children
|
|
227
|
+
}),
|
|
228
|
+
children: renderInputGroup()
|
|
229
|
+
})
|
|
230
|
+
}) : jsx(ConditionalWrapper, {
|
|
231
|
+
condition: showRangeControl,
|
|
232
|
+
wrapper: children => jsx(Box, {
|
|
233
|
+
css: css,
|
|
234
|
+
children: jsx(ContainerDateRangePicker, {
|
|
235
|
+
disabled: disabled,
|
|
236
|
+
readOnly: readOnly,
|
|
237
|
+
isInvalid: isInvalid,
|
|
238
|
+
onRangeChange: handleRangeChange,
|
|
239
|
+
mobileOnly: mobileOnly,
|
|
240
|
+
desktopOnly: desktopOnly,
|
|
241
|
+
children: children
|
|
242
|
+
})
|
|
243
|
+
}),
|
|
244
|
+
children: jsx(PopoverTrigger, {
|
|
245
|
+
children: showRangeControl ? renderInputGroup() : jsx(Box, {
|
|
246
|
+
css: css,
|
|
247
|
+
children: renderInputGroup()
|
|
248
|
+
})
|
|
249
|
+
})
|
|
250
|
+
}), jsx(PopoverContent, {
|
|
251
|
+
portalled: portalled,
|
|
252
|
+
children: renderDatePicker()
|
|
253
|
+
})]
|
|
254
|
+
}) : jsxs(Fragment, {
|
|
255
|
+
children: [jsx(Box, {
|
|
256
|
+
css: css,
|
|
257
|
+
children: jsx(ConditionalWrapper, {
|
|
258
|
+
condition: showRangeControl,
|
|
259
|
+
wrapper: children => jsx(ContainerDateRangePicker, {
|
|
260
|
+
disabled: disabled,
|
|
261
|
+
readOnly: readOnly,
|
|
262
|
+
isInvalid: isInvalid,
|
|
263
|
+
onRangeChange: handleRangeChange,
|
|
264
|
+
mobileOnly: mobileOnly,
|
|
265
|
+
desktopOnly: desktopOnly,
|
|
266
|
+
children: children
|
|
267
|
+
}),
|
|
268
|
+
children: renderInputGroup()
|
|
269
|
+
})
|
|
270
|
+
}), jsx(Drawer, {
|
|
271
|
+
open: openPicker,
|
|
272
|
+
onOpenChange: isOpen => {
|
|
273
|
+
handleChange();
|
|
274
|
+
!isOpen && (onClose === null || onClose === void 0 ? void 0 : onClose());
|
|
275
|
+
},
|
|
276
|
+
side: "bottom",
|
|
277
|
+
portalled: portalledMobile,
|
|
278
|
+
css: drawerCss,
|
|
279
|
+
children: jsx(DrawerContent, {
|
|
280
|
+
size: "full",
|
|
281
|
+
css: Object.assign(Object.assign({}, drawerContentCss), {
|
|
282
|
+
height: 'unset !important'
|
|
283
|
+
}),
|
|
284
|
+
children: renderDatePicker()
|
|
285
|
+
})
|
|
286
|
+
})]
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export { InputDatePicker };
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import Flex from '../../layout/flex/Flex.esm.js';
|
|
4
|
+
import { styled, colors } from '../../config/stitches.config.esm.js';
|
|
5
|
+
import { CalendarOutline, ChevronRightOutline, ChevronLeftOutline } from '@majoo-ui/icons';
|
|
6
|
+
import { InputGroup } from '../form/components/InputGroup/InputGroup.esm.js';
|
|
7
|
+
import { InputLeftElement } from '../form/components/InputElement/InputElement.esm.js';
|
|
8
|
+
import { InputText } from '../form/components/InputText/InputText.esm.js';
|
|
9
|
+
|
|
10
|
+
const Container = styled(Flex, {
|
|
11
|
+
flexDirection: 'row',
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
userSelect: 'none',
|
|
14
|
+
border: '1px solid $bgOutline',
|
|
15
|
+
borderRadius: 6,
|
|
16
|
+
'&:hover': {
|
|
17
|
+
border: '1px solid $primary400'
|
|
18
|
+
},
|
|
19
|
+
variants: {
|
|
20
|
+
readOnly: {
|
|
21
|
+
true: {
|
|
22
|
+
backgroundColor: '$formDisable'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
disabled: {
|
|
26
|
+
true: {
|
|
27
|
+
backgroundColor: '$formDisable',
|
|
28
|
+
color: '$textDisable',
|
|
29
|
+
cursor: 'not-allowed',
|
|
30
|
+
'&::placeholder': {
|
|
31
|
+
color: '$textDisable'
|
|
32
|
+
},
|
|
33
|
+
'&:hover': {
|
|
34
|
+
border: '1px solid $colors$gray300'
|
|
35
|
+
},
|
|
36
|
+
'& > input': {
|
|
37
|
+
color: '$textSecondary',
|
|
38
|
+
cursor: 'not-allowed'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
isInvalid: {
|
|
43
|
+
true: {
|
|
44
|
+
border: '1px solid $colors$red400',
|
|
45
|
+
'&:focus': {
|
|
46
|
+
border: '1px solid $colors$red400'
|
|
47
|
+
},
|
|
48
|
+
'&:hover': {
|
|
49
|
+
border: '1px solid $colors$red400'
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
mobileOnly: {
|
|
54
|
+
true: {
|
|
55
|
+
'@lg': {
|
|
56
|
+
display: 'none !important'
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
desktopOnly: {
|
|
61
|
+
true: {
|
|
62
|
+
display: 'none !important',
|
|
63
|
+
'@lg': {
|
|
64
|
+
display: 'flex !important'
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
const Button = styled(Flex, {
|
|
71
|
+
alignItems: 'center',
|
|
72
|
+
justifyContent: 'center',
|
|
73
|
+
cursor: 'pointer',
|
|
74
|
+
userSelect: 'none',
|
|
75
|
+
margin: 4,
|
|
76
|
+
padding: '0px 4px'
|
|
77
|
+
});
|
|
78
|
+
const IconStateFull = props => {
|
|
79
|
+
const [isHover, setIsHover] = useState(false);
|
|
80
|
+
function handleHover() {
|
|
81
|
+
setIsHover(true);
|
|
82
|
+
}
|
|
83
|
+
function handleUnHover() {
|
|
84
|
+
setIsHover(false);
|
|
85
|
+
}
|
|
86
|
+
return props.type === 'next' ? jsx(ChevronRightOutline, Object.assign({}, props, {
|
|
87
|
+
color: isHover && !props.disabled ? colors.primary400 : colors.iconPrimary,
|
|
88
|
+
onMouseEnter: handleHover,
|
|
89
|
+
onMouseLeave: handleUnHover
|
|
90
|
+
})) : jsx(ChevronLeftOutline, Object.assign({}, props, {
|
|
91
|
+
color: isHover && !props.disabled ? colors.primary400 : colors.iconPrimary,
|
|
92
|
+
onMouseEnter: handleHover,
|
|
93
|
+
onMouseLeave: handleUnHover
|
|
94
|
+
}));
|
|
95
|
+
};
|
|
96
|
+
function ContainerDateRangePicker(props) {
|
|
97
|
+
const {
|
|
98
|
+
css,
|
|
99
|
+
children,
|
|
100
|
+
disabled,
|
|
101
|
+
readOnly,
|
|
102
|
+
onRangeChange,
|
|
103
|
+
isInvalid,
|
|
104
|
+
mobileOnly,
|
|
105
|
+
desktopOnly
|
|
106
|
+
} = props;
|
|
107
|
+
return jsxs(Container, {
|
|
108
|
+
css: css,
|
|
109
|
+
disabled: disabled,
|
|
110
|
+
readOnly: readOnly,
|
|
111
|
+
isInvalid: isInvalid,
|
|
112
|
+
mobileOnly: mobileOnly,
|
|
113
|
+
desktopOnly: desktopOnly,
|
|
114
|
+
children: [jsx(Button, {
|
|
115
|
+
css: {
|
|
116
|
+
borderRight: '1px solid $bgBorder'
|
|
117
|
+
},
|
|
118
|
+
onClick: () => onRangeChange('prev'),
|
|
119
|
+
children: jsx(IconStateFull, {
|
|
120
|
+
type: "prev",
|
|
121
|
+
disabled: disabled || readOnly || isInvalid
|
|
122
|
+
})
|
|
123
|
+
}), children, jsx(Button, {
|
|
124
|
+
css: {
|
|
125
|
+
borderLeft: '1px solid $bgBorder'
|
|
126
|
+
},
|
|
127
|
+
onClick: () => onRangeChange('next'),
|
|
128
|
+
children: jsx(IconStateFull, {
|
|
129
|
+
type: "next",
|
|
130
|
+
disabled: disabled || readOnly || isInvalid
|
|
131
|
+
})
|
|
132
|
+
})]
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function InputDateRangePicker(props) {
|
|
136
|
+
const {
|
|
137
|
+
value,
|
|
138
|
+
disabled,
|
|
139
|
+
readOnly,
|
|
140
|
+
onClick,
|
|
141
|
+
size,
|
|
142
|
+
isInvalid,
|
|
143
|
+
placeholder,
|
|
144
|
+
mobileOnly,
|
|
145
|
+
desktopOnly
|
|
146
|
+
} = props;
|
|
147
|
+
return jsxs(InputGroup, {
|
|
148
|
+
css: {
|
|
149
|
+
border: 'none',
|
|
150
|
+
'&:hover': {
|
|
151
|
+
border: 'none'
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
disabled: disabled,
|
|
155
|
+
readOnly: readOnly,
|
|
156
|
+
isInvalid: isInvalid,
|
|
157
|
+
onClick: onClick,
|
|
158
|
+
size: size,
|
|
159
|
+
mobileOnly: mobileOnly,
|
|
160
|
+
desktopOnly: desktopOnly,
|
|
161
|
+
children: [jsx(InputLeftElement, {
|
|
162
|
+
children: jsx(CalendarOutline, {})
|
|
163
|
+
}), jsx(InputText, {
|
|
164
|
+
placeholder: placeholder,
|
|
165
|
+
value: value,
|
|
166
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
167
|
+
onChange: () => {},
|
|
168
|
+
isPicker: true,
|
|
169
|
+
autoComplete: "false"
|
|
170
|
+
})]
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export { ContainerDateRangePicker, InputDateRangePicker };
|