@nordmanai/nif 0.1.0 → 0.2.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 (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 +110 -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 +87 -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,92 @@
1
+ import { useCallback, useLayoutEffect, useRef, useState, type RefObject } from 'react';
2
+ import {
3
+ BAR_OVERFLOW_MODES,
4
+ resolveBarOverflow,
5
+ type BarOverflowMode,
6
+ } from '../../lib/bar-overflow.ts';
7
+ import { createLogger } from '../../kit-logger.ts';
8
+
9
+ const logger = createLogger('interface-nm-bar-overflow');
10
+
11
+ export function useBarOverflow(
12
+ rootRef: RefObject<HTMLElement | null>,
13
+ rowRef: RefObject<HTMLElement | null>,
14
+ ): {
15
+ mode: BarOverflowMode;
16
+ open: boolean;
17
+ setOpen: (open: boolean) => void;
18
+ } {
19
+ const [mode, setMode] = useState<BarOverflowMode>(BAR_OVERFLOW_MODES.inline);
20
+ const [open, setOpenState] = useState(false);
21
+ const openRef = useRef(false);
22
+ const neededRef = useRef(0);
23
+ const modeRef = useRef<BarOverflowMode>(BAR_OVERFLOW_MODES.inline);
24
+
25
+ const apply = useCallback(() => {
26
+ const root = rootRef.current;
27
+ const row = rowRef.current;
28
+ if (root == null || row == null) {
29
+ return;
30
+ }
31
+ if (!openRef.current && row.scrollWidth > 0) {
32
+ neededRef.current = row.scrollWidth;
33
+ }
34
+ const next = resolveBarOverflow({
35
+ availableWidth: root.clientWidth,
36
+ neededWidth: neededRef.current,
37
+ });
38
+ if (modeRef.current !== next) {
39
+ logger.debug('measure', next, {
40
+ available: Math.round(root.clientWidth),
41
+ needed: Math.round(neededRef.current),
42
+ });
43
+ modeRef.current = next;
44
+ setMode(next);
45
+ }
46
+ if (next === BAR_OVERFLOW_MODES.inline && openRef.current) {
47
+ openRef.current = false;
48
+ setOpenState(false);
49
+ }
50
+ }, [rootRef, rowRef]);
51
+
52
+ useLayoutEffect(() => {
53
+ apply();
54
+ const root = rootRef.current;
55
+ const row = rowRef.current;
56
+ const observer = new ResizeObserver(() => {
57
+ apply();
58
+ });
59
+ if (root != null) {
60
+ observer.observe(root);
61
+ }
62
+ if (row != null) {
63
+ observer.observe(row);
64
+ }
65
+ window.addEventListener('resize', apply);
66
+ let cancelled = false;
67
+ if (document.fonts != null) {
68
+ void document.fonts.ready.then(() => {
69
+ if (!cancelled) {
70
+ apply();
71
+ }
72
+ });
73
+ }
74
+ return () => {
75
+ cancelled = true;
76
+ observer.disconnect();
77
+ window.removeEventListener('resize', apply);
78
+ };
79
+ }, [apply, rootRef, rowRef]);
80
+
81
+ useLayoutEffect(() => {
82
+ apply();
83
+ }, [apply, open]);
84
+
85
+ const setOpen = useCallback((next: boolean) => {
86
+ openRef.current = next;
87
+ setOpenState(next);
88
+ logger.debug('toggle', next ? 'open' : 'close');
89
+ }, []);
90
+
91
+ return { mode, open, setOpen };
92
+ }
@@ -0,0 +1,20 @@
1
+ .nm-brand-logo {
2
+ display: inline-flex;
3
+ flex-shrink: 0;
4
+ align-items: center;
5
+ justify-content: center;
6
+ width: var(--nm-icon);
7
+ height: var(--nm-icon);
8
+ color: var(--nm-fg);
9
+ }
10
+
11
+ .nm-brand-logo > svg {
12
+ display: block;
13
+ width: 100%;
14
+ height: 100%;
15
+ }
16
+
17
+ /* A mono logo has no colour of its own. It is filled with the text colour. */
18
+ .nm-brand-logo[data-mono] > svg {
19
+ fill: currentColor;
20
+ }
@@ -0,0 +1,21 @@
1
+ import type { ComponentProps } from 'react';
2
+ import { nmClass } from '../../lib/nm-class.ts';
3
+
4
+ /**
5
+ * A brand logo from its SVG source, such as the strings in @thesvg/icons. The markup must come from a trusted
6
+ * package, never from user input. It is drawn at the icon size, and a mono logo (`mono`) takes the text colour, so it reads on any theme.
7
+ */
8
+ export function NmBrandLogo({ svg, label, mono, className, ...props }: Omit<ComponentProps<'span'>, 'children'> & { svg: string; label?: string; mono?: boolean }) {
9
+ return (
10
+ <span
11
+ data-slot="brand-logo"
12
+ data-mono={mono ? '' : undefined}
13
+ role={label ? 'img' : undefined}
14
+ aria-label={label}
15
+ aria-hidden={label ? undefined : true}
16
+ className={nmClass('nm-brand-logo', className)}
17
+ dangerouslySetInnerHTML={{ __html: svg }}
18
+ {...props}
19
+ />
20
+ );
21
+ }
@@ -0,0 +1,57 @@
1
+ .nm-breadcrumb {
2
+ font-family: var(--nm-font);
3
+ font-size: var(--nm-type-ui);
4
+ }
5
+
6
+ .nm-breadcrumb__list {
7
+ display: flex;
8
+ flex-wrap: wrap;
9
+ align-items: center;
10
+ gap: var(--nm-space-8);
11
+ margin: 0;
12
+ padding: 0;
13
+ list-style: none;
14
+ color: var(--nm-fg-muted);
15
+ }
16
+
17
+ .nm-breadcrumb__item {
18
+ display: inline-flex;
19
+ align-items: center;
20
+ gap: var(--nm-space-6);
21
+ }
22
+
23
+ .nm-breadcrumb__link {
24
+ color: inherit;
25
+ text-decoration: none;
26
+ }
27
+
28
+ .nm-breadcrumb__link:hover {
29
+ color: var(--nm-fg);
30
+ }
31
+
32
+ .nm-breadcrumb__link:focus-visible {
33
+ border-radius: var(--nm-radius-sm);
34
+ outline: var(--nm-rule) solid var(--focus);
35
+ outline-offset: var(--nm-space-2);
36
+ }
37
+
38
+ .nm-breadcrumb__page {
39
+ color: var(--nm-fg);
40
+ }
41
+
42
+ .nm-breadcrumb__separator {
43
+ display: inline-flex;
44
+ color: var(--nm-fg-subtle);
45
+ transform: rotate(-90deg);
46
+ }
47
+
48
+ .nm-breadcrumb__separator .nm-icon,
49
+ .nm-breadcrumb__ellipsis .nm-icon {
50
+ width: var(--nm-icon-sm);
51
+ height: var(--nm-icon-sm);
52
+ }
53
+
54
+ .nm-breadcrumb__ellipsis {
55
+ display: inline-flex;
56
+ align-items: center;
57
+ }
@@ -0,0 +1,42 @@
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
+ /** The path to the current page. The shadcn Breadcrumb composition, styled by NIF tokens. */
6
+ export function NmBreadcrumb({ className, ...props }: ComponentProps<'nav'>) {
7
+ return <nav aria-label="Breadcrumb" data-slot="breadcrumb" className={nmClass('nm-breadcrumb', className)} {...props} />;
8
+ }
9
+
10
+ export function NmBreadcrumbList({ className, ...props }: ComponentProps<'ol'>) {
11
+ return <ol data-slot="breadcrumb-list" className={nmClass('nm-breadcrumb__list', className)} {...props} />;
12
+ }
13
+
14
+ export function NmBreadcrumbItem({ className, ...props }: ComponentProps<'li'>) {
15
+ return <li data-slot="breadcrumb-item" className={nmClass('nm-breadcrumb__item', className)} {...props} />;
16
+ }
17
+
18
+ export function NmBreadcrumbLink({ className, ...props }: ComponentProps<'a'>) {
19
+ return <a data-slot="breadcrumb-link" className={nmClass('nm-breadcrumb__link', className)} {...props} />;
20
+ }
21
+
22
+ /** The current page. It is not a link. */
23
+ export function NmBreadcrumbPage({ className, ...props }: ComponentProps<'span'>) {
24
+ return <span aria-current="page" data-slot="breadcrumb-page" className={nmClass('nm-breadcrumb__page', className)} {...props} />;
25
+ }
26
+
27
+ export function NmBreadcrumbSeparator({ className, children, ...props }: ComponentProps<'li'>) {
28
+ return (
29
+ <li role="presentation" aria-hidden="true" data-slot="breadcrumb-separator" className={nmClass('nm-breadcrumb__separator', className)} {...props}>
30
+ {children ?? <NmIcon id="chevron" />}
31
+ </li>
32
+ );
33
+ }
34
+
35
+ /** Stands for the levels left out. Put it in a dropdown menu trigger to let people reach them. */
36
+ export function NmBreadcrumbEllipsis({ className, ...props }: ComponentProps<'span'>) {
37
+ return (
38
+ <span role="presentation" aria-hidden="true" data-slot="breadcrumb-ellipsis" className={nmClass('nm-breadcrumb__ellipsis', className)} {...props}>
39
+ <NmIcon id="ellipsis" />
40
+ </span>
41
+ );
42
+ }
@@ -0,0 +1,110 @@
1
+ .nm-button {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ gap: var(--control-gap);
6
+ box-sizing: border-box;
7
+ height: var(--control-h);
8
+ padding: 0 var(--control-px);
9
+ border: var(--nm-rule) solid transparent;
10
+ border-radius: var(--nm-control-r);
11
+ font-family: var(--nm-font);
12
+ font-size: var(--control-fs);
13
+ font-weight: var(--control-fw);
14
+ line-height: var(--nm-leading-none);
15
+ text-decoration: none;
16
+ white-space: nowrap;
17
+ cursor: pointer;
18
+ transition:
19
+ background 0.15s,
20
+ border-color 0.15s,
21
+ opacity 0.15s;
22
+ }
23
+
24
+ .nm-button--chip {
25
+ height: var(--control-h-sm);
26
+ font-size: var(--nm-type-ui-sm);
27
+ }
28
+
29
+ .nm-button--large {
30
+ height: var(--control-h-lg);
31
+ }
32
+
33
+ /* An icon alone is a square the height of the button. */
34
+ .nm-button--icon {
35
+ width: var(--control-h);
36
+ padding: 0;
37
+ }
38
+
39
+ .nm-button--icon.nm-button--chip {
40
+ width: var(--control-h-sm);
41
+ }
42
+
43
+ .nm-button--icon.nm-button--large {
44
+ width: var(--control-h-lg);
45
+ }
46
+
47
+ .nm-button--block {
48
+ width: 100%;
49
+ }
50
+
51
+ .nm-button--filled {
52
+ border-color: var(--nm-fg);
53
+ background: var(--nm-fg);
54
+ color: var(--nm-canvas);
55
+ }
56
+
57
+ .nm-button--outline {
58
+ border-color: var(--nm-line-strong);
59
+ background: var(--nm-raised);
60
+ color: var(--nm-fg);
61
+ }
62
+
63
+ .nm-button--muted {
64
+ border-color: transparent;
65
+ background: var(--nm-panel);
66
+ color: var(--nm-stroke);
67
+ }
68
+
69
+ .nm-button--panel {
70
+ border-color: var(--nm-line-strong);
71
+ background: var(--nm-panel);
72
+ color: var(--nm-fg);
73
+ }
74
+
75
+ .nm-button--danger {
76
+ border-color: transparent;
77
+ background: rgb(var(--nm-destructive-rgb) / 16%);
78
+ color: rgb(var(--nm-destructive-rgb));
79
+ }
80
+
81
+ .nm-button--filled:hover:not(:disabled),
82
+ .nm-button--danger:hover:not(:disabled) {
83
+ opacity: var(--btn-hover);
84
+ }
85
+
86
+ .nm-button--outline:hover:not(:disabled),
87
+ .nm-button--panel:hover:not(:disabled) {
88
+ background: var(--nm-panel);
89
+ }
90
+
91
+ .nm-button:focus-visible {
92
+ outline: 2px solid var(--focus);
93
+ outline-offset: 2px;
94
+ }
95
+
96
+ .nm-button:disabled {
97
+ opacity: var(--nm-soon-opacity);
98
+ cursor: default;
99
+ }
100
+
101
+ .nm-button:has(.nm-button__icon):not(:has(.nm-button__label)) {
102
+ width: var(--control-h);
103
+ padding: 0;
104
+ }
105
+
106
+ .nm-button__icon {
107
+ width: var(--nm-icon-button);
108
+ height: var(--nm-icon-button);
109
+ }
110
+
@@ -0,0 +1,58 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { NmIconId } from '../../config/nm-icons.ts';
3
+ import {
4
+ NM_BUTTON_CLASSES,
5
+ NM_BUTTON_SIZES,
6
+ NM_BUTTON_TONES,
7
+ type NmButtonSize,
8
+ type NmButtonTone,
9
+ } from '../../config/nm-button.ts';
10
+ import { createLogger } from '../../kit-logger.ts';
11
+ import { NmIcon } from '../nm-icon/nm-icon.tsx';
12
+
13
+ const logger = createLogger('interface-nm-button');
14
+
15
+ export type NmButtonProps = {
16
+ label: string;
17
+ tone: NmButtonTone;
18
+ size?: NmButtonSize;
19
+ block?: boolean;
20
+ type?: 'button' | 'submit';
21
+ disabled?: boolean;
22
+ pressed?: boolean;
23
+ icon?: NmIconId;
24
+ /** Shows the icon alone, in a square. The label is still its accessible name. */
25
+ iconOnly?: boolean;
26
+ testId?: string;
27
+ onClick?: () => void;
28
+ };
29
+
30
+ export function NmButton(props: NmButtonProps): ReactNode {
31
+ const size = props.size ?? NM_BUTTON_SIZES.default;
32
+ const className = [
33
+ NM_BUTTON_CLASSES.root,
34
+ NM_BUTTON_CLASSES[props.tone],
35
+ NM_BUTTON_CLASSES[size],
36
+ props.block ? NM_BUTTON_CLASSES.block : null,
37
+ props.iconOnly ? NM_BUTTON_CLASSES.icon : null,
38
+ ]
39
+ .filter(Boolean)
40
+ .join(' ');
41
+ logger.debug('render', props.label, { tone: props.tone, size });
42
+ return (
43
+ <button
44
+ className={className}
45
+ type={props.type ?? 'button'}
46
+ disabled={props.disabled}
47
+ aria-pressed={props.pressed}
48
+ aria-label={props.iconOnly ? props.label : undefined}
49
+ data-testid={props.testId}
50
+ onClick={props.onClick}
51
+ >
52
+ {props.icon ? <NmIcon id={props.icon} className="nm-button__icon" /> : null}
53
+ {props.iconOnly ? null : <span className="nm-button__label">{props.label}</span>}
54
+ </button>
55
+ );
56
+ }
57
+
58
+ export { NM_BUTTON_SIZES, NM_BUTTON_TONES };
@@ -0,0 +1,87 @@
1
+ .nm-button-group {
2
+ display: inline-flex;
3
+ align-items: stretch;
4
+ width: fit-content;
5
+ max-width: 100%;
6
+ }
7
+
8
+ .nm-button-group[data-orientation='vertical'] {
9
+ flex-direction: column;
10
+ }
11
+
12
+ /* Groups inside a group sit apart. */
13
+ .nm-button-group:has(> .nm-button-group) {
14
+ gap: var(--nm-space-8);
15
+ }
16
+
17
+ .nm-button-group > :not(.nm-button-group, .nm-button-group__separator) {
18
+ position: relative;
19
+ }
20
+
21
+ .nm-button-group > :not(.nm-button-group, .nm-button-group__separator):hover,
22
+ .nm-button-group > :not(.nm-button-group, .nm-button-group__separator):focus-within {
23
+ z-index: 1;
24
+ }
25
+
26
+ /* Neighbours share a border, and only the outer corners stay round. */
27
+ .nm-button-group[data-orientation='horizontal'] > :not(.nm-button-group, .nm-button-group__separator):not(:first-child) {
28
+ margin-inline-start: calc(var(--nm-rule) * -1);
29
+ border-start-start-radius: 0;
30
+ border-end-start-radius: 0;
31
+ }
32
+
33
+ .nm-button-group[data-orientation='horizontal'] > :not(.nm-button-group, .nm-button-group__separator):not(:last-child) {
34
+ border-start-end-radius: 0;
35
+ border-end-end-radius: 0;
36
+ }
37
+
38
+ .nm-button-group[data-orientation='vertical'] > :not(.nm-button-group, .nm-button-group__separator):not(:first-child) {
39
+ margin-block-start: calc(var(--nm-rule) * -1);
40
+ border-start-start-radius: 0;
41
+ border-start-end-radius: 0;
42
+ }
43
+
44
+ .nm-button-group[data-orientation='vertical'] > :not(.nm-button-group, .nm-button-group__separator):not(:last-child) {
45
+ border-end-start-radius: 0;
46
+ border-end-end-radius: 0;
47
+ }
48
+
49
+ .nm-button-group > .nm-button-group__separator + * {
50
+ margin-inline-start: 0;
51
+ margin-block-start: 0;
52
+ }
53
+
54
+ .nm-button-group > :is(.nm-input, .nm-input-group, .nm-combobox__group) {
55
+ flex: 1;
56
+ min-width: var(--nm-width-popup-sm);
57
+ }
58
+
59
+ .nm-button-group__separator {
60
+ flex-shrink: 0;
61
+ align-self: stretch;
62
+ background: var(--nm-line-strong);
63
+ }
64
+
65
+ .nm-button-group__separator[data-orientation='vertical'] {
66
+ width: var(--nm-rule);
67
+ }
68
+
69
+ .nm-button-group__separator[data-orientation='horizontal'] {
70
+ height: var(--nm-rule);
71
+ }
72
+
73
+ .nm-button-group__text {
74
+ box-sizing: border-box;
75
+ display: flex;
76
+ align-items: center;
77
+ gap: var(--nm-space-8);
78
+ min-height: var(--control-h);
79
+ padding: 0 var(--control-px);
80
+ border: var(--nm-rule) solid var(--nm-line-strong);
81
+ border-radius: var(--nm-control-r);
82
+ background: var(--nm-raised);
83
+ color: var(--nm-fg-muted);
84
+ font-family: var(--nm-font);
85
+ font-size: var(--control-fs);
86
+ white-space: nowrap;
87
+ }
@@ -0,0 +1,32 @@
1
+ import { cloneElement, type ComponentProps, type ReactElement } from 'react';
2
+ import { nmClass } from '../../lib/nm-class.ts';
3
+ import { NmSeparator } from '../nm-separator/nm-separator.tsx';
4
+
5
+ /**
6
+ * Joins buttons, and the controls that sit beside them, into one bar. Neighbours share a border and only the outer
7
+ * corners stay round. Nest groups to set sets of buttons apart. The shadcn Button Group composition, styled by NIF tokens.
8
+ */
9
+ export function NmButtonGroup({
10
+ className,
11
+ orientation = 'horizontal',
12
+ ...props
13
+ }: ComponentProps<'div'> & { orientation?: 'horizontal' | 'vertical' }) {
14
+ return <div role="group" data-slot="button-group" data-orientation={orientation} className={nmClass('nm-button-group', className)} {...props} />;
15
+ }
16
+
17
+ /** A line between buttons that have no border of their own. Outline buttons do not need one. */
18
+ export function NmButtonGroupSeparator({ className, orientation = 'vertical', ...props }: ComponentProps<typeof NmSeparator>) {
19
+ return <NmSeparator data-slot="button-group-separator" orientation={orientation} className={nmClass('nm-button-group__separator', className as string)} {...props} />;
20
+ }
21
+
22
+ /** Text in the bar, set like a button. Give `render` an element, such as a Label, to draw the text with it. */
23
+ export function NmButtonGroupText({ className, render, children, ...props }: ComponentProps<'div'> & { render?: ReactElement<{ className?: string }> }) {
24
+ const classes = nmClass('nm-button-group__text', className);
25
+ return render ? (
26
+ cloneElement(render, { className: nmClass(classes, render.props.className), ...props } as object, children)
27
+ ) : (
28
+ <div data-slot="button-group-text" className={classes} {...props}>
29
+ {children}
30
+ </div>
31
+ );
32
+ }
@@ -0,0 +1,178 @@
1
+ .nm-calendar__root {
2
+ position: relative;
3
+ font-family: var(--nm-font);
4
+ font-size: var(--nm-type-ui);
5
+ color: var(--nm-fg);
6
+ }
7
+
8
+ .nm-calendar__months {
9
+ display: flex;
10
+ gap: var(--nm-space-16);
11
+ }
12
+
13
+ .nm-calendar__month {
14
+ display: flex;
15
+ flex-direction: column;
16
+ gap: var(--nm-space-8);
17
+ }
18
+
19
+ .nm-calendar__nav {
20
+ position: absolute;
21
+ top: 0;
22
+ right: 0;
23
+ left: 0;
24
+ display: flex;
25
+ align-items: center;
26
+ justify-content: space-between;
27
+ height: var(--control-h);
28
+ pointer-events: none;
29
+ }
30
+
31
+ .nm-calendar__nav-button {
32
+ display: inline-flex;
33
+ align-items: center;
34
+ justify-content: center;
35
+ width: var(--control-h);
36
+ height: var(--control-h);
37
+ padding: 0;
38
+ border: 0;
39
+ border-radius: var(--nm-control-r);
40
+ background: transparent;
41
+ color: var(--nm-fg-muted);
42
+ cursor: pointer;
43
+ pointer-events: auto;
44
+ }
45
+
46
+ .nm-calendar__nav-button:hover:not(:disabled),
47
+ .nm-calendar__nav-button:focus-visible {
48
+ background: var(--nm-inset);
49
+ color: var(--nm-fg);
50
+ outline: none;
51
+ }
52
+
53
+ .nm-calendar__nav-button:disabled {
54
+ opacity: 0.4;
55
+ cursor: default;
56
+ }
57
+
58
+ .nm-calendar__chevron--left {
59
+ transform: rotate(90deg);
60
+ }
61
+
62
+ .nm-calendar__chevron--right {
63
+ transform: rotate(-90deg);
64
+ }
65
+
66
+ .nm-calendar__chevron--up {
67
+ transform: rotate(180deg);
68
+ }
69
+
70
+ .nm-calendar__caption {
71
+ display: flex;
72
+ align-items: center;
73
+ justify-content: center;
74
+ height: var(--control-h);
75
+ }
76
+
77
+ .nm-calendar__caption-label {
78
+ font-weight: var(--nm-weight-medium);
79
+ }
80
+
81
+ .nm-calendar__grid {
82
+ border-collapse: collapse;
83
+ }
84
+
85
+ .nm-calendar__weekdays,
86
+ .nm-calendar__week {
87
+ height: var(--control-h);
88
+ }
89
+
90
+ .nm-calendar__weekday {
91
+ width: var(--control-h);
92
+ height: var(--control-h);
93
+ padding: 0;
94
+ color: var(--nm-fg-subtle);
95
+ font-size: var(--nm-type-ui-sm);
96
+ font-weight: var(--nm-weight-regular);
97
+ text-align: center;
98
+ }
99
+
100
+ .nm-calendar__day {
101
+ width: var(--control-h);
102
+ height: var(--control-h);
103
+ padding: 0;
104
+ text-align: center;
105
+ }
106
+
107
+ .nm-calendar__day-button {
108
+ width: 100%;
109
+ height: 100%;
110
+ padding: 0;
111
+ border: var(--nm-rule) solid transparent;
112
+ border-radius: var(--nm-control-r);
113
+ background: transparent;
114
+ color: inherit;
115
+ font: inherit;
116
+ cursor: pointer;
117
+ }
118
+
119
+ .nm-calendar__day-button:hover {
120
+ background: var(--nm-inset);
121
+ }
122
+
123
+ .nm-calendar__day-button:focus-visible {
124
+ outline: var(--nm-rule) solid var(--focus);
125
+ outline-offset: calc(var(--nm-space-2) * -1);
126
+ }
127
+
128
+ .nm-calendar__day--today .nm-calendar__day-button {
129
+ border-color: var(--nm-stroke);
130
+ }
131
+
132
+ .nm-calendar__day--outside .nm-calendar__day-button {
133
+ color: var(--nm-fg-subtle);
134
+ }
135
+
136
+ .nm-calendar__day--disabled .nm-calendar__day-button {
137
+ cursor: not-allowed;
138
+ opacity: 0.4;
139
+ }
140
+
141
+ .nm-calendar__day--hidden {
142
+ visibility: hidden;
143
+ }
144
+
145
+ .nm-calendar__day--selected .nm-calendar__day-button {
146
+ border-color: var(--nm-fg);
147
+ background: var(--nm-fg);
148
+ color: var(--nm-canvas);
149
+ font-weight: var(--nm-weight-medium);
150
+ }
151
+
152
+ .nm-calendar__day--range-middle {
153
+ background: var(--nm-panel);
154
+ }
155
+
156
+ .nm-calendar__day--range-middle .nm-calendar__day-button {
157
+ border-color: transparent;
158
+ background: transparent;
159
+ color: var(--nm-fg);
160
+ font-weight: var(--nm-weight-regular);
161
+ }
162
+
163
+ .nm-calendar__day--range-start,
164
+ .nm-calendar__day--range-end {
165
+ background: var(--nm-panel);
166
+ }
167
+
168
+ .nm-calendar__day--range-start {
169
+ border-radius: var(--nm-control-r) 0 0 var(--nm-control-r);
170
+ }
171
+
172
+ .nm-calendar__day--range-end {
173
+ border-radius: 0 var(--nm-control-r) var(--nm-control-r) 0;
174
+ }
175
+
176
+ .nm-calendar__day--range-start.nm-calendar__day--range-end {
177
+ border-radius: var(--nm-control-r);
178
+ }