@kapiuara/ui 0.8.0 → 0.10.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.
Files changed (31) hide show
  1. package/README.md +67 -2
  2. package/dist/components/data/KapiPagination.d.ts +13 -4
  3. package/dist/components/data/KapiPagination.js +31 -88
  4. package/dist/components/data/KapiPaginationFooter.d.ts +35 -0
  5. package/dist/components/data/KapiPaginationFooter.js +106 -0
  6. package/dist/components/data/KapiTable.d.ts +39 -5
  7. package/dist/components/data/KapiTable.js +280 -321
  8. package/dist/components/feedback/KapiBulkBar.d.ts +1 -1
  9. package/dist/components/layout/KapiContextSlot.d.ts +34 -6
  10. package/dist/components/layout/KapiContextSlot.js +115 -71
  11. package/dist/components/layout/KapiPageHeader.js +110 -25
  12. package/dist/components/layout/pageHeaderLogic.d.ts +38 -0
  13. package/dist/components/layout/pageHeaderLogic.js +18 -0
  14. package/dist/components/navigation/panelMiniLogic.d.ts +10 -1
  15. package/dist/components/navigation/panelMiniLogic.js +2 -2
  16. package/dist/components/overlays/KapiOffcanvas.js +124 -118
  17. package/dist/hooks/index.d.ts +3 -1
  18. package/dist/hooks/themeDeriveLogic.d.ts +17 -0
  19. package/dist/hooks/themeDeriveLogic.js +61 -32
  20. package/dist/hooks/themeRadiiLogic.d.ts +11 -0
  21. package/dist/hooks/themeRadiiLogic.js +32 -0
  22. package/dist/hooks/useKapiTheme.d.ts +10 -3
  23. package/dist/hooks/useKapiTheme.js +66 -57
  24. package/dist/hooks/useWheelZoom.d.ts +30 -0
  25. package/dist/hooks/useWheelZoom.js +27 -0
  26. package/dist/hooks/wheelZoomLogic.d.ts +18 -0
  27. package/dist/hooks/wheelZoomLogic.js +9 -0
  28. package/dist/index.js +9 -8
  29. package/dist/kapi.css +1 -1
  30. package/dist/kapi.layered.css +1 -1
  31. package/package.json +2 -2
@@ -2,202 +2,208 @@
2
2
  import { useLabels as e } from "../locale/KapiLocaleProvider.js";
3
3
  import { joinClasses as t } from "../rootProps.js";
4
4
  import { maxTransitionMs as n } from "./dialogUtils.js";
5
- import { getPortalRoot as r, useBackdropClose as i, useNativeDialog as a } from "./useNativeDialog.js";
6
- import { DEFAULT_PUSH_RATIO as o, depthOf as s, levelOf as c, offcanvasStackStore as l, phaseReducer as u, pushTransform as ee } from "./offcanvasStack.js";
7
- import { normalizeSide as te, pushForSide as ne, sideDataAttr as d, sizeVar as re } from "./offcanvasSide.js";
8
- import { companionDockClasses as ie, isCompanionActive as ae, resolveCompanionOrder as oe, resolveCompanionWidth as se } from "./offcanvasCompanion.js";
9
- import { resolveInitialWidth as ce, resolveMaxWidth as f, stepOffcanvasWidth as le, widthFromDrag as ue } from "./offcanvasResize.js";
5
+ import { useExitPresence as r } from "./useExitPresence.js";
6
+ import { getPortalRoot as i, useBackdropClose as a, useNativeDialog as o } from "./useNativeDialog.js";
7
+ import { DEFAULT_PUSH_RATIO as s, depthOf as c, levelOf as ee, offcanvasStackStore as l, phaseReducer as u, pushTransform as te } from "./offcanvasStack.js";
8
+ import { normalizeSide as ne, pushForSide as re, sideDataAttr as ie, sizeVar as ae } from "./offcanvasSide.js";
9
+ import { companionDockClasses as oe, isCompanionActive as se, resolveCompanionOrder as ce, resolveCompanionWidth as le, supportsCompanion as ue } from "./offcanvasCompanion.js";
10
+ import { resolveInitialWidth as de, resolveMaxWidth as d, stepOffcanvasWidth as fe, widthFromDrag as pe } from "./offcanvasResize.js";
10
11
  /* empty css */
11
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
12
- import { useEffect as de, useId as h, useLayoutEffect as g, useReducer as _, useRef as v, useState as y, useSyncExternalStore as fe } from "react";
13
- import { X as b } from "lucide-react";
14
- import { createPortal as x } from "react-dom";
15
- var pe = 120, S = {
12
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
13
+ import { useEffect as me, useId as m, useLayoutEffect as h, useReducer as g, useRef as _, useState as v, useSyncExternalStore as he } from "react";
14
+ import { X as y } from "lucide-react";
15
+ import { createPortal as b } from "react-dom";
16
+ var ge = 120, x = {
16
17
  resize: "Redimensionar panel",
17
18
  close: "Cerrar",
18
19
  closePanel: "Cerrar panel"
19
- }, C = ({ stackId: r, phase: u, onEntered: _, onExited: x, onClose: C, title: w, subtitle: T, children: me, footer: E, side: he, width: D = 520, height: ge, pushRatio: _e = o, pushOffset: ve = 16, closeOnBackdrop: ye = !0, closeOnEscape: be = !0, closeLabel: xe, labels: Se, className: Ce, style: O, id: k, companion: A, resizable: we = !1, minWidth: j = 320, maxWidth: M, onResize: N }) => {
20
- let P = e("offcanvas", S, Se), Te = xe ?? P.close, F = h(), I = h(), L = te(he), R = v(null), z = fe(l.subscribe, l.getSnapshot, l.getServerSnapshot), B = s(z, r), Ee = Math.max(0, c(z, r)), { scale: De, translateX: Oe } = ne(L, ee(B, _e, ve)), [V, ke] = y(() => ce(D, 520)), [Ae, H] = y(!1), U = v(null), W = v(N);
21
- W.current = N;
22
- let G = (e) => {
23
- ke(e), e !== V && W.current?.(e);
24
- }, je = (e) => {
20
+ }, S = ({ stackId: i, phase: u, onEntered: g, onExited: b, onClose: S, title: C, subtitle: w, children: _e, footer: T, side: ve, width: E = 520, height: ye, pushRatio: be = s, pushOffset: xe = 16, closeOnBackdrop: Se = !0, closeOnEscape: Ce = !0, closeLabel: we, labels: Te, className: Ee, style: De, id: Oe, companion: D, resizable: ke = !1, minWidth: O = 320, maxWidth: k, onResize: A }) => {
21
+ let j = e("offcanvas", x, Te), Ae = we ?? j.close, M = m(), N = m(), P = ne(ve), F = _(null), I = he(l.subscribe, l.getSnapshot, l.getServerSnapshot), L = c(I, i), je = Math.max(0, ee(I, i)), { scale: Me, translateX: Ne } = re(P, te(L, be, xe)), [R, Pe] = v(() => de(E, 520)), [Fe, z] = v(!1), B = _(null), V = _(A);
22
+ V.current = A;
23
+ let H = (e) => {
24
+ Pe(e), e !== R && V.current?.(e);
25
+ }, Ie = (e) => {
25
26
  if (e.button !== 0) return;
26
- let t = R.current?.offsetWidth ?? V;
27
- U.current = {
27
+ let t = F.current?.offsetWidth ?? R;
28
+ B.current = {
28
29
  startX: e.clientX,
29
30
  startWidth: t
30
- }, e.currentTarget.setPointerCapture(e.pointerId), H(!0), e.preventDefault();
31
- }, Me = (e) => {
32
- let t = U.current;
31
+ }, e.currentTarget.setPointerCapture(e.pointerId), z(!0), e.preventDefault();
32
+ }, Le = (e) => {
33
+ let t = B.current;
33
34
  if (!t) return;
34
- let n = f(M, window.innerWidth);
35
- G(ue(L, t.startWidth, t.startX, e.clientX, j, n));
36
- }, K = (e) => {
37
- U.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId), H(!1);
38
- }, Ne = (e) => {
39
- let t = f(M, window.innerWidth), n = le(L, V, e.key, j, t);
40
- n !== null && (e.preventDefault(), e.stopPropagation(), G(n));
41
- }, q = u === "open" ? C : void 0, { ref: Pe, dialogProps: Fe } = a({ onRequestClose: be ? q : void 0 }), J = i(ye ? q : void 0);
42
- g(() => (l.dispatch({
35
+ let n = d(k, window.innerWidth);
36
+ H(pe(P, t.startWidth, t.startX, e.clientX, O, n));
37
+ }, U = (e) => {
38
+ B.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId), z(!1);
39
+ }, Re = (e) => {
40
+ let t = d(k, window.innerWidth), n = fe(P, R, e.key, O, t);
41
+ n !== null && (e.preventDefault(), e.stopPropagation(), H(n));
42
+ }, W = u === "open" ? S : void 0, { ref: ze, dialogProps: Be } = o({ onRequestClose: Ce ? W : void 0 }), Ve = a(Se ? W : void 0);
43
+ h(() => (l.dispatch({
43
44
  type: "add",
44
- id: r
45
+ id: i
45
46
  }), () => l.dispatch({
46
47
  type: "remove",
47
- id: r
48
- })), [r]);
49
- let Y = v(_);
50
- Y.current = _, g(() => {
51
- R.current?.getBoundingClientRect(), Y.current();
48
+ id: i
49
+ })), [i]);
50
+ let G = _(g);
51
+ G.current = g, h(() => {
52
+ F.current?.getBoundingClientRect(), G.current();
52
53
  }, []);
53
- let X = v(x);
54
- X.current = x, de(() => {
54
+ let K = _(b);
55
+ K.current = b, me(() => {
55
56
  if (u !== "exit") return;
56
- let e = R.current;
57
+ let e = F.current;
57
58
  if (!e) {
58
- X.current();
59
+ K.current();
59
60
  return;
60
61
  }
61
62
  let t = getComputedStyle(e), r = n(t.transitionDuration, t.transitionDelay);
62
63
  if (r <= 0) {
63
- X.current();
64
+ K.current();
64
65
  return;
65
66
  }
66
67
  let i = !1, a = () => {
67
- i || (i = !0, X.current());
68
+ i || (i = !0, K.current());
68
69
  }, o = (t) => {
69
70
  t.target === e && t.propertyName === "transform" && a();
70
71
  };
71
72
  e.addEventListener("transitionend", o);
72
- let s = window.setTimeout(a, r + pe);
73
+ let s = window.setTimeout(a, r + ge);
73
74
  return () => {
74
75
  i = !0, e.removeEventListener("transitionend", o), window.clearTimeout(s);
75
76
  };
76
77
  }, [u]);
77
- let Z = we && (L === "left" || L === "right"), Q = re(L, D, ge, "520px");
78
- Z && (Q.value = `${V}px`);
79
- let Ie = {
80
- ...O,
81
- [Q.name]: Q.value,
82
- "--kapi-offc-push-x": `${Oe}px`,
83
- "--kapi-offc-push-s": De
84
- }, $ = ae(L, A), Le = /* @__PURE__ */ m("div", {
85
- ref: R,
78
+ let q = ke && (P === "left" || P === "right"), J = ae(P, E, ye, "520px");
79
+ q && (J.value = `${R}px`);
80
+ let He = {
81
+ ...De,
82
+ [J.name]: J.value,
83
+ "--kapi-offc-push-x": `${Ne}px`,
84
+ "--kapi-offc-push-s": Me
85
+ }, Ue = se(P, D), Y = _(null), { present: We, closing: X } = r(Ue, Y), Z = _(D);
86
+ D && (Z.current = D);
87
+ let Q = D ?? Z.current, $ = We && ue(P) && Q !== void 0, Ge = /* @__PURE__ */ p("div", {
88
+ ref: F,
86
89
  className: "kapi-offc__panel",
87
90
  children: [
88
- Z && /* @__PURE__ */ p("div", {
91
+ q && /* @__PURE__ */ f("div", {
89
92
  className: "kapi-offc__resize",
90
93
  role: "separator",
91
94
  "aria-orientation": "vertical",
92
- "aria-label": P.resize,
93
- "aria-valuemin": j,
94
- "aria-valuemax": f(M, typeof window > "u" ? void 0 : window.innerWidth),
95
- "aria-valuenow": V,
95
+ "aria-label": j.resize,
96
+ "aria-valuemin": O,
97
+ "aria-valuemax": d(k, typeof window > "u" ? void 0 : window.innerWidth),
98
+ "aria-valuenow": R,
96
99
  tabIndex: 0,
97
- onPointerDown: je,
98
- onPointerMove: Me,
99
- onPointerUp: K,
100
- onPointerCancel: K,
101
- onKeyDown: Ne
100
+ onPointerDown: Ie,
101
+ onPointerMove: Le,
102
+ onPointerUp: U,
103
+ onPointerCancel: U,
104
+ onKeyDown: Re
102
105
  }),
103
- /* @__PURE__ */ m("div", {
106
+ /* @__PURE__ */ p("div", {
104
107
  className: "kapi-offc__head",
105
- children: [/* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("div", {
106
- id: F,
108
+ children: [/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("div", {
109
+ id: M,
107
110
  className: "kapi-modal__title",
108
- children: w
109
- }), T && /* @__PURE__ */ p("div", {
111
+ children: C
112
+ }), w && /* @__PURE__ */ f("div", {
110
113
  className: "kapi-modal__sub",
111
- children: T
112
- })] }), /* @__PURE__ */ p("button", {
114
+ children: w
115
+ })] }), /* @__PURE__ */ f("button", {
113
116
  type: "button",
114
117
  className: "kapi-modal__x",
115
- onClick: q,
116
- "aria-label": Te,
117
- children: /* @__PURE__ */ p(b, {
118
+ onClick: W,
119
+ "aria-label": Ae,
120
+ children: /* @__PURE__ */ f(y, {
118
121
  size: 17,
119
122
  strokeWidth: 2.2
120
123
  })
121
124
  })]
122
125
  }),
123
- /* @__PURE__ */ p("div", {
126
+ /* @__PURE__ */ f("div", {
124
127
  className: "kapi-offc__body",
125
- children: me
128
+ children: _e
126
129
  }),
127
- E && /* @__PURE__ */ p("div", {
130
+ T && /* @__PURE__ */ f("div", {
128
131
  className: "kapi-offc__foot",
129
- children: E
132
+ children: T
130
133
  })
131
134
  ]
132
- }, "main"), Re = A && $ ? /* @__PURE__ */ m("div", {
135
+ }, "main"), Ke = Q && $ ? /* @__PURE__ */ p("div", {
136
+ ref: Y,
137
+ "data-closing": X || void 0,
138
+ inert: X || void 0,
133
139
  className: "kapi-offc__panel kapi-offc__companion",
134
140
  role: "complementary",
135
- "aria-labelledby": A.title ? I : void 0,
136
- style: { "--kapi-offc-companion-w": se(A.width) },
141
+ "aria-labelledby": Q.title ? N : void 0,
142
+ style: { "--kapi-offc-companion-w": le(Q.width) },
137
143
  children: [
138
- (A.title || A.onClose) && /* @__PURE__ */ m("div", {
144
+ (Q.title || Q.onClose) && /* @__PURE__ */ p("div", {
139
145
  className: "kapi-offc__head",
140
- children: [/* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("div", {
141
- id: I,
146
+ children: [/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("div", {
147
+ id: N,
142
148
  className: "kapi-modal__title",
143
- children: A.title
144
- }), A.subtitle && /* @__PURE__ */ p("div", {
149
+ children: Q.title
150
+ }), Q.subtitle && /* @__PURE__ */ f("div", {
145
151
  className: "kapi-modal__sub",
146
- children: A.subtitle
147
- })] }), A.onClose && /* @__PURE__ */ p("button", {
152
+ children: Q.subtitle
153
+ })] }), Q.onClose && /* @__PURE__ */ f("button", {
148
154
  type: "button",
149
155
  className: "kapi-modal__x",
150
- onClick: A.onClose,
151
- "aria-label": A.closeLabel ?? P.closePanel,
152
- children: /* @__PURE__ */ p(b, {
156
+ onClick: Q.onClose,
157
+ "aria-label": Q.closeLabel ?? j.closePanel,
158
+ children: /* @__PURE__ */ f(y, {
153
159
  size: 17,
154
160
  strokeWidth: 2.2
155
161
  })
156
162
  })]
157
163
  }),
158
- /* @__PURE__ */ p("div", {
164
+ /* @__PURE__ */ f("div", {
159
165
  className: "kapi-offc__body",
160
- children: A.children
166
+ children: Q.children
161
167
  }),
162
- A.footer && /* @__PURE__ */ p("div", {
168
+ Q.footer && /* @__PURE__ */ f("div", {
163
169
  className: "kapi-offc__foot",
164
- children: A.footer
170
+ children: Q.footer
165
171
  })
166
172
  ]
167
- }, "companion") : null, ze = oe(L).map((e) => e === "main" ? Le : Re).filter((e) => e !== null);
168
- return /* @__PURE__ */ p("dialog", {
169
- ref: Pe,
170
- id: k,
171
- className: t("kapi-offc", Ae && "is-resizing", Ce),
172
- "data-side": d(L),
173
+ }, "companion") : null, qe = ce(P).map((e) => e === "main" ? Ge : Ke).filter((e) => e !== null);
174
+ return /* @__PURE__ */ f("dialog", {
175
+ ref: ze,
176
+ id: Oe,
177
+ className: t("kapi-offc", Fe && "is-resizing", Ee),
178
+ "data-side": ie(P),
173
179
  "data-state": u === "open" ? "open" : "closed",
174
- "data-level": Ee,
175
- "data-pushed": B > 0 ? "" : void 0,
180
+ "data-level": je,
181
+ "data-pushed": L > 0 ? "" : void 0,
176
182
  "aria-modal": "true",
177
- "aria-labelledby": F,
178
- style: Ie,
179
- ...Fe,
180
- ...J,
181
- children: /* @__PURE__ */ p("div", {
182
- className: ie($),
183
- children: ze
183
+ "aria-labelledby": M,
184
+ style: He,
185
+ ...Be,
186
+ ...Ve,
187
+ children: /* @__PURE__ */ f("div", {
188
+ className: oe($),
189
+ children: qe
184
190
  })
185
191
  });
186
- }, w = ({ open: e, onExited: t, ...n }) => {
187
- let i = h(), [a, o] = _(u, "unmounted"), s = v(t);
188
- s.current = t, g(() => {
192
+ }, C = ({ open: e, onExited: t, ...n }) => {
193
+ let r = m(), [a, o] = g(u, "unmounted"), s = _(t);
194
+ s.current = t, h(() => {
189
195
  o(e ? "open" : "close");
190
- }, [e]), g(() => {
196
+ }, [e]), h(() => {
191
197
  (a === "exit" || a === "open") && l.dispatch({
192
198
  type: "mark",
193
- id: i,
199
+ id: r,
194
200
  state: a === "exit" ? "closing" : "open"
195
201
  });
196
- }, [a, i]);
197
- let c = r();
198
- return a === "unmounted" || !c ? null : x(/* @__PURE__ */ p(C, {
202
+ }, [a, r]);
203
+ let c = i();
204
+ return a === "unmounted" || !c ? null : b(/* @__PURE__ */ f(S, {
199
205
  ...n,
200
- stackId: i,
206
+ stackId: r,
201
207
  phase: a,
202
208
  onEntered: () => o("entered"),
203
209
  onExited: () => {
@@ -206,4 +212,4 @@ var pe = 120, S = {
206
212
  }), c);
207
213
  };
208
214
  //#endregion
209
- export { S as DEFAULT_OFFCANVAS_LABELS, w as KapiOffcanvas };
215
+ export { x as DEFAULT_OFFCANVAS_LABELS, C as KapiOffcanvas };
@@ -11,6 +11,8 @@ export type { BeforeUnloadLike as KapiBeforeUnloadLike, UnsavedGuard as KapiUnsa
11
11
  export { KAPI_ROOT_SELECTOR, resolveKapiRoot, useKapiRoot } from "./kapiRoot";
12
12
  export { REDUCED_MOTION_QUERY, prefersReducedMotion } from "./reducedMotion";
13
13
  export { SHELL_MOBILE_QUERY, matchesQuery, useMediaQuery } from "./useMediaQuery";
14
+ export { useWheelZoom } from "./useWheelZoom";
15
+ export type { UseWheelZoomOptions } from "./useWheelZoom";
14
16
  export { useHotkey } from "./useHotkey";
15
17
  export type { UseHotkeyOptions } from "./useHotkey";
16
18
  export { usePersistentState } from "./usePersistentState";
@@ -50,6 +52,6 @@ export type { UseScrollEdgesOptions, UseScrollEdgesResult } from "./useScrollEdg
50
52
  export { DEFAULT_PAGE_FRACTION, DEFAULT_SCROLL_EDGE_TOLERANCE, maxScroll, pageSize, pageTarget, revealTarget, sameScrollEdges, scrollEdges } from "./scrollEdgesLogic";
51
53
  export type { KapiScrollAxis, ScrollEdges as KapiScrollEdges, ScrollMetrics as KapiScrollMetrics } from "./scrollEdgesLogic";
52
54
  export { deriveTheme } from "./themeDeriveLogic";
53
- export type { KapiCustomTheme, KapiThemeColors } from "./themeDeriveLogic";
55
+ export type { KapiCustomTheme, KapiThemeColors, KapiThemeRadii } from "./themeDeriveLogic";
54
56
  export { checkThemeContrast } from "./themeContrastLogic";
55
57
  export type { KapiThemeContrastFailure, KapiThemeContrastOptions } from "./themeContrastLogic";
@@ -22,13 +22,30 @@ export type KapiThemeColors = {
22
22
  /** Font stack, passed through as-is (`--kapi-font`). */
23
23
  font?: string | undefined;
24
24
  };
25
+ /** The radius knobs a custom theme sets; each one derives a tier of the radius scale. */
26
+ export type KapiThemeRadii = {
27
+ /** Anchor of the control tier, a px length (`10px`): xs, inner, sm, ctl-sm, md and group (`--kapi-radius-md`). */
28
+ control?: string | undefined;
29
+ /** Anchor of the box tier, a px length (`10px`): check and box, the shape of checkboxes and textareas (`--kapi-radius-box`). */
30
+ box?: string | undefined;
31
+ /** Anchor of the surface tier, a px length (`18px`): lg, xl, the card radius and surfaces (`--kapi-radius-surface`). */
32
+ surface?: string | undefined;
33
+ /** Corner of square fixed-size controls, a percentage or px length, passed as-is (`--kapi-radius-squircle`). */
34
+ squircle?: string | undefined;
35
+ };
25
36
  /** A user theme: which built-in theme it stands on, and the base values it overrides. */
26
37
  export type KapiCustomTheme = {
27
38
  /** The built-in theme that supplies everything not derived, and the defaults for unset colors. */
28
39
  base: "light" | "dark";
29
40
  /** The base values; an unset or unparseable color falls back to the base theme's own. */
30
41
  colors: KapiThemeColors;
42
+ /** The radius knobs; an unset or invalid one leaves its whole tier at the base theme's values. */
43
+ radii?: KapiThemeRadii | undefined;
31
44
  };
45
+ /** A px length such as `10px` or `999px`: what the `control`, `box` and `surface` knobs accept. */
46
+ export declare const RADIUS_PX_PATTERN: RegExp;
47
+ /** A px length or a percentage such as `32%`: what the `squircle` knob accepts. */
48
+ export declare const RADIUS_SHAPE_PATTERN: RegExp;
32
49
  /**
33
50
  * Derives the override map for a user theme. Colors that are unset or can't be parsed fall back
34
51
  * to the base theme's for the math; alpha is ignored (colors are treated as opaque). The values
@@ -1,6 +1,35 @@
1
1
  import { contrastRatio as e, formatHex as t, mixColors as n, parseColor as r, readableForeground as i } from "./colorLogic.js";
2
2
  //#region src/hooks/themeDeriveLogic.ts
3
- var a = {
3
+ var a = /^\d+(\.\d+)?px$/, o = /^\d+(\.\d+)?(px|%)$/, s = {
4
+ "--kapi-radius-xs": .6,
5
+ "--kapi-radius-inner": .7,
6
+ "--kapi-radius-sm": .8,
7
+ "--kapi-radius-ctl-sm": .9,
8
+ "--kapi-radius-md": 1,
9
+ "--kapi-radius-group": 1.1
10
+ }, c = {
11
+ "--kapi-radius-check": .6,
12
+ "--kapi-radius-box": 1
13
+ }, l = {
14
+ "--kapi-radius-lg": 12 / 18,
15
+ "--kapi-radius-xl": 14 / 18,
16
+ "--kapi-radius": 16 / 18,
17
+ "--kapi-radius-surface": 1
18
+ }, u = (e, t) => `${Math.min(999, Math.round(e * t * 10) / 10)}px`, d = (e) => {
19
+ let t = {}, n = [
20
+ [e.control, s],
21
+ [e.box, c],
22
+ [e.surface, l]
23
+ ];
24
+ for (let [e, r] of n) {
25
+ let n = e?.trim();
26
+ if (!n || !a.test(n)) continue;
27
+ let i = parseFloat(n);
28
+ for (let [e, n] of Object.entries(r)) t[e] = u(i, n);
29
+ }
30
+ let r = e.squircle?.trim();
31
+ return r && o.test(r) && (t["--kapi-radius-squircle"] = r), t;
32
+ }, f = {
4
33
  light: {
5
34
  bg: "#f4f2fb",
6
35
  card: "#ffffff",
@@ -23,64 +52,64 @@ var a = {
23
52
  warning: "#e0a44e",
24
53
  danger: "#f06a8a"
25
54
  }
26
- }, o = Object.keys(a.light), s = 4.5, c = {
55
+ }, p = Object.keys(f.light), m = 4.5, h = {
27
56
  "--kapi-ink-2": 12,
28
57
  "--kapi-ink-3": 22,
29
58
  "--kapi-muted": 28,
30
59
  "--kapi-muted-2": 32
31
- }, l = {
60
+ }, g = {
32
61
  r: 255,
33
62
  g: 255,
34
63
  b: 255,
35
64
  a: 1
36
- }, u = {
65
+ }, _ = {
37
66
  r: 0,
38
67
  g: 0,
39
68
  b: 0,
40
69
  a: 1
41
- }, d = [l, {
70
+ }, v = [g, {
42
71
  r: 15,
43
72
  g: 13,
44
73
  b: 23,
45
74
  a: 1
46
- }], f = [
75
+ }], y = [
47
76
  "success",
48
77
  "info",
49
78
  "warning",
50
79
  "danger"
51
- ], p = (e) => ({
80
+ ], b = (e) => ({
52
81
  ...e,
53
82
  a: 1
54
- }), m = (t, r, i, a) => {
83
+ }), x = (t, r, i, a) => {
55
84
  for (let o = i; o > 0; o--) {
56
85
  let i = n(r, t, o);
57
- if (a.every((t) => e(i, t) >= s)) return i;
86
+ if (a.every((t) => e(i, t) >= m)) return i;
58
87
  }
59
88
  return t;
60
- }, h = (e, t) => `rgba(${Math.round(e.r)}, ${Math.round(e.g)}, ${Math.round(e.b)}, ${t})`, g = (e) => {
61
- let s = a[e.base], l = e.base === "dark", g = {}, _ = {}, v = /* @__PURE__ */ new Set();
62
- for (let n of o) {
89
+ }, S = (e, t) => `rgba(${Math.round(e.r)}, ${Math.round(e.g)}, ${Math.round(e.b)}, ${t})`, C = (e) => {
90
+ let a = f[e.base], o = e.base === "dark", s = {}, c = {}, l = /* @__PURE__ */ new Set();
91
+ for (let n of p) {
63
92
  let i = e.colors[n] === void 0 ? null : r(e.colors[n]);
64
- i && (v.add(n), g[`--kapi-${n}`] = t(i)), _[n] = p(i ?? r(s[n]));
93
+ i && (l.add(n), s[`--kapi-${n}`] = t(i)), c[n] = b(i ?? r(a[n]));
65
94
  }
66
- let y = e.colors.font?.trim();
67
- y && (g["--kapi-font"] = y);
68
- let { bg: b, card: x, line: S, ink: C } = _, w = (e) => t(e), T = v.has("bg") || v.has("card") || v.has("line"), E = T || v.has("ink"), D = n(b, x, 60), O = n(b, x, 30), k = n(S, C, 92), A = n(b, C, 96);
69
- T && (g["--kapi-surface"] = w(D), g["--kapi-soft"] = w(O), g["--kapi-border"] = w(k), g["--kapi-divider"] = w(n(S, x, 50)), g["--kapi-tab"] = w(A), g["--kapi-sk-base"] = w(n(b, C, 94)), g["--kapi-sk-shine"] = w(l ? k : n(x, b, 50)));
70
- let j = [
71
- b,
72
- x,
73
- D,
95
+ let u = e.colors.font?.trim();
96
+ u && (s["--kapi-font"] = u), e.radii && Object.assign(s, d(e.radii));
97
+ let { bg: m, card: g, line: C, ink: w } = c, T = (e) => t(e), E = l.has("bg") || l.has("card") || l.has("line"), D = E || l.has("ink"), O = n(m, g, 60), k = n(m, g, 30), A = n(C, w, 92), j = n(m, w, 96);
98
+ E && (s["--kapi-surface"] = T(O), s["--kapi-soft"] = T(k), s["--kapi-border"] = T(A), s["--kapi-divider"] = T(n(C, g, 50)), s["--kapi-tab"] = T(j), s["--kapi-sk-base"] = T(n(m, w, 94)), s["--kapi-sk-shine"] = T(o ? A : n(g, m, 50)));
99
+ let M = [
100
+ m,
101
+ g,
74
102
  O,
75
- A
76
- ], M = {};
77
- for (let [e, t] of Object.entries(c)) M[e] = m(C, b, t, j), E && (g[e] = w(M[e]));
78
- v.has("primary") && (g["--kapi-primary-fg"] = w(i(_.primary, d)));
79
- let N = f.filter((e) => v.has(e)).map((e) => [e, _[e]]);
80
- E && N.push(["neutral", M["--kapi-muted-2"]]);
81
- for (let [e, t] of N) g[`--kapi-${e}-bg`] = w(n(t, x, l ? 16 : 12)), g[`--kapi-${e}-border`] = w(n(t, x, l ? 35 : 28)), g[`--kapi-${e}-fg`] = w(i(t, d));
82
- E && (g["--kapi-neutral"] = w(M["--kapi-muted-2"])), v.has("ink") && (g["--kapi-tip-bg"] = w(C), g["--kapi-tip-fg"] = w(i(C, d)));
83
- let P = l ? u : n(C, u, 60), F = l ? {
103
+ k,
104
+ j
105
+ ], N = {};
106
+ for (let [e, t] of Object.entries(h)) N[e] = x(w, m, t, M), D && (s[e] = T(N[e]));
107
+ l.has("primary") && (s["--kapi-primary-fg"] = T(i(c.primary, v)));
108
+ let P = y.filter((e) => l.has(e)).map((e) => [e, c[e]]);
109
+ D && P.push(["neutral", N["--kapi-muted-2"]]);
110
+ for (let [e, t] of P) s[`--kapi-${e}-bg`] = T(n(t, g, o ? 16 : 12)), s[`--kapi-${e}-border`] = T(n(t, g, o ? 35 : 28)), s[`--kapi-${e}-fg`] = T(i(t, v));
111
+ D && (s["--kapi-neutral"] = T(N["--kapi-muted-2"])), l.has("ink") && (s["--kapi-tip-bg"] = T(w), s["--kapi-tip-fg"] = T(i(w, v)));
112
+ let F = o ? _ : n(w, _, 60), I = o ? {
84
113
  base: .55,
85
114
  soft: .3,
86
115
  tour: .65,
@@ -97,7 +126,7 @@ var a = {
97
126
  strong: .6,
98
127
  edge: .06
99
128
  };
100
- return v.has("ink") && !l && (g["--kapi-scrim"] = h(P, F.base), g["--kapi-scrim-soft"] = h(P, F.soft), g["--kapi-scrim-tour"] = h(P, F.tour), g["--kapi-scrim-drawer"] = h(P, F.drawer), g["--kapi-scrim-cmdk"] = h(P, F.cmdk), g["--kapi-scrim-strong"] = h(P, F.strong), g["--kapi-edge-shade"] = h(P, F.edge)), g;
129
+ return l.has("ink") && !o && (s["--kapi-scrim"] = S(F, I.base), s["--kapi-scrim-soft"] = S(F, I.soft), s["--kapi-scrim-tour"] = S(F, I.tour), s["--kapi-scrim-drawer"] = S(F, I.drawer), s["--kapi-scrim-cmdk"] = S(F, I.cmdk), s["--kapi-scrim-strong"] = S(F, I.strong), s["--kapi-edge-shade"] = S(F, I.edge)), s;
101
130
  };
102
131
  //#endregion
103
- export { g as deriveTheme };
132
+ export { a as RADIUS_PX_PATTERN, o as RADIUS_SHAPE_PATTERN, C as deriveTheme };
@@ -0,0 +1,11 @@
1
+ import { type KapiThemeRadii } from "./themeDeriveLogic";
2
+ /** Shared empty value, so "no radii" is referentially stable across renders. */
3
+ export declare const NO_THEME_RADII: KapiThemeRadii;
4
+ /** Keeps only known knobs whose value is a well-formed length (`control`/`box`/`surface`: px; `squircle`: px or %). */
5
+ export declare const sanitizeThemeRadii: (input: unknown) => KapiThemeRadii;
6
+ /** Parses the stored JSON. Broken or invalid JSON counts as "no radii"; it never throws. */
7
+ export declare const parseStoredThemeRadii: (raw: string | null | undefined) => KapiThemeRadii;
8
+ /** Serializes for storage; "no radii" is the empty string (like the colors). */
9
+ export declare const serializeThemeRadii: (radii: KapiThemeRadii) => string;
10
+ /** Merges layers left to right: a later layer wins knob by knob; unset values never clobber. */
11
+ export declare const mergeThemeRadii: (...layers: (KapiThemeRadii | null | undefined)[]) => KapiThemeRadii;
@@ -0,0 +1,32 @@
1
+ import { RADIUS_PX_PATTERN as e, RADIUS_SHAPE_PATTERN as t } from "./themeDeriveLogic.js";
2
+ //#region src/hooks/themeRadiiLogic.ts
3
+ var n = {
4
+ control: e,
5
+ box: e,
6
+ surface: e,
7
+ squircle: t
8
+ }, r = Object.freeze({}), i = (e) => {
9
+ if (typeof e != "object" || !e || Array.isArray(e)) return r;
10
+ let t = e, i = {};
11
+ for (let e of Object.keys(n)) {
12
+ let r = t[e];
13
+ typeof r == "string" && n[e].test(r.trim()) && (i[e] = r.trim());
14
+ }
15
+ return Object.keys(i).length ? i : r;
16
+ }, a = (e) => {
17
+ if (!e) return r;
18
+ try {
19
+ return i(JSON.parse(e));
20
+ } catch {
21
+ return r;
22
+ }
23
+ }, o = (e) => Object.keys(e).length ? JSON.stringify(e) : "", s = (...e) => {
24
+ let t = {};
25
+ for (let r of e) if (r) for (let e of Object.keys(n)) {
26
+ let n = r[e];
27
+ n && (t[e] = n);
28
+ }
29
+ return t;
30
+ };
31
+ //#endregion
32
+ export { r as NO_THEME_RADII, s as mergeThemeRadii, a as parseStoredThemeRadii, i as sanitizeThemeRadii, o as serializeThemeRadii };
@@ -1,5 +1,5 @@
1
1
  import { type CSSProperties } from "react";
2
- import { type KapiThemeColors } from "./themeDeriveLogic";
2
+ import { type KapiThemeColors, type KapiThemeRadii } from "./themeDeriveLogic";
3
3
  export type KapiTheme = "light" | "dark";
4
4
  /** Lo que elige la persona: un tema fijo o `system` (sigue a `prefers-color-scheme` del SO). */
5
5
  export type KapiThemePreference = KapiTheme | "system";
@@ -9,7 +9,7 @@ export type KapiFontKey = "nunito" | "roboto" | "system";
9
9
  /** Movimiento: `auto` sigue al SO (prefers-reduced-motion); `reduced` lo apaga siempre. */
10
10
  export type KapiMotion = "auto" | "reduced";
11
11
  /** Preferencias del tema que se guardan. */
12
- export type KapiThemeStorageName = "theme" | "accent" | "font" | "motion" | "customTheme";
12
+ export type KapiThemeStorageName = "theme" | "accent" | "font" | "motion" | "customTheme" | "radii";
13
13
  /** Claves de localStorage del tema para un namespace (default `kapi` → `kapi:theme`…). */
14
14
  export declare const themeStorageKeys: (namespace?: string) => Record<KapiThemeStorageName, string>;
15
15
  /** Claves viejas (sin namespace): se migran a las nuevas en la primera lectura y se borran. */
@@ -34,6 +34,11 @@ export type KapiThemeState = {
34
34
  * (el selector). Si no, ese valor queda como estado muerto y reaparece al resetear el tema propio.
35
35
  */
36
36
  customTheme: KapiThemeColors;
37
+ /**
38
+ * Radius knobs que fijó la persona (`control`, `surface`, `squircle`); `{}` si no hay. Se guardan aparte
39
+ * de `customTheme` (`kapi:radii`) para no cambiar la forma de lo que ya hay guardado.
40
+ */
41
+ radii: KapiThemeRadii;
37
42
  font: KapiFontKey;
38
43
  /** `true` si la persona eligió una fuente (hay `kapi:font` guardada); si no, la de la marca manda. */
39
44
  fontChosen: boolean;
@@ -51,6 +56,8 @@ export type KapiThemeState = {
51
56
  * al fijar un `primary` o un `font` propios corresponde reconciliar el acento y el selector de fuente.
52
57
  */
53
58
  setCustomTheme: (colors?: KapiThemeColors | null) => void;
59
+ /** Fija los radios propios (reemplaza los anteriores); `null` o `{}` los borra. */
60
+ setRadii: (radii?: KapiThemeRadii | null) => void;
54
61
  setFont: (f: KapiFontKey) => void;
55
62
  setMotion: (m: KapiMotion) => void;
56
63
  /** Alterna entre `auto` y `reduced`. */
@@ -78,7 +85,7 @@ export declare const isMotion: (v: string) => v is KapiMotion;
78
85
  * la marca o del tema propio, se emite tal cual como `--kapi-primary` y se omite sólo el
79
86
  * `--kapi-primary-fg` calculado, que es lo único que necesita los números.
80
87
  */
81
- export declare const themeRootStyle: (state: Pick<KapiThemeState, "font" | "accent"> & Partial<Pick<KapiThemeState, "theme" | "customTheme" | "fontChosen">>, brand?: KapiThemeColors) => CSSProperties;
88
+ export declare const themeRootStyle: (state: Pick<KapiThemeState, "font" | "accent"> & Partial<Pick<KapiThemeState, "theme" | "customTheme" | "radii" | "fontChosen">>, brand?: KapiThemeColors) => CSSProperties;
82
89
  export declare const KapiThemeContext: import("react").Context<KapiThemeState>;
83
90
  export type KapiThemeStateOptions = {
84
91
  /**