@kanda-libs/ks-component-ts 0.3.56 → 0.3.58
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/app/src/App.tsx +12 -49
- package/dist/index.d.ts +13796 -13794
- package/dist/index.esm.js +4 -4
- package/dist/index.esm.js.map +3 -3
- package/package.json +1 -1
- package/src/field/components/RangeInput/RangeInputUncontrolled.tsx +40 -14
- package/src/field/components/RangeInput/constants.ts +6 -0
- package/src/field/components/RangeInput/useRangeInputProps.ts +145 -31
- package/src/generated/widget/index.tsx +63142 -63142
package/app/src/App.tsx
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
FormTheme,
|
|
14
14
|
} from "@kanda-libs/ks-component-ts";
|
|
15
15
|
import { StringIndexedObject } from "~/types";
|
|
16
|
-
import { useEffect, useState } from "react";
|
|
16
|
+
import { useCallback, useEffect, useState } from "react";
|
|
17
17
|
import { Button } from "@kanda-libs/ks-design-library";
|
|
18
18
|
|
|
19
19
|
if (!(Window.prototype as StringIndexedObject).setImmediate) {
|
|
@@ -22,50 +22,21 @@ if (!(Window.prototype as StringIndexedObject).setImmediate) {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
interface FormValues {
|
|
26
|
+
range: string;
|
|
27
|
+
}
|
|
26
28
|
|
|
27
29
|
function App() {
|
|
28
|
-
const form = useForm({
|
|
30
|
+
const form = useForm<FormValues>({
|
|
29
31
|
mode: "onBlur",
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const { watch, setValue } = form;
|
|
33
|
-
const { range1, range2 } = watch();
|
|
34
|
-
|
|
35
|
-
const onSubmit = (data: StringIndexedObject) => console.log({ data });
|
|
36
|
-
const [query, setQuery] = useState("");
|
|
37
|
-
|
|
38
|
-
const validateRange = (
|
|
39
|
-
value: string | number | boolean | undefined
|
|
40
|
-
): boolean => {
|
|
41
|
-
const v = `${value}`;
|
|
42
|
-
const test = parseInt(v, 10);
|
|
43
|
-
if (test < 50000) return false;
|
|
44
|
-
return true;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const validation: ValidationItems = {
|
|
48
|
-
validate: {
|
|
49
|
-
value: (value: string | number | boolean | undefined) =>
|
|
50
|
-
validateRange(value),
|
|
51
|
-
message: "Must be between over £500",
|
|
32
|
+
defaultValues: {
|
|
33
|
+
range: "65432",
|
|
52
34
|
},
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const formatter = (value: string) => {
|
|
56
|
-
const pounds = new Intl.NumberFormat("en-BG", {
|
|
57
|
-
style: "currency",
|
|
58
|
-
currency: "GBP",
|
|
59
|
-
}).format(parseInt(value) / 100);
|
|
60
|
-
return pounds;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const [isLoading, setIsLoading] = useState<boolean>(false);
|
|
35
|
+
});
|
|
64
36
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}, [range1]);
|
|
37
|
+
const onSubmit = useCallback((values: StringIndexedObject<FormValues>) => {
|
|
38
|
+
console.log({ values });
|
|
39
|
+
}, []);
|
|
69
40
|
|
|
70
41
|
return (
|
|
71
42
|
<div style={{ maxWidth: 500 }}>
|
|
@@ -76,15 +47,7 @@ function App() {
|
|
|
76
47
|
onSubmit={onSubmit}
|
|
77
48
|
className="flex flex-col p-6 bg-neutral-100"
|
|
78
49
|
>
|
|
79
|
-
<
|
|
80
|
-
<Widget.JobCustomerPhone className="bg-neutral-000 mb-10" />
|
|
81
|
-
</FormTheme>
|
|
82
|
-
<FormTheme variant="default">
|
|
83
|
-
<Widget.JobCustomerPhone
|
|
84
|
-
className="bg-neutral-000"
|
|
85
|
-
name="defaultphone"
|
|
86
|
-
/>
|
|
87
|
-
</FormTheme>
|
|
50
|
+
<Field.RangeInput name="range" min="50001" max="100000" />
|
|
88
51
|
<Button.Text
|
|
89
52
|
submit
|
|
90
53
|
label="submit"
|