@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,47 @@
1
+ import { cn } from "./utils"
2
+
3
+ /**
4
+ * A row of headline numbers (docs/design/components/TplReports, TplImport;
5
+ * `.wk-kpis`, `.wk-kpi` in bundle.css), for Reports, Import and Bank. Values
6
+ * are mono and stay left to right; money comes already formatted in normal
7
+ * units with the currency's decimals ("$31,880.00").
8
+ */
9
+
10
+ export interface KpiItem {
11
+ label: string
12
+ value: string
13
+ /** The comparison or what the number means ("+12% on September", "At cost"). */
14
+ note?: string
15
+ /** Colours the note: good green, bad red. Never the only signal: the note says it. */
16
+ tone?: "good" | "bad"
17
+ }
18
+
19
+ function KpiStrip({ items, className }: { items: KpiItem[]; className?: string }) {
20
+ return (
21
+ <dl
22
+ data-slot="kpi-strip"
23
+ className={cn("m-0 grid grid-cols-[repeat(auto-fit,minmax(180px,1fr))] gap-3", className)}
24
+ >
25
+ {items.map((item) => (
26
+ <div key={item.label} className="grid gap-1 rounded-card border border-border bg-card px-4 py-3.5">
27
+ <dt className="text-xs text-muted-foreground">{item.label}</dt>
28
+ <dd className="m-0 font-mono text-[1.375rem] font-medium tabular-nums" dir="ltr">
29
+ {item.value}
30
+ </dd>
31
+ {item.note && (
32
+ <dd
33
+ className={cn(
34
+ "m-0 text-xs",
35
+ item.tone === "good" ? "text-success-text" : item.tone === "bad" ? "text-destructive" : "text-muted-foreground"
36
+ )}
37
+ >
38
+ {item.note}
39
+ </dd>
40
+ )}
41
+ </div>
42
+ ))}
43
+ </dl>
44
+ )
45
+ }
46
+
47
+ export { KpiStrip }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Text people write in more than one language: one object of language code to
3
+ * text, such as `{ ar: "مجلس المعايير", en: "Standards Board" }` (WHIT-1038).
4
+ *
5
+ * The TypeScript twin of `Whity\Core\i18n\LocalizedText`. The server sends the
6
+ * whole object; the page picks for its reader with {@link localizedText}, by
7
+ * the same rule the server uses when it can show only one string:
8
+ *
9
+ * 1. the reader's language;
10
+ * 2. the text's original language, when it has one (a workspace or unit name:
11
+ * for many institutions the Arabic name is the legal one, so English is
12
+ * never assumed to be the original);
13
+ * 3. English, then Arabic;
14
+ * 4. any language that has text;
15
+ * 5. `fallback`, or "".
16
+ */
17
+
18
+ /** A language => text map, as the API sends it. Missing or blank languages are allowed. */
19
+ export type LocalizedText = Record<string, string | undefined>
20
+
21
+ /** What the readers below accept: a map whose languages may also be null. */
22
+ type LocalizedTextInput = Readonly<Record<string, string | null | undefined>>
23
+
24
+ /** Arabic and English: the two languages a bilingual field offers. */
25
+ export const BILINGUAL = ["ar", "en"] as const
26
+ export type BilingualLanguage = (typeof BILINGUAL)[number]
27
+
28
+ /**
29
+ * One string for a reader of `language`, by the rule above. A plain string is
30
+ * returned trimmed; `[]` (how PHP encodes an empty map) and null read as empty.
31
+ */
32
+ export function localizedText(
33
+ text: LocalizedTextInput | string | readonly unknown[] | null | undefined,
34
+ language?: string | null,
35
+ originalLanguage?: string | null,
36
+ fallback = ""
37
+ ): string {
38
+ if (typeof text === "string") return text.trim() !== "" ? text.trim() : fallback
39
+ if (text === null || text === undefined || Array.isArray(text)) return fallback
40
+
41
+ const map = text as LocalizedTextInput
42
+ for (const code of [language, originalLanguage, "en", "ar"]) {
43
+ if (!code) continue
44
+ const value = map[code]
45
+ if (typeof value === "string" && value.trim() !== "") return value.trim()
46
+ }
47
+ for (const value of Object.values(map)) {
48
+ if (typeof value === "string" && value.trim() !== "") return value.trim()
49
+ }
50
+ return fallback
51
+ }
52
+
53
+ /** Trimmed, with blank languages left out: what the API stores. */
54
+ export function cleanLocalizedText(text: LocalizedTextInput): Record<string, string> {
55
+ const out: Record<string, string> = {}
56
+ for (const [code, value] of Object.entries(text)) {
57
+ if (typeof value === "string" && value.trim() !== "") out[code] = value.trim()
58
+ }
59
+ return out
60
+ }
61
+
62
+ /** Whether two maps say the same thing once blanks are ignored. */
63
+ export function sameLocalizedText(a: LocalizedTextInput, b: LocalizedTextInput): boolean {
64
+ const left = cleanLocalizedText(a)
65
+ const right = cleanLocalizedText(b)
66
+ const keys = new Set([...Object.keys(left), ...Object.keys(right)])
67
+ for (const key of keys) {
68
+ if (left[key] !== right[key]) return false
69
+ }
70
+ return true
71
+ }
72
+
73
+ /** The language of a text typed without one: Arabic letters mean Arabic. */
74
+ export function guessLanguage(text: string): BilingualLanguage {
75
+ return /[؀-ۿݐ-ݿࢠ-ࣿ]/.test(text) ? "ar" : "en"
76
+ }
@@ -0,0 +1,29 @@
1
+ import type { Meta, StoryObj } from "@storybook/react-vite"
2
+
3
+ import { Button } from "./button"
4
+ import { LockedScreen } from "./locked-screen"
5
+
6
+ const meta = {
7
+ title: "Primitives/LockedScreen",
8
+ component: LockedScreen,
9
+ tags: ["autodocs"],
10
+ parameters: { layout: "padded" },
11
+ } satisfies Meta<typeof LockedScreen>
12
+
13
+ export default meta
14
+ type Story = StoryObj<typeof meta>
15
+
16
+ export const Default: Story = {
17
+ args: {
18
+ description:
19
+ "Your offline session has expired. Reconnect and sign in again to keep working.",
20
+ },
21
+ }
22
+
23
+ export const WithReloginAction: Story = {
24
+ args: {
25
+ description:
26
+ "Your offline session has expired. Reconnect and sign in again to keep working.",
27
+ action: <Button>Sign in again</Button>,
28
+ },
29
+ }
@@ -0,0 +1,75 @@
1
+ import * as React from "react"
2
+ import { IconLock } from "@tabler/icons-react"
3
+
4
+ import { Lottie } from "./lottie"
5
+ import { cn } from "./utils"
6
+
7
+ /**
8
+ * Full-page LOCKED state — e.g. an offline-first desktop app whose cached-login
9
+ * TTL has elapsed and must re-authenticate online (WC-desktop-sync). A sibling
10
+ * of {@link AccessDenied}: domain-free, presentational, `role="alert"`.
11
+ *
12
+ * Like AccessDenied, `action` has NO default — the caller supplies the re-login
13
+ * button/link. This primitive owns no auth opinion (a desktop app wires its
14
+ * "sign in again" here; another product might do something else).
15
+ */
16
+ export interface LockedScreenProps extends Omit<React.ComponentProps<"div">, "title"> {
17
+ icon?: React.ReactNode
18
+ title?: React.ReactNode
19
+ description: React.ReactNode
20
+ action?: React.ReactNode
21
+ }
22
+
23
+ function LockedScreen({
24
+ className,
25
+ icon,
26
+ title = "Session locked",
27
+ description,
28
+ action,
29
+ ...props
30
+ }: LockedScreenProps) {
31
+ return (
32
+ <div
33
+ data-slot="locked-screen"
34
+ role="alert"
35
+ className={cn(
36
+ "flex min-h-[450px] flex-col items-center justify-center rounded-2xl border border-border bg-card p-8 text-center shadow-sm",
37
+ className
38
+ )}
39
+ {...props}
40
+ >
41
+ {icon ? (
42
+ <div
43
+ data-slot="locked-screen-icon"
44
+ aria-hidden="true"
45
+ className="mb-4 rounded-full bg-muted p-4 text-muted-foreground [&>svg]:size-12"
46
+ >
47
+ {icon}
48
+ </div>
49
+ ) : (
50
+ // The security-lock scene (LT.4); the lock icon shows until it is ready.
51
+ <Lottie
52
+ name="security-lock"
53
+ className="mb-4 h-[120px] w-[160px]"
54
+ fallback={
55
+ <span data-slot="locked-screen-icon" className="rounded-full bg-muted p-4 text-muted-foreground [&>svg]:size-12">
56
+ <IconLock />
57
+ </span>
58
+ }
59
+ />
60
+ )}
61
+ <h2 data-slot="locked-screen-title" className="mb-2 text-xl font-semibold text-foreground">
62
+ {title}
63
+ </h2>
64
+ <div
65
+ data-slot="locked-screen-description"
66
+ className="mb-6 max-w-md text-sm text-muted-foreground"
67
+ >
68
+ {description}
69
+ </div>
70
+ {action}
71
+ </div>
72
+ )
73
+ }
74
+
75
+ export { LockedScreen }
package/src/lockup.tsx ADDED
@@ -0,0 +1,42 @@
1
+ import { Mark } from "./mark"
2
+ import { cn } from "./utils"
3
+
4
+ /**
5
+ * The horizontal lockup (docs/design/01-logo.md): the mark, then "Whity" in
6
+ * Readex Pro 600, always in Latin letters and always left to right, also in
7
+ * Arabic. The word's cap height is about the plane's side and it starts a
8
+ * short gap after the sheet. `size` is the mark's height in pixels; use 20 or
9
+ * more. Whity's own surfaces only: a white-labelled tenant shows `TenantLogo`.
10
+ */
11
+ function Lockup({
12
+ size = 32,
13
+ label = "Whity",
14
+ className,
15
+ }: {
16
+ size?: number
17
+ /** The accessible name of the whole lockup. */
18
+ label?: string
19
+ className?: string
20
+ }) {
21
+ return (
22
+ <span
23
+ data-slot="lockup"
24
+ role="img"
25
+ aria-label={label}
26
+ dir="ltr"
27
+ className={cn("inline-flex shrink-0 items-center text-foreground", className)}
28
+ style={{ gap: Math.round(size * 0.16) }}
29
+ >
30
+ <Mark size={size} label="" />
31
+ <span
32
+ aria-hidden="true"
33
+ className="font-display leading-none font-semibold"
34
+ style={{ fontSize: Math.round(size * 0.94), letterSpacing: "-0.01em" }}
35
+ >
36
+ Whity
37
+ </span>
38
+ </span>
39
+ )
40
+ }
41
+
42
+ export { Lockup }