@teambit/docs 1.0.993 → 1.0.995
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/docs.ui.runtime.d.ts +14 -5
- package/dist/docs.ui.runtime.js +20 -5
- package/dist/docs.ui.runtime.js.map +1 -1
- package/dist/overview/overview.d.ts +8 -1
- package/dist/overview/overview.js +10 -3
- package/dist/overview/overview.js.map +1 -1
- package/dist/overview/overview.module.scss +0 -5
- package/dist/overview.section.d.ts +3 -2
- package/dist/overview.section.js +4 -2
- package/dist/overview.section.js.map +1 -1
- package/dist/{preview-1779204000743.js → preview-1779305522985.js} +2 -2
- package/docs.ui.runtime.tsx +36 -7
- package/overview/overview.module.scss +0 -5
- package/overview/overview.tsx +19 -2
- package/overview.section.tsx +4 -2
- package/package.json +28 -28
|
@@ -2,15 +2,17 @@ import type { ComponentType } from 'react';
|
|
|
2
2
|
import type { ComponentUI } from '@teambit/component';
|
|
3
3
|
import type { SlotRegistry } from '@teambit/harmony';
|
|
4
4
|
import type { ComponentCompareUI } from '@teambit/component-compare';
|
|
5
|
-
import type { UseSandboxPermission } from '@teambit/preview.ui.component-preview';
|
|
5
|
+
import type { UsePreviewProps, UseSandboxPermission } from '@teambit/preview.ui.component-preview';
|
|
6
6
|
import type { APIReferenceUI } from '@teambit/api-reference';
|
|
7
7
|
import type { TitleBadgeSlot, TitleBadge, OverviewOptionsSlot, OverviewOptions } from './overview';
|
|
8
8
|
export type UsePreviewSandboxSlot = SlotRegistry<UseSandboxPermission>;
|
|
9
|
+
export type UsePreviewPropsSlot = SlotRegistry<UsePreviewProps>;
|
|
9
10
|
export declare class DocsUI {
|
|
10
11
|
readonly titleBadgeSlot: TitleBadgeSlot;
|
|
11
12
|
readonly overviewOptionsSlot: OverviewOptionsSlot;
|
|
12
13
|
private usePreviewSandboxSlot;
|
|
13
|
-
|
|
14
|
+
private usePreviewPropsSlot;
|
|
15
|
+
constructor(titleBadgeSlot: TitleBadgeSlot, overviewOptionsSlot: OverviewOptionsSlot, usePreviewSandboxSlot: UsePreviewSandboxSlot, usePreviewPropsSlot: UsePreviewPropsSlot);
|
|
14
16
|
/**
|
|
15
17
|
* register a new title badge into the overview section of a component.
|
|
16
18
|
*/
|
|
@@ -22,16 +24,23 @@ export declare class DocsUI {
|
|
|
22
24
|
private _emptyState?;
|
|
23
25
|
registerEmptyState(emptyState: ComponentType): ComponentType;
|
|
24
26
|
registerPreviewSandbox(useSandboxPermission: UseSandboxPermission): void;
|
|
27
|
+
/**
|
|
28
|
+
* register a per-component resolver for iframe attributes on the overview preview
|
|
29
|
+
* (`allow`, `referrerPolicy`, ...). The resolver runs at render time with the current
|
|
30
|
+
* `ComponentModel`; results from multiple resolvers merge with later keys winning.
|
|
31
|
+
*/
|
|
32
|
+
registerPreviewProps(usePreviewProps: UsePreviewProps): void;
|
|
25
33
|
getEmptyState(): ComponentType | undefined;
|
|
26
34
|
getDocsCompare(): import("react/jsx-runtime").JSX.Element;
|
|
27
35
|
registerOverviewOptions(options: OverviewOptions): void;
|
|
28
36
|
static dependencies: import("@teambit/harmony").Aspect[];
|
|
29
37
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
30
|
-
static slots: (((registerFn: () => string) => SlotRegistry<TitleBadge>) | ((registerFn: () => string) => SlotRegistry<UseSandboxPermission>))[];
|
|
31
|
-
static provider([component, componentCompare, apiRef]: [ComponentUI, ComponentCompareUI, APIReferenceUI], config:
|
|
38
|
+
static slots: (((registerFn: () => string) => SlotRegistry<TitleBadge>) | ((registerFn: () => string) => SlotRegistry<UseSandboxPermission>) | ((registerFn: () => string) => SlotRegistry<UsePreviewProps>))[];
|
|
39
|
+
static provider([component, componentCompare, apiRef]: [ComponentUI, ComponentCompareUI, APIReferenceUI], config: {}, [titleBadgeSlot, overviewOptionsSlot, usePreviewSandboxSlot, usePreviewPropsSlot]: [
|
|
32
40
|
TitleBadgeSlot,
|
|
33
41
|
OverviewOptionsSlot,
|
|
34
|
-
UsePreviewSandboxSlot
|
|
42
|
+
UsePreviewSandboxSlot,
|
|
43
|
+
UsePreviewPropsSlot
|
|
35
44
|
]): Promise<DocsUI>;
|
|
36
45
|
}
|
|
37
46
|
export default DocsUI;
|
package/dist/docs.ui.runtime.js
CHANGED
|
@@ -86,10 +86,11 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
|
|
|
86
86
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
87
87
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
88
88
|
class DocsUI {
|
|
89
|
-
constructor(titleBadgeSlot, overviewOptionsSlot, usePreviewSandboxSlot) {
|
|
89
|
+
constructor(titleBadgeSlot, overviewOptionsSlot, usePreviewSandboxSlot, usePreviewPropsSlot) {
|
|
90
90
|
this.titleBadgeSlot = titleBadgeSlot;
|
|
91
91
|
this.overviewOptionsSlot = overviewOptionsSlot;
|
|
92
92
|
this.usePreviewSandboxSlot = usePreviewSandboxSlot;
|
|
93
|
+
this.usePreviewPropsSlot = usePreviewPropsSlot;
|
|
93
94
|
_defineProperty(this, "_emptyState", void 0);
|
|
94
95
|
}
|
|
95
96
|
|
|
@@ -114,6 +115,15 @@ class DocsUI {
|
|
|
114
115
|
registerPreviewSandbox(useSandboxPermission) {
|
|
115
116
|
this.usePreviewSandboxSlot.register(useSandboxPermission);
|
|
116
117
|
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* register a per-component resolver for iframe attributes on the overview preview
|
|
121
|
+
* (`allow`, `referrerPolicy`, ...). The resolver runs at render time with the current
|
|
122
|
+
* `ComponentModel`; results from multiple resolvers merge with later keys winning.
|
|
123
|
+
*/
|
|
124
|
+
registerPreviewProps(usePreviewProps) {
|
|
125
|
+
this.usePreviewPropsSlot.register(usePreviewProps);
|
|
126
|
+
}
|
|
117
127
|
getEmptyState() {
|
|
118
128
|
return this._emptyState;
|
|
119
129
|
}
|
|
@@ -126,9 +136,9 @@ class DocsUI {
|
|
|
126
136
|
registerOverviewOptions(options) {
|
|
127
137
|
this.overviewOptionsSlot.register(options);
|
|
128
138
|
}
|
|
129
|
-
static async provider([component, componentCompare, apiRef], config, [titleBadgeSlot, overviewOptionsSlot, usePreviewSandboxSlot]) {
|
|
130
|
-
const docs = new DocsUI(titleBadgeSlot, overviewOptionsSlot, usePreviewSandboxSlot);
|
|
131
|
-
const section = new (_overview().OverviewSection)(titleBadgeSlot, overviewOptionsSlot, docs, apiRef, usePreviewSandboxSlot);
|
|
139
|
+
static async provider([component, componentCompare, apiRef], config, [titleBadgeSlot, overviewOptionsSlot, usePreviewSandboxSlot, usePreviewPropsSlot]) {
|
|
140
|
+
const docs = new DocsUI(titleBadgeSlot, overviewOptionsSlot, usePreviewSandboxSlot, usePreviewPropsSlot);
|
|
141
|
+
const section = new (_overview().OverviewSection)(titleBadgeSlot, overviewOptionsSlot, docs, apiRef, usePreviewSandboxSlot, usePreviewPropsSlot);
|
|
132
142
|
const compareSection = new (_docsUi2().OverviewCompareSection)(docs);
|
|
133
143
|
component.registerRoute(section.route);
|
|
134
144
|
component.registerNavigation(section.navigationLink, section.order);
|
|
@@ -140,13 +150,18 @@ class DocsUI {
|
|
|
140
150
|
manager.add('allow-same-origin');
|
|
141
151
|
}
|
|
142
152
|
});
|
|
153
|
+
// Default Permissions Policy: allow clipboard writes so copy-to-clipboard buttons in
|
|
154
|
+
// readme MDX work. Clipboard-read, camera, mic, geolocation, etc. remain denied.
|
|
155
|
+
docs.registerPreviewProps(manager => {
|
|
156
|
+
manager.set('allow', 'clipboard-write');
|
|
157
|
+
});
|
|
143
158
|
return docs;
|
|
144
159
|
}
|
|
145
160
|
}
|
|
146
161
|
exports.DocsUI = DocsUI;
|
|
147
162
|
_defineProperty(DocsUI, "dependencies", [_component().ComponentAspect, _componentCompare().ComponentCompareAspect, _apiReference().APIReferenceAspect]);
|
|
148
163
|
_defineProperty(DocsUI, "runtime", _ui().UIRuntime);
|
|
149
|
-
_defineProperty(DocsUI, "slots", [_harmony().Slot.withType(), _harmony().Slot.withType(), _harmony().Slot.withType()]);
|
|
164
|
+
_defineProperty(DocsUI, "slots", [_harmony().Slot.withType(), _harmony().Slot.withType(), _harmony().Slot.withType(), _harmony().Slot.withType()]);
|
|
150
165
|
var _default = exports.default = DocsUI;
|
|
151
166
|
_docs().DocsAspect.addRuntime(DocsUI);
|
|
152
167
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","data","_interopRequireDefault","require","_lodash","_component","_harmony","_ui","_componentCompare","_docsUi","_docsUi2","_apiReference","_docs","_overview","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","DocsUI","constructor","titleBadgeSlot","overviewOptionsSlot","usePreviewSandboxSlot","registerTitleBadge","titleBadges","badges","Array","isArray","register","listTitleBadges","flatten","values","registerEmptyState","emptyState","_emptyState","registerPreviewSandbox","useSandboxPermission","getEmptyState","getDocsCompare","createElement","OverviewCompare","overviewOptions","registerOverviewOptions","options","provider","component","componentCompare","apiRef","config","docs","section","OverviewSection","compareSection","OverviewCompareSection","registerRoute","route","registerNavigation","navigationLink","order","registerRoutes","manager","componentModel","host","add","exports","ComponentAspect","ComponentCompareAspect","APIReferenceAspect","UIRuntime","Slot","withType","_default","DocsAspect","addRuntime"],"sources":["docs.ui.runtime.tsx"],"sourcesContent":["import type { ComponentType } from 'react';\nimport React from 'react';\nimport { flatten } from 'lodash';\nimport type { ComponentUI } from '@teambit/component';\nimport { ComponentAspect } from '@teambit/component';\nimport type { SlotRegistry } from '@teambit/harmony';\nimport { Slot } from '@teambit/harmony';\nimport { UIRuntime } from '@teambit/ui';\nimport type { ComponentCompareUI } from '@teambit/component-compare';\nimport { ComponentCompareAspect } from '@teambit/component-compare';\nimport { OverviewCompare } from '@teambit/docs.ui.overview-compare';\nimport { OverviewCompareSection } from '@teambit/docs.ui.overview-compare-section';\nimport type { UseSandboxPermission } from '@teambit/preview.ui.component-preview';\nimport type { APIReferenceUI } from '@teambit/api-reference';\nimport { APIReferenceAspect } from '@teambit/api-reference';\nimport { DocsAspect } from './docs.aspect';\nimport { OverviewSection } from './overview.section';\nimport type { TitleBadgeSlot, TitleBadge, OverviewOptionsSlot, OverviewOptions } from './overview';\n\nexport type UsePreviewSandboxSlot = SlotRegistry<UseSandboxPermission>;\n\nexport class DocsUI {\n constructor(\n readonly titleBadgeSlot: TitleBadgeSlot,\n readonly overviewOptionsSlot: OverviewOptionsSlot,\n private usePreviewSandboxSlot: UsePreviewSandboxSlot\n ) {}\n\n /**\n * register a new title badge into the overview section of a component.\n */\n registerTitleBadge(titleBadges: TitleBadge | TitleBadge[]) {\n const badges = Array.isArray(titleBadges) ? titleBadges : [titleBadges];\n this.titleBadgeSlot.register(badges);\n return this;\n }\n\n /**\n * list all title badges registered.\n */\n listTitleBadges() {\n return flatten(this.titleBadgeSlot.values());\n }\n\n private _emptyState?: ComponentType;\n\n registerEmptyState(emptyState: ComponentType) {\n return (this._emptyState = emptyState);\n }\n\n registerPreviewSandbox(useSandboxPermission: UseSandboxPermission) {\n this.usePreviewSandboxSlot.register(useSandboxPermission);\n }\n\n getEmptyState() {\n return this._emptyState;\n }\n\n getDocsCompare() {\n return <OverviewCompare titleBadges={this.titleBadgeSlot} overviewOptions={this.overviewOptionsSlot} />;\n }\n\n registerOverviewOptions(options: OverviewOptions) {\n this.overviewOptionsSlot.register(options);\n }\n\n static dependencies = [ComponentAspect, ComponentCompareAspect, APIReferenceAspect];\n\n static runtime = UIRuntime;\n\n static slots = [Slot.withType<TitleBadge>(), Slot.withType<OverviewOptions>(), Slot.withType<UseSandboxPermission>()];\n\n static async provider(\n [component, componentCompare, apiRef]: [ComponentUI, ComponentCompareUI, APIReferenceUI],\n config,\n [titleBadgeSlot, overviewOptionsSlot, usePreviewSandboxSlot]: [\n TitleBadgeSlot,\n OverviewOptionsSlot,\n UsePreviewSandboxSlot,\n ]\n ) {\n const docs = new DocsUI(titleBadgeSlot, overviewOptionsSlot, usePreviewSandboxSlot);\n const section = new OverviewSection(titleBadgeSlot, overviewOptionsSlot, docs, apiRef, usePreviewSandboxSlot);\n const compareSection = new OverviewCompareSection(docs);\n component.registerRoute(section.route);\n component.registerNavigation(section.navigationLink, section.order);\n componentCompare.registerNavigation(compareSection);\n componentCompare.registerRoutes([compareSection.route]);\n docs.registerPreviewSandbox((manager, componentModel) => {\n if (componentModel?.host === 'teambit.scope/scope') {\n manager.add('allow-scripts');\n manager.add('allow-same-origin');\n }\n });\n return docs;\n }\n}\n\nexport default DocsUI;\n\nDocsAspect.addRuntime(DocsUI);\n"],"mappings":";;;;;;AACA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,WAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,UAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,SAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,QAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,IAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,GAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;A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CAAA9C,MAAA,GAAAA,MAAA;AAAAlB,eAAA,CA3EYkB,MAAM,kBA6CK,CAAC+C,4BAAe,EAAEC,0CAAsB,EAAEC,kCAAkB,CAAC;AAAAnE,eAAA,CA7CxEkB,MAAM,aA+CAkD,eAAS;AAAApE,eAAA,CA/CfkB,MAAM,WAiDF,CAACmD,eAAI,CAACC,QAAQ,CAAa,CAAC,EAAED,eAAI,CAACC,QAAQ,CAAkB,CAAC,EAAED,eAAI,CAACC,QAAQ,CAAuB,CAAC,CAAC;AAAA,IAAAC,QAAA,GAAAP,OAAA,CAAAjE,OAAA,GA4BxGmB,MAAM;AAErBsD,kBAAU,CAACC,UAAU,CAACvD,MAAM,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","data","_interopRequireDefault","require","_lodash","_component","_harmony","_ui","_componentCompare","_docsUi","_docsUi2","_apiReference","_docs","_overview","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","DocsUI","constructor","titleBadgeSlot","overviewOptionsSlot","usePreviewSandboxSlot","usePreviewPropsSlot","registerTitleBadge","titleBadges","badges","Array","isArray","register","listTitleBadges","flatten","values","registerEmptyState","emptyState","_emptyState","registerPreviewSandbox","useSandboxPermission","registerPreviewProps","usePreviewProps","getEmptyState","getDocsCompare","createElement","OverviewCompare","overviewOptions","registerOverviewOptions","options","provider","component","componentCompare","apiRef","config","docs","section","OverviewSection","compareSection","OverviewCompareSection","registerRoute","route","registerNavigation","navigationLink","order","registerRoutes","manager","componentModel","host","add","set","exports","ComponentAspect","ComponentCompareAspect","APIReferenceAspect","UIRuntime","Slot","withType","_default","DocsAspect","addRuntime"],"sources":["docs.ui.runtime.tsx"],"sourcesContent":["import type { ComponentType } from 'react';\nimport React from 'react';\nimport { flatten } from 'lodash';\nimport type { ComponentUI } from '@teambit/component';\nimport { ComponentAspect } from '@teambit/component';\nimport type { SlotRegistry } from '@teambit/harmony';\nimport { Slot } from '@teambit/harmony';\nimport { UIRuntime } from '@teambit/ui';\nimport type { ComponentCompareUI } from '@teambit/component-compare';\nimport { ComponentCompareAspect } from '@teambit/component-compare';\nimport { OverviewCompare } from '@teambit/docs.ui.overview-compare';\nimport { OverviewCompareSection } from '@teambit/docs.ui.overview-compare-section';\nimport type { UsePreviewProps, UseSandboxPermission } from '@teambit/preview.ui.component-preview';\nimport type { APIReferenceUI } from '@teambit/api-reference';\nimport { APIReferenceAspect } from '@teambit/api-reference';\nimport { DocsAspect } from './docs.aspect';\nimport { OverviewSection } from './overview.section';\nimport type { TitleBadgeSlot, TitleBadge, OverviewOptionsSlot, OverviewOptions } from './overview';\n\nexport type UsePreviewSandboxSlot = SlotRegistry<UseSandboxPermission>;\nexport type UsePreviewPropsSlot = SlotRegistry<UsePreviewProps>;\n\nexport class DocsUI {\n constructor(\n readonly titleBadgeSlot: TitleBadgeSlot,\n readonly overviewOptionsSlot: OverviewOptionsSlot,\n private usePreviewSandboxSlot: UsePreviewSandboxSlot,\n private usePreviewPropsSlot: UsePreviewPropsSlot\n ) {}\n\n /**\n * register a new title badge into the overview section of a component.\n */\n registerTitleBadge(titleBadges: TitleBadge | TitleBadge[]) {\n const badges = Array.isArray(titleBadges) ? titleBadges : [titleBadges];\n this.titleBadgeSlot.register(badges);\n return this;\n }\n\n /**\n * list all title badges registered.\n */\n listTitleBadges() {\n return flatten(this.titleBadgeSlot.values());\n }\n\n private _emptyState?: ComponentType;\n\n registerEmptyState(emptyState: ComponentType) {\n return (this._emptyState = emptyState);\n }\n\n registerPreviewSandbox(useSandboxPermission: UseSandboxPermission) {\n this.usePreviewSandboxSlot.register(useSandboxPermission);\n }\n\n /**\n * register a per-component resolver for iframe attributes on the overview preview\n * (`allow`, `referrerPolicy`, ...). The resolver runs at render time with the current\n * `ComponentModel`; results from multiple resolvers merge with later keys winning.\n */\n registerPreviewProps(usePreviewProps: UsePreviewProps) {\n this.usePreviewPropsSlot.register(usePreviewProps);\n }\n\n getEmptyState() {\n return this._emptyState;\n }\n\n getDocsCompare() {\n return <OverviewCompare titleBadges={this.titleBadgeSlot} overviewOptions={this.overviewOptionsSlot} />;\n }\n\n registerOverviewOptions(options: OverviewOptions) {\n this.overviewOptionsSlot.register(options);\n }\n\n static dependencies = [ComponentAspect, ComponentCompareAspect, APIReferenceAspect];\n\n static runtime = UIRuntime;\n\n static slots = [\n Slot.withType<TitleBadge>(),\n Slot.withType<OverviewOptions>(),\n Slot.withType<UseSandboxPermission>(),\n Slot.withType<UsePreviewProps>(),\n ];\n\n static async provider(\n [component, componentCompare, apiRef]: [ComponentUI, ComponentCompareUI, APIReferenceUI],\n config: {},\n [titleBadgeSlot, overviewOptionsSlot, usePreviewSandboxSlot, usePreviewPropsSlot]: [\n TitleBadgeSlot,\n OverviewOptionsSlot,\n UsePreviewSandboxSlot,\n UsePreviewPropsSlot,\n ]\n ) {\n const docs = new DocsUI(titleBadgeSlot, overviewOptionsSlot, usePreviewSandboxSlot, usePreviewPropsSlot);\n const section = new OverviewSection(\n titleBadgeSlot,\n overviewOptionsSlot,\n docs,\n apiRef,\n usePreviewSandboxSlot,\n usePreviewPropsSlot\n );\n const compareSection = new OverviewCompareSection(docs);\n component.registerRoute(section.route);\n component.registerNavigation(section.navigationLink, section.order);\n componentCompare.registerNavigation(compareSection);\n componentCompare.registerRoutes([compareSection.route]);\n docs.registerPreviewSandbox((manager, componentModel) => {\n if (componentModel?.host === 'teambit.scope/scope') {\n manager.add('allow-scripts');\n manager.add('allow-same-origin');\n }\n });\n // Default Permissions Policy: allow clipboard writes so copy-to-clipboard buttons in\n // readme MDX work. Clipboard-read, camera, mic, geolocation, etc. remain denied.\n docs.registerPreviewProps((manager) => {\n manager.set('allow', 'clipboard-write');\n });\n return docs;\n }\n}\n\nexport default DocsUI;\n\nDocsAspect.addRuntime(DocsUI);\n"],"mappings":";;;;;;AACA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC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AAC,EAChCD,eAAI,CAACC,QAAQ,CAAuB,CAAC,EACrCD,eAAI,CAACC,QAAQ,CAAkB,CAAC,CACjC;AAAA,IAAAC,QAAA,GAAAP,OAAA,CAAArE,OAAA,GAyCYmB,MAAM;AAErB0D,kBAAU,CAACC,UAAU,CAAC3D,MAAM,CAAC","ignoreList":[]}
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import type { SlotRegistry } from '@teambit/harmony';
|
|
4
4
|
import type { ComponentPreviewProps } from '@teambit/preview.ui.component-preview';
|
|
5
5
|
import type { UsePreviewSandboxSlot } from '@teambit/compositions';
|
|
6
|
+
import type { UsePreviewPropsSlot } from '../docs.ui.runtime';
|
|
6
7
|
export declare enum BadgePosition {
|
|
7
8
|
Title = 0,
|
|
8
9
|
SubTitle = 1,
|
|
@@ -30,5 +31,11 @@ export type OverviewProps = {
|
|
|
30
31
|
componentId: string;
|
|
31
32
|
}>;
|
|
32
33
|
usePreviewSandboxSlot?: UsePreviewSandboxSlot;
|
|
34
|
+
/**
|
|
35
|
+
* per-component resolvers for iframe attributes on the overview preview (`allow`,
|
|
36
|
+
* `referrerPolicy`, ...). Each resolver gets the current `ComponentModel`; results merge
|
|
37
|
+
* with later registrations winning.
|
|
38
|
+
*/
|
|
39
|
+
usePreviewPropsSlot?: UsePreviewPropsSlot;
|
|
33
40
|
};
|
|
34
|
-
export declare function Overview({ titleBadges, overviewOptions, previewProps, getEmptyState, TaggedAPI, usePreviewSandboxSlot, }: OverviewProps): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
export declare function Overview({ titleBadges, overviewOptions, previewProps, getEmptyState, TaggedAPI, usePreviewSandboxSlot, usePreviewPropsSlot, }: OverviewProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -98,7 +98,8 @@ function Overview({
|
|
|
98
98
|
previewProps,
|
|
99
99
|
getEmptyState,
|
|
100
100
|
TaggedAPI,
|
|
101
|
-
usePreviewSandboxSlot
|
|
101
|
+
usePreviewSandboxSlot,
|
|
102
|
+
usePreviewPropsSlot
|
|
102
103
|
}) {
|
|
103
104
|
const component = (0, _react().useContext)(_component().ComponentContext);
|
|
104
105
|
const componentDescriptor = (0, _component().useComponentDescriptor)();
|
|
@@ -116,6 +117,8 @@ function Overview({
|
|
|
116
117
|
} = (0, _workspaceUi().useWorkspaceMode)();
|
|
117
118
|
const [isLoading, setLoading] = (0, _react().useState)(defaultLoadingState);
|
|
118
119
|
const previewSandboxHooks = usePreviewSandboxSlot?.values() ?? [];
|
|
120
|
+
const previewPropsHooks = usePreviewPropsSlot?.values() ?? [];
|
|
121
|
+
const [previewAttrs, setPreviewAttrs] = (0, _react().useState)({});
|
|
119
122
|
const [sandboxValue, setSandboxValue] = (0, _react().useState)('');
|
|
120
123
|
const iframeQueryParams = `onlyOverview=${component.preview?.onlyOverview || 'false'}&skipIncludes=${component.preview?.skipIncludes || component.preview?.onlyOverview}`;
|
|
121
124
|
const overviewPropsValues = overviewProps && overviewProps();
|
|
@@ -146,6 +149,10 @@ function Overview({
|
|
|
146
149
|
hooks: previewSandboxHooks,
|
|
147
150
|
onSandboxChange: setSandboxValue,
|
|
148
151
|
component: component
|
|
152
|
+
}), /*#__PURE__*/_react().default.createElement(_previewUi().PreviewPropsAggregator, {
|
|
153
|
+
hooks: previewPropsHooks,
|
|
154
|
+
onPreviewPropsChange: setPreviewAttrs,
|
|
155
|
+
component: component
|
|
149
156
|
}), showHeader && /*#__PURE__*/_react().default.createElement(_componentUi().ComponentOverview, {
|
|
150
157
|
className: (0, _classnames().default)(_overviewModule().default.componentOverviewBlock, !isScaling && _overviewModule().default.legacyPreview),
|
|
151
158
|
displayName: component.displayName,
|
|
@@ -161,7 +168,7 @@ function Overview({
|
|
|
161
168
|
className: _overviewModule().default.readme
|
|
162
169
|
}, isLoading && /*#__PURE__*/_react().default.createElement(_readmeSkeleton().ReadmeSkeleton, null, /*#__PURE__*/_react().default.createElement(_compositionsPanels().CompositionGallerySkeleton, {
|
|
163
170
|
compositionsLength: Math.min(component.compositions.length, 3)
|
|
164
|
-
})), !isMinimal && !renderCompositionsFirst ? /*#__PURE__*/_react().default.createElement(_react().default.Fragment, null, /*#__PURE__*/_react().default.createElement(_previewUi().ComponentPreview, _extends({
|
|
171
|
+
})), !isMinimal && !renderCompositionsFirst ? /*#__PURE__*/_react().default.createElement(_react().default.Fragment, null, /*#__PURE__*/_react().default.createElement(_previewUi().ComponentPreview, _extends({}, previewAttrs, {
|
|
165
172
|
onLoad: onPreviewLoad,
|
|
166
173
|
previewName: "overview",
|
|
167
174
|
pubsub: true,
|
|
@@ -183,7 +190,7 @@ function Overview({
|
|
|
183
190
|
})) : /*#__PURE__*/_react().default.createElement(_react().default.Fragment, null, component.preview?.onlyOverview && !isLoading && /*#__PURE__*/_react().default.createElement(_compositionsPanels().CompositionGallery, {
|
|
184
191
|
component: component,
|
|
185
192
|
sandbox: sandboxValue
|
|
186
|
-
}), /*#__PURE__*/_react().default.createElement(_previewUi().ComponentPreview, _extends({
|
|
193
|
+
}), /*#__PURE__*/_react().default.createElement(_previewUi().ComponentPreview, _extends({}, previewAttrs, {
|
|
187
194
|
onLoad: onPreviewLoad,
|
|
188
195
|
previewName: "overview",
|
|
189
196
|
pubsub: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","data","_interopRequireWildcard","require","_classnames","_interopRequireDefault","_lodash","_component","_previewUi","_componentUi","_compositionsPanels","_workspaceUi","_readmeSkeleton","_overviewModule","_excluded","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","_objectWithoutProperties","_objectWithoutPropertiesLoose","getOwnPropertySymbols","indexOf","propertyIsEnumerable","BadgePosition","exports","Overview","titleBadges","overviewOptions","previewProps","getEmptyState","TaggedAPI","usePreviewSandboxSlot","component","useContext","ComponentContext","componentDescriptor","useComponentDescriptor","overviewProps","flatten","values","showHeader","preview","legacyHeader","EmptyState","buildFailed","buildStatus","toLowerCase","host","isScaling","Boolean","includesEnvTemplate","defaultLoadingState","React","useMemo","isMinimal","useWorkspaceMode","isLoading","setLoading","useState","previewSandboxHooks","sandboxValue","setSandboxValue","iframeQueryParams","onlyOverview","skipIncludes","overviewPropsValues","renderCompositionsFirst","defaultPkgManager","_ref","onLoad","style","rest","onPreviewLoad","useCallback","props","useEffect","id","toString","createElement","className","classNames","styles","overviewWrapper","noOverflow","key","SandboxPermissionsAggregator","hooks","onSandboxChange","ComponentOverview","componentOverviewBlock","legacyPreview","displayName","version","abstract","description","labels","packageName","pkgManager","readme","ReadmeSkeleton","CompositionGallerySkeleton","compositionsLength","Math","min","compositions","Fragment","ComponentPreview","previewName","pubsub","queryParams","viewport","fullContentHeight","disableScroll","sandbox","width","height","minHeight","undefined","CompositionGallery","propagateError","componentId"],"sources":["overview.tsx"],"sourcesContent":["/* eslint-disable complexity */\nimport type { ComponentType } from 'react';\nimport React, { useContext, useState } from 'react';\nimport classNames from 'classnames';\nimport { flatten } from 'lodash';\n// import { Icon } from '@teambit/design.elements.icon';\n// import { LinkedHeading } from '@teambit/documenter.ui.linked-heading';\nimport { ComponentContext, useComponentDescriptor } from '@teambit/component';\nimport type { SlotRegistry } from '@teambit/harmony';\nimport type { ComponentPreviewProps } from '@teambit/preview.ui.component-preview';\nimport { ComponentPreview, SandboxPermissionsAggregator } from '@teambit/preview.ui.component-preview';\n// import { StatusMessageCard } from '@teambit/design.ui.surfaces.status-message-card';\nimport { ComponentOverview } from '@teambit/component.ui.component-meta';\nimport { CompositionGallery, CompositionGallerySkeleton } from '@teambit/compositions.panels.composition-gallery';\nimport { useWorkspaceMode } from '@teambit/workspace.ui.use-workspace-mode';\nimport type { UsePreviewSandboxSlot } from '@teambit/compositions';\nimport { ReadmeSkeleton } from './readme-skeleton';\nimport styles from './overview.module.scss';\n\nexport enum BadgePosition {\n Title,\n SubTitle,\n Labels,\n Package,\n}\n\nexport type TitleBadge = {\n component: ComponentType<any>;\n weight?: number;\n position?: BadgePosition;\n};\n\nexport type TitleBadgeSlot = SlotRegistry<TitleBadge[]>;\n\nexport type OverviewOptions = () => {\n queryParams?: string;\n renderCompositionsFirst?: boolean;\n defaultPkgManager?: 'npm' | 'yarn' | 'pnpm' | 'bit';\n};\n\nexport type OverviewOptionsSlot = SlotRegistry<OverviewOptions>;\n\nexport type OverviewProps = {\n titleBadges: TitleBadgeSlot;\n overviewOptions: OverviewOptionsSlot;\n previewProps?: Partial<ComponentPreviewProps>;\n getEmptyState?: () => ComponentType | undefined;\n TaggedAPI?: React.ComponentType<{ componentId: string }>;\n usePreviewSandboxSlot?: UsePreviewSandboxSlot;\n};\n\nexport function Overview({\n titleBadges,\n overviewOptions,\n previewProps,\n getEmptyState,\n TaggedAPI,\n usePreviewSandboxSlot,\n}: OverviewProps) {\n const component = useContext(ComponentContext);\n const componentDescriptor = useComponentDescriptor();\n const overviewProps = flatten(overviewOptions.values())[0];\n const showHeader = !component.preview?.legacyHeader;\n const EmptyState = getEmptyState && getEmptyState();\n const buildFailed = component.buildStatus?.toLowerCase() !== 'succeed' && component?.host === 'teambit.scope/scope';\n const isScaling = Boolean(component.preview?.isScaling);\n const includesEnvTemplate = Boolean(component.preview?.includesEnvTemplate);\n const defaultLoadingState = React.useMemo(() => {\n return isScaling && !includesEnvTemplate;\n }, [isScaling, includesEnvTemplate]);\n const { isMinimal } = useWorkspaceMode();\n const [isLoading, setLoading] = useState(defaultLoadingState);\n const previewSandboxHooks = usePreviewSandboxSlot?.values() ?? [];\n const [sandboxValue, setSandboxValue] = useState('');\n const iframeQueryParams = `onlyOverview=${component.preview?.onlyOverview || 'false'}&skipIncludes=${\n component.preview?.skipIncludes || component.preview?.onlyOverview\n }`;\n\n const overviewPropsValues = overviewProps && overviewProps();\n\n const { renderCompositionsFirst, defaultPkgManager } = overviewPropsValues || {};\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { onLoad, style, ...rest } = previewProps || {};\n\n const onPreviewLoad = React.useCallback(\n (e, props) => {\n setLoading(false);\n onLoad?.(e, props);\n },\n [onLoad]\n );\n\n React.useEffect(() => {\n if (!isLoading && defaultLoadingState) setLoading(true);\n if (isLoading && !defaultLoadingState) setLoading(false);\n }, [component.id.toString(), defaultLoadingState]);\n\n return (\n <div\n className={classNames(styles.overviewWrapper, isLoading && styles.noOverflow)}\n key={`${component.id.toString()}`}\n >\n <SandboxPermissionsAggregator\n hooks={previewSandboxHooks}\n onSandboxChange={setSandboxValue}\n component={component}\n />\n {showHeader && (\n <ComponentOverview\n className={classNames(styles.componentOverviewBlock, !isScaling && styles.legacyPreview)}\n displayName={component.displayName}\n version={component.version}\n abstract={component.description}\n labels={component.labels}\n packageName={component.packageName}\n titleBadges={flatten(titleBadges.values())}\n componentDescriptor={componentDescriptor}\n component={component}\n pkgManager={defaultPkgManager}\n />\n )}\n {!buildFailed && (\n <div className={styles.readme}>\n {isLoading && (\n <ReadmeSkeleton>\n <CompositionGallerySkeleton compositionsLength={Math.min(component.compositions.length, 3)} />\n </ReadmeSkeleton>\n )}\n {!isMinimal && !renderCompositionsFirst ? (\n <>\n <ComponentPreview\n onLoad={onPreviewLoad}\n previewName=\"overview\"\n pubsub={true}\n queryParams={[iframeQueryParams, overviewPropsValues?.queryParams || '']}\n viewport={null}\n fullContentHeight\n disableScroll={true}\n sandbox={sandboxValue}\n {...rest}\n component={component}\n style={{ width: '100%', height: '100%', minHeight: !isScaling ? 500 : undefined }}\n />\n {component.preview?.onlyOverview && !isLoading && (\n <CompositionGallery component={component} sandbox={sandboxValue} />\n )}\n </>\n ) : (\n <>\n {component.preview?.onlyOverview && !isLoading && (\n <CompositionGallery component={component} sandbox={sandboxValue} />\n )}\n <ComponentPreview\n onLoad={onPreviewLoad}\n previewName=\"overview\"\n pubsub={true}\n queryParams={[iframeQueryParams, overviewPropsValues?.queryParams || '']}\n viewport={null}\n fullContentHeight\n disableScroll={true}\n propagateError={isMinimal}\n sandbox={sandboxValue}\n {...rest}\n component={component}\n style={{ width: '100%', height: '100%', minHeight: !isScaling ? 500 : undefined }}\n />\n </>\n )}\n {component.preview?.onlyOverview && !isLoading && TaggedAPI && (\n <TaggedAPI componentId={component.id.toString()} />\n )}\n </div>\n )}\n {buildFailed && EmptyState && <EmptyState />}\n </div>\n );\n}\n"],"mappings":";;;;;;;AAEA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,uBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAM,WAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,UAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAO,WAAA;EAAA,MAAAP,IAAA,GAAAE,OAAA;EAAAK,UAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAQ,aAAA;EAAA,MAAAR,IAAA,GAAAE,OAAA;EAAAM,YAAA,YAAAA,CAAA;IAAA,OAAAR,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAS,oBAAA;EAAA,MAAAT,IAAA,GAAAE,OAAA;EAAAO,mBAAA,YAAAA,CAAA;IAAA,OAAAT,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAU,aAAA;EAAA,MAAAV,IAAA,GAAAE,OAAA;EAAAQ,YAAA,YAAAA,CAAA;IAAA,OAAAV,IAAA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F,aAAA,CAAC1F,mBAAA,GAAAkI,kBAAkB;IAACtF,SAAS,EAAEA,SAAU;IAACiF,OAAO,EAAErD;EAAa,CAAE,CACnE,eACDlF,MAAA,GAAAiB,OAAA,CAAAmF,aAAA,CAAC5F,UAAA,GAAAwH,gBAAgB,EAAA9F,QAAA;IACfyD,MAAM,EAAEG,aAAc;IACtBmC,WAAW,EAAC,UAAU;IACtBC,MAAM,EAAE,IAAK;IACbC,WAAW,EAAE,CAAC/C,iBAAiB,EAAEG,mBAAmB,EAAE4C,WAAW,IAAI,EAAE,CAAE;IACzEC,QAAQ,EAAE,IAAK;IACfC,iBAAiB;IACjBC,aAAa,EAAE,IAAK;IACpBO,cAAc,EAAEjE,SAAU;IAC1B2D,OAAO,EAAErD;EAAa,GAClBW,IAAI;IACRvC,SAAS,EAAEA,SAAU;IACrBsC,KAAK,EAAE;MAAE4C,KAAK,EAAE,MAAM;MAAEC,MAAM,EAAE,MAAM;MAAEC,SAAS,EAAE,CAACpE,SAAS,GAAG,GAAG,GAAGqE;IAAU;EAAE,EACnF,CACD,CACH,EACArF,SAAS,CAACS,OAAO,EAAEsB,YAAY,IAAI,CAACP,SAAS,IAAI1B,SAAS,iBACzDpD,MAAA,GAAAiB,OAAA,CAAAmF,aAAA,CAAChD,SAAS;IAAC0F,WAAW,EAAExF,SAAS,CAAC4C,EAAE,CAACC,QAAQ,CAAC;EAAE,CAAE,CAEjD,CACN,EACAjC,WAAW,IAAID,UAAU,iBAAIjE,MAAA,GAAAiB,OAAA,CAAAmF,aAAA,CAACnC,UAAU,MAAE,CACxC,CAAC;AAEV","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","data","_interopRequireWildcard","require","_classnames","_interopRequireDefault","_lodash","_component","_previewUi","_componentUi","_compositionsPanels","_workspaceUi","_readmeSkeleton","_overviewModule","_excluded","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","_objectWithoutProperties","_objectWithoutPropertiesLoose","getOwnPropertySymbols","indexOf","propertyIsEnumerable","BadgePosition","exports","Overview","titleBadges","overviewOptions","previewProps","getEmptyState","TaggedAPI","usePreviewSandboxSlot","usePreviewPropsSlot","component","useContext","ComponentContext","componentDescriptor","useComponentDescriptor","overviewProps","flatten","values","showHeader","preview","legacyHeader","EmptyState","buildFailed","buildStatus","toLowerCase","host","isScaling","Boolean","includesEnvTemplate","defaultLoadingState","React","useMemo","isMinimal","useWorkspaceMode","isLoading","setLoading","useState","previewSandboxHooks","previewPropsHooks","previewAttrs","setPreviewAttrs","sandboxValue","setSandboxValue","iframeQueryParams","onlyOverview","skipIncludes","overviewPropsValues","renderCompositionsFirst","defaultPkgManager","_ref","onLoad","style","rest","onPreviewLoad","useCallback","props","useEffect","id","toString","createElement","className","classNames","styles","overviewWrapper","noOverflow","key","SandboxPermissionsAggregator","hooks","onSandboxChange","PreviewPropsAggregator","onPreviewPropsChange","ComponentOverview","componentOverviewBlock","legacyPreview","displayName","version","abstract","description","labels","packageName","pkgManager","readme","ReadmeSkeleton","CompositionGallerySkeleton","compositionsLength","Math","min","compositions","Fragment","ComponentPreview","previewName","pubsub","queryParams","viewport","fullContentHeight","disableScroll","sandbox","width","height","minHeight","undefined","CompositionGallery","propagateError","componentId"],"sources":["overview.tsx"],"sourcesContent":["/* eslint-disable complexity */\nimport type { ComponentType } from 'react';\nimport React, { useContext, useState } from 'react';\nimport classNames from 'classnames';\nimport { flatten } from 'lodash';\n// import { Icon } from '@teambit/design.elements.icon';\n// import { LinkedHeading } from '@teambit/documenter.ui.linked-heading';\nimport { ComponentContext, useComponentDescriptor } from '@teambit/component';\nimport type { SlotRegistry } from '@teambit/harmony';\nimport type { ComponentPreviewProps, PreviewIframeAttrs } from '@teambit/preview.ui.component-preview';\nimport {\n ComponentPreview,\n PreviewPropsAggregator,\n SandboxPermissionsAggregator,\n} from '@teambit/preview.ui.component-preview';\n// import { StatusMessageCard } from '@teambit/design.ui.surfaces.status-message-card';\nimport { ComponentOverview } from '@teambit/component.ui.component-meta';\nimport { CompositionGallery, CompositionGallerySkeleton } from '@teambit/compositions.panels.composition-gallery';\nimport { useWorkspaceMode } from '@teambit/workspace.ui.use-workspace-mode';\nimport type { UsePreviewSandboxSlot } from '@teambit/compositions';\nimport type { UsePreviewPropsSlot } from '../docs.ui.runtime';\nimport { ReadmeSkeleton } from './readme-skeleton';\nimport styles from './overview.module.scss';\n\nexport enum BadgePosition {\n Title,\n SubTitle,\n Labels,\n Package,\n}\n\nexport type TitleBadge = {\n component: ComponentType<any>;\n weight?: number;\n position?: BadgePosition;\n};\n\nexport type TitleBadgeSlot = SlotRegistry<TitleBadge[]>;\n\nexport type OverviewOptions = () => {\n queryParams?: string;\n renderCompositionsFirst?: boolean;\n defaultPkgManager?: 'npm' | 'yarn' | 'pnpm' | 'bit';\n};\n\nexport type OverviewOptionsSlot = SlotRegistry<OverviewOptions>;\n\nexport type OverviewProps = {\n titleBadges: TitleBadgeSlot;\n overviewOptions: OverviewOptionsSlot;\n previewProps?: Partial<ComponentPreviewProps>;\n getEmptyState?: () => ComponentType | undefined;\n TaggedAPI?: React.ComponentType<{ componentId: string }>;\n usePreviewSandboxSlot?: UsePreviewSandboxSlot;\n /**\n * per-component resolvers for iframe attributes on the overview preview (`allow`,\n * `referrerPolicy`, ...). Each resolver gets the current `ComponentModel`; results merge\n * with later registrations winning.\n */\n usePreviewPropsSlot?: UsePreviewPropsSlot;\n};\n\nexport function Overview({\n titleBadges,\n overviewOptions,\n previewProps,\n getEmptyState,\n TaggedAPI,\n usePreviewSandboxSlot,\n usePreviewPropsSlot,\n}: OverviewProps) {\n const component = useContext(ComponentContext);\n const componentDescriptor = useComponentDescriptor();\n const overviewProps = flatten(overviewOptions.values())[0];\n const showHeader = !component.preview?.legacyHeader;\n const EmptyState = getEmptyState && getEmptyState();\n const buildFailed = component.buildStatus?.toLowerCase() !== 'succeed' && component?.host === 'teambit.scope/scope';\n const isScaling = Boolean(component.preview?.isScaling);\n const includesEnvTemplate = Boolean(component.preview?.includesEnvTemplate);\n const defaultLoadingState = React.useMemo(() => {\n return isScaling && !includesEnvTemplate;\n }, [isScaling, includesEnvTemplate]);\n const { isMinimal } = useWorkspaceMode();\n const [isLoading, setLoading] = useState(defaultLoadingState);\n const previewSandboxHooks = usePreviewSandboxSlot?.values() ?? [];\n const previewPropsHooks = usePreviewPropsSlot?.values() ?? [];\n const [previewAttrs, setPreviewAttrs] = useState<PreviewIframeAttrs>({});\n const [sandboxValue, setSandboxValue] = useState('');\n const iframeQueryParams = `onlyOverview=${component.preview?.onlyOverview || 'false'}&skipIncludes=${\n component.preview?.skipIncludes || component.preview?.onlyOverview\n }`;\n\n const overviewPropsValues = overviewProps && overviewProps();\n\n const { renderCompositionsFirst, defaultPkgManager } = overviewPropsValues || {};\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { onLoad, style, ...rest } = previewProps || {};\n\n const onPreviewLoad = React.useCallback(\n (e, props) => {\n setLoading(false);\n onLoad?.(e, props);\n },\n [onLoad]\n );\n\n React.useEffect(() => {\n if (!isLoading && defaultLoadingState) setLoading(true);\n if (isLoading && !defaultLoadingState) setLoading(false);\n }, [component.id.toString(), defaultLoadingState]);\n\n return (\n <div\n className={classNames(styles.overviewWrapper, isLoading && styles.noOverflow)}\n key={`${component.id.toString()}`}\n >\n <SandboxPermissionsAggregator\n hooks={previewSandboxHooks}\n onSandboxChange={setSandboxValue}\n component={component}\n />\n <PreviewPropsAggregator hooks={previewPropsHooks} onPreviewPropsChange={setPreviewAttrs} component={component} />\n {showHeader && (\n <ComponentOverview\n className={classNames(styles.componentOverviewBlock, !isScaling && styles.legacyPreview)}\n displayName={component.displayName}\n version={component.version}\n abstract={component.description}\n labels={component.labels}\n packageName={component.packageName}\n titleBadges={flatten(titleBadges.values())}\n componentDescriptor={componentDescriptor}\n component={component}\n pkgManager={defaultPkgManager}\n />\n )}\n {!buildFailed && (\n <div className={styles.readme}>\n {isLoading && (\n <ReadmeSkeleton>\n <CompositionGallerySkeleton compositionsLength={Math.min(component.compositions.length, 3)} />\n </ReadmeSkeleton>\n )}\n {!isMinimal && !renderCompositionsFirst ? (\n <>\n <ComponentPreview\n {...previewAttrs}\n onLoad={onPreviewLoad}\n previewName=\"overview\"\n pubsub={true}\n queryParams={[iframeQueryParams, overviewPropsValues?.queryParams || '']}\n viewport={null}\n fullContentHeight\n disableScroll={true}\n sandbox={sandboxValue}\n {...rest}\n component={component}\n style={{ width: '100%', height: '100%', minHeight: !isScaling ? 500 : undefined }}\n />\n {component.preview?.onlyOverview && !isLoading && (\n <CompositionGallery component={component} sandbox={sandboxValue} />\n )}\n </>\n ) : (\n <>\n {component.preview?.onlyOverview && !isLoading && (\n <CompositionGallery component={component} sandbox={sandboxValue} />\n )}\n <ComponentPreview\n {...previewAttrs}\n onLoad={onPreviewLoad}\n previewName=\"overview\"\n pubsub={true}\n queryParams={[iframeQueryParams, overviewPropsValues?.queryParams || '']}\n viewport={null}\n fullContentHeight\n disableScroll={true}\n propagateError={isMinimal}\n sandbox={sandboxValue}\n {...rest}\n component={component}\n style={{ width: '100%', height: '100%', minHeight: !isScaling ? 500 : undefined }}\n />\n </>\n )}\n {component.preview?.onlyOverview && !isLoading && TaggedAPI && (\n <TaggedAPI componentId={component.id.toString()} />\n )}\n </div>\n )}\n {buildFailed && EmptyState && <EmptyState />}\n </div>\n );\n}\n"],"mappings":";;;;;;;AAEA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,uBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAE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A8H,gBAAgB,EAAApG,QAAA,KACXkD,YAAY;IAChBW,MAAM,EAAEG,aAAc;IACtBqC,WAAW,EAAC,UAAU;IACtBC,MAAM,EAAE,IAAK;IACbC,WAAW,EAAE,CAACjD,iBAAiB,EAAEG,mBAAmB,EAAE8C,WAAW,IAAI,EAAE,CAAE;IACzEC,QAAQ,EAAE,IAAK;IACfC,iBAAiB;IACjBC,aAAa,EAAE,IAAK;IACpBO,cAAc,EAAEtE,SAAU;IAC1BgE,OAAO,EAAEvD;EAAa,GAClBW,IAAI;IACR1C,SAAS,EAAEA,SAAU;IACrByC,KAAK,EAAE;MAAE8C,KAAK,EAAE,MAAM;MAAEC,MAAM,EAAE,MAAM;MAAEC,SAAS,EAAE,CAACzE,SAAS,GAAG,GAAG,GAAG0E;IAAU;EAAE,EACnF,CACD,CACH,EACA1F,SAAS,CAACS,OAAO,EAAEyB,YAAY,IAAI,CAACV,SAAS,IAAI3B,SAAS,iBACzDpD,MAAA,GAAAiB,OAAA,CAAAuF,aAAA,CAACpD,SAAS;IAACgG,WAAW,EAAE7F,SAAS,CAAC+C,EAAE,CAACC,QAAQ,CAAC;EAAE,CAAE,CAEjD,CACN,EACApC,WAAW,IAAID,UAAU,iBAAIlE,MAAA,GAAAiB,OAAA,CAAAuF,aAAA,CAACtC,UAAU,MAAE,CACxC,CAAC;AAEV","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Section } from '@teambit/component';
|
|
2
2
|
import type { APIReferenceUI } from '@teambit/api-reference';
|
|
3
3
|
import type { TitleBadgeSlot, OverviewOptionsSlot } from './overview';
|
|
4
|
-
import type { DocsUI, UsePreviewSandboxSlot } from './docs.ui.runtime';
|
|
4
|
+
import type { DocsUI, UsePreviewSandboxSlot, UsePreviewPropsSlot } from './docs.ui.runtime';
|
|
5
5
|
export declare class OverviewSection implements Section {
|
|
6
6
|
/**
|
|
7
7
|
* title badge slot.
|
|
@@ -11,11 +11,12 @@ export declare class OverviewSection implements Section {
|
|
|
11
11
|
private docs;
|
|
12
12
|
private apiRef;
|
|
13
13
|
private usePreviewSandboxSlot;
|
|
14
|
+
private usePreviewPropsSlot;
|
|
14
15
|
constructor(
|
|
15
16
|
/**
|
|
16
17
|
* title badge slot.
|
|
17
18
|
*/
|
|
18
|
-
titleBadgeSlot: TitleBadgeSlot, overviewOptionsSlot: OverviewOptionsSlot, docs: DocsUI, apiRef: APIReferenceUI, usePreviewSandboxSlot: UsePreviewSandboxSlot);
|
|
19
|
+
titleBadgeSlot: TitleBadgeSlot, overviewOptionsSlot: OverviewOptionsSlot, docs: DocsUI, apiRef: APIReferenceUI, usePreviewSandboxSlot: UsePreviewSandboxSlot, usePreviewPropsSlot: UsePreviewPropsSlot);
|
|
19
20
|
navigationLink: {
|
|
20
21
|
href: string;
|
|
21
22
|
exact: boolean;
|
package/dist/overview.section.js
CHANGED
|
@@ -27,12 +27,13 @@ class OverviewSection {
|
|
|
27
27
|
/**
|
|
28
28
|
* title badge slot.
|
|
29
29
|
*/
|
|
30
|
-
titleBadgeSlot, overviewOptionsSlot, docs, apiRef, usePreviewSandboxSlot) {
|
|
30
|
+
titleBadgeSlot, overviewOptionsSlot, docs, apiRef, usePreviewSandboxSlot, usePreviewPropsSlot) {
|
|
31
31
|
this.titleBadgeSlot = titleBadgeSlot;
|
|
32
32
|
this.overviewOptionsSlot = overviewOptionsSlot;
|
|
33
33
|
this.docs = docs;
|
|
34
34
|
this.apiRef = apiRef;
|
|
35
35
|
this.usePreviewSandboxSlot = usePreviewSandboxSlot;
|
|
36
|
+
this.usePreviewPropsSlot = usePreviewPropsSlot;
|
|
36
37
|
_defineProperty(this, "navigationLink", {
|
|
37
38
|
href: '.',
|
|
38
39
|
exact: true,
|
|
@@ -45,7 +46,8 @@ class OverviewSection {
|
|
|
45
46
|
overviewOptions: this.overviewOptionsSlot,
|
|
46
47
|
getEmptyState: this.docs.getEmptyState.bind(this.docs),
|
|
47
48
|
TaggedAPI: this.apiRef.TaggedAPIPage,
|
|
48
|
-
usePreviewSandboxSlot: this.usePreviewSandboxSlot
|
|
49
|
+
usePreviewSandboxSlot: this.usePreviewSandboxSlot,
|
|
50
|
+
usePreviewPropsSlot: this.usePreviewPropsSlot
|
|
49
51
|
})
|
|
50
52
|
});
|
|
51
53
|
_defineProperty(this, "order", 10);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","data","_interopRequireDefault","require","_overview","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","OverviewSection","constructor","titleBadgeSlot","overviewOptionsSlot","docs","apiRef","usePreviewSandboxSlot","href","exact","children","index","element","createElement","Overview","titleBadges","overviewOptions","getEmptyState","bind","TaggedAPI","TaggedAPIPage","exports"],"sources":["overview.section.tsx"],"sourcesContent":["import React from 'react';\nimport type { Section } from '@teambit/component';\nimport type { APIReferenceUI } from '@teambit/api-reference';\nimport type { TitleBadgeSlot, OverviewOptionsSlot } from './overview';\nimport { Overview } from './overview';\nimport type { DocsUI, UsePreviewSandboxSlot } from './docs.ui.runtime';\n\nexport class OverviewSection implements Section {\n constructor(\n /**\n * title badge slot.\n */\n private titleBadgeSlot: TitleBadgeSlot,\n private overviewOptionsSlot: OverviewOptionsSlot,\n private docs: DocsUI,\n private apiRef: APIReferenceUI,\n private usePreviewSandboxSlot: UsePreviewSandboxSlot\n ) {}\n\n navigationLink = {\n href: '.',\n exact: true,\n children: 'Overview',\n };\n\n route = {\n index: true,\n element: (\n <Overview\n titleBadges={this.titleBadgeSlot}\n overviewOptions={this.overviewOptionsSlot}\n getEmptyState={this.docs.getEmptyState.bind(this.docs)}\n TaggedAPI={this.apiRef.TaggedAPIPage}\n usePreviewSandboxSlot={this.usePreviewSandboxSlot}\n />\n ),\n };\n\n order = 10;\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OA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PropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","OverviewSection","constructor","titleBadgeSlot","overviewOptionsSlot","docs","apiRef","usePreviewSandboxSlot","usePreviewPropsSlot","href","exact","children","index","element","createElement","Overview","titleBadges","overviewOptions","getEmptyState","bind","TaggedAPI","TaggedAPIPage","exports"],"sources":["overview.section.tsx"],"sourcesContent":["import React from 'react';\nimport type { Section } from '@teambit/component';\nimport type { APIReferenceUI } from '@teambit/api-reference';\nimport type { TitleBadgeSlot, OverviewOptionsSlot } from './overview';\nimport { Overview } from './overview';\nimport type { DocsUI, UsePreviewSandboxSlot, UsePreviewPropsSlot } from './docs.ui.runtime';\n\nexport class OverviewSection implements Section {\n constructor(\n /**\n * title badge slot.\n */\n private titleBadgeSlot: TitleBadgeSlot,\n private overviewOptionsSlot: OverviewOptionsSlot,\n private docs: DocsUI,\n private apiRef: APIReferenceUI,\n private usePreviewSandboxSlot: UsePreviewSandboxSlot,\n private usePreviewPropsSlot: UsePreviewPropsSlot\n ) {}\n\n navigationLink = {\n href: '.',\n exact: true,\n children: 'Overview',\n };\n\n route = {\n index: true,\n element: (\n <Overview\n titleBadges={this.titleBadgeSlot}\n overviewOptions={this.overviewOptionsSlot}\n getEmptyState={this.docs.getEmptyState.bind(this.docs)}\n TaggedAPI={this.apiRef.TaggedAPIPage}\n usePreviewSandboxSlot={this.usePreviewSandboxSlot}\n usePreviewPropsSlot={this.usePreviewPropsSlot}\n />\n ),\n };\n\n order = 10;\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIA,SAAAG,UAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IA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I,EAAE,GAAG;MACTC,KAAK,EAAE,IAAI;MACXC,QAAQ,EAAE;IACZ,CAAC;IAAA5B,eAAA,gBAEO;MACN6B,KAAK,EAAE,IAAI;MACXC,OAAO,eACLtC,MAAA,GAAAO,OAAA,CAAAgC,aAAA,CAACnC,SAAA,GAAAoC,QAAQ;QACPC,WAAW,EAAE,IAAI,CAACb,cAAe;QACjCc,eAAe,EAAE,IAAI,CAACb,mBAAoB;QAC1Cc,aAAa,EAAE,IAAI,CAACb,IAAI,CAACa,aAAa,CAACC,IAAI,CAAC,IAAI,CAACd,IAAI,CAAE;QACvDe,SAAS,EAAE,IAAI,CAACd,MAAM,CAACe,aAAc;QACrCd,qBAAqB,EAAE,IAAI,CAACA,qBAAsB;QAClDC,mBAAmB,EAAE,IAAI,CAACA;MAAoB,CAC/C;IAEL,CAAC;IAAAzB,eAAA,gBAEO,EAAE;EAtBP;AAuBL;AAACuC,OAAA,CAAArB,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.docs_docs@1.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.docs_docs@1.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.docs_docs@1.0.995/dist/docs.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.docs_docs@1.0.995/dist/docs.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
package/docs.ui.runtime.tsx
CHANGED
|
@@ -10,7 +10,7 @@ import type { ComponentCompareUI } from '@teambit/component-compare';
|
|
|
10
10
|
import { ComponentCompareAspect } from '@teambit/component-compare';
|
|
11
11
|
import { OverviewCompare } from '@teambit/docs.ui.overview-compare';
|
|
12
12
|
import { OverviewCompareSection } from '@teambit/docs.ui.overview-compare-section';
|
|
13
|
-
import type { UseSandboxPermission } from '@teambit/preview.ui.component-preview';
|
|
13
|
+
import type { UsePreviewProps, UseSandboxPermission } from '@teambit/preview.ui.component-preview';
|
|
14
14
|
import type { APIReferenceUI } from '@teambit/api-reference';
|
|
15
15
|
import { APIReferenceAspect } from '@teambit/api-reference';
|
|
16
16
|
import { DocsAspect } from './docs.aspect';
|
|
@@ -18,12 +18,14 @@ import { OverviewSection } from './overview.section';
|
|
|
18
18
|
import type { TitleBadgeSlot, TitleBadge, OverviewOptionsSlot, OverviewOptions } from './overview';
|
|
19
19
|
|
|
20
20
|
export type UsePreviewSandboxSlot = SlotRegistry<UseSandboxPermission>;
|
|
21
|
+
export type UsePreviewPropsSlot = SlotRegistry<UsePreviewProps>;
|
|
21
22
|
|
|
22
23
|
export class DocsUI {
|
|
23
24
|
constructor(
|
|
24
25
|
readonly titleBadgeSlot: TitleBadgeSlot,
|
|
25
26
|
readonly overviewOptionsSlot: OverviewOptionsSlot,
|
|
26
|
-
private usePreviewSandboxSlot: UsePreviewSandboxSlot
|
|
27
|
+
private usePreviewSandboxSlot: UsePreviewSandboxSlot,
|
|
28
|
+
private usePreviewPropsSlot: UsePreviewPropsSlot
|
|
27
29
|
) {}
|
|
28
30
|
|
|
29
31
|
/**
|
|
@@ -52,6 +54,15 @@ export class DocsUI {
|
|
|
52
54
|
this.usePreviewSandboxSlot.register(useSandboxPermission);
|
|
53
55
|
}
|
|
54
56
|
|
|
57
|
+
/**
|
|
58
|
+
* register a per-component resolver for iframe attributes on the overview preview
|
|
59
|
+
* (`allow`, `referrerPolicy`, ...). The resolver runs at render time with the current
|
|
60
|
+
* `ComponentModel`; results from multiple resolvers merge with later keys winning.
|
|
61
|
+
*/
|
|
62
|
+
registerPreviewProps(usePreviewProps: UsePreviewProps) {
|
|
63
|
+
this.usePreviewPropsSlot.register(usePreviewProps);
|
|
64
|
+
}
|
|
65
|
+
|
|
55
66
|
getEmptyState() {
|
|
56
67
|
return this._emptyState;
|
|
57
68
|
}
|
|
@@ -68,19 +79,32 @@ export class DocsUI {
|
|
|
68
79
|
|
|
69
80
|
static runtime = UIRuntime;
|
|
70
81
|
|
|
71
|
-
static slots = [
|
|
82
|
+
static slots = [
|
|
83
|
+
Slot.withType<TitleBadge>(),
|
|
84
|
+
Slot.withType<OverviewOptions>(),
|
|
85
|
+
Slot.withType<UseSandboxPermission>(),
|
|
86
|
+
Slot.withType<UsePreviewProps>(),
|
|
87
|
+
];
|
|
72
88
|
|
|
73
89
|
static async provider(
|
|
74
90
|
[component, componentCompare, apiRef]: [ComponentUI, ComponentCompareUI, APIReferenceUI],
|
|
75
|
-
config,
|
|
76
|
-
[titleBadgeSlot, overviewOptionsSlot, usePreviewSandboxSlot]: [
|
|
91
|
+
config: {},
|
|
92
|
+
[titleBadgeSlot, overviewOptionsSlot, usePreviewSandboxSlot, usePreviewPropsSlot]: [
|
|
77
93
|
TitleBadgeSlot,
|
|
78
94
|
OverviewOptionsSlot,
|
|
79
95
|
UsePreviewSandboxSlot,
|
|
96
|
+
UsePreviewPropsSlot,
|
|
80
97
|
]
|
|
81
98
|
) {
|
|
82
|
-
const docs = new DocsUI(titleBadgeSlot, overviewOptionsSlot, usePreviewSandboxSlot);
|
|
83
|
-
const section = new OverviewSection(
|
|
99
|
+
const docs = new DocsUI(titleBadgeSlot, overviewOptionsSlot, usePreviewSandboxSlot, usePreviewPropsSlot);
|
|
100
|
+
const section = new OverviewSection(
|
|
101
|
+
titleBadgeSlot,
|
|
102
|
+
overviewOptionsSlot,
|
|
103
|
+
docs,
|
|
104
|
+
apiRef,
|
|
105
|
+
usePreviewSandboxSlot,
|
|
106
|
+
usePreviewPropsSlot
|
|
107
|
+
);
|
|
84
108
|
const compareSection = new OverviewCompareSection(docs);
|
|
85
109
|
component.registerRoute(section.route);
|
|
86
110
|
component.registerNavigation(section.navigationLink, section.order);
|
|
@@ -92,6 +116,11 @@ export class DocsUI {
|
|
|
92
116
|
manager.add('allow-same-origin');
|
|
93
117
|
}
|
|
94
118
|
});
|
|
119
|
+
// Default Permissions Policy: allow clipboard writes so copy-to-clipboard buttons in
|
|
120
|
+
// readme MDX work. Clipboard-read, camera, mic, geolocation, etc. remain denied.
|
|
121
|
+
docs.registerPreviewProps((manager) => {
|
|
122
|
+
manager.set('allow', 'clipboard-write');
|
|
123
|
+
});
|
|
95
124
|
return docs;
|
|
96
125
|
}
|
|
97
126
|
}
|
package/overview/overview.tsx
CHANGED
|
@@ -7,13 +7,18 @@ import { flatten } from 'lodash';
|
|
|
7
7
|
// import { LinkedHeading } from '@teambit/documenter.ui.linked-heading';
|
|
8
8
|
import { ComponentContext, useComponentDescriptor } from '@teambit/component';
|
|
9
9
|
import type { SlotRegistry } from '@teambit/harmony';
|
|
10
|
-
import type { ComponentPreviewProps } from '@teambit/preview.ui.component-preview';
|
|
11
|
-
import {
|
|
10
|
+
import type { ComponentPreviewProps, PreviewIframeAttrs } from '@teambit/preview.ui.component-preview';
|
|
11
|
+
import {
|
|
12
|
+
ComponentPreview,
|
|
13
|
+
PreviewPropsAggregator,
|
|
14
|
+
SandboxPermissionsAggregator,
|
|
15
|
+
} from '@teambit/preview.ui.component-preview';
|
|
12
16
|
// import { StatusMessageCard } from '@teambit/design.ui.surfaces.status-message-card';
|
|
13
17
|
import { ComponentOverview } from '@teambit/component.ui.component-meta';
|
|
14
18
|
import { CompositionGallery, CompositionGallerySkeleton } from '@teambit/compositions.panels.composition-gallery';
|
|
15
19
|
import { useWorkspaceMode } from '@teambit/workspace.ui.use-workspace-mode';
|
|
16
20
|
import type { UsePreviewSandboxSlot } from '@teambit/compositions';
|
|
21
|
+
import type { UsePreviewPropsSlot } from '../docs.ui.runtime';
|
|
17
22
|
import { ReadmeSkeleton } from './readme-skeleton';
|
|
18
23
|
import styles from './overview.module.scss';
|
|
19
24
|
|
|
@@ -47,6 +52,12 @@ export type OverviewProps = {
|
|
|
47
52
|
getEmptyState?: () => ComponentType | undefined;
|
|
48
53
|
TaggedAPI?: React.ComponentType<{ componentId: string }>;
|
|
49
54
|
usePreviewSandboxSlot?: UsePreviewSandboxSlot;
|
|
55
|
+
/**
|
|
56
|
+
* per-component resolvers for iframe attributes on the overview preview (`allow`,
|
|
57
|
+
* `referrerPolicy`, ...). Each resolver gets the current `ComponentModel`; results merge
|
|
58
|
+
* with later registrations winning.
|
|
59
|
+
*/
|
|
60
|
+
usePreviewPropsSlot?: UsePreviewPropsSlot;
|
|
50
61
|
};
|
|
51
62
|
|
|
52
63
|
export function Overview({
|
|
@@ -56,6 +67,7 @@ export function Overview({
|
|
|
56
67
|
getEmptyState,
|
|
57
68
|
TaggedAPI,
|
|
58
69
|
usePreviewSandboxSlot,
|
|
70
|
+
usePreviewPropsSlot,
|
|
59
71
|
}: OverviewProps) {
|
|
60
72
|
const component = useContext(ComponentContext);
|
|
61
73
|
const componentDescriptor = useComponentDescriptor();
|
|
@@ -71,6 +83,8 @@ export function Overview({
|
|
|
71
83
|
const { isMinimal } = useWorkspaceMode();
|
|
72
84
|
const [isLoading, setLoading] = useState(defaultLoadingState);
|
|
73
85
|
const previewSandboxHooks = usePreviewSandboxSlot?.values() ?? [];
|
|
86
|
+
const previewPropsHooks = usePreviewPropsSlot?.values() ?? [];
|
|
87
|
+
const [previewAttrs, setPreviewAttrs] = useState<PreviewIframeAttrs>({});
|
|
74
88
|
const [sandboxValue, setSandboxValue] = useState('');
|
|
75
89
|
const iframeQueryParams = `onlyOverview=${component.preview?.onlyOverview || 'false'}&skipIncludes=${
|
|
76
90
|
component.preview?.skipIncludes || component.preview?.onlyOverview
|
|
@@ -106,6 +120,7 @@ export function Overview({
|
|
|
106
120
|
onSandboxChange={setSandboxValue}
|
|
107
121
|
component={component}
|
|
108
122
|
/>
|
|
123
|
+
<PreviewPropsAggregator hooks={previewPropsHooks} onPreviewPropsChange={setPreviewAttrs} component={component} />
|
|
109
124
|
{showHeader && (
|
|
110
125
|
<ComponentOverview
|
|
111
126
|
className={classNames(styles.componentOverviewBlock, !isScaling && styles.legacyPreview)}
|
|
@@ -130,6 +145,7 @@ export function Overview({
|
|
|
130
145
|
{!isMinimal && !renderCompositionsFirst ? (
|
|
131
146
|
<>
|
|
132
147
|
<ComponentPreview
|
|
148
|
+
{...previewAttrs}
|
|
133
149
|
onLoad={onPreviewLoad}
|
|
134
150
|
previewName="overview"
|
|
135
151
|
pubsub={true}
|
|
@@ -152,6 +168,7 @@ export function Overview({
|
|
|
152
168
|
<CompositionGallery component={component} sandbox={sandboxValue} />
|
|
153
169
|
)}
|
|
154
170
|
<ComponentPreview
|
|
171
|
+
{...previewAttrs}
|
|
155
172
|
onLoad={onPreviewLoad}
|
|
156
173
|
previewName="overview"
|
|
157
174
|
pubsub={true}
|
package/overview.section.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import type { Section } from '@teambit/component';
|
|
|
3
3
|
import type { APIReferenceUI } from '@teambit/api-reference';
|
|
4
4
|
import type { TitleBadgeSlot, OverviewOptionsSlot } from './overview';
|
|
5
5
|
import { Overview } from './overview';
|
|
6
|
-
import type { DocsUI, UsePreviewSandboxSlot } from './docs.ui.runtime';
|
|
6
|
+
import type { DocsUI, UsePreviewSandboxSlot, UsePreviewPropsSlot } from './docs.ui.runtime';
|
|
7
7
|
|
|
8
8
|
export class OverviewSection implements Section {
|
|
9
9
|
constructor(
|
|
@@ -14,7 +14,8 @@ export class OverviewSection implements Section {
|
|
|
14
14
|
private overviewOptionsSlot: OverviewOptionsSlot,
|
|
15
15
|
private docs: DocsUI,
|
|
16
16
|
private apiRef: APIReferenceUI,
|
|
17
|
-
private usePreviewSandboxSlot: UsePreviewSandboxSlot
|
|
17
|
+
private usePreviewSandboxSlot: UsePreviewSandboxSlot,
|
|
18
|
+
private usePreviewPropsSlot: UsePreviewPropsSlot
|
|
18
19
|
) {}
|
|
19
20
|
|
|
20
21
|
navigationLink = {
|
|
@@ -32,6 +33,7 @@ export class OverviewSection implements Section {
|
|
|
32
33
|
getEmptyState={this.docs.getEmptyState.bind(this.docs)}
|
|
33
34
|
TaggedAPI={this.apiRef.TaggedAPIPage}
|
|
34
35
|
usePreviewSandboxSlot={this.usePreviewSandboxSlot}
|
|
36
|
+
usePreviewPropsSlot={this.usePreviewPropsSlot}
|
|
35
37
|
/>
|
|
36
38
|
),
|
|
37
39
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/docs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.995",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/docs/docs",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.docs",
|
|
8
8
|
"name": "docs",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.995"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"graphql-tag": "2.12.1",
|
|
@@ -14,31 +14,31 @@
|
|
|
14
14
|
"classnames": "^2.5.1",
|
|
15
15
|
"@teambit/docs.entities.doc": "0.0.12",
|
|
16
16
|
"@teambit/harmony": "0.4.7",
|
|
17
|
-
"@teambit/
|
|
18
|
-
"@teambit/
|
|
17
|
+
"@teambit/cli": "0.0.1327",
|
|
18
|
+
"@teambit/component.sources": "0.0.169",
|
|
19
|
+
"@teambit/legacy.consumer-component": "0.0.118",
|
|
20
|
+
"@teambit/logger": "0.0.1420",
|
|
19
21
|
"@teambit/docs.ui.overview-compare-section": "0.0.102",
|
|
20
22
|
"@teambit/docs.ui.overview-compare": "1.0.12",
|
|
21
23
|
"@teambit/component.ui.component-meta": "0.0.368",
|
|
24
|
+
"@teambit/workspace.ui.use-workspace-mode": "0.0.3",
|
|
22
25
|
"@teambit/base-ui.loaders.skeleton": "1.0.2",
|
|
23
|
-
"@teambit/compiler": "1.0.
|
|
24
|
-
"@teambit/component": "1.0.
|
|
25
|
-
"@teambit/pkg": "1.0.
|
|
26
|
-
"@teambit/workspace": "1.0.
|
|
27
|
-
"@teambit/
|
|
28
|
-
"@teambit/
|
|
29
|
-
"@teambit/
|
|
30
|
-
"@teambit/
|
|
31
|
-
"@teambit/
|
|
32
|
-
"@teambit/
|
|
33
|
-
"@teambit/
|
|
34
|
-
"@teambit/
|
|
35
|
-
"@teambit/
|
|
36
|
-
"@teambit/
|
|
37
|
-
"@teambit/
|
|
38
|
-
"@teambit/
|
|
39
|
-
"@teambit/compositions.panels.composition-gallery": "0.0.226",
|
|
40
|
-
"@teambit/compositions": "1.0.993",
|
|
41
|
-
"@teambit/workspace.ui.use-workspace-mode": "0.0.3"
|
|
26
|
+
"@teambit/compiler": "1.0.995",
|
|
27
|
+
"@teambit/component": "1.0.995",
|
|
28
|
+
"@teambit/pkg": "1.0.995",
|
|
29
|
+
"@teambit/workspace": "1.0.995",
|
|
30
|
+
"@teambit/dev-files": "1.0.995",
|
|
31
|
+
"@teambit/envs": "1.0.995",
|
|
32
|
+
"@teambit/graphql": "1.0.995",
|
|
33
|
+
"@teambit/preview": "1.0.995",
|
|
34
|
+
"@teambit/scope": "1.0.995",
|
|
35
|
+
"@teambit/api-reference": "1.0.995",
|
|
36
|
+
"@teambit/component-compare": "1.0.995",
|
|
37
|
+
"@teambit/preview.ui.component-preview": "1.0.35",
|
|
38
|
+
"@teambit/ui": "1.0.995",
|
|
39
|
+
"@teambit/pubsub": "1.0.995",
|
|
40
|
+
"@teambit/compositions.panels.composition-gallery": "0.0.227",
|
|
41
|
+
"@teambit/compositions": "1.0.995"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/lodash": "4.14.165",
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
"@types/mocha": "9.1.0",
|
|
47
47
|
"@teambit/docs.content.docs-overview": "1.96.8",
|
|
48
48
|
"@teambit/component-id": "1.2.4",
|
|
49
|
-
"@teambit/harmony.envs.core-aspect-env": "0.1.
|
|
49
|
+
"@teambit/harmony.envs.core-aspect-env": "0.1.5"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"react": "^17.0.0 || ^18.0.0",
|
|
53
|
-
"react-dom": "^17.0.0 || ^18.0.0",
|
|
54
|
-
"@types/react": "^
|
|
55
|
-
"@types/react-dom": "^
|
|
52
|
+
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
53
|
+
"react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
54
|
+
"@types/react": "^19.0.0",
|
|
55
|
+
"@types/react-dom": "^19.0.0"
|
|
56
56
|
},
|
|
57
57
|
"license": "Apache-2.0",
|
|
58
58
|
"optionalDependencies": {},
|