@majoo-ui/react 2.2.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/alertDialog/AlertDialog.esm.js +28 -15
- package/components/alertDialog/locale.esm.js +20 -0
- package/components/chart/lineChart/LineChart.esm.js +4 -0
- package/components/datePicker/DatePicker.esm.js +16 -6
- package/components/datePicker/DatePickerMulti.esm.js +5 -3
- package/components/datePicker/InputDatePicker.esm.js +14 -12
- package/components/datePicker/components/Calendar.esm.js +17 -23
- package/components/datePicker/components/CalendarMulti.esm.js +4 -7
- package/components/datePicker/components/CalendarTimePicker.esm.js +6 -9
- package/components/datePicker/components/MobileCalendar.esm.js +13 -17
- package/components/datePicker/locale.esm.js +92 -0
- package/components/devicePreview/DevicePreview.esm.js +4 -0
- package/components/editableTable/EditableMobile.esm.js +4 -6
- package/components/editableTable/EditableTable.esm.js +7 -7
- package/components/form/components/InputCombobox/InputCombobox.esm.js +3 -0
- package/components/form/components/InputCreatable/InputCreatable.esm.js +16 -8
- package/components/form/components/InputCreatable/locale.esm.js +15 -0
- package/components/form/components/InputDateRange/InputDateRange.esm.js +15 -11
- package/components/form/components/InputDateRange/locale.esm.js +15 -0
- package/components/form/components/InputOTP/InputOTP.esm.js +9 -6
- package/components/form/components/InputOTP/locale.esm.js +15 -0
- package/components/form/components/InputResourceList/InputResourceList.esm.js +8 -11
- package/components/form/components/InputResourceList/locale.esm.js +27 -0
- package/components/form/components/InputSearchbox/InputSearchbox.esm.js +15 -6
- package/components/form/components/InputSearchbox/locale.esm.js +16 -0
- package/components/form/components/InputSelect/InputSelect.esm.js +29 -16
- package/components/form/components/InputSelect/locale.esm.js +23 -0
- package/components/form/components/InputSelectCheck/InputSelectCheck.esm.js +32 -23
- package/components/form/components/InputSelectCheck/locale.esm.js +30 -0
- package/components/form/components/InputSignature/InputSignature.esm.js +7 -8
- package/components/form/components/InputSignature/SignatureModal.esm.js +3 -3
- package/components/form/components/InputSignature/locale.esm.js +27 -0
- package/components/image/Image.esm.js +15 -9
- package/components/image/locale.esm.js +15 -0
- package/components/mapPicker/InputMapPicker.esm.js +5 -0
- package/components/pageDialog/PageDialog.esm.js +4 -0
- package/components/periodSelect/PeriodSelect.esm.js +11 -12
- package/components/periodSelect/locale.esm.js +25 -0
- package/components/table/MobileTable.esm.js +4 -6
- package/components/table/Table.esm.js +63 -95
- package/components/table/components/columns/RowMenuColumn.esm.js +0 -5
- package/components/table/locale.esm.js +91 -0
- package/components/tagList/TagList.esm.js +6 -7
- package/components/tagList/locale.esm.js +22 -0
- package/components/toast/context/ToastProvider.esm.js +13 -9
- package/components/toast/context/locale.esm.js +20 -0
- package/config/locale/LocaleContext.esm.js +29 -0
- package/config/locale/LocaleTextContext.esm.js +5 -0
- package/config/locale/useLocaleText.esm.js +30 -0
- package/index.esm.css +249 -249
- package/index.esm.js +13 -0
- package/majoo-provider/MajooProvider.esm.js +41 -4
- package/package.json +2 -2
- package/src/components/alertDialog/locale.d.ts +10 -0
- package/src/components/datePicker/DatePickerMulti.d.ts +2 -1
- package/src/components/datePicker/InputDatePicker.d.ts +13 -2
- package/src/components/datePicker/components/Calendar.d.ts +12 -1
- package/src/components/datePicker/components/CalendarMulti.d.ts +6 -1
- package/src/components/datePicker/components/CalendarTimePicker.d.ts +4 -1
- package/src/components/datePicker/components/MobileCalendar.d.ts +1 -1
- package/src/components/datePicker/index.d.ts +2 -0
- package/src/components/datePicker/locale.d.ts +45 -0
- package/src/components/editableTable/EditableMobile.d.ts +1 -0
- package/src/components/editableTable/EditableTable.d.ts +9 -18
- package/src/components/form/components/InputCreatable/locale.d.ts +13 -0
- package/src/components/form/components/InputDateRange/InputDateRange.d.ts +16 -1
- package/src/components/form/components/InputDateRange/index.d.ts +2 -0
- package/src/components/form/components/InputDateRange/locale.d.ts +10 -0
- package/src/components/form/components/InputOTP/InputOTP.d.ts +7 -1
- package/src/components/form/components/InputOTP/index.d.ts +2 -0
- package/src/components/form/components/InputOTP/locale.d.ts +10 -0
- package/src/components/form/components/InputResourceList/InputResourceList.d.ts +8 -1
- package/src/components/form/components/InputResourceList/locale.d.ts +17 -0
- package/src/components/form/components/InputSearchbox/locale.d.ts +11 -0
- package/src/components/form/components/InputSelect/index.d.ts +2 -0
- package/src/components/form/components/InputSelect/locale.d.ts +15 -0
- package/src/components/form/components/InputSelectCheck/locale.d.ts +20 -0
- package/src/components/form/components/InputSignature/InputSignature.d.ts +7 -1
- package/src/components/form/components/InputSignature/SignatureModal.d.ts +2 -1
- package/src/components/form/components/InputSignature/index.d.ts +2 -0
- package/src/components/form/components/InputSignature/locale.d.ts +16 -0
- package/src/components/form/components/index.d.ts +4 -0
- package/src/components/image/index.d.ts +2 -0
- package/src/components/image/locale.d.ts +10 -0
- package/src/components/periodSelect/PeriodSelect.d.ts +14 -3
- package/src/components/periodSelect/index.d.ts +2 -0
- package/src/components/periodSelect/locale.d.ts +15 -0
- package/src/components/table/MobileTable.d.ts +1 -0
- package/src/components/table/index.d.ts +2 -0
- package/src/components/table/locale.d.ts +40 -0
- package/src/components/tagList/TagList.d.ts +8 -2
- package/src/components/tagList/index.d.ts +2 -0
- package/src/components/tagList/locale.d.ts +13 -0
- package/src/components/toast/context/locale.d.ts +11 -0
- package/src/config/locale/LocaleContext.d.ts +13 -0
- package/src/config/locale/LocaleTextContext.d.ts +38 -0
- package/src/config/locale/useLocaleText.d.ts +10 -0
|
@@ -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 {
|
|
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([]);
|
|
@@ -437,7 +436,10 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
|
|
|
437
436
|
return setItem(options);
|
|
438
437
|
} else {
|
|
439
438
|
setItem(options.filter(item => {
|
|
440
|
-
|
|
439
|
+
var _a;
|
|
440
|
+
// textSelector can point at a non-string field (numeric id, null), so never
|
|
441
|
+
// assume item.name is a string here.
|
|
442
|
+
const nameIsIncluded = String((_a = item.name) !== null && _a !== void 0 ? _a : '').toLowerCase().includes(value.toLocaleLowerCase());
|
|
441
443
|
if (item.render && isFunction(item.render)) {
|
|
442
444
|
const extractedString = item.render() ? extractStringFromHTML(renderToString(item.render())).join(',') : '';
|
|
443
445
|
return nameIsIncluded || extractedString.toLowerCase().includes(value.toLocaleLowerCase());
|
|
@@ -532,12 +534,23 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
|
|
|
532
534
|
return addedGroupItems;
|
|
533
535
|
}, []));
|
|
534
536
|
}, [item]);
|
|
535
|
-
const stateReducer = (
|
|
537
|
+
const stateReducer = (state, changes) => {
|
|
536
538
|
switch (changes.type) {
|
|
537
539
|
case Downshift.stateChangeTypes.blurButton:
|
|
538
540
|
return {
|
|
539
541
|
isOpen: true
|
|
540
542
|
};
|
|
543
|
+
// Downshift wipes selectedItem on Escape whenever its own isOpen is already false,
|
|
544
|
+
// firing onChange(null) on consumers that never asked to clear the selection.
|
|
545
|
+
// Escape only closes the menu and restores the label of the current selection.
|
|
546
|
+
case Downshift.stateChangeTypes.keyDownEscape:
|
|
547
|
+
{
|
|
548
|
+
const nextChanges = Object.assign(Object.assign({}, changes), {
|
|
549
|
+
inputValue: state.selectedItem ? state.selectedItem.name : ''
|
|
550
|
+
});
|
|
551
|
+
delete nextChanges.selectedItem;
|
|
552
|
+
return nextChanges;
|
|
553
|
+
}
|
|
541
554
|
default:
|
|
542
555
|
return changes;
|
|
543
556
|
}
|
|
@@ -623,7 +636,7 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
|
|
|
623
636
|
showLeadingIcon: showLeadingIcon,
|
|
624
637
|
showClearIcon: hideArrowicon,
|
|
625
638
|
disabled: disabled,
|
|
626
|
-
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder :
|
|
639
|
+
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : text.placeholder,
|
|
627
640
|
readOnly: readOnly,
|
|
628
641
|
handleInputValue: !fetchData ? handleInputValue : query => {
|
|
629
642
|
if (onSearch) onSearch(query);
|
|
@@ -658,7 +671,7 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
|
|
|
658
671
|
}) : jsx(Text, {
|
|
659
672
|
color: "disable",
|
|
660
673
|
css: StyledText,
|
|
661
|
-
children: placeholder !== null && placeholder !== void 0 ? placeholder :
|
|
674
|
+
children: placeholder !== null && placeholder !== void 0 ? placeholder : text.placeholder
|
|
662
675
|
})
|
|
663
676
|
})), handleDownOption()]
|
|
664
677
|
}))
|
|
@@ -727,7 +740,7 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
|
|
|
727
740
|
children: jsx(InputSearchbox, {
|
|
728
741
|
size: 'sm',
|
|
729
742
|
onChange: handleInputValue,
|
|
730
|
-
placeholder: searchPlaceholder !== null && searchPlaceholder !== void 0 ? searchPlaceholder :
|
|
743
|
+
placeholder: searchPlaceholder !== null && searchPlaceholder !== void 0 ? searchPlaceholder : text.searchPlaceholder,
|
|
731
744
|
withDebounce: withDebounce
|
|
732
745
|
})
|
|
733
746
|
}), item.length > 0 || isLoading ? jsx(ConditionalWrapper, {
|
|
@@ -788,7 +801,7 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
|
|
|
788
801
|
verticalAlign: 'text-bottom'
|
|
789
802
|
}
|
|
790
803
|
})
|
|
791
|
-
}), emptyDataMessage ||
|
|
804
|
+
}), emptyDataMessage || text.emptyDataText]
|
|
792
805
|
})
|
|
793
806
|
})]
|
|
794
807
|
}))
|
|
@@ -834,14 +847,14 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
|
|
|
834
847
|
}) : jsx(Text, {
|
|
835
848
|
color: "disable",
|
|
836
849
|
css: StyledText,
|
|
837
|
-
children: placeholder !== null && placeholder !== void 0 ? placeholder :
|
|
850
|
+
children: placeholder !== null && placeholder !== void 0 ? placeholder : text.placeholder
|
|
838
851
|
})
|
|
839
852
|
})), handleDownOption()]
|
|
840
853
|
})), jsxs(ModalDialog, {
|
|
841
854
|
isMobile: true,
|
|
842
855
|
open: isOpen,
|
|
843
856
|
children: [jsx(ModalDialogTitle, {
|
|
844
|
-
children: mobileTitle || placeholder ||
|
|
857
|
+
children: mobileTitle || placeholder || text.placeholder
|
|
845
858
|
}), jsx(ModalDialogContent, {
|
|
846
859
|
css: {
|
|
847
860
|
padding: 0,
|
|
@@ -888,7 +901,7 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
|
|
|
888
901
|
children: jsx(InputSearchbox, {
|
|
889
902
|
size: 'sm',
|
|
890
903
|
onChange: handleInputValue,
|
|
891
|
-
placeholder: searchPlaceholder !== null && searchPlaceholder !== void 0 ? searchPlaceholder :
|
|
904
|
+
placeholder: searchPlaceholder !== null && searchPlaceholder !== void 0 ? searchPlaceholder : text.searchPlaceholder,
|
|
892
905
|
withDebounce: withDebounce
|
|
893
906
|
})
|
|
894
907
|
}), item.length > 0 || isLoading ? jsx(ConditionalWrapper, {
|
|
@@ -941,7 +954,7 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
|
|
|
941
954
|
verticalAlign: 'text-bottom'
|
|
942
955
|
}
|
|
943
956
|
})
|
|
944
|
-
}), emptyDataMessage ||
|
|
957
|
+
}), emptyDataMessage || text.emptyDataText]
|
|
945
958
|
})
|
|
946
959
|
}), renderFooter && typeof renderFooter === 'function' && jsx(StyledFooter, {
|
|
947
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 };
|
|
@@ -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 {
|
|
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 ??
|
|
566
|
+
name: selectAllLabel ?? text.selectAllLabel
|
|
570
567
|
}, ...options] : options);
|
|
571
568
|
} else {
|
|
572
569
|
setItems(isShowSelectAll ? [{
|
|
573
570
|
id: '!all',
|
|
574
|
-
name: selectAllLabel ??
|
|
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 ??
|
|
881
|
+
name: selectAllLabel ?? text.selectAllLabel
|
|
885
882
|
}, ...memoOptions] : memoOptions);
|
|
886
883
|
setInitItems(isShowSelectAll ? [{
|
|
887
884
|
id: '!all',
|
|
888
|
-
name: selectAllLabel ??
|
|
885
|
+
name: selectAllLabel ?? text.selectAllLabel
|
|
889
886
|
}, ...memoOptions] : memoOptions);
|
|
890
887
|
}
|
|
891
|
-
}, [isShowSelectAll, selectAllLabel,
|
|
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 ??
|
|
900
|
+
name: selectAllLabel ?? text.selectAllLabel
|
|
904
901
|
}, ...options] : options);
|
|
905
902
|
setInitItems(isShowSelectAll ? [{
|
|
906
903
|
id: '!all',
|
|
907
|
-
name: selectAllLabel ??
|
|
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 ??
|
|
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 ??
|
|
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 ??
|
|
1093
|
+
name: selectAllLabel ?? text.selectAllLabel
|
|
1097
1094
|
},
|
|
1098
1095
|
index: 0
|
|
1099
1096
|
}),
|
|
1100
1097
|
onRemove: handleRemoveAllItem,
|
|
1101
1098
|
css: tagCss,
|
|
1102
|
-
children: selectAllLabel ??
|
|
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 ?
|
|
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 ||
|
|
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 ||
|
|
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 ??
|
|
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 {
|
|
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:
|
|
108
|
+
children: text.placeholder
|
|
110
109
|
})
|
|
111
110
|
}), jsx(SignatureModal, {
|
|
112
|
-
|
|
111
|
+
text: text,
|
|
113
112
|
open: open,
|
|
114
113
|
onOpenChange: setOpen,
|
|
115
114
|
onSave: handleSave,
|
|
116
115
|
isMobile: isMobile,
|
|
117
|
-
title: title || signatureImage ?
|
|
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
|
-
|
|
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:
|
|
56
|
+
children: text.cancelButton
|
|
57
57
|
})
|
|
58
58
|
}), jsx(Button, {
|
|
59
59
|
size: "sm",
|
|
60
60
|
onClick: handleSave,
|
|
61
|
-
children:
|
|
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 {
|
|
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
|
|
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
|
-
|
|
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:
|
|
115
|
-
week:
|
|
116
|
-
month:
|
|
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 :
|
|
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 };
|