@majoo-ui/react 1.57.11 → 1.57.13
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.
|
@@ -62,6 +62,10 @@ interface EditableTableProps<Data extends object> {
|
|
|
62
62
|
* expanded row callback.
|
|
63
63
|
*/
|
|
64
64
|
onExpand?: (expanded: boolean) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Override isMobile condition
|
|
67
|
+
*/
|
|
68
|
+
isMobileLayout?: boolean;
|
|
65
69
|
}
|
|
66
70
|
interface RemoveProps {
|
|
67
71
|
position?: 'leftBottom' | 'rightBottom' | 'leftTop' | 'rightTop';
|
|
@@ -587,7 +587,7 @@ export declare const SelectItem: import("@stitches/react/types/styled-component"
|
|
|
587
587
|
backgroundColor: string;
|
|
588
588
|
};
|
|
589
589
|
}>>;
|
|
590
|
-
export declare const SelectInputSearch: React.ForwardRefExoticComponent<Pick<any, string | number | symbol> & React.RefAttributes<HTMLInputElement
|
|
590
|
+
export declare const SelectInputSearch: React.ForwardRefExoticComponent<Pick<any, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
|
|
591
591
|
export declare type Option = {
|
|
592
592
|
value: string;
|
|
593
593
|
name: string;
|
|
@@ -713,5 +713,5 @@ interface InputSelectProps extends Omit<DownshiftProps<Option>, 'initialSelected
|
|
|
713
713
|
*/
|
|
714
714
|
renderFooter?: () => React.ReactNode;
|
|
715
715
|
}
|
|
716
|
-
declare
|
|
716
|
+
export declare function InputSelect({ 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, ...props }: InputSelectProps): JSX.Element;
|
|
717
717
|
export default InputSelect;
|
package/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import React__default, { useState, useEffect, createContext, useContext, useRef, useCallback, cloneElement,
|
|
2
|
+
import React__default, { useState, useEffect, createContext, useContext, useRef, useCallback, cloneElement, createElement as createElement$2, forwardRef, useLayoutEffect, useReducer, useMemo, memo } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { createStitches, styled as styled$1 } from '@stitches/react';
|
|
5
5
|
import { foundations } from '@majoo-ui/core';
|
|
@@ -7187,7 +7187,6 @@ const InputNumber = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
7187
7187
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$i);
|
|
7188
7188
|
return /*#__PURE__*/React__default.createElement(StyledInput, _extends({
|
|
7189
7189
|
ref: ref,
|
|
7190
|
-
getInputRef: ref,
|
|
7191
7190
|
placeholder: placeholder,
|
|
7192
7191
|
value: value,
|
|
7193
7192
|
size: size,
|
|
@@ -9101,7 +9100,7 @@ const SelectInputSearch = /*#__PURE__*/React.forwardRef((_a, forwardedRef) => {
|
|
|
9101
9100
|
}, void 0)]
|
|
9102
9101
|
}), void 0);
|
|
9103
9102
|
});
|
|
9104
|
-
|
|
9103
|
+
function InputSelect(_a) {
|
|
9105
9104
|
var {
|
|
9106
9105
|
option,
|
|
9107
9106
|
onChange,
|
|
@@ -9183,7 +9182,7 @@ const InputSelect = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
|
9183
9182
|
setItem(generatedOption);
|
|
9184
9183
|
setOptions(generatedOption);
|
|
9185
9184
|
}, [option, disabledOptions, valueSelector, textSelector]);
|
|
9186
|
-
const debouncedSearch = React.useRef(debounce(query => __awaiter(
|
|
9185
|
+
const debouncedSearch = React.useRef(debounce(query => __awaiter(this, void 0, void 0, function* () {
|
|
9187
9186
|
setQuery(query);
|
|
9188
9187
|
if (onSearch) onSearch(query);
|
|
9189
9188
|
}), 1000)).current;
|
|
@@ -9269,7 +9268,6 @@ const InputSelect = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
|
9269
9268
|
}
|
|
9270
9269
|
}, {
|
|
9271
9270
|
children: jsx(SelectInputSearch, {
|
|
9272
|
-
ref: ref,
|
|
9273
9271
|
showLeadingIcon: showLeadingIcon,
|
|
9274
9272
|
showClearIcon: hideArrowicon,
|
|
9275
9273
|
disabled: disabled,
|
|
@@ -9294,7 +9292,6 @@ const InputSelect = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
|
9294
9292
|
}), void 0) : jsx(Button$3, Object.assign({}, getToggleButtonProps({
|
|
9295
9293
|
disabled: disabled || readOnly
|
|
9296
9294
|
}), {
|
|
9297
|
-
ref: ref,
|
|
9298
9295
|
disabled: disabled,
|
|
9299
9296
|
size: size,
|
|
9300
9297
|
readOnly: readOnly,
|
|
@@ -9453,7 +9450,7 @@ const InputSelect = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
|
9453
9450
|
}), void 0);
|
|
9454
9451
|
}
|
|
9455
9452
|
}), void 0);
|
|
9456
|
-
}
|
|
9453
|
+
}
|
|
9457
9454
|
|
|
9458
9455
|
var tryToString$3 = tryToString$5;
|
|
9459
9456
|
|
|
@@ -11344,7 +11341,7 @@ const InputSelectCheck = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
11344
11341
|
}
|
|
11345
11342
|
}
|
|
11346
11343
|
});
|
|
11347
|
-
const getOption = useCallback(() => option === null || option === void 0 ? void 0 : option.map(item => {
|
|
11344
|
+
const getOption = maxSelectedItem ? useCallback(() => option === null || option === void 0 ? void 0 : option.map(item => {
|
|
11348
11345
|
const isMaxSelectedItem = maxSelectedItem && (selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.length) >= maxSelectedItem;
|
|
11349
11346
|
if (isMaxSelectedItem && !(selectedValue !== null && selectedValue !== void 0 && selectedValue.includes(item.id))) {
|
|
11350
11347
|
item.hideCheck = true;
|
|
@@ -11354,7 +11351,7 @@ const InputSelectCheck = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
11354
11351
|
item.isDisabled = false;
|
|
11355
11352
|
}
|
|
11356
11353
|
return item;
|
|
11357
|
-
}), [maxSelectedItem, option, selectedValue]);
|
|
11354
|
+
}), [maxSelectedItem, option, selectedValue]) : () => option;
|
|
11358
11355
|
useEffect(() => {
|
|
11359
11356
|
sortItems();
|
|
11360
11357
|
setItems(isShowSelectAll ? [{
|
|
@@ -11365,7 +11362,7 @@ const InputSelectCheck = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
11365
11362
|
id: '!all',
|
|
11366
11363
|
name: selectAllLabel != null ? selectAllLabel : t('selectAllLabelText', 'Pilih Semua')
|
|
11367
11364
|
}, ...getOption()] : getOption());
|
|
11368
|
-
}, [
|
|
11365
|
+
}, [option, isShowSelectAll]);
|
|
11369
11366
|
useEffect(() => {
|
|
11370
11367
|
if (selectedValue.length > 0 && disabledOptions.length === 0) {
|
|
11371
11368
|
setInitItems(sortValue);
|
|
@@ -47512,7 +47509,8 @@ function EditableTable(props) {
|
|
|
47512
47509
|
getCheckboxProps,
|
|
47513
47510
|
keyId = 'id',
|
|
47514
47511
|
selectedIds,
|
|
47515
|
-
onExpand
|
|
47512
|
+
onExpand,
|
|
47513
|
+
isMobileLayout
|
|
47516
47514
|
} = props;
|
|
47517
47515
|
const {
|
|
47518
47516
|
t
|
|
@@ -47585,7 +47583,7 @@ function EditableTable(props) {
|
|
|
47585
47583
|
});
|
|
47586
47584
|
}
|
|
47587
47585
|
}, [selectedRowIds, data, onSelectedChange, selectedIndex]);
|
|
47588
|
-
const
|
|
47586
|
+
const isMobile = useMediaQuery(isMobileLayout === undefined ? '(max-width: 767px)' : isMobileLayout ? '(max-width: 8000px)' : '(max-width: 0px)');
|
|
47589
47587
|
const getCustomRows = (row, renderRow) => {
|
|
47590
47588
|
var _a;
|
|
47591
47589
|
let customStyle = {};
|
|
@@ -47637,7 +47635,7 @@ function EditableTable(props) {
|
|
|
47637
47635
|
})
|
|
47638
47636
|
}), void 0);
|
|
47639
47637
|
};
|
|
47640
|
-
return
|
|
47638
|
+
return !isMobile ? jsx(TableContainer$1, Object.assign({
|
|
47641
47639
|
css: props === null || props === void 0 ? void 0 : props.css
|
|
47642
47640
|
}, {
|
|
47643
47641
|
children: jsxs(TableContent$1, Object.assign({}, getTableProps(), {
|
package/index.umd.js
CHANGED
|
@@ -7271,7 +7271,6 @@
|
|
|
7271
7271
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$i);
|
|
7272
7272
|
return /*#__PURE__*/React__default["default"].createElement(StyledInput, _extends({
|
|
7273
7273
|
ref: ref,
|
|
7274
|
-
getInputRef: ref,
|
|
7275
7274
|
placeholder: placeholder,
|
|
7276
7275
|
value: value,
|
|
7277
7276
|
size: size,
|
|
@@ -9183,7 +9182,8 @@
|
|
|
9183
9182
|
}, void 0)]
|
|
9184
9183
|
}), void 0);
|
|
9185
9184
|
});
|
|
9186
|
-
|
|
9185
|
+
function InputSelect(_a) {
|
|
9186
|
+
var _this = this;
|
|
9187
9187
|
var option = _a.option,
|
|
9188
9188
|
onChange = _a.onChange,
|
|
9189
9189
|
value = _a.value,
|
|
@@ -9297,7 +9297,7 @@
|
|
|
9297
9297
|
setOptions(generatedOption);
|
|
9298
9298
|
}, [option, disabledOptions, valueSelector, textSelector]);
|
|
9299
9299
|
var debouncedSearch = React__namespace.useRef(debounce__default["default"](function (query) {
|
|
9300
|
-
return __awaiter(
|
|
9300
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
9301
9301
|
return __generator(this, function (_a) {
|
|
9302
9302
|
setQuery(query);
|
|
9303
9303
|
if (onSearch) onSearch(query);
|
|
@@ -9392,7 +9392,6 @@
|
|
|
9392
9392
|
}
|
|
9393
9393
|
}, {
|
|
9394
9394
|
children: jsxRuntime.jsx(SelectInputSearch, {
|
|
9395
|
-
ref: ref,
|
|
9396
9395
|
showLeadingIcon: showLeadingIcon,
|
|
9397
9396
|
showClearIcon: hideArrowicon,
|
|
9398
9397
|
disabled: disabled,
|
|
@@ -9417,7 +9416,6 @@
|
|
|
9417
9416
|
}), void 0) : jsxRuntime.jsx(Button$3, __assign({}, getToggleButtonProps({
|
|
9418
9417
|
disabled: disabled || readOnly
|
|
9419
9418
|
}), {
|
|
9420
|
-
ref: ref,
|
|
9421
9419
|
disabled: disabled,
|
|
9422
9420
|
size: size,
|
|
9423
9421
|
readOnly: readOnly,
|
|
@@ -9580,7 +9578,7 @@
|
|
|
9580
9578
|
}), void 0);
|
|
9581
9579
|
}
|
|
9582
9580
|
}), void 0);
|
|
9583
|
-
}
|
|
9581
|
+
}
|
|
9584
9582
|
|
|
9585
9583
|
var tryToString$3 = tryToString$5;
|
|
9586
9584
|
|
|
@@ -11493,7 +11491,7 @@
|
|
|
11493
11491
|
}
|
|
11494
11492
|
}
|
|
11495
11493
|
});
|
|
11496
|
-
const getOption = React.useCallback(() => option === null || option === void 0 ? void 0 : option.map(item => {
|
|
11494
|
+
const getOption = maxSelectedItem ? React.useCallback(() => option === null || option === void 0 ? void 0 : option.map(item => {
|
|
11497
11495
|
const isMaxSelectedItem = maxSelectedItem && (selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.length) >= maxSelectedItem;
|
|
11498
11496
|
if (isMaxSelectedItem && !(selectedValue !== null && selectedValue !== void 0 && selectedValue.includes(item.id))) {
|
|
11499
11497
|
item.hideCheck = true;
|
|
@@ -11503,7 +11501,7 @@
|
|
|
11503
11501
|
item.isDisabled = false;
|
|
11504
11502
|
}
|
|
11505
11503
|
return item;
|
|
11506
|
-
}), [maxSelectedItem, option, selectedValue]);
|
|
11504
|
+
}), [maxSelectedItem, option, selectedValue]) : () => option;
|
|
11507
11505
|
React.useEffect(() => {
|
|
11508
11506
|
sortItems();
|
|
11509
11507
|
setItems(isShowSelectAll ? [{
|
|
@@ -11514,7 +11512,7 @@
|
|
|
11514
11512
|
id: '!all',
|
|
11515
11513
|
name: selectAllLabel != null ? selectAllLabel : t('selectAllLabelText', 'Pilih Semua')
|
|
11516
11514
|
}, ...getOption()] : getOption());
|
|
11517
|
-
}, [
|
|
11515
|
+
}, [option, isShowSelectAll]);
|
|
11518
11516
|
React.useEffect(() => {
|
|
11519
11517
|
if (selectedValue.length > 0 && disabledOptions.length === 0) {
|
|
11520
11518
|
setInitItems(sortValue);
|
|
@@ -47930,7 +47928,8 @@
|
|
|
47930
47928
|
_a = props.keyId,
|
|
47931
47929
|
keyId = _a === void 0 ? 'id' : _a,
|
|
47932
47930
|
selectedIds = props.selectedIds,
|
|
47933
|
-
onExpand = props.onExpand
|
|
47931
|
+
onExpand = props.onExpand,
|
|
47932
|
+
isMobileLayout = props.isMobileLayout;
|
|
47934
47933
|
var t = reactI18next.useTranslation('translation').t;
|
|
47935
47934
|
var _b = React.useState(null),
|
|
47936
47935
|
selectedIndex = _b[0],
|
|
@@ -48002,7 +48001,7 @@
|
|
|
48002
48001
|
});
|
|
48003
48002
|
}
|
|
48004
48003
|
}, [selectedRowIds, data, onSelectedChange, selectedIndex]);
|
|
48005
|
-
var
|
|
48004
|
+
var isMobile = useMediaQuery(isMobileLayout === undefined ? '(max-width: 767px)' : isMobileLayout ? '(max-width: 8000px)' : '(max-width: 0px)');
|
|
48006
48005
|
var getCustomRows = function getCustomRows(row, renderRow) {
|
|
48007
48006
|
var _a;
|
|
48008
48007
|
var customStyle = {};
|
|
@@ -48057,7 +48056,7 @@
|
|
|
48057
48056
|
})
|
|
48058
48057
|
}), void 0);
|
|
48059
48058
|
};
|
|
48060
|
-
return
|
|
48059
|
+
return !isMobile ? jsxRuntime.jsx(TableContainer$1, __assign({
|
|
48061
48060
|
css: props === null || props === void 0 ? void 0 : props.css
|
|
48062
48061
|
}, {
|
|
48063
48062
|
children: jsxRuntime.jsxs(TableContent$1, __assign({}, getTableProps(), {
|