@pyreon/elements 0.11.5 → 0.11.7
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/README.md +38 -35
- package/lib/index.d.ts +15 -15
- package/package.json +24 -24
- package/src/Element/component.tsx +14 -14
- package/src/Element/constants.ts +25 -25
- package/src/Element/index.ts +2 -2
- package/src/Element/types.ts +3 -3
- package/src/Element/utils.ts +1 -1
- package/src/List/component.tsx +7 -7
- package/src/List/index.ts +2 -2
- package/src/Overlay/component.tsx +22 -22
- package/src/Overlay/context.tsx +2 -2
- package/src/Overlay/index.ts +3 -3
- package/src/Overlay/useOverlay.tsx +97 -97
- package/src/Portal/component.tsx +6 -6
- package/src/Portal/index.ts +2 -2
- package/src/Text/component.tsx +6 -6
- package/src/Text/index.ts +2 -2
- package/src/Text/styled.ts +4 -4
- package/src/Util/component.tsx +5 -5
- package/src/Util/index.ts +2 -2
- package/src/__tests__/Content.test.tsx +46 -46
- package/src/__tests__/Element.test.ts +251 -251
- package/src/__tests__/Iterator.test.ts +142 -142
- package/src/__tests__/List.test.ts +61 -61
- package/src/__tests__/Overlay.test.ts +125 -125
- package/src/__tests__/Portal.test.ts +33 -33
- package/src/__tests__/Text.test.ts +128 -128
- package/src/__tests__/Util.test.ts +31 -31
- package/src/__tests__/Wrapper.test.tsx +60 -60
- package/src/__tests__/equalBeforeAfter.test.ts +41 -41
- package/src/__tests__/helpers.test.ts +29 -29
- package/src/__tests__/overlayContext.test.tsx +14 -14
- package/src/__tests__/responsiveProps.test.ts +116 -116
- package/src/__tests__/useOverlay.test.ts +283 -283
- package/src/__tests__/utils.test.ts +43 -43
- package/src/constants.ts +1 -1
- package/src/helpers/Content/component.tsx +5 -5
- package/src/helpers/Content/index.ts +1 -1
- package/src/helpers/Content/styled.ts +16 -16
- package/src/helpers/Content/types.ts +7 -7
- package/src/helpers/Iterator/component.tsx +28 -28
- package/src/helpers/Iterator/index.ts +2 -2
- package/src/helpers/Iterator/types.ts +3 -3
- package/src/helpers/Wrapper/component.tsx +6 -6
- package/src/helpers/Wrapper/index.ts +1 -1
- package/src/helpers/Wrapper/styled.ts +8 -8
- package/src/helpers/Wrapper/types.ts +3 -3
- package/src/helpers/Wrapper/utils.ts +1 -1
- package/src/helpers/index.ts +2 -2
- package/src/index.ts +16 -16
- package/src/types.ts +7 -7
- package/src/utils.ts +1 -1
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
import { describe, expect, it } from
|
|
2
|
-
import { getShouldBeEmpty, isInlineElement } from
|
|
3
|
-
import { isWebFixNeeded } from
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { getShouldBeEmpty, isInlineElement } from '../Element/utils'
|
|
3
|
+
import { isWebFixNeeded } from '../helpers/Wrapper/utils'
|
|
4
4
|
|
|
5
|
-
describe(
|
|
6
|
-
it(
|
|
7
|
-
expect(isInlineElement(
|
|
8
|
-
expect(isInlineElement(
|
|
9
|
-
expect(isInlineElement(
|
|
10
|
-
expect(isInlineElement(
|
|
11
|
-
expect(isInlineElement(
|
|
12
|
-
expect(isInlineElement(
|
|
13
|
-
expect(isInlineElement(
|
|
14
|
-
expect(isInlineElement(
|
|
5
|
+
describe('isInlineElement', () => {
|
|
6
|
+
it('returns true for inline elements', () => {
|
|
7
|
+
expect(isInlineElement('span')).toBe(true)
|
|
8
|
+
expect(isInlineElement('a')).toBe(true)
|
|
9
|
+
expect(isInlineElement('button')).toBe(true)
|
|
10
|
+
expect(isInlineElement('input')).toBe(true)
|
|
11
|
+
expect(isInlineElement('label')).toBe(true)
|
|
12
|
+
expect(isInlineElement('strong')).toBe(true)
|
|
13
|
+
expect(isInlineElement('em')).toBe(true)
|
|
14
|
+
expect(isInlineElement('img')).toBe(true)
|
|
15
15
|
})
|
|
16
16
|
|
|
17
|
-
it(
|
|
18
|
-
expect(isInlineElement(
|
|
19
|
-
expect(isInlineElement(
|
|
20
|
-
expect(isInlineElement(
|
|
21
|
-
expect(isInlineElement(
|
|
17
|
+
it('returns false for block elements', () => {
|
|
18
|
+
expect(isInlineElement('div')).toBe(false)
|
|
19
|
+
expect(isInlineElement('p')).toBe(false)
|
|
20
|
+
expect(isInlineElement('section')).toBe(false)
|
|
21
|
+
expect(isInlineElement('header')).toBe(false)
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
-
it(
|
|
24
|
+
it('returns false for undefined', () => {
|
|
25
25
|
expect(isInlineElement(undefined)).toBe(false)
|
|
26
26
|
})
|
|
27
27
|
|
|
28
|
-
it(
|
|
29
|
-
expect(isInlineElement(
|
|
28
|
+
it('returns false for empty string', () => {
|
|
29
|
+
expect(isInlineElement('')).toBe(false)
|
|
30
30
|
})
|
|
31
31
|
})
|
|
32
32
|
|
|
33
|
-
describe(
|
|
34
|
-
it(
|
|
35
|
-
expect(getShouldBeEmpty(
|
|
36
|
-
expect(getShouldBeEmpty(
|
|
37
|
-
expect(getShouldBeEmpty(
|
|
38
|
-
expect(getShouldBeEmpty(
|
|
39
|
-
expect(getShouldBeEmpty(
|
|
33
|
+
describe('getShouldBeEmpty', () => {
|
|
34
|
+
it('returns true for void elements', () => {
|
|
35
|
+
expect(getShouldBeEmpty('br')).toBe(true)
|
|
36
|
+
expect(getShouldBeEmpty('img')).toBe(true)
|
|
37
|
+
expect(getShouldBeEmpty('input')).toBe(true)
|
|
38
|
+
expect(getShouldBeEmpty('hr')).toBe(true)
|
|
39
|
+
expect(getShouldBeEmpty('embed')).toBe(true)
|
|
40
40
|
})
|
|
41
41
|
|
|
42
|
-
it(
|
|
43
|
-
expect(getShouldBeEmpty(
|
|
44
|
-
expect(getShouldBeEmpty(
|
|
45
|
-
expect(getShouldBeEmpty(
|
|
42
|
+
it('returns false for non-void elements', () => {
|
|
43
|
+
expect(getShouldBeEmpty('div')).toBe(false)
|
|
44
|
+
expect(getShouldBeEmpty('span')).toBe(false)
|
|
45
|
+
expect(getShouldBeEmpty('p')).toBe(false)
|
|
46
46
|
})
|
|
47
47
|
|
|
48
|
-
it(
|
|
48
|
+
it('returns false for undefined', () => {
|
|
49
49
|
expect(getShouldBeEmpty(undefined)).toBe(false)
|
|
50
50
|
})
|
|
51
51
|
})
|
|
52
52
|
|
|
53
|
-
describe(
|
|
54
|
-
it(
|
|
55
|
-
expect(isWebFixNeeded(
|
|
56
|
-
expect(isWebFixNeeded(
|
|
57
|
-
expect(isWebFixNeeded(
|
|
53
|
+
describe('isWebFixNeeded', () => {
|
|
54
|
+
it('returns true for button, fieldset, legend', () => {
|
|
55
|
+
expect(isWebFixNeeded('button')).toBe(true)
|
|
56
|
+
expect(isWebFixNeeded('fieldset')).toBe(true)
|
|
57
|
+
expect(isWebFixNeeded('legend')).toBe(true)
|
|
58
58
|
})
|
|
59
59
|
|
|
60
|
-
it(
|
|
61
|
-
expect(isWebFixNeeded(
|
|
62
|
-
expect(isWebFixNeeded(
|
|
63
|
-
expect(isWebFixNeeded(
|
|
60
|
+
it('returns false for other elements', () => {
|
|
61
|
+
expect(isWebFixNeeded('div')).toBe(false)
|
|
62
|
+
expect(isWebFixNeeded('span')).toBe(false)
|
|
63
|
+
expect(isWebFixNeeded('input')).toBe(false)
|
|
64
64
|
})
|
|
65
65
|
|
|
66
|
-
it(
|
|
66
|
+
it('returns false for undefined', () => {
|
|
67
67
|
expect(isWebFixNeeded(undefined)).toBe(false)
|
|
68
68
|
})
|
|
69
69
|
})
|
package/src/constants.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PKG_NAME =
|
|
1
|
+
export const PKG_NAME = '@pyreon/elements' as const
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Children are rendered via core `render()`.
|
|
8
8
|
*/
|
|
9
|
-
import { render } from
|
|
10
|
-
import { IS_DEVELOPMENT } from
|
|
11
|
-
import Styled from
|
|
12
|
-
import type { Props } from
|
|
9
|
+
import { render } from '@pyreon/ui-core'
|
|
10
|
+
import { IS_DEVELOPMENT } from '../../utils'
|
|
11
|
+
import Styled from './styled'
|
|
12
|
+
import type { Props } from './types'
|
|
13
13
|
|
|
14
14
|
const Component = ({
|
|
15
15
|
contentType,
|
|
@@ -26,7 +26,7 @@ const Component = ({
|
|
|
26
26
|
}: Partial<Props>) => {
|
|
27
27
|
const debugProps = IS_DEVELOPMENT
|
|
28
28
|
? {
|
|
29
|
-
|
|
29
|
+
'data-pyr-element': contentType,
|
|
30
30
|
}
|
|
31
31
|
: {}
|
|
32
32
|
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* equalCols flex distribution. The "content" slot gets `flex: 1` to
|
|
6
6
|
* fill remaining space between before and after.
|
|
7
7
|
*/
|
|
8
|
-
import { config } from
|
|
9
|
-
import { alignContent, extendCss, makeItResponsive, value } from
|
|
10
|
-
import type { ResponsiveStylesCallback } from
|
|
11
|
-
import type { StyledProps, ThemeProps } from
|
|
8
|
+
import { config } from '@pyreon/ui-core'
|
|
9
|
+
import { alignContent, extendCss, makeItResponsive, value } from '@pyreon/unistyle'
|
|
10
|
+
import type { ResponsiveStylesCallback } from '../../types'
|
|
11
|
+
import type { StyledProps, ThemeProps } from './types'
|
|
12
12
|
|
|
13
13
|
const { styled, css, component } = config
|
|
14
14
|
|
|
@@ -25,20 +25,20 @@ const typeContentCSS = `
|
|
|
25
25
|
// --------------------------------------------------------
|
|
26
26
|
const gapDimensions = {
|
|
27
27
|
inline: {
|
|
28
|
-
before:
|
|
29
|
-
after:
|
|
28
|
+
before: 'margin-right',
|
|
29
|
+
after: 'margin-left',
|
|
30
30
|
},
|
|
31
31
|
reverseInline: {
|
|
32
|
-
before:
|
|
33
|
-
after:
|
|
32
|
+
before: 'margin-right',
|
|
33
|
+
after: 'margin-left',
|
|
34
34
|
},
|
|
35
35
|
rows: {
|
|
36
|
-
before:
|
|
37
|
-
after:
|
|
36
|
+
before: 'margin-bottom',
|
|
37
|
+
after: 'margin-top',
|
|
38
38
|
},
|
|
39
39
|
reverseRows: {
|
|
40
|
-
before:
|
|
41
|
-
after:
|
|
40
|
+
before: 'margin-bottom',
|
|
41
|
+
after: 'margin-top',
|
|
42
42
|
},
|
|
43
43
|
} as const
|
|
44
44
|
|
|
@@ -48,10 +48,10 @@ const calculateGap = ({
|
|
|
48
48
|
value: gapValue,
|
|
49
49
|
}: {
|
|
50
50
|
direction: keyof typeof gapDimensions
|
|
51
|
-
type: ThemeProps[
|
|
51
|
+
type: ThemeProps['contentType']
|
|
52
52
|
value: string | number | null | undefined
|
|
53
53
|
}) => {
|
|
54
|
-
if (!direction || !type || type ===
|
|
54
|
+
if (!direction || !type || type === 'content') return undefined
|
|
55
55
|
|
|
56
56
|
const finalStyles = `${gapDimensions[direction][type]}: ${gapValue};`
|
|
57
57
|
|
|
@@ -92,10 +92,10 @@ const StyledComponent = styled(component)`
|
|
|
92
92
|
align-self: stretch;
|
|
93
93
|
flex-wrap: wrap;
|
|
94
94
|
|
|
95
|
-
${(({ $contentType }: StyledProps) => $contentType ===
|
|
95
|
+
${(({ $contentType }: StyledProps) => $contentType === 'content' && typeContentCSS) as any};
|
|
96
96
|
|
|
97
97
|
${makeItResponsive({
|
|
98
|
-
key:
|
|
98
|
+
key: '$element',
|
|
99
99
|
styles,
|
|
100
100
|
css,
|
|
101
101
|
normalize: true,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HTMLTags } from
|
|
1
|
+
import type { HTMLTags } from '@pyreon/ui-core'
|
|
2
2
|
import type {
|
|
3
3
|
AlignX,
|
|
4
4
|
AlignY,
|
|
@@ -13,12 +13,12 @@ import type {
|
|
|
13
13
|
ExtendCss,
|
|
14
14
|
Responsive,
|
|
15
15
|
ResponsiveBoolType,
|
|
16
|
-
} from
|
|
16
|
+
} from '../../types'
|
|
17
17
|
|
|
18
18
|
export interface Props {
|
|
19
19
|
parentDirection: Direction | undefined
|
|
20
20
|
gap: Responsive | undefined
|
|
21
|
-
contentType:
|
|
21
|
+
contentType: 'before' | 'content' | 'after' | undefined
|
|
22
22
|
children: Content
|
|
23
23
|
tag: HTMLTags | undefined
|
|
24
24
|
direction: Direction | undefined
|
|
@@ -31,14 +31,14 @@ export interface Props {
|
|
|
31
31
|
export interface StyledProps {
|
|
32
32
|
$element: Pick<
|
|
33
33
|
Props,
|
|
34
|
-
|
|
34
|
+
'contentType' | 'parentDirection' | 'direction' | 'alignX' | 'alignY' | 'equalCols' | 'gap'
|
|
35
35
|
> & {
|
|
36
|
-
extraStyles: Props[
|
|
36
|
+
extraStyles: Props['extendCss']
|
|
37
37
|
}
|
|
38
|
-
$contentType: Props[
|
|
38
|
+
$contentType: Props['contentType']
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
export type ThemeProps = Pick<Props,
|
|
41
|
+
export type ThemeProps = Pick<Props, 'contentType'> & {
|
|
42
42
|
parentDirection: ContentDirection
|
|
43
43
|
direction: ContentDirection
|
|
44
44
|
alignX: ContentAlignX
|
|
@@ -7,20 +7,20 @@
|
|
|
7
7
|
* component+data prop pattern.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type { VNode, VNodeChild } from
|
|
11
|
-
import { Fragment } from
|
|
12
|
-
import { isEmpty, render } from
|
|
13
|
-
import type { ExtendedProps, ObjectValue, Props, SimpleValue } from
|
|
10
|
+
import type { VNode, VNodeChild } from '@pyreon/core'
|
|
11
|
+
import { Fragment } from '@pyreon/core'
|
|
12
|
+
import { isEmpty, render } from '@pyreon/ui-core'
|
|
13
|
+
import type { ExtendedProps, ObjectValue, Props, SimpleValue } from './types'
|
|
14
14
|
|
|
15
15
|
type ClassifiedData =
|
|
16
|
-
| { type:
|
|
17
|
-
| { type:
|
|
16
|
+
| { type: 'simple'; data: SimpleValue[] }
|
|
17
|
+
| { type: 'complex'; data: ObjectValue[] }
|
|
18
18
|
| null
|
|
19
19
|
|
|
20
20
|
const classifyData = (data: unknown[]): ClassifiedData => {
|
|
21
21
|
const items = data.filter(
|
|
22
22
|
(item) =>
|
|
23
|
-
item != null && !(typeof item ===
|
|
23
|
+
item != null && !(typeof item === 'object' && isEmpty(item as Record<string, unknown>)),
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
if (items.length === 0) return null
|
|
@@ -29,9 +29,9 @@ const classifyData = (data: unknown[]): ClassifiedData => {
|
|
|
29
29
|
let isComplex = true
|
|
30
30
|
|
|
31
31
|
for (const item of items) {
|
|
32
|
-
if (typeof item ===
|
|
32
|
+
if (typeof item === 'string' || typeof item === 'number') {
|
|
33
33
|
isComplex = false
|
|
34
|
-
} else if (typeof item ===
|
|
34
|
+
} else if (typeof item === 'object') {
|
|
35
35
|
isSimple = false
|
|
36
36
|
} else {
|
|
37
37
|
isSimple = false
|
|
@@ -39,20 +39,20 @@ const classifyData = (data: unknown[]): ClassifiedData => {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
if (isSimple) return { type:
|
|
43
|
-
if (isComplex) return { type:
|
|
42
|
+
if (isSimple) return { type: 'simple', data: items as SimpleValue[] }
|
|
43
|
+
if (isComplex) return { type: 'complex', data: items as ObjectValue[] }
|
|
44
44
|
return null
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
const RESERVED_PROPS = [
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
'children',
|
|
49
|
+
'component',
|
|
50
|
+
'wrapComponent',
|
|
51
|
+
'data',
|
|
52
|
+
'itemKey',
|
|
53
|
+
'valueName',
|
|
54
|
+
'itemProps',
|
|
55
|
+
'wrapProps',
|
|
56
56
|
] as const
|
|
57
57
|
|
|
58
58
|
type AttachItemProps = ({ i, length }: { i: number; length: number }) => ExtendedProps
|
|
@@ -82,12 +82,12 @@ const Component = (props: Props) => {
|
|
|
82
82
|
itemProps,
|
|
83
83
|
} = props
|
|
84
84
|
|
|
85
|
-
const injectItemProps = typeof itemProps ===
|
|
85
|
+
const injectItemProps = typeof itemProps === 'function' ? itemProps : () => itemProps
|
|
86
86
|
|
|
87
|
-
const injectWrapItemProps = typeof wrapProps ===
|
|
87
|
+
const injectWrapItemProps = typeof wrapProps === 'function' ? wrapProps : () => wrapProps
|
|
88
88
|
|
|
89
89
|
const getKey = (item: string | number, index: number) => {
|
|
90
|
-
if (typeof itemKey ===
|
|
90
|
+
if (typeof itemKey === 'function') return itemKey(item, index)
|
|
91
91
|
return index
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -130,8 +130,8 @@ const Component = (props: Props) => {
|
|
|
130
130
|
|
|
131
131
|
// if children is Fragment — check VNode type
|
|
132
132
|
if (
|
|
133
|
-
typeof children ===
|
|
134
|
-
|
|
133
|
+
typeof children === 'object' &&
|
|
134
|
+
'type' in (children as VNode) &&
|
|
135
135
|
(children as VNode).type === Fragment
|
|
136
136
|
) {
|
|
137
137
|
const fragmentChildren = (children as VNode).children as VNodeChild[]
|
|
@@ -154,7 +154,7 @@ const Component = (props: Props) => {
|
|
|
154
154
|
|
|
155
155
|
return simpleData.map((item, i) => {
|
|
156
156
|
const key = getKey(item, i)
|
|
157
|
-
const keyName = valueName ??
|
|
157
|
+
const keyName = valueName ?? 'children'
|
|
158
158
|
const extendedProps = attachItemProps({
|
|
159
159
|
i,
|
|
160
160
|
length,
|
|
@@ -186,8 +186,8 @@ const Component = (props: Props) => {
|
|
|
186
186
|
// --------------------------------------------------------
|
|
187
187
|
const getObjectKey = (item: ObjectValue, index: number) => {
|
|
188
188
|
if (!itemKey) return item.key ?? item.id ?? item.itemId ?? index
|
|
189
|
-
if (typeof itemKey ===
|
|
190
|
-
if (typeof itemKey ===
|
|
189
|
+
if (typeof itemKey === 'function') return itemKey(item, index)
|
|
190
|
+
if (typeof itemKey === 'string') return item[itemKey]
|
|
191
191
|
|
|
192
192
|
return index
|
|
193
193
|
}
|
|
@@ -236,7 +236,7 @@ const Component = (props: Props) => {
|
|
|
236
236
|
if (component && Array.isArray(data)) {
|
|
237
237
|
const classified = classifyData(data)
|
|
238
238
|
if (!classified) return null
|
|
239
|
-
if (classified.type ===
|
|
239
|
+
if (classified.type === 'simple') return renderSimpleArray(classified.data) as VNodeChild
|
|
240
240
|
return renderComplexArray(classified.data) as VNodeChild
|
|
241
241
|
}
|
|
242
242
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import component from
|
|
1
|
+
import component from './component'
|
|
2
2
|
import type {
|
|
3
3
|
ElementType,
|
|
4
4
|
ExtendedProps,
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
Props,
|
|
7
7
|
PropsCallback,
|
|
8
8
|
SimpleValue,
|
|
9
|
-
} from
|
|
9
|
+
} from './types'
|
|
10
10
|
|
|
11
11
|
export type { ElementType, ExtendedProps, ObjectValue, Props, PropsCallback, SimpleValue }
|
|
12
12
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ComponentFn, VNodeChild } from
|
|
2
|
-
import type { HTMLTags } from
|
|
1
|
+
import type { ComponentFn, VNodeChild } from '@pyreon/core'
|
|
2
|
+
import type { HTMLTags } from '@pyreon/ui-core'
|
|
3
3
|
|
|
4
4
|
export type MaybeNull = undefined | null
|
|
5
5
|
export type TObj = Record<string, unknown>
|
|
@@ -75,5 +75,5 @@ export type Props = Partial<{
|
|
|
75
75
|
*/
|
|
76
76
|
itemKey?:
|
|
77
77
|
| keyof ObjectValue
|
|
78
|
-
| ((item: SimpleValue | Omit<ObjectValue,
|
|
78
|
+
| ((item: SimpleValue | Omit<ObjectValue, 'component'>, index: number) => SimpleValue)
|
|
79
79
|
}>
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* fix (parent + child Styled) because these HTML elements do not natively
|
|
5
5
|
* support `display: flex` consistently across browsers.
|
|
6
6
|
*/
|
|
7
|
-
import { IS_DEVELOPMENT } from
|
|
8
|
-
import Styled from
|
|
9
|
-
import type { Props } from
|
|
10
|
-
import { isWebFixNeeded } from
|
|
7
|
+
import { IS_DEVELOPMENT } from '../../utils'
|
|
8
|
+
import Styled from './styled'
|
|
9
|
+
import type { Props } from './types'
|
|
10
|
+
import { isWebFixNeeded } from './utils'
|
|
11
11
|
|
|
12
|
-
const DEV_PROPS: Record<string, string> = IS_DEVELOPMENT ? {
|
|
12
|
+
const DEV_PROPS: Record<string, string> = IS_DEVELOPMENT ? { 'data-pyr-element': 'Element' } : {}
|
|
13
13
|
|
|
14
14
|
const Component = ({
|
|
15
15
|
children,
|
|
@@ -64,7 +64,7 @@ const Component = ({
|
|
|
64
64
|
)
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
const asTag = isInline ?
|
|
67
|
+
const asTag = isInline ? 'span' : 'div'
|
|
68
68
|
|
|
69
69
|
return (
|
|
70
70
|
<Styled {...COMMON_PROPS} $element={parentFixElement}>
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* split flex behavior across two DOM nodes for button/fieldset/legend
|
|
6
6
|
* elements where a single flex container is insufficient.
|
|
7
7
|
*/
|
|
8
|
-
import { config } from
|
|
9
|
-
import { alignContent, extendCss, makeItResponsive } from
|
|
10
|
-
import type { ResponsiveStylesCallback } from
|
|
11
|
-
import type { StyledProps } from
|
|
8
|
+
import { config } from '@pyreon/ui-core'
|
|
9
|
+
import { alignContent, extendCss, makeItResponsive } from '@pyreon/unistyle'
|
|
10
|
+
import type { ResponsiveStylesCallback } from '../../types'
|
|
11
|
+
import type { StyledProps } from './types'
|
|
12
12
|
|
|
13
13
|
const { styled, css, component } = config
|
|
14
14
|
|
|
@@ -32,10 +32,10 @@ const blockCSS = `
|
|
|
32
32
|
width: 100%;
|
|
33
33
|
`
|
|
34
34
|
|
|
35
|
-
const childFixPosition = (isBlock?: boolean) => `display: ${isBlock ?
|
|
35
|
+
const childFixPosition = (isBlock?: boolean) => `display: ${isBlock ? 'flex' : 'inline-flex'};`
|
|
36
36
|
|
|
37
37
|
const styles: ResponsiveStylesCallback = ({ theme: t, css: cssFn }) => cssFn`
|
|
38
|
-
${t.alignY ===
|
|
38
|
+
${t.alignY === 'block' && fullHeightCSS};
|
|
39
39
|
|
|
40
40
|
${alignContent({
|
|
41
41
|
direction: t.direction,
|
|
@@ -44,7 +44,7 @@ const styles: ResponsiveStylesCallback = ({ theme: t, css: cssFn }) => cssFn`
|
|
|
44
44
|
})};
|
|
45
45
|
|
|
46
46
|
${t.block && blockCSS};
|
|
47
|
-
${t.alignY ===
|
|
47
|
+
${t.alignY === 'block' && t.block && fullHeightCSS};
|
|
48
48
|
|
|
49
49
|
${!t.childFix && childFixPosition(t.block)};
|
|
50
50
|
${t.parentFix && parentFixCSS};
|
|
@@ -61,7 +61,7 @@ export default styled(component)`
|
|
|
61
61
|
${(({ $childFix }: StyledProps) => $childFix && childFixCSS) as any};
|
|
62
62
|
|
|
63
63
|
${makeItResponsive({
|
|
64
|
-
key:
|
|
64
|
+
key: '$element',
|
|
65
65
|
styles,
|
|
66
66
|
css,
|
|
67
67
|
normalize: true,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { VNodeChild } from
|
|
2
|
-
import type { HTMLTags } from
|
|
1
|
+
import type { VNodeChild } from '@pyreon/core'
|
|
2
|
+
import type { HTMLTags } from '@pyreon/ui-core'
|
|
3
3
|
import type {
|
|
4
4
|
AlignX,
|
|
5
5
|
AlignY,
|
|
@@ -11,7 +11,7 @@ import type {
|
|
|
11
11
|
Direction,
|
|
12
12
|
ExtendCss,
|
|
13
13
|
ResponsiveBoolType,
|
|
14
|
-
} from
|
|
14
|
+
} from '../../types'
|
|
15
15
|
|
|
16
16
|
export type Reference = unknown
|
|
17
17
|
|
package/src/helpers/index.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Provider } from
|
|
1
|
+
import { Provider } from '@pyreon/unistyle'
|
|
2
2
|
|
|
3
|
-
export type { ElementProps, PyreonElement } from
|
|
4
|
-
export { Element } from
|
|
3
|
+
export type { ElementProps, PyreonElement } from './Element'
|
|
4
|
+
export { Element } from './Element'
|
|
5
5
|
export type {
|
|
6
6
|
ElementType,
|
|
7
7
|
ExtendedProps,
|
|
@@ -9,16 +9,16 @@ export type {
|
|
|
9
9
|
Props as IteratorProps,
|
|
10
10
|
PropsCallback,
|
|
11
11
|
SimpleValue,
|
|
12
|
-
} from
|
|
13
|
-
export { default as Iterator } from
|
|
14
|
-
export type { ListProps } from
|
|
15
|
-
export { List } from
|
|
16
|
-
export type { OverlayProps, UseOverlayProps } from
|
|
17
|
-
export { Overlay, OverlayProvider, useOverlay } from
|
|
18
|
-
export type { PortalProps } from
|
|
19
|
-
export { Portal } from
|
|
20
|
-
export type { TextProps } from
|
|
21
|
-
export { Text } from
|
|
12
|
+
} from './helpers/Iterator'
|
|
13
|
+
export { default as Iterator } from './helpers/Iterator'
|
|
14
|
+
export type { ListProps } from './List'
|
|
15
|
+
export { List } from './List'
|
|
16
|
+
export type { OverlayProps, UseOverlayProps } from './Overlay'
|
|
17
|
+
export { Overlay, OverlayProvider, useOverlay } from './Overlay'
|
|
18
|
+
export type { PortalProps } from './Portal'
|
|
19
|
+
export { Portal } from './Portal'
|
|
20
|
+
export type { TextProps } from './Text'
|
|
21
|
+
export { Text } from './Text'
|
|
22
22
|
export type {
|
|
23
23
|
AlignX,
|
|
24
24
|
AlignY,
|
|
@@ -30,8 +30,8 @@ export type {
|
|
|
30
30
|
PyreonStatic,
|
|
31
31
|
Responsive,
|
|
32
32
|
ResponsiveBoolType,
|
|
33
|
-
} from
|
|
34
|
-
export type { UtilProps } from
|
|
35
|
-
export { Util } from
|
|
33
|
+
} from './types'
|
|
34
|
+
export type { UtilProps } from './Util'
|
|
35
|
+
export { Util } from './Util'
|
|
36
36
|
|
|
37
37
|
export { Provider }
|
package/src/types.ts
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* value types (single | array | breakpoint-map) for layout props like
|
|
4
4
|
* alignment and direction, plus utility types for merging prop objects.
|
|
5
5
|
*/
|
|
6
|
-
import type { ComponentFn } from
|
|
7
|
-
import type { BreakpointKeys, config, render } from
|
|
8
|
-
import type { MakeItResponsiveStyles } from
|
|
6
|
+
import type { ComponentFn } from '@pyreon/core'
|
|
7
|
+
import type { BreakpointKeys, config, render } from '@pyreon/ui-core'
|
|
8
|
+
import type { MakeItResponsiveStyles } from '@pyreon/unistyle'
|
|
9
9
|
|
|
10
10
|
export type ResponsiveStylesCallback = MakeItResponsiveStyles
|
|
11
11
|
|
|
@@ -29,13 +29,13 @@ export type CssCallback = (css: typeof config.css) => ReturnType<typeof css>
|
|
|
29
29
|
|
|
30
30
|
export type Css = CssCallback | ReturnType<typeof config.css> | string
|
|
31
31
|
|
|
32
|
-
export type Content = Parameters<typeof render>[
|
|
32
|
+
export type Content = Parameters<typeof render>['0']
|
|
33
33
|
|
|
34
|
-
export type ContentAlignX =
|
|
34
|
+
export type ContentAlignX = 'left' | 'center' | 'right' | 'spaceBetween' | 'spaceAround' | 'block'
|
|
35
35
|
|
|
36
|
-
export type ContentAlignY =
|
|
36
|
+
export type ContentAlignY = 'top' | 'center' | 'bottom' | 'spaceBetween' | 'spaceAround' | 'block'
|
|
37
37
|
|
|
38
|
-
export type ContentDirection =
|
|
38
|
+
export type ContentDirection = 'inline' | 'rows' | 'reverseInline' | 'reverseRows'
|
|
39
39
|
|
|
40
40
|
export type ContentBoolean = boolean
|
|
41
41
|
export type ContentSimpleValue = string | number
|
package/src/utils.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const IS_DEVELOPMENT = process.env.NODE_ENV !==
|
|
1
|
+
export const IS_DEVELOPMENT = process.env.NODE_ENV !== 'production'
|