@majoo-ui/react 2.3.0 → 2.4.2
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 +19 -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 +62 -29
- package/components/datePicker/components/MobileCalendar.esm.js +35 -18
- 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 +20 -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.css +4 -4
- package/index.esm.js +14 -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 +6 -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 +8 -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
|
@@ -16,7 +16,9 @@ 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 CalendarTimePicker from './CalendarTimePicker.esm.js';
|
|
20
|
+
import { useLocale } from '../../../config/locale/LocaleContext.esm.js';
|
|
21
|
+
import { useDatePickerLocaleText } from '../locale.esm.js';
|
|
20
22
|
|
|
21
23
|
const getVariant = ({
|
|
22
24
|
selectable,
|
|
@@ -110,7 +112,15 @@ const CalendarsContainer = styled(Box, {
|
|
|
110
112
|
});
|
|
111
113
|
const CalendarItemContainer = styled(Flex, {
|
|
112
114
|
height: '100%',
|
|
113
|
-
paddingBottom: '160px'
|
|
115
|
+
paddingBottom: '160px',
|
|
116
|
+
variants: {
|
|
117
|
+
// Keeps the last calendar row clear of the taller footer.
|
|
118
|
+
withTimePicker: {
|
|
119
|
+
true: {
|
|
120
|
+
paddingBottom: '244px'
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
114
124
|
});
|
|
115
125
|
const DateContainer = styled(Box, {
|
|
116
126
|
width: '100%',
|
|
@@ -205,12 +215,15 @@ const MobileCalendar = ({
|
|
|
205
215
|
maxDate,
|
|
206
216
|
allowReset,
|
|
207
217
|
maxRange = 0,
|
|
208
|
-
overMaxRange = false
|
|
218
|
+
overMaxRange = false,
|
|
219
|
+
showTimePicker,
|
|
220
|
+
timePickerProps,
|
|
221
|
+
onSetDateValue,
|
|
222
|
+
locale,
|
|
223
|
+
localeText
|
|
209
224
|
}) => {
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
i18n
|
|
213
|
-
} = useTranslation(['MajooUI/datePicker', 'translation']);
|
|
225
|
+
const language = useLocale(locale);
|
|
226
|
+
const text = useDatePickerLocaleText(language, localeText);
|
|
214
227
|
const [pickerState, setPickerState] = useState({
|
|
215
228
|
type: DATE_PICKER,
|
|
216
229
|
selectedMonth: Number(calendars[0].month),
|
|
@@ -218,7 +231,6 @@ const MobileCalendar = ({
|
|
|
218
231
|
selectedYearRange: getCalendarStartYear(calendars[0].year),
|
|
219
232
|
selectedYearRangeStart: getCalendarStartYearRange(calendars[0].year)
|
|
220
233
|
});
|
|
221
|
-
const language = i18n.language;
|
|
222
234
|
const monthNamesFull = language === 'en' ? monthNamesFullEng : monthNamesFullId;
|
|
223
235
|
const weekdayNamesShort = language === 'en' ? weekdayNamesShortEng : weekdayNamesShortId;
|
|
224
236
|
const [expandAdvanceView, setExpandAdvanceView] = useState(false);
|
|
@@ -447,7 +459,7 @@ const MobileCalendar = ({
|
|
|
447
459
|
css: {
|
|
448
460
|
color: '$textPrimary'
|
|
449
461
|
},
|
|
450
|
-
children:
|
|
462
|
+
children: text.selectRangeToggle
|
|
451
463
|
}), expandAdvanceView ? jsx(ChevronDownOutline, {}) : jsx(ChevronUpOutline, {})]
|
|
452
464
|
}), expandAdvanceView && advanceView, jsx(Separator, {
|
|
453
465
|
css: {
|
|
@@ -460,9 +472,17 @@ const MobileCalendar = ({
|
|
|
460
472
|
},
|
|
461
473
|
variant: "status",
|
|
462
474
|
color: overMaxRange ? 'red' : selected && selected.length > 1 ? 'primary' : 'disable',
|
|
463
|
-
children: overMaxRange ?
|
|
475
|
+
children: overMaxRange ? text.maxRangeExceeded({
|
|
464
476
|
maxRange
|
|
465
|
-
}) : selected && selected.length > 1 && !disabled ? `${toDateFormat(selected[0], language)} - ${toDateFormat(selected[1], language)}` :
|
|
477
|
+
}) : selected && selected.length > 1 && !disabled ? `${toDateFormat(selected[0], language)} - ${toDateFormat(selected[1], language)}` : text.emptySelection
|
|
478
|
+
}), showTimePicker && jsx(CalendarTimePicker, {
|
|
479
|
+
selected,
|
|
480
|
+
disabled,
|
|
481
|
+
language,
|
|
482
|
+
onSetDateValue,
|
|
483
|
+
timePickerProps,
|
|
484
|
+
text,
|
|
485
|
+
inline: true
|
|
466
486
|
}), jsxs(Flex, {
|
|
467
487
|
gap: 3,
|
|
468
488
|
children: [allowReset ? jsx(Button, {
|
|
@@ -472,7 +492,7 @@ const MobileCalendar = ({
|
|
|
472
492
|
disabled: disabled || !selected || selected.length <= 1,
|
|
473
493
|
type: "button",
|
|
474
494
|
block: true,
|
|
475
|
-
children:
|
|
495
|
+
children: text.resetButton
|
|
476
496
|
}) : jsx(Button, {
|
|
477
497
|
buttonType: "ghost",
|
|
478
498
|
size: "md",
|
|
@@ -480,18 +500,14 @@ const MobileCalendar = ({
|
|
|
480
500
|
disabled: disabled,
|
|
481
501
|
type: "button",
|
|
482
502
|
block: true,
|
|
483
|
-
children:
|
|
484
|
-
ns: 'translation'
|
|
485
|
-
})
|
|
503
|
+
children: text.cancelButton
|
|
486
504
|
}), jsx(Button, {
|
|
487
505
|
size: "md",
|
|
488
506
|
onClick: onUpdate,
|
|
489
507
|
disabled: disabled || !selected || selected.length <= 1 || overMaxRange,
|
|
490
508
|
type: "button",
|
|
491
509
|
block: true,
|
|
492
|
-
children:
|
|
493
|
-
ns: 'translation'
|
|
494
|
-
})
|
|
510
|
+
children: text.processButton
|
|
495
511
|
})]
|
|
496
512
|
})]
|
|
497
513
|
});
|
|
@@ -503,6 +519,7 @@ const MobileCalendar = ({
|
|
|
503
519
|
children: jsx(CalendarItemContainer, {
|
|
504
520
|
direction: "column",
|
|
505
521
|
gap: 5,
|
|
522
|
+
withTimePicker: multiDatePicker && !!showTimePicker,
|
|
506
523
|
children: calendars.map((calendar, index) => jsxs(DateContainer, {
|
|
507
524
|
children: [renderHeader(index), jsx(Separator, {
|
|
508
525
|
css: {
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import 'core-js/modules/es.iterator.constructor.js';
|
|
2
|
+
import 'core-js/modules/es.iterator.filter.js';
|
|
3
|
+
import 'core-js/modules/es.iterator.map.js';
|
|
4
|
+
import 'core-js/modules/es.iterator.reduce.js';
|
|
5
|
+
import { useContext, useMemo } from 'react';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
import { LocaleTextContext } from '../../config/locale/LocaleTextContext.esm.js';
|
|
8
|
+
import { advancePickerOptionsId, advancePickerOptionsEn } from './state/reducer.esm.js';
|
|
9
|
+
|
|
10
|
+
const toLabels = options => Object.fromEntries(options.map(({
|
|
11
|
+
label,
|
|
12
|
+
value
|
|
13
|
+
}) => [value, label]));
|
|
14
|
+
const defaultDatePickerLocaleText = {
|
|
15
|
+
placeholder: 'Pilih Tanggal',
|
|
16
|
+
cancelButton: 'Batal',
|
|
17
|
+
saveButton: 'Simpan',
|
|
18
|
+
processButton: 'Proses',
|
|
19
|
+
resetButton: 'Reset',
|
|
20
|
+
emptySelection: 'Tanggal belum dipilih',
|
|
21
|
+
maxRangeExceeded: ({
|
|
22
|
+
maxRange
|
|
23
|
+
}) => `Maksimal range adalah ${maxRange} hari`,
|
|
24
|
+
selectRangeToggle: 'Pilih Rentang Waktu',
|
|
25
|
+
dateLabel: 'Tanggal',
|
|
26
|
+
timeLabel: 'Waktu',
|
|
27
|
+
dateFromLabel: 'Dari Tanggal',
|
|
28
|
+
dateUntilLabel: 'Hingga Tanggal',
|
|
29
|
+
timeFromLabel: 'Dari Pukul',
|
|
30
|
+
timeUntilLabel: 'Hingga Pukul',
|
|
31
|
+
advanceOptions: toLabels(advancePickerOptionsId)
|
|
32
|
+
};
|
|
33
|
+
// Transitional: keeps apps that still ship `MajooUI/datePicker` locale files translated until they pass
|
|
34
|
+
// `localeText`, and keeps the English quick range labels for `en`. Remove together with the
|
|
35
|
+
// react-i18next dependency of the date picker family.
|
|
36
|
+
const i18nDatePickerLocaleText = (t, locale) => {
|
|
37
|
+
const d = defaultDatePickerLocaleText;
|
|
38
|
+
return {
|
|
39
|
+
placeholder: t('datePickerPlaceholder', d.placeholder),
|
|
40
|
+
cancelButton: t('label.cancel', d.cancelButton, {
|
|
41
|
+
ns: 'translation'
|
|
42
|
+
}),
|
|
43
|
+
saveButton: t('label.save', d.saveButton, {
|
|
44
|
+
ns: 'translation'
|
|
45
|
+
}),
|
|
46
|
+
processButton: t('label.process', d.processButton, {
|
|
47
|
+
ns: 'translation'
|
|
48
|
+
}),
|
|
49
|
+
resetButton: d.resetButton,
|
|
50
|
+
emptySelection: t('notSelectedDateText', d.emptySelection),
|
|
51
|
+
maxRangeExceeded: ({
|
|
52
|
+
maxRange
|
|
53
|
+
}) => t('label.maxRangeDate', `Maksimal range adalah ${maxRange} hari`, {
|
|
54
|
+
maxRange
|
|
55
|
+
}),
|
|
56
|
+
selectRangeToggle: t('selectTimeRangeText', d.selectRangeToggle),
|
|
57
|
+
dateLabel: t('label.date', d.dateLabel),
|
|
58
|
+
timeLabel: t('time', d.timeLabel),
|
|
59
|
+
dateFromLabel: t('dateFromLabel', d.dateFromLabel),
|
|
60
|
+
dateUntilLabel: t('dateUntilLabel', d.dateUntilLabel),
|
|
61
|
+
timeFromLabel: t('timeFromLabel', d.timeFromLabel),
|
|
62
|
+
timeUntilLabel: t('timeUntilLabel', d.timeUntilLabel),
|
|
63
|
+
advanceOptions: locale === 'en' ? toLabels(advancePickerOptionsEn) : d.advanceOptions
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
const definedEntries = obj => obj ? Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== undefined)) : {};
|
|
67
|
+
/** Later sources win; an `undefined` value never erases an earlier one. */
|
|
68
|
+
const mergeDatePickerLocaleText = (base, ...overrides) => overrides.reduce((merged, override) => Object.assign(Object.assign(Object.assign({}, merged), definedEntries(override)), {
|
|
69
|
+
advanceOptions: Object.assign(Object.assign({}, merged.advanceOptions), definedEntries(override === null || override === void 0 ? void 0 : override.advanceOptions))
|
|
70
|
+
}), base);
|
|
71
|
+
/**
|
|
72
|
+
* Resolves the date picker texts. Precedence: the component's own `localeText`, then `MajooProvider`'s
|
|
73
|
+
* `localeText.datePicker`, then the app's `MajooUI/datePicker` translations, then the Indonesian defaults.
|
|
74
|
+
*/
|
|
75
|
+
const useDatePickerLocaleText = (locale, localeText) => {
|
|
76
|
+
const {
|
|
77
|
+
t
|
|
78
|
+
} = useTranslation(['MajooUI/datePicker', 'translation']);
|
|
79
|
+
const {
|
|
80
|
+
datePicker: appLocaleText
|
|
81
|
+
} = useContext(LocaleTextContext);
|
|
82
|
+
return useMemo(() => mergeDatePickerLocaleText(i18nDatePickerLocaleText(t, locale), appLocaleText, localeText), [t, locale, appLocaleText, localeText]);
|
|
83
|
+
};
|
|
84
|
+
/** The quick range options with their labels taken from the resolved texts. */
|
|
85
|
+
const localizeAdvanceOptions = (options, text) => options.map(option => {
|
|
86
|
+
var _a;
|
|
87
|
+
return Object.assign(Object.assign({}, option), {
|
|
88
|
+
label: (_a = text.advanceOptions[option.value]) !== null && _a !== void 0 ? _a : option.label
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
export { defaultDatePickerLocaleText, i18nDatePickerLocaleText, localizeAdvanceOptions, mergeDatePickerLocaleText, useDatePickerLocaleText };
|
|
@@ -9,6 +9,10 @@ import { styled, css, colors, getCssText, theme } from '../../config/stitches.co
|
|
|
9
9
|
import Box from '../../layout/box/Box.esm.js';
|
|
10
10
|
import Flex from '../../layout/flex/Flex.esm.js';
|
|
11
11
|
import { Image } from '../image/Image.esm.js';
|
|
12
|
+
import 'core-js/modules/es.iterator.filter.js';
|
|
13
|
+
import 'core-js/modules/es.iterator.reduce.js';
|
|
14
|
+
import 'react-i18next';
|
|
15
|
+
import 'core-js/modules/es.array.includes.js';
|
|
12
16
|
import Paragraph from '../paragraph/Paragraph.esm.js';
|
|
13
17
|
import Text from '../text/Text.esm.js';
|
|
14
18
|
import img$3 from './deviceFrame/android-transparant.png.esm.js';
|
|
@@ -7,6 +7,9 @@ import { useState, useRef, useLayoutEffect, createElement } from 'react';
|
|
|
7
7
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
8
8
|
import { useCombobox } from 'downshift';
|
|
9
9
|
import { SelectContainer, SelectBox, OptionWrapper, SelectOption, SelectItem, Input } from '../InputSelect/InputSelect.esm.js';
|
|
10
|
+
import 'core-js/modules/es.iterator.reduce.js';
|
|
11
|
+
import 'react-i18next';
|
|
12
|
+
import 'core-js/modules/es.array.includes.js';
|
|
10
13
|
import { Portal } from '@majoo-ui/helpers';
|
|
11
14
|
import { InputGroup } from '../InputGroup/InputGroup.esm.js';
|
|
12
15
|
import { InputLeftElement, InputRightElement } from '../InputElement/InputElement.esm.js';
|
|
@@ -2,7 +2,7 @@ import React__default from 'react';
|
|
|
2
2
|
import { CirclePlusOutline } from '@majoo-ui/icons';
|
|
3
3
|
import { colors, styled } from '../../../../config/stitches.config.esm.js';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
-
import {
|
|
5
|
+
import { useInputCreatableLocaleText } from './locale.esm.js';
|
|
6
6
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
7
7
|
|
|
8
8
|
const Wrapper = styled('div', {
|
|
@@ -152,11 +152,10 @@ function InputCreatable({
|
|
|
152
152
|
disabled,
|
|
153
153
|
readOnly,
|
|
154
154
|
maxChar,
|
|
155
|
-
onClickItem
|
|
155
|
+
onClickItem,
|
|
156
|
+
localeText
|
|
156
157
|
}) {
|
|
157
|
-
const
|
|
158
|
-
t
|
|
159
|
-
} = useTranslation(['MajooUI/inputCreatable', 'translation']);
|
|
158
|
+
const text = useInputCreatableLocaleText(localeText);
|
|
160
159
|
const [inputValue, setInputValue] = React__default.useState(value || '');
|
|
161
160
|
const [isOpen, setOpen] = React__default.useState(false);
|
|
162
161
|
React__default.useEffect(() => {
|
|
@@ -195,12 +194,14 @@ function InputCreatable({
|
|
|
195
194
|
children: /*#__PURE__*/jsxs(ItemWrapper, {
|
|
196
195
|
children: [/*#__PURE__*/jsx(CirclePlusOutline, {
|
|
197
196
|
color: colors.iconBrand
|
|
198
|
-
}), /*#__PURE__*/
|
|
197
|
+
}), /*#__PURE__*/jsx(Item, {
|
|
199
198
|
onClick: () => {
|
|
200
199
|
if (onClickItem) onClickItem();
|
|
201
200
|
setOpen(false);
|
|
202
201
|
},
|
|
203
|
-
children:
|
|
202
|
+
children: text.addOptionLabel({
|
|
203
|
+
value: inputValue
|
|
204
|
+
})
|
|
204
205
|
})]
|
|
205
206
|
})
|
|
206
207
|
})]
|
|
@@ -215,7 +216,14 @@ InputCreatable.propTypes = {
|
|
|
215
216
|
maxChar: PropTypes.number,
|
|
216
217
|
isInvalid: PropTypes.bool,
|
|
217
218
|
disabled: PropTypes.bool,
|
|
218
|
-
readOnly: PropTypes.bool
|
|
219
|
+
readOnly: PropTypes.bool,
|
|
220
|
+
/**
|
|
221
|
+
* Texts of this input, `{ addOptionLabel: ({ value }) => string }`. Keys left unset fall back to
|
|
222
|
+
* `MajooProvider`'s `localeText.inputCreatable`, then the Indonesian defaults.
|
|
223
|
+
*/
|
|
224
|
+
localeText: PropTypes.shape({
|
|
225
|
+
addOptionLabel: PropTypes.func
|
|
226
|
+
})
|
|
219
227
|
};
|
|
220
228
|
InputCreatable.defaultProps = {
|
|
221
229
|
placeholder: 'Placeholder',
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useLocaleText } from '../../../../config/locale/useLocaleText.esm.js';
|
|
2
|
+
|
|
3
|
+
const defaultInputCreatableLocaleText = {
|
|
4
|
+
addOptionLabel: ({
|
|
5
|
+
value
|
|
6
|
+
}) => `Tambah "${value}"`
|
|
7
|
+
};
|
|
8
|
+
const i18nInputCreatableLocaleText = t => ({
|
|
9
|
+
addOptionLabel: ({
|
|
10
|
+
value
|
|
11
|
+
}) => `${t('addText', 'Tambah')} "${value}"`
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Resolves the creatable input texts. Precedence: the input's own `localeText`, then `MajooProvider`'s
|
|
15
|
+
* `localeText.inputCreatable`, then the app's `MajooUI/inputCreatable` translations, then the Indonesian
|
|
16
|
+
* defaults.
|
|
17
|
+
*/
|
|
18
|
+
const useInputCreatableLocaleText = localeText => useLocaleText('inputCreatable', ['MajooUI/inputCreatable', 'translation'], i18nInputCreatableLocaleText, localeText);
|
|
19
|
+
|
|
20
|
+
export { defaultInputCreatableLocaleText, useInputCreatableLocaleText };
|
|
@@ -4,8 +4,10 @@ import { __rest } from 'tslib';
|
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import { InputSelect } from '../InputSelect/InputSelect.esm.js';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { advancePickerDate, advancePickerOptionsId } from '../../../datePicker/state/reducer.esm.js';
|
|
8
|
+
import { useLocale } from '../../../../config/locale/LocaleContext.esm.js';
|
|
9
|
+
import { useDatePickerLocaleText, localizeAdvanceOptions } from '../../../datePicker/locale.esm.js';
|
|
10
|
+
import { useInputDateRangeLocaleText } from './locale.esm.js';
|
|
9
11
|
|
|
10
12
|
const InputDateRange = /*#__PURE__*/React.forwardRef((_a, ref) => {
|
|
11
13
|
var {
|
|
@@ -16,15 +18,17 @@ const InputDateRange = /*#__PURE__*/React.forwardRef((_a, ref) => {
|
|
|
16
18
|
placement = 'bottom',
|
|
17
19
|
readOnly = false,
|
|
18
20
|
isInvalid = false,
|
|
19
|
-
css
|
|
21
|
+
css,
|
|
22
|
+
locale,
|
|
23
|
+
localeText
|
|
20
24
|
} = _a,
|
|
21
|
-
props = __rest(_a, ["onChange", "placeholder", "size", "disabled", "placement", "readOnly", "isInvalid", "css"]);
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const pickerOptions =
|
|
25
|
+
props = __rest(_a, ["onChange", "placeholder", "size", "disabled", "placement", "readOnly", "isInvalid", "css", "locale", "localeText"]);
|
|
26
|
+
const language = useLocale(locale);
|
|
27
|
+
const text = useInputDateRangeLocaleText(localeText);
|
|
28
|
+
const datePickerText = useDatePickerLocaleText(language, (localeText === null || localeText === void 0 ? void 0 : localeText.advanceOptions) && {
|
|
29
|
+
advanceOptions: localeText.advanceOptions
|
|
30
|
+
});
|
|
31
|
+
const pickerOptions = localizeAdvanceOptions(advancePickerOptionsId, datePickerText);
|
|
28
32
|
return jsx(InputSelect, Object.assign({}, props, {
|
|
29
33
|
option: pickerOptions.map(option => ({
|
|
30
34
|
name: option.label,
|
|
@@ -33,7 +37,7 @@ const InputDateRange = /*#__PURE__*/React.forwardRef((_a, ref) => {
|
|
|
33
37
|
onChange: selectedOption => {
|
|
34
38
|
if (onChange) onChange(advancePickerDate(selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value, undefined));
|
|
35
39
|
},
|
|
36
|
-
placeholder: placeholder ||
|
|
40
|
+
placeholder: placeholder || text.placeholder,
|
|
37
41
|
size: size,
|
|
38
42
|
disabled: disabled,
|
|
39
43
|
placement: placement,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useLocaleText } from '../../../../config/locale/useLocaleText.esm.js';
|
|
2
|
+
|
|
3
|
+
const defaultInputDateRangeLocaleText = {
|
|
4
|
+
placeholder: 'Pilih'
|
|
5
|
+
};
|
|
6
|
+
const i18nInputDateRangeLocaleText = t => ({
|
|
7
|
+
placeholder: t('placeholder.select', defaultInputDateRangeLocaleText.placeholder)
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* Resolves the date range select texts. Precedence: the select's own `localeText`, then `MajooProvider`'s
|
|
11
|
+
* `localeText.inputDateRange`, then the app's `translation` keys, then the Indonesian defaults.
|
|
12
|
+
*/
|
|
13
|
+
const useInputDateRangeLocaleText = localeText => useLocaleText('inputDateRange', 'translation', i18nInputDateRangeLocaleText, localeText);
|
|
14
|
+
|
|
15
|
+
export { defaultInputDateRangeLocaleText, useInputDateRangeLocaleText };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { __rest } from 'tslib';
|
|
1
2
|
import { jsx } from 'react/jsx-runtime';
|
|
2
3
|
import OTPInput, { ResendOTP as ResendOTP$1 } from 'otp-input-react';
|
|
3
4
|
import Paragraph from '../../../paragraph/Paragraph.esm.js';
|
|
4
|
-
import {
|
|
5
|
+
import { useInputOtpLocaleText } from './locale.esm.js';
|
|
5
6
|
import { foundations } from '@majoo-ui/core';
|
|
6
7
|
|
|
7
8
|
const {
|
|
@@ -33,10 +34,12 @@ InputOTP.defaultProps = {
|
|
|
33
34
|
otpType: 'any',
|
|
34
35
|
secure: false
|
|
35
36
|
};
|
|
36
|
-
function ResendOTP(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
function ResendOTP(_a) {
|
|
38
|
+
var {
|
|
39
|
+
localeText
|
|
40
|
+
} = _a,
|
|
41
|
+
props = __rest(_a, ["localeText"]);
|
|
42
|
+
const text = useInputOtpLocaleText(localeText);
|
|
40
43
|
function renderButton() {
|
|
41
44
|
return;
|
|
42
45
|
}
|
|
@@ -54,7 +57,7 @@ function ResendOTP(props) {
|
|
|
54
57
|
userSelect: 'none'
|
|
55
58
|
},
|
|
56
59
|
onClick: handleClick,
|
|
57
|
-
children: `${
|
|
60
|
+
children: `${text.resendButton} ${time > 0 ? `(${time}s)` : ''}`
|
|
58
61
|
});
|
|
59
62
|
}
|
|
60
63
|
return jsx(ResendOTP$1, Object.assign({
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useLocaleText } from '../../../../config/locale/useLocaleText.esm.js';
|
|
2
|
+
|
|
3
|
+
const defaultInputOtpLocaleText = {
|
|
4
|
+
resendButton: 'Kirim Ulang'
|
|
5
|
+
};
|
|
6
|
+
const i18nInputOtpLocaleText = t => ({
|
|
7
|
+
resendButton: t('resendingText', defaultInputOtpLocaleText.resendButton)
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* Resolves the OTP texts. Precedence: the component's own `localeText`, then `MajooProvider`'s
|
|
11
|
+
* `localeText.inputOtp`, then the app's `MajooUI/inputOtp` translations, then the Indonesian defaults.
|
|
12
|
+
*/
|
|
13
|
+
const useInputOtpLocaleText = localeText => useLocaleText('inputOtp', ['MajooUI/inputOtp', 'translation'], i18nInputOtpLocaleText, localeText);
|
|
14
|
+
|
|
15
|
+
export { defaultInputOtpLocaleText, useInputOtpLocaleText };
|
|
@@ -24,8 +24,8 @@ import { ConditionalWrapper } from '../../../../wrapper/ConditionalWrapper.esm.j
|
|
|
24
24
|
import debounce from 'lodash.debounce';
|
|
25
25
|
import { styled, colors } from '../../../../config/stitches.config.esm.js';
|
|
26
26
|
import { SortingOutline, ChevronUpOutline, ChevronDownOutline } from '@majoo-ui/icons';
|
|
27
|
-
import { useTranslation } from 'react-i18next';
|
|
28
27
|
import CheckOutline from '../InputSelectCheck/icon/CheckOutline.esm.js';
|
|
28
|
+
import { useInputResourceListLocaleText } from './locale.esm.js';
|
|
29
29
|
import InputCheckbox from '../InputCheckbox/InputCheckbox.esm.js';
|
|
30
30
|
import CheckboxGroup from '../InputCheckbox/CheckboxGroup.esm.js';
|
|
31
31
|
import { Tag } from '../../../tag/Tag.esm.js';
|
|
@@ -80,11 +80,10 @@ function InputResourceList({
|
|
|
80
80
|
renderSelectAll,
|
|
81
81
|
customHeader,
|
|
82
82
|
expandable,
|
|
83
|
-
searchable
|
|
83
|
+
searchable,
|
|
84
|
+
localeText
|
|
84
85
|
}) {
|
|
85
|
-
const
|
|
86
|
-
t
|
|
87
|
-
} = useTranslation(['MajooUI/inputResourceList', 'translation']);
|
|
86
|
+
const text = useInputResourceListLocaleText(localeText);
|
|
88
87
|
const [query, setQuery] = useState('');
|
|
89
88
|
const [sortType, setSortType] = useState('asc');
|
|
90
89
|
const [data, setData] = useState([]);
|
|
@@ -273,7 +272,7 @@ function InputResourceList({
|
|
|
273
272
|
}, css),
|
|
274
273
|
children: [customHeader, (searchable || !!onQueryChange) && jsx(InputSearchbox, Object.assign({
|
|
275
274
|
size: "lg",
|
|
276
|
-
placeholder: searchPlaceholder ||
|
|
275
|
+
placeholder: searchPlaceholder || text.searchPlaceholder,
|
|
277
276
|
onChange: debounce(query => {
|
|
278
277
|
setQuery(query);
|
|
279
278
|
if (onQueryChange) onQueryChange(query);
|
|
@@ -295,7 +294,7 @@ function InputResourceList({
|
|
|
295
294
|
}
|
|
296
295
|
}), jsx(Heading, {
|
|
297
296
|
heading: "headerTable",
|
|
298
|
-
children: title ||
|
|
297
|
+
children: title || text.title
|
|
299
298
|
}), jsx(SortingIcon, {
|
|
300
299
|
onClick: toggleSort,
|
|
301
300
|
children: jsx(SortingOutline, {
|
|
@@ -342,9 +341,7 @@ function InputResourceList({
|
|
|
342
341
|
paragraph: "shortContentRegular",
|
|
343
342
|
align: "center",
|
|
344
343
|
color: "secondary",
|
|
345
|
-
children: emptyDataMessage ||
|
|
346
|
-
ns: 'translation'
|
|
347
|
-
})
|
|
344
|
+
children: emptyDataMessage || text.emptyDataText
|
|
348
345
|
})
|
|
349
346
|
}) : null, jsx(ConditionalWrapper, {
|
|
350
347
|
condition: !!fetchData && data.length > 0,
|
|
@@ -386,7 +383,7 @@ function InputResourceList({
|
|
|
386
383
|
children: jsx(Text, {
|
|
387
384
|
variant: "helper",
|
|
388
385
|
color: disabled ? 'disable' : 'brand',
|
|
389
|
-
children: `${checkedItems.length} ${counterFooterText ||
|
|
386
|
+
children: `${checkedItems.length} ${counterFooterText || text.counterLabel}`
|
|
390
387
|
})
|
|
391
388
|
})]
|
|
392
389
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useLocaleText } from '../../../../config/locale/useLocaleText.esm.js';
|
|
2
|
+
|
|
3
|
+
const defaultInputResourceListLocaleText = {
|
|
4
|
+
searchPlaceholder: 'Cari ...',
|
|
5
|
+
title: 'Urutkan',
|
|
6
|
+
emptyDataText: 'Tidak ada data',
|
|
7
|
+
counterLabel: 'kategori dipilih'
|
|
8
|
+
};
|
|
9
|
+
const i18nInputResourceListLocaleText = t => {
|
|
10
|
+
const d = defaultInputResourceListLocaleText;
|
|
11
|
+
return {
|
|
12
|
+
searchPlaceholder: t('placeholder.search', d.searchPlaceholder),
|
|
13
|
+
title: t('defaultTitle', d.title),
|
|
14
|
+
emptyDataText: t('label.noData', d.emptyDataText, {
|
|
15
|
+
ns: 'translation'
|
|
16
|
+
}),
|
|
17
|
+
counterLabel: t('counterFooterText', d.counterLabel)
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Resolves the resource list texts. Precedence: the list's own `localeText`, then `MajooProvider`'s
|
|
22
|
+
* `localeText.inputResourceList`, then the app's `MajooUI/inputResourceList` translations, then the
|
|
23
|
+
* Indonesian defaults.
|
|
24
|
+
*/
|
|
25
|
+
const useInputResourceListLocaleText = localeText => useLocaleText('inputResourceList', ['MajooUI/inputResourceList', 'translation'], i18nInputResourceListLocaleText, localeText);
|
|
26
|
+
|
|
27
|
+
export { defaultInputResourceListLocaleText, useInputResourceListLocaleText };
|
|
@@ -6,8 +6,8 @@ import SvgCloseFilled from './CloseFilled.esm.js';
|
|
|
6
6
|
import SvgSearchOutline from './SearchOutline.esm.js';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import debounce from 'lodash.debounce';
|
|
9
|
-
import { useTranslation } from 'react-i18next';
|
|
10
9
|
import { foundations } from '@majoo-ui/core';
|
|
10
|
+
import { useInputSearchboxLocaleText } from './locale.esm.js';
|
|
11
11
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
12
12
|
|
|
13
13
|
const {
|
|
@@ -22,11 +22,10 @@ const InputSearchbox = ({
|
|
|
22
22
|
defaultValue,
|
|
23
23
|
mobileOnly,
|
|
24
24
|
desktopOnly,
|
|
25
|
+
localeText,
|
|
25
26
|
...props
|
|
26
27
|
}) => {
|
|
27
|
-
const
|
|
28
|
-
t
|
|
29
|
-
} = useTranslation(['MajooUI/inputSearchbox', 'translation']);
|
|
28
|
+
const text = useInputSearchboxLocaleText(localeText);
|
|
30
29
|
const [value, setValue] = useState(defaultValue);
|
|
31
30
|
const inputValue = props?.value ?? value;
|
|
32
31
|
const debounceChange = useCallback(debounce(e => onChange?.(e), 1000), [onChange]);
|
|
@@ -54,7 +53,7 @@ const InputSearchbox = ({
|
|
|
54
53
|
children: [/*#__PURE__*/jsx(InputLeftElement, {
|
|
55
54
|
children: /*#__PURE__*/jsx(SvgSearchOutline, {})
|
|
56
55
|
}), /*#__PURE__*/jsx(InputText, {
|
|
57
|
-
placeholder:
|
|
56
|
+
placeholder: text.placeholder,
|
|
58
57
|
onChange: handleChange,
|
|
59
58
|
value: value,
|
|
60
59
|
disabled: disabled,
|
|
@@ -71,6 +70,9 @@ const InputSearchbox = ({
|
|
|
71
70
|
});
|
|
72
71
|
};
|
|
73
72
|
InputSearchbox.propTypes = {
|
|
73
|
+
/**
|
|
74
|
+
* Wins over `localeText.placeholder`.
|
|
75
|
+
*/
|
|
74
76
|
placeholder: PropTypes.string,
|
|
75
77
|
value: PropTypes.string,
|
|
76
78
|
size: PropTypes.oneOf(['sm', 'lg']),
|
|
@@ -80,7 +82,14 @@ InputSearchbox.propTypes = {
|
|
|
80
82
|
onChange: PropTypes.func,
|
|
81
83
|
withDebounce: PropTypes.bool,
|
|
82
84
|
mobileOnly: PropTypes.bool,
|
|
83
|
-
desktopOnly: PropTypes.bool
|
|
85
|
+
desktopOnly: PropTypes.bool,
|
|
86
|
+
/**
|
|
87
|
+
* Texts of this search box, `{ placeholder }`. Keys left unset fall back to `MajooProvider`'s
|
|
88
|
+
* `localeText.inputSearchbox`, then `Cari ...`.
|
|
89
|
+
*/
|
|
90
|
+
localeText: PropTypes.shape({
|
|
91
|
+
placeholder: PropTypes.string
|
|
92
|
+
})
|
|
84
93
|
};
|
|
85
94
|
InputSearchbox.defaultProps = {
|
|
86
95
|
size: 'sm'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useLocaleText } from '../../../../config/locale/useLocaleText.esm.js';
|
|
2
|
+
|
|
3
|
+
const defaultInputSearchboxLocaleText = {
|
|
4
|
+
placeholder: 'Cari ...'
|
|
5
|
+
};
|
|
6
|
+
const i18nInputSearchboxLocaleText = t => ({
|
|
7
|
+
placeholder: t('placeholder', defaultInputSearchboxLocaleText.placeholder)
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* Resolves the search box texts. Precedence: the search box's own `localeText`, then `MajooProvider`'s
|
|
11
|
+
* `localeText.inputSearchbox`, then the app's `MajooUI/inputSearchbox` translations, then the Indonesian
|
|
12
|
+
* defaults.
|
|
13
|
+
*/
|
|
14
|
+
const useInputSearchboxLocaleText = localeText => useLocaleText('inputSearchbox', ['MajooUI/inputSearchbox', 'translation'], i18nInputSearchboxLocaleText, localeText);
|
|
15
|
+
|
|
16
|
+
export { defaultInputSearchboxLocaleText, useInputSearchboxLocaleText };
|