@walidsj/react-ui 0.1.3 → 0.1.5

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/README.md CHANGED
@@ -29,13 +29,14 @@ Import the compiled stylesheet once, then use components from the package
29
29
  root:
30
30
 
31
31
  ``` tsx
32
- import { Button, Input } from "@walidsj/react-ui";
32
+ import { Button, Input, Textarea } from "@walidsj/react-ui";
33
33
  import "@walidsj/react-ui/style.css";
34
34
 
35
35
  export function Example() {
36
36
  return (
37
37
  <div style={{ display: "grid", gap: "1rem", maxWidth: "24rem" }}>
38
38
  <Input aria-label="Full name" placeholder="Full name" />
39
+ <Textarea aria-label="Notes" placeholder="Notes" size="lg" />
39
40
  <Button variant="primary" size="md">
40
41
  Save changes
41
42
  </Button>
@@ -44,6 +45,14 @@ export function Example() {
44
45
  }
45
46
  ```
46
47
 
48
+ Components can also be imported individually:
49
+
50
+ ``` tsx
51
+ import { Button } from "@walidsj/react-ui/components/button";
52
+ import { Input } from "@walidsj/react-ui/components/input";
53
+ import { Textarea } from "@walidsj/react-ui/components/textarea";
54
+ ```
55
+
47
56
  ## Components
48
57
 
49
58
  ### Button
@@ -77,8 +86,34 @@ consumer-provided `aria-invalid` value is preserved when `invalid` is
77
86
  not set. Labels, descriptions, and error messages are composed by the
78
87
  consumer.
79
88
 
80
- Both components merge `className` with their internal classes. Conflicting
81
- Tailwind utilities are resolved with `tailwind-merge`.
89
+ `size` controls the input height and horizontal padding:
90
+
91
+ - `sm`: compact control (`h-8`)
92
+ - `md`: default control (`h-10`)
93
+ - `lg`: larger control (`h-12`)
94
+
95
+ ### Textarea
96
+
97
+ Renders a native `<textarea>` and forwards native textarea props and refs.
98
+
99
+ | Prop | Type | Default |
100
+ | ----------- | ---------------- | ------- |
101
+ | `invalid` | `boolean` | `false` |
102
+ | `size` | `sm \| md \| lg` | `md` |
103
+ | `className` | `string` | — |
104
+
105
+ `invalid` sets `aria-invalid="true"` and applies error styling. A
106
+ consumer-provided `aria-invalid` value is preserved when `invalid` is not set.
107
+ Labels, descriptions, and error messages are composed by the consumer.
108
+
109
+ `size` controls the minimum height and horizontal padding:
110
+
111
+ - `sm`: compact textarea (`min-h-16`)
112
+ - `md`: default textarea (`min-h-20`)
113
+ - `lg`: larger textarea (`min-h-28`)
114
+
115
+ Both form controls merge `className` with their internal classes using the
116
+ `cn` package. Consumers do not need to install `clsx` or `tailwind-merge`.
82
117
 
83
118
  ## Styling
84
119
 
@@ -0,0 +1,39 @@
1
+ import { n as cva, t as cn } from "./cn-BtC0eFBk.js";
2
+ import { Button } from "@base-ui/react/button";
3
+ import { forwardRef } from "react";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/components/button/button.tsx
6
+ var buttonVariants = cva("rounded-ui-md focus-visible:ring-ring focus-visible:ring-offset-background inline-flex items-center justify-center font-medium whitespace-nowrap transition-colors outline-none select-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", {
7
+ variants: {
8
+ variant: {
9
+ primary: "bg-primary text-primary-foreground hover:bg-primary/90 active:bg-primary/80",
10
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80 active:bg-secondary/70",
11
+ outline: "border-border text-foreground hover:bg-muted active:bg-muted/70 border bg-transparent",
12
+ ghost: "text-foreground hover:bg-muted active:bg-muted/70 bg-transparent",
13
+ danger: "bg-danger text-danger-foreground hover:bg-danger/90 active:bg-danger/80"
14
+ },
15
+ size: {
16
+ sm: "h-8 gap-1.5 px-3 text-sm",
17
+ md: "h-10 gap-2 px-4 text-sm",
18
+ lg: "h-12 gap-2.5 px-6 text-base"
19
+ }
20
+ },
21
+ defaultVariants: {
22
+ variant: "primary",
23
+ size: "md"
24
+ }
25
+ });
26
+ var Button$1 = forwardRef(function Button$2({ className, variant = "primary", size = "md", type = "button", ...props }, ref) {
27
+ return /* @__PURE__ */ jsx(Button, {
28
+ ...props,
29
+ ref,
30
+ type,
31
+ className: cn(buttonVariants({
32
+ variant,
33
+ size
34
+ }), className)
35
+ });
36
+ });
37
+ export { Button$1 as t };
38
+
39
+ //# sourceMappingURL=button-CYdt-JvA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button-CYdt-JvA.js","names":["Button","BaseButton"],"sources":["../src/components/button/button.tsx"],"sourcesContent":["import { Button as BaseButton } from \"@base-ui/react/button\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { type ComponentPropsWithoutRef, forwardRef, type Ref } from \"react\";\nimport { cn } from \"../../lib/cn\";\n\nconst buttonVariants = cva(\n \"rounded-ui-md focus-visible:ring-ring focus-visible:ring-offset-background inline-flex items-center justify-center font-medium whitespace-nowrap transition-colors outline-none select-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50\",\n {\n variants: {\n variant: {\n primary:\n \"bg-primary text-primary-foreground hover:bg-primary/90 active:bg-primary/80\",\n secondary:\n \"bg-secondary text-secondary-foreground hover:bg-secondary/80 active:bg-secondary/70\",\n outline:\n \"border-border text-foreground hover:bg-muted active:bg-muted/70 border bg-transparent\",\n ghost:\n \"text-foreground hover:bg-muted active:bg-muted/70 bg-transparent\",\n danger:\n \"bg-danger text-danger-foreground hover:bg-danger/90 active:bg-danger/80\",\n },\n size: {\n sm: \"h-8 gap-1.5 px-3 text-sm\",\n md: \"h-10 gap-2 px-4 text-sm\",\n lg: \"h-12 gap-2.5 px-6 text-base\",\n },\n },\n defaultVariants: {\n variant: \"primary\",\n size: \"md\",\n },\n },\n);\n\nexport type ButtonVariant = NonNullable<\n VariantProps<typeof buttonVariants>[\"variant\"]\n>;\nexport type ButtonSize = NonNullable<\n VariantProps<typeof buttonVariants>[\"size\"]\n>;\n\nexport interface ButtonProps extends ComponentPropsWithoutRef<\"button\"> {\n variant?: ButtonVariant;\n size?: ButtonSize;\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n function Button(\n { className, variant = \"primary\", size = \"md\", type = \"button\", ...props },\n ref,\n ) {\n return (\n <BaseButton\n {...props}\n ref={ref as Ref<HTMLElement>}\n type={type}\n className={cn(buttonVariants({ variant, size }), className)}\n />\n );\n },\n);\n"],"mappings":";;;;;AAKA,IAAM,iBAAiB,IACrB,iSACA;CACE,UAAU;EACR,SAAS;GACP,SACE;GACF,WACE;GACF,SACE;GACF,OACE;GACF,QACE;EACJ;EACA,MAAM;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI;EACN;CACF;CACA,iBAAiB;EACf,SAAS;EACT,MAAM;CACR;AACF,CACF;AAcA,IAAaA,WAAS,WACpB,SAASA,SACP,EAAE,WAAW,UAAU,WAAW,OAAO,MAAM,OAAO,UAAU,GAAG,SACnE,KACA;CACA,OACE,oBAACC,QAAD;EACE,GAAI;EACC;EACC;EACN,WAAW,GAAG,eAAe;GAAE;GAAS;EAAK,CAAC,GAAG,SAAS;CAC3D,CAAA;AAEL,CACF"}
@@ -0,0 +1,70 @@
1
+ import { cn } from "cn";
2
+ // node_modules/clsx/dist/clsx.mjs
3
+ function r(e) {
4
+ var t, f, n = "";
5
+ if ("string" == typeof e || "number" == typeof e) n += e;
6
+ else if ("object" == typeof e) if (Array.isArray(e)) {
7
+ var o = e.length;
8
+ for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
9
+ } else for (f in e) e[f] && (n && (n += " "), n += f);
10
+ return n;
11
+ }
12
+ function clsx() {
13
+ for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
14
+ return n;
15
+ }
16
+ // node_modules/class-variance-authority/dist/index.mjs
17
+ /**
18
+ * Copyright 2022 Joe Bell. All rights reserved.
19
+ *
20
+ * This file is licensed to you under the Apache License, Version 2.0
21
+ * (the "License"); you may not use this file except in compliance with the
22
+ * License. You may obtain a copy of the License at
23
+ *
24
+ * http://www.apache.org/licenses/LICENSE-2.0
25
+ *
26
+ * Unless required by applicable law or agreed to in writing, software
27
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
28
+ * WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the
29
+ * License for the specific language governing permissions and limitations under
30
+ * the License.
31
+ */ var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
32
+ var cx = clsx;
33
+ var cva = (base, config) => (props) => {
34
+ var _config_compoundVariants;
35
+ if ((config === null || config === void 0 ? void 0 : config.variants) == null) return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
36
+ const { variants, defaultVariants } = config;
37
+ const getVariantClassNames = Object.keys(variants).map((variant) => {
38
+ const variantProp = props === null || props === void 0 ? void 0 : props[variant];
39
+ const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];
40
+ if (variantProp === null) return null;
41
+ const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);
42
+ return variants[variant][variantKey];
43
+ });
44
+ const propsWithoutUndefined = props && Object.entries(props).reduce((acc, param) => {
45
+ let [key, value] = param;
46
+ if (value === void 0) return acc;
47
+ acc[key] = value;
48
+ return acc;
49
+ }, {});
50
+ return cx(base, getVariantClassNames, config === null || config === void 0 ? void 0 : (_config_compoundVariants = config.compoundVariants) === null || _config_compoundVariants === void 0 ? void 0 : _config_compoundVariants.reduce((acc, param) => {
51
+ let { class: cvClass, className: cvClassName, ...compoundVariantOptions } = param;
52
+ return Object.entries(compoundVariantOptions).every((param) => {
53
+ let [key, value] = param;
54
+ return Array.isArray(value) ? value.includes({
55
+ ...defaultVariants,
56
+ ...propsWithoutUndefined
57
+ }[key]) : {
58
+ ...defaultVariants,
59
+ ...propsWithoutUndefined
60
+ }[key] === value;
61
+ }) ? [
62
+ ...acc,
63
+ cvClass,
64
+ cvClassName
65
+ ] : acc;
66
+ }, []), props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
67
+ };
68
+ export { cva as n, cn as t };
69
+
70
+ //# sourceMappingURL=cn-BtC0eFBk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cn-BtC0eFBk.js","names":[],"sources":["../node_modules/clsx/dist/clsx.mjs","../node_modules/class-variance-authority/dist/index.mjs"],"sourcesContent":["function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","/**\n * Copyright 2022 Joe Bell. All rights reserved.\n *\n * This file is licensed to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with the\n * License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations under\n * the License.\n */ import { clsx } from \"clsx\";\nconst falsyToString = (value)=>typeof value === \"boolean\" ? `${value}` : value === 0 ? \"0\" : value;\nexport const cx = clsx;\nexport const cva = (base, config)=>(props)=>{\n var _config_compoundVariants;\n if ((config === null || config === void 0 ? void 0 : config.variants) == null) return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);\n const { variants, defaultVariants } = config;\n const getVariantClassNames = Object.keys(variants).map((variant)=>{\n const variantProp = props === null || props === void 0 ? void 0 : props[variant];\n const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];\n if (variantProp === null) return null;\n const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);\n return variants[variant][variantKey];\n });\n const propsWithoutUndefined = props && Object.entries(props).reduce((acc, param)=>{\n let [key, value] = param;\n if (value === undefined) {\n return acc;\n }\n acc[key] = value;\n return acc;\n }, {});\n const getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (_config_compoundVariants = config.compoundVariants) === null || _config_compoundVariants === void 0 ? void 0 : _config_compoundVariants.reduce((acc, param)=>{\n let { class: cvClass, className: cvClassName, ...compoundVariantOptions } = param;\n return Object.entries(compoundVariantOptions).every((param)=>{\n let [key, value] = param;\n return Array.isArray(value) ? value.includes({\n ...defaultVariants,\n ...propsWithoutUndefined\n }[key]) : ({\n ...defaultVariants,\n ...propsWithoutUndefined\n })[key] === value;\n }) ? [\n ...acc,\n cvClass,\n cvClassName\n ] : acc;\n }, []);\n return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);\n };\n\n"],"ignoreList":[0,1],"mappings":";;AAAA,SAAS,EAAE,GAAE;CAAC,IAAI,GAAE,GAAE,IAAE;CAAG,IAAG,YAAU,OAAO,KAAG,YAAU,OAAO,GAAE,KAAG;MAAO,IAAG,YAAU,OAAO,GAAE,IAAG,MAAM,QAAQ,CAAC,GAAE;EAAC,IAAI,IAAE,EAAE;EAAO,KAAI,IAAE,GAAE,IAAE,GAAE,KAAI,EAAE,OAAK,IAAE,EAAE,EAAE,EAAE,OAAK,MAAI,KAAG,MAAK,KAAG;CAAE,OAAM,KAAI,KAAK,GAAE,EAAE,OAAK,MAAI,KAAG,MAAK,KAAG;CAAG,OAAO;AAAC;AAAC,SAAgB,OAAM;CAAC,KAAI,IAAI,GAAE,GAAE,IAAE,GAAE,IAAE,IAAG,IAAE,UAAU,QAAO,IAAE,GAAE,KAAI,CAAC,IAAE,UAAU,QAAM,IAAE,EAAE,CAAC,OAAK,MAAI,KAAG,MAAK,KAAG;CAAG,OAAO;AAAC;;;;;;;;;;;;;;;;GCe/W,IAAM,iBAAiB,UAAQ,OAAO,UAAU,YAAY,GAAG,UAAU,UAAU,IAAI,MAAM;AAC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