@nesso-how/ui 1.0.0-alpha.34 → 1.0.0-beta.2
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 +4 -2
- package/dist/index.d.ts +17 -2
- package/dist/index.js +55 -12
- package/dist/styles.css +30 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,12 +44,14 @@ Your build must compile this CSS; it is not a precompiled stylesheet. Supply the
|
|
|
44
44
|
| Menus and popovers | `Menu`, `MenuItem`, `MenuPopup`, `MenuRadioItem`, `Popover`, `PopoverPopup` |
|
|
45
45
|
| Search and suggestions | `Combobox`, `ComboboxItem`, `ComboboxPopup`, `Autocomplete`, `AutocompleteClear`, `AutocompleteItem`, `AutocompletePopup` |
|
|
46
46
|
| Dialogs | `Dialog`, `DialogActions`, `DialogPopup`, `ConfirmDialog`, `TextPromptDialog` |
|
|
47
|
-
| Panels and disclosure | `SidePanel`, `PanelHeader`, `SectionHeading`, `Collapsible`, `Tabs`
|
|
48
|
-
| Feedback | `Banner`, `ToastViewport`, `Spinner`
|
|
47
|
+
| Panels and disclosure | `SidePanel`, `PanelHeader`, `PluginPage`, `PluginContent`, `SectionHeading`, `Collapsible`, `Tabs` |
|
|
48
|
+
| Feedback | `Banner`, `BannerRow`, `BannerDetails`, `ToastViewport`, `Spinner` |
|
|
49
49
|
| Labels and icons | `Kbd`, `ContextLabel`, `ActionIcon` |
|
|
50
50
|
|
|
51
51
|
`Button` supports `default`, `outline`, and `ghost` variants. `SidePanel` supports controlled resizing and collapse. `Spinner` accepts an accessible `label` and respects reduced motion. State, content, and event handling remain yours to provide.
|
|
52
52
|
|
|
53
53
|
`MarkdownInput` provides a live preview of bold, italic, links, and bullet or numbered lists in one field without a toolbar. Markdown delimiters reappear when the cursor or selection enters formatted text, including link destinations and list markers. Enter continues a list, incrementing the current number for numbered lists; Enter on an empty nested item returns to the parent level, and on an empty top-level item ends the list. Tab nests the current item under the previous one; Shift+Tab moves it up a level. Both move the item's continuation lines and children together, leaving unrelated text alone. At level boundaries they leave content and focus unchanged; outside lists they retain normal focus navigation. Shift+Enter inserts a plain line break. Existing items are not renumbered, and there are no checklists. It accepts the unchanged Markdown source through `value` and `onChange`, supports Cmd/Ctrl+B/I on selections, and preserves line breaks. Set `history={false}` when the host owns undo/redo and its shortcuts. Cmd/Ctrl-click requests `onOpenLink`; read-only fields request it on a regular click. The host is responsible for validating and opening destinations.
|
|
54
54
|
|
|
55
|
+
`MarkdownInput` also accepts an optional `placeholder` shown only while the editor is empty.
|
|
56
|
+
|
|
55
57
|
The package also exports `useMediaQuery`, `contrastColor`, `presetColors`, and the `ActionIconName` and `ToastItem` types. See the [public exports](https://github.com/nesso-how/nesso/blob/main/packages/ui/src/index.ts) and component source files for prop definitions; published TypeScript declarations provide editor completion.
|
package/dist/index.d.ts
CHANGED
|
@@ -34,10 +34,15 @@ export declare function SidePanel({ id, side, open, size, minSize, maxSize, onTo
|
|
|
34
34
|
}): import("react").JSX.Element;
|
|
35
35
|
//#endregion
|
|
36
36
|
//#region src/panel-header.d.ts
|
|
37
|
-
export declare function PanelHeader({ actions, className, children, ...props }: ComponentProps<'header'> & {
|
|
37
|
+
export declare function PanelHeader({ actions, size, className, children, ...props }: ComponentProps<'header'> & {
|
|
38
38
|
actions: ReactNode;
|
|
39
|
+
size?: 'default' | 'lg';
|
|
39
40
|
}): import("react").JSX.Element;
|
|
40
41
|
//#endregion
|
|
42
|
+
//#region src/plugin-page.d.ts
|
|
43
|
+
export declare function PluginPage({ className, children, ...props }: ComponentProps<'main'>): import("react").JSX.Element;
|
|
44
|
+
export declare function PluginContent({ className, children, ...props }: ComponentProps<'div'>): import("react").JSX.Element;
|
|
45
|
+
//#endregion
|
|
41
46
|
//#region src/spinner.d.ts
|
|
42
47
|
export declare function Spinner({ label, className }: {
|
|
43
48
|
label: string;
|
|
@@ -57,8 +62,9 @@ type MarkdownInputProps = Omit<ComponentProps<'div'>, 'onChange' | 'children' |
|
|
|
57
62
|
readOnly?: boolean;
|
|
58
63
|
history?: boolean;
|
|
59
64
|
onOpenLink?: (url: string) => void;
|
|
65
|
+
placeholder?: string;
|
|
60
66
|
};
|
|
61
|
-
export declare function MarkdownInput({ value, onChange, readOnly, history, onOpenLink, className, id, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, ...props }: MarkdownInputProps): import("react").JSX.Element;
|
|
67
|
+
export declare function MarkdownInput({ value, onChange, readOnly, history, onOpenLink, placeholder, className, id, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, ...props }: MarkdownInputProps): import("react").JSX.Element;
|
|
62
68
|
//#endregion
|
|
63
69
|
//#region src/label.d.ts
|
|
64
70
|
declare function Label({ className, ...props }: ComponentProps<'label'>): import("react").JSX.Element;
|
|
@@ -74,6 +80,14 @@ type BannerProps = ComponentProps<'div'> & {
|
|
|
74
80
|
tone?: 'info' | 'warning' | 'error';
|
|
75
81
|
};
|
|
76
82
|
export declare function Banner({ tone, className, children, ...props }: BannerProps): import("react").JSX.Element;
|
|
83
|
+
export declare function BannerRow({ message, actions }: {
|
|
84
|
+
message: ReactNode;
|
|
85
|
+
actions?: ReactNode;
|
|
86
|
+
}): import("react").JSX.Element;
|
|
87
|
+
export declare function BannerDetails({ label, children }: {
|
|
88
|
+
label: ReactNode;
|
|
89
|
+
children: ReactNode;
|
|
90
|
+
}): import("react").JSX.Element;
|
|
77
91
|
//#endregion
|
|
78
92
|
//#region src/toast.d.ts
|
|
79
93
|
type ToastAction = {
|
|
@@ -270,6 +284,7 @@ declare const icons: {
|
|
|
270
284
|
readonly play: LucideIcon;
|
|
271
285
|
readonly plus: LucideIcon;
|
|
272
286
|
readonly refresh: LucideIcon;
|
|
287
|
+
readonly repeat: LucideIcon;
|
|
273
288
|
readonly scissors: LucideIcon;
|
|
274
289
|
readonly search: LucideIcon;
|
|
275
290
|
readonly share: LucideIcon;
|
package/dist/index.js
CHANGED
|
@@ -3,10 +3,10 @@ import { cva } from "class-variance-authority";
|
|
|
3
3
|
import { cn } from "cn";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
6
|
-
import { ArrowRight, BookOpen, Check, ChevronDown, ChevronLeft, ChevronRight, CircleHelp, ClipboardPaste, Copy, Download, FileDown, FileUp, Folder, Glasses, Globe, Info, Layers, Minus, Pencil, Play, Plus, RefreshCw, RotateCcw, Scissors, Search, Share2, Sparkles, TriangleAlert, Upload, X, Zap } from "lucide-react";
|
|
6
|
+
import { ArrowRight, BookOpen, Check, ChevronDown, ChevronLeft, ChevronRight, CircleHelp, ClipboardPaste, Copy, Download, FileDown, FileUp, Folder, Glasses, Globe, Info, Layers, Minus, Pencil, Play, Plus, RefreshCw, Repeat, RotateCcw, Scissors, Search, Share2, Sparkles, TriangleAlert, Upload, X, Zap } from "lucide-react";
|
|
7
7
|
import { Input as Input$1 } from "@base-ui/react/input";
|
|
8
8
|
import { Annotation, Compartment, EditorSelection, EditorState, Transaction } from "@codemirror/state";
|
|
9
|
-
import { Decoration, EditorView, ViewPlugin, WidgetType, keymap } from "@codemirror/view";
|
|
9
|
+
import { Decoration, EditorView, ViewPlugin, WidgetType, keymap, placeholder } from "@codemirror/view";
|
|
10
10
|
import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
|
|
11
11
|
import { parser } from "@lezer/markdown";
|
|
12
12
|
import { Dialog, Dialog as Dialog$1 } from "@base-ui/react/dialog";
|
|
@@ -21,8 +21,8 @@ const buttonVariants = cva("nesso-button inline-flex shrink-0 items-center justi
|
|
|
21
21
|
variants: {
|
|
22
22
|
variant: {
|
|
23
23
|
default: "bg-primary text-primary-foreground hover:bg-primary-hover active:bg-primary-hover",
|
|
24
|
-
outline: "border-border bg-background hover:bg-accent active:bg-pressed",
|
|
25
|
-
ghost: "hover:bg-accent active:bg-pressed"
|
|
24
|
+
outline: "border-border bg-background text-foreground hover:bg-accent active:bg-pressed",
|
|
25
|
+
ghost: "text-foreground hover:bg-accent active:bg-pressed"
|
|
26
26
|
},
|
|
27
27
|
size: {
|
|
28
28
|
default: "min-h-9",
|
|
@@ -169,9 +169,9 @@ function SidePanel({ id, side, open, size, minSize, maxSize, onToggle, onSizeCha
|
|
|
169
169
|
}
|
|
170
170
|
//#endregion
|
|
171
171
|
//#region src/panel-header.tsx
|
|
172
|
-
function PanelHeader({ actions, className, children, ...props }) {
|
|
172
|
+
function PanelHeader({ actions, size = "default", className, children, ...props }) {
|
|
173
173
|
return /* @__PURE__ */ jsxs("header", {
|
|
174
|
-
className: cn("nesso-panel-header", className),
|
|
174
|
+
className: cn("nesso-panel-header", size === "lg" && "h-[49px] pointer-coarse:h-[52px]", className),
|
|
175
175
|
...props,
|
|
176
176
|
children: [children, /* @__PURE__ */ jsx("div", {
|
|
177
177
|
className: "nesso-panel-actions",
|
|
@@ -180,6 +180,22 @@ function PanelHeader({ actions, className, children, ...props }) {
|
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
182
|
//#endregion
|
|
183
|
+
//#region src/plugin-page.tsx
|
|
184
|
+
function PluginPage({ className, children, ...props }) {
|
|
185
|
+
return /* @__PURE__ */ jsx("main", {
|
|
186
|
+
className: cn("nesso-plugin-page", className),
|
|
187
|
+
...props,
|
|
188
|
+
children
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
function PluginContent({ className, children, ...props }) {
|
|
192
|
+
return /* @__PURE__ */ jsx("div", {
|
|
193
|
+
className: cn("nesso-plugin-content", className),
|
|
194
|
+
...props,
|
|
195
|
+
children
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
//#endregion
|
|
183
199
|
//#region src/spinner.tsx
|
|
184
200
|
function Spinner({ label, className }) {
|
|
185
201
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -421,7 +437,7 @@ const livePreview = ViewPlugin.define((view) => ({
|
|
|
421
437
|
if (update.docChanged || update.selectionSet || update.focusChanged || update.startState.readOnly !== update.state.readOnly) this.decorations = markdownDecorations(update.state, update.view.hasFocus && !update.state.readOnly);
|
|
422
438
|
}
|
|
423
439
|
}), { decorations: (plugin) => plugin.decorations });
|
|
424
|
-
function MarkdownInput({ value, onChange, readOnly = false, history: history$1 = true, onOpenLink, className, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...props }) {
|
|
440
|
+
function MarkdownInput({ value, onChange, readOnly = false, history: history$1 = true, onOpenLink, placeholder: placeholder$1, className, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...props }) {
|
|
425
441
|
const container = useRef(null);
|
|
426
442
|
const editor = useRef(null);
|
|
427
443
|
const callbacks = useRef({
|
|
@@ -523,7 +539,8 @@ function MarkdownInput({ value, onChange, readOnly = false, history: history$1 =
|
|
|
523
539
|
"aria-readonly": String(readOnly),
|
|
524
540
|
spellcheck: "true"
|
|
525
541
|
}),
|
|
526
|
-
...history$1 ? [history(), keymap.of(historyKeymap)] : []
|
|
542
|
+
...history$1 ? [history(), keymap.of(historyKeymap)] : [],
|
|
543
|
+
...placeholder$1 ? [placeholder(placeholder$1)] : []
|
|
527
544
|
]) });
|
|
528
545
|
}, [
|
|
529
546
|
configuration,
|
|
@@ -531,7 +548,8 @@ function MarkdownInput({ value, onChange, readOnly = false, history: history$1 =
|
|
|
531
548
|
history$1,
|
|
532
549
|
id,
|
|
533
550
|
ariaLabel,
|
|
534
|
-
ariaLabelledBy
|
|
551
|
+
ariaLabelledBy,
|
|
552
|
+
placeholder$1
|
|
535
553
|
]);
|
|
536
554
|
useLayoutEffect(() => {
|
|
537
555
|
const view = editor.current;
|
|
@@ -564,7 +582,7 @@ function Label({ className, ...props }) {
|
|
|
564
582
|
//#region src/kbd.tsx
|
|
565
583
|
function Kbd({ className, ...props }) {
|
|
566
584
|
return /* @__PURE__ */ jsx("kbd", {
|
|
567
|
-
className: cn("inline-flex h-6 min-w-6 items-center justify-center rounded-sm border border-border bg-
|
|
585
|
+
className: cn("inline-flex h-6 min-w-6 items-center justify-center rounded-sm border border-border bg-transparent px-1.5 font-mono text-[11px] leading-none text-muted-foreground", className),
|
|
568
586
|
...props
|
|
569
587
|
});
|
|
570
588
|
}
|
|
@@ -589,6 +607,30 @@ function Banner({ tone = "info", className, children, ...props }) {
|
|
|
589
607
|
children
|
|
590
608
|
});
|
|
591
609
|
}
|
|
610
|
+
function BannerRow({ message, actions }) {
|
|
611
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
612
|
+
className: "flex flex-wrap items-center gap-x-3 gap-y-2",
|
|
613
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
614
|
+
className: "min-w-0 flex-1",
|
|
615
|
+
children: message
|
|
616
|
+
}), actions && /* @__PURE__ */ jsx("span", {
|
|
617
|
+
className: "ml-auto flex flex-wrap items-center gap-2",
|
|
618
|
+
children: actions
|
|
619
|
+
})]
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
function BannerDetails({ label, children }) {
|
|
623
|
+
return /* @__PURE__ */ jsxs("details", {
|
|
624
|
+
className: "mt-1",
|
|
625
|
+
children: [/* @__PURE__ */ jsx("summary", {
|
|
626
|
+
className: "w-fit cursor-pointer text-[11px] leading-4 text-muted-foreground underline underline-offset-2",
|
|
627
|
+
children: label
|
|
628
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
629
|
+
className: "pt-2",
|
|
630
|
+
children
|
|
631
|
+
})]
|
|
632
|
+
});
|
|
633
|
+
}
|
|
592
634
|
//#endregion
|
|
593
635
|
//#region src/toast.tsx
|
|
594
636
|
function useToastLifecycle({ id, duration, onDismiss, onRestoreFocus }) {
|
|
@@ -1409,6 +1451,7 @@ const icons = {
|
|
|
1409
1451
|
play: Play,
|
|
1410
1452
|
plus: Plus,
|
|
1411
1453
|
refresh: RefreshCw,
|
|
1454
|
+
repeat: Repeat,
|
|
1412
1455
|
scissors: Scissors,
|
|
1413
1456
|
search: Search,
|
|
1414
1457
|
share: Share2,
|
|
@@ -1417,11 +1460,11 @@ const icons = {
|
|
|
1417
1460
|
zap: Zap
|
|
1418
1461
|
};
|
|
1419
1462
|
function ActionIcon({ name, ...props }) {
|
|
1420
|
-
const Icon =
|
|
1463
|
+
const Icon = name !== void 0 && Object.hasOwn(icons, name) ? icons[name] : Zap;
|
|
1421
1464
|
return /* @__PURE__ */ jsx(Icon, {
|
|
1422
1465
|
"aria-hidden": "true",
|
|
1423
1466
|
...props
|
|
1424
1467
|
});
|
|
1425
1468
|
}
|
|
1426
1469
|
//#endregion
|
|
1427
|
-
export { ActionIcon, Autocomplete, AutocompleteClear, AutocompleteItem, AutocompletePopup, Banner, Button, Collapsible, ColorPicker, Combobox, ComboboxItem, ComboboxPopup, ConfirmDialog, ContextLabel, Dialog, DialogActions, DialogPopup, Field, FieldHint, IconButton, Input, Kbd, Label, ListRow, ListRowButton, ListRowDetail, ListRowTitle, MarkdownInput, Menu, MenuItem, MenuPopup, MenuRadioItem, PanelHeader, Popover, PopoverPopup, PreferenceSelect, PromptForm, RevealActions, SectionHeading, SidePanel, Spinner, Tabs, TextPromptDialog, ToastViewport, contrastColor, presetColors, useMediaQuery };
|
|
1470
|
+
export { ActionIcon, Autocomplete, AutocompleteClear, AutocompleteItem, AutocompletePopup, Banner, BannerDetails, BannerRow, Button, Collapsible, ColorPicker, Combobox, ComboboxItem, ComboboxPopup, ConfirmDialog, ContextLabel, Dialog, DialogActions, DialogPopup, Field, FieldHint, IconButton, Input, Kbd, Label, ListRow, ListRowButton, ListRowDetail, ListRowTitle, MarkdownInput, Menu, MenuItem, MenuPopup, MenuRadioItem, PanelHeader, PluginContent, PluginPage, Popover, PopoverPopup, PreferenceSelect, PromptForm, RevealActions, SectionHeading, SidePanel, Spinner, Tabs, TextPromptDialog, ToastViewport, contrastColor, presetColors, useMediaQuery };
|
package/dist/styles.css
CHANGED
|
@@ -24,6 +24,18 @@
|
|
|
24
24
|
--radius-lg: var(--radius-object);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
@layer base {
|
|
28
|
+
:root {
|
|
29
|
+
--nesso-panel-bar-height: 40px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@media (pointer: coarse) {
|
|
33
|
+
:root {
|
|
34
|
+
--nesso-panel-bar-height: 52px;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
27
39
|
@layer components {
|
|
28
40
|
.nesso-button,
|
|
29
41
|
.nesso-input,
|
|
@@ -138,7 +150,7 @@
|
|
|
138
150
|
align-items: center;
|
|
139
151
|
justify-content: space-between;
|
|
140
152
|
gap: 12px;
|
|
141
|
-
height:
|
|
153
|
+
height: var(--nesso-panel-bar-height);
|
|
142
154
|
padding: 0 14px 0 20px;
|
|
143
155
|
border-bottom: 1px solid var(--border);
|
|
144
156
|
}
|
|
@@ -146,12 +158,28 @@
|
|
|
146
158
|
display: flex;
|
|
147
159
|
flex-shrink: 0;
|
|
148
160
|
gap: 2px;
|
|
149
|
-
color: var(--muted-foreground);
|
|
150
161
|
}
|
|
151
162
|
.nesso-panel-actions button {
|
|
152
163
|
width: 26px;
|
|
153
164
|
height: 28px;
|
|
154
165
|
}
|
|
166
|
+
.nesso-plugin-page {
|
|
167
|
+
display: flex;
|
|
168
|
+
flex-direction: column;
|
|
169
|
+
height: 100%;
|
|
170
|
+
min-height: 0;
|
|
171
|
+
overflow: hidden;
|
|
172
|
+
background: var(--background);
|
|
173
|
+
color: var(--foreground);
|
|
174
|
+
font-family: var(--font-sans);
|
|
175
|
+
}
|
|
176
|
+
.nesso-plugin-content {
|
|
177
|
+
box-sizing: border-box;
|
|
178
|
+
width: 100%;
|
|
179
|
+
max-width: 40rem;
|
|
180
|
+
margin-inline: auto;
|
|
181
|
+
padding: clamp(1.5rem, 5vw, 3rem);
|
|
182
|
+
}
|
|
155
183
|
|
|
156
184
|
.side-panel {
|
|
157
185
|
position: relative;
|
package/package.json
CHANGED