@moonwitness/ui 7.3.0 → 8.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 (261) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/pixelfx-boundary.js +1 -1
  3. package/package.json +2 -3
  4. package/scripts/consumer-smoke.mjs +0 -45
  5. package/scripts/generate-icons.mjs +0 -110
  6. package/scripts/generate-token-artifacts.mjs +0 -90
  7. package/scripts/icon-svg-to-jsx.mjs +0 -249
  8. package/scripts/verification-diagnostics.mjs +0 -40
  9. package/scripts/verify-package.mjs +0 -412
  10. package/src/cartoon/anime-avatar.tsx +0 -628
  11. package/src/cartoon/anime-stage.tsx +0 -458
  12. package/src/cartoon/index.tsx +0 -542
  13. package/src/cartoon.tsx +0 -645
  14. package/src/characters.ts +0 -625
  15. package/src/components/accordion.tsx +0 -77
  16. package/src/components/alert.tsx +0 -139
  17. package/src/components/appearance-menu.tsx +0 -181
  18. package/src/components/artwork-frame.tsx +0 -49
  19. package/src/components/audio.tsx +0 -97
  20. package/src/components/avatar.tsx +0 -75
  21. package/src/components/badge.tsx +0 -94
  22. package/src/components/brand-mark.tsx +0 -73
  23. package/src/components/breadcrumbs.tsx +0 -98
  24. package/src/components/button.tsx +0 -340
  25. package/src/components/card.tsx +0 -171
  26. package/src/components/character-badge.tsx +0 -58
  27. package/src/components/character-preview.tsx +0 -104
  28. package/src/components/character-stage.tsx +0 -225
  29. package/src/components/chart.tsx +0 -481
  30. package/src/components/checkbox.tsx +0 -64
  31. package/src/components/comic-panel.tsx +0 -301
  32. package/src/components/comic-theater.tsx +0 -170
  33. package/src/components/command.tsx +0 -189
  34. package/src/components/confirm-dialog.tsx +0 -129
  35. package/src/components/copy-button.tsx +0 -62
  36. package/src/components/date-picker.tsx +0 -126
  37. package/src/components/dialog.tsx +0 -164
  38. package/src/components/dna-icon.tsx +0 -77
  39. package/src/components/dropdown-menu.tsx +0 -87
  40. package/src/components/effects.tsx +0 -1021
  41. package/src/components/empty-state.tsx +0 -93
  42. package/src/components/epistemic-branch-panel.tsx +0 -101
  43. package/src/components/error-state.tsx +0 -137
  44. package/src/components/field.tsx +0 -96
  45. package/src/components/filter-facet-bar.tsx +0 -91
  46. package/src/components/inbox-popover.tsx +0 -146
  47. package/src/components/input.tsx +0 -25
  48. package/src/components/kanban-board.tsx +0 -190
  49. package/src/components/label.tsx +0 -19
  50. package/src/components/layered-scene.tsx +0 -555
  51. package/src/components/log-console.tsx +0 -261
  52. package/src/components/metric-tile.tsx +0 -99
  53. package/src/components/mode-picker.tsx +0 -149
  54. package/src/components/motion-timeline.tsx +0 -848
  55. package/src/components/number-input.tsx +0 -104
  56. package/src/components/page-header.tsx +0 -123
  57. package/src/components/pagination.tsx +0 -83
  58. package/src/components/panel.tsx +0 -121
  59. package/src/components/paper-note.tsx +0 -77
  60. package/src/components/popover.tsx +0 -72
  61. package/src/components/progress.tsx +0 -127
  62. package/src/components/quest-card.tsx +0 -319
  63. package/src/components/radio-group.tsx +0 -50
  64. package/src/components/riot-sticker.tsx +0 -151
  65. package/src/components/scene-particles.tsx +0 -196
  66. package/src/components/scene-transitions.tsx +0 -130
  67. package/src/components/section-ribbon.tsx +0 -94
  68. package/src/components/select-field.tsx +0 -27
  69. package/src/components/select.tsx +0 -81
  70. package/src/components/separator.tsx +0 -58
  71. package/src/components/sheet.tsx +0 -96
  72. package/src/components/skeleton.tsx +0 -35
  73. package/src/components/sketch-annotation.tsx +0 -87
  74. package/src/components/smart-button-box.tsx +0 -114
  75. package/src/components/speech-bubble.tsx +0 -116
  76. package/src/components/spinner.tsx +0 -69
  77. package/src/components/sprite-player.tsx +0 -412
  78. package/src/components/status-bar.tsx +0 -63
  79. package/src/components/status-pill.tsx +0 -68
  80. package/src/components/switch.tsx +0 -76
  81. package/src/components/table.tsx +0 -163
  82. package/src/components/tabs.tsx +0 -101
  83. package/src/components/tag-input.tsx +0 -170
  84. package/src/components/textarea.tsx +0 -25
  85. package/src/components/toast.tsx +0 -14
  86. package/src/components/toolbar.tsx +0 -39
  87. package/src/components/tooltip.tsx +0 -49
  88. package/src/components/update-banner.tsx +0 -220
  89. package/src/components/xv-primitives.tsx +0 -256
  90. package/src/css-exports.ts +0 -142
  91. package/src/dna.tsx +0 -137
  92. package/src/game/boss-hud.tsx +0 -384
  93. package/src/game/index.tsx +0 -886
  94. package/src/game/tactical.tsx +0 -245
  95. package/src/game.tsx +0 -770
  96. package/src/icons/activity.tsx +0 -38
  97. package/src/icons/add.tsx +0 -38
  98. package/src/icons/addon.tsx +0 -37
  99. package/src/icons/anime-anger.tsx +0 -37
  100. package/src/icons/anime-shock.tsx +0 -37
  101. package/src/icons/anime-sparkle.tsx +0 -38
  102. package/src/icons/anime-sweatdrop.tsx +0 -38
  103. package/src/icons/archive.tsx +0 -37
  104. package/src/icons/arrow-left.tsx +0 -37
  105. package/src/icons/arrow-right.tsx +0 -37
  106. package/src/icons/attachment.tsx +0 -38
  107. package/src/icons/bank.tsx +0 -37
  108. package/src/icons/bolt.tsx +0 -37
  109. package/src/icons/book-open.tsx +0 -37
  110. package/src/icons/bookmark.tsx +0 -37
  111. package/src/icons/boss-skull.tsx +0 -40
  112. package/src/icons/calendar-clock.tsx +0 -40
  113. package/src/icons/calendar.tsx +0 -38
  114. package/src/icons/check-circle.tsx +0 -38
  115. package/src/icons/check-square.tsx +0 -38
  116. package/src/icons/check.tsx +0 -37
  117. package/src/icons/chevron-right.tsx +0 -37
  118. package/src/icons/chevrons-left.tsx +0 -37
  119. package/src/icons/chevrons-right.tsx +0 -37
  120. package/src/icons/clapperboard.tsx +0 -38
  121. package/src/icons/clock.tsx +0 -38
  122. package/src/icons/close.tsx +0 -37
  123. package/src/icons/code.tsx +0 -37
  124. package/src/icons/columns.tsx +0 -38
  125. package/src/icons/combo-flame.tsx +0 -38
  126. package/src/icons/company.tsx +0 -38
  127. package/src/icons/credit-card.tsx +0 -38
  128. package/src/icons/critical-star.tsx +0 -37
  129. package/src/icons/currency.tsx +0 -38
  130. package/src/icons/delete.tsx +0 -37
  131. package/src/icons/document.tsx +0 -38
  132. package/src/icons/download.tsx +0 -37
  133. package/src/icons/dpad.tsx +0 -38
  134. package/src/icons/edit.tsx +0 -38
  135. package/src/icons/element-fire.tsx +0 -37
  136. package/src/icons/element-ice.tsx +0 -38
  137. package/src/icons/element-solar.tsx +0 -38
  138. package/src/icons/element-void.tsx +0 -38
  139. package/src/icons/element-volt.tsx +0 -38
  140. package/src/icons/element-wind.tsx +0 -37
  141. package/src/icons/error.tsx +0 -38
  142. package/src/icons/external-link.tsx +0 -38
  143. package/src/icons/field.tsx +0 -38
  144. package/src/icons/file-spreadsheet.tsx +0 -38
  145. package/src/icons/filter.tsx +0 -37
  146. package/src/icons/gacha-ticket.tsx +0 -38
  147. package/src/icons/gamepad.tsx +0 -40
  148. package/src/icons/globe.tsx +0 -38
  149. package/src/icons/grid.tsx +0 -40
  150. package/src/icons/hash.tsx +0 -37
  151. package/src/icons/heart-hp.tsx +0 -38
  152. package/src/icons/history.tsx +0 -37
  153. package/src/icons/home.tsx +0 -37
  154. package/src/icons/image.tsx +0 -39
  155. package/src/icons/impact-slash.tsx +0 -38
  156. package/src/icons/inbox.tsx +0 -38
  157. package/src/icons/index.ts +0 -120
  158. package/src/icons/info.tsx +0 -38
  159. package/src/icons/jobs.tsx +0 -38
  160. package/src/icons/katana.tsx +0 -38
  161. package/src/icons/key.tsx +0 -38
  162. package/src/icons/keyboard.tsx +0 -38
  163. package/src/icons/keyframe-diamond.tsx +0 -38
  164. package/src/icons/knowledge.tsx +0 -38
  165. package/src/icons/language.tsx +0 -39
  166. package/src/icons/lock.tsx +0 -38
  167. package/src/icons/logout.tsx +0 -37
  168. package/src/icons/loot-chest.tsx +0 -39
  169. package/src/icons/mail.tsx +0 -38
  170. package/src/icons/mana-crystal.tsx +0 -38
  171. package/src/icons/map-pin.tsx +0 -38
  172. package/src/icons/mecha-helm.tsx +0 -38
  173. package/src/icons/menu.tsx +0 -37
  174. package/src/icons/message.tsx +0 -38
  175. package/src/icons/model.tsx +0 -38
  176. package/src/icons/moon.tsx +0 -37
  177. package/src/icons/notification.tsx +0 -38
  178. package/src/icons/partner.tsx +0 -41
  179. package/src/icons/pause.tsx +0 -37
  180. package/src/icons/phone.tsx +0 -37
  181. package/src/icons/play.tsx +0 -37
  182. package/src/icons/potion-flask.tsx +0 -40
  183. package/src/icons/quest-scroll.tsx +0 -39
  184. package/src/icons/radar-ping.tsx +0 -40
  185. package/src/icons/refresh.tsx +0 -38
  186. package/src/icons/relation.tsx +0 -40
  187. package/src/icons/save.tsx +0 -38
  188. package/src/icons/search.tsx +0 -38
  189. package/src/icons/security.tsx +0 -38
  190. package/src/icons/send.tsx +0 -38
  191. package/src/icons/settings.tsx +0 -39
  192. package/src/icons/shield-crest.tsx +0 -38
  193. package/src/icons/shuriken.tsx +0 -38
  194. package/src/icons/signal-off.tsx +0 -37
  195. package/src/icons/signal.tsx +0 -37
  196. package/src/icons/skill-node.tsx +0 -40
  197. package/src/icons/smartphone.tsx +0 -38
  198. package/src/icons/sort-ascending.tsx +0 -37
  199. package/src/icons/sort-descending.tsx +0 -37
  200. package/src/icons/sort.tsx +0 -37
  201. package/src/icons/sparkle.tsx +0 -38
  202. package/src/icons/speech-burst.tsx +0 -37
  203. package/src/icons/story.tsx +0 -37
  204. package/src/icons/sun.tsx +0 -38
  205. package/src/icons/tag.tsx +0 -38
  206. package/src/icons/team.tsx +0 -40
  207. package/src/icons/trophy-crown.tsx +0 -39
  208. package/src/icons/upload.tsx +0 -37
  209. package/src/icons/user.tsx +0 -38
  210. package/src/icons/users.tsx +0 -39
  211. package/src/icons/visibility-off.tsx +0 -38
  212. package/src/icons/visibility.tsx +0 -38
  213. package/src/icons/volume-off.tsx +0 -37
  214. package/src/icons/volume.tsx +0 -37
  215. package/src/icons/warning.tsx +0 -38
  216. package/src/icons/workflow.tsx +0 -40
  217. package/src/icons.tsx +0 -965
  218. package/src/index.ts +0 -89
  219. package/src/lib/asset-registry.ts +0 -534
  220. package/src/lib/audio-runtime.ts +0 -314
  221. package/src/lib/character-adapter.ts +0 -370
  222. package/src/lib/character-registry.ts +0 -2368
  223. package/src/lib/cn.ts +0 -6
  224. package/src/lib/compose-refs.ts +0 -16
  225. package/src/lib/sanitize-url.ts +0 -51
  226. package/src/lib/scene-camera.ts +0 -483
  227. package/src/lib/scene-playback.ts +0 -622
  228. package/src/lib/scene-soundscape.ts +0 -151
  229. package/src/lib/scene-test-harness.ts +0 -200
  230. package/src/lib/scene-timeline.ts +0 -398
  231. package/src/lib/use-animation-visibility.ts +0 -45
  232. package/src/lib/use-modal-focus.ts +0 -270
  233. package/src/lib/use-reduced-motion.ts +0 -37
  234. package/src/motion/easing-presets.ts +0 -262
  235. package/src/motion/index.tsx +0 -894
  236. package/src/motion/physics.ts +0 -259
  237. package/src/motion/timeline-math.ts +0 -358
  238. package/src/motion.tsx +0 -639
  239. package/src/pixelfx-boundary.ts +0 -188
  240. package/src/pixelfx-registry.ts +0 -1190
  241. package/src/pixelfx-types.d.ts +0 -73
  242. package/src/pixelfx.tsx +0 -1022
  243. package/src/provider.tsx +0 -63
  244. package/src/skin-catalog.ts +0 -306
  245. package/src/skin-tokens.ts +0 -425
  246. package/src/ssr/init-script.ts +0 -281
  247. package/src/ssr/resolve-skin.ts +0 -217
  248. package/src/ssr/theme-mismatch-dev.ts +0 -181
  249. package/src/templates/battle-arena.tsx +0 -688
  250. package/src/templates/index.tsx +0 -314
  251. package/src/templates.tsx +0 -225
  252. package/src/themes/dna-presets.ts +0 -119
  253. package/src/themes/index.ts +0 -56
  254. package/src/themes/provider.tsx +0 -183
  255. package/src/themes/types.ts +0 -111
  256. package/src/themes.ts +0 -9
  257. package/src/token-exporter.ts +0 -12
  258. package/src/token-exporters.ts +0 -343
  259. package/src/token-seeds.ts +0 -335
  260. package/src/token-snapshot.ts +0 -179
  261. package/src/utils.ts +0 -58
@@ -1,104 +0,0 @@
1
- 'use client';
2
- import { useId } from "react";
3
- import { Label } from "./label.js";
4
- import { Input } from "./input.js";
5
- import { useComponentPixelFx } from "../pixelfx.js";
6
- import type { PixelFxProp } from "../pixelfx-registry.js";
7
- import { cn } from "../utils.js";
8
-
9
- export type NumberInputProps = {
10
- id?: string;
11
- name?: string;
12
- label: string;
13
- value: number | null;
14
- onValueChange: (next: number | null) => void;
15
- min?: number;
16
- max?: number;
17
- step?: number | "any";
18
- integer?: boolean;
19
- currency?: string;
20
- disabled?: boolean;
21
- required?: boolean;
22
- invalid?: boolean;
23
- description?: string;
24
- fx?: PixelFxProp;
25
- className?: string;
26
- };
27
-
28
- /**
29
- * Parse a string input to a number, applying min/max bounds and integer constraint.
30
- * Returns null if the input is empty or invalid.
31
- */
32
- export function parseNumber(
33
- raw: string,
34
- options?: { min?: number; max?: number; integer?: boolean }
35
- ): number | null {
36
- const trimmed = raw.trim();
37
- if (!trimmed) return null;
38
- // Replace comma decimal separator with dot for European format
39
- const normalized = trimmed.replace(/,/g, '.');
40
- // Reject leading zeros followed by non-zero digit
41
- if (/^0[1-9]/.test(normalized)) return null;
42
- let parsed = Number(normalized);
43
- if (Number.isNaN(parsed)) return null;
44
- const isInteger = typeof options === 'boolean' ? options : options?.integer;
45
- if (isInteger) {
46
- // Reject decimal values when integer mode
47
- if (normalized.includes('.')) return null;
48
- parsed = Math.trunc(parsed);
49
- }
50
- if (typeof options?.min === "number") parsed = Math.max(options.min, parsed);
51
- if (typeof options?.max === "number") parsed = Math.min(options.max, parsed);
52
- return parsed;
53
- }
54
-
55
- export function NumberInput({
56
- label,
57
- value,
58
- onValueChange,
59
- min,
60
- max,
61
- step,
62
- integer = false,
63
- description,
64
- fx = "auto",
65
- className = "",
66
- id: providedId,
67
- currency,
68
- disabled,
69
- }: NumberInputProps) {
70
- const id = providedId ?? useId();
71
- const pfx = useComponentPixelFx({ kind: "number-input", fx });
72
-
73
- return (
74
- <div
75
- className={cn("mw-ui-number-input", className)}
76
- {...pfx.dataAttributes}
77
- {...pfx.handlers}
78
- style={{ position: "relative", display: "grid", gap: "0.4rem" }}
79
- >
80
- {pfx.layer}
81
- <Label htmlFor={id}>{label}</Label>
82
- <Input
83
- id={id}
84
- type="number"
85
- min={min}
86
- max={max}
87
- step={step ?? (integer ? 1 : "any")}
88
- value={value === null ? "" : value === undefined ? undefined : String(value)}
89
- data-currency={currency}
90
- disabled={disabled}
91
- onChange={(event) => {
92
- const raw = event.currentTarget.value.trim();
93
- const parsed = parseNumber(raw, { min, max, integer });
94
- onValueChange(parsed);
95
- }}
96
- />
97
- {description ? (
98
- <small style={{ color: "var(--mw-muted-foreground)", fontSize: "0.78rem" }}>
99
- {description}
100
- </small>
101
- ) : null}
102
- </div>
103
- );
104
- }
@@ -1,123 +0,0 @@
1
- import type { HTMLAttributes, ReactNode } from "react";
2
- import { useComponentPixelFx } from "../pixelfx.js";
3
- import type { PixelFxProp } from "../pixelfx-registry.js";
4
- import { cn } from "../utils.js";
5
-
6
- export type PageHeaderTreatment = "display" | "brush";
7
-
8
- export type PageHeaderProps = Omit<HTMLAttributes<HTMLElement>, "title"> & {
9
- title: ReactNode;
10
- accentTitle?: ReactNode;
11
- accent?: "magenta" | "cyan" | "yellow" | "violet";
12
- description?: ReactNode;
13
- breadcrumbs?: ReactNode;
14
- actions?: ReactNode;
15
- treatment?: PageHeaderTreatment;
16
- scale?: "default" | "hero";
17
- headingLevel?: 1 | 2 | 3 | 4;
18
- fx?: PixelFxProp;
19
- };
20
-
21
- const accentColorMap = {
22
- magenta: "var(--mw-magenta)",
23
- cyan: "var(--mw-cyan)",
24
- yellow: "var(--mw-yellow)",
25
- violet: "var(--mw-violet)",
26
- };
27
-
28
- export function PageHeader({
29
- title,
30
- accentTitle,
31
- accent = "magenta",
32
- description,
33
- actions,
34
- treatment = "display",
35
- scale = "default",
36
- headingLevel = 1,
37
- fx = "auto",
38
- className = "",
39
- ...rest
40
- }: PageHeaderProps) {
41
- const Heading = `h${headingLevel}` as const;
42
- const pfx = useComponentPixelFx({
43
- kind: "page-header",
44
- variant: accent,
45
- fx,
46
- placement: "background",
47
- });
48
-
49
- return (
50
- <header
51
- className={cn("mw-ui-page-header", className)}
52
- data-scale={scale}
53
- data-treatment={treatment}
54
- {...pfx.dataAttributes}
55
- {...pfx.handlers}
56
- style={{
57
- position: "relative",
58
- overflow: "hidden",
59
- display: "flex",
60
- flexWrap: "wrap",
61
- alignItems: "flex-start",
62
- justifyContent: "space-between",
63
- gap: "0.75rem",
64
- paddingBottom: "0.65rem",
65
- borderBottom: "var(--mw-frame-width, 1.5px) solid var(--mw-border)",
66
- ...rest.style,
67
- }}
68
- data-accent={accent}
69
- {...rest}
70
- >
71
- {pfx.layer}
72
- <div style={{ display: "grid", gap: "0.25rem", minWidth: 0 }}>
73
- <Heading
74
- className={cn("mw-ui-page-header-title", treatment === "brush" && "mw-ui-page-header-title-accent")}
75
- style={{
76
- margin: 0,
77
- fontFamily:
78
- treatment === "brush"
79
- ? "var(--mw-font-brush)"
80
- : "var(--mw-font-display)",
81
- fontSize: headingLevel === 1 ? "2.25rem" : headingLevel === 2 ? "1.65rem" : "1.3rem",
82
- lineHeight: 1.05,
83
- letterSpacing: "0.02em",
84
- textTransform: "uppercase",
85
- }}
86
- >
87
- <span>{title}</span>
88
- {accentTitle ? (
89
- <>
90
- {" "}
91
- <span style={{ color: accentColorMap[accent] }}>
92
- {accentTitle}
93
- </span>
94
- </>
95
- ) : null}
96
- </Heading>
97
- {description ? (
98
- <p
99
- style={{
100
- margin: 0,
101
- fontSize: "0.86rem",
102
- color: "var(--mw-muted-foreground)",
103
- }}
104
- >
105
- {description}
106
- </p>
107
- ) : null}
108
- </div>
109
- {actions ? (
110
- <div
111
- style={{
112
- display: "flex",
113
- flexWrap: "wrap",
114
- alignItems: "center",
115
- gap: "0.5rem",
116
- }}
117
- >
118
- {actions}
119
- </div>
120
- ) : null}
121
- </header>
122
- );
123
- }
@@ -1,83 +0,0 @@
1
- 'use client';
2
- import { Button } from "./button.js";
3
- import { useComponentPixelFx } from "../pixelfx.js";
4
- import type { PixelFxProp } from "../pixelfx-registry.js";
5
- import { cn } from "../utils.js";
6
-
7
- export type PaginationProps = {
8
- page: number;
9
- pageCount: number;
10
- onPageChange: (page: number) => void;
11
- fx?: PixelFxProp;
12
- className?: string;
13
- trailing?: React.ReactNode;
14
- };
15
-
16
- export function Pagination({
17
- page,
18
- pageCount,
19
- onPageChange,
20
- fx = "auto",
21
- className = "",
22
- trailing,
23
- }: PaginationProps) {
24
- const safeCount = Math.max(1, pageCount);
25
- const safePage = Math.min(Math.max(1, page), safeCount);
26
- const pages = Array.from({ length: safeCount }, (_, i) => i + 1);
27
- const pfx = useComponentPixelFx({ kind: "pagination", fx });
28
-
29
- return (
30
- <nav
31
- aria-label="Pagination"
32
- className={cn("mw-ui-pagination", className)}
33
- {...pfx.dataAttributes}
34
- style={{
35
- display: "flex",
36
- alignItems: "center",
37
- gap: "0.35rem",
38
- flexWrap: "wrap",
39
- }}
40
- >
41
- <Button
42
- size="xs"
43
- variant="outline"
44
- className="mw-ui-pagination-btn"
45
- fx={fx}
46
- type="button"
47
- disabled={safePage <= 1}
48
- onClick={() => onPageChange(safePage - 1)}
49
- >
50
- Previous
51
- </Button>
52
- {pages.map((p) => (
53
- <Button
54
- key={p}
55
- size="xs"
56
- variant={p === safePage ? "default" : "outline"}
57
- className="mw-ui-pagination-btn"
58
- fx={fx}
59
- aria-current={p === safePage ? "page" : undefined}
60
- type="button"
61
- onClick={() => onPageChange(p)}
62
- >
63
- {p}
64
- </Button>
65
- ))}
66
- <Button
67
- size="xs"
68
- variant="outline"
69
- className="mw-ui-pagination-btn"
70
- fx={fx}
71
- type="button"
72
- disabled={safePage >= safeCount}
73
- onClick={() => onPageChange(safePage + 1)}
74
- >
75
- Next
76
- </Button>
77
- {trailing ? (
78
- <span className="mw-ui-pagination-trailing">{trailing}</span>
79
- ) : null}
80
- <span className="mw-ui-pagination-info">Page {safePage} of {safeCount}</span>
81
- </nav>
82
- );
83
- }
@@ -1,121 +0,0 @@
1
- 'use client';
2
- import { forwardRef, useState, type HTMLAttributes, type ReactNode } from "react";
3
- import { JaggedBorderSvg, PixelFxComponentLayer } from "../pixelfx.js";
4
- import {
5
- resolveComponentPixelFx,
6
- type EmpirePaletteId,
7
- type PixelFxEffectId,
8
- } from "../pixelfx-registry.js";
9
-
10
- export interface PanelProps extends Omit<HTMLAttributes<HTMLElement>, "title"> {
11
- title?: ReactNode;
12
- description?: string;
13
- surface?: "default" | "paper" | "ink";
14
- frame?: "line" | "torn" | "scuffed" | "grunge";
15
- density?: "micro" | "compact" | "comfortable" | "spacious";
16
- headingLevel?: 2 | 3 | 4 | 5;
17
- actions?: ReactNode;
18
- jagged?: boolean;
19
- jaggedColor?: string;
20
- fxAura?: PixelFxEffectId | "auto" | false;
21
- fxPalette?: EmpirePaletteId;
22
- fxTrigger?: "always" | "hover";
23
- contentClassName?: string;
24
- }
25
-
26
- const PANEL_SURFACE_BORDER_COLOR: Record<"default" | "paper" | "ink", string> = {
27
- default: "var(--mw-cyan)",
28
- paper: "var(--mw-yellow)",
29
- ink: "var(--mw-magenta)",
30
- };
31
-
32
- export const Panel = forwardRef<HTMLElement, PanelProps>(
33
- function Panel(
34
- {
35
- title,
36
- description,
37
- surface = "default",
38
- frame = "line",
39
- density = "comfortable",
40
- headingLevel = 3,
41
- actions,
42
- jagged = true,
43
- jaggedColor,
44
- fxAura = "auto",
45
- fxPalette,
46
- fxTrigger,
47
- contentClassName,
48
- className,
49
- children,
50
- onMouseEnter,
51
- onMouseLeave,
52
- ...props
53
- }: PanelProps,
54
- ref,
55
- ) {
56
- const [hovered, setHovered] = useState(false);
57
- const autoFx = resolveComponentPixelFx(
58
- "panel",
59
- surface === "ink" ? "ink" : frame,
60
- );
61
- const resolvedEffectId =
62
- fxAura === false ? null : fxAura === "auto" ? autoFx.effectId : fxAura;
63
- const effectiveTrigger = fxTrigger ?? (surface === "ink" ? "always" : "hover");
64
- const resolvedBorderColor = jaggedColor ?? PANEL_SURFACE_BORDER_COLOR[surface];
65
- const fxActive = Boolean(
66
- resolvedEffectId && (effectiveTrigger === "always" || hovered),
67
- );
68
- const Heading = `h${headingLevel}` as "h2" | "h3" | "h4" | "h5";
69
-
70
- return (
71
- <section
72
- ref={ref}
73
- className={className ? `mw-ui-panel ${className}` : "mw-ui-panel"}
74
- data-surface={surface}
75
- data-frame={frame}
76
- data-density={density}
77
- data-jagged={jagged ? "true" : undefined}
78
- data-pixelfx={resolvedEffectId ?? undefined}
79
- data-pixelfx-ready={resolvedEffectId ? "true" : undefined}
80
- onMouseEnter={(event) => {
81
- if (resolvedEffectId && effectiveTrigger === "hover") setHovered(true);
82
- onMouseEnter?.(event);
83
- }}
84
- onMouseLeave={(event) => {
85
- if (resolvedEffectId && effectiveTrigger === "hover") setHovered(false);
86
- onMouseLeave?.(event);
87
- }}
88
- {...props}
89
- >
90
- {jagged ? <JaggedBorderSvg color={resolvedBorderColor} /> : null}
91
- {resolvedEffectId ? (
92
- <PixelFxComponentLayer
93
- effectId={resolvedEffectId}
94
- paletteId={fxPalette ?? autoFx.paletteId}
95
- layer={autoFx.layer}
96
- loop
97
- active={fxActive}
98
- speed={autoFx.speed}
99
- seed={autoFx.seed}
100
- lightK={autoFx.lightK}
101
- placement="background"
102
- />
103
- ) : null}
104
- {title || description || actions ? (
105
- <header className="mw-ui-panel-header">
106
- <div>
107
- {title ? <Heading className="mw-ui-panel-title">{title}</Heading> : null}
108
- {description ? (
109
- <p className="mw-ui-panel-description">{description}</p>
110
- ) : null}
111
- </div>
112
- {actions ? <div>{actions}</div> : null}
113
- </header>
114
- ) : null}
115
- <div className={contentClassName ? `mw-ui-panel-content ${contentClassName}` : "mw-ui-panel-content"}>
116
- {children}
117
- </div>
118
- </section>
119
- );
120
- }
121
- );
@@ -1,77 +0,0 @@
1
- 'use client';
2
- import { useState, type HTMLAttributes } from "react";
3
- import { PixelFxComponentLayer } from "../pixelfx.js";
4
- import { resolveComponentPixelFx } from "../pixelfx-registry.js";
5
-
6
- export interface PaperNoteProps extends HTMLAttributes<HTMLDivElement> {
7
- accent?: "yellow" | "magenta" | "cyan" | "paper";
8
- fx?: boolean | "auto";
9
- }
10
-
11
- export function PaperNote({
12
- accent = "yellow",
13
- fx = "auto",
14
- className,
15
- style,
16
- children,
17
- onMouseEnter,
18
- onMouseLeave,
19
- ...props
20
- }: PaperNoteProps) {
21
- const [hovered, setHovered] = useState(false);
22
- const fxEnabled = fx !== false;
23
- const resolvedFx = resolveComponentPixelFx("panel", accent);
24
- const bg =
25
- accent === "magenta"
26
- ? "var(--mw-magenta)"
27
- : accent === "cyan"
28
- ? "var(--mw-cyan)"
29
- : accent === "paper"
30
- ? "var(--mw-paper-raised)"
31
- : "var(--mw-yellow)";
32
- const fg =
33
- accent === "paper"
34
- ? "var(--mw-ink)"
35
- : accent === "magenta"
36
- ? "var(--mw-on-magenta)"
37
- : "var(--mw-on-accent)";
38
-
39
- return (
40
- <div
41
- className={className ? `mw-ui-paper-note ${className}` : "mw-ui-paper-note"}
42
- data-pixelfx={fxEnabled ? resolvedFx.effectId : "none"}
43
- data-pixelfx-ready="true"
44
- onMouseEnter={(e) => {
45
- setHovered(true);
46
- onMouseEnter?.(e);
47
- }}
48
- onMouseLeave={(e) => {
49
- setHovered(false);
50
- onMouseLeave?.(e);
51
- }}
52
- style={{
53
- position: "relative",
54
- overflow: "hidden",
55
- background: bg,
56
- color: fg,
57
- ...style,
58
- }}
59
- {...props}
60
- >
61
- {fxEnabled ? (
62
- <PixelFxComponentLayer
63
- effectId={resolvedFx.effectId}
64
- paletteId={resolvedFx.paletteId}
65
- layer={resolvedFx.layer}
66
- loop
67
- active={hovered}
68
- speed={resolvedFx.speed}
69
- seed={resolvedFx.seed}
70
- lightK={resolvedFx.lightK}
71
- placement="background"
72
- />
73
- ) : null}
74
- <div style={{ position: "relative", zIndex: 2 }}>{children}</div>
75
- </div>
76
- );
77
- }
@@ -1,72 +0,0 @@
1
- 'use client';
2
- import { Popover as RadixPopover } from "radix-ui";
3
- import type { ComponentProps, HTMLAttributes } from "react";
4
- import { useComponentPixelFx } from "../pixelfx.js";
5
- import type { PixelFxProp } from "../pixelfx-registry.js";
6
- import { cn } from "../utils.js";
7
-
8
- export const Popover = RadixPopover.Root;
9
- export const PopoverTrigger = RadixPopover.Trigger;
10
-
11
- export function PopoverContent({
12
- className,
13
- sideOffset = 6,
14
- fx = "auto",
15
- children,
16
- ...props
17
- }: ComponentProps<typeof RadixPopover.Content> & { fx?: PixelFxProp }) {
18
- const pfx = useComponentPixelFx({
19
- kind: "popover",
20
- fx,
21
- placement: "background",
22
- });
23
- return (
24
- <RadixPopover.Portal>
25
- <RadixPopover.Content
26
- sideOffset={sideOffset}
27
- className={cn("mw-ui-popover-content", className)}
28
- {...pfx.dataAttributes}
29
- {...pfx.handlers}
30
- {...props}
31
- >
32
- {pfx.layer}
33
- {children}
34
- </RadixPopover.Content>
35
- </RadixPopover.Portal>
36
- );
37
- }
38
-
39
- export function PopoverHeader({
40
- style,
41
- ...props
42
- }: HTMLAttributes<HTMLDivElement>) {
43
- return (
44
- <div style={{ display: "grid", gap: "0.25rem", padding: "0.35rem", ...style }} {...props} />
45
- );
46
- }
47
-
48
- export function PopoverTitle({
49
- style,
50
- ...props
51
- }: HTMLAttributes<HTMLHeadingElement>) {
52
- return (
53
- <h2 data-slot="popover-title" style={{ margin: 0, fontSize: "0.9rem", fontWeight: 700, ...style }} {...props} />
54
- );
55
- }
56
-
57
- export function PopoverDescription({
58
- style,
59
- ...props
60
- }: HTMLAttributes<HTMLParagraphElement>) {
61
- return (
62
- <p
63
- style={{
64
- margin: 0,
65
- fontSize: "0.8rem",
66
- color: "var(--mw-muted-foreground)",
67
- ...style,
68
- }}
69
- {...props}
70
- />
71
- );
72
- }
@@ -1,127 +0,0 @@
1
- 'use client';
2
- import { forwardRef, useState, type HTMLAttributes } from "react";
3
- import { PixelFxComponentLayer } from "../pixelfx.js";
4
- import {
5
- resolveComponentPixelFx,
6
- type EmpirePaletteId,
7
- type PixelFxEffectId,
8
- } from "../pixelfx-registry.js";
9
-
10
- export type ProgressVariant =
11
- | "default"
12
- | "magenta"
13
- | "cyan"
14
- | "success"
15
- | "warning"
16
- | "destructive";
17
-
18
- export type ProgressSize = "sm" | "md" | "lg";
19
-
20
- export interface ProgressProps extends HTMLAttributes<HTMLDivElement> {
21
- value?: number;
22
- max?: number;
23
- label?: string;
24
- showValue?: boolean;
25
- indeterminate?: boolean;
26
- variant?: ProgressVariant;
27
- size?: ProgressSize;
28
- fx?: PixelFxEffectId | "auto" | false;
29
- fxPalette?: EmpirePaletteId;
30
- fxTrigger?: "hover" | "always";
31
- }
32
-
33
- export const Progress = forwardRef<HTMLDivElement, ProgressProps>(
34
- (
35
- {
36
- value = 0,
37
- max = 100,
38
- label,
39
- showValue = false,
40
- indeterminate = false,
41
- variant = "default",
42
- size = "md",
43
- fx = "auto",
44
- fxPalette,
45
- fxTrigger,
46
- className,
47
- onMouseEnter,
48
- onMouseLeave,
49
- ...props
50
- },
51
- ref,
52
- ) => {
53
- const [hovered, setHovered] = useState(false);
54
- const clamped = Math.max(0, Math.min(max, value));
55
- const pct = max > 0 ? Math.round((clamped / max) * 100) : 0;
56
- const autoFx = resolveComponentPixelFx("progress", variant);
57
- const resolvedEffectId =
58
- fx === false ? null : fx === "auto" ? autoFx.effectId : fx;
59
- const effectiveTrigger = fxTrigger ?? "always";
60
- const fxActive = Boolean(
61
- resolvedEffectId && (effectiveTrigger === "always" || hovered),
62
- );
63
-
64
- return (
65
- <div
66
- ref={ref}
67
- className={className ? `mw-ui-progress ${className}` : "mw-ui-progress"}
68
- data-variant={variant}
69
- data-size={size}
70
- data-pixelfx={resolvedEffectId ?? undefined}
71
- data-pixelfx-ready={resolvedEffectId ? "true" : undefined}
72
- onMouseEnter={(event) => {
73
- if (resolvedEffectId && effectiveTrigger === "hover") setHovered(true);
74
- onMouseEnter?.(event);
75
- }}
76
- onMouseLeave={(event) => {
77
- if (resolvedEffectId && effectiveTrigger === "hover") setHovered(false);
78
- onMouseLeave?.(event);
79
- }}
80
- {...props}
81
- >
82
- {label || showValue ? (
83
- <div className="mw-ui-progress-head">
84
- <span>{label}</span>
85
- {showValue && !indeterminate ? <span>{pct}%</span> : null}
86
- </div>
87
- ) : null}
88
- <div
89
- className="mw-ui-progress-track"
90
- role="progressbar"
91
- aria-label={label ?? "Progress"}
92
- aria-valuemin={0}
93
- aria-valuemax={max}
94
- aria-valuenow={indeterminate ? undefined : clamped}
95
- >
96
- <div
97
- className="mw-ui-progress-fill"
98
- data-indeterminate={indeterminate ? "true" : "false"}
99
- style={
100
- indeterminate
101
- ? { position: "relative", overflow: "hidden" }
102
- : { width: `${pct}%`, position: "relative", overflow: "hidden" }
103
- }
104
- >
105
- {resolvedEffectId ? (
106
- <PixelFxComponentLayer
107
- effectId={resolvedEffectId}
108
- paletteId={fxPalette ?? autoFx.paletteId}
109
- layer={autoFx.layer}
110
- loop
111
- active={fxActive}
112
- speed={autoFx.speed}
113
- seed={autoFx.seed}
114
- lightK={autoFx.lightK}
115
- placement="inline"
116
- width={96}
117
- height={24}
118
- />
119
- ) : null}
120
- </div>
121
- </div>
122
- </div>
123
- );
124
- },
125
- );
126
-
127
- Progress.displayName = "Progress";