@pyreon/elements 0.15.0 → 0.16.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/index.d.ts +105 -48
- package/lib/index.js +51 -32
- package/package.json +12 -12
- package/src/Element/component.tsx +13 -2
- package/src/List/component.tsx +65 -15
- package/src/Portal/component.tsx +23 -10
- package/src/__tests__/Element.test.ts +157 -0
- package/src/__tests__/Iterator.test.ts +12 -3
- package/src/__tests__/Iterator.types.test.ts +237 -0
- package/src/__tests__/Portal.test.ts +122 -48
- package/src/__tests__/Wrapper-innerhtml.test.tsx +178 -0
- package/src/__tests__/elements.browser.test.tsx +47 -0
- package/src/__tests__/wrapper-block-cascade.test.ts +121 -0
- package/src/helpers/Iterator/component.tsx +55 -4
- package/src/helpers/Iterator/index.ts +17 -1
- package/src/helpers/Iterator/types.ts +97 -38
- package/src/helpers/Wrapper/component.tsx +32 -0
- package/src/helpers/Wrapper/styled.ts +12 -18
- package/src/index.ts +4 -0
- package/src/types.ts +33 -2
|
@@ -23,31 +23,25 @@ const parentFixCSS = `
|
|
|
23
23
|
flex-direction: column;
|
|
24
24
|
`
|
|
25
25
|
|
|
26
|
-
const
|
|
27
|
-
height: 100%;
|
|
28
|
-
`
|
|
29
|
-
|
|
30
|
-
const blockCSS = `
|
|
31
|
-
align-self: stretch;
|
|
32
|
-
flex: 1;
|
|
33
|
-
min-width: 0;
|
|
34
|
-
`
|
|
35
|
-
|
|
36
|
-
const childFixPosition = (isBlock?: boolean) => `display: ${isBlock ? 'flex' : 'inline-flex'};`
|
|
37
|
-
|
|
38
|
-
const styles: ResponsiveStylesCallback = ({ theme: t, css: cssFn }) => cssFn`
|
|
39
|
-
${t.alignY === 'block' && fullHeightCSS};
|
|
40
|
-
|
|
26
|
+
export const styles: ResponsiveStylesCallback = ({ theme: t, css: cssFn }) => cssFn`
|
|
41
27
|
${alignContent({
|
|
42
28
|
direction: t.direction,
|
|
43
29
|
alignX: t.alignX,
|
|
44
30
|
alignY: t.alignY,
|
|
45
31
|
})};
|
|
46
32
|
|
|
47
|
-
|
|
48
|
-
|
|
33
|
+
/*
|
|
34
|
+
* Always emit a value for the block-related properties so a responsive
|
|
35
|
+
* theme that flips from \`block: true\` at one breakpoint to \`block: false\`
|
|
36
|
+
* at another resets cleanly. Previously \`align-self\` / \`width\` / \`height\`
|
|
37
|
+
* were only set when the truthy branch matched, which left the prior
|
|
38
|
+
* breakpoint's values cascading through.
|
|
39
|
+
*/
|
|
40
|
+
${`align-self: ${t.block ? 'stretch' : 'auto'};
|
|
41
|
+
width: ${t.block ? '100%' : 'auto'};
|
|
42
|
+
height: ${t.alignY === 'block' ? '100%' : 'auto'};`};
|
|
49
43
|
|
|
50
|
-
${!t.childFix &&
|
|
44
|
+
${!t.childFix && `display: ${t.block ? 'flex' : 'inline-flex'};`};
|
|
51
45
|
${t.parentFix && parentFixCSS};
|
|
52
46
|
|
|
53
47
|
${t.extraStyles && extendCss(t.extraStyles as Parameters<typeof extendCss>[0])};
|
package/src/index.ts
CHANGED
|
@@ -3,12 +3,16 @@ import { Provider } from '@pyreon/unistyle'
|
|
|
3
3
|
export type { ElementProps, PyreonElement } from './Element'
|
|
4
4
|
export { Element } from './Element'
|
|
5
5
|
export type {
|
|
6
|
+
ChildrenProps as IteratorChildrenProps,
|
|
6
7
|
ElementType,
|
|
7
8
|
ExtendedProps,
|
|
9
|
+
LooseProps as IteratorLooseProps,
|
|
8
10
|
MaybeNull,
|
|
11
|
+
ObjectProps as IteratorObjectProps,
|
|
9
12
|
ObjectValue,
|
|
10
13
|
Props as IteratorProps,
|
|
11
14
|
PropsCallback,
|
|
15
|
+
SimpleProps as IteratorSimpleProps,
|
|
12
16
|
SimpleValue,
|
|
13
17
|
} from './helpers/Iterator'
|
|
14
18
|
export { default as Iterator } from './helpers/Iterator'
|
package/src/types.ts
CHANGED
|
@@ -69,8 +69,39 @@ export type Responsive =
|
|
|
69
69
|
|
|
70
70
|
export type ExtendCss = Css | Css[] | Partial<Record<BreakpointKeys, Css>>
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Extracts the props type from a Pyreon component function — multi-overload
|
|
74
|
+
* aware. Matches up to 4 call signatures and produces the UNION of their
|
|
75
|
+
* first-argument types. Iterator / List ship 3-overload primitives whose
|
|
76
|
+
* LAST overload is `ChildrenProps` (the loosest); without overload-aware
|
|
77
|
+
* extraction, `ExtractProps<Iterator>` returned just `ChildrenProps` and
|
|
78
|
+
* lost `SimpleProps<T>` / `ObjectProps<T>` shapes. Mirrors vitus-labs
|
|
79
|
+
* PR #222.
|
|
80
|
+
*
|
|
81
|
+
* Kept in sync with the copies in `@pyreon/core` / `@pyreon/attrs` /
|
|
82
|
+
* `@pyreon/rocketstyle`.
|
|
83
|
+
*/
|
|
84
|
+
export type ExtractProps<TComponentOrTProps> = TComponentOrTProps extends {
|
|
85
|
+
(props: infer P1, ...args: any): any
|
|
86
|
+
(props: infer P2, ...args: any): any
|
|
87
|
+
(props: infer P3, ...args: any): any
|
|
88
|
+
(props: infer P4, ...args: any): any
|
|
89
|
+
}
|
|
90
|
+
? P1 | P2 | P3 | P4
|
|
91
|
+
: TComponentOrTProps extends {
|
|
92
|
+
(props: infer P1, ...args: any): any
|
|
93
|
+
(props: infer P2, ...args: any): any
|
|
94
|
+
(props: infer P3, ...args: any): any
|
|
95
|
+
}
|
|
96
|
+
? P1 | P2 | P3
|
|
97
|
+
: TComponentOrTProps extends {
|
|
98
|
+
(props: infer P1, ...args: any): any
|
|
99
|
+
(props: infer P2, ...args: any): any
|
|
100
|
+
}
|
|
101
|
+
? P1 | P2
|
|
102
|
+
: TComponentOrTProps extends ComponentFn<infer TProps>
|
|
103
|
+
? TProps
|
|
104
|
+
: TComponentOrTProps
|
|
74
105
|
|
|
75
106
|
export type PyreonComponent<P extends Record<string, any> = {}> = ComponentFn<P> & PyreonStatic
|
|
76
107
|
|