@hirobius/design-system 0.8.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.
Files changed (111) hide show
  1. package/LICENSE/main.tsx +21 -0
  2. package/README.md +124 -0
  3. package/dist/chunks/TokenDisplayContext-B3gxyQN7.js +95 -0
  4. package/dist/chunks/form-DnGRy27o.js +63 -0
  5. package/dist/cn.js +8 -0
  6. package/dist/contexts.js +133 -0
  7. package/dist/form.js +62 -0
  8. package/dist/hirobius-ui.js +5611 -0
  9. package/dist/manifest.js +28 -0
  10. package/dist/tokens.css +1 -0
  11. package/dist/tokens.js +693 -0
  12. package/dist/types/src/app/components/activity-feed.d.ts +43 -0
  13. package/dist/types/src/app/components/alert.d.ts +18 -0
  14. package/dist/types/src/app/components/asset-img.d.ts +54 -0
  15. package/dist/types/src/app/components/avatar.d.ts +23 -0
  16. package/dist/types/src/app/components/badge.d.ts +20 -0
  17. package/dist/types/src/app/components/breadcrumb.d.ts +26 -0
  18. package/dist/types/src/app/components/button.d.ts +37 -0
  19. package/dist/types/src/app/components/callout.d.ts +23 -0
  20. package/dist/types/src/app/components/card.d.ts +119 -0
  21. package/dist/types/src/app/components/checkbox.d.ts +20 -0
  22. package/dist/types/src/app/components/cinematic-link.d.ts +13 -0
  23. package/dist/types/src/app/components/code-block.d.ts +29 -0
  24. package/dist/types/src/app/components/combobox.d.ts +46 -0
  25. package/dist/types/src/app/components/component-instance-matrix.d.ts +21 -0
  26. package/dist/types/src/app/components/container.d.ts +31 -0
  27. package/dist/types/src/app/components/dialog.d.ts +73 -0
  28. package/dist/types/src/app/components/disclosure.d.ts +32 -0
  29. package/dist/types/src/app/components/divider.d.ts +21 -0
  30. package/dist/types/src/app/components/doc-link-card.d.ts +26 -0
  31. package/dist/types/src/app/components/empty-state.d.ts +24 -0
  32. package/dist/types/src/app/components/error-boundary.d.ts +25 -0
  33. package/dist/types/src/app/components/error-pattern.d.ts +9 -0
  34. package/dist/types/src/app/components/field.d.ts +25 -0
  35. package/dist/types/src/app/components/form.d.ts +106 -0
  36. package/dist/types/src/app/components/foundation-swatch.d.ts +39 -0
  37. package/dist/types/src/app/components/grid.d.ts +65 -0
  38. package/dist/types/src/app/components/heading-stack.d.ts +42 -0
  39. package/dist/types/src/app/components/history-card.d.ts +12 -0
  40. package/dist/types/src/app/components/icon-button.d.ts +23 -0
  41. package/dist/types/src/app/components/icon.d.ts +30 -0
  42. package/dist/types/src/app/components/info-page.d.ts +10 -0
  43. package/dist/types/src/app/components/inline-code.d.ts +12 -0
  44. package/dist/types/src/app/components/inline-link.d.ts +17 -0
  45. package/dist/types/src/app/components/input.d.ts +46 -0
  46. package/dist/types/src/app/components/lab/tokenUtils.d.ts +38 -0
  47. package/dist/types/src/app/components/menu.d.ts +56 -0
  48. package/dist/types/src/app/components/nav-group.d.ts +24 -0
  49. package/dist/types/src/app/components/nav-item.d.ts +21 -0
  50. package/dist/types/src/app/components/not-found-pattern.d.ts +1 -0
  51. package/dist/types/src/app/components/page.d.ts +43 -0
  52. package/dist/types/src/app/components/pagination.d.ts +24 -0
  53. package/dist/types/src/app/components/popover.d.ts +44 -0
  54. package/dist/types/src/app/components/progress.d.ts +25 -0
  55. package/dist/types/src/app/components/radio.d.ts +18 -0
  56. package/dist/types/src/app/components/segmented-control.d.ts +33 -0
  57. package/dist/types/src/app/components/skeleton.d.ts +25 -0
  58. package/dist/types/src/app/components/sketch.d.ts +13 -0
  59. package/dist/types/src/app/components/slider.d.ts +22 -0
  60. package/dist/types/src/app/components/spinner.d.ts +20 -0
  61. package/dist/types/src/app/components/stack.d.ts +39 -0
  62. package/dist/types/src/app/components/stat.d.ts +24 -0
  63. package/dist/types/src/app/components/status-list-item.d.ts +25 -0
  64. package/dist/types/src/app/components/status-tile.d.ts +22 -0
  65. package/dist/types/src/app/components/stepper-field.d.ts +13 -0
  66. package/dist/types/src/app/components/surface-padding.d.ts +18 -0
  67. package/dist/types/src/app/components/surface.d.ts +30 -0
  68. package/dist/types/src/app/components/table.d.ts +40 -0
  69. package/dist/types/src/app/components/tabs.d.ts +27 -0
  70. package/dist/types/src/app/components/tag.d.ts +32 -0
  71. package/dist/types/src/app/components/text-lockup.d.ts +38 -0
  72. package/dist/types/src/app/components/text.d.ts +26 -0
  73. package/dist/types/src/app/components/tile-grid.d.ts +17 -0
  74. package/dist/types/src/app/components/toast.d.ts +56 -0
  75. package/dist/types/src/app/components/toggle.d.ts +18 -0
  76. package/dist/types/src/app/components/token.d.ts +59 -0
  77. package/dist/types/src/app/components/tooltip.d.ts +33 -0
  78. package/dist/types/src/app/context/DemoStateContext.d.ts +21 -0
  79. package/dist/types/src/app/context/FontContext.d.ts +4 -0
  80. package/dist/types/src/app/context/LanguageContext.d.ts +23 -0
  81. package/dist/types/src/app/context/RouterContext.d.ts +61 -0
  82. package/dist/types/src/app/context/TenantContext.d.ts +29 -0
  83. package/dist/types/src/app/context/ThemeContext.d.ts +18 -0
  84. package/dist/types/src/app/context/TokenDisplayContext.d.ts +11 -0
  85. package/dist/types/src/app/context/index.d.ts +19 -0
  86. package/dist/types/src/app/data/manifest-types.d.ts +128 -0
  87. package/dist/types/src/app/design-system/generated-token-refs.d.ts +586 -0
  88. package/dist/types/src/app/design-system/generated-token-values.d.ts +223 -0
  89. package/dist/types/src/app/design-system/theme.d.ts +32 -0
  90. package/dist/types/src/app/design-system/tokens.d.ts +333 -0
  91. package/dist/types/src/app/hooks/useFocusVisible.d.ts +9 -0
  92. package/dist/types/src/app/hooks/useInteractionState.d.ts +27 -0
  93. package/dist/types/src/app/layouts/CaseStudyLayout.d.ts +21 -0
  94. package/dist/types/src/app/layouts/DocLayout.d.ts +16 -0
  95. package/dist/types/src/app/layouts/EmbeddedDocLayoutContext.d.ts +6 -0
  96. package/dist/types/src/app/lib/nav-active.d.ts +16 -0
  97. package/dist/types/src/app/lib/navLevels.d.ts +4 -0
  98. package/dist/types/src/app/pages/hds/HdsSystemDocLayout.d.ts +7 -0
  99. package/dist/types/src/form/hds-form.d.ts +61 -0
  100. package/dist/types/src/form/index.d.ts +30 -0
  101. package/dist/types/src/form/use-hds-form.d.ts +23 -0
  102. package/dist/types/src/index.d.ts +2276 -0
  103. package/dist/types/src/lib/deprecation.d.ts +4 -0
  104. package/dist/types/src/lib/manifest-entry.d.ts +3 -0
  105. package/dist/types/src/lib/utils.d.ts +3 -0
  106. package/dist/variables.css +461 -0
  107. package/hirobius.tokens.json +2220 -0
  108. package/package.json +366 -0
  109. package/protocol/envelope.mjs +201 -0
  110. package/protocol/figma-snapshot.schema.json +190 -0
  111. package/public/hds-manifest.json +11230 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Adrian Milsap
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,124 @@
1
+ # Hirobius Design System V2
2
+
3
+ Hirobius is a portfolio-grade design-system product surface: a React and TypeScript site, a governed component library, a token pipeline, and an autonomous verification loop living in one repository.
4
+
5
+ ## Using the published package
6
+
7
+ Installing HDS in another project? It ships to the **public npm registry** as
8
+ `@hirobius/design-system` (ESM) — no `.npmrc`, no token, no registry config. Full
9
+ guide: **[docs/CONSUMING.md](docs/CONSUMING.md)**. The short version:
10
+
11
+ ```bash
12
+ npm install @hirobius/design-system react react-dom
13
+ # react-router is an OPTIONAL peer — only if you want HDS links to drive your router
14
+ ```
15
+
16
+ ```tsx
17
+ // once at the app root — full bundle: tokens + theme + utilities + embedded fonts
18
+ import '@hirobius/design-system/tokens.css';
19
+ import { Button } from '@hirobius/design-system';
20
+
21
+ // add data-hds to the root (or any section) so the scoped base styles apply
22
+ export const App = () => (
23
+ <div data-hds>
24
+ <Button>Get started</Button>
25
+ </div>
26
+ );
27
+ ```
28
+
29
+ No router, Tailwind config, or font files needed. With a router, inject it once
30
+ via `<HdsRouterProvider>`. See **[docs/CONSUMING.md](docs/CONSUMING.md)** for the
31
+ router seam, `data-hds` scoping, and MUI coexistence.
32
+
33
+ ## Developing this repo
34
+
35
+ ```bash
36
+ pnpm install
37
+ pnpm dev
38
+ ```
39
+
40
+ Core verification commands:
41
+
42
+ ```bash
43
+ pnpm typecheck
44
+ pnpm run heal
45
+ pnpm test:layout
46
+ pnpm check:size
47
+ ```
48
+
49
+ ## HDS V2 architecture
50
+
51
+ HDS V2 is built around three structural rules:
52
+
53
+ - Strict semantics: public surfaces prefer system primitives such as `HdsStack`, `HdsGrid`, `HdsSurface`, `HdsTextLockup`, `DocLayout`, and `CaseStudyLayout` instead of raw layout divs or ad hoc CSS.
54
+ - Polymorphism: primitives are expected to preserve semantic HTML while staying composable through governed APIs such as `forwardRef`, `as`, and layout slots.
55
+ - 12-column grid: page structure is organized around a consistent editorial grid, with readable center columns, intentional breakout zones, and explicit `gap` ownership rather than one-off spacing math.
56
+
57
+ This repo treats the following files as source of truth:
58
+
59
+ - `hirobius.tokens.json`: token values and alias chain.
60
+ - `public/hds-manifest.json`: machine-readable system inventory, metadata, and docs linkage.
61
+ - `src/app/data/component-api.json`: generated prop tables and reflected component API.
62
+ - `DESIGN.md`: lean visual spec for agents and engineers.
63
+ - `DESIGN-HANDOFF.md`: verbose visual mirror for handoff and review.
64
+
65
+ ## Editorial Enterprise philosophy
66
+
67
+ The governing visual direction is "Editorial Enterprise": enterprise-grade rigor with editorial pacing and restraint. The system favors sharp hierarchy, open whitespace, disciplined monochrome neutrals, and a single electric-blue accent. Layouts should feel authored rather than templated.
68
+
69
+ In practice that means:
70
+
71
+ - documentation reads like a designed publication, not a component dump
72
+ - cards are used sparingly; whitespace, rails, dividers, and bands carry structure first
73
+ - motion teaches or clarifies instead of decorating
74
+ - surfaces, spacing, and type are token-governed so the visual language stays coherent across portfolio pages and HDS docs
75
+
76
+ ## Autonomous agentic workflow
77
+
78
+ Regression prevention is intentionally layered.
79
+
80
+ `CLAUDE.md` is the operating contract. It defines the agent execution protocol, permanent UI guardrails, required validation steps, and the self-heal requirement before a task can be marked complete.
81
+
82
+ `scripts/self-heal.mjs` is the automated repair loop. It runs the local static and smoke checks, captures failures, and gives the agent a consistent path to diagnose and fix type, layout, and runtime drift before reporting completion.
83
+
84
+ The Playwright guardrails enforce the visual constitution at runtime. The current suite covers accessibility, layout integrity, collision detection, responsiveness, and visual regression so changes that violate containment, overlap, or responsive behavior fail automatically.
85
+
86
+ Together the workflow is:
87
+
88
+ 1. Change code inside the token and component constraints.
89
+ 2. Run `pnpm typecheck` and `pnpm run heal`.
90
+ 3. Let Playwright catch runtime and visual regressions.
91
+ 4. If a regression is fixed through self-healing, log the root cause and resolution.
92
+ 5. Only then update the verification checklist and ship the change.
93
+
94
+ ## Bundle and release hygiene
95
+
96
+ This repo tracks both runtime quality and size drift:
97
+
98
+ - `pnpm check:size` builds the library bundle and runs `size-limit`.
99
+ - `pnpm perf:budget` runs Lighthouse CI assertions for page performance budgets.
100
+ - `pnpm check:release` runs the full release gate, including accessibility, responsive, collision, visual, and bundle-size checks.
101
+
102
+ ## Repository shape
103
+
104
+ ```text
105
+ src/
106
+ app/
107
+ components/
108
+ layouts/
109
+ pages/
110
+ styles/
111
+ scripts/
112
+ docs/
113
+ public/
114
+ ```
115
+
116
+ ## Primary docs
117
+
118
+ - [`docs/CONSUMING.md`](docs/CONSUMING.md) — installing & using the published package
119
+ - `CLAUDE.md`
120
+ - `DESIGN.md`
121
+ - `DESIGN-HANDOFF.md`
122
+ - `TASKS.md`
123
+ - `TOKEN_GOVERNANCE.md`
124
+ - `SYSTEMS_REGISTRY.md`
@@ -0,0 +1,95 @@
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { useContext as i, createContext as a, forwardRef as w, useState as l, useEffect as L, useCallback as c } from "react";
3
+ const d = a(null);
4
+ function b({ state: t, children: e }) {
5
+ return /* @__PURE__ */ r(d.Provider, { value: t, children: e });
6
+ }
7
+ function E() {
8
+ return i(d);
9
+ }
10
+ const x = w(
11
+ function({ to: e, children: n, ...o }, u) {
12
+ return /* @__PURE__ */ r("a", { ref: u, href: e, ...o, children: n });
13
+ }
14
+ ), g = a(null);
15
+ function k({ adapter: t, children: e }) {
16
+ return /* @__PURE__ */ r(g.Provider, { value: t, children: e });
17
+ }
18
+ function y() {
19
+ const t = i(g);
20
+ return t || {
21
+ navigate: (e) => {
22
+ typeof window < "u" && window.location.assign(e);
23
+ },
24
+ currentPath: typeof window < "u" ? window.location.pathname : "/",
25
+ LinkComponent: x
26
+ };
27
+ }
28
+ const f = {
29
+ en: {
30
+ language: "en",
31
+ dir: "ltr",
32
+ label: "English",
33
+ nativeLabel: "English"
34
+ }
35
+ }, m = a({
36
+ language: "en",
37
+ direction: "ltr",
38
+ isRtl: !1,
39
+ setLanguage: () => {
40
+ },
41
+ setDirection: () => {
42
+ },
43
+ toggleDirection: () => {
44
+ },
45
+ options: f
46
+ });
47
+ function D() {
48
+ try {
49
+ const t = localStorage.getItem("hds-direction");
50
+ if (t === "ltr" || t === "rtl") return t;
51
+ } catch {
52
+ }
53
+ return "ltr";
54
+ }
55
+ function A({ children: t }) {
56
+ const [e, n] = l(D), o = "en", u = e === "rtl";
57
+ L(() => {
58
+ try {
59
+ localStorage.setItem("hds-direction", e);
60
+ } catch {
61
+ }
62
+ document.documentElement.setAttribute("lang", "en"), document.documentElement.setAttribute("data-language", "en"), document.documentElement.setAttribute("dir", e), document.documentElement.setAttribute("data-reading-direction", e);
63
+ }, [e]);
64
+ const h = c((s) => {
65
+ }, []), v = c((s) => {
66
+ n(s);
67
+ }, []), p = c(() => {
68
+ n((s) => s === "ltr" ? "rtl" : "ltr");
69
+ }, []);
70
+ return /* @__PURE__ */ r(m.Provider, { value: { language: o, direction: e, isRtl: u, setLanguage: h, setDirection: v, toggleDirection: p, options: f }, children: t });
71
+ }
72
+ function R() {
73
+ return i(m);
74
+ }
75
+ const C = a(void 0);
76
+ function H({ children: t }) {
77
+ const [e, n] = l(!1);
78
+ return /* @__PURE__ */ r(C.Provider, { value: { showCss: e, setShowCss: n, toggleCss: () => n((o) => !o) }, children: t });
79
+ }
80
+ function T() {
81
+ const t = i(C);
82
+ return t || { showCss: !1, setShowCss: () => {
83
+ }, toggleCss: () => {
84
+ } };
85
+ }
86
+ export {
87
+ b as F,
88
+ k as H,
89
+ A as L,
90
+ H as T,
91
+ R as a,
92
+ E as b,
93
+ T as c,
94
+ y as u
95
+ };
@@ -0,0 +1,63 @@
1
+ import { jsx as m, jsxs as u } from "react/jsx-runtime";
2
+ import * as s from "react";
3
+ import { cn as p } from "../cn.js";
4
+ const g = s.forwardRef(function({ className: e, ...l }, o) {
5
+ return /* @__PURE__ */ m("form", { ref: o, className: p("flex flex-col gap-4", e), ...l });
6
+ });
7
+ function F({
8
+ htmlFor: c,
9
+ childId: e,
10
+ description: l,
11
+ error: o
12
+ }) {
13
+ const i = s.useId(), r = c ?? e ?? i, n = `${r}-description`, d = `${r}-error`, a = [l ? n : null, o ? d : null].filter(Boolean).join(" ") || void 0;
14
+ return { controlId: r, descriptionId: n, errorId: d, describedBy: a };
15
+ }
16
+ const b = s.forwardRef(
17
+ function({ controlId: e, label: l, description: o, error: i, required: r = !1, className: n, children: d }, a) {
18
+ const t = `${e}-description`, f = `${e}-error`;
19
+ return /* @__PURE__ */ u("div", { ref: a, className: p("flex flex-col gap-2", n), children: [
20
+ /* @__PURE__ */ u("label", { htmlFor: e, className: "text-sm font-medium text-foreground", children: [
21
+ l,
22
+ r ? /* @__PURE__ */ u("span", { "aria-hidden": "true", className: "text-destructive", children: [
23
+ " ",
24
+ "*"
25
+ ] }) : null
26
+ ] }),
27
+ d,
28
+ o && !i ? /* @__PURE__ */ m("p", { id: t, className: "text-xs text-muted-foreground", children: o }) : null,
29
+ i ? /* @__PURE__ */ m("p", { id: f, role: "alert", className: "text-xs text-destructive", children: i }) : null
30
+ ] });
31
+ }
32
+ ), N = s.forwardRef(function({ label: e, children: l, htmlFor: o, description: i, error: r, required: n = !1, className: d }, a) {
33
+ const t = s.Children.only(l), { controlId: f, describedBy: x } = F({
34
+ htmlFor: o,
35
+ childId: t.props.id,
36
+ description: i,
37
+ error: r
38
+ }), h = s.cloneElement(t, {
39
+ id: f,
40
+ required: t.props.required ?? n,
41
+ "aria-invalid": r ? !0 : t.props["aria-invalid"],
42
+ "aria-describedby": [t.props["aria-describedby"], x].filter(Boolean).join(" ") || void 0
43
+ });
44
+ return /* @__PURE__ */ m(
45
+ b,
46
+ {
47
+ ref: a,
48
+ controlId: f,
49
+ label: e,
50
+ description: i,
51
+ error: r,
52
+ required: n,
53
+ className: d,
54
+ children: h
55
+ }
56
+ );
57
+ });
58
+ export {
59
+ g as F,
60
+ N as a,
61
+ b,
62
+ F as u
63
+ };
package/dist/cn.js ADDED
@@ -0,0 +1,8 @@
1
+ import { clsx as o } from "clsx";
2
+ import { twMerge as t } from "tailwind-merge";
3
+ function n(...r) {
4
+ return t(o(r));
5
+ }
6
+ export {
7
+ n as cn
8
+ };
@@ -0,0 +1,133 @@
1
+ import { jsx as l, Fragment as A } from "react/jsx-runtime";
2
+ import { useState as i, useCallback as a, useEffect as s, useContext as T, createContext as v } from "react";
3
+ import { F as U, H as z, L as K, T as Y, b as j, u as q, a as B, c as J } from "./chunks/TokenDisplayContext-B3gxyQN7.js";
4
+ const I = ["system", "light", "dark"], m = "hds-theme-mode", w = "hds-theme", S = v({
5
+ isDark: !0,
6
+ toggleDark: () => {
7
+ },
8
+ mode: "system",
9
+ setMode: () => {
10
+ },
11
+ density: "comfortable",
12
+ toggleDensity: () => {
13
+ },
14
+ setDensity: () => {
15
+ }
16
+ });
17
+ function y() {
18
+ try {
19
+ const t = localStorage.getItem(m);
20
+ if (t && I.includes(t)) return t;
21
+ } catch {
22
+ }
23
+ return "system";
24
+ }
25
+ function M() {
26
+ var t;
27
+ return typeof window > "u" ? !1 : !!((t = window.matchMedia) != null && t.call(window, "(prefers-color-scheme: dark)").matches);
28
+ }
29
+ function E(t) {
30
+ return t === "dark" ? !0 : t === "light" ? !1 : M();
31
+ }
32
+ function L() {
33
+ try {
34
+ const t = localStorage.getItem("hds-density");
35
+ if (t === "compact" || t === "comfortable") return t;
36
+ } catch {
37
+ }
38
+ return "comfortable";
39
+ }
40
+ function C({ children: t }) {
41
+ const [n, f] = i(y), [r, u] = i(() => E(y())), [c, g] = i(L), h = a((e) => {
42
+ const o = e ? "dark" : "light";
43
+ try {
44
+ localStorage.setItem(w, o);
45
+ } catch {
46
+ }
47
+ document.documentElement.setAttribute("data-theme", o), document.documentElement.classList.toggle("dark", e);
48
+ }, []);
49
+ s(() => {
50
+ try {
51
+ localStorage.setItem("hds-density", c);
52
+ } catch {
53
+ }
54
+ document.documentElement.setAttribute("data-density", c);
55
+ }, [c]), s(() => {
56
+ h(r);
57
+ }, [r, h]), s(() => {
58
+ if (n !== "system" || typeof window > "u" || !window.matchMedia) return;
59
+ const e = window.matchMedia("(prefers-color-scheme: dark)"), o = () => {
60
+ u(e.matches);
61
+ };
62
+ return e.addEventListener("change", o), () => {
63
+ e.removeEventListener("change", o);
64
+ };
65
+ }, [n]);
66
+ const _ = a(() => {
67
+ const e = !r, o = e ? "dark" : "light";
68
+ f(o), u(e);
69
+ try {
70
+ localStorage.setItem(m, o);
71
+ } catch {
72
+ }
73
+ }, [r]), k = a((e) => {
74
+ f(e), u(E(e));
75
+ try {
76
+ localStorage.setItem(m, e);
77
+ } catch {
78
+ }
79
+ }, []), b = a(
80
+ () => g((e) => e === "comfortable" ? "compact" : "comfortable"),
81
+ []
82
+ ), p = a((e) => g(e), []);
83
+ return /* @__PURE__ */ l(
84
+ S.Provider,
85
+ {
86
+ value: { isDark: r, toggleDark: _, mode: n, setMode: k, density: c, toggleDensity: b, setDensity: p },
87
+ children: t
88
+ }
89
+ );
90
+ }
91
+ function N() {
92
+ return T(S);
93
+ }
94
+ const d = {}, D = v({ tenantSlug: null });
95
+ function F({ children: t }) {
96
+ const n = typeof d.VITE_TENANT_SLUG == "string" && d.VITE_TENANT_SLUG.trim().length > 0 ? d.VITE_TENANT_SLUG.trim() : null;
97
+ return s(() => {
98
+ if (n)
99
+ return document.documentElement.setAttribute("data-tenant", n), () => {
100
+ document.documentElement.removeAttribute("data-tenant");
101
+ };
102
+ }, [n]), /* @__PURE__ */ l(D.Provider, { value: { tenantSlug: n }, children: t });
103
+ }
104
+ function G() {
105
+ return T(D);
106
+ }
107
+ function O(t) {
108
+ s(() => {
109
+ const n = document.documentElement.getAttribute("data-tenant");
110
+ return document.documentElement.setAttribute("data-tenant", t), () => {
111
+ n !== null ? document.documentElement.setAttribute("data-tenant", n) : document.documentElement.removeAttribute("data-tenant");
112
+ };
113
+ }, [t]);
114
+ }
115
+ function H({ children: t }) {
116
+ return /* @__PURE__ */ l(A, { children: t });
117
+ }
118
+ export {
119
+ H as FontProvider,
120
+ U as FreezeState,
121
+ z as HdsRouterProvider,
122
+ K as LanguageProvider,
123
+ F as TenantProvider,
124
+ C as ThemeProvider,
125
+ Y as TokenDisplayProvider,
126
+ j as useFrozenState,
127
+ q as useHdsRouter,
128
+ B as useLanguage,
129
+ G as useTenant,
130
+ O as useTenantOnDocument,
131
+ N as useTheme,
132
+ J as useTokenDisplay
133
+ };
package/dist/form.js ADDED
@@ -0,0 +1,62 @@
1
+ import { useForm as f, FormProvider as h, useController as v } from "react-hook-form";
2
+ import { zodResolver as b } from "@hookform/resolvers/zod";
3
+ import { jsx as t } from "react/jsx-runtime";
4
+ import { F as p, u as g, b as S } from "./chunks/form-DnGRy27o.js";
5
+ function y(r, e) {
6
+ return f({
7
+ mode: "onTouched",
8
+ ...e,
9
+ // @hookform/resolvers v5 + zod v4 model the resolver through separate
10
+ // input/output generics that don't unify against a single TFieldValues
11
+ // parameter. The schema parses TO TFieldValues here, so the cast is sound
12
+ // and keeps the public return type a plain UseFormReturn<TFieldValues>.
13
+ resolver: b(r)
14
+ });
15
+ }
16
+ function P({
17
+ form: r,
18
+ onSubmit: e,
19
+ children: i,
20
+ ...n
21
+ }) {
22
+ return /* @__PURE__ */ t(h, { ...r, children: /* @__PURE__ */ t(p, { noValidate: !0, onSubmit: r.handleSubmit(e), ...n, children: i }) });
23
+ }
24
+ function j({
25
+ name: r,
26
+ label: e,
27
+ children: i,
28
+ description: n,
29
+ required: l,
30
+ className: a
31
+ }) {
32
+ var m;
33
+ const { field: o, fieldState: u } = v({ name: r }), d = (m = u.error) == null ? void 0 : m.message, { controlId: s, describedBy: c } = g({ description: n, error: d }), F = {
34
+ name: o.name,
35
+ // Coalesce nullish to '' so a controlled input never flips to uncontrolled.
36
+ value: o.value ?? "",
37
+ onChange: o.onChange,
38
+ onBlur: o.onBlur,
39
+ ref: o.ref,
40
+ id: s,
41
+ required: l,
42
+ "aria-invalid": d ? !0 : void 0,
43
+ "aria-describedby": c
44
+ };
45
+ return /* @__PURE__ */ t(
46
+ S,
47
+ {
48
+ controlId: s,
49
+ label: e,
50
+ description: n,
51
+ error: d,
52
+ required: l,
53
+ className: a,
54
+ children: i(F)
55
+ }
56
+ );
57
+ }
58
+ export {
59
+ P as HdsForm,
60
+ j as HdsFormField,
61
+ y as useHdsForm
62
+ };