@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.
Files changed (84) hide show
  1. package/components/alertDialog/AlertDialog.esm.js +28 -15
  2. package/components/alertDialog/locale.esm.js +20 -0
  3. package/components/chart/lineChart/LineChart.esm.js +4 -0
  4. package/components/datePicker/DatePicker.esm.js +16 -6
  5. package/components/datePicker/DatePickerMulti.esm.js +5 -3
  6. package/components/datePicker/InputDatePicker.esm.js +14 -12
  7. package/components/datePicker/components/Calendar.esm.js +17 -23
  8. package/components/datePicker/components/CalendarMulti.esm.js +4 -7
  9. package/components/datePicker/components/CalendarTimePicker.esm.js +6 -9
  10. package/components/datePicker/components/MobileCalendar.esm.js +13 -17
  11. package/components/datePicker/locale.esm.js +92 -0
  12. package/components/devicePreview/DevicePreview.esm.js +4 -0
  13. package/components/form/components/InputCombobox/InputCombobox.esm.js +3 -0
  14. package/components/form/components/InputCreatable/InputCreatable.esm.js +16 -8
  15. package/components/form/components/InputCreatable/locale.esm.js +15 -0
  16. package/components/form/components/InputDateRange/InputDateRange.esm.js +15 -11
  17. package/components/form/components/InputDateRange/locale.esm.js +15 -0
  18. package/components/form/components/InputOTP/InputOTP.esm.js +9 -6
  19. package/components/form/components/InputOTP/locale.esm.js +15 -0
  20. package/components/form/components/InputResourceList/InputResourceList.esm.js +8 -11
  21. package/components/form/components/InputResourceList/locale.esm.js +27 -0
  22. package/components/form/components/InputSearchbox/InputSearchbox.esm.js +15 -6
  23. package/components/form/components/InputSearchbox/locale.esm.js +16 -0
  24. package/components/form/components/InputSelect/InputSelect.esm.js +13 -14
  25. package/components/form/components/InputSelect/locale.esm.js +23 -0
  26. package/components/form/components/InputSelectCheck/InputSelectCheck.esm.js +32 -23
  27. package/components/form/components/InputSelectCheck/locale.esm.js +30 -0
  28. package/components/form/components/InputSignature/InputSignature.esm.js +7 -8
  29. package/components/form/components/InputSignature/SignatureModal.esm.js +3 -3
  30. package/components/form/components/InputSignature/locale.esm.js +27 -0
  31. package/components/image/Image.esm.js +15 -9
  32. package/components/image/locale.esm.js +15 -0
  33. package/components/mapPicker/InputMapPicker.esm.js +5 -0
  34. package/components/pageDialog/PageDialog.esm.js +4 -0
  35. package/components/periodSelect/PeriodSelect.esm.js +11 -12
  36. package/components/periodSelect/locale.esm.js +25 -0
  37. package/components/tagList/TagList.esm.js +6 -7
  38. package/components/tagList/locale.esm.js +22 -0
  39. package/components/toast/context/ToastProvider.esm.js +13 -9
  40. package/components/toast/context/locale.esm.js +20 -0
  41. package/config/locale/LocaleContext.esm.js +29 -0
  42. package/config/locale/useLocaleText.esm.js +30 -0
  43. package/index.esm.js +12 -0
  44. package/majoo-provider/MajooProvider.esm.js +29 -5
  45. package/package.json +1 -1
  46. package/src/components/alertDialog/locale.d.ts +10 -0
  47. package/src/components/datePicker/DatePickerMulti.d.ts +2 -1
  48. package/src/components/datePicker/InputDatePicker.d.ts +13 -2
  49. package/src/components/datePicker/components/Calendar.d.ts +12 -1
  50. package/src/components/datePicker/components/CalendarMulti.d.ts +6 -1
  51. package/src/components/datePicker/components/CalendarTimePicker.d.ts +4 -1
  52. package/src/components/datePicker/components/MobileCalendar.d.ts +1 -1
  53. package/src/components/datePicker/index.d.ts +2 -0
  54. package/src/components/datePicker/locale.d.ts +45 -0
  55. package/src/components/form/components/InputCreatable/locale.d.ts +13 -0
  56. package/src/components/form/components/InputDateRange/InputDateRange.d.ts +16 -1
  57. package/src/components/form/components/InputDateRange/index.d.ts +2 -0
  58. package/src/components/form/components/InputDateRange/locale.d.ts +10 -0
  59. package/src/components/form/components/InputOTP/InputOTP.d.ts +7 -1
  60. package/src/components/form/components/InputOTP/index.d.ts +2 -0
  61. package/src/components/form/components/InputOTP/locale.d.ts +10 -0
  62. package/src/components/form/components/InputResourceList/InputResourceList.d.ts +8 -1
  63. package/src/components/form/components/InputResourceList/locale.d.ts +17 -0
  64. package/src/components/form/components/InputSearchbox/locale.d.ts +11 -0
  65. package/src/components/form/components/InputSelect/index.d.ts +2 -0
  66. package/src/components/form/components/InputSelect/locale.d.ts +15 -0
  67. package/src/components/form/components/InputSelectCheck/locale.d.ts +20 -0
  68. package/src/components/form/components/InputSignature/InputSignature.d.ts +7 -1
  69. package/src/components/form/components/InputSignature/SignatureModal.d.ts +2 -1
  70. package/src/components/form/components/InputSignature/index.d.ts +2 -0
  71. package/src/components/form/components/InputSignature/locale.d.ts +16 -0
  72. package/src/components/form/components/index.d.ts +4 -0
  73. package/src/components/image/index.d.ts +2 -0
  74. package/src/components/image/locale.d.ts +10 -0
  75. package/src/components/periodSelect/PeriodSelect.d.ts +14 -3
  76. package/src/components/periodSelect/index.d.ts +2 -0
  77. package/src/components/periodSelect/locale.d.ts +15 -0
  78. package/src/components/tagList/TagList.d.ts +8 -2
  79. package/src/components/tagList/index.d.ts +2 -0
  80. package/src/components/tagList/locale.d.ts +13 -0
  81. package/src/components/toast/context/locale.d.ts +11 -0
  82. package/src/config/locale/LocaleContext.d.ts +13 -0
  83. package/src/config/locale/LocaleTextContext.d.ts +28 -0
  84. 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';
@@ -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 { useTranslation } from 'react-i18next';
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__*/jsxs(Item, {
197
+ }), /*#__PURE__*/jsx(Item, {
199
198
  onClick: () => {
200
199
  if (onClickItem) onClickItem();
201
200
  setOpen(false);
202
201
  },
203
- children: [t('addText', 'Tambah'), " \"", inputValue, "\""]
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 { useTranslation } from 'react-i18next';
8
- import { advancePickerDate, advancePickerOptionsId, advancePickerOptionsEn } from '../../../datePicker/state/reducer.esm.js';
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
- t,
24
- i18n
25
- } = useTranslation('translation');
26
- const language = i18n.language;
27
- const pickerOptions = language === 'id' ? advancePickerOptionsId : advancePickerOptionsEn;
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 || t('placeholder.select', 'Pilih'),
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 { useTranslation } from 'react-i18next';
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(props) {
37
- const {
38
- t
39
- } = useTranslation(['MajooUI/inputOtp', 'translation']);
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: `${t('resendingText', 'Kirim Ulang')} ${time > 0 ? `(${time}s)` : ''}`
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 || t('placeholder.search', 'Cari ...'),
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 || t('defaultTitle', 'Urutkan')
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 || t('label.noData', 'Tidak ada data', {
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 || t('counterFooterText', 'kategori dipilih')}`
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: t('placeholder', 'Cari ...'),
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 };
@@ -23,7 +23,7 @@ import InputSearchbox from '../InputSearchbox/InputSearchbox.esm.js';
23
23
  import InfiniteScroll from 'react-infinite-scroller';
24
24
  import { ConditionalWrapper } from '../../../../wrapper/ConditionalWrapper.esm.js';
25
25
  import debounce from 'lodash.debounce';
26
- import { useTranslation } from 'react-i18next';
26
+ import { useInputSelectLocaleText } from './locale.esm.js';
27
27
  import { Portal } from '@majoo-ui/helpers';
28
28
  import { foundations } from '@majoo-ui/core';
29
29
  import ModalDialog, { ModalDialogTitle, ModalDialogContent } from '../../../modalDialog/ModalDialog.esm.js';
@@ -396,12 +396,11 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
396
396
  isMobile = false,
397
397
  mobileTitle,
398
398
  withDebounce = true,
399
- renderAsLabel = true
399
+ renderAsLabel = true,
400
+ localeText
400
401
  } = _a,
401
- props = __rest(_a, ["option", "onChange", "value", "placeholder", "searchPlaceholder", "embedSearch", "size", "disabled", "search", "iconColor", "hideArrowicon", "showLeadingIcon", "placement", "disabledOptions", "textSelector", "valueSelector", "readOnly", "isInvalid", "noOptionIcon", "fetchData", "onSearch", "isLoading", "showTooltip", "css", "renderFooter", "optionCss", "emptyDataMessage", "mobileOnly", "desktopOnly", "onStateChange", "isMobile", "mobileTitle", "withDebounce", "renderAsLabel"]);
402
- const {
403
- t
404
- } = useTranslation(['MajooUI/inputSelect', 'translation']);
402
+ props = __rest(_a, ["option", "onChange", "value", "placeholder", "searchPlaceholder", "embedSearch", "size", "disabled", "search", "iconColor", "hideArrowicon", "showLeadingIcon", "placement", "disabledOptions", "textSelector", "valueSelector", "readOnly", "isInvalid", "noOptionIcon", "fetchData", "onSearch", "isLoading", "showTooltip", "css", "renderFooter", "optionCss", "emptyDataMessage", "mobileOnly", "desktopOnly", "onStateChange", "isMobile", "mobileTitle", "withDebounce", "renderAsLabel", "localeText"]);
403
+ const text = useInputSelectLocaleText(localeText);
405
404
  const [options, setOptions] = useState([]);
406
405
  const [item, setItem] = useState([]);
407
406
  const [groupedItems, setGroupedItems] = useState([]);
@@ -637,7 +636,7 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
637
636
  showLeadingIcon: showLeadingIcon,
638
637
  showClearIcon: hideArrowicon,
639
638
  disabled: disabled,
640
- placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : t('placeholder', 'Pilih Item'),
639
+ placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : text.placeholder,
641
640
  readOnly: readOnly,
642
641
  handleInputValue: !fetchData ? handleInputValue : query => {
643
642
  if (onSearch) onSearch(query);
@@ -672,7 +671,7 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
672
671
  }) : jsx(Text, {
673
672
  color: "disable",
674
673
  css: StyledText,
675
- children: placeholder !== null && placeholder !== void 0 ? placeholder : t('placeholder', 'Pilih Item')
674
+ children: placeholder !== null && placeholder !== void 0 ? placeholder : text.placeholder
676
675
  })
677
676
  })), handleDownOption()]
678
677
  }))
@@ -741,7 +740,7 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
741
740
  children: jsx(InputSearchbox, {
742
741
  size: 'sm',
743
742
  onChange: handleInputValue,
744
- placeholder: searchPlaceholder !== null && searchPlaceholder !== void 0 ? searchPlaceholder : t('searchPlaceholder', 'Cari ...'),
743
+ placeholder: searchPlaceholder !== null && searchPlaceholder !== void 0 ? searchPlaceholder : text.searchPlaceholder,
745
744
  withDebounce: withDebounce
746
745
  })
747
746
  }), item.length > 0 || isLoading ? jsx(ConditionalWrapper, {
@@ -802,7 +801,7 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
802
801
  verticalAlign: 'text-bottom'
803
802
  }
804
803
  })
805
- }), emptyDataMessage || t('noItemPlaceholder', 'Item tidak ditemukan')]
804
+ }), emptyDataMessage || text.emptyDataText]
806
805
  })
807
806
  })]
808
807
  }))
@@ -848,14 +847,14 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
848
847
  }) : jsx(Text, {
849
848
  color: "disable",
850
849
  css: StyledText,
851
- children: placeholder !== null && placeholder !== void 0 ? placeholder : t('placeholder', 'Pilih Item')
850
+ children: placeholder !== null && placeholder !== void 0 ? placeholder : text.placeholder
852
851
  })
853
852
  })), handleDownOption()]
854
853
  })), jsxs(ModalDialog, {
855
854
  isMobile: true,
856
855
  open: isOpen,
857
856
  children: [jsx(ModalDialogTitle, {
858
- children: mobileTitle || placeholder || t('placeholder', 'Pilih Item')
857
+ children: mobileTitle || placeholder || text.placeholder
859
858
  }), jsx(ModalDialogContent, {
860
859
  css: {
861
860
  padding: 0,
@@ -902,7 +901,7 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
902
901
  children: jsx(InputSearchbox, {
903
902
  size: 'sm',
904
903
  onChange: handleInputValue,
905
- placeholder: searchPlaceholder !== null && searchPlaceholder !== void 0 ? searchPlaceholder : t('searchPlaceholder', 'Cari ...'),
904
+ placeholder: searchPlaceholder !== null && searchPlaceholder !== void 0 ? searchPlaceholder : text.searchPlaceholder,
906
905
  withDebounce: withDebounce
907
906
  })
908
907
  }), item.length > 0 || isLoading ? jsx(ConditionalWrapper, {
@@ -955,7 +954,7 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
955
954
  verticalAlign: 'text-bottom'
956
955
  }
957
956
  })
958
- }), emptyDataMessage || t('noItemPlaceholder', 'Item tidak ditemukan')]
957
+ }), emptyDataMessage || text.emptyDataText]
959
958
  })
960
959
  }), renderFooter && typeof renderFooter === 'function' && jsx(StyledFooter, {
961
960
  children: renderFooter()
@@ -0,0 +1,23 @@
1
+ import { useLocaleText } from '../../../../config/locale/useLocaleText.esm.js';
2
+
3
+ const defaultInputSelectLocaleText = {
4
+ placeholder: 'Pilih Item',
5
+ searchPlaceholder: 'Cari ...',
6
+ emptyDataText: 'Item tidak ditemukan'
7
+ };
8
+ const i18nInputSelectLocaleText = t => {
9
+ const d = defaultInputSelectLocaleText;
10
+ return {
11
+ placeholder: t('placeholder', d.placeholder),
12
+ searchPlaceholder: t('searchPlaceholder', d.searchPlaceholder),
13
+ emptyDataText: t('noItemPlaceholder', d.emptyDataText)
14
+ };
15
+ };
16
+ /**
17
+ * Resolves the select texts. Precedence: the select's own `localeText`, then `MajooProvider`'s
18
+ * `localeText.inputSelect`, then the app's `MajooUI/inputSelect` translations, then the Indonesian
19
+ * defaults.
20
+ */
21
+ const useInputSelectLocaleText = localeText => useLocaleText('inputSelect', ['MajooUI/inputSelect', 'translation'], i18nInputSelectLocaleText, localeText);
22
+
23
+ export { defaultInputSelectLocaleText, useInputSelectLocaleText };