@whity/ui 0.0.0-stage → 1.0.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 (205) hide show
  1. package/README.md +106 -2
  2. package/package.json +219 -4
  3. package/src/access-denied.stories.tsx +179 -0
  4. package/src/access-denied.tsx +305 -0
  5. package/src/action-proposal.tsx +338 -0
  6. package/src/actor-chip.tsx +71 -0
  7. package/src/agent-activity.tsx +163 -0
  8. package/src/agent-collaboration.stories.tsx +156 -0
  9. package/src/agent-run-status.tsx +196 -0
  10. package/src/alert-dialog.stories.tsx +45 -0
  11. package/src/alert-dialog.tsx +147 -0
  12. package/src/alert.stories.tsx +91 -0
  13. package/src/alert.tsx +89 -0
  14. package/src/app-sidebar.stories.tsx +195 -0
  15. package/src/app-sidebar.tsx +604 -0
  16. package/src/approval-queue.tsx +109 -0
  17. package/src/audience-group-picker.stories.tsx +198 -0
  18. package/src/audience-group-picker.tsx +362 -0
  19. package/src/audience-people-picker.stories.tsx +102 -0
  20. package/src/audience-people-picker.tsx +279 -0
  21. package/src/avatar-pattern.ts +138 -0
  22. package/src/avatar.tsx +125 -0
  23. package/src/badge.stories.tsx +105 -0
  24. package/src/badge.tsx +68 -0
  25. package/src/beta-warning.stories.tsx +79 -0
  26. package/src/beta-warning.tsx +189 -0
  27. package/src/bilingual-input.stories.tsx +82 -0
  28. package/src/bilingual-input.tsx +188 -0
  29. package/src/board.tsx +216 -0
  30. package/src/breadcrumb.stories.tsx +51 -0
  31. package/src/breadcrumb.tsx +90 -0
  32. package/src/built-on-whity.tsx +52 -0
  33. package/src/button.stories.tsx +87 -0
  34. package/src/button.tsx +123 -0
  35. package/src/card.stories.tsx +423 -0
  36. package/src/card.tsx +180 -0
  37. package/src/chart.stories.tsx +66 -0
  38. package/src/chart.tsx +228 -0
  39. package/src/checkbox.stories.tsx +62 -0
  40. package/src/checkbox.tsx +54 -0
  41. package/src/collapsible.stories.tsx +48 -0
  42. package/src/collapsible.tsx +34 -0
  43. package/src/color-card.stories.tsx +61 -0
  44. package/src/color-card.tsx +270 -0
  45. package/src/color-picker.stories.tsx +65 -0
  46. package/src/color-picker.tsx +425 -0
  47. package/src/column-matcher.tsx +84 -0
  48. package/src/command-palette.tsx +398 -0
  49. package/src/confirm-action.tsx +98 -0
  50. package/src/copy-block.stories.tsx +38 -0
  51. package/src/copy-block.tsx +85 -0
  52. package/src/data-table.stories.tsx +200 -0
  53. package/src/data-table.tsx +1686 -0
  54. package/src/date-picker.stories.tsx +61 -0
  55. package/src/date-picker.tsx +456 -0
  56. package/src/design-cards.stories.tsx +551 -0
  57. package/src/dialog.stories.tsx +48 -0
  58. package/src/dialog.tsx +179 -0
  59. package/src/display-preferences.tsx +50 -0
  60. package/src/documents/barcode-svg.stories.tsx +72 -0
  61. package/src/documents/barcode-svg.tsx +79 -0
  62. package/src/dropdown-menu.stories.tsx +77 -0
  63. package/src/dropdown-menu.tsx +271 -0
  64. package/src/editor/agent-panel.tsx +222 -0
  65. package/src/editor/agents.stories.tsx +81 -0
  66. package/src/editor/agents.ts +55 -0
  67. package/src/editor/behaviour.ts +279 -0
  68. package/src/editor/block-ids.ts +44 -0
  69. package/src/editor/block-list.tsx +104 -0
  70. package/src/editor/block-toolbar.tsx +490 -0
  71. package/src/editor/bubble.tsx +119 -0
  72. package/src/editor/catalogue.ts +169 -0
  73. package/src/editor/collab-rail.tsx +746 -0
  74. package/src/editor/collab.stories.tsx +207 -0
  75. package/src/editor/collab.ts +87 -0
  76. package/src/editor/contract.ts +476 -0
  77. package/src/editor/convert.ts +414 -0
  78. package/src/editor/doc-editor.stories.tsx +98 -0
  79. package/src/editor/doc-editor.tsx +1492 -0
  80. package/src/editor/editor.css +636 -0
  81. package/src/editor/extensions.ts +86 -0
  82. package/src/editor/field-bar.tsx +154 -0
  83. package/src/editor/field-picker.tsx +109 -0
  84. package/src/editor/fields.ts +100 -0
  85. package/src/editor/gutter.tsx +443 -0
  86. package/src/editor/index.ts +23 -0
  87. package/src/editor/label-sheet.tsx +289 -0
  88. package/src/editor/labels.ts +394 -0
  89. package/src/editor/link-tools.tsx +141 -0
  90. package/src/editor/node-views.tsx +461 -0
  91. package/src/editor/page-view.tsx +372 -0
  92. package/src/editor/phone.tsx +310 -0
  93. package/src/editor/plugin-block-view.tsx +230 -0
  94. package/src/editor/plugin-blocks.stories.tsx +96 -0
  95. package/src/editor/plugin-blocks.ts +52 -0
  96. package/src/editor/publish-check.tsx +201 -0
  97. package/src/editor/rich-blocks.stories.tsx +146 -0
  98. package/src/editor/sample.ts +40 -0
  99. package/src/editor/save-block-dialog.tsx +141 -0
  100. package/src/editor/saved-block-view.tsx +205 -0
  101. package/src/editor/saved-blocks.stories.tsx +105 -0
  102. package/src/editor/saved-parts.ts +192 -0
  103. package/src/editor/schema-rich.ts +156 -0
  104. package/src/editor/schema.ts +368 -0
  105. package/src/editor/services.tsx +205 -0
  106. package/src/editor/slash.ts +64 -0
  107. package/src/editor/suggesting.ts +372 -0
  108. package/src/editor/suggestions.ts +763 -0
  109. package/src/editor/table-keys.ts +66 -0
  110. package/src/editor/templates.stories.tsx +324 -0
  111. package/src/editor/toolbar.tsx +364 -0
  112. package/src/empty-state.stories.tsx +51 -0
  113. package/src/empty-state.tsx +126 -0
  114. package/src/empty-state.usage-notes.md +30 -0
  115. package/src/form.stories.tsx +112 -0
  116. package/src/form.tsx +176 -0
  117. package/src/globals.css +20 -0
  118. package/src/icon-button.tsx +85 -0
  119. package/src/icon-map.ts +335 -0
  120. package/src/icon.tsx +41 -0
  121. package/src/index.ts +90 -0
  122. package/src/input.stories.tsx +157 -0
  123. package/src/input.tsx +768 -0
  124. package/src/kpi-strip.tsx +47 -0
  125. package/src/localized-text.ts +76 -0
  126. package/src/locked-screen.stories.tsx +29 -0
  127. package/src/locked-screen.tsx +75 -0
  128. package/src/lockup.tsx +42 -0
  129. package/src/lottie.tsx +441 -0
  130. package/src/mark.tsx +62 -0
  131. package/src/math-text.stories.tsx +33 -0
  132. package/src/math-text.tsx +43 -0
  133. package/src/menu-bar.stories.tsx +198 -0
  134. package/src/menu-bar.tsx +373 -0
  135. package/src/message-thread.tsx +181 -0
  136. package/src/money/currency.ts +244 -0
  137. package/src/money/money-input.tsx +131 -0
  138. package/src/money/money.tsx +33 -0
  139. package/src/open-on-computer.tsx +150 -0
  140. package/src/otp-input.tsx +161 -0
  141. package/src/page-header.stories.tsx +95 -0
  142. package/src/page-header.tsx +122 -0
  143. package/src/page-shell.stories.tsx +42 -0
  144. package/src/page-shell.tsx +32 -0
  145. package/src/page-states.tsx +277 -0
  146. package/src/pagination.stories.tsx +45 -0
  147. package/src/pagination.tsx +98 -0
  148. package/src/paper-sheet.stories.tsx +88 -0
  149. package/src/paper-sheet.tsx +85 -0
  150. package/src/phone-tab-bar.tsx +152 -0
  151. package/src/plugin-card.stories.tsx +208 -0
  152. package/src/plugin-card.tsx +931 -0
  153. package/src/popover.stories.tsx +48 -0
  154. package/src/popover.tsx +55 -0
  155. package/src/radio-group.stories.tsx +26 -0
  156. package/src/radio-group.tsx +44 -0
  157. package/src/route-flow/editor.tsx +1087 -0
  158. package/src/route-flow/model.ts +771 -0
  159. package/src/save-bar.tsx +94 -0
  160. package/src/scope-grant.tsx +139 -0
  161. package/src/screen-too-small.stories.tsx +61 -0
  162. package/src/screen-too-small.tsx +104 -0
  163. package/src/search-field.tsx +65 -0
  164. package/src/select.stories.tsx +44 -0
  165. package/src/select.tsx +197 -0
  166. package/src/separator.stories.tsx +34 -0
  167. package/src/separator.tsx +34 -0
  168. package/src/sheet.stories.tsx +49 -0
  169. package/src/sheet.tsx +168 -0
  170. package/src/skeleton.stories.tsx +28 -0
  171. package/src/skeleton.tsx +19 -0
  172. package/src/slider.stories.tsx +78 -0
  173. package/src/slider.tsx +300 -0
  174. package/src/spinner.stories.tsx +33 -0
  175. package/src/spinner.tsx +55 -0
  176. package/src/stepper.tsx +85 -0
  177. package/src/switch.stories.tsx +42 -0
  178. package/src/switch.tsx +41 -0
  179. package/src/switcher.stories.tsx +111 -0
  180. package/src/switcher.tsx +131 -0
  181. package/src/system-state.tsx +55 -0
  182. package/src/table.stories.tsx +48 -0
  183. package/src/table.tsx +121 -0
  184. package/src/tabs.stories.tsx +74 -0
  185. package/src/tabs.tsx +90 -0
  186. package/src/tag-input.stories.tsx +67 -0
  187. package/src/tag-input.tsx +117 -0
  188. package/src/tenant-logo.tsx +63 -0
  189. package/src/tenant-switcher.stories.tsx +38 -0
  190. package/src/tenant-switcher.tsx +164 -0
  191. package/src/textarea.stories.tsx +27 -0
  192. package/src/textarea.tsx +18 -0
  193. package/src/theme-mode.ts +52 -0
  194. package/src/time-grid.tsx +163 -0
  195. package/src/time-picker.stories.tsx +62 -0
  196. package/src/time-picker.tsx +615 -0
  197. package/src/toggle-group.tsx +138 -0
  198. package/src/tooltip.stories.tsx +43 -0
  199. package/src/tooltip.tsx +73 -0
  200. package/src/top-nav.stories.tsx +58 -0
  201. package/src/top-nav.tsx +324 -0
  202. package/src/undo-bar.tsx +107 -0
  203. package/src/utils.ts +45 -0
  204. package/src/view-toggle.stories.tsx +84 -0
  205. package/src/view-toggle.tsx +110 -0
@@ -0,0 +1,188 @@
1
+ "use client"
2
+
3
+
4
+ import { cn } from "./utils"
5
+ import { Input } from "./input"
6
+ import { Badge } from "./badge"
7
+
8
+ /**
9
+ * The value shape every bilingual field speaks — a plain `{ar?, en?, [key: string]: string | undefined}` pair/map,
10
+ * matching the LocalizedText convention (WC-532) used by schema-driven CRUD
11
+ * screens and any plugin storing bilingual/multilingual content.
12
+ */
13
+ export interface BilingualValue {
14
+ ar?: string
15
+ en?: string
16
+ [key: string]: string | undefined
17
+ }
18
+
19
+ export interface LanguageConfig {
20
+ /** Language ISO code (e.g. "ar", "en", "fr", "de", "es") */
21
+ code: string
22
+ /** Human-readable language name (e.g. "Arabic", "English", "French") */
23
+ label: string
24
+ /** Text direction: "rtl" or "ltr" (defaults to "rtl" for ar/fa/ur/he, "ltr" otherwise) */
25
+ dir?: "rtl" | "ltr"
26
+ /** Short badge text (defaults to uppercase code e.g. "AR") */
27
+ badge?: string
28
+ }
29
+
30
+ export interface BilingualInputProps {
31
+ /** Overall field group title/label (e.g. "Job Title" or "Organization Name"). */
32
+ label?: string
33
+ /** Subtitle or description explaining the field. */
34
+ description?: string
35
+ /** Base id; the primary/secondary inputs get `${id}-${primaryLang.code}` / `${id}-${secondaryLang.code}`. */
36
+ id?: string
37
+ value: BilingualValue
38
+ onChange: (value: BilingualValue) => void
39
+ /** Configuration for primary language input (defaults to Arabic `AR`). */
40
+ primaryLang?: LanguageConfig
41
+ /** Configuration for secondary language input (defaults to English `EN`). */
42
+ secondaryLang?: LanguageConfig
43
+ /** Backward-compatibility prop for Arabic label text. */
44
+ arLabel?: string
45
+ /** Backward-compatibility prop for English label text. */
46
+ enLabel?: string
47
+ disabled?: boolean
48
+ required?: boolean
49
+ /** The words on the badge beside a language that has text, and one that has none. */
50
+ presentLabel?: string
51
+ emptyLabel?: string
52
+ className?: string
53
+ }
54
+
55
+ /**
56
+ * The atom of every bilingual form (WC-532): two synced fields —
57
+ * configurable for any language pair (e.g. AR/EN, FR/DE, ES/EN) —
58
+ * with an overall field title, explicit language badges (`AR`, `EN`),
59
+ * presence indicators, and a single `{ar?, en?}` value in/out.
60
+ */
61
+ export function BilingualInput({
62
+ label,
63
+ description,
64
+ id,
65
+ value,
66
+ onChange,
67
+ primaryLang,
68
+ secondaryLang,
69
+ arLabel,
70
+ enLabel,
71
+ disabled = false,
72
+ required = false,
73
+ presentLabel = "Set",
74
+ emptyLabel = "Empty",
75
+ className,
76
+ }: BilingualInputProps) {
77
+ const pCode = primaryLang?.code ?? "ar"
78
+ const sCode = secondaryLang?.code ?? "en"
79
+
80
+ const pLang: LanguageConfig = {
81
+ code: pCode,
82
+ label: arLabel ?? primaryLang?.label ?? "Arabic",
83
+ dir: primaryLang?.dir ?? (pCode === "ar" || pCode === "fa" || pCode === "ur" || pCode === "he" ? "rtl" : "ltr"),
84
+ badge: primaryLang?.badge ?? pCode.toUpperCase(),
85
+ }
86
+
87
+ const sLang: LanguageConfig = {
88
+ code: sCode,
89
+ label: enLabel ?? secondaryLang?.label ?? "English",
90
+ dir: secondaryLang?.dir ?? (sCode === "ar" || sCode === "fa" || sCode === "ur" || sCode === "he" ? "rtl" : "ltr"),
91
+ badge: secondaryLang?.badge ?? sCode.toUpperCase(),
92
+ }
93
+
94
+ const arId = id ? (id.endsWith("-ar") ? id : `${id}-ar`) : undefined
95
+ const enId = id ? (id.endsWith("-en") ? id : `${id}-en`) : undefined
96
+
97
+ const pId = pCode === "ar" ? arId : id ? `${id}-${pCode}` : undefined
98
+ const sId = sCode === "en" ? enId : id ? `${id}-${sCode}` : undefined
99
+
100
+ const pVal = value[pLang.code] ?? (pLang.code === "ar" ? value.ar : undefined) ?? ""
101
+ const sVal = value[sLang.code] ?? (sLang.code === "en" ? value.en : undefined) ?? ""
102
+
103
+ return (
104
+ <div data-slot="bilingual-input" className={cn("space-y-2", className)}>
105
+ {/* Field Title & Description */}
106
+ {label && (
107
+ <div className="flex flex-col gap-0.5">
108
+ <label className="text-xs font-semibold text-foreground">
109
+ {label}
110
+ {required && <span className="ms-0.5 text-destructive">*</span>}
111
+ </label>
112
+ {description && <p className="text-xs text-muted-foreground">{description}</p>}
113
+ </div>
114
+ )}
115
+
116
+ {/* Grid of Language Inputs */}
117
+ <div className="grid gap-3 sm:grid-cols-2">
118
+ {/* Primary Language Input */}
119
+ <div className="space-y-1.5">
120
+ <div className="flex items-center justify-between gap-2">
121
+ <div className="flex items-center gap-1.5 min-w-0">
122
+ <Badge variant="outline" className="font-mono font-semibold text-xs uppercase px-1.5 py-0 bg-muted/60 text-foreground shrink-0">
123
+ {pLang.badge}
124
+ </Badge>
125
+ <label htmlFor={pId} className="text-xs font-medium text-muted-foreground truncate">
126
+ {pLang.label}
127
+ </label>
128
+ </div>
129
+ <PresenceIndicator present={Boolean(pVal.trim())} testId="bilingual-presence-ar" presentLabel={presentLabel} emptyLabel={emptyLabel} />
130
+ </div>
131
+ <Input
132
+ id={pId}
133
+ dir={pLang.dir}
134
+ lang={pLang.code}
135
+ disabled={disabled}
136
+ required={required}
137
+ value={pVal}
138
+ onChange={(event) => {
139
+ const nextVal = { ...value, [pLang.code]: event.target.value }
140
+ if (pLang.code === "ar") nextVal.ar = event.target.value
141
+ onChange(nextVal)
142
+ }}
143
+ />
144
+ </div>
145
+
146
+ {/* Secondary Language Input */}
147
+ <div className="space-y-1.5">
148
+ <div className="flex items-center justify-between gap-2">
149
+ <div className="flex items-center gap-1.5 min-w-0">
150
+ <Badge variant="outline" className="font-mono font-semibold text-xs uppercase px-1.5 py-0 bg-muted/60 text-foreground shrink-0">
151
+ {sLang.badge}
152
+ </Badge>
153
+ <label htmlFor={sId} className="text-xs font-medium text-muted-foreground truncate">
154
+ {sLang.label}
155
+ </label>
156
+ </div>
157
+ <PresenceIndicator present={Boolean(sVal.trim())} testId="bilingual-presence-en" presentLabel={presentLabel} emptyLabel={emptyLabel} />
158
+ </div>
159
+ <Input
160
+ id={sId}
161
+ dir={sLang.dir}
162
+ lang={sLang.code}
163
+ disabled={disabled}
164
+ required={required}
165
+ value={sVal}
166
+ onChange={(event) => {
167
+ const nextVal = { ...value, [sLang.code]: event.target.value }
168
+ if (sLang.code === "en") nextVal.en = event.target.value
169
+ onChange(nextVal)
170
+ }}
171
+ />
172
+ </div>
173
+ </div>
174
+ </div>
175
+ )
176
+ }
177
+
178
+ function PresenceIndicator({ present, testId, presentLabel, emptyLabel }: { present: boolean; testId: string; presentLabel: string; emptyLabel: string }) {
179
+ return (
180
+ <Badge
181
+ variant={present ? "secondary" : "outline"}
182
+ className="text-xs uppercase"
183
+ data-testid={testId}
184
+ >
185
+ {present ? presentLabel : emptyLabel}
186
+ </Badge>
187
+ )
188
+ }
package/src/board.tsx ADDED
@@ -0,0 +1,216 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+
5
+ import { Avatar, type ActorKind } from "./avatar"
6
+ import { Icon, type IconName } from "./icon"
7
+ import { cn } from "./utils"
8
+
9
+ /**
10
+ * A board (T.2, docs/design/components/TplBoard; `.wk-board`, `.wk-col`,
11
+ * `.wk-card` in bundle.css). Tasks live in Taskaat (T.1-T.4); these pieces
12
+ * only draw them, for Tasks, Boards and Flows.
13
+ *
14
+ * Columns are task statuses. A `gate` column (Awaiting review) is amber: an
15
+ * agent's task waits there with its evidence until a person accepts it. A card
16
+ * being dragged is `lifted` onto the plane (tilted 2°) and the place it will
17
+ * land is a dashed `BoardSlot`. Dragging itself belongs to the screen.
18
+ */
19
+
20
+ function Board({ className, ...props }: React.ComponentProps<"div">) {
21
+ return (
22
+ <div
23
+ data-slot="board"
24
+ className={cn(
25
+ "grid auto-cols-[minmax(240px,1fr)] grid-flow-col items-start gap-3.5 overflow-x-auto pb-2",
26
+ // A phone shows one column at a time and swipes between them (TmBoards).
27
+ "max-sm:snap-x max-sm:snap-mandatory max-sm:auto-cols-[100%]",
28
+ className
29
+ )}
30
+ {...props}
31
+ />
32
+ )
33
+ }
34
+
35
+ export interface BoardColumnProps extends Omit<React.ComponentProps<"section">, "title"> {
36
+ title: string
37
+ count?: number
38
+ icon?: IconName
39
+ /** The review gate (amber): nothing passes into Done without a person. */
40
+ gate?: boolean
41
+ /** The column's menu (rename, limits), e.g. an IconButton. */
42
+ menu?: React.ReactNode
43
+ /** Shown at the foot as "Add task"; omit to hide. */
44
+ addLabel?: string
45
+ onAdd?: () => void
46
+ }
47
+
48
+ function BoardColumn({
49
+ title,
50
+ count,
51
+ icon,
52
+ gate = false,
53
+ menu,
54
+ addLabel,
55
+ onAdd,
56
+ className,
57
+ children,
58
+ ...props
59
+ }: BoardColumnProps) {
60
+ const headingId = React.useId()
61
+ return (
62
+ <section
63
+ data-slot="board-column"
64
+ data-gate={gate ? "" : undefined}
65
+ aria-labelledby={headingId}
66
+ className={cn("grid gap-2 rounded-card p-2.5 max-sm:snap-start", gate ? "bg-warning-tint" : "bg-muted", className)}
67
+ {...props}
68
+ >
69
+ <header className="flex items-center gap-2 px-1 pt-0.5 pb-1 text-sm font-semibold">
70
+ {icon && <Icon name={icon} size={14} />}
71
+ <h3 id={headingId} className="m-0 text-sm font-semibold">
72
+ {title}
73
+ </h3>
74
+ {count != null && <span className="font-medium text-muted-foreground tabular-nums">{count}</span>}
75
+ {menu && <span className="ms-auto text-muted-foreground">{menu}</span>}
76
+ </header>
77
+ <div role="list" className="grid gap-2">
78
+ {children}
79
+ </div>
80
+ {addLabel && onAdd && (
81
+ <button
82
+ type="button"
83
+ onClick={onAdd}
84
+ className="flex min-h-8 items-center gap-1.5 rounded-control border-0 bg-transparent px-1 py-1.5 text-start text-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/30"
85
+ >
86
+ <Icon name="plus" size={14} />
87
+ {addLabel}
88
+ </button>
89
+ )}
90
+ </section>
91
+ )
92
+ }
93
+
94
+ /** A label on a card: a small swatch in the label's own colour and its name. */
95
+ function LabelChip({ name, color, className }: { name: string; color?: string; className?: string }) {
96
+ return (
97
+ <span
98
+ data-slot="label-chip"
99
+ className={cn("inline-flex h-6 items-center gap-1.5 rounded-sm bg-muted px-2 text-xs whitespace-nowrap text-foreground", className)}
100
+ >
101
+ <i aria-hidden="true" className="block size-2 rounded-[2px] bg-primary" style={color ? { background: color } : undefined} />
102
+ {name}
103
+ </span>
104
+ )
105
+ }
106
+
107
+ /** Checks met out of the total, as bars that turn green (`.wk-prog`). */
108
+ function CheckProgress({ met, total, label }: { met: number; total: number; label?: string }) {
109
+ const text = (label ?? "{met} of {total} checks met").replace("{met}", String(met)).replace("{total}", String(total))
110
+ return (
111
+ <span data-slot="check-progress" role="img" aria-label={text} className="flex gap-[3px]">
112
+ {Array.from({ length: total }, (_, index) => (
113
+ <i key={index} className={cn("block h-1 w-3.5 rounded-[2px]", index < met ? "bg-success" : "bg-border")} />
114
+ ))}
115
+ </span>
116
+ )
117
+ }
118
+
119
+ export interface BoardCardProps extends Omit<React.ComponentProps<"article">, "title"> {
120
+ title: string
121
+ /** A status badge at the top: Working, Evidence ready, Verified, Done, unverified. */
122
+ badge?: React.ReactNode
123
+ labels?: { name: string; color?: string }[]
124
+ checks?: { met: number; total: number; label?: string }
125
+ /** Already formatted ("12 Nov"). */
126
+ due?: string
127
+ assignee?: { name: string; kind?: ActorKind; src?: string; pattern?: string; hue?: number }
128
+ /** Being dragged: on the plane, tilted. */
129
+ lifted?: boolean
130
+ /** Opens the task. */
131
+ onOpen?: () => void
132
+ }
133
+
134
+ function BoardCard({
135
+ title,
136
+ badge,
137
+ labels = [],
138
+ checks,
139
+ due,
140
+ assignee,
141
+ lifted = false,
142
+ onOpen,
143
+ className,
144
+ ...props
145
+ }: BoardCardProps) {
146
+ return (
147
+ <article
148
+ role="listitem"
149
+ data-slot="board-card"
150
+ data-lifted={lifted ? "" : undefined}
151
+ className={cn(
152
+ "grid gap-2 rounded-control border border-border bg-card px-3 py-2.5 text-sm",
153
+ "transition-[box-shadow,transform] duration-150 ease-out-whity",
154
+ lifted && "rotate-2 border-primary shadow-[var(--plane-primary-rest),var(--shadow-float)]",
155
+ onOpen && "cursor-pointer hover:shadow-plane",
156
+ className
157
+ )}
158
+ {...props}
159
+ >
160
+ {badge && <div className="justify-self-start">{badge}</div>}
161
+ {onOpen ? (
162
+ <button
163
+ type="button"
164
+ onClick={onOpen}
165
+ className="m-0 border-0 bg-transparent p-0 text-start text-[0.9375rem] leading-snug font-medium text-foreground outline-none focus-visible:underline"
166
+ >
167
+ {title}
168
+ </button>
169
+ ) : (
170
+ <b className="text-[0.9375rem] leading-snug font-medium">{title}</b>
171
+ )}
172
+ {(labels.length > 0 || checks) && (
173
+ <div className="flex flex-wrap items-center gap-1.5">
174
+ {labels.map((label) => (
175
+ <LabelChip key={label.name} name={label.name} color={label.color} />
176
+ ))}
177
+ {checks && <CheckProgress met={checks.met} total={checks.total} label={checks.label} />}
178
+ </div>
179
+ )}
180
+ {(due || assignee) && (
181
+ <footer className="flex items-center gap-2 text-xs text-muted-foreground">
182
+ {due && (
183
+ <>
184
+ <Icon name="calendar" size={12} />
185
+ <span dir="ltr">{due}</span>
186
+ </>
187
+ )}
188
+ {assignee && (
189
+ <Avatar
190
+ className="ms-auto"
191
+ name={assignee.name}
192
+ kind={assignee.kind}
193
+ src={assignee.src}
194
+ pattern={assignee.pattern}
195
+ hue={assignee.hue}
196
+ size={24}
197
+ />
198
+ )}
199
+ </footer>
200
+ )}
201
+ </article>
202
+ )
203
+ }
204
+
205
+ /** Where a dragged card will land: a dashed, empty slot. */
206
+ function BoardSlot({ className }: { className?: string }) {
207
+ return (
208
+ <div
209
+ data-slot="board-slot"
210
+ aria-hidden="true"
211
+ className={cn("min-h-16 rounded-control border-[1.5px] border-dashed border-input", className)}
212
+ />
213
+ )
214
+ }
215
+
216
+ export { Board, BoardCard, BoardColumn, BoardSlot, CheckProgress, LabelChip }
@@ -0,0 +1,51 @@
1
+ import type { Meta, StoryObj } from "@storybook/react-vite"
2
+ import { IconBuilding, IconFolder, IconUsers } from "@tabler/icons-react"
3
+
4
+ import { Breadcrumb } from "./breadcrumb"
5
+
6
+ const meta = {
7
+ title: "Primitives/Breadcrumb",
8
+ component: Breadcrumb,
9
+ tags: ["autodocs"],
10
+ } satisfies Meta<typeof Breadcrumb>
11
+
12
+ export default meta
13
+ type Story = StoryObj<typeof meta>
14
+
15
+ export const Default: Story = {
16
+ args: {
17
+ items: [
18
+ { label: "Admin", href: "/admin" },
19
+ { label: "Users", href: "/admin/users" },
20
+ { label: "Jane Doe" },
21
+ ],
22
+ },
23
+ }
24
+
25
+ export const WithHomeIcon: Story = {
26
+ args: {
27
+ showHomeIcon: true,
28
+ items: [
29
+ { label: "Home", href: "/" },
30
+ { label: "Settings", href: "/settings" },
31
+ { label: "Team Members" },
32
+ ],
33
+ },
34
+ }
35
+
36
+ export const WithCustomIcons: Story = {
37
+ args: {
38
+ items: [
39
+ { label: "Organization", href: "#", icon: <IconBuilding /> },
40
+ { label: "Projects", href: "#", icon: <IconFolder /> },
41
+ { label: "Engineering Team", icon: <IconUsers /> },
42
+ ],
43
+ },
44
+ }
45
+
46
+ export const SingleLevel: Story = {
47
+ args: {
48
+ showHomeIcon: true,
49
+ items: [{ label: "Dashboard" }],
50
+ },
51
+ }
@@ -0,0 +1,90 @@
1
+ import * as React from "react"
2
+ import { IconChevronRight, IconHome } from "@tabler/icons-react"
3
+
4
+ import { cn } from "./utils"
5
+
6
+ /**
7
+ * PRESENTATIONAL breadcrumb — a plain, controlled list of items with rich visual feedback.
8
+ */
9
+ export interface BreadcrumbItem {
10
+ label: string
11
+ /** Omit (or omit on the LAST item) to render plain text instead of a link — the current page is never a link. */
12
+ href?: string
13
+ /** Optional icon displayed before the label (e.g. <IconHome /> for root). */
14
+ icon?: React.ReactNode
15
+ }
16
+
17
+ export interface BreadcrumbProps extends Omit<React.ComponentProps<"nav">, "children"> {
18
+ items: BreadcrumbItem[]
19
+ /** Custom link component (e.g. Next.js <Link>) — defaults to a plain <a>. */
20
+ linkComponent?: React.ElementType
21
+ /** Automatically render a Home icon on the first item. */
22
+ showHomeIcon?: boolean
23
+ /** Custom separator node between items. Defaults to a subtle chevron. */
24
+ separator?: React.ReactNode
25
+ /** Accessible name for the <nav>. Defaults to "Breadcrumb". */
26
+ navLabel?: string
27
+ }
28
+
29
+ function Breadcrumb({
30
+ className,
31
+ items,
32
+ linkComponent,
33
+ showHomeIcon = false,
34
+ separator,
35
+ navLabel = "Breadcrumb",
36
+ ...props
37
+ }: BreadcrumbProps) {
38
+ const Link = linkComponent ?? "a"
39
+
40
+ return (
41
+ <nav data-slot="breadcrumb" aria-label={navLabel} className={className} {...props}>
42
+ <ol className="flex flex-wrap items-center gap-1 text-xs/relaxed text-muted-foreground">
43
+ {items.map((item, index) => {
44
+ const isLast = index === items.length - 1
45
+ const isFirst = index === 0
46
+ const itemIcon = item.icon ?? (isFirst && showHomeIcon ? <IconHome /> : null)
47
+
48
+ return (
49
+ <li key={`${item.label}-${index}`} className="flex items-center gap-1">
50
+ {index > 0 && (
51
+ <span className="flex items-center justify-center px-0.5 text-muted-foreground/40">
52
+ {separator ?? (
53
+ <IconChevronRight
54
+ aria-hidden="true"
55
+ className="size-3 shrink-0 rtl:rotate-180"
56
+ />
57
+ )}
58
+ </span>
59
+ )}
60
+ {isLast || !item.href ? (
61
+ <span
62
+ aria-current={isLast ? "page" : undefined}
63
+ className={cn(
64
+ "inline-flex items-center gap-1.5 rounded-md px-1.5 py-0.5 text-xs transition-colors",
65
+ isLast
66
+ ? "font-semibold text-foreground bg-muted/40 border border-border/40 shadow-2xs"
67
+ : "font-medium text-muted-foreground"
68
+ )}
69
+ >
70
+ {itemIcon && <span className="shrink-0 [&_svg]:size-3.5">{itemIcon}</span>}
71
+ {item.label}
72
+ </span>
73
+ ) : (
74
+ <Link
75
+ href={item.href}
76
+ className="inline-flex items-center gap-1.5 rounded-md px-1.5 py-0.5 text-xs font-medium transition-all hover:bg-muted/70 hover:text-foreground active:scale-95"
77
+ >
78
+ {itemIcon && <span className="shrink-0 text-muted-foreground/80 [&_svg]:size-3.5">{itemIcon}</span>}
79
+ {item.label}
80
+ </Link>
81
+ )}
82
+ </li>
83
+ )
84
+ })}
85
+ </ol>
86
+ </nav>
87
+ )
88
+ }
89
+
90
+ export { Breadcrumb }
@@ -0,0 +1,52 @@
1
+ import * as React from "react"
2
+ import { cn } from "./utils"
3
+
4
+ /**
5
+ * The credit a partner or tenant may show (docs/design/components/BuiltOnWhity):
6
+ * the mono small-cut mark and "Built on Whity", linking to whity.dev.
7
+ *
8
+ * Use it in footers, About screens and the sidebar foot of a white-labelled app,
9
+ * never in a header and never larger than the partner's own logo. The mark takes
10
+ * the text colour, so it follows light and dark. `label` is translated text; the
11
+ * name "Whity" stays in Latin letters.
12
+ */
13
+ function BuiltOnWhity({
14
+ href = "https://whity.dev",
15
+ label = "Built on Whity",
16
+ className,
17
+ }: {
18
+ href?: string
19
+ label?: string
20
+ className?: string
21
+ }) {
22
+ const maskId = React.useId()
23
+ return (
24
+ <a
25
+ data-slot="built-on-whity"
26
+ href={href}
27
+ target="_blank"
28
+ rel="noopener noreferrer"
29
+ className={cn(
30
+ "inline-flex items-center gap-2 rounded-sm font-mono text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",
31
+ className
32
+ )}
33
+ >
34
+ <svg aria-hidden="true" viewBox="0 0 32 32" width="20" height="20" className="shrink-0">
35
+ <defs>
36
+ <mask id={maskId}>
37
+ <rect x="-100" y="-100" width="400" height="400" fill="#fff" />
38
+ <path
39
+ d="M16.0 1.125H24.75A6.125 6.125 0 0 1 30.875 7.25V16.0A6.125 6.125 0 0 1 24.75 22.125H16.0A6.125 6.125 0 0 1 9.875 16.0V7.25A6.125 6.125 0 0 1 16.0 1.125Z"
40
+ fill="#000"
41
+ />
42
+ </mask>
43
+ </defs>
44
+ <rect x="3" y="11" width="17.5" height="17.5" rx="4.5" fill="currentColor" stroke="currentColor" strokeWidth="3.25" mask={`url(#${maskId})`} />
45
+ <rect x="11.5" y="2.75" width="17.75" height="17.75" rx="4.5" fill="none" stroke="currentColor" strokeWidth="3.25" />
46
+ </svg>
47
+ <span>{label}</span>
48
+ </a>
49
+ )
50
+ }
51
+
52
+ export { BuiltOnWhity }
@@ -0,0 +1,87 @@
1
+ import type { Meta, StoryObj } from "@storybook/react-vite"
2
+
3
+ import { Button } from "./button"
4
+
5
+ const meta = {
6
+ title: "Primitives/Button",
7
+ component: Button,
8
+ tags: ["autodocs"],
9
+ argTypes: {
10
+ variant: {
11
+ control: "select",
12
+ options: ["default", "outline", "secondary", "ghost", "destructive", "link"],
13
+ },
14
+ size: {
15
+ control: "select",
16
+ options: ["default", "xs", "sm", "lg", "icon", "icon-xs", "icon-sm", "icon-lg"],
17
+ },
18
+ loading: { control: "boolean" },
19
+ active: { control: "boolean" },
20
+ disabled: { control: "boolean" },
21
+ },
22
+ args: { children: "Button", variant: "default", size: "default" },
23
+ } satisfies Meta<typeof Button>
24
+
25
+ export default meta
26
+ type Story = StoryObj<typeof meta>
27
+
28
+ export const Playground: Story = {}
29
+
30
+ const VARIANTS = ["default", "outline", "secondary", "ghost", "destructive", "link"] as const
31
+
32
+ const SIZES = ["xs", "sm", "default", "lg"] as const
33
+
34
+ export const AllVariants: Story = {
35
+ render: () => (
36
+ <div className="flex flex-wrap items-center gap-3">
37
+ {VARIANTS.map((variant) => (
38
+ <Button key={variant} variant={variant}>
39
+ {variant}
40
+ </Button>
41
+ ))}
42
+ </div>
43
+ ),
44
+ }
45
+
46
+ export const Sizes: Story = {
47
+ render: () => (
48
+ <div className="flex flex-wrap items-center gap-3">
49
+ {SIZES.map((size) => (
50
+ <Button key={size} size={size}>
51
+ {size}
52
+ </Button>
53
+ ))}
54
+ </div>
55
+ ),
56
+ }
57
+
58
+ export const IconSizes: Story = {
59
+ render: () => (
60
+ <div className="flex flex-wrap items-center gap-3">
61
+ <Button size="icon-xs" aria-label="Add" icon="plus" />
62
+ <Button size="icon-sm" aria-label="Add" icon="plus" />
63
+ <Button size="icon" aria-label="Add" icon="plus" />
64
+ <Button size="icon-lg" aria-label="Add" icon="plus" />
65
+ </div>
66
+ ),
67
+ }
68
+
69
+ export const WithIcons: Story = {
70
+ render: () => (
71
+ <div className="flex flex-wrap items-center gap-3">
72
+ <Button icon="plus">New invoice</Button>
73
+ <Button variant="outline" iconEnd="arrow-right">Continue</Button>
74
+ </div>
75
+ ),
76
+ }
77
+
78
+ export const States: Story = {
79
+ render: () => (
80
+ <div className="flex flex-wrap items-center gap-3">
81
+ <Button loading>Loading</Button>
82
+ <Button active>Active Toggle</Button>
83
+ <Button disabled>Disabled</Button>
84
+ <Button aria-invalid>Invalid</Button>
85
+ </div>
86
+ ),
87
+ }