@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.
- package/README.md +18 -0
- package/bin/nif.mjs +196 -0
- package/dist/index.d.ts +30 -1
- package/dist/index.js +9661 -2499
- package/dist/styles.css +1 -1
- package/dist/tokens.css +4 -1
- package/dist/ui/components/nm-ai/nm-ai.d.ts +7 -7
- package/dist/ui/components/nm-brand-logo/nm-brand-logo.d.ts +10 -0
- package/dist/ui/components/nm-breadcrumb/nm-breadcrumb.d.ts +11 -0
- package/dist/ui/components/nm-button/nm-button.d.ts +2 -0
- package/dist/ui/components/nm-button-group/nm-button-group.d.ts +17 -0
- package/dist/ui/components/nm-calendar/nm-calendar.d.ts +3 -0
- package/dist/ui/components/nm-card/nm-card.d.ts +34 -0
- package/dist/ui/components/nm-chip/nm-chip.d.ts +38 -0
- package/dist/ui/components/nm-code-block/nm-code-block.d.ts +55 -0
- package/dist/ui/components/nm-color-picker/nm-color-picker.d.ts +15 -0
- package/dist/ui/components/nm-combobox/nm-combobox.d.ts +26 -0
- package/dist/ui/components/nm-command/nm-command.d.ts +37 -0
- package/dist/ui/components/nm-composer/nm-composer.d.ts +4 -0
- package/dist/ui/components/nm-context-menu/nm-context-menu.d.ts +9 -0
- package/dist/ui/components/nm-date-picker/nm-date-picker.d.ts +35 -0
- package/dist/ui/components/nm-dialog/nm-dialog.d.ts +13 -0
- package/dist/ui/components/nm-field/nm-field.d.ts +2 -0
- package/dist/ui/components/nm-form-field/nm-form-field.d.ts +18 -0
- package/dist/ui/components/nm-gallery/nm-gallery.d.ts +8 -0
- package/dist/ui/components/nm-input/nm-input.d.ts +5 -0
- package/dist/ui/components/nm-input-group/nm-input-group.d.ts +9 -0
- package/dist/ui/components/nm-label/nm-label.d.ts +2 -0
- package/dist/ui/components/nm-menubar/nm-menubar.d.ts +9 -0
- package/dist/ui/components/nm-native-select/nm-native-select.d.ts +5 -0
- package/dist/ui/components/nm-panel/nm-panel.d.ts +14 -0
- package/dist/ui/components/nm-prose/nm-prose.d.ts +6 -0
- package/dist/ui/components/nm-resize-handle/nm-resize-handle.d.ts +18 -0
- package/dist/ui/components/nm-select/nm-select.d.ts +22 -0
- package/dist/ui/components/nm-side-panel/nm-side-panel.d.ts +33 -0
- package/dist/ui/components/nm-slider/nm-slider.d.ts +5 -1
- package/dist/ui/components/nm-status-bar/nm-status-bar.d.ts +8 -0
- package/dist/ui/components/nm-table/nm-table.d.ts +38 -0
- package/dist/ui/components/nm-textarea/nm-textarea.d.ts +2 -0
- package/dist/ui/components/nm-toolbar/nm-toolbar.d.ts +21 -0
- package/dist/ui/config/nm-ai.d.ts +0 -3
- package/dist/ui/config/nm-appearance.d.ts +36 -1
- package/dist/ui/config/nm-button.d.ts +2 -1
- package/dist/ui/config/nm-composer.d.ts +1 -2
- package/dist/ui/config/nm-field.d.ts +2 -0
- package/dist/ui/config/nm-icons.d.ts +13 -1
- package/dist/ui/config/nm-radius.d.ts +4 -4
- package/dist/ui/config/nm-side-panel.d.ts +33 -0
- package/dist/ui/lib/appearance/appearanceState.d.ts +1 -0
- package/dist/ui/lib/appearance/deriveTokens.d.ts +2 -0
- package/package.json +12 -4
- package/registry/index.json +1634 -0
- package/registry/tokens.css +72 -0
- package/registry/ui/components/nm-ai/nm-ai.css +358 -0
- package/registry/ui/components/nm-ai/nm-ai.tsx +632 -0
- package/registry/ui/components/nm-app-panel/nm-app-panel.css +169 -0
- package/registry/ui/components/nm-ask/nm-ask.css +277 -0
- package/registry/ui/components/nm-avatar/nm-avatar.css +85 -0
- package/registry/ui/components/nm-avatar/nm-avatar.tsx +30 -0
- package/registry/ui/components/nm-bar-overflow/nm-bar-overflow.css +43 -0
- package/registry/ui/components/nm-bar-overflow/nm-bar-overflow.tsx +61 -0
- package/registry/ui/components/nm-bar-overflow/use-bar-overflow.ts +92 -0
- package/registry/ui/components/nm-brand-logo/nm-brand-logo.css +20 -0
- package/registry/ui/components/nm-brand-logo/nm-brand-logo.tsx +21 -0
- package/registry/ui/components/nm-breadcrumb/nm-breadcrumb.css +57 -0
- package/registry/ui/components/nm-breadcrumb/nm-breadcrumb.tsx +42 -0
- package/registry/ui/components/nm-button/nm-button.css +110 -0
- package/registry/ui/components/nm-button/nm-button.tsx +58 -0
- package/registry/ui/components/nm-button-group/nm-button-group.css +87 -0
- package/registry/ui/components/nm-button-group/nm-button-group.tsx +32 -0
- package/registry/ui/components/nm-calendar/nm-calendar.css +178 -0
- package/registry/ui/components/nm-calendar/nm-calendar.tsx +43 -0
- package/registry/ui/components/nm-card/nm-card.css +130 -0
- package/registry/ui/components/nm-card/nm-card.tsx +83 -0
- package/registry/ui/components/nm-chatbox/nm-chatbox-icon.tsx +39 -0
- package/registry/ui/components/nm-chatbox/nm-chatbox.css +682 -0
- package/registry/ui/components/nm-chatbox/nm-chatbox.tsx +101 -0
- package/registry/ui/components/nm-checkbox/nm-checkbox.css +61 -0
- package/registry/ui/components/nm-checkbox/nm-checkbox.tsx +14 -0
- package/registry/ui/components/nm-chip/nm-chip.css +112 -0
- package/registry/ui/components/nm-chip/nm-chip.tsx +86 -0
- package/registry/ui/components/nm-code-block/nm-code-block.css +240 -0
- package/registry/ui/components/nm-code-block/nm-code-block.tsx +196 -0
- package/registry/ui/components/nm-collection/nm-collection-bar.tsx +65 -0
- package/registry/ui/components/nm-collection/nm-collection-grid.tsx +69 -0
- package/registry/ui/components/nm-collection/nm-collection-query.tsx +99 -0
- package/registry/ui/components/nm-collection/nm-collection-row-menu.tsx +55 -0
- package/registry/ui/components/nm-collection/nm-collection-table.tsx +99 -0
- package/registry/ui/components/nm-collection/nm-collection-tile-actions.tsx +50 -0
- package/registry/ui/components/nm-collection/nm-collection-title.tsx +25 -0
- package/registry/ui/components/nm-collection/nm-collection.css +353 -0
- package/registry/ui/components/nm-collection/use-collection-scroll-reveal.ts +38 -0
- package/registry/ui/components/nm-color-picker/nm-color-picker.css +67 -0
- package/registry/ui/components/nm-color-picker/nm-color-picker.tsx +79 -0
- package/registry/ui/components/nm-combobox/nm-combobox.css +72 -0
- package/registry/ui/components/nm-combobox/nm-combobox.tsx +80 -0
- package/registry/ui/components/nm-command/nm-command.css +190 -0
- package/registry/ui/components/nm-command/nm-command.tsx +125 -0
- package/registry/ui/components/nm-composer/nm-composer.css +178 -0
- package/registry/ui/components/nm-composer/nm-composer.tsx +151 -0
- package/registry/ui/components/nm-context-menu/nm-context-menu.tsx +25 -0
- package/registry/ui/components/nm-date-picker/nm-date-picker.css +140 -0
- package/registry/ui/components/nm-date-picker/nm-date-picker.tsx +153 -0
- package/registry/ui/components/nm-dialog/nm-dialog.css +84 -0
- package/registry/ui/components/nm-dialog/nm-dialog.tsx +40 -0
- package/registry/ui/components/nm-dropdown/nm-dropdown-item.ts +68 -0
- package/registry/ui/components/nm-dropdown/nm-dropdown-options.tsx +242 -0
- package/registry/ui/components/nm-dropdown/nm-dropdown-panel.tsx +171 -0
- package/registry/ui/components/nm-dropdown/nm-dropdown-placement.ts +157 -0
- package/registry/ui/components/nm-dropdown/nm-dropdown.css +312 -0
- package/registry/ui/components/nm-dropdown/nm-dropdown.tsx +412 -0
- package/registry/ui/components/nm-dropdown-menu/nm-dropdown-menu.css +145 -0
- package/registry/ui/components/nm-dropdown-menu/nm-dropdown-menu.tsx +118 -0
- package/registry/ui/components/nm-field/nm-field.css +356 -0
- package/registry/ui/components/nm-field/nm-field.tsx +355 -0
- package/registry/ui/components/nm-form-field/nm-form-field.css +103 -0
- package/registry/ui/components/nm-form-field/nm-form-field.tsx +71 -0
- package/registry/ui/components/nm-gallery/nm-gallery.css +66 -0
- package/registry/ui/components/nm-gallery/nm-gallery.tsx +31 -0
- package/registry/ui/components/nm-hover-card/nm-hover-card.css +26 -0
- package/registry/ui/components/nm-hover-card/nm-hover-card.tsx +28 -0
- package/registry/ui/components/nm-icon/nm-icon.css +6 -0
- package/registry/ui/components/nm-icon/nm-icon.tsx +69 -0
- package/registry/ui/components/nm-icon/nm-lucide.tsx +180 -0
- package/registry/ui/components/nm-icon-border/nm-icon-border.tsx +56 -0
- package/registry/ui/components/nm-input/nm-input.css +75 -0
- package/registry/ui/components/nm-input/nm-input.tsx +7 -0
- package/registry/ui/components/nm-input-group/nm-input-group.css +66 -0
- package/registry/ui/components/nm-input-group/nm-input-group.tsx +20 -0
- package/registry/ui/components/nm-label/nm-label.css +11 -0
- package/registry/ui/components/nm-label/nm-label.tsx +6 -0
- package/registry/ui/components/nm-list-item/nm-list-item.css +177 -0
- package/registry/ui/components/nm-list-item/nm-list-item.tsx +112 -0
- package/registry/ui/components/nm-menubar/nm-menubar.css +32 -0
- package/registry/ui/components/nm-menubar/nm-menubar.tsx +19 -0
- package/registry/ui/components/nm-message/nm-message-actions.tsx +24 -0
- package/registry/ui/components/nm-message/nm-message-meta.tsx +49 -0
- package/registry/ui/components/nm-message/nm-message.css +686 -0
- package/registry/ui/components/nm-message/nm-text-shimmer.tsx +6 -0
- package/registry/ui/components/nm-message/nm-trace.tsx +219 -0
- package/registry/ui/components/nm-modal/nm-modal.css +763 -0
- package/registry/ui/components/nm-modal/nm-modal.tsx +497 -0
- package/registry/ui/components/nm-native-select/nm-native-select.css +47 -0
- package/registry/ui/components/nm-native-select/nm-native-select.tsx +23 -0
- package/registry/ui/components/nm-panel/nm-panel.css +73 -0
- package/registry/ui/components/nm-panel/nm-panel.tsx +35 -0
- package/registry/ui/components/nm-panel-bar/nm-panel-bar.css +20 -0
- package/registry/ui/components/nm-panel-bar/nm-panel-bar.tsx +48 -0
- package/registry/ui/components/nm-popover/nm-popover.css +43 -0
- package/registry/ui/components/nm-popover/nm-popover.tsx +40 -0
- package/registry/ui/components/nm-progress/nm-progress.css +21 -0
- package/registry/ui/components/nm-progress/nm-progress.tsx +14 -0
- package/registry/ui/components/nm-prose/nm-prose.css +81 -0
- package/registry/ui/components/nm-prose/nm-prose.tsx +10 -0
- package/registry/ui/components/nm-questionnaire/nm-questionnaire.css +182 -0
- package/registry/ui/components/nm-questionnaire/nm-questionnaire.tsx +221 -0
- package/registry/ui/components/nm-radio-group/nm-radio-group.css +48 -0
- package/registry/ui/components/nm-radio-group/nm-radio-group.tsx +15 -0
- package/registry/ui/components/nm-rail-icon/nm-rail-icon.css +6 -0
- package/registry/ui/components/nm-rail-icon/nm-rail-icon.tsx +28 -0
- package/registry/ui/components/nm-resize-handle/nm-resize-handle.css +45 -0
- package/registry/ui/components/nm-resize-handle/nm-resize-handle.tsx +102 -0
- package/registry/ui/components/nm-segmented/nm-segmented.css +104 -0
- package/registry/ui/components/nm-segmented/nm-segmented.tsx +77 -0
- package/registry/ui/components/nm-select/nm-select.css +78 -0
- package/registry/ui/components/nm-select/nm-select.tsx +64 -0
- package/registry/ui/components/nm-separator/nm-separator.css +14 -0
- package/registry/ui/components/nm-separator/nm-separator.tsx +6 -0
- package/registry/ui/components/nm-side-panel/nm-side-panel.css +93 -0
- package/registry/ui/components/nm-side-panel/nm-side-panel.tsx +86 -0
- package/registry/ui/components/nm-slider/nm-slider.css +53 -0
- package/registry/ui/components/nm-slider/nm-slider.tsx +40 -0
- package/registry/ui/components/nm-small-icon-button/nm-small-icon-button.tsx +66 -0
- package/registry/ui/components/nm-status-bar/nm-status-bar.css +50 -0
- package/registry/ui/components/nm-status-bar/nm-status-bar.tsx +28 -0
- package/registry/ui/components/nm-switch/nm-switch.css +45 -0
- package/registry/ui/components/nm-switch/nm-switch.tsx +10 -0
- package/registry/ui/components/nm-table/nm-table.css +155 -0
- package/registry/ui/components/nm-table/nm-table.tsx +95 -0
- package/registry/ui/components/nm-tabs/nm-tabs.css +28 -0
- package/registry/ui/components/nm-tabs/nm-tabs.tsx +32 -0
- package/registry/ui/components/nm-textarea/nm-textarea.css +41 -0
- package/registry/ui/components/nm-textarea/nm-textarea.tsx +6 -0
- package/registry/ui/components/nm-toggle/nm-toggle.css +55 -0
- package/registry/ui/components/nm-toggle/nm-toggle.tsx +16 -0
- package/registry/ui/components/nm-toolbar/nm-toolbar.css +42 -0
- package/registry/ui/components/nm-toolbar/nm-toolbar.tsx +54 -0
- package/registry/ui/components/nm-tooltip/nm-tooltip.css +37 -0
- package/registry/ui/components/nm-tooltip/nm-tooltip.tsx +35 -0
- package/registry/ui/components/nm-top-bar/nm-top-bar.css +29 -0
- package/registry/ui/components/nm-top-bar/nm-top-bar.tsx +34 -0
- package/registry/ui/components/nordman-icon-button/nordman-icon-button.css +119 -0
- package/registry/ui/components/nordman-icon-button/nordman-icon-button.tsx +185 -0
- package/registry/ui/components/nordman-login/nordman-login.css +195 -0
- package/registry/ui/components/nordman-login/nordman-login.tsx +136 -0
- package/registry/ui/components/nordman-login-field/nordman-login-field.tsx +55 -0
- package/registry/ui/components/nordman-login-forgot/nordman-login-forgot.tsx +56 -0
- package/registry/ui/components/nordman-login-google/nordman-login-google.tsx +28 -0
- package/registry/ui/components/nordman-login-hero/nordman-login-hero.tsx +38 -0
- package/registry/ui/components/nordman-login-register/nordman-login-register.tsx +70 -0
- package/registry/ui/components/nordman-login-reset/nordman-login-reset.tsx +71 -0
- package/registry/ui/components/nordman-login-reveal/nordman-login-reveal.tsx +41 -0
- package/registry/ui/components/nordman-login-sign-in/nordman-login-sign-in.tsx +69 -0
- package/registry/ui/components/nordman-toggle/nordman-toggle.css +28 -0
- package/registry/ui/components/nordman-toggle/nordman-toggle.tsx +35 -0
- package/registry/ui/config/nm-ai.ts +59 -0
- package/registry/ui/config/nm-appearance.ts +275 -0
- package/registry/ui/config/nm-bar-overflow.ts +10 -0
- package/registry/ui/config/nm-button.ts +38 -0
- package/registry/ui/config/nm-chatbox-icons.ts +67 -0
- package/registry/ui/config/nm-chatbox.ts +42 -0
- package/registry/ui/config/nm-collection.ts +101 -0
- package/registry/ui/config/nm-composer.ts +39 -0
- package/registry/ui/config/nm-dropdown.ts +62 -0
- package/registry/ui/config/nm-field.ts +43 -0
- package/registry/ui/config/nm-icon-button.ts +35 -0
- package/registry/ui/config/nm-icons.ts +417 -0
- package/registry/ui/config/nm-list-item.ts +14 -0
- package/registry/ui/config/nm-message.ts +106 -0
- package/registry/ui/config/nm-modal.ts +76 -0
- package/registry/ui/config/nm-panel-bar.ts +11 -0
- package/registry/ui/config/nm-questionnaire.ts +53 -0
- package/registry/ui/config/nm-radius.ts +56 -0
- package/registry/ui/config/nm-rail-icons.ts +27 -0
- package/registry/ui/config/nm-segmented.ts +19 -0
- package/registry/ui/config/nm-side-panel.ts +16 -0
- package/registry/ui/config/nm-site-palette.ts +30 -0
- package/registry/ui/config/nm-small-icon-button.ts +17 -0
- package/registry/ui/config/nm-tabs.ts +9 -0
- package/registry/ui/config/nm-top-bar.ts +4 -0
- package/registry/ui/config/nordman-chrome.ts +14 -0
- package/registry/ui/config/nordman-login.ts +28 -0
- package/registry/ui/content/nm-modal.ts +5 -0
- package/registry/ui/content/nordman-login.ts +85 -0
- package/registry/ui/kit-logger.ts +1 -0
- package/registry/ui/lib/appearance/appearanceState.ts +240 -0
- package/registry/ui/lib/appearance/applyAppearance.ts +36 -0
- package/registry/ui/lib/appearance/cloudOrbAppearance.ts +36 -0
- package/registry/ui/lib/appearance/color.ts +96 -0
- package/registry/ui/lib/appearance/deriveTokens.ts +218 -0
- package/registry/ui/lib/appearance/index.ts +6 -0
- package/registry/ui/lib/appearance/markTokens.ts +49 -0
- package/registry/ui/lib/appearance/readLayoutMetrics.ts +28 -0
- package/registry/ui/lib/bar-overflow.ts +41 -0
- package/registry/ui/lib/logger.ts +53 -0
- package/registry/ui/lib/menu-motion.ts +187 -0
- package/registry/ui/lib/nm-class.ts +4 -0
- package/registry/ui/lib/nordman-ui-locale.ts +43 -0
- package/registry/ui/styles/interface-theme.css +196 -0
- package/registry/ui/styles/light-appearance.css +72 -0
- package/registry/ui/styles/tokens.css +424 -0
- package/registry/ui/styles/utilities.css +12 -0
- package/dist/ui/components/nm-accordion/nm-accordion.d.ts +0 -6
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
.nm-picker__trigger {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: var(--nm-space-8);
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
width: 100%;
|
|
7
|
+
min-width: var(--nm-width-date);
|
|
8
|
+
height: var(--nm-field-h);
|
|
9
|
+
padding: 0 var(--control-px);
|
|
10
|
+
border: var(--nm-rule) solid var(--nm-line-strong);
|
|
11
|
+
border-radius: var(--nm-control-r);
|
|
12
|
+
background: var(--nm-raised);
|
|
13
|
+
color: var(--nm-fg);
|
|
14
|
+
font-family: var(--nm-font);
|
|
15
|
+
font-size: var(--control-fs);
|
|
16
|
+
text-align: left;
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
transition: border-color 0.15s;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.nm-picker__trigger[data-empty] {
|
|
22
|
+
color: var(--nm-fg-subtle);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.nm-picker__trigger > .nm-icon {
|
|
26
|
+
flex-shrink: 0;
|
|
27
|
+
color: var(--nm-fg-subtle);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.nm-picker__trigger:hover:not(:disabled) {
|
|
31
|
+
border-color: var(--nm-stroke);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.nm-picker__trigger:focus-visible,
|
|
35
|
+
.nm-picker__trigger[data-popup-open] {
|
|
36
|
+
border-color: var(--nm-fg);
|
|
37
|
+
outline: none;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.nm-picker__trigger:disabled {
|
|
41
|
+
cursor: not-allowed;
|
|
42
|
+
opacity: 0.5;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.nm-picker__trigger[aria-invalid='true'] {
|
|
46
|
+
border-color: var(--nm-destructive);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* The popup is the popover, sized to its content. */
|
|
50
|
+
.nm-picker__popup {
|
|
51
|
+
width: auto;
|
|
52
|
+
padding: var(--nm-space-12);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.nm-picker__popup--row {
|
|
56
|
+
flex-direction: row;
|
|
57
|
+
gap: var(--nm-space-16);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.nm-picker__time {
|
|
61
|
+
display: flex;
|
|
62
|
+
gap: var(--nm-space-8);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.nm-picker__column {
|
|
66
|
+
display: flex;
|
|
67
|
+
flex-direction: column;
|
|
68
|
+
gap: var(--nm-space-2);
|
|
69
|
+
max-height: var(--nm-height-picker);
|
|
70
|
+
overflow-y: auto;
|
|
71
|
+
scrollbar-width: none;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.nm-picker__option {
|
|
75
|
+
min-width: var(--control-h-lg);
|
|
76
|
+
height: var(--control-h);
|
|
77
|
+
padding: 0 var(--nm-space-8);
|
|
78
|
+
border: 0;
|
|
79
|
+
border-radius: var(--nm-control-r);
|
|
80
|
+
background: transparent;
|
|
81
|
+
color: var(--nm-fg);
|
|
82
|
+
font: inherit;
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.nm-picker__option:hover {
|
|
87
|
+
background: var(--nm-inset);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.nm-picker__option:focus-visible {
|
|
91
|
+
outline: var(--nm-rule) solid var(--focus);
|
|
92
|
+
outline-offset: calc(var(--nm-space-2) * -1);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.nm-picker__option[aria-selected='true'],
|
|
96
|
+
.nm-picker__option[aria-pressed='true'] {
|
|
97
|
+
background: var(--nm-fg);
|
|
98
|
+
color: var(--nm-canvas);
|
|
99
|
+
font-weight: var(--nm-weight-medium);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.nm-picker__months {
|
|
103
|
+
display: flex;
|
|
104
|
+
flex-direction: column;
|
|
105
|
+
gap: var(--nm-space-8);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.nm-picker__year {
|
|
109
|
+
display: flex;
|
|
110
|
+
align-items: center;
|
|
111
|
+
justify-content: space-between;
|
|
112
|
+
font-weight: var(--nm-weight-medium);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.nm-picker__step {
|
|
116
|
+
display: inline-flex;
|
|
117
|
+
align-items: center;
|
|
118
|
+
justify-content: center;
|
|
119
|
+
width: var(--control-h);
|
|
120
|
+
height: var(--control-h);
|
|
121
|
+
padding: 0;
|
|
122
|
+
border: 0;
|
|
123
|
+
border-radius: var(--nm-control-r);
|
|
124
|
+
background: transparent;
|
|
125
|
+
color: var(--nm-fg-muted);
|
|
126
|
+
cursor: pointer;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.nm-picker__step:hover,
|
|
130
|
+
.nm-picker__step:focus-visible {
|
|
131
|
+
background: var(--nm-inset);
|
|
132
|
+
color: var(--nm-fg);
|
|
133
|
+
outline: none;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.nm-picker__month-grid {
|
|
137
|
+
display: grid;
|
|
138
|
+
grid-template-columns: repeat(4, 1fr);
|
|
139
|
+
gap: var(--nm-space-4);
|
|
140
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { useState, type ReactNode } from 'react';
|
|
2
|
+
import type { DateRange } from 'react-day-picker';
|
|
3
|
+
import { NmCalendar } from '../nm-calendar/nm-calendar.tsx';
|
|
4
|
+
import { NmIcon } from '../nm-icon/nm-icon.tsx';
|
|
5
|
+
import { NmPopover, NmPopoverContent, NmPopoverTrigger } from '../nm-popover/nm-popover.tsx';
|
|
6
|
+
|
|
7
|
+
const dateText = (d: Date) => d.toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' });
|
|
8
|
+
const pad = (n: number) => String(n).padStart(2, '0');
|
|
9
|
+
|
|
10
|
+
type TriggerProps = { icon: 'calendar' | 'clock'; text: string | null; placeholder: string; invalid?: boolean; disabled?: boolean; label?: string };
|
|
11
|
+
|
|
12
|
+
function PickerTrigger(props: TriggerProps): ReactNode {
|
|
13
|
+
return (
|
|
14
|
+
<NmPopoverTrigger
|
|
15
|
+
className="nm-picker__trigger"
|
|
16
|
+
disabled={props.disabled}
|
|
17
|
+
aria-invalid={props.invalid ? true : undefined}
|
|
18
|
+
aria-label={props.label}
|
|
19
|
+
data-empty={props.text == null ? '' : undefined}
|
|
20
|
+
>
|
|
21
|
+
<NmIcon id={props.icon} />
|
|
22
|
+
<span>{props.text ?? props.placeholder}</span>
|
|
23
|
+
</NmPopoverTrigger>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type Common = { placeholder?: string; invalid?: boolean; disabled?: boolean; label?: string; className?: string };
|
|
28
|
+
|
|
29
|
+
/** A date field. The calendar opens in a popover, so it follows the theme as everything else does. */
|
|
30
|
+
export function NmDatePicker({ value, onValueChange, placeholder = 'Pick a date', ...rest }: Common & { value?: Date; onValueChange?: (date: Date | undefined) => void }) {
|
|
31
|
+
const [open, setOpen] = useState(false);
|
|
32
|
+
return (
|
|
33
|
+
<NmPopover open={open} onOpenChange={setOpen}>
|
|
34
|
+
<PickerTrigger icon="calendar" text={value ? dateText(value) : null} placeholder={placeholder} {...rest} />
|
|
35
|
+
<NmPopoverContent className="nm-picker__popup" align="start">
|
|
36
|
+
<NmCalendar
|
|
37
|
+
mode="single"
|
|
38
|
+
selected={value}
|
|
39
|
+
onSelect={(next) => {
|
|
40
|
+
onValueChange?.(next);
|
|
41
|
+
setOpen(false);
|
|
42
|
+
}}
|
|
43
|
+
defaultMonth={value}
|
|
44
|
+
/>
|
|
45
|
+
</NmPopoverContent>
|
|
46
|
+
</NmPopover>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function NmDateRangePicker({ value, onValueChange, placeholder = 'Pick a range', ...rest }: Common & { value?: DateRange; onValueChange?: (range: DateRange | undefined) => void }) {
|
|
51
|
+
const text = value?.from ? `${dateText(value.from)}${value.to ? ` – ${dateText(value.to)}` : ''}` : null;
|
|
52
|
+
return (
|
|
53
|
+
<NmPopover>
|
|
54
|
+
<PickerTrigger icon="calendar" text={text} placeholder={placeholder} {...rest} />
|
|
55
|
+
<NmPopoverContent className="nm-picker__popup" align="start">
|
|
56
|
+
<NmCalendar mode="range" numberOfMonths={2} selected={value} onSelect={onValueChange} defaultMonth={value?.from} />
|
|
57
|
+
</NmPopoverContent>
|
|
58
|
+
</NmPopover>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** A month field. Value is `YYYY-MM`. */
|
|
63
|
+
export function NmMonthPicker({ value, onValueChange, placeholder = 'Pick a month', ...rest }: Common & { value?: string; onValueChange?: (month: string) => void }) {
|
|
64
|
+
const [open, setOpen] = useState(false);
|
|
65
|
+
const now = new Date();
|
|
66
|
+
const [year, setYear] = useState(value ? Number(value.slice(0, 4)) : now.getFullYear());
|
|
67
|
+
const selected = value ? { y: Number(value.slice(0, 4)), m: Number(value.slice(5, 7)) } : null;
|
|
68
|
+
const names = Array.from({ length: 12 }, (_, i) => new Date(2000, i, 1).toLocaleDateString(undefined, { month: 'short' }));
|
|
69
|
+
const text = selected ? new Date(selected.y, selected.m - 1, 1).toLocaleDateString(undefined, { year: 'numeric', month: 'long' }) : null;
|
|
70
|
+
return (
|
|
71
|
+
<NmPopover open={open} onOpenChange={setOpen}>
|
|
72
|
+
<PickerTrigger icon="calendar" text={text} placeholder={placeholder} {...rest} />
|
|
73
|
+
<NmPopoverContent className="nm-picker__popup" align="start">
|
|
74
|
+
<div className="nm-picker__months">
|
|
75
|
+
<div className="nm-picker__year">
|
|
76
|
+
<button type="button" className="nm-picker__step" aria-label="Previous year" onClick={() => setYear(year - 1)}><NmIcon id="chevron" className="nm-calendar__chevron--left" /></button>
|
|
77
|
+
<span>{year}</span>
|
|
78
|
+
<button type="button" className="nm-picker__step" aria-label="Next year" onClick={() => setYear(year + 1)}><NmIcon id="chevron" className="nm-calendar__chevron--right" /></button>
|
|
79
|
+
</div>
|
|
80
|
+
<div className="nm-picker__month-grid">
|
|
81
|
+
{names.map((name, i) => (
|
|
82
|
+
<button
|
|
83
|
+
key={name}
|
|
84
|
+
type="button"
|
|
85
|
+
className="nm-picker__option"
|
|
86
|
+
aria-pressed={selected?.y === year && selected.m === i + 1}
|
|
87
|
+
onClick={() => {
|
|
88
|
+
onValueChange?.(`${year}-${pad(i + 1)}`);
|
|
89
|
+
setOpen(false);
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
{name}
|
|
93
|
+
</button>
|
|
94
|
+
))}
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
</NmPopoverContent>
|
|
98
|
+
</NmPopover>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function TimeColumns(props: { value: string; onValueChange: (time: string) => void; minuteStep: number }) {
|
|
103
|
+
const [hour, minute] = props.value ? props.value.split(':').map(Number) : [undefined, undefined];
|
|
104
|
+
const hours = Array.from({ length: 24 }, (_, i) => i);
|
|
105
|
+
const minutes = Array.from({ length: Math.ceil(60 / props.minuteStep) }, (_, i) => i * props.minuteStep);
|
|
106
|
+
return (
|
|
107
|
+
<div className="nm-picker__time">
|
|
108
|
+
<div className="nm-picker__column" role="listbox" aria-label="Hour">
|
|
109
|
+
{hours.map((h) => (
|
|
110
|
+
<button key={h} type="button" role="option" aria-selected={h === hour} className="nm-picker__option" onClick={() => props.onValueChange(`${pad(h)}:${pad(minute ?? 0)}`)}>{pad(h)}</button>
|
|
111
|
+
))}
|
|
112
|
+
</div>
|
|
113
|
+
<div className="nm-picker__column" role="listbox" aria-label="Minute">
|
|
114
|
+
{minutes.map((m) => (
|
|
115
|
+
<button key={m} type="button" role="option" aria-selected={m === minute} className="nm-picker__option" onClick={() => props.onValueChange(`${pad(hour ?? 0)}:${pad(m)}`)}>{pad(m)}</button>
|
|
116
|
+
))}
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** A time field in 24 hours. Value is `HH:mm`. */
|
|
123
|
+
export function NmTimePicker({ value, onValueChange, placeholder = 'Pick a time', minuteStep = 5, ...rest }: Common & { value?: string; onValueChange?: (time: string) => void; minuteStep?: number }) {
|
|
124
|
+
return (
|
|
125
|
+
<NmPopover>
|
|
126
|
+
<PickerTrigger icon="clock" text={value || null} placeholder={placeholder} {...rest} />
|
|
127
|
+
<NmPopoverContent className="nm-picker__popup" align="start">
|
|
128
|
+
<TimeColumns value={value ?? ''} onValueChange={(t) => onValueChange?.(t)} minuteStep={minuteStep} />
|
|
129
|
+
</NmPopoverContent>
|
|
130
|
+
</NmPopover>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** A date and a time in one field. */
|
|
135
|
+
export function NmDateTimePicker({ value, onValueChange, placeholder = 'Pick a date and time', minuteStep = 5, ...rest }: Common & { value?: Date; onValueChange?: (date: Date | undefined) => void; minuteStep?: number }) {
|
|
136
|
+
const time = value ? `${pad(value.getHours())}:${pad(value.getMinutes())}` : '';
|
|
137
|
+
const withTime = (day: Date, t: string) => {
|
|
138
|
+
const [h, m] = t ? t.split(':').map(Number) : [0, 0];
|
|
139
|
+
const next = new Date(day);
|
|
140
|
+
next.setHours(h, m, 0, 0);
|
|
141
|
+
return next;
|
|
142
|
+
};
|
|
143
|
+
return (
|
|
144
|
+
<NmPopover>
|
|
145
|
+
<PickerTrigger icon="calendar" text={value ? `${dateText(value)}, ${time}` : null} placeholder={placeholder} {...rest} />
|
|
146
|
+
<NmPopoverContent className="nm-picker__popup nm-picker__popup--row" align="start">
|
|
147
|
+
<NmCalendar mode="single" selected={value} onSelect={(day) => onValueChange?.(day ? withTime(day, time) : undefined)} defaultMonth={value} />
|
|
148
|
+
<TimeColumns value={time} onValueChange={(t) => onValueChange?.(withTime(value ?? new Date(), t))} minuteStep={minuteStep} />
|
|
149
|
+
</NmPopoverContent>
|
|
150
|
+
</NmPopover>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
.nm-dialog__backdrop {
|
|
2
|
+
position: fixed;
|
|
3
|
+
z-index: var(--nm-menu-z);
|
|
4
|
+
inset: 0;
|
|
5
|
+
background: rgb(var(--nm-canvas-rgb) / 0.7);
|
|
6
|
+
transition: opacity 0.15s;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.nm-dialog__backdrop[data-starting-style],
|
|
10
|
+
.nm-dialog__backdrop[data-ending-style] {
|
|
11
|
+
opacity: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.nm-dialog {
|
|
15
|
+
position: fixed;
|
|
16
|
+
z-index: var(--nm-menu-z);
|
|
17
|
+
top: 20%;
|
|
18
|
+
left: 50%;
|
|
19
|
+
box-sizing: border-box;
|
|
20
|
+
width: min(var(--nm-width-dialog), calc(100% - var(--nm-space-24) * 2));
|
|
21
|
+
max-height: 70%;
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
border: var(--nm-rule) solid var(--nm-line-strong);
|
|
24
|
+
border-radius: var(--nm-radius-lg);
|
|
25
|
+
background: var(--nm-panel);
|
|
26
|
+
color: var(--nm-fg);
|
|
27
|
+
font-family: var(--nm-font);
|
|
28
|
+
font-size: var(--nm-type-ui);
|
|
29
|
+
outline: none;
|
|
30
|
+
transform: translateX(-50%);
|
|
31
|
+
transition:
|
|
32
|
+
opacity 0.15s,
|
|
33
|
+
transform 0.15s;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.nm-dialog[data-starting-style],
|
|
37
|
+
.nm-dialog[data-ending-style] {
|
|
38
|
+
opacity: 0;
|
|
39
|
+
transform: translateX(-50%) scale(0.98);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.nm-dialog__header {
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-direction: column;
|
|
45
|
+
gap: var(--nm-space-4);
|
|
46
|
+
padding: var(--nm-space-24) var(--nm-space-24) 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.nm-dialog__title {
|
|
50
|
+
margin: 0;
|
|
51
|
+
font-size: var(--nm-type-body);
|
|
52
|
+
font-weight: var(--nm-weight-medium);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.nm-dialog__description {
|
|
56
|
+
margin: 0;
|
|
57
|
+
color: var(--nm-fg-muted);
|
|
58
|
+
font-size: var(--nm-type-ui-sm);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.nm-dialog[data-size='full'] {
|
|
62
|
+
inset: 0;
|
|
63
|
+
display: flex;
|
|
64
|
+
flex-direction: column;
|
|
65
|
+
width: 100%;
|
|
66
|
+
max-height: none;
|
|
67
|
+
border: 0;
|
|
68
|
+
border-radius: 0;
|
|
69
|
+
background: var(--nm-canvas);
|
|
70
|
+
transform: none;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.nm-dialog[data-size='full'][data-starting-style],
|
|
74
|
+
.nm-dialog[data-size='full'][data-ending-style] {
|
|
75
|
+
transform: none;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* The way out of a full view sits in the corner, over the content. */
|
|
79
|
+
.nm-dialog__corner {
|
|
80
|
+
position: absolute;
|
|
81
|
+
z-index: 1;
|
|
82
|
+
right: var(--nm-space-12);
|
|
83
|
+
bottom: var(--nm-space-12);
|
|
84
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import { Dialog as DialogPrimitive } from '@base-ui/react/dialog';
|
|
3
|
+
import { nmClass } from '../../lib/nm-class.ts';
|
|
4
|
+
|
|
5
|
+
/** Base UI Dialog, in the shadcn composition, styled by NIF tokens. */
|
|
6
|
+
export function NmDialog(props: DialogPrimitive.Root.Props) {
|
|
7
|
+
return <DialogPrimitive.Root data-slot="dialog" {...props} />;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function NmDialogTrigger(props: DialogPrimitive.Trigger.Props) {
|
|
11
|
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function NmDialogClose(props: DialogPrimitive.Close.Props) {
|
|
15
|
+
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** `size="full"` fills the screen, for a whole view. */
|
|
19
|
+
export function NmDialogContent({ className, children, size = 'default', ...props }: DialogPrimitive.Popup.Props & { size?: 'default' | 'full' }) {
|
|
20
|
+
return (
|
|
21
|
+
<DialogPrimitive.Portal>
|
|
22
|
+
<DialogPrimitive.Backdrop data-slot="dialog-overlay" className="nm-dialog__backdrop" />
|
|
23
|
+
<DialogPrimitive.Popup data-slot="dialog-content" data-size={size} className={nmClass('nm-dialog', className as string)} {...props}>
|
|
24
|
+
{children}
|
|
25
|
+
</DialogPrimitive.Popup>
|
|
26
|
+
</DialogPrimitive.Portal>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function NmDialogHeader({ className, ...props }: ComponentProps<'div'>) {
|
|
31
|
+
return <div data-slot="dialog-header" className={nmClass('nm-dialog__header', className)} {...props} />;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function NmDialogTitle({ className, ...props }: DialogPrimitive.Title.Props) {
|
|
35
|
+
return <DialogPrimitive.Title data-slot="dialog-title" className={nmClass('nm-dialog__title', className as string)} {...props} />;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function NmDialogDescription({ className, ...props }: DialogPrimitive.Description.Props) {
|
|
39
|
+
return <DialogPrimitive.Description data-slot="dialog-description" className={nmClass('nm-dialog__description', className as string)} {...props} />;
|
|
40
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { NmIconId } from '../../config/nm-icons.ts';
|
|
3
|
+
|
|
4
|
+
export type NmDropdownItem = {
|
|
5
|
+
id: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
detail?: string;
|
|
8
|
+
/** Keyboard hint, such as ⌘K. Display only; the binding lives with the command. */
|
|
9
|
+
shortcut?: string;
|
|
10
|
+
icon?: NmIconId;
|
|
11
|
+
imageSrc?: string;
|
|
12
|
+
leading?: ReactNode;
|
|
13
|
+
separator?: boolean;
|
|
14
|
+
danger?: boolean;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
checked?: boolean;
|
|
17
|
+
/** Publish row state. The row stays inactive while busy or live. */
|
|
18
|
+
mark?: 'idle' | 'busy' | 'live';
|
|
19
|
+
children?: readonly NmDropdownItem[];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function isNmDropdownSeparator(item: NmDropdownItem): boolean {
|
|
23
|
+
return item.separator === true;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function nmDropdownSeparator(id: string): NmDropdownItem {
|
|
27
|
+
return { id, separator: true };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function dropdownBranchPath(
|
|
31
|
+
items: readonly NmDropdownItem[],
|
|
32
|
+
id: string,
|
|
33
|
+
trail: readonly string[] = [],
|
|
34
|
+
): string[] | null {
|
|
35
|
+
for (const item of items) {
|
|
36
|
+
if (item.separator === true) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (item.id === id) {
|
|
40
|
+
return [...trail, id];
|
|
41
|
+
}
|
|
42
|
+
if (item.children != null) {
|
|
43
|
+
const nested = dropdownBranchPath(item.children, id, [...trail, item.id]);
|
|
44
|
+
if (nested != null) {
|
|
45
|
+
return nested;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Hover and click open this branch. They do not close it again. */
|
|
53
|
+
export function openDropdownBranch(items: readonly NmDropdownItem[], id: string): string[] {
|
|
54
|
+
return dropdownBranchPath(items, id) ?? [id];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Opening a branch keeps only that branch and its parents. Closing it keeps the parents. */
|
|
58
|
+
export function nextExpandedBranches(
|
|
59
|
+
items: readonly NmDropdownItem[],
|
|
60
|
+
expanded: readonly string[],
|
|
61
|
+
id: string,
|
|
62
|
+
): string[] {
|
|
63
|
+
const path = dropdownBranchPath(items, id) ?? [id];
|
|
64
|
+
if (expanded.includes(id)) {
|
|
65
|
+
return path.slice(0, -1);
|
|
66
|
+
}
|
|
67
|
+
return path;
|
|
68
|
+
}
|