Skip to content
Open
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
441 changes: 437 additions & 4 deletions packages/plasma-core/package-lock.json

Large diffs are not rendered by default.

29 changes: 10 additions & 19 deletions packages/plasma-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,7 @@
"main": "index.js",
"module": "es/index.js",
"types": "index.d.ts",
"files": [
"components",
"hocs",
"hooks",
"mixins",
"tokens",
"types",
"utils",
"index.d.ts",
"index.js",
"es"
],
"files": ["components", "hocs", "hooks", "mixins", "tokens", "types", "utils", "index.d.ts", "index.js", "es"],
"peerDependencies": {
"react": ">=16.13.1",
"react-dom": ">=16.13.1",
Expand Down Expand Up @@ -48,7 +37,8 @@
"styled-components": "5.3.1",
"ts-jest": "27.0.5",
"ts-node": "10.2.1",
"typescript": "3.9.10"
"typescript": "3.9.10",
"typescript-coverage-report": "0.6.4"
},
"publishConfig": {
"access": "public"
Expand All @@ -61,13 +51,14 @@
"build:cjs": "BABEL_ENV=cjs SC_NAMESPACE=plasma babel ./src --out-dir . --source-maps --extensions .ts,.tsx",
"build:esm": "BABEL_ENV=esm SC_NAMESPACE=plasma babel ./src --out-dir ./es --source-maps --extensions .ts,.tsx",
"test": "NODE_ICU_DATA=node_modules/full-icu jest",
"test:watch": "NODE_ICU_DATA=node_modules/full-icu jest --watch"
"test:watch": "NODE_ICU_DATA=node_modules/full-icu jest --watch",
"typescript-coverage": "npx typescript-coverage-report"
},
"contributors": [
"Vasiliy Loginevskiy",
"Виноградов Антон Александрович",
"Зубаиров Фаниль Асхатович"
],
"typeCoverage": {
"ignoreFiles": ["src/**/*component-test.tsx"],
"atLeast": 100
},
"contributors": ["Vasiliy Loginevskiy", "Виноградов Антон Александрович", "Зубаиров Фаниль Асхатович"],
"sideEffects": false,
"dependencies": {
"focus-visible": "5.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/plasma-core/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const ButtonText = styled.span<ButtonIsContentProps>`
* Базовая кнопка.
* @deprecated
*/
export const Button = React.forwardRef<any, any>(
export const Button = React.forwardRef<HTMLButtonElement, StyledButtonProps>(
// eslint-disable-next-line prefer-arrow-callback
function Button(props, ref) {
return <ButtonRoot ref={ref} {...props} />;
Expand Down
4 changes: 2 additions & 2 deletions packages/plasma-core/src/components/Carousel/hooks.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext, useRef, useMemo, useEffect, useCallback } from 'react';
import { useContext, useRef, useMemo, useEffect, useCallback, UIEventHandler } from 'react';
import throttle from 'lodash.throttle';

import { useDebouncedFunction } from '../../hooks';
Expand Down Expand Up @@ -184,7 +184,7 @@ export const useCarousel = ({
/**
* Обработчик скролла на DOM-узел.
*/
const handleScroll = useCallback(
const handleScroll = useCallback<UIEventHandler<HTMLDivElement>>(
(event) => {
detectActiveItem();
onScroll?.(event);
Expand Down
6 changes: 3 additions & 3 deletions packages/plasma-core/src/components/Carousel/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ export const getCalculatedPos = ({
scrollAlign: ScrollAlign;
}) => {
let position = scrollAlign === 'center' ? offset : 0;
let carouselSize;
let itemSize;
let scrollStart;
let carouselSize: number;
let itemSize: number;
let scrollStart: number;

if (!items[index]) {
return position;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export const usePaginationDots = ({ items, index, visibleItems = 7 }: SmartPagin
direction = index > prevIndex.current ? 1 : -1;
}

let start;
let end;
let start: number;
let end: number;

if (direction === 1) {
end = Math.min(Math.max(index + 2, visibleItems), items.length);
Expand Down
10 changes: 5 additions & 5 deletions packages/plasma-core/src/components/Popup/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ export const Popup = memo<PopupProps>(({ disclosure, children, isOpen, trigger,
const popupRef = useRef<HTMLDivElement | null>(null);

const onDocumentClick = useCallback(
(event) => {
(event: MouseEvent) => {
const targetIsRoot = event.target === rootRef.current;
const targetInRoot = rootRef.current?.contains(event.target);
const targetInRoot = rootRef.current?.contains(event.target as Node);

if (!targetIsRoot && !targetInRoot) {
onToggle?.(false);
Expand All @@ -82,11 +82,11 @@ export const Popup = memo<PopupProps>(({ disclosure, children, isOpen, trigger,
[onToggle],
);

const onClick = useCallback(
const onClick = useCallback<React.MouseEventHandler<HTMLDivElement>>(
(event) => {
if (trigger === 'click') {
const targetIsPopup = event.target === popupRef;
const targetInPopup = popupRef.current?.contains(event.target);
const targetIsPopup = event.target === popupRef.current;
const targetInPopup = popupRef.current?.contains(event.target as Node);

if (!targetIsPopup && !targetInPopup) {
onToggle?.(!isOpen);
Expand Down
4 changes: 2 additions & 2 deletions packages/plasma-core/src/components/Skeleton/TextSkeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export const TextSkeleton: React.FC<TextSkeletonProps & React.HTMLAttributes<HTM
...props
}) => (
<StyledTextSkeleton {...props}>
{Array.from(Array(lines), (_, i) => {
let w;
{Array.from(Array(lines), (_: number, i: number) => {
let w: number | string;
if (width) {
w = width;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function createTabsController<T extends HTMLDivElement, P extends TabsCon
return forwardRef<T, P>(function TabsController({ disabled, items, index, onIndexChange, ...rest }, ref) {
const refs = useMemo(() => new TabItemRefs(), []);

const onItemFocus = useCallback(
const onItemFocus = useCallback<React.FocusEventHandler<HTMLButtonElement>>(
(event) => {
const focusIndex = refs.items.findIndex((itemRef) => itemRef.current === event.target);

Expand All @@ -45,7 +45,7 @@ export function createTabsController<T extends HTMLDivElement, P extends TabsCon
(event: KeyboardEvent) => {
const minIndex = 0;
const maxIndex = refs.items.length - 1;
let nextIndex;
let nextIndex: number;

switch (event.keyCode) {
case Keys.end:
Expand Down
2 changes: 1 addition & 1 deletion packages/plasma-core/src/utils/transformStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const hyphenate = (str: string) => (uppercaseCheck.test(str) ? str.replace(upper
* а ключи переводя в kebab-case.
* Подходит для подготовки типографической темы.
*/
export const transformStyles = (styles: object) =>
export const transformStyles = (styles: { [key: string]: string | number }) =>
Object.entries(styles)
.map(([key, value]) => `${hyphenate(key)}: ${value}`)
.join(';');