@propellerads/input 0.1.0 → 0.1.1

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
@@ -140,7 +140,8 @@ mark in such a group, use `ErrorLabel` from `@propellerads/error-label`.
140
140
  ## Props
141
141
 
142
142
  `Input` takes every `<input>` prop except `disabled` and `size`. `ref` reaches
143
- the `<input>`. `className` and `style` land on the `<input>`; `groupClassName`
143
+ the `<input>` under React 18 and 19 alike; `Textarea` and the `InputGroup*` parts
144
+ pass it to their own element the same way. `className` and `style` land on the `<input>`; `groupClassName`
144
145
  and `groupStyle` on the box around it.
145
146
 
146
147
  | Prop | Type | Default | What it does |
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
+ import { ComponentProps, ComponentPropsWithRef, ReactNode, Ref } from 'react';
2
3
  import { Button } from '@base-ui-components/react/button';
3
4
  import { Field as Field$1 } from '@base-ui-components/react/field';
4
- import { ComponentProps, ComponentPropsWithRef, ReactNode, Ref } from 'react';
5
5
 
6
6
  /** Which colour the errors are shown in. */
7
7
  declare const InputTone: {
@@ -96,38 +96,38 @@ type TextareaProps = Omit<ComponentPropsWithRef<'textarea'>, 'disabled'> & Field
96
96
  };
97
97
 
98
98
  /** A label, a control and a description, stacked or in a row. */
99
- declare const Field: ({ orientation, isDisabled, isInvalid, className, ...props }: FieldProps) => react_jsx_runtime.JSX.Element;
99
+ declare const Field: react.ForwardRefExoticComponent<Omit<FieldProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
100
100
  /** The label. Inside a `Field` it finds the input itself; outside one, pass `htmlFor`. */
101
- declare const FieldLabel: ({ isRequired, className, ...props }: FieldLabelProps) => react_jsx_runtime.JSX.Element;
101
+ declare const FieldLabel: react.ForwardRefExoticComponent<Omit<FieldLabelProps, "ref"> & react.RefAttributes<HTMLLabelElement>>;
102
102
  /** Quiet text under the input. The input is described by it. */
103
- declare const FieldDescription: ({ className, ...props }: FieldDescriptionProps) => react_jsx_runtime.JSX.Element;
103
+ declare const FieldDescription: react.ForwardRefExoticComponent<Omit<FieldDescriptionProps, "ref"> & react.RefAttributes<HTMLParagraphElement>>;
104
104
  /** Fields of one form, spaced apart; `columns` lays them out in a grid. */
105
- declare const FieldGroup: ({ columns, className, style, ...props }: FieldGroupProps) => react_jsx_runtime.JSX.Element;
105
+ declare const FieldGroup: react.ForwardRefExoticComponent<Omit<FieldGroupProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
106
106
 
107
107
  /** The box. Draws the contour and the focus ring for the control inside it. */
108
- declare const InputGroup: ({ tone, isInvalid, className, ...props }: InputGroupProps) => react_jsx_runtime.JSX.Element;
108
+ declare const InputGroup: react.ForwardRefExoticComponent<Omit<InputGroupProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
109
109
  /** The `<input>` inside a group. Takes every native prop. */
110
- declare const InputGroupInput: ({ className, ...props }: InputGroupInputProps) => react_jsx_runtime.JSX.Element;
110
+ declare const InputGroupInput: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & react.RefAttributes<HTMLInputElement>>;
111
111
  /** The `<textarea>` inside a group. Takes every native prop. */
112
- declare const InputGroupTextarea: ({ className, ...props }: InputGroupTextareaProps) => react_jsx_runtime.JSX.Element;
112
+ declare const InputGroupTextarea: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref"> & react.RefAttributes<HTMLTextAreaElement>>;
113
113
  /** Something that stands beside the text: an icon, a unit, a button. */
114
- declare const InputGroupAddon: ({ align, className, ...props }: InputGroupAddonProps) => react_jsx_runtime.JSX.Element;
114
+ declare const InputGroupAddon: react.ForwardRefExoticComponent<Omit<InputGroupAddonProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
115
115
  /** Quiet text inside the box: a unit, a prefix, a counter. */
116
- declare const InputGroupText: ({ className, ...props }: InputGroupTextProps) => react_jsx_runtime.JSX.Element;
116
+ declare const InputGroupText: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & react.RefAttributes<HTMLSpanElement>>;
117
117
  /** A small square button inside the box. Name it with `aria-label` when it is only an icon. */
118
- declare const InputGroupButton: ({ className, ...props }: InputGroupButtonProps) => react_jsx_runtime.JSX.Element;
118
+ declare const InputGroupButton: react.ForwardRefExoticComponent<Omit<InputGroupButtonProps, "ref"> & react.RefAttributes<HTMLButtonElement>>;
119
119
  /**
120
120
  * A text field, a password field or a number field, by `type`. A password gets
121
121
  * the show-password button; a number stays the native input, so its value is
122
122
  * the string the user typed, a comma included.
123
123
  */
124
- declare const Input: ({ type, id, errors, tone, showErrors, onErrorsClick, characterLimit, countCharacters, isDisabled, startAddon, endAddon, passwordToggleLabel, groupClassName, groupStyle, value, defaultValue, onChange, ...props }: InputProps) => react_jsx_runtime.JSX.Element;
124
+ declare const Input: react.ForwardRefExoticComponent<Omit<InputProps, "ref"> & react.RefAttributes<HTMLInputElement>>;
125
125
  /**
126
126
  * A field for more than a line, the same box as `Input`. The `!` mark sits in
127
127
  * the top corner, next to the first line; the counter in the bottom one, next to
128
128
  * where the typing is.
129
129
  */
130
- declare const Textarea: ({ id, rows, errors, tone, showErrors, onErrorsClick, characterLimit, countCharacters, isDisabled, groupClassName, groupStyle, value, defaultValue, onChange, ...props }: TextareaProps) => react_jsx_runtime.JSX.Element;
130
+ declare const Textarea: react.ForwardRefExoticComponent<Omit<TextareaProps, "ref"> & react.RefAttributes<HTMLTextAreaElement>>;
131
131
 
132
132
  export { Field, FieldDescription, FieldGroup, FieldLabel, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputTone, Textarea, Input as default };
133
133
  export type { FieldDescriptionProps, FieldGroupProps, FieldLabelProps, FieldProps, InputGroupAddonProps, InputGroupButtonProps, InputGroupInputProps, InputGroupProps, InputGroupTextProps, InputGroupTextareaProps, InputProps, TextareaProps };
package/dist/index.js CHANGED
@@ -2,173 +2,208 @@ import { Button as e } from "@base-ui-components/react/button";
2
2
  import { Field as t } from "@base-ui-components/react/field";
3
3
  import { Input as n } from "@base-ui-components/react/input";
4
4
  import r, { errorLabelTextId as i } from "@propellerads/error-label";
5
- import { createContext as a, useContext as o, useId as s, useState as c } from "react";
6
- import { clsx as l } from "clsx";
7
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
5
+ import { createContext as a, forwardRef as o, useContext as s, useId as c, useState as l } from "react";
6
+ import { clsx as u } from "clsx";
7
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
8
8
  import './index.css';//#region src/cn.ts
9
- var f = (...e) => l(e), p = a(!1), m = () => o(p), h = ({ orientation: e = "vertical", isDisabled: n, isInvalid: r, className: i, ...a }) => /* @__PURE__ */ u(p.Provider, {
9
+ var p = (...e) => u(e), m = a(!1), h = () => s(m), g = o(({ orientation: e = "vertical", isDisabled: n, isInvalid: r, className: i, ...a }, o) => /* @__PURE__ */ d(m.Provider, {
10
10
  value: !0,
11
- children: /* @__PURE__ */ u(t.Root, {
11
+ children: /* @__PURE__ */ d(t.Root, {
12
12
  ...a,
13
+ ref: o,
13
14
  disabled: n,
14
15
  invalid: r,
15
16
  "data-orientation": e,
16
- className: f("field", i)
17
+ className: p("field", i)
17
18
  })
18
- }), g = ({ isRequired: e = !1, className: n, ...r }) => /* @__PURE__ */ u(t.Label, {
19
+ }));
20
+ g.displayName = "Field";
21
+ var _ = o(({ isRequired: e = !1, className: n, ...r }, i) => /* @__PURE__ */ d(t.Label, {
19
22
  ...r,
23
+ ref: i,
20
24
  "data-required": e || void 0,
21
- className: f("field-label", n)
22
- }), _ = ({ className: e, ...n }) => /* @__PURE__ */ u(t.Description, {
25
+ className: p("field-label", n)
26
+ }));
27
+ _.displayName = "FieldLabel";
28
+ var v = o(({ className: e, ...n }, r) => /* @__PURE__ */ d(t.Description, {
23
29
  ...n,
24
- className: f("field-description", e)
25
- }), v = ({ columns: e, className: t, style: n, ...r }) => /* @__PURE__ */ u("div", {
30
+ ref: r,
31
+ className: p("field-description", e)
32
+ }));
33
+ v.displayName = "FieldDescription";
34
+ var y = o(({ columns: e, className: t, style: n, ...r }, i) => /* @__PURE__ */ d("div", {
26
35
  ...r,
36
+ ref: i,
27
37
  "data-columns": e,
28
- className: f("field-group", t),
38
+ className: p("field-group", t),
29
39
  style: e === void 0 ? n : {
30
40
  "--field-group-columns": e,
31
41
  ...n
32
42
  }
33
- }), y = {
43
+ }));
44
+ y.displayName = "FieldGroup";
45
+ //#endregion
46
+ //#region src/types.ts
47
+ var b = {
34
48
  Danger: "danger",
35
49
  Warning: "warning"
36
- }, b = ({ tone: e = y.Danger, isInvalid: t = !1, className: n, ...r }) => /* @__PURE__ */ u("div", {
50
+ }, x = o(({ tone: e = b.Danger, isInvalid: t = !1, className: n, ...r }, i) => /* @__PURE__ */ d("div", {
37
51
  ...r,
52
+ ref: i,
38
53
  "data-tone": e,
39
54
  "data-invalid": t || void 0,
40
- className: f("input-group", n)
41
- }), x = ({ className: e, ...t }) => /* @__PURE__ */ u(n, {
55
+ className: p("input-group", n)
56
+ }));
57
+ x.displayName = "InputGroup";
58
+ var S = o(({ className: e, ...t }, r) => /* @__PURE__ */ d(n, {
42
59
  ...t,
43
- className: f("input-group__control", e)
44
- }), S = ({ className: e, ...n }) => /* @__PURE__ */ u(t.Control, {
60
+ ref: r,
61
+ className: p("input-group__control", e)
62
+ }));
63
+ S.displayName = "InputGroupInput";
64
+ var C = o(({ className: e, ...n }, r) => /* @__PURE__ */ d(t.Control, {
45
65
  ...n,
46
- render: /* @__PURE__ */ u("textarea", {}),
47
- className: f("input-group__control", "input-group__control--multiline", e)
48
- }), C = ({ align: e = "inline-end", className: t, ...n }) => /* @__PURE__ */ u("div", {
66
+ ref: r,
67
+ render: /* @__PURE__ */ d("textarea", {}),
68
+ className: p("input-group__control", "input-group__control--multiline", e)
69
+ }));
70
+ C.displayName = "InputGroupTextarea";
71
+ var w = o(({ align: e = "inline-end", className: t, ...n }, r) => /* @__PURE__ */ d("div", {
49
72
  ...n,
73
+ ref: r,
50
74
  "data-align": e,
51
- className: f("input-group__addon", `input-group__addon--${e}`, t)
52
- }), w = ({ className: e, ...t }) => /* @__PURE__ */ u("span", {
75
+ className: p("input-group__addon", `input-group__addon--${e}`, t)
76
+ }));
77
+ w.displayName = "InputGroupAddon";
78
+ var T = o(({ className: e, ...t }, n) => /* @__PURE__ */ d("span", {
53
79
  ...t,
54
- className: f("input-group__text", e)
55
- }), T = ({ className: t, ...n }) => /* @__PURE__ */ u(e, {
80
+ ref: n,
81
+ className: p("input-group__text", e)
82
+ }));
83
+ T.displayName = "InputGroupText";
84
+ var E = o(({ className: t, ...n }, r) => /* @__PURE__ */ d(e, {
56
85
  type: "button",
57
86
  ...n,
58
- className: f("input-group__button", t)
59
- }), E = ({ isOpen: e }) => /* @__PURE__ */ d("svg", {
87
+ ref: r,
88
+ className: p("input-group__button", t)
89
+ }));
90
+ E.displayName = "InputGroupButton";
91
+ var D = ({ isOpen: e }) => /* @__PURE__ */ f("svg", {
60
92
  viewBox: "0 0 16 16",
61
93
  width: "16",
62
94
  height: "16",
63
95
  fill: "none",
64
96
  "aria-hidden": "true",
65
97
  children: [
66
- /* @__PURE__ */ u("path", {
98
+ /* @__PURE__ */ d("path", {
67
99
  d: "M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8Z",
68
100
  stroke: "currentColor",
69
101
  strokeWidth: "1.5",
70
102
  strokeLinejoin: "round"
71
103
  }),
72
- /* @__PURE__ */ u("circle", {
104
+ /* @__PURE__ */ d("circle", {
73
105
  cx: "8",
74
106
  cy: "8",
75
107
  r: "2",
76
108
  stroke: "currentColor",
77
109
  strokeWidth: "1.5"
78
110
  }),
79
- !e && /* @__PURE__ */ u("path", {
111
+ !e && /* @__PURE__ */ d("path", {
80
112
  d: "M2.5 13.5l11-11",
81
113
  stroke: "currentColor",
82
114
  strokeWidth: "1.5",
83
115
  strokeLinecap: "round"
84
116
  })
85
117
  ]
86
- }), D = (e) => e.trim().length, O = ({ id: e, errors: t, characterLimit: n, countCharacters: r, value: a, defaultValue: o, onChange: l, describedBy: u }) => {
87
- let d = m(), p = s(), h = e ?? p, [g, _] = c(String(o ?? "")), v = t.length > 0;
118
+ }), O = (e) => e.trim().length, k = ({ id: e, errors: t, characterLimit: n, countCharacters: r, value: a, defaultValue: o, onChange: s, describedBy: u }) => {
119
+ let d = h(), f = c(), m = e ?? f, [g, _] = l(String(o ?? "")), v = t.length > 0;
88
120
  return {
89
- errorsKey: h,
121
+ errorsKey: m,
90
122
  isInField: d,
91
123
  isInvalid: v,
92
124
  remaining: n === void 0 ? void 0 : n - r(a === void 0 ? g : String(a)),
93
125
  handleChange: (e) => {
94
- a === void 0 && _(e.target.value), l?.(e);
126
+ a === void 0 && _(e.target.value), s?.(e);
95
127
  },
96
128
  ariaProps: {
97
129
  ...v ? { "aria-invalid": !0 } : {},
98
- ...v && !d ? { "aria-describedby": f(u, i(h)) } : {}
130
+ ...v && !d ? { "aria-describedby": p(u, i(m)) } : {}
99
131
  }
100
132
  };
101
- }, k = ({ remaining: e }) => /* @__PURE__ */ u(w, {
133
+ }, A = ({ remaining: e }) => /* @__PURE__ */ d(T, {
102
134
  className: "input-group__counter",
103
135
  "data-over": e < 0 || void 0,
104
136
  children: e
105
- }), A = ({ errorsKey: e, errors: n }) => {
106
- let r = m(), a = n.join(". ");
107
- return u(r ? t.Description : "span", {
137
+ }), j = ({ errorsKey: e, errors: n }) => {
138
+ let r = h(), a = n.join(". ");
139
+ return d(r ? t.Description : "span", {
108
140
  id: i(e),
109
141
  hidden: !0,
110
142
  children: a
111
143
  });
112
- }, j = ({ type: e = "text", id: t, errors: n = [], tone: i = y.Danger, showErrors: a = !0, onErrorsClick: o, characterLimit: s, countCharacters: l = D, isDisabled: f = !1, startAddon: p, endAddon: m, passwordToggleLabel: h = "Show password", groupClassName: g, groupStyle: _, value: v, defaultValue: S, onChange: w, ...j }) => {
113
- let [M, N] = c(!1), { errorsKey: P, isInField: F, isInvalid: I, remaining: L, handleChange: R, ariaProps: z } = O({
144
+ }, M = o(({ type: e = "text", id: t, errors: n = [], tone: i = b.Danger, showErrors: a = !0, onErrorsClick: o, characterLimit: s, countCharacters: c = O, isDisabled: u = !1, startAddon: p, endAddon: m, passwordToggleLabel: h = "Show password", groupClassName: g, groupStyle: _, value: v, defaultValue: y, onChange: C, ...T }, M) => {
145
+ let [N, P] = l(!1), { errorsKey: F, isInField: I, isInvalid: L, remaining: R, handleChange: z, ariaProps: B } = k({
114
146
  id: t,
115
147
  errors: n,
116
148
  characterLimit: s,
117
- countCharacters: l,
149
+ countCharacters: c,
118
150
  value: v,
119
- defaultValue: S,
120
- onChange: w,
121
- describedBy: j["aria-describedby"]
122
- }), B = e === "password";
123
- return /* @__PURE__ */ d(b, {
151
+ defaultValue: y,
152
+ onChange: C,
153
+ describedBy: T["aria-describedby"]
154
+ }), V = e === "password";
155
+ return /* @__PURE__ */ f(x, {
124
156
  tone: i,
125
- isInvalid: I,
157
+ isInvalid: L,
126
158
  className: g,
127
159
  style: _,
128
160
  children: [
129
- p !== void 0 && /* @__PURE__ */ u(C, {
161
+ p !== void 0 && /* @__PURE__ */ d(w, {
130
162
  align: "inline-start",
131
163
  children: p
132
164
  }),
133
- /* @__PURE__ */ u(x, {
134
- ...j,
165
+ /* @__PURE__ */ d(S, {
166
+ ...T,
167
+ ref: M,
135
168
  id: t,
136
- type: B && M ? "text" : e,
169
+ type: V && N ? "text" : e,
137
170
  value: v,
138
- defaultValue: S,
139
- onChange: R,
140
- disabled: f,
141
- ...z
171
+ defaultValue: y,
172
+ onChange: z,
173
+ disabled: u,
174
+ ...B
142
175
  }),
143
- (m !== void 0 || B || L !== void 0 || I && a) && /* @__PURE__ */ d(C, {
176
+ (m !== void 0 || V || R !== void 0 || L && a) && /* @__PURE__ */ f(w, {
144
177
  align: "inline-end",
145
178
  children: [
146
179
  m,
147
- B && /* @__PURE__ */ u(T, {
180
+ V && /* @__PURE__ */ d(E, {
148
181
  "aria-label": h,
149
- "aria-pressed": M,
150
- disabled: f,
151
- onClick: () => N((e) => !e),
152
- children: /* @__PURE__ */ u(E, { isOpen: M })
182
+ "aria-pressed": N,
183
+ disabled: u,
184
+ onClick: () => P((e) => !e),
185
+ children: /* @__PURE__ */ d(D, { isOpen: N })
153
186
  }),
154
- L !== void 0 && /* @__PURE__ */ u(k, { remaining: L }),
155
- I && a && /* @__PURE__ */ u(r, {
156
- elementId: P,
187
+ R !== void 0 && /* @__PURE__ */ d(A, { remaining: R }),
188
+ L && a && /* @__PURE__ */ d(r, {
189
+ elementId: F,
157
190
  errors: n,
158
191
  tone: i,
159
192
  onClick: o,
160
- hasDescription: !F
193
+ hasDescription: !I
161
194
  })
162
195
  ]
163
196
  }),
164
- I && (F || !a) && /* @__PURE__ */ u(A, {
165
- errorsKey: P,
197
+ L && (I || !a) && /* @__PURE__ */ d(j, {
198
+ errorsKey: F,
166
199
  errors: n
167
200
  })
168
201
  ]
169
202
  });
170
- }, M = ({ id: e, rows: t = 3, errors: n = [], tone: i = y.Danger, showErrors: a = !0, onErrorsClick: o, characterLimit: s, countCharacters: c = D, isDisabled: l = !1, groupClassName: p, groupStyle: m, value: h, defaultValue: g, onChange: _, ...v }) => {
171
- let { errorsKey: x, isInField: w, isInvalid: T, remaining: E, handleChange: j, ariaProps: M } = O({
203
+ });
204
+ M.displayName = "Input";
205
+ var N = o(({ id: e, rows: t = 3, errors: n = [], tone: i = b.Danger, showErrors: a = !0, onErrorsClick: o, characterLimit: s, countCharacters: c = O, isDisabled: l = !1, groupClassName: u, groupStyle: m, value: h, defaultValue: g, onChange: _, ...v }, y) => {
206
+ let { errorsKey: S, isInField: T, isInvalid: E, remaining: D, handleChange: M, ariaProps: N } = k({
172
207
  id: e,
173
208
  errors: n,
174
209
  characterLimit: s,
@@ -178,46 +213,48 @@ var f = (...e) => l(e), p = a(!1), m = () => o(p), h = ({ orientation: e = "vert
178
213
  onChange: _,
179
214
  describedBy: v["aria-describedby"]
180
215
  });
181
- return /* @__PURE__ */ d(b, {
216
+ return /* @__PURE__ */ f(x, {
182
217
  tone: i,
183
- isInvalid: T,
184
- className: f("input-group--multiline", p),
218
+ isInvalid: E,
219
+ className: p("input-group--multiline", u),
185
220
  style: m,
186
- "data-has-errors": T && a || void 0,
187
- "data-has-counter": E !== void 0 || void 0,
221
+ "data-has-errors": E && a || void 0,
222
+ "data-has-counter": D !== void 0 || void 0,
188
223
  children: [
189
- /* @__PURE__ */ u(S, {
224
+ /* @__PURE__ */ d(C, {
190
225
  ...v,
226
+ ref: y,
191
227
  id: e,
192
228
  rows: t,
193
229
  value: h,
194
230
  defaultValue: g,
195
- onChange: j,
231
+ onChange: M,
196
232
  disabled: l,
197
- ...M
233
+ ...N
198
234
  }),
199
- T && a && /* @__PURE__ */ u(C, {
235
+ E && a && /* @__PURE__ */ d(w, {
200
236
  align: "block-start",
201
- children: /* @__PURE__ */ u(r, {
202
- elementId: x,
237
+ children: /* @__PURE__ */ d(r, {
238
+ elementId: S,
203
239
  errors: n,
204
240
  tone: i,
205
241
  onClick: o,
206
- hasDescription: !w
242
+ hasDescription: !T
207
243
  })
208
244
  }),
209
- E !== void 0 && /* @__PURE__ */ u(C, {
245
+ D !== void 0 && /* @__PURE__ */ d(w, {
210
246
  align: "block-end",
211
- children: /* @__PURE__ */ u(k, { remaining: E })
247
+ children: /* @__PURE__ */ d(A, { remaining: D })
212
248
  }),
213
- T && (w || !a) && /* @__PURE__ */ u(A, {
214
- errorsKey: x,
249
+ E && (T || !a) && /* @__PURE__ */ d(j, {
250
+ errorsKey: S,
215
251
  errors: n
216
252
  })
217
253
  ]
218
254
  });
219
- };
255
+ });
256
+ N.displayName = "Textarea";
220
257
  //#endregion
221
- export { h as Field, _ as FieldDescription, v as FieldGroup, g as FieldLabel, j as Input, j as default, b as InputGroup, C as InputGroupAddon, T as InputGroupButton, x as InputGroupInput, w as InputGroupText, S as InputGroupTextarea, y as InputTone, M as Textarea };
258
+ export { g as Field, v as FieldDescription, y as FieldGroup, _ as FieldLabel, M as Input, M as default, x as InputGroup, w as InputGroupAddon, E as InputGroupButton, S as InputGroupInput, T as InputGroupText, C as InputGroupTextarea, b as InputTone, N as Textarea };
222
259
 
223
260
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/cn.ts","../src/field.tsx","../src/types.ts","../src/index.tsx"],"sourcesContent":["import {type ClassValue, clsx} from 'clsx';\n\n/**\n * Joins class names. There is no tailwind-merge here on purpose: the input\n * ships its own stylesheet instead of utility classes, so there is nothing to\n * deduplicate.\n */\nconst cn = (...inputs: ClassValue[]): string => clsx(inputs);\n\nexport {cn};\n","import {Field as BaseField} from '@base-ui-components/react/field';\nimport {type CSSProperties, createContext, useContext} from 'react';\nimport {cn} from './cn';\nimport type {FieldDescriptionProps, FieldGroupProps, FieldLabelProps, FieldProps} from './types';\n\n/*\n * The parts follow shadcn's Field, on Base UI's. The field wires itself: the\n * label points at the input, and the input is described by the description and\n * by its errors, with no ids written by hand.\n */\n\n/** Whether a part is standing inside a `Field`, which then does the wiring. */\nconst FieldContext = createContext<boolean>(false);\n\nconst useIsInField = (): boolean => useContext(FieldContext);\n\n/** A label, a control and a description, stacked or in a row. */\nconst Field = ({orientation = 'vertical', isDisabled, isInvalid, className, ...props}: FieldProps) => (\n <FieldContext.Provider value={true}>\n <BaseField.Root\n {...props}\n disabled={isDisabled}\n invalid={isInvalid}\n data-orientation={orientation}\n className={cn('field', className)}\n />\n </FieldContext.Provider>\n);\n\n/** The label. Inside a `Field` it finds the input itself; outside one, pass `htmlFor`. */\nconst FieldLabel = ({isRequired = false, className, ...props}: FieldLabelProps) => (\n <BaseField.Label {...props} data-required={isRequired || undefined} className={cn('field-label', className)} />\n);\n\n/** Quiet text under the input. The input is described by it. */\nconst FieldDescription = ({className, ...props}: FieldDescriptionProps) => (\n <BaseField.Description {...props} className={cn('field-description', className)} />\n);\n\n/** Fields of one form, spaced apart; `columns` lays them out in a grid. */\nconst FieldGroup = ({columns, className, style, ...props}: FieldGroupProps) => (\n <div\n {...props}\n data-columns={columns}\n className={cn('field-group', className)}\n style={columns === undefined ? style : ({'--field-group-columns': columns, ...style} as CSSProperties)}\n />\n);\n\nexport {Field, FieldDescription, FieldGroup, FieldLabel, useIsInField};\n","import type {Button as BaseButton} from '@base-ui-components/react/button';\nimport type {Field as BaseField} from '@base-ui-components/react/field';\nimport type {ComponentProps, ComponentPropsWithRef, ReactNode, Ref} from 'react';\n\n/** Which colour the errors are shown in. */\nexport const InputTone = {\n /** Something is wrong and has to be fixed. */\n Danger: 'danger',\n /** Something is allowed but worth a second look — a bid far above the market. */\n Warning: 'warning',\n} as const;\nexport type InputTone = (typeof InputTone)[keyof typeof InputTone];\n\nexport type InputGroupProps = ComponentPropsWithRef<'div'> & {\n /** Colour of the contour when the group is invalid. @default 'danger' */\n tone?: InputTone;\n /** Draws the contour in the tone. Set by `Input` when it has errors. */\n isInvalid?: boolean;\n};\n\nexport type InputGroupInputProps = ComponentPropsWithRef<'input'>;\n\nexport type InputGroupAddonProps = ComponentPropsWithRef<'div'> & {\n /**\n * Where the addon stands. `inline-*` beside the text of an input;\n * `block-*` in the top or bottom end corner of a textarea. @default 'inline-end'\n */\n align?: 'inline-start' | 'inline-end' | 'block-start' | 'block-end';\n};\n\nexport type InputGroupTextProps = ComponentPropsWithRef<'span'>;\n\nexport type InputGroupButtonProps = Omit<ComponentProps<typeof BaseButton>, 'className'> & {\n className?: string;\n};\n\nexport type FieldProps = Omit<ComponentProps<typeof BaseField.Root>, 'className' | 'disabled' | 'invalid'> & {\n className?: string;\n /** `horizontal` puts the parts in a row: an input and its button, a checkbox and its label. @default 'vertical' */\n orientation?: 'vertical' | 'horizontal';\n /** Switches off the input inside and fades the label and the description. */\n isDisabled?: boolean;\n /** Marks the field invalid: the contour, the label and `aria-invalid` on the input. */\n isInvalid?: boolean;\n};\n\nexport type FieldLabelProps = Omit<ComponentProps<typeof BaseField.Label>, 'className'> & {\n className?: string;\n /** Adds the asterisk. The input itself takes `required` separately. */\n isRequired?: boolean;\n};\n\nexport type FieldDescriptionProps = Omit<ComponentProps<typeof BaseField.Description>, 'className'> & {\n className?: string;\n};\n\nexport type FieldGroupProps = ComponentPropsWithRef<'div'> & {\n /** Lays the fields out in this many equal columns. Stacked when omitted. */\n columns?: number;\n};\n\n/** What `Input` and `Textarea` share: the errors, the counter, the switch and the box. */\ntype FieldControlOwnProps = {\n /**\n * Shown behind the `!` mark at the end of the field. A non-empty list also\n * draws the contour in the tone and sets `aria-invalid`.\n */\n errors?: ReadonlyArray<string>;\n /** Which colour the errors are shown in. @default 'danger' */\n tone?: InputTone;\n /** Hides the `!` mark and keeps the contour and the description. @default true */\n showErrors?: boolean;\n /** Called when the `!` mark is clicked. */\n onErrorsClick?: () => void;\n /**\n * Shows how many characters are left. Typing past it is allowed and turns the\n * counter red — unlike the native `maxLength`, which stops the keyboard.\n */\n characterLimit?: number;\n /** Counts the value for `characterLimit`. @default trimmed length */\n countCharacters?: (value: string) => number;\n /** Switches the field off. The native `disabled` is not accepted, as on Button. */\n isDisabled?: boolean;\n /** On the group, the box that draws the contour. `className` stays on the control. */\n groupClassName?: string;\n groupStyle?: InputGroupProps['style'];\n};\n\nexport type InputProps = Omit<ComponentPropsWithRef<'input'>, 'disabled' | 'size'> &\n FieldControlOwnProps & {\n /** Before the text: an icon, a currency sign. */\n startAddon?: ReactNode;\n /** After the text, before the counter and the `!` mark. */\n endAddon?: ReactNode;\n /** Names the show-password button. @default 'Show password' */\n passwordToggleLabel?: string;\n ref?: Ref<HTMLInputElement>;\n };\n\nexport type InputGroupTextareaProps = ComponentPropsWithRef<'textarea'>;\n\nexport type TextareaProps = Omit<ComponentPropsWithRef<'textarea'>, 'disabled'> &\n FieldControlOwnProps & {\n /**\n * The height it starts at, in lines. The field grows with the text past it\n * where the browser can size a field by its content. @default 3\n */\n rows?: number;\n ref?: Ref<HTMLTextAreaElement>;\n };\n","import {Button as BaseButton} from '@base-ui-components/react/button';\nimport {Field as BaseField} from '@base-ui-components/react/field';\nimport {Input as BaseInput} from '@base-ui-components/react/input';\nimport ErrorLabel, {errorLabelTextId} from '@propellerads/error-label';\nimport {type ChangeEvent, type ComponentProps, useId, useState} from 'react';\nimport './input.css';\nimport {cn} from './cn';\nimport {Field, FieldDescription, FieldGroup, FieldLabel, useIsInField} from './field';\nimport {\n type FieldDescriptionProps,\n type FieldGroupProps,\n type FieldLabelProps,\n type FieldProps,\n type InputGroupAddonProps,\n type InputGroupButtonProps,\n type InputGroupInputProps,\n type InputGroupProps,\n type InputGroupTextareaProps,\n type InputGroupTextProps,\n type InputProps,\n InputTone,\n type TextareaProps,\n} from './types';\n\n/*\n * The parts follow shadcn's Input Group, on Base UI instead of Radix. The group is\n * the box — contour, corners, focus ring — and the control inside it draws\n * nothing, so an icon, a counter or a button can stand in the same box. `Input`\n * and `Textarea` below are the group with the common parts filled in.\n */\n\n/** The box. Draws the contour and the focus ring for the control inside it. */\nconst InputGroup = ({tone = InputTone.Danger, isInvalid = false, className, ...props}: InputGroupProps) => (\n <div {...props} data-tone={tone} data-invalid={isInvalid || undefined} className={cn('input-group', className)} />\n);\n\n/** The `<input>` inside a group. Takes every native prop. */\nconst InputGroupInput = ({className, ...props}: InputGroupInputProps) => (\n <BaseInput {...props} className={cn('input-group__control', className)} />\n);\n\n/** The `<textarea>` inside a group. Takes every native prop. */\nconst InputGroupTextarea = ({className, ...props}: InputGroupTextareaProps) => (\n <BaseField.Control\n // Base UI types the control as an <input>, and renders a textarea through\n // `render` the way its own docs do; the props are the textarea's.\n {...(props as unknown as ComponentProps<typeof BaseField.Control>)}\n render={<textarea />}\n className={cn('input-group__control', 'input-group__control--multiline', className)}\n />\n);\n\n/** Something that stands beside the text: an icon, a unit, a button. */\nconst InputGroupAddon = ({align = 'inline-end', className, ...props}: InputGroupAddonProps) => (\n <div {...props} data-align={align} className={cn('input-group__addon', `input-group__addon--${align}`, className)} />\n);\n\n/** Quiet text inside the box: a unit, a prefix, a counter. */\nconst InputGroupText = ({className, ...props}: InputGroupTextProps) => (\n <span {...props} className={cn('input-group__text', className)} />\n);\n\n/** A small square button inside the box. Name it with `aria-label` when it is only an icon. */\nconst InputGroupButton = ({className, ...props}: InputGroupButtonProps) => (\n <BaseButton type=\"button\" {...props} className={cn('input-group__button', className)} />\n);\n\nconst EyeIcon = ({isOpen}: {isOpen: boolean}) => (\n <svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" fill=\"none\" aria-hidden=\"true\">\n <path\n d=\"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8Z\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinejoin=\"round\"\n />\n <circle cx=\"8\" cy=\"8\" r=\"2\" stroke=\"currentColor\" strokeWidth=\"1.5\" />\n {!isOpen && <path d=\"M2.5 13.5l11-11\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />}\n </svg>\n);\n\nconst defaultCount = (value: string): number => value.trim().length;\n\ntype ControlState<E extends HTMLInputElement | HTMLTextAreaElement> = {\n id?: string;\n errors: ReadonlyArray<string>;\n characterLimit?: number;\n countCharacters: (value: string) => number;\n value?: ChangeEvent<E>['target']['value'] | number | ReadonlyArray<string>;\n defaultValue?: ChangeEvent<E>['target']['value'] | number | ReadonlyArray<string>;\n onChange?: (event: ChangeEvent<E>) => void;\n describedBy?: string;\n};\n\n/**\n * What `Input` and `Textarea` work out the same way: the key the error label is\n * named by, whether the control has to be pointed at the errors by hand, and\n * what is left under the character limit.\n */\nconst useControlState = <E extends HTMLInputElement | HTMLTextAreaElement>({\n id,\n errors,\n characterLimit,\n countCharacters,\n value,\n defaultValue,\n onChange,\n describedBy,\n}: ControlState<E>) => {\n const isInField = useIsInField();\n const fallbackKey = useId();\n const errorsKey = id ?? fallbackKey;\n // The counter needs the text even when the control is not controlled.\n const [uncontrolledValue, setUncontrolledValue] = useState<string>(String(defaultValue ?? ''));\n\n const isInvalid = errors.length > 0;\n const text = value === undefined ? uncontrolledValue : String(value);\n const remaining = characterLimit === undefined ? undefined : characterLimit - countCharacters(text);\n\n const handleChange = (event: ChangeEvent<E>): void => {\n if (value === undefined) {\n setUncontrolledValue(event.target.value);\n }\n\n onChange?.(event);\n };\n\n const ariaProps = {\n // Left out rather than `undefined` when valid: a Field marked invalid writes its own.\n ...(isInvalid ? {'aria-invalid': true} : {}),\n // Inside a Field the description registers itself; outside one it is pointed at here.\n ...(isInvalid && !isInField ? {'aria-describedby': cn(describedBy, errorLabelTextId(errorsKey))} : {}),\n };\n\n return {errorsKey, isInField, isInvalid, remaining, handleChange, ariaProps};\n};\n\nconst Counter = ({remaining}: {remaining: number}) => (\n <InputGroupText className=\"input-group__counter\" data-over={remaining < 0 || undefined}>\n {remaining}\n </InputGroupText>\n);\n\n/**\n * The errors as hidden text inside a Field, as a Base UI description, so the\n * control is described by them next to the field's own description. Outside a\n * Field the error label writes this text and the control is pointed at it.\n */\nconst HiddenErrors = ({errorsKey, errors}: {errorsKey: string; errors: ReadonlyArray<string>}) => {\n const isInField = useIsInField();\n const text = errors.join('. ');\n\n // Base UI throws for a description with no Field around it.\n return isInField ? (\n <BaseField.Description id={errorLabelTextId(errorsKey)} hidden>\n {text}\n </BaseField.Description>\n ) : (\n <span id={errorLabelTextId(errorsKey)} hidden>\n {text}\n </span>\n );\n};\n\n/**\n * A text field, a password field or a number field, by `type`. A password gets\n * the show-password button; a number stays the native input, so its value is\n * the string the user typed, a comma included.\n */\nconst Input = ({\n type = 'text',\n id,\n errors = [],\n tone = InputTone.Danger,\n showErrors = true,\n onErrorsClick,\n characterLimit,\n countCharacters = defaultCount,\n isDisabled = false,\n startAddon,\n endAddon,\n passwordToggleLabel = 'Show password',\n groupClassName,\n groupStyle,\n value,\n defaultValue,\n onChange,\n ...props\n}: InputProps) => {\n const [isRevealed, setRevealed] = useState<boolean>(false);\n const {errorsKey, isInField, isInvalid, remaining, handleChange, ariaProps} = useControlState<HTMLInputElement>({\n id,\n errors,\n characterLimit,\n countCharacters,\n value,\n defaultValue,\n onChange,\n describedBy: props['aria-describedby'],\n });\n\n const isPassword = type === 'password';\n\n return (\n <InputGroup tone={tone} isInvalid={isInvalid} className={groupClassName} style={groupStyle}>\n {startAddon !== undefined && <InputGroupAddon align=\"inline-start\">{startAddon}</InputGroupAddon>}\n <InputGroupInput\n {...props}\n // Inside a Field the id is Base UI's, so the label finds the input.\n id={id}\n type={isPassword && isRevealed ? 'text' : type}\n value={value}\n defaultValue={defaultValue}\n onChange={handleChange}\n disabled={isDisabled}\n {...ariaProps}\n />\n {(endAddon !== undefined || isPassword || remaining !== undefined || (isInvalid && showErrors)) && (\n <InputGroupAddon align=\"inline-end\">\n {endAddon}\n {isPassword && (\n <InputGroupButton\n aria-label={passwordToggleLabel}\n aria-pressed={isRevealed}\n disabled={isDisabled}\n onClick={() => setRevealed((previous) => !previous)}\n >\n <EyeIcon isOpen={isRevealed} />\n </InputGroupButton>\n )}\n {remaining !== undefined && <Counter remaining={remaining} />}\n {isInvalid && showErrors && (\n <ErrorLabel\n elementId={errorsKey}\n errors={errors}\n tone={tone}\n onClick={onErrorsClick}\n hasDescription={!isInField}\n />\n )}\n </InputGroupAddon>\n )}\n {isInvalid && (isInField || !showErrors) && <HiddenErrors errorsKey={errorsKey} errors={errors} />}\n </InputGroup>\n );\n};\n\n/**\n * A field for more than a line, the same box as `Input`. The `!` mark sits in\n * the top corner, next to the first line; the counter in the bottom one, next to\n * where the typing is.\n */\nconst Textarea = ({\n id,\n rows = 3,\n errors = [],\n tone = InputTone.Danger,\n showErrors = true,\n onErrorsClick,\n characterLimit,\n countCharacters = defaultCount,\n isDisabled = false,\n groupClassName,\n groupStyle,\n value,\n defaultValue,\n onChange,\n ...props\n}: TextareaProps) => {\n const {errorsKey, isInField, isInvalid, remaining, handleChange, ariaProps} = useControlState<HTMLTextAreaElement>({\n id,\n errors,\n characterLimit,\n countCharacters,\n value,\n defaultValue,\n onChange,\n describedBy: props['aria-describedby'],\n });\n\n return (\n <InputGroup\n tone={tone}\n isInvalid={isInvalid}\n className={cn('input-group--multiline', groupClassName)}\n style={groupStyle}\n data-has-errors={(isInvalid && showErrors) || undefined}\n data-has-counter={remaining !== undefined || undefined}\n >\n <InputGroupTextarea\n {...props}\n id={id}\n rows={rows}\n value={value}\n defaultValue={defaultValue}\n onChange={handleChange}\n disabled={isDisabled}\n {...ariaProps}\n />\n {isInvalid && showErrors && (\n <InputGroupAddon align=\"block-start\">\n <ErrorLabel\n elementId={errorsKey}\n errors={errors}\n tone={tone}\n onClick={onErrorsClick}\n hasDescription={!isInField}\n />\n </InputGroupAddon>\n )}\n {remaining !== undefined && (\n <InputGroupAddon align=\"block-end\">\n <Counter remaining={remaining} />\n </InputGroupAddon>\n )}\n {isInvalid && (isInField || !showErrors) && <HiddenErrors errorsKey={errorsKey} errors={errors} />}\n </InputGroup>\n );\n};\n\nexport default Input;\n\nexport type {\n FieldDescriptionProps,\n FieldGroupProps,\n FieldLabelProps,\n FieldProps,\n InputGroupAddonProps,\n InputGroupButtonProps,\n InputGroupInputProps,\n InputGroupProps,\n InputGroupTextareaProps,\n InputGroupTextProps,\n InputProps,\n TextareaProps,\n};\nexport {\n Field,\n FieldDescription,\n FieldGroup,\n FieldLabel,\n Input,\n InputGroup,\n InputGroupAddon,\n InputGroupButton,\n InputGroupInput,\n InputGroupText,\n InputGroupTextarea,\n InputTone,\n Textarea,\n};\n"],"mappings":";;;;;;;;AAOA,IAAM,KAAM,GAAG,MAAiC,EAAK,EAAO,ECKtD,IAAe,EAAuB,GAAM,EAE5C,UAA8B,EAAW,EAAa,EAGtD,KAAS,EAAC,iBAAc,YAAY,eAAY,cAAW,cAAW,GAA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MAAc,KAAA,KAAa,kBAAC,GAAD,EAAoB,cAAa,CAAA;KAC5D,KAAa,KACZ,kBAAC,GAAD;MACE,WAAW;MACH;MACF;MACN,SAAS;MACT,gBAAgB,CAAC;MACjB,CAAA;KAEY;;GAEnB,MAAc,KAAa,CAAC,MAAe,kBAAC,GAAD;IAAyB;IAAmB;IAAU,CAAA;GACvF;;GASX,KAAY,EAChB,OACA,UAAO,GACP,YAAS,EAAE,EACX,UAAO,EAAU,QACjB,gBAAa,IACb,kBACA,mBACA,qBAAkB,GAClB,gBAAa,IACb,mBACA,eACA,UACA,iBACA,aACA,GAAG,QACgB;CACnB,IAAM,EAAC,cAAW,cAAW,cAAW,cAAW,iBAAc,iBAAa,EAAqC;EACjH;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa,EAAM;EACpB,CAAC;CAEF,OACE,kBAAC,GAAD;EACQ;EACK;EACX,WAAW,EAAG,0BAA0B,EAAe;EACvD,OAAO;EACP,mBAAkB,KAAa,KAAe,KAAA;EAC9C,oBAAkB,MAAc,KAAA,KAAa,KAAA;YAN/C;GAQE,kBAAC,GAAD;IACE,GAAI;IACA;IACE;IACC;IACO;IACd,UAAU;IACV,UAAU;IACV,GAAI;IACJ,CAAA;GACD,KAAa,KACZ,kBAAC,GAAD;IAAiB,OAAM;cACrB,kBAAC,GAAD;KACE,WAAW;KACH;KACF;KACN,SAAS;KACT,gBAAgB,CAAC;KACjB,CAAA;IACc,CAAA;GAEnB,MAAc,KAAA,KACb,kBAAC,GAAD;IAAiB,OAAM;cACrB,kBAAC,GAAD,EAAoB,cAAa,CAAA;IACjB,CAAA;GAEnB,MAAc,KAAa,CAAC,MAAe,kBAAC,GAAD;IAAyB;IAAmB;IAAU,CAAA;GACvF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/cn.ts","../src/field.tsx","../src/types.ts","../src/index.tsx"],"sourcesContent":["import {type ClassValue, clsx} from 'clsx';\n\n/**\n * Joins class names. There is no tailwind-merge here on purpose: the input\n * ships its own stylesheet instead of utility classes, so there is nothing to\n * deduplicate.\n */\nconst cn = (...inputs: ClassValue[]): string => clsx(inputs);\n\nexport {cn};\n","import {Field as BaseField} from '@base-ui-components/react/field';\nimport {type CSSProperties, createContext, forwardRef, type PropsWithoutRef, useContext} from 'react';\nimport {cn} from './cn';\nimport type {FieldDescriptionProps, FieldGroupProps, FieldLabelProps, FieldProps} from './types';\n\n/*\n * The parts follow shadcn's Field, on Base UI's. The field wires itself: the\n * label points at the input, and the input is described by the description and\n * by its errors, with no ids written by hand.\n */\n\n/** Whether a part is standing inside a `Field`, which then does the wiring. */\nconst FieldContext = createContext<boolean>(false);\n\nconst useIsInField = (): boolean => useContext(FieldContext);\n\n/** A label, a control and a description, stacked or in a row. */\nconst Field = forwardRef<HTMLDivElement, PropsWithoutRef<FieldProps>>(\n ({orientation = 'vertical', isDisabled, isInvalid, className, ...props}, ref) => (\n <FieldContext.Provider value={true}>\n <BaseField.Root\n {...props}\n ref={ref}\n disabled={isDisabled}\n invalid={isInvalid}\n data-orientation={orientation}\n className={cn('field', className)}\n />\n </FieldContext.Provider>\n ),\n);\nField.displayName = 'Field';\n\n/** The label. Inside a `Field` it finds the input itself; outside one, pass `htmlFor`. */\nconst FieldLabel = forwardRef<HTMLLabelElement, PropsWithoutRef<FieldLabelProps>>(\n ({isRequired = false, className, ...props}, ref) => (\n <BaseField.Label\n {...props}\n ref={ref}\n data-required={isRequired || undefined}\n className={cn('field-label', className)}\n />\n ),\n);\nFieldLabel.displayName = 'FieldLabel';\n\n/** Quiet text under the input. The input is described by it. */\nconst FieldDescription = forwardRef<HTMLParagraphElement, PropsWithoutRef<FieldDescriptionProps>>(\n ({className, ...props}, ref) => (\n <BaseField.Description {...props} ref={ref} className={cn('field-description', className)} />\n ),\n);\nFieldDescription.displayName = 'FieldDescription';\n\n/** Fields of one form, spaced apart; `columns` lays them out in a grid. */\nconst FieldGroup = forwardRef<HTMLDivElement, PropsWithoutRef<FieldGroupProps>>(\n ({columns, className, style, ...props}, ref) => (\n <div\n {...props}\n ref={ref}\n data-columns={columns}\n className={cn('field-group', className)}\n style={columns === undefined ? style : ({'--field-group-columns': columns, ...style} as CSSProperties)}\n />\n ),\n);\nFieldGroup.displayName = 'FieldGroup';\n\nexport {Field, FieldDescription, FieldGroup, FieldLabel, useIsInField};\n","import type {Button as BaseButton} from '@base-ui-components/react/button';\nimport type {Field as BaseField} from '@base-ui-components/react/field';\nimport type {ComponentProps, ComponentPropsWithRef, ReactNode, Ref} from 'react';\n\n/** Which colour the errors are shown in. */\nexport const InputTone = {\n /** Something is wrong and has to be fixed. */\n Danger: 'danger',\n /** Something is allowed but worth a second look — a bid far above the market. */\n Warning: 'warning',\n} as const;\nexport type InputTone = (typeof InputTone)[keyof typeof InputTone];\n\nexport type InputGroupProps = ComponentPropsWithRef<'div'> & {\n /** Colour of the contour when the group is invalid. @default 'danger' */\n tone?: InputTone;\n /** Draws the contour in the tone. Set by `Input` when it has errors. */\n isInvalid?: boolean;\n};\n\nexport type InputGroupInputProps = ComponentPropsWithRef<'input'>;\n\nexport type InputGroupAddonProps = ComponentPropsWithRef<'div'> & {\n /**\n * Where the addon stands. `inline-*` beside the text of an input;\n * `block-*` in the top or bottom end corner of a textarea. @default 'inline-end'\n */\n align?: 'inline-start' | 'inline-end' | 'block-start' | 'block-end';\n};\n\nexport type InputGroupTextProps = ComponentPropsWithRef<'span'>;\n\nexport type InputGroupButtonProps = Omit<ComponentProps<typeof BaseButton>, 'className'> & {\n className?: string;\n};\n\nexport type FieldProps = Omit<ComponentProps<typeof BaseField.Root>, 'className' | 'disabled' | 'invalid'> & {\n className?: string;\n /** `horizontal` puts the parts in a row: an input and its button, a checkbox and its label. @default 'vertical' */\n orientation?: 'vertical' | 'horizontal';\n /** Switches off the input inside and fades the label and the description. */\n isDisabled?: boolean;\n /** Marks the field invalid: the contour, the label and `aria-invalid` on the input. */\n isInvalid?: boolean;\n};\n\nexport type FieldLabelProps = Omit<ComponentProps<typeof BaseField.Label>, 'className'> & {\n className?: string;\n /** Adds the asterisk. The input itself takes `required` separately. */\n isRequired?: boolean;\n};\n\nexport type FieldDescriptionProps = Omit<ComponentProps<typeof BaseField.Description>, 'className'> & {\n className?: string;\n};\n\nexport type FieldGroupProps = ComponentPropsWithRef<'div'> & {\n /** Lays the fields out in this many equal columns. Stacked when omitted. */\n columns?: number;\n};\n\n/** What `Input` and `Textarea` share: the errors, the counter, the switch and the box. */\ntype FieldControlOwnProps = {\n /**\n * Shown behind the `!` mark at the end of the field. A non-empty list also\n * draws the contour in the tone and sets `aria-invalid`.\n */\n errors?: ReadonlyArray<string>;\n /** Which colour the errors are shown in. @default 'danger' */\n tone?: InputTone;\n /** Hides the `!` mark and keeps the contour and the description. @default true */\n showErrors?: boolean;\n /** Called when the `!` mark is clicked. */\n onErrorsClick?: () => void;\n /**\n * Shows how many characters are left. Typing past it is allowed and turns the\n * counter red — unlike the native `maxLength`, which stops the keyboard.\n */\n characterLimit?: number;\n /** Counts the value for `characterLimit`. @default trimmed length */\n countCharacters?: (value: string) => number;\n /** Switches the field off. The native `disabled` is not accepted, as on Button. */\n isDisabled?: boolean;\n /** On the group, the box that draws the contour. `className` stays on the control. */\n groupClassName?: string;\n groupStyle?: InputGroupProps['style'];\n};\n\nexport type InputProps = Omit<ComponentPropsWithRef<'input'>, 'disabled' | 'size'> &\n FieldControlOwnProps & {\n /** Before the text: an icon, a currency sign. */\n startAddon?: ReactNode;\n /** After the text, before the counter and the `!` mark. */\n endAddon?: ReactNode;\n /** Names the show-password button. @default 'Show password' */\n passwordToggleLabel?: string;\n ref?: Ref<HTMLInputElement>;\n };\n\nexport type InputGroupTextareaProps = ComponentPropsWithRef<'textarea'>;\n\nexport type TextareaProps = Omit<ComponentPropsWithRef<'textarea'>, 'disabled'> &\n FieldControlOwnProps & {\n /**\n * The height it starts at, in lines. The field grows with the text past it\n * where the browser can size a field by its content. @default 3\n */\n rows?: number;\n ref?: Ref<HTMLTextAreaElement>;\n };\n","import {Button as BaseButton} from '@base-ui-components/react/button';\nimport {Field as BaseField} from '@base-ui-components/react/field';\nimport {Input as BaseInput} from '@base-ui-components/react/input';\nimport ErrorLabel, {errorLabelTextId} from '@propellerads/error-label';\nimport {type ChangeEvent, type ComponentProps, forwardRef, type PropsWithoutRef, useId, useState} from 'react';\nimport './input.css';\nimport {cn} from './cn';\nimport {Field, FieldDescription, FieldGroup, FieldLabel, useIsInField} from './field';\nimport {\n type FieldDescriptionProps,\n type FieldGroupProps,\n type FieldLabelProps,\n type FieldProps,\n type InputGroupAddonProps,\n type InputGroupButtonProps,\n type InputGroupInputProps,\n type InputGroupProps,\n type InputGroupTextareaProps,\n type InputGroupTextProps,\n type InputProps,\n InputTone,\n type TextareaProps,\n} from './types';\n\n/*\n * The parts follow shadcn's Input Group, on Base UI instead of Radix. The group is\n * the box — contour, corners, focus ring — and the control inside it draws\n * nothing, so an icon, a counter or a button can stand in the same box. `Input`\n * and `Textarea` below are the group with the common parts filled in.\n */\n\n/** The box. Draws the contour and the focus ring for the control inside it. */\nconst InputGroup = forwardRef<HTMLDivElement, PropsWithoutRef<InputGroupProps>>(\n ({tone = InputTone.Danger, isInvalid = false, className, ...props}, ref) => (\n <div\n {...props}\n ref={ref}\n data-tone={tone}\n data-invalid={isInvalid || undefined}\n className={cn('input-group', className)}\n />\n ),\n);\nInputGroup.displayName = 'InputGroup';\n\n/** The `<input>` inside a group. Takes every native prop. */\nconst InputGroupInput = forwardRef<HTMLInputElement, PropsWithoutRef<InputGroupInputProps>>(\n ({className, ...props}, ref) => <BaseInput {...props} ref={ref} className={cn('input-group__control', className)} />,\n);\nInputGroupInput.displayName = 'InputGroupInput';\n\n/** The `<textarea>` inside a group. Takes every native prop. */\nconst InputGroupTextarea = forwardRef<HTMLTextAreaElement, PropsWithoutRef<InputGroupTextareaProps>>(\n ({className, ...props}, ref) => (\n <BaseField.Control\n // Base UI types the control as an <input>, and renders a textarea through\n // `render` the way its own docs do; the props are the textarea's.\n {...(props as unknown as ComponentProps<typeof BaseField.Control>)}\n ref={ref as unknown as ComponentProps<typeof BaseField.Control>['ref']}\n render={<textarea />}\n className={cn('input-group__control', 'input-group__control--multiline', className)}\n />\n ),\n);\nInputGroupTextarea.displayName = 'InputGroupTextarea';\n\n/** Something that stands beside the text: an icon, a unit, a button. */\nconst InputGroupAddon = forwardRef<HTMLDivElement, PropsWithoutRef<InputGroupAddonProps>>(\n ({align = 'inline-end', className, ...props}, ref) => (\n <div\n {...props}\n ref={ref}\n data-align={align}\n className={cn('input-group__addon', `input-group__addon--${align}`, className)}\n />\n ),\n);\nInputGroupAddon.displayName = 'InputGroupAddon';\n\n/** Quiet text inside the box: a unit, a prefix, a counter. */\nconst InputGroupText = forwardRef<HTMLSpanElement, PropsWithoutRef<InputGroupTextProps>>(\n ({className, ...props}, ref) => <span {...props} ref={ref} className={cn('input-group__text', className)} />,\n);\nInputGroupText.displayName = 'InputGroupText';\n\n/** A small square button inside the box. Name it with `aria-label` when it is only an icon. */\nconst InputGroupButton = forwardRef<HTMLButtonElement, PropsWithoutRef<InputGroupButtonProps>>(\n ({className, ...props}, ref) => (\n <BaseButton type=\"button\" {...props} ref={ref} className={cn('input-group__button', className)} />\n ),\n);\nInputGroupButton.displayName = 'InputGroupButton';\n\nconst EyeIcon = ({isOpen}: {isOpen: boolean}) => (\n <svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" fill=\"none\" aria-hidden=\"true\">\n <path\n d=\"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8Z\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinejoin=\"round\"\n />\n <circle cx=\"8\" cy=\"8\" r=\"2\" stroke=\"currentColor\" strokeWidth=\"1.5\" />\n {!isOpen && <path d=\"M2.5 13.5l11-11\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />}\n </svg>\n);\n\nconst defaultCount = (value: string): number => value.trim().length;\n\ntype ControlState<E extends HTMLInputElement | HTMLTextAreaElement> = {\n id?: string;\n errors: ReadonlyArray<string>;\n characterLimit?: number;\n countCharacters: (value: string) => number;\n value?: ChangeEvent<E>['target']['value'] | number | ReadonlyArray<string>;\n defaultValue?: ChangeEvent<E>['target']['value'] | number | ReadonlyArray<string>;\n onChange?: (event: ChangeEvent<E>) => void;\n describedBy?: string;\n};\n\n/**\n * What `Input` and `Textarea` work out the same way: the key the error label is\n * named by, whether the control has to be pointed at the errors by hand, and\n * what is left under the character limit.\n */\nconst useControlState = <E extends HTMLInputElement | HTMLTextAreaElement>({\n id,\n errors,\n characterLimit,\n countCharacters,\n value,\n defaultValue,\n onChange,\n describedBy,\n}: ControlState<E>) => {\n const isInField = useIsInField();\n const fallbackKey = useId();\n const errorsKey = id ?? fallbackKey;\n // The counter needs the text even when the control is not controlled.\n const [uncontrolledValue, setUncontrolledValue] = useState<string>(String(defaultValue ?? ''));\n\n const isInvalid = errors.length > 0;\n const text = value === undefined ? uncontrolledValue : String(value);\n const remaining = characterLimit === undefined ? undefined : characterLimit - countCharacters(text);\n\n const handleChange = (event: ChangeEvent<E>): void => {\n if (value === undefined) {\n setUncontrolledValue(event.target.value);\n }\n\n onChange?.(event);\n };\n\n const ariaProps = {\n // Left out rather than `undefined` when valid: a Field marked invalid writes its own.\n ...(isInvalid ? {'aria-invalid': true} : {}),\n // Inside a Field the description registers itself; outside one it is pointed at here.\n ...(isInvalid && !isInField ? {'aria-describedby': cn(describedBy, errorLabelTextId(errorsKey))} : {}),\n };\n\n return {errorsKey, isInField, isInvalid, remaining, handleChange, ariaProps};\n};\n\nconst Counter = ({remaining}: {remaining: number}) => (\n <InputGroupText className=\"input-group__counter\" data-over={remaining < 0 || undefined}>\n {remaining}\n </InputGroupText>\n);\n\n/**\n * The errors as hidden text inside a Field, as a Base UI description, so the\n * control is described by them next to the field's own description. Outside a\n * Field the error label writes this text and the control is pointed at it.\n */\nconst HiddenErrors = ({errorsKey, errors}: {errorsKey: string; errors: ReadonlyArray<string>}) => {\n const isInField = useIsInField();\n const text = errors.join('. ');\n\n // Base UI throws for a description with no Field around it.\n return isInField ? (\n <BaseField.Description id={errorLabelTextId(errorsKey)} hidden>\n {text}\n </BaseField.Description>\n ) : (\n <span id={errorLabelTextId(errorsKey)} hidden>\n {text}\n </span>\n );\n};\n\n/**\n * A text field, a password field or a number field, by `type`. A password gets\n * the show-password button; a number stays the native input, so its value is\n * the string the user typed, a comma included.\n */\nconst Input = forwardRef<HTMLInputElement, PropsWithoutRef<InputProps>>(\n (\n {\n type = 'text',\n id,\n errors = [],\n tone = InputTone.Danger,\n showErrors = true,\n onErrorsClick,\n characterLimit,\n countCharacters = defaultCount,\n isDisabled = false,\n startAddon,\n endAddon,\n passwordToggleLabel = 'Show password',\n groupClassName,\n groupStyle,\n value,\n defaultValue,\n onChange,\n ...props\n },\n ref,\n ) => {\n const [isRevealed, setRevealed] = useState<boolean>(false);\n const {errorsKey, isInField, isInvalid, remaining, handleChange, ariaProps} = useControlState<HTMLInputElement>({\n id,\n errors,\n characterLimit,\n countCharacters,\n value,\n defaultValue,\n onChange,\n describedBy: props['aria-describedby'],\n });\n\n const isPassword = type === 'password';\n\n return (\n <InputGroup tone={tone} isInvalid={isInvalid} className={groupClassName} style={groupStyle}>\n {startAddon !== undefined && <InputGroupAddon align=\"inline-start\">{startAddon}</InputGroupAddon>}\n <InputGroupInput\n {...props}\n ref={ref}\n // Inside a Field the id is Base UI's, so the label finds the input.\n id={id}\n type={isPassword && isRevealed ? 'text' : type}\n value={value}\n defaultValue={defaultValue}\n onChange={handleChange}\n disabled={isDisabled}\n {...ariaProps}\n />\n {(endAddon !== undefined || isPassword || remaining !== undefined || (isInvalid && showErrors)) && (\n <InputGroupAddon align=\"inline-end\">\n {endAddon}\n {isPassword && (\n <InputGroupButton\n aria-label={passwordToggleLabel}\n aria-pressed={isRevealed}\n disabled={isDisabled}\n onClick={() => setRevealed((previous) => !previous)}\n >\n <EyeIcon isOpen={isRevealed} />\n </InputGroupButton>\n )}\n {remaining !== undefined && <Counter remaining={remaining} />}\n {isInvalid && showErrors && (\n <ErrorLabel\n elementId={errorsKey}\n errors={errors}\n tone={tone}\n onClick={onErrorsClick}\n hasDescription={!isInField}\n />\n )}\n </InputGroupAddon>\n )}\n {isInvalid && (isInField || !showErrors) && <HiddenErrors errorsKey={errorsKey} errors={errors} />}\n </InputGroup>\n );\n },\n);\nInput.displayName = 'Input';\n\n/**\n * A field for more than a line, the same box as `Input`. The `!` mark sits in\n * the top corner, next to the first line; the counter in the bottom one, next to\n * where the typing is.\n */\nconst Textarea = forwardRef<HTMLTextAreaElement, PropsWithoutRef<TextareaProps>>(\n (\n {\n id,\n rows = 3,\n errors = [],\n tone = InputTone.Danger,\n showErrors = true,\n onErrorsClick,\n characterLimit,\n countCharacters = defaultCount,\n isDisabled = false,\n groupClassName,\n groupStyle,\n value,\n defaultValue,\n onChange,\n ...props\n },\n ref,\n ) => {\n const {errorsKey, isInField, isInvalid, remaining, handleChange, ariaProps} = useControlState<HTMLTextAreaElement>({\n id,\n errors,\n characterLimit,\n countCharacters,\n value,\n defaultValue,\n onChange,\n describedBy: props['aria-describedby'],\n });\n\n return (\n <InputGroup\n tone={tone}\n isInvalid={isInvalid}\n className={cn('input-group--multiline', groupClassName)}\n style={groupStyle}\n data-has-errors={(isInvalid && showErrors) || undefined}\n data-has-counter={remaining !== undefined || undefined}\n >\n <InputGroupTextarea\n {...props}\n ref={ref}\n id={id}\n rows={rows}\n value={value}\n defaultValue={defaultValue}\n onChange={handleChange}\n disabled={isDisabled}\n {...ariaProps}\n />\n {isInvalid && showErrors && (\n <InputGroupAddon align=\"block-start\">\n <ErrorLabel\n elementId={errorsKey}\n errors={errors}\n tone={tone}\n onClick={onErrorsClick}\n hasDescription={!isInField}\n />\n </InputGroupAddon>\n )}\n {remaining !== undefined && (\n <InputGroupAddon align=\"block-end\">\n <Counter remaining={remaining} />\n </InputGroupAddon>\n )}\n {isInvalid && (isInField || !showErrors) && <HiddenErrors errorsKey={errorsKey} errors={errors} />}\n </InputGroup>\n );\n },\n);\nTextarea.displayName = 'Textarea';\n\nexport default Input;\n\nexport type {\n FieldDescriptionProps,\n FieldGroupProps,\n FieldLabelProps,\n FieldProps,\n InputGroupAddonProps,\n InputGroupButtonProps,\n InputGroupInputProps,\n InputGroupProps,\n InputGroupTextareaProps,\n InputGroupTextProps,\n InputProps,\n TextareaProps,\n};\nexport {\n Field,\n FieldDescription,\n FieldGroup,\n FieldLabel,\n Input,\n InputGroup,\n InputGroupAddon,\n InputGroupButton,\n InputGroupInput,\n InputGroupText,\n InputGroupTextarea,\n InputTone,\n Textarea,\n};\n"],"mappings":";;;;;;;;AAOA,IAAM,KAAM,GAAG,MAAiC,EAAK,EAAO,ECKtD,IAAe,EAAuB,GAAM,EAE5C,UAA8B,EAAW,EAAa,EAGtD,IAAQ,GACX,EAAC,iBAAc,YAAY,eAAY,cAAW,cAAW,GAAG,KAAQ,MACvE,kBAAC,EAAa,UAAd;CAAuB,OAAO;WAC5B,kBAAC,EAAU,MAAX;EACE,GAAI;EACC;EACL,UAAU;EACV,SAAS;EACT,oBAAkB;EAClB,WAAW,EAAG,SAAS,EAAU;EACjC,CAAA;CACoB,CAAA,CAE3B;AACD,EAAM,cAAc;AAGpB,IAAM,IAAa,GAChB,EAAC,gBAAa,IAAO,cAAW,GAAG,KAAQ,MAC1C,kBAAC,EAAU,OAAX;CACE,GAAI;CACC;CACL,iBAAe,KAAc,KAAA;CAC7B,WAAW,EAAG,eAAe,EAAU;CACvC,CAAA,CAEL;AACD,EAAW,cAAc;AAGzB,IAAM,IAAmB,GACtB,EAAC,cAAW,GAAG,KAAQ,MACtB,kBAAC,EAAU,aAAX;CAAuB,GAAI;CAAY;CAAK,WAAW,EAAG,qBAAqB,EAAU;CAAI,CAAA,CAEhG;AACD,EAAiB,cAAc;AAG/B,IAAM,IAAa,GAChB,EAAC,YAAS,cAAW,UAAO,GAAG,KAAQ,MACtC,kBAAC,OAAD;CACE,GAAI;CACC;C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CAAC,MAAe,kBAAC,GAAD;IAAyB;IAAmB;IAAU,CAAA;GACvF;;EAGlB;AACD,EAAM,cAAc;AAOpB,IAAM,IAAW,GAEb,EACE,OACA,UAAO,GACP,YAAS,EAAE,EACX,UAAO,EAAU,QACjB,gBAAa,IACb,kBACA,mBACA,qBAAkB,GAClB,gBAAa,IACb,mBACA,eACA,UACA,iBACA,aACA,GAAG,KAEL,MACG;CACH,IAAM,EAAC,cAAW,cAAW,cAAW,cAAW,iBAAc,iBAAa,EAAqC;EACjH;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa,EAAM;EACpB,CAAC;CAEF,OACE,kBAAC,GAAD;EACQ;EACK;EACX,WAAW,EAAG,0BAA0B,EAAe;EACvD,OAAO;EACP,mBAAkB,KAAa,KAAe,KAAA;EAC9C,oBAAkB,MAAc,KAAA,KAAa,KAAA;YAN/C;GAQE,kBAAC,GAAD;IACE,GAAI;IACC;IACD;IACE;IACC;IACO;IACd,UAAU;IACV,UAAU;IACV,GAAI;IACJ,CAAA;GACD,KAAa,KACZ,kBAAC,GAAD;IAAiB,OAAM;cACrB,kBAAC,GAAD;KACE,WAAW;KACH;KACF;KACN,SAAS;KACT,gBAAgB,CAAC;KACjB,CAAA;IACc,CAAA;GAEnB,MAAc,KAAA,KACb,kBAAC,GAAD;IAAiB,OAAM;cACrB,kBAAC,GAAD,EAAoB,cAAa,CAAA;IACjB,CAAA;GAEnB,MAAc,KAAa,CAAC,MAAe,kBAAC,GAAD;IAAyB;IAAmB;IAAU,CAAA;GACvF;;EAGlB;AACD,EAAS,cAAc"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@propellerads/input",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/index.css",