@cripty2001/utils 0.0.126 → 0.0.128
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/dist/react-ui/form.js +13 -3
- package/dist/react-whispr.js +16 -1
- package/package.json +1 -1
package/dist/react-ui/form.js
CHANGED
|
@@ -18,17 +18,27 @@ function FormComponent(props) {
|
|
|
18
18
|
...prev,
|
|
19
19
|
[input.key]: v
|
|
20
20
|
}));
|
|
21
|
+
const baseProps = {
|
|
22
|
+
label: input.label,
|
|
23
|
+
value: value,
|
|
24
|
+
setValue: setValue,
|
|
25
|
+
variant: "default",
|
|
26
|
+
variants: variants,
|
|
27
|
+
key: index,
|
|
28
|
+
required: input.required,
|
|
29
|
+
icon: input.icon,
|
|
30
|
+
};
|
|
21
31
|
switch (input.type) {
|
|
22
32
|
case "text":
|
|
23
33
|
case "email":
|
|
24
34
|
case "password":
|
|
25
35
|
case "tel":
|
|
26
|
-
return (0, jsx_runtime_1.jsx)(input_1.default, {
|
|
36
|
+
return (0, jsx_runtime_1.jsx)(input_1.default, { ...baseProps, children: ({ value, setValue, className }) => ((0, jsx_runtime_1.jsx)("input", { type: input.type, value: value, onChange: (e) => setValue(e.target.value), required: input.required, className: className, placeholder: input.label })) });
|
|
27
37
|
case "select":
|
|
28
|
-
return (0, jsx_runtime_1.jsx)(input_1.default, {
|
|
38
|
+
return (0, jsx_runtime_1.jsx)(input_1.default, { ...baseProps, required: input.required, validate: (v) => {
|
|
29
39
|
if (!input.options.includes(v))
|
|
30
40
|
throw new Error("Invalid option");
|
|
31
|
-
}, children: ({ value, setValue, className }) => ((0, jsx_runtime_1.jsx)("select", { value: value, onChange: (e) => setValue(e.target.value), required: input.required, className: className, children: input.options.map(option => ((0, jsx_runtime_1.jsx)("option", { value: option, children: option }, option))) })) }
|
|
41
|
+
}, children: ({ value, setValue, className }) => ((0, jsx_runtime_1.jsx)("select", { value: value, onChange: (e) => setValue(e.target.value), required: input.required, className: className, children: input.options.map(option => ((0, jsx_runtime_1.jsx)("option", { value: option, children: option }, option))) })) });
|
|
32
42
|
default:
|
|
33
43
|
return (0, jsx_runtime_1.jsx)("div", { style: { color: '#ef4444', backgroundColor: 'white' }, children: "Unknown input type" });
|
|
34
44
|
}
|
package/dist/react-whispr.js
CHANGED
|
@@ -171,7 +171,22 @@ function useRelTime(refresh = 1000) {
|
|
|
171
171
|
const then = ts instanceof Date ? ts.getTime() : ts;
|
|
172
172
|
const delta = then - now;
|
|
173
173
|
const seconds = Math.round(delta / 1000);
|
|
174
|
-
|
|
174
|
+
const format = (() => {
|
|
175
|
+
if (seconds < 60)
|
|
176
|
+
return "second";
|
|
177
|
+
if (seconds < 3600)
|
|
178
|
+
return "minute";
|
|
179
|
+
if (seconds < 86400)
|
|
180
|
+
return "hour";
|
|
181
|
+
if (seconds < 604800)
|
|
182
|
+
return "day";
|
|
183
|
+
if (seconds < 2592000)
|
|
184
|
+
return "week";
|
|
185
|
+
if (seconds < 31536000)
|
|
186
|
+
return "month";
|
|
187
|
+
return "year";
|
|
188
|
+
})();
|
|
189
|
+
return rtf.format(seconds, format);
|
|
175
190
|
}, [currTs, rtf]);
|
|
176
191
|
return cb;
|
|
177
192
|
}
|
package/package.json
CHANGED