@rahmatsaputra-my-id/react-js-library 0.0.16 → 0.0.18

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.
@@ -14,6 +14,7 @@ export interface ITextInputProps {
14
14
  placeholder?: string;
15
15
  right?: number;
16
16
  rows?: number;
17
+ maxRows?: number;
17
18
  style?: any;
18
19
  styleLabel?: any;
19
20
  styleTextInput?: any;
@@ -21,5 +22,6 @@ export interface ITextInputProps {
21
22
  type?: string;
22
23
  value?: any;
23
24
  isInputRupiah?: boolean;
25
+ isInputNumber?: boolean;
24
26
  handleOnScanQr?: (data?: string | null) => void;
25
27
  }
@@ -8,6 +8,8 @@ export interface IIconOption {
8
8
  edit?: string;
9
9
  exit?: string;
10
10
  filter?: string;
11
+ flag_english?: string;
12
+ flag_indonesia?: string;
11
13
  flash_off?: string;
12
14
  flash_on?: string;
13
15
  history_transaction?: string;
package/dist/index.es.js CHANGED
@@ -420,6 +420,8 @@ var Icons = {
420
420
  edit: "".concat(PATH.IMAGE, "/icon-edit.png"),
421
421
  exit: "".concat(PATH.IMAGE, "/icon-exit.png"),
422
422
  filter: "".concat(PATH.IMAGE, "/icon-filter.png"),
423
+ flag_english: "".concat(PATH.PERSONAL_WEB, "/icon/icon_flag_united_states.png"),
424
+ flag_indonesia: "".concat(PATH.PERSONAL_WEB, "/icon/icon_flag_indonesia.png"),
423
425
  flash_off: "".concat(PATH.IMAGE, "/icon-flash-off.png"),
424
426
  flash_on: "".concat(PATH.IMAGE, "/icon-flash-on.png"),
425
427
  history_transaction: "".concat(PATH.IMAGE, "/icon-history-transaction.png"),
@@ -30215,8 +30217,9 @@ var styles = {
30215
30217
  };
30216
30218
 
30217
30219
  var TextInput = function (_a) {
30218
- var _b = _a.borderColor, borderColor = _b === void 0 ? Colors.grey2 : _b, _c = _a.borderRadius, borderRadius = _c === void 0 ? 4 : _c, _d = _a.bottom, bottom = _d === void 0 ? 0 : _d, _e = _a.center, center = _e === void 0 ? false : _e, _f = _a.label, label = _f === void 0 ? false : _f, _g = _a.labelError, labelError = _g === void 0 ? false : _g, _h = _a.left, left = _h === void 0 ? 0 : _h, _j = _a.multiline, multiline = _j === void 0 ? false : _j, _k = _a.padding, padding = _k === void 0 ? 0 : _k, _l = _a.right, right = _l === void 0 ? 0 : _l, _m = _a.rows, rows = _m === void 0 ? 10 : _m, _o = _a.style, style = _o === void 0 ? {} : _o, _p = _a.styleLabel, styleLabel = _p === void 0 ? {} : _p, _q = _a.styleTextInput, styleTextInput = _q === void 0 ? {} : _q, _r = _a.top, top = _r === void 0 ? 0 : _r, value = _a.value, onChange = _a.onChange, handleOnScanQr = _a.handleOnScanQr, _s = _a.isInputRupiah, isInputRupiah = _s === void 0 ? false : _s, props = __rest(_a, ["borderColor", "borderRadius", "bottom", "center", "label", "labelError", "left", "multiline", "padding", "right", "rows", "style", "styleLabel", "styleTextInput", "top", "value", "onChange", "handleOnScanQr", "isInputRupiah"]);
30219
- var _t = useState(false), isScannerVisible = _t[0], setIsScannerVisible = _t[1];
30220
+ var _b = _a.borderColor, borderColor = _b === void 0 ? Colors.grey2 : _b, _c = _a.borderRadius, borderRadius = _c === void 0 ? 4 : _c, _d = _a.bottom, bottom = _d === void 0 ? 0 : _d, _e = _a.center, center = _e === void 0 ? false : _e, _f = _a.label, label = _f === void 0 ? false : _f, _g = _a.labelError, labelError = _g === void 0 ? false : _g, _h = _a.left, left = _h === void 0 ? 0 : _h, _j = _a.multiline, multiline = _j === void 0 ? false : _j, _k = _a.padding, padding = _k === void 0 ? 0 : _k, _l = _a.right, right = _l === void 0 ? 0 : _l, _m = _a.rows, rows = _m === void 0 ? 1 : _m, _o = _a.maxRows, maxRows = _o === void 0 ? 4 : _o, _p = _a.style, style = _p === void 0 ? {} : _p, _q = _a.styleLabel, styleLabel = _q === void 0 ? {} : _q, _r = _a.styleTextInput, styleTextInput = _r === void 0 ? {} : _r, _s = _a.top, top = _s === void 0 ? 0 : _s, value = _a.value, onChange = _a.onChange, handleOnScanQr = _a.handleOnScanQr, _t = _a.isInputRupiah, isInputRupiah = _t === void 0 ? false : _t, _u = _a.isInputNumber, isInputNumber = _u === void 0 ? false : _u, props = __rest(_a, ["borderColor", "borderRadius", "bottom", "center", "label", "labelError", "left", "multiline", "padding", "right", "rows", "maxRows", "style", "styleLabel", "styleTextInput", "top", "value", "onChange", "handleOnScanQr", "isInputRupiah", "isInputNumber"]);
30221
+ var _v = useState(false), isScannerVisible = _v[0], setIsScannerVisible = _v[1];
30222
+ var textAreaRef = useRef(null);
30220
30223
  var formatRupiahDisplay = function (val) {
30221
30224
  if (!val)
30222
30225
  return '';
@@ -30227,6 +30230,13 @@ var TextInput = function (_a) {
30227
30230
  var handleChange = function (event) {
30228
30231
  var _a;
30229
30232
  var inputVal = ((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.value) || '';
30233
+ if (isInputNumber) {
30234
+ inputVal = inputVal.replace(/\D/g, '');
30235
+ event.target.value = inputVal;
30236
+ }
30237
+ if (multiline && textAreaRef.current) {
30238
+ autoResize(textAreaRef.current);
30239
+ }
30230
30240
  if (isInputRupiah) {
30231
30241
  var numericVal = parseRupiahValue(inputVal);
30232
30242
  var formatted = formatRupiahDisplay(numericVal);
@@ -30237,9 +30247,23 @@ var TextInput = function (_a) {
30237
30247
  onChange(event);
30238
30248
  }
30239
30249
  };
30240
- var adjustedStyleTextInput = __assign(__assign({}, styleTextInput), { paddingRight: handleOnScanQr ? 40 : styleTextInput.paddingRight });
30250
+ var autoResize = function (el) {
30251
+ el.style.height = 'auto';
30252
+ var lineHeight = parseInt(window.getComputedStyle(el).lineHeight || '20', 10);
30253
+ var maxHeight = lineHeight * maxRows;
30254
+ var newHeight = Math.min(el.scrollHeight, maxHeight);
30255
+ el.style.height = "".concat(newHeight, "px");
30256
+ el.style.overflowY = el.scrollHeight > maxHeight ? 'auto' : 'hidden';
30257
+ };
30258
+ useEffect(function () {
30259
+ if (multiline && textAreaRef.current) {
30260
+ autoResize(textAreaRef.current);
30261
+ }
30262
+ }, [value, multiline]);
30263
+ var adjustedStyleTextInput = __assign(__assign({}, styleTextInput), { paddingRight: handleOnScanQr ? 40 : styleTextInput.paddingRight, resize: 'none' });
30241
30264
  var stylesTextInput = __assign(__assign({ borderColor: borderColor, borderRadius: borderRadius, textAlign: center ? 'center' : 'left', paddingBottom: multiline ? 16 : 8 }, styles.textArea), adjustedStyleTextInput);
30242
- return (jsxs(Fragment, { children: [jsxs(View, __assign({ style: styles.container }, { children: [jsxs(View, __assign({ style: __assign({ marginTop: top, marginRight: right, marginBottom: bottom, marginLeft: left, padding: padding }, style) }, { children: [label && (jsx(Text, { style: __assign(__assign({}, styles.label), styleLabel), children: label })), jsx(View, { children: multiline ? (jsx("textarea", __assign({ rows: rows, type: "text", style: stylesTextInput, value: isInputRupiah ? formatRupiahDisplay(value) : value !== null && value !== void 0 ? value : '', onChange: handleChange }, props))) : (jsx("input", __assign({ type: "text", style: stylesTextInput, value: isInputRupiah ? formatRupiahDisplay(value) : value !== null && value !== void 0 ? value : '', onChange: handleChange }, props))) }), labelError ? (jsx(Text, { style: styles.labelError, children: labelError })) : null] })), handleOnScanQr && (jsx(TouchableOpacity, __assign({ style: label
30265
+ var inputType = isInputRupiah || isInputNumber ? 'tel' : 'text';
30266
+ return (jsxs(Fragment, { children: [jsxs(View, __assign({ style: styles.container }, { children: [jsxs(View, __assign({ style: __assign({ marginTop: top, marginRight: right, marginBottom: bottom, marginLeft: left, padding: padding }, style) }, { children: [label && (jsx(Text, { style: __assign(__assign({}, styles.label), styleLabel), children: label })), jsx(View, { children: multiline ? (jsx("textarea", __assign({ ref: textAreaRef, rows: rows, inputMode: isInputNumber ? 'numeric' : 'text', style: stylesTextInput, value: isInputRupiah ? formatRupiahDisplay(value) : value !== null && value !== void 0 ? value : '', onChange: handleChange }, props))) : (jsx("input", __assign({ type: inputType, inputMode: isInputNumber ? 'numeric' : 'text', style: stylesTextInput, value: isInputRupiah ? formatRupiahDisplay(value) : value !== null && value !== void 0 ? value : '', onChange: handleChange }, props))) }), labelError ? (jsx(Text, { style: styles.labelError, children: labelError })) : null] })), handleOnScanQr && (jsx(TouchableOpacity, __assign({ style: label
30243
30267
  ? styles.scanQrImageContainerWithLabel
30244
30268
  : styles.scanQrImageContainer, onPress: function () {
30245
30269
  handleOnScanQr();