@prom-ui/core 0.2.0 → 1.0.0-alpha.0
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/Avatar/package.json +1 -1
- package/Backdrop/package.json +1 -1
- package/Body/package.json +1 -1
- package/BodyProvider/package.json +1 -1
- package/Box/cjs/index.development.js +9 -5
- package/Box/cjs/index.development.v2.js +9 -5
- package/Box/cjs/index.production.js +1 -1
- package/Box/cjs/index.production.v2.js +1 -1
- package/Box/index.d.ts +88 -2
- package/Box/package.json +1 -1
- package/Button/package.json +1 -1
- package/ButtonPageUp/package.json +1 -1
- package/Checkbox/package.json +1 -1
- package/Flex/package.json +1 -1
- package/Grid/package.json +1 -1
- package/Icon/package.json +1 -1
- package/Image/package.json +1 -1
- package/ImageEmoji/package.json +1 -1
- package/Input/package.json +1 -1
- package/InputField/package.json +1 -1
- package/KeyPress/cjs/index.development.js +5 -1
- package/KeyPress/cjs/index.development.v2.js +5 -1
- package/KeyPress/cjs/index.production.js +1 -1
- package/KeyPress/cjs/index.production.v2.js +1 -1
- package/KeyPress/index.d.ts +2 -0
- package/KeyPress/package.json +1 -1
- package/Line/package.json +1 -1
- package/Link/package.json +1 -1
- package/List/package.json +1 -1
- package/Media/{context.d.ts → MediaProvider.d.ts} +2 -2
- package/Media/cjs/index.development.js +16 -48
- package/Media/cjs/index.development.v2.js +16 -48
- package/Media/cjs/index.production.js +1 -1
- package/Media/cjs/index.production.v2.js +1 -1
- package/Media/index.d.ts +15 -7
- package/Media/package.json +2 -2
- package/OutsideClick/cjs/index.development.js +5 -1
- package/OutsideClick/cjs/index.development.v2.js +5 -1
- package/OutsideClick/cjs/index.production.js +1 -1
- package/OutsideClick/cjs/index.production.v2.js +1 -1
- package/OutsideClick/index.d.ts +2 -1
- package/OutsideClick/package.json +1 -1
- package/Overlay/package.json +1 -1
- package/Picture/package.json +1 -1
- package/PortableOverlay/package.json +1 -1
- package/Portal/cjs/index.development.js +1 -1
- package/Portal/cjs/index.development.v2.js +1 -1
- package/Portal/cjs/index.production.js +1 -1
- package/Portal/cjs/index.production.v2.js +1 -1
- package/Portal/package.json +1 -1
- package/QRCode/package.json +1 -1
- package/Rating/package.json +1 -1
- package/SafeQuery/package.json +1 -1
- package/Scroll/package.json +1 -1
- package/ScrollControls/package.json +1 -1
- package/SideOverlay/package.json +1 -1
- package/SimpleSlider/package.json +1 -1
- package/Skeleton/package.json +1 -1
- package/Spinner/package.json +1 -1
- package/Text/package.json +1 -1
- package/TextEmoji/package.json +1 -1
- package/Tooltip/package.json +1 -1
- package/Tumbler/package.json +1 -1
- package/package.json +5 -4
- package/useDebounce/cjs/index.development.js +32 -0
- package/useDebounce/cjs/index.development.v2.js +32 -0
- package/useDebounce/cjs/index.production.js +1 -0
- package/useDebounce/cjs/index.production.v2.js +1 -0
- package/useDebounce/index.d.ts +4 -0
- package/useDebounce/index.js +7 -0
- package/useDebounce/index.v2.js +7 -0
- package/useDebounce/package.json +9 -0
- package/useIsMounted/cjs/index.development.js +21 -0
- package/useIsMounted/cjs/index.development.v2.js +21 -0
- package/useIsMounted/cjs/index.production.js +1 -0
- package/useIsMounted/cjs/index.production.v2.js +1 -0
- package/useIsMounted/index.d.ts +4 -0
- package/useIsMounted/index.js +7 -0
- package/useIsMounted/index.v2.js +7 -0
- package/useIsMounted/package.json +9 -0
- package/useKeyPress/cjs/index.development.js +60 -0
- package/useKeyPress/cjs/index.development.v2.js +60 -0
- package/useKeyPress/cjs/index.production.js +1 -0
- package/useKeyPress/cjs/index.production.v2.js +1 -0
- package/useKeyPress/index.d.ts +6 -0
- package/useKeyPress/index.js +7 -0
- package/useKeyPress/index.v2.js +7 -0
- package/useKeyPress/package.json +9 -0
- package/useMedia/cjs/index.development.js +27 -0
- package/useMedia/cjs/index.development.v2.js +27 -0
- package/useMedia/cjs/index.production.js +1 -0
- package/useMedia/cjs/index.production.v2.js +1 -0
- package/useMedia/index.d.ts +21 -0
- package/useMedia/index.js +7 -0
- package/useMedia/index.v2.js +7 -0
- package/useMedia/package.json +12 -0
- package/useOutsideClick/cjs/index.development.js +16 -0
- package/useOutsideClick/cjs/index.development.v2.js +16 -0
- package/useOutsideClick/cjs/index.production.js +1 -0
- package/useOutsideClick/cjs/index.production.v2.js +1 -0
- package/useOutsideClick/index.d.ts +5 -0
- package/useOutsideClick/index.js +7 -0
- package/useOutsideClick/index.v2.js +7 -0
- package/useOutsideClick/package.json +12 -0
- package/usePortal/cjs/index.development.js +85 -0
- package/usePortal/cjs/index.development.v2.js +85 -0
- package/usePortal/cjs/index.production.js +1 -0
- package/usePortal/cjs/index.production.v2.js +1 -0
- package/usePortal/index.d.ts +12 -0
- package/usePortal/index.js +7 -0
- package/usePortal/index.v2.js +7 -0
- package/usePortal/package.json +9 -0
- package/useScrollPosition/cjs/index.development.js +12 -0
- package/useScrollPosition/cjs/index.development.v2.js +12 -0
- package/useScrollPosition/cjs/index.production.js +1 -0
- package/useScrollPosition/cjs/index.production.v2.js +1 -0
- package/useScrollPosition/index.d.ts +5 -0
- package/useScrollPosition/index.js +7 -0
- package/useScrollPosition/index.v2.js +7 -0
- package/useScrollPosition/package.json +12 -0
- package/Media/breakpoints.d.ts +0 -17
- package/Media/useMedia.d.ts +0 -7
package/Box/index.d.ts
CHANGED
|
@@ -1,2 +1,88 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
type AsProp<C extends React.ElementType> = {
|
|
3
|
+
'box-as'?: C;
|
|
4
|
+
};
|
|
5
|
+
type PolymorphicRef<C extends React.ElementType> = React.ComponentPropsWithRef<C>['ref'];
|
|
6
|
+
type PropsToOmit<C extends React.ElementType, P> = keyof (AsProp<C> & P);
|
|
7
|
+
type PolymorphicComponentProp<C extends React.ElementType, Props = {}> = React.PropsWithChildren<Props & AsProp<C>> & Omit<React.ComponentPropsWithoutRef<C>, PropsToOmit<C, Props>>;
|
|
8
|
+
type PolymorphicComponentPropWithRef<C extends React.ElementType, Props = {}> = PolymorphicComponentProp<C, Props> & {
|
|
9
|
+
ref?: PolymorphicRef<C>;
|
|
10
|
+
};
|
|
11
|
+
type EvokitMedia = 'small' | 'medium' | 'large' | 'wide' | 'huge';
|
|
12
|
+
type EvokitMediaSufix<T extends string | number> = T | `${T}` | `${T}@${EvokitMedia}`;
|
|
13
|
+
type EvokitProps<T extends string | number> = T | `${T}` | T[] | `${T}`[] | Partial<Record<`${T}`, boolean>>;
|
|
14
|
+
type BoxThemes = EvokitMediaSufix<'black-100' | 'black-200' | 'black-300' | 'black-400' | 'black-600' | 'black-700' | 'black-800' | 'black-900' | 'green-50' | 'green-500' | 'green-700' | 'red-50' | 'red-100' | 'red-500' | 'violet-50' | 'violet-100' | 'violet-500' | 'violet-700' | 'violet-800' | 'white' | 'yellow-50' | 'yellow-100' | 'yellow-200' | 'yellow-500'>;
|
|
15
|
+
type BoxBorderWidth = EvokitMediaSufix<'none' | 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | '3xl' | '4xl' | '5xl'>;
|
|
16
|
+
type BoxBorderStyle = EvokitMediaSufix<'solid' | 'dotted' | 'dashed'>;
|
|
17
|
+
type BoxAlign = EvokitMediaSufix<'none' | 'left' | 'center' | 'right'>;
|
|
18
|
+
type BoxDisplay = EvokitMediaSufix<'none' | 'none:empty' | 'block' | 'inline-block' | 'inline'>;
|
|
19
|
+
type BoxHeight = EvokitMediaSufix<'auto' | '1-1'>;
|
|
20
|
+
type BoxMargin = EvokitMediaSufix<'none' | 'auto' | 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | '3xl' | '4xl' | '5xl'>;
|
|
21
|
+
type BoxOpacity = EvokitMediaSufix<0 | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 100>;
|
|
22
|
+
type BoxOverflow = EvokitMediaSufix<'auto' | 'hidden' | 'scroll' | 'visible'>;
|
|
23
|
+
type BoxPadding = EvokitMediaSufix<'none' | 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | '3xl' | '4xl' | '5xl'>;
|
|
24
|
+
type BoxPlace = EvokitMediaSufix<'none' | 'top' | 'top-left' | 'top-right' | 'center' | 'center-left' | 'center-right' | 'bottom' | 'bottom-left' | 'bottom-right'>;
|
|
25
|
+
type BoxPosition = EvokitMediaSufix<'static' | 'relative' | 'absolute' | 'fixed' | 'sticky'>;
|
|
26
|
+
type BoxRound = EvokitMediaSufix<'none' | 'full' | 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | '3xl' | '4xl' | '5xl'>;
|
|
27
|
+
type BoxWidth = EvokitMediaSufix<'auto' | `1-${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10}` | `2-${2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10}` | `3-${3 | 4 | 5 | 6 | 7 | 8 | 9 | 10}` | `4-${4 | 5 | 6 | 7 | 8 | 9 | 10}` | `5-${5 | 6 | 7 | 8 | 9 | 10}` | `6-${6 | 7 | 8 | 9 | 10}` | `7-${7 | 8 | 9 | 10}` | `8-${8 | 9 | 10}` | `9-${9 | 10}` | `10-10`>;
|
|
28
|
+
type BoxZIndex = EvokitMediaSufix<'none' | 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | '3xl' | '4xl' | '5xl'>;
|
|
29
|
+
export type BoxProps = {
|
|
30
|
+
'box-align'?: EvokitProps<BoxAlign>;
|
|
31
|
+
'box-background'?: EvokitProps<BoxThemes>;
|
|
32
|
+
'box-border'?: EvokitProps<BoxThemes | `${BoxThemes} ${string}`>;
|
|
33
|
+
/** @ignore */
|
|
34
|
+
'box-border-color'?: EvokitProps<BoxThemes>;
|
|
35
|
+
/** @ignore */
|
|
36
|
+
'box-border-width'?: EvokitProps<BoxBorderWidth>;
|
|
37
|
+
/** @ignore */
|
|
38
|
+
'box-border-style'?: EvokitProps<BoxBorderStyle>;
|
|
39
|
+
'box-display'?: EvokitProps<BoxDisplay>;
|
|
40
|
+
'box-height'?: EvokitProps<BoxHeight>;
|
|
41
|
+
'box-margin'?: EvokitProps<BoxMargin | `${BoxMargin} ${string}`>;
|
|
42
|
+
/** @ignore */
|
|
43
|
+
'box-margin-top'?: EvokitProps<BoxMargin>;
|
|
44
|
+
/** @ignore */
|
|
45
|
+
'box-margin-right'?: EvokitProps<BoxMargin>;
|
|
46
|
+
/** @ignore */
|
|
47
|
+
'box-margin-bottom'?: EvokitProps<BoxMargin>;
|
|
48
|
+
/** @ignore */
|
|
49
|
+
'box-margin-left'?: EvokitProps<BoxMargin>;
|
|
50
|
+
'box-opacity'?: EvokitProps<BoxOpacity>;
|
|
51
|
+
'box-overflow'?: EvokitProps<BoxOverflow | `${BoxOverflow} ${string}`>;
|
|
52
|
+
/** @ignore */
|
|
53
|
+
'box-overflow-x'?: EvokitProps<BoxOverflow>;
|
|
54
|
+
/** @ignore */
|
|
55
|
+
'box-overflow-y'?: EvokitProps<BoxOverflow>;
|
|
56
|
+
'box-padding'?: EvokitProps<BoxPadding | `${BoxPadding} ${string}`>;
|
|
57
|
+
/** @ignore */
|
|
58
|
+
'box-padding-top'?: EvokitProps<BoxPadding>;
|
|
59
|
+
/** @ignore */
|
|
60
|
+
'box-padding-right'?: EvokitProps<BoxPadding>;
|
|
61
|
+
/** @ignore */
|
|
62
|
+
'box-padding-bottom'?: EvokitProps<BoxPadding>;
|
|
63
|
+
/** @ignore */
|
|
64
|
+
'box-padding-left'?: EvokitProps<BoxPadding>;
|
|
65
|
+
'box-place'?: EvokitProps<BoxPlace>;
|
|
66
|
+
'box-position'?: EvokitProps<BoxPosition | `${BoxPosition} ${string}`>;
|
|
67
|
+
'box-round'?: EvokitProps<BoxRound | `${BoxRound} ${string}`>;
|
|
68
|
+
/** @ignore */
|
|
69
|
+
'box-round-top-left'?: EvokitProps<BoxRound>;
|
|
70
|
+
/** @ignore */
|
|
71
|
+
'box-round-top-right'?: EvokitProps<BoxRound>;
|
|
72
|
+
/** @ignore */
|
|
73
|
+
'box-round-bottom-left'?: EvokitProps<BoxRound>;
|
|
74
|
+
/** @ignore */
|
|
75
|
+
'box-round-bottom-right'?: EvokitProps<BoxRound>;
|
|
76
|
+
'box-width'?: EvokitProps<BoxWidth>;
|
|
77
|
+
'box-zindex'?: EvokitProps<BoxZIndex>;
|
|
78
|
+
'box-blackhole'?: EvokitProps<'shadow-hover' | 'product-tile'>;
|
|
79
|
+
};
|
|
80
|
+
export type BoxPropsPolymorphic<C extends React.ElementType> = PolymorphicComponentPropWithRef<C, BoxProps>;
|
|
81
|
+
export type Box = <C extends React.ElementType = 'div'>(props: BoxPropsPolymorphic<C>) => React.ReactElement | null;
|
|
82
|
+
/**
|
|
83
|
+
* Компонент `Box` из библиотеки `evokit` является простым контейнером, который может
|
|
84
|
+
* использоваться для размещения других элементов интерфейса.
|
|
85
|
+
* Он может использоваться как самостоятельный элемент или в качестве родительского элемента для других компонентов.
|
|
86
|
+
*/
|
|
87
|
+
export declare const Box: Box;
|
|
88
|
+
export {};
|
package/Box/package.json
CHANGED
package/Button/package.json
CHANGED
package/Checkbox/package.json
CHANGED
package/Flex/package.json
CHANGED
package/Grid/package.json
CHANGED
package/Icon/package.json
CHANGED
package/Image/package.json
CHANGED
package/ImageEmoji/package.json
CHANGED
package/Input/package.json
CHANGED
package/InputField/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var useKeyPress = require('@prom-ui/
|
|
6
|
+
var useKeyPress = require('@prom-ui/core/useKeyPress');
|
|
7
7
|
|
|
8
8
|
function _interopNamespaceCompat(e) {
|
|
9
9
|
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
@@ -50,4 +50,8 @@ var KeyPress = function (_a) {
|
|
|
50
50
|
return null;
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
+
Object.defineProperty(exports, 'useKeyPress', {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
get: function () { return useKeyPress.useKeyPress; }
|
|
56
|
+
});
|
|
53
57
|
exports.KeyPress = KeyPress;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var useKeyPress = require('@prom-ui/
|
|
6
|
+
var useKeyPress = require('@prom-ui/core/useKeyPress');
|
|
7
7
|
|
|
8
8
|
function _interopNamespaceCompat(e) {
|
|
9
9
|
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
@@ -50,4 +50,8 @@ var KeyPress = function (_a) {
|
|
|
50
50
|
return null;
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
+
Object.defineProperty(exports, 'useKeyPress', {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
get: function () { return useKeyPress.useKeyPress; }
|
|
56
|
+
});
|
|
53
57
|
exports.KeyPress = KeyPress;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("@prom-ui/
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("@prom-ui/core/useKeyPress");function t(e){if(e&&"object"==typeof e&&"default"in e)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var n=t(e),o=function(e){var t=e.code,n=e.onKeyDown,o=e.onKeyUp;return r.useKeyPress(t,n,o),null};Object.defineProperty(exports,"useKeyPress",{enumerable:!0,get:function(){return r.useKeyPress}}),exports.KeyPress=function(e){var r=e.isActive,t=void 0===r||r,u=e.code,c=e.onKeyDown,i=void 0===c?function(){}:c,s=e.onKeyUp,f=void 0===s?function(){}:s;return t?n.createElement(o,{code:u,onKeyDown:i,onKeyUp:f}):null};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("@prom-ui/
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("@prom-ui/core/useKeyPress");function t(e){if(e&&"object"==typeof e&&"default"in e)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var n=t(e),o=function(e){var t=e.code,n=e.onKeyDown,o=e.onKeyUp;return r.useKeyPress(t,n,o),null};Object.defineProperty(exports,"useKeyPress",{enumerable:!0,get:function(){return r.useKeyPress}}),exports.KeyPress=function(e){var r=e.isActive,t=void 0===r||r,u=e.code,c=e.onKeyDown,i=void 0===c?function(){}:c,s=e.onKeyUp,f=void 0===s?function(){}:s;return t?n.createElement(o,{code:u,onKeyDown:i,onKeyUp:f}):null};
|
package/KeyPress/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { useKeyPress } from '@prom-ui/core/useKeyPress';
|
|
2
3
|
export type KeyPressProps = {
|
|
3
4
|
/** Если передать `false` компонент перестанет работать */
|
|
4
5
|
isActive?: boolean;
|
|
@@ -10,3 +11,4 @@ export type KeyPressProps = {
|
|
|
10
11
|
onKeyUp?: (e: KeyboardEvent) => void;
|
|
11
12
|
};
|
|
12
13
|
export declare const KeyPress: React.FC<KeyPressProps>;
|
|
14
|
+
export { useKeyPress };
|
package/KeyPress/package.json
CHANGED
package/Line/package.json
CHANGED
package/Link/package.json
CHANGED
package/List/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { SCREEN_BREAKPOINTS } from '@prom-ui/core/useMedia';
|
|
3
3
|
export type MediaProviderProps = {
|
|
4
4
|
children?: React.ReactNode;
|
|
5
5
|
resetOnMount?: boolean;
|
|
6
|
-
width?:
|
|
6
|
+
width?: keyof typeof SCREEN_BREAKPOINTS;
|
|
7
7
|
};
|
|
8
8
|
export declare const MediaProvider: React.FC<MediaProviderProps>;
|
|
@@ -2,48 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var useMedia = require('@prom-ui/core/useMedia');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var
|
|
7
|
+
var reactResponsive = require('react-responsive');
|
|
8
8
|
|
|
9
9
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
10
10
|
|
|
11
11
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
12
|
-
var PropTypes__default = /*#__PURE__*/_interopDefaultCompat(PropTypes);
|
|
13
|
-
|
|
14
|
-
var MIN_SCREEN_WIDTH = 1;
|
|
15
|
-
var SCREEN_BREAKPOINTS = {
|
|
16
|
-
small: 480,
|
|
17
|
-
medium: 768,
|
|
18
|
-
large: 960,
|
|
19
|
-
wide: 1200,
|
|
20
|
-
huge: 1400
|
|
21
|
-
};
|
|
22
|
-
var SCREEN_BREAKPOINTS_PROXY = new Proxy(SCREEN_BREAKPOINTS, {
|
|
23
|
-
get: function (target, key) {
|
|
24
|
-
if (!target.hasOwnProperty(key)) {
|
|
25
|
-
var keyListStr = JSON.stringify(Object.keys(target));
|
|
26
|
-
throw new Error("Media received unknown width \"".concat(key, "\". You should use one of ").concat(keyListStr));
|
|
27
|
-
}
|
|
28
|
-
return target[key];
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
var getBreakPoint = function (key) {
|
|
32
|
-
// Use proxy in debug mode, to ensure that we are reading only existing breakpoints
|
|
33
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
34
|
-
return SCREEN_BREAKPOINTS_PROXY[key];
|
|
35
|
-
}
|
|
36
|
-
return SCREEN_BREAKPOINTS[key];
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
var useMedia = function (_a) {
|
|
40
|
-
var minWidth = _a.minWidth,
|
|
41
|
-
maxWidth = _a.maxWidth;
|
|
42
|
-
return reactResponsive.useMediaQuery({
|
|
43
|
-
minWidth: minWidth ? getBreakPoint(minWidth) : MIN_SCREEN_WIDTH,
|
|
44
|
-
maxWidth: maxWidth ? getBreakPoint(maxWidth) - 1 : undefined
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
12
|
|
|
48
13
|
var MediaProvider = function (_a) {
|
|
49
14
|
var _b = _a.resetOnMount,
|
|
@@ -51,7 +16,7 @@ var MediaProvider = function (_a) {
|
|
|
51
16
|
width = _a.width,
|
|
52
17
|
children = _a.children;
|
|
53
18
|
var _c = React.useState({
|
|
54
|
-
width: width ?
|
|
19
|
+
width: width ? useMedia.SCREEN_BREAKPOINTS[width] : 1
|
|
55
20
|
}),
|
|
56
21
|
value = _c[0],
|
|
57
22
|
setValue = _c[1];
|
|
@@ -64,20 +29,16 @@ var MediaProvider = function (_a) {
|
|
|
64
29
|
value: value
|
|
65
30
|
}, children);
|
|
66
31
|
};
|
|
67
|
-
// MediaProvider.defaultProps = {
|
|
68
|
-
// resetOnMount: false,
|
|
69
|
-
// };
|
|
70
|
-
MediaProvider.propTypes = {
|
|
71
|
-
resetOnMount: PropTypes__default.default.bool,
|
|
72
|
-
// children: PropTypes.node.isRequired,
|
|
73
|
-
width: PropTypes__default.default.oneOf(['small', 'medium', 'large', 'wide', 'huge'])
|
|
74
|
-
};
|
|
75
32
|
|
|
33
|
+
// PDS core
|
|
34
|
+
/**
|
|
35
|
+
* Компонент отображает соответствующий контент от состояние медиа-запроса и обновляет его при изменении размера окна браузера.
|
|
36
|
+
*/
|
|
76
37
|
var Media = function (_a) {
|
|
77
38
|
var minWidth = _a.minWidth,
|
|
78
39
|
maxWidth = _a.maxWidth,
|
|
79
40
|
children = _a.children;
|
|
80
|
-
var matchMedia = useMedia({
|
|
41
|
+
var matchMedia = useMedia.useMedia({
|
|
81
42
|
minWidth: minWidth,
|
|
82
43
|
maxWidth: maxWidth
|
|
83
44
|
});
|
|
@@ -87,6 +48,13 @@ var Media = function (_a) {
|
|
|
87
48
|
return null;
|
|
88
49
|
};
|
|
89
50
|
|
|
51
|
+
Object.defineProperty(exports, 'SCREEN_BREAKPOINTS', {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () { return useMedia.SCREEN_BREAKPOINTS; }
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(exports, 'useMedia', {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () { return useMedia.useMedia; }
|
|
58
|
+
});
|
|
90
59
|
exports.Media = Media;
|
|
91
60
|
exports.MediaProvider = MediaProvider;
|
|
92
|
-
exports.useMedia = useMedia;
|
|
@@ -2,48 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var useMedia = require('@prom-ui/core/useMedia');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var
|
|
7
|
+
var reactResponsive = require('react-responsive');
|
|
8
8
|
|
|
9
9
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
10
10
|
|
|
11
11
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
12
|
-
var PropTypes__default = /*#__PURE__*/_interopDefaultCompat(PropTypes);
|
|
13
|
-
|
|
14
|
-
var MIN_SCREEN_WIDTH = 1;
|
|
15
|
-
var SCREEN_BREAKPOINTS = {
|
|
16
|
-
small: 480,
|
|
17
|
-
medium: 768,
|
|
18
|
-
large: 960,
|
|
19
|
-
wide: 1200,
|
|
20
|
-
huge: 1400
|
|
21
|
-
};
|
|
22
|
-
var SCREEN_BREAKPOINTS_PROXY = new Proxy(SCREEN_BREAKPOINTS, {
|
|
23
|
-
get: function (target, key) {
|
|
24
|
-
if (!target.hasOwnProperty(key)) {
|
|
25
|
-
var keyListStr = JSON.stringify(Object.keys(target));
|
|
26
|
-
throw new Error("Media received unknown width \"".concat(key, "\". You should use one of ").concat(keyListStr));
|
|
27
|
-
}
|
|
28
|
-
return target[key];
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
var getBreakPoint = function (key) {
|
|
32
|
-
// Use proxy in debug mode, to ensure that we are reading only existing breakpoints
|
|
33
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
34
|
-
return SCREEN_BREAKPOINTS_PROXY[key];
|
|
35
|
-
}
|
|
36
|
-
return SCREEN_BREAKPOINTS[key];
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
var useMedia = function (_a) {
|
|
40
|
-
var minWidth = _a.minWidth,
|
|
41
|
-
maxWidth = _a.maxWidth;
|
|
42
|
-
return reactResponsive.useMediaQuery({
|
|
43
|
-
minWidth: minWidth ? getBreakPoint(minWidth) : MIN_SCREEN_WIDTH,
|
|
44
|
-
maxWidth: maxWidth ? getBreakPoint(maxWidth) - 1 : undefined
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
12
|
|
|
48
13
|
var MediaProvider = function (_a) {
|
|
49
14
|
var _b = _a.resetOnMount,
|
|
@@ -51,7 +16,7 @@ var MediaProvider = function (_a) {
|
|
|
51
16
|
width = _a.width,
|
|
52
17
|
children = _a.children;
|
|
53
18
|
var _c = React.useState({
|
|
54
|
-
width: width ?
|
|
19
|
+
width: width ? useMedia.SCREEN_BREAKPOINTS[width] : 1
|
|
55
20
|
}),
|
|
56
21
|
value = _c[0],
|
|
57
22
|
setValue = _c[1];
|
|
@@ -64,20 +29,16 @@ var MediaProvider = function (_a) {
|
|
|
64
29
|
value: value
|
|
65
30
|
}, children);
|
|
66
31
|
};
|
|
67
|
-
// MediaProvider.defaultProps = {
|
|
68
|
-
// resetOnMount: false,
|
|
69
|
-
// };
|
|
70
|
-
MediaProvider.propTypes = {
|
|
71
|
-
resetOnMount: PropTypes__default.default.bool,
|
|
72
|
-
// children: PropTypes.node.isRequired,
|
|
73
|
-
width: PropTypes__default.default.oneOf(['small', 'medium', 'large', 'wide', 'huge'])
|
|
74
|
-
};
|
|
75
32
|
|
|
33
|
+
// PDS core
|
|
34
|
+
/**
|
|
35
|
+
* Компонент отображает соответствующий контент от состояние медиа-запроса и обновляет его при изменении размера окна браузера.
|
|
36
|
+
*/
|
|
76
37
|
var Media = function (_a) {
|
|
77
38
|
var minWidth = _a.minWidth,
|
|
78
39
|
maxWidth = _a.maxWidth,
|
|
79
40
|
children = _a.children;
|
|
80
|
-
var matchMedia = useMedia({
|
|
41
|
+
var matchMedia = useMedia.useMedia({
|
|
81
42
|
minWidth: minWidth,
|
|
82
43
|
maxWidth: maxWidth
|
|
83
44
|
});
|
|
@@ -87,6 +48,13 @@ var Media = function (_a) {
|
|
|
87
48
|
return null;
|
|
88
49
|
};
|
|
89
50
|
|
|
51
|
+
Object.defineProperty(exports, 'SCREEN_BREAKPOINTS', {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () { return useMedia.SCREEN_BREAKPOINTS; }
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(exports, 'useMedia', {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () { return useMedia.useMedia; }
|
|
58
|
+
});
|
|
90
59
|
exports.Media = Media;
|
|
91
60
|
exports.MediaProvider = MediaProvider;
|
|
92
|
-
exports.useMedia = useMedia;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@prom-ui/core/useMedia"),t=require("react"),r=require("react-responsive");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=i(t);Object.defineProperty(exports,"SCREEN_BREAKPOINTS",{enumerable:!0,get:function(){return e.SCREEN_BREAKPOINTS}}),Object.defineProperty(exports,"useMedia",{enumerable:!0,get:function(){return e.useMedia}}),exports.Media=function(t){var r=t.minWidth,i=t.maxWidth,n=t.children;return e.useMedia({minWidth:r,maxWidth:i})?n:null},exports.MediaProvider=function(i){var u=i.resetOnMount,o=void 0!==u&&u,d=i.width,a=i.children,c=t.useState({width:d?e.SCREEN_BREAKPOINTS[d]:1}),s=c[0],f=c[1];return t.useEffect((function(){o&&f(void 0)}),[]),n.default.createElement(r.Context.Provider,{value:s},a)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@prom-ui/core/useMedia"),t=require("react"),r=require("react-responsive");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=i(t);Object.defineProperty(exports,"SCREEN_BREAKPOINTS",{enumerable:!0,get:function(){return e.SCREEN_BREAKPOINTS}}),Object.defineProperty(exports,"useMedia",{enumerable:!0,get:function(){return e.useMedia}}),exports.Media=function(t){var r=t.minWidth,i=t.maxWidth,n=t.children;return e.useMedia({minWidth:r,maxWidth:i})?n:null},exports.MediaProvider=function(i){var u=i.resetOnMount,o=void 0!==u&&u,d=i.width,a=i.children,c=t.useState({width:d?e.SCREEN_BREAKPOINTS[d]:1}),s=c[0],f=c[1];return t.useEffect((function(){o&&f(void 0)}),[]),n.default.createElement(r.Context.Provider,{value:s},a)};
|
package/Media/index.d.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { MediaProvider } from './context';
|
|
2
|
+
import { useMedia, SCREEN_BREAKPOINTS } from '@prom-ui/core/useMedia';
|
|
3
|
+
export { MediaProvider } from './MediaProvider';
|
|
5
4
|
export type MediaProps = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Аналог CSS медиа правила `@media (min-width: ...)`
|
|
7
|
+
*/
|
|
8
|
+
minWidth?: keyof typeof SCREEN_BREAKPOINTS;
|
|
9
|
+
/**
|
|
10
|
+
* Аналог CSS медиа правила `@media (max-width: ...)`
|
|
11
|
+
*/
|
|
12
|
+
maxWidth?: keyof typeof SCREEN_BREAKPOINTS;
|
|
13
|
+
/** @ignore */
|
|
9
14
|
children?: any;
|
|
10
15
|
};
|
|
11
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Компонент отображает соответствующий контент от состояние медиа-запроса и обновляет его при изменении размера окна браузера.
|
|
18
|
+
*/
|
|
12
19
|
export declare const Media: React.FC<MediaProps>;
|
|
20
|
+
export { useMedia, SCREEN_BREAKPOINTS };
|
package/Media/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prom-ui/core/Media",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"sideEffects": [
|
|
7
7
|
"*.css"
|
|
8
8
|
],
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"react-responsive": "^
|
|
10
|
+
"react-responsive": "^9.0.2"
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var useOutsideClick = require('@prom-ui/
|
|
6
|
+
var useOutsideClick = require('@prom-ui/core/useOutsideClick');
|
|
7
7
|
|
|
8
8
|
function _interopNamespaceCompat(e) {
|
|
9
9
|
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
@@ -78,4 +78,8 @@ var OutsideClick = function (_a) {
|
|
|
78
78
|
}), children);
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
+
Object.defineProperty(exports, 'useOutsideClick', {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () { return useOutsideClick.useOutsideClick; }
|
|
84
|
+
});
|
|
81
85
|
exports.OutsideClick = OutsideClick;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var useOutsideClick = require('@prom-ui/
|
|
6
|
+
var useOutsideClick = require('@prom-ui/core/useOutsideClick');
|
|
7
7
|
|
|
8
8
|
function _interopNamespaceCompat(e) {
|
|
9
9
|
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
@@ -78,4 +78,8 @@ var OutsideClick = function (_a) {
|
|
|
78
78
|
}), children);
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
+
Object.defineProperty(exports, 'useOutsideClick', {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () { return useOutsideClick.useOutsideClick; }
|
|
84
|
+
});
|
|
81
85
|
exports.OutsideClick = OutsideClick;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@prom-ui/
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@prom-ui/core/useOutsideClick");function r(e){if(e&&"object"==typeof e&&"default"in e)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var n=r(e),i=function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},i.apply(this,arguments)};Object.defineProperty(exports,"useOutsideClick",{enumerable:!0,get:function(){return t.useOutsideClick}}),exports.OutsideClick=function(e){var r=e.children,c=e.isActive,o=void 0===c||c,u=e.onClick,l=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(e,["children","isActive","onClick"]),a=t.useOutsideClick(u)[0];return o?n.createElement("div",i({},l,{ref:a}),r):n.createElement("div",null,r)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@prom-ui/
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@prom-ui/core/useOutsideClick");function r(e){if(e&&"object"==typeof e&&"default"in e)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var n=r(e),i=function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},i.apply(this,arguments)};Object.defineProperty(exports,"useOutsideClick",{enumerable:!0,get:function(){return t.useOutsideClick}}),exports.OutsideClick=function(e){var r=e.children,c=e.isActive,o=void 0===c||c,u=e.onClick,l=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(e,["children","isActive","onClick"]),a=t.useOutsideClick(u)[0];return o?n.createElement("div",i({},l,{ref:a}),r):n.createElement("div",null,r)};
|
package/OutsideClick/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { useOutsideClick } from '@prom-ui/core/useOutsideClick';
|
|
2
3
|
type OutsideClickProps = {
|
|
3
4
|
/** React children */
|
|
4
5
|
children?: React.ReactNode;
|
|
@@ -8,4 +9,4 @@ type OutsideClickProps = {
|
|
|
8
9
|
onClick: () => void;
|
|
9
10
|
};
|
|
10
11
|
export declare const OutsideClick: React.FC<OutsideClickProps>;
|
|
11
|
-
export {};
|
|
12
|
+
export { useOutsideClick };
|