@majoo-ui/react 2.4.10 → 3.0.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/components/alertDialog/AlertDialog.esm.js +45 -3
- package/components/alertDialog/locale.esm.js +2 -9
- package/components/avatar/Avatar.esm.js +14 -1
- package/components/banner/Banner.esm.js +47 -8
- package/components/buttonGroup/ButtonGroup.esm.js +39 -2
- package/components/datePicker/CustomDatePicker.esm.js +28 -14
- package/components/datePicker/InputDatePicker.esm.js +1 -3
- package/components/datePicker/locale.esm.js +8 -47
- package/components/drawer/Drawer.esm.js +26 -2
- package/components/dropdownMenu/DropdownMenu.esm.js +25 -2
- package/components/form/components/FormGroup/FormGroup.esm.js +12 -1
- package/components/form/components/FormHelper/Helper.esm.js +10 -1
- package/components/form/components/FormLabel/Label.esm.js +15 -1
- package/components/form/components/InputCheckbox/CheckboxGroup.esm.js +11 -1
- package/components/form/components/InputCounter/InputCounter.esm.js +4 -1
- package/components/form/components/InputCreatable/InputCreatable.esm.js +17 -1
- package/components/form/components/InputCreatable/locale.esm.js +2 -8
- package/components/form/components/InputDateRange/locale.esm.js +2 -5
- package/components/form/components/InputGroup/InputGroup.esm.js +13 -1
- package/components/form/components/InputOTP/locale.esm.js +2 -5
- package/components/form/components/InputRadio/InputRadio.esm.js +20 -2
- package/components/form/components/InputRadio/InputRadioGroup.esm.js +15 -1
- package/components/form/components/InputResourceList/locale.esm.js +2 -14
- package/components/form/components/InputSearchbox/locale.esm.js +2 -6
- package/components/form/components/InputSelect/locale.esm.js +2 -11
- package/components/form/components/InputSelectCheck/InputSelectCheck.esm.js +58 -3
- package/components/form/components/InputSelectCheck/locale.esm.js +5 -14
- package/components/form/components/InputSelectTag/InputSelectTag.esm.js +6 -1
- package/components/form/components/InputSignature/locale.esm.js +2 -13
- package/components/form/components/InputSwitch/InputSwitch.esm.js +15 -1
- package/components/form/components/InputSwitch/InputSwitchWithImage.esm.js +19 -1
- package/components/form/components/InputTags/InputTags.esm.js +24 -1
- package/components/form/components/InputTextArea/InputTextArea.esm.js +16 -1
- package/components/image/locale.esm.js +2 -5
- package/components/notificationBadge/NotificationBadge.esm.js +14 -1
- package/components/pagination/Pagination.esm.js +26 -1
- package/components/paper/Paper.esm.js +14 -1
- package/components/periodSelect/locale.esm.js +2 -12
- package/components/popover/Popover.esm.js +41 -4
- package/components/progress/Progress.esm.js +16 -1
- package/components/slider/Slider.esm.js +24 -1
- package/components/table/Table.esm.js +4 -13
- package/components/table/components/columns/DateColumn.esm.js +2 -1
- package/components/table/locale.esm.js +4 -47
- package/components/tableOfContent/TableOfContent.esm.js +4 -0
- package/components/tabs/Tabs.esm.js +45 -4
- package/components/tagList/locale.esm.js +2 -10
- package/components/tagStatus/TagStatus.esm.js +14 -1
- package/components/toast/context/ToastProvider.esm.js +9 -1
- package/components/toast/context/locale.esm.js +2 -9
- package/components/upload/Upload.esm.js +50 -1
- package/config/locale/LocaleContext.esm.js +2 -8
- package/config/locale/useLocaleText.esm.js +4 -12
- package/index.esm.css +4 -4
- package/layout/grid/Grid.esm.js +29 -3
- package/layout/pageContainer/PageContainer.esm.js +12 -1
- package/majoo-provider/MajooProvider.esm.js +43 -13
- package/package.json +2 -4
- package/src/components/alertDialog/locale.d.ts +1 -1
- package/src/components/datePicker/CustomDatePicker.d.ts +12 -1
- package/src/components/datePicker/InputDatePicker.d.ts +10 -10
- package/src/components/datePicker/components/CalendarMulti.d.ts +1 -2
- package/src/components/datePicker/locale.d.ts +1 -2
- package/src/components/editableTable/EditableTable.d.ts +1 -0
- package/src/components/form/components/InputCounter/InputCounter.d.ts +1 -1
- package/src/components/form/components/InputCreatable/locale.d.ts +1 -2
- package/src/components/form/components/InputDateRange/InputDateRange.d.ts +2 -2
- package/src/components/form/components/InputDateRange/locale.d.ts +1 -1
- package/src/components/form/components/InputOTP/locale.d.ts +1 -1
- package/src/components/form/components/InputResourceList/locale.d.ts +1 -2
- package/src/components/form/components/InputSearchbox/locale.d.ts +1 -2
- package/src/components/form/components/InputSelect/locale.d.ts +1 -2
- package/src/components/form/components/InputSelectCheck/locale.d.ts +1 -2
- package/src/components/form/components/InputSignature/locale.d.ts +1 -2
- package/src/components/image/locale.d.ts +1 -1
- package/src/components/periodSelect/PeriodSelect.d.ts +1 -2
- package/src/components/periodSelect/locale.d.ts +1 -2
- package/src/components/table/locale.d.ts +2 -4
- package/src/components/tagList/locale.d.ts +1 -1
- package/src/components/toast/context/locale.d.ts +1 -1
- package/src/config/locale/LocaleContext.d.ts +1 -1
- package/src/config/locale/useLocaleText.d.ts +3 -3
|
@@ -80,7 +80,14 @@ const StyledDescription = styled('div', {
|
|
|
80
80
|
const Flex = styled('div', {
|
|
81
81
|
display: 'flex'
|
|
82
82
|
});
|
|
83
|
-
const Content =
|
|
83
|
+
const Content =
|
|
84
|
+
/*#__PURE__*/
|
|
85
|
+
/**
|
|
86
|
+
* @type {React.ForwardRefExoticComponent<
|
|
87
|
+
* { children?: React.ReactNode, [key: string]: any } & React.RefAttributes<HTMLDivElement>
|
|
88
|
+
* >}
|
|
89
|
+
*/
|
|
90
|
+
forwardRef(({
|
|
84
91
|
children,
|
|
85
92
|
...props
|
|
86
93
|
}, ref) => /*#__PURE__*/jsxs(ADialog.Portal, {
|
|
@@ -251,7 +258,35 @@ const TemplateAlertFunction = props => {
|
|
|
251
258
|
})
|
|
252
259
|
});
|
|
253
260
|
};
|
|
254
|
-
function AlertDialog(
|
|
261
|
+
function AlertDialog(
|
|
262
|
+
/**
|
|
263
|
+
* @type {{
|
|
264
|
+
* title: import('react').ReactNode,
|
|
265
|
+
* description: import('react').ReactNode,
|
|
266
|
+
* open?: boolean,
|
|
267
|
+
* defaultOpen?: boolean,
|
|
268
|
+
* onOpenChange?: (open: boolean) => void,
|
|
269
|
+
* onOpenAutoFocus?: (event: Event) => void,
|
|
270
|
+
* id?: string,
|
|
271
|
+
* css?: object,
|
|
272
|
+
* isMobile?: boolean,
|
|
273
|
+
* btnSize?: string,
|
|
274
|
+
* dialogType?: string,
|
|
275
|
+
* onCancel?: Function,
|
|
276
|
+
* onConfirm?: Function,
|
|
277
|
+
* onClose?: Function,
|
|
278
|
+
* disabledButton?: boolean,
|
|
279
|
+
* actionButtonProps?: object,
|
|
280
|
+
* cancelButtonProps?: object,
|
|
281
|
+
* hideCloseButton?: boolean,
|
|
282
|
+
* hideActionButton?: boolean,
|
|
283
|
+
* singleButton?: boolean,
|
|
284
|
+
* labelConfirm?: import('react').ReactNode,
|
|
285
|
+
* labelCancel?: import('react').ReactNode,
|
|
286
|
+
* localeText?: { confirmButton?: string, cancelButton?: string },
|
|
287
|
+
* }}
|
|
288
|
+
*/
|
|
289
|
+
props) {
|
|
255
290
|
const text = useAlertDialogLocaleText(props.localeText);
|
|
256
291
|
const ref = useCallback(node => {
|
|
257
292
|
const appElement = document.getElementById('app');
|
|
@@ -446,7 +481,14 @@ const AlertDialogRoot = ADialog.Root;
|
|
|
446
481
|
const AlertDialogTrigger = ADialog.Trigger;
|
|
447
482
|
const AlertDialogContent = Content;
|
|
448
483
|
const AlertDialogTitle = StyledTitle;
|
|
449
|
-
const AlertDialogDescription =
|
|
484
|
+
const AlertDialogDescription =
|
|
485
|
+
/*#__PURE__*/
|
|
486
|
+
/**
|
|
487
|
+
* @type {React.ForwardRefExoticComponent<
|
|
488
|
+
* { children?: React.ReactNode, [key: string]: any } & React.RefAttributes<HTMLDivElement>
|
|
489
|
+
* >}
|
|
490
|
+
*/
|
|
491
|
+
forwardRef(({
|
|
450
492
|
children,
|
|
451
493
|
...props
|
|
452
494
|
}, ref) => /*#__PURE__*/jsx(ADialog.Description, {
|
|
@@ -4,17 +4,10 @@ const defaultAlertDialogLocaleText = {
|
|
|
4
4
|
confirmButton: 'Ya, Lanjutkan',
|
|
5
5
|
cancelButton: 'Batal'
|
|
6
6
|
};
|
|
7
|
-
const i18nAlertDialogLocaleText = t => {
|
|
8
|
-
const d = defaultAlertDialogLocaleText;
|
|
9
|
-
return {
|
|
10
|
-
confirmButton: t('label.continue', d.confirmButton),
|
|
11
|
-
cancelButton: t('label.cancel', d.cancelButton)
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
7
|
/**
|
|
15
8
|
* Resolves the alert dialog texts. Precedence: the dialog's own `localeText`, then `MajooProvider`'s
|
|
16
|
-
* `localeText.alertDialog`, then the
|
|
9
|
+
* `localeText.alertDialog`, then the Indonesian defaults.
|
|
17
10
|
*/
|
|
18
|
-
const useAlertDialogLocaleText = localeText => useLocaleText('alertDialog',
|
|
11
|
+
const useAlertDialogLocaleText = localeText => useLocaleText('alertDialog', defaultAlertDialogLocaleText, localeText);
|
|
19
12
|
|
|
20
13
|
export { defaultAlertDialogLocaleText, useAlertDialogLocaleText };
|
|
@@ -38,7 +38,20 @@ const StyledFallback = styled(AvatarPrimitive.Fallback, {
|
|
|
38
38
|
const StyledIcon = styled('div', {
|
|
39
39
|
fontSize: '20px'
|
|
40
40
|
});
|
|
41
|
-
function Avatar(
|
|
41
|
+
function Avatar(
|
|
42
|
+
/**
|
|
43
|
+
* @type {{
|
|
44
|
+
* className?: string,
|
|
45
|
+
* img?: string,
|
|
46
|
+
* children?: import('react').ReactNode,
|
|
47
|
+
* onLoadingStatusChange?: (status: 'idle' | 'loading' | 'loaded' | 'error') => void,
|
|
48
|
+
* delayMs?: number,
|
|
49
|
+
* onClick?: import('react').MouseEventHandler<HTMLSpanElement>,
|
|
50
|
+
* css?: object,
|
|
51
|
+
* [key: string]: any,
|
|
52
|
+
* }}
|
|
53
|
+
*/
|
|
54
|
+
{
|
|
42
55
|
className,
|
|
43
56
|
img,
|
|
44
57
|
children,
|
|
@@ -104,7 +104,15 @@ const CloseButton = styled(Flex, {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
});
|
|
107
|
-
const BannerTitle =
|
|
107
|
+
const BannerTitle = (
|
|
108
|
+
/**
|
|
109
|
+
* @type {{
|
|
110
|
+
* children?: import('react').ReactNode,
|
|
111
|
+
* css?: object,
|
|
112
|
+
* [key: string]: any,
|
|
113
|
+
* }}
|
|
114
|
+
*/
|
|
115
|
+
props) => /*#__PURE__*/jsx(Title, {
|
|
108
116
|
heading: "sectionTitle",
|
|
109
117
|
...props,
|
|
110
118
|
children: props.children
|
|
@@ -117,9 +125,17 @@ BannerTitle.propTypes = {
|
|
|
117
125
|
/**
|
|
118
126
|
Title of the Banner to be displayed
|
|
119
127
|
*/
|
|
120
|
-
children: PropTypes.
|
|
128
|
+
children: PropTypes.node
|
|
121
129
|
};
|
|
122
|
-
const BannerDescription =
|
|
130
|
+
const BannerDescription = (
|
|
131
|
+
/**
|
|
132
|
+
* @type {{
|
|
133
|
+
* children?: import('react').ReactNode,
|
|
134
|
+
* css?: object,
|
|
135
|
+
* [key: string]: any,
|
|
136
|
+
* }}
|
|
137
|
+
*/
|
|
138
|
+
props) => /*#__PURE__*/jsx(Description, {
|
|
123
139
|
paragraph: "longContentRegular",
|
|
124
140
|
color: "secondary",
|
|
125
141
|
...props,
|
|
@@ -133,7 +149,7 @@ BannerDescription.propTypes = {
|
|
|
133
149
|
/**
|
|
134
150
|
Description of the Banner to be displayed
|
|
135
151
|
*/
|
|
136
|
-
children: PropTypes.
|
|
152
|
+
children: PropTypes.node
|
|
137
153
|
};
|
|
138
154
|
const BannerLink = ({
|
|
139
155
|
css,
|
|
@@ -166,6 +182,10 @@ const BannerLink = ({
|
|
|
166
182
|
});
|
|
167
183
|
};
|
|
168
184
|
BannerLink.propTypes = {
|
|
185
|
+
/**
|
|
186
|
+
Additional styles of the link
|
|
187
|
+
*/
|
|
188
|
+
css: PropTypes.object,
|
|
169
189
|
/**
|
|
170
190
|
The purpose of a clickable link, presented in url
|
|
171
191
|
*/
|
|
@@ -177,7 +197,7 @@ BannerLink.propTypes = {
|
|
|
177
197
|
/**
|
|
178
198
|
Additional theme of BannerLink is presented by color variants
|
|
179
199
|
*/
|
|
180
|
-
variant: PropTypes.oneOf(['info', 'warning', 'success', 'failed'])
|
|
200
|
+
variant: PropTypes.oneOf(['info', 'warning', 'success', 'failed', 'pending'])
|
|
181
201
|
};
|
|
182
202
|
BannerLink.defaultProps = {
|
|
183
203
|
children: 'Learn more'
|
|
@@ -244,7 +264,26 @@ const SingleTagBanner = props => {
|
|
|
244
264
|
})]
|
|
245
265
|
});
|
|
246
266
|
};
|
|
247
|
-
const Banner = (
|
|
267
|
+
const Banner = (
|
|
268
|
+
/**
|
|
269
|
+
* @type {{
|
|
270
|
+
* children?: import('react').ReactNode,
|
|
271
|
+
* title?: string,
|
|
272
|
+
* description?: import('react').ReactNode,
|
|
273
|
+
* variant?: 'info' | 'warning' | 'success' | 'failed' | 'pending',
|
|
274
|
+
* link?: string,
|
|
275
|
+
* linkText?: string,
|
|
276
|
+
* icon?: () => import('react').ReactNode,
|
|
277
|
+
* onClick?: import('react').MouseEventHandler<HTMLDivElement>,
|
|
278
|
+
* onRemove?: () => void,
|
|
279
|
+
* bannerBlock?: boolean,
|
|
280
|
+
* mobileOnly?: boolean,
|
|
281
|
+
* desktopOnly?: boolean,
|
|
282
|
+
* css?: object,
|
|
283
|
+
* [key: string]: any,
|
|
284
|
+
* }}
|
|
285
|
+
*/
|
|
286
|
+
{
|
|
248
287
|
title,
|
|
249
288
|
description,
|
|
250
289
|
variant,
|
|
@@ -304,11 +343,11 @@ Banner.propTypes = {
|
|
|
304
343
|
/**
|
|
305
344
|
Description of banner to be displayed
|
|
306
345
|
*/
|
|
307
|
-
description: PropTypes.
|
|
346
|
+
description: PropTypes.node,
|
|
308
347
|
/**
|
|
309
348
|
The banner theme is presented in color variants
|
|
310
349
|
*/
|
|
311
|
-
variant: PropTypes.oneOf(['info', 'warning', 'success', 'failed']),
|
|
350
|
+
variant: PropTypes.oneOf(['info', 'warning', 'success', 'failed', 'pending']),
|
|
312
351
|
/**
|
|
313
352
|
The purpose of a clickable link, presented in url
|
|
314
353
|
*/
|
|
@@ -193,7 +193,30 @@ const StyledIconRight = styled('div', {
|
|
|
193
193
|
display: 'inline-block',
|
|
194
194
|
verticalAlign: 'middle'
|
|
195
195
|
});
|
|
196
|
-
function ButtonGroup(
|
|
196
|
+
function ButtonGroup(
|
|
197
|
+
/**
|
|
198
|
+
* @type {{
|
|
199
|
+
* className?: string,
|
|
200
|
+
* children?: import('react').ReactNode,
|
|
201
|
+
* type?: 'single' | 'multiple',
|
|
202
|
+
* value?: string | string[],
|
|
203
|
+
* defaultValue?: string | string[],
|
|
204
|
+
* onValueChange?: (value: any) => void,
|
|
205
|
+
* disabled?: boolean,
|
|
206
|
+
* rovingFocus?: boolean,
|
|
207
|
+
* orientation?: 'horizontal' | 'vertical',
|
|
208
|
+
* dir?: 'ltr' | 'rtl',
|
|
209
|
+
* loop?: boolean,
|
|
210
|
+
* size?: 'xs' | 'sm' | 'md' | 'lg' | 'full',
|
|
211
|
+
* withMaxWidth?: boolean,
|
|
212
|
+
* mobileOnly?: boolean,
|
|
213
|
+
* desktopOnly?: boolean,
|
|
214
|
+
* segmented?: boolean,
|
|
215
|
+
* css?: object,
|
|
216
|
+
* [key: string]: any,
|
|
217
|
+
* }}
|
|
218
|
+
*/
|
|
219
|
+
{
|
|
197
220
|
className,
|
|
198
221
|
children,
|
|
199
222
|
type,
|
|
@@ -310,7 +333,21 @@ ButtonGroup.defaultProps = {
|
|
|
310
333
|
// spacing: 3,
|
|
311
334
|
// segmented: true,
|
|
312
335
|
};
|
|
313
|
-
function ButtonGroupItem(
|
|
336
|
+
function ButtonGroupItem(
|
|
337
|
+
/**
|
|
338
|
+
* @type {{
|
|
339
|
+
* value: string,
|
|
340
|
+
* className?: string,
|
|
341
|
+
* children?: import('react').ReactNode,
|
|
342
|
+
* leftIcon?: import('react').ReactElement,
|
|
343
|
+
* rightIcon?: import('react').ReactElement,
|
|
344
|
+
* disabled?: boolean,
|
|
345
|
+
* isToggle?: boolean,
|
|
346
|
+
* css?: object,
|
|
347
|
+
* [key: string]: any,
|
|
348
|
+
* }}
|
|
349
|
+
*/
|
|
350
|
+
{
|
|
314
351
|
className,
|
|
315
352
|
children,
|
|
316
353
|
leftIcon,
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useState, useEffect, useReducer } from 'react';
|
|
4
|
+
import moment from 'moment';
|
|
4
5
|
import useMediaQuery from '../../utils/useMediaQuery.esm.js';
|
|
5
6
|
import { Drawer, DrawerContent, DrawerTitle } from '../drawer/Drawer.esm.js';
|
|
6
7
|
import { AdvancedOption } from './AdvancedOption.esm.js';
|
|
7
8
|
import { SINGLE_PICKER, DatePicker, ADVANCE_PICKER } from './DatePicker.esm.js';
|
|
8
|
-
import { pickerReducer, UPDATE_PICKER,
|
|
9
|
+
import { pickerReducer, UPDATE_PICKER, advancePickerDate, advancePickerOptionsId } from './state/reducer.esm.js';
|
|
10
|
+
import { useLocale } from '../../config/locale/LocaleContext.esm.js';
|
|
11
|
+
import { useDatePickerLocaleText, localizeAdvanceOptions } from './locale.esm.js';
|
|
9
12
|
import { Popover, PopoverTrigger, PopoverContent } from '../popover/Popover.esm.js';
|
|
10
13
|
|
|
11
14
|
function CustomDatePicker({
|
|
@@ -23,8 +26,12 @@ function CustomDatePicker({
|
|
|
23
26
|
minDate,
|
|
24
27
|
maxDate,
|
|
25
28
|
allowReset,
|
|
26
|
-
sideOffset = 8
|
|
29
|
+
sideOffset = 8,
|
|
30
|
+
locale,
|
|
31
|
+
localeText
|
|
27
32
|
}) {
|
|
33
|
+
const language = useLocale(locale);
|
|
34
|
+
const text = useDatePickerLocaleText(language, localeText);
|
|
28
35
|
const [value, setValue] = useState(date || dateValue);
|
|
29
36
|
const [defaultValue, setDefaultValue] = useState(defaultDate || defaultDateValue);
|
|
30
37
|
useEffect(() => {
|
|
@@ -47,7 +54,7 @@ function CustomDatePicker({
|
|
|
47
54
|
});
|
|
48
55
|
}
|
|
49
56
|
}, [value]);
|
|
50
|
-
const isMobile = useMediaQuery(`(max-width: ${type === SINGLE_PICKER ? '480px' : '
|
|
57
|
+
const isMobile = useMediaQuery(`(max-width: ${type === SINGLE_PICKER ? '480px' : '1090px'})`);
|
|
51
58
|
function handleOpenChange() {
|
|
52
59
|
if (!disabled) {
|
|
53
60
|
setOpenPicker(!openPicker);
|
|
@@ -63,19 +70,20 @@ function CustomDatePicker({
|
|
|
63
70
|
const renderDatePicker = () => {
|
|
64
71
|
return jsx(DatePicker, {
|
|
65
72
|
advanceView: type === ADVANCE_PICKER && (!advanceView ? jsx(AdvancedOption, {
|
|
66
|
-
options: advancePickerOptionsId,
|
|
73
|
+
options: localizeAdvanceOptions(advancePickerOptionsId, text),
|
|
67
74
|
disabled: disabled,
|
|
68
75
|
optionHandler: value => {
|
|
76
|
+
const reducedResult = advancePickerDate(value, undefined);
|
|
77
|
+
const dateAsString = moment(reducedResult[1]).format('YYYY-MM-DD');
|
|
78
|
+
const payload = [reducedResult[0], moment(`${dateAsString} 23:59`, 'YYYY-MM-DD HH:mm').toDate()];
|
|
69
79
|
dispatch({
|
|
70
80
|
type: 'UPDATE',
|
|
71
|
-
payload
|
|
81
|
+
payload
|
|
72
82
|
});
|
|
73
|
-
if (onChange) onChange(
|
|
83
|
+
if (onChange) onChange(payload);
|
|
74
84
|
setOpenPicker(false);
|
|
75
85
|
}
|
|
76
|
-
}) :
|
|
77
|
-
advanceView
|
|
78
|
-
}),
|
|
86
|
+
}) : advanceView),
|
|
79
87
|
type: type,
|
|
80
88
|
disabled: disabled,
|
|
81
89
|
date: value ? value === null || value === void 0 ? void 0 : value[1] : selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate[1],
|
|
@@ -86,7 +94,9 @@ function CustomDatePicker({
|
|
|
86
94
|
showTimePicker: showTimePicker,
|
|
87
95
|
minDate: minDate,
|
|
88
96
|
maxDate: maxDate,
|
|
89
|
-
allowReset: allowReset
|
|
97
|
+
allowReset: allowReset,
|
|
98
|
+
locale: language,
|
|
99
|
+
localeText: localeText
|
|
90
100
|
});
|
|
91
101
|
};
|
|
92
102
|
return !isMobile ? jsxs(Popover, {
|
|
@@ -101,9 +111,13 @@ function CustomDatePicker({
|
|
|
101
111
|
children: renderDatePicker()
|
|
102
112
|
})]
|
|
103
113
|
}) : jsxs(Fragment, {
|
|
104
|
-
children: [/*#__PURE__*/React.cloneElement(children,
|
|
105
|
-
onClick:
|
|
106
|
-
|
|
114
|
+
children: [/*#__PURE__*/React.cloneElement(children, {
|
|
115
|
+
onClick: event => {
|
|
116
|
+
var _a, _b;
|
|
117
|
+
(_b = (_a = children.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
|
118
|
+
handleOpenChange();
|
|
119
|
+
}
|
|
120
|
+
}), jsx(Drawer, {
|
|
107
121
|
open: openPicker,
|
|
108
122
|
onOpenChange: handleOpenChange,
|
|
109
123
|
side: "bottom",
|
|
@@ -120,7 +134,7 @@ function CustomDatePicker({
|
|
|
120
134
|
overflow: 'hidden',
|
|
121
135
|
clip: 'rect(0 0 0 0)'
|
|
122
136
|
},
|
|
123
|
-
children:
|
|
137
|
+
children: text.drawerTitle
|
|
124
138
|
}), renderDatePicker()]
|
|
125
139
|
})
|
|
126
140
|
})]
|
|
@@ -212,9 +212,7 @@ function InputDatePicker({
|
|
|
212
212
|
if (onChange) onChange(payload);
|
|
213
213
|
setOpenPicker(false);
|
|
214
214
|
}
|
|
215
|
-
}) :
|
|
216
|
-
advanceView
|
|
217
|
-
}),
|
|
215
|
+
}) : advanceView),
|
|
218
216
|
type: showRangeControl ? DATE_RANGE_PICKER : type,
|
|
219
217
|
disabled: disabled,
|
|
220
218
|
date: value ? value === null || value === void 0 ? void 0 : value[1] : selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate[1],
|
|
@@ -3,7 +3,6 @@ import 'core-js/modules/es.iterator.filter.js';
|
|
|
3
3
|
import 'core-js/modules/es.iterator.map.js';
|
|
4
4
|
import 'core-js/modules/es.iterator.reduce.js';
|
|
5
5
|
import { useContext, useMemo } from 'react';
|
|
6
|
-
import { useTranslation } from 'react-i18next';
|
|
7
6
|
import { LocaleTextContext } from '../../config/locale/LocaleTextContext.esm.js';
|
|
8
7
|
import { advancePickerOptionsId, advancePickerOptionsEn } from './state/reducer.esm.js';
|
|
9
8
|
|
|
@@ -37,8 +36,7 @@ const defaultDatePickerLocaleText = {
|
|
|
37
36
|
previousYearLabel: 'Tahun sebelumnya',
|
|
38
37
|
nextYearLabel: 'Tahun berikutnya'
|
|
39
38
|
};
|
|
40
|
-
//
|
|
41
|
-
// them yet; English gets its own defaults the same way the quick range labels do.
|
|
39
|
+
// English defaults of the month range texts, alongside the English quick range labels.
|
|
42
40
|
const monthRangeLocaleTextEn = {
|
|
43
41
|
applyButton: 'Apply',
|
|
44
42
|
monthRangeHelper: ({
|
|
@@ -47,44 +45,10 @@ const monthRangeLocaleTextEn = {
|
|
|
47
45
|
previousYearLabel: 'Previous year',
|
|
48
46
|
nextYearLabel: 'Next year'
|
|
49
47
|
};
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const d = defaultDatePickerLocaleText;
|
|
55
|
-
return Object.assign({
|
|
56
|
-
placeholder: t('datePickerPlaceholder', d.placeholder),
|
|
57
|
-
cancelButton: t('label.cancel', d.cancelButton, {
|
|
58
|
-
ns: 'translation'
|
|
59
|
-
}),
|
|
60
|
-
saveButton: t('label.save', d.saveButton, {
|
|
61
|
-
ns: 'translation'
|
|
62
|
-
}),
|
|
63
|
-
processButton: t('label.process', d.processButton, {
|
|
64
|
-
ns: 'translation'
|
|
65
|
-
}),
|
|
66
|
-
resetButton: d.resetButton,
|
|
67
|
-
emptySelection: t('notSelectedDateText', d.emptySelection),
|
|
68
|
-
maxRangeExceeded: ({
|
|
69
|
-
maxRange
|
|
70
|
-
}) => t('label.maxRangeDate', `Maksimal range adalah ${maxRange} hari`, {
|
|
71
|
-
maxRange
|
|
72
|
-
}),
|
|
73
|
-
selectRangeToggle: t('selectTimeRangeText', d.selectRangeToggle),
|
|
74
|
-
drawerTitle: t('label.selectDate', d.drawerTitle),
|
|
75
|
-
dateLabel: t('label.date', d.dateLabel),
|
|
76
|
-
timeLabel: t('time', d.timeLabel),
|
|
77
|
-
dateFromLabel: t('dateFromLabel', d.dateFromLabel),
|
|
78
|
-
dateUntilLabel: t('dateUntilLabel', d.dateUntilLabel),
|
|
79
|
-
timeFromLabel: t('timeFromLabel', d.timeFromLabel),
|
|
80
|
-
timeUntilLabel: t('timeUntilLabel', d.timeUntilLabel),
|
|
81
|
-
advanceOptions: locale === 'en' ? toLabels(advancePickerOptionsEn) : d.advanceOptions,
|
|
82
|
-
applyButton: d.applyButton,
|
|
83
|
-
monthRangeHelper: d.monthRangeHelper,
|
|
84
|
-
previousYearLabel: d.previousYearLabel,
|
|
85
|
-
nextYearLabel: d.nextYearLabel
|
|
86
|
-
}, locale === 'en' && monthRangeLocaleTextEn);
|
|
87
|
-
};
|
|
48
|
+
// `en` keeps the English quick range labels and month range texts the picker has always shown for it.
|
|
49
|
+
const datePickerDefaultsFor = locale => locale === 'en' ? Object.assign(Object.assign(Object.assign({}, defaultDatePickerLocaleText), {
|
|
50
|
+
advanceOptions: toLabels(advancePickerOptionsEn)
|
|
51
|
+
}), monthRangeLocaleTextEn) : defaultDatePickerLocaleText;
|
|
88
52
|
const definedEntries = obj => obj ? Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== undefined)) : {};
|
|
89
53
|
/** Later sources win; an `undefined` value never erases an earlier one. */
|
|
90
54
|
const mergeDatePickerLocaleText = (base, ...overrides) => overrides.reduce((merged, override) => Object.assign(Object.assign(Object.assign({}, merged), definedEntries(override)), {
|
|
@@ -92,16 +56,13 @@ const mergeDatePickerLocaleText = (base, ...overrides) => overrides.reduce((merg
|
|
|
92
56
|
}), base);
|
|
93
57
|
/**
|
|
94
58
|
* Resolves the date picker texts. Precedence: the component's own `localeText`, then `MajooProvider`'s
|
|
95
|
-
* `localeText.datePicker`, then the
|
|
59
|
+
* `localeText.datePicker`, then the defaults (Indonesian, except the quick range and month range texts for `en`).
|
|
96
60
|
*/
|
|
97
61
|
const useDatePickerLocaleText = (locale, localeText) => {
|
|
98
|
-
const {
|
|
99
|
-
t
|
|
100
|
-
} = useTranslation(['MajooUI/datePicker', 'translation']);
|
|
101
62
|
const {
|
|
102
63
|
datePicker: appLocaleText
|
|
103
64
|
} = useContext(LocaleTextContext);
|
|
104
|
-
return useMemo(() => mergeDatePickerLocaleText(
|
|
65
|
+
return useMemo(() => mergeDatePickerLocaleText(datePickerDefaultsFor(locale), appLocaleText, localeText), [locale, appLocaleText, localeText]);
|
|
105
66
|
};
|
|
106
67
|
/** The quick range options with their labels taken from the resolved texts. */
|
|
107
68
|
const localizeAdvanceOptions = (options, text) => options.map(option => {
|
|
@@ -111,4 +72,4 @@ const localizeAdvanceOptions = (options, text) => options.map(option => {
|
|
|
111
72
|
});
|
|
112
73
|
});
|
|
113
74
|
|
|
114
|
-
export { defaultDatePickerLocaleText,
|
|
75
|
+
export { defaultDatePickerLocaleText, localizeAdvanceOptions, mergeDatePickerLocaleText, useDatePickerLocaleText };
|
|
@@ -45,7 +45,24 @@ const StyledOverlay = styled(DialogPrimitive.Overlay, {
|
|
|
45
45
|
animation: `${fadeOut} 150ms cubic-bezier(0.22, 1, 0.36, 1)`
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
-
function Drawer(
|
|
48
|
+
function Drawer(
|
|
49
|
+
/**
|
|
50
|
+
* @type {{
|
|
51
|
+
* children?: import('react').ReactNode,
|
|
52
|
+
* defaultOpen?: boolean,
|
|
53
|
+
* open?: boolean,
|
|
54
|
+
* onOpenChange?: (open: boolean) => void,
|
|
55
|
+
* modal?: boolean,
|
|
56
|
+
* portalled?: boolean,
|
|
57
|
+
* side?: 'top' | 'left' | 'bottom' | 'right',
|
|
58
|
+
* size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full',
|
|
59
|
+
* css?: object,
|
|
60
|
+
* borderHeader?: boolean,
|
|
61
|
+
* borderFooter?: boolean,
|
|
62
|
+
* [key: string]: any,
|
|
63
|
+
* }}
|
|
64
|
+
*/
|
|
65
|
+
{
|
|
49
66
|
children,
|
|
50
67
|
...props
|
|
51
68
|
}) {
|
|
@@ -291,7 +308,14 @@ const DrawerFooter = props => {
|
|
|
291
308
|
const DrawerTrigger = DialogPrimitive.Trigger;
|
|
292
309
|
const DrawerClose = StyledClose;
|
|
293
310
|
const DrawerTitle = DialogPrimitive.Title;
|
|
294
|
-
const DrawerDescription =
|
|
311
|
+
const DrawerDescription =
|
|
312
|
+
/*#__PURE__*/
|
|
313
|
+
/**
|
|
314
|
+
* @type {React.ForwardRefExoticComponent<
|
|
315
|
+
* { children?: React.ReactNode, [key: string]: any } & React.RefAttributes<HTMLParagraphElement>
|
|
316
|
+
* >}
|
|
317
|
+
*/
|
|
318
|
+
React__default.forwardRef((props, ref) => {
|
|
295
319
|
const registerDescription = React__default.useContext(DescriptionContext);
|
|
296
320
|
React__default.useLayoutEffect(() => registerDescription?.(), [registerDescription]);
|
|
297
321
|
return /*#__PURE__*/jsx(DialogPrimitive.Description, {
|
|
@@ -232,7 +232,20 @@ const StyledItemIndicator = styled(DropdownMenuPrimitive.ItemIndicator, {
|
|
|
232
232
|
const StyledArrow = styled(DropdownMenuPrimitive.Arrow, {
|
|
233
233
|
fill: 'white'
|
|
234
234
|
});
|
|
235
|
-
const DropdownMenuContext = (
|
|
235
|
+
const DropdownMenuContext = (
|
|
236
|
+
/**
|
|
237
|
+
* @type {{
|
|
238
|
+
* children?: import('react').ReactNode,
|
|
239
|
+
* side?: 'top' | 'right' | 'bottom' | 'left',
|
|
240
|
+
* align?: 'start' | 'center' | 'end',
|
|
241
|
+
* open?: boolean,
|
|
242
|
+
* defaultOpen?: boolean,
|
|
243
|
+
* onOpenChange?: (open: boolean) => void,
|
|
244
|
+
* modal?: boolean,
|
|
245
|
+
* [key: string]: any,
|
|
246
|
+
* }}
|
|
247
|
+
*/
|
|
248
|
+
{
|
|
236
249
|
side,
|
|
237
250
|
align,
|
|
238
251
|
children,
|
|
@@ -377,7 +390,17 @@ const StyledDropdown = styled(Button, {
|
|
|
377
390
|
}
|
|
378
391
|
}
|
|
379
392
|
});
|
|
380
|
-
const ButtonDropdown =
|
|
393
|
+
const ButtonDropdown =
|
|
394
|
+
/*#__PURE__*/
|
|
395
|
+
/**
|
|
396
|
+
* @type {React.ForwardRefExoticComponent<{
|
|
397
|
+
* children: React.ReactNode,
|
|
398
|
+
* css?: object,
|
|
399
|
+
* rightIcon?: React.ReactNode,
|
|
400
|
+
* [key: string]: any,
|
|
401
|
+
* } & React.RefAttributes<HTMLButtonElement>>}
|
|
402
|
+
*/
|
|
403
|
+
React__default.forwardRef((props, ref) => {
|
|
381
404
|
const {
|
|
382
405
|
...rest
|
|
383
406
|
} = props;
|
|
@@ -104,7 +104,18 @@ const StyledFormGroup = styled('div', {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
});
|
|
107
|
-
const FormGroup = (
|
|
107
|
+
const FormGroup = (
|
|
108
|
+
/**
|
|
109
|
+
* @type {{
|
|
110
|
+
* children?: import('react').ReactNode,
|
|
111
|
+
* count?: number,
|
|
112
|
+
* maxCount?: number,
|
|
113
|
+
* css?: object,
|
|
114
|
+
* responsive?: 'input' | 'button' | 'switch',
|
|
115
|
+
* [key: string]: any,
|
|
116
|
+
* }}
|
|
117
|
+
*/
|
|
118
|
+
{
|
|
108
119
|
count,
|
|
109
120
|
maxCount,
|
|
110
121
|
css,
|
|
@@ -15,7 +15,16 @@ const StyledHelper = styled(Text, {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
const FormHelper = (
|
|
18
|
+
const FormHelper = (
|
|
19
|
+
/**
|
|
20
|
+
* @type {{
|
|
21
|
+
* children?: import('react').ReactNode,
|
|
22
|
+
* error?: boolean,
|
|
23
|
+
* errorMessage?: import('react').ReactNode,
|
|
24
|
+
* [key: string]: any,
|
|
25
|
+
* }}
|
|
26
|
+
*/
|
|
27
|
+
{
|
|
19
28
|
children,
|
|
20
29
|
error,
|
|
21
30
|
errorMessage,
|
|
@@ -30,7 +30,21 @@ const StyledHelpIcon = styled(CircleQuestionOutline, {
|
|
|
30
30
|
size: '16px'
|
|
31
31
|
});
|
|
32
32
|
const LabelVariantsEnum = ['required', 'optional', 'with-tooltip'];
|
|
33
|
-
const FormLabel = (
|
|
33
|
+
const FormLabel = (
|
|
34
|
+
/**
|
|
35
|
+
* @type {{
|
|
36
|
+
* children?: import('react').ReactNode,
|
|
37
|
+
* htmlFor?: string,
|
|
38
|
+
* variant?: 'required' | 'optional' | 'with-tooltip',
|
|
39
|
+
* variants?: Array<'required' | 'optional' | 'with-tooltip'>,
|
|
40
|
+
* tooltipLabel?: import('react').ReactNode,
|
|
41
|
+
* count?: number,
|
|
42
|
+
* maxCount?: number,
|
|
43
|
+
* labelCss?: object,
|
|
44
|
+
* [key: string]: any,
|
|
45
|
+
* }}
|
|
46
|
+
*/
|
|
47
|
+
{
|
|
34
48
|
children,
|
|
35
49
|
htmlFor,
|
|
36
50
|
variant,
|
|
@@ -6,7 +6,17 @@ import React__default, { useState, createContext } from 'react';
|
|
|
6
6
|
import { jsx } from 'react/jsx-runtime';
|
|
7
7
|
|
|
8
8
|
const CheckboxContext = /*#__PURE__*/createContext();
|
|
9
|
-
const CheckboxGroup = (
|
|
9
|
+
const CheckboxGroup = (
|
|
10
|
+
/**
|
|
11
|
+
* @type {{
|
|
12
|
+
* children?: import('react').ReactNode,
|
|
13
|
+
* onChange: Function,
|
|
14
|
+
* value?: any[],
|
|
15
|
+
* defaultValue?: any[],
|
|
16
|
+
* disabled?: boolean,
|
|
17
|
+
* }}
|
|
18
|
+
*/
|
|
19
|
+
{
|
|
10
20
|
children,
|
|
11
21
|
onChange,
|
|
12
22
|
value,
|
|
@@ -6,7 +6,7 @@ import { styled, colors } from '../../../../config/stitches.config.esm.js';
|
|
|
6
6
|
import { MinusOutline, PlusOutline } from '@majoo-ui/icons';
|
|
7
7
|
import { InputNumber } from '../InputNumber/InputNumber.esm.js';
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const StyledInput = styled(InputNumber, {
|
|
10
10
|
border: `1px solid $gray150`,
|
|
11
11
|
borderLeft: 'none',
|
|
12
12
|
borderRight: 'none',
|
|
@@ -36,6 +36,9 @@ const Input = styled(InputNumber, {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
|
+
// styled() rebuilds the wrapped props with Omit, which flattens InputNumber's index-signature props type to
|
|
40
|
+
// { [key: string]: any }, so StyledInput alone would accept size="xl". Re-attach InputNumber's own props.
|
|
41
|
+
const Input = StyledInput;
|
|
39
42
|
const Button = styled(Button$1, {
|
|
40
43
|
border: `1px solid $gray150 !important`,
|
|
41
44
|
paddingRight: '16px !important',
|