Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: добавлены атомарные экспорты в компаунд-компоненты; #1451

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changeset/funny-oranges-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@alfalab/core-components-file-upload-item': minor
'@alfalab/core-components-list': minor
'@alfalab/core-components-modal': minor
'@alfalab/core-components-pure-cell': minor
'@alfalab/core-components-side-panel': minor
'@alfalab/core-components-tab-bar': minor
'@alfalab/core-components-table': minor
---

- Добавлены атомарные экспорты.
- Компаунд-экспорты помечены как deprecated.
- Добавлено sideEffects: false
1 change: 1 addition & 0 deletions packages/file-upload-item/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"access": "public",
"directory": "dist"
},
"sideEffects": false,
"peerDependencies": {
"react": "^16.9.0 || ^17.0.1 || ^18.0.0"
},
Expand Down
8 changes: 8 additions & 0 deletions packages/file-upload-item/src/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,16 @@ export const FileUploadItemComponent: React.FC<FileUploadItemProps> = ({
</div>
);

/** @deprecated Используйте атомарные импорты */
export const FileUploadItem = Object.assign(FileUploadItemComponent, {
StatusControl,
Content,
Actions,
});

export {
// FileUploadItemComponent - экспорт выше
StatusControl,
Content,
Actions,
};
1 change: 1 addition & 0 deletions packages/list/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"access": "public",
"directory": "dist"
},
"sideEffects": false,
"peerDependencies": {
"react": "^16.9.0 || ^17.0.1 || ^18.0.0"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/list/src/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ const ListComponent: React.FC<ListProps> = ({
);
};

/** @deprecated Используйте атомарные импорты */
export const List = Object.assign(ListComponent, {
Item,
});

export { ListComponent, Item };
1 change: 1 addition & 0 deletions packages/modal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"access": "public",
"directory": "dist"
},
"sideEffects": false,
"dependencies": {
"@alfalab/core-components-base-modal": "^5.8.4",
"@alfalab/core-components-navigation-bar-private": "^0.5.1",
Expand Down
3 changes: 3 additions & 0 deletions packages/modal/src/Component.responsive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ const ModalResponsiveComponent = forwardRef<HTMLDivElement, ModalResponsiveProps
},
);

/** @deprecated Используйте атомарные импорты */
export const ModalResponsive = Object.assign(ModalResponsiveComponent, {
Header,
Content,
Footer,
Controls,
});

export { ModalResponsiveComponent, Header, Content, Footer, Controls };

ModalResponsiveComponent.displayName = 'ModalResponsiveComponent';
16 changes: 14 additions & 2 deletions packages/modal/src/desktop/Component.desktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,21 @@ const ModalDesktopComponent = forwardRef<HTMLDivElement, ModalDesktopProps>((pro
<Modal {...props} ref={ref} view='desktop' />
));

const HeaderCustomType = Header as React.FC<Omit<HeaderProps, 'titleSize' | 'subtitle'>>;
const ControlsCustomType = Controls as React.FC<Omit<ControlsProps, 'mobileLayout'>>;

/** @deprecated Используйте атомарные импорты */
export const ModalDesktop = Object.assign(ModalDesktopComponent, {
Content,
Header: Header as React.FC<Omit<HeaderProps, 'titleSize' | 'subtitle'>>,
Header: HeaderCustomType,
Footer,
Controls: Controls as React.FC<Omit<ControlsProps, 'mobileLayout'>>,
Controls: ControlsCustomType,
});

export {
ModalDesktopComponent,
Content,
HeaderCustomType as Header,
Footer,
ControlsCustomType as Controls,
};
10 changes: 9 additions & 1 deletion packages/modal/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
export { ModalResponsive as Modal } from './Component.responsive';
export {
ModalResponsive as Modal,
ModalResponsiveComponent,
Header,
Content,
Footer,
Controls,
} from './Component.responsive';

export { ModalResponsiveProps as ModalProps } from './typings';
7 changes: 6 additions & 1 deletion packages/modal/src/mobile/Component.mobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ const ModalMobileComponent = forwardRef<HTMLDivElement, ModalMobileProps>((props
<Modal {...props} ref={ref} view='mobile' />
));

const ControlsCustomType = Controls as React.FC<Omit<ControlsProps, 'mobileLayout'>>;

/** @deprecated Используйте атомарные импорты */
export const ModalMobile = Object.assign(ModalMobileComponent, {
Content,
Header,
Footer,
Controls: Controls as React.FC<Omit<ControlsProps, 'mobileLayout'>>,
Controls: ControlsCustomType,
});

export { ModalMobileComponent, Content, Header, Footer, ControlsCustomType as Controls };
1 change: 1 addition & 0 deletions packages/pure-cell/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"access": "public",
"directory": "dist"
},
"sideEffects": false,
"peerDependencies": {
"react": "^16.9.0 || ^17.0.1 || ^18.0.0",
"react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0"
Expand Down
22 changes: 21 additions & 1 deletion packages/pure-cell/src/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,14 @@ const PureCellComponent = forwardRef<HTMLElement, PureCellProps>(
},
);

const FooterTextCustomType = FooterText as React.FC<FooterTextProps>;

/**
* Универсальный конструктор для сборки любой ячейки.
*
* [Макет](https://www.figma.com/file/KlFOLLkKO8rtvvQE3RXuhq/Click-Library?node-id=43525%3A240018)
*
* @deprecated Используйте атомарные импорты
*/
export const PureCell = Object.assign(PureCellComponent, {
Main,
Expand All @@ -233,10 +237,26 @@ export const PureCell = Object.assign(PureCellComponent, {
AmountTitle,
Addon,
Footer,
ExtraSubtitle: FooterText as React.FC<FooterTextProps>,
ExtraSubtitle: FooterTextCustomType,
FooterButton,
Comment,
Category,
});

export {
PureCellComponent,
Main,
Graphics,
Comment,
Text,
Amount,
AmountTitle,
Addon,
Footer,
FooterTextCustomType as ExtraSubtitle,
FooterButton,
Content,
Category,
};

PureCellComponent.displayName = 'PureCellComponent';
18 changes: 17 additions & 1 deletion packages/pure-cell/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
export { PureCell } from './component';
export {
PureCell,
PureCellComponent,
Comment,
Addon,
Amount,
AmountTitle,
Category,
Content,
Footer,
FooterButton,
ExtraSubtitle,
Graphics,
Main,
Text,
} from './component';

export type { PureCellProps } from './component';
16 changes: 14 additions & 2 deletions packages/side-panel/src/Component.responsive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,23 @@ const SidePanelResponsiveComponent = forwardRef<HTMLDivElement, SidePanelRespons
},
);

const ContentGenerated = createResponsive(SidePanelDesktop.Content, SidePanelMobile.Content);
const FooterGenerated = createResponsive(SidePanelDesktop.Footer, SidePanelMobile.Footer);

/** @deprecated Используйте атомарные импорты */
export const SidePanelResponsive = Object.assign(SidePanelResponsiveComponent, {
Header,
Controls,
Content: createResponsive(SidePanelDesktop.Content, SidePanelMobile.Content),
Footer: createResponsive(SidePanelDesktop.Footer, SidePanelMobile.Footer),
Content: ContentGenerated,
Footer: FooterGenerated,
});

export {
SidePanelResponsiveComponent,
Header,
Controls,
ContentGenerated as Content,
FooterGenerated as Footer,
};

SidePanelResponsiveComponent.displayName = 'SidePanelResponsiveComponent';
16 changes: 14 additions & 2 deletions packages/side-panel/src/desktop/Component.desktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,21 @@ const SidePanelDesktopComponent = forwardRef<HTMLDivElement, SidePanelDesktopPro
},
);

const HeaderCustomType = Header as React.FC<Omit<HeaderProps, 'titleSize' | 'subtitle'>>;
const ControlsCustomType = Controls as React.FC<Omit<ControlsProps, 'mobileLayout'>>;

/** @deprecated Используйте атомарные импорты */
export const SidePanelDesktop = Object.assign(SidePanelDesktopComponent, {
Content: ContentDesktop,
Header: Header as React.FC<Omit<HeaderProps, 'titleSize' | 'subtitle'>>,
Header: HeaderCustomType,
Footer: FooterDesktop,
Controls: Controls as React.FC<Omit<ControlsProps, 'mobileLayout'>>,
Controls: ControlsCustomType,
});

export {
SidePanelDesktopComponent,
ContentDesktop as Content,
HeaderCustomType as Header,
FooterDesktop as Footer,
ControlsCustomType as Controls,
};
13 changes: 12 additions & 1 deletion packages/side-panel/src/mobile/Component.mobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,20 @@ const SidePanelMobileComponent = forwardRef<HTMLDivElement, SidePanelMobileProps
},
);

const ControlsCustomType = Controls as React.FC<Omit<ControlsProps, 'mobileLayout'>>;

/** @deprecated Используйте атомарные импорты */
export const SidePanelMobile = Object.assign(SidePanelMobileComponent, {
Content: ContentMobile,
Header,
Footer: FooterMobile,
Controls: Controls as React.FC<Omit<ControlsProps, 'mobileLayout'>>,
Controls: ControlsCustomType,
});

export {
SidePanelMobileComponent,
ContentMobile as Content,
Header,
FooterMobile as Footer,
ControlsCustomType as Controls,
};
1 change: 1 addition & 0 deletions packages/system-message/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Graphic } from './components/graphic';
import { Subtitle } from './components/subtitle';
import { Title } from './components/title';

// TODO уйти от компаунда
export function createCompound<T>(functionComponent: T) {
return Object.assign(functionComponent, {
Graphic,
Expand Down
1 change: 1 addition & 0 deletions packages/tab-bar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"access": "public",
"directory": "dist"
},
"sideEffects": false,
"peerDependencies": {
"react": ">=16.8.0",
"react-dom": ">=16.8.0"
Expand Down
3 changes: 3 additions & 0 deletions packages/tab-bar/src/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,7 @@ const TabBarComponent = forwardRef<HTMLDivElement, TabBarProps>(

TabBarComponent.displayName = 'TabBarComponent';

/** @deprecated Используйте атомарные импорты */
export const TabBar = Object.assign(TabBarComponent, { Tab });

export { TabBarComponent, Tab };
2 changes: 1 addition & 1 deletion packages/tab-bar/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { TabBar } from './Component';
export * from './Component';
export { TabBarProps, TabProps } from './types';
1 change: 1 addition & 0 deletions packages/table/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"access": "public",
"directory": "dist"
},
"sideEffects": false,
"peerDependencies": {
"react": "^16.9.0 || ^17.0.1 || ^18.0.0",
"react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0"
Expand Down
13 changes: 13 additions & 0 deletions packages/table/src/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
TSortableHeadCell,
} from './components';

/** @deprecated Используйте атомарные импорты */
export const Table = Object.assign(TableComponent, {
TBody,
THead,
Expand All @@ -20,3 +21,15 @@ export const Table = Object.assign(TableComponent, {
TExpandableRow,
Pagination,
});

export {
TableComponent,
TBody,
THead,
THeadCell,
TSortableHeadCell,
TCell,
TRow,
TExpandableRow,
Pagination,
};
Loading