@rackbops/ui-react 0.2.20 → 0.2.21
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/feedback.js +11 -6
- package/dist/form.js +23 -28
- package/package.json +1 -1
package/dist/feedback.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, } from "react";
|
|
2
|
+
import { createElement, forwardRef, } from "react";
|
|
3
3
|
import { cx } from "./cx.js";
|
|
4
|
+
/** A forwardRef DOM wrapper that adds a base rb-* class and any fixed static attributes. */
|
|
5
|
+
function styled(tag, cls, attrs = {}) {
|
|
6
|
+
return forwardRef(function Styled({ className, ...rest }, ref) {
|
|
7
|
+
return createElement(tag, { ref, ...attrs, className: cx(cls, className), ...rest });
|
|
8
|
+
});
|
|
9
|
+
}
|
|
4
10
|
export const Badge = forwardRef(function Badge({ variant, className, ...rest }, ref) {
|
|
5
11
|
return (_jsx("span", { ref: ref, className: cx("rb-badge", variant && `rb-badge--${variant}`, className), ...rest }));
|
|
6
12
|
});
|
|
@@ -10,11 +16,10 @@ export const Alert = forwardRef(function Alert({ variant, title, className, chil
|
|
|
10
16
|
return (_jsxs("div", { ref: ref, role: "alert", className: cx("rb-alert", variant && `rb-alert--${variant}`, className), ...rest, children: [title !== undefined && _jsx("div", { className: "rb-alert__title", children: title }), children] }));
|
|
11
17
|
});
|
|
12
18
|
Alert.displayName = "Alert";
|
|
13
|
-
export const Progress =
|
|
14
|
-
return _jsx("progress", { ref: ref, className: cx("rb-progress", className), ...rest });
|
|
15
|
-
});
|
|
19
|
+
export const Progress = styled("progress", "rb-progress");
|
|
16
20
|
Progress.displayName = "Progress";
|
|
17
|
-
export const Spinner =
|
|
18
|
-
|
|
21
|
+
export const Spinner = styled("span", "rb-spinner", {
|
|
22
|
+
role: "status",
|
|
23
|
+
"aria-label": "Loading",
|
|
19
24
|
});
|
|
20
25
|
Spinner.displayName = "Spinner";
|
package/dist/form.js
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, } from "react";
|
|
2
|
+
import { createElement, forwardRef, } from "react";
|
|
3
3
|
import { cx } from "./cx.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
})
|
|
4
|
+
/** A forwardRef DOM wrapper that only adds a base rb-* class -- Input, Textarea, Select, Label, Field. */
|
|
5
|
+
function styled(tag, cls) {
|
|
6
|
+
return forwardRef(function Styled({ className, ...rest }, ref) {
|
|
7
|
+
return createElement(tag, { ref, className: cx(cls, className), ...rest });
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export const Input = styled("input", "rb-input");
|
|
7
11
|
Input.displayName = "Input";
|
|
8
|
-
export const Textarea =
|
|
9
|
-
return _jsx("textarea", { ref: ref, className: cx("rb-textarea", className), ...rest });
|
|
10
|
-
});
|
|
12
|
+
export const Textarea = styled("textarea", "rb-textarea");
|
|
11
13
|
Textarea.displayName = "Textarea";
|
|
12
|
-
export const Select =
|
|
13
|
-
return _jsx("select", { ref: ref, className: cx("rb-select", className), ...rest });
|
|
14
|
-
});
|
|
14
|
+
export const Select = styled("select", "rb-select");
|
|
15
15
|
Select.displayName = "Select";
|
|
16
|
-
export const Label =
|
|
17
|
-
return _jsx("label", { ref: ref, className: cx("rb-label", className), ...rest });
|
|
18
|
-
});
|
|
16
|
+
export const Label = styled("label", "rb-label");
|
|
19
17
|
Label.displayName = "Label";
|
|
20
|
-
export const Field =
|
|
21
|
-
return _jsx("div", { ref: ref, className: cx("rb-field", className), ...rest });
|
|
22
|
-
});
|
|
18
|
+
export const Field = styled("div", "rb-field");
|
|
23
19
|
Field.displayName = "Field";
|
|
24
20
|
/** A checkbox/radio/switch control, optionally wrapped with its label. */
|
|
25
21
|
function ChoiceControl({ label, control, wrapperClassName, wrapperStyle, }) {
|
|
@@ -27,15 +23,14 @@ function ChoiceControl({ label, control, wrapperClassName, wrapperStyle, }) {
|
|
|
27
23
|
return _jsx(_Fragment, { children: control });
|
|
28
24
|
return (_jsxs("label", { className: cx("rb-choice", wrapperClassName), style: wrapperStyle, children: [control, label] }));
|
|
29
25
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export const
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
Switch.displayName = "Switch";
|
|
26
|
+
/** A Checkbox/Radio/Switch factory: wraps an `<input>` carrying its fixed `type`/`role` in ChoiceControl. */
|
|
27
|
+
function choiceControl(displayName, cls, attrs) {
|
|
28
|
+
const Component = forwardRef(function Choice({ label, className, wrapperClassName, wrapperStyle, ...rest }, ref) {
|
|
29
|
+
return (_jsx(ChoiceControl, { label: label, wrapperClassName: wrapperClassName, wrapperStyle: wrapperStyle, control: _jsx("input", { ref: ref, ...attrs, className: cx(cls, className), ...rest }) }));
|
|
30
|
+
});
|
|
31
|
+
Component.displayName = displayName;
|
|
32
|
+
return Component;
|
|
33
|
+
}
|
|
34
|
+
export const Checkbox = choiceControl("Checkbox", "rb-checkbox", { type: "checkbox" });
|
|
35
|
+
export const Radio = choiceControl("Radio", "rb-radio", { type: "radio" });
|
|
36
|
+
export const Switch = choiceControl("Switch", "rb-switch", { type: "checkbox", role: "switch" });
|