@nordmanai/nif 0.1.0 → 0.2.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 (253) hide show
  1. package/README.md +18 -0
  2. package/bin/nif.mjs +196 -0
  3. package/dist/index.d.ts +30 -1
  4. package/dist/index.js +9661 -2499
  5. package/dist/styles.css +1 -1
  6. package/dist/tokens.css +4 -1
  7. package/dist/ui/components/nm-ai/nm-ai.d.ts +7 -7
  8. package/dist/ui/components/nm-brand-logo/nm-brand-logo.d.ts +10 -0
  9. package/dist/ui/components/nm-breadcrumb/nm-breadcrumb.d.ts +11 -0
  10. package/dist/ui/components/nm-button/nm-button.d.ts +2 -0
  11. package/dist/ui/components/nm-button-group/nm-button-group.d.ts +17 -0
  12. package/dist/ui/components/nm-calendar/nm-calendar.d.ts +3 -0
  13. package/dist/ui/components/nm-card/nm-card.d.ts +34 -0
  14. package/dist/ui/components/nm-chip/nm-chip.d.ts +38 -0
  15. package/dist/ui/components/nm-code-block/nm-code-block.d.ts +55 -0
  16. package/dist/ui/components/nm-color-picker/nm-color-picker.d.ts +15 -0
  17. package/dist/ui/components/nm-combobox/nm-combobox.d.ts +26 -0
  18. package/dist/ui/components/nm-command/nm-command.d.ts +37 -0
  19. package/dist/ui/components/nm-composer/nm-composer.d.ts +4 -0
  20. package/dist/ui/components/nm-context-menu/nm-context-menu.d.ts +9 -0
  21. package/dist/ui/components/nm-date-picker/nm-date-picker.d.ts +35 -0
  22. package/dist/ui/components/nm-dialog/nm-dialog.d.ts +13 -0
  23. package/dist/ui/components/nm-field/nm-field.d.ts +2 -0
  24. package/dist/ui/components/nm-form-field/nm-form-field.d.ts +18 -0
  25. package/dist/ui/components/nm-gallery/nm-gallery.d.ts +8 -0
  26. package/dist/ui/components/nm-input/nm-input.d.ts +5 -0
  27. package/dist/ui/components/nm-input-group/nm-input-group.d.ts +9 -0
  28. package/dist/ui/components/nm-label/nm-label.d.ts +2 -0
  29. package/dist/ui/components/nm-menubar/nm-menubar.d.ts +9 -0
  30. package/dist/ui/components/nm-native-select/nm-native-select.d.ts +5 -0
  31. package/dist/ui/components/nm-panel/nm-panel.d.ts +14 -0
  32. package/dist/ui/components/nm-prose/nm-prose.d.ts +6 -0
  33. package/dist/ui/components/nm-resize-handle/nm-resize-handle.d.ts +18 -0
  34. package/dist/ui/components/nm-select/nm-select.d.ts +22 -0
  35. package/dist/ui/components/nm-side-panel/nm-side-panel.d.ts +33 -0
  36. package/dist/ui/components/nm-slider/nm-slider.d.ts +5 -1
  37. package/dist/ui/components/nm-status-bar/nm-status-bar.d.ts +8 -0
  38. package/dist/ui/components/nm-table/nm-table.d.ts +38 -0
  39. package/dist/ui/components/nm-textarea/nm-textarea.d.ts +2 -0
  40. package/dist/ui/components/nm-toolbar/nm-toolbar.d.ts +21 -0
  41. package/dist/ui/config/nm-ai.d.ts +0 -3
  42. package/dist/ui/config/nm-appearance.d.ts +36 -1
  43. package/dist/ui/config/nm-button.d.ts +2 -1
  44. package/dist/ui/config/nm-composer.d.ts +1 -2
  45. package/dist/ui/config/nm-field.d.ts +2 -0
  46. package/dist/ui/config/nm-icons.d.ts +13 -1
  47. package/dist/ui/config/nm-radius.d.ts +4 -4
  48. package/dist/ui/config/nm-side-panel.d.ts +33 -0
  49. package/dist/ui/lib/appearance/appearanceState.d.ts +1 -0
  50. package/dist/ui/lib/appearance/deriveTokens.d.ts +2 -0
  51. package/package.json +12 -4
  52. package/registry/index.json +1634 -0
  53. package/registry/tokens.css +72 -0
  54. package/registry/ui/components/nm-ai/nm-ai.css +358 -0
  55. package/registry/ui/components/nm-ai/nm-ai.tsx +632 -0
  56. package/registry/ui/components/nm-app-panel/nm-app-panel.css +169 -0
  57. package/registry/ui/components/nm-ask/nm-ask.css +277 -0
  58. package/registry/ui/components/nm-avatar/nm-avatar.css +85 -0
  59. package/registry/ui/components/nm-avatar/nm-avatar.tsx +30 -0
  60. package/registry/ui/components/nm-bar-overflow/nm-bar-overflow.css +43 -0
  61. package/registry/ui/components/nm-bar-overflow/nm-bar-overflow.tsx +61 -0
  62. package/registry/ui/components/nm-bar-overflow/use-bar-overflow.ts +92 -0
  63. package/registry/ui/components/nm-brand-logo/nm-brand-logo.css +20 -0
  64. package/registry/ui/components/nm-brand-logo/nm-brand-logo.tsx +21 -0
  65. package/registry/ui/components/nm-breadcrumb/nm-breadcrumb.css +57 -0
  66. package/registry/ui/components/nm-breadcrumb/nm-breadcrumb.tsx +42 -0
  67. package/registry/ui/components/nm-button/nm-button.css +106 -0
  68. package/registry/ui/components/nm-button/nm-button.tsx +58 -0
  69. package/registry/ui/components/nm-button-group/nm-button-group.css +98 -0
  70. package/registry/ui/components/nm-button-group/nm-button-group.tsx +32 -0
  71. package/registry/ui/components/nm-calendar/nm-calendar.css +178 -0
  72. package/registry/ui/components/nm-calendar/nm-calendar.tsx +43 -0
  73. package/registry/ui/components/nm-card/nm-card.css +130 -0
  74. package/registry/ui/components/nm-card/nm-card.tsx +83 -0
  75. package/registry/ui/components/nm-chatbox/nm-chatbox-icon.tsx +39 -0
  76. package/registry/ui/components/nm-chatbox/nm-chatbox.css +682 -0
  77. package/registry/ui/components/nm-chatbox/nm-chatbox.tsx +101 -0
  78. package/registry/ui/components/nm-checkbox/nm-checkbox.css +61 -0
  79. package/registry/ui/components/nm-checkbox/nm-checkbox.tsx +14 -0
  80. package/registry/ui/components/nm-chip/nm-chip.css +112 -0
  81. package/registry/ui/components/nm-chip/nm-chip.tsx +86 -0
  82. package/registry/ui/components/nm-code-block/nm-code-block.css +240 -0
  83. package/registry/ui/components/nm-code-block/nm-code-block.tsx +196 -0
  84. package/registry/ui/components/nm-collection/nm-collection-bar.tsx +65 -0
  85. package/registry/ui/components/nm-collection/nm-collection-grid.tsx +69 -0
  86. package/registry/ui/components/nm-collection/nm-collection-query.tsx +99 -0
  87. package/registry/ui/components/nm-collection/nm-collection-row-menu.tsx +55 -0
  88. package/registry/ui/components/nm-collection/nm-collection-table.tsx +99 -0
  89. package/registry/ui/components/nm-collection/nm-collection-tile-actions.tsx +50 -0
  90. package/registry/ui/components/nm-collection/nm-collection-title.tsx +25 -0
  91. package/registry/ui/components/nm-collection/nm-collection.css +353 -0
  92. package/registry/ui/components/nm-collection/use-collection-scroll-reveal.ts +38 -0
  93. package/registry/ui/components/nm-color-picker/nm-color-picker.css +67 -0
  94. package/registry/ui/components/nm-color-picker/nm-color-picker.tsx +79 -0
  95. package/registry/ui/components/nm-combobox/nm-combobox.css +72 -0
  96. package/registry/ui/components/nm-combobox/nm-combobox.tsx +80 -0
  97. package/registry/ui/components/nm-command/nm-command.css +190 -0
  98. package/registry/ui/components/nm-command/nm-command.tsx +125 -0
  99. package/registry/ui/components/nm-composer/nm-composer.css +178 -0
  100. package/registry/ui/components/nm-composer/nm-composer.tsx +151 -0
  101. package/registry/ui/components/nm-context-menu/nm-context-menu.tsx +25 -0
  102. package/registry/ui/components/nm-date-picker/nm-date-picker.css +140 -0
  103. package/registry/ui/components/nm-date-picker/nm-date-picker.tsx +153 -0
  104. package/registry/ui/components/nm-dialog/nm-dialog.css +84 -0
  105. package/registry/ui/components/nm-dialog/nm-dialog.tsx +40 -0
  106. package/registry/ui/components/nm-dropdown/nm-dropdown-item.ts +68 -0
  107. package/registry/ui/components/nm-dropdown/nm-dropdown-options.tsx +242 -0
  108. package/registry/ui/components/nm-dropdown/nm-dropdown-panel.tsx +171 -0
  109. package/registry/ui/components/nm-dropdown/nm-dropdown-placement.ts +157 -0
  110. package/registry/ui/components/nm-dropdown/nm-dropdown.css +312 -0
  111. package/registry/ui/components/nm-dropdown/nm-dropdown.tsx +412 -0
  112. package/registry/ui/components/nm-dropdown-menu/nm-dropdown-menu.css +145 -0
  113. package/registry/ui/components/nm-dropdown-menu/nm-dropdown-menu.tsx +118 -0
  114. package/registry/ui/components/nm-field/nm-field.css +356 -0
  115. package/registry/ui/components/nm-field/nm-field.tsx +355 -0
  116. package/registry/ui/components/nm-form-field/nm-form-field.css +103 -0
  117. package/registry/ui/components/nm-form-field/nm-form-field.tsx +71 -0
  118. package/registry/ui/components/nm-gallery/nm-gallery.css +66 -0
  119. package/registry/ui/components/nm-gallery/nm-gallery.tsx +31 -0
  120. package/registry/ui/components/nm-hover-card/nm-hover-card.css +26 -0
  121. package/registry/ui/components/nm-hover-card/nm-hover-card.tsx +28 -0
  122. package/registry/ui/components/nm-icon/nm-icon.css +6 -0
  123. package/registry/ui/components/nm-icon/nm-icon.tsx +69 -0
  124. package/registry/ui/components/nm-icon/nm-lucide.tsx +180 -0
  125. package/registry/ui/components/nm-icon-border/nm-icon-border.tsx +56 -0
  126. package/registry/ui/components/nm-input/nm-input.css +75 -0
  127. package/registry/ui/components/nm-input/nm-input.tsx +7 -0
  128. package/registry/ui/components/nm-input-group/nm-input-group.css +66 -0
  129. package/registry/ui/components/nm-input-group/nm-input-group.tsx +20 -0
  130. package/registry/ui/components/nm-label/nm-label.css +11 -0
  131. package/registry/ui/components/nm-label/nm-label.tsx +6 -0
  132. package/registry/ui/components/nm-list-item/nm-list-item.css +177 -0
  133. package/registry/ui/components/nm-list-item/nm-list-item.tsx +112 -0
  134. package/registry/ui/components/nm-menubar/nm-menubar.css +32 -0
  135. package/registry/ui/components/nm-menubar/nm-menubar.tsx +19 -0
  136. package/registry/ui/components/nm-message/nm-message-actions.tsx +24 -0
  137. package/registry/ui/components/nm-message/nm-message-meta.tsx +49 -0
  138. package/registry/ui/components/nm-message/nm-message.css +686 -0
  139. package/registry/ui/components/nm-message/nm-text-shimmer.tsx +6 -0
  140. package/registry/ui/components/nm-message/nm-trace.tsx +219 -0
  141. package/registry/ui/components/nm-modal/nm-modal.css +763 -0
  142. package/registry/ui/components/nm-modal/nm-modal.tsx +497 -0
  143. package/registry/ui/components/nm-native-select/nm-native-select.css +47 -0
  144. package/registry/ui/components/nm-native-select/nm-native-select.tsx +23 -0
  145. package/registry/ui/components/nm-panel/nm-panel.css +73 -0
  146. package/registry/ui/components/nm-panel/nm-panel.tsx +35 -0
  147. package/registry/ui/components/nm-panel-bar/nm-panel-bar.css +20 -0
  148. package/registry/ui/components/nm-panel-bar/nm-panel-bar.tsx +48 -0
  149. package/registry/ui/components/nm-popover/nm-popover.css +43 -0
  150. package/registry/ui/components/nm-popover/nm-popover.tsx +40 -0
  151. package/registry/ui/components/nm-progress/nm-progress.css +21 -0
  152. package/registry/ui/components/nm-progress/nm-progress.tsx +14 -0
  153. package/registry/ui/components/nm-prose/nm-prose.css +81 -0
  154. package/registry/ui/components/nm-prose/nm-prose.tsx +10 -0
  155. package/registry/ui/components/nm-questionnaire/nm-questionnaire.css +182 -0
  156. package/registry/ui/components/nm-questionnaire/nm-questionnaire.tsx +221 -0
  157. package/registry/ui/components/nm-radio-group/nm-radio-group.css +48 -0
  158. package/registry/ui/components/nm-radio-group/nm-radio-group.tsx +15 -0
  159. package/registry/ui/components/nm-rail-icon/nm-rail-icon.css +6 -0
  160. package/registry/ui/components/nm-rail-icon/nm-rail-icon.tsx +28 -0
  161. package/registry/ui/components/nm-resize-handle/nm-resize-handle.css +45 -0
  162. package/registry/ui/components/nm-resize-handle/nm-resize-handle.tsx +102 -0
  163. package/registry/ui/components/nm-segmented/nm-segmented.css +104 -0
  164. package/registry/ui/components/nm-segmented/nm-segmented.tsx +77 -0
  165. package/registry/ui/components/nm-select/nm-select.css +78 -0
  166. package/registry/ui/components/nm-select/nm-select.tsx +64 -0
  167. package/registry/ui/components/nm-separator/nm-separator.css +14 -0
  168. package/registry/ui/components/nm-separator/nm-separator.tsx +6 -0
  169. package/registry/ui/components/nm-side-panel/nm-side-panel.css +93 -0
  170. package/registry/ui/components/nm-side-panel/nm-side-panel.tsx +86 -0
  171. package/registry/ui/components/nm-slider/nm-slider.css +53 -0
  172. package/registry/ui/components/nm-slider/nm-slider.tsx +40 -0
  173. package/registry/ui/components/nm-small-icon-button/nm-small-icon-button.tsx +66 -0
  174. package/registry/ui/components/nm-status-bar/nm-status-bar.css +50 -0
  175. package/registry/ui/components/nm-status-bar/nm-status-bar.tsx +28 -0
  176. package/registry/ui/components/nm-switch/nm-switch.css +45 -0
  177. package/registry/ui/components/nm-switch/nm-switch.tsx +10 -0
  178. package/registry/ui/components/nm-table/nm-table.css +155 -0
  179. package/registry/ui/components/nm-table/nm-table.tsx +95 -0
  180. package/registry/ui/components/nm-tabs/nm-tabs.css +28 -0
  181. package/registry/ui/components/nm-tabs/nm-tabs.tsx +32 -0
  182. package/registry/ui/components/nm-textarea/nm-textarea.css +41 -0
  183. package/registry/ui/components/nm-textarea/nm-textarea.tsx +6 -0
  184. package/registry/ui/components/nm-toggle/nm-toggle.css +55 -0
  185. package/registry/ui/components/nm-toggle/nm-toggle.tsx +16 -0
  186. package/registry/ui/components/nm-toolbar/nm-toolbar.css +42 -0
  187. package/registry/ui/components/nm-toolbar/nm-toolbar.tsx +54 -0
  188. package/registry/ui/components/nm-tooltip/nm-tooltip.css +37 -0
  189. package/registry/ui/components/nm-tooltip/nm-tooltip.tsx +35 -0
  190. package/registry/ui/components/nm-top-bar/nm-top-bar.css +29 -0
  191. package/registry/ui/components/nm-top-bar/nm-top-bar.tsx +34 -0
  192. package/registry/ui/components/nordman-icon-button/nordman-icon-button.css +119 -0
  193. package/registry/ui/components/nordman-icon-button/nordman-icon-button.tsx +185 -0
  194. package/registry/ui/components/nordman-login/nordman-login.css +195 -0
  195. package/registry/ui/components/nordman-login/nordman-login.tsx +136 -0
  196. package/registry/ui/components/nordman-login-field/nordman-login-field.tsx +55 -0
  197. package/registry/ui/components/nordman-login-forgot/nordman-login-forgot.tsx +56 -0
  198. package/registry/ui/components/nordman-login-google/nordman-login-google.tsx +28 -0
  199. package/registry/ui/components/nordman-login-hero/nordman-login-hero.tsx +38 -0
  200. package/registry/ui/components/nordman-login-register/nordman-login-register.tsx +70 -0
  201. package/registry/ui/components/nordman-login-reset/nordman-login-reset.tsx +71 -0
  202. package/registry/ui/components/nordman-login-reveal/nordman-login-reveal.tsx +41 -0
  203. package/registry/ui/components/nordman-login-sign-in/nordman-login-sign-in.tsx +69 -0
  204. package/registry/ui/components/nordman-toggle/nordman-toggle.css +28 -0
  205. package/registry/ui/components/nordman-toggle/nordman-toggle.tsx +35 -0
  206. package/registry/ui/config/nm-ai.ts +59 -0
  207. package/registry/ui/config/nm-appearance.ts +275 -0
  208. package/registry/ui/config/nm-bar-overflow.ts +10 -0
  209. package/registry/ui/config/nm-button.ts +38 -0
  210. package/registry/ui/config/nm-chatbox-icons.ts +67 -0
  211. package/registry/ui/config/nm-chatbox.ts +42 -0
  212. package/registry/ui/config/nm-collection.ts +101 -0
  213. package/registry/ui/config/nm-composer.ts +39 -0
  214. package/registry/ui/config/nm-dropdown.ts +62 -0
  215. package/registry/ui/config/nm-field.ts +43 -0
  216. package/registry/ui/config/nm-icon-button.ts +35 -0
  217. package/registry/ui/config/nm-icons.ts +417 -0
  218. package/registry/ui/config/nm-list-item.ts +14 -0
  219. package/registry/ui/config/nm-message.ts +106 -0
  220. package/registry/ui/config/nm-modal.ts +76 -0
  221. package/registry/ui/config/nm-panel-bar.ts +11 -0
  222. package/registry/ui/config/nm-questionnaire.ts +53 -0
  223. package/registry/ui/config/nm-radius.ts +56 -0
  224. package/registry/ui/config/nm-rail-icons.ts +27 -0
  225. package/registry/ui/config/nm-segmented.ts +19 -0
  226. package/registry/ui/config/nm-side-panel.ts +16 -0
  227. package/registry/ui/config/nm-site-palette.ts +30 -0
  228. package/registry/ui/config/nm-small-icon-button.ts +17 -0
  229. package/registry/ui/config/nm-tabs.ts +9 -0
  230. package/registry/ui/config/nm-top-bar.ts +4 -0
  231. package/registry/ui/config/nordman-chrome.ts +14 -0
  232. package/registry/ui/config/nordman-login.ts +28 -0
  233. package/registry/ui/content/nm-modal.ts +5 -0
  234. package/registry/ui/content/nordman-login.ts +85 -0
  235. package/registry/ui/kit-logger.ts +1 -0
  236. package/registry/ui/lib/appearance/appearanceState.ts +240 -0
  237. package/registry/ui/lib/appearance/applyAppearance.ts +36 -0
  238. package/registry/ui/lib/appearance/cloudOrbAppearance.ts +36 -0
  239. package/registry/ui/lib/appearance/color.ts +96 -0
  240. package/registry/ui/lib/appearance/deriveTokens.ts +218 -0
  241. package/registry/ui/lib/appearance/index.ts +6 -0
  242. package/registry/ui/lib/appearance/markTokens.ts +49 -0
  243. package/registry/ui/lib/appearance/readLayoutMetrics.ts +28 -0
  244. package/registry/ui/lib/bar-overflow.ts +41 -0
  245. package/registry/ui/lib/logger.ts +53 -0
  246. package/registry/ui/lib/menu-motion.ts +187 -0
  247. package/registry/ui/lib/nm-class.ts +4 -0
  248. package/registry/ui/lib/nordman-ui-locale.ts +43 -0
  249. package/registry/ui/styles/interface-theme.css +196 -0
  250. package/registry/ui/styles/light-appearance.css +72 -0
  251. package/registry/ui/styles/tokens.css +424 -0
  252. package/registry/ui/styles/utilities.css +12 -0
  253. package/dist/ui/components/nm-accordion/nm-accordion.d.ts +0 -6
@@ -0,0 +1,86 @@
1
+ import { useRef, useState, type ComponentProps } from 'react';
2
+ import { nmClass } from '../../lib/nm-class.ts';
3
+ import { NM_SIDE_PANEL_KINDS, type NmSidePanelKind, type NmSidePanelSize } from '../../config/nm-side-panel.ts';
4
+ import { NmResizeHandle } from '../nm-resize-handle/nm-resize-handle.tsx';
5
+ import { NmToolbarButton } from '../nm-toolbar/nm-toolbar.tsx';
6
+
7
+ /**
8
+ * A view that holds a main area and a side panel next to it, such as a chat with an artifact beside it.
9
+ * It is the organ the side panel opens in.
10
+ */
11
+ export function NmWorkspace({ className, height = 'fill', ...props }: ComponentProps<'div'> & { height?: 'fill' | 'sm' | 'lg' }) {
12
+ return <div data-slot="workspace" data-height={height} className={nmClass('nm-workspace', className)} {...props} />;
13
+ }
14
+
15
+ /** The main area. It takes the room the side panel leaves. */
16
+ export function NmWorkspaceMain({ className, ...props }: ComponentProps<'div'>) {
17
+ return <div data-slot="workspace-main" className={nmClass('nm-workspace__main', className)} {...props} />;
18
+ }
19
+
20
+ /** The content under a bar in the main area. It fills the height and scrolls. */
21
+ export function NmWorkspaceBody({ className, ...props }: ComponentProps<'div'>) {
22
+ return <div data-slot="workspace-body" className={nmClass('nm-workspace__body', className)} {...props} />;
23
+ }
24
+
25
+ /** A row under the body, such as the composer. */
26
+ export function NmWorkspaceFooter({ className, ...props }: ComponentProps<'div'>) {
27
+ return <div data-slot="workspace-footer" className={nmClass('nm-workspace__footer', className)} {...props} />;
28
+ }
29
+
30
+ /**
31
+ * The panel that opens beside the main area, for an app, code, an artifact, media, docs or markdown.
32
+ * `open` shows it. `size` sets how much of the view it takes, and the handle on its edge resizes it. Fill it with a toolbar and a body.
33
+ */
34
+ export function NmSidePanel({
35
+ className,
36
+ open = true,
37
+ size = 'default',
38
+ label,
39
+ resizable = true,
40
+ style,
41
+ children,
42
+ ...props
43
+ }: Omit<ComponentProps<'aside'>, 'aria-label'> & { open?: boolean; size?: NmSidePanelSize; label: string; resizable?: boolean }) {
44
+ const ref = useRef<HTMLElement>(null);
45
+ const [width, setWidth] = useState<number | null>(null);
46
+ return (
47
+ <aside
48
+ ref={ref}
49
+ data-slot="side-panel"
50
+ data-open={open ? '' : undefined}
51
+ data-size={size}
52
+ aria-label={label}
53
+ hidden={!open}
54
+ className={nmClass('nm-side-panel', className)}
55
+ style={width == null ? style : { ...style, ['--nm-side-panel-basis' as string]: `${width}px` }}
56
+ {...props}
57
+ >
58
+ {resizable ? <NmResizeHandle target={ref} edge="start" placement="inside" label={`Resize ${label}`} onSize={setWidth} /> : null}
59
+ {children}
60
+ </aside>
61
+ );
62
+ }
63
+
64
+ /** The content under the toolbar. It fills the height and scrolls. */
65
+ export function NmSidePanelBody({ className, ...props }: ComponentProps<'div'>) {
66
+ return <div data-slot="side-panel-body" className={nmClass('nm-side-panel__body', className)} {...props} />;
67
+ }
68
+
69
+ /** One button per kind of content. Pressing one opens the panel on that kind. */
70
+ export function NmSidePanelKinds({
71
+ kinds = NM_SIDE_PANEL_KINDS.map((k) => k.id),
72
+ active,
73
+ onSelect,
74
+ }: {
75
+ kinds?: readonly NmSidePanelKind[];
76
+ active?: NmSidePanelKind | null;
77
+ onSelect: (kind: NmSidePanelKind) => void;
78
+ }) {
79
+ return (
80
+ <>
81
+ {NM_SIDE_PANEL_KINDS.filter((k) => kinds.includes(k.id)).map((k) => (
82
+ <NmToolbarButton key={k.id} icon={k.icon} label={k.label} pressed={active === k.id} tone={active === k.id ? 'panel' : 'quiet'} onClick={() => onSelect(k.id)} />
83
+ ))}
84
+ </>
85
+ );
86
+ }
@@ -0,0 +1,53 @@
1
+ .nm-slider {
2
+ width: 100%;
3
+ }
4
+
5
+ .nm-slider__control {
6
+ position: relative;
7
+ display: flex;
8
+ align-items: center;
9
+ width: 100%;
10
+ height: var(--nm-icon-button);
11
+ touch-action: none;
12
+ user-select: none;
13
+ }
14
+
15
+ .nm-slider__track {
16
+ position: relative;
17
+ flex-grow: 1;
18
+ height: var(--nm-space-4);
19
+ overflow: hidden;
20
+ border-radius: var(--toggle-r);
21
+ background: var(--nm-panel);
22
+ }
23
+
24
+ .nm-slider__range {
25
+ height: 100%;
26
+ background: var(--nm-fg);
27
+ }
28
+
29
+ .nm-slider__thumb {
30
+ width: var(--nm-icon-button);
31
+ height: var(--nm-icon-button);
32
+ box-sizing: border-box;
33
+ border: var(--nm-rule) solid var(--nm-fg);
34
+ border-radius: 50%;
35
+ background: var(--nm-canvas);
36
+ user-select: none;
37
+ }
38
+
39
+ .nm-slider__thumb:focus-visible {
40
+ outline: var(--nm-rule) solid var(--focus);
41
+ outline-offset: var(--nm-space-2);
42
+ }
43
+
44
+ .nm-slider[data-disabled] {
45
+ opacity: 0.5;
46
+ }
47
+
48
+ .nm-slider__head {
49
+ display: flex;
50
+ align-items: baseline;
51
+ justify-content: space-between;
52
+ gap: var(--nm-space-8);
53
+ }
@@ -0,0 +1,40 @@
1
+ import { Slider as SliderPrimitive } from '@base-ui/react/slider';
2
+ import { nmClass } from '../../lib/nm-class.ts';
3
+
4
+ /** `label` and `output` add a caption above the track, set like the caption of a Field. */
5
+ export function NmSlider({ className, defaultValue, value, min = 0, max = 100, label, output, ...props }: SliderPrimitive.Root.Props & { label?: string; output?: string }) {
6
+ const values = Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max];
7
+ const slider = (
8
+ <SliderPrimitive.Root
9
+ data-slot="slider"
10
+ className={nmClass('nm-slider', className as string)}
11
+ defaultValue={defaultValue}
12
+ value={value}
13
+ min={min}
14
+ max={max}
15
+ thumbAlignment="edge"
16
+ aria-label={label}
17
+ {...props}
18
+ >
19
+ <SliderPrimitive.Control className="nm-slider__control">
20
+ <SliderPrimitive.Track data-slot="slider-track" className="nm-slider__track">
21
+ <SliderPrimitive.Indicator data-slot="slider-range" className="nm-slider__range" />
22
+ </SliderPrimitive.Track>
23
+ {Array.from({ length: values.length }, (_, index) => (
24
+ <SliderPrimitive.Thumb key={index} data-slot="slider-thumb" className="nm-slider__thumb" />
25
+ ))}
26
+ </SliderPrimitive.Control>
27
+ </SliderPrimitive.Root>
28
+ );
29
+ return label ? (
30
+ <div className="nm-field nm-field--stack">
31
+ <div className="nm-slider__head">
32
+ <span className="nm-field__caption">{label}</span>
33
+ {output != null ? <output className="nm-field__caption">{output}</output> : null}
34
+ </div>
35
+ {slider}
36
+ </div>
37
+ ) : (
38
+ slider
39
+ );
40
+ }
@@ -0,0 +1,66 @@
1
+ import { forwardRef, type ButtonHTMLAttributes, type ReactNode } from 'react';
2
+ import type { NmIconId } from '../../config/nm-icons.ts';
3
+ import {
4
+ NM_SMALL_ICON_BUTTON_TONES,
5
+ type NmSmallIconButtonTone,
6
+ } from '../../config/nm-small-icon-button.ts';
7
+ import { NM_ICON_BUTTON_TONES, type NmIconButtonTone } from '../../config/nm-icon-button.ts';
8
+ import { NordmanIconButton } from '../nordman-icon-button/nordman-icon-button.tsx';
9
+ import { createLogger } from '../../kit-logger.ts';
10
+
11
+ const logger = createLogger('interface-nm-small-icon-button');
12
+
13
+ const SMALL_ICON_BUTTON_TONE: Record<NmSmallIconButtonTone, NmIconButtonTone> = {
14
+ [NM_SMALL_ICON_BUTTON_TONES.solid]: NM_ICON_BUTTON_TONES.solid,
15
+ [NM_SMALL_ICON_BUTTON_TONES.quiet]: NM_ICON_BUTTON_TONES.quiet,
16
+ };
17
+
18
+ export type NmSmallIconButtonProps = {
19
+ label: string;
20
+ icon: NmIconId;
21
+ tone?: NmSmallIconButtonTone;
22
+ active?: boolean;
23
+ iconContent?: ReactNode;
24
+ testId?: string;
25
+ onClick?: () => void;
26
+ } & Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick' | 'aria-label' | 'children'>;
27
+
28
+ export const NmSmallIconButton = forwardRef<HTMLButtonElement, NmSmallIconButtonProps>(
29
+ function NmSmallIconButton(props, ref): ReactNode {
30
+ const {
31
+ label,
32
+ icon,
33
+ tone = NM_SMALL_ICON_BUTTON_TONES.solid,
34
+ active = false,
35
+ iconContent,
36
+ testId,
37
+ onClick,
38
+ className,
39
+ disabled,
40
+ ...rest
41
+ } = props;
42
+ logger.debug('render', label, { icon, tone, disabled: disabled === true, active });
43
+ return (
44
+ <NordmanIconButton
45
+ {...rest}
46
+ ref={ref}
47
+ glyph={icon}
48
+ label={label}
49
+ tone={SMALL_ICON_BUTTON_TONE[tone]}
50
+ active={active}
51
+ disabled={disabled}
52
+ testId={testId}
53
+ className={className}
54
+ onClick={(event) => {
55
+ event.stopPropagation();
56
+ if (disabled === true) {
57
+ return;
58
+ }
59
+ onClick?.();
60
+ }}
61
+ >
62
+ {iconContent}
63
+ </NordmanIconButton>
64
+ );
65
+ },
66
+ );
@@ -0,0 +1,50 @@
1
+ .nm-status-bar {
2
+ box-sizing: border-box;
3
+ display: flex;
4
+ align-items: center;
5
+ gap: var(--nm-space-4);
6
+ width: 100%;
7
+ min-width: 0;
8
+ height: var(--control-h-sm);
9
+ padding: 0 var(--nm-space-8);
10
+ background: var(--nm-panel);
11
+ color: var(--nm-fg-muted);
12
+ font-family: var(--nm-font);
13
+ font-size: var(--nm-type-ui-sm);
14
+ }
15
+
16
+ .nm-status-bar__item {
17
+ display: inline-flex;
18
+ align-items: center;
19
+ gap: var(--nm-space-6);
20
+ height: 100%;
21
+ padding: 0 var(--nm-space-8);
22
+ border: 0;
23
+ background: transparent;
24
+ color: inherit;
25
+ font: inherit;
26
+ white-space: nowrap;
27
+ }
28
+
29
+ button.nm-status-bar__item {
30
+ cursor: pointer;
31
+ }
32
+
33
+ button.nm-status-bar__item:hover {
34
+ background: var(--nm-line);
35
+ color: var(--nm-fg);
36
+ }
37
+
38
+ button.nm-status-bar__item:focus-visible {
39
+ outline: var(--nm-rule) solid var(--focus);
40
+ outline-offset: calc(var(--nm-space-2) * -1);
41
+ }
42
+
43
+ .nm-status-bar__item .nm-icon {
44
+ width: var(--nm-icon-sm);
45
+ height: var(--nm-icon-sm);
46
+ }
47
+
48
+ .nm-status-bar__spacer {
49
+ flex: 1;
50
+ }
@@ -0,0 +1,28 @@
1
+ import type { ComponentProps } from 'react';
2
+ import { nmClass } from '../../lib/nm-class.ts';
3
+
4
+ /** A thin bar at the bottom of a window for state: branch, errors, cursor position, connection. */
5
+ export function NmStatusBar({ className, ...props }: ComponentProps<'footer'>) {
6
+ return <footer data-slot="status-bar" className={nmClass('nm-status-bar', className)} {...props} />;
7
+ }
8
+
9
+ /** One item. Give it `onClick` and it becomes a button. */
10
+ export function NmStatusBarItem({ className, onClick, children, ...props }: Omit<ComponentProps<'span'>, 'onClick'> & { onClick?: () => void }) {
11
+ const classes = nmClass('nm-status-bar__item', className);
12
+ if (onClick) {
13
+ return (
14
+ <button type="button" data-slot="status-bar-item" className={classes} onClick={onClick}>
15
+ {children}
16
+ </button>
17
+ );
18
+ }
19
+ return (
20
+ <span data-slot="status-bar-item" className={classes} {...props}>
21
+ {children}
22
+ </span>
23
+ );
24
+ }
25
+
26
+ export function NmStatusBarSpacer({ className, ...props }: ComponentProps<'span'>) {
27
+ return <span aria-hidden="true" data-slot="status-bar-spacer" className={nmClass('nm-status-bar__spacer', className)} {...props} />;
28
+ }
@@ -0,0 +1,45 @@
1
+ .nm-switch {
2
+ --nm-switch-thumb: var(--nm-icon-button);
3
+ display: inline-flex;
4
+ flex-shrink: 0;
5
+ align-items: center;
6
+ box-sizing: content-box;
7
+ width: calc(var(--nm-switch-thumb) * 2);
8
+ height: var(--nm-switch-thumb);
9
+ padding: var(--nm-space-2);
10
+ border: 0;
11
+ border-radius: var(--toggle-r);
12
+ background: var(--nm-panel);
13
+ cursor: pointer;
14
+ transition: background 0.15s;
15
+ }
16
+
17
+ .nm-switch:focus-visible {
18
+ outline: var(--nm-rule) solid var(--focus);
19
+ outline-offset: var(--nm-space-2);
20
+ }
21
+
22
+ .nm-switch[data-checked] {
23
+ background: var(--nm-fg);
24
+ }
25
+
26
+ .nm-switch[data-disabled] {
27
+ cursor: not-allowed;
28
+ opacity: 0.5;
29
+ }
30
+
31
+ .nm-switch__thumb {
32
+ display: block;
33
+ width: var(--nm-switch-thumb);
34
+ height: var(--nm-switch-thumb);
35
+ border-radius: 50%;
36
+ background: var(--nm-fg);
37
+ transition:
38
+ transform 0.15s,
39
+ background 0.15s;
40
+ }
41
+
42
+ .nm-switch[data-checked] .nm-switch__thumb {
43
+ transform: translateX(var(--nm-switch-thumb));
44
+ background: var(--nm-canvas);
45
+ }
@@ -0,0 +1,10 @@
1
+ import { Switch as SwitchPrimitive } from '@base-ui/react/switch';
2
+ import { nmClass } from '../../lib/nm-class.ts';
3
+
4
+ export function NmSwitch({ className, ...props }: SwitchPrimitive.Root.Props) {
5
+ return (
6
+ <SwitchPrimitive.Root data-slot="switch" className={nmClass('nm-switch', className as string)} {...props}>
7
+ <SwitchPrimitive.Thumb data-slot="switch-thumb" className="nm-switch__thumb" />
8
+ </SwitchPrimitive.Root>
9
+ );
10
+ }
@@ -0,0 +1,155 @@
1
+ .nm-table__container {
2
+ position: relative;
3
+ width: 100%;
4
+ overflow-x: auto;
5
+ }
6
+
7
+ .nm-table__container[data-sticky] {
8
+ overflow-y: auto;
9
+ }
10
+
11
+ .nm-table {
12
+ --nm-table-pad-y: var(--nm-space-12);
13
+ --nm-table-pad-x: var(--nm-space-12);
14
+ width: 100%;
15
+ border-collapse: collapse;
16
+ caption-side: bottom;
17
+ color: var(--nm-fg);
18
+ font-family: var(--nm-font);
19
+ font-size: var(--nm-type-ui);
20
+ line-height: var(--nm-leading-snug);
21
+ }
22
+
23
+ .nm-table[data-size='sm'] {
24
+ --nm-table-pad-y: var(--nm-space-6);
25
+ --nm-table-pad-x: var(--nm-space-8);
26
+ }
27
+
28
+ .nm-table__header,
29
+ .nm-table__body {
30
+ font: inherit;
31
+ }
32
+
33
+ .nm-table__head {
34
+ padding: var(--nm-table-pad-y) var(--nm-table-pad-x);
35
+ border-bottom: var(--nm-rule) solid var(--nm-line-strong);
36
+ color: var(--nm-fg-muted);
37
+ font-size: var(--nm-type-ui-sm);
38
+ font-weight: var(--nm-weight-medium);
39
+ text-align: left;
40
+ white-space: nowrap;
41
+ }
42
+
43
+ .nm-table__container[data-sticky] .nm-table__head {
44
+ position: sticky;
45
+ top: 0;
46
+ z-index: 1;
47
+ background: var(--nm-canvas);
48
+ }
49
+
50
+ .nm-table__cell {
51
+ padding: var(--nm-table-pad-y) var(--nm-table-pad-x);
52
+ vertical-align: middle;
53
+ white-space: nowrap;
54
+ }
55
+
56
+ .nm-table__cell[data-wrap] {
57
+ vertical-align: top;
58
+ white-space: normal;
59
+ }
60
+
61
+ .nm-table__head[data-align='center'],
62
+ .nm-table__cell[data-align='center'] {
63
+ text-align: center;
64
+ }
65
+
66
+ .nm-table__head[data-align='end'],
67
+ .nm-table__cell[data-align='end'] {
68
+ text-align: right;
69
+ font-variant-numeric: tabular-nums;
70
+ }
71
+
72
+ .nm-table__row {
73
+ transition: background 0.12s;
74
+ }
75
+
76
+ .nm-table[data-variant='default'] .nm-table__body .nm-table__row:not(:last-child),
77
+ .nm-table[data-variant='striped'] .nm-table__body .nm-table__row:not(:last-child) {
78
+ border-bottom: var(--nm-rule) solid var(--nm-line);
79
+ }
80
+
81
+ .nm-table[data-variant='striped'] .nm-table__body .nm-table__row:nth-child(even) {
82
+ background: var(--nm-raised);
83
+ }
84
+
85
+ .nm-table[data-variant='lined'] .nm-table__head,
86
+ .nm-table[data-variant='lined'] .nm-table__cell {
87
+ border: var(--nm-rule) solid var(--nm-line);
88
+ }
89
+
90
+ .nm-table[data-variant='plain'] .nm-table__head {
91
+ border-bottom-color: transparent;
92
+ }
93
+
94
+ .nm-table__row:hover:not([data-disabled]) {
95
+ background: var(--nm-inset);
96
+ }
97
+
98
+ .nm-table__row[data-interactive]:not([data-disabled]) {
99
+ cursor: pointer;
100
+ }
101
+
102
+ .nm-table__row[data-selected] {
103
+ background: var(--nm-panel);
104
+ }
105
+
106
+ .nm-table__row[data-disabled] {
107
+ color: var(--nm-fg-subtle);
108
+ }
109
+
110
+ .nm-table__row[data-disabled] .nm-table__cell {
111
+ opacity: 0.6;
112
+ }
113
+
114
+ .nm-table__footer {
115
+ border-top: var(--nm-rule) solid var(--nm-line-strong);
116
+ background: var(--nm-raised);
117
+ font-weight: var(--nm-weight-medium);
118
+ }
119
+
120
+ .nm-table__caption {
121
+ margin-top: var(--nm-space-12);
122
+ color: var(--nm-fg-muted);
123
+ font-size: var(--nm-type-ui-sm);
124
+ }
125
+
126
+ .nm-table__sort {
127
+ display: inline-flex;
128
+ align-items: center;
129
+ gap: var(--nm-space-4);
130
+ padding: 0;
131
+ border: 0;
132
+ background: transparent;
133
+ color: inherit;
134
+ font: inherit;
135
+ cursor: pointer;
136
+ }
137
+
138
+ .nm-table__sort:hover,
139
+ .nm-table__sort:focus-visible {
140
+ color: var(--nm-fg);
141
+ outline: none;
142
+ }
143
+
144
+ /* The chevron points down. Ascending turns it up. An unsorted column shows it faint. */
145
+ .nm-table__sort-icon[data-sort='none'] {
146
+ opacity: 0.4;
147
+ }
148
+
149
+ .nm-table__sort-icon[data-sort='asc'] {
150
+ transform: rotate(180deg);
151
+ }
152
+
153
+ .nm-table__sort-icon[data-sort='desc'] {
154
+ transform: none;
155
+ }
@@ -0,0 +1,95 @@
1
+ import type { ComponentProps } from 'react';
2
+ import { nmClass } from '../../lib/nm-class.ts';
3
+ import { NmIcon } from '../nm-icon/nm-icon.tsx';
4
+
5
+ export const NM_TABLE_VARIANTS = ['default', 'striped', 'lined', 'plain'] as const;
6
+ export const NM_TABLE_SIZES = ['default', 'sm'] as const;
7
+ export type NmTableVariant = (typeof NM_TABLE_VARIANTS)[number];
8
+ export type NmTableSize = (typeof NM_TABLE_SIZES)[number];
9
+
10
+ type TableOptions = {
11
+ /** default has a line between rows. striped alternates the row fill. lined draws every cell. plain has no lines. */
12
+ variant?: NmTableVariant;
13
+ size?: NmTableSize;
14
+ /** Keeps the header in view while the body scrolls. Give the container a height with `maxHeight`. */
15
+ stickyHeader?: boolean;
16
+ /** The container's maximum height. The body scrolls past it. */
17
+ maxHeight?: string;
18
+ };
19
+
20
+ /** The shadcn Table composition, styled by NIF tokens. The container scrolls sideways when the table is wider than its space. */
21
+ export function NmTable({ className, variant = 'default', size = 'default', stickyHeader, maxHeight, ...props }: ComponentProps<'table'> & TableOptions) {
22
+ return (
23
+ <div
24
+ data-slot="table-container"
25
+ data-sticky={stickyHeader ? '' : undefined}
26
+ className="nm-table__container"
27
+ style={maxHeight ? { maxHeight } : undefined}
28
+ >
29
+ <table data-slot="table" data-variant={variant} data-size={size} className={nmClass('nm-table', className)} {...props} />
30
+ </div>
31
+ );
32
+ }
33
+
34
+ export function NmTableHeader({ className, ...props }: ComponentProps<'thead'>) {
35
+ return <thead data-slot="table-header" className={nmClass('nm-table__header', className)} {...props} />;
36
+ }
37
+
38
+ export function NmTableBody({ className, ...props }: ComponentProps<'tbody'>) {
39
+ return <tbody data-slot="table-body" className={nmClass('nm-table__body', className)} {...props} />;
40
+ }
41
+
42
+ export function NmTableFooter({ className, ...props }: ComponentProps<'tfoot'>) {
43
+ return <tfoot data-slot="table-footer" className={nmClass('nm-table__footer', className)} {...props} />;
44
+ }
45
+
46
+ /** A row. `selected` marks it chosen. `disabled` dims it and stops its hover. Give it `onClick` to make the whole row a target. */
47
+ export function NmTableRow({ className, selected, disabled, ...props }: ComponentProps<'tr'> & { selected?: boolean; disabled?: boolean }) {
48
+ return (
49
+ <tr
50
+ data-slot="table-row"
51
+ data-selected={selected ? '' : undefined}
52
+ data-disabled={disabled ? '' : undefined}
53
+ data-interactive={props.onClick != null ? '' : undefined}
54
+ aria-selected={selected ? true : undefined}
55
+ aria-disabled={disabled ? true : undefined}
56
+ className={nmClass('nm-table__row', className)}
57
+ {...props}
58
+ />
59
+ );
60
+ }
61
+
62
+ export type NmSortDirection = 'asc' | 'desc' | 'none';
63
+
64
+ /** A column heading. Give it `sort` and `onSort` and it becomes a sort button. `textAlign="end"` is for numbers. */
65
+ export function NmTableHead({
66
+ className,
67
+ textAlign = 'start',
68
+ sort,
69
+ onSort,
70
+ children,
71
+ ...props
72
+ }: Omit<ComponentProps<'th'>, 'align'> & { textAlign?: 'start' | 'center' | 'end'; sort?: NmSortDirection; onSort?: () => void }) {
73
+ const ariaSort = sort === 'asc' ? 'ascending' : sort === 'desc' ? 'descending' : sort === 'none' ? 'none' : undefined;
74
+ return (
75
+ <th data-slot="table-head" data-align={textAlign} aria-sort={ariaSort} className={nmClass('nm-table__head', className)} scope="col" {...props}>
76
+ {onSort ? (
77
+ <button type="button" className="nm-table__sort" onClick={onSort}>
78
+ {children}
79
+ <NmIcon id="chevron" className="nm-table__sort-icon" data-sort={sort ?? 'none'} />
80
+ </button>
81
+ ) : (
82
+ children
83
+ )}
84
+ </th>
85
+ );
86
+ }
87
+
88
+ /** Cells stay on one line. Give `wrap` to a cell that holds a sentence, and it wraps and aligns to the top. */
89
+ export function NmTableCell({ className, textAlign = 'start', wrap, ...props }: Omit<ComponentProps<'td'>, 'align'> & { textAlign?: 'start' | 'center' | 'end'; wrap?: boolean }) {
90
+ return <td data-slot="table-cell" data-align={textAlign} data-wrap={wrap ? '' : undefined} className={nmClass('nm-table__cell', className)} {...props} />;
91
+ }
92
+
93
+ export function NmTableCaption({ className, ...props }: ComponentProps<'caption'>) {
94
+ return <caption data-slot="table-caption" className={nmClass('nm-table__caption', className)} {...props} />;
95
+ }
@@ -0,0 +1,28 @@
1
+ .nm-tabs {
2
+ display: flex;
3
+ flex-wrap: wrap;
4
+ gap: var(--nm-space-4);
5
+ border-bottom: var(--nm-rule) solid var(--nm-line);
6
+ }
7
+
8
+ .nm-tabs__item {
9
+ margin-bottom: calc(var(--nm-rule) * -1);
10
+ padding: var(--tab-py) var(--tab-px);
11
+ border: 0;
12
+ border-bottom: var(--tab-rule) solid transparent;
13
+ background: transparent;
14
+ color: var(--nm-fg-subtle);
15
+ font-family: var(--nm-font);
16
+ font-size: var(--control-fs);
17
+ font-weight: var(--nm-weight-regular);
18
+ cursor: pointer;
19
+ }
20
+
21
+ .nm-tabs__item:hover {
22
+ color: var(--nm-fg);
23
+ }
24
+
25
+ .nm-tabs__item[aria-selected='true'] {
26
+ border-bottom-color: var(--nm-fg);
27
+ color: var(--nm-fg);
28
+ }