@itcase/ui-core 1.10.77 → 1.10.79
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} +13 -23
- 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 +3 -9
- package/dist/cjs/hooks/useDevicePropsGenerator/index.js +1 -9
- package/dist/cjs/hooks/useDevicePropsGenerator/useDevicePropsGenerator.js +2 -10
- 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 +1 -9
- package/dist/cjs/hooks/useStyles/useStyles.js +2 -10
- 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} +14 -23
- 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 +3 -9
- package/dist/hooks/useDevicePropsGenerator/index.js +1 -9
- package/dist/hooks/useDevicePropsGenerator/useDevicePropsGenerator.js +1 -9
- package/dist/hooks/useDeviceTargetClass/index.js +4 -0
- package/dist/hooks/useDeviceTargetClass/useDeviceTargetClass.js +48 -0
- package/dist/hooks/useStyles/index.js +1 -9
- package/dist/hooks/useStyles/useStyles.js +1 -9
- 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 +42 -4
- 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,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
|