@pnkx-lib/ui 1.9.476 → 1.9.477
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/es/fields/Input.js +36 -31
- package/es/ui/Tabs.js +2 -2
- package/package.json +1 -1
- package/types/components/fields/Input.d.ts +7 -2
package/es/fields/Input.js
CHANGED
|
@@ -1294,6 +1294,7 @@ const Input = (props) => {
|
|
|
1294
1294
|
allowClear,
|
|
1295
1295
|
subLabel,
|
|
1296
1296
|
classNameSubLabel,
|
|
1297
|
+
maxValue,
|
|
1297
1298
|
...restProps
|
|
1298
1299
|
} = props;
|
|
1299
1300
|
const { name, value, onChange, onBlur } = field || {};
|
|
@@ -1320,18 +1321,15 @@ const Input = (props) => {
|
|
|
1320
1321
|
const handleCompositionStart = useCallback(() => {
|
|
1321
1322
|
setIsComposing(true);
|
|
1322
1323
|
}, []);
|
|
1323
|
-
const handleCompositionEnd = useCallback(
|
|
1324
|
-
(
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
},
|
|
1333
|
-
[]
|
|
1334
|
-
);
|
|
1324
|
+
const handleCompositionEnd = useCallback(() => {
|
|
1325
|
+
setIsComposing(false);
|
|
1326
|
+
const input = inputRef.current?.input;
|
|
1327
|
+
if (input) {
|
|
1328
|
+
setTimeout(() => {
|
|
1329
|
+
input.scrollLeft = input.scrollWidth;
|
|
1330
|
+
}, 0);
|
|
1331
|
+
}
|
|
1332
|
+
}, []);
|
|
1335
1333
|
const renderErrorMessage = () => {
|
|
1336
1334
|
if (!errorMessage) return null;
|
|
1337
1335
|
return /* @__PURE__ */ jsx(
|
|
@@ -1359,11 +1357,12 @@ const Input = (props) => {
|
|
|
1359
1357
|
return node;
|
|
1360
1358
|
};
|
|
1361
1359
|
const renderInput = () => {
|
|
1362
|
-
const isNumberInput = type === "number" || type === "money"
|
|
1360
|
+
const isNumberInput = type === "number" || type === "money";
|
|
1363
1361
|
if (isNumberInput) {
|
|
1364
1362
|
return /* @__PURE__ */ jsx(
|
|
1365
1363
|
NumericFormatCustom,
|
|
1366
1364
|
{
|
|
1365
|
+
maxValue,
|
|
1367
1366
|
name,
|
|
1368
1367
|
ref: inputRef,
|
|
1369
1368
|
type,
|
|
@@ -1419,7 +1418,17 @@ const Input = (props) => {
|
|
|
1419
1418
|
if (label && subLabel)
|
|
1420
1419
|
return /* @__PURE__ */ jsxs("div", { className: "label-input-container", children: [
|
|
1421
1420
|
renderLabel(),
|
|
1422
|
-
/* @__PURE__ */ jsx(
|
|
1421
|
+
/* @__PURE__ */ jsx(
|
|
1422
|
+
Label,
|
|
1423
|
+
{
|
|
1424
|
+
label: subLabel,
|
|
1425
|
+
classNameLabel: twMerge(
|
|
1426
|
+
"default-class-name-subLabel",
|
|
1427
|
+
classNameSubLabel
|
|
1428
|
+
),
|
|
1429
|
+
isSubLabel: true
|
|
1430
|
+
}
|
|
1431
|
+
)
|
|
1423
1432
|
] });
|
|
1424
1433
|
return /* @__PURE__ */ jsx(Fragment, {});
|
|
1425
1434
|
};
|
|
@@ -1439,30 +1448,29 @@ const NumericFormatCustom = forwardRef((props, ref) => {
|
|
|
1439
1448
|
type,
|
|
1440
1449
|
prefix,
|
|
1441
1450
|
helperText,
|
|
1442
|
-
|
|
1451
|
+
maxValue = 999999999999999,
|
|
1452
|
+
decimalScale,
|
|
1453
|
+
thousandSeparator,
|
|
1454
|
+
decimalSeparator,
|
|
1443
1455
|
...restProps
|
|
1444
1456
|
} = props;
|
|
1445
1457
|
const isMoney = type === "money";
|
|
1446
|
-
const isIdentity = type === "identity_number";
|
|
1447
|
-
const MAX_VALUE = 999999999999999;
|
|
1448
1458
|
//! Function
|
|
1449
1459
|
const handleValueChange = (values) => {
|
|
1450
|
-
|
|
1451
|
-
if (maxLength && rawValue.length > maxLength) {
|
|
1452
|
-
rawValue = rawValue.substring(0, maxLength);
|
|
1453
|
-
}
|
|
1460
|
+
const { value: value2 } = values;
|
|
1454
1461
|
if (onChange && name) {
|
|
1455
1462
|
onChange({
|
|
1456
1463
|
target: {
|
|
1457
1464
|
name,
|
|
1458
|
-
value:
|
|
1465
|
+
value: value2
|
|
1459
1466
|
}
|
|
1460
1467
|
});
|
|
1461
1468
|
}
|
|
1462
1469
|
if (afterOnChange) {
|
|
1463
|
-
afterOnChange(
|
|
1470
|
+
afterOnChange(value2);
|
|
1464
1471
|
}
|
|
1465
1472
|
};
|
|
1473
|
+
const isSeparatorFormat = isMoney;
|
|
1466
1474
|
//! Render
|
|
1467
1475
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
1468
1476
|
/* @__PURE__ */ jsx(
|
|
@@ -1471,19 +1479,16 @@ const NumericFormatCustom = forwardRef((props, ref) => {
|
|
|
1471
1479
|
customInput: Input$1,
|
|
1472
1480
|
onValueChange: handleValueChange,
|
|
1473
1481
|
value,
|
|
1474
|
-
thousandSeparator:
|
|
1475
|
-
decimalSeparator:
|
|
1476
|
-
decimalScale
|
|
1482
|
+
thousandSeparator: isSeparatorFormat ? "." : thousandSeparator,
|
|
1483
|
+
decimalSeparator: isSeparatorFormat ? "," : decimalSeparator,
|
|
1484
|
+
decimalScale,
|
|
1477
1485
|
allowNegative: false,
|
|
1478
1486
|
valueIsNumericString: true,
|
|
1479
1487
|
getInputRef: ref,
|
|
1480
1488
|
prefix: isMoney ? "$" : prefix,
|
|
1481
1489
|
isAllowed: (values) => {
|
|
1482
|
-
const { floatValue
|
|
1483
|
-
|
|
1484
|
-
return /^\d*$/.test(value2) && (!maxLength || value2.length <= maxLength);
|
|
1485
|
-
}
|
|
1486
|
-
return floatValue === void 0 || floatValue <= MAX_VALUE;
|
|
1490
|
+
const { floatValue } = values;
|
|
1491
|
+
return floatValue === void 0 || floatValue.toString().length <= maxValue;
|
|
1487
1492
|
},
|
|
1488
1493
|
...restProps
|
|
1489
1494
|
}
|
package/es/ui/Tabs.js
CHANGED
|
@@ -23,7 +23,7 @@ const createStoreImpl = (createState) => {
|
|
|
23
23
|
const initialState = state = createState(setState, getState, api);
|
|
24
24
|
return api;
|
|
25
25
|
};
|
|
26
|
-
const createStore = (
|
|
26
|
+
const createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
|
|
27
27
|
|
|
28
28
|
const identity = (arg) => arg;
|
|
29
29
|
function useStore(api, selector = identity) {
|
|
@@ -41,7 +41,7 @@ const createImpl = (createState) => {
|
|
|
41
41
|
Object.assign(useBoundStore, api);
|
|
42
42
|
return useBoundStore;
|
|
43
43
|
};
|
|
44
|
-
const create = (
|
|
44
|
+
const create = (createState) => createState ? createImpl(createState) : createImpl;
|
|
45
45
|
|
|
46
46
|
const useTabStore = create((set) => ({
|
|
47
47
|
activeTabKey: void 0,
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { default as React, JSX } from 'react';
|
|
2
2
|
import { InputProps as InputPropsAntd } from 'antd';
|
|
3
3
|
import { ControllerRenderProps, UseFormStateReturn } from 'react-hook-form';
|
|
4
|
-
type
|
|
5
|
-
type
|
|
4
|
+
type TInputNumberType = "number" | "money";
|
|
5
|
+
type CustomInputTypeAttribute = React.HTMLInputTypeAttribute | TInputNumberType;
|
|
6
6
|
export interface InputProps extends InputPropsAntd {
|
|
7
7
|
field?: ControllerRenderProps<any, any>;
|
|
8
8
|
formState?: UseFormStateReturn<any>;
|
|
@@ -23,6 +23,9 @@ export interface InputProps extends InputPropsAntd {
|
|
|
23
23
|
inputPassword?: boolean;
|
|
24
24
|
subLabel?: string;
|
|
25
25
|
classNameSubLabel?: string;
|
|
26
|
+
maxValue?: number;
|
|
27
|
+
thousandSeparator?: string;
|
|
28
|
+
decimalSeparator?: string;
|
|
26
29
|
}
|
|
27
30
|
export declare const Input: (props: InputProps) => import("react/jsx-runtime").JSX.Element;
|
|
28
31
|
export interface PropsNumberFormat extends Omit<InputProps, "onChange" | "afterOnChange" | "value" | "defaultValue" | "iconStartInput" | "iconEndInput"> {
|
|
@@ -35,5 +38,7 @@ export interface PropsNumberFormat extends Omit<InputProps, "onChange" | "afterO
|
|
|
35
38
|
prefix?: string;
|
|
36
39
|
suffix?: string;
|
|
37
40
|
helperText?: () => JSX.Element | null;
|
|
41
|
+
thousandSeparator?: string;
|
|
42
|
+
decimalSeparator?: string;
|
|
38
43
|
}
|
|
39
44
|
export {};
|