@itcase/ui-core 1.9.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/context/Notifications.interface.js +1 -0
- package/dist/cjs/context/Notifications.js +1 -0
- package/dist/cjs/context/UIContext.js +1 -0
- package/dist/cjs/context/UrlAssetPrefix.js +1 -0
- package/dist/cjs/context/index.js +1 -0
- package/dist/cjs/hoc/index.js +1 -0
- package/dist/cjs/hoc/urlWithAssetPrefix.js +1 -0
- package/dist/cjs/hooks/index.js +1 -0
- package/dist/cjs/hooks/useActiveClasses/index.js +1 -0
- package/dist/cjs/hooks/useActiveClasses/useActiveClasses.helpers.js +1 -0
- package/dist/cjs/hooks/useActiveClasses/useActiveClasses.interface.js +1 -0
- package/dist/cjs/hooks/useActiveClasses/useActiveClasses.js +1 -0
- package/dist/cjs/hooks/useAppearanceConfig/index.js +1 -0
- package/dist/cjs/hooks/useAppearanceConfig/useAppearanceConfig.js +1 -0
- package/dist/cjs/hooks/useDevicePropsGenerator/index.js +1 -0
- package/dist/cjs/hooks/useDevicePropsGenerator/useDevicePropsGenerator.interface.js +1 -0
- package/dist/cjs/hooks/useDevicePropsGenerator/useDevicePropsGenerator.js +1 -0
- package/dist/cjs/hooks/useDeviceTargetClass.js +1 -0
- package/dist/cjs/hooks/useDropzoneFieldFiles.js +1 -0
- package/dist/cjs/hooks/useHoldProgress.js +1 -0
- package/dist/cjs/hooks/useMediaQueries/index.js +1 -0
- package/dist/cjs/hooks/useMediaQueries/useMediaQueries.js +1 -0
- package/dist/cjs/hooks/useStyles/index.js +1 -0
- package/dist/cjs/hooks/useStyles/styleAttributes.helpers.js +1 -0
- package/dist/cjs/hooks/useStyles/styleAttributes.interface.js +1 -0
- package/dist/cjs/hooks/useStyles/styleAttributes.js +1 -0
- package/dist/cjs/hooks/useStyles/useStyles.js +1 -0
- package/dist/cjs/hooks/useViewportFix.js +1 -0
- package/dist/cjs/utils/index.js +1 -0
- package/dist/cjs/utils/mergeAppearanceKeys.js +1 -0
- package/dist/cjs/utils/setViewportProperty.js +1 -0
- package/dist/context/Notifications.interface.js +1 -0
- package/dist/context/Notifications.js +1 -0
- package/dist/context/UIContext.js +1 -0
- package/dist/context/UrlAssetPrefix.js +1 -0
- package/dist/context/index.js +1 -0
- package/dist/hoc/index.js +1 -0
- package/dist/hoc/urlWithAssetPrefix.js +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useActiveClasses/index.js +1 -0
- package/dist/hooks/useActiveClasses/useActiveClasses.helpers.js +1 -0
- package/dist/hooks/useActiveClasses/useActiveClasses.interface.js +1 -0
- package/dist/hooks/useActiveClasses/useActiveClasses.js +1 -0
- package/dist/hooks/useAppearanceConfig/index.js +1 -0
- package/dist/hooks/useAppearanceConfig/useAppearanceConfig.js +1 -0
- package/dist/hooks/useDevicePropsGenerator/index.js +1 -0
- package/dist/hooks/useDevicePropsGenerator/useDevicePropsGenerator.interface.js +1 -0
- package/dist/hooks/useDevicePropsGenerator/useDevicePropsGenerator.js +1 -0
- package/dist/hooks/useDeviceTargetClass.js +1 -0
- package/dist/hooks/useDropzoneFieldFiles.js +1 -0
- package/dist/hooks/useHoldProgress.js +1 -0
- package/dist/hooks/useMediaQueries/index.js +1 -0
- package/dist/hooks/useMediaQueries/useMediaQueries.js +1 -0
- package/dist/hooks/useStyles/index.js +1 -0
- package/dist/hooks/useStyles/styleAttributes.helpers.js +1 -0
- package/dist/hooks/useStyles/styleAttributes.interface.js +1 -0
- package/dist/hooks/useStyles/styleAttributes.js +1 -0
- package/dist/hooks/useStyles/useStyles.js +1 -0
- package/dist/hooks/useViewportFix.js +1 -0
- package/dist/stories/useActiveClasses.mdx +134 -0
- package/dist/stories/useAppearanceConfig.mdx +83 -0
- package/dist/stories/useDevicePropsGenerator.mdx +202 -0
- package/dist/stories/useMediaQueries.mdx +80 -0
- package/dist/stories/useStyles.mdx +150 -0
- package/dist/types/context/Notifications.d.ts +21 -0
- package/dist/types/context/Notifications.interface.d.ts +47 -0
- package/dist/types/context/UIContext.d.ts +23 -0
- package/dist/types/context/UrlAssetPrefix.d.ts +12 -0
- package/dist/types/context/index.d.ts +4 -0
- package/dist/types/hoc/index.d.ts +2 -0
- package/dist/types/hoc/urlWithAssetPrefix.d.ts +28 -0
- package/dist/types/hooks/index.d.ts +9 -0
- package/dist/types/hooks/useActiveClasses/index.d.ts +2 -0
- package/dist/types/hooks/useActiveClasses/useActiveClasses.d.ts +3 -0
- package/dist/types/hooks/useActiveClasses/useActiveClasses.helpers.d.ts +5 -0
- package/dist/types/hooks/useActiveClasses/useActiveClasses.interface.d.ts +27 -0
- package/dist/types/hooks/useAppearanceConfig/index.d.ts +1 -0
- package/dist/types/hooks/useAppearanceConfig/useAppearanceConfig.d.ts +5 -0
- package/dist/types/hooks/useDevicePropsGenerator/index.d.ts +2 -0
- package/dist/types/hooks/useDevicePropsGenerator/useDevicePropsGenerator.d.ts +8 -0
- package/dist/types/hooks/useDevicePropsGenerator/useDevicePropsGenerator.interface.d.ts +12 -0
- package/dist/types/hooks/useDeviceTargetClass.d.ts +5 -0
- package/dist/types/hooks/useDropzoneFieldFiles.d.ts +14 -0
- package/dist/types/hooks/useHoldProgress.d.ts +17 -0
- package/dist/types/hooks/useMediaQueries/index.d.ts +1 -0
- package/dist/types/hooks/useMediaQueries/useMediaQueries.d.ts +7 -0
- package/dist/types/hooks/useStyles/index.d.ts +4 -0
- package/dist/types/hooks/useStyles/styleAttributes.d.ts +3 -0
- package/dist/types/hooks/useStyles/styleAttributes.helpers.d.ts +3 -0
- package/dist/types/hooks/useStyles/styleAttributes.interface.d.ts +147 -0
- package/dist/types/hooks/useStyles/useStyles.d.ts +4 -0
- package/dist/types/hooks/useViewportFix.d.ts +2 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/utils.d.ts +43 -0
- package/dist/types/utils/index.d.ts +3 -0
- package/dist/types/utils/mergeAppearanceKeys.d.ts +7 -0
- package/dist/types/utils/setViewportProperty.d.ts +2 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/mergeAppearanceKeys.js +1 -0
- package/dist/utils/setViewportProperty.js +1 -0
- package/package.json +103 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { GeneratedId } from '@itcase/types-core';
|
|
3
|
+
import { statusToAppearanceList } from './Notifications';
|
|
4
|
+
type NotificationAppearance = (typeof statusToAppearanceList)[keyof typeof statusToAppearanceList];
|
|
5
|
+
interface Notification {
|
|
6
|
+
id: GeneratedId;
|
|
7
|
+
_closeTimeout?: ReturnType<typeof setTimeout>;
|
|
8
|
+
after: React.ReactNode;
|
|
9
|
+
appearance?: NotificationAppearance;
|
|
10
|
+
buttonLabel: string;
|
|
11
|
+
closeByTime: number | false;
|
|
12
|
+
closeIcon?: string;
|
|
13
|
+
closeIconAppearance?: string;
|
|
14
|
+
closeIconSrc?: string;
|
|
15
|
+
status: 'error' | 'info' | 'success' | 'warning';
|
|
16
|
+
text: string;
|
|
17
|
+
textColor?: string;
|
|
18
|
+
title: string;
|
|
19
|
+
type?: 'float' | 'global' | 'toast';
|
|
20
|
+
isLoading: boolean;
|
|
21
|
+
onClickButton: React.MouseEventHandler<HTMLButtonElement>;
|
|
22
|
+
onClose?: () => void;
|
|
23
|
+
}
|
|
24
|
+
interface CreatedNotification {
|
|
25
|
+
id?: Notification['id'];
|
|
26
|
+
after?: Notification['after'];
|
|
27
|
+
appearance?: NotificationAppearance;
|
|
28
|
+
buttonLabel?: Notification['buttonLabel'];
|
|
29
|
+
closeByTime?: Notification['closeByTime'];
|
|
30
|
+
closeIcon?: Notification['closeIcon'];
|
|
31
|
+
closeIconAppearance?: Notification['closeIconAppearance'];
|
|
32
|
+
closeIconSrc?: Notification['closeIconSrc'];
|
|
33
|
+
status?: Notification['status'];
|
|
34
|
+
text?: Notification['text'];
|
|
35
|
+
textColor?: Notification['textColor'];
|
|
36
|
+
title?: Notification['title'];
|
|
37
|
+
type?: Notification['type'];
|
|
38
|
+
isLoading?: Notification['isLoading'];
|
|
39
|
+
onClickButton?: Notification['onClickButton'];
|
|
40
|
+
onClose?: Notification['onClose'];
|
|
41
|
+
}
|
|
42
|
+
interface NotificationsProviderProps {
|
|
43
|
+
children: React.ReactNode;
|
|
44
|
+
initialNotificationsList: CreatedNotification[];
|
|
45
|
+
isLogRequestsErrors?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export type { CreatedNotification, Notification, NotificationAppearance, NotificationsProviderProps, };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
type DeviceType = '' | 'desktop' | 'mobile' | 'tablet';
|
|
3
|
+
type UIProviderProps = {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
userDeviceState?: {
|
|
6
|
+
deviceCurrentMainType: DeviceType;
|
|
7
|
+
deviceCurrentType: string;
|
|
8
|
+
deviceTypesList: string[];
|
|
9
|
+
isDesktop?: boolean;
|
|
10
|
+
isMobile?: boolean;
|
|
11
|
+
isTablet?: boolean;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
declare const UIProvider: import("react").NamedExoticComponent<UIProviderProps>;
|
|
15
|
+
declare function useUserDeviceContext(): {
|
|
16
|
+
deviceCurrentMainType: DeviceType;
|
|
17
|
+
deviceCurrentType: string;
|
|
18
|
+
deviceTypesList: string[];
|
|
19
|
+
isDesktop?: boolean;
|
|
20
|
+
isMobile?: boolean;
|
|
21
|
+
isTablet?: boolean;
|
|
22
|
+
};
|
|
23
|
+
export { UIProvider, useUserDeviceContext };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type UrlAssetPrefixValue = {
|
|
2
|
+
assetPrefix?: string;
|
|
3
|
+
ignorePathsList?: Array<string | RegExp>;
|
|
4
|
+
};
|
|
5
|
+
type UrlAssetPrefixProviderProps = {
|
|
6
|
+
assetPrefix?: string;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
ignorePathsList?: Array<string | RegExp>;
|
|
9
|
+
};
|
|
10
|
+
declare const UrlAssetPrefixContext: import("react").Context<UrlAssetPrefixValue>;
|
|
11
|
+
declare function UrlAssetPrefixProvider(props: UrlAssetPrefixProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export { UrlAssetPrefixContext, UrlAssetPrefixProvider };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ComponentType, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from 'react';
|
|
3
|
+
import { RequireAtLeastOneProp, RequireAtLeastOnePropError } from '../types';
|
|
4
|
+
type UrlPropKeys = (typeof urlPropsList)[number];
|
|
5
|
+
type OnePropCheckError = [
|
|
6
|
+
'urlWithAssetPrefix: компонент должен содержать хотя бы один из пропсов',
|
|
7
|
+
UrlPropKeys
|
|
8
|
+
];
|
|
9
|
+
declare const urlPropsList: readonly ["src", "imageSrc", "svgSrc", "placeholderUrl"];
|
|
10
|
+
/**
|
|
11
|
+
* HOC, который добавляет assetPrefix к URL-пропсам.
|
|
12
|
+
*
|
|
13
|
+
* @template P - Тип пропсов оборачиваемого компонента.
|
|
14
|
+
* @template T - Тип ref (если используется forwardRef).
|
|
15
|
+
* @template Check - Проверка на наличие хотя бы одного URL-пропа.
|
|
16
|
+
*
|
|
17
|
+
* @param WrappedComponent - Компонент, который оборачиваем.
|
|
18
|
+
* @param _error - Проверка: если ни одного URL-пропа нет, будет ошибка компиляции.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const A = (props: { src?: string }) => <div />;
|
|
22
|
+
* urlWithAssetPrefix(A); // ✅ OK
|
|
23
|
+
*
|
|
24
|
+
* const B = (props: { id: string }) => <div />;
|
|
25
|
+
* urlWithAssetPrefix(B); // ❌ TS ошибка (нет url-пропов)
|
|
26
|
+
*/
|
|
27
|
+
declare const urlWithAssetPrefix: <P extends Record<string, any>, T = unknown, OnePropCheck extends RequireAtLeastOneProp<P, UrlPropKeys> = RequireAtLeastOneProp<P, UrlPropKeys>>(WrappedComponent: ComponentType<P> | ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>, ..._error: RequireAtLeastOnePropError<OnePropCheck, OnePropCheckError>) => React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<T>>;
|
|
28
|
+
export { urlWithAssetPrefix };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './useActiveClasses';
|
|
2
|
+
export * from './useAppearanceConfig';
|
|
3
|
+
export * from './useDevicePropsGenerator';
|
|
4
|
+
export * from './useDeviceTargetClass';
|
|
5
|
+
export * from './useDropzoneFieldFiles';
|
|
6
|
+
export * from './useHoldProgress';
|
|
7
|
+
export * from './useMediaQueries';
|
|
8
|
+
export * from './useStyles';
|
|
9
|
+
export * from './useViewportFix';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RulesConfig } from './useActiveClasses.interface';
|
|
2
|
+
declare const CLASS_RULES: Record<string, RulesConfig[]>;
|
|
3
|
+
declare const formatState: (key: string) => string;
|
|
4
|
+
declare const toKebabCase: (str: string) => string;
|
|
5
|
+
export { CLASS_RULES, formatState, toKebabCase };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare const suffix: readonly ["Button", "Checkbox", "Radio", "Checkmark", "Avatar", "AvatarStack", "Badge", "Breadcrumbs", "Cell", "Chips", "Choice", "Code", "CookiesWarning", "Dadata", "DatePeriod", "Divider", "Dot", "Drawer", "Dropdown", "DropdownItem", "Flex", "Grid", "Group", "HeroTitle", "HTMLContent", "Icon", "Image", "Input", "InputPassword", "Label", "Link", "List", "Loader", "Logo", "MenuItem", "Modal", "ModalSheetBottom", "Notification", "Overlay", "Pagination", "RangeSlider", "Response", "ScrollBar", "ScrollOnDrag", "ScrollToView", "Search", "Segmented", "Select", "SvgContent", "Swiper", "Switch", "Tab", "Text", "Textarea", "Tile", "Title", "Tooltip", "Video", "Warning"];
|
|
2
|
+
type SuffixComponents = (typeof suffix)[number];
|
|
3
|
+
type SpecialSuffix<T extends string> = T extends 'HTMLContent' ? 'htmlContent' : Uncapitalize<T>;
|
|
4
|
+
type SuffixKeys = SpecialSuffix<SuffixComponents>;
|
|
5
|
+
interface PropsGenerator {
|
|
6
|
+
[key: string]: any | number | string | undefined;
|
|
7
|
+
getProp?: (propKey: string) => number | string | undefined;
|
|
8
|
+
}
|
|
9
|
+
interface UseActiveClassesReturn {
|
|
10
|
+
rootClasses: string;
|
|
11
|
+
suffixClasses: Record<SuffixKeys, string>;
|
|
12
|
+
}
|
|
13
|
+
interface UseActiveClasses {
|
|
14
|
+
propsGenerator: PropsGenerator;
|
|
15
|
+
suffixes?: SuffixComponents[];
|
|
16
|
+
isActive?: boolean;
|
|
17
|
+
isDisabled?: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface RulesConfig {
|
|
20
|
+
key: string;
|
|
21
|
+
stateFn?: (params: {
|
|
22
|
+
isActive?: boolean;
|
|
23
|
+
isDisabled?: boolean;
|
|
24
|
+
}) => boolean;
|
|
25
|
+
}
|
|
26
|
+
export { suffix };
|
|
27
|
+
export type { RulesConfig, SuffixComponents, SuffixKeys, UseActiveClasses, UseActiveClassesReturn, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useAppearanceConfig } from './useAppearanceConfig';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AppearanceConfig } from '../useDevicePropsGenerator';
|
|
2
|
+
declare const useAppearanceConfig: <Keys extends string, Config extends Record<"disabled" | "disabledPrimary" | Keys, AppearanceConfig>>(appearance: string | undefined, componentConfig: {
|
|
3
|
+
appearance?: Partial<Config>;
|
|
4
|
+
}, isDisabled?: boolean) => AppearanceConfig;
|
|
5
|
+
export { useAppearanceConfig };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { KebabCase, WithClassKeys } from '../../types';
|
|
2
|
+
import type { AppearanceConfig, ComponentProps, GeneratorGetClassParams as GP } from './useDevicePropsGenerator.interface';
|
|
3
|
+
declare function useDevicePropsGenerator<Props extends ComponentProps>(componentProps: Props, appearanceConfig?: AppearanceConfig): Props & {
|
|
4
|
+
getProp(propKey: string): number | string | undefined;
|
|
5
|
+
getClassName<K extends keyof Props, P extends GP | undefined = undefined>(propKey: K, params?: P): ReturnGetClassName<Props, K, P>;
|
|
6
|
+
} & WithClassKeys<Props>;
|
|
7
|
+
type ReturnGetClassName<Props, K extends keyof Props, Params = undefined> = Params extends undefined ? NonNullable<Props[K]> extends string ? KebabCase<NonNullable<Props[K]>> : string : Props[K];
|
|
8
|
+
export { useDevicePropsGenerator };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface ComponentProps {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
}
|
|
5
|
+
interface AppearanceConfig {
|
|
6
|
+
[key: string]: boolean | number | object | string | Element | ReactNode | VoidFunction;
|
|
7
|
+
}
|
|
8
|
+
interface GeneratorGetClassParams {
|
|
9
|
+
prefix?: string;
|
|
10
|
+
replace?: [RegExp, string];
|
|
11
|
+
}
|
|
12
|
+
export type { AppearanceConfig, ComponentProps, GeneratorGetClassParams };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DropzoneFieldValuesList, DropzoneFileItem } from '@itcase/ui-web/components/Dropzone';
|
|
2
|
+
/**
|
|
3
|
+
* Hook for file and state management in "react-dropzone".
|
|
4
|
+
* @param {Array} fieldValuesList - value from "react-final-form"
|
|
5
|
+
* @param {boolean} isPreviews - marker for create previews for files
|
|
6
|
+
* @returns {Object} data with states and functions for working with files
|
|
7
|
+
*/
|
|
8
|
+
declare function useDropzoneFieldFiles(fieldValuesList: DropzoneFieldValuesList, isPreviews?: boolean): {
|
|
9
|
+
convertValueFilesToDropzoneItems: (currentFilesList: DropzoneFileItem[] | File[], isSilent?: boolean) => Promise<DropzoneFileItem[]>;
|
|
10
|
+
fileIsLoading: boolean;
|
|
11
|
+
fileRejectedMessage: string;
|
|
12
|
+
setFileRejectedMessage: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
13
|
+
};
|
|
14
|
+
export { useDropzoneFieldFiles };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
declare const HOLD_STATE: {
|
|
3
|
+
readonly HOLDING: "holding";
|
|
4
|
+
readonly IDLE: "idle";
|
|
5
|
+
};
|
|
6
|
+
type HoldStates = (typeof HOLD_STATE)[keyof typeof HOLD_STATE];
|
|
7
|
+
type UseHoldProgressOptions = {
|
|
8
|
+
holdDurationMs?: number;
|
|
9
|
+
isHolding?: boolean;
|
|
10
|
+
onHoldComplete?: () => void;
|
|
11
|
+
};
|
|
12
|
+
declare function useHoldProgress(options: UseHoldProgressOptions): {
|
|
13
|
+
holdState: HoldStates;
|
|
14
|
+
onHoldEnd: (_event?: React.PointerEvent) => void;
|
|
15
|
+
onHoldStart: (event: React.PointerEvent) => void;
|
|
16
|
+
};
|
|
17
|
+
export { useHoldProgress, type UseHoldProgressOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useMediaQueries } from './useMediaQueries';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { StyleAttributeOrValidator } from './styleAttributes.interface';
|
|
2
|
+
declare const getStyleAttributeKey: (targetStyleAttribute: StyleAttributeOrValidator) => 0 | "fill" | "fixed" | import("./styleAttributes.interface").StyleAttributes | "-moz-initial" | "inherit" | "initial" | "revert" | "revert-layer" | "unset" | (string & {}) | "auto" | "fit-content" | "max-content" | "min-content" | "-moz-fit-content" | "-moz-max-content" | "-moz-min-content" | "-webkit-fit-content" | "hug" | "-webkit-max-content" | "intrinsic" | "min-intrinsic";
|
|
3
|
+
export { getStyleAttributeKey };
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import type * as CSS from 'csstype';
|
|
3
|
+
import { HeightProps, ResizeModeProps, WidthProps } from '@itcase/types-ui';
|
|
4
|
+
export interface StyleAttributes {
|
|
5
|
+
/**
|
|
6
|
+
* Layout
|
|
7
|
+
*/
|
|
8
|
+
alignContent?: CSS.Property.AlignContent;
|
|
9
|
+
alignItems?: CSS.Property.AlignItems;
|
|
10
|
+
alignSelf?: CSS.Property.AlignSelf;
|
|
11
|
+
aspectRatio?: CSS.Property.AspectRatio;
|
|
12
|
+
/**
|
|
13
|
+
* Filter
|
|
14
|
+
*/
|
|
15
|
+
backdropFilter?: CSS.Property.BackdropFilter;
|
|
16
|
+
/**
|
|
17
|
+
* View
|
|
18
|
+
*/
|
|
19
|
+
background?: CSS.Property.Background;
|
|
20
|
+
backgroundColor?: CSS.Property.BackgroundColor;
|
|
21
|
+
border?: CSS.Property.Border;
|
|
22
|
+
borderBottomColor?: CSS.Property.BorderColor;
|
|
23
|
+
borderBottomLeftRadius?: CSS.Property.BorderBottomLeftRadius;
|
|
24
|
+
borderBottomRightRadius?: CSS.Property.BorderBottomRightRadius;
|
|
25
|
+
borderBottomWidth?: CSS.Property.BorderBottomWidth;
|
|
26
|
+
borderLeftColor?: CSS.Property.BorderColor;
|
|
27
|
+
borderLeftWidth?: CSS.Property.BorderLeftWidth;
|
|
28
|
+
borderRadius?: CSS.Property.BorderRadius;
|
|
29
|
+
borderRightColor?: CSS.Property.BorderColor;
|
|
30
|
+
borderRightWidth?: CSS.Property.BorderRightWidth;
|
|
31
|
+
borderStyle?: CSS.Property.BorderStyle;
|
|
32
|
+
borderTopColor?: CSS.Property.BorderColor;
|
|
33
|
+
borderTopLeftRadius?: CSS.Property.BorderTopLeftRadius;
|
|
34
|
+
borderTopRightRadius?: CSS.Property.BorderTopRightRadius;
|
|
35
|
+
borderTopWidth?: CSS.Property.BorderTopWidth;
|
|
36
|
+
bottom?: CSS.Property.Bottom;
|
|
37
|
+
/**
|
|
38
|
+
* Text
|
|
39
|
+
*/
|
|
40
|
+
color?: CSS.Property.Color;
|
|
41
|
+
columnGap?: CSS.Property.ColumnGap;
|
|
42
|
+
columnWidth?: CSS.Property.ColumnWidth;
|
|
43
|
+
cursor?: CSS.Property.Cursor;
|
|
44
|
+
display?: CSS.Property.Display;
|
|
45
|
+
flex?: CSS.Property.Flex;
|
|
46
|
+
flexBasis?: CSS.Property.FlexBasis;
|
|
47
|
+
flexDirection?: CSS.Property.FlexDirection;
|
|
48
|
+
flexShrink?: CSS.Property.FlexShrink;
|
|
49
|
+
flexWrap?: CSS.Property.FlexWrap;
|
|
50
|
+
fontFamily?: CSS.Property.FontFamily;
|
|
51
|
+
fontSize?: CSS.Property.FontSize;
|
|
52
|
+
fontStyle?: CSS.Property.FontStyle;
|
|
53
|
+
fontVariant?: CSS.Property.FontVariant;
|
|
54
|
+
fontWeight?: CSS.Property.FontWeight;
|
|
55
|
+
gap?: CSS.Property.Gap;
|
|
56
|
+
/**
|
|
57
|
+
* Grid
|
|
58
|
+
*/
|
|
59
|
+
gridArea?: CSS.Property.GridArea;
|
|
60
|
+
gridAutoColumns?: CSS.Property.GridAutoColumns;
|
|
61
|
+
gridAutoFlow?: CSS.Property.GridAutoFlow;
|
|
62
|
+
gridAutoRows?: CSS.Property.GridAutoRows;
|
|
63
|
+
gridColumn?: CSS.Property.GridColumn;
|
|
64
|
+
gridColumnGap?: CSS.Property.GridColumnGap;
|
|
65
|
+
gridRow?: CSS.Property.GridRow;
|
|
66
|
+
gridRowGap?: CSS.Property.GridRowGap;
|
|
67
|
+
gridTemplate?: CSS.Property.GridTemplate;
|
|
68
|
+
gridTemplateAreas?: CSS.Property.GridTemplateAreas;
|
|
69
|
+
gridTemplateColumns?: CSS.Property.GridTemplateColumns;
|
|
70
|
+
gridTemplateRows?: CSS.Property.GridTemplateRows;
|
|
71
|
+
height?: CSS.Property.Height | HeightProps;
|
|
72
|
+
left?: CSS.Property.Left;
|
|
73
|
+
letterSpacing?: CSS.Property.LetterSpacing;
|
|
74
|
+
lineHeight?: CSS.Property.LineHeight;
|
|
75
|
+
margin?: CSS.Property.Margin;
|
|
76
|
+
marginBottom?: CSS.Property.MarginBottom;
|
|
77
|
+
marginHorizontal?: CSS.Property.Margin;
|
|
78
|
+
marginLeft?: CSS.Property.MarginLeft;
|
|
79
|
+
marginRight?: CSS.Property.MarginRight;
|
|
80
|
+
marginTop?: CSS.Property.MarginTop;
|
|
81
|
+
marginVertical?: CSS.Property.Margin;
|
|
82
|
+
maxHeight?: CSS.Property.MaxHeight;
|
|
83
|
+
maxWidth?: CSS.Property.MaxWidth;
|
|
84
|
+
minHeight?: CSS.Property.MinHeight;
|
|
85
|
+
minWidth?: CSS.Property.MinWidth;
|
|
86
|
+
/**
|
|
87
|
+
* Image
|
|
88
|
+
*/
|
|
89
|
+
objectFit?: CSS.Property.ObjectFit;
|
|
90
|
+
objectPosition?: CSS.Property.ObjectPosition;
|
|
91
|
+
opacity?: CSS.Property.Opacity;
|
|
92
|
+
order?: CSS.Property.Order;
|
|
93
|
+
overflow?: CSS.Property.Overflow;
|
|
94
|
+
overlayColor?: string;
|
|
95
|
+
padding?: CSS.Property.Padding;
|
|
96
|
+
paddingBottom?: CSS.Property.PaddingBottom;
|
|
97
|
+
paddingEnd?: CSS.Property.Padding;
|
|
98
|
+
paddingHorizontal?: CSS.Property.Padding;
|
|
99
|
+
paddingLeft?: CSS.Property.PaddingLeft;
|
|
100
|
+
paddingRight?: CSS.Property.PaddingRight;
|
|
101
|
+
paddingStart?: CSS.Property.Padding;
|
|
102
|
+
paddingTop?: CSS.Property.PaddingTop;
|
|
103
|
+
paddingVertical?: CSS.Property.Padding;
|
|
104
|
+
position?: CSS.Property.Position;
|
|
105
|
+
resizeMode?: ResizeModeProps;
|
|
106
|
+
right?: CSS.Property.Right;
|
|
107
|
+
rowGap?: CSS.Property.RowGap;
|
|
108
|
+
textAlign?: CSS.Property.TextAlign;
|
|
109
|
+
textDecorationColor?: string;
|
|
110
|
+
textDecorationLine?: string;
|
|
111
|
+
textDecorationStyle?: CSS.Property.TextDecorationStyle;
|
|
112
|
+
textTransform?: CSS.Property.TextTransform;
|
|
113
|
+
top?: CSS.Property.Top;
|
|
114
|
+
/**
|
|
115
|
+
* Transform
|
|
116
|
+
*/
|
|
117
|
+
transform?: CSS.Property.Transform;
|
|
118
|
+
verticalAlign?: CSS.Property.VerticalAlign;
|
|
119
|
+
whiteSpace?: CSS.Property.WhiteSpace;
|
|
120
|
+
width?: CSS.Property.Width | WidthProps;
|
|
121
|
+
writingMode?: CSS.Property.WritingMode;
|
|
122
|
+
zIndex?: CSS.Property.ZIndex;
|
|
123
|
+
}
|
|
124
|
+
type WrappedInterface<T> = {
|
|
125
|
+
[P in keyof T as `${P & string}Wrapper`]: T[P];
|
|
126
|
+
};
|
|
127
|
+
type LabelInterface<T> = {
|
|
128
|
+
[P in keyof T as `${P & string}Label`]: T[P];
|
|
129
|
+
};
|
|
130
|
+
type ImageInterface<T> = {
|
|
131
|
+
[P in keyof T as `${P & string}Image`]: T[P];
|
|
132
|
+
};
|
|
133
|
+
export type CSSPropertiesKey = keyof CSSProperties;
|
|
134
|
+
export interface TypeStyleWrapperAttributes extends WrappedInterface<StyleAttributes> {
|
|
135
|
+
}
|
|
136
|
+
export interface TypeStyleLabelAttributes extends LabelInterface<StyleAttributes> {
|
|
137
|
+
}
|
|
138
|
+
export interface TypeStyleImageAttributes extends ImageInterface<StyleAttributes> {
|
|
139
|
+
}
|
|
140
|
+
export type StyleValidator = [
|
|
141
|
+
StyleAttributes['width'],
|
|
142
|
+
{
|
|
143
|
+
validate?: (value: string) => boolean;
|
|
144
|
+
}
|
|
145
|
+
];
|
|
146
|
+
export type StyleAttributeOrValidator = StyleAttributes | StyleValidator;
|
|
147
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './utils';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export type ExactlyOne<K extends PropertyKey, V> = {
|
|
2
|
+
[P in K]: Partial<Record<Exclude<K, P>, never>> & {
|
|
3
|
+
[Q in P]: V;
|
|
4
|
+
};
|
|
5
|
+
}[K];
|
|
6
|
+
export type WithClassKeys<T> = T & {
|
|
7
|
+
[K in keyof T & string as `${K}Class`]: NonNullable<T[K]> extends string ? KebabCase<T[K]> | undefined : string | undefined;
|
|
8
|
+
};
|
|
9
|
+
export type KebabCase<S> = S extends string ? S extends `${infer F}${infer R}` ? R extends Uncapitalize<R> ? `${Lowercase<F>}${KebabCase<R>}` : `${Lowercase<F>}-${KebabCase<Uncapitalize<R>>}` : Lowercase<S> : never;
|
|
10
|
+
/**
|
|
11
|
+
* Проверяет, что у типа `P` есть хотя бы один ключ из списка `Keys`.
|
|
12
|
+
*
|
|
13
|
+
* @template P - Объект, который проверяем (обычно тип пропсов компонента).
|
|
14
|
+
* @template Keys - Набор ключей, хотя бы один из которых должен присутствовать.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* type Props = { id: string; placeholderUrl?: string };
|
|
18
|
+
*
|
|
19
|
+
* type Check1 = RequireAtLeastOneProp<Props, 'src' | 'placeholderUrl'>;
|
|
20
|
+
* // ✅ "placeholderUrl" (совпадение есть)
|
|
21
|
+
*
|
|
22
|
+
* type Check2 = RequireAtLeastOneProp<Props, 'src' | 'imageSrc'>;
|
|
23
|
+
* // ❌ never (совпадений нет)
|
|
24
|
+
*/
|
|
25
|
+
export type RequireAtLeastOneProp<P, Keys> = Extract<keyof P, Keys>;
|
|
26
|
+
/**
|
|
27
|
+
* Выводит типовую ошибку, если в `Check` нет ни одного ключа (равен `never`).
|
|
28
|
+
*
|
|
29
|
+
* @template Check - Результат проверки из `RequireAtLeastOneProp`.
|
|
30
|
+
* @template Error - Текст ошибки, который будет показан в TS.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* type Props = { id: string };
|
|
34
|
+
*
|
|
35
|
+
* type Check = RequireAtLeastOneProp<Props, 'src' | 'imageSrc'>;
|
|
36
|
+
*
|
|
37
|
+
* type ErrorCheck = RequireAtLeastOnePropError<
|
|
38
|
+
* Check,
|
|
39
|
+
* ['Компонент должен содержать хотя бы один из пропсов', 'src' | 'imageSrc']
|
|
40
|
+
* >;
|
|
41
|
+
* // ❌ TS ошибка: ["Компонент должен содержать хотя бы один из пропсов", "src" | "imageSrc"]
|
|
42
|
+
*/
|
|
43
|
+
export type RequireAtLeastOnePropError<Check, Error> = [Check] extends [never] ? Error : [];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type MergeAppearanceKeysReturn = any;
|
|
2
|
+
/**
|
|
3
|
+
* @example
|
|
4
|
+
* mergeAppearanceKeys(' ', '1', undefined, '2', '1') === '1 2'
|
|
5
|
+
*/
|
|
6
|
+
declare const mergeAppearanceKeys: (...appearances: Array<string | undefined>) => MergeAppearanceKeysReturn;
|
|
7
|
+
export { mergeAppearanceKeys };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{mergeAppearanceKeys}from"./mergeAppearanceKeys.js";export{setViewportProperty}from"./setViewportProperty.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const r=(...r)=>{const t=r.map(r=>r?.trim()).filter(Boolean);if(t.length<2)return t[0]??"";return Array.from(new Set(t)).join(" ")};export{r as mergeAppearanceKeys};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=()=>{const e=.01*window.innerHeight;document.documentElement.style.setProperty("--vh",`${e}px`)};export{e as setViewportProperty};
|
package/package.json
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@itcase/ui-core",
|
|
3
|
+
"version": "1.9.77",
|
|
4
|
+
"description": "UI shared components",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Modal",
|
|
7
|
+
"Loader",
|
|
8
|
+
"Popup",
|
|
9
|
+
"CookiesWarning"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"private": false,
|
|
13
|
+
"exports": {
|
|
14
|
+
"./context": {
|
|
15
|
+
"types": "./dist/types/context/index.d.ts",
|
|
16
|
+
"import": "./dist/context/index.js",
|
|
17
|
+
"require": "./dist/cjs/context/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./hoc": {
|
|
20
|
+
"types": "./dist/types/hoc/index.d.ts",
|
|
21
|
+
"import": "./dist/hoc/index.js",
|
|
22
|
+
"require": "./dist/cjs/hoc/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./hooks": {
|
|
25
|
+
"types": "./dist/types/hooks/index.d.ts",
|
|
26
|
+
"import": "./dist/hooks/index.js",
|
|
27
|
+
"require": "./dist/cjs/hooks/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./utils": {
|
|
30
|
+
"types": "./dist/types/utils/index.d.ts",
|
|
31
|
+
"import": "./dist/utils/index.js",
|
|
32
|
+
"require": "./dist/cjs/utils/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./types": {
|
|
35
|
+
"import": "./dist/types/types/index.d.ts",
|
|
36
|
+
"types": "./dist/types/types/index.d.ts"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "npm run build-js",
|
|
41
|
+
"build-js": "rm -rf dist && rollup -c",
|
|
42
|
+
"dev": "npm run dev-js",
|
|
43
|
+
"dev-js": "rollup -c -w",
|
|
44
|
+
"prepack": "NODE_ENV=production npm run build",
|
|
45
|
+
"typecheck": "tsc --noEmit --pretty"
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"./dist"
|
|
49
|
+
],
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "https://github.com/ITCase/itcase-ui.git"
|
|
53
|
+
},
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public",
|
|
56
|
+
"registry": "https://registry.npmjs.org/"
|
|
57
|
+
},
|
|
58
|
+
"msw": {
|
|
59
|
+
"workerDirectory": [
|
|
60
|
+
"public"
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@emotion/is-prop-valid": "^1.4.0",
|
|
65
|
+
"@itcase/common": "^1.2.41",
|
|
66
|
+
"@itcase/storybook-config": "^1.2.44",
|
|
67
|
+
"@itcase/types-ui": "^1.1.33",
|
|
68
|
+
"clsx": "^2.1.1",
|
|
69
|
+
"lodash": "^4.17.23",
|
|
70
|
+
"react": "^18.3.1",
|
|
71
|
+
"react-dom": "^18.3.1",
|
|
72
|
+
"react-responsive": "^10.0.1",
|
|
73
|
+
"uuid": "^13.0.0"
|
|
74
|
+
},
|
|
75
|
+
"devDependencies": {
|
|
76
|
+
"@babel/core": "^7.29.0",
|
|
77
|
+
"@babel/preset-react": "^7.28.5",
|
|
78
|
+
"@itcase/types-core": "^1.1.31",
|
|
79
|
+
"@itcase/types-ui": "^1.1.33",
|
|
80
|
+
"@itcase/ui-web": "1.9.77",
|
|
81
|
+
"@rollup/plugin-alias": "^6.0.0",
|
|
82
|
+
"@rollup/plugin-babel": "^7.0.0",
|
|
83
|
+
"@rollup/plugin-commonjs": "^29.0.1",
|
|
84
|
+
"@rollup/plugin-image": "^3.0.3",
|
|
85
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
86
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
87
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
88
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
89
|
+
"@types/lodash": "^4.17.24",
|
|
90
|
+
"@types/luxon": "^3.7.1",
|
|
91
|
+
"@types/react": "^19",
|
|
92
|
+
"@types/react-dom": "^19.0.2",
|
|
93
|
+
"@types/uuid": "^11.0.0",
|
|
94
|
+
"babel-loader": "^10.0.0",
|
|
95
|
+
"babel-plugin-inline-react-svg": "^2.0.2",
|
|
96
|
+
"rollup": "4.59.0",
|
|
97
|
+
"rollup-plugin-copy": "^3.5.0",
|
|
98
|
+
"rollup-plugin-dts": "^6.3.0",
|
|
99
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
100
|
+
"rollup-preserve-directives": "^1.1.3"
|
|
101
|
+
},
|
|
102
|
+
"gitHead": "742a9b654d9b57ffa4776ff90706af7021263591"
|
|
103
|
+
}
|