@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
@@ -29,7 +29,7 @@ import { ChevronUpOutline, ChevronDownOutline, CircleInfoOutline, CaretDownOutli
29
29
  import { colors, styled } from '../../../../config/stitches.config.esm.js';
30
30
  import CheckOutline from './icon/CheckOutline.esm.js';
31
31
  import PropTypes from 'prop-types';
32
- import { useTranslation } from 'react-i18next';
32
+ import { useInputSelectCheckLocaleText } from './locale.esm.js';
33
33
  import debounce from 'lodash.debounce';
34
34
  import InfiniteScroll from 'react-infinite-scroller';
35
35
  import { ConditionalWrapper } from '../../../../wrapper/ConditionalWrapper.esm.js';
@@ -335,14 +335,11 @@ const InputSelectCheck = /*#__PURE__*/forwardRef(({
335
335
  onItemClick,
336
336
  virtualized,
337
337
  virtualizedThreshold,
338
+ locale,
339
+ localeText,
338
340
  ...props
339
341
  }, ref) => {
340
- const {
341
- t,
342
- i18n: {
343
- language
344
- }
345
- } = useTranslation(['MajooUI/inputSelectCheck', 'translation']);
342
+ const text = useInputSelectCheckLocaleText(localeText, locale);
346
343
  const [initItem, setInitItems] = React__default.useState(option); //init filter selectedItems on useMultipleSelection
347
344
  const [items, setItems] = React__default.useState([]);
348
345
  const [selectedValue, setSelectedValue] = React__default.useState([]);
@@ -566,12 +563,12 @@ const InputSelectCheck = /*#__PURE__*/forwardRef(({
566
563
  const options = generateOptions(sortDisabled);
567
564
  setItems(isShowSelectAll ? [{
568
565
  id: '!all',
569
- name: selectAllLabel ?? t('selectAllLabelText', 'Pilih Semua')
566
+ name: selectAllLabel ?? text.selectAllLabel
570
567
  }, ...options] : options);
571
568
  } else {
572
569
  setItems(isShowSelectAll ? [{
573
570
  id: '!all',
574
- name: selectAllLabel ?? t('selectAllLabelText', 'Pilih Semua')
571
+ name: selectAllLabel ?? text.selectAllLabel
575
572
  }, ...option] : option);
576
573
  }
577
574
  } else {
@@ -881,14 +878,14 @@ const InputSelectCheck = /*#__PURE__*/forwardRef(({
881
878
  if (!inputValue || fetchData) {
882
879
  setItems(isShowSelectAll ? [{
883
880
  id: '!all',
884
- name: selectAllLabel ?? (language === 'en' ? 'Select All' : 'Pilih Semua')
881
+ name: selectAllLabel ?? text.selectAllLabel
885
882
  }, ...memoOptions] : memoOptions);
886
883
  setInitItems(isShowSelectAll ? [{
887
884
  id: '!all',
888
- name: selectAllLabel ?? (language === 'en' ? 'Select All' : 'Pilih Semua')
885
+ name: selectAllLabel ?? text.selectAllLabel
889
886
  }, ...memoOptions] : memoOptions);
890
887
  }
891
- }, [isShowSelectAll, selectAllLabel, language, memoOptionsString, inputValue, sortBy]);
888
+ }, [isShowSelectAll, selectAllLabel, text.selectAllLabel, memoOptionsString, inputValue, sortBy]);
892
889
  useEffect(() => {
893
890
  if (selectedValue.length > 0 && disabledOptions.length === 0) {
894
891
  setInitItems(sortValue);
@@ -900,11 +897,11 @@ const InputSelectCheck = /*#__PURE__*/forwardRef(({
900
897
  const options = generateOptions(sortDisabled);
901
898
  setItems(isShowSelectAll ? [{
902
899
  id: '!all',
903
- name: selectAllLabel ?? t('selectAllLabelText', 'Pilih Semua')
900
+ name: selectAllLabel ?? text.selectAllLabel
904
901
  }, ...options] : options);
905
902
  setInitItems(isShowSelectAll ? [{
906
903
  id: '!all',
907
- name: selectAllLabel ?? t('selectAllLabelText', 'Pilih Semua')
904
+ name: selectAllLabel ?? text.selectAllLabel
908
905
  }, ...options] : options);
909
906
  }
910
907
  }, [disabledOptions, isShowSelectAll]);
@@ -1050,7 +1047,7 @@ const InputSelectCheck = /*#__PURE__*/forwardRef(({
1050
1047
  ...(toggleInput && getToggleButtonProps({
1051
1048
  disabled: disabled || readOnly
1052
1049
  })),
1053
- placeholder: placeholder ?? t('placeholder', 'Pilih Item'),
1050
+ placeholder: placeholder ?? text.placeholder,
1054
1051
  disabled: disabled || readOnly,
1055
1052
  hidden: !search
1056
1053
  }), /*#__PURE__*/jsx(Button, {
@@ -1062,7 +1059,7 @@ const InputSelectCheck = /*#__PURE__*/forwardRef(({
1062
1059
  type: "button",
1063
1060
  hidden: search,
1064
1061
  withLabel: !!label,
1065
- children: label ?? placeholder ?? t('placeholder', 'Pilih Item')
1062
+ children: label ?? placeholder ?? text.placeholder
1066
1063
  })]
1067
1064
  }), /*#__PURE__*/jsx(IconWrapper, {
1068
1065
  ...getToggleButtonProps({
@@ -1093,13 +1090,13 @@ const InputSelectCheck = /*#__PURE__*/forwardRef(({
1093
1090
  ...getSelectedItemProps({
1094
1091
  selectedItem: {
1095
1092
  id: '!all',
1096
- name: selectAllLabel ?? t('selectAllLabelText', 'Pilih Semua')
1093
+ name: selectAllLabel ?? text.selectAllLabel
1097
1094
  },
1098
1095
  index: 0
1099
1096
  }),
1100
1097
  onRemove: handleRemoveAllItem,
1101
1098
  css: tagCss,
1102
- children: selectAllLabel ?? t('selectAllLabelText', 'Pilih Semua')
1099
+ children: selectAllLabel ?? text.selectAllLabel
1103
1100
  }, `selected-item-!all`) : selectedItems?.filter(item => item?.id !== '!all')?.filter((_, idx) => {
1104
1101
  if (showAllTags || !collapsible) {
1105
1102
  return true;
@@ -1151,7 +1148,7 @@ const InputSelectCheck = /*#__PURE__*/forwardRef(({
1151
1148
  whiteSpace: 'nowrap'
1152
1149
  },
1153
1150
  color: "secondary",
1154
- children: showAllTags ? t('showSomeText', 'Tampilkan Sebagian') : t('showAllText', 'Tampilkan Semua')
1151
+ children: showAllTags ? text.showLessButton : text.showAllButton
1155
1152
  })]
1156
1153
  }), /*#__PURE__*/jsx(Separator, {})]
1157
1154
  }), showCollapsibleCounter && /*#__PURE__*/jsx(Paragraph, {
@@ -1159,7 +1156,7 @@ const InputSelectCheck = /*#__PURE__*/forwardRef(({
1159
1156
  fontSize: '$label'
1160
1157
  },
1161
1158
  color: "brand",
1162
- children: `${totalOptions ? totalOptions : selectedItems?.filter(item => item?.id !== '!all')?.length} ${labelCounter || t('labelCounterText', 'Item terpilih')}`
1159
+ children: `${totalOptions ? totalOptions : selectedItems?.filter(item => item?.id !== '!all')?.length} ${labelCounter || text.counterLabel}`
1163
1160
  })]
1164
1161
  })]
1165
1162
  }), showCounter && !isShowTagSelectAll && Boolean(selectedItems?.length) && /*#__PURE__*/jsx(Paragraph, {
@@ -1168,7 +1165,7 @@ const InputSelectCheck = /*#__PURE__*/forwardRef(({
1168
1165
  marginTop: '$spacing-01'
1169
1166
  },
1170
1167
  color: "brand",
1171
- children: `${totalOptions ? totalOptions : selectedItems?.filter(item => item?.id !== '!all')?.length} ${labelCounter || t('labelCounterText', 'Item terpilih')}`
1168
+ children: `${totalOptions ? totalOptions : selectedItems?.filter(item => item?.id !== '!all')?.length} ${labelCounter || text.counterLabel}`
1172
1169
  }), /*#__PURE__*/jsx(Portal, {
1173
1170
  children: /*#__PURE__*/jsxs(OptionWrapper, {
1174
1171
  ref: isMenuShown ? floating.refs.setFloating : null,
@@ -1312,7 +1309,7 @@ const InputSelectCheck = /*#__PURE__*/forwardRef(({
1312
1309
  verticalAlign: 'text-bottom'
1313
1310
  }
1314
1311
  })
1315
- }), textEmptyItem ?? t('emptyItemText', 'Item tidak ditemukan')]
1312
+ }), textEmptyItem ?? text.emptyDataText]
1316
1313
  })
1317
1314
  })]
1318
1315
  })
@@ -1362,7 +1359,19 @@ InputSelectCheck.propTypes = {
1362
1359
  clearSearchOnSelect: PropTypes.bool,
1363
1360
  onItemClick: PropTypes.func,
1364
1361
  virtualized: PropTypes.bool,
1365
- virtualizedThreshold: PropTypes.number
1362
+ virtualizedThreshold: PropTypes.number,
1363
+ /**
1364
+ * Language the select-all label follows while the transition lasts (`en` keeps "Select All"). Falls
1365
+ * back to `MajooProvider`'s `locale`, then the app's i18next language, then `id`.
1366
+ */
1367
+ locale: PropTypes.string,
1368
+ /**
1369
+ * Texts of this select: `placeholder`, `selectAllLabel`, `showAllButton`, `showLessButton`,
1370
+ * `counterLabel`, `emptyDataText`. Keys left unset fall back to `MajooProvider`'s
1371
+ * `localeText.inputSelectCheck`, then the Indonesian defaults. `placeholder`, `selectAllLabel`,
1372
+ * `labelCounter` and `textEmptyItem` still win.
1373
+ */
1374
+ localeText: PropTypes.object
1366
1375
  };
1367
1376
  InputSelectCheck.defaultProps = {
1368
1377
  size: 'lg',
@@ -0,0 +1,30 @@
1
+ import { useLocaleText } from '../../../../config/locale/useLocaleText.esm.js';
2
+
3
+ const defaultInputSelectCheckLocaleText = {
4
+ placeholder: 'Pilih Item',
5
+ selectAllLabel: 'Pilih Semua',
6
+ showAllButton: 'Tampilkan Semua',
7
+ showLessButton: 'Tampilkan Sebagian',
8
+ counterLabel: 'Item terpilih',
9
+ emptyDataText: 'Item tidak ditemukan'
10
+ };
11
+ // `en` keeps the English select-all label the component used to pick by language.
12
+ const i18nInputSelectCheckLocaleText = (t, locale) => {
13
+ const d = defaultInputSelectCheckLocaleText;
14
+ return {
15
+ placeholder: t('placeholder', d.placeholder),
16
+ selectAllLabel: t('selectAllLabelText', locale === 'en' ? 'Select All' : d.selectAllLabel),
17
+ showAllButton: t('showAllText', d.showAllButton),
18
+ showLessButton: t('showSomeText', d.showLessButton),
19
+ counterLabel: t('labelCounterText', d.counterLabel),
20
+ emptyDataText: t('emptyItemText', d.emptyDataText)
21
+ };
22
+ };
23
+ /**
24
+ * Resolves the multi-select texts. Precedence: the select's own `localeText`, then `MajooProvider`'s
25
+ * `localeText.inputSelectCheck`, then the app's `MajooUI/inputSelectCheck` translations, then the
26
+ * Indonesian defaults.
27
+ */
28
+ const useInputSelectCheckLocaleText = (localeText, locale) => useLocaleText('inputSelectCheck', ['MajooUI/inputSelectCheck', 'translation'], i18nInputSelectCheckLocaleText, localeText, locale);
29
+
30
+ export { defaultInputSelectCheckLocaleText, useInputSelectCheckLocaleText };
@@ -4,7 +4,7 @@ import Box from '../../../../layout/box/Box.esm.js';
4
4
  import Flex from '../../../../layout/flex/Flex.esm.js';
5
5
  import SignatureModal from './SignatureModal.esm.js';
6
6
  import { styled } from '@stitches/react';
7
- import { useTranslation } from 'react-i18next';
7
+ import { useInputSignatureLocaleText } from './locale.esm.js';
8
8
  import Text from '../../../text/Text.esm.js';
9
9
  import { CloseFilled } from '@majoo-ui/icons';
10
10
  import { foundations } from '@majoo-ui/core';
@@ -59,11 +59,10 @@ function InputSignature({
59
59
  defaultValue = '',
60
60
  disabled = false,
61
61
  css,
62
- isMobile
62
+ isMobile,
63
+ localeText
63
64
  }) {
64
- const {
65
- t
66
- } = useTranslation(['MajooUI/inputSignature', 'translation']);
65
+ const text = useInputSignatureLocaleText(localeText);
67
66
  const [signatureImage, setSignatureImage] = useState(defaultValue);
68
67
  const [open, setOpen] = useState(false);
69
68
  const handleSave = signature => {
@@ -106,15 +105,15 @@ function InputSignature({
106
105
  }) : jsx(Text, {
107
106
  variant: "label",
108
107
  color: "disable",
109
- children: t('placeholder', 'Tanda tangan di sini')
108
+ children: text.placeholder
110
109
  })
111
110
  }), jsx(SignatureModal, {
112
- t: t,
111
+ text: text,
113
112
  open: open,
114
113
  onOpenChange: setOpen,
115
114
  onSave: handleSave,
116
115
  isMobile: isMobile,
117
- title: title || signatureImage ? t('editTitle', 'Ubah Tanda Tangan') : t('addTitle', 'Tambah Tanda Tangan')
116
+ title: title || (signatureImage ? text.editTitle : text.addTitle)
118
117
  })]
119
118
  });
120
119
  }
@@ -7,7 +7,7 @@ import SignaturePad from 'react-signature-pad-wrapper';
7
7
  import { foundations } from '@majoo-ui/core';
8
8
 
9
9
  const SignatureModal = ({
10
- t,
10
+ text,
11
11
  open,
12
12
  onOpenChange,
13
13
  onSave,
@@ -53,12 +53,12 @@ const SignatureModal = ({
53
53
  children: jsx(Button, {
54
54
  buttonType: "ghost",
55
55
  size: "sm",
56
- children: t('label.cancel', 'Batal')
56
+ children: text.cancelButton
57
57
  })
58
58
  }), jsx(Button, {
59
59
  size: "sm",
60
60
  onClick: handleSave,
61
- children: t('label.save', 'Simpan')
61
+ children: text.saveButton
62
62
  })]
63
63
  })]
64
64
  });
@@ -0,0 +1,27 @@
1
+ import { useLocaleText } from '../../../../config/locale/useLocaleText.esm.js';
2
+
3
+ const defaultInputSignatureLocaleText = {
4
+ placeholder: 'Tanda tangan di sini',
5
+ addTitle: 'Tambah Tanda Tangan',
6
+ editTitle: 'Ubah Tanda Tangan',
7
+ cancelButton: 'Batal',
8
+ saveButton: 'Simpan'
9
+ };
10
+ const i18nInputSignatureLocaleText = t => {
11
+ const d = defaultInputSignatureLocaleText;
12
+ return {
13
+ placeholder: t('placeholder', d.placeholder),
14
+ addTitle: t('addTitle', d.addTitle),
15
+ editTitle: t('editTitle', d.editTitle),
16
+ cancelButton: t('label.cancel', d.cancelButton),
17
+ saveButton: t('label.save', d.saveButton)
18
+ };
19
+ };
20
+ /**
21
+ * Resolves the signature input texts. Precedence: the input's own `localeText`, then `MajooProvider`'s
22
+ * `localeText.inputSignature`, then the app's `MajooUI/inputSignature` translations, then the Indonesian
23
+ * defaults.
24
+ */
25
+ const useInputSignatureLocaleText = localeText => useLocaleText('inputSignature', ['MajooUI/inputSignature', 'translation'], i18nInputSignatureLocaleText, localeText);
26
+
27
+ export { defaultInputSignatureLocaleText, useInputSignatureLocaleText };
@@ -2,9 +2,10 @@ import 'react';
2
2
  import { styled } from '../../config/stitches.config.esm.js';
3
3
  import PropTypes from 'prop-types';
4
4
  import Flex from '../../layout/flex/Flex.esm.js';
5
- import { useTranslation } from 'react-i18next';
5
+ import { useImageLocaleText } from './locale.esm.js';
6
6
  import { jsx } from 'react/jsx-runtime';
7
7
 
8
+ const LEGACY_FALLBACK_TITLE = 'Tidak ada foto';
8
9
  const ContainerFallback = styled(Flex, {
9
10
  boxSizing: 'border-box',
10
11
  border: '2px dashed #C0C4C4',
@@ -51,11 +52,10 @@ function Image({
51
52
  css,
52
53
  cssFallback,
53
54
  rounded,
55
+ localeText,
54
56
  ...props
55
57
  }) {
56
- const {
57
- t
58
- } = useTranslation('translation');
58
+ const text = useImageLocaleText(localeText);
59
59
  if (src || fallback) {
60
60
  return /*#__PURE__*/jsx(StyledImage, {
61
61
  className: className,
@@ -82,7 +82,7 @@ function Image({
82
82
  ...cssFallback
83
83
  },
84
84
  children: /*#__PURE__*/jsx(TextFallback, {
85
- children: fallbackTitle === 'Tidak ada foto' ? t('fallbackTitle', fallbackTitle) : fallbackTitle
85
+ children: fallbackTitle && fallbackTitle !== LEGACY_FALLBACK_TITLE ? fallbackTitle : text.fallbackTitle
86
86
  })
87
87
  });
88
88
  }
@@ -129,13 +129,19 @@ Image.propTypes = {
129
129
  */
130
130
  fallback: PropTypes.string,
131
131
  /**
132
- Custom fallback title for default fallback.
132
+ Custom fallback title for default fallback. Wins over `localeText.fallbackTitle`.
133
133
  */
134
- fallbackTitle: PropTypes.string
134
+ fallbackTitle: PropTypes.string,
135
+ /**
136
+ Texts of this image, `{ fallbackTitle }`. Keys left unset fall back to `MajooProvider`'s
137
+ `localeText.image`, then the Indonesian defaults.
138
+ */
139
+ localeText: PropTypes.shape({
140
+ fallbackTitle: PropTypes.string
141
+ })
135
142
  };
136
143
  Image.defaultProps = {
137
- rounded: false,
138
- fallbackTitle: 'Tidak ada foto'
144
+ rounded: false
139
145
  };
140
146
 
141
147
  export { Image, Image as default };
@@ -0,0 +1,15 @@
1
+ import { useLocaleText } from '../../config/locale/useLocaleText.esm.js';
2
+
3
+ const defaultImageLocaleText = {
4
+ fallbackTitle: 'Tidak ada foto'
5
+ };
6
+ const i18nImageLocaleText = t => ({
7
+ fallbackTitle: t('fallbackTitle', defaultImageLocaleText.fallbackTitle)
8
+ });
9
+ /**
10
+ * Resolves the image texts. Precedence: the image's own `localeText`, then `MajooProvider`'s
11
+ * `localeText.image`, then the app's `translation` keys, then the Indonesian defaults.
12
+ */
13
+ const useImageLocaleText = localeText => useLocaleText('image', 'translation', i18nImageLocaleText, localeText);
14
+
15
+ export { defaultImageLocaleText, useImageLocaleText };
@@ -4,6 +4,11 @@ import React__default, { useState, useRef, useCallback, useEffect } from 'react'
4
4
  import MapPicker from './MapPicker.esm.js';
5
5
  import { Button } from '../button/Button.esm.js';
6
6
  import { Image } from '../image/Image.esm.js';
7
+ import 'core-js/modules/es.iterator.constructor.js';
8
+ import 'core-js/modules/es.iterator.filter.js';
9
+ import 'core-js/modules/es.iterator.reduce.js';
10
+ import 'react-i18next';
11
+ import 'core-js/modules/es.array.includes.js';
7
12
  import ModalDialog, { ModalDialogTrigger, ModalDialogTitle, ModalDialogContent } from '../modalDialog/ModalDialog.esm.js';
8
13
  import Paragraph from '../paragraph/Paragraph.esm.js';
9
14
  import { styled } from '../../config/stitches.config.esm.js';
@@ -9,6 +9,10 @@ import Box from '../../layout/box/Box.esm.js';
9
9
  import Dialog, { DialogTrigger, DialogContent, DialogClose, DialogTitle, DialogPortal } from '../dialog/Dialog.esm.js';
10
10
  import Heading from '../heading/Heading.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 { ConditionalWrapper } from '../../wrapper/ConditionalWrapper.esm.js';
13
17
  import { CloseOutline } from '@majoo-ui/icons';
14
18
  import useMediaQuery from '../../utils/useMediaQuery.esm.js';
@@ -2,10 +2,11 @@ import 'core-js/modules/es.iterator.constructor.js';
2
2
  import 'core-js/modules/es.iterator.map.js';
3
3
  import { jsxs, jsx } from 'react/jsx-runtime';
4
4
  import React__default, { useState } from 'react';
5
- import { useTranslation } from 'react-i18next';
6
5
  import { CaretDownOutline, ChevronRightOutline } from '@majoo-ui/icons';
7
6
  import { styled, colors } from '../../config/stitches.config.esm.js';
8
7
  import { weekdayNamesFullEng, weekdayNamesFullId } from '../../utils/calendar.esm.js';
8
+ import { useLocale } from '../../config/locale/LocaleContext.esm.js';
9
+ import { usePeriodSelectLocaleText } from './locale.esm.js';
9
10
  import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSub, DropdownMenuSubTrigger, RightSlot, DropdownMenuSubContent, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem } from '../dropdownMenu/DropdownMenu.esm.js';
10
11
 
11
12
  const Trigger = styled('button', {
@@ -85,14 +86,12 @@ const PeriodSelect = /*#__PURE__*/React__default.forwardRef(({
85
86
  periodLabels,
86
87
  startWeekLabel,
87
88
  formatWeekRange,
88
- css
89
+ css,
90
+ locale,
91
+ localeText
89
92
  }, ref) => {
90
- const {
91
- t,
92
- i18n: {
93
- language
94
- }
95
- } = useTranslation(['MajooUI/periodSelect', 'translation']);
93
+ const language = useLocale(locale);
94
+ const text = usePeriodSelectLocaleText(localeText);
96
95
  const [open, setOpen] = useState(false);
97
96
  const [internalStartDay, setInternalStartDay] = useState(defaultStartDay);
98
97
  const activeStartDay = startDay !== null && startDay !== void 0 ? startDay : internalStartDay;
@@ -111,9 +110,9 @@ const PeriodSelect = /*#__PURE__*/React__default.forwardRef(({
111
110
  };
112
111
  const showWeekRange = showRange && value === 'week';
113
112
  const defaultPeriodLabels = {
114
- day: t('day', 'Hari'),
115
- week: t('week', 'Minggu'),
116
- month: t('month', 'Bulan')
113
+ day: text.dayLabel,
114
+ week: text.weekLabel,
115
+ month: text.monthLabel
117
116
  };
118
117
  const periodLabel = period => {
119
118
  var _a;
@@ -157,7 +156,7 @@ const PeriodSelect = /*#__PURE__*/React__default.forwardRef(({
157
156
  padding: '$spacing-04 $spacing-05'
158
157
  },
159
158
  children: [jsx(DropdownMenuLabel, {
160
- children: startWeekLabel !== null && startWeekLabel !== void 0 ? startWeekLabel : t('startWeekFrom', 'Mulai minggu dari:')
159
+ children: startWeekLabel !== null && startWeekLabel !== void 0 ? startWeekLabel : text.startWeekLabel
161
160
  }), jsx(DropdownMenuRadioGroup, {
162
161
  value: String(activeStartDay),
163
162
  onValueChange: day => {
@@ -0,0 +1,25 @@
1
+ import { useLocaleText } from '../../config/locale/useLocaleText.esm.js';
2
+
3
+ const defaultPeriodSelectLocaleText = {
4
+ dayLabel: 'Hari',
5
+ weekLabel: 'Minggu',
6
+ monthLabel: 'Bulan',
7
+ startWeekLabel: 'Mulai minggu dari:'
8
+ };
9
+ const i18nPeriodSelectLocaleText = t => {
10
+ const d = defaultPeriodSelectLocaleText;
11
+ return {
12
+ dayLabel: t('day', d.dayLabel),
13
+ weekLabel: t('week', d.weekLabel),
14
+ monthLabel: t('month', d.monthLabel),
15
+ startWeekLabel: t('startWeekFrom', d.startWeekLabel)
16
+ };
17
+ };
18
+ /**
19
+ * Resolves the period select texts. Precedence: the select's own `localeText`, then `MajooProvider`'s
20
+ * `localeText.periodSelect`, then the app's `MajooUI/periodSelect` translations, then the Indonesian
21
+ * defaults.
22
+ */
23
+ const usePeriodSelectLocaleText = localeText => useLocaleText('periodSelect', ['MajooUI/periodSelect', 'translation'], i18nPeriodSelectLocaleText, localeText);
24
+
25
+ export { defaultPeriodSelectLocaleText, usePeriodSelectLocaleText };
@@ -10,7 +10,7 @@ import { Separator } from '../separator/Separator.esm.js';
10
10
  import Text from '../text/Text.esm.js';
11
11
  import { ChevronUpOutline, ChevronDownOutline } from '@majoo-ui/icons';
12
12
  import { styled, colors } from '../../config/stitches.config.esm.js';
13
- import { useTranslation } from 'react-i18next';
13
+ import { useTagListLocaleText } from './locale.esm.js';
14
14
  import { Tag } from '../tag/Tag.esm.js';
15
15
 
16
16
  const TagWrapper = styled(Box, {
@@ -24,11 +24,10 @@ const TagWrapper = styled(Box, {
24
24
  function TagList({
25
25
  selectedItems,
26
26
  onRemoveItem,
27
- counterLabel
27
+ counterLabel,
28
+ localeText
28
29
  }) {
29
- const {
30
- t
31
- } = useTranslation(['MajooUI/inputSelectCheck', 'translation']);
30
+ const text = useTagListLocaleText(localeText);
32
31
  const [showAllTags, setShowAllTags] = useState(false);
33
32
  return jsxs(React__default.Fragment, {
34
33
  children: [jsx(TagWrapper, {
@@ -73,7 +72,7 @@ function TagList({
73
72
  whiteSpace: 'nowrap'
74
73
  },
75
74
  color: "secondary",
76
- children: showAllTags ? t('showSomeText', 'Tampilkan Sebagian') : t('showAllText', 'Tampilkan Semua')
75
+ children: showAllTags ? text.showLessButton : text.showAllButton
77
76
  })]
78
77
  }), jsx(Separator, {})]
79
78
  }), jsxs(Text, {
@@ -82,7 +81,7 @@ function TagList({
82
81
  css: {
83
82
  marginTop: '$spacing-03 !important'
84
83
  },
85
- children: [selectedItems.length, " ", counterLabel || t('labelCounterText', 'Item terpilih')]
84
+ children: [selectedItems.length, " ", counterLabel || text.counterLabel]
86
85
  })]
87
86
  });
88
87
  }
@@ -0,0 +1,22 @@
1
+ import { useLocaleText } from '../../config/locale/useLocaleText.esm.js';
2
+
3
+ const defaultTagListLocaleText = {
4
+ showAllButton: 'Tampilkan Semua',
5
+ showLessButton: 'Tampilkan Sebagian',
6
+ counterLabel: 'Item terpilih'
7
+ };
8
+ const i18nTagListLocaleText = t => {
9
+ const d = defaultTagListLocaleText;
10
+ return {
11
+ showAllButton: t('showAllText', d.showAllButton),
12
+ showLessButton: t('showSomeText', d.showLessButton),
13
+ counterLabel: t('labelCounterText', d.counterLabel)
14
+ };
15
+ };
16
+ /**
17
+ * Resolves the tag list texts. Precedence: the list's own `localeText`, then `MajooProvider`'s
18
+ * `localeText.tagList`, then the app's `MajooUI/inputSelectCheck` translations, then the Indonesian defaults.
19
+ */
20
+ const useTagListLocaleText = localeText => useLocaleText('tagList', ['MajooUI/inputSelectCheck', 'translation'], i18nTagListLocaleText, localeText);
21
+
22
+ export { defaultTagListLocaleText, useTagListLocaleText };
@@ -8,21 +8,25 @@ import { TOP_RIGHT_POSITION, TOP_LEFT_POSITION, BOTTOM_RIGHT_POSITION, BOTTOM_LE
8
8
  import ToastContainer from '../ToastContainer.esm.js';
9
9
  import ToastContext from './ToastContext.esm.js';
10
10
  import useNavigatorOnLine from '../../../utils/useNavigatorOnline.esm.js';
11
- import { useTranslation } from 'react-i18next';
11
+ import { useToastLocaleText } from './locale.esm.js';
12
12
  import { catchError } from '../../../utils/request.esm.js';
13
13
  import { jsxs, jsx } from 'react/jsx-runtime';
14
14
 
15
15
  let toastCount = 0;
16
+
17
+ /**
18
+ * `localeText` ({ offlineTitle, offlineDescription }) sets the offline toast texts. Keys left unset fall
19
+ * back to `MajooProvider`'s `localeText.toast` when `ToastProvider` sits inside it, then the Indonesian
20
+ * defaults.
21
+ */
16
22
  const ToastProvider = ({
17
23
  children,
18
- theme
24
+ theme,
25
+ localeText
19
26
  }) => {
20
27
  const isOnline = useNavigatorOnLine();
21
28
  const [toasts, setToasts] = useState([]);
22
- const {
23
- t,
24
- i18n
25
- } = useTranslation(['MajooUI/toast', 'translation']);
29
+ const text = useToastLocaleText(localeText);
26
30
  const catchError$1 = (e, values) => {
27
31
  let errorMsg = catchError(e);
28
32
  if (values) {
@@ -43,9 +47,9 @@ const ToastProvider = ({
43
47
  const uniqueId = ++toastCount;
44
48
  const toastId = toast.id || `${id || 'toast'}-${uniqueId}`;
45
49
  const offlineInstance = {
46
- title: t('offlineTitle', 'Internet Bermasalah'),
50
+ title: text.offlineTitle,
47
51
  variant: 'failed',
48
- description: t('offlineDescription', 'Tidak ada koneksi internet, mohon periksa jaringan'),
52
+ description: text.offlineDescription,
49
53
  hrefOfAction: false,
50
54
  onClickOfAction: false,
51
55
  isExternalOfAction: false
@@ -57,7 +61,7 @@ const ToastProvider = ({
57
61
  description: /*#__PURE__*/React.isValidElement(toast.description) ? toast.description : catchError$1(toast.description, toast.values),
58
62
  ...(!isOnline && !disabledOfflineIntercept && offlineInstance)
59
63
  };
60
- }, [isOnline, t, i18n.language]);
64
+ }, [isOnline, text]);
61
65
  const addToast = React.useCallback(toast => {
62
66
  const toastInstance = createToastInstance(toast);
63
67
  setToasts(toastItems => {
@@ -0,0 +1,20 @@
1
+ import { useLocaleText } from '../../../config/locale/useLocaleText.esm.js';
2
+
3
+ const defaultToastLocaleText = {
4
+ offlineTitle: 'Internet Bermasalah',
5
+ offlineDescription: 'Tidak ada koneksi internet, mohon periksa jaringan'
6
+ };
7
+ const i18nToastLocaleText = t => {
8
+ const d = defaultToastLocaleText;
9
+ return {
10
+ offlineTitle: t('offlineTitle', d.offlineTitle),
11
+ offlineDescription: t('offlineDescription', d.offlineDescription)
12
+ };
13
+ };
14
+ /**
15
+ * Resolves the toast texts. Precedence: `ToastProvider`'s own `localeText`, then `MajooProvider`'s
16
+ * `localeText.toast`, then the app's `MajooUI/toast` translations, then the Indonesian defaults.
17
+ */
18
+ const useToastLocaleText = localeText => useLocaleText('toast', ['MajooUI/toast', 'translation'], i18nToastLocaleText, localeText);
19
+
20
+ export { defaultToastLocaleText, useToastLocaleText };
@@ -0,0 +1,29 @@
1
+ import 'core-js/modules/es.array.includes.js';
2
+ import * as React from 'react';
3
+ import { useContext } from 'react';
4
+ import { useTranslation } from 'react-i18next';
5
+
6
+ const SUPPORTED_LOCALES = ['id', 'en'];
7
+ const DEFAULT_LOCALE = 'id';
8
+ /** The app's language, supplied once through `MajooProvider`'s `locale`. */
9
+ const LocaleContext = /*#__PURE__*/React.createContext(undefined);
10
+ /** Reduces a tag such as `en-US` to its language; an unsupported language falls back to `id`. */
11
+ const normalizeLocale = locale => {
12
+ const language = (locale || '').toLowerCase().split(/[-_]/)[0];
13
+ return SUPPORTED_LOCALES.includes(language) ? language : DEFAULT_LOCALE;
14
+ };
15
+ /**
16
+ * Resolves the language. Precedence: the component's own `locale`, then `MajooProvider`'s `locale`,
17
+ * then the app's i18next language, then `id`.
18
+ */
19
+ // Transitional: the i18next step keeps apps that never pass `locale` in their current language.
20
+ // Remove together with the react-i18next dependency.
21
+ const useLocale = locale => {
22
+ const appLocale = useContext(LocaleContext);
23
+ const {
24
+ i18n
25
+ } = useTranslation();
26
+ return normalizeLocale(locale || appLocale || (i18n === null || i18n === void 0 ? void 0 : i18n.language));
27
+ };
28
+
29
+ export { DEFAULT_LOCALE, LocaleContext, normalizeLocale, useLocale };