@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.
- 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 +106 -0
- package/registry/ui/components/nm-button/nm-button.tsx +58 -0
- package/registry/ui/components/nm-button-group/nm-button-group.css +98 -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,353 @@
|
|
|
1
|
+
.nm-collection {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
min-width: 0;
|
|
5
|
+
height: 100%;
|
|
6
|
+
background: var(--nm-canvas);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.nm-collection__cluster {
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
gap: var(--nm-space-8);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.nm-collection__title,
|
|
16
|
+
.nm-collection__filter {
|
|
17
|
+
display: inline-flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
padding: var(--nm-icon-pad);
|
|
21
|
+
border: 0;
|
|
22
|
+
border-radius: var(--nm-control-radius);
|
|
23
|
+
background: transparent;
|
|
24
|
+
color: var(--nm-fg);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.nm-collection__title:hover {
|
|
28
|
+
background: var(--nm-raised);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.nm-collection__filter {
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.nm-collection__filter[data-active='true'] {
|
|
36
|
+
background: var(--nm-raised);
|
|
37
|
+
color: var(--nm-fg);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.nm-collection__title img,
|
|
41
|
+
.nm-collection__title .nm-icon,
|
|
42
|
+
.nm-collection__filter img {
|
|
43
|
+
display: block;
|
|
44
|
+
flex-shrink: 0;
|
|
45
|
+
width: var(--nm-icon-button);
|
|
46
|
+
height: var(--nm-icon-button);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.nm-collection__search {
|
|
50
|
+
width: var(--nm-collection-search);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.nm-dropdown__trigger--icon.nm-collection__kind-filter {
|
|
54
|
+
border-radius: var(--nm-control-radius);
|
|
55
|
+
color: var(--nm-fg);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.nm-dropdown__trigger--icon.nm-collection__kind-filter .nm-icon {
|
|
59
|
+
color: var(--nm-fg);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.nm-collection__body {
|
|
63
|
+
flex: 1;
|
|
64
|
+
min-height: 0;
|
|
65
|
+
overflow: auto;
|
|
66
|
+
padding-inline: var(--nm-space-24);
|
|
67
|
+
padding-bottom: var(--nm-space-24);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.nm-collection__table {
|
|
71
|
+
display: flex;
|
|
72
|
+
flex-direction: column;
|
|
73
|
+
gap: 0;
|
|
74
|
+
width: 100%;
|
|
75
|
+
margin: 0;
|
|
76
|
+
padding: 0;
|
|
77
|
+
list-style: none;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.nm-collection__row,
|
|
81
|
+
.nm-collection__tile {
|
|
82
|
+
display: flex;
|
|
83
|
+
width: 100%;
|
|
84
|
+
padding: var(--nm-space-8);
|
|
85
|
+
border: 0;
|
|
86
|
+
border-radius: var(--nm-radius-sm);
|
|
87
|
+
background: transparent;
|
|
88
|
+
color: var(--nm-fg);
|
|
89
|
+
font-family: var(--nm-font);
|
|
90
|
+
text-align: left;
|
|
91
|
+
cursor: pointer;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.nm-collection__row {
|
|
95
|
+
align-items: center;
|
|
96
|
+
justify-content: space-between;
|
|
97
|
+
gap: var(--nm-space-8);
|
|
98
|
+
padding: var(--table-cell-py) var(--table-gap);
|
|
99
|
+
border-bottom: var(--nm-rule) solid var(--nm-line);
|
|
100
|
+
border-radius: 0;
|
|
101
|
+
color: var(--nm-fg-subtle);
|
|
102
|
+
font-size: var(--table-fs);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.nm-collection__row:hover,
|
|
106
|
+
.nm-collection__row:focus-within {
|
|
107
|
+
background: var(--nm-raised);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.nm-collection__head,
|
|
111
|
+
.nm-collection__head:hover,
|
|
112
|
+
.nm-collection__head:focus-within {
|
|
113
|
+
padding-block: var(--table-head-py);
|
|
114
|
+
border-bottom-color: var(--nm-line-strong);
|
|
115
|
+
background: transparent;
|
|
116
|
+
color: var(--nm-fg-subtle);
|
|
117
|
+
font-size: var(--table-head-fs);
|
|
118
|
+
cursor: default;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.nm-collection__row[data-columns='true'] {
|
|
122
|
+
color: var(--nm-fg);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.nm-collection__facts {
|
|
126
|
+
display: flex;
|
|
127
|
+
flex-shrink: 0;
|
|
128
|
+
align-items: center;
|
|
129
|
+
gap: var(--nm-space-40);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.nm-collection__cell {
|
|
133
|
+
width: 6.25rem;
|
|
134
|
+
overflow: hidden;
|
|
135
|
+
font-size: inherit;
|
|
136
|
+
font-weight: var(--nm-weight-regular);
|
|
137
|
+
line-height: var(--nm-leading-snug);
|
|
138
|
+
text-overflow: ellipsis;
|
|
139
|
+
white-space: nowrap;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.nm-collection__head .nm-collection__name,
|
|
143
|
+
.nm-collection__row[data-columns='true'] .nm-collection__name {
|
|
144
|
+
flex: 1 1 auto;
|
|
145
|
+
min-width: 0;
|
|
146
|
+
font-weight: var(--nm-weight-regular);
|
|
147
|
+
line-height: var(--nm-type-ui);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.nm-collection__row[data-columns='true'] .nm-collection__row-hit {
|
|
151
|
+
align-items: center;
|
|
152
|
+
padding: 0;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.nm-collection__row[data-columns='true']:not(.nm-collection__head) .nm-collection__menu {
|
|
156
|
+
opacity: 0;
|
|
157
|
+
pointer-events: none;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.nm-collection__row[data-columns='true']:hover .nm-collection__menu,
|
|
161
|
+
.nm-collection__row[data-columns='true']:focus-within .nm-collection__menu {
|
|
162
|
+
opacity: 1;
|
|
163
|
+
pointer-events: auto;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.nm-collection__row[data-columns='true']:hover .nm-icon-button--quiet,
|
|
167
|
+
.nm-collection__row[data-columns='true']:focus-within .nm-icon-button--quiet {
|
|
168
|
+
background: transparent;
|
|
169
|
+
color: var(--nm-fg);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.nm-collection__row-hit,
|
|
173
|
+
.nm-collection__hit {
|
|
174
|
+
display: flex;
|
|
175
|
+
flex: 1;
|
|
176
|
+
min-width: 0;
|
|
177
|
+
width: 100%;
|
|
178
|
+
border: 0;
|
|
179
|
+
background: transparent;
|
|
180
|
+
color: inherit;
|
|
181
|
+
font: inherit;
|
|
182
|
+
text-align: left;
|
|
183
|
+
cursor: pointer;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.nm-collection__row-hit {
|
|
187
|
+
align-items: baseline;
|
|
188
|
+
justify-content: space-between;
|
|
189
|
+
gap: var(--nm-space-16);
|
|
190
|
+
padding: var(--nm-space-8);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.nm-collection__hit {
|
|
194
|
+
height: 100%;
|
|
195
|
+
padding: 0;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.nm-collection__menu {
|
|
199
|
+
display: flex;
|
|
200
|
+
flex-shrink: 0;
|
|
201
|
+
align-items: center;
|
|
202
|
+
padding-inline-end: var(--nm-space-8);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.nm-collection__grid {
|
|
206
|
+
display: grid;
|
|
207
|
+
grid-template-columns: repeat(auto-fill, minmax(var(--nm-collection-tile), 1fr));
|
|
208
|
+
gap: var(--nm-space-12);
|
|
209
|
+
margin: 0;
|
|
210
|
+
padding: 0;
|
|
211
|
+
list-style: none;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.nm-collection__tile {
|
|
215
|
+
position: relative;
|
|
216
|
+
flex-direction: column;
|
|
217
|
+
gap: var(--nm-space-4);
|
|
218
|
+
aspect-ratio: 1;
|
|
219
|
+
overflow: hidden;
|
|
220
|
+
border: 0;
|
|
221
|
+
border-radius: var(--nm-radius-lg);
|
|
222
|
+
background: var(--nm-raised);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.nm-collection__actions {
|
|
226
|
+
position: absolute;
|
|
227
|
+
top: var(--nm-space-8);
|
|
228
|
+
inset-inline-end: var(--nm-space-8);
|
|
229
|
+
z-index: 1;
|
|
230
|
+
display: flex;
|
|
231
|
+
gap: var(--nm-space-4);
|
|
232
|
+
opacity: 0;
|
|
233
|
+
pointer-events: none;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.nm-collection__tile:hover .nm-collection__actions,
|
|
237
|
+
.nm-collection__tile:focus-within .nm-collection__actions {
|
|
238
|
+
opacity: 1;
|
|
239
|
+
pointer-events: auto;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.nm-collection__tile[data-media] {
|
|
243
|
+
padding: 0;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.nm-collection__tile[data-media='audio'] {
|
|
247
|
+
padding: var(--nm-space-8);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.nm-collection__media {
|
|
251
|
+
display: block;
|
|
252
|
+
width: 100%;
|
|
253
|
+
height: 100%;
|
|
254
|
+
object-fit: cover;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.nm-collection__stage {
|
|
258
|
+
display: flex;
|
|
259
|
+
flex-direction: column;
|
|
260
|
+
width: 100%;
|
|
261
|
+
height: 100%;
|
|
262
|
+
background: var(--nm-canvas);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.nm-collection__stage-bar {
|
|
266
|
+
display: flex;
|
|
267
|
+
align-items: center;
|
|
268
|
+
justify-content: flex-end;
|
|
269
|
+
flex-shrink: 0;
|
|
270
|
+
gap: var(--nm-space-8);
|
|
271
|
+
padding: var(--nm-space-12);
|
|
272
|
+
border-bottom: var(--nm-rule) solid var(--nm-panel);
|
|
273
|
+
border-left: var(--nm-rule) solid var(--nm-panel);
|
|
274
|
+
background: var(--nm-canvas);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.nm-collection__preview {
|
|
278
|
+
display: flex;
|
|
279
|
+
align-items: center;
|
|
280
|
+
justify-content: center;
|
|
281
|
+
flex: 1;
|
|
282
|
+
width: 100%;
|
|
283
|
+
min-height: 0;
|
|
284
|
+
overflow: hidden;
|
|
285
|
+
background: var(--nm-canvas);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.nm-collection__preview .nm-collection__media {
|
|
289
|
+
object-fit: contain;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.nm-collection__preview:has(.nm-collection__document) {
|
|
293
|
+
align-items: stretch;
|
|
294
|
+
justify-content: flex-start;
|
|
295
|
+
overflow: auto;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.nm-collection__document {
|
|
299
|
+
margin: 0;
|
|
300
|
+
padding: var(--nm-space-24);
|
|
301
|
+
white-space: pre-wrap;
|
|
302
|
+
color: var(--nm-fg);
|
|
303
|
+
font-family: var(--nm-font);
|
|
304
|
+
font-size: var(--nm-type-ui);
|
|
305
|
+
line-height: var(--nm-leading-normal);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.nm-collection__audio {
|
|
309
|
+
width: 100%;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.nm-collection__name {
|
|
313
|
+
overflow: hidden;
|
|
314
|
+
font-size: var(--nm-type-ui);
|
|
315
|
+
font-weight: var(--nm-weight-semibold);
|
|
316
|
+
text-overflow: ellipsis;
|
|
317
|
+
white-space: nowrap;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.nm-collection__meta {
|
|
321
|
+
color: var(--nm-fg-subtle);
|
|
322
|
+
font-size: var(--nm-type-ui-sm);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.nm-collection__body,
|
|
326
|
+
.nm-collection__preview {
|
|
327
|
+
scrollbar-width: none;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.nm-collection__body[data-scrolling='true'],
|
|
331
|
+
.nm-collection__preview[data-scrolling='true'] {
|
|
332
|
+
scrollbar-width: thin;
|
|
333
|
+
scrollbar-color: var(--nm-stroke) transparent;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
.nm-collection__body::-webkit-scrollbar,
|
|
337
|
+
.nm-collection__preview::-webkit-scrollbar {
|
|
338
|
+
width: 0;
|
|
339
|
+
height: 0;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.nm-collection__body[data-scrolling='true']::-webkit-scrollbar,
|
|
343
|
+
.nm-collection__preview[data-scrolling='true']::-webkit-scrollbar {
|
|
344
|
+
width: var(--nm-rail-scrollbar);
|
|
345
|
+
height: var(--nm-rail-scrollbar);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
.nm-collection__body[data-scrolling='true']::-webkit-scrollbar-thumb,
|
|
349
|
+
.nm-collection__preview[data-scrolling='true']::-webkit-scrollbar-thumb {
|
|
350
|
+
background: var(--nm-stroke);
|
|
351
|
+
border-radius: var(--nm-radius-sm);
|
|
352
|
+
}
|
|
353
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import type { RefObject } from 'react';
|
|
3
|
+
import { NM_COLLECTION_SCROLL_IDLE_MS } from '../../config/nm-collection.ts';
|
|
4
|
+
import { createLogger } from '../../kit-logger.ts';
|
|
5
|
+
|
|
6
|
+
const logger = createLogger('interface-nm-collection-scroll');
|
|
7
|
+
|
|
8
|
+
/** Shows the collection scroll thumb only while the region is moving. */
|
|
9
|
+
export default function useCollectionScrollReveal(
|
|
10
|
+
scrollableRef: RefObject<HTMLElement | null>,
|
|
11
|
+
): void {
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const node = scrollableRef.current;
|
|
14
|
+
if (node == null) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let idle = 0;
|
|
19
|
+
const onScroll = () => {
|
|
20
|
+
if (node.dataset.scrolling !== 'true') {
|
|
21
|
+
logger.debug('scroll', 'start', {});
|
|
22
|
+
}
|
|
23
|
+
node.dataset.scrolling = 'true';
|
|
24
|
+
window.clearTimeout(idle);
|
|
25
|
+
idle = window.setTimeout(() => {
|
|
26
|
+
delete node.dataset.scrolling;
|
|
27
|
+
logger.debug('scroll', 'idle', {});
|
|
28
|
+
}, NM_COLLECTION_SCROLL_IDLE_MS);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
node.addEventListener('scroll', onScroll);
|
|
32
|
+
return () => {
|
|
33
|
+
node.removeEventListener('scroll', onScroll);
|
|
34
|
+
window.clearTimeout(idle);
|
|
35
|
+
delete node.dataset.scrolling;
|
|
36
|
+
};
|
|
37
|
+
}, [scrollableRef]);
|
|
38
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
.nm-color {
|
|
2
|
+
flex-direction: column;
|
|
3
|
+
gap: var(--nm-space-12);
|
|
4
|
+
width: var(--nm-width-popup-sm);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.nm-color__swatch {
|
|
8
|
+
flex-shrink: 0;
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
width: var(--nm-icon-button);
|
|
11
|
+
height: var(--nm-icon-button);
|
|
12
|
+
border: var(--nm-rule) solid var(--nm-line-strong);
|
|
13
|
+
border-radius: var(--nm-radius-sm);
|
|
14
|
+
background: var(--nm-swatch);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.nm-color__swatch[data-shape='round'] {
|
|
18
|
+
border-radius: 50%;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.nm-color__swatches {
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-wrap: wrap;
|
|
24
|
+
gap: var(--nm-space-8);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.nm-color__swatch--button {
|
|
28
|
+
padding: 0;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.nm-color__swatch--button[aria-pressed='true'] {
|
|
33
|
+
border-color: var(--nm-fg);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.nm-color__swatch--button:focus-visible {
|
|
37
|
+
outline: var(--nm-rule) solid var(--focus);
|
|
38
|
+
outline-offset: var(--nm-space-2);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* react-colorful draws the area and the sliders. NIF sets their size, radius and pointer. */
|
|
42
|
+
.nm-color .react-colorful {
|
|
43
|
+
gap: var(--nm-space-12);
|
|
44
|
+
width: 100%;
|
|
45
|
+
height: auto;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.nm-color .react-colorful__saturation {
|
|
49
|
+
height: var(--nm-height-color);
|
|
50
|
+
border-radius: var(--nm-control-r);
|
|
51
|
+
border-bottom: 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.nm-color .react-colorful__hue {
|
|
55
|
+
height: var(--nm-space-12);
|
|
56
|
+
border-radius: var(--toggle-r);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.nm-color .react-colorful__interactive:focus .react-colorful__pointer {
|
|
60
|
+
border-color: var(--focus);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.nm-color .react-colorful__pointer {
|
|
64
|
+
width: var(--nm-icon-button);
|
|
65
|
+
height: var(--nm-icon-button);
|
|
66
|
+
border: var(--nm-space-2) solid var(--nm-fg);
|
|
67
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { useEffect, useId, useState, type CSSProperties } from 'react';
|
|
2
|
+
import { HexColorPicker } from 'react-colorful';
|
|
3
|
+
import { NmInput } from '../nm-input/nm-input.tsx';
|
|
4
|
+
import { NmPopover, NmPopoverContent, NmPopoverTrigger } from '../nm-popover/nm-popover.tsx';
|
|
5
|
+
|
|
6
|
+
/** One colour as a swatch. The colour picker and the theme list both draw it. */
|
|
7
|
+
export function NmColorSwatch({ color, shape = 'square' }: { color: string; shape?: 'square' | 'round' }) {
|
|
8
|
+
return <span className="nm-color__swatch" data-shape={shape} style={{ '--nm-swatch': color } as CSSProperties} />;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const HEX = /^#[0-9a-fA-F]{6}$/;
|
|
12
|
+
|
|
13
|
+
/** A colour field. The picker opens in a popover, drawn by NIF tokens around react-colorful. */
|
|
14
|
+
export function NmColorPicker({
|
|
15
|
+
value,
|
|
16
|
+
onValueChange,
|
|
17
|
+
swatches,
|
|
18
|
+
label = 'Colour',
|
|
19
|
+
caption,
|
|
20
|
+
disabled,
|
|
21
|
+
}: {
|
|
22
|
+
value: string;
|
|
23
|
+
onValueChange: (hex: string) => void;
|
|
24
|
+
swatches?: readonly string[];
|
|
25
|
+
label?: string;
|
|
26
|
+
/** A caption above the field, set like the caption of a Field. */
|
|
27
|
+
caption?: string;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
}) {
|
|
30
|
+
const [text, setText] = useState(value);
|
|
31
|
+
useEffect(() => setText(value), [value]);
|
|
32
|
+
const id = useId();
|
|
33
|
+
const field = (
|
|
34
|
+
<NmPopover>
|
|
35
|
+
<NmPopoverTrigger id={id} className="nm-picker__trigger" disabled={disabled} aria-label={label}>
|
|
36
|
+
<NmColorSwatch color={value} />
|
|
37
|
+
<span>{value.toUpperCase()}</span>
|
|
38
|
+
</NmPopoverTrigger>
|
|
39
|
+
<NmPopoverContent className="nm-picker__popup nm-color" align="start">
|
|
40
|
+
<HexColorPicker color={value} onChange={onValueChange} />
|
|
41
|
+
<NmInput
|
|
42
|
+
aria-label={`${label} hex`}
|
|
43
|
+
value={text}
|
|
44
|
+
onChange={(event) => {
|
|
45
|
+
const next = event.target.value;
|
|
46
|
+
setText(next);
|
|
47
|
+
if (HEX.test(next)) {
|
|
48
|
+
onValueChange(next);
|
|
49
|
+
}
|
|
50
|
+
}}
|
|
51
|
+
aria-invalid={HEX.test(text) ? undefined : true}
|
|
52
|
+
/>
|
|
53
|
+
{swatches ? (
|
|
54
|
+
<div className="nm-color__swatches">
|
|
55
|
+
{swatches.map((hex) => (
|
|
56
|
+
<button
|
|
57
|
+
key={hex}
|
|
58
|
+
type="button"
|
|
59
|
+
className="nm-color__swatch nm-color__swatch--button"
|
|
60
|
+
style={{ '--nm-swatch': hex } as CSSProperties}
|
|
61
|
+
aria-label={hex}
|
|
62
|
+
aria-pressed={hex.toLowerCase() === value.toLowerCase()}
|
|
63
|
+
onClick={() => onValueChange(hex)}
|
|
64
|
+
/>
|
|
65
|
+
))}
|
|
66
|
+
</div>
|
|
67
|
+
) : null}
|
|
68
|
+
</NmPopoverContent>
|
|
69
|
+
</NmPopover>
|
|
70
|
+
);
|
|
71
|
+
return caption ? (
|
|
72
|
+
<div className="nm-field nm-field--stack">
|
|
73
|
+
<label className="nm-field__caption" htmlFor={id}>{caption}</label>
|
|
74
|
+
{field}
|
|
75
|
+
</div>
|
|
76
|
+
) : (
|
|
77
|
+
field
|
|
78
|
+
);
|
|
79
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
.nm-combobox__group {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
gap: var(--nm-space-8);
|
|
6
|
+
width: 100%;
|
|
7
|
+
min-width: 0;
|
|
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
|
+
}
|
|
17
|
+
|
|
18
|
+
.nm-combobox__group[data-bare] {
|
|
19
|
+
height: auto;
|
|
20
|
+
padding: 0;
|
|
21
|
+
border: 0;
|
|
22
|
+
background: transparent;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.nm-combobox__group:not([data-bare]):focus-within {
|
|
26
|
+
border-color: var(--nm-stroke);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.nm-combobox__input {
|
|
30
|
+
flex: 1;
|
|
31
|
+
min-width: 0;
|
|
32
|
+
padding: 0;
|
|
33
|
+
border: 0;
|
|
34
|
+
background: transparent;
|
|
35
|
+
color: inherit;
|
|
36
|
+
font: inherit;
|
|
37
|
+
outline: none;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.nm-combobox__input::placeholder {
|
|
41
|
+
color: var(--nm-fg-subtle);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.nm-combobox__button {
|
|
45
|
+
display: inline-flex;
|
|
46
|
+
flex-shrink: 0;
|
|
47
|
+
align-items: center;
|
|
48
|
+
padding: 0;
|
|
49
|
+
border: 0;
|
|
50
|
+
background: transparent;
|
|
51
|
+
color: var(--nm-fg-subtle);
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.nm-combobox__button:hover {
|
|
56
|
+
color: var(--nm-fg);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.nm-combobox__button:focus-visible {
|
|
60
|
+
outline: var(--nm-rule) solid var(--focus);
|
|
61
|
+
outline-offset: var(--nm-space-2);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.nm-combobox__empty {
|
|
65
|
+
padding: var(--nm-space-8) var(--nm-icon-pad);
|
|
66
|
+
color: var(--nm-fg-subtle);
|
|
67
|
+
font-size: var(--nm-type-ui-sm);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.nm-combobox__empty:empty {
|
|
71
|
+
display: none;
|
|
72
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { Combobox as ComboboxPrimitive } from '@base-ui/react/combobox';
|
|
3
|
+
import { nmClass } from '../../lib/nm-class.ts';
|
|
4
|
+
import { NmIcon } from '../nm-icon/nm-icon.tsx';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Base UI Combobox, in the shadcn composition, styled by NIF tokens. A select you can search: type to filter the
|
|
8
|
+
* list, then choose. The list is the same surface as the Dropdown Menu and the Select.
|
|
9
|
+
*/
|
|
10
|
+
export function NmCombobox<Value = string>(props: ComboboxPrimitive.Root.Props<Value>) {
|
|
11
|
+
return <ComboboxPrimitive.Root data-slot="combobox" {...props} />;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** The field you type in, with the button that opens the list. `bare` drops its own box, for use inside a Field. */
|
|
15
|
+
export function NmComboboxInput({
|
|
16
|
+
className,
|
|
17
|
+
bare,
|
|
18
|
+
showClear,
|
|
19
|
+
...props
|
|
20
|
+
}: ComboboxPrimitive.Input.Props & { bare?: boolean; showClear?: boolean }) {
|
|
21
|
+
return (
|
|
22
|
+
<ComboboxPrimitive.InputGroup data-slot="combobox-input-group" data-bare={bare ? '' : undefined} className="nm-combobox__group">
|
|
23
|
+
<ComboboxPrimitive.Input data-slot="combobox-input" className={nmClass('nm-combobox__input', className as string)} {...props} />
|
|
24
|
+
{showClear ? (
|
|
25
|
+
<ComboboxPrimitive.Clear data-slot="combobox-clear" className="nm-combobox__button" aria-label="Clear">
|
|
26
|
+
<NmIcon id="x" />
|
|
27
|
+
</ComboboxPrimitive.Clear>
|
|
28
|
+
) : null}
|
|
29
|
+
<ComboboxPrimitive.Trigger data-slot="combobox-trigger" className="nm-combobox__button" aria-label="Open the list">
|
|
30
|
+
<NmIcon id="chevron" />
|
|
31
|
+
</ComboboxPrimitive.Trigger>
|
|
32
|
+
</ComboboxPrimitive.InputGroup>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** `anchor` is the element the list lines up with. It defaults to the input. */
|
|
37
|
+
export function NmComboboxContent({ className, children, anchor, ...props }: ComboboxPrimitive.Popup.Props & { anchor?: HTMLElement | null }) {
|
|
38
|
+
return (
|
|
39
|
+
<ComboboxPrimitive.Portal>
|
|
40
|
+
<ComboboxPrimitive.Positioner className="nm-menu__positioner" sideOffset={4} anchor={anchor ?? undefined}>
|
|
41
|
+
<ComboboxPrimitive.Popup data-slot="combobox-content" className={nmClass('nm-menu nm-select__popup', className as string)} {...props}>
|
|
42
|
+
{children}
|
|
43
|
+
</ComboboxPrimitive.Popup>
|
|
44
|
+
</ComboboxPrimitive.Positioner>
|
|
45
|
+
</ComboboxPrimitive.Portal>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** The items. Give it a function of one item, and it draws the filtered list. */
|
|
50
|
+
export function NmComboboxList({ className, ...props }: ComboboxPrimitive.List.Props) {
|
|
51
|
+
return <ComboboxPrimitive.List data-slot="combobox-list" className={nmClass('nm-select__list', className as string)} {...props} />;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function NmComboboxItem({ className, children, ...props }: ComboboxPrimitive.Item.Props & { children: ReactNode }) {
|
|
55
|
+
return (
|
|
56
|
+
<ComboboxPrimitive.Item data-slot="combobox-item" className={nmClass('nm-menu__item nm-select__item', className as string)} {...props}>
|
|
57
|
+
<span className="nm-select__text">{children}</span>
|
|
58
|
+
<ComboboxPrimitive.ItemIndicator className="nm-select__check">
|
|
59
|
+
<NmIcon id="check" />
|
|
60
|
+
</ComboboxPrimitive.ItemIndicator>
|
|
61
|
+
</ComboboxPrimitive.Item>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** What the list says when nothing matches. */
|
|
66
|
+
export function NmComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props) {
|
|
67
|
+
return <ComboboxPrimitive.Empty data-slot="combobox-empty" className={nmClass('nm-combobox__empty', className as string)} {...props} />;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function NmComboboxGroup(props: ComboboxPrimitive.Group.Props) {
|
|
71
|
+
return <ComboboxPrimitive.Group data-slot="combobox-group" {...props} />;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function NmComboboxLabel({ className, ...props }: ComboboxPrimitive.GroupLabel.Props) {
|
|
75
|
+
return <ComboboxPrimitive.GroupLabel data-slot="combobox-label" className={nmClass('nm-menu__label', className as string)} {...props} />;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function NmComboboxSeparator({ className, ...props }: ComboboxPrimitive.Separator.Props) {
|
|
79
|
+
return <ComboboxPrimitive.Separator data-slot="combobox-separator" className={nmClass('nm-menu__separator', className as string)} {...props} />;
|
|
80
|
+
}
|