@activecollab/components 2.0.409 → 2.0.411
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/cjs/components/BreakPoints.js +12 -1
- package/dist/cjs/components/BreakPoints.js.map +1 -1
- package/dist/cjs/components/Columns/Columns.js +42 -0
- package/dist/cjs/components/Columns/Columns.js.map +1 -0
- package/dist/cjs/components/Columns/Styles.js +25 -0
- package/dist/cjs/components/Columns/Styles.js.map +1 -0
- package/dist/cjs/components/Columns/index.js +17 -0
- package/dist/cjs/components/Columns/index.js.map +1 -0
- package/dist/cjs/components/LayoutTokens.js +21 -0
- package/dist/cjs/components/LayoutTokens.js.map +1 -0
- package/dist/cjs/components/Media/Media.js +39 -0
- package/dist/cjs/components/Media/Media.js.map +1 -0
- package/dist/cjs/components/Media/Styles.js +18 -0
- package/dist/cjs/components/Media/Styles.js.map +1 -0
- package/dist/cjs/components/Media/index.js +17 -0
- package/dist/cjs/components/Media/index.js.map +1 -0
- package/dist/cjs/components/PortableText/PortableText.js +125 -0
- package/dist/cjs/components/PortableText/PortableText.js.map +1 -0
- package/dist/cjs/components/PortableText/Styles.js +33 -0
- package/dist/cjs/components/PortableText/Styles.js.map +1 -0
- package/dist/cjs/components/PortableText/index.js +39 -0
- package/dist/cjs/components/PortableText/index.js.map +1 -0
- package/dist/cjs/components/PortableText/renderers.js +136 -0
- package/dist/cjs/components/PortableText/renderers.js.map +1 -0
- package/dist/cjs/components/PortableText/types.js +122 -0
- package/dist/cjs/components/PortableText/types.js.map +1 -0
- package/dist/cjs/components/PortableText/types.test.js +194 -0
- package/dist/cjs/components/PortableText/types.test.js.map +1 -0
- package/dist/cjs/components/Row/Row.js +30 -0
- package/dist/cjs/components/Row/Row.js.map +1 -0
- package/dist/cjs/components/Row/Styles.js +25 -0
- package/dist/cjs/components/Row/Styles.js.map +1 -0
- package/dist/cjs/components/Row/index.js +17 -0
- package/dist/cjs/components/Row/index.js.map +1 -0
- package/dist/cjs/components/Stack/Stack.js +27 -0
- package/dist/cjs/components/Stack/Stack.js.map +1 -0
- package/dist/cjs/components/Stack/Styles.js +21 -0
- package/dist/cjs/components/Stack/Styles.js.map +1 -0
- package/dist/cjs/components/Stack/index.js +17 -0
- package/dist/cjs/components/Stack/index.js.map +1 -0
- package/dist/cjs/components/Tiles/Styles.js +25 -0
- package/dist/cjs/components/Tiles/Styles.js.map +1 -0
- package/dist/cjs/components/Tiles/Tiles.js +29 -0
- package/dist/cjs/components/Tiles/Tiles.js.map +1 -0
- package/dist/cjs/components/Tiles/index.js +17 -0
- package/dist/cjs/components/Tiles/index.js.map +1 -0
- package/dist/cjs/components/TitledText/Styles.js +15 -0
- package/dist/cjs/components/TitledText/Styles.js.map +1 -0
- package/dist/cjs/components/TitledText/TitledText.js +50 -0
- package/dist/cjs/components/TitledText/TitledText.js.map +1 -0
- package/dist/cjs/components/TitledText/index.js +17 -0
- package/dist/cjs/components/TitledText/index.js.map +1 -0
- package/dist/cjs/components/index.js +88 -0
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/cjs/presentation/shared/MessageDialog.js +351 -0
- package/dist/cjs/presentation/shared/MessageDialog.js.map +1 -0
- package/dist/cjs/presentation/shared/index.js +22 -0
- package/dist/cjs/presentation/shared/index.js.map +1 -1
- package/dist/esm/components/BreakPoints.d.ts +2 -0
- package/dist/esm/components/BreakPoints.d.ts.map +1 -1
- package/dist/esm/components/BreakPoints.js +9 -0
- package/dist/esm/components/BreakPoints.js.map +1 -1
- package/dist/esm/components/Columns/Columns.d.ts +11 -0
- package/dist/esm/components/Columns/Columns.d.ts.map +1 -0
- package/dist/esm/components/Columns/Columns.js +34 -0
- package/dist/esm/components/Columns/Columns.js.map +1 -0
- package/dist/esm/components/Columns/Styles.d.ts +8 -0
- package/dist/esm/components/Columns/Styles.d.ts.map +1 -0
- package/dist/esm/components/Columns/Styles.js +18 -0
- package/dist/esm/components/Columns/Styles.js.map +1 -0
- package/dist/esm/components/Columns/index.d.ts +2 -0
- package/dist/esm/components/Columns/index.d.ts.map +1 -0
- package/dist/esm/components/Columns/index.js +2 -0
- package/dist/esm/components/Columns/index.js.map +1 -0
- package/dist/esm/components/LayoutTokens.d.ts +6 -0
- package/dist/esm/components/LayoutTokens.d.ts.map +1 -0
- package/dist/esm/components/LayoutTokens.js +15 -0
- package/dist/esm/components/LayoutTokens.js.map +1 -0
- package/dist/esm/components/Media/Media.d.ts +10 -0
- package/dist/esm/components/Media/Media.d.ts.map +1 -0
- package/dist/esm/components/Media/Media.js +31 -0
- package/dist/esm/components/Media/Media.js.map +1 -0
- package/dist/esm/components/Media/Styles.d.ts +4 -0
- package/dist/esm/components/Media/Styles.d.ts.map +1 -0
- package/dist/esm/components/Media/Styles.js +11 -0
- package/dist/esm/components/Media/Styles.js.map +1 -0
- package/dist/esm/components/Media/index.d.ts +2 -0
- package/dist/esm/components/Media/index.d.ts.map +1 -0
- package/dist/esm/components/Media/index.js +2 -0
- package/dist/esm/components/Media/index.js.map +1 -0
- package/dist/esm/components/PortableText/PortableText.d.ts +24 -0
- package/dist/esm/components/PortableText/PortableText.d.ts.map +1 -0
- package/dist/esm/components/PortableText/PortableText.js +111 -0
- package/dist/esm/components/PortableText/PortableText.js.map +1 -0
- package/dist/esm/components/PortableText/Styles.d.ts +9 -0
- package/dist/esm/components/PortableText/Styles.d.ts.map +1 -0
- package/dist/esm/components/PortableText/Styles.js +27 -0
- package/dist/esm/components/PortableText/Styles.js.map +1 -0
- package/dist/esm/components/PortableText/index.d.ts +4 -0
- package/dist/esm/components/PortableText/index.d.ts.map +1 -0
- package/dist/esm/components/PortableText/index.js +4 -0
- package/dist/esm/components/PortableText/index.js.map +1 -0
- package/dist/esm/components/PortableText/renderers.d.ts +9 -0
- package/dist/esm/components/PortableText/renderers.d.ts.map +1 -0
- package/dist/esm/components/PortableText/renderers.js +130 -0
- package/dist/esm/components/PortableText/renderers.js.map +1 -0
- package/dist/esm/components/PortableText/types.d.ts +141 -0
- package/dist/esm/components/PortableText/types.d.ts.map +1 -0
- package/dist/esm/components/PortableText/types.js +106 -0
- package/dist/esm/components/PortableText/types.js.map +1 -0
- package/dist/esm/components/PortableText/types.test.d.ts +2 -0
- package/dist/esm/components/PortableText/types.test.d.ts.map +1 -0
- package/dist/esm/components/PortableText/types.test.js +192 -0
- package/dist/esm/components/PortableText/types.test.js.map +1 -0
- package/dist/esm/components/Row/Row.d.ts +10 -0
- package/dist/esm/components/Row/Row.d.ts.map +1 -0
- package/dist/esm/components/Row/Row.js +22 -0
- package/dist/esm/components/Row/Row.js.map +1 -0
- package/dist/esm/components/Row/Styles.d.ts +8 -0
- package/dist/esm/components/Row/Styles.d.ts.map +1 -0
- package/dist/esm/components/Row/Styles.js +18 -0
- package/dist/esm/components/Row/Styles.js.map +1 -0
- package/dist/esm/components/Row/index.d.ts +2 -0
- package/dist/esm/components/Row/index.d.ts.map +1 -0
- package/dist/esm/components/Row/index.js +2 -0
- package/dist/esm/components/Row/index.js.map +1 -0
- package/dist/esm/components/Stack/Stack.d.ts +8 -0
- package/dist/esm/components/Stack/Stack.d.ts.map +1 -0
- package/dist/esm/components/Stack/Stack.js +19 -0
- package/dist/esm/components/Stack/Stack.js.map +1 -0
- package/dist/esm/components/Stack/Styles.d.ts +6 -0
- package/dist/esm/components/Stack/Styles.d.ts.map +1 -0
- package/dist/esm/components/Stack/Styles.js +14 -0
- package/dist/esm/components/Stack/Styles.js.map +1 -0
- package/dist/esm/components/Stack/index.d.ts +2 -0
- package/dist/esm/components/Stack/index.d.ts.map +1 -0
- package/dist/esm/components/Stack/index.js +2 -0
- package/dist/esm/components/Stack/index.js.map +1 -0
- package/dist/esm/components/Tiles/Styles.d.ts +8 -0
- package/dist/esm/components/Tiles/Styles.d.ts.map +1 -0
- package/dist/esm/components/Tiles/Styles.js +18 -0
- package/dist/esm/components/Tiles/Styles.js.map +1 -0
- package/dist/esm/components/Tiles/Tiles.d.ts +10 -0
- package/dist/esm/components/Tiles/Tiles.d.ts.map +1 -0
- package/dist/esm/components/Tiles/Tiles.js +21 -0
- package/dist/esm/components/Tiles/Tiles.js.map +1 -0
- package/dist/esm/components/Tiles/index.d.ts +2 -0
- package/dist/esm/components/Tiles/index.d.ts.map +1 -0
- package/dist/esm/components/Tiles/index.js +2 -0
- package/dist/esm/components/Tiles/index.js.map +1 -0
- package/dist/esm/components/TitledText/Styles.d.ts +2 -0
- package/dist/esm/components/TitledText/Styles.d.ts.map +1 -0
- package/dist/esm/components/TitledText/Styles.js +8 -0
- package/dist/esm/components/TitledText/Styles.js.map +1 -0
- package/dist/esm/components/TitledText/TitledText.d.ts +18 -0
- package/dist/esm/components/TitledText/TitledText.d.ts.map +1 -0
- package/dist/esm/components/TitledText/TitledText.js +43 -0
- package/dist/esm/components/TitledText/TitledText.js.map +1 -0
- package/dist/esm/components/TitledText/index.d.ts +2 -0
- package/dist/esm/components/TitledText/index.d.ts.map +1 -0
- package/dist/esm/components/TitledText/index.js +2 -0
- package/dist/esm/components/TitledText/index.js.map +1 -0
- package/dist/esm/components/index.d.ts +8 -0
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/components/index.js +8 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/presentation/shared/MessageDialog.d.ts +35 -0
- package/dist/esm/presentation/shared/MessageDialog.d.ts.map +1 -0
- package/dist/esm/presentation/shared/MessageDialog.js +331 -0
- package/dist/esm/presentation/shared/MessageDialog.js.map +1 -0
- package/dist/esm/presentation/shared/index.d.ts +2 -0
- package/dist/esm/presentation/shared/index.d.ts.map +1 -1
- package/dist/esm/presentation/shared/index.js +1 -0
- package/dist/esm/presentation/shared/index.js.map +1 -1
- package/dist/index.js +1375 -742
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { ComponentType, ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Portable Text envelope — the general content contract for structured,
|
|
4
|
+
* renderer-independent content (in-app messages, help, changelogs).
|
|
5
|
+
*
|
|
6
|
+
* The design system owns this envelope and the universal default set below.
|
|
7
|
+
* It never hardcodes a product element: concrete elements (callout,
|
|
8
|
+
* button-reference, doc-link, …) are defined in the application catalog and
|
|
9
|
+
* injected into the Portable Text engine through {@link PortableTextComponents}.
|
|
10
|
+
* See README.md next to this file for the full contract.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* A mark with data. Parameterless marks travel as plain strings ("strong");
|
|
14
|
+
* marks that need data travel as objects discriminated by `type`.
|
|
15
|
+
*/
|
|
16
|
+
export interface PortableTextMarkObject {
|
|
17
|
+
type: string;
|
|
18
|
+
[data: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
/** The one default mark that carries data. */
|
|
21
|
+
export interface PortableTextLinkMark extends PortableTextMarkObject {
|
|
22
|
+
type: "link";
|
|
23
|
+
href: string;
|
|
24
|
+
}
|
|
25
|
+
export type PortableTextMark = string | PortableTextMarkObject;
|
|
26
|
+
/** The leaf of every text run: a piece of text plus the marks wrapping it. */
|
|
27
|
+
export interface PortableTextSpan {
|
|
28
|
+
text: string;
|
|
29
|
+
marks?: PortableTextMark[];
|
|
30
|
+
}
|
|
31
|
+
/** Marks every client understands without injection. */
|
|
32
|
+
export declare const PORTABLE_TEXT_DEFAULT_MARKS: readonly ["strong", "em", "code", "link"];
|
|
33
|
+
export type PortableTextDefaultMark = (typeof PORTABLE_TEXT_DEFAULT_MARKS)[number];
|
|
34
|
+
export interface PortableTextParagraphBlock {
|
|
35
|
+
type: "paragraph";
|
|
36
|
+
children: PortableTextSpan[];
|
|
37
|
+
}
|
|
38
|
+
/** 1 maps to Title1, 2 to Title2, 3 to Header2 typography. */
|
|
39
|
+
export type PortableTextHeadingLevel = 1 | 2 | 3;
|
|
40
|
+
export interface PortableTextHeadingBlock {
|
|
41
|
+
type: "heading";
|
|
42
|
+
level: PortableTextHeadingLevel;
|
|
43
|
+
children: PortableTextSpan[];
|
|
44
|
+
}
|
|
45
|
+
export type PortableTextListStyle = "bullet" | "number";
|
|
46
|
+
export interface PortableTextListItemBlock {
|
|
47
|
+
type: "list-item";
|
|
48
|
+
children: PortableTextSpan[];
|
|
49
|
+
}
|
|
50
|
+
export interface PortableTextListBlock {
|
|
51
|
+
type: "list";
|
|
52
|
+
style?: PortableTextListStyle;
|
|
53
|
+
children: PortableTextListItemBlock[];
|
|
54
|
+
}
|
|
55
|
+
/** Screenshots render framed (border, no shadow); illustrations render flat. */
|
|
56
|
+
export type PortableTextMediaVariant = "screenshot" | "illustration";
|
|
57
|
+
export interface PortableTextMediaBlock {
|
|
58
|
+
type: "media";
|
|
59
|
+
src: string;
|
|
60
|
+
alt?: string;
|
|
61
|
+
variant?: PortableTextMediaVariant;
|
|
62
|
+
caption?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface PortableTextTitledTextBlock {
|
|
65
|
+
type: "titled-text";
|
|
66
|
+
/**
|
|
67
|
+
* Same semantic scale as `heading` — 1, 2 or 3 (the default) — so the wire
|
|
68
|
+
* format never encodes a typography name. How a level looks is the
|
|
69
|
+
* renderer's business.
|
|
70
|
+
*/
|
|
71
|
+
level?: PortableTextHeadingLevel;
|
|
72
|
+
title: string;
|
|
73
|
+
content?: PortableTextNode[];
|
|
74
|
+
}
|
|
75
|
+
export type PortableTextBlock = PortableTextParagraphBlock | PortableTextHeadingBlock | PortableTextListBlock | PortableTextMediaBlock | PortableTextTitledTextBlock;
|
|
76
|
+
/**
|
|
77
|
+
* Derived from the union's discriminators, so adding a block to the union
|
|
78
|
+
* without a renderer entry is a compile error, never silent drift.
|
|
79
|
+
*/
|
|
80
|
+
export type PortableTextDefaultBlockType = (PortableTextBlock | PortableTextListItemBlock)["type"];
|
|
81
|
+
/** Blocks every client understands without injection. */
|
|
82
|
+
export declare const PORTABLE_TEXT_DEFAULT_BLOCKS: readonly PortableTextDefaultBlockType[];
|
|
83
|
+
/**
|
|
84
|
+
* An embedded component the envelope does not interpret: `_type` names an
|
|
85
|
+
* application-catalog element, everything else is that element's data. An
|
|
86
|
+
* object whose `_type` has no injected renderer renders nothing and is logged.
|
|
87
|
+
*/
|
|
88
|
+
export interface PortableTextObjectNode {
|
|
89
|
+
type: "object";
|
|
90
|
+
_type: string;
|
|
91
|
+
[data: string]: unknown;
|
|
92
|
+
}
|
|
93
|
+
export type PortableTextNode = PortableTextBlock | PortableTextObjectNode;
|
|
94
|
+
/** The root of a message body: what an API returns under `content`. */
|
|
95
|
+
export type PortableTextContent = PortableTextNode[];
|
|
96
|
+
export interface PortableTextMarkRendererProps<TMark extends PortableTextMarkObject = PortableTextMarkObject> {
|
|
97
|
+
/** Present for object marks; absent when the mark is a plain string. */
|
|
98
|
+
mark?: TMark;
|
|
99
|
+
children: ReactNode;
|
|
100
|
+
}
|
|
101
|
+
export type PortableTextMarkRenderer<TMark extends PortableTextMarkObject = PortableTextMarkObject> = ComponentType<PortableTextMarkRendererProps<TMark>>;
|
|
102
|
+
export interface PortableTextObjectRendererProps<TNode extends PortableTextObjectNode = PortableTextObjectNode> {
|
|
103
|
+
node: TNode;
|
|
104
|
+
/** The object's nested `content`, already rendered by the engine. */
|
|
105
|
+
children?: ReactNode;
|
|
106
|
+
}
|
|
107
|
+
export type PortableTextObjectRenderer<TNode extends PortableTextObjectNode = PortableTextObjectNode> = ComponentType<PortableTextObjectRendererProps<TNode>>;
|
|
108
|
+
export interface PortableTextBlockRendererProps<TBlock extends PortableTextBlock = PortableTextBlock> {
|
|
109
|
+
block: TBlock;
|
|
110
|
+
/** The block's rendered children/content, when it has any. */
|
|
111
|
+
children?: ReactNode;
|
|
112
|
+
}
|
|
113
|
+
export type PortableTextBlockRenderer<TBlock extends PortableTextBlock = PortableTextBlock> = ComponentType<PortableTextBlockRendererProps<TBlock>>;
|
|
114
|
+
export type PortableTextUnknownKind = "block" | "mark" | "object";
|
|
115
|
+
/**
|
|
116
|
+
* Called once per unknown type instead of rendering it, so content written
|
|
117
|
+
* for newer clients degrades silently on older ones.
|
|
118
|
+
*/
|
|
119
|
+
export type PortableTextUnknownTypeHandler = (kind: PortableTextUnknownKind, type: string) => void;
|
|
120
|
+
/**
|
|
121
|
+
* What an application injects into the Portable Text engine: renderers for
|
|
122
|
+
* its catalog marks and objects, optional overrides for the default blocks,
|
|
123
|
+
* and the unknown-type hook.
|
|
124
|
+
*/
|
|
125
|
+
export interface PortableTextComponents {
|
|
126
|
+
marks?: Record<string, PortableTextMarkRenderer>;
|
|
127
|
+
objects?: Record<string, PortableTextObjectRenderer>;
|
|
128
|
+
blocks?: Partial<Record<PortableTextDefaultBlockType, PortableTextBlockRenderer>>;
|
|
129
|
+
onUnknownType?: PortableTextUnknownTypeHandler;
|
|
130
|
+
}
|
|
131
|
+
export declare const isPortableTextSpan: (value: unknown) => value is PortableTextSpan;
|
|
132
|
+
export declare const isPortableTextObjectNode: (value: unknown) => value is PortableTextObjectNode;
|
|
133
|
+
/**
|
|
134
|
+
* A block is any non-object node with a string `type`. Unknown block types
|
|
135
|
+
* stay valid on purpose — they render nothing on clients that predate them.
|
|
136
|
+
* Known types are held to their shape, so a serializer bug (a paragraph
|
|
137
|
+
* without `children`, a list of non-nodes) fails here instead of at render.
|
|
138
|
+
*/
|
|
139
|
+
export declare const isPortableTextBlock: (value: unknown) => value is PortableTextBlock;
|
|
140
|
+
export declare const isPortableTextContent: (value: unknown) => value is PortableTextContent;
|
|
141
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/PortableText/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEjD;;;;;;;;;GASG;AAIH;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CACzB;AAED,8CAA8C;AAC9C,MAAM,W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O,KACb,KAAK,IAAI,mBAIT,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portable Text envelope — the general content contract for structured,
|
|
3
|
+
* renderer-independent content (in-app messages, help, changelogs).
|
|
4
|
+
*
|
|
5
|
+
* The design system owns this envelope and the universal default set below.
|
|
6
|
+
* It never hardcodes a product element: concrete elements (callout,
|
|
7
|
+
* button-reference, doc-link, …) are defined in the application catalog and
|
|
8
|
+
* injected into the Portable Text engine through {@link PortableTextComponents}.
|
|
9
|
+
* See README.md next to this file for the full contract.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/* ---- Spans and marks ------------------------------------------------- */
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A mark with data. Parameterless marks travel as plain strings ("strong");
|
|
16
|
+
* marks that need data travel as objects discriminated by `type`.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** The one default mark that carries data. */
|
|
20
|
+
|
|
21
|
+
/** The leaf of every text run: a piece of text plus the marks wrapping it. */
|
|
22
|
+
|
|
23
|
+
/** Marks every client understands without injection. */
|
|
24
|
+
export const PORTABLE_TEXT_DEFAULT_MARKS = ["strong", "em", "code", "link"];
|
|
25
|
+
|
|
26
|
+
/* ---- Blocks ----------------------------------------------------------- */
|
|
27
|
+
|
|
28
|
+
/** 1 maps to Title1, 2 to Title2, 3 to Header2 typography. */
|
|
29
|
+
|
|
30
|
+
/** Screenshots render framed (border, no shadow); illustrations render flat. */
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Derived from the union's discriminators, so adding a block to the union
|
|
34
|
+
* without a renderer entry is a compile error, never silent drift.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
// A Record so the compiler checks the list against the union in both
|
|
38
|
+
// directions: a missing and a stray key each fail to build.
|
|
39
|
+
const DEFAULT_BLOCK_TYPES = {
|
|
40
|
+
paragraph: true,
|
|
41
|
+
heading: true,
|
|
42
|
+
list: true,
|
|
43
|
+
"list-item": true,
|
|
44
|
+
media: true,
|
|
45
|
+
"titled-text": true
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** Blocks every client understands without injection. */
|
|
49
|
+
export const PORTABLE_TEXT_DEFAULT_BLOCKS = Object.keys(DEFAULT_BLOCK_TYPES);
|
|
50
|
+
|
|
51
|
+
/* ---- Objects ----------------------------------------------------------- */
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* An embedded component the envelope does not interpret: `_type` names an
|
|
55
|
+
* application-catalog element, everything else is that element's data. An
|
|
56
|
+
* object whose `_type` has no injected renderer renders nothing and is logged.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/** The root of a message body: what an API returns under `content`. */
|
|
60
|
+
|
|
61
|
+
/* ---- Injection contract ------------------------------------------------ */
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Called once per unknown type instead of rendering it, so content written
|
|
65
|
+
* for newer clients degrades silently on older ones.
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* What an application injects into the Portable Text engine: renderers for
|
|
70
|
+
* its catalog marks and objects, optional overrides for the default blocks,
|
|
71
|
+
* and the unknown-type hook.
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
/* ---- Runtime guards ----------------------------------------------------- */
|
|
75
|
+
|
|
76
|
+
const isRecord = value => typeof value === "object" && value !== null;
|
|
77
|
+
export const isPortableTextSpan = value => isRecord(value) && typeof value.text === "string";
|
|
78
|
+
export const isPortableTextObjectNode = value => isRecord(value) && value.type === "object" && typeof value._type === "string";
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* A block is any non-object node with a string `type`. Unknown block types
|
|
82
|
+
* stay valid on purpose — they render nothing on clients that predate them.
|
|
83
|
+
* Known types are held to their shape, so a serializer bug (a paragraph
|
|
84
|
+
* without `children`, a list of non-nodes) fails here instead of at render.
|
|
85
|
+
*/
|
|
86
|
+
export const isPortableTextBlock = value => {
|
|
87
|
+
if (!isRecord(value) || typeof value.type !== "string" || value.type === "object") {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
switch (value.type) {
|
|
91
|
+
case "paragraph":
|
|
92
|
+
case "heading":
|
|
93
|
+
case "list-item":
|
|
94
|
+
return Array.isArray(value.children) && value.children.every(isPortableTextSpan);
|
|
95
|
+
case "list":
|
|
96
|
+
return Array.isArray(value.children) && value.children.every(isPortableTextBlock);
|
|
97
|
+
case "media":
|
|
98
|
+
return typeof value.src === "string";
|
|
99
|
+
case "titled-text":
|
|
100
|
+
return typeof value.title === "string" && (value.content === undefined || isPortableTextContent(value.content));
|
|
101
|
+
default:
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
export const isPortableTextContent = value => Array.isArray(value) && value.every(node => isPortableTextBlock(node) || isPortableTextObjectNode(node));
|
|
106
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":["PORTABLE_TEXT_DEFAULT_MARKS","DEFAULT_BLOCK_TYPES","paragraph","heading","list","media","PORTABLE_TEXT_DEFAULT_BLOCKS","Object","keys","isRecord","value","isPortableTextSpan","text","isPortableTextObjectNode","type","_type","isPortableTextBlock","Array","isArray","children","every","src","title","content","undefined","isPortableTextContent","node"],"sources":["../../../../src/components/PortableText/types.ts"],"sourcesContent":["import { ComponentType, ReactNode } from \"react\";\n\n/**\n * Portable Text envelope — the general content contract for structured,\n * renderer-independent content (in-app messages, help, changelogs).\n *\n * The design system owns this envelope and the universal default set below.\n * It never hardcodes a product element: concrete elements (callout,\n * button-reference, doc-link, …) are defined in the application catalog and\n * injected into the Portable Text engine through {@link PortableTextComponents}.\n * See README.md next to this file for the full contract.\n */\n\n/* ---- Spans and marks ------------------------------------------------- */\n\n/**\n * A mark with data. Parameterless marks travel as plain strings (\"strong\");\n * marks that need data travel as objects discriminated by `type`.\n */\nexport interface PortableTextMarkObject {\n type: string;\n [data: string]: unknown;\n}\n\n/** The one default mark that carries data. */\nexport interface PortableTextLinkMark extends PortableTextMarkObject {\n type: \"link\";\n href: string;\n}\n\nexport type PortableTextMark = string | PortableTextMarkObject;\n\n/** The leaf of every text run: a piece of text plus the marks wrapping it. */\nexport interface PortableTextSpan {\n text: string;\n marks?: PortableTextMark[];\n}\n\n/** Marks every client understands without injection. */\nexport const PORTABLE_TEXT_DEFAULT_MARKS = [\n \"strong\",\n \"em\",\n \"code\",\n \"link\",\n] as const;\n\nexport type PortableTextDefaultMark =\n (typeof PORTABLE_TEXT_DEFAULT_MARKS)[number];\n\n/* ---- Blocks ----------------------------------------------------------- */\n\nexport interface PortableTextParagraphBlock {\n type: \"paragraph\";\n children: PortableTextSpan[];\n}\n\n/** 1 maps to Title1, 2 to Title2, 3 to Header2 typography. */\nexport type PortableTextHeadingLevel = 1 | 2 | 3;\n\nexport interface PortableTextHeadingBlock {\n type: \"heading\";\n level: PortableTextHeadingLevel;\n children: PortableTextSpan[];\n}\n\nexport type PortableTextListStyle = \"bullet\" | \"number\";\n\nexport interface PortableTextListItemBlock {\n type: \"list-item\";\n children: PortableTextSpan[];\n}\n\nexport interface PortableTextListBlock {\n type: \"list\";\n style?: PortableTextListStyle;\n children: PortableTextListItemBlock[];\n}\n\n/** Screenshots render framed (border, no shadow); illustrations render flat. */\nexport type PortableTextMediaVariant = \"screenshot\" | \"illustration\";\n\nexport interface PortableTextMediaBlock {\n type: \"media\";\n src: string;\n alt?: string;\n variant?: PortableTextMediaVariant;\n caption?: string;\n}\n\nexport interface PortableTextTitledTextBlock {\n type: \"titled-text\";\n /**\n * Same semantic scale as `heading` — 1, 2 or 3 (the default) — so the wire\n * format never encodes a typography name. How a level looks is the\n * renderer's business.\n */\n level?: PortableTextHeadingLevel;\n title: string;\n content?: PortableTextNode[];\n}\n\nexport type PortableTextBlock =\n | PortableTextParagraphBlock\n | PortableTextHeadingBlock\n | PortableTextListBlock\n | PortableTextMediaBlock\n | PortableTextTitledTextBlock;\n\n/**\n * Derived from the union's discriminators, so adding a block to the union\n * without a renderer entry is a compile error, never silent drift.\n */\nexport type PortableTextDefaultBlockType = (\n | PortableTextBlock\n | PortableTextListItemBlock\n)[\"type\"];\n\n// A Record so the compiler checks the list against the union in both\n// directions: a missing and a stray key each fail to build.\nconst DEFAULT_BLOCK_TYPES: Record<PortableTextDefaultBlockType, true> = {\n paragraph: true,\n heading: true,\n list: true,\n \"list-item\": true,\n media: true,\n \"titled-text\": true,\n};\n\n/** Blocks every client understands without injection. */\nexport const PORTABLE_TEXT_DEFAULT_BLOCKS = Object.keys(\n DEFAULT_BLOCK_TYPES\n) as readonly PortableTextDefaultBlockType[];\n\n/* ---- Objects ----------------------------------------------------------- */\n\n/**\n * An embedded component the envelope does not interpret: `_type` names an\n * application-catalog element, everything else is that element's data. An\n * object whose `_type` has no injected renderer renders nothing and is logged.\n */\nexport interface PortableTextObjectNode {\n type: \"object\";\n _type: string;\n [data: string]: unknown;\n}\n\nexport type PortableTextNode = PortableTextBlock | PortableTextObjectNode;\n\n/** The root of a message body: what an API returns under `content`. */\nexport type PortableTextContent = PortableTextNode[];\n\n/* ---- Injection contract ------------------------------------------------ */\n\nexport interface PortableTextMarkRendererProps<\n TMark extends PortableTextMarkObject = PortableTextMarkObject\n> {\n /** Present for object marks; absent when the mark is a plain string. */\n mark?: TMark;\n children: ReactNode;\n}\n\nexport type PortableTextMarkRenderer<\n TMark extends PortableTextMarkObject = PortableTextMarkObject\n> = ComponentType<PortableTextMarkRendererProps<TMark>>;\n\nexport interface PortableTextObjectRendererProps<\n TNode extends PortableTextObjectNode = PortableTextObjectNode\n> {\n node: TNode;\n /** The object's nested `content`, already rendered by the engine. */\n children?: ReactNode;\n}\n\nexport type PortableTextObjectRenderer<\n TNode extends PortableTextObjectNode = PortableTextObjectNode\n> = ComponentType<PortableTextObjectRendererProps<TNode>>;\n\nexport interface PortableTextBlockRendererProps<\n TBlock extends PortableTextBlock = PortableTextBlock\n> {\n block: TBlock;\n /** The block's rendered children/content, when it has any. */\n children?: ReactNode;\n}\n\nexport type PortableTextBlockRenderer<\n TBlock extends PortableTextBlock = PortableTextBlock\n> = ComponentType<PortableTextBlockRendererProps<TBlock>>;\n\nexport type PortableTextUnknownKind = \"block\" | \"mark\" | \"object\";\n\n/**\n * Called once per unknown type instead of rendering it, so content written\n * for newer clients degrades silently on older ones.\n */\nexport type PortableTextUnknownTypeHandler = (\n kind: PortableTextUnknownKind,\n type: string\n) => void;\n\n/**\n * What an application injects into the Portable Text engine: renderers for\n * its catalog marks and objects, optional overrides for the default blocks,\n * and the unknown-type hook.\n */\nexport interface PortableTextComponents {\n marks?: Record<string, PortableTextMarkRenderer>;\n objects?: Record<string, PortableTextObjectRenderer>;\n blocks?: Partial<\n Record<PortableTextDefaultBlockType, PortableTextBlockRenderer>\n >;\n onUnknownType?: PortableTextUnknownTypeHandler;\n}\n\n/* ---- Runtime guards ----------------------------------------------------- */\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nexport const isPortableTextSpan = (value: unknown): value is PortableTextSpan =>\n isRecord(value) && typeof value.text === \"string\";\n\nexport const isPortableTextObjectNode = (\n value: unknown\n): value is PortableTextObjectNode =>\n isRecord(value) && value.type === \"object\" && typeof value._type === \"string\";\n\n/**\n * A block is any non-object node with a string `type`. Unknown block types\n * stay valid on purpose — they render nothing on clients that predate them.\n * Known types are held to their shape, so a serializer bug (a paragraph\n * without `children`, a list of non-nodes) fails here instead of at render.\n */\nexport const isPortableTextBlock = (\n value: unknown\n): value is PortableTextBlock => {\n if (\n !isRecord(value) ||\n typeof value.type !== \"string\" ||\n value.type === \"object\"\n ) {\n return false;\n }\n\n switch (value.type) {\n case \"paragraph\":\n case \"heading\":\n case \"list-item\":\n return (\n Array.isArray(value.children) &&\n value.children.every(isPortableTextSpan)\n );\n case \"list\":\n return (\n Array.isArray(value.children) &&\n value.children.every(isPortableTextBlock)\n );\n case \"media\":\n return typeof value.src === \"string\";\n case \"titled-text\":\n return (\n typeof value.title === \"string\" &&\n (value.content === undefined || isPortableTextContent(value.content))\n );\n default:\n return true;\n }\n};\n\nexport const isPortableTextContent = (\n value: unknown\n): value is PortableTextContent =>\n Array.isArray(value) &&\n value.every(\n (node) => isPortableTextBlock(node) || isPortableTextObjectNode(node)\n );\n"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAMA;;AAQA;;AAMA;AACA,OAAO,MAAMA,2BAA2B,GAAG,CACzC,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,MAAM,CACE;;AAKV;;AAOA;;AAsBA;;AA8BA;AACA;AACA;AACA;;AAMA;AACA;AACA,MAAMC,mBAA+D,GAAG;EACtEC,SAAS,EAAE,IAAI;EACfC,OAAO,EAAE,IAAI;EACbC,IAAI,EAAE,IAAI;EACV,WAAW,EAAE,IAAI;EACjBC,KAAK,EAAE,IAAI;EACX,aAAa,EAAE;AACjB,CAAC;;AAED;AACA,OAAO,MAAMC,4BAA4B,GAAGC,MAAM,CAACC,IAAI,CACrDP,mBACF,CAA4C;;AAE5C;;AAEA;AACA;AACA;AACA;AACA;;AASA;;AAGA;;AAwCA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;;AAUA;;AAEA,MAAMQ,QAAQ,GAAIC,KAAc,IAC9B,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI;AAE7C,OAAO,MAAMC,kBAAkB,GAAID,KAAc,IAC/CD,QAAQ,CAACC,KAAK,CAAC,IAAI,OAAOA,KAAK,CAACE,IAAI,KAAK,QAAQ;AAEnD,OAAO,MAAMC,wBAAwB,GACnCH,KAAc,IAEdD,QAAQ,CAACC,KAAK,CAAC,IAAIA,KAAK,CAACI,IAAI,KAAK,QAAQ,IAAI,OAAOJ,KAAK,CAACK,KAAK,KAAK,QAAQ;;AAE/E;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,GAC9BN,KAAc,IACiB;EAC/B,IACE,CAACD,QAAQ,CAACC,KAAK,CAAC,IAChB,OAAOA,KAAK,CAACI,IAAI,KAAK,QAAQ,IAC9BJ,KAAK,CAACI,IAAI,KAAK,QAAQ,EACvB;IACA,OAAO,KAAK;EACd;EAEA,QAAQJ,KAAK,CAACI,IAAI;IAChB,KAAK,WAAW;IAChB,KAAK,SAAS;IACd,KAAK,WAAW;MACd,OACEG,KAAK,CAACC,OAAO,CAACR,KAAK,CAACS,QAAQ,CAAC,IAC7BT,KAAK,CAACS,QAAQ,CAACC,KAAK,CAACT,kBAAkB,CAAC;IAE5C,KAAK,MAAM;MACT,OACEM,KAAK,CAACC,OAAO,CAACR,KAAK,CAACS,QAAQ,CAAC,IAC7BT,KAAK,CAACS,QAAQ,CAACC,KAAK,CAACJ,mBAAmB,CAAC;IAE7C,KAAK,OAAO;MACV,OAAO,OAAON,KAAK,CAACW,GAAG,KAAK,QAAQ;IACtC,KAAK,aAAa;MAChB,OACE,OAAOX,KAAK,CAACY,KAAK,KAAK,QAAQ,KAC9BZ,KAAK,CAACa,OAAO,KAAKC,SAAS,IAAIC,qBAAqB,CAACf,KAAK,CAACa,OAAO,CAAC,CAAC;IAEzE;MACE,OAAO,IAAI;EACf;AACF,CAAC;AAED,OAAO,MAAME,qBAAqB,GAChCf,KAAc,IAEdO,KAAK,CAACC,OAAO,CAACR,KAAK,CAAC,IACpBA,KAAK,CAACU,KAAK,CACRM,IAAI,IAAKV,mBAAmB,CAACU,IAAI,CAAC,IAAIb,wBAAwB,CAACa,IAAI,CACtE,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.test.d.ts","sourceRoot":"","sources":["../../../../src/components/PortableText/types.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { createElement, Fragment } from "react";
|
|
2
|
+
import { isPortableTextBlock, isPortableTextContent, isPortableTextObjectNode, isPortableTextSpan, PORTABLE_TEXT_DEFAULT_BLOCKS, PORTABLE_TEXT_DEFAULT_MARKS } from "./types";
|
|
3
|
+
describe("PortableText envelope", () => {
|
|
4
|
+
const sampleMessageContent = [{
|
|
5
|
+
type: "heading",
|
|
6
|
+
level: 2,
|
|
7
|
+
children: [{
|
|
8
|
+
text: "IP Firewall"
|
|
9
|
+
}]
|
|
10
|
+
}, {
|
|
11
|
+
type: "paragraph",
|
|
12
|
+
children: [{
|
|
13
|
+
text: "Open the "
|
|
14
|
+
}, {
|
|
15
|
+
text: "Security page",
|
|
16
|
+
marks: ["interface-name"]
|
|
17
|
+
}, {
|
|
18
|
+
text: " and press "
|
|
19
|
+
}, {
|
|
20
|
+
text: "Enter",
|
|
21
|
+
marks: ["keyboard-key"]
|
|
22
|
+
}, {
|
|
23
|
+
text: ". Read more in "
|
|
24
|
+
}, {
|
|
25
|
+
text: "the help article",
|
|
26
|
+
marks: [{
|
|
27
|
+
type: "doc-link",
|
|
28
|
+
article: "ip-firewall"
|
|
29
|
+
}]
|
|
30
|
+
}, {
|
|
31
|
+
text: "."
|
|
32
|
+
}]
|
|
33
|
+
}, {
|
|
34
|
+
type: "list",
|
|
35
|
+
style: "bullet",
|
|
36
|
+
children: [{
|
|
37
|
+
type: "list-item",
|
|
38
|
+
children: [{
|
|
39
|
+
text: "Allowlist the IPs you trust"
|
|
40
|
+
}]
|
|
41
|
+
}, {
|
|
42
|
+
type: "list-item",
|
|
43
|
+
children: [{
|
|
44
|
+
text: "immediately",
|
|
45
|
+
marks: ["strong"]
|
|
46
|
+
}]
|
|
47
|
+
}]
|
|
48
|
+
}, {
|
|
49
|
+
type: "media",
|
|
50
|
+
src: "/screenshots/firewall.png",
|
|
51
|
+
variant: "screenshot",
|
|
52
|
+
caption: "The firewall settings"
|
|
53
|
+
}, {
|
|
54
|
+
type: "titled-text",
|
|
55
|
+
title: "Allowlist the IPs you trust",
|
|
56
|
+
level: 3,
|
|
57
|
+
content: [{
|
|
58
|
+
type: "paragraph",
|
|
59
|
+
children: [{
|
|
60
|
+
text: "Add one range per line."
|
|
61
|
+
}]
|
|
62
|
+
}]
|
|
63
|
+
}, {
|
|
64
|
+
type: "object",
|
|
65
|
+
_type: "callout",
|
|
66
|
+
tone: "note",
|
|
67
|
+
content: [{
|
|
68
|
+
type: "paragraph",
|
|
69
|
+
children: [{
|
|
70
|
+
text: "Takes effect immediately."
|
|
71
|
+
}]
|
|
72
|
+
}]
|
|
73
|
+
}, {
|
|
74
|
+
type: "object",
|
|
75
|
+
_type: "button-reference",
|
|
76
|
+
label: "Save Changes",
|
|
77
|
+
variant: "primary"
|
|
78
|
+
}];
|
|
79
|
+
it("validates a sample message that mixes default blocks and catalog objects", () => {
|
|
80
|
+
expect(isPortableTextContent(sampleMessageContent)).toBe(true);
|
|
81
|
+
});
|
|
82
|
+
it("keeps unknown block and object types valid so older clients degrade instead of break", () => {
|
|
83
|
+
expect(isPortableTextContent([{
|
|
84
|
+
type: "some-future-block",
|
|
85
|
+
payload: 1
|
|
86
|
+
}, {
|
|
87
|
+
type: "object",
|
|
88
|
+
_type: "some-future-element",
|
|
89
|
+
data: true
|
|
90
|
+
}])).toBe(true);
|
|
91
|
+
});
|
|
92
|
+
it("rejects nodes without a type discriminator and objects without _type", () => {
|
|
93
|
+
expect(isPortableTextContent([{
|
|
94
|
+
children: []
|
|
95
|
+
}])).toBe(false);
|
|
96
|
+
expect(isPortableTextContent([{
|
|
97
|
+
type: "object"
|
|
98
|
+
}])).toBe(false);
|
|
99
|
+
expect(isPortableTextContent(["paragraph"])).toBe(false);
|
|
100
|
+
expect(isPortableTextContent({
|
|
101
|
+
content: []
|
|
102
|
+
})).toBe(false);
|
|
103
|
+
});
|
|
104
|
+
it("rejects known blocks whose shape a serializer bug has broken", () => {
|
|
105
|
+
expect(isPortableTextContent([{
|
|
106
|
+
type: "paragraph"
|
|
107
|
+
}])).toBe(false);
|
|
108
|
+
expect(isPortableTextContent([{
|
|
109
|
+
type: "heading",
|
|
110
|
+
level: 2,
|
|
111
|
+
children: "oops"
|
|
112
|
+
}])).toBe(false);
|
|
113
|
+
expect(isPortableTextContent([{
|
|
114
|
+
type: "paragraph",
|
|
115
|
+
children: [{
|
|
116
|
+
marks: ["strong"]
|
|
117
|
+
}]
|
|
118
|
+
}])).toBe(false);
|
|
119
|
+
expect(isPortableTextContent([{
|
|
120
|
+
type: "list"
|
|
121
|
+
}])).toBe(false);
|
|
122
|
+
expect(isPortableTextContent([{
|
|
123
|
+
type: "list",
|
|
124
|
+
children: ["not a node"]
|
|
125
|
+
}])).toBe(false);
|
|
126
|
+
expect(isPortableTextContent([{
|
|
127
|
+
type: "media"
|
|
128
|
+
}])).toBe(false);
|
|
129
|
+
expect(isPortableTextContent([{
|
|
130
|
+
type: "titled-text",
|
|
131
|
+
content: []
|
|
132
|
+
}])).toBe(false);
|
|
133
|
+
expect(isPortableTextContent([{
|
|
134
|
+
type: "titled-text",
|
|
135
|
+
title: "Ranges",
|
|
136
|
+
content: "oops"
|
|
137
|
+
}])).toBe(false);
|
|
138
|
+
});
|
|
139
|
+
it("accepts a titled-text with only a title, with or without content", () => {
|
|
140
|
+
expect(isPortableTextContent([{
|
|
141
|
+
type: "titled-text",
|
|
142
|
+
title: "Ranges"
|
|
143
|
+
}])).toBe(true);
|
|
144
|
+
expect(isPortableTextContent([{
|
|
145
|
+
type: "titled-text",
|
|
146
|
+
title: "Ranges",
|
|
147
|
+
content: []
|
|
148
|
+
}])).toBe(true);
|
|
149
|
+
});
|
|
150
|
+
it("tells blocks, objects and spans apart", () => {
|
|
151
|
+
const heading = sampleMessageContent[0],
|
|
152
|
+
paragraph = sampleMessageContent[1];
|
|
153
|
+
const callout = sampleMessageContent[5];
|
|
154
|
+
expect(isPortableTextBlock(heading)).toBe(true);
|
|
155
|
+
expect(isPortableTextBlock(callout)).toBe(false);
|
|
156
|
+
expect(isPortableTextObjectNode(callout)).toBe(true);
|
|
157
|
+
expect(isPortableTextObjectNode(heading)).toBe(false);
|
|
158
|
+
expect(isPortableTextSpan({
|
|
159
|
+
text: "plain"
|
|
160
|
+
})).toBe(true);
|
|
161
|
+
expect(isPortableTextSpan(paragraph)).toBe(false);
|
|
162
|
+
});
|
|
163
|
+
it("ships a universal default set free of product elements", () => {
|
|
164
|
+
expect(PORTABLE_TEXT_DEFAULT_BLOCKS).toEqual(["paragraph", "heading", "list", "list-item", "media", "titled-text"]);
|
|
165
|
+
expect(PORTABLE_TEXT_DEFAULT_MARKS).toEqual(["strong", "em", "code", "link"]);
|
|
166
|
+
});
|
|
167
|
+
it("accepts an application components map through the injection contract", () => {
|
|
168
|
+
var _components$marks;
|
|
169
|
+
const seen = [];
|
|
170
|
+
const components = {
|
|
171
|
+
marks: {
|
|
172
|
+
"interface-name": _ref => {
|
|
173
|
+
let children = _ref.children;
|
|
174
|
+
return /*#__PURE__*/createElement(Fragment, null, children);
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
objects: {
|
|
178
|
+
callout: _ref2 => {
|
|
179
|
+
let children = _ref2.children;
|
|
180
|
+
return /*#__PURE__*/createElement(Fragment, null, children);
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
onUnknownType: (kind, type) => {
|
|
184
|
+
seen.push(kind + ":" + type);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
components.onUnknownType == null || components.onUnknownType("object", "some-future-element");
|
|
188
|
+
expect(Object.keys((_components$marks = components.marks) != null ? _components$marks : {})).toEqual(["interface-name"]);
|
|
189
|
+
expect(seen).toEqual(["object:some-future-element"]);
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
//# sourceMappingURL=types.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.test.js","names":["createElement","Fragment","isPortableTextBlock","isPortableTextContent","isPortableTextObjectNode","isPortableTextSpan","PORTABLE_TEXT_DEFAULT_BLOCKS","PORTABLE_TEXT_DEFAULT_MARKS","describe","sampleMessageContent","type","level","children","text","marks","article","style","src","variant","caption","title","content","_type","tone","label","it","expect","toBe","payload","data","heading","paragraph","callout","toEqual","_components$marks","seen","components","_ref","objects","_ref2","onUnknownType","kind","push","Object","keys"],"sources":["../../../../src/components/PortableText/types.test.ts"],"sourcesContent":["import { createElement, Fragment } from \"react\";\n\nimport {\n isPortableTextBlock,\n isPortableTextContent,\n isPortableTextObjectNode,\n isPortableTextSpan,\n PORTABLE_TEXT_DEFAULT_BLOCKS,\n PORTABLE_TEXT_DEFAULT_MARKS,\n PortableTextComponents,\n PortableTextContent,\n} from \"./types\";\n\ndescribe(\"PortableText envelope\", () => {\n const sampleMessageContent: PortableTextContent = [\n { type: \"heading\", level: 2, children: [{ text: \"IP Firewall\" }] },\n {\n type: \"paragraph\",\n children: [\n { text: \"Open the \" },\n { text: \"Security page\", marks: [\"interface-name\"] },\n { text: \" and press \" },\n { text: \"Enter\", marks: [\"keyboard-key\"] },\n { text: \". Read more in \" },\n {\n text: \"the help article\",\n marks: [{ type: \"doc-link\", article: \"ip-firewall\" }],\n },\n { text: \".\" },\n ],\n },\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n {\n type: \"list-item\",\n children: [{ text: \"Allowlist the IPs you trust\" }],\n },\n {\n type: \"list-item\",\n children: [{ text: \"immediately\", marks: [\"strong\"] }],\n },\n ],\n },\n {\n type: \"media\",\n src: \"/screenshots/firewall.png\",\n variant: \"screenshot\",\n caption: \"The firewall settings\",\n },\n {\n type: \"titled-text\",\n title: \"Allowlist the IPs you trust\",\n level: 3,\n content: [\n { type: \"paragraph\", children: [{ text: \"Add one range per line.\" }] },\n ],\n },\n {\n type: \"object\",\n _type: \"callout\",\n tone: \"note\",\n content: [\n {\n type: \"paragraph\",\n children: [{ text: \"Takes effect immediately.\" }],\n },\n ],\n },\n {\n type: \"object\",\n _type: \"button-reference\",\n label: \"Save Changes\",\n variant: \"primary\",\n },\n ];\n\n it(\"validates a sample message that mixes default blocks and catalog objects\", () => {\n expect(isPortableTextContent(sampleMessageContent)).toBe(true);\n });\n\n it(\"keeps unknown block and object types valid so older clients degrade instead of break\", () => {\n expect(\n isPortableTextContent([\n { type: \"some-future-block\", payload: 1 },\n { type: \"object\", _type: \"some-future-element\", data: true },\n ])\n ).toBe(true);\n });\n\n it(\"rejects nodes without a type discriminator and objects without _type\", () => {\n expect(isPortableTextContent([{ children: [] }])).toBe(false);\n expect(isPortableTextContent([{ type: \"object\" }])).toBe(false);\n expect(isPortableTextContent([\"paragraph\"])).toBe(false);\n expect(isPortableTextContent({ content: [] })).toBe(false);\n });\n\n it(\"rejects known blocks whose shape a serializer bug has broken\", () => {\n expect(isPortableTextContent([{ type: \"paragraph\" }])).toBe(false);\n expect(\n isPortableTextContent([{ type: \"heading\", level: 2, children: \"oops\" }])\n ).toBe(false);\n expect(\n isPortableTextContent([\n { type: \"paragraph\", children: [{ marks: [\"strong\"] }] },\n ])\n ).toBe(false);\n expect(isPortableTextContent([{ type: \"list\" }])).toBe(false);\n expect(\n isPortableTextContent([{ type: \"list\", children: [\"not a node\"] }])\n ).toBe(false);\n expect(isPortableTextContent([{ type: \"media\" }])).toBe(false);\n expect(isPortableTextContent([{ type: \"titled-text\", content: [] }])).toBe(\n false\n );\n expect(\n isPortableTextContent([\n { type: \"titled-text\", title: \"Ranges\", content: \"oops\" },\n ])\n ).toBe(false);\n });\n\n it(\"accepts a titled-text with only a title, with or without content\", () => {\n expect(\n isPortableTextContent([{ type: \"titled-text\", title: \"Ranges\" }])\n ).toBe(true);\n expect(\n isPortableTextContent([\n { type: \"titled-text\", title: \"Ranges\", content: [] },\n ])\n ).toBe(true);\n });\n\n it(\"tells blocks, objects and spans apart\", () => {\n const [heading, paragraph] = sampleMessageContent;\n const callout = sampleMessageContent[5];\n\n expect(isPortableTextBlock(heading)).toBe(true);\n expect(isPortableTextBlock(callout)).toBe(false);\n expect(isPortableTextObjectNode(callout)).toBe(true);\n expect(isPortableTextObjectNode(heading)).toBe(false);\n expect(isPortableTextSpan({ text: \"plain\" })).toBe(true);\n expect(isPortableTextSpan(paragraph)).toBe(false);\n });\n\n it(\"ships a universal default set free of product elements\", () => {\n expect(PORTABLE_TEXT_DEFAULT_BLOCKS).toEqual([\n \"paragraph\",\n \"heading\",\n \"list\",\n \"list-item\",\n \"media\",\n \"titled-text\",\n ]);\n expect(PORTABLE_TEXT_DEFAULT_MARKS).toEqual([\n \"strong\",\n \"em\",\n \"code\",\n \"link\",\n ]);\n });\n\n it(\"accepts an application components map through the injection contract\", () => {\n const seen: string[] = [];\n const components: PortableTextComponents = {\n marks: {\n \"interface-name\": ({ children }) =>\n createElement(Fragment, null, children),\n },\n objects: {\n callout: ({ children }) => createElement(Fragment, null, children),\n },\n onUnknownType: (kind, type) => {\n seen.push(`${kind}:${type}`);\n },\n };\n\n components.onUnknownType?.(\"object\", \"some-future-element\");\n\n expect(Object.keys(components.marks ?? {})).toEqual([\"interface-name\"]);\n expect(seen).toEqual([\"object:some-future-element\"]);\n });\n});\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,OAAO;AAE/C,SACEC,mBAAmB,EACnBC,qBAAqB,EACrBC,wBAAwB,EACxBC,kBAAkB,EAClBC,4BAA4B,EAC5BC,2BAA2B,QAGtB,SAAS;AAEhBC,QAAQ,CAAC,uBAAuB,EAAE,MAAM;EACtC,MAAMC,oBAAyC,GAAG,CAChD;IAAEC,IAAI,EAAE,SAAS;IAAEC,KAAK,EAAE,CAAC;IAAEC,QAAQ,EAAE,CAAC;MAAEC,IAAI,EAAE;IAAc,CAAC;EAAE,CAAC,EAClE;IACEH,IAAI,EAAE,WAAW;IACjBE,QAAQ,EAAE,CACR;MAAEC,IAAI,EAAE;IAAY,CAAC,EACrB;MAAEA,IAAI,EAAE,eAAe;MAAEC,KAAK,EAAE,CAAC,gBAAgB;IAAE,CAAC,EACpD;MAAED,IAAI,EAAE;IAAc,CAAC,EACvB;MAAEA,IAAI,EAAE,OAAO;MAAEC,KAAK,EAAE,CAAC,cAAc;IAAE,CAAC,EAC1C;MAAED,IAAI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ACL,gBAAgB,EAAEuB,IAAA;UAAA,IAAGzB,QAAQ,GAAAyB,IAAA,CAARzB,QAAQ;UAAA,oBAC3BZ,aAAa,CAACC,QAAQ,EAAE,IAAI,EAAEW,QAAQ,CAAC;QAAA;MAC3C,CAAC;MACD0B,OAAO,EAAE;QACPN,OAAO,EAAEO,KAAA;UAAA,IAAG3B,QAAQ,GAAA2B,KAAA,CAAR3B,QAAQ;UAAA,oBAAOZ,aAAa,CAACC,QAAQ,EAAE,IAAI,EAAEW,QAAQ,CAAC;QAAA;MACpE,CAAC;MACD4B,aAAa,EAAEA,CAACC,IAAI,EAAE/B,IAAI,KAAK;QAC7ByB,IAAI,CAACO,IAAI,CAAID,IAAI,SAAI/B,IAAM,CAAC;MAC9B;IACF,CAAC;IAED0B,UAAU,CAACI,aAAa,YAAxBJ,UAAU,CAACI,aAAa,CAAG,QAAQ,EAAE,qBAAqB,CAAC;IAE3Dd,MAAM,CAACiB,MAAM,CAACC,IAAI,EAAAV,iBAAA,GAACE,UAAU,CAACtB,KAAK,YAAAoB,iBAAA,GAAI,CAAC,CAAC,CAAC,CAAC,CAACD,OAAO,CAAC,CAAC,gBAAgB,CAAC,CAAC;IACvEP,MAAM,CAACS,IAAI,CAAC,CAACF,OAAO,CAAC,CAAC,4BAA4B,CAAC,CAAC;EACtD,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Breakpoint } from "../BreakPoints";
|
|
3
|
+
import { Align, Space } from "../LayoutTokens";
|
|
4
|
+
export interface IRowProps extends React.ComponentPropsWithoutRef<"div"> {
|
|
5
|
+
space?: Space;
|
|
6
|
+
align?: Align;
|
|
7
|
+
collapseBelow?: Breakpoint;
|
|
8
|
+
}
|
|
9
|
+
export declare const Row: React.ForwardRefExoticComponent<IRowProps & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
//# sourceMappingURL=Row.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Row.d.ts","sourceRoot":"","sources":["../../../../src/components/Row/Row.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,WAAW,SAAU,SAAQ,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC;IACtE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,aAAa,CAAC,EAAE,UAAU,CAAC;CAC5B;AAED,eAAO,MAAM,GAAG,kFAef,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["space", "align", "collapseBelow", "children"];
|
|
4
|
+
import React, { forwardRef } from "react";
|
|
5
|
+
import { StyledRow } from "./Styles";
|
|
6
|
+
export const Row = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
7
|
+
let _ref$space = _ref.space,
|
|
8
|
+
space = _ref$space === void 0 ? "md" : _ref$space,
|
|
9
|
+
_ref$align = _ref.align,
|
|
10
|
+
align = _ref$align === void 0 ? "center" : _ref$align,
|
|
11
|
+
collapseBelow = _ref.collapseBelow,
|
|
12
|
+
children = _ref.children,
|
|
13
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
14
|
+
return /*#__PURE__*/React.createElement(StyledRow, _extends({
|
|
15
|
+
ref: ref,
|
|
16
|
+
$space: space,
|
|
17
|
+
$align: align,
|
|
18
|
+
$collapse: collapseBelow
|
|
19
|
+
}, rest), children);
|
|
20
|
+
});
|
|
21
|
+
Row.displayName = "Row";
|
|
22
|
+
//# sourceMappingURL=Row.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Row.js","names":["React","forwardRef","StyledRow","Row","_ref","ref","_ref$space","space","_ref$align","align","collapseBelow","children","rest","_objectWithoutPropertiesLoose","_excluded","createElement","_extends","$space","$align","$collapse","displayName"],"sources":["../../../../src/components/Row/Row.tsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\n\nimport { StyledRow } from \"./Styles\";\nimport { Breakpoint } from \"../BreakPoints\";\nimport { Align, Space } from \"../LayoutTokens\";\n\nexport interface IRowProps extends React.ComponentPropsWithoutRef<\"div\"> {\n space?: Space;\n align?: Align;\n collapseBelow?: Breakpoint;\n}\n\nexport const Row = forwardRef<HTMLDivElement, IRowProps>(\n (\n { space = \"md\", align = \"center\", collapseBelow, children, ...rest },\n ref\n ) => (\n <StyledRow\n ref={ref}\n $space={space}\n $align={align}\n $collapse={collapseBelow}\n {...rest}\n >\n {children}\n </StyledRow>\n )\n);\n\nRow.displayName = \"Row\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AAEzC,SAASC,SAAS,QAAQ,UAAU;AAUpC,OAAO,MAAMC,GAAG,gBAAGF,UAAU,CAC3B,CAAAG,IAAA,EAEEC,GAAG;EAAA,IAAAC,UAAA,GAAAF,IAAA,CADDG,KAAK;IAALA,KAAK,GAAAD,UAAA,cAAG,IAAI,GAAAA,UAAA;IAAAE,UAAA,GAAAJ,IAAA,CAAEK,KAAK;IAALA,KAAK,GAAAD,UAAA,cAAG,QAAQ,GAAAA,UAAA;IAAEE,aAAa,GAAAN,IAAA,CAAbM,aAAa;IAAEC,QAAQ,GAAAP,IAAA,CAARO,QAAQ;IAAKC,IAAI,GAAAC,6BAAA,CAAAT,IAAA,EAAAU,SAAA;EAAA,oBAGlEd,KAAA,CAAAe,aAAA,CAACb,SAAS,EAAAc,QAAA;IACRX,GAAG,EAAEA,GAAI;IACTY,MAAM,EAAEV,KAAM;IACdW,MAAM,EAAET,KAAM;IACdU,SAAS,EAAET;EAAc,GACrBE,IAAI,GAEPD,QACQ,CAAC;AAAA,CAEhB,CAAC;AAEDR,GAAG,CAACiB,WAAW,GAAG,KAAK","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Breakpoint } from "../BreakPoints";
|
|
2
|
+
import { Align, Space } from "../LayoutTokens";
|
|
3
|
+
export declare const StyledRow: import("styled-components").StyledComponent<"div", any, {
|
|
4
|
+
$space: Space;
|
|
5
|
+
$align: Align;
|
|
6
|
+
$collapse?: Breakpoint;
|
|
7
|
+
}, never>;
|
|
8
|
+
//# sourceMappingURL=Styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/Row/Styles.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAe,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAc,KAAK,EAAS,MAAM,iBAAiB,CAAC;AAElE,eAAO,MAAM,SAAS;YACZ,KAAK;YACL,KAAK;gBACD,UAAU;SAgBvB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
import { screenBelow } from "../BreakPoints";
|
|
3
|
+
import { FLEX_ALIGN, SPACE } from "../LayoutTokens";
|
|
4
|
+
export const StyledRow = styled.div.withConfig({
|
|
5
|
+
displayName: "Styles__StyledRow",
|
|
6
|
+
componentId: "sc-1sfgw5v-0"
|
|
7
|
+
})(["display:flex;flex-direction:row;flex-wrap:wrap;align-items:", ";gap:", ";", ""], _ref => {
|
|
8
|
+
let $align = _ref.$align;
|
|
9
|
+
return FLEX_ALIGN[$align];
|
|
10
|
+
}, _ref2 => {
|
|
11
|
+
let $space = _ref2.$space;
|
|
12
|
+
return SPACE[$space];
|
|
13
|
+
}, _ref3 => {
|
|
14
|
+
let $collapse = _ref3.$collapse;
|
|
15
|
+
return $collapse && css(["", "{flex-direction:column;align-items:stretch;}"], screenBelow[$collapse]);
|
|
16
|
+
});
|
|
17
|
+
StyledRow.displayName = "StyledRow";
|
|
18
|
+
//# sourceMappingURL=Styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Styles.js","names":["styled","css","screenBelow","FLEX_ALIGN","SPACE","StyledRow","div","withConfig","displayName","componentId","_ref","$align","_ref2","$space","_ref3","$collapse"],"sources":["../../../../src/components/Row/Styles.ts"],"sourcesContent":["import styled, { css } from \"styled-components\";\n\nimport { Breakpoint, screenBelow } from \"../BreakPoints\";\nimport { Align, FLEX_ALIGN, Space, SPACE } from \"../LayoutTokens\";\n\nexport const StyledRow = styled.div<{\n $space: Space;\n $align: Align;\n $collapse?: Breakpoint;\n}>`\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n align-items: ${({ $align }) => FLEX_ALIGN[$align]};\n gap: ${({ $space }) => SPACE[$space]};\n\n ${({ $collapse }) =>\n $collapse &&\n css`\n ${screenBelow[$collapse]} {\n flex-direction: column;\n align-items: stretch;\n }\n `}\n`;\n\nStyledRow.displayName = \"StyledRow\";\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAE/C,SAAqBC,WAAW,QAAQ,gBAAgB;AACxD,SAAgBC,UAAU,EAASC,KAAK,QAAQ,iBAAiB;AAEjE,OAAO,MAAMC,SAAS,GAAGL,MAAM,CAACM,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,sFAQlBC,IAAA;EAAA,IAAGC,MAAM,GAAAD,IAAA,CAANC,MAAM;EAAA,OAAOR,UAAU,CAACQ,MAAM,CAAC;AAAA,GAC1CC,KAAA;EAAA,IAAGC,MAAM,GAAAD,KAAA,CAANC,MAAM;EAAA,OAAOT,KAAK,CAACS,MAAM,CAAC;AAAA,GAElCC,KAAA;EAAA,IAAGC,SAAS,GAAAD,KAAA,CAATC,SAAS;EAAA,OACZA,SAAS,IACTd,GAAG,uDACCC,WAAW,CAACa,SAAS,CAAC,CAIzB;AAAA,EACJ;AAEDV,SAAS,CAACG,WAAW,GAAG,WAAW","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Row/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/Row/index.ts"],"sourcesContent":["export * from \"./Row\";\n"],"mappings":"AAAA,cAAc,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Align, Space } from "../LayoutTokens";
|
|
3
|
+
export interface IStackProps extends React.ComponentPropsWithoutRef<"div"> {
|
|
4
|
+
space?: Space;
|
|
5
|
+
align?: Align;
|
|
6
|
+
}
|
|
7
|
+
export declare const Stack: React.ForwardRefExoticComponent<IStackProps & React.RefAttributes<HTMLDivElement>>;
|
|
8
|
+
//# sourceMappingURL=Stack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stack.d.ts","sourceRoot":"","sources":["../../../../src/components/Stack/Stack.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,WAAW,WAAY,SAAQ,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC;IACxE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,eAAO,MAAM,KAAK,oFAMjB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["space", "align", "children"];
|
|
4
|
+
import React, { forwardRef } from "react";
|
|
5
|
+
import { StyledStack } from "./Styles";
|
|
6
|
+
export const Stack = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
7
|
+
let _ref$space = _ref.space,
|
|
8
|
+
space = _ref$space === void 0 ? "md" : _ref$space,
|
|
9
|
+
align = _ref.align,
|
|
10
|
+
children = _ref.children,
|
|
11
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
12
|
+
return /*#__PURE__*/React.createElement(StyledStack, _extends({
|
|
13
|
+
ref: ref,
|
|
14
|
+
$space: space,
|
|
15
|
+
$align: align
|
|
16
|
+
}, rest), children);
|
|
17
|
+
});
|
|
18
|
+
Stack.displayName = "Stack";
|
|
19
|
+
//# sourceMappingURL=Stack.js.map
|