neatkit 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/code.cjs ADDED
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Code-CDHkXHVo.cjs");exports.Code=e.Code;
package/dist/code.js ADDED
@@ -0,0 +1,5 @@
1
+ "use client";
2
+ import { C as r } from "./Code-D4qqPnTN.js";
3
+ export {
4
+ r as Code
5
+ };
@@ -19,8 +19,8 @@ type ButtonOwnProps = {
19
19
  variant?: ButtonVariant;
20
20
  /** The semantic intent applied to the Button. */
21
21
  tone?: ButtonTone;
22
- /** The outline shape applied to the Button. */
23
- shape: ButtonShape;
22
+ /** The outline shape applied to the Button. Defaults to capsule. */
23
+ shape?: ButtonShape;
24
24
  /** Whether the Button fills its containing block. */
25
25
  fullWidth?: boolean;
26
26
  /** Whether the Button displays a loading indicator and blocks interaction. */
@@ -0,0 +1,47 @@
1
+ import { type HTMLAttributes } from "react";
2
+ import "./styles/code.css";
3
+ /** A syntax-highlighting language supported by Code. */
4
+ export type CodeLanguage = "C" | "C++" | "CSS" | "Go" | "HTML" | "JSON" | "JavaScript" | "Markdown" | "Python" | "Ruby" | "Rust" | "SQL" | "Shell" | "TypeScript" | "YAML";
5
+ /** Properties owned by Code rather than its native container. */
6
+ type CodeOwnProps = {
7
+ /** Native properties applied to the rendered code element. */
8
+ codeProps?: Omit<HTMLAttributes<HTMLElement>, "children" | "dangerouslySetInnerHTML">;
9
+ /** The plain source string displayed by the component. */
10
+ code: string;
11
+ /** The additional class name applied to the horizontal scroll container. */
12
+ containerClassName?: string;
13
+ /** The language label and optional syntax grammar applied to the source. */
14
+ language?: CodeLanguage;
15
+ /**
16
+ * The maximum line count rendered with individual wrappers and numbers.
17
+ * Larger source remains complete as one plain text node. Set to null only
18
+ * for trusted source whose line count is constrained elsewhere.
19
+ */
20
+ maxLineCount?: number | null;
21
+ /**
22
+ * The maximum UTF-16 source length processed by syntax highlighting. Set to
23
+ * null only for trusted source whose size is constrained elsewhere.
24
+ */
25
+ maxHighlightLength?: number | null;
26
+ /** Native properties applied to the rendered preformatted element. */
27
+ preProps?: Omit<HTMLAttributes<HTMLPreElement>, "children" | "dangerouslySetInnerHTML">;
28
+ /** The optional source title displayed in the Card header. */
29
+ title?: string;
30
+ };
31
+ /** A type representing properties for the Code component. */
32
+ export type CodeProps = Omit<HTMLAttributes<HTMLDivElement>, "children" | "dangerouslySetInnerHTML" | "title"> & CodeOwnProps;
33
+ /**
34
+ * Renders highlighted, line-numbered source inside a Card.
35
+ *
36
+ * The horizontal scroll region becomes keyboard-focusable only when its
37
+ * content overflows, while line numbers remain hidden from assistive
38
+ * technology and text selection. Syntax highlighting and individual line
39
+ * wrappers are bounded while oversized source remains complete as plain text.
40
+ *
41
+ * @param props - The source, presentation, and native container properties.
42
+ * @param forwardedReference - The reference assigned to the outer Card.
43
+ *
44
+ * @returns The rendered source-code surface.
45
+ */
46
+ declare const Code: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "title" | "children" | "dangerouslySetInnerHTML"> & CodeOwnProps & import("react").RefAttributes<HTMLDivElement>>;
47
+ export default Code;
@@ -0,0 +1,2 @@
1
+ export { default as Code } from "./Code";
2
+ export type { CodeLanguage, CodeProps } from "./Code";
@@ -0,0 +1,17 @@
1
+ import type { CodeLanguage } from "../Code";
2
+ /** A highlighted text fragment rendered within one source line. */
3
+ export type CodeHighlightSegment = {
4
+ /** The syntax classes describing the highlighted fragment. */
5
+ className?: string;
6
+ /** The source text represented by the fragment. */
7
+ text: string;
8
+ };
9
+ /**
10
+ * Highlights source code and groups its syntax fragments by line.
11
+ *
12
+ * @param code - The normalized source code to highlight.
13
+ * @param language - The language grammar used to parse the source.
14
+ *
15
+ * @returns Highlighted lines, or null when parsing cannot complete.
16
+ */
17
+ export declare function highlightCode(code: string, language: CodeLanguage): CodeHighlightSegment[][] | null;
@@ -5,7 +5,7 @@ export type ContentTheme = "light" | "dark";
5
5
  /** A type representing Content's visual background modes. */
6
6
  export type ContentMode = "grid" | "none";
7
7
  /** A type representing Content's minimum-height behavior. */
8
- export type ContentFill = "none" | "available" | "viewport";
8
+ export type ContentMinHeight = "auto" | "available" | "viewport";
9
9
  /** A type representing Content's vertical spacing behavior. */
10
10
  export type ContentSpacing = "standard" | "none";
11
11
  /** A type representing CSS custom properties accepted by Content styles. */
@@ -24,8 +24,8 @@ type ContentOwnProps = {
24
24
  accent?: string;
25
25
  /** The visual background treatment applied to Content. */
26
26
  mode?: ContentMode;
27
- /** The minimum-height behavior applied to Content. */
28
- fill?: ContentFill;
27
+ /** The minimum height applied to Content. */
28
+ minHeight?: ContentMinHeight;
29
29
  /** The vertical spacing applied within Content. */
30
30
  spacing?: ContentSpacing;
31
31
  /** Whether Content applies its responsive cell-aligned inner width. */
@@ -1,2 +1,2 @@
1
1
  export { default as Content } from "./Content";
2
- export type { ContentFill, ContentMode, ContentProps, ContentSpacing, ContentTheme, } from "./Content";
2
+ export type { ContentMinHeight, ContentMode, ContentProps, ContentSpacing, ContentTheme, } from "./Content";
@@ -0,0 +1,66 @@
1
+ import { type HTMLAttributes } from "react";
2
+ import type { PluggableList } from "unified";
3
+ import { type MarkdownImageSourceAllowlist } from "./utils/security";
4
+ import "./styles/markdown.css";
5
+ /** Properties owned by Markdown rather than its native container. */
6
+ type MarkdownOwnProps = {
7
+ /** Image sources permitted to initiate requests. The default blocks all. */
8
+ allowedImageSources?: MarkdownImageSourceAllowlist;
9
+ /**
10
+ * A stable public prefix applied after Markdown's fixed `md-` security
11
+ * namespace. IDs remain document-global: multiple Markdown components and
12
+ * their footnotes can collide, and duplicate fragments use native first-match
13
+ * behavior. Use distinct values for multiple navigable documents.
14
+ */
15
+ anchorPrefix?: string;
16
+ /** The untrusted Markdown source to parse and render. */
17
+ content: string;
18
+ /** Trusted absolute base used to resolve pattern-allowed relative images. */
19
+ imageBaseUrl?: string;
20
+ /** Trusted rehype plugins run before the mandatory security transforms. */
21
+ rehypePlugins?: PluggableList;
22
+ /** Trusted remark plugins run after the built-in GFM extension. */
23
+ remarkPlugins?: PluggableList;
24
+ /**
25
+ * The maximum UTF-16 source length parsed synchronously. Set to null only
26
+ * for trusted content whose size is constrained elsewhere.
27
+ */
28
+ maxContentLength?: number | null;
29
+ /**
30
+ * The maximum source length syntax-highlighted within each code block. Set
31
+ * to null only for trusted source whose size is constrained elsewhere.
32
+ */
33
+ maxCodeHighlightLength?: number | null;
34
+ /**
35
+ * The maximum code-block line count rendered with wrappers and numbers.
36
+ * Larger blocks remain complete as one plain text node. Set to null only
37
+ * for trusted source whose line count is constrained elsewhere.
38
+ */
39
+ maxCodeLineCount?: number | null;
40
+ /**
41
+ * The pixel offset reserved above smoothly scrolled anchors. Set to null to
42
+ * use immediate in-document navigation without a reserved offset.
43
+ */
44
+ scrollOffset?: number | null;
45
+ };
46
+ /** A type representing properties for the Markdown component. */
47
+ export type MarkdownProps = Omit<HTMLAttributes<HTMLDivElement>, "children" | "dangerouslySetInnerHTML"> & MarkdownOwnProps;
48
+ /**
49
+ * Renders untrusted CommonMark and GFM content through Neatkit components.
50
+ *
51
+ * Embedded HTML is parsed through a fixed allowlist, unsafe URL protocols are
52
+ * removed, generated IDs use a fixed `md-` clobber-protection namespace, and
53
+ * all images are blocked unless explicitly enabled. IDs are document-global;
54
+ * consumers must provide distinct `anchorPrefix` values when rendering
55
+ * multiple independently navigable documents. Parsing and code rendering are
56
+ * bounded by default. Consumer plugins run before the fixed security
57
+ * transforms; renderer overrides and Markdown-to-HTML conversion options stay
58
+ * private because they can invalidate these guarantees.
59
+ *
60
+ * @param props - The Markdown source, security options, and native properties.
61
+ * @param forwardedReference - The reference assigned to the outer container.
62
+ *
63
+ * @returns The safely rendered Markdown content.
64
+ */
65
+ declare const Markdown: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "children" | "dangerouslySetInnerHTML"> & MarkdownOwnProps & import("react").RefAttributes<HTMLDivElement>>;
66
+ export default Markdown;
@@ -0,0 +1,3 @@
1
+ export { default as Markdown } from "./Markdown";
2
+ export type { MarkdownProps } from "./Markdown";
3
+ export type { MarkdownImageSourceAllowlist } from "./utils/security";
@@ -0,0 +1,9 @@
1
+ import type { CodeLanguage } from "../../Code/Code";
2
+ /**
3
+ * Resolves a fenced-code identifier to a supported syntax grammar.
4
+ *
5
+ * @param className - The language class generated from the Markdown fence.
6
+ *
7
+ * @returns The supported language, or undefined for an unknown identifier.
8
+ */
9
+ export declare function resolveCodeLanguage(className?: string): CodeLanguage | undefined;
@@ -0,0 +1,15 @@
1
+ import type { MouseEventHandler } from "react";
2
+ import type { Components } from "react-markdown";
3
+ import { type MarkdownImageSourceAllowlist } from "./security";
4
+ /**
5
+ * Creates the constrained element renderers used by Markdown.
6
+ *
7
+ * @param allowedImageSources - The consumer-owned image source allowlist.
8
+ * @param imageBaseUrl - The trusted base used to resolve relative sources.
9
+ * @param maxCodeHighlightLength - Maximum highlighted code-block length.
10
+ * @param maxCodeLineCount - Maximum individually rendered code-block lines.
11
+ * @param onAnchorClick - The handler for scoped in-document navigation.
12
+ *
13
+ * @returns Renderers composed from semantic Neatkit components.
14
+ */
15
+ export declare function createMarkdownComponents(allowedImageSources: MarkdownImageSourceAllowlist | undefined, imageBaseUrl: string | undefined, maxCodeHighlightLength: number | null | undefined, maxCodeLineCount: number | null | undefined, onAnchorClick: MouseEventHandler<HTMLAnchorElement>): Components;
@@ -0,0 +1,66 @@
1
+ import type { Root } from "hast";
2
+ import { type Options as SanitizeSchema } from "rehype-sanitize";
3
+ /** Options used to prefix public Markdown identifiers. */
4
+ type MarkdownIdentifierOptions = {
5
+ /** The fixed security prefix applied by the final sanitizer. */
6
+ clobberPrefix: string;
7
+ /** The stable consumer-provided prefix prepended to every identifier. */
8
+ prefix: string;
9
+ };
10
+ /** The namespace preventing Markdown IDs from clobbering host globals. */
11
+ export declare const MARKDOWN_CLOBBER_PREFIX = "md-";
12
+ /** Sources a Markdown document may load as images. */
13
+ export type MarkdownImageSourceAllowlist = "*" | RegExp | readonly RegExp[];
14
+ /** The elements produced by the supported CommonMark and GFM syntax. */
15
+ export declare const ALLOWED_MARKDOWN_ELEMENTS: readonly ["a", "blockquote", "br", "code", "del", "em", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "img", "input", "li", "ol", "p", "picture", "pre", "section", "source", "strong", "sup", "table", "tbody", "td", "th", "thead", "tr", "ul"];
16
+ /** The final sanitizer schema applied after all Markdown transformations. */
17
+ export declare const MARKDOWN_SANITIZE_SCHEMA: SanitizeSchema;
18
+ /**
19
+ * Resolves an image source through the consumer's explicit allowlist.
20
+ *
21
+ * Pattern policies inspect and return a normalized absolute URL. Relative and
22
+ * protocol-relative sources therefore require an explicit trusted base URL.
23
+ * The wildcard retains authored URLs after applying the protocol constraints.
24
+ *
25
+ * @param source - The safe source returned by React Markdown.
26
+ * @param allowedSources - The consumer-owned source allowlist.
27
+ * @param baseUrl - The trusted base used to resolve non-absolute sources.
28
+ *
29
+ * @returns The safe URL to render, or undefined when the source is blocked.
30
+ */
31
+ export declare function resolveAllowedImageSource(source: string, allowedSources: MarkdownImageSourceAllowlist | undefined, baseUrl?: string): string | undefined;
32
+ /**
33
+ * Filters one responsive image source list through the image URL policy.
34
+ *
35
+ * A malformed candidate invalidates the complete list instead of allowing the
36
+ * browser to select an unverified fallback.
37
+ *
38
+ * @param sourceSet - The comma-separated image candidates to validate.
39
+ * @param allowedSources - The consumer-owned source allowlist.
40
+ * @param baseUrl - The trusted base used to resolve non-absolute sources.
41
+ *
42
+ * @returns The safe normalized list, or undefined when a candidate is unsafe.
43
+ */
44
+ export declare function sanitizeImageSourceSet(sourceSet: string | undefined, allowedSources: MarkdownImageSourceAllowlist | undefined, baseUrl?: string): string | undefined;
45
+ /**
46
+ * Removes authored inputs while retaining inert GFM task-list controls.
47
+ *
48
+ * Rehype Raw preserves source positions on authored HTML elements, whereas
49
+ * Remark GFM creates its disabled task-list inputs without source positions.
50
+ *
51
+ * @returns A rehype transformer that prevents authored form controls.
52
+ */
53
+ export declare function rehypeRemoveAuthoredInputs(): (tree: Root) => void;
54
+ /**
55
+ * Prefixes IDs and their internal references before final sanitization.
56
+ *
57
+ * The public prefix is applied to declarations and references here. The final
58
+ * sanitizer adds the fixed clobber prefix to declarations and ARIA references,
59
+ * so local fragment links account for that prefix in advance.
60
+ *
61
+ * @param options - The fixed security prefix and public document prefix.
62
+ *
63
+ * @returns A rehype transformer that keeps declarations and references aligned.
64
+ */
65
+ export declare function rehypePrefixMarkdownIdentifiers(options: MarkdownIdentifierOptions): (tree: Root) => void;
66
+ export {};
@@ -12,8 +12,6 @@ export type TableProps = TableHTMLAttributes<HTMLTableElement> & {
12
12
  children: ReactNode;
13
13
  /** The additional class name applied to the horizontal scroll container. */
14
14
  containerClassName?: string;
15
- /** The accessible label announced for the horizontal scroll container. */
16
- scrollContainerLabel?: string;
17
15
  };
18
16
  /** A type representing properties for the Table.Head component. */
19
17
  export type TableHeadProps = HTMLAttributes<HTMLTableSectionElement> & {
@@ -35,20 +33,20 @@ export type TableFootProps = HTMLAttributes<HTMLTableSectionElement> & {
35
33
  children: ReactNode;
36
34
  };
37
35
  /** Shared native properties for every Table.Row configuration. */
38
- type TableRowBaseProps = Omit<HTMLAttributes<HTMLTableRowElement>, "children" | "onClick"> & {
36
+ type TableRowBaseProps = Omit<HTMLAttributes<HTMLTableRowElement>, "aria-label" | "children" | "onClick"> & {
39
37
  /** The cells rendered inside the Table row. */
40
38
  children: ReactNode;
41
39
  };
42
40
  /** A type representing a static Table.Row configuration. */
43
41
  type TableStaticRowProps = {
42
+ /** The optional accessible name applied to the static row. */
43
+ "aria-label"?: string;
44
44
  /** Static rows do not expose download behavior. */
45
45
  download?: never;
46
46
  /** Static rows do not expose a navigation destination. */
47
47
  href?: never;
48
48
  /** Static rows do not describe a linked resource language. */
49
49
  hrefLang?: never;
50
- /** Static rows do not require an action label. */
51
- label?: never;
52
50
  /** Static rows do not expose whole-row activation. */
53
51
  onClick?: never;
54
52
  /** Static rows do not expose navigation interception. */
@@ -58,14 +56,14 @@ type TableStaticRowProps = {
58
56
  };
59
57
  /** A type representing a button-backed Table.Row configuration. */
60
58
  type TableButtonRowProps = {
59
+ /** The accessible name describing the whole-row action. */
60
+ "aria-label": string;
61
61
  /** Button-backed rows do not expose download behavior. */
62
62
  download?: never;
63
63
  /** Button-backed rows do not expose a navigation destination. */
64
64
  href?: never;
65
65
  /** Button-backed rows do not describe a linked resource language. */
66
66
  hrefLang?: never;
67
- /** The accessible name describing the whole-row action. */
68
- label: string;
69
67
  /** The callback invoked when the row's button is activated. */
70
68
  onClick: MouseEventHandler<HTMLButtonElement>;
71
69
  /** Button-backed rows do not expose navigation interception. */
@@ -75,14 +73,14 @@ type TableButtonRowProps = {
75
73
  };
76
74
  /** A type representing a link-backed Table.Row configuration. */
77
75
  type TableLinkRowProps = {
76
+ /** The accessible name describing the whole-row link. */
77
+ "aria-label": string;
78
78
  /** Whether the linked resource should be downloaded. */
79
79
  download?: boolean | string;
80
80
  /** The destination opened by whole-row activation. */
81
81
  href: string;
82
82
  /** The language of the linked resource. */
83
83
  hrefLang?: string;
84
- /** The accessible name describing the whole-row link. */
85
- label: string;
86
84
  /** Link-backed rows do not expose button activation. */
87
85
  onClick?: never;
88
86
  /** The callback invoked when the row's link is activated. */
@@ -279,8 +277,6 @@ declare const TableRoot: import("react").ForwardRefExoticComponent<TableHTMLAttr
279
277
  children: ReactNode;
280
278
  /** The additional class name applied to the horizontal scroll container. */
281
279
  containerClassName?: string;
282
- /** The accessible label announced for the horizontal scroll container. */
283
- scrollContainerLabel?: string;
284
280
  } & import("react").RefAttributes<HTMLTableElement>>;
285
281
  /** The compound Table component and its semantic subcomponents. */
286
282
  declare const Table: TableComponent;
@@ -0,0 +1 @@
1
+ export { Code, type CodeLanguage, type CodeProps, } from "../components/Code";
@@ -0,0 +1,29 @@
1
+ import "../style.css";
2
+ export { breakpoint, cell, px, space, } from "../utils/units";
3
+ export { tokens } from "../tokens";
4
+ export type { BreakpointName, SpaceSize } from "../tokens";
5
+ export { Alert, type AlertProps, type AlertTone, } from "../components/Alert";
6
+ export { Avatar, type AvatarProps } from "../components/Avatar";
7
+ export { Badge, type BadgeProps, type BadgeTone, type BadgeVariant, } from "../components/Badge";
8
+ export { Button, type ButtonIconAlignment, type ButtonProps, type ButtonShape, type ButtonTextAlignment, type ButtonTone, type ButtonVariant, } from "../components/Button";
9
+ export { Card, type CardHeader, type CardProps, type CardSpacing, } from "../components/Card";
10
+ export { Checkbox, type CheckboxProps } from "../components/Checkbox";
11
+ export { CheckboxGroup, type CheckboxGroupOrientation, type CheckboxGroupProps, } from "../components/CheckboxGroup";
12
+ export { Content, type ContentMinHeight, type ContentMode, type ContentProps, type ContentSpacing, type ContentTheme, } from "../components/Content";
13
+ export { Divider, type DividerOrientation, type DividerProps, } from "../components/Divider";
14
+ export { Field, type FieldOrientation, type FieldProps, } from "../components/Field";
15
+ export { Icon, type IconProps, type IconType } from "../components/Icon";
16
+ export { Input, type InputProps, type InputType, } from "../components/Input";
17
+ export { Modal, type ModalCloseReason, type ModalProps, } from "../components/Modal";
18
+ export { Popover, type PopoverOpenChangeReason, type PopoverPlacement, type PopoverProps, } from "../components/Popover";
19
+ export { PinInput, type PinInputMode, type PinInputProps, } from "../components/PinInput";
20
+ export { Radio, type RadioProps } from "../components/Radio";
21
+ export { RadioGroup, type RadioGroupOrientation, type RadioGroupProps, } from "../components/RadioGroup";
22
+ export { Select, type CustomSelectProps, type NativeSelectProps, type SelectDisplayOverride, type SelectOption, type SelectProps, } from "../components/Select";
23
+ export { Skeleton, type SkeletonProps, type SkeletonShape, } from "../components/Skeleton";
24
+ export { Spinner, type SpinnerProps } from "../components/Spinner";
25
+ export { Switch, type SwitchProps } from "../components/Switch";
26
+ export { Table, type TableActionCellProps, type TableActionHeaderCellProps, type TableActionProps, type TableBodyProps, type TableCellAlignment, type TableCellProps, type TableCellValue, type TableFootProps, type TableHeaderCellProps, type TableHeadProps, type TableProps, type TableRowProps, } from "../components/Table";
27
+ export { Text, type TextAlignment, type TextProps, type TextSize, type TextTone, type TextWeight, } from "../components/Text";
28
+ export { TextArea, type TextAreaProps, type TextAreaResize, } from "../components/TextArea";
29
+ export { Tooltip, type TooltipPlacement, type TooltipProps, TooltipProvider, type TooltipProviderProps, } from "../components/Tooltip";
@@ -0,0 +1 @@
1
+ export { Markdown, type MarkdownImageSourceAllowlist, type MarkdownProps, } from "../components/Markdown";