@teambit/sidebar 0.0.844 → 0.0.847
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/sidebar.ui.runtime.d.ts +4 -1
- package/dist/sidebar.ui.runtime.js.map +1 -1
- package/dist/ui/side-bar/side-bar.d.ts +4 -4
- package/dist/ui/side-bar/side-bar.js +2 -3
- package/dist/ui/side-bar/side-bar.js.map +1 -1
- package/package-tar/teambit-sidebar-0.0.847.tgz +0 -0
- package/package.json +6 -6
- package/{preview-1662281577904.js → preview-1662694416892.js} +2 -2
- package/sidebar.ui.runtime.tsx +4 -1
- package/ui/side-bar/side-bar.tsx +4 -5
- package/package-tar/teambit-sidebar-0.0.844.tgz +0 -0
|
@@ -6,7 +6,10 @@ import { SideBarProps } from './ui';
|
|
|
6
6
|
export declare type ComponentTypeProps = {
|
|
7
7
|
component: ComponentModel;
|
|
8
8
|
};
|
|
9
|
-
export declare type SidebarItem =
|
|
9
|
+
export declare type SidebarItem = {
|
|
10
|
+
weight?: number;
|
|
11
|
+
component?: ComponentType;
|
|
12
|
+
};
|
|
10
13
|
export declare type SidebarItemSlot = SlotRegistry<SidebarItem[]>;
|
|
11
14
|
export declare type DrawerSlot = SlotRegistry<DrawerType[]>;
|
|
12
15
|
export declare class SidebarUI {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SidebarUI","constructor","drawerSlot","props","registerDrawer","drawer","register","provider","deps","config","UIRuntime","Slot","withType","SidebarAspect","addRuntime"],"sources":["sidebar.ui.runtime.tsx"],"sourcesContent":["import { ComponentModel } from '@teambit/component';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { UIRuntime } from '@teambit/ui';\nimport React, { ComponentType } from 'react';\n\nimport type { DrawerType } from '@teambit/ui-foundation.ui.tree.drawer';\nimport { SidebarAspect } from './sidebar.aspect';\nimport { SideBar, SideBarProps } from './ui';\n\nexport type ComponentTypeProps = {\n component: ComponentModel;\n};\n\nexport type SidebarItem = ComponentType;\n\nexport type SidebarItemSlot = SlotRegistry<SidebarItem[]>;\n\nexport type DrawerSlot = SlotRegistry<DrawerType[]>;\n\nexport class SidebarUI {\n constructor(private drawerSlot: DrawerSlot) {}\n\n /**\n * register a new drawer into the component sidebar.\n */\n registerDrawer(...drawer: DrawerType[]) {\n this.drawerSlot.register(drawer);\n return this;\n }\n\n /**\n * render the sidebar.\n */\n render = (props: Partial<SideBarProps>) => {\n return <SideBar drawerSlot={this.drawerSlot} {...props}></SideBar>;\n };\n\n static runtime = UIRuntime;\n\n static slots = [Slot.withType<DrawerType>()];\n\n static dependencies = [];\n\n static async provider(deps, config, [drawerSlot]: [DrawerSlot]) {\n return new SidebarUI(drawerSlot);\n }\n}\n\nSidebarAspect.addRuntime(SidebarUI);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;
|
|
1
|
+
{"version":3,"names":["SidebarUI","constructor","drawerSlot","props","registerDrawer","drawer","register","provider","deps","config","UIRuntime","Slot","withType","SidebarAspect","addRuntime"],"sources":["sidebar.ui.runtime.tsx"],"sourcesContent":["import { ComponentModel } from '@teambit/component';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { UIRuntime } from '@teambit/ui';\nimport React, { ComponentType } from 'react';\n\nimport type { DrawerType } from '@teambit/ui-foundation.ui.tree.drawer';\nimport { SidebarAspect } from './sidebar.aspect';\nimport { SideBar, SideBarProps } from './ui';\n\nexport type ComponentTypeProps = {\n component: ComponentModel;\n};\n\nexport type SidebarItem = {\n weight?: number,\n component?: ComponentType\n};\n\nexport type SidebarItemSlot = SlotRegistry<SidebarItem[]>;\n\nexport type DrawerSlot = SlotRegistry<DrawerType[]>;\n\nexport class SidebarUI {\n constructor(private drawerSlot: DrawerSlot) {}\n\n /**\n * register a new drawer into the component sidebar.\n */\n registerDrawer(...drawer: DrawerType[]) {\n this.drawerSlot.register(drawer);\n return this;\n }\n\n /**\n * render the sidebar.\n */\n render = (props: Partial<SideBarProps>) => {\n return <SideBar drawerSlot={this.drawerSlot} {...props}></SideBar>;\n };\n\n static runtime = UIRuntime;\n\n static slots = [Slot.withType<DrawerType>()];\n\n static dependencies = [];\n\n static async provider(deps, config, [drawerSlot]: [DrawerSlot]) {\n return new SidebarUI(drawerSlot);\n }\n}\n\nSidebarAspect.addRuntime(SidebarUI);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAeO,MAAMA,SAAN,CAAgB;EACrBC,WAAW,CAASC,UAAT,EAAiC;IAAA,KAAxBA,UAAwB,GAAxBA,UAAwB;IAAA,gDAalCC,KAAD,IAAkC;MACzC,oBAAO,+BAAC,cAAD;QAAS,UAAU,EAAE,KAAKD;MAA1B,GAA0CC,KAA1C,EAAP;IACD,CAf2C;EAAE;EAE9C;AACF;AACA;;;EACEC,cAAc,CAAC,GAAGC,MAAJ,EAA0B;IACtC,KAAKH,UAAL,CAAgBI,QAAhB,CAAyBD,MAAzB;IACA,OAAO,IAAP;EACD;EAED;AACF;AACA;;;EAWuB,aAARE,QAAQ,CAACC,IAAD,EAAOC,MAAP,EAAe,CAACP,UAAD,CAAf,EAA2C;IAC9D,OAAO,IAAIF,SAAJ,CAAcE,UAAd,CAAP;EACD;;AA1BoB;;;gCAAVF,S,aAkBMU,e;gCAlBNV,S,WAoBI,CAACW,eAAA,CAAKC,QAAL,EAAD,C;gCApBJZ,S,kBAsBW,E;;AAOxBa,wBAAA,CAAcC,UAAd,CAAyBd,SAAzB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { DrawerSlot
|
|
1
|
+
import React, { ComponentType } from 'react';
|
|
2
|
+
import { DrawerSlot } from '../../sidebar.ui.runtime';
|
|
3
3
|
export declare type SideBarProps = {
|
|
4
4
|
/**
|
|
5
5
|
* slot of registered drawers.
|
|
@@ -8,9 +8,9 @@ export declare type SideBarProps = {
|
|
|
8
8
|
/**
|
|
9
9
|
* slot of registered items to the main section at the top.
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
items?: ComponentType[];
|
|
12
12
|
} & React.HTMLAttributes<HTMLDivElement>;
|
|
13
13
|
/**
|
|
14
14
|
* side bar component.
|
|
15
15
|
*/
|
|
16
|
-
export declare function SideBar({ drawerSlot,
|
|
16
|
+
export declare function SideBar({ drawerSlot, items, ...rest }: SideBarProps): JSX.Element;
|
|
@@ -101,16 +101,15 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
101
101
|
function SideBar(_ref) {
|
|
102
102
|
let {
|
|
103
103
|
drawerSlot,
|
|
104
|
-
|
|
104
|
+
items = []
|
|
105
105
|
} = _ref,
|
|
106
|
-
rest = (0, _objectWithoutProperties2().default)(_ref, ["drawerSlot", "
|
|
106
|
+
rest = (0, _objectWithoutProperties2().default)(_ref, ["drawerSlot", "items"]);
|
|
107
107
|
const drawers = (0, _lodash().flatten)(drawerSlot.values()).filter(drawer => {
|
|
108
108
|
var _drawer$isHidden;
|
|
109
109
|
|
|
110
110
|
return !(drawer !== null && drawer !== void 0 && (_drawer$isHidden = drawer.isHidden) !== null && _drawer$isHidden !== void 0 && _drawer$isHidden.call(drawer));
|
|
111
111
|
}).sort(sortFn);
|
|
112
112
|
const [openDrawerList, onToggleDrawer] = (0, _react().useState)(drawers.map(drawer => drawer.id));
|
|
113
|
-
const items = (0, _react().useMemo)(() => (0, _lodash().flatten)(itemSlot === null || itemSlot === void 0 ? void 0 : itemSlot.values()), [itemSlot]);
|
|
114
113
|
|
|
115
114
|
const handleDrawerToggle = id => {
|
|
116
115
|
const isDrawerOpen = openDrawerList.includes(id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SideBar","drawerSlot","
|
|
1
|
+
{"version":3,"names":["SideBar","drawerSlot","items","rest","drawers","flatten","values","filter","drawer","isHidden","sort","sortFn","openDrawerList","onToggleDrawer","useState","map","id","handleDrawerToggle","isDrawerOpen","includes","list","concat","styles","sidebar","name","isOpen","classNames","sidebarDrawer","open","widgets","Context","first","second","order"],"sources":["side-bar.tsx"],"sourcesContent":["import React, { useState, ComponentType } from 'react';\nimport { flatten } from 'lodash';\nimport classNames from 'classnames';\nimport { MenuSection } from '@teambit/design.ui.surfaces.menu.section';\nimport { DrawerType, DrawerUI } from '@teambit/ui-foundation.ui.tree.drawer';\nimport { DrawerSlot } from '../../sidebar.ui.runtime';\nimport styles from './side-bar.module.scss';\n\nexport type SideBarProps = {\n /**\n * slot of registered drawers.\n */\n drawerSlot: DrawerSlot;\n /**\n * slot of registered items to the main section at the top.\n */\n items?: ComponentType[];\n} & React.HTMLAttributes<HTMLDivElement>;\n\n/**\n * side bar component.\n */\nexport function SideBar({ drawerSlot, items = [], ...rest }: SideBarProps) {\n const drawers = flatten(drawerSlot.values())\n .filter((drawer) => !drawer?.isHidden?.())\n .sort(sortFn);\n\n const [openDrawerList, onToggleDrawer] = useState<(string | undefined)[]>(drawers.map((drawer) => drawer.id));\n\n const handleDrawerToggle = (id: string) => {\n const isDrawerOpen = openDrawerList.includes(id);\n if (isDrawerOpen) {\n onToggleDrawer((list) => list.filter((drawer) => drawer !== id));\n return;\n }\n onToggleDrawer((list) => list.concat(id));\n };\n\n return (\n <div {...rest} className={styles.sidebar}>\n <MenuSection items={items} />\n {drawers.map((drawer) => {\n if (!drawer || !drawer.name) return null;\n // consider passing collapse all as a prop so each drawer collapses itself\n const isOpen = openDrawerList.includes(drawer.id);\n\n return (\n <DrawerUI\n className={classNames(styles.sidebarDrawer, isOpen && styles.open)}\n isOpen={isOpen}\n onToggle={() => handleDrawerToggle(drawer.id)}\n key={drawer.id}\n name={drawer.name}\n Widgets={drawer.widgets}\n Context={drawer.Context}\n >\n <drawer.render />\n </DrawerUI>\n );\n })}\n </div>\n );\n}\nfunction sortFn(first: DrawerType, second: DrawerType) {\n // 0 - equal\n // <0 - first < second\n // >0 - first > second\n\n return (first.order ?? 0) - (second.order ?? 0);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AAaA;AACA;AACA;AACO,SAASA,OAAT,OAAoE;EAAA,IAAnD;IAAEC,UAAF;IAAcC,KAAK,GAAG;EAAtB,CAAmD;EAAA,IAAtBC,IAAsB;EACzE,MAAMC,OAAO,GAAG,IAAAC,iBAAA,EAAQJ,UAAU,CAACK,MAAX,EAAR,EACbC,MADa,CACLC,MAAD;IAAA;;IAAA,OAAY,EAACA,MAAD,aAACA,MAAD,mCAACA,MAAM,CAAEC,QAAT,6CAAC,sBAAAD,MAAM,CAAP,CAAZ;EAAA,CADM,EAEbE,IAFa,CAERC,MAFQ,CAAhB;EAIA,MAAM,CAACC,cAAD,EAAiBC,cAAjB,IAAmC,IAAAC,iBAAA,EAAiCV,OAAO,CAACW,GAAR,CAAaP,MAAD,IAAYA,MAAM,CAACQ,EAA/B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iBAACD,KAAK,CAACE,KAAP,uDAAgB,CAAhB,sBAAsBD,MAAM,CAACC,KAA7B,yDAAsC,CAAtC,CAAP;AACD"}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/sidebar",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.847",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/ui-foundation/sidebar",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.ui-foundation",
|
|
8
8
|
"name": "sidebar",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.847"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"classnames": "2.2.6",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"@babel/runtime": "7.12.18",
|
|
15
15
|
"core-js": "^3.0.0",
|
|
16
16
|
"@teambit/harmony": "0.3.3",
|
|
17
|
-
"@teambit/
|
|
18
|
-
"@teambit/component": "0.0.844",
|
|
17
|
+
"@teambit/component": "0.0.847",
|
|
19
18
|
"@teambit/ui-foundation.ui.tree.drawer": "0.0.505",
|
|
20
|
-
"@teambit/ui": "0.0.
|
|
19
|
+
"@teambit/ui": "0.0.847",
|
|
20
|
+
"@teambit/design.ui.surfaces.menu.section": "0.0.347"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/react": "^17.0.8",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@types/node": "12.20.4"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@teambit/legacy": "1.0.
|
|
33
|
+
"@teambit/legacy": "1.0.346",
|
|
34
34
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
35
35
|
"react": "^16.8.0 || ^17.0.0"
|
|
36
36
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.ui-foundation_sidebar@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.ui-foundation_sidebar@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.ui-foundation_sidebar@0.0.847/dist/sidebar.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.ui-foundation_sidebar@0.0.847/dist/sidebar.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
package/sidebar.ui.runtime.tsx
CHANGED
|
@@ -11,7 +11,10 @@ export type ComponentTypeProps = {
|
|
|
11
11
|
component: ComponentModel;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export type SidebarItem =
|
|
14
|
+
export type SidebarItem = {
|
|
15
|
+
weight?: number,
|
|
16
|
+
component?: ComponentType
|
|
17
|
+
};
|
|
15
18
|
|
|
16
19
|
export type SidebarItemSlot = SlotRegistry<SidebarItem[]>;
|
|
17
20
|
|
package/ui/side-bar/side-bar.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React, { useState,
|
|
1
|
+
import React, { useState, ComponentType } from 'react';
|
|
2
2
|
import { flatten } from 'lodash';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { MenuSection } from '@teambit/design.ui.surfaces.menu.section';
|
|
5
5
|
import { DrawerType, DrawerUI } from '@teambit/ui-foundation.ui.tree.drawer';
|
|
6
|
-
import { DrawerSlot
|
|
6
|
+
import { DrawerSlot } from '../../sidebar.ui.runtime';
|
|
7
7
|
import styles from './side-bar.module.scss';
|
|
8
8
|
|
|
9
9
|
export type SideBarProps = {
|
|
@@ -14,19 +14,18 @@ export type SideBarProps = {
|
|
|
14
14
|
/**
|
|
15
15
|
* slot of registered items to the main section at the top.
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
items?: ComponentType[];
|
|
18
18
|
} & React.HTMLAttributes<HTMLDivElement>;
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* side bar component.
|
|
22
22
|
*/
|
|
23
|
-
export function SideBar({ drawerSlot,
|
|
23
|
+
export function SideBar({ drawerSlot, items = [], ...rest }: SideBarProps) {
|
|
24
24
|
const drawers = flatten(drawerSlot.values())
|
|
25
25
|
.filter((drawer) => !drawer?.isHidden?.())
|
|
26
26
|
.sort(sortFn);
|
|
27
27
|
|
|
28
28
|
const [openDrawerList, onToggleDrawer] = useState<(string | undefined)[]>(drawers.map((drawer) => drawer.id));
|
|
29
|
-
const items = useMemo(() => flatten(itemSlot?.values()), [itemSlot]);
|
|
30
29
|
|
|
31
30
|
const handleDrawerToggle = (id: string) => {
|
|
32
31
|
const isDrawerOpen = openDrawerList.includes(id);
|
|
Binary file
|