@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.
Files changed (97) 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/editableTable/EditableMobile.esm.js +4 -6
  14. package/components/editableTable/EditableTable.esm.js +7 -7
  15. package/components/form/components/InputCombobox/InputCombobox.esm.js +3 -0
  16. package/components/form/components/InputCreatable/InputCreatable.esm.js +16 -8
  17. package/components/form/components/InputCreatable/locale.esm.js +15 -0
  18. package/components/form/components/InputDateRange/InputDateRange.esm.js +15 -11
  19. package/components/form/components/InputDateRange/locale.esm.js +15 -0
  20. package/components/form/components/InputOTP/InputOTP.esm.js +9 -6
  21. package/components/form/components/InputOTP/locale.esm.js +15 -0
  22. package/components/form/components/InputResourceList/InputResourceList.esm.js +8 -11
  23. package/components/form/components/InputResourceList/locale.esm.js +27 -0
  24. package/components/form/components/InputSearchbox/InputSearchbox.esm.js +15 -6
  25. package/components/form/components/InputSearchbox/locale.esm.js +16 -0
  26. package/components/form/components/InputSelect/InputSelect.esm.js +29 -16
  27. package/components/form/components/InputSelect/locale.esm.js +23 -0
  28. package/components/form/components/InputSelectCheck/InputSelectCheck.esm.js +32 -23
  29. package/components/form/components/InputSelectCheck/locale.esm.js +30 -0
  30. package/components/form/components/InputSignature/InputSignature.esm.js +7 -8
  31. package/components/form/components/InputSignature/SignatureModal.esm.js +3 -3
  32. package/components/form/components/InputSignature/locale.esm.js +27 -0
  33. package/components/image/Image.esm.js +15 -9
  34. package/components/image/locale.esm.js +15 -0
  35. package/components/mapPicker/InputMapPicker.esm.js +5 -0
  36. package/components/pageDialog/PageDialog.esm.js +4 -0
  37. package/components/periodSelect/PeriodSelect.esm.js +11 -12
  38. package/components/periodSelect/locale.esm.js +25 -0
  39. package/components/table/MobileTable.esm.js +4 -6
  40. package/components/table/Table.esm.js +63 -95
  41. package/components/table/components/columns/RowMenuColumn.esm.js +0 -5
  42. package/components/table/locale.esm.js +91 -0
  43. package/components/tagList/TagList.esm.js +6 -7
  44. package/components/tagList/locale.esm.js +22 -0
  45. package/components/toast/context/ToastProvider.esm.js +13 -9
  46. package/components/toast/context/locale.esm.js +20 -0
  47. package/config/locale/LocaleContext.esm.js +29 -0
  48. package/config/locale/LocaleTextContext.esm.js +5 -0
  49. package/config/locale/useLocaleText.esm.js +30 -0
  50. package/index.esm.css +249 -249
  51. package/index.esm.js +13 -0
  52. package/majoo-provider/MajooProvider.esm.js +41 -4
  53. package/package.json +2 -2
  54. package/src/components/alertDialog/locale.d.ts +10 -0
  55. package/src/components/datePicker/DatePickerMulti.d.ts +2 -1
  56. package/src/components/datePicker/InputDatePicker.d.ts +13 -2
  57. package/src/components/datePicker/components/Calendar.d.ts +12 -1
  58. package/src/components/datePicker/components/CalendarMulti.d.ts +6 -1
  59. package/src/components/datePicker/components/CalendarTimePicker.d.ts +4 -1
  60. package/src/components/datePicker/components/MobileCalendar.d.ts +1 -1
  61. package/src/components/datePicker/index.d.ts +2 -0
  62. package/src/components/datePicker/locale.d.ts +45 -0
  63. package/src/components/editableTable/EditableMobile.d.ts +1 -0
  64. package/src/components/editableTable/EditableTable.d.ts +9 -18
  65. package/src/components/form/components/InputCreatable/locale.d.ts +13 -0
  66. package/src/components/form/components/InputDateRange/InputDateRange.d.ts +16 -1
  67. package/src/components/form/components/InputDateRange/index.d.ts +2 -0
  68. package/src/components/form/components/InputDateRange/locale.d.ts +10 -0
  69. package/src/components/form/components/InputOTP/InputOTP.d.ts +7 -1
  70. package/src/components/form/components/InputOTP/index.d.ts +2 -0
  71. package/src/components/form/components/InputOTP/locale.d.ts +10 -0
  72. package/src/components/form/components/InputResourceList/InputResourceList.d.ts +8 -1
  73. package/src/components/form/components/InputResourceList/locale.d.ts +17 -0
  74. package/src/components/form/components/InputSearchbox/locale.d.ts +11 -0
  75. package/src/components/form/components/InputSelect/index.d.ts +2 -0
  76. package/src/components/form/components/InputSelect/locale.d.ts +15 -0
  77. package/src/components/form/components/InputSelectCheck/locale.d.ts +20 -0
  78. package/src/components/form/components/InputSignature/InputSignature.d.ts +7 -1
  79. package/src/components/form/components/InputSignature/SignatureModal.d.ts +2 -1
  80. package/src/components/form/components/InputSignature/index.d.ts +2 -0
  81. package/src/components/form/components/InputSignature/locale.d.ts +16 -0
  82. package/src/components/form/components/index.d.ts +4 -0
  83. package/src/components/image/index.d.ts +2 -0
  84. package/src/components/image/locale.d.ts +10 -0
  85. package/src/components/periodSelect/PeriodSelect.d.ts +14 -3
  86. package/src/components/periodSelect/index.d.ts +2 -0
  87. package/src/components/periodSelect/locale.d.ts +15 -0
  88. package/src/components/table/MobileTable.d.ts +1 -0
  89. package/src/components/table/index.d.ts +2 -0
  90. package/src/components/table/locale.d.ts +40 -0
  91. package/src/components/tagList/TagList.d.ts +8 -2
  92. package/src/components/tagList/index.d.ts +2 -0
  93. package/src/components/tagList/locale.d.ts +13 -0
  94. package/src/components/toast/context/locale.d.ts +11 -0
  95. package/src/config/locale/LocaleContext.d.ts +13 -0
  96. package/src/config/locale/LocaleTextContext.d.ts +38 -0
  97. package/src/config/locale/useLocaleText.d.ts +10 -0
@@ -18,7 +18,7 @@ import Text from '../text/Text.esm.js';
18
18
  import { ConditionalWrapper } from '../../wrapper/ConditionalWrapper.esm.js';
19
19
  import { ContextMenuTrigger } from '../contextMenu/ContextMenu.esm.js';
20
20
  import Paragraph from '../paragraph/Paragraph.esm.js';
21
- import { useTranslation } from 'react-i18next';
21
+ import { defaultTableLocaleText } from './locale.esm.js';
22
22
 
23
23
  const TableContainer = styled(Flex, {
24
24
  position: 'relative',
@@ -88,12 +88,10 @@ const MobileTable = /*#__PURE__*/React__default.forwardRef(({
88
88
  footerData,
89
89
  footerColumnIds,
90
90
  headerRowSpan,
91
- keyId = 'id'
91
+ keyId = 'id',
92
+ sortColumnTitle = defaultTableLocaleText.sortColumnTitle
92
93
  }, ref) => {
93
94
  var _a, _b, _c, _d;
94
- const {
95
- t
96
- } = useTranslation('MajooUI/table');
97
95
  const {
98
96
  getTableProps,
99
97
  getTableBodyProps,
@@ -190,7 +188,7 @@ const MobileTable = /*#__PURE__*/React__default.forwardRef(({
190
188
  children: headerGroup.headers.filter((column, index) => filterMobileHeader(column, index)).map(column => {
191
189
  const headerRender = column.render('Header');
192
190
  return jsx(TableHeadCell, Object.assign({}, column.getHeaderProps(isHeaderSortable(column) ? column.getSortByToggleProps({
193
- title: t('sortColumnTitle', 'Urutkan') || 'Urutkan'
191
+ title: sortColumnTitle
194
192
  }) : {
195
193
  onClick: column.onToggle
196
194
  }), {
@@ -44,8 +44,8 @@ import { alignCss, headerAlignCss, resolveCellCss } from './utils/columnStyles.e
44
44
  import { footerValueOf } from './utils/footerValue.esm.js';
45
45
  import { HeaderTooltip } from './utils/HeaderTooltip.esm.js';
46
46
  import { isHeaderSortable, getAriaSort } from './utils/headerSort.esm.js';
47
+ import { useTableLocaleText, i18nTableLocaleText } from './locale.esm.js';
47
48
  import { useSticky, getStickyValue, getMarginRight } from 'react-table-sticky';
48
- import { useTranslation } from 'react-i18next';
49
49
  import { useVirtual } from 'react-virtual';
50
50
  import { PlusPrimitive } from '@majoo-ui/icons';
51
51
  import '../scrollSync/ScrollSync.esm.js';
@@ -524,9 +524,9 @@ const formattingData = (rawData, rowGroup) => {
524
524
  }
525
525
  return rawData;
526
526
  };
527
- const defaultEmptyDataProps = (t, isMobile) => ({
527
+ const emptyStateProps = (asset, title, description, isMobile) => ({
528
528
  doodleImage: jsx(TableEmptyStateDoodle, {
529
- asset: "emptyData",
529
+ asset: asset,
530
530
  "aria-hidden": "true"
531
531
  }),
532
532
  title: jsx(Paragraph, {
@@ -536,48 +536,31 @@ const defaultEmptyDataProps = (t, isMobile) => ({
536
536
  css: {
537
537
  marginTop: isMobile ? 0 : '$spacing-05'
538
538
  },
539
- children: t('dataNotAvailableTitle', 'Data tidak tersedia')
539
+ children: title
540
540
  }),
541
- description: !isMobile ? jsxs(Paragraph, {
541
+ description: !isMobile ? jsx(Paragraph, {
542
542
  paragraph: "shortContentRegular",
543
543
  color: "secondary",
544
544
  align: "center",
545
- children: [t('dataNotAvailableDescription_1', 'Belum ada data yang dapat ditampilkan'), ' ', t('dataNotAvailableDescription_2', 'di halaman ini')]
546
- }) : jsxs(Text, {
545
+ children: description
546
+ }) : jsx(Text, {
547
547
  variant: "caption",
548
548
  color: "secondary",
549
549
  align: "center",
550
- children: [t('dataNotAvailableDescription_1', 'Belum ada data yang dapat ditampilkan'), jsx("br", {}), t('dataNotAvailableDescription_2', 'di halaman ini')]
551
- })
552
- });
553
- const defaultEmptySearchProps = (t, isMobile, query) => ({
554
- doodleImage: jsx(TableEmptyStateDoodle, {
555
- asset: "emptySearchData",
556
- "aria-hidden": "true"
557
- }),
558
- title: jsx(Paragraph, {
559
- paragraph: "shortContentBold",
560
- color: "primary",
561
- align: "center",
562
- css: {
563
- marginTop: isMobile ? 0 : '$spacing-05'
564
- },
565
- children: t('dataNotAvailableTitleSearch', `Oops... ${query} tidak ditemukan`, {
566
- query
567
- })
568
- }),
569
- description: !isMobile ? jsxs(Paragraph, {
570
- paragraph: "shortContentRegular",
571
- color: "secondary",
572
- align: "center",
573
- children: [t('dataNotAvailableDescriptionSearch_1', 'Coba lagi dengan memasukkan'), ' ', t('dataNotAvailableDescriptionSearch_2', 'kata kunci yang tepat')]
574
- }) : jsxs(Text, {
575
- variant: "caption",
576
- color: "secondary",
577
- align: "center",
578
- children: [t('dataNotAvailableDescriptionSearch_1', 'Coba lagi dengan memasukkan'), jsx("br", {}), t('dataNotAvailableDescriptionSearch_2', 'kata kunci yang tepat')]
550
+ children: description
579
551
  })
580
552
  });
553
+ /**
554
+ * Builds the default empty state from resolved table texts.
555
+ * Passing an i18next `t` function as the first argument is deprecated.
556
+ */
557
+ const defaultEmptyDataProps = (localeText, isMobile) => {
558
+ const text = typeof localeText === 'function' ? i18nTableLocaleText(localeText) : localeText;
559
+ return emptyStateProps('emptyData', text.emptyDataTitle, text.emptyDataDescription, isMobile);
560
+ };
561
+ const defaultEmptySearchProps = (localeText, isMobile, query) => emptyStateProps('emptySearchData', localeText.emptySearchTitle({
562
+ query
563
+ }), localeText.emptySearchDescription, isMobile);
581
564
  function HeaderMenuOption(props) {
582
565
  const {
583
566
  open,
@@ -587,7 +570,8 @@ function HeaderMenuOption(props) {
587
570
  headerGroups,
588
571
  id,
589
572
  filterHeader: items,
590
- rowData
573
+ rowData,
574
+ title
591
575
  } = props;
592
576
  const {
593
577
  headers = []
@@ -601,7 +585,7 @@ function HeaderMenuOption(props) {
601
585
  asChild: true,
602
586
  children: children
603
587
  }), jsx(ModalDialogTitle, {
604
- children: "Tampilkan Kolom"
588
+ children: title
605
589
  }), jsx(ModalDialogContent, {
606
590
  css: {
607
591
  overflowY: visibleHeaders.filter(val => typeof val.Header === 'string').length > 8 ? 'scroll' : 'none'
@@ -710,8 +694,9 @@ function Table({
710
694
  fetchData,
711
695
  hideDataInfo = false,
712
696
  rowsPerPageOptions = [10, 25, 50, 100],
713
- emptyDataMessage = 'Tidak ada data',
697
+ localeText,
714
698
  customEmptyDataProps: emptyDataProps,
699
+ customEmptySearchProps: emptySearchProps,
715
700
  isLoading = false,
716
701
  css,
717
702
  headerCss,
@@ -766,11 +751,11 @@ function Table({
766
751
  const [filteredHeader, setFilteredHeader] = useState([]);
767
752
  const [hasDarkParent, setHasDarkParent] = useState(false);
768
753
  const [hoveredRowId, setHoveredRowId] = useState(null);
769
- const {
770
- t
771
- } = useTranslation('MajooUI/table');
754
+ const tableLocaleText = useTableLocaleText(paginationLabel && {
755
+ pagination: paginationLabel
756
+ }, localeText);
772
757
  const isMobile = useMediaQuery(isMobileLayout === undefined ? '(max-width: 1024px)' : isMobileLayout ? '(max-width: 8000px)' : '(max-width: 0px)');
773
- const customEmptyDataProps = searchQuery ? defaultEmptySearchProps(t, isMobile, searchQuery) : emptyDataProps || defaultEmptyDataProps(t, isMobile);
758
+ const customEmptyDataProps = searchQuery ? emptySearchProps || defaultEmptySearchProps(tableLocaleText, isMobile, searchQuery) : emptyDataProps || defaultEmptyDataProps(tableLocaleText, isMobile);
774
759
  const getInitialState = () => {
775
760
  const initialState = {};
776
761
  if (fetchData) {
@@ -903,56 +888,37 @@ function Table({
903
888
  });
904
889
  if (fetchData) fetchData(fetchParams);
905
890
  };
906
- const renderFooter = () => {
907
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
908
- return jsx(Pagination, {
909
- hidePagination: hidePagination || isExpandableTree,
910
- hideInputPageSection: false,
911
- limit: pageSize,
912
- currentPage: pageIndex + 1,
913
- totalData: totalData,
914
- totalPage: totalPage,
915
- onLimitChange: selectedItem => {
916
- if (selectedItem) {
917
- // always reset page when limit changed
918
- gotoPage(0);
919
- doFetchData(0, selectedItem);
920
- setPageSize(selectedItem);
921
- setLimit(selectedItem);
922
- }
923
- },
924
- hideDataInfo: hideDataInfo || isExpandableTree,
925
- onPageChange: page => {
926
- doFetchData(page - 1, pageSize);
927
- gotoPage(page - 1);
928
- },
929
- rowsPerPageOptions: rowsPerPageOptions,
930
- showingText: (_a = paginationLabel === null || paginationLabel === void 0 ? void 0 : paginationLabel.showingText) !== null && _a !== void 0 ? _a : t('pagination.showingText', 'Tampilkan:'),
931
- showingCountText: (_b = paginationLabel === null || paginationLabel === void 0 ? void 0 : paginationLabel.showingCountText) !== null && _b !== void 0 ? _b : ({
932
- from,
933
- to,
934
- total
935
- }) => t('pagination.showingCountText', `Ditampilkan ${from} - ${to} dari ${total} data`, {
936
- from,
937
- to,
938
- total
939
- }),
940
- dialogShowingText: (_c = paginationLabel === null || paginationLabel === void 0 ? void 0 : paginationLabel.dialogShowingText) !== null && _c !== void 0 ? _c : t('pagination.dialogShowingText', 'Tampilkan Data'),
941
- previousButton: (_d = paginationLabel === null || paginationLabel === void 0 ? void 0 : paginationLabel.previousButton) !== null && _d !== void 0 ? _d : t('pagination.previousButton', 'Sebelumnya'),
942
- nextButton: (_e = paginationLabel === null || paginationLabel === void 0 ? void 0 : paginationLabel.nextButton) !== null && _e !== void 0 ? _e : t('pagination.nextButton', 'Selanjutnya'),
943
- gotoPageText: (_f = paginationLabel === null || paginationLabel === void 0 ? void 0 : paginationLabel.gotoPageText) !== null && _f !== void 0 ? _f : t('pagination.gotoPageText', 'Ke Halaman'),
944
- goToPagePlaceholder: (_g = paginationLabel === null || paginationLabel === void 0 ? void 0 : paginationLabel.goToPagePlaceholder) !== null && _g !== void 0 ? _g : t('pagination.goToPagePlaceholder', 'Contoh: 10'),
945
- btnCancelText: (_h = paginationLabel === null || paginationLabel === void 0 ? void 0 : paginationLabel.btnCancelText) !== null && _h !== void 0 ? _h : t('pagination.btnCancelText', 'Batal'),
946
- btnSubmitText: (_j = paginationLabel === null || paginationLabel === void 0 ? void 0 : paginationLabel.btnSubmitText) !== null && _j !== void 0 ? _j : t('pagination.btnSubmitText', 'Lanjutkan'),
947
- css: {
948
- backgroundColor: '$bgWhite',
949
- padding: '$spacing-04 0',
950
- '@md': {
951
- padding: '$spacing-06 $spacing-03'
952
- }
891
+ const renderFooter = () => jsx(Pagination, Object.assign({
892
+ hidePagination: hidePagination || isExpandableTree,
893
+ hideInputPageSection: false,
894
+ limit: pageSize,
895
+ currentPage: pageIndex + 1,
896
+ totalData: totalData,
897
+ totalPage: totalPage,
898
+ onLimitChange: selectedItem => {
899
+ if (selectedItem) {
900
+ // always reset page when limit changed
901
+ gotoPage(0);
902
+ doFetchData(0, selectedItem);
903
+ setPageSize(selectedItem);
904
+ setLimit(selectedItem);
953
905
  }
954
- });
955
- };
906
+ },
907
+ hideDataInfo: hideDataInfo || isExpandableTree,
908
+ onPageChange: page => {
909
+ doFetchData(page - 1, pageSize);
910
+ gotoPage(page - 1);
911
+ },
912
+ rowsPerPageOptions: rowsPerPageOptions
913
+ }, tableLocaleText.pagination, {
914
+ css: {
915
+ backgroundColor: '$bgWhite',
916
+ padding: '$spacing-04 0',
917
+ '@md': {
918
+ padding: '$spacing-06 $spacing-03'
919
+ }
920
+ }
921
+ }));
956
922
  const renderInfiniteScrollWrapper = children => jsx(ConditionalWrapper, {
957
923
  condition: isInfiniteScroll && rawData.length > 0,
958
924
  wrapper: children => jsx(InfiniteScroll, {
@@ -1059,7 +1025,7 @@ function Table({
1059
1025
  children: visibleHeaders.map((column, index) => {
1060
1026
  const headerRender = column.render('Header');
1061
1027
  return jsx(TableHeadCell, Object.assign({}, column.getHeaderProps(props => [props, isHeaderSortable(column) ? column.getSortByToggleProps({
1062
- title: t('sortColumnTitle', 'Urutkan') || 'Urutkan'
1028
+ title: tableLocaleText.sortColumnTitle
1063
1029
  }) : {
1064
1030
  onClick: column.onToggle
1065
1031
  }, {
@@ -1303,7 +1269,7 @@ function Table({
1303
1269
  }, index) => {
1304
1270
  const headerRender = column.render('Header');
1305
1271
  return jsx(TableHeadCell, Object.assign({}, column.getHeaderProps(props => [props, isHeaderSortable(column) ? column.getSortByToggleProps({
1306
- title: t('sortColumnTitle', 'Urutkan') || 'Urutkan'
1272
+ title: tableLocaleText.sortColumnTitle
1307
1273
  }) : {
1308
1274
  onClick: column.onToggle
1309
1275
  }, {
@@ -1621,6 +1587,7 @@ function Table({
1621
1587
  onChange: handleFilterHeaderChange,
1622
1588
  headerGroups: headerGroups,
1623
1589
  filterHeader: filterHeader,
1590
+ title: tableLocaleText.showColumnTitle,
1624
1591
  children: jsx(IconButton, {
1625
1592
  css: {
1626
1593
  zIndex: '$docked',
@@ -1695,7 +1662,8 @@ function Table({
1695
1662
  footerData: footerData,
1696
1663
  footerColumnIds: (footerData === null || footerData === void 0 ? void 0 : footerData.length) ? new Set(visibleColumns.filter(column => column.Footer !== emptyRenderer).map(column => column.id)) : undefined,
1697
1664
  headerRowSpan: headerRowSpan,
1698
- keyId: keyId
1665
+ keyId: keyId,
1666
+ sortColumnTitle: tableLocaleText.sortColumnTitle
1699
1667
  })]
1700
1668
  });
1701
1669
  }
@@ -3,7 +3,6 @@ import 'core-js/modules/es.iterator.map.js';
3
3
  import React__default, { useState } from 'react';
4
4
  import { EllipsisHorizontalOutline } from '@majoo-ui/icons';
5
5
  import Box from '../../../../layout/box/Box.esm.js';
6
- import { useTranslation } from 'react-i18next';
7
6
  import { jsxs, jsx } from 'react/jsx-runtime';
8
7
  import { DropdownMenu, DropdownMenuTrigger, DropdownMenuPortal, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator } from '../../../dropdownMenu/DropdownMenu.esm.js';
9
8
  import IconButton from '../../../iconButton/IconButton.esm.js';
@@ -13,11 +12,7 @@ const rowMenuColumn = (options, icon, config) => ({
13
12
  options,
14
13
  Header: () => null,
15
14
  Cell: props => {
16
- const {
17
- t
18
- } = useTranslation('MajooUI/table');
19
15
  const defaultConfig = {
20
- mobileTitle: t('rowMenuMobileLabel', 'Aksi'),
21
16
  cssContent: {},
22
17
  cssMenuItem: {},
23
18
  align: 'end'
@@ -0,0 +1,91 @@
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.reduce.js';
4
+ import { useContext, useMemo } from 'react';
5
+ import { useTranslation } from 'react-i18next';
6
+ import { LocaleTextContext } from '../../config/locale/LocaleTextContext.esm.js';
7
+
8
+ const defaultTableLocaleText = {
9
+ sortColumnTitle: 'Urutkan',
10
+ showColumnTitle: 'Tampilkan Kolom',
11
+ emptyDataTitle: 'Data tidak tersedia',
12
+ emptyDataDescription: 'Belum ada data yang dapat ditampilkan di halaman ini',
13
+ emptySearchTitle: ({
14
+ query
15
+ }) => `Oops... ${query} tidak ditemukan`,
16
+ emptySearchDescription: 'Coba lagi dengan memasukkan kata kunci yang tepat',
17
+ pagination: {
18
+ showingText: 'Tampilkan:',
19
+ showingCountText: ({
20
+ from,
21
+ to,
22
+ total
23
+ }) => `Ditampilkan ${from} - ${to} dari ${total} data`,
24
+ dialogShowingText: 'Tampilkan Data',
25
+ previousButton: 'Sebelumnya',
26
+ nextButton: 'Selanjutnya',
27
+ gotoPageText: 'Ke Halaman',
28
+ goToPagePlaceholder: 'Contoh: 10',
29
+ btnCancelText: 'Batal',
30
+ btnSubmitText: 'Lanjutkan'
31
+ }
32
+ };
33
+ // Transitional: keeps apps that still ship `MajooUI/table` locale files translated until they pass
34
+ // `localeText`. Remove together with the react-i18next dependency of the table family.
35
+ const i18nTableLocaleText = t => {
36
+ const d = defaultTableLocaleText;
37
+ return {
38
+ sortColumnTitle: t('sortColumnTitle', d.sortColumnTitle),
39
+ showColumnTitle: t('customColumnTitle', d.showColumnTitle),
40
+ emptyDataTitle: t('dataNotAvailableTitle', d.emptyDataTitle),
41
+ emptyDataDescription: `${t('dataNotAvailableDescription_1', 'Belum ada data yang dapat ditampilkan')} ${t('dataNotAvailableDescription_2', 'di halaman ini')}`,
42
+ emptySearchTitle: ({
43
+ query
44
+ }) => t('dataNotAvailableTitleSearch', `Oops... ${query} tidak ditemukan`, {
45
+ query
46
+ }),
47
+ emptySearchDescription: `${t('dataNotAvailableDescriptionSearch_1', 'Coba lagi dengan memasukkan')} ${t('dataNotAvailableDescriptionSearch_2', 'kata kunci yang tepat')}`,
48
+ pagination: {
49
+ showingText: t('pagination.showingText', d.pagination.showingText),
50
+ showingCountText: ({
51
+ from,
52
+ to,
53
+ total
54
+ }) => t('pagination.showingCountText', `Ditampilkan ${from} - ${to} dari ${total} data`, {
55
+ from,
56
+ to,
57
+ total
58
+ }),
59
+ dialogShowingText: t('pagination.dialogShowingText', d.pagination.dialogShowingText),
60
+ previousButton: t('pagination.previousButton', d.pagination.previousButton),
61
+ nextButton: t('pagination.nextButton', d.pagination.nextButton),
62
+ gotoPageText: t('pagination.gotoPageText', d.pagination.gotoPageText),
63
+ goToPagePlaceholder: t('pagination.goToPagePlaceholder', d.pagination.goToPagePlaceholder),
64
+ btnCancelText: t('pagination.btnCancelText', d.pagination.btnCancelText),
65
+ btnSubmitText: t('pagination.btnSubmitText', d.pagination.btnSubmitText)
66
+ }
67
+ };
68
+ };
69
+ const definedEntries = obj => obj ? Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== undefined)) : {};
70
+ /** Later sources win; an `undefined` value never erases an earlier one. */
71
+ const mergeTableLocaleText = (base, ...overrides) => overrides.reduce((merged, override) => Object.assign(Object.assign(Object.assign({}, merged), definedEntries(override)), {
72
+ pagination: Object.assign(Object.assign({}, merged.pagination), definedEntries(override === null || override === void 0 ? void 0 : override.pagination))
73
+ }), base);
74
+ /**
75
+ * Resolves the table texts. Precedence: the table's own `localeText`, then `MajooProvider`'s
76
+ * `localeText.table`, then the app's `MajooUI/table` translations, then the Indonesian defaults.
77
+ * Several table-level overrides may be passed; later ones win. Pass the same number on every render.
78
+ */
79
+ const useTableLocaleText = (...localeTexts) => {
80
+ const {
81
+ t
82
+ } = useTranslation('MajooUI/table');
83
+ const {
84
+ table: appLocaleText
85
+ } = useContext(LocaleTextContext);
86
+ return useMemo(() => mergeTableLocaleText(i18nTableLocaleText(t), appLocaleText, ...localeTexts),
87
+ // eslint-disable-next-line react-hooks/exhaustive-deps
88
+ [t, appLocaleText, ...localeTexts]);
89
+ };
90
+
91
+ export { defaultTableLocaleText, i18nTableLocaleText, mergeTableLocaleText, useTableLocaleText };
@@ -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 };
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+
3
+ const LocaleTextContext = /*#__PURE__*/React.createContext({});
4
+
5
+ export { LocaleTextContext };
@@ -0,0 +1,30 @@
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.reduce.js';
4
+ import { useContext, useMemo } from 'react';
5
+ import { useTranslation } from 'react-i18next';
6
+ import { LocaleTextContext } from './LocaleTextContext.esm.js';
7
+ import { useLocale } from './LocaleContext.esm.js';
8
+
9
+ const definedEntries = obj => obj ? Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== undefined)) : {};
10
+ /** Later sources win; an `undefined` value never erases an earlier one. */
11
+ const mergeLocaleText = (base, ...overrides) => overrides.reduce((merged, override) => Object.assign(Object.assign({}, merged), definedEntries(override)), base);
12
+ /**
13
+ * Resolves the flat texts of a component. Precedence: the component's own `localeText`, then
14
+ * `MajooProvider`'s `localeText[key]`, then the app's i18next translations, then the defaults that
15
+ * `fromI18n` falls back to.
16
+ */
17
+ // Transitional: `fromI18n` keeps apps that still ship `MajooUI/*` locale files translated until they pass
18
+ // `localeText`. Remove together with the react-i18next dependency, leaving the defaults.
19
+ const useLocaleText = (key, namespaces, fromI18n, localeText, locale) => {
20
+ const {
21
+ t
22
+ } = useTranslation(namespaces);
23
+ const language = useLocale(locale);
24
+ const appLocaleText = useContext(LocaleTextContext)[key];
25
+ return useMemo(() => mergeLocaleText(fromI18n(t, language), appLocaleText, localeText),
26
+ // eslint-disable-next-line react-hooks/exhaustive-deps
27
+ [t, language, appLocaleText, localeText]);
28
+ };
29
+
30
+ export { mergeLocaleText, useLocaleText };