@itcase/ui-core 1.10.78 → 1.10.82
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/index.js +14 -0
- package/dist/cjs/context/{UIContext.js → UIProvider/UIProvider.js} +14 -24
- package/dist/cjs/context/UIProvider/index.js +15 -0
- package/dist/cjs/context/UIProviderApp/UIProviderApp.js +20 -0
- package/dist/cjs/context/UIProviderApp/index.js +11 -0
- package/dist/cjs/context/UrlAssetPrefix/index.js +10 -0
- package/dist/cjs/context/UserDeviceContext/UserDeviceContext.helpers.js +16 -0
- package/dist/cjs/context/UserDeviceContext/UserDeviceContext.js +24 -0
- package/dist/cjs/context/UserDeviceContext/index.js +12 -0
- package/dist/cjs/context/index.js +5 -18
- package/dist/cjs/context/index2.js +26 -0
- package/dist/cjs/hoc/index.js +1 -1
- package/dist/cjs/hoc/urlWithAssetPrefix.js +1 -1
- package/dist/cjs/hooks/index.js +8 -14
- package/dist/cjs/hooks/useDevicePropsGenerator/index.js +6 -14
- package/dist/cjs/hooks/useDevicePropsGenerator/useDevicePropsGenerator.js +7 -15
- package/dist/cjs/hooks/useDeviceTargetClass/index.js +10 -0
- package/dist/cjs/hooks/useDeviceTargetClass/useDeviceTargetClass.js +50 -0
- package/dist/cjs/hooks/useStyles/index.js +5 -13
- package/dist/cjs/hooks/useStyles/useStyles.js +6 -14
- package/dist/cjs/hooks/useStylesReactNative/index.js +12 -0
- package/dist/cjs/hooks/useStylesReactNative/styleAttributes.js +137 -0
- package/dist/cjs/hooks/useStylesReactNative/useStyles.js +59 -0
- package/dist/cjs/hooks/useViewportFix/index.js +8 -0
- package/dist/cjs/utils/setViewportProperty.js +3 -0
- package/dist/context/Notifications/index.js +5 -0
- package/dist/context/{UIContext.js → UIProvider/UIProvider.js} +15 -24
- package/dist/context/UIProvider/index.js +9 -0
- package/dist/context/UIProviderApp/UIProviderApp.js +18 -0
- package/dist/context/UIProviderApp/index.js +4 -0
- package/dist/context/UrlAssetPrefix/index.js +3 -0
- package/dist/context/UserDeviceContext/UserDeviceContext.helpers.js +14 -0
- package/dist/context/UserDeviceContext/UserDeviceContext.js +20 -0
- package/dist/context/UserDeviceContext/index.js +3 -0
- package/dist/context/index.js +3 -10
- package/dist/context/index2.js +13 -0
- package/dist/hoc/index.js +1 -1
- package/dist/hoc/urlWithAssetPrefix.js +1 -1
- package/dist/hooks/index.js +8 -14
- package/dist/hooks/useDevicePropsGenerator/index.js +6 -14
- package/dist/hooks/useDevicePropsGenerator/useDevicePropsGenerator.js +6 -14
- package/dist/hooks/useDeviceTargetClass/index.js +4 -0
- package/dist/hooks/useDeviceTargetClass/useDeviceTargetClass.js +48 -0
- package/dist/hooks/useStyles/index.js +5 -13
- package/dist/hooks/useStyles/useStyles.js +5 -13
- package/dist/hooks/useStylesReactNative/index.js +5 -0
- package/dist/hooks/useStylesReactNative/styleAttributes.js +135 -0
- package/dist/hooks/useStylesReactNative/useStyles.js +57 -0
- package/dist/hooks/useViewportFix/index.js +2 -0
- package/dist/stories/useDevicePropsGenerator.mdx +1 -1
- package/dist/types/context/Notifications/index.d.ts +4 -0
- package/dist/types/context/UIProvider/UIProvider.d.ts +3 -0
- package/dist/types/context/UIProvider/UIProvider.interface.d.ts +7 -0
- package/dist/types/context/UIProvider/index.d.ts +4 -0
- package/dist/types/context/UIProviderApp/UIProviderApp.d.ts +3 -0
- package/dist/types/context/UIProviderApp/UIProviderApp.interface.d.ts +5 -0
- package/dist/types/context/UIProviderApp/index.d.ts +6 -0
- package/dist/types/context/{UrlAssetPrefix.d.ts → UrlAssetPrefix/UrlAssetPrefix.d.ts} +1 -9
- package/dist/types/context/UrlAssetPrefix/UrlAssetPrefix.interface.d.ts +11 -0
- package/dist/types/context/UrlAssetPrefix/index.d.ts +4 -0
- package/dist/types/context/UserDeviceContext/UserDeviceContext.d.ts +5 -0
- package/dist/types/context/UserDeviceContext/UserDeviceContext.helpers.d.ts +3 -0
- package/dist/types/context/UserDeviceContext/UserDeviceContext.interface.d.ts +10 -0
- package/dist/types/context/UserDeviceContext/index.d.ts +5 -0
- package/dist/types/context/index.d.ts +10 -4
- package/dist/types/context/index.native.d.ts +4 -0
- package/dist/types/hooks/useDeviceTargetClass/index.d.ts +4 -0
- package/dist/types/hooks/useDeviceTargetClass/useDeviceTargetClass.d.ts +7 -0
- package/dist/types/hooks/useDeviceTargetClass/useDeviceTargetClass.interface.d.ts +9 -0
- package/dist/types/hooks/useStylesReactNative/index.d.ts +6 -0
- package/dist/types/hooks/useStylesReactNative/styleAttributes.d.ts +30 -0
- package/dist/types/hooks/useStylesReactNative/styleAttributes.interface.d.ts +143 -0
- package/dist/types/hooks/useStylesReactNative/useStyles.d.ts +6 -0
- package/dist/types/hooks/useViewportFix/index.d.ts +2 -0
- package/dist/utils/setViewportProperty.js +3 -0
- package/package.json +44 -6
- package/dist/cjs/context/Notifications.interface.js +0 -2
- package/dist/cjs/hooks/useActiveClasses/useActiveClasses.interface.js +0 -65
- package/dist/cjs/hooks/useDevicePropsGenerator/useDevicePropsGenerator.interface.js +0 -2
- package/dist/cjs/hooks/useDeviceTargetClass.js +0 -64
- package/dist/cjs/hooks/useStyles/styleAttributes.interface.js +0 -2
- package/dist/context/Notifications.interface.js +0 -1
- package/dist/hooks/useActiveClasses/useActiveClasses.interface.js +0 -63
- package/dist/hooks/useDevicePropsGenerator/useDevicePropsGenerator.interface.js +0 -1
- package/dist/hooks/useDeviceTargetClass.js +0 -62
- package/dist/hooks/useStyles/styleAttributes.interface.js +0 -1
- package/dist/types/context/UIContext.d.ts +0 -23
- package/dist/types/hooks/useDeviceTargetClass.d.ts +0 -6
- /package/dist/cjs/context/{Notifications.js → Notifications/Notifications.js} +0 -0
- /package/dist/cjs/context/{UrlAssetPrefix.js → UrlAssetPrefix/UrlAssetPrefix.js} +0 -0
- /package/dist/cjs/hooks/{useViewportFix.js → useViewportFix/useViewportFix.js} +0 -0
- /package/dist/context/{Notifications.js → Notifications/Notifications.js} +0 -0
- /package/dist/context/{UrlAssetPrefix.js → UrlAssetPrefix/UrlAssetPrefix.js} +0 -0
- /package/dist/hooks/{useViewportFix.js → useViewportFix/useViewportFix.js} +0 -0
- /package/dist/types/context/{Notifications.d.ts → Notifications/Notifications.d.ts} +0 -0
- /package/dist/types/context/{Notifications.interface.d.ts → Notifications/Notifications.interface.d.ts} +0 -0
- /package/dist/types/hooks/{useViewportFix.d.ts → useViewportFix/useViewportFix.d.ts} +0 -0
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
var camelCase = require('lodash/camelCase');
|
|
5
|
-
var castArray = require('lodash/castArray');
|
|
6
|
-
require('../context/Notifications.js');
|
|
7
|
-
var UIContext = require('../context/UIContext.js');
|
|
8
|
-
require('../context/UrlAssetPrefix.js');
|
|
9
|
-
require('react/jsx-runtime');
|
|
10
|
-
require('uuid');
|
|
11
|
-
require('@itcase/common');
|
|
12
|
-
require('./useMediaQueries/useMediaQueries.js');
|
|
13
|
-
require('react-responsive');
|
|
14
|
-
require('../utils/setViewportProperty.js');
|
|
15
|
-
|
|
16
|
-
/** TODO:
|
|
17
|
-
* Hook is still used in "itcase-forms".
|
|
18
|
-
* Need replace with "useDevicePropsGenerator" and delete this.
|
|
19
|
-
*/
|
|
20
|
-
function useDeviceTargetClass(componentProps, hookProps) {
|
|
21
|
-
/** Generate a class depending on the user's device.
|
|
22
|
-
*
|
|
23
|
-
* Usage:
|
|
24
|
-
* const sizeClass = useDeviceTargetClass(props, {
|
|
25
|
-
* prefix: 'some-item_size_',
|
|
26
|
-
* propsKey: 'size',
|
|
27
|
-
* })
|
|
28
|
-
* Return: "some-item_size_m" (or "s", or "l", or something else)
|
|
29
|
-
*
|
|
30
|
-
* "componentProps" - "props" from component
|
|
31
|
-
* "hookProps" - special props for generating class
|
|
32
|
-
**/
|
|
33
|
-
const {
|
|
34
|
-
prefix = '',
|
|
35
|
-
propsKey,
|
|
36
|
-
replace = [/([A-Z])/g, '-$1']
|
|
37
|
-
} = hookProps;
|
|
38
|
-
const {
|
|
39
|
-
isMobile,
|
|
40
|
-
isTablet,
|
|
41
|
-
isDesktop
|
|
42
|
-
} = UIContext.useUserDeviceContext();
|
|
43
|
-
const targetClassValue = React.useMemo(() => {
|
|
44
|
-
// prettier-ignore
|
|
45
|
-
const deviceCurrentMainType = isMobile && 'Mobile' || isTablet && 'Tablet' || isDesktop && 'Desktop' || '';
|
|
46
|
-
const valueForDevice = componentProps[`${propsKey}${deviceCurrentMainType}`];
|
|
47
|
-
const valueDefault = componentProps[propsKey];
|
|
48
|
-
return valueForDevice || valueDefault;
|
|
49
|
-
}, [isMobile, isTablet, isDesktop, componentProps, propsKey]);
|
|
50
|
-
const targetClass = React.useMemo(() => {
|
|
51
|
-
if (targetClassValue) {
|
|
52
|
-
let cleanClassValue = camelCase(String(targetClassValue));
|
|
53
|
-
if (replace) {
|
|
54
|
-
const replaceList = castArray(replace);
|
|
55
|
-
cleanClassValue = cleanClassValue.replace(replaceList[0], replaceList[1] || '');
|
|
56
|
-
}
|
|
57
|
-
return `${prefix}${cleanClassValue}`.toLowerCase();
|
|
58
|
-
}
|
|
59
|
-
return null;
|
|
60
|
-
}, [targetClassValue, prefix, replace]);
|
|
61
|
-
return targetClass;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
exports.useDeviceTargetClass = useDeviceTargetClass;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
const suffix = [
|
|
2
|
-
'Button',
|
|
3
|
-
'Checkbox',
|
|
4
|
-
'Radio',
|
|
5
|
-
'Checkmark',
|
|
6
|
-
'Avatar',
|
|
7
|
-
'AvatarStack',
|
|
8
|
-
'Badge',
|
|
9
|
-
'Breadcrumbs',
|
|
10
|
-
'Cell',
|
|
11
|
-
'Chips',
|
|
12
|
-
'Choice',
|
|
13
|
-
'Code',
|
|
14
|
-
'CookiesWarning',
|
|
15
|
-
'Dadata',
|
|
16
|
-
'DatePeriod',
|
|
17
|
-
'Divider',
|
|
18
|
-
'Dot',
|
|
19
|
-
'Drawer',
|
|
20
|
-
'Dropdown',
|
|
21
|
-
'DropdownItem',
|
|
22
|
-
'Flex',
|
|
23
|
-
'Grid',
|
|
24
|
-
'Group',
|
|
25
|
-
'HeroTitle',
|
|
26
|
-
'HTMLContent',
|
|
27
|
-
'Icon',
|
|
28
|
-
'Image',
|
|
29
|
-
'Input',
|
|
30
|
-
'InputPassword',
|
|
31
|
-
'Label',
|
|
32
|
-
'Link',
|
|
33
|
-
'List',
|
|
34
|
-
'Loader',
|
|
35
|
-
'Logo',
|
|
36
|
-
'MenuItem',
|
|
37
|
-
'Modal',
|
|
38
|
-
'ModalSheetBottom',
|
|
39
|
-
'Notification',
|
|
40
|
-
'Overlay',
|
|
41
|
-
'Pagination',
|
|
42
|
-
'RangeSlider',
|
|
43
|
-
'Response',
|
|
44
|
-
'ScrollBar',
|
|
45
|
-
'ScrollOnDrag',
|
|
46
|
-
'ScrollToView',
|
|
47
|
-
'Search',
|
|
48
|
-
'Segmented',
|
|
49
|
-
'Select',
|
|
50
|
-
'SvgContent',
|
|
51
|
-
'Swiper',
|
|
52
|
-
'Switch',
|
|
53
|
-
'Tab',
|
|
54
|
-
'Text',
|
|
55
|
-
'Textarea',
|
|
56
|
-
'Tile',
|
|
57
|
-
'Title',
|
|
58
|
-
'Tooltip',
|
|
59
|
-
'Video',
|
|
60
|
-
'Warning',
|
|
61
|
-
];
|
|
62
|
-
|
|
63
|
-
export { suffix };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import camelCase from 'lodash/camelCase';
|
|
3
|
-
import castArray from 'lodash/castArray';
|
|
4
|
-
import '../context/Notifications.js';
|
|
5
|
-
import { useUserDeviceContext } from '../context/UIContext.js';
|
|
6
|
-
import '../context/UrlAssetPrefix.js';
|
|
7
|
-
import 'react/jsx-runtime';
|
|
8
|
-
import 'uuid';
|
|
9
|
-
import '@itcase/common';
|
|
10
|
-
import './useMediaQueries/useMediaQueries.js';
|
|
11
|
-
import 'react-responsive';
|
|
12
|
-
import '../utils/setViewportProperty.js';
|
|
13
|
-
|
|
14
|
-
/** TODO:
|
|
15
|
-
* Hook is still used in "itcase-forms".
|
|
16
|
-
* Need replace with "useDevicePropsGenerator" and delete this.
|
|
17
|
-
*/
|
|
18
|
-
function useDeviceTargetClass(componentProps, hookProps) {
|
|
19
|
-
/** Generate a class depending on the user's device.
|
|
20
|
-
*
|
|
21
|
-
* Usage:
|
|
22
|
-
* const sizeClass = useDeviceTargetClass(props, {
|
|
23
|
-
* prefix: 'some-item_size_',
|
|
24
|
-
* propsKey: 'size',
|
|
25
|
-
* })
|
|
26
|
-
* Return: "some-item_size_m" (or "s", or "l", or something else)
|
|
27
|
-
*
|
|
28
|
-
* "componentProps" - "props" from component
|
|
29
|
-
* "hookProps" - special props for generating class
|
|
30
|
-
**/
|
|
31
|
-
const {
|
|
32
|
-
prefix = '',
|
|
33
|
-
propsKey,
|
|
34
|
-
replace = [/([A-Z])/g, '-$1']
|
|
35
|
-
} = hookProps;
|
|
36
|
-
const {
|
|
37
|
-
isMobile,
|
|
38
|
-
isTablet,
|
|
39
|
-
isDesktop
|
|
40
|
-
} = useUserDeviceContext();
|
|
41
|
-
const targetClassValue = useMemo(() => {
|
|
42
|
-
// prettier-ignore
|
|
43
|
-
const deviceCurrentMainType = isMobile && 'Mobile' || isTablet && 'Tablet' || isDesktop && 'Desktop' || '';
|
|
44
|
-
const valueForDevice = componentProps[`${propsKey}${deviceCurrentMainType}`];
|
|
45
|
-
const valueDefault = componentProps[propsKey];
|
|
46
|
-
return valueForDevice || valueDefault;
|
|
47
|
-
}, [isMobile, isTablet, isDesktop, componentProps, propsKey]);
|
|
48
|
-
const targetClass = useMemo(() => {
|
|
49
|
-
if (targetClassValue) {
|
|
50
|
-
let cleanClassValue = camelCase(String(targetClassValue));
|
|
51
|
-
if (replace) {
|
|
52
|
-
const replaceList = castArray(replace);
|
|
53
|
-
cleanClassValue = cleanClassValue.replace(replaceList[0], replaceList[1] || '');
|
|
54
|
-
}
|
|
55
|
-
return `${prefix}${cleanClassValue}`.toLowerCase();
|
|
56
|
-
}
|
|
57
|
-
return null;
|
|
58
|
-
}, [targetClassValue, prefix, replace]);
|
|
59
|
-
return targetClass;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export { useDeviceTargetClass };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,23 +0,0 @@
|
|
|
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").MemoExoticComponent<(props: UIProviderProps) => import("react").JSX.Element>;
|
|
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 };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|