@nesso-how/ui 1.0.0-beta.2 → 1.0.0-beta.21

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 CHANGED
@@ -39,19 +39,23 @@ Your build must compile this CSS; it is not a precompiled stylesheet. Supply the
39
39
 
40
40
  | Area | Exports |
41
41
  | ---------------------- | ------------------------------------------------------------------------------------------------------------------------- |
42
- | Buttons and inputs | `Button`, `IconButton`, `Input`, `MarkdownInput`, `Label`, `PreferenceSelect`, `ColorPicker` |
42
+ | Buttons and inputs | `Button`, `IconButton`, `Input`, `DirectoryField`, `MarkdownInput`, `Label`, `PreferenceSelect`, `ColorPicker` |
43
43
  | Forms and rows | `Field`, `FieldHint`, `ListRow`, `ListRowButton`, `ListRowDetail`, `ListRowTitle`, `RevealActions`, `PromptForm` |
44
44
  | Menus and popovers | `Menu`, `MenuItem`, `MenuPopup`, `MenuRadioItem`, `Popover`, `PopoverPopup` |
45
45
  | Search and suggestions | `Combobox`, `ComboboxItem`, `ComboboxPopup`, `Autocomplete`, `AutocompleteClear`, `AutocompleteItem`, `AutocompletePopup` |
46
- | Dialogs | `Dialog`, `DialogActions`, `DialogPopup`, `ConfirmDialog`, `TextPromptDialog` |
46
+ | Dialogs | `Dialog`, `DialogActions`, `DialogPopup`, `ConfirmDialog`, `TextPromptDialog`, `BottomSheet` |
47
47
  | Panels and disclosure | `SidePanel`, `PanelHeader`, `PluginPage`, `PluginContent`, `SectionHeading`, `Collapsible`, `Tabs` |
48
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
- `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.
53
+ `BottomSheet` is a controlled, non-modal drawer with a title, close label, optional footer, and popup ref for measuring covered content. It supports swipe-down dismissal, safe-area padding, and reduced motion. Reading text can use `--nesso-reading-font-size` and `--nesso-reading-line-height`, which increase from 13/20px to 15/23px on narrow screens or coarse pointers.
54
54
 
55
- `MarkdownInput` also accepts an optional `placeholder` shown only while the editor is empty.
55
+ `MarkdownInput` accepts Markdown through `value`/`onChange`, with live preview of emphasis, inline code, links, and lists. Syntax reappears around the selection. Cmd/Ctrl+B/I/E toggles bold, italic, and inline code; Enter continues or exits lists, Tab/Shift+Tab changes nesting, and Shift+Enter inserts a line break. Optional `tasks` enables clickable task checkboxes; `placeholder` appears when empty.
56
+
57
+ Undo/redo is local by default. Use `history={false}` for host-owned history or `history="focus"` to reset local history on blur and external value changes. Exhausted local history never falls through. Menu commands can send `beforeinput` events (`historyUndo`/`historyRedo`) to the focused editor inside `[data-local-history]`.
58
+
59
+ Cmd/Ctrl-click calls `onOpenLink`; read-only fields use a regular click. The host validates and opens destinations.
56
60
 
57
61
  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
@@ -1,6 +1,6 @@
1
1
  import { Button as Button$1 } from "@base-ui/react/button";
2
2
  import { VariantProps } from "class-variance-authority";
3
- import { ButtonHTMLAttributes, ComponentProps, HTMLAttributes, ReactNode } from "react";
3
+ import { ButtonHTMLAttributes, ComponentProps, HTMLAttributes, ReactNode, Ref } from "react";
4
4
  import { LucideIcon, Zap } from "lucide-react";
5
5
  import { Dialog, Dialog as Dialog$1 } from "@base-ui/react/dialog";
6
6
  import { Combobox } from "@base-ui/react/combobox";
@@ -55,16 +55,33 @@ export declare function useMediaQuery(query: string): boolean;
55
55
  //#region src/input.d.ts
56
56
  declare function Input({ className, type, ...props }: ComponentProps<'input'>): import("react").JSX.Element;
57
57
  //#endregion
58
+ //#region src/directory-field.d.ts
59
+ export declare function DirectoryField({ label, value, labels, disabled, changeDisabled, onOpen, onChange, onRestore }: {
60
+ label: string;
61
+ value?: string;
62
+ labels: {
63
+ open: string;
64
+ change: string;
65
+ restore: string;
66
+ };
67
+ disabled?: boolean;
68
+ changeDisabled?: boolean;
69
+ onOpen: () => void;
70
+ onChange: () => void;
71
+ onRestore?: () => void;
72
+ }): import("react").JSX.Element;
73
+ //#endregion
58
74
  //#region src/markdown-input.d.ts
59
75
  type MarkdownInputProps = Omit<ComponentProps<'div'>, 'onChange' | 'children' | 'defaultValue'> & {
60
76
  value: string;
61
77
  onChange: (value: string) => void;
62
78
  readOnly?: boolean;
63
- history?: boolean;
79
+ history?: boolean | 'focus';
80
+ tasks?: boolean;
64
81
  onOpenLink?: (url: string) => void;
65
82
  placeholder?: string;
66
83
  };
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;
84
+ export declare function MarkdownInput({ value, onChange, readOnly, history, tasks, onOpenLink, placeholder, className, id, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, ...props }: MarkdownInputProps): import("react").JSX.Element;
68
85
  //#endregion
69
86
  //#region src/label.d.ts
70
87
  declare function Label({ className, ...props }: ComponentProps<'label'>): import("react").JSX.Element;
@@ -140,6 +157,18 @@ export declare function ConfirmDialog({ open, onOpenChange, title, description,
140
157
  children?: ReactNode;
141
158
  }): import("react").JSX.Element;
142
159
  //#endregion
160
+ //#region src/sheet.d.ts
161
+ export declare function BottomSheet({ open, onOpenChange, title, closeLabel, popupRef, footer, className, children }: {
162
+ open: boolean;
163
+ onOpenChange: (open: boolean) => void;
164
+ title: ReactNode;
165
+ closeLabel: string;
166
+ popupRef?: Ref<HTMLDivElement>;
167
+ footer?: ReactNode;
168
+ className?: string;
169
+ children: ReactNode;
170
+ }): import("react").JSX.Element;
171
+ //#endregion
143
172
  //#region src/prompt.d.ts
144
173
  export declare function PromptForm({ initialValue, nameLabel, submitLabel, cancelLabel, maxLength, onSubmit }: {
145
174
  initialValue?: string;
package/dist/index.js CHANGED
@@ -5,11 +5,12 @@ import { jsx, jsxs } from "react/jsx-runtime";
5
5
  import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
6
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
- import { Annotation, Compartment, EditorSelection, EditorState, Transaction } from "@codemirror/state";
8
+ import { Annotation, Compartment, EditorSelection, EditorState, Facet, Transaction } from "@codemirror/state";
9
9
  import { Decoration, EditorView, ViewPlugin, WidgetType, keymap, placeholder } from "@codemirror/view";
10
- import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
11
- import { parser } from "@lezer/markdown";
10
+ import { defaultKeymap, history, historyKeymap, redo } from "@codemirror/commands";
11
+ import { TaskList, parser } from "@lezer/markdown";
12
12
  import { Dialog, Dialog as Dialog$1 } from "@base-ui/react/dialog";
13
+ import { Drawer } from "@base-ui/react/drawer";
13
14
  import { Combobox } from "@base-ui/react/combobox";
14
15
  import { Menu } from "@base-ui/react/menu";
15
16
  import { Popover } from "@base-ui/react/popover";
@@ -236,27 +237,166 @@ function Input({ className, type, ...props }) {
236
237
  });
237
238
  }
238
239
  //#endregion
240
+ //#region src/directory-field.tsx
241
+ function DirectoryField({ label, value, labels, disabled, changeDisabled, onOpen, onChange, onRestore }) {
242
+ const id = useId();
243
+ return /* @__PURE__ */ jsxs("div", {
244
+ className: "mt-4",
245
+ children: [
246
+ /* @__PURE__ */ jsx("label", {
247
+ htmlFor: id,
248
+ className: "block text-xs",
249
+ children: label
250
+ }),
251
+ /* @__PURE__ */ jsxs("div", {
252
+ className: "mt-2 flex items-center gap-2",
253
+ children: [/* @__PURE__ */ jsxs("div", {
254
+ className: "relative min-w-0 flex-1",
255
+ children: [/* @__PURE__ */ jsx(Input, {
256
+ id,
257
+ className: "pr-10",
258
+ readOnly: true,
259
+ value: value ?? "",
260
+ title: value
261
+ }), /* @__PURE__ */ jsx(IconButton, {
262
+ className: "absolute top-1/2 right-1 -translate-y-1/2 text-muted-foreground",
263
+ "aria-label": labels.open,
264
+ title: labels.open,
265
+ disabled,
266
+ onClick: onOpen,
267
+ children: /* @__PURE__ */ jsx(Folder, { "aria-hidden": "true" })
268
+ })]
269
+ }), /* @__PURE__ */ jsx(Button, {
270
+ variant: "outline",
271
+ disabled: disabled || changeDisabled,
272
+ onClick: onChange,
273
+ children: labels.change
274
+ })]
275
+ }),
276
+ onRestore && /* @__PURE__ */ jsxs(Button, {
277
+ variant: "ghost",
278
+ size: "sm",
279
+ className: "mt-2",
280
+ disabled: disabled || changeDisabled,
281
+ onClick: onRestore,
282
+ children: [/* @__PURE__ */ jsx(RotateCcw, { "aria-hidden": "true" }), labels.restore]
283
+ })
284
+ ]
285
+ });
286
+ }
287
+ //#endregion
239
288
  //#region src/markdown.ts
240
289
  const listPrefix = /^(\s*)([-+*]|(\d{1,9})([.)]))([\t ]+|$)/;
290
+ const taskPrefix = /^\[[ xX]\]([\t ]+|$)/;
291
+ const taskParser = parser.configure(TaskList);
292
+ const formats = {
293
+ "**": {
294
+ node: "StrongEmphasis",
295
+ mark: "EmphasisMark",
296
+ decoration: Decoration.mark({ class: "nesso-markdown-bold" })
297
+ },
298
+ "*": {
299
+ node: "Emphasis",
300
+ mark: "EmphasisMark",
301
+ decoration: Decoration.mark({ class: "nesso-markdown-italic" })
302
+ },
303
+ "`": {
304
+ node: "InlineCode",
305
+ mark: "CodeMark",
306
+ decoration: Decoration.mark({
307
+ class: "nesso-markdown-code",
308
+ attributes: { spellcheck: "false" }
309
+ })
310
+ }
311
+ };
312
+ const markdownTasks = Facet.define({ combine: (values) => values.some(Boolean) });
313
+ const parse = (state) => (state.facet(markdownTasks) ? taskParser : parser).parse(state.doc.toString());
241
314
  var ListMarker = class extends WidgetType {
242
315
  label;
243
- constructor(label) {
316
+ checked;
317
+ constructor(label, checked = null) {
244
318
  super();
245
319
  this.label = label;
320
+ this.checked = checked;
246
321
  }
247
322
  eq(other) {
248
- return this.label === other.label;
323
+ return this.label === other.label && this.checked === other.checked;
249
324
  }
250
325
  toDOM(view) {
251
- const marker = view.dom.ownerDocument.createElement("span");
326
+ const document = view.dom.ownerDocument;
327
+ const marker = document.createElement("span");
252
328
  marker.className = "nesso-markdown-list-marker";
253
329
  marker.textContent = this.label;
330
+ if (this.label === "• ") {
331
+ const bullet = document.createElement("span");
332
+ bullet.className = "nesso-markdown-bullet";
333
+ bullet.textContent = "•";
334
+ marker.replaceChildren(bullet, document.createTextNode(" "));
335
+ }
336
+ if (this.checked !== null) {
337
+ const checkbox = document.createElement("input");
338
+ checkbox.type = "checkbox";
339
+ checkbox.className = "nesso-markdown-task";
340
+ checkbox.checked = this.checked;
341
+ checkbox.tabIndex = -1;
342
+ marker.append(checkbox);
343
+ }
254
344
  return marker;
255
345
  }
256
346
  ignoreEvent() {
257
347
  return false;
258
348
  }
259
349
  };
350
+ function markerWidth(item) {
351
+ const marker = item.getChild("ListMark");
352
+ const task = item.getChild("Task") ? 1.4 : 0;
353
+ return item.parent?.name === "BulletList" ? {
354
+ ch: 0,
355
+ em: task || 1
356
+ } : {
357
+ ch: marker.to - marker.from - 1,
358
+ em: .75 + task
359
+ };
360
+ }
361
+ function markerLabel(state, item, checked) {
362
+ if (item.parent?.name !== "BulletList") {
363
+ const marker = item.getChild("ListMark");
364
+ return `${state.sliceDoc(marker.from, marker.to)} `;
365
+ }
366
+ return checked === null ? "• " : "";
367
+ }
368
+ function listPadding(item) {
369
+ const padding = {
370
+ ch: 0,
371
+ em: 0
372
+ };
373
+ for (let node = item; node; node = node.parent) {
374
+ if (node.name !== "ListItem") continue;
375
+ const width = markerWidth(node);
376
+ padding.ch += width.ch;
377
+ padding.em += width.em;
378
+ }
379
+ return padding;
380
+ }
381
+ function listItemDecorations(state, item, active) {
382
+ const marker = item.getChild("ListMark");
383
+ const task = item.getChild("Task");
384
+ const taskMarker = task?.getChild("TaskMarker");
385
+ const checked = taskMarker ? state.sliceDoc(taskMarker.from + 1, taskMarker.from + 2) !== " " : null;
386
+ const line = state.doc.lineAt(marker.from);
387
+ const from = /^[\t ]*$/.test(state.sliceDoc(line.from, marker.from)) ? line.from : marker.from;
388
+ const start = taskMarker?.to ?? marker.to;
389
+ const end = start + state.sliceDoc(start, line.to).match(/^[\t ]*/)[0].length;
390
+ const label = markerLabel(state, item, checked);
391
+ const width = markerWidth(item);
392
+ const padding = listPadding(item);
393
+ const decorations = [Decoration.line({
394
+ class: "nesso-markdown-list-item",
395
+ attributes: { style: `--nesso-list-indent: calc(${width.ch}ch + ${width.em}em); --nesso-list-padding: calc(var(--nesso-list-inset) + ${padding.ch}ch + ${padding.em}em)` }
396
+ }).range(line.from), (active ? Decoration.mark({ class: "nesso-markdown-syntax nesso-markdown-list-marker" }) : Decoration.replace({ widget: new ListMarker(label, checked) })).range(from, end)];
397
+ if (checked && task && end < task.to) decorations.push(Decoration.mark({ class: "nesso-markdown-task-done" }).range(end, task.to));
398
+ return decorations;
399
+ }
260
400
  function markdownDecorations(state, focused) {
261
401
  const source = state.doc.toString();
262
402
  const decorations = [];
@@ -265,29 +405,19 @@ function markdownDecorations(state, focused) {
265
405
  const decoration = active ? Decoration.mark({ class: "nesso-markdown-syntax" }) : Decoration.replace({});
266
406
  decorations.push(decoration.range(from, to));
267
407
  };
268
- parser.parse(source).iterate({ enter(node) {
408
+ parse(state).iterate({ enter(node) {
269
409
  if ([
270
410
  "Image",
271
- "InlineCode",
272
411
  "FencedCode",
273
412
  "CodeBlock",
274
413
  "HTMLBlock"
275
414
  ].includes(node.name)) return false;
276
415
  const active = focused && state.selection.ranges.some((range) => range.from <= node.to && range.to >= node.from);
277
- if (node.name === "ListItem") {
278
- const marker = node.node.getChild("ListMark");
279
- const line = state.doc.lineAt(marker.from);
280
- const end = marker.to + (source.slice(marker.to, line.to).match(/^[\t ]*/)?.[0].length ?? 0);
281
- const label = node.node.parent?.name === "BulletList" ? "•" : source.slice(marker.from, marker.to);
282
- const width = Math.max(3, end - marker.from);
283
- decorations.push(Decoration.line({
284
- class: "nesso-markdown-list-item",
285
- attributes: { style: `--nesso-list-indent: ${width}ch; --nesso-list-padding: ${marker.from - line.from + width}ch` }
286
- }).range(line.from), (active ? Decoration.mark({ class: "nesso-markdown-syntax nesso-markdown-list-marker" }) : Decoration.replace({ widget: new ListMarker(`${label} `) })).range(marker.from, end));
287
- }
288
- if (node.name === "StrongEmphasis" || node.name === "Emphasis") {
289
- const [open, close] = node.node.getChildren("EmphasisMark");
290
- decorations.push(Decoration.mark({ class: node.name === "StrongEmphasis" ? "nesso-markdown-bold" : "nesso-markdown-italic" }).range(open.to, close.from));
416
+ if (node.name === "ListItem") decorations.push(...listItemDecorations(state, node.node, active));
417
+ const format = Object.values(formats).find((format) => format.node === node.name);
418
+ if (format) {
419
+ const [open, close] = node.node.getChildren(format.mark);
420
+ decorations.push(format.decoration.range(open.to, close.from));
291
421
  syntax(open.from, open.to, active);
292
422
  syntax(close.from, close.to, active);
293
423
  }
@@ -309,7 +439,7 @@ function markdownListItem(state) {
309
439
  if (state.readOnly || state.selection.ranges.length !== 1) return null;
310
440
  const { from, to } = state.selection.main;
311
441
  if (to > state.doc.lineAt(from).to) return null;
312
- let node = parser.parse(state.doc.toString()).resolveInner(from, -1);
442
+ let node = parse(state).resolveInner(from, -1);
313
443
  while (node.name !== "ListItem") {
314
444
  if ([
315
445
  "FencedCode",
@@ -377,12 +507,17 @@ function continueMarkdownList(state) {
377
507
  if (!item) return null;
378
508
  const { node, firstLine, prefix } = item;
379
509
  let { from, to } = state.selection.main;
380
- if (from < firstLine.from + prefix[0].length) return null;
381
- let insert = nextListPrefix(prefix);
382
- if (state.doc.lineAt(from).from === firstLine.from && !firstLine.text.slice(prefix[0].length).trim()) {
510
+ const task = state.facet(markdownTasks) ? firstLine.text.slice(prefix[0].length).match(taskPrefix)?.[0] ?? "" : "";
511
+ if (from < firstLine.from + prefix[0].length + task.length) return null;
512
+ const next = (prefix) => {
513
+ const marker = nextListPrefix(prefix);
514
+ return marker === null ? null : marker + (task && "[ ] ");
515
+ };
516
+ let insert = next(prefix);
517
+ if (state.doc.lineAt(from).from === firstLine.from && !firstLine.text.slice(prefix[0].length + task.length).trim()) {
383
518
  const parent = node.parent?.parent;
384
519
  const parentPrefix = parent?.name === "ListItem" ? state.doc.lineAt(parent.from).text.match(listPrefix) : null;
385
- insert = parentPrefix ? nextListPrefix(parentPrefix) : "";
520
+ insert = parentPrefix ? next(parentPrefix) : "";
386
521
  from = firstLine.from;
387
522
  to = firstLine.to;
388
523
  } else if (insert !== null) insert = `\n${insert}`;
@@ -397,14 +532,29 @@ function continueMarkdownList(state) {
397
532
  userEvent: "input"
398
533
  };
399
534
  }
535
+ function toggleMarkdownTask(state, position) {
536
+ if (state.readOnly || !state.facet(markdownTasks)) return null;
537
+ const marker = parse(state).resolveInner(position, 1).parent?.getChild("Task")?.getChild("TaskMarker");
538
+ if (!marker) return null;
539
+ const from = marker.from + 1;
540
+ return {
541
+ changes: {
542
+ from,
543
+ to: from + 1,
544
+ insert: state.sliceDoc(from, from + 1) === " " ? "x" : " "
545
+ },
546
+ userEvent: "input.toggle"
547
+ };
548
+ }
400
549
  function toggleMarkdownFormat(state, marker) {
401
550
  if (state.readOnly) return null;
402
551
  const { from, to } = state.selection.main;
403
552
  const selected = state.sliceDoc(from, to);
553
+ const format = formats[marker];
404
554
  let delimiters;
405
- parser.parse(state.doc.toString()).iterate({ enter(node) {
406
- if (node.name !== (marker === "**" ? "StrongEmphasis" : "Emphasis")) return;
407
- const [open, close] = node.node.getChildren("EmphasisMark");
555
+ parse(state).iterate({ enter(node) {
556
+ if (node.name !== format.node) return;
557
+ const [open, close] = node.node.getChildren(format.mark);
408
558
  if (from === node.from && to === node.to || from >= open.to && to <= close.from) delimiters = [open, close].map(({ from, to }) => ({
409
559
  from,
410
560
  to
@@ -431,13 +581,32 @@ function toggleMarkdownFormat(state, marker) {
431
581
  //#endregion
432
582
  //#region src/markdown-input.tsx
433
583
  const externalChange = Annotation.define();
584
+ const resetHistory = (view, compartment) => {
585
+ view.dispatch({ effects: compartment.reconfigure([]) });
586
+ view.dispatch({ effects: compartment.reconfigure(history()) });
587
+ };
434
588
  const livePreview = ViewPlugin.define((view) => ({
435
589
  decorations: markdownDecorations(view.state, view.hasFocus && !view.state.readOnly),
436
590
  update(update) {
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);
591
+ if (update.docChanged || update.selectionSet || update.focusChanged || update.startState.readOnly !== update.state.readOnly || update.startState.facet(markdownTasks) !== update.state.facet(markdownTasks)) this.decorations = markdownDecorations(update.state, update.view.hasFocus && !update.state.readOnly);
438
592
  }
439
593
  }), { decorations: (plugin) => plugin.decorations });
440
- function MarkdownInput({ value, onChange, readOnly = false, history: history$1 = true, onOpenLink, placeholder: placeholder$1, className, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...props }) {
594
+ const taskCheckboxes = EditorView.domEventHandlers({
595
+ mousedown(event, view) {
596
+ const task = event.target.closest(".nesso-markdown-task");
597
+ if (!task) return false;
598
+ event.preventDefault();
599
+ const transaction = toggleMarkdownTask(view.state, view.posAtDOM(task));
600
+ if (transaction) view.dispatch(transaction);
601
+ return true;
602
+ },
603
+ click(event) {
604
+ if (!event.target.closest(".nesso-markdown-task")) return false;
605
+ event.preventDefault();
606
+ return true;
607
+ }
608
+ });
609
+ function MarkdownInput({ value, onChange, readOnly = false, history: history$1 = true, tasks, onOpenLink, placeholder: placeholder$1, className, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...props }) {
441
610
  const container = useRef(null);
442
611
  const editor = useRef(null);
443
612
  const callbacks = useRef({
@@ -445,6 +614,7 @@ function MarkdownInput({ value, onChange, readOnly = false, history: history$1 =
445
614
  onOpenLink
446
615
  });
447
616
  const [configuration] = useState(() => new Compartment());
617
+ const [historyState] = useState(() => new Compartment());
448
618
  const [initialValue] = useState(value);
449
619
  useLayoutEffect(() => {
450
620
  callbacks.current = {
@@ -468,10 +638,11 @@ function MarkdownInput({ value, onChange, readOnly = false, history: history$1 =
468
638
  ".cm-content, .cm-line": { padding: "0" },
469
639
  ".cm-line.nesso-markdown-list-item": {
470
640
  paddingInlineStart: "var(--nesso-list-padding)",
471
- textIndent: "calc(-1 * var(--nesso-list-padding))"
641
+ textIndent: "calc(-1 * var(--nesso-list-indent))"
472
642
  }
473
643
  }),
474
644
  livePreview,
645
+ taskCheckboxes,
475
646
  configuration.of([]),
476
647
  keymap.of([
477
648
  ...["Tab", "Shift-Tab"].map((key) => ({
@@ -498,8 +669,12 @@ function MarkdownInput({ value, onChange, readOnly = false, history: history$1 =
498
669
  return true;
499
670
  }
500
671
  },
501
- ...["**", "*"].map((marker) => ({
502
- key: marker === "**" ? "Mod-b" : "Mod-i",
672
+ ...[
673
+ ["Mod-b", "**"],
674
+ ["Mod-i", "*"],
675
+ ["Mod-e", "`"]
676
+ ].map(([key, marker]) => ({
677
+ key,
503
678
  run: (view) => {
504
679
  const transaction = toggleMarkdownFormat(view.state, marker);
505
680
  if (!transaction) return false;
@@ -531,6 +706,7 @@ function MarkdownInput({ value, onChange, readOnly = false, history: history$1 =
531
706
  editor.current?.dispatch({ effects: configuration.reconfigure([
532
707
  EditorState.readOnly.of(readOnly),
533
708
  EditorView.editable.of(!readOnly),
709
+ markdownTasks.of(tasks),
534
710
  EditorView.contentAttributes.of({
535
711
  ...id ? { id } : {},
536
712
  ...ariaLabel ? { "aria-label": ariaLabel } : {},
@@ -539,13 +715,22 @@ function MarkdownInput({ value, onChange, readOnly = false, history: history$1 =
539
715
  "aria-readonly": String(readOnly),
540
716
  spellcheck: "true"
541
717
  }),
542
- ...history$1 ? [history(), keymap.of(historyKeymap)] : [],
718
+ ...history$1 ? [historyState.of(history()), keymap.of([...historyKeymap, {
719
+ key: "Mod-Shift-z",
720
+ run: redo,
721
+ preventDefault: true
722
+ }])] : [],
723
+ ...history$1 === "focus" ? [EditorView.domEventHandlers({ blur(_event, view) {
724
+ resetHistory(view, historyState);
725
+ } })] : [],
543
726
  ...placeholder$1 ? [placeholder(placeholder$1)] : []
544
727
  ]) });
545
728
  }, [
546
729
  configuration,
730
+ historyState,
547
731
  readOnly,
548
732
  history$1,
733
+ tasks,
549
734
  id,
550
735
  ariaLabel,
551
736
  ariaLabelledBy,
@@ -554,6 +739,7 @@ function MarkdownInput({ value, onChange, readOnly = false, history: history$1 =
554
739
  useLayoutEffect(() => {
555
740
  const view = editor.current;
556
741
  if (!view || value === view.state.doc.toString()) return;
742
+ if (history$1 === "focus") resetHistory(view, historyState);
557
743
  view.dispatch({
558
744
  changes: {
559
745
  from: 0,
@@ -562,11 +748,16 @@ function MarkdownInput({ value, onChange, readOnly = false, history: history$1 =
562
748
  },
563
749
  annotations: [externalChange.of(true), Transaction.addToHistory.of(false)]
564
750
  });
565
- }, [value]);
751
+ }, [
752
+ value,
753
+ history$1,
754
+ historyState
755
+ ]);
566
756
  return /* @__PURE__ */ jsx("div", {
567
757
  ...props,
568
758
  ref: container,
569
- className: cn("nesso-input nesso-markdown-input min-h-24 w-full overflow-y-auto border border-input bg-background px-2.5 py-2 focus-within:border-muted-foreground", className)
759
+ "data-local-history": history$1 ? "" : void 0,
760
+ className: cn("nesso-input nesso-markdown-input nesso-scroll min-h-24 w-full overflow-y-auto border border-input bg-background px-2.5 py-2 focus-within:border-muted-foreground", className)
570
761
  });
571
762
  }
572
763
  //#endregion
@@ -858,6 +1049,53 @@ function ConfirmDialog({ open, onOpenChange, title, description, cancelLabel, co
858
1049
  });
859
1050
  }
860
1051
  //#endregion
1052
+ //#region src/sheet.tsx
1053
+ function BottomSheet({ open, onOpenChange, title, closeLabel, popupRef, footer, className, children }) {
1054
+ return /* @__PURE__ */ jsx(Drawer.Root, {
1055
+ open,
1056
+ onOpenChange,
1057
+ modal: false,
1058
+ disablePointerDismissal: true,
1059
+ swipeDirection: "down",
1060
+ children: /* @__PURE__ */ jsx(Drawer.Portal, { children: /* @__PURE__ */ jsx(Drawer.Viewport, {
1061
+ className: "pointer-events-none fixed inset-0 z-40 flex items-end pr-[env(safe-area-inset-right)] pl-[env(safe-area-inset-left)]",
1062
+ children: /* @__PURE__ */ jsxs(Drawer.Popup, {
1063
+ ref: popupRef,
1064
+ className: cn("nesso-sheet pointer-events-auto", className),
1065
+ initialFocus: false,
1066
+ children: [
1067
+ /* @__PURE__ */ jsx("div", {
1068
+ "aria-hidden": "true",
1069
+ className: "nesso-sheet-handle"
1070
+ }),
1071
+ /* @__PURE__ */ jsxs("div", {
1072
+ className: "flex shrink-0 items-center justify-between gap-2 pr-2 pl-5",
1073
+ children: [/* @__PURE__ */ jsx(Drawer.Title, {
1074
+ className: "nesso-sheet-title",
1075
+ children: title
1076
+ }), /* @__PURE__ */ jsx(Drawer.Close, {
1077
+ render: /* @__PURE__ */ jsx(IconButton, {
1078
+ className: "min-h-11 min-w-11",
1079
+ "aria-label": closeLabel,
1080
+ title: closeLabel
1081
+ }),
1082
+ children: /* @__PURE__ */ jsx(X, {})
1083
+ })]
1084
+ }),
1085
+ /* @__PURE__ */ jsx(Drawer.Content, {
1086
+ className: "nesso-scroll min-h-0 flex-1 overflow-y-auto overscroll-contain px-5 pt-1 pb-5",
1087
+ children
1088
+ }),
1089
+ footer && /* @__PURE__ */ jsx("div", {
1090
+ className: "nesso-sheet-footer",
1091
+ children: footer
1092
+ })
1093
+ ]
1094
+ })
1095
+ }) })
1096
+ });
1097
+ }
1098
+ //#endregion
861
1099
  //#region src/prompt.tsx
862
1100
  function PromptForm({ initialValue = "", nameLabel, submitLabel, cancelLabel, maxLength, onSubmit }) {
863
1101
  const [value, setValue] = useState(initialValue);
@@ -1028,7 +1266,7 @@ function MenuPopup({ className, align = "start", anchor, sideOffset = 4, childre
1028
1266
  sideOffset,
1029
1267
  className: "z-50",
1030
1268
  children: /* @__PURE__ */ jsx(Menu.Popup, {
1031
- className: cn("nesso-popup w-max min-w-32 max-w-[calc(100vw-32px)] max-h-(--available-height) overflow-y-auto p-1", className),
1269
+ className: cn("nesso-popup nesso-scroll w-max min-w-32 max-w-[calc(100vw-32px)] max-h-(--available-height) overflow-y-auto p-1", className),
1032
1270
  ...props,
1033
1271
  children
1034
1272
  })
@@ -1059,7 +1297,7 @@ function PopoverPopup({ className, anchor, align = "start", sideOffset = 4, chil
1059
1297
  sideOffset,
1060
1298
  className: "z-50",
1061
1299
  children: /* @__PURE__ */ jsx(Popover.Popup, {
1062
- className: cn("nesso-popup z-50 max-h-(--available-height) overflow-y-auto p-3 outline-none", className),
1300
+ className: cn("nesso-popup nesso-scroll z-50 max-h-(--available-height) overflow-y-auto p-3 outline-none", className),
1063
1301
  ...props,
1064
1302
  children
1065
1303
  })
@@ -1402,7 +1640,7 @@ function AutocompletePopup({ className, children, ...props }) {
1402
1640
  sideOffset: 4,
1403
1641
  className: "z-50 outline-none",
1404
1642
  children: /* @__PURE__ */ jsx(Autocomplete.Popup, {
1405
- className: cn("nesso-popup max-h-72 w-(--anchor-width) overflow-y-auto p-1", className),
1643
+ className: cn("nesso-popup nesso-scroll max-h-72 w-(--anchor-width) overflow-y-auto p-1", className),
1406
1644
  ...props,
1407
1645
  children
1408
1646
  })
@@ -1467,4 +1705,4 @@ function ActionIcon({ name, ...props }) {
1467
1705
  });
1468
1706
  }
1469
1707
  //#endregion
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 };
1708
+ export { ActionIcon, Autocomplete, AutocompleteClear, AutocompleteItem, AutocompletePopup, Banner, BannerDetails, BannerRow, BottomSheet, Button, Collapsible, ColorPicker, Combobox, ComboboxItem, ComboboxPopup, ConfirmDialog, ContextLabel, Dialog, DialogActions, DialogPopup, DirectoryField, 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
@@ -27,11 +27,15 @@
27
27
  @layer base {
28
28
  :root {
29
29
  --nesso-panel-bar-height: 40px;
30
+ --nesso-reading-font-size: 13px;
31
+ --nesso-reading-line-height: 20px;
30
32
  }
31
33
 
32
34
  @media (pointer: coarse) {
33
35
  :root {
34
36
  --nesso-panel-bar-height: 52px;
37
+ --nesso-reading-font-size: 15px;
38
+ --nesso-reading-line-height: 23px;
35
39
  }
36
40
  }
37
41
  }
@@ -57,6 +61,7 @@
57
61
  }
58
62
 
59
63
  .nesso-markdown-input {
64
+ --nesso-list-inset: 0.5em;
60
65
  display: flex;
61
66
  }
62
67
 
@@ -66,13 +71,23 @@
66
71
  }
67
72
 
68
73
  .nesso-markdown-bold {
69
- font-weight: 700;
74
+ font-weight: 600;
70
75
  }
71
76
 
72
77
  .nesso-markdown-italic {
73
78
  font-style: italic;
74
79
  }
75
80
 
81
+ .nesso-markdown-code {
82
+ padding: 2px 4px;
83
+ border-radius: var(--radius-control);
84
+ background: var(--sidebar);
85
+ font-family: var(--font-mono);
86
+ font-size: 0.92em;
87
+ box-decoration-break: clone;
88
+ -webkit-box-decoration-break: clone;
89
+ }
90
+
76
91
  .nesso-markdown-link {
77
92
  color: var(--primary);
78
93
  text-decoration: underline;
@@ -88,6 +103,29 @@
88
103
  text-indent: 0;
89
104
  }
90
105
 
106
+ .nesso-markdown-bullet {
107
+ display: inline-block;
108
+ transform: scale(1.2);
109
+ }
110
+
111
+ .nesso-markdown-task {
112
+ width: 0.875em;
113
+ height: 0.875em;
114
+ margin: 0;
115
+ vertical-align: -0.1em;
116
+ accent-color: var(--primary);
117
+ cursor: pointer;
118
+ }
119
+
120
+ .nesso-markdown-input [aria-readonly='true'] .nesso-markdown-task {
121
+ cursor: default;
122
+ }
123
+
124
+ .nesso-markdown-task-done {
125
+ color: var(--muted-foreground);
126
+ text-decoration: line-through;
127
+ }
128
+
91
129
  .nesso-popup {
92
130
  border: 1px solid var(--border);
93
131
  border-radius: var(--radius-object);
@@ -97,6 +135,57 @@
97
135
  outline: none;
98
136
  }
99
137
 
138
+ .nesso-sheet {
139
+ display: flex;
140
+ width: 100%;
141
+ max-height: min(60dvh, calc(100dvh - 96px));
142
+ flex-direction: column;
143
+ border-top: 1px solid var(--border);
144
+ border-radius: calc(var(--radius-object) * 2) calc(var(--radius-object) * 2) 0 0;
145
+ background: var(--background);
146
+ color: var(--foreground);
147
+ box-shadow: 0 -8px 24px #00000014;
148
+ outline: none;
149
+ transform: translateY(var(--drawer-swipe-movement-y, 0px));
150
+ transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
151
+ }
152
+
153
+ .nesso-sheet[data-swiping] {
154
+ transition-duration: 0s;
155
+ user-select: none;
156
+ }
157
+
158
+ .nesso-sheet[data-starting-style],
159
+ .nesso-sheet[data-ending-style] {
160
+ transform: translateY(calc(100% + 2px));
161
+ }
162
+
163
+ .nesso-sheet-handle {
164
+ flex-shrink: 0;
165
+ width: 36px;
166
+ height: 4px;
167
+ margin: 8px auto 0;
168
+ border-radius: 2px;
169
+ background: var(--node-border);
170
+ }
171
+
172
+ .nesso-sheet-title {
173
+ min-width: 0;
174
+ font-size: 18px;
175
+ line-height: 24px;
176
+ font-weight: 500;
177
+ overflow-wrap: anywhere;
178
+ }
179
+
180
+ .nesso-sheet-footer {
181
+ display: flex;
182
+ flex-shrink: 0;
183
+ align-items: center;
184
+ gap: 12px;
185
+ padding: 12px 20px calc(16px + env(safe-area-inset-bottom, 0px));
186
+ border-top: 1px solid var(--border);
187
+ }
188
+
100
189
  .nesso-option[data-highlighted] {
101
190
  background: var(--hover);
102
191
  }
@@ -163,6 +252,10 @@
163
252
  width: 26px;
164
253
  height: 28px;
165
254
  }
255
+ .nesso-scroll {
256
+ scrollbar-width: thin;
257
+ scrollbar-color: var(--border) transparent;
258
+ }
166
259
  .nesso-plugin-page {
167
260
  display: flex;
168
261
  flex-direction: column;
@@ -340,6 +433,9 @@
340
433
  }
341
434
 
342
435
  @media (prefers-reduced-motion: reduce) {
436
+ .nesso-sheet {
437
+ transition: none;
438
+ }
343
439
  *,
344
440
  *::before,
345
441
  *::after {
@@ -468,6 +564,7 @@
468
564
  color: var(--muted-foreground);
469
565
  font-size: 12px;
470
566
  line-height: 18px;
567
+ white-space: pre-line;
471
568
  }
472
569
  .toast-actions {
473
570
  display: flex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nesso-how/ui",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.21",
4
4
  "description": "Reusable React primitives and shared styles for Nesso, usable in the app and in isolated plugin panels",
5
5
  "license": "MIT",
6
6
  "repository": {