@leonardaustin/ui 0.26.0 → 0.26.2

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.
@@ -16,4 +16,4 @@ export interface PaginationProps extends Omit<ComponentPropsWithRef<"div">, "chi
16
16
  */
17
17
  summary?: ReactNode | ((total: number | undefined) => ReactNode);
18
18
  }
19
- export declare function Pagination({ page, totalPages, onPageChange, loading, total, summary, className, ref, ...rest }: PaginationProps): import("react/jsx-runtime").JSX.Element | null;
19
+ export declare function Pagination({ page, totalPages, onPageChange, loading, total, summary, className, ref, ...rest }: PaginationProps): import("react/jsx-runtime").JSX.Element;
@@ -3,17 +3,16 @@ import { Fragment as t, jsx as n, jsxs as r } from "react/jsx-runtime";
3
3
  import { ChevronLeft as i, ChevronRight as a } from "lucide-react";
4
4
  //#region src/components/tables/Pagination.tsx
5
5
  function o({ page: o, totalPages: s, onPageChange: c, loading: l = !1, total: u, summary: d, className: f, ref: p, ...m }) {
6
- if (s <= 1 && !l && u === void 0 && d == null) return null;
7
- let h = [];
8
- for (let e = 1; e <= s; e++) e === 1 || e === s || e >= o - 1 && e <= o + 1 ? h.push(e) : h[h.length - 1] !== "ellipsis" && h.push("ellipsis");
6
+ let h = s <= 1 && !l && u === void 0 && d == null, g = d !== null && (l || u !== void 0 || d !== void 0), _ = [];
7
+ for (let e = 1; e <= s; e++) e === 1 || e === s || e >= o - 1 && e <= o + 1 ? _.push(e) : _[_.length - 1] !== "ellipsis" && _.push("ellipsis");
9
8
  return /* @__PURE__ */ r("div", {
10
9
  ref: p,
11
10
  ...m,
12
- className: e("flex items-center gap-1", f),
13
- children: [d !== null && (l || u !== void 0 || d !== void 0) && /* @__PURE__ */ n("span", {
11
+ className: h ? "contents" : e("flex items-center gap-1", f),
12
+ children: [/* @__PURE__ */ n("span", {
14
13
  role: "status",
15
- className: "text-text-tertiary text-xs",
16
- children: l ? "Loading results..." : d === void 0 ? `${u} in total` : typeof d == "function" ? d(u) : d
14
+ className: g ? "text-text-tertiary text-xs" : "sr-only",
15
+ children: g && (l ? "Loading results..." : d === void 0 ? `${u} in total` : typeof d == "function" ? d(u) : d)
17
16
  }), s > 1 && /* @__PURE__ */ r(t, { children: [
18
17
  /* @__PURE__ */ n("button", {
19
18
  type: "button",
@@ -26,7 +25,7 @@ function o({ page: o, totalPages: s, onPageChange: c, loading: l = !1, total: u,
26
25
  "aria-label": "Previous page",
27
26
  children: /* @__PURE__ */ n(i, { className: "h-3.5 w-3.5" })
28
27
  }),
29
- h.map((t, r) => t === "ellipsis" ? /* @__PURE__ */ n("span", {
28
+ _.map((t, r) => t === "ellipsis" ? /* @__PURE__ */ n("span", {
30
29
  className: "text-text-tertiary flex h-7 w-7 items-center justify-center text-xs",
31
30
  children: "..."
32
31
  }, `e${r}`) : /* @__PURE__ */ n("button", {
@@ -36,4 +36,4 @@ export interface CodeInputProps extends Omit<ComponentPropsWithRef<"div">, "chil
36
36
  * Handles typing, paste, SMS autofill, Backspace/Delete and arrow keys; each
37
37
  * box keeps its position, so clearing one never shifts the others.
38
38
  */
39
- export declare function CodeInput({ value: valueProp, defaultValue, onValueChange, onComplete, length, error, invalid, disabled, autoFocus, name, "aria-label": ariaLabel, className, ref, ...rest }: CodeInputProps): import("react/jsx-runtime").JSX.Element;
39
+ export declare function CodeInput({ value: valueProp, defaultValue, onValueChange, onComplete, length, error, invalid, disabled, autoFocus, name, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, className, ref, ...rest }: CodeInputProps): import("react/jsx-runtime").JSX.Element;
@@ -1,96 +1,97 @@
1
1
  import { cn as e } from "../../lib/cn.js";
2
2
  import { useControllableState as t } from "../../hooks/useControllableState.js";
3
- import { applyBackspace as n, applyInput as r, applyText as i, toSlots as a } from "../../lib/codeInput.js";
4
- import { useId as o, useRef as s, useState as c } from "react";
5
- import { jsx as l, jsxs as u } from "react/jsx-runtime";
3
+ import { describeField as n } from "./FieldContext.js";
4
+ import { applyBackspace as r, applyInput as i, applyText as a, toSlots as o } from "../../lib/codeInput.js";
5
+ import { useId as s, useRef as c, useState as l } from "react";
6
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
6
7
  //#region src/components/ui/CodeInput.tsx
7
- function d({ value: d, defaultValue: f = "", onValueChange: p, onComplete: m, length: h = 6, error: g, invalid: _, disabled: v, autoFocus: y, name: b, "aria-label": x = "Verification code", className: S, ref: C, ...w }) {
8
- let [T, E] = t({
9
- value: d,
10
- defaultValue: f,
11
- onChange: p
12
- }), D = s([]), O = o(), k = _ || !!g, [A, j] = c(() => {
13
- let e = a(T, h);
8
+ function f({ value: f, defaultValue: p = "", onValueChange: m, onComplete: h, length: g = 6, error: _, invalid: v, disabled: y, autoFocus: b, name: x, "aria-label": S = "Verification code", "aria-describedby": C, className: w, ref: T, ...E }) {
9
+ let [D, O] = t({
10
+ value: f,
11
+ defaultValue: p,
12
+ onChange: m
13
+ }), k = c([]), A = s(), j = v || !!_, [M, N] = l(() => {
14
+ let e = o(D, g);
14
15
  return {
15
16
  proposed: e,
16
17
  shown: e
17
18
  };
18
- }), M = (e) => e.length === h && e.join("") === T, [N, P] = c({
19
- value: T,
20
- length: h
19
+ }), P = (e) => e.length === g && e.join("") === D, [F, I] = l({
20
+ value: D,
21
+ length: g
21
22
  });
22
- if ((N.value !== T || N.length !== h) && (P({
23
- value: T,
24
- length: h
25
- }), !M(A.proposed) && !M(A.shown))) {
26
- let e = a(T, h);
27
- j({
23
+ if ((F.value !== D || F.length !== g) && (I({
24
+ value: D,
25
+ length: g
26
+ }), !P(M.proposed) && !P(M.shown))) {
27
+ let e = o(D, g);
28
+ N({
28
29
  proposed: e,
29
30
  shown: e
30
31
  });
31
32
  }
32
- let F = M(A.proposed) ? A.proposed : M(A.shown) ? A.shown : a(T, h);
33
- function I(e) {
34
- let t = D.current[Math.max(0, Math.min(e, h - 1))];
33
+ let L = P(M.proposed) ? M.proposed : P(M.shown) ? M.shown : o(D, g);
34
+ function R(e) {
35
+ let t = k.current[Math.max(0, Math.min(e, g - 1))];
35
36
  t?.focus(), t?.select();
36
37
  }
37
- function L(e) {
38
+ function z(e) {
38
39
  if (!e) return;
39
- j({
40
+ N({
40
41
  proposed: e.slots,
41
- shown: F
42
+ shown: L
42
43
  });
43
44
  let t = e.slots.join("");
44
- E(t), e.slots.every(Boolean) && m?.(t), I(e.focus);
45
+ O(t), e.slots.every(Boolean) && h?.(t), R(e.focus);
45
46
  }
46
- function R(e, t) {
47
- t.key === "Backspace" ? (t.preventDefault(), L(n(F, e))) : t.key === "ArrowLeft" ? (t.preventDefault(), I(e - 1)) : t.key === "ArrowRight" && (t.preventDefault(), I(e + 1));
47
+ function B(e, t) {
48
+ t.key === "Backspace" ? (t.preventDefault(), z(r(L, e))) : t.key === "ArrowLeft" ? (t.preventDefault(), R(e - 1)) : t.key === "ArrowRight" && (t.preventDefault(), R(e + 1));
48
49
  }
49
- return /* @__PURE__ */ u("div", {
50
- ref: C,
51
- ...w,
52
- className: e("flex flex-col gap-1.5", S),
50
+ return /* @__PURE__ */ d("div", {
51
+ ref: T,
52
+ ...E,
53
+ className: e("flex flex-col gap-1.5", w),
53
54
  children: [
54
- /* @__PURE__ */ l("div", {
55
+ /* @__PURE__ */ u("div", {
55
56
  role: "group",
56
- "aria-label": x,
57
+ "aria-label": S,
57
58
  className: "flex justify-between gap-2",
58
- children: F.map((t, n) => /* @__PURE__ */ l("input", {
59
+ children: L.map((t, r) => /* @__PURE__ */ u("input", {
59
60
  ref: (e) => {
60
- D.current[n] = e;
61
+ k.current[r] = e;
61
62
  },
62
63
  type: "text",
63
64
  inputMode: "numeric",
64
- autoComplete: n === 0 ? "one-time-code" : "off",
65
- autoFocus: y && n === 0,
66
- disabled: v,
67
- "aria-label": `Digit ${n + 1} of ${h}`,
68
- "aria-invalid": k || void 0,
69
- "aria-describedby": g ? O : void 0,
65
+ autoComplete: r === 0 ? "one-time-code" : "off",
66
+ autoFocus: b && r === 0,
67
+ disabled: y,
68
+ "aria-label": `Digit ${r + 1} of ${g}`,
69
+ "aria-invalid": j || void 0,
70
+ "aria-describedby": n(C, _ ? A : void 0),
70
71
  value: t,
71
72
  onFocus: (e) => e.target.select(),
72
- onChange: (e) => L(r(F, n, e.target.value, e.target.selectionStart)),
73
- onKeyDown: (e) => R(n, e),
73
+ onChange: (e) => z(i(L, r, e.target.value, e.target.selectionStart)),
74
+ onKeyDown: (e) => B(r, e),
74
75
  onPaste: (e) => {
75
- e.preventDefault(), L(i(F, n, e.clipboardData.getData("text")));
76
+ e.preventDefault(), z(a(L, r, e.clipboardData.getData("text")));
76
77
  },
77
- className: e("bg-bg-secondary text-text-primary h-10 w-10 rounded-md border text-center font-mono text-sm", "transition-colors duration-[100ms]", "focus:border-accent focus:outline-none", "disabled:cursor-not-allowed disabled:opacity-40", k ? "border-danger" : "border-border")
78
- }, n))
78
+ className: e("bg-bg-secondary text-text-primary h-10 w-10 min-w-0 shrink rounded-md border text-center font-mono text-sm", "transition-colors duration-[100ms]", "focus:border-accent focus:outline-none", "disabled:cursor-not-allowed disabled:opacity-40", j ? "border-danger" : "border-border")
79
+ }, r))
79
80
  }),
80
- b && /* @__PURE__ */ l("input", {
81
+ x && /* @__PURE__ */ u("input", {
81
82
  type: "hidden",
82
- name: b,
83
- value: T,
84
- disabled: v
83
+ name: x,
84
+ value: D,
85
+ disabled: y
85
86
  }),
86
- g && /* @__PURE__ */ l("p", {
87
- id: O,
87
+ _ && /* @__PURE__ */ u("p", {
88
+ id: A,
88
89
  role: "alert",
89
90
  className: "text-2xs text-danger-fg",
90
- children: g
91
+ children: _
91
92
  })
92
93
  ]
93
94
  });
94
95
  }
95
96
  //#endregion
96
- export { d as CodeInput };
97
+ export { f as CodeInput };
@@ -35,9 +35,9 @@ interface MetadataItem {
35
35
  value: ReactNode;
36
36
  }
37
37
  export interface MetadataGridProps extends Omit<HTMLAttributes<HTMLElement>, "children"> {
38
- /** Ref to the root element: a `dl` when stacked, otherwise a `div`. */
38
+ /** Ref to the root `dl` element. */
39
39
  ref?: Ref<HTMLElement>;
40
- /** Inline preserves the original two-column markup (unless `striped`); stacked places labels above values. */
40
+ /** Inline places labels beside values in two columns; stacked places labels above values. */
41
41
  layout?: "inline" | "stacked";
42
42
  /** Stacked layout columns at mobile-first breakpoints. */
43
43
  columns?: LayoutResponsive<number>;
@@ -8,7 +8,7 @@ function c(e, t) {
8
8
  return n("stripe", t, (t) => Math.floor(e / t) % 2 == 0 ? "var(--ui-metadata-stripe-color, var(--bg-tertiary))" : "transparent", 1);
9
9
  }
10
10
  function l({ items: l, labelWidth: u = "100px", layout: d = "inline", columns: f = 1, gap: p = 3, striped: m = !1, className: h, ref: g, style: _, ...v }) {
11
- let y = g, b = g;
11
+ let y = g;
12
12
  return d === "stacked" ? /* @__PURE__ */ a("dl", {
13
13
  ...v,
14
14
  ref: y,
@@ -29,9 +29,9 @@ function l({ items: l, labelWidth: u = "100px", layout: d = "inline", columns: f
29
29
  children: t.value
30
30
  })]
31
31
  }, t.label))
32
- }) : m ? /* @__PURE__ */ a("div", {
32
+ }) : m ? /* @__PURE__ */ a("dl", {
33
33
  ...v,
34
- ref: b,
34
+ ref: y,
35
35
  className: e("gap-x-3 text-xs", h),
36
36
  style: {
37
37
  display: "grid",
@@ -46,30 +46,30 @@ function l({ items: l, labelWidth: u = "100px", layout: d = "inline", columns: f
46
46
  gridColumn: "1 / -1",
47
47
  gridTemplateColumns: "subgrid"
48
48
  },
49
- children: [/* @__PURE__ */ a("span", {
49
+ children: [/* @__PURE__ */ a("dt", {
50
50
  className: "text-text-tertiary font-label",
51
51
  children: e.label
52
- }), typeof e.value == "string" || typeof e.value == "number" ? /* @__PURE__ */ a("span", {
52
+ }), typeof e.value == "string" || typeof e.value == "number" ? /* @__PURE__ */ a("dd", {
53
53
  className: "text-text-primary font-data",
54
54
  children: e.value
55
- }) : /* @__PURE__ */ a("span", { children: e.value })]
55
+ }) : /* @__PURE__ */ a("dd", { children: e.value })]
56
56
  }, e.label))
57
- }) : /* @__PURE__ */ a("div", {
57
+ }) : /* @__PURE__ */ a("dl", {
58
58
  ...v,
59
- ref: b,
59
+ ref: y,
60
60
  className: e("gap-x-3 gap-y-2 text-xs", h),
61
61
  style: {
62
62
  display: "grid",
63
63
  gridTemplateColumns: `${u} 1fr`,
64
64
  ..._
65
65
  },
66
- children: l.map((e) => /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ a("span", {
66
+ children: l.map((e) => /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ a("dt", {
67
67
  className: "text-text-tertiary font-label",
68
68
  children: e.label
69
- }), typeof e.value == "string" || typeof e.value == "number" ? /* @__PURE__ */ a("span", {
69
+ }), typeof e.value == "string" || typeof e.value == "number" ? /* @__PURE__ */ a("dd", {
70
70
  className: "text-text-primary font-data",
71
71
  children: e.value
72
- }) : /* @__PURE__ */ a("span", { children: e.value })] }, e.label))
72
+ }) : /* @__PURE__ */ a("dd", { children: e.value })] }, e.label))
73
73
  });
74
74
  }
75
75
  //#endregion
@@ -42,7 +42,7 @@ export interface PaginationBarProps extends Omit<ComponentPropsWithRef<"div">, "
42
42
  summary?: ReactNode | ((total: number) => ReactNode);
43
43
  /** Show a short total caption after the range or custom summary. */
44
44
  showTotal?: boolean;
45
- /** Show a loading caption and disable both navigation and page-size selection. */
45
+ /** Show a loading caption, disable navigation, and mark the page-size selector busy. */
46
46
  loading?: boolean;
47
47
  /**
48
48
  * Options for the page-size dropdown.
@@ -28,15 +28,14 @@ function s({ page: s, pageSize: c, total: l, summary: u, showTotal: d = !1, load
28
28
  children: [h && /* @__PURE__ */ i(t, {
29
29
  size: "sm",
30
30
  value: String(c),
31
- onValueChange: (e) => {
32
- f || h(Number(e));
33
- },
31
+ onValueChange: (e) => h(Number(e)),
34
32
  options: p,
35
33
  className: "w-28",
36
- disabled: f
34
+ role: "group",
35
+ "aria-busy": f || void 0
37
36
  }), /* @__PURE__ */ a("span", {
38
37
  role: "status",
39
- className: e("text-text-tertiary text-xs", !f && "hidden sm:inline"),
38
+ className: e("text-text-tertiary text-xs", !f && "ui-pagination-count"),
40
39
  children: [f ? "Loading results..." : u === void 0 ? /* @__PURE__ */ a(r, { children: [
41
40
  b,
42
41
  "–",
@@ -104,7 +104,7 @@ function u({ label: u, labelPlacement: d = "above", error: f, options: p, classN
104
104
  }),
105
105
  I && /* @__PURE__ */ s("span", {
106
106
  "aria-hidden": "true",
107
- className: "ui-select-placeholder text-text-placeholder font-control pointer-events-none absolute top-1/2 -translate-y-1/2 truncate",
107
+ className: "ui-select-placeholder font-control pointer-events-none absolute top-1/2 -translate-y-1/2 truncate",
108
108
  children: A
109
109
  }),
110
110
  /* @__PURE__ */ s(l, { className: "text-text-tertiary pointer-events-none absolute top-1/2 right-2.5 h-3.5 w-3.5 -translate-y-1/2" })
@@ -5,7 +5,7 @@ export interface TextInputProps extends ComponentPropsWithRef<"input"> {
5
5
  label?: string;
6
6
  /** Error message shown next to the label; also marks the input invalid and turns the border red. */
7
7
  error?: string;
8
- /** Helper text shown above the input and linked via `aria-describedby`. */
8
+ /** Helper text shown below the label and linked via `aria-describedby`. */
9
9
  hint?: string;
10
10
  /** Opt-in larger control, or inherit ControlSizeProvider. */
11
11
  controlSize?: ControlSize;
@@ -15,11 +15,6 @@ function a({ label: a, error: o, icon: s, className: c, id: l, readOnly: u, hint
15
15
  return /* @__PURE__ */ i("div", {
16
16
  className: "flex flex-col gap-1.5",
17
17
  children: [
18
- d && /* @__PURE__ */ r("p", {
19
- id: x,
20
- className: "text-text-secondary text-xs",
21
- children: d
22
- }),
23
18
  (a || o) && /* @__PURE__ */ i("div", {
24
19
  className: "flex items-center justify-between",
25
20
  children: [a && /* @__PURE__ */ r("label", {
@@ -32,6 +27,11 @@ function a({ label: a, error: o, icon: s, className: c, id: l, readOnly: u, hint
32
27
  children: o
33
28
  })]
34
29
  }),
30
+ d && /* @__PURE__ */ r("p", {
31
+ id: x,
32
+ className: "text-text-secondary text-xs",
33
+ children: d
34
+ }),
35
35
  /* @__PURE__ */ i("div", {
36
36
  className: "relative",
37
37
  children: [s && /* @__PURE__ */ r("span", {
package/dist/core.css CHANGED
@@ -1931,6 +1931,7 @@ select.ui-sized-control[data-control-size="comfortable"] {
1931
1931
  padding-inline-end: 2.25rem;
1932
1932
  }
1933
1933
  .ui-select-placeholder {
1934
+ color: var(--text-secondary);
1934
1935
  left: calc(var(--spacing) * 2);
1935
1936
  right: calc(var(--spacing) * 7);
1936
1937
  font-size: 0.75rem;
@@ -1945,6 +1946,7 @@ select.ui-sized-control[data-control-size="comfortable"] {
1945
1946
  font-size: 1rem;
1946
1947
  }
1947
1948
  select:disabled + .ui-select-placeholder {
1949
+ color: var(--text-disabled);
1948
1950
  opacity: 0.4;
1949
1951
  }
1950
1952
  .ui-password-input[data-control-size="comfortable"] {
@@ -2179,6 +2181,19 @@ select:disabled + .ui-select-placeholder {
2179
2181
 
2180
2182
  /* Component defaults stay below consumer utilities in the cascade. */
2181
2183
  @layer components {
2184
+ @media (width < 40rem) {
2185
+ .ui-pagination-count:where(:not(:focus-within)) {
2186
+ clip-path: inset(50%);
2187
+ white-space: nowrap;
2188
+ border-width: 0;
2189
+ width: 1px;
2190
+ height: 1px;
2191
+ margin: -1px;
2192
+ padding: 0;
2193
+ position: absolute;
2194
+ overflow: hidden;
2195
+ }}
2196
+
2182
2197
  .ui-stack,
2183
2198
  .ui-inline,
2184
2199
  .ui-grid {
package/dist/styles.css CHANGED
@@ -2617,6 +2617,7 @@ select.ui-sized-control[data-control-size="comfortable"] {
2617
2617
  padding-inline-end: 2.25rem;
2618
2618
  }
2619
2619
  .ui-select-placeholder {
2620
+ color: var(--text-secondary);
2620
2621
  left: calc(var(--spacing) * 2);
2621
2622
  right: calc(var(--spacing) * 7);
2622
2623
  font-size: 0.75rem;
@@ -2631,6 +2632,7 @@ select.ui-sized-control[data-control-size="comfortable"] {
2631
2632
  font-size: 1rem;
2632
2633
  }
2633
2634
  select:disabled + .ui-select-placeholder {
2635
+ color: var(--text-disabled);
2634
2636
  opacity: 0.4;
2635
2637
  }
2636
2638
  .ui-password-input[data-control-size="comfortable"] {
@@ -2867,6 +2869,20 @@ select:disabled + .ui-select-placeholder {
2867
2869
 
2868
2870
  /* Component defaults stay below consumer utilities in the cascade. */
2869
2871
  @layer components {
2872
+ @media (width < 40rem) {
2873
+ .ui-pagination-count:where(:not(:focus-within)) {
2874
+ clip-path: inset(50%);
2875
+ white-space: nowrap;
2876
+ border-width: 0;
2877
+ width: 1px;
2878
+ height: 1px;
2879
+ margin: -1px;
2880
+ padding: 0;
2881
+ position: absolute;
2882
+ overflow: hidden;
2883
+ }
2884
+ }
2885
+
2870
2886
  .ui-stack,
2871
2887
  .ui-inline,
2872
2888
  .ui-grid {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leonardaustin/ui",
3
- "version": "0.26.0",
3
+ "version": "0.26.2",
4
4
  "description": "Reusable React component library and application shell for Leonard Austin projects.",
5
5
  "license": "MIT",
6
6
  "type": "module",