@bouko/react 2.7.7 → 2.7.9
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.
|
@@ -4,13 +4,14 @@ type FieldProps<T> = {
|
|
|
4
4
|
label?: string;
|
|
5
5
|
style?: string;
|
|
6
6
|
value?: T;
|
|
7
|
-
update
|
|
7
|
+
update?: (x: T) => void;
|
|
8
|
+
updateForm?: (id: string, x: T) => void;
|
|
8
9
|
required?: boolean;
|
|
9
10
|
disabled?: boolean;
|
|
10
11
|
note?: ReactNode;
|
|
11
12
|
};
|
|
12
13
|
type Variant = "normal" | "ghost";
|
|
13
|
-
type Props =
|
|
14
|
+
type Props<T> = FieldProps<T> & {
|
|
14
15
|
type?: "text" | "number" | "email" | "password";
|
|
15
16
|
variant?: Variant;
|
|
16
17
|
style?: string;
|
|
@@ -34,5 +35,5 @@ type Props = Omit<FieldProps<string>, "id"> & {
|
|
|
34
35
|
* @param {string} placeholder - Placeholder text for the input. (optional)
|
|
35
36
|
* @param {Function} onEnter - Callback when `Enter` key is pressed. (optional)
|
|
36
37
|
**/
|
|
37
|
-
export default function Input({ type, variant, style, value, update, onEnter, disabled, placeholder, ...props }: Props): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
export default function Input<T>({ id, type, variant, style, value, update, updateForm, onEnter, disabled, placeholder, ...props }: Props<T>): import("react/jsx-runtime").JSX.Element;
|
|
38
39
|
export {};
|
package/dist/components/input.js
CHANGED
|
@@ -25,8 +25,14 @@ const fieldStyles = {
|
|
|
25
25
|
* @param {string} placeholder - Placeholder text for the input. (optional)
|
|
26
26
|
* @param {Function} onEnter - Callback when `Enter` key is pressed. (optional)
|
|
27
27
|
**/
|
|
28
|
-
export default function Input({ type = "text", variant, style, value, update, onEnter, disabled, placeholder, ...props }) {
|
|
29
|
-
|
|
28
|
+
export default function Input({ id, type = "text", variant, style, value, update, updateForm, onEnter, disabled, placeholder, ...props }) {
|
|
29
|
+
const handleUpdate = (value) => {
|
|
30
|
+
if (id && updateForm)
|
|
31
|
+
updateForm(id, value);
|
|
32
|
+
else if (update)
|
|
33
|
+
update(value);
|
|
34
|
+
};
|
|
35
|
+
return (_jsx(Field, { ...props, children: _jsx("input", { type: type, className: cn(styles({ variant }), style), placeholder: placeholder, value: value, onChange: ({ target: { value } }) => handleUpdate(value), onKeyUp: ({ key }) => key === "Enter" && value ? onEnter?.(value) : null, disabled: disabled }) }));
|
|
30
36
|
}
|
|
31
37
|
const styles = tv({
|
|
32
38
|
base: "px-3 py-2 duration-200 rounded text-xs sm:text-sm placeholder:text-primary-darker text-primary disabled:brightness-90 disabled:cursor-not-allowed",
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "@bouko/style";
|
|
3
|
+
const ProgressBar = ({ style, progress }) => (_jsx("div", { className: cn(styles.container, style), children: _jsx("div", { className: styles.filled, style: { width: (progress * 100) + "%" } }) }));
|
|
4
|
+
const styles = {
|
|
5
|
+
container: "flex grow h-1 rounded-full bg-gray-800/70 overflow-hidden",
|
|
6
|
+
filled: "h-full bg-accent"
|
|
7
|
+
};
|
|
8
|
+
export default ProgressBar;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { default as MultipleChoice } from "./components/multiple-choice";
|
|
|
5
5
|
export { default as Attachment } from "./components/attachment";
|
|
6
6
|
export { default as CheckBox } from "./components/checkbox";
|
|
7
7
|
export { default as FadeCarousel } from "./components/fade-carousel";
|
|
8
|
+
export { default as ProgressBar } from "./components/progress";
|
|
8
9
|
export * from "./components";
|
|
9
10
|
export * from "./components/search-bar";
|
|
10
11
|
export * from "./core/types";
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export { default as MultipleChoice } from "./components/multiple-choice";
|
|
|
5
5
|
export { default as Attachment } from "./components/attachment";
|
|
6
6
|
export { default as CheckBox } from "./components/checkbox";
|
|
7
7
|
export { default as FadeCarousel } from "./components/fade-carousel";
|
|
8
|
+
export { default as ProgressBar } from "./components/progress";
|
|
8
9
|
export * from "./components";
|
|
9
10
|
export * from "./components/search-bar";
|
|
10
11
|
export * from "./core/types";
|