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