@pyreon/elements 0.24.4 → 0.24.6
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/package.json +10 -12
- package/src/Element/component.tsx +0 -315
- package/src/Element/constants.ts +0 -96
- package/src/Element/index.ts +0 -6
- package/src/Element/types.ts +0 -168
- package/src/Element/utils.ts +0 -15
- package/src/List/component.tsx +0 -105
- package/src/List/index.ts +0 -5
- package/src/Overlay/component.tsx +0 -140
- package/src/Overlay/context.tsx +0 -36
- package/src/Overlay/index.ts +0 -7
- package/src/Overlay/positioning.ts +0 -191
- package/src/Overlay/useOverlay.tsx +0 -461
- package/src/Portal/component.tsx +0 -54
- package/src/Portal/index.ts +0 -5
- package/src/Text/component.tsx +0 -67
- package/src/Text/index.ts +0 -5
- package/src/Text/styled.ts +0 -30
- package/src/Util/component.tsx +0 -43
- package/src/Util/index.ts +0 -5
- package/src/__tests__/Content.test.tsx +0 -123
- package/src/__tests__/Element-slot-reactivity.browser.test.tsx +0 -152
- package/src/__tests__/Element.test.ts +0 -819
- package/src/__tests__/Iterator.test.ts +0 -492
- package/src/__tests__/Iterator.types.test.ts +0 -237
- package/src/__tests__/List.test.ts +0 -199
- package/src/__tests__/Overlay.test.ts +0 -492
- package/src/__tests__/Portal.test.ts +0 -156
- package/src/__tests__/Text.test.ts +0 -274
- package/src/__tests__/Util.test.ts +0 -63
- package/src/__tests__/Wrapper-innerhtml.test.tsx +0 -178
- package/src/__tests__/Wrapper.test.tsx +0 -196
- package/src/__tests__/elements.browser.test.tsx +0 -132
- package/src/__tests__/equalBeforeAfter.test.ts +0 -122
- package/src/__tests__/helpers.test.ts +0 -65
- package/src/__tests__/integration.test.tsx +0 -118
- package/src/__tests__/internElementBundle.test.ts +0 -102
- package/src/__tests__/iterator-function-children.test.tsx +0 -120
- package/src/__tests__/native-markers.test.ts +0 -13
- package/src/__tests__/overlayContext.test.tsx +0 -78
- package/src/__tests__/perf-stress.browser.test.tsx +0 -119
- package/src/__tests__/positioning.test.ts +0 -90
- package/src/__tests__/responsiveProps.test.ts +0 -328
- package/src/__tests__/slot-component-reference.test.tsx +0 -157
- package/src/__tests__/useOverlay.test.ts +0 -1336
- package/src/__tests__/utils.test.ts +0 -69
- package/src/__tests__/wrapper-block-cascade.test.ts +0 -121
- package/src/constants.ts +0 -1
- package/src/env.d.ts +0 -6
- package/src/helpers/Content/component.tsx +0 -75
- package/src/helpers/Content/index.ts +0 -3
- package/src/helpers/Content/styled.ts +0 -105
- package/src/helpers/Content/types.ts +0 -49
- package/src/helpers/Iterator/component.tsx +0 -316
- package/src/helpers/Iterator/index.ts +0 -30
- package/src/helpers/Iterator/types.ts +0 -138
- package/src/helpers/Wrapper/component.tsx +0 -180
- package/src/helpers/Wrapper/constants.ts +0 -10
- package/src/helpers/Wrapper/index.ts +0 -3
- package/src/helpers/Wrapper/styled.ts +0 -64
- package/src/helpers/Wrapper/types.ts +0 -56
- package/src/helpers/Wrapper/utils.ts +0 -7
- package/src/helpers/index.ts +0 -4
- package/src/helpers/internElementBundle.ts +0 -37
- package/src/helpers/isPyreonComponent.ts +0 -46
- package/src/index.ts +0 -42
- package/src/manifest.ts +0 -190
- package/src/tests/manifest-snapshot.test.ts +0 -45
- package/src/types.ts +0 -112
- package/src/utils.ts +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyreon/elements",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.6",
|
|
4
4
|
"description": "Foundational UI components for Pyreon",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
"!lib/**/*.map",
|
|
14
14
|
"!lib/analysis",
|
|
15
15
|
"README.md",
|
|
16
|
-
"LICENSE"
|
|
17
|
-
"src"
|
|
16
|
+
"LICENSE"
|
|
18
17
|
],
|
|
19
18
|
"type": "module",
|
|
20
19
|
"sideEffects": false,
|
|
@@ -22,7 +21,6 @@
|
|
|
22
21
|
"types": "./lib/index.d.ts",
|
|
23
22
|
"exports": {
|
|
24
23
|
".": {
|
|
25
|
-
"bun": "./src/index.ts",
|
|
26
24
|
"import": "./lib/index.js",
|
|
27
25
|
"types": "./lib/index.d.ts"
|
|
28
26
|
}
|
|
@@ -42,12 +40,12 @@
|
|
|
42
40
|
"typecheck": "tsc --noEmit"
|
|
43
41
|
},
|
|
44
42
|
"devDependencies": {
|
|
45
|
-
"@pyreon/core": "^0.24.
|
|
43
|
+
"@pyreon/core": "^0.24.6",
|
|
46
44
|
"@pyreon/manifest": "0.13.1",
|
|
47
|
-
"@pyreon/reactivity": "^0.24.
|
|
48
|
-
"@pyreon/runtime-dom": "^0.24.
|
|
45
|
+
"@pyreon/reactivity": "^0.24.6",
|
|
46
|
+
"@pyreon/runtime-dom": "^0.24.6",
|
|
49
47
|
"@pyreon/test-utils": "^0.13.11",
|
|
50
|
-
"@pyreon/typescript": "^0.24.
|
|
48
|
+
"@pyreon/typescript": "^0.24.6",
|
|
51
49
|
"@vitest/browser-playwright": "^4.1.4",
|
|
52
50
|
"@vitus-labs/tools-rolldown": "^2.4.0"
|
|
53
51
|
},
|
|
@@ -55,9 +53,9 @@
|
|
|
55
53
|
"node": ">= 22"
|
|
56
54
|
},
|
|
57
55
|
"dependencies": {
|
|
58
|
-
"@pyreon/core": "^0.24.
|
|
59
|
-
"@pyreon/reactivity": "^0.24.
|
|
60
|
-
"@pyreon/ui-core": "^0.24.
|
|
61
|
-
"@pyreon/unistyle": "^0.24.
|
|
56
|
+
"@pyreon/core": "^0.24.6",
|
|
57
|
+
"@pyreon/reactivity": "^0.24.6",
|
|
58
|
+
"@pyreon/ui-core": "^0.24.6",
|
|
59
|
+
"@pyreon/unistyle": "^0.24.6"
|
|
62
60
|
}
|
|
63
61
|
}
|
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core building block of the elements package. Renders a three-section layout
|
|
3
|
-
* (beforeContent / content / afterContent) inside a flex Wrapper. When only
|
|
4
|
-
* content is present, the Wrapper inherits content-level alignment directly
|
|
5
|
-
* to avoid an unnecessary nesting layer. Handles HTML-specific edge cases
|
|
6
|
-
* like void elements (input, img) and inline elements (span, a) by
|
|
7
|
-
* skipping children or switching sub-tags accordingly.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { h, onMount, splitProps } from '@pyreon/core'
|
|
11
|
-
import type { ComponentFn, VNodeChildAtom } from '@pyreon/core'
|
|
12
|
-
import { render } from '@pyreon/ui-core'
|
|
13
|
-
import { PKG_NAME } from '../constants'
|
|
14
|
-
import { Content, Wrapper } from '../helpers'
|
|
15
|
-
import { internElementBundle } from '../helpers/internElementBundle'
|
|
16
|
-
import { isPyreonComponent } from '../helpers/isPyreonComponent'
|
|
17
|
-
import WrapperStyled from '../helpers/Wrapper/styled'
|
|
18
|
-
import { isWebFixNeeded } from '../helpers/Wrapper/utils'
|
|
19
|
-
import { IS_DEVELOPMENT } from '../utils'
|
|
20
|
-
import type { PyreonElement } from './types'
|
|
21
|
-
import { getShouldBeEmpty, isInlineElement } from './utils'
|
|
22
|
-
|
|
23
|
-
const WRAPPER_DEV_PROPS: Record<string, string> = IS_DEVELOPMENT
|
|
24
|
-
? { 'data-pyr-element': 'Element' }
|
|
25
|
-
: {}
|
|
26
|
-
|
|
27
|
-
const equalize = (el: HTMLElement, direction: unknown) => {
|
|
28
|
-
const beforeEl = el.firstElementChild as HTMLElement | null
|
|
29
|
-
const afterEl = el.lastElementChild as HTMLElement | null
|
|
30
|
-
|
|
31
|
-
if (beforeEl && afterEl && beforeEl !== afterEl) {
|
|
32
|
-
const type: 'height' | 'width' = direction === 'rows' ? 'height' : 'width'
|
|
33
|
-
const prop = type === 'height' ? 'offsetHeight' : 'offsetWidth'
|
|
34
|
-
const beforeSize = beforeEl[prop]
|
|
35
|
-
const afterSize = afterEl[prop]
|
|
36
|
-
|
|
37
|
-
if (Number.isInteger(beforeSize) && Number.isInteger(afterSize)) {
|
|
38
|
-
const maxSize = `${Math.max(beforeSize, afterSize)}px`
|
|
39
|
-
beforeEl.style[type] = maxSize
|
|
40
|
-
afterEl.style[type] = maxSize
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const defaultDirection = 'inline'
|
|
46
|
-
const defaultContentDirection = 'rows'
|
|
47
|
-
const defaultAlignX = 'left'
|
|
48
|
-
const defaultAlignY = 'center'
|
|
49
|
-
|
|
50
|
-
const Component: PyreonElement = (props) => {
|
|
51
|
-
const [own, rest] = splitProps(props, [
|
|
52
|
-
'innerRef',
|
|
53
|
-
'tag',
|
|
54
|
-
'label',
|
|
55
|
-
'content',
|
|
56
|
-
'children',
|
|
57
|
-
'beforeContent',
|
|
58
|
-
'afterContent',
|
|
59
|
-
'equalBeforeAfter',
|
|
60
|
-
'block',
|
|
61
|
-
'equalCols',
|
|
62
|
-
'gap',
|
|
63
|
-
'direction',
|
|
64
|
-
'alignX',
|
|
65
|
-
'alignY',
|
|
66
|
-
'css',
|
|
67
|
-
'contentCss',
|
|
68
|
-
'beforeContentCss',
|
|
69
|
-
'afterContentCss',
|
|
70
|
-
'contentDirection',
|
|
71
|
-
'contentAlignX',
|
|
72
|
-
'contentAlignY',
|
|
73
|
-
'beforeContentDirection',
|
|
74
|
-
'beforeContentAlignX',
|
|
75
|
-
'beforeContentAlignY',
|
|
76
|
-
'afterContentDirection',
|
|
77
|
-
'afterContentAlignX',
|
|
78
|
-
'afterContentAlignY',
|
|
79
|
-
'ref',
|
|
80
|
-
])
|
|
81
|
-
|
|
82
|
-
const alignX = own.alignX ?? defaultAlignX
|
|
83
|
-
const alignY = own.alignY ?? defaultAlignY
|
|
84
|
-
const contentDirection = own.contentDirection ?? defaultContentDirection
|
|
85
|
-
const contentAlignX = own.contentAlignX ?? defaultAlignX
|
|
86
|
-
const contentAlignY = own.contentAlignY ?? defaultAlignY
|
|
87
|
-
const beforeContentDirection = own.beforeContentDirection ?? defaultDirection
|
|
88
|
-
const beforeContentAlignX = own.beforeContentAlignX ?? defaultAlignX
|
|
89
|
-
const beforeContentAlignY = own.beforeContentAlignY ?? defaultAlignY
|
|
90
|
-
const afterContentDirection = own.afterContentDirection ?? defaultDirection
|
|
91
|
-
const afterContentAlignX = own.afterContentAlignX ?? defaultAlignX
|
|
92
|
-
const afterContentAlignY = own.afterContentAlignY ?? defaultAlignY
|
|
93
|
-
|
|
94
|
-
// --------------------------------------------------------
|
|
95
|
-
// check if should render only single element
|
|
96
|
-
// --------------------------------------------------------
|
|
97
|
-
const shouldBeEmpty = !!rest.dangerouslySetInnerHTML || getShouldBeEmpty(own.tag)
|
|
98
|
-
|
|
99
|
-
// --------------------------------------------------------
|
|
100
|
-
// if not single element, calculate values
|
|
101
|
-
// --------------------------------------------------------
|
|
102
|
-
const isSimpleElement = !own.beforeContent && !own.afterContent
|
|
103
|
-
// Getter — preserves reactivity of own.content (which may be _rp() wrapped).
|
|
104
|
-
// Reading own.content via ?? at setup would capture the value once.
|
|
105
|
-
const getChildren = () => own.children ?? own.content ?? own.label
|
|
106
|
-
|
|
107
|
-
// Resolve a slot value INSIDE a reactive accessor. If the consumer passed a
|
|
108
|
-
// function-returning-VNode (e.g. `content={() => <Icon name={signal()} />}`),
|
|
109
|
-
// unwrap it by calling — its body's signal reads are then tracked by the
|
|
110
|
-
// enclosing mountReactive effect, and the slot re-renders on signal change.
|
|
111
|
-
// Static VNodes / strings / null pass through unchanged to `render()`.
|
|
112
|
-
//
|
|
113
|
-
// **Component vs accessor discriminator** (regression fix for the
|
|
114
|
-
// 0.24.3 → 0.24.4 follow-up — see #839 for the original reactive-slot fix):
|
|
115
|
-
// `beforeContent={Header}` (component-reference shorthand) and
|
|
116
|
-
// `content={() => <X />}` (reactive accessor) are BOTH `typeof === 'function'`.
|
|
117
|
-
// PR #839 called both bare, which crashed component shorthands the moment a
|
|
118
|
-
// rocketstyle / attrs HOC ran `removeUndefinedProps(undefined)` on the
|
|
119
|
-
// un-supplied props (`TypeError: Cannot convert undefined or null to object`).
|
|
120
|
-
//
|
|
121
|
-
// Discriminator: framework components carry one of two markers attached by
|
|
122
|
-
// their factory:
|
|
123
|
-
// - `IS_ROCKETSTYLE` — anything `rocketstyle()` produces
|
|
124
|
-
// - `PYREON__COMPONENT` / `pkgName` — `@pyreon/elements` components
|
|
125
|
-
// (Element, Text, List, Portal, Overlay, Util)
|
|
126
|
-
// Marked function → mount as `h(Component, null)` (no props, defaults
|
|
127
|
-
// fill in via the HOC pipeline). Unmarked function → reactive accessor,
|
|
128
|
-
// called bare so its return value (a VNode) renders. Bare-function
|
|
129
|
-
// components without HOC wrapping (e.g. `const MyComp = () => <div />`)
|
|
130
|
-
// also work via the accessor path — they're called with no args and
|
|
131
|
-
// their VNode return goes through `render()` correctly. The marker
|
|
132
|
-
// check ONLY rescues components that REQUIRE props to be defined.
|
|
133
|
-
//
|
|
134
|
-
// Return type is the RESOLVED atom (VNodeChildAtom | VNodeChildAtom[]) —
|
|
135
|
-
// never a nested accessor — so the enclosing `() => resolveSlot(...)` IS
|
|
136
|
-
// a valid VNodeChildAccessor in the JSX child position.
|
|
137
|
-
const resolveSlot = (value: unknown): VNodeChildAtom | VNodeChildAtom[] => {
|
|
138
|
-
if (typeof value === 'function') {
|
|
139
|
-
if (isPyreonComponent(value)) {
|
|
140
|
-
return h(value as ComponentFn, null) as VNodeChildAtom
|
|
141
|
-
}
|
|
142
|
-
return (value as () => VNodeChildAtom | VNodeChildAtom[])()
|
|
143
|
-
}
|
|
144
|
-
return render(value as Parameters<typeof render>[0]) as VNodeChildAtom | VNodeChildAtom[]
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const isInline = isInlineElement(own.tag)
|
|
148
|
-
const SUB_TAG = isInline ? 'span' : undefined
|
|
149
|
-
|
|
150
|
-
// --------------------------------------------------------
|
|
151
|
-
// direction & alignX & alignY calculations
|
|
152
|
-
// --------------------------------------------------------
|
|
153
|
-
let wrapperDirection: typeof own.direction = own.direction
|
|
154
|
-
let wrapperAlignX: typeof alignX = alignX
|
|
155
|
-
let wrapperAlignY: typeof alignY = alignY
|
|
156
|
-
|
|
157
|
-
if (isSimpleElement) {
|
|
158
|
-
if (contentDirection) wrapperDirection = contentDirection
|
|
159
|
-
if (contentAlignX) wrapperAlignX = contentAlignX
|
|
160
|
-
if (contentAlignY) wrapperAlignY = contentAlignY
|
|
161
|
-
} else if (own.direction) {
|
|
162
|
-
wrapperDirection = own.direction
|
|
163
|
-
} else {
|
|
164
|
-
wrapperDirection = defaultDirection
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// --------------------------------------------------------
|
|
168
|
-
// equalBeforeAfter: measure & equalize slot dimensions
|
|
169
|
-
// --------------------------------------------------------
|
|
170
|
-
let equalizeRef: HTMLElement | null = null
|
|
171
|
-
const externalRef = own.ref ?? own.innerRef
|
|
172
|
-
|
|
173
|
-
const mergedRef = (node: HTMLElement | null) => {
|
|
174
|
-
equalizeRef = node
|
|
175
|
-
if (typeof externalRef === 'function') (externalRef as (el: HTMLElement | null) => void)(node)
|
|
176
|
-
else if (externalRef != null) {
|
|
177
|
-
;(externalRef as unknown as { current: HTMLElement | null }).current = node
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (own.equalBeforeAfter && own.beforeContent && own.afterContent) {
|
|
182
|
-
// Run once on mount AND continue equalizing as the element resizes —
|
|
183
|
-
// catches async slot content (font swaps, lazy text, viewport resize)
|
|
184
|
-
// that a one-shot measurement would miss. Mirrors vitus-labs's Element
|
|
185
|
-
// useLayoutEffect + ResizeObserver pattern.
|
|
186
|
-
onMount(() => {
|
|
187
|
-
const node = equalizeRef
|
|
188
|
-
if (!node) return undefined
|
|
189
|
-
|
|
190
|
-
equalize(node, own.direction)
|
|
191
|
-
|
|
192
|
-
if (typeof ResizeObserver === 'undefined') return undefined
|
|
193
|
-
const observer = new ResizeObserver(() => equalize(node, own.direction))
|
|
194
|
-
observer.observe(node)
|
|
195
|
-
return () => observer.disconnect()
|
|
196
|
-
})
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// --------------------------------------------------------
|
|
200
|
-
// common wrapper props
|
|
201
|
-
// --------------------------------------------------------
|
|
202
|
-
const WRAPPER_PROPS = {
|
|
203
|
-
ref: mergedRef,
|
|
204
|
-
extendCss: own.css,
|
|
205
|
-
tag: own.tag,
|
|
206
|
-
block: own.block,
|
|
207
|
-
direction: wrapperDirection,
|
|
208
|
-
alignX: wrapperAlignX,
|
|
209
|
-
alignY: wrapperAlignY,
|
|
210
|
-
as: undefined, // reset styled-components `as` prop
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// --------------------------------------------------------
|
|
214
|
-
// return simple/empty element like input or image etc.
|
|
215
|
-
// --------------------------------------------------------
|
|
216
|
-
if (shouldBeEmpty) {
|
|
217
|
-
return <Wrapper {...rest} {...WRAPPER_PROPS} />
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// Simple-Element fast path: no beforeContent / afterContent slots, and no
|
|
221
|
-
// button/fieldset/legend two-layer flex fix needed. Inline the Wrapper
|
|
222
|
-
// helper directly into a single Styled invocation — saves one component
|
|
223
|
-
// hop, one splitProps call, and one mountChild per Element. The Wrapper
|
|
224
|
-
// helper still exists for the rare needsFix case below; tests that asserted
|
|
225
|
-
// Wrapper appears in the VNode tree are updated to the new shape.
|
|
226
|
-
const dangerouslySetInnerHTML = (rest as { dangerouslySetInnerHTML?: unknown })
|
|
227
|
-
.dangerouslySetInnerHTML
|
|
228
|
-
const needsFix = !dangerouslySetInnerHTML && isWebFixNeeded(own.tag)
|
|
229
|
-
|
|
230
|
-
if (isSimpleElement && !needsFix) {
|
|
231
|
-
return (
|
|
232
|
-
<WrapperStyled
|
|
233
|
-
{...rest}
|
|
234
|
-
{...WRAPPER_DEV_PROPS}
|
|
235
|
-
ref={mergedRef}
|
|
236
|
-
as={own.tag}
|
|
237
|
-
$element={internElementBundle({
|
|
238
|
-
block: own.block,
|
|
239
|
-
direction: wrapperDirection,
|
|
240
|
-
alignX: wrapperAlignX,
|
|
241
|
-
alignY: wrapperAlignY,
|
|
242
|
-
equalCols: own.equalCols,
|
|
243
|
-
extraStyles: own.css,
|
|
244
|
-
})}
|
|
245
|
-
>
|
|
246
|
-
{() => resolveSlot(getChildren())}
|
|
247
|
-
</WrapperStyled>
|
|
248
|
-
)
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
if (isSimpleElement) {
|
|
252
|
-
return (
|
|
253
|
-
<Wrapper {...rest} {...WRAPPER_PROPS} isInline={isInline}>
|
|
254
|
-
{() => resolveSlot(getChildren())}
|
|
255
|
-
</Wrapper>
|
|
256
|
-
)
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
return (
|
|
260
|
-
<Wrapper {...rest} {...WRAPPER_PROPS} isInline={isInline}>
|
|
261
|
-
{own.beforeContent && (
|
|
262
|
-
<Content
|
|
263
|
-
tag={SUB_TAG}
|
|
264
|
-
contentType="before"
|
|
265
|
-
parentDirection={wrapperDirection}
|
|
266
|
-
extendCss={own.beforeContentCss}
|
|
267
|
-
direction={beforeContentDirection}
|
|
268
|
-
alignX={beforeContentAlignX}
|
|
269
|
-
alignY={beforeContentAlignY}
|
|
270
|
-
equalCols={own.equalCols}
|
|
271
|
-
gap={own.gap}
|
|
272
|
-
>
|
|
273
|
-
{() => resolveSlot(own.beforeContent)}
|
|
274
|
-
</Content>
|
|
275
|
-
)}
|
|
276
|
-
|
|
277
|
-
<Content
|
|
278
|
-
tag={SUB_TAG}
|
|
279
|
-
contentType="content"
|
|
280
|
-
parentDirection={wrapperDirection}
|
|
281
|
-
extendCss={own.contentCss}
|
|
282
|
-
direction={contentDirection}
|
|
283
|
-
alignX={contentAlignX}
|
|
284
|
-
alignY={contentAlignY}
|
|
285
|
-
equalCols={own.equalCols}
|
|
286
|
-
>
|
|
287
|
-
{() => resolveSlot(getChildren())}
|
|
288
|
-
</Content>
|
|
289
|
-
|
|
290
|
-
{own.afterContent && (
|
|
291
|
-
<Content
|
|
292
|
-
tag={SUB_TAG}
|
|
293
|
-
contentType="after"
|
|
294
|
-
parentDirection={wrapperDirection}
|
|
295
|
-
extendCss={own.afterContentCss}
|
|
296
|
-
direction={afterContentDirection}
|
|
297
|
-
alignX={afterContentAlignX}
|
|
298
|
-
alignY={afterContentAlignY}
|
|
299
|
-
equalCols={own.equalCols}
|
|
300
|
-
gap={own.gap}
|
|
301
|
-
>
|
|
302
|
-
{() => resolveSlot(own.afterContent)}
|
|
303
|
-
</Content>
|
|
304
|
-
)}
|
|
305
|
-
</Wrapper>
|
|
306
|
-
)
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
const name = `${PKG_NAME}/Element` as const
|
|
310
|
-
|
|
311
|
-
Component.displayName = name
|
|
312
|
-
Component.pkgName = PKG_NAME
|
|
313
|
-
Component.PYREON__COMPONENT = name
|
|
314
|
-
|
|
315
|
-
export default Component
|
package/src/Element/constants.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/** Props consumed by Element that should not be forwarded to the underlying DOM node. */
|
|
2
|
-
export const RESERVED_PROPS = [
|
|
3
|
-
'innerRef',
|
|
4
|
-
'tag',
|
|
5
|
-
'block',
|
|
6
|
-
'label',
|
|
7
|
-
'children',
|
|
8
|
-
'beforeContent',
|
|
9
|
-
'afterContent',
|
|
10
|
-
|
|
11
|
-
'equalCols',
|
|
12
|
-
'vertical',
|
|
13
|
-
'direction',
|
|
14
|
-
'alignX',
|
|
15
|
-
'alignY',
|
|
16
|
-
|
|
17
|
-
'css',
|
|
18
|
-
'contentCss',
|
|
19
|
-
'beforeContentCss',
|
|
20
|
-
'afterContentCss',
|
|
21
|
-
|
|
22
|
-
'contentDirection',
|
|
23
|
-
'contentAlignX',
|
|
24
|
-
'contentAlignY',
|
|
25
|
-
|
|
26
|
-
'beforeContentDirection',
|
|
27
|
-
'beforeContentAlignX',
|
|
28
|
-
'beforeContentAlignY',
|
|
29
|
-
|
|
30
|
-
'afterContentDirection',
|
|
31
|
-
'afterContentAlignX',
|
|
32
|
-
'afterContentAlignY',
|
|
33
|
-
] as const
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* HTML tags that are inline-level by default. When Element renders one of
|
|
37
|
-
* these tags, child Content wrappers use `span` instead of `div` to
|
|
38
|
-
* preserve valid HTML nesting.
|
|
39
|
-
*/
|
|
40
|
-
export const INLINE_ELEMENTS = {
|
|
41
|
-
span: true,
|
|
42
|
-
a: true,
|
|
43
|
-
button: true,
|
|
44
|
-
input: true,
|
|
45
|
-
label: true,
|
|
46
|
-
select: true,
|
|
47
|
-
textarea: true,
|
|
48
|
-
br: true,
|
|
49
|
-
img: true,
|
|
50
|
-
strong: true,
|
|
51
|
-
small: true,
|
|
52
|
-
code: true,
|
|
53
|
-
b: true,
|
|
54
|
-
big: true,
|
|
55
|
-
i: true,
|
|
56
|
-
tt: true,
|
|
57
|
-
abbr: true,
|
|
58
|
-
acronym: true,
|
|
59
|
-
cite: true,
|
|
60
|
-
dfn: true,
|
|
61
|
-
em: true,
|
|
62
|
-
kbd: true,
|
|
63
|
-
samp: true,
|
|
64
|
-
var: true,
|
|
65
|
-
bdo: true,
|
|
66
|
-
map: true,
|
|
67
|
-
object: true,
|
|
68
|
-
q: true,
|
|
69
|
-
script: true,
|
|
70
|
-
sub: true,
|
|
71
|
-
sup: true,
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* HTML void/self-closing elements that cannot have children. When Element
|
|
76
|
-
* detects one of these tags, it skips rendering beforeContent/content/afterContent
|
|
77
|
-
* and returns the Wrapper alone.
|
|
78
|
-
*/
|
|
79
|
-
export const EMPTY_ELEMENTS = {
|
|
80
|
-
area: true,
|
|
81
|
-
base: true,
|
|
82
|
-
br: true,
|
|
83
|
-
col: true,
|
|
84
|
-
embed: true,
|
|
85
|
-
hr: true,
|
|
86
|
-
img: true,
|
|
87
|
-
input: true,
|
|
88
|
-
keygen: true,
|
|
89
|
-
link: true,
|
|
90
|
-
textarea: true,
|
|
91
|
-
// 'meta': true,
|
|
92
|
-
// 'param': true,
|
|
93
|
-
source: true,
|
|
94
|
-
track: true,
|
|
95
|
-
wbr: true,
|
|
96
|
-
}
|
package/src/Element/index.ts
DELETED
package/src/Element/types.ts
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import type { ComponentFn, PyreonHTMLAttributes } from '@pyreon/core'
|
|
2
|
-
import type { HTMLTags } from '@pyreon/ui-core'
|
|
3
|
-
import type {
|
|
4
|
-
AlignX,
|
|
5
|
-
AlignY,
|
|
6
|
-
Content,
|
|
7
|
-
Direction,
|
|
8
|
-
ExtendCss,
|
|
9
|
-
InnerRef,
|
|
10
|
-
PyreonStatic,
|
|
11
|
-
Responsive,
|
|
12
|
-
ResponsiveBoolType,
|
|
13
|
-
} from '../types'
|
|
14
|
-
|
|
15
|
-
export type Props = Partial<{
|
|
16
|
-
/**
|
|
17
|
-
* Valid HTML Tag
|
|
18
|
-
*/
|
|
19
|
-
tag: HTMLTags
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Ref prop, alternative to `ref`
|
|
23
|
-
*/
|
|
24
|
-
innerRef: InnerRef
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Valid `children`
|
|
28
|
-
*/
|
|
29
|
-
children: Content
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Alternative prop to `children`
|
|
33
|
-
* It is recommended to pass only one of `children`, `content` or `label` props
|
|
34
|
-
*
|
|
35
|
-
* The prioritization of rendering is following: `children` → `content` → `label`
|
|
36
|
-
*/
|
|
37
|
-
content: Content
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Alternative prop to `children`
|
|
41
|
-
* It is recommended to pass only one of `children`, `content` or `label` props
|
|
42
|
-
*
|
|
43
|
-
* The prioritization of rendering is following: `children` → `content` → `label`
|
|
44
|
-
*/
|
|
45
|
-
label: Content
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Valid `children` to be rendered inside _beforeContent_ wrapper
|
|
49
|
-
*/
|
|
50
|
-
beforeContent: Content
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Valid `children` to be rendered inside _afterContent_ wrapper
|
|
54
|
-
*/
|
|
55
|
-
afterContent: Content
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* A boolean type to define whether **Element** should behave
|
|
59
|
-
* as an inline or block element (`flex` vs. `inline-flex`)
|
|
60
|
-
*/
|
|
61
|
-
block: ResponsiveBoolType
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* A boolean type to define whether inner wrappers should be equal
|
|
65
|
-
* (have the same width or height)
|
|
66
|
-
*/
|
|
67
|
-
equalCols: ResponsiveBoolType
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* When true, measures the `beforeContent` and `afterContent` slot wrappers
|
|
71
|
-
* after render and sets both to the larger dimension so they match.
|
|
72
|
-
*/
|
|
73
|
-
equalBeforeAfter: boolean
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Defines a `gap` spacing between inner wrappers
|
|
77
|
-
*/
|
|
78
|
-
gap: Responsive
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Defines direction of inner wrappers
|
|
82
|
-
*/
|
|
83
|
-
direction: Direction
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Defines flow of `children` elements within its inner wrapper.
|
|
87
|
-
*/
|
|
88
|
-
contentDirection: Direction
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Defines flow of `beforeContent` elements within its inner wrapper.
|
|
92
|
-
*/
|
|
93
|
-
beforeContentDirection: Direction
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Defines flow of `afterContent` elements within its inner wrapper.
|
|
97
|
-
*/
|
|
98
|
-
afterContentDirection: Direction
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Define alignment horizontally.
|
|
102
|
-
*/
|
|
103
|
-
alignX: AlignX
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Defines how `content` children are aligned horizontally.
|
|
107
|
-
*/
|
|
108
|
-
contentAlignX: AlignX
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Defines how `beforeContent` children are aligned horizontally.
|
|
112
|
-
*/
|
|
113
|
-
beforeContentAlignX: AlignX
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Defines how `afterContent` children are aligned horizontally.
|
|
117
|
-
*/
|
|
118
|
-
afterContentAlignX: AlignX
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Define alignment vertically.
|
|
122
|
-
*/
|
|
123
|
-
alignY: AlignY
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Defines how `content` children are aligned vertically.
|
|
127
|
-
*/
|
|
128
|
-
contentAlignY: AlignY
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Defines how `beforeContent` children are aligned vertically.
|
|
132
|
-
*/
|
|
133
|
-
beforeContentAlignY: AlignY
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Defines how `afterContent` children are aligned vertically.
|
|
137
|
-
*/
|
|
138
|
-
afterContentAlignY: AlignY
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* `dangerouslySetInnerHTML` prop
|
|
142
|
-
*/
|
|
143
|
-
dangerouslySetInnerHTML: { __html: string }
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* An additional prop for extending styling of the **root** wrapper element
|
|
147
|
-
*/
|
|
148
|
-
css: ExtendCss
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* An additional prop for extending styling of the **content** wrapper element.
|
|
152
|
-
*/
|
|
153
|
-
contentCss: ExtendCss
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* An additional prop for extending styling of the **beforeContent** wrapper element.
|
|
157
|
-
*/
|
|
158
|
-
beforeContentCss: ExtendCss
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* An additional prop for extending styling of the **afterContent** wrapper element.
|
|
162
|
-
*/
|
|
163
|
-
afterContentCss: ExtendCss
|
|
164
|
-
}> &
|
|
165
|
-
PyreonHTMLAttributes
|
|
166
|
-
|
|
167
|
-
export type PyreonElement<P extends Record<string, unknown> = {}> = ComponentFn<Props & P> &
|
|
168
|
-
PyreonStatic
|
package/src/Element/utils.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { EMPTY_ELEMENTS, INLINE_ELEMENTS } from './constants'
|
|
2
|
-
|
|
3
|
-
type GetValue = (tag?: string) => boolean
|
|
4
|
-
|
|
5
|
-
/** Checks whether the given HTML tag is an inline-level element, used to determine sub-tag nesting. */
|
|
6
|
-
export const isInlineElement: GetValue = (tag) => {
|
|
7
|
-
if (tag && tag in INLINE_ELEMENTS) return true
|
|
8
|
-
return false
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/** Checks whether the given HTML tag is a void element that cannot have children. */
|
|
12
|
-
export const getShouldBeEmpty: GetValue = (tag) => {
|
|
13
|
-
if (tag && tag in EMPTY_ELEMENTS) return true
|
|
14
|
-
return false
|
|
15
|
-
}
|