@storybook/blocks 8.6.0-alpha.2 → 8.6.0-alpha.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/index.d.ts +98 -84
- package/dist/index.js +11 -12
- package/dist/index.mjs +11 -12
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -415,47 +415,48 @@ declare const Heading: FC<PropsWithChildren<HeadingProps>>;
|
|
|
415
415
|
* Analogous to `node.type`. Please note that the values here may change at any time,
|
|
416
416
|
* so do not hard code against the value directly.
|
|
417
417
|
*/
|
|
418
|
-
declare const
|
|
419
|
-
blockQuote
|
|
420
|
-
breakLine
|
|
421
|
-
breakThematic
|
|
422
|
-
codeBlock
|
|
423
|
-
codeFenced
|
|
424
|
-
codeInline
|
|
425
|
-
footnote
|
|
426
|
-
footnoteReference
|
|
427
|
-
gfmTask
|
|
428
|
-
heading
|
|
429
|
-
headingSetext
|
|
418
|
+
declare const RuleType: {
|
|
419
|
+
readonly blockQuote: "0";
|
|
420
|
+
readonly breakLine: "1";
|
|
421
|
+
readonly breakThematic: "2";
|
|
422
|
+
readonly codeBlock: "3";
|
|
423
|
+
readonly codeFenced: "4";
|
|
424
|
+
readonly codeInline: "5";
|
|
425
|
+
readonly footnote: "6";
|
|
426
|
+
readonly footnoteReference: "7";
|
|
427
|
+
readonly gfmTask: "8";
|
|
428
|
+
readonly heading: "9";
|
|
429
|
+
readonly headingSetext: "10";
|
|
430
430
|
/** only available if not `disableHTMLParsing` */
|
|
431
|
-
htmlBlock
|
|
432
|
-
htmlComment
|
|
431
|
+
readonly htmlBlock: "11";
|
|
432
|
+
readonly htmlComment: "12";
|
|
433
433
|
/** only available if not `disableHTMLParsing` */
|
|
434
|
-
htmlSelfClosing
|
|
435
|
-
image
|
|
436
|
-
link
|
|
434
|
+
readonly htmlSelfClosing: "13";
|
|
435
|
+
readonly image: "14";
|
|
436
|
+
readonly link: "15";
|
|
437
437
|
/** emits a `link` 'node', does not render directly */
|
|
438
|
-
linkAngleBraceStyleDetector
|
|
438
|
+
readonly linkAngleBraceStyleDetector: "16";
|
|
439
439
|
/** emits a `link` 'node', does not render directly */
|
|
440
|
-
linkBareUrlDetector
|
|
440
|
+
readonly linkBareUrlDetector: "17";
|
|
441
441
|
/** emits a `link` 'node', does not render directly */
|
|
442
|
-
linkMailtoDetector
|
|
443
|
-
newlineCoalescer
|
|
444
|
-
orderedList
|
|
445
|
-
paragraph
|
|
446
|
-
ref
|
|
447
|
-
refImage
|
|
448
|
-
refLink
|
|
449
|
-
table
|
|
450
|
-
tableSeparator
|
|
451
|
-
text
|
|
452
|
-
textBolded
|
|
453
|
-
textEmphasized
|
|
454
|
-
textEscaped
|
|
455
|
-
textMarked
|
|
456
|
-
textStrikethroughed
|
|
457
|
-
unorderedList
|
|
458
|
-
}
|
|
442
|
+
readonly linkMailtoDetector: "18";
|
|
443
|
+
readonly newlineCoalescer: "19";
|
|
444
|
+
readonly orderedList: "20";
|
|
445
|
+
readonly paragraph: "21";
|
|
446
|
+
readonly ref: "22";
|
|
447
|
+
readonly refImage: "23";
|
|
448
|
+
readonly refLink: "24";
|
|
449
|
+
readonly table: "25";
|
|
450
|
+
readonly tableSeparator: "26";
|
|
451
|
+
readonly text: "27";
|
|
452
|
+
readonly textBolded: "28";
|
|
453
|
+
readonly textEmphasized: "29";
|
|
454
|
+
readonly textEscaped: "30";
|
|
455
|
+
readonly textMarked: "31";
|
|
456
|
+
readonly textStrikethroughed: "32";
|
|
457
|
+
readonly unorderedList: "33";
|
|
458
|
+
};
|
|
459
|
+
type RuleType = (typeof RuleType)[keyof typeof RuleType];
|
|
459
460
|
declare const enum Priority {
|
|
460
461
|
/**
|
|
461
462
|
* anything that must scan the tree before everything else
|
|
@@ -482,8 +483,7 @@ declare const enum Priority {
|
|
|
482
483
|
* A simple HOC for easy React use. Feed the markdown content as a direct child
|
|
483
484
|
* and the rest is taken care of automatically.
|
|
484
485
|
*/
|
|
485
|
-
declare const Markdown$1: React.FC<{
|
|
486
|
-
[key: string]: any;
|
|
486
|
+
declare const Markdown$1: React.FC<Omit<React.HTMLAttributes<Element>, 'children'> & {
|
|
487
487
|
children: string;
|
|
488
488
|
options?: MarkdownToJSX.Options;
|
|
489
489
|
}>;
|
|
@@ -495,7 +495,7 @@ declare namespace MarkdownToJSX {
|
|
|
495
495
|
[K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
|
|
496
496
|
}[Keys];
|
|
497
497
|
export type CreateElement = typeof React.createElement;
|
|
498
|
-
export type HTMLTags = keyof JSX.IntrinsicElements;
|
|
498
|
+
export type HTMLTags = keyof React.JSX.IntrinsicElements;
|
|
499
499
|
export type State = {
|
|
500
500
|
/** true if the current content is inside anchor link grammar */
|
|
501
501
|
inAnchor?: boolean;
|
|
@@ -507,111 +507,114 @@ declare namespace MarkdownToJSX {
|
|
|
507
507
|
key?: React.Key;
|
|
508
508
|
/** true if in a list */
|
|
509
509
|
list?: boolean;
|
|
510
|
+
/** used for lookbacks */
|
|
511
|
+
prevCapture?: string;
|
|
510
512
|
/** true if parsing in inline context w/o links */
|
|
511
513
|
simple?: boolean;
|
|
512
514
|
};
|
|
513
515
|
export interface BlockQuoteNode {
|
|
516
|
+
alert?: string;
|
|
514
517
|
children: MarkdownToJSX.ParserResult[];
|
|
515
|
-
type: RuleType.blockQuote;
|
|
518
|
+
type: typeof RuleType.blockQuote;
|
|
516
519
|
}
|
|
517
520
|
export interface BreakLineNode {
|
|
518
|
-
type: RuleType.breakLine;
|
|
521
|
+
type: typeof RuleType.breakLine;
|
|
519
522
|
}
|
|
520
523
|
export interface BreakThematicNode {
|
|
521
|
-
type: RuleType.breakThematic;
|
|
524
|
+
type: typeof RuleType.breakThematic;
|
|
522
525
|
}
|
|
523
526
|
export interface CodeBlockNode {
|
|
524
|
-
type: RuleType.codeBlock;
|
|
525
|
-
attrs?: JSX.IntrinsicAttributes;
|
|
527
|
+
type: typeof RuleType.codeBlock;
|
|
528
|
+
attrs?: React.JSX.IntrinsicAttributes;
|
|
526
529
|
lang?: string;
|
|
527
530
|
text: string;
|
|
528
531
|
}
|
|
529
532
|
export interface CodeFencedNode {
|
|
530
|
-
type: RuleType.codeFenced;
|
|
533
|
+
type: typeof RuleType.codeFenced;
|
|
531
534
|
}
|
|
532
535
|
export interface CodeInlineNode {
|
|
533
|
-
type: RuleType.codeInline;
|
|
536
|
+
type: typeof RuleType.codeInline;
|
|
534
537
|
text: string;
|
|
535
538
|
}
|
|
536
539
|
export interface FootnoteNode {
|
|
537
|
-
type: RuleType.footnote;
|
|
540
|
+
type: typeof RuleType.footnote;
|
|
538
541
|
}
|
|
539
542
|
export interface FootnoteReferenceNode {
|
|
540
|
-
type: RuleType.footnoteReference;
|
|
543
|
+
type: typeof RuleType.footnoteReference;
|
|
541
544
|
target: string;
|
|
542
545
|
text: string;
|
|
543
546
|
}
|
|
544
547
|
export interface GFMTaskNode {
|
|
545
|
-
type: RuleType.gfmTask;
|
|
548
|
+
type: typeof RuleType.gfmTask;
|
|
546
549
|
completed: boolean;
|
|
547
550
|
}
|
|
548
551
|
export interface HeadingNode {
|
|
549
|
-
type: RuleType.heading;
|
|
552
|
+
type: typeof RuleType.heading;
|
|
550
553
|
children: MarkdownToJSX.ParserResult[];
|
|
551
554
|
id: string;
|
|
552
555
|
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
553
556
|
}
|
|
554
557
|
export interface HeadingSetextNode {
|
|
555
|
-
type: RuleType.headingSetext;
|
|
558
|
+
type: typeof RuleType.headingSetext;
|
|
556
559
|
}
|
|
557
560
|
export interface HTMLCommentNode {
|
|
558
|
-
type: RuleType.htmlComment;
|
|
561
|
+
type: typeof RuleType.htmlComment;
|
|
559
562
|
}
|
|
560
563
|
export interface ImageNode {
|
|
561
|
-
type: RuleType.image;
|
|
564
|
+
type: typeof RuleType.image;
|
|
562
565
|
alt?: string;
|
|
563
566
|
target: string;
|
|
564
567
|
title?: string;
|
|
565
568
|
}
|
|
566
569
|
export interface LinkNode {
|
|
567
|
-
type: RuleType.link;
|
|
570
|
+
type: typeof RuleType.link;
|
|
568
571
|
children: MarkdownToJSX.ParserResult[];
|
|
569
572
|
target: string;
|
|
570
573
|
title?: string;
|
|
571
574
|
}
|
|
572
575
|
export interface LinkAngleBraceNode {
|
|
573
|
-
type: RuleType.linkAngleBraceStyleDetector;
|
|
576
|
+
type: typeof RuleType.linkAngleBraceStyleDetector;
|
|
574
577
|
}
|
|
575
578
|
export interface LinkBareURLNode {
|
|
576
|
-
type: RuleType.linkBareUrlDetector;
|
|
579
|
+
type: typeof RuleType.linkBareUrlDetector;
|
|
577
580
|
}
|
|
578
581
|
export interface LinkMailtoNode {
|
|
579
|
-
type: RuleType.linkMailtoDetector;
|
|
582
|
+
type: typeof RuleType.linkMailtoDetector;
|
|
580
583
|
}
|
|
581
584
|
export interface OrderedListNode {
|
|
582
|
-
type: RuleType.orderedList;
|
|
585
|
+
type: typeof RuleType.orderedList;
|
|
583
586
|
items: MarkdownToJSX.ParserResult[][];
|
|
584
587
|
ordered: true;
|
|
585
588
|
start?: number;
|
|
586
589
|
}
|
|
587
590
|
export interface UnorderedListNode {
|
|
588
|
-
type: RuleType.unorderedList;
|
|
591
|
+
type: typeof RuleType.unorderedList;
|
|
589
592
|
items: MarkdownToJSX.ParserResult[][];
|
|
590
593
|
ordered: false;
|
|
591
594
|
}
|
|
592
595
|
export interface NewlineNode {
|
|
593
|
-
type: RuleType.newlineCoalescer;
|
|
596
|
+
type: typeof RuleType.newlineCoalescer;
|
|
594
597
|
}
|
|
595
598
|
export interface ParagraphNode {
|
|
596
|
-
type: RuleType.paragraph;
|
|
599
|
+
type: typeof RuleType.paragraph;
|
|
597
600
|
children: MarkdownToJSX.ParserResult[];
|
|
598
601
|
}
|
|
599
602
|
export interface ReferenceNode {
|
|
600
|
-
type: RuleType.ref;
|
|
603
|
+
type: typeof RuleType.ref;
|
|
601
604
|
}
|
|
602
605
|
export interface ReferenceImageNode {
|
|
603
|
-
type: RuleType.refImage;
|
|
606
|
+
type: typeof RuleType.refImage;
|
|
604
607
|
alt?: string;
|
|
605
608
|
ref: string;
|
|
606
609
|
}
|
|
607
610
|
export interface ReferenceLinkNode {
|
|
608
|
-
type: RuleType.refLink;
|
|
611
|
+
type: typeof RuleType.refLink;
|
|
609
612
|
children: MarkdownToJSX.ParserResult[];
|
|
610
|
-
fallbackChildren:
|
|
613
|
+
fallbackChildren: string;
|
|
611
614
|
ref: string;
|
|
612
615
|
}
|
|
613
616
|
export interface TableNode {
|
|
614
|
-
type: RuleType.table;
|
|
617
|
+
type: typeof RuleType.table;
|
|
615
618
|
/**
|
|
616
619
|
* alignment for each table column
|
|
617
620
|
*/
|
|
@@ -620,48 +623,48 @@ declare namespace MarkdownToJSX {
|
|
|
620
623
|
header: MarkdownToJSX.ParserResult[][];
|
|
621
624
|
}
|
|
622
625
|
export interface TableSeparatorNode {
|
|
623
|
-
type: RuleType.tableSeparator;
|
|
626
|
+
type: typeof RuleType.tableSeparator;
|
|
624
627
|
}
|
|
625
628
|
export interface TextNode {
|
|
626
|
-
type: RuleType.text;
|
|
629
|
+
type: typeof RuleType.text;
|
|
627
630
|
text: string;
|
|
628
631
|
}
|
|
629
632
|
export interface BoldTextNode {
|
|
630
|
-
type: RuleType.textBolded;
|
|
633
|
+
type: typeof RuleType.textBolded;
|
|
631
634
|
children: MarkdownToJSX.ParserResult[];
|
|
632
635
|
}
|
|
633
636
|
export interface ItalicTextNode {
|
|
634
|
-
type: RuleType.textEmphasized;
|
|
637
|
+
type: typeof RuleType.textEmphasized;
|
|
635
638
|
children: MarkdownToJSX.ParserResult[];
|
|
636
639
|
}
|
|
637
640
|
export interface EscapedTextNode {
|
|
638
|
-
type: RuleType.textEscaped;
|
|
641
|
+
type: typeof RuleType.textEscaped;
|
|
639
642
|
}
|
|
640
643
|
export interface MarkedTextNode {
|
|
641
|
-
type: RuleType.textMarked;
|
|
644
|
+
type: typeof RuleType.textMarked;
|
|
642
645
|
children: MarkdownToJSX.ParserResult[];
|
|
643
646
|
}
|
|
644
647
|
export interface StrikethroughTextNode {
|
|
645
|
-
type: RuleType.textStrikethroughed;
|
|
648
|
+
type: typeof RuleType.textStrikethroughed;
|
|
646
649
|
children: MarkdownToJSX.ParserResult[];
|
|
647
650
|
}
|
|
648
651
|
export interface HTMLNode {
|
|
649
|
-
type: RuleType.htmlBlock;
|
|
650
|
-
attrs: JSX.IntrinsicAttributes;
|
|
652
|
+
type: typeof RuleType.htmlBlock;
|
|
653
|
+
attrs: React.JSX.IntrinsicAttributes;
|
|
651
654
|
children?: ReturnType<MarkdownToJSX.NestedParser> | undefined;
|
|
652
655
|
noInnerParse: Boolean;
|
|
653
656
|
tag: MarkdownToJSX.HTMLTags;
|
|
654
657
|
text?: string | undefined;
|
|
655
658
|
}
|
|
656
659
|
export interface HTMLSelfClosingNode {
|
|
657
|
-
type: RuleType.htmlSelfClosing;
|
|
658
|
-
attrs: JSX.IntrinsicAttributes;
|
|
660
|
+
type: typeof RuleType.htmlSelfClosing;
|
|
661
|
+
attrs: React.JSX.IntrinsicAttributes;
|
|
659
662
|
tag: string;
|
|
660
663
|
}
|
|
661
664
|
export type ParserResult = BlockQuoteNode | BreakLineNode | BreakThematicNode | CodeBlockNode | CodeFencedNode | CodeInlineNode | FootnoteNode | FootnoteReferenceNode | GFMTaskNode | HeadingNode | HeadingSetextNode | HTMLCommentNode | ImageNode | LinkNode | LinkAngleBraceNode | LinkBareURLNode | LinkMailtoNode | OrderedListNode | UnorderedListNode | NewlineNode | ParagraphNode | ReferenceNode | ReferenceImageNode | ReferenceLinkNode | TableNode | TableSeparatorNode | TextNode | BoldTextNode | ItalicTextNode | EscapedTextNode | MarkedTextNode | StrikethroughTextNode | HTMLNode | HTMLSelfClosingNode;
|
|
662
665
|
export type NestedParser = (input: string, state?: MarkdownToJSX.State) => MarkdownToJSX.ParserResult[];
|
|
663
666
|
export type Parser<ParserOutput> = (capture: RegExpMatchArray, nestedParse: NestedParser, state?: MarkdownToJSX.State) => ParserOutput;
|
|
664
|
-
export type RuleOutput = (ast: MarkdownToJSX.ParserResult | MarkdownToJSX.ParserResult[], state: MarkdownToJSX.State) => JSX.Element;
|
|
667
|
+
export type RuleOutput = (ast: MarkdownToJSX.ParserResult | MarkdownToJSX.ParserResult[], state: MarkdownToJSX.State) => React.JSX.Element;
|
|
665
668
|
export type Rule<ParserOutput = MarkdownToJSX.ParserResult> = {
|
|
666
669
|
match: (source: string, state: MarkdownToJSX.State, prevCapturedString?: string) => RegExpMatchArray;
|
|
667
670
|
order: Priority;
|
|
@@ -670,10 +673,12 @@ declare namespace MarkdownToJSX {
|
|
|
670
673
|
/**
|
|
671
674
|
* Continue rendering AST nodes if applicable.
|
|
672
675
|
*/
|
|
673
|
-
render: RuleOutput, state?: MarkdownToJSX.State) => React.
|
|
676
|
+
render: RuleOutput, state?: MarkdownToJSX.State) => React.ReactNode;
|
|
674
677
|
};
|
|
675
678
|
export type Rules = {
|
|
676
|
-
[K in ParserResult['type']]: Rule<Extract<ParserResult, {
|
|
679
|
+
[K in ParserResult['type']]: K extends typeof RuleType.table ? Rule<Extract<ParserResult, {
|
|
680
|
+
type: K | typeof RuleType.paragraph;
|
|
681
|
+
}>> : Rule<Extract<ParserResult, {
|
|
677
682
|
type: K;
|
|
678
683
|
}>>;
|
|
679
684
|
};
|
|
@@ -690,7 +695,12 @@ declare namespace MarkdownToJSX {
|
|
|
690
695
|
/**
|
|
691
696
|
* Ultimate control over the output of all rendered JSX.
|
|
692
697
|
*/
|
|
693
|
-
createElement: (tag: Parameters<CreateElement>[0], props: JSX.IntrinsicAttributes, ...children: React.
|
|
698
|
+
createElement: (tag: Parameters<CreateElement>[0], props: React.JSX.IntrinsicAttributes, ...children: React.ReactNode[]) => React.ReactNode;
|
|
699
|
+
/**
|
|
700
|
+
* The library automatically generates an anchor tag for bare URLs included in the markdown
|
|
701
|
+
* document, but this behavior can be disabled if desired.
|
|
702
|
+
*/
|
|
703
|
+
disableAutoLink: boolean;
|
|
694
704
|
/**
|
|
695
705
|
* Disable the compiler's best-effort transcription of provided raw HTML
|
|
696
706
|
* into JSX-equivalent. This is the functionality that prevents the need to
|
|
@@ -768,18 +778,22 @@ declare namespace MarkdownToJSX {
|
|
|
768
778
|
*/
|
|
769
779
|
renderRule: (
|
|
770
780
|
/** Resume normal processing, call this function as a fallback if you are not returning custom JSX. */
|
|
771
|
-
next: () => React.
|
|
781
|
+
next: () => React.ReactNode,
|
|
772
782
|
/** the current AST node, use `RuleType` against `node.type` for identification */
|
|
773
783
|
node: ParserResult,
|
|
774
784
|
/** use as `renderChildren(node.children)` for block nodes */
|
|
775
785
|
renderChildren: RuleOutput,
|
|
776
786
|
/** contains `key` which should be supplied to the topmost JSX element */
|
|
777
|
-
state: State) => React.
|
|
787
|
+
state: State) => React.ReactNode;
|
|
788
|
+
/**
|
|
789
|
+
* Override the built-in sanitizer function for URLs, etc if desired. The built-in version is available as a library export called `sanitizer`.
|
|
790
|
+
*/
|
|
791
|
+
sanitizer: (value: string, tag: HTMLTags, attribute: string) => string | null;
|
|
778
792
|
/**
|
|
779
793
|
* Override normalization of non-URI-safe characters for use in generating
|
|
780
794
|
* HTML IDs for anchor linking purposes.
|
|
781
795
|
*/
|
|
782
|
-
slugify: (
|
|
796
|
+
slugify: (input: string, defaultFn: (input: string) => string) => string;
|
|
783
797
|
/**
|
|
784
798
|
* Declare the type of the wrapper to be used when there are multiple
|
|
785
799
|
* children to render. Set to `null` to get an array of children back
|