@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,32 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { NM_TABS_CLASSES, type NmTabItem } from '../../config/nm-tabs.ts';
|
|
3
|
+
import { createLogger } from '../../kit-logger.ts';
|
|
4
|
+
|
|
5
|
+
const logger = createLogger('interface-nm-tabs');
|
|
6
|
+
|
|
7
|
+
export type NmTabsProps = {
|
|
8
|
+
label: string;
|
|
9
|
+
items: readonly NmTabItem[];
|
|
10
|
+
value: string;
|
|
11
|
+
onChange: (id: string) => void;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function NmTabs(props: NmTabsProps): ReactNode {
|
|
15
|
+
logger.debug('render', props.label, { value: props.value });
|
|
16
|
+
return (
|
|
17
|
+
<div className={NM_TABS_CLASSES.root} role="tablist" aria-label={props.label}>
|
|
18
|
+
{props.items.map((item) => (
|
|
19
|
+
<button
|
|
20
|
+
key={item.id}
|
|
21
|
+
className={NM_TABS_CLASSES.item}
|
|
22
|
+
type="button"
|
|
23
|
+
role="tab"
|
|
24
|
+
aria-selected={item.id === props.value}
|
|
25
|
+
onClick={() => props.onChange(item.id)}
|
|
26
|
+
>
|
|
27
|
+
{item.label}
|
|
28
|
+
</button>
|
|
29
|
+
))}
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
.nm-textarea {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
display: block;
|
|
4
|
+
width: 100%;
|
|
5
|
+
min-height: calc(var(--control-h) * 2.5);
|
|
6
|
+
padding: var(--field-area-py) var(--control-px);
|
|
7
|
+
border: var(--nm-rule) solid var(--nm-line-strong);
|
|
8
|
+
border-radius: var(--nm-control-r);
|
|
9
|
+
background: var(--nm-raised);
|
|
10
|
+
color: var(--nm-fg);
|
|
11
|
+
font-family: var(--nm-font);
|
|
12
|
+
font-size: var(--control-fs);
|
|
13
|
+
font-weight: var(--nm-weight-regular);
|
|
14
|
+
line-height: var(--nm-leading-normal);
|
|
15
|
+
outline: none;
|
|
16
|
+
resize: vertical;
|
|
17
|
+
field-sizing: content;
|
|
18
|
+
transition: border-color 0.15s;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.nm-textarea::placeholder {
|
|
22
|
+
color: var(--nm-fg-subtle);
|
|
23
|
+
opacity: 1;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.nm-textarea:hover:not(:disabled) {
|
|
27
|
+
border-color: var(--nm-stroke);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.nm-textarea:focus-visible {
|
|
31
|
+
border-color: var(--nm-fg);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.nm-textarea:disabled {
|
|
35
|
+
cursor: not-allowed;
|
|
36
|
+
opacity: 0.5;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.nm-textarea[aria-invalid='true'] {
|
|
40
|
+
border-color: var(--nm-destructive);
|
|
41
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import { nmClass } from '../../lib/nm-class.ts';
|
|
3
|
+
|
|
4
|
+
export function NmTextarea({ className, ...props }: ComponentProps<'textarea'>) {
|
|
5
|
+
return <textarea data-slot="textarea" className={nmClass('nm-textarea', className)} {...props} />;
|
|
6
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
.nm-toggle-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
|
+
min-width: var(--control-h);
|
|
9
|
+
padding: 0 var(--control-px);
|
|
10
|
+
border: var(--nm-rule) solid transparent;
|
|
11
|
+
border-radius: var(--nm-control-r);
|
|
12
|
+
background: transparent;
|
|
13
|
+
color: var(--nm-fg-muted);
|
|
14
|
+
font-family: var(--nm-font);
|
|
15
|
+
font-size: var(--control-fs);
|
|
16
|
+
font-weight: var(--control-fw);
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
transition:
|
|
19
|
+
background 0.15s,
|
|
20
|
+
color 0.15s;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.nm-toggle-button[data-size='sm'] {
|
|
24
|
+
height: var(--control-h-sm);
|
|
25
|
+
min-width: var(--control-h-sm);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.nm-toggle-button[data-size='lg'] {
|
|
29
|
+
height: var(--control-h-lg);
|
|
30
|
+
min-width: var(--control-h-lg);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.nm-toggle-button[data-variant='outline'] {
|
|
34
|
+
border-color: var(--nm-line-strong);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.nm-toggle-button:hover:not([data-disabled]) {
|
|
38
|
+
background: var(--nm-inset);
|
|
39
|
+
color: var(--nm-fg);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.nm-toggle-button[data-pressed] {
|
|
43
|
+
background: var(--nm-panel);
|
|
44
|
+
color: var(--nm-fg);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.nm-toggle-button:focus-visible {
|
|
48
|
+
outline: var(--nm-rule) solid var(--focus);
|
|
49
|
+
outline-offset: var(--nm-space-2);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.nm-toggle-button[data-disabled] {
|
|
53
|
+
cursor: not-allowed;
|
|
54
|
+
opacity: 0.5;
|
|
55
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Toggle as TogglePrimitive } from '@base-ui/react/toggle';
|
|
2
|
+
import { nmClass } from '../../lib/nm-class.ts';
|
|
3
|
+
|
|
4
|
+
export const NM_TOGGLE_VARIANTS = ['default', 'outline'] as const;
|
|
5
|
+
export const NM_TOGGLE_SIZES = ['sm', 'default', 'lg'] as const;
|
|
6
|
+
export type NmToggleVariant = (typeof NM_TOGGLE_VARIANTS)[number];
|
|
7
|
+
export type NmToggleSize = (typeof NM_TOGGLE_SIZES)[number];
|
|
8
|
+
|
|
9
|
+
export function NmToggle({
|
|
10
|
+
className,
|
|
11
|
+
variant = 'default',
|
|
12
|
+
size = 'default',
|
|
13
|
+
...props
|
|
14
|
+
}: TogglePrimitive.Props & { variant?: NmToggleVariant; size?: NmToggleSize }) {
|
|
15
|
+
return <TogglePrimitive data-slot="toggle" data-variant={variant} data-size={size} className={nmClass('nm-toggle-button', className as string)} {...props} />;
|
|
16
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
.nm-toolbar {
|
|
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
|
+
padding: var(--nm-space-12);
|
|
9
|
+
background: var(--nm-canvas);
|
|
10
|
+
color: var(--nm-fg);
|
|
11
|
+
font-family: var(--nm-font);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.nm-toolbar__group {
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-shrink: 0;
|
|
17
|
+
align-items: center;
|
|
18
|
+
gap: var(--nm-space-8);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.nm-toolbar__spacer {
|
|
22
|
+
flex: 1;
|
|
23
|
+
min-width: 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.nm-toolbar__separator {
|
|
27
|
+
flex-shrink: 0;
|
|
28
|
+
align-self: stretch;
|
|
29
|
+
width: var(--nm-rule);
|
|
30
|
+
background: var(--nm-divider);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.nm-toolbar__input {
|
|
34
|
+
flex: 1;
|
|
35
|
+
min-width: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.nm-toolbar__text {
|
|
39
|
+
width: auto;
|
|
40
|
+
gap: var(--nm-space-6);
|
|
41
|
+
padding: 0 var(--nm-space-8);
|
|
42
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
2
|
+
import { Toolbar as ToolbarPrimitive } from '@base-ui/react/toolbar';
|
|
3
|
+
import { nmClass } from '../../lib/nm-class.ts';
|
|
4
|
+
import type { NmIconId } from '../../config/nm-icons.ts';
|
|
5
|
+
import { nmIconButtonClassName, type NmIconButtonTone } from '../../config/nm-icon-button.ts';
|
|
6
|
+
import { NmIcon } from '../nm-icon/nm-icon.tsx';
|
|
7
|
+
|
|
8
|
+
/** Base UI Toolbar, in the shadcn composition, styled by NIF tokens. One tab stop, arrow keys move between controls. */
|
|
9
|
+
export function NmToolbar({ className, ...props }: ToolbarPrimitive.Root.Props) {
|
|
10
|
+
return <ToolbarPrimitive.Root data-slot="toolbar" className={nmClass('nm-toolbar', className as string)} {...props} />;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function NmToolbarGroup({ className, ...props }: ToolbarPrimitive.Group.Props) {
|
|
14
|
+
return <ToolbarPrimitive.Group data-slot="toolbar-group" className={nmClass('nm-toolbar__group', className as string)} {...props} />;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** A vertical line between groups, such as between two panes. It follows the Contrast setting. */
|
|
18
|
+
export function NmToolbarSeparator({ className, ...props }: ToolbarPrimitive.Separator.Props) {
|
|
19
|
+
return <ToolbarPrimitive.Separator data-slot="toolbar-separator" className={nmClass('nm-toolbar__separator', className as string)} {...props} />;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Takes the free space, pushing what follows to the end. */
|
|
23
|
+
export function NmToolbarSpacer({ className, ...props }: ComponentProps<'span'>) {
|
|
24
|
+
return <span aria-hidden="true" data-slot="toolbar-spacer" className={nmClass('nm-toolbar__spacer', className)} {...props} />;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** An icon button, or a button with text. `label` is its accessible name. */
|
|
28
|
+
export function NmToolbarButton({
|
|
29
|
+
icon,
|
|
30
|
+
label,
|
|
31
|
+
tone = 'quiet',
|
|
32
|
+
pressed,
|
|
33
|
+
className,
|
|
34
|
+
children,
|
|
35
|
+
...props
|
|
36
|
+
}: Omit<ToolbarPrimitive.Button.Props, 'children'> & { icon?: NmIconId; label: string; tone?: NmIconButtonTone; pressed?: boolean; children?: ReactNode }) {
|
|
37
|
+
return (
|
|
38
|
+
<ToolbarPrimitive.Button
|
|
39
|
+
data-slot="toolbar-button"
|
|
40
|
+
aria-label={label}
|
|
41
|
+
aria-pressed={pressed}
|
|
42
|
+
className={nmClass(nmIconButtonClassName(tone), children ? 'nm-toolbar__text' : undefined, className as string)}
|
|
43
|
+
{...props}
|
|
44
|
+
>
|
|
45
|
+
{icon ? <NmIcon id={icon} /> : null}
|
|
46
|
+
{children}
|
|
47
|
+
</ToolbarPrimitive.Button>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** A field in the bar that takes the free width, such as an address. */
|
|
52
|
+
export function NmToolbarInput({ className, ...props }: ToolbarPrimitive.Input.Props) {
|
|
53
|
+
return <ToolbarPrimitive.Input data-slot="toolbar-input" className={nmClass('nm-input nm-toolbar__input', className as string)} {...props} />;
|
|
54
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.nm-tooltip__positioner {
|
|
2
|
+
z-index: var(--nm-menu-z);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.nm-tooltip {
|
|
6
|
+
display: inline-flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
gap: var(--nm-space-6);
|
|
9
|
+
max-width: var(--nm-width-tooltip);
|
|
10
|
+
padding: var(--nm-space-6) var(--nm-space-12);
|
|
11
|
+
border-radius: var(--nm-control-r);
|
|
12
|
+
background: var(--nm-fg);
|
|
13
|
+
color: var(--nm-canvas);
|
|
14
|
+
font-family: var(--nm-font);
|
|
15
|
+
font-size: var(--nm-type-ui-sm);
|
|
16
|
+
transition: opacity 0.12s;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.nm-tooltip[data-starting-style],
|
|
20
|
+
.nm-tooltip[data-ending-style] {
|
|
21
|
+
opacity: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.nm-tooltip__arrow {
|
|
25
|
+
width: var(--nm-space-8);
|
|
26
|
+
height: var(--nm-space-8);
|
|
27
|
+
background: var(--nm-fg);
|
|
28
|
+
transform: rotate(45deg);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.nm-tooltip__arrow[data-side='top'] {
|
|
32
|
+
bottom: calc(var(--nm-space-4) * -1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.nm-tooltip__arrow[data-side='bottom'] {
|
|
36
|
+
top: calc(var(--nm-space-4) * -1);
|
|
37
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
|
|
2
|
+
import { nmClass } from '../../lib/nm-class.ts';
|
|
3
|
+
|
|
4
|
+
export function NmTooltipProvider({ delay = 0, ...props }: TooltipPrimitive.Provider.Props) {
|
|
5
|
+
return <TooltipPrimitive.Provider data-slot="tooltip-provider" delay={delay} {...props} />;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function NmTooltip(props: TooltipPrimitive.Root.Props) {
|
|
9
|
+
return <TooltipPrimitive.Root data-slot="tooltip" {...props} />;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function NmTooltipTrigger(props: TooltipPrimitive.Trigger.Props) {
|
|
13
|
+
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function NmTooltipContent({
|
|
17
|
+
className,
|
|
18
|
+
side = 'top',
|
|
19
|
+
sideOffset = 4,
|
|
20
|
+
align = 'center',
|
|
21
|
+
alignOffset = 0,
|
|
22
|
+
children,
|
|
23
|
+
...props
|
|
24
|
+
}: TooltipPrimitive.Popup.Props & Pick<TooltipPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'>) {
|
|
25
|
+
return (
|
|
26
|
+
<TooltipPrimitive.Portal>
|
|
27
|
+
<TooltipPrimitive.Positioner align={align} alignOffset={alignOffset} side={side} sideOffset={sideOffset} className="nm-tooltip__positioner">
|
|
28
|
+
<TooltipPrimitive.Popup data-slot="tooltip-content" className={nmClass('nm-tooltip', className as string)} {...props}>
|
|
29
|
+
{children}
|
|
30
|
+
<TooltipPrimitive.Arrow className="nm-tooltip__arrow" />
|
|
31
|
+
</TooltipPrimitive.Popup>
|
|
32
|
+
</TooltipPrimitive.Positioner>
|
|
33
|
+
</TooltipPrimitive.Portal>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.nm-header {
|
|
2
|
+
position: relative;
|
|
3
|
+
z-index: var(--nm-header-z, 10);
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-shrink: 0;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: space-between;
|
|
8
|
+
gap: var(--nm-space-8);
|
|
9
|
+
width: 100%;
|
|
10
|
+
min-width: 0;
|
|
11
|
+
padding: var(--nm-space-12);
|
|
12
|
+
background: var(--nm-canvas);
|
|
13
|
+
color: var(--nm-fg);
|
|
14
|
+
font-family: var(--nm-font);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.nm-header__end {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-shrink: 0;
|
|
20
|
+
align-items: center;
|
|
21
|
+
gap: var(--nm-space-8);
|
|
22
|
+
margin-inline-start: auto;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@media (max-width: 48rem) {
|
|
26
|
+
.nm-header__end[data-hidden-narrow='true'] {
|
|
27
|
+
display: none;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { NM_TOP_BAR_CLASSES } from '../../config/nm-top-bar.ts';
|
|
3
|
+
import { createLogger } from '../../kit-logger.ts';
|
|
4
|
+
|
|
5
|
+
const logger = createLogger('interface-nm-top-bar');
|
|
6
|
+
|
|
7
|
+
export type NmTopBarProps = {
|
|
8
|
+
/** Controls on the leading side: mode, title, search, filters. */
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/** Controls on the trailing edge, such as the panel toggle. */
|
|
11
|
+
end?: ReactNode;
|
|
12
|
+
/** Narrow-screen control, such as the button that opens the rail. */
|
|
13
|
+
menu?: ReactNode;
|
|
14
|
+
endHidden?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** The one page bar. Chat, agents, work, artifacts, and the library pass their controls in. */
|
|
18
|
+
export function NmTopBar(props: NmTopBarProps): ReactNode {
|
|
19
|
+
logger.debug('render', 'top-bar', { end: props.end != null, menu: props.menu != null });
|
|
20
|
+
return (
|
|
21
|
+
<header className={NM_TOP_BAR_CLASSES.root}>
|
|
22
|
+
{props.menu}
|
|
23
|
+
{props.children}
|
|
24
|
+
{props.end != null ? (
|
|
25
|
+
<div
|
|
26
|
+
className={NM_TOP_BAR_CLASSES.end}
|
|
27
|
+
data-hidden-narrow={props.endHidden === true ? 'true' : 'false'}
|
|
28
|
+
>
|
|
29
|
+
{props.end}
|
|
30
|
+
</div>
|
|
31
|
+
) : null}
|
|
32
|
+
</header>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
.nm-icon-button {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
flex-shrink: 0;
|
|
5
|
+
align-items: center;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
padding: var(--nm-icon-pad);
|
|
8
|
+
border: 0;
|
|
9
|
+
border-radius: var(--nm-control-radius);
|
|
10
|
+
background: transparent;
|
|
11
|
+
color: var(--nm-fg);
|
|
12
|
+
text-decoration: none;
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.nm-icon-button:hover:not(:disabled):not([aria-disabled='true']),
|
|
17
|
+
.nm-icon-button:focus-visible:not(:disabled):not([aria-disabled='true']),
|
|
18
|
+
.nm-icon-button[aria-expanded='true']:not(:disabled):not([aria-disabled='true']),
|
|
19
|
+
.nm-icon-button[aria-pressed='true']:not(:disabled):not([aria-disabled='true']) {
|
|
20
|
+
background: var(--nm-panel);
|
|
21
|
+
color: var(--nm-fg);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.nm-icon-button:disabled {
|
|
25
|
+
opacity: var(--nm-soon-opacity);
|
|
26
|
+
cursor: default;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.nm-icon-button[aria-disabled='true'] {
|
|
30
|
+
cursor: default;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.nm-icon-button--raised {
|
|
34
|
+
background: var(--nm-raised);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.nm-icon-button--quiet {
|
|
38
|
+
background: transparent;
|
|
39
|
+
color: var(--nm-fg-subtle);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.nm-icon-button--quiet.nm-icon-button--active:not(:disabled) {
|
|
43
|
+
background: var(--nm-raised);
|
|
44
|
+
color: var(--nm-fg);
|
|
45
|
+
box-shadow: inset 0 0 0 var(--nm-rule) var(--nm-line);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.nm-icon-button--solid {
|
|
49
|
+
background: var(--nm-stroke);
|
|
50
|
+
color: var(--nm-fg);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.nm-icon-button--solid:hover:not(:disabled):not([aria-disabled='true']),
|
|
54
|
+
.nm-icon-button--solid:focus-visible:not(:disabled):not([aria-disabled='true']) {
|
|
55
|
+
background: var(--nm-fg);
|
|
56
|
+
color: var(--nm-canvas);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.nm-icon-button--solid.nm-icon-button--active:not(:disabled) {
|
|
60
|
+
background: var(--nm-fg);
|
|
61
|
+
color: var(--nm-canvas);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.nm-icon-button--subtle {
|
|
65
|
+
background: transparent;
|
|
66
|
+
color: var(--nm-fg-subtle);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.nm-icon-button--subtle[data-active='true'] {
|
|
70
|
+
color: var(--nm-fg);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.nm-icon-button--panel,
|
|
74
|
+
.nm-icon-button--panel:hover:not(:disabled):not([aria-disabled='true']),
|
|
75
|
+
.nm-icon-button--panel:focus-visible:not(:disabled):not([aria-disabled='true']) {
|
|
76
|
+
background: var(--nm-panel);
|
|
77
|
+
color: var(--nm-fg);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.nm-icon-button--invert,
|
|
81
|
+
.nm-icon-button--invert:hover:not(:disabled):not([aria-disabled='true']),
|
|
82
|
+
.nm-icon-button--invert:focus-visible:not(:disabled):not([aria-disabled='true']) {
|
|
83
|
+
background: var(--nm-fg);
|
|
84
|
+
color: var(--nm-canvas);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.nm-icon-button--invert:disabled {
|
|
88
|
+
background: var(--nm-fg-subtle);
|
|
89
|
+
color: var(--nm-canvas);
|
|
90
|
+
opacity: 1;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.nm-icon-button--invert[data-voice-trigger='true']:disabled {
|
|
94
|
+
background: var(--nm-accent);
|
|
95
|
+
color: var(--nm-canvas);
|
|
96
|
+
cursor: pointer;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.nm-icon-button--invert.nm-chatbox__send:not(:disabled),
|
|
100
|
+
.nm-icon-button--invert.nm-chatbox__send:not(:disabled):hover,
|
|
101
|
+
.nm-icon-button--invert.nm-chatbox__send:not(:disabled):focus-visible {
|
|
102
|
+
background: var(--nm-accent);
|
|
103
|
+
color: var(--nm-canvas);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.nm-icon-button--invert.nm-chatbox__send[data-voice-trigger='true']:disabled {
|
|
107
|
+
background: var(--nm-accent);
|
|
108
|
+
color: var(--nm-canvas);
|
|
109
|
+
cursor: pointer;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.nm-icon-button__icon,
|
|
113
|
+
.nm-icon-button .nm-icon,
|
|
114
|
+
.nm-icon-button > img {
|
|
115
|
+
display: block;
|
|
116
|
+
flex-shrink: 0;
|
|
117
|
+
width: var(--nm-icon-button);
|
|
118
|
+
height: var(--nm-icon-button);
|
|
119
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { forwardRef, type ButtonHTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import type { NmIconId } from '../../config/nm-icons.ts';
|
|
3
|
+
import {
|
|
4
|
+
NM_ICON_BUTTON_CLASSES,
|
|
5
|
+
NM_ICON_BUTTON_TONES,
|
|
6
|
+
type NmIconButtonTone,
|
|
7
|
+
} from '../../config/nm-icon-button.ts';
|
|
8
|
+
import { NORDMAN_CHROME_ICONS, type NordmanChromeIconId } from '../../config/nordman-chrome.ts';
|
|
9
|
+
import { createLogger } from '../../kit-logger.ts';
|
|
10
|
+
import { NmIcon } from '../nm-icon/nm-icon.tsx';
|
|
11
|
+
|
|
12
|
+
const logger = createLogger('interface-nordman-icon-button');
|
|
13
|
+
|
|
14
|
+
export const NORDMAN_ICON_BUTTON_VARIANTS = {
|
|
15
|
+
line: NM_ICON_BUTTON_TONES.line,
|
|
16
|
+
raised: NM_ICON_BUTTON_TONES.raised,
|
|
17
|
+
} as const;
|
|
18
|
+
|
|
19
|
+
export type NordmanIconButtonVariant =
|
|
20
|
+
(typeof NORDMAN_ICON_BUTTON_VARIANTS)[keyof typeof NORDMAN_ICON_BUTTON_VARIANTS];
|
|
21
|
+
|
|
22
|
+
type NordmanIconButtonProps = {
|
|
23
|
+
label: string;
|
|
24
|
+
href?: string;
|
|
25
|
+
tone?: NmIconButtonTone;
|
|
26
|
+
variant?: NordmanIconButtonVariant;
|
|
27
|
+
testId?: string;
|
|
28
|
+
imageSrc?: string;
|
|
29
|
+
children?: ReactNode;
|
|
30
|
+
active?: boolean;
|
|
31
|
+
pressed?: boolean;
|
|
32
|
+
checked?: boolean;
|
|
33
|
+
busy?: boolean;
|
|
34
|
+
expanded?: boolean;
|
|
35
|
+
popup?: 'listbox';
|
|
36
|
+
controls?: string;
|
|
37
|
+
ariaDisabled?: boolean;
|
|
38
|
+
glyph?: NmIconId;
|
|
39
|
+
icon?: NordmanChromeIconId;
|
|
40
|
+
} & Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'aria-label'>;
|
|
41
|
+
|
|
42
|
+
function iconButtonTone(
|
|
43
|
+
tone: NmIconButtonTone | undefined,
|
|
44
|
+
variant: NordmanIconButtonVariant | undefined,
|
|
45
|
+
): NmIconButtonTone {
|
|
46
|
+
if (tone != null) {
|
|
47
|
+
return tone;
|
|
48
|
+
}
|
|
49
|
+
if (variant === NORDMAN_ICON_BUTTON_VARIANTS.raised) {
|
|
50
|
+
return NM_ICON_BUTTON_TONES.raised;
|
|
51
|
+
}
|
|
52
|
+
return NM_ICON_BUTTON_TONES.line;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function iconButtonClass(
|
|
56
|
+
tone: NmIconButtonTone,
|
|
57
|
+
active: boolean,
|
|
58
|
+
className: string | undefined,
|
|
59
|
+
): string {
|
|
60
|
+
return [
|
|
61
|
+
NM_ICON_BUTTON_CLASSES.root,
|
|
62
|
+
tone === NM_ICON_BUTTON_TONES.line ? '' : NM_ICON_BUTTON_CLASSES[tone],
|
|
63
|
+
active ? NM_ICON_BUTTON_CLASSES.active : '',
|
|
64
|
+
className ?? '',
|
|
65
|
+
]
|
|
66
|
+
.filter((value) => value !== '')
|
|
67
|
+
.join(' ');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function IconButtonFace(props: {
|
|
71
|
+
glyph?: NmIconId;
|
|
72
|
+
icon?: NordmanChromeIconId;
|
|
73
|
+
imageSrc?: string;
|
|
74
|
+
children?: ReactNode;
|
|
75
|
+
}): ReactNode {
|
|
76
|
+
if (props.children != null) {
|
|
77
|
+
return props.children;
|
|
78
|
+
}
|
|
79
|
+
if (props.imageSrc != null) {
|
|
80
|
+
return <img className={NM_ICON_BUTTON_CLASSES.icon} src={props.imageSrc} alt="" />;
|
|
81
|
+
}
|
|
82
|
+
if (props.glyph != null) {
|
|
83
|
+
return <NmIcon id={props.glyph} className={NM_ICON_BUTTON_CLASSES.icon} />;
|
|
84
|
+
}
|
|
85
|
+
if (props.icon != null) {
|
|
86
|
+
const chrome = NORDMAN_CHROME_ICONS[props.icon];
|
|
87
|
+
return (
|
|
88
|
+
<svg
|
|
89
|
+
className={NM_ICON_BUTTON_CLASSES.icon}
|
|
90
|
+
viewBox={chrome.viewBox}
|
|
91
|
+
fill="none"
|
|
92
|
+
aria-hidden="true"
|
|
93
|
+
focusable="false"
|
|
94
|
+
>
|
|
95
|
+
<path d={chrome.path} stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
|
|
96
|
+
</svg>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function iconButtonPressed(
|
|
103
|
+
checked: boolean | undefined,
|
|
104
|
+
pressed: boolean | undefined,
|
|
105
|
+
active: boolean,
|
|
106
|
+
): boolean | undefined {
|
|
107
|
+
if (checked != null) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
if (pressed != null) {
|
|
111
|
+
return pressed;
|
|
112
|
+
}
|
|
113
|
+
if (active) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export const NordmanIconButton = forwardRef<HTMLButtonElement, NordmanIconButtonProps>(
|
|
120
|
+
function NordmanIconButton(props, ref): ReactNode {
|
|
121
|
+
const {
|
|
122
|
+
icon,
|
|
123
|
+
glyph,
|
|
124
|
+
imageSrc,
|
|
125
|
+
children,
|
|
126
|
+
label,
|
|
127
|
+
href,
|
|
128
|
+
tone,
|
|
129
|
+
variant,
|
|
130
|
+
active = false,
|
|
131
|
+
pressed,
|
|
132
|
+
checked,
|
|
133
|
+
busy,
|
|
134
|
+
expanded,
|
|
135
|
+
popup,
|
|
136
|
+
controls,
|
|
137
|
+
ariaDisabled,
|
|
138
|
+
testId,
|
|
139
|
+
className,
|
|
140
|
+
type,
|
|
141
|
+
...rest
|
|
142
|
+
} = props;
|
|
143
|
+
const resolvedTone = iconButtonTone(tone, variant);
|
|
144
|
+
const buttonClass = iconButtonClass(resolvedTone, active, className);
|
|
145
|
+
const marked = pressed ?? checked ?? (active ? true : undefined);
|
|
146
|
+
logger.debug('render', glyph ?? icon ?? label, { href: Boolean(href), tone: resolvedTone });
|
|
147
|
+
const face = (
|
|
148
|
+
<IconButtonFace glyph={glyph} icon={icon} imageSrc={imageSrc}>
|
|
149
|
+
{children}
|
|
150
|
+
</IconButtonFace>
|
|
151
|
+
);
|
|
152
|
+
let dataActive: 'true' | 'false' | undefined;
|
|
153
|
+
if (marked != null) {
|
|
154
|
+
dataActive = marked ? 'true' : 'false';
|
|
155
|
+
}
|
|
156
|
+
const shared = {
|
|
157
|
+
className: buttonClass,
|
|
158
|
+
'aria-label': label,
|
|
159
|
+
'aria-pressed': iconButtonPressed(checked, pressed, active),
|
|
160
|
+
'aria-checked': checked,
|
|
161
|
+
'aria-disabled': ariaDisabled,
|
|
162
|
+
'aria-busy': busy,
|
|
163
|
+
...(expanded == null ? {} : { 'aria-expanded': expanded }),
|
|
164
|
+
'aria-haspopup': popup,
|
|
165
|
+
'aria-controls': controls,
|
|
166
|
+
role: checked != null ? ('radio' as const) : undefined,
|
|
167
|
+
'data-active': dataActive,
|
|
168
|
+
'data-testid': testId,
|
|
169
|
+
};
|
|
170
|
+
if (href) {
|
|
171
|
+
return (
|
|
172
|
+
<a href={href} {...shared}>
|
|
173
|
+
{face}
|
|
174
|
+
</a>
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
return (
|
|
178
|
+
<button {...rest} {...shared} ref={ref} type={type ?? 'button'}>
|
|
179
|
+
{face}
|
|
180
|
+
</button>
|
|
181
|
+
);
|
|
182
|
+
},
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
export { NM_ICON_BUTTON_TONES };
|