@vitus-labs/elements 0.40.0 → 0.41.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/lib/analysis/vitus-labs-elements.browser.js.html +1 -1
- package/lib/analysis/vitus-labs-elements.js.html +1 -1
- package/lib/analysis/vitus-labs-elements.module.js.html +1 -1
- package/lib/analysis/vitus-labs-elements.native.js.html +1 -1
- package/lib/analysis/vitus-labs-elements.umd.js.html +1 -1
- package/lib/analysis/vitus-labs-elements.umd.min.js.html +1 -1
- package/lib/index.d.ts +59 -2
- package/lib/types/helpers/Iterator/types.d.ts +12 -0
- package/lib/types/index.d.ts +2 -1
- package/lib/types/types.d.ts +48 -0
- package/lib/vitus-labs-elements.browser.js +30 -19
- package/lib/vitus-labs-elements.browser.js.map +1 -1
- package/lib/vitus-labs-elements.js +30 -19
- package/lib/vitus-labs-elements.js.map +1 -1
- package/lib/vitus-labs-elements.module.js +30 -19
- package/lib/vitus-labs-elements.module.js.map +1 -1
- package/lib/vitus-labs-elements.native.js +18 -7
- package/lib/vitus-labs-elements.native.js.map +1 -1
- package/lib/vitus-labs-elements.umd.js +30 -19
- package/lib/vitus-labs-elements.umd.js.map +1 -1
- package/lib/vitus-labs-elements.umd.min.js +14 -14
- package/lib/vitus-labs-elements.umd.min.js.map +1 -1
- package/package.json +5 -5
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { Provider } from '@vitus-labs/unistyle';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import React__default, { ComponentType, VFC,
|
|
3
|
+
import React__default, { ForwardedRef, ComponentType, VFC, PropsWithChildren, ReactElement, ReactNode, ReactText, ForwardRefExoticComponent, FC } from 'react';
|
|
4
4
|
import { renderContent, config, HTMLTags, HTMLTagsText } from '@vitus-labs/core';
|
|
5
5
|
|
|
6
6
|
declare type ExtractNullableKeys<T> = {
|
|
@@ -13,20 +13,65 @@ declare type SpreadTwo<L, R> = Id<Pick<L, Exclude<keyof L, keyof R>> & R>;
|
|
|
13
13
|
declare type Spread<A extends readonly [...any]> = A extends [infer L, ...infer R] ? SpreadTwo<L, Spread<R>> : unknown;
|
|
14
14
|
declare type MergeTypes<A extends readonly [...any]> = ExtractNullableKeys<Spread<A>>;
|
|
15
15
|
declare type SimpleHoc<P extends Record<string, unknown>> = <T extends ComponentType<any>>(WrappedComponent: T) => VFC<MergeTypes<[P, ExtractProps<T>]>>;
|
|
16
|
+
/**
|
|
17
|
+
* @hidden
|
|
18
|
+
*/
|
|
16
19
|
declare type InnerRef = ForwardedRef<any>;
|
|
20
|
+
/**
|
|
21
|
+
* @hidden
|
|
22
|
+
*/
|
|
17
23
|
declare type CssCallback = (css: typeof config.css) => ReturnType<typeof css>;
|
|
24
|
+
/**
|
|
25
|
+
* @hidden
|
|
26
|
+
*/
|
|
18
27
|
declare type Css = CssCallback | string | ReturnType<typeof config.css>;
|
|
28
|
+
/**
|
|
29
|
+
* @hidden
|
|
30
|
+
*/
|
|
19
31
|
declare type isEmpty = null | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* @hidden
|
|
34
|
+
*/
|
|
20
35
|
declare type Content = Parameters<typeof renderContent>['0'];
|
|
36
|
+
/**
|
|
37
|
+
* @hidden
|
|
38
|
+
*/
|
|
21
39
|
declare type ContentAlignX = 'left' | 'center' | 'right' | 'spaceBetween' | 'spaceAround' | 'block' | isEmpty;
|
|
40
|
+
/**
|
|
41
|
+
* @hidden
|
|
42
|
+
*/
|
|
22
43
|
declare type ContentAlignY = 'top' | 'center' | 'bottom' | 'spaceBetween' | 'spaceAround' | 'block' | isEmpty;
|
|
44
|
+
/**
|
|
45
|
+
* @hidden
|
|
46
|
+
*/
|
|
23
47
|
declare type ContentDirection = 'inline' | 'rows' | 'reverseInline' | 'reverseRows' | isEmpty;
|
|
48
|
+
/**
|
|
49
|
+
* @hidden
|
|
50
|
+
*/
|
|
24
51
|
declare type AlignY$2 = ContentAlignY | ContentAlignY[] | Record<string, ContentAlignY>;
|
|
52
|
+
/**
|
|
53
|
+
* @hidden
|
|
54
|
+
*/
|
|
25
55
|
declare type AlignX$2 = ContentAlignX | ContentAlignX[] | Record<string, ContentAlignX>;
|
|
56
|
+
/**
|
|
57
|
+
* @hidden
|
|
58
|
+
*/
|
|
26
59
|
declare type Direction = ContentDirection | ContentDirection[] | Record<string, ContentDirection>;
|
|
60
|
+
/**
|
|
61
|
+
* @hidden
|
|
62
|
+
*/
|
|
27
63
|
declare type ResponsiveBooltype = boolean | Record<string, boolean> | Array<boolean>;
|
|
64
|
+
/**
|
|
65
|
+
* @hidden
|
|
66
|
+
*/
|
|
28
67
|
declare type Responsive = number | Array<string | number> | Record<string, number | string>;
|
|
68
|
+
/**
|
|
69
|
+
* @hidden
|
|
70
|
+
*/
|
|
29
71
|
declare type ExtendCss = Css | Array<Css> | Record<string, Css>;
|
|
72
|
+
/**
|
|
73
|
+
* @hidden
|
|
74
|
+
*/
|
|
30
75
|
declare type ExtractProps<TComponentOrTProps> = TComponentOrTProps extends ComponentType<infer TProps> ? TProps : TComponentOrTProps;
|
|
31
76
|
declare type VLForwardedComponent<P = Record<string, unknown>> = ForwardRefRenderFunction<any, P> & VLStatic;
|
|
32
77
|
declare type VLComponent<P = Record<string, unknown>> = VFC<P> & VLStatic;
|
|
@@ -100,7 +145,13 @@ declare const withEqualBeforeAfter: SimpleHoc<Props$7>;
|
|
|
100
145
|
declare type MaybeNull = undefined | null;
|
|
101
146
|
declare type TObj = Record<string, unknown>;
|
|
102
147
|
declare type SimpleValue = ReactText;
|
|
148
|
+
/**
|
|
149
|
+
* @hidden
|
|
150
|
+
*/
|
|
103
151
|
declare type ElementType<T extends Record<string, unknown> = any> = ComponentType<T> | ForwardRefExoticComponent<T> | HTMLTags;
|
|
152
|
+
/**
|
|
153
|
+
* @hidden
|
|
154
|
+
*/
|
|
104
155
|
declare type ExtendedProps = {
|
|
105
156
|
index: number;
|
|
106
157
|
first: boolean;
|
|
@@ -109,12 +160,18 @@ declare type ExtendedProps = {
|
|
|
109
160
|
even: boolean;
|
|
110
161
|
position: number;
|
|
111
162
|
};
|
|
163
|
+
/**
|
|
164
|
+
* @hidden
|
|
165
|
+
*/
|
|
112
166
|
declare type DataArrayObject = Partial<{
|
|
113
167
|
id: SimpleValue;
|
|
114
168
|
key: SimpleValue;
|
|
115
169
|
itemId: SimpleValue;
|
|
116
170
|
component: ElementType;
|
|
117
171
|
}> & Record<string, unknown>;
|
|
172
|
+
/**
|
|
173
|
+
* @hidden
|
|
174
|
+
*/
|
|
118
175
|
declare type PropsCallback = TObj | ((itemProps: Record<string, never> | Record<string, SimpleValue> | DataArrayObject, extendedProps: ExtendedProps) => TObj);
|
|
119
176
|
declare type Props$6 = Partial<{
|
|
120
177
|
children: ReactNode;
|
|
@@ -238,4 +295,4 @@ declare type Props = {
|
|
|
238
295
|
};
|
|
239
296
|
declare const component: VLComponent<Props>;
|
|
240
297
|
|
|
241
|
-
export { component$7 as Element, Props$8 as ElementProps, component$6 as List, Props$5 as ListProps, component$4 as Overlay, Props$3 as OverlayProps, component$3 as OverlayProvider, component$2 as Portal, Props$2 as PortalProps, component$1 as Text, Props$1 as TextProps, UseOverlayProps, component as Util, Props as UtilProps, _default as useOverlay, component$5 as withActiveState, withEqualBeforeAfter as withEqualSizeBeforeAfter };
|
|
298
|
+
export { AlignX$2 as AlignX, AlignY$2 as AlignY, Content, Direction, component$7 as Element, Props$8 as ElementProps, ExtendCss, InnerRef, component$6 as List, Props$5 as ListProps, component$4 as Overlay, Props$3 as OverlayProps, component$3 as OverlayProvider, component$2 as Portal, Props$2 as PortalProps, Responsive, ResponsiveBooltype, component$1 as Text, Props$1 as TextProps, UseOverlayProps, component as Util, Props as UtilProps, _default as useOverlay, component$5 as withActiveState, withEqualBeforeAfter as withEqualSizeBeforeAfter };
|
|
@@ -3,7 +3,13 @@ import { HTMLTags } from '@vitus-labs/core';
|
|
|
3
3
|
export declare type MaybeNull = undefined | null;
|
|
4
4
|
export declare type TObj = Record<string, unknown>;
|
|
5
5
|
export declare type SimpleValue = ReactText;
|
|
6
|
+
/**
|
|
7
|
+
* @hidden
|
|
8
|
+
*/
|
|
6
9
|
export declare type ElementType<T extends Record<string, unknown> = any> = ComponentType<T> | ForwardRefExoticComponent<T> | HTMLTags;
|
|
10
|
+
/**
|
|
11
|
+
* @hidden
|
|
12
|
+
*/
|
|
7
13
|
export declare type ExtendedProps = {
|
|
8
14
|
index: number;
|
|
9
15
|
first: boolean;
|
|
@@ -12,12 +18,18 @@ export declare type ExtendedProps = {
|
|
|
12
18
|
even: boolean;
|
|
13
19
|
position: number;
|
|
14
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* @hidden
|
|
23
|
+
*/
|
|
15
24
|
export declare type DataArrayObject = Partial<{
|
|
16
25
|
id: SimpleValue;
|
|
17
26
|
key: SimpleValue;
|
|
18
27
|
itemId: SimpleValue;
|
|
19
28
|
component: ElementType;
|
|
20
29
|
}> & Record<string, unknown>;
|
|
30
|
+
/**
|
|
31
|
+
* @hidden
|
|
32
|
+
*/
|
|
21
33
|
export declare type PropsCallback = TObj | ((itemProps: Record<string, never> | Record<string, SimpleValue> | DataArrayObject, extendedProps: ExtendedProps) => TObj);
|
|
22
34
|
export declare type Props = Partial<{
|
|
23
35
|
children: ReactNode;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -5,5 +5,6 @@ import Overlay, { Props as OverlayProps, useOverlay, OverlayProvider, UseOverlay
|
|
|
5
5
|
import Portal, { Props as PortalProps } from "./Portal";
|
|
6
6
|
import Text, { Props as TextProps } from "./Text";
|
|
7
7
|
import Util, { Props as UtilProps } from "./Util";
|
|
8
|
-
|
|
8
|
+
import type { AlignX, AlignY, Content, Direction, ResponsiveBooltype, Responsive, ExtendCss, InnerRef } from "./types";
|
|
9
|
+
export type { ElementProps, ListProps, OverlayProps, UseOverlayProps, PortalProps, TextProps, UtilProps, AlignX, AlignY, Content, Direction, ResponsiveBooltype, Responsive, ExtendCss, InnerRef, };
|
|
9
10
|
export { Element, withEqualSizeBeforeAfter, withActiveState, List, Overlay, useOverlay, OverlayProvider, Portal, Text, Util, Provider, };
|
package/lib/types/types.d.ts
CHANGED
|
@@ -10,21 +10,69 @@ declare type SpreadTwo<L, R> = Id<Pick<L, Exclude<keyof L, keyof R>> & R>;
|
|
|
10
10
|
declare type Spread<A extends readonly [...any]> = A extends [infer L, ...infer R] ? SpreadTwo<L, Spread<R>> : unknown;
|
|
11
11
|
export declare type MergeTypes<A extends readonly [...any]> = ExtractNullableKeys<Spread<A>>;
|
|
12
12
|
export declare type SimpleHoc<P extends Record<string, unknown>> = <T extends ComponentType<any>>(WrappedComponent: T) => VFC<MergeTypes<[P, ExtractProps<T>]>>;
|
|
13
|
+
/**
|
|
14
|
+
* @hidden
|
|
15
|
+
*/
|
|
13
16
|
export declare type InnerRef = ForwardedRef<any>;
|
|
17
|
+
/**
|
|
18
|
+
* @hidden
|
|
19
|
+
*/
|
|
14
20
|
export declare type CssCallback = (css: typeof config.css) => ReturnType<typeof css>;
|
|
21
|
+
/**
|
|
22
|
+
* @hidden
|
|
23
|
+
*/
|
|
15
24
|
export declare type Css = CssCallback | string | ReturnType<typeof config.css>;
|
|
25
|
+
/**
|
|
26
|
+
* @hidden
|
|
27
|
+
*/
|
|
16
28
|
export declare type isEmpty = null | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* @hidden
|
|
31
|
+
*/
|
|
17
32
|
export declare type Content = Parameters<typeof renderContent>['0'];
|
|
33
|
+
/**
|
|
34
|
+
* @hidden
|
|
35
|
+
*/
|
|
18
36
|
export declare type ContentAlignX = 'left' | 'center' | 'right' | 'spaceBetween' | 'spaceAround' | 'block' | isEmpty;
|
|
37
|
+
/**
|
|
38
|
+
* @hidden
|
|
39
|
+
*/
|
|
19
40
|
export declare type ContentAlignY = 'top' | 'center' | 'bottom' | 'spaceBetween' | 'spaceAround' | 'block' | isEmpty;
|
|
41
|
+
/**
|
|
42
|
+
* @hidden
|
|
43
|
+
*/
|
|
20
44
|
export declare type ContentDirection = 'inline' | 'rows' | 'reverseInline' | 'reverseRows' | isEmpty;
|
|
45
|
+
/**
|
|
46
|
+
* @hidden
|
|
47
|
+
*/
|
|
21
48
|
export declare type Ref = HTMLElement;
|
|
49
|
+
/**
|
|
50
|
+
* @hidden
|
|
51
|
+
*/
|
|
22
52
|
export declare type AlignY = ContentAlignY | ContentAlignY[] | Record<string, ContentAlignY>;
|
|
53
|
+
/**
|
|
54
|
+
* @hidden
|
|
55
|
+
*/
|
|
23
56
|
export declare type AlignX = ContentAlignX | ContentAlignX[] | Record<string, ContentAlignX>;
|
|
57
|
+
/**
|
|
58
|
+
* @hidden
|
|
59
|
+
*/
|
|
24
60
|
export declare type Direction = ContentDirection | ContentDirection[] | Record<string, ContentDirection>;
|
|
61
|
+
/**
|
|
62
|
+
* @hidden
|
|
63
|
+
*/
|
|
25
64
|
export declare type ResponsiveBooltype = boolean | Record<string, boolean> | Array<boolean>;
|
|
65
|
+
/**
|
|
66
|
+
* @hidden
|
|
67
|
+
*/
|
|
26
68
|
export declare type Responsive = number | Array<string | number> | Record<string, number | string>;
|
|
69
|
+
/**
|
|
70
|
+
* @hidden
|
|
71
|
+
*/
|
|
27
72
|
export declare type ExtendCss = Css | Array<Css> | Record<string, Css>;
|
|
73
|
+
/**
|
|
74
|
+
* @hidden
|
|
75
|
+
*/
|
|
28
76
|
export declare type ExtractProps<TComponentOrTProps> = TComponentOrTProps extends ComponentType<infer TProps> ? TProps : TComponentOrTProps;
|
|
29
77
|
export declare type VLForwardedComponent<P = Record<string, unknown>> = ForwardRefRenderFunction<any, P> & VLStatic;
|
|
30
78
|
export declare type VLComponent<P = Record<string, unknown>> = VFC<P> & VLStatic;
|
|
@@ -20,20 +20,6 @@ const INLINE_ELEMENTS_FLEX_FIX = {
|
|
|
20
20
|
const isWebFixNeeded = (tag) => INLINE_ELEMENTS_FLEX_FIX[tag];
|
|
21
21
|
|
|
22
22
|
const styles$2 = ({ theme: t, css }) => css `
|
|
23
|
-
${css `
|
|
24
|
-
${({ $childFix }) => !$childFix &&
|
|
25
|
-
css `
|
|
26
|
-
display: ${t.block ? 'flex' : 'inline-flex'};
|
|
27
|
-
`};
|
|
28
|
-
|
|
29
|
-
${({ $parentFix }) => $parentFix &&
|
|
30
|
-
t.block &&
|
|
31
|
-
css `
|
|
32
|
-
flex-direction: column;
|
|
33
|
-
width: 100%;
|
|
34
|
-
`};
|
|
35
|
-
`};
|
|
36
|
-
|
|
37
23
|
${t.alignY === 'block' &&
|
|
38
24
|
css `
|
|
39
25
|
height: 100%;
|
|
@@ -50,6 +36,20 @@ const styles$2 = ({ theme: t, css }) => css `
|
|
|
50
36
|
align-self: stretch;
|
|
51
37
|
`}
|
|
52
38
|
|
|
39
|
+
${css `
|
|
40
|
+
${({ $childFix }) => !$childFix &&
|
|
41
|
+
css `
|
|
42
|
+
display: ${t.block ? 'flex' : 'inline-flex'};
|
|
43
|
+
`};
|
|
44
|
+
|
|
45
|
+
${({ $parentFix }) => $parentFix &&
|
|
46
|
+
t.block &&
|
|
47
|
+
css `
|
|
48
|
+
flex-direction: column;
|
|
49
|
+
width: 100%;
|
|
50
|
+
`};
|
|
51
|
+
`};
|
|
52
|
+
|
|
53
53
|
${t.extraStyles && extendCss(t.extraStyles)};
|
|
54
54
|
`;
|
|
55
55
|
const platformStyles = 'box-sizing: border-box;' ;
|
|
@@ -735,22 +735,33 @@ offsetX = 0, offsetY = 0, throttleDelay = 200, customScrollListener, closeOnEsc
|
|
|
735
735
|
const hideContent = useCallback(() => {
|
|
736
736
|
handleActive(false);
|
|
737
737
|
}, []);
|
|
738
|
+
useEffect(() => {
|
|
739
|
+
if (active) {
|
|
740
|
+
if (onOpen)
|
|
741
|
+
onOpen();
|
|
742
|
+
}
|
|
743
|
+
else {
|
|
744
|
+
if (onClose)
|
|
745
|
+
onClose();
|
|
746
|
+
}
|
|
747
|
+
}, [active, onOpen, onClose]);
|
|
748
|
+
useEffect(() => {
|
|
749
|
+
if (disabled) {
|
|
750
|
+
hideContent();
|
|
751
|
+
}
|
|
752
|
+
}, [disabled]);
|
|
738
753
|
// if an Overlay has an Overlay child, this will prevent closing parent child
|
|
739
754
|
// + calculate correct position when an Overlay is opened
|
|
740
755
|
useEffect(() => {
|
|
741
756
|
if (active) {
|
|
742
757
|
if (ctx?.setBlocked)
|
|
743
758
|
ctx.setBlocked();
|
|
744
|
-
if (onOpen)
|
|
745
|
-
onOpen();
|
|
746
759
|
}
|
|
747
760
|
else {
|
|
748
761
|
if (ctx?.setUnblocked)
|
|
749
762
|
ctx.setUnblocked();
|
|
750
|
-
if (onClose)
|
|
751
|
-
onClose();
|
|
752
763
|
}
|
|
753
|
-
}, [active,
|
|
764
|
+
}, [active, ctx]);
|
|
754
765
|
// calculate position on every position change state
|
|
755
766
|
useEffect(() => {
|
|
756
767
|
if (active) {
|