@majoo-ui/react 2.2.1 → 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/editableTable/EditableMobile.esm.js +4 -6
- package/components/editableTable/EditableTable.esm.js +7 -7
- 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 +29 -16
- 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/table/MobileTable.esm.js +4 -6
- package/components/table/Table.esm.js +63 -95
- package/components/table/components/columns/RowMenuColumn.esm.js +0 -5
- package/components/table/locale.esm.js +91 -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/LocaleTextContext.esm.js +5 -0
- package/config/locale/useLocaleText.esm.js +30 -0
- package/index.esm.css +249 -249
- package/index.esm.js +13 -0
- package/majoo-provider/MajooProvider.esm.js +41 -4
- package/package.json +2 -2
- 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/editableTable/EditableMobile.d.ts +1 -0
- package/src/components/editableTable/EditableTable.d.ts +9 -18
- 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/table/MobileTable.d.ts +1 -0
- package/src/components/table/index.d.ts +2 -0
- package/src/components/table/locale.d.ts +40 -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 +38 -0
- package/src/config/locale/useLocaleText.d.ts +10 -0
|
@@ -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';
|
|
@@ -12,7 +12,7 @@ import Flex from '../../layout/flex/Flex.esm.js';
|
|
|
12
12
|
import { Grid, GridItem } from '../../layout/grid/Grid.esm.js';
|
|
13
13
|
import Collapalse from './transition.esm.js';
|
|
14
14
|
import { TableHeaderCellContainer, TableHeadCellContent } from '../table/Table.esm.js';
|
|
15
|
-
import {
|
|
15
|
+
import { defaultTableLocaleText } from '../table/locale.esm.js';
|
|
16
16
|
|
|
17
17
|
const TableContainer = styled('div', {
|
|
18
18
|
display: 'block',
|
|
@@ -101,7 +101,8 @@ function EditableTableMobile(props) {
|
|
|
101
101
|
onExpand,
|
|
102
102
|
hiddenColumns,
|
|
103
103
|
customEmptyDataProps,
|
|
104
|
-
virtualized
|
|
104
|
+
virtualized,
|
|
105
|
+
sortColumnTitle = defaultTableLocaleText.sortColumnTitle
|
|
105
106
|
} = props;
|
|
106
107
|
const {
|
|
107
108
|
getTableProps,
|
|
@@ -113,9 +114,6 @@ function EditableTableMobile(props) {
|
|
|
113
114
|
toggleAllRowsExpanded,
|
|
114
115
|
setHiddenColumns
|
|
115
116
|
} = instance;
|
|
116
|
-
const {
|
|
117
|
-
t
|
|
118
|
-
} = useTranslation('MajooUI/table');
|
|
119
117
|
useEffect(() => {
|
|
120
118
|
if (hiddenColumns === null || hiddenColumns === void 0 ? void 0 : hiddenColumns.length) {
|
|
121
119
|
setHiddenColumns(hiddenColumns);
|
|
@@ -275,7 +273,7 @@ function EditableTableMobile(props) {
|
|
|
275
273
|
const isSelector = (column === null || column === void 0 ? void 0 : column.id) === 'selection';
|
|
276
274
|
const headerRender = column.render('Header');
|
|
277
275
|
return (isMobileHeader || isSelector) && (/*#__PURE__*/createElement(TableHeadCell, Object.assign({}, column.getHeaderProps(props => [props, column.sortable ? column.getSortByToggleProps({
|
|
278
|
-
title:
|
|
276
|
+
title: sortColumnTitle
|
|
279
277
|
}) : {
|
|
280
278
|
onClick: column.onToggle
|
|
281
279
|
}, {
|
|
@@ -15,9 +15,9 @@ import InputCheckbox from '../form/components/InputCheckbox/InputCheckbox.esm.js
|
|
|
15
15
|
import Flex from '../../layout/flex/Flex.esm.js';
|
|
16
16
|
import useMediaQuery from '../../utils/useMediaQuery.esm.js';
|
|
17
17
|
import EditableTableMobile from './EditableMobile.esm.js';
|
|
18
|
-
import { useTranslation } from 'react-i18next';
|
|
19
18
|
import { pick, isEqual } from 'lodash';
|
|
20
19
|
import { defaultEmptyDataProps, TableHeaderCellContainer, TableHeadCellContent } from '../table/Table.esm.js';
|
|
20
|
+
import { useTableLocaleText } from '../table/locale.esm.js';
|
|
21
21
|
import { useVirtual } from 'react-virtual';
|
|
22
22
|
import Tooltip from '../tooltip/Tooltip.esm.js';
|
|
23
23
|
|
|
@@ -309,11 +309,10 @@ function EditableTable(props) {
|
|
|
309
309
|
hiddenColumns,
|
|
310
310
|
customEmptyDataProps: emptyDataProps,
|
|
311
311
|
virtualized = false,
|
|
312
|
-
onSortByChange
|
|
312
|
+
onSortByChange,
|
|
313
|
+
localeText
|
|
313
314
|
} = props;
|
|
314
|
-
const
|
|
315
|
-
t
|
|
316
|
-
} = useTranslation('MajooUI/table');
|
|
315
|
+
const tableLocaleText = useTableLocaleText(localeText);
|
|
317
316
|
const [selectedIndex, setSelectedIndex] = useState(null);
|
|
318
317
|
const isMobile = useMediaQuery(isMobileLayout === undefined ? '(max-width: 767px)' : isMobileLayout ? '(max-width: 8000px)' : '(max-width: 0px)');
|
|
319
318
|
const IndeterminateCheckbox = props => {
|
|
@@ -403,7 +402,7 @@ function EditableTable(props) {
|
|
|
403
402
|
});
|
|
404
403
|
}
|
|
405
404
|
}, [selectedRowIds, data, onSelectedChange, selectedIndex]);
|
|
406
|
-
const customEmptyDataProps = emptyDataProps || defaultEmptyDataProps(
|
|
405
|
+
const customEmptyDataProps = emptyDataProps || defaultEmptyDataProps(tableLocaleText, isMobile);
|
|
407
406
|
const getCustomRows = (row, renderRow) => {
|
|
408
407
|
var _a;
|
|
409
408
|
let customStyle = {};
|
|
@@ -473,7 +472,7 @@ function EditableTable(props) {
|
|
|
473
472
|
children: visibleHeaders.map(column => {
|
|
474
473
|
const headerRender = column.render('Header');
|
|
475
474
|
return !(column === null || column === void 0 ? void 0 : column.isMobileOnly) && jsx(TableHeadCell, Object.assign({}, column.getHeaderProps(props => [props, column.sortable ? column.getSortByToggleProps({
|
|
476
|
-
title:
|
|
475
|
+
title: tableLocaleText.sortColumnTitle
|
|
477
476
|
}) : {
|
|
478
477
|
onClick: column.onToggle
|
|
479
478
|
}, {
|
|
@@ -597,6 +596,7 @@ function EditableTable(props) {
|
|
|
597
596
|
onExpand: onExpand,
|
|
598
597
|
hiddenColumns: hiddenColumns,
|
|
599
598
|
customEmptyDataProps: customEmptyDataProps,
|
|
599
|
+
sortColumnTitle: tableLocaleText.sortColumnTitle,
|
|
600
600
|
virtualized: virtualized,
|
|
601
601
|
rowVirtualizer: rowVirtualizer,
|
|
602
602
|
tableContainerRef: tableContainerRef
|
|
@@ -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,15 @@
|
|
|
1
|
+
import { useLocaleText } from '../../../../config/locale/useLocaleText.esm.js';
|
|
2
|
+
|
|
3
|
+
const i18nInputCreatableLocaleText = t => ({
|
|
4
|
+
addOptionLabel: ({
|
|
5
|
+
value
|
|
6
|
+
}) => `${t('addText', 'Tambah')} "${value}"`
|
|
7
|
+
});
|
|
8
|
+
/**
|
|
9
|
+
* Resolves the creatable input texts. Precedence: the input's own `localeText`, then `MajooProvider`'s
|
|
10
|
+
* `localeText.inputCreatable`, then the app's `MajooUI/inputCreatable` translations, then the Indonesian
|
|
11
|
+
* defaults.
|
|
12
|
+
*/
|
|
13
|
+
const useInputCreatableLocaleText = localeText => useLocaleText('inputCreatable', ['MajooUI/inputCreatable', 'translation'], i18nInputCreatableLocaleText, localeText);
|
|
14
|
+
|
|
15
|
+
export { 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 };
|