@pyreon/elements 0.14.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 +113 -56
- package/lib/index.js +200 -180
- package/package.json +14 -13
- package/src/Element/component.tsx +16 -4
- package/src/List/component.tsx +65 -15
- package/src/Overlay/component.tsx +6 -1
- package/src/Overlay/context.tsx +5 -1
- 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__/Overlay.test.ts +8 -1
- package/src/__tests__/Portal.test.ts +122 -48
- package/src/__tests__/Wrapper-innerhtml.test.tsx +178 -0
- package/src/__tests__/Wrapper.test.tsx +44 -0
- package/src/__tests__/elements.browser.test.tsx +77 -4
- package/src/__tests__/internElementBundle.test.ts +102 -0
- package/src/__tests__/native-markers.test.ts +13 -0
- package/src/__tests__/useOverlay.test.ts +7 -1
- package/src/__tests__/wrapper-block-cascade.test.ts +121 -0
- package/src/env.d.ts +6 -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 +67 -30
- package/src/helpers/Wrapper/styled.ts +12 -18
- package/src/helpers/internElementBundle.ts +37 -0
- package/src/index.ts +4 -0
- package/src/types.ts +33 -2
- package/src/utils.ts +1 -4
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Provider } from "@pyreon/unistyle";
|
|
2
|
-
import * as _pyreon_core0 from "@pyreon/core";
|
|
2
|
+
import * as _$_pyreon_core0 from "@pyreon/core";
|
|
3
3
|
import { ComponentFn, PyreonHTMLAttributes, VNodeChild } from "@pyreon/core";
|
|
4
4
|
import { BreakpointKeys, HTMLTags, HTMLTextTags, config, render } from "@pyreon/ui-core";
|
|
5
|
-
import * as _pyreon_reactivity0 from "@pyreon/reactivity";
|
|
5
|
+
import * as _$_pyreon_reactivity0 from "@pyreon/reactivity";
|
|
6
6
|
|
|
7
7
|
//#region src/types.d.ts
|
|
8
8
|
type ExtractNullableKeys<T> = { [P in keyof T as T[P] extends null | undefined ? never : P]: T[P] };
|
|
@@ -182,54 +182,87 @@ type ExtendedProps = {
|
|
|
182
182
|
even: boolean;
|
|
183
183
|
position: number;
|
|
184
184
|
};
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
/**
|
|
186
|
+
* Iterator over an array of strings/numbers. Each item is wrapped in
|
|
187
|
+
* `{ [valueName]: item }` and that object is what callbacks see + what's
|
|
188
|
+
* spread onto the rendered component.
|
|
189
|
+
*/
|
|
190
|
+
type SimpleProps<T extends SimpleValue> = {
|
|
191
|
+
data: Array<T | MaybeNull>; /** A component to be rendered per item. */
|
|
192
|
+
component: ElementType;
|
|
187
193
|
/**
|
|
188
|
-
*
|
|
189
|
-
|
|
194
|
+
* Key under which each primitive value is exposed to `component` and
|
|
195
|
+
* callbacks. Defaults to `'children'` at runtime — i.e. the value is
|
|
196
|
+
* passed to the component as its children.
|
|
197
|
+
*/
|
|
198
|
+
valueName?: string; /** Optional wrapper around each item. */
|
|
199
|
+
wrapComponent?: ElementType; /** Stable key per item (defaults to index). */
|
|
200
|
+
itemKey?: (item: T, index: number) => SimpleValue; /** Extra props merged onto the rendered component, optionally per-item. */
|
|
201
|
+
itemProps?: TObj | ((item: {
|
|
202
|
+
[k: string]: T;
|
|
203
|
+
}, ext: ExtendedProps) => TObj); /** Extra props merged onto the wrapper, optionally per-item. */
|
|
204
|
+
wrapProps?: TObj | ((item: {
|
|
205
|
+
[k: string]: T;
|
|
206
|
+
}, ext: ExtendedProps) => TObj);
|
|
207
|
+
children?: never;
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Iterator over an array of objects. Each item is spread onto the rendered
|
|
211
|
+
* component as props. Per-item `component` overrides also work — when an
|
|
212
|
+
* item carries its own `component` field, the wrapper is bypassed.
|
|
213
|
+
*/
|
|
214
|
+
type ObjectProps<T extends ObjectValue> = {
|
|
215
|
+
data: Array<T | MaybeNull>; /** Default component to be rendered per item (item-level `component` overrides). */
|
|
216
|
+
component: ElementType; /** `valueName` is meaningless when iterating objects — TS forbids it. */
|
|
217
|
+
valueName?: never; /** Optional wrapper around each item. */
|
|
218
|
+
wrapComponent?: ElementType; /** Stable key per item — pick a key from the item, or compute it. */
|
|
219
|
+
itemKey?: keyof T | ((item: T, index: number) => SimpleValue); /** Extra props merged onto the rendered component, optionally per-item. */
|
|
220
|
+
itemProps?: TObj | ((item: T, ext: ExtendedProps) => TObj); /** Extra props merged onto the wrapper, optionally per-item. */
|
|
221
|
+
wrapProps?: TObj | ((item: T, ext: ExtendedProps) => TObj);
|
|
222
|
+
children?: never;
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* Iterator over `children` — no `data`/`component`. Each child gets
|
|
226
|
+
* positional metadata via `itemProps` and an optional `wrapComponent`.
|
|
227
|
+
*/
|
|
228
|
+
type ChildrenProps = {
|
|
229
|
+
children: VNodeChild;
|
|
230
|
+
data?: never;
|
|
231
|
+
component?: never;
|
|
232
|
+
valueName?: never;
|
|
233
|
+
itemKey?: never;
|
|
234
|
+
wrapComponent?: ElementType;
|
|
235
|
+
itemProps?: TObj | ((_: Record<string, never>, ext: ExtendedProps) => TObj);
|
|
236
|
+
wrapProps?: TObj | ((_: Record<string, never>, ext: ExtendedProps) => TObj);
|
|
237
|
+
};
|
|
238
|
+
type PropsCallback = TObj | ((itemProps: Record<string, never> | Record<string, SimpleValue> | ObjectValue, extendedProps: ExtendedProps) => TObj);
|
|
239
|
+
type LooseProps = Partial<{
|
|
190
240
|
children: VNodeChild;
|
|
191
|
-
/**
|
|
192
|
-
* Array of data passed to `component` prop
|
|
193
|
-
*/
|
|
194
241
|
data: Array<SimpleValue | ObjectValue | MaybeNull>;
|
|
195
|
-
/**
|
|
196
|
-
* A component to be rendered within list
|
|
197
|
-
*/
|
|
198
242
|
component: ElementType;
|
|
199
|
-
/**
|
|
200
|
-
* Defines name of the prop to be passed to the iteration component
|
|
201
|
-
* when **data** prop is type of `string[]`, `number[]` or combination
|
|
202
|
-
* of both. Otherwise ignored.
|
|
203
|
-
*/
|
|
204
243
|
valueName: string;
|
|
205
|
-
/**
|
|
206
|
-
* A component to be rendered within list. `wrapComponent`
|
|
207
|
-
* wraps `component`. Therefore it can be used to enhance the behavior
|
|
208
|
-
* of the list component
|
|
209
|
-
*/
|
|
210
244
|
wrapComponent: ElementType;
|
|
211
|
-
/**
|
|
212
|
-
* Extension of **item** `component` props to be passed
|
|
213
|
-
*/
|
|
214
245
|
itemProps: PropsCallback;
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
*/
|
|
218
|
-
wrapProps?: PropsCallback;
|
|
219
|
-
/**
|
|
220
|
-
* Extension of **item** `wrapComponent` props to be passed
|
|
221
|
-
*/
|
|
222
|
-
itemKey?: keyof ObjectValue | ((item: SimpleValue | Omit<ObjectValue, 'component'>, index: number) => SimpleValue);
|
|
246
|
+
wrapProps: PropsCallback;
|
|
247
|
+
itemKey: keyof ObjectValue | ((item: SimpleValue | Omit<ObjectValue, 'component'>, index: number) => SimpleValue);
|
|
223
248
|
}>;
|
|
249
|
+
type Props$1<T = unknown> = unknown extends T ? LooseProps : T extends SimpleValue ? SimpleProps<T> : T extends ObjectValue ? ObjectProps<T> : ChildrenProps;
|
|
224
250
|
//#endregion
|
|
225
251
|
//#region src/helpers/Iterator/component.d.ts
|
|
226
|
-
declare const
|
|
252
|
+
declare const RESERVED_PROPS: readonly ["children", "component", "wrapComponent", "data", "itemKey", "valueName", "itemProps", "wrapProps"];
|
|
253
|
+
interface IteratorComponent {
|
|
254
|
+
<T extends SimpleValue>(props: SimpleProps<T>): VNodeChild;
|
|
255
|
+
<T extends ObjectValue>(props: ObjectProps<T>): VNodeChild;
|
|
256
|
+
(props: ChildrenProps): VNodeChild;
|
|
257
|
+
(props: LooseProps): VNodeChild;
|
|
227
258
|
isIterator: true;
|
|
228
|
-
RESERVED_PROPS:
|
|
229
|
-
|
|
259
|
+
RESERVED_PROPS: typeof RESERVED_PROPS;
|
|
260
|
+
displayName?: string;
|
|
261
|
+
}
|
|
262
|
+
declare const Iterator: IteratorComponent;
|
|
230
263
|
//#endregion
|
|
231
264
|
//#region src/List/component.d.ts
|
|
232
|
-
type
|
|
265
|
+
type ListOnly = {
|
|
233
266
|
/**
|
|
234
267
|
* A boolean value. When set to `false`, component returns fragment.
|
|
235
268
|
* When set to `true`, component returns as the **root** element `Element`
|
|
@@ -239,14 +272,38 @@ type ListProps = {
|
|
|
239
272
|
/**
|
|
240
273
|
* Label prop from `Element` component is being ignored.
|
|
241
274
|
*/
|
|
242
|
-
label
|
|
275
|
+
label?: never;
|
|
243
276
|
/**
|
|
244
277
|
* Content prop from `Element` component is being ignored.
|
|
245
278
|
*/
|
|
246
|
-
content
|
|
279
|
+
content?: never;
|
|
247
280
|
};
|
|
248
|
-
|
|
249
|
-
|
|
281
|
+
/**
|
|
282
|
+
* Props that List accepts on top of the Iterator branch — the Element prop
|
|
283
|
+
* surface (so `tag`, `direction`, `alignX`, etc. forward when
|
|
284
|
+
* `rootElement` is true) plus the List-only toggle.
|
|
285
|
+
*/
|
|
286
|
+
type ListExtras = Partial<Omit<Props, 'children' | 'content' | 'label'>> & ListOnly;
|
|
287
|
+
/**
|
|
288
|
+
* Public Props — generic over the data element type so callers get the same
|
|
289
|
+
* inference Iterator does, plus the List-specific `rootElement` toggle and
|
|
290
|
+
* Element prop forwarding.
|
|
291
|
+
*
|
|
292
|
+
* Props<string> → SimpleProps & ListExtras (valueName REQUIRED)
|
|
293
|
+
* Props<{ id; name }> → ObjectProps & ListExtras (valueName FORBIDDEN)
|
|
294
|
+
* Props<unknown> / Props → LooseProps & ListExtras (today's behavior)
|
|
295
|
+
*/
|
|
296
|
+
type Props$2<T = unknown> = MergeTypes<[Props$1<T>, ListExtras]>;
|
|
297
|
+
interface ListComponent {
|
|
298
|
+
<T extends SimpleValue>(props: SimpleProps<T> & ListExtras): VNodeChild;
|
|
299
|
+
<T extends ObjectValue>(props: ObjectProps<T> & ListExtras): VNodeChild;
|
|
300
|
+
(props: ChildrenProps & ListExtras): VNodeChild;
|
|
301
|
+
(props: LooseProps & ListExtras): VNodeChild;
|
|
302
|
+
displayName?: string;
|
|
303
|
+
pkgName?: string;
|
|
304
|
+
PYREON__COMPONENT?: string;
|
|
305
|
+
}
|
|
306
|
+
declare const _default: ListComponent;
|
|
250
307
|
//#endregion
|
|
251
308
|
//#region src/Overlay/context.d.ts
|
|
252
309
|
interface OverlayContext {
|
|
@@ -254,9 +311,9 @@ interface OverlayContext {
|
|
|
254
311
|
setBlocked: () => void;
|
|
255
312
|
setUnblocked: () => void;
|
|
256
313
|
}
|
|
257
|
-
declare const Component$
|
|
314
|
+
declare const Component$2: (props: OverlayContext & {
|
|
258
315
|
children: VNodeChild;
|
|
259
|
-
}) => _pyreon_core0.VNode;
|
|
316
|
+
}) => _$_pyreon_core0.VNode;
|
|
260
317
|
//#endregion
|
|
261
318
|
//#region src/Overlay/positioning.d.ts
|
|
262
319
|
type Align$1 = 'bottom' | 'top' | 'left' | 'right';
|
|
@@ -304,10 +361,10 @@ declare const useOverlay: ({
|
|
|
304
361
|
}?: Partial<UseOverlayProps>) => {
|
|
305
362
|
triggerRef: (node: HTMLElement | null) => void;
|
|
306
363
|
contentRef: (node: HTMLElement | null) => void;
|
|
307
|
-
active: _pyreon_reactivity0.Signal<boolean>;
|
|
364
|
+
active: _$_pyreon_reactivity0.Signal<boolean>;
|
|
308
365
|
align: Align$1;
|
|
309
|
-
alignX: _pyreon_reactivity0.Signal<AlignX$2>;
|
|
310
|
-
alignY: _pyreon_reactivity0.Signal<AlignY$2>;
|
|
366
|
+
alignX: _$_pyreon_reactivity0.Signal<AlignX$2>;
|
|
367
|
+
alignY: _$_pyreon_reactivity0.Signal<AlignY$2>;
|
|
311
368
|
showContent: () => void;
|
|
312
369
|
hideContent: () => void;
|
|
313
370
|
blocked: () => boolean;
|
|
@@ -315,8 +372,8 @@ declare const useOverlay: ({
|
|
|
315
372
|
setUnblocked: () => void;
|
|
316
373
|
setupListeners: () => () => void;
|
|
317
374
|
Provider: (props: OverlayContext & {
|
|
318
|
-
children: _pyreon_core0.VNodeChild;
|
|
319
|
-
}) => _pyreon_core0.VNode;
|
|
375
|
+
children: _$_pyreon_core0.VNodeChild;
|
|
376
|
+
}) => _$_pyreon_core0.VNode;
|
|
320
377
|
};
|
|
321
378
|
//#endregion
|
|
322
379
|
//#region src/Overlay/component.d.ts
|
|
@@ -343,24 +400,24 @@ type Props$3 = {
|
|
|
343
400
|
triggerRefName?: string;
|
|
344
401
|
contentRefName?: string;
|
|
345
402
|
} & UseOverlayProps;
|
|
346
|
-
declare const Component$
|
|
403
|
+
declare const Component$1: PyreonComponent<Props$3>;
|
|
347
404
|
//#endregion
|
|
348
405
|
//#region src/Portal/component.d.ts
|
|
349
406
|
interface Props$4 {
|
|
350
407
|
/**
|
|
351
|
-
*
|
|
408
|
+
* DOM element to mount the wrapper into. Defaults to `document.body`.
|
|
352
409
|
*/
|
|
353
410
|
DOMLocation?: HTMLElement;
|
|
354
411
|
/**
|
|
355
|
-
* Children
|
|
412
|
+
* Children rendered inside the wrapper.
|
|
356
413
|
*/
|
|
357
414
|
children: VNodeChild;
|
|
358
415
|
/**
|
|
359
|
-
*
|
|
416
|
+
* HTML tag for the per-instance wrapper element. Defaults to `'div'`.
|
|
360
417
|
*/
|
|
361
418
|
tag?: string;
|
|
362
419
|
}
|
|
363
|
-
declare const Component$
|
|
420
|
+
declare const Component$3: PyreonComponent<Props$4>;
|
|
364
421
|
//#endregion
|
|
365
422
|
//#region src/Text/component.d.ts
|
|
366
423
|
type Props$5 = Partial<{
|
|
@@ -385,7 +442,7 @@ type Props$5 = Partial<{
|
|
|
385
442
|
*/
|
|
386
443
|
css: ExtendCss;
|
|
387
444
|
}> & PyreonHTMLAttributes;
|
|
388
|
-
declare const Component$
|
|
445
|
+
declare const Component$4: PyreonComponent<Props$5> & {
|
|
389
446
|
isText?: true;
|
|
390
447
|
};
|
|
391
448
|
//#endregion
|
|
@@ -404,7 +461,7 @@ interface Props$6 {
|
|
|
404
461
|
*/
|
|
405
462
|
style?: Record<string, unknown> | undefined;
|
|
406
463
|
}
|
|
407
|
-
declare const Component$
|
|
464
|
+
declare const Component$5: PyreonComponent<Props$6>;
|
|
408
465
|
//#endregion
|
|
409
|
-
export { type AlignX, type AlignY, type Content, type ContentBoolean, type Direction, Component as Element, type Props as ElementProps, type ElementType, type ExtendCss, type ExtendedProps, type InnerRef,
|
|
466
|
+
export { type AlignX, type AlignY, type Content, type ContentBoolean, type Direction, Component as Element, type Props as ElementProps, type ElementType, type ExtendCss, type ExtendedProps, type InnerRef, Iterator, type ChildrenProps as IteratorChildrenProps, type LooseProps as IteratorLooseProps, type ObjectProps as IteratorObjectProps, type Props$1 as IteratorProps, type SimpleProps as IteratorSimpleProps, _default as List, type Props$2 as ListProps, type MaybeNull, type ObjectValue, Component$1 as Overlay, type Props$3 as OverlayProps, Component$2 as OverlayProvider, Component$3 as Portal, type Props$4 as PortalProps, type PropsCallback, Provider, type PyreonElement, type PyreonStatic, type Responsive, type ResponsiveBoolType, type SimpleValue, Component$4 as Text, type Props$5 as TextProps, type UseOverlayProps, Component$5 as Util, type Props$6 as UtilProps, useOverlay };
|
|
410
467
|
//# sourceMappingURL=index2.d.ts.map
|