@diegopluna/narvi 0.3.2 → 0.3.3
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/dist/components/activity/ActivityIcon.svelte +54 -0
- package/dist/components/activity/ActivityIcon.svelte.d.ts +24 -0
- package/dist/components/activity/ActivityStep.svelte +47 -13
- package/dist/components/activity/ActivityStep.svelte.d.ts +13 -4
- package/dist/components/activity/ActivityThought.svelte +24 -5
- package/dist/components/activity/ActivityThought.svelte.d.ts +12 -2
- package/dist/components/activity/index.d.ts +3 -1
- package/dist/components/activity/index.js +2 -1
- package/dist/components/app-shell/AppShellHeader.svelte +18 -4
- package/dist/components/app-shell/AppShellHeader.svelte.d.ts +5 -0
- package/dist/components/approval/Approval.svelte +14 -1
- package/dist/components/approval/Approval.svelte.d.ts +5 -0
- package/dist/components/badge/Badge.svelte +3 -1
- package/dist/components/badge/Badge.svelte.d.ts +1 -1
- package/dist/components/button/Button.svelte +17 -6
- package/dist/components/composer/ComposerModelPicker.svelte +80 -13
- package/dist/components/composer/ComposerModelPicker.svelte.d.ts +23 -6
- package/dist/components/composer/ComposerRoot.svelte +51 -12
- package/dist/components/composer/ComposerRoot.svelte.d.ts +16 -0
- package/dist/components/composer/ComposerSubmit.svelte +19 -5
- package/dist/components/composer/ComposerSubmit.svelte.d.ts +3 -1
- package/dist/components/composer/ComposerToggle.svelte +18 -4
- package/dist/components/composer/ComposerToggle.svelte.d.ts +2 -0
- package/dist/components/composer/ComposerTray.svelte +17 -3
- package/dist/components/composer/ComposerTray.svelte.d.ts +5 -0
- package/dist/components/composer/context.d.ts +4 -1
- package/dist/components/dialog/DialogContent.svelte +22 -12
- package/dist/components/dialog/DialogContent.svelte.d.ts +10 -0
- package/dist/components/divider/Divider.svelte +56 -14
- package/dist/components/divider/Divider.svelte.d.ts +13 -3
- package/dist/components/empty-state/EmptyState.svelte +12 -2
- package/dist/components/empty-state/EmptyState.svelte.d.ts +6 -0
- package/dist/components/heading/Heading.svelte +15 -0
- package/dist/components/heading/Heading.svelte.d.ts +6 -0
- package/dist/components/hover-card/HoverCardContent.svelte +18 -2
- package/dist/components/hover-card/HoverCardContent.svelte.d.ts +8 -0
- package/dist/components/input/Input.svelte +13 -3
- package/dist/components/input/Input.svelte.d.ts +10 -2
- package/dist/components/markdown/Markdown.svelte +22 -2
- package/dist/components/markdown/MarkdownDiagram.svelte +33 -2
- package/dist/components/markdown/MarkdownFile.svelte +56 -10
- package/dist/components/markdown/MarkdownMath.svelte +6 -0
- package/dist/components/markdown/MarkdownTable.svelte +3 -4
- package/dist/components/markdown/context.d.ts +6 -0
- package/dist/components/markdown/labels.d.ts +7 -0
- package/dist/components/markdown/labels.js +2 -0
- package/dist/components/menu/MenuCheckboxItem.svelte +44 -7
- package/dist/components/menu/MenuCheckboxItem.svelte.d.ts +12 -2
- package/dist/components/menu/MenuContent.svelte +10 -2
- package/dist/components/menu/MenuContent.svelte.d.ts +10 -0
- package/dist/components/menu/MenuItem.svelte +17 -2
- package/dist/components/menu/MenuItem.svelte.d.ts +8 -0
- package/dist/components/menu/MenuSubContent.svelte +10 -2
- package/dist/components/menu/MenuSubContent.svelte.d.ts +10 -0
- package/dist/components/menu/MenuSubTrigger.svelte +19 -2
- package/dist/components/menu/MenuSubTrigger.svelte.d.ts +6 -0
- package/dist/components/message/MessageBubble.svelte +40 -0
- package/dist/components/message/MessageBubble.svelte.d.ts +12 -0
- package/dist/components/message/MessageContent.svelte +23 -14
- package/dist/components/message/MessageContent.svelte.d.ts +6 -0
- package/dist/components/message/MessageCopy.svelte +27 -15
- package/dist/components/message/MessageCopy.svelte.d.ts +9 -2
- package/dist/components/message/MessageRoot.svelte +20 -3
- package/dist/components/message/MessageRoot.svelte.d.ts +6 -0
- package/dist/components/message/context.d.ts +2 -0
- package/dist/components/message/index.d.ts +4 -1
- package/dist/components/message/index.js +3 -2
- package/dist/components/message/styles.d.ts +30 -0
- package/dist/components/message/styles.js +24 -0
- package/dist/components/notice/Notice.svelte +3 -3
- package/dist/components/popover/PopoverContent.svelte +27 -3
- package/dist/components/popover/PopoverContent.svelte.d.ts +18 -0
- package/dist/components/questionnaire/Questionnaire.svelte +103 -19
- package/dist/components/questionnaire/Questionnaire.svelte.d.ts +13 -1
- package/dist/components/queued-message/QueuedMessage.svelte +44 -6
- package/dist/components/queued-message/QueuedMessage.svelte.d.ts +12 -1
- package/dist/components/select/Select.svelte +18 -2
- package/dist/components/select/Select.svelte.d.ts +7 -0
- package/dist/components/toast/Toaster.svelte +1 -1
- package/dist/components/toggle/Toggle.svelte +12 -2
- package/dist/components/toggle/Toggle.svelte.d.ts +11 -1
- package/dist/components/toggle-group/ToggleGroupItem.svelte +10 -1
- package/dist/components/toggle-group/ToggleGroupRoot.svelte +7 -1
- package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +3 -1
- package/dist/components/toggle-group/context.d.ts +2 -1
- package/dist/components/tooltip/TooltipContent.svelte +13 -1
- package/dist/components/tooltip/TooltipContent.svelte.d.ts +10 -0
- package/dist/components/work-fold/WorkFold.svelte +13 -4
- package/dist/components/work-fold/WorkFold.svelte.d.ts +2 -1
- package/dist/focus-ring.d.ts +29 -0
- package/dist/focus-ring.js +42 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +7 -2
- package/dist/internal/Collapse.svelte +15 -2
- package/dist/internal/Glyph.svelte +28 -0
- package/dist/internal/Glyph.svelte.d.ts +5 -0
- package/dist/internal/Tile.svelte +3 -2
- package/dist/internal/layer.d.ts +23 -0
- package/dist/internal/layer.js +19 -0
- package/dist/internal/toggle.d.ts +8 -1
- package/dist/internal/toggle.js +20 -2
- package/dist/markdown/file-paths.d.ts +7 -0
- package/dist/markdown/file-paths.js +29 -0
- package/dist/markdown/files.d.ts +22 -2
- package/dist/markdown/files.js +45 -14
- package/dist/tokens.stylex.d.ts +3 -0
- package/dist/tokens.stylex.js +5 -1
- package/package.json +1 -1
- package/skills/building-ui/SKILL.md +55 -3
- package/skills/building-ui/references/components.md +33 -33
- package/skills/markdown/SKILL.md +22 -6
- package/skills/setup/SKILL.md +1 -1
- package/skills/styling/SKILL.md +10 -3
- package/skills/theming/SKILL.md +11 -4
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
Omit<Tooltip.ContentProps, 'children' | 'child'> & {
|
|
13
13
|
/** The keys that do the same, shown after the label: `['⌘', 'K']`. */
|
|
14
14
|
shortcut?: string[] | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* `row` keeps the label and the shortcut on one line. `column` sets the content one
|
|
17
|
+
* part under another: a title, then a line or two that says more.
|
|
18
|
+
*/
|
|
19
|
+
layout?: 'row' | 'column' | undefined;
|
|
15
20
|
sx?: Sx | undefined;
|
|
16
21
|
children?: Snippet | undefined;
|
|
17
22
|
}
|
|
@@ -48,6 +53,12 @@
|
|
|
48
53
|
// toolbar should feel quick, not like each button is thinking
|
|
49
54
|
transitionDuration: { default: '120ms', [CLOSED]: '80ms', [INSTANT]: '0ms' }
|
|
50
55
|
},
|
|
56
|
+
column: {
|
|
57
|
+
flexDirection: 'column',
|
|
58
|
+
alignItems: 'flex-start',
|
|
59
|
+
gap: '0.125rem',
|
|
60
|
+
paddingBlock: '0.4375rem'
|
|
61
|
+
},
|
|
51
62
|
keys: { display: 'inline-flex', gap: '0.125rem' }
|
|
52
63
|
});
|
|
53
64
|
</script>
|
|
@@ -57,6 +68,7 @@
|
|
|
57
68
|
sideOffset = 6,
|
|
58
69
|
collisionPadding = 8,
|
|
59
70
|
shortcut,
|
|
71
|
+
layout = 'row',
|
|
60
72
|
sx,
|
|
61
73
|
class: className,
|
|
62
74
|
children,
|
|
@@ -70,7 +82,7 @@
|
|
|
70
82
|
{collisionPadding}
|
|
71
83
|
data-slot="tooltip"
|
|
72
84
|
{...rest}
|
|
73
|
-
{...attrs([styles.content, sx], className)}
|
|
85
|
+
{...attrs([styles.content, layout === 'column' && styles.column, sx], className)}
|
|
74
86
|
>
|
|
75
87
|
{@render children?.()}
|
|
76
88
|
{#if shortcut?.length}
|
|
@@ -5,12 +5,22 @@ import { type Sx } from '../../internal/sx.js';
|
|
|
5
5
|
export type TooltipContentProps = Loose<Omit<Tooltip.ContentProps, 'children' | 'child'> & {
|
|
6
6
|
/** The keys that do the same, shown after the label: `['⌘', 'K']`. */
|
|
7
7
|
shortcut?: string[] | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* `row` keeps the label and the shortcut on one line. `column` sets the content one
|
|
10
|
+
* part under another: a title, then a line or two that says more.
|
|
11
|
+
*/
|
|
12
|
+
layout?: 'row' | 'column' | undefined;
|
|
8
13
|
sx?: Sx | undefined;
|
|
9
14
|
children?: Snippet | undefined;
|
|
10
15
|
}>;
|
|
11
16
|
declare const TooltipContent: import("svelte").Component<Loose<Omit<Tooltip.ContentProps, "children" | "child"> & {
|
|
12
17
|
/** The keys that do the same, shown after the label: `['⌘', 'K']`. */
|
|
13
18
|
shortcut?: string[] | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* `row` keeps the label and the shortcut on one line. `column` sets the content one
|
|
21
|
+
* part under another: a title, then a line or two that says more.
|
|
22
|
+
*/
|
|
23
|
+
layout?: "row" | "column" | undefined;
|
|
14
24
|
sx?: Sx | undefined;
|
|
15
25
|
children?: Snippet | undefined;
|
|
16
26
|
}>, {}, "">;
|
|
@@ -12,9 +12,11 @@
|
|
|
12
12
|
import { colors, font, motion, radius } from '../../tokens.stylex.js';
|
|
13
13
|
import { media } from '../../media.stylex.js';
|
|
14
14
|
import CollapsibleContent from '../collapsible/CollapsibleContent.svelte';
|
|
15
|
-
import CollapsibleRoot
|
|
15
|
+
import CollapsibleRoot, {
|
|
16
|
+
type CollapsibleRootProps
|
|
17
|
+
} from '../collapsible/CollapsibleRoot.svelte';
|
|
16
18
|
|
|
17
|
-
export type WorkFoldProps = {
|
|
19
|
+
export type WorkFoldProps = Omit<CollapsibleRootProps, 'children' | 'open' | 'sx' | 'class'> & {
|
|
18
20
|
/** What the fold holds, in words: "Worked for 2m 5s". */
|
|
19
21
|
label: string;
|
|
20
22
|
/** Whether the work shows. Bindable. */
|
|
@@ -65,12 +67,19 @@
|
|
|
65
67
|
</script>
|
|
66
68
|
|
|
67
69
|
<script lang="ts">
|
|
68
|
-
let {
|
|
70
|
+
let {
|
|
71
|
+
label,
|
|
72
|
+
open = $bindable(false),
|
|
73
|
+
sx,
|
|
74
|
+
class: className,
|
|
75
|
+
children,
|
|
76
|
+
...rest
|
|
77
|
+
}: WorkFoldProps = $props();
|
|
69
78
|
|
|
70
79
|
const uid = $props.id();
|
|
71
80
|
</script>
|
|
72
81
|
|
|
73
|
-
<CollapsibleRoot bind:open data-slot="work-fold" {sx} class={className}>
|
|
82
|
+
<CollapsibleRoot bind:open data-slot="work-fold" {...rest} {sx} class={className}>
|
|
74
83
|
<Collapsible.Trigger id="{uid}-trigger" {...stylex.attrs(styles.trigger)}>
|
|
75
84
|
<Tile glyph="layers" />
|
|
76
85
|
<span {...stylex.attrs(styles.label)}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { Sx } from '../../internal/sx.js';
|
|
3
|
-
|
|
3
|
+
import { type CollapsibleRootProps } from '../collapsible/CollapsibleRoot.svelte';
|
|
4
|
+
export type WorkFoldProps = Omit<CollapsibleRootProps, 'children' | 'open' | 'sx' | 'class'> & {
|
|
4
5
|
/** What the fold holds, in words: "Worked for 2m 5s". */
|
|
5
6
|
label: string;
|
|
6
7
|
/** Whether the work shows. Bindable. */
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Focus as Narvi's own parts show it, for an element of your own.
|
|
3
|
+
*
|
|
4
|
+
* - `ring`: for anything that takes focus, such as a button or a row. A 2px ring in the
|
|
5
|
+
* accent, 2px out, when the keyboard brings focus there, and none for a click. Normally it
|
|
6
|
+
* is a transparent hairline, which forced-colours mode turns into an edge.
|
|
7
|
+
* - `frame`: for a frame around a field, such as the box around an editor of your own. Its
|
|
8
|
+
* hairline turns to the ring, with a halo, while a field in it is typed into, as a text
|
|
9
|
+
* field's does. Buttons inside the frame show their own focus, not the frame's.
|
|
10
|
+
*
|
|
11
|
+
* <button {...stylex.attrs(focusRing.ring, styles.chip)}>
|
|
12
|
+
* <div {...stylex.attrs(focusRing.frame, styles.box)}>…your editor…</div>
|
|
13
|
+
*/
|
|
14
|
+
import * as stylex from '@stylexjs/stylex';
|
|
15
|
+
export declare const focusRing: Readonly<{
|
|
16
|
+
readonly ring: Readonly<{
|
|
17
|
+
readonly outlineStyle: stylex.StyleXClassNameFor<"outlineStyle", "solid">;
|
|
18
|
+
readonly outlineWidth: stylex.StyleXClassNameFor<"outlineWidth", "1px" | "2px">;
|
|
19
|
+
readonly outlineColor: stylex.StyleXClassNameFor<"outlineColor", string>;
|
|
20
|
+
readonly outlineOffset: stylex.StyleXClassNameFor<"outlineOffset", "2px" | "-1px">;
|
|
21
|
+
}>;
|
|
22
|
+
readonly frame: Readonly<{
|
|
23
|
+
readonly boxShadow: stylex.StyleXClassNameFor<"boxShadow", `inset 0 0 0 1px ${stylex.StyleXVar<string>}` | `inset 0 0 0 1px ${stylex.StyleXVar<string>}, 0 0 0 3px ${stylex.StyleXVar<string>}`>;
|
|
24
|
+
readonly outlineStyle: stylex.StyleXClassNameFor<"outlineStyle", "solid">;
|
|
25
|
+
readonly outlineColor: stylex.StyleXClassNameFor<"outlineColor", "transparent">;
|
|
26
|
+
readonly outlineOffset: stylex.StyleXClassNameFor<"outlineOffset", "-1px">;
|
|
27
|
+
readonly outlineWidth: stylex.StyleXClassNameFor<"outlineWidth", "1px" | "2px">;
|
|
28
|
+
}>;
|
|
29
|
+
}>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Focus as Narvi's own parts show it, for an element of your own.
|
|
3
|
+
*
|
|
4
|
+
* - `ring`: for anything that takes focus, such as a button or a row. A 2px ring in the
|
|
5
|
+
* accent, 2px out, when the keyboard brings focus there, and none for a click. Normally it
|
|
6
|
+
* is a transparent hairline, which forced-colours mode turns into an edge.
|
|
7
|
+
* - `frame`: for a frame around a field, such as the box around an editor of your own. Its
|
|
8
|
+
* hairline turns to the ring, with a halo, while a field in it is typed into, as a text
|
|
9
|
+
* field's does. Buttons inside the frame show their own focus, not the frame's.
|
|
10
|
+
*
|
|
11
|
+
* <button {...stylex.attrs(focusRing.ring, styles.chip)}>
|
|
12
|
+
* <div {...stylex.attrs(focusRing.frame, styles.box)}>…your editor…</div>
|
|
13
|
+
*/
|
|
14
|
+
import * as stylex from '@stylexjs/stylex';
|
|
15
|
+
import { colors } from './tokens.stylex.js';
|
|
16
|
+
import { media } from './media.stylex.js';
|
|
17
|
+
// A field inside the frame, as it takes the keyboard. A text field matches `:focus-visible`
|
|
18
|
+
// for a click too, as it is typed into either way.
|
|
19
|
+
const FIELD = `:has(:is(input, textarea, [contenteditable]:not([contenteditable="false"])):focus-visible)`;
|
|
20
|
+
const styles = stylex.create({
|
|
21
|
+
ring: {
|
|
22
|
+
outlineStyle: 'solid',
|
|
23
|
+
outlineWidth: { default: '1px', ':focus-visible': '2px' },
|
|
24
|
+
outlineColor: { default: 'transparent', ':focus-visible': colors.focusRing },
|
|
25
|
+
outlineOffset: { default: '-1px', ':focus-visible': '2px' }
|
|
26
|
+
},
|
|
27
|
+
frame: {
|
|
28
|
+
boxShadow: {
|
|
29
|
+
default: `inset 0 0 0 1px ${colors.border}`,
|
|
30
|
+
[FIELD]: `inset 0 0 0 1px ${colors.focusRing}, 0 0 0 3px ${colors.focusHalo}`
|
|
31
|
+
},
|
|
32
|
+
// In forced colours the shadow is gone; the outline is the edge, and thickens with focus
|
|
33
|
+
outlineStyle: 'solid',
|
|
34
|
+
outlineColor: 'transparent',
|
|
35
|
+
outlineOffset: '-1px',
|
|
36
|
+
outlineWidth: {
|
|
37
|
+
default: '1px',
|
|
38
|
+
[media.forcedColors]: { default: '1px', ':focus-within': '2px' }
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
export const focusRing = styles;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export * as AppShell from './components/app-shell/index.js';
|
|
|
4
4
|
export { getAppShellContext } from './components/app-shell/index.js';
|
|
5
5
|
export type { AppShellBarProps, AppShellContext, AppShellHeaderProps, AppShellMainProps, AppShellPanelProps, AppShellPanesProps, AppShellRailProps, AppShellRootProps, AppShellSheetProps, AppShellSidebarProps, AppShellToggleProps } from './components/app-shell/index.js';
|
|
6
6
|
export * as Activity from './components/activity/index.js';
|
|
7
|
-
export type { ActivityContentProps, ActivityRootProps, ActivityStepKind, ActivityStepProps, ActivityStepStatus, ActivityThoughtProps, ActivityTriggerProps } from './components/activity/index.js';
|
|
7
|
+
export type { ActivityContentProps, ActivityIconProps, ActivityIconTone, ActivityRootProps, ActivityStepKind, ActivityStepProps, ActivityStepStatus, ActivityThoughtProps, ActivityTriggerProps } from './components/activity/index.js';
|
|
8
8
|
export { default as Announcer } from './components/announcer/Announcer.svelte';
|
|
9
9
|
export type { AnnouncerProps } from './components/announcer/Announcer.svelte';
|
|
10
10
|
export * as Avatar from './components/avatar/index.js';
|
|
@@ -55,7 +55,7 @@ export type { FrameProps } from './components/frame/Frame.svelte';
|
|
|
55
55
|
export { default as Grid } from './components/grid/Grid.svelte';
|
|
56
56
|
export type { GridAlign, GridColumns, GridGap, GridProps } from './components/grid/Grid.svelte';
|
|
57
57
|
export { default as Heading } from './components/heading/Heading.svelte';
|
|
58
|
-
export type { HeadingLevel, HeadingProps, HeadingSize } from './components/heading/Heading.svelte';
|
|
58
|
+
export type { HeadingLevel, HeadingProps, HeadingSize, HeadingWeight } from './components/heading/Heading.svelte';
|
|
59
59
|
export * as HoverCard from './components/hover-card/index.js';
|
|
60
60
|
export type { HoverCardContentProps, HoverCardRootProps } from './components/hover-card/index.js';
|
|
61
61
|
export { default as Input } from './components/input/Input.svelte';
|
|
@@ -67,7 +67,7 @@ export type { LinkProps } from './components/link/Link.svelte';
|
|
|
67
67
|
export * as Menu from './components/menu/index.js';
|
|
68
68
|
export type { MenuCheckboxItemProps, MenuContentProps, MenuGroupProps, MenuItemProps, MenuLabelProps, MenuRadioGroupProps, MenuRadioItemProps, MenuSeparatorProps, MenuSubContentProps, MenuSubTriggerProps } from './components/menu/index.js';
|
|
69
69
|
export * as Message from './components/message/index.js';
|
|
70
|
-
export type { MessageActionProps, MessageActionsProps, MessageContentProps, MessageCopyProps, MessageFrom, MessageHeaderProps, MessagePendingProps, MessageRootProps, MessageTimeProps } from './components/message/index.js';
|
|
70
|
+
export type { MessageActionProps, MessageActionsProps, MessageBubbleProps, MessageContentProps, MessageCopyProps, MessageFrom, MessageHeaderProps, MessagePendingProps, MessageRootProps, MessageTextSize, MessageTimeProps } from './components/message/index.js';
|
|
71
71
|
export { default as Markdown } from './components/markdown/Markdown.svelte';
|
|
72
72
|
export type { MarkdownProps } from './components/markdown/Markdown.svelte';
|
|
73
73
|
export { copyAsWritten } from './components/markdown/copy.js';
|
|
@@ -86,7 +86,7 @@ export type { PopoverContentProps } from './components/popover/index.js';
|
|
|
86
86
|
export { default as Questionnaire } from './components/questionnaire/Questionnaire.svelte';
|
|
87
87
|
export type { Question, QuestionAnswer, QuestionnaireAnswers, QuestionnaireProps } from './components/questionnaire/Questionnaire.svelte';
|
|
88
88
|
export { default as QueuedMessage } from './components/queued-message/QueuedMessage.svelte';
|
|
89
|
-
export type { QueuedMessageProps, QueuedMessageStatus } from './components/queued-message/QueuedMessage.svelte';
|
|
89
|
+
export type { QueuedMessageAction, QueuedMessageProps, QueuedMessageStatus } from './components/queued-message/QueuedMessage.svelte';
|
|
90
90
|
export * as Rail from './components/rail/index.js';
|
|
91
91
|
export type { RailItemProps, RailRootProps } from './components/rail/index.js';
|
|
92
92
|
export * as Reasoning from './components/reasoning/index.js';
|
|
@@ -141,12 +141,13 @@ export type { TextFace, TextProps, TextTone, TextVariant, TextWeight } from './c
|
|
|
141
141
|
export { typography } from './typography.js';
|
|
142
142
|
export type { TypeRole } from './typography.js';
|
|
143
143
|
export { visuallyHidden } from './visually-hidden.js';
|
|
144
|
+
export { focusRing } from './focus-ring.js';
|
|
144
145
|
export type { IconComponent } from './internal/icon.js';
|
|
145
146
|
export { default as Textarea } from './components/textarea/Textarea.svelte';
|
|
146
147
|
export type { TextareaProps } from './components/textarea/Textarea.svelte';
|
|
147
148
|
export { default as Toggle } from './components/toggle/Toggle.svelte';
|
|
148
149
|
export type { ToggleProps } from './components/toggle/Toggle.svelte';
|
|
149
|
-
export type { ToggleSize } from './internal/toggle.js';
|
|
150
|
+
export type { ToggleSize, ToggleTone } from './internal/toggle.js';
|
|
150
151
|
export * as ToggleGroup from './components/toggle-group/index.js';
|
|
151
152
|
export type { ToggleGroupItemProps, ToggleGroupRootProps } from './components/toggle-group/index.js';
|
|
152
153
|
export * as Tool from './components/tool/index.js';
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,8 @@ export { default as Approval } from './components/approval/Approval.svelte';
|
|
|
4
4
|
// <AppShell.Sidebar>, <AppShell.Main>, <AppShell.Header>, <AppShell.Panel>, <AppShell.Toggle>
|
|
5
5
|
export * as AppShell from './components/app-shell/index.js';
|
|
6
6
|
export { getAppShellContext } from './components/app-shell/index.js';
|
|
7
|
-
// Compound: <Activity.Root>, <Activity.Trigger>, <Activity.Content>, <Activity.Step>, <Activity.Thought
|
|
7
|
+
// Compound: <Activity.Root>, <Activity.Trigger>, <Activity.Content>, <Activity.Step>, <Activity.Thought>,
|
|
8
|
+
// <Activity.Icon>
|
|
8
9
|
export * as Activity from './components/activity/index.js';
|
|
9
10
|
export { default as Announcer } from './components/announcer/Announcer.svelte';
|
|
10
11
|
// Compound: <Avatar.Root>, <Avatar.Image>, <Avatar.Fallback>
|
|
@@ -52,7 +53,8 @@ export { default as Link } from './components/link/Link.svelte';
|
|
|
52
53
|
// Compound: <Menu.Root>, <Menu.Trigger>, <Menu.Content>, <Menu.Item>, <Menu.CheckboxItem>,
|
|
53
54
|
// <Menu.RadioGroup>, <Menu.RadioItem>, <Menu.Group>, <Menu.Label>, <Menu.Separator>, <Menu.Sub>…
|
|
54
55
|
export * as Menu from './components/menu/index.js';
|
|
55
|
-
// Compound: <Message.Root>, <Message.Header>, <Message.Pending>, <Message.Content>, <Message.
|
|
56
|
+
// Compound: <Message.Root>, <Message.Header>, <Message.Pending>, <Message.Content>, <Message.Bubble>,
|
|
57
|
+
// <Message.Actions>, <Message.Action>, <Message.Copy>, <Message.Time>
|
|
56
58
|
export * as Message from './components/message/index.js';
|
|
57
59
|
export { default as Markdown } from './components/markdown/Markdown.svelte';
|
|
58
60
|
export { copyAsWritten } from './components/markdown/copy.js';
|
|
@@ -103,6 +105,9 @@ export { default as Text } from './components/text/Text.svelte';
|
|
|
103
105
|
export { typography } from './typography.js';
|
|
104
106
|
// Hidden from sight, kept for assistive technology: `stylex.attrs(visuallyHidden)`
|
|
105
107
|
export { visuallyHidden } from './visually-hidden.js';
|
|
108
|
+
// Focus as Narvi's parts show it: `focusRing.ring` for a control of your own, `focusRing.frame`
|
|
109
|
+
// for the box around a field of your own
|
|
110
|
+
export { focusRing } from './focus-ring.js';
|
|
106
111
|
export { default as Textarea } from './components/textarea/Textarea.svelte';
|
|
107
112
|
export { default as Toggle } from './components/toggle/Toggle.svelte';
|
|
108
113
|
// Compound: <ToggleGroup.Root>, <ToggleGroup.Item>
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
A region that folds open and shut. Its height eases between nothing and its
|
|
3
3
|
content's height by moving a grid row between 0fr and 1fr, which needs no
|
|
4
4
|
measuring. While shut it is inert: out of the tab order and the accessibility tree.
|
|
5
|
+
Once it has finished closing, its content is not rendered either, so the page's find,
|
|
6
|
+
`checkVisibility()` and a test's visibility checks all know it is not shown.
|
|
5
7
|
-->
|
|
6
8
|
<script lang="ts" module>
|
|
7
9
|
import * as stylex from '@stylexjs/stylex';
|
|
@@ -24,9 +26,20 @@
|
|
|
24
26
|
gridTemplateRows: '1fr',
|
|
25
27
|
opacity: 1
|
|
26
28
|
},
|
|
29
|
+
// Shut, the content stops being rendered at the end of the fold, and starts again as it
|
|
30
|
+
// opens: `visibility` turns at those ends by itself, `content-visibility` as a discrete step
|
|
27
31
|
inner: {
|
|
28
32
|
minHeight: 0,
|
|
29
|
-
overflow: 'hidden'
|
|
33
|
+
overflow: 'hidden',
|
|
34
|
+
visibility: 'hidden',
|
|
35
|
+
contentVisibility: 'hidden',
|
|
36
|
+
transitionProperty: 'visibility, content-visibility',
|
|
37
|
+
transitionBehavior: 'allow-discrete',
|
|
38
|
+
transitionDuration: motion.slow
|
|
39
|
+
},
|
|
40
|
+
innerOpen: {
|
|
41
|
+
visibility: 'visible',
|
|
42
|
+
contentVisibility: 'visible'
|
|
30
43
|
}
|
|
31
44
|
});
|
|
32
45
|
</script>
|
|
@@ -50,7 +63,7 @@
|
|
|
50
63
|
</script>
|
|
51
64
|
|
|
52
65
|
<div inert={!open} {...rest} {...attrs([styles.region, open && styles.open, sx], className)}>
|
|
53
|
-
<div {...stylex.attrs(styles.inner)}>
|
|
66
|
+
<div {...stylex.attrs(styles.inner, open && styles.innerOpen)}>
|
|
54
67
|
<div {...attrs([innerSx], innerClass)}>
|
|
55
68
|
{@render children?.()}
|
|
56
69
|
</div>
|
|
@@ -38,6 +38,34 @@
|
|
|
38
38
|
steer: ['M3.5 3v5.5a2 2 0 0 0 2 2h7', 'M10 8l2.5 2.5L10 13'],
|
|
39
39
|
search: ['M11.5 7a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0Z', 'm10.5 10.5 3 3'],
|
|
40
40
|
file: ['M4.25 2.25h4.5l3 3v8.5h-7.5Z', 'M8.75 2.25v3h3'],
|
|
41
|
+
// Files by kind: the page, with what it holds on it
|
|
42
|
+
fileCode: [
|
|
43
|
+
'M4.25 2.25h4.5l3 3v8.5h-7.5Z',
|
|
44
|
+
'M8.75 2.25v3h3',
|
|
45
|
+
'M7 8.5 5.75 9.75 7 11',
|
|
46
|
+
'M9 8.5l1.25 1.25L9 11'
|
|
47
|
+
],
|
|
48
|
+
fileText: [
|
|
49
|
+
'M4.25 2.25h4.5l3 3v8.5h-7.5Z',
|
|
50
|
+
'M8.75 2.25v3h3',
|
|
51
|
+
'M6.25 8.5h3.5',
|
|
52
|
+
'M6.25 10.75h3.5'
|
|
53
|
+
],
|
|
54
|
+
fileData: [
|
|
55
|
+
'M4.25 2.25h4.5l3 3v8.5h-7.5Z',
|
|
56
|
+
'M8.75 2.25v3h3',
|
|
57
|
+
'M7 8c-.5 0-.75.3-.75.75v.4c0 .4-.25.6-.6.6.35 0 .6.2.6.6v.4c0 .45.25.75.75.75',
|
|
58
|
+
'M9 8c.5 0 .75.3.75.75v.4c0 .4.25.6.6.6-.35 0-.6.2-.6.6v.4c0 .45-.25.75-.75.75'
|
|
59
|
+
],
|
|
60
|
+
fileImage: [
|
|
61
|
+
'M4.25 2.25h4.5l3 3v8.5h-7.5Z',
|
|
62
|
+
'M8.75 2.25v3h3',
|
|
63
|
+
'm4.25 12.5 2.25-2.25 1.75 1.75 1.25-1.25 2.25 2.25',
|
|
64
|
+
'M6.75 7.75h.01'
|
|
65
|
+
],
|
|
66
|
+
folder: [
|
|
67
|
+
'M2.25 4.5c0-.69.56-1.25 1.25-1.25h2.6c.4 0 .77.19 1 .51l.75 1.04c.24.32.61.5 1 .5h3.65c.69 0 1.25.56 1.25 1.25v5.7c0 .69-.56 1.25-1.25 1.25h-9c-.69 0-1.25-.56-1.25-1.25Z'
|
|
68
|
+
],
|
|
41
69
|
selector: ['M5.25 6 8 3.25 10.75 6', 'M5.25 10 8 12.75 10.75 10'],
|
|
42
70
|
// A thought: a bulb with its filament
|
|
43
71
|
bulb: [
|
|
@@ -21,6 +21,11 @@ declare const paths: {
|
|
|
21
21
|
readonly steer: readonly ["M3.5 3v5.5a2 2 0 0 0 2 2h7", "M10 8l2.5 2.5L10 13"];
|
|
22
22
|
readonly search: readonly ["M11.5 7a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0Z", "m10.5 10.5 3 3"];
|
|
23
23
|
readonly file: readonly ["M4.25 2.25h4.5l3 3v8.5h-7.5Z", "M8.75 2.25v3h3"];
|
|
24
|
+
readonly fileCode: readonly ["M4.25 2.25h4.5l3 3v8.5h-7.5Z", "M8.75 2.25v3h3", "M7 8.5 5.75 9.75 7 11", "M9 8.5l1.25 1.25L9 11"];
|
|
25
|
+
readonly fileText: readonly ["M4.25 2.25h4.5l3 3v8.5h-7.5Z", "M8.75 2.25v3h3", "M6.25 8.5h3.5", "M6.25 10.75h3.5"];
|
|
26
|
+
readonly fileData: readonly ["M4.25 2.25h4.5l3 3v8.5h-7.5Z", "M8.75 2.25v3h3", "M7 8c-.5 0-.75.3-.75.75v.4c0 .4-.25.6-.6.6.35 0 .6.2.6.6v.4c0 .45.25.75.75.75", "M9 8c.5 0 .75.3.75.75v.4c0 .4.25.6.6.6-.35 0-.6.2-.6.6v.4c0 .45-.25.75-.75.75"];
|
|
27
|
+
readonly fileImage: readonly ["M4.25 2.25h4.5l3 3v8.5h-7.5Z", "M8.75 2.25v3h3", "m4.25 12.5 2.25-2.25 1.75 1.75 1.25-1.25 2.25 2.25", "M6.75 7.75h.01"];
|
|
28
|
+
readonly folder: readonly ["M2.25 4.5c0-.69.56-1.25 1.25-1.25h2.6c.4 0 .77.19 1 .51l.75 1.04c.24.32.61.5 1 .5h3.65c.69 0 1.25.56 1.25 1.25v5.7c0 .69-.56 1.25-1.25 1.25h-9c-.69 0-1.25-.56-1.25-1.25Z"];
|
|
24
29
|
readonly selector: readonly ["M5.25 6 8 3.25 10.75 6", "M5.25 10 8 12.75 10.75 10"];
|
|
25
30
|
readonly bulb: readonly ["M6.25 13.75h3.5", "M8 2.25a4 4 0 0 0-2.4 7.2c.42.32.65.7.65 1.15v.65h3.5v-.65c0-.45.23-.83.65-1.15A4 4 0 0 0 8 2.25Z"];
|
|
26
31
|
readonly layers: readonly ["M8 2.75 13.25 5.5 8 8.25 2.75 5.5Z", "M2.75 8.25 8 11l5.25-2.75", "M2.75 11 8 13.75 13.25 11"];
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
transitionDuration: motion.slow,
|
|
26
26
|
transitionTimingFunction: 'ease'
|
|
27
27
|
},
|
|
28
|
-
md: { width: '1rem', height: '1.5rem' },
|
|
29
|
-
sm: { width: '1rem', height: '1.25rem' },
|
|
28
|
+
md: { '--narvi-icon-size': '1rem', width: '1rem', height: '1.5rem' },
|
|
29
|
+
sm: { '--narvi-icon-size': '0.875rem', width: '1rem', height: '1.25rem' },
|
|
30
30
|
neutral: {},
|
|
31
31
|
live: { color: colors.accent },
|
|
32
32
|
success: { color: colors.success },
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
|
|
55
55
|
<span
|
|
56
56
|
aria-hidden="true"
|
|
57
|
+
data-icons
|
|
57
58
|
data-slot="tile"
|
|
58
59
|
data-tone={tone}
|
|
59
60
|
{...stylex.attrs(styles.tile, styles[size], styles[tone], sx)}
|
package/dist/internal/layer.d.ts
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as stylex from '@stylexjs/stylex';
|
|
9
9
|
import './icons.css';
|
|
10
|
+
/** The `style` that gives a floating surface a `width` of its own, with any `style` given too. */
|
|
11
|
+
export declare function widthStyle(width: string | undefined, style: unknown): string | undefined;
|
|
10
12
|
export declare const layer: Readonly<{
|
|
11
13
|
readonly surface: Readonly<{
|
|
12
14
|
readonly boxSizing: stylex.StyleXClassNameFor<"boxSizing", "border-box">;
|
|
@@ -35,6 +37,16 @@ export declare const layer: Readonly<{
|
|
|
35
37
|
readonly transitionDuration: stylex.StyleXClassNameFor<"transitionDuration", string>;
|
|
36
38
|
readonly transitionTimingFunction: stylex.StyleXClassNameFor<"transitionTimingFunction", string>;
|
|
37
39
|
}>;
|
|
40
|
+
readonly sized: Readonly<{
|
|
41
|
+
readonly width: stylex.StyleXClassNameFor<"width", "min(var(--narvi-layer-width), var(--bits-floating-available-width, 100vw))">;
|
|
42
|
+
readonly minWidth: stylex.StyleXClassNameFor<"minWidth", 0>;
|
|
43
|
+
readonly maxWidth: stylex.StyleXClassNameFor<"maxWidth", "none">;
|
|
44
|
+
}>;
|
|
45
|
+
readonly column: Readonly<{
|
|
46
|
+
readonly display: stylex.StyleXClassNameFor<"display", "flex">;
|
|
47
|
+
readonly flexDirection: stylex.StyleXClassNameFor<"flexDirection", "column">;
|
|
48
|
+
readonly gap: stylex.StyleXClassNameFor<"gap", "0.625rem">;
|
|
49
|
+
}>;
|
|
38
50
|
readonly item: Readonly<{
|
|
39
51
|
readonly position: stylex.StyleXClassNameFor<"position", "relative">;
|
|
40
52
|
readonly boxSizing: stylex.StyleXClassNameFor<"boxSizing", "border-box">;
|
|
@@ -72,6 +84,17 @@ export declare const layer: Readonly<{
|
|
|
72
84
|
readonly textOverflow: stylex.StyleXClassNameFor<"textOverflow", "ellipsis">;
|
|
73
85
|
readonly whiteSpace: stylex.StyleXClassNameFor<"whiteSpace", "nowrap">;
|
|
74
86
|
}>;
|
|
87
|
+
readonly text: Readonly<{
|
|
88
|
+
readonly display: stylex.StyleXClassNameFor<"display", "flex">;
|
|
89
|
+
readonly flexDirection: stylex.StyleXClassNameFor<"flexDirection", "column">;
|
|
90
|
+
readonly gap: stylex.StyleXClassNameFor<"gap", "0.125rem">;
|
|
91
|
+
readonly minWidth: stylex.StyleXClassNameFor<"minWidth", 0>;
|
|
92
|
+
readonly flexGrow: stylex.StyleXClassNameFor<"flexGrow", 1>;
|
|
93
|
+
}>;
|
|
94
|
+
readonly description: Readonly<{
|
|
95
|
+
readonly color: stylex.StyleXClassNameFor<"color", string>;
|
|
96
|
+
readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
|
|
97
|
+
}>;
|
|
75
98
|
readonly trailing: Readonly<{
|
|
76
99
|
readonly display: stylex.StyleXClassNameFor<"display", "inline-flex">;
|
|
77
100
|
readonly alignItems: stylex.StyleXClassNameFor<"alignItems", "center">;
|
package/dist/internal/layer.js
CHANGED
|
@@ -12,6 +12,13 @@ import './icons.css';
|
|
|
12
12
|
const CLOSED = ':is([data-state="closed"])';
|
|
13
13
|
const HIGHLIGHTED = ':is([data-highlighted])';
|
|
14
14
|
const DISABLED = ':is([data-disabled])';
|
|
15
|
+
/** The `style` that gives a floating surface a `width` of its own, with any `style` given too. */
|
|
16
|
+
export function widthStyle(width, style) {
|
|
17
|
+
const own = typeof style === 'string' && style ? style : undefined;
|
|
18
|
+
if (!width)
|
|
19
|
+
return own;
|
|
20
|
+
return [`--narvi-layer-width: ${width}`, own].filter(Boolean).join('; ');
|
|
21
|
+
}
|
|
15
22
|
export const layer = stylex.create({
|
|
16
23
|
surface: {
|
|
17
24
|
boxSizing: 'border-box',
|
|
@@ -47,6 +54,15 @@ export const layer = stylex.create({
|
|
|
47
54
|
transitionDuration: { default: motion.fast, [CLOSED]: '80ms' },
|
|
48
55
|
transitionTimingFunction: motion.easeOut
|
|
49
56
|
},
|
|
57
|
+
// A width of its own (`--narvi-layer-width`), in place of fitting its items: still no wider
|
|
58
|
+
// than the room bits-ui measures for it
|
|
59
|
+
sized: {
|
|
60
|
+
width: 'min(var(--narvi-layer-width), var(--bits-floating-available-width, 100vw))',
|
|
61
|
+
minWidth: 0,
|
|
62
|
+
maxWidth: 'none'
|
|
63
|
+
},
|
|
64
|
+
// Content of its own, one part under another, with room between them
|
|
65
|
+
column: { display: 'flex', flexDirection: 'column', gap: '0.625rem' },
|
|
50
66
|
// A row in a menu, a select or the palette
|
|
51
67
|
item: {
|
|
52
68
|
position: 'relative',
|
|
@@ -95,6 +111,9 @@ export const layer = stylex.create({
|
|
|
95
111
|
textOverflow: 'ellipsis',
|
|
96
112
|
whiteSpace: 'nowrap'
|
|
97
113
|
},
|
|
114
|
+
// A label with a line under it, such as what a choice means
|
|
115
|
+
text: { display: 'flex', flexDirection: 'column', gap: '0.125rem', minWidth: 0, flexGrow: 1 },
|
|
116
|
+
description: { color: colors.textMuted, fontSize: font.sizeCaption },
|
|
98
117
|
// A shortcut or a count, at the far end
|
|
99
118
|
trailing: {
|
|
100
119
|
display: 'inline-flex',
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The look of a button that stays pressed: Toggle, and the items of a
|
|
3
3
|
* ToggleGroup. Off, it is as quiet as a ghost button; on, it is lit with
|
|
4
|
-
* the accent, the one colour that marks state, as Composer's toggles are
|
|
4
|
+
* the accent, the one colour that marks state, as Composer's toggles are, or, `neutral`, with
|
|
5
|
+
* the fill of what is chosen.
|
|
5
6
|
*/
|
|
6
7
|
import * as stylex from '@stylexjs/stylex';
|
|
7
8
|
export declare const toggle: Readonly<{
|
|
@@ -69,5 +70,11 @@ export declare const toggle: Readonly<{
|
|
|
69
70
|
readonly width: stylex.StyleXClassNameFor<"width", "2rem">;
|
|
70
71
|
readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", 0>;
|
|
71
72
|
}>;
|
|
73
|
+
readonly neutral: Readonly<{
|
|
74
|
+
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string | null>;
|
|
75
|
+
readonly color: stylex.StyleXClassNameFor<"color", string | null>;
|
|
76
|
+
}>;
|
|
72
77
|
}>;
|
|
73
78
|
export type ToggleSize = 'sm' | 'md';
|
|
79
|
+
/** How a pressed toggle shows it: lit in the `accent`, or `neutral`, in the fill of what is chosen. */
|
|
80
|
+
export type ToggleTone = 'accent' | 'neutral';
|
package/dist/internal/toggle.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The look of a button that stays pressed: Toggle, and the items of a
|
|
3
3
|
* ToggleGroup. Off, it is as quiet as a ghost button; on, it is lit with
|
|
4
|
-
* the accent, the one colour that marks state, as Composer's toggles are
|
|
4
|
+
* the accent, the one colour that marks state, as Composer's toggles are, or, `neutral`, with
|
|
5
|
+
* the fill of what is chosen.
|
|
5
6
|
*/
|
|
6
7
|
import * as stylex from '@stylexjs/stylex';
|
|
7
8
|
import { colors, font, motion, radius } from '../tokens.stylex.js';
|
|
@@ -79,5 +80,22 @@ export const toggle = stylex.create({
|
|
|
79
80
|
'::after': { content: '""', position: 'absolute', insetInline: 0, insetBlock: '-4px' }
|
|
80
81
|
},
|
|
81
82
|
iconSm: { width: '1.75rem', paddingInline: 0 },
|
|
82
|
-
iconMd: { width: '2rem', paddingInline: 0 }
|
|
83
|
+
iconMd: { width: '2rem', paddingInline: 0 },
|
|
84
|
+
// On, without the accent: the fill of what is chosen, in the text's colour. For a toolbar's
|
|
85
|
+
// icons, such as a panel shown or hidden, where a lit one would read as something live.
|
|
86
|
+
neutral: {
|
|
87
|
+
backgroundColor: {
|
|
88
|
+
default: 'transparent',
|
|
89
|
+
':hover': { default: null, [media.hover]: colors.fillHover },
|
|
90
|
+
[ON]: {
|
|
91
|
+
default: colors.fillSelected,
|
|
92
|
+
':hover': { default: null, [media.hover]: colors.fillSelected }
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
color: {
|
|
96
|
+
default: colors.textMuted,
|
|
97
|
+
':hover': { default: null, [media.hover]: colors.text },
|
|
98
|
+
[ON]: { default: colors.text, [media.forcedColors]: 'Highlight' }
|
|
99
|
+
}
|
|
100
|
+
}
|
|
83
101
|
});
|
|
@@ -16,6 +16,13 @@ export declare const reExtension: RegExp;
|
|
|
16
16
|
* "1/2", "v1.2.3" and "github.com/owner/repo" are not paths.
|
|
17
17
|
*/
|
|
18
18
|
export declare function looksLikePath(path: string, hasPosition?: boolean): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* What kind of thing a path names, by its name: a `folder` (it ends in a slash), `code`, an
|
|
21
|
+
* `image`, `text` to read, `data` (configuration and records), or any other `file`.
|
|
22
|
+
*/
|
|
23
|
+
export type FileKind = 'folder' | 'code' | 'image' | 'text' | 'data' | 'file';
|
|
24
|
+
/** What kind of thing a path names: see `FileKind`. */
|
|
25
|
+
export declare function fileKind(path: string): FileKind;
|
|
19
26
|
export declare function basename(path: string): string;
|
|
20
27
|
/**
|
|
21
28
|
* What a chip shows for a path: the file's name, or the whole path when it leaves the
|
|
@@ -50,6 +50,35 @@ export function looksLikePath(path, hasPosition = false) {
|
|
|
50
50
|
// `./.env` and `/etc/hosts` name files without an extension; `src/lib` alone could be anything
|
|
51
51
|
return hasExtension || rooted || segments.length > 2;
|
|
52
52
|
}
|
|
53
|
+
const KINDS = {
|
|
54
|
+
code: new Set(('ts tsx mts cts js jsx mjs cjs svelte vue astro py pyi rb go rs java kt kts swift c h cc ' +
|
|
55
|
+
'cpp cxx hpp hh m mm cs fs php sh bash zsh fish ps1 lua dart scala ex exs erl hrl clj ' +
|
|
56
|
+
'cljs elm hs ml mli zig nim jl r pl sql html htm css scss sass less styl wasm wat gleam').split(' ')),
|
|
57
|
+
image: new Set('png jpg jpeg gif webp avif svg ico bmp tif tiff heic heif'.split(' ')),
|
|
58
|
+
text: new Set('md mdx markdown txt rst adoc asciidoc org tex rtf log pdf'.split(' ')),
|
|
59
|
+
data: new Set(('json jsonc json5 jsonl ndjson yaml yml toml xml csv tsv ini cfg conf env lock plist ' +
|
|
60
|
+
'properties graphql gql proto prisma').split(' '))
|
|
61
|
+
};
|
|
62
|
+
// Files whose name is their kind: `Makefile`, `Dockerfile`, `.gitignore`
|
|
63
|
+
const CODE_NAMES = /^(?:[A-Z][a-z]*file|Dockerfile\..+|Containerfile)$/;
|
|
64
|
+
const DATA_NAMES = /^\.(?:[a-z]+rc|env(?:\..+)?|git(?:ignore|attributes|modules)|editorconfig|npmrc|nvmrc|prettierrc|eslintrc)$/;
|
|
65
|
+
/** What kind of thing a path names: see `FileKind`. */
|
|
66
|
+
export function fileKind(path) {
|
|
67
|
+
if (/[\\/]$/.test(path))
|
|
68
|
+
return 'folder';
|
|
69
|
+
const name = basename(path);
|
|
70
|
+
if (CODE_NAMES.test(name))
|
|
71
|
+
return 'code';
|
|
72
|
+
if (DATA_NAMES.test(name))
|
|
73
|
+
return 'data';
|
|
74
|
+
const extension = /\.([A-Za-z0-9]+)$/.exec(name)?.[1]?.toLowerCase();
|
|
75
|
+
if (!extension || extension === name.slice(1).toLowerCase())
|
|
76
|
+
return 'file';
|
|
77
|
+
for (const [kind, extensions] of Object.entries(KINDS))
|
|
78
|
+
if (extensions.has(extension))
|
|
79
|
+
return kind;
|
|
80
|
+
return 'file';
|
|
81
|
+
}
|
|
53
82
|
export function basename(path) {
|
|
54
83
|
const trimmed = path.replace(/[\\/]+$/, '');
|
|
55
84
|
const base = trimmed.slice(Math.max(trimmed.lastIndexOf('/'), trimmed.lastIndexOf('\\')) + 1);
|
package/dist/markdown/files.d.ts
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
|
-
import { formatPosition, looksLikePath, splitPosition, type FileReference } from './file-paths.js';
|
|
1
|
+
import { fileKind, formatPosition, looksLikePath, splitPosition, type FileKind, type FileReference } from './file-paths.js';
|
|
2
2
|
import { type MarkdownPlugin } from './plugin.js';
|
|
3
|
-
export { formatPosition, looksLikePath, splitPosition, type FileReference };
|
|
3
|
+
export { fileKind, formatPosition, looksLikePath, splitPosition, type FileKind, type FileReference };
|
|
4
|
+
/** A file named in a reply, as `icon` is asked about it: where it is, and what kind of thing. */
|
|
5
|
+
export type FileChipTarget = FileReference & {
|
|
6
|
+
kind: FileKind;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* A chip's icon of the app's own: an SVG image, by its address (a `data:` URL, or one the
|
|
10
|
+
* page can load), drawn as a mask in `color`, so it takes the chip's colours unless given its
|
|
11
|
+
* own. `color` is any CSS colour, `light-dark()` too.
|
|
12
|
+
*/
|
|
13
|
+
export type FileIcon = {
|
|
14
|
+
url: string;
|
|
15
|
+
color?: string | undefined;
|
|
16
|
+
};
|
|
4
17
|
export type FilesOptions = {
|
|
5
18
|
/**
|
|
6
19
|
* Says whether a path names a file the app knows, and returns it as the app wants it (made
|
|
@@ -11,6 +24,13 @@ export type FilesOptions = {
|
|
|
11
24
|
resolve?: ((path: string) => string | null | undefined) | undefined;
|
|
12
25
|
/** Opens a file when its chip is activated. Without it, chips only show. */
|
|
13
26
|
open?: ((file: FileReference, event: MouseEvent) => void) | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* The icon a chip shows, from the app's own set: given the file and its kind (`folder`,
|
|
29
|
+
* `code`, `image`, `text`, `data` or `file`). Return null for Narvi's own icon for the kind.
|
|
30
|
+
* It is asked once per chip, as the reply is read, so finished replies are still written
|
|
31
|
+
* as markup (`static`).
|
|
32
|
+
*/
|
|
33
|
+
icon?: ((file: FileChipTarget) => FileIcon | null | undefined) | undefined;
|
|
14
34
|
};
|
|
15
35
|
/** The first-party file plugin. */
|
|
16
36
|
export declare function files(options?: FilesOptions): MarkdownPlugin;
|