@rackbops/ui-react 0.2.20 → 0.2.22

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 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 = forwardRef(function Progress({ className, ...rest }, ref) {
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 = forwardRef(function Spinner({ className, ...rest }, ref) {
18
- return (_jsx("span", { ref: ref, role: "status", "aria-label": "Loading", className: cx("rb-spinner", className), ...rest }));
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
- export const Input = forwardRef(function Input({ className, ...rest }, ref) {
5
- return _jsx("input", { ref: ref, className: cx("rb-input", className), ...rest });
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 = forwardRef(function Textarea({ className, ...rest }, ref) {
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 = forwardRef(function Select({ className, ...rest }, ref) {
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 = forwardRef(function Label({ className, ...rest }, ref) {
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 = forwardRef(function Field({ className, ...rest }, ref) {
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
- export const Checkbox = forwardRef(function Checkbox({ label, className, wrapperClassName, wrapperStyle, ...rest }, ref) {
31
- return (_jsx(ChoiceControl, { label: label, wrapperClassName: wrapperClassName, wrapperStyle: wrapperStyle, control: _jsx("input", { ref: ref, type: "checkbox", className: cx("rb-checkbox", className), ...rest }) }));
32
- });
33
- Checkbox.displayName = "Checkbox";
34
- export const Radio = forwardRef(function Radio({ label, className, wrapperClassName, wrapperStyle, ...rest }, ref) {
35
- return (_jsx(ChoiceControl, { label: label, wrapperClassName: wrapperClassName, wrapperStyle: wrapperStyle, control: _jsx("input", { ref: ref, type: "radio", className: cx("rb-radio", className), ...rest }) }));
36
- });
37
- Radio.displayName = "Radio";
38
- export const Switch = forwardRef(function Switch({ label, className, wrapperClassName, wrapperStyle, ...rest }, ref) {
39
- return (_jsx(ChoiceControl, { label: label, wrapperClassName: wrapperClassName, wrapperStyle: wrapperStyle, control: _jsx("input", { ref: ref, type: "checkbox", role: "switch", className: cx("rb-switch", className), ...rest }) }));
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" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rackbops/ui-react",
3
- "version": "0.2.20",
3
+ "version": "0.2.22",
4
4
  "description": "React components styled by @rackbops/styles rackbops themes.",
5
5
  "license": "MIT",
6
6
  "repository": {