@majoo-ui/react 2.3.0 → 2.4.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 +28 -15
- package/components/alertDialog/locale.esm.js +20 -0
- package/components/chart/lineChart/LineChart.esm.js +4 -0
- package/components/datePicker/DatePicker.esm.js +16 -6
- package/components/datePicker/DatePickerMulti.esm.js +5 -3
- package/components/datePicker/InputDatePicker.esm.js +14 -12
- package/components/datePicker/components/Calendar.esm.js +17 -23
- package/components/datePicker/components/CalendarMulti.esm.js +4 -7
- package/components/datePicker/components/CalendarTimePicker.esm.js +6 -9
- package/components/datePicker/components/MobileCalendar.esm.js +13 -17
- package/components/datePicker/locale.esm.js +92 -0
- package/components/devicePreview/DevicePreview.esm.js +4 -0
- package/components/form/components/InputCombobox/InputCombobox.esm.js +3 -0
- package/components/form/components/InputCreatable/InputCreatable.esm.js +16 -8
- package/components/form/components/InputCreatable/locale.esm.js +15 -0
- package/components/form/components/InputDateRange/InputDateRange.esm.js +15 -11
- package/components/form/components/InputDateRange/locale.esm.js +15 -0
- package/components/form/components/InputOTP/InputOTP.esm.js +9 -6
- package/components/form/components/InputOTP/locale.esm.js +15 -0
- package/components/form/components/InputResourceList/InputResourceList.esm.js +8 -11
- package/components/form/components/InputResourceList/locale.esm.js +27 -0
- package/components/form/components/InputSearchbox/InputSearchbox.esm.js +15 -6
- package/components/form/components/InputSearchbox/locale.esm.js +16 -0
- package/components/form/components/InputSelect/InputSelect.esm.js +13 -14
- package/components/form/components/InputSelect/locale.esm.js +23 -0
- package/components/form/components/InputSelectCheck/InputSelectCheck.esm.js +32 -23
- package/components/form/components/InputSelectCheck/locale.esm.js +30 -0
- package/components/form/components/InputSignature/InputSignature.esm.js +7 -8
- package/components/form/components/InputSignature/SignatureModal.esm.js +3 -3
- package/components/form/components/InputSignature/locale.esm.js +27 -0
- package/components/image/Image.esm.js +15 -9
- package/components/image/locale.esm.js +15 -0
- package/components/mapPicker/InputMapPicker.esm.js +5 -0
- package/components/pageDialog/PageDialog.esm.js +4 -0
- package/components/periodSelect/PeriodSelect.esm.js +11 -12
- package/components/periodSelect/locale.esm.js +25 -0
- package/components/tagList/TagList.esm.js +6 -7
- package/components/tagList/locale.esm.js +22 -0
- package/components/toast/context/ToastProvider.esm.js +13 -9
- package/components/toast/context/locale.esm.js +20 -0
- package/config/locale/LocaleContext.esm.js +29 -0
- package/config/locale/useLocaleText.esm.js +30 -0
- package/index.esm.js +12 -0
- package/majoo-provider/MajooProvider.esm.js +29 -5
- package/package.json +1 -1
- package/src/components/alertDialog/locale.d.ts +10 -0
- package/src/components/datePicker/DatePickerMulti.d.ts +2 -1
- package/src/components/datePicker/InputDatePicker.d.ts +13 -2
- package/src/components/datePicker/components/Calendar.d.ts +12 -1
- package/src/components/datePicker/components/CalendarMulti.d.ts +6 -1
- package/src/components/datePicker/components/CalendarTimePicker.d.ts +4 -1
- package/src/components/datePicker/components/MobileCalendar.d.ts +1 -1
- package/src/components/datePicker/index.d.ts +2 -0
- package/src/components/datePicker/locale.d.ts +45 -0
- package/src/components/form/components/InputCreatable/locale.d.ts +13 -0
- package/src/components/form/components/InputDateRange/InputDateRange.d.ts +16 -1
- package/src/components/form/components/InputDateRange/index.d.ts +2 -0
- package/src/components/form/components/InputDateRange/locale.d.ts +10 -0
- package/src/components/form/components/InputOTP/InputOTP.d.ts +7 -1
- package/src/components/form/components/InputOTP/index.d.ts +2 -0
- package/src/components/form/components/InputOTP/locale.d.ts +10 -0
- package/src/components/form/components/InputResourceList/InputResourceList.d.ts +8 -1
- package/src/components/form/components/InputResourceList/locale.d.ts +17 -0
- package/src/components/form/components/InputSearchbox/locale.d.ts +11 -0
- package/src/components/form/components/InputSelect/index.d.ts +2 -0
- package/src/components/form/components/InputSelect/locale.d.ts +15 -0
- package/src/components/form/components/InputSelectCheck/locale.d.ts +20 -0
- package/src/components/form/components/InputSignature/InputSignature.d.ts +7 -1
- package/src/components/form/components/InputSignature/SignatureModal.d.ts +2 -1
- package/src/components/form/components/InputSignature/index.d.ts +2 -0
- package/src/components/form/components/InputSignature/locale.d.ts +16 -0
- package/src/components/form/components/index.d.ts +4 -0
- package/src/components/image/index.d.ts +2 -0
- package/src/components/image/locale.d.ts +10 -0
- package/src/components/periodSelect/PeriodSelect.d.ts +14 -3
- package/src/components/periodSelect/index.d.ts +2 -0
- package/src/components/periodSelect/locale.d.ts +15 -0
- package/src/components/tagList/TagList.d.ts +8 -2
- package/src/components/tagList/index.d.ts +2 -0
- package/src/components/tagList/locale.d.ts +13 -0
- package/src/components/toast/context/locale.d.ts +11 -0
- package/src/config/locale/LocaleContext.d.ts +13 -0
- package/src/config/locale/LocaleTextContext.d.ts +28 -0
- package/src/config/locale/useLocaleText.d.ts +10 -0
|
@@ -9,7 +9,7 @@ import Paragraph from '../paragraph/Paragraph.esm.js';
|
|
|
9
9
|
import { Separator } from '../separator/Separator.esm.js';
|
|
10
10
|
import { styled, keyframes } from '../../config/stitches.config.esm.js';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
|
-
import {
|
|
12
|
+
import { useAlertDialogLocaleText } from './locale.esm.js';
|
|
13
13
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
14
14
|
|
|
15
15
|
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
@@ -105,9 +105,7 @@ function AlertDialogFunction(properties) {
|
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
107
|
const TemplateAlertFunction = props => {
|
|
108
|
-
const
|
|
109
|
-
t
|
|
110
|
-
} = useTranslation('translation');
|
|
108
|
+
const text = useAlertDialogLocaleText(props.localeText);
|
|
111
109
|
const [open, setOpen] = React__default.useState(true);
|
|
112
110
|
const ref = useCallback(node => {
|
|
113
111
|
const appElement = document.getElementById('app');
|
|
@@ -216,7 +214,7 @@ const TemplateAlertFunction = props => {
|
|
|
216
214
|
buttonType: props.dialogType,
|
|
217
215
|
disabled: props?.disabledButton,
|
|
218
216
|
...props?.actionButtonProps,
|
|
219
|
-
children: props.labelConfirm ? props.labelConfirm :
|
|
217
|
+
children: props.labelConfirm ? props.labelConfirm : text.confirmButton
|
|
220
218
|
})
|
|
221
219
|
}) : /*#__PURE__*/jsxs(Fragment, {
|
|
222
220
|
children: [/*#__PURE__*/jsx(ADialog.Cancel, {
|
|
@@ -231,7 +229,7 @@ const TemplateAlertFunction = props => {
|
|
|
231
229
|
buttonType: props.dialogType === 'negative' && !props?.disabledButton ? 'ghost-secondary' : 'ghost',
|
|
232
230
|
disabled: props?.disabledButton,
|
|
233
231
|
...props?.cancelButtonProps,
|
|
234
|
-
children: props.labelCancel ? props.labelCancel :
|
|
232
|
+
children: props.labelCancel ? props.labelCancel : text.cancelButton
|
|
235
233
|
})
|
|
236
234
|
}), !props?.hideActionButton && /*#__PURE__*/jsx(ADialog.Action, {
|
|
237
235
|
asChild: true,
|
|
@@ -244,7 +242,7 @@ const TemplateAlertFunction = props => {
|
|
|
244
242
|
},
|
|
245
243
|
disabled: props?.disabledButton,
|
|
246
244
|
...props?.actionButtonProps,
|
|
247
|
-
children: props.labelConfirm ? props.labelConfirm :
|
|
245
|
+
children: props.labelConfirm ? props.labelConfirm : text.confirmButton
|
|
248
246
|
})
|
|
249
247
|
})]
|
|
250
248
|
})
|
|
@@ -254,9 +252,7 @@ const TemplateAlertFunction = props => {
|
|
|
254
252
|
});
|
|
255
253
|
};
|
|
256
254
|
function AlertDialog(props) {
|
|
257
|
-
const
|
|
258
|
-
t
|
|
259
|
-
} = useTranslation('translation');
|
|
255
|
+
const text = useAlertDialogLocaleText(props.localeText);
|
|
260
256
|
const ref = useCallback(node => {
|
|
261
257
|
const appElement = document.getElementById('app');
|
|
262
258
|
if (appElement) {
|
|
@@ -351,7 +347,7 @@ function AlertDialog(props) {
|
|
|
351
347
|
},
|
|
352
348
|
disabled: props?.disabledButton,
|
|
353
349
|
...props?.actionButtonProps,
|
|
354
|
-
children: props.labelConfirm ? props.labelConfirm :
|
|
350
|
+
children: props.labelConfirm ? props.labelConfirm : text.confirmButton
|
|
355
351
|
})
|
|
356
352
|
}) : /*#__PURE__*/jsxs(Fragment, {
|
|
357
353
|
children: [/*#__PURE__*/jsx(ADialog.Cancel, {
|
|
@@ -366,7 +362,7 @@ function AlertDialog(props) {
|
|
|
366
362
|
buttonType: props.dialogType === 'negative' && !props?.disabledButton ? 'ghost-secondary' : 'ghost',
|
|
367
363
|
disabled: props?.disabledButton,
|
|
368
364
|
...props?.cancelButtonProps,
|
|
369
|
-
children: props.labelCancel ? props.labelCancel :
|
|
365
|
+
children: props.labelCancel ? props.labelCancel : text.cancelButton
|
|
370
366
|
})
|
|
371
367
|
}), !props?.hideActionButton && /*#__PURE__*/jsx(ADialog.Action, {
|
|
372
368
|
asChild: true,
|
|
@@ -379,7 +375,7 @@ function AlertDialog(props) {
|
|
|
379
375
|
},
|
|
380
376
|
disabled: props?.disabledButton,
|
|
381
377
|
...props?.actionButtonProps,
|
|
382
|
-
children: props.labelConfirm ? props.labelConfirm :
|
|
378
|
+
children: props.labelConfirm ? props.labelConfirm : text.confirmButton
|
|
383
379
|
})
|
|
384
380
|
})]
|
|
385
381
|
})
|
|
@@ -399,7 +395,15 @@ TemplateAlertFunction.propTypes = {
|
|
|
399
395
|
actionButtonProps: PropTypes.object,
|
|
400
396
|
cancelButtonProps: PropTypes.object,
|
|
401
397
|
hideCloseButton: PropTypes.bool,
|
|
402
|
-
hideActionButton: PropTypes.bool
|
|
398
|
+
hideActionButton: PropTypes.bool,
|
|
399
|
+
/**
|
|
400
|
+
* Texts of this dialog, `{ confirmButton, cancelButton }`. `labelConfirm` and `labelCancel` still win.
|
|
401
|
+
* `MajooProvider`'s `localeText` does not reach `AlertDialogFunction`, which renders outside the app.
|
|
402
|
+
*/
|
|
403
|
+
localeText: PropTypes.shape({
|
|
404
|
+
confirmButton: PropTypes.string,
|
|
405
|
+
cancelButton: PropTypes.string
|
|
406
|
+
})
|
|
403
407
|
};
|
|
404
408
|
TemplateAlertFunction.defaultProps = {
|
|
405
409
|
dialogType: 'primary',
|
|
@@ -419,7 +423,16 @@ AlertDialog.propTypes = {
|
|
|
419
423
|
disabledButton: PropTypes.bool,
|
|
420
424
|
actionButtonProps: PropTypes.object,
|
|
421
425
|
cancelButtonProps: PropTypes.object,
|
|
422
|
-
hideCloseButton: PropTypes.bool
|
|
426
|
+
hideCloseButton: PropTypes.bool,
|
|
427
|
+
/**
|
|
428
|
+
* Texts of this dialog, `{ confirmButton, cancelButton }`. Keys left unset fall back to
|
|
429
|
+
* `MajooProvider`'s `localeText.alertDialog`, then the Indonesian defaults. `labelConfirm` and
|
|
430
|
+
* `labelCancel` still win.
|
|
431
|
+
*/
|
|
432
|
+
localeText: PropTypes.shape({
|
|
433
|
+
confirmButton: PropTypes.string,
|
|
434
|
+
cancelButton: PropTypes.string
|
|
435
|
+
})
|
|
423
436
|
};
|
|
424
437
|
AlertDialog.defaultProps = {
|
|
425
438
|
dialogType: 'primary',
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useLocaleText } from '../../config/locale/useLocaleText.esm.js';
|
|
2
|
+
|
|
3
|
+
const defaultAlertDialogLocaleText = {
|
|
4
|
+
confirmButton: 'Ya, Lanjutkan',
|
|
5
|
+
cancelButton: 'Batal'
|
|
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
|
+
/**
|
|
15
|
+
* Resolves the alert dialog texts. Precedence: the dialog's own `localeText`, then `MajooProvider`'s
|
|
16
|
+
* `localeText.alertDialog`, then the app's `translation` keys, then the Indonesian defaults.
|
|
17
|
+
*/
|
|
18
|
+
const useAlertDialogLocaleText = localeText => useLocaleText('alertDialog', 'translation', i18nAlertDialogLocaleText, localeText);
|
|
19
|
+
|
|
20
|
+
export { defaultAlertDialogLocaleText, useAlertDialogLocaleText };
|
|
@@ -6,6 +6,10 @@ import { foundations } from '@majoo-ui/core';
|
|
|
6
6
|
import { useState, useEffect } from 'react';
|
|
7
7
|
import { ResponsiveContainer, LineChart as LineChart$1, XAxis, YAxis, CartesianGrid, Tooltip, Line } from 'recharts';
|
|
8
8
|
import { Image } from '../../image/Image.esm.js';
|
|
9
|
+
import 'core-js/modules/es.iterator.filter.js';
|
|
10
|
+
import 'core-js/modules/es.iterator.reduce.js';
|
|
11
|
+
import 'react-i18next';
|
|
12
|
+
import 'core-js/modules/es.array.includes.js';
|
|
9
13
|
import Text from '../../text/Text.esm.js';
|
|
10
14
|
import { styled } from '../../../config/stitches.config.esm.js';
|
|
11
15
|
import img from '../assets/data_kosong.png.esm.js';
|
|
@@ -29,9 +29,11 @@ const CalendarPicker = _a => {
|
|
|
29
29
|
showTimePicker,
|
|
30
30
|
timePickerProps,
|
|
31
31
|
minDate,
|
|
32
|
-
maxDate
|
|
32
|
+
maxDate,
|
|
33
|
+
locale,
|
|
34
|
+
localeText
|
|
33
35
|
} = _a,
|
|
34
|
-
props = __rest(_a, ["isMultiDatePicker", "onChange", "onClose", "advanceView", "selected", "disabled", "showTimePicker", "timePickerProps", "minDate", "maxDate"]);
|
|
36
|
+
props = __rest(_a, ["isMultiDatePicker", "onChange", "onClose", "advanceView", "selected", "disabled", "showTimePicker", "timePickerProps", "minDate", "maxDate", "locale", "localeText"]);
|
|
35
37
|
const [dateValue, setDateValue] = useState(selected);
|
|
36
38
|
const [calendarDate, setCalendarDate] = useState(selected !== null && selected !== void 0 ? selected : new Date());
|
|
37
39
|
const onDateSelected = selectedDate => {
|
|
@@ -83,7 +85,9 @@ const CalendarPicker = _a => {
|
|
|
83
85
|
showTimePicker: showTimePicker,
|
|
84
86
|
minDate: minDate,
|
|
85
87
|
maxDate: maxDate,
|
|
86
|
-
timePickerProps: timePickerProps
|
|
88
|
+
timePickerProps: timePickerProps,
|
|
89
|
+
locale: locale,
|
|
90
|
+
localeText: localeText
|
|
87
91
|
}, showTimePicker && {
|
|
88
92
|
onSetDateValue: setDateValue,
|
|
89
93
|
timePickerProps
|
|
@@ -105,9 +109,11 @@ const CalendarRangePicker = _a => {
|
|
|
105
109
|
allowReset,
|
|
106
110
|
showTimePicker,
|
|
107
111
|
maxRange,
|
|
108
|
-
timePickerProps
|
|
112
|
+
timePickerProps,
|
|
113
|
+
locale,
|
|
114
|
+
localeText
|
|
109
115
|
} = _a,
|
|
110
|
-
props = __rest(_a, ["isMultiDatePicker", "isRangeControl", "onChange", "onDateSelected", "onClose", "onReset", "advanceView", "selected", "disabled", "minDate", "maxDate", "allowReset", "showTimePicker", "maxRange", "timePickerProps"]);
|
|
116
|
+
props = __rest(_a, ["isMultiDatePicker", "isRangeControl", "onChange", "onDateSelected", "onClose", "onReset", "advanceView", "selected", "disabled", "minDate", "maxDate", "allowReset", "showTimePicker", "maxRange", "timePickerProps", "locale", "localeText"]);
|
|
111
117
|
const today = new Date();
|
|
112
118
|
const prevMonth = new Date(today.getFullYear(), today.getMonth() - 1, 1, 0);
|
|
113
119
|
const nowMonth = new Date(today.getFullYear(), today.getMonth(), 1, 0);
|
|
@@ -207,7 +213,9 @@ const CalendarRangePicker = _a => {
|
|
|
207
213
|
allowReset: allowReset,
|
|
208
214
|
onReset: isMultiDatePicker ? resetHandler : undefined,
|
|
209
215
|
maxRange: maxRange,
|
|
210
|
-
overMaxRange: overMaxRange
|
|
216
|
+
overMaxRange: overMaxRange,
|
|
217
|
+
locale: locale,
|
|
218
|
+
localeText: localeText
|
|
211
219
|
}, dayzedData)) : jsx(Calendar, Object.assign({
|
|
212
220
|
onUpdate: isMultiDatePicker ? updateHandler : undefined,
|
|
213
221
|
onCancel: onClose,
|
|
@@ -224,6 +232,8 @@ const CalendarRangePicker = _a => {
|
|
|
224
232
|
maxRange: maxRange,
|
|
225
233
|
overMaxRange: overMaxRange,
|
|
226
234
|
timePickerProps: timePickerProps,
|
|
235
|
+
locale: locale,
|
|
236
|
+
localeText: localeText,
|
|
227
237
|
onSetDateValue: setDateValue
|
|
228
238
|
}, dayzedData));
|
|
229
239
|
};
|
|
@@ -19,9 +19,10 @@ const DatePickerMulti = _a => {
|
|
|
19
19
|
disabled,
|
|
20
20
|
minDate,
|
|
21
21
|
maxDate,
|
|
22
|
-
disabledDate
|
|
22
|
+
disabledDate,
|
|
23
|
+
locale
|
|
23
24
|
} = _a,
|
|
24
|
-
props = __rest(_a, ["onChange", "onClose", "selected", "disabled", "minDate", "maxDate", "disabledDate"]);
|
|
25
|
+
props = __rest(_a, ["onChange", "onClose", "selected", "disabled", "minDate", "maxDate", "disabledDate", "locale"]);
|
|
25
26
|
const today = new Date();
|
|
26
27
|
const nowMonth = new Date(today.getFullYear(), today.getMonth(), 1, 0);
|
|
27
28
|
let initMonth = nowMonth;
|
|
@@ -63,7 +64,8 @@ const DatePickerMulti = _a => {
|
|
|
63
64
|
onCalendarDateChange: setCalendarDate,
|
|
64
65
|
minDate: minDate,
|
|
65
66
|
maxDate: maxDate,
|
|
66
|
-
disabledDate: disabledDate
|
|
67
|
+
disabledDate: disabledDate,
|
|
68
|
+
locale: locale
|
|
67
69
|
}, dayzedData));
|
|
68
70
|
};
|
|
69
71
|
|
|
@@ -9,11 +9,12 @@ import { InputLeftElement } from '../form/components/InputElement/InputElement.e
|
|
|
9
9
|
import { InputText } from '../form/components/InputText/InputText.esm.js';
|
|
10
10
|
import { AdvancedOption } from './AdvancedOption.esm.js';
|
|
11
11
|
import { SINGLE_PICKER, WEEKLY, DatePicker, DATE_RANGE_PICKER, ADVANCE_PICKER } from './DatePicker.esm.js';
|
|
12
|
-
import { pickerReducer, UPDATE_PICKER, advancePickerDate, advancePickerOptionsId
|
|
12
|
+
import { pickerReducer, UPDATE_PICKER, advancePickerDate, advancePickerOptionsId } from './state/reducer.esm.js';
|
|
13
13
|
import moment from 'moment';
|
|
14
14
|
import { ContainerDateRangePicker, InputDateRangePicker } from './InputDateRangePicker.esm.js';
|
|
15
15
|
import { ConditionalWrapper } from '../../wrapper/ConditionalWrapper.esm.js';
|
|
16
|
-
import {
|
|
16
|
+
import { useLocale } from '../../config/locale/LocaleContext.esm.js';
|
|
17
|
+
import { useDatePickerLocaleText, localizeAdvanceOptions } from './locale.esm.js';
|
|
17
18
|
import { Popover, PopoverTrigger, PopoverContent } from '../popover/Popover.esm.js';
|
|
18
19
|
|
|
19
20
|
const getInputPickerValue = (type, date, isTimePicker) => {
|
|
@@ -55,15 +56,14 @@ function InputDatePicker({
|
|
|
55
56
|
drawerCss,
|
|
56
57
|
drawerContentCss = {},
|
|
57
58
|
isMobile = false,
|
|
58
|
-
maxRange
|
|
59
|
+
maxRange,
|
|
60
|
+
locale,
|
|
61
|
+
localeText
|
|
59
62
|
}) {
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
i18n
|
|
63
|
-
} = useTranslation('MajooUI/datePicker');
|
|
63
|
+
const language = useLocale(locale);
|
|
64
|
+
const text = useDatePickerLocaleText(language, localeText);
|
|
64
65
|
const [value, setValue] = useState(date || dateValue);
|
|
65
66
|
const [defaultValue, setDefaultValue] = useState(defaultDate || defaultDateValue);
|
|
66
|
-
const language = i18n.language;
|
|
67
67
|
useEffect(() => {
|
|
68
68
|
setValue(date || dateValue);
|
|
69
69
|
}, [date, dateValue]);
|
|
@@ -123,7 +123,7 @@ function InputDatePicker({
|
|
|
123
123
|
color: "currentColor"
|
|
124
124
|
})
|
|
125
125
|
}), jsx(InputText, {
|
|
126
|
-
placeholder: placeholder ||
|
|
126
|
+
placeholder: placeholder || text.placeholder,
|
|
127
127
|
value: getInputPickerValue(type, selectedDate, showTimePicker),
|
|
128
128
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
129
129
|
onChange: () => {},
|
|
@@ -134,7 +134,7 @@ function InputDatePicker({
|
|
|
134
134
|
} else {
|
|
135
135
|
return jsx(InputDateRangePicker, {
|
|
136
136
|
value: getInputPickerValue(ADVANCE_PICKER, selectedDate, false),
|
|
137
|
-
placeholder: placeholder ||
|
|
137
|
+
placeholder: placeholder || text.placeholder,
|
|
138
138
|
disabled: disabled,
|
|
139
139
|
readOnly: readOnly,
|
|
140
140
|
size: size,
|
|
@@ -171,7 +171,7 @@ function InputDatePicker({
|
|
|
171
171
|
};
|
|
172
172
|
return jsx(DatePicker, {
|
|
173
173
|
advanceView: type === ADVANCE_PICKER && (!advanceView ? jsx(AdvancedOption, {
|
|
174
|
-
options:
|
|
174
|
+
options: localizeAdvanceOptions(advancePickerOptionsId, text),
|
|
175
175
|
disabled: disabled,
|
|
176
176
|
optionHandler: value => {
|
|
177
177
|
const reducedResult = advancePickerDate(value, undefined);
|
|
@@ -203,7 +203,9 @@ function InputDatePicker({
|
|
|
203
203
|
minDate: minDate,
|
|
204
204
|
maxDate: maxDate,
|
|
205
205
|
allowReset: allowReset,
|
|
206
|
-
maxRange: maxRange
|
|
206
|
+
maxRange: maxRange,
|
|
207
|
+
locale: language,
|
|
208
|
+
localeText: localeText
|
|
207
209
|
});
|
|
208
210
|
};
|
|
209
211
|
return !isMobile && !isMobileView ? jsxs(Popover, {
|
|
@@ -15,8 +15,9 @@ import Flex from '../../../layout/flex/Flex.esm.js';
|
|
|
15
15
|
import { Grid } from '../../../layout/grid/Grid.esm.js';
|
|
16
16
|
import { getCalendarStartYearRange, getCalendarStartYear, weekdayNamesShortEng, weekdayNamesShortId, monthNamesFullEng, monthNamesFullId, yearRangesList, toDateFormat } from '../../../utils/calendar.esm.js';
|
|
17
17
|
import DateNumber from './DateNumber.esm.js';
|
|
18
|
-
import { useTranslation } from 'react-i18next';
|
|
19
18
|
import CalendarTimePicker from './CalendarTimePicker.esm.js';
|
|
19
|
+
import { useLocale } from '../../../config/locale/LocaleContext.esm.js';
|
|
20
|
+
import { useDatePickerLocaleText } from '../locale.esm.js';
|
|
20
21
|
|
|
21
22
|
const getVariant = ({
|
|
22
23
|
selectable,
|
|
@@ -219,12 +220,12 @@ const Calendar = ({
|
|
|
219
220
|
onSetDateValue,
|
|
220
221
|
maxRange = 0,
|
|
221
222
|
overMaxRange = false,
|
|
222
|
-
timePickerProps
|
|
223
|
+
timePickerProps,
|
|
224
|
+
locale,
|
|
225
|
+
localeText
|
|
223
226
|
}) => {
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
i18n
|
|
227
|
-
} = useTranslation(['MajooUI/datePicker', 'translation']);
|
|
227
|
+
const language = useLocale(locale);
|
|
228
|
+
const text = useDatePickerLocaleText(language, localeText);
|
|
228
229
|
const [pickerState, setPickerState] = useState({
|
|
229
230
|
type: DATE_PICKER,
|
|
230
231
|
selectedMonth: Number(calendars[0].month),
|
|
@@ -232,7 +233,6 @@ const Calendar = ({
|
|
|
232
233
|
selectedYearRange: getCalendarStartYear(calendars[0].year),
|
|
233
234
|
selectedYearRangeStart: getCalendarStartYearRange(calendars[0].year)
|
|
234
235
|
});
|
|
235
|
-
const language = i18n.language;
|
|
236
236
|
const monthNamesFull = language === 'en' ? monthNamesFullEng : monthNamesFullId;
|
|
237
237
|
const weekdayNamesShort = language === 'en' ? weekdayNamesShortEng : weekdayNamesShortId;
|
|
238
238
|
useEffect(() => {
|
|
@@ -505,9 +505,9 @@ const Calendar = ({
|
|
|
505
505
|
lineHeight: '$short-content-regular',
|
|
506
506
|
fontSize: '$short-content-regular'
|
|
507
507
|
},
|
|
508
|
-
children: overMaxRange ?
|
|
508
|
+
children: overMaxRange ? text.maxRangeExceeded({
|
|
509
509
|
maxRange
|
|
510
|
-
}) : selected && selected.length > 1 && !disabled ? `${toDateFormat(selected[0], language)} - ${toDateFormat(selected[1], language)}` : !selected || selected.length <= 0 ?
|
|
510
|
+
}) : selected && selected.length > 1 && !disabled ? `${toDateFormat(selected[0], language)} - ${toDateFormat(selected[1], language)}` : !selected || selected.length <= 0 ? text.emptySelection : toDateFormat(selected[0], language)
|
|
511
511
|
}), jsxs(Flex, {
|
|
512
512
|
gap: 3,
|
|
513
513
|
children: [allowReset ? jsx(Button, {
|
|
@@ -519,7 +519,7 @@ const Calendar = ({
|
|
|
519
519
|
disabled: disabled || !selected || selected.length <= 1,
|
|
520
520
|
size: "sm",
|
|
521
521
|
type: "button",
|
|
522
|
-
children:
|
|
522
|
+
children: text.resetButton
|
|
523
523
|
}) : jsx(Button, {
|
|
524
524
|
buttonType: "ghost",
|
|
525
525
|
css: {
|
|
@@ -529,9 +529,7 @@ const Calendar = ({
|
|
|
529
529
|
disabled: disabled,
|
|
530
530
|
size: "sm",
|
|
531
531
|
type: "button",
|
|
532
|
-
children:
|
|
533
|
-
ns: 'translation'
|
|
534
|
-
})
|
|
532
|
+
children: text.cancelButton
|
|
535
533
|
}), jsx(Button, {
|
|
536
534
|
css: {
|
|
537
535
|
fontWeight: 600
|
|
@@ -540,9 +538,7 @@ const Calendar = ({
|
|
|
540
538
|
disabled: disabled || !selected || selected.length <= 1 || overMaxRange || isDisableSaveMinDate,
|
|
541
539
|
size: "sm",
|
|
542
540
|
type: "button",
|
|
543
|
-
children:
|
|
544
|
-
ns: 'translation'
|
|
545
|
-
})
|
|
541
|
+
children: text.processButton
|
|
546
542
|
})]
|
|
547
543
|
})]
|
|
548
544
|
})]
|
|
@@ -558,6 +554,7 @@ const Calendar = ({
|
|
|
558
554
|
language,
|
|
559
555
|
onSetDateValue,
|
|
560
556
|
timePickerProps,
|
|
557
|
+
text,
|
|
561
558
|
isSingle: !multiDatePicker
|
|
562
559
|
})]
|
|
563
560
|
});
|
|
@@ -588,9 +585,7 @@ const Calendar = ({
|
|
|
588
585
|
disabled: disabled,
|
|
589
586
|
size: "sm",
|
|
590
587
|
type: "button",
|
|
591
|
-
children:
|
|
592
|
-
ns: 'translation'
|
|
593
|
-
})
|
|
588
|
+
children: text.cancelButton
|
|
594
589
|
}), jsx(Button, {
|
|
595
590
|
css: {
|
|
596
591
|
fontWeight: 600
|
|
@@ -599,9 +594,7 @@ const Calendar = ({
|
|
|
599
594
|
disabled: disabled || !(selected && selected.length) || isDisableSaveMinDate,
|
|
600
595
|
size: "sm",
|
|
601
596
|
type: "button",
|
|
602
|
-
children:
|
|
603
|
-
ns: 'translation'
|
|
604
|
-
})
|
|
597
|
+
children: text.saveButton
|
|
605
598
|
})]
|
|
606
599
|
})
|
|
607
600
|
})]
|
|
@@ -642,7 +635,8 @@ const Calendar = ({
|
|
|
642
635
|
disabled,
|
|
643
636
|
language,
|
|
644
637
|
onSetDateValue,
|
|
645
|
-
timePickerProps
|
|
638
|
+
timePickerProps,
|
|
639
|
+
text
|
|
646
640
|
})]
|
|
647
641
|
})]
|
|
648
642
|
}), !multiDatePicker && showTimePicker && renderFooterSingleTimePicker(), multiDatePicker && renderFooter()]
|
|
@@ -14,7 +14,7 @@ import Flex from '../../../layout/flex/Flex.esm.js';
|
|
|
14
14
|
import { Grid } from '../../../layout/grid/Grid.esm.js';
|
|
15
15
|
import { getCalendarStartYearRange, getCalendarStartYear, monthNamesFullEng, monthNamesFullId, yearRangesList, weekdayNamesShortEng, weekdayNamesShortId } from '../../../utils/calendar.esm.js';
|
|
16
16
|
import DateNumber from './DateNumber.esm.js';
|
|
17
|
-
import {
|
|
17
|
+
import { useLocale } from '../../../config/locale/LocaleContext.esm.js';
|
|
18
18
|
|
|
19
19
|
const getVariant = ({
|
|
20
20
|
selectable,
|
|
@@ -147,12 +147,10 @@ const CalendarMulti = ({
|
|
|
147
147
|
disabled,
|
|
148
148
|
minDate,
|
|
149
149
|
maxDate,
|
|
150
|
-
disabledDate
|
|
150
|
+
disabledDate,
|
|
151
|
+
locale
|
|
151
152
|
}) => {
|
|
152
|
-
const
|
|
153
|
-
t,
|
|
154
|
-
i18n
|
|
155
|
-
} = useTranslation(['MajooUI/datePicker', 'translation']);
|
|
153
|
+
const language = useLocale(locale);
|
|
156
154
|
const [pickerState, setPickerState] = useState({
|
|
157
155
|
type: DATE_PICKER,
|
|
158
156
|
selectedMonth: Number(calendars[0].month),
|
|
@@ -160,7 +158,6 @@ const CalendarMulti = ({
|
|
|
160
158
|
selectedYearRange: getCalendarStartYear(calendars[0].year),
|
|
161
159
|
selectedYearRangeStart: getCalendarStartYearRange(calendars[0].year)
|
|
162
160
|
});
|
|
163
|
-
const language = i18n.language;
|
|
164
161
|
const monthNamesFull = language === 'en' ? monthNamesFullEng : monthNamesFullId;
|
|
165
162
|
const weekdayNamesShort = language === 'en' ? weekdayNamesShortEng : weekdayNamesShortId;
|
|
166
163
|
useEffect(() => {
|
|
@@ -6,7 +6,6 @@ import Text from '../../text/Text.esm.js';
|
|
|
6
6
|
import { InputTimePicker } from '../timePicker/InputTimePicker.esm.js';
|
|
7
7
|
import { Separator } from '../../separator/Separator.esm.js';
|
|
8
8
|
import { toDateFormat } from '../../../utils/calendar.esm.js';
|
|
9
|
-
import { useTranslation } from 'react-i18next';
|
|
10
9
|
|
|
11
10
|
const CalendarTimePicker = ({
|
|
12
11
|
selected,
|
|
@@ -14,11 +13,9 @@ const CalendarTimePicker = ({
|
|
|
14
13
|
language,
|
|
15
14
|
onSetDateValue,
|
|
16
15
|
isSingle,
|
|
17
|
-
timePickerProps
|
|
16
|
+
timePickerProps,
|
|
17
|
+
text
|
|
18
18
|
}) => {
|
|
19
|
-
const {
|
|
20
|
-
t
|
|
21
|
-
} = useTranslation('MajooUI/datePicker');
|
|
22
19
|
let startTime = moment('00:00', 'HH:mm').toDate();
|
|
23
20
|
let endTime = moment('00:00', 'HH:mm').toDate();
|
|
24
21
|
if (isSingle && selected && selected.length) {
|
|
@@ -42,7 +39,7 @@ const CalendarTimePicker = ({
|
|
|
42
39
|
children: [jsx(Text, {
|
|
43
40
|
variant: "label",
|
|
44
41
|
color: "primary",
|
|
45
|
-
children: isSingle ?
|
|
42
|
+
children: isSingle ? text.dateLabel : text.dateFromLabel
|
|
46
43
|
}), jsx(Text, {
|
|
47
44
|
variant: "label",
|
|
48
45
|
color: "disable",
|
|
@@ -54,7 +51,7 @@ const CalendarTimePicker = ({
|
|
|
54
51
|
children: [jsx(Text, {
|
|
55
52
|
variant: "label",
|
|
56
53
|
color: "primary",
|
|
57
|
-
children: isSingle ?
|
|
54
|
+
children: isSingle ? text.timeLabel : text.timeFromLabel
|
|
58
55
|
}), jsx(InputTimePicker, Object.assign({
|
|
59
56
|
onChange: val => {
|
|
60
57
|
if (isSingle && selected && selected.length && !!onSetDateValue) onSetDateValue(val.toDate());else if (selected && selected.length > 1 && !!onSetDateValue) onSetDateValue([val.toDate(), selected[1]]);
|
|
@@ -72,7 +69,7 @@ const CalendarTimePicker = ({
|
|
|
72
69
|
children: [jsx(Text, {
|
|
73
70
|
variant: "label",
|
|
74
71
|
color: "primary",
|
|
75
|
-
children:
|
|
72
|
+
children: text.dateUntilLabel
|
|
76
73
|
}), jsx(Text, {
|
|
77
74
|
variant: "label",
|
|
78
75
|
color: "disable",
|
|
@@ -84,7 +81,7 @@ const CalendarTimePicker = ({
|
|
|
84
81
|
children: [jsx(Text, {
|
|
85
82
|
variant: "label",
|
|
86
83
|
color: "primary",
|
|
87
|
-
children:
|
|
84
|
+
children: text.timeUntilLabel
|
|
88
85
|
}), jsx(InputTimePicker, {
|
|
89
86
|
onChange: val => {
|
|
90
87
|
const endDate = moment(endTime).format('YYYY-MM-DD');
|
|
@@ -16,7 +16,8 @@ import { Separator } from '../../separator/Separator.esm.js';
|
|
|
16
16
|
import Text from '../../text/Text.esm.js';
|
|
17
17
|
import { DATE_PICKER, MONTH_PICKER, YEAR_PICKER, YEAR_RANGE_PICKER } from './Calendar.esm.js';
|
|
18
18
|
import DateNumber from './DateNumber.esm.js';
|
|
19
|
-
import {
|
|
19
|
+
import { useLocale } from '../../../config/locale/LocaleContext.esm.js';
|
|
20
|
+
import { useDatePickerLocaleText } from '../locale.esm.js';
|
|
20
21
|
|
|
21
22
|
const getVariant = ({
|
|
22
23
|
selectable,
|
|
@@ -205,12 +206,12 @@ const MobileCalendar = ({
|
|
|
205
206
|
maxDate,
|
|
206
207
|
allowReset,
|
|
207
208
|
maxRange = 0,
|
|
208
|
-
overMaxRange = false
|
|
209
|
+
overMaxRange = false,
|
|
210
|
+
locale,
|
|
211
|
+
localeText
|
|
209
212
|
}) => {
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
i18n
|
|
213
|
-
} = useTranslation(['MajooUI/datePicker', 'translation']);
|
|
213
|
+
const language = useLocale(locale);
|
|
214
|
+
const text = useDatePickerLocaleText(language, localeText);
|
|
214
215
|
const [pickerState, setPickerState] = useState({
|
|
215
216
|
type: DATE_PICKER,
|
|
216
217
|
selectedMonth: Number(calendars[0].month),
|
|
@@ -218,7 +219,6 @@ const MobileCalendar = ({
|
|
|
218
219
|
selectedYearRange: getCalendarStartYear(calendars[0].year),
|
|
219
220
|
selectedYearRangeStart: getCalendarStartYearRange(calendars[0].year)
|
|
220
221
|
});
|
|
221
|
-
const language = i18n.language;
|
|
222
222
|
const monthNamesFull = language === 'en' ? monthNamesFullEng : monthNamesFullId;
|
|
223
223
|
const weekdayNamesShort = language === 'en' ? weekdayNamesShortEng : weekdayNamesShortId;
|
|
224
224
|
const [expandAdvanceView, setExpandAdvanceView] = useState(false);
|
|
@@ -447,7 +447,7 @@ const MobileCalendar = ({
|
|
|
447
447
|
css: {
|
|
448
448
|
color: '$textPrimary'
|
|
449
449
|
},
|
|
450
|
-
children:
|
|
450
|
+
children: text.selectRangeToggle
|
|
451
451
|
}), expandAdvanceView ? jsx(ChevronDownOutline, {}) : jsx(ChevronUpOutline, {})]
|
|
452
452
|
}), expandAdvanceView && advanceView, jsx(Separator, {
|
|
453
453
|
css: {
|
|
@@ -460,9 +460,9 @@ const MobileCalendar = ({
|
|
|
460
460
|
},
|
|
461
461
|
variant: "status",
|
|
462
462
|
color: overMaxRange ? 'red' : selected && selected.length > 1 ? 'primary' : 'disable',
|
|
463
|
-
children: overMaxRange ?
|
|
463
|
+
children: overMaxRange ? text.maxRangeExceeded({
|
|
464
464
|
maxRange
|
|
465
|
-
}) : selected && selected.length > 1 && !disabled ? `${toDateFormat(selected[0], language)} - ${toDateFormat(selected[1], language)}` :
|
|
465
|
+
}) : selected && selected.length > 1 && !disabled ? `${toDateFormat(selected[0], language)} - ${toDateFormat(selected[1], language)}` : text.emptySelection
|
|
466
466
|
}), jsxs(Flex, {
|
|
467
467
|
gap: 3,
|
|
468
468
|
children: [allowReset ? jsx(Button, {
|
|
@@ -472,7 +472,7 @@ const MobileCalendar = ({
|
|
|
472
472
|
disabled: disabled || !selected || selected.length <= 1,
|
|
473
473
|
type: "button",
|
|
474
474
|
block: true,
|
|
475
|
-
children:
|
|
475
|
+
children: text.resetButton
|
|
476
476
|
}) : jsx(Button, {
|
|
477
477
|
buttonType: "ghost",
|
|
478
478
|
size: "md",
|
|
@@ -480,18 +480,14 @@ const MobileCalendar = ({
|
|
|
480
480
|
disabled: disabled,
|
|
481
481
|
type: "button",
|
|
482
482
|
block: true,
|
|
483
|
-
children:
|
|
484
|
-
ns: 'translation'
|
|
485
|
-
})
|
|
483
|
+
children: text.cancelButton
|
|
486
484
|
}), jsx(Button, {
|
|
487
485
|
size: "md",
|
|
488
486
|
onClick: onUpdate,
|
|
489
487
|
disabled: disabled || !selected || selected.length <= 1 || overMaxRange,
|
|
490
488
|
type: "button",
|
|
491
489
|
block: true,
|
|
492
|
-
children:
|
|
493
|
-
ns: 'translation'
|
|
494
|
-
})
|
|
490
|
+
children: text.processButton
|
|
495
491
|
})]
|
|
496
492
|
})]
|
|
497
493
|
});
|