@crystal-neuo/react 4.0.1 → 4.3.0

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/Input.d.ts CHANGED
@@ -6,6 +6,10 @@ export interface InputProps extends Omit<React.ComponentProps<"input">, "size">
6
6
  label?: string;
7
7
  error?: string;
8
8
  hint?: string;
9
+ /** Inside the input's box, at its start, centred on the input: e.g. a search or currency icon. */
10
+ start?: React.ReactNode;
11
+ /** Inside the input's box, at its end, centred on the input: e.g. a reveal or clear button. */
12
+ end?: React.ReactNode;
9
13
  }
10
- export declare function Input({ material, className, size, label, error, hint, id, ...props }: InputProps): React.JSX.Element;
14
+ export declare function Input({ material, className, size, label, error, hint, start, end, id, ...props }: InputProps): React.JSX.Element;
11
15
  //# sourceMappingURL=Input.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../src/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGlE,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC7E,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,KAAK,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAW,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,UAAU,qBAiCvG"}
1
+ {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../src/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGlE,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC7E,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kGAAkG;IAClG,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,+FAA+F;IAC/F,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACvB;AAED,wBAAgB,KAAK,CAAC,EACpB,QAAQ,EACR,SAAS,EACT,IAAW,EACX,KAAK,EACL,KAAK,EACL,IAAI,EACJ,KAAK,EACL,GAAG,EACH,EAAE,EACF,GAAG,KAAK,EACT,EAAE,UAAU,qBA6CZ"}
package/dist/Input.js CHANGED
@@ -1,12 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import { cn } from "./cn.js";
4
- export function Input({ material, className, size = "md", label, error, hint, id, ...props }) {
4
+ export function Input({ material, className, size = "md", label, error, hint, start, end, id, ...props }) {
5
5
  const autoId = React.useId();
6
6
  const inputId = id ?? autoId;
7
7
  const msgId = `${inputId}-msg`;
8
8
  const hintId = `${inputId}-hint`;
9
9
  const describedBy = [error ? msgId : null, hint ? hintId : null].filter(Boolean).join(" ") || undefined;
10
- return (_jsxs("div", { className: cn("cn-field", className), "data-slot": "input-field", "data-material": material, children: [label ? (_jsx("label", { className: "cn-field__label", htmlFor: inputId, children: label })) : null, _jsx("input", { id: inputId, className: cn("cn-input", `cn-input--size-${size}`, error && "cn-input--error"), "aria-invalid": error ? true : undefined, "aria-describedby": describedBy, ...props }), hint && !error ? (_jsx("span", { className: "cn-field__hint", id: hintId, children: hint })) : null, error ? (_jsx("span", { className: "cn-field__message", id: msgId, children: error })) : null] }));
10
+ const control = (_jsx("input", { id: inputId, className: cn("cn-input", `cn-input--size-${size}`, error && "cn-input--error"), "aria-invalid": error ? true : undefined, "aria-describedby": describedBy, ...props }));
11
+ return (_jsxs("div", { className: cn("cn-field", className), "data-slot": "input-field", "data-material": material, children: [label ? (_jsx("label", { className: "cn-field__label", htmlFor: inputId, children: label })) : null, start == null && end == null ? (control) : (_jsxs("div", { className: cn("cn-input-group", `cn-input-group--size-${size}`), children: [start == null ? null : _jsx("span", { className: "cn-input-group__start", children: start }), control, end == null ? null : _jsx("span", { className: "cn-input-group__end", children: end })] })), hint && !error ? (_jsx("span", { className: "cn-field__hint", id: hintId, children: hint })) : null, error ? (_jsx("span", { className: "cn-field__message", id: msgId, children: error })) : null] }));
11
12
  }
12
13
  //# sourceMappingURL=Input.js.map
package/dist/Input.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Input.js","sourceRoot":"","sources":["../src/Input.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAU7B,MAAM,UAAU,KAAK,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,KAAK,EAAc;IACtG,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IAC7B,MAAM,OAAO,GAAG,EAAE,IAAI,MAAM,CAAC;IAC7B,MAAM,KAAK,GAAG,GAAG,OAAO,MAAM,CAAC;IAC/B,MAAM,MAAM,GAAG,GAAG,OAAO,OAAO,CAAC;IACjC,MAAM,WAAW,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CA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AG,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAM,SAAS,EAAC,qBAAqB,YAAE,GAAG,GAAQ,IACpE,CACP,EACA,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAChB,eAAM,SAAS,EAAC,gBAAgB,EAAC,EAAE,EAAE,MAAM,YACxC,IAAI,GACA,CACR,CAAC,CAAC,CAAC,IAAI,EACP,KAAK,CAAC,CAAC,CAAC,CACP,eAAM,SAAS,EAAC,mBAAmB,EAAC,EAAE,EAAE,KAAK,YAC1C,KAAK,GACD,CACR,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crystal-neuo/react",
3
- "version": "4.0.1",
3
+ "version": "4.3.0",
4
4
  "description": "Crystal Neuo React components (shadcn/ui pattern). Prop types derived from @crystal-neuo/contract.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -30,8 +30,8 @@
30
30
  "react-dom": ">=18"
31
31
  },
32
32
  "dependencies": {
33
- "@crystal-neuo/contract": "4.0.1",
34
- "@crystal-neuo/css": "4.0.1"
33
+ "@crystal-neuo/contract": "4.3.0",
34
+ "@crystal-neuo/css": "4.3.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/react": "^19.3.0",
package/src/Input.tsx CHANGED
@@ -8,15 +8,40 @@ export interface InputProps extends Omit<React.ComponentProps<"input">, "size">
8
8
  label?: string;
9
9
  error?: string;
10
10
  hint?: string;
11
+ /** Inside the input's box, at its start, centred on the input: e.g. a search or currency icon. */
12
+ start?: React.ReactNode;
13
+ /** Inside the input's box, at its end, centred on the input: e.g. a reveal or clear button. */
14
+ end?: React.ReactNode;
11
15
  }
12
16
 
13
- export function Input({ material, className, size = "md", label, error, hint, id, ...props }: InputProps) {
17
+ export function Input({
18
+ material,
19
+ className,
20
+ size = "md",
21
+ label,
22
+ error,
23
+ hint,
24
+ start,
25
+ end,
26
+ id,
27
+ ...props
28
+ }: InputProps) {
14
29
  const autoId = React.useId();
15
30
  const inputId = id ?? autoId;
16
31
  const msgId = `${inputId}-msg`;
17
32
  const hintId = `${inputId}-hint`;
18
33
  const describedBy = [error ? msgId : null, hint ? hintId : null].filter(Boolean).join(" ") || undefined;
19
34
 
35
+ const control = (
36
+ <input
37
+ id={inputId}
38
+ className={cn("cn-input", `cn-input--size-${size}`, error && "cn-input--error")}
39
+ aria-invalid={error ? true : undefined}
40
+ aria-describedby={describedBy}
41
+ {...props}
42
+ />
43
+ );
44
+
20
45
  return (
21
46
  <div className={cn("cn-field", className)} data-slot="input-field" data-material={material}>
22
47
  {label ? (
@@ -24,13 +49,15 @@ export function Input({ material, className, size = "md", label, error, hint, id
24
49
  {label}
25
50
  </label>
26
51
  ) : null}
27
- <input
28
- id={inputId}
29
- className={cn("cn-input", `cn-input--size-${size}`, error && "cn-input--error")}
30
- aria-invalid={error ? true : undefined}
31
- aria-describedby={describedBy}
32
- {...props}
33
- />
52
+ {start == null && end == null ? (
53
+ control
54
+ ) : (
55
+ <div className={cn("cn-input-group", `cn-input-group--size-${size}`)}>
56
+ {start == null ? null : <span className="cn-input-group__start">{start}</span>}
57
+ {control}
58
+ {end == null ? null : <span className="cn-input-group__end">{end}</span>}
59
+ </div>
60
+ )}
34
61
  {hint && !error ? (
35
62
  <span className="cn-field__hint" id={hintId}>
36
63
  {hint}