@vitus-labs/elements 2.1.0 → 2.2.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 +101 -43
- package/lib/index.js +4 -4
- package/lib/vitus-labs-elements.native.js +4 -4
- package/package.json +4 -5
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Provider } from "@vitus-labs/unistyle";
|
|
2
2
|
import { BreakpointKeys, HTMLTags, HTMLTextTags, config, render } from "@vitus-labs/core";
|
|
3
3
|
import * as _$react from "react";
|
|
4
|
-
import { ComponentType, FC, ForwardRefExoticComponent, ForwardedRef, ReactElement, ReactNode } from "react";
|
|
4
|
+
import { ComponentType, FC, ForwardRefExoticComponent, ForwardedRef, ReactElement, ReactNode, Ref } from "react";
|
|
5
5
|
|
|
6
6
|
//#region src/types.d.ts
|
|
7
7
|
type ExtractNullableKeys<T> = { [P in keyof T as T[P] extends null | undefined ? never : P]: T[P] };
|
|
@@ -318,48 +318,74 @@ type ExtendedProps = {
|
|
|
318
318
|
even: boolean;
|
|
319
319
|
position: number;
|
|
320
320
|
};
|
|
321
|
-
|
|
322
|
-
|
|
321
|
+
/**
|
|
322
|
+
* Iterator over an array of strings/numbers. Each item is wrapped in
|
|
323
|
+
* `{ [valueName]: item }` and that object is what callbacks see + what's
|
|
324
|
+
* spread onto the rendered component.
|
|
325
|
+
*/
|
|
326
|
+
type SimpleProps<T extends SimpleValue> = {
|
|
327
|
+
data: Array<T | MaybeNull>; /** A React component to be rendered per item. */
|
|
328
|
+
component: ElementType;
|
|
323
329
|
/**
|
|
324
|
-
*
|
|
325
|
-
|
|
330
|
+
* Key under which each primitive value is exposed to `component` and
|
|
331
|
+
* callbacks. Defaults to `'children'` at runtime — i.e. the value is
|
|
332
|
+
* passed to the component as its children.
|
|
333
|
+
*/
|
|
334
|
+
valueName?: string; /** Optional wrapper around each item. */
|
|
335
|
+
wrapComponent?: ElementType; /** Stable key per item (defaults to index). */
|
|
336
|
+
itemKey?: (item: T, index: number) => SimpleValue; /** Extra props merged onto the rendered component, optionally per-item. */
|
|
337
|
+
itemProps?: TObj | ((item: {
|
|
338
|
+
[k: string]: T;
|
|
339
|
+
}, ext: ExtendedProps) => TObj); /** Extra props merged onto the wrapper, optionally per-item. */
|
|
340
|
+
wrapProps?: TObj | ((item: {
|
|
341
|
+
[k: string]: T;
|
|
342
|
+
}, ext: ExtendedProps) => TObj);
|
|
343
|
+
children?: never;
|
|
344
|
+
};
|
|
345
|
+
/**
|
|
346
|
+
* Iterator over an array of objects. Each item is spread onto the rendered
|
|
347
|
+
* component as props. Per-item `component` overrides also work — when an
|
|
348
|
+
* item carries its own `component` field, the wrapper is bypassed.
|
|
349
|
+
*/
|
|
350
|
+
type ObjectProps<T extends ObjectValue> = {
|
|
351
|
+
data: Array<T | MaybeNull>; /** Default React component to be rendered per item (item-level `component` overrides). */
|
|
352
|
+
component: ElementType; /** `valueName` is meaningless when iterating objects — TS forbids it. */
|
|
353
|
+
valueName?: never; /** Optional wrapper around each item. */
|
|
354
|
+
wrapComponent?: ElementType; /** Stable key per item — pick a key from the item, or compute it. */
|
|
355
|
+
itemKey?: keyof T | ((item: T, index: number) => SimpleValue); /** Extra props merged onto the rendered component, optionally per-item. */
|
|
356
|
+
itemProps?: TObj | ((item: T, ext: ExtendedProps) => TObj); /** Extra props merged onto the wrapper, optionally per-item. */
|
|
357
|
+
wrapProps?: TObj | ((item: T, ext: ExtendedProps) => TObj);
|
|
358
|
+
children?: never;
|
|
359
|
+
};
|
|
360
|
+
/**
|
|
361
|
+
* Iterator over `children` — no `data`/`component`. Each child gets
|
|
362
|
+
* positional metadata via `itemProps` and an optional `wrapComponent`.
|
|
363
|
+
*/
|
|
364
|
+
type ChildrenProps = {
|
|
365
|
+
children: ReactNode;
|
|
366
|
+
data?: never;
|
|
367
|
+
component?: never;
|
|
368
|
+
valueName?: never;
|
|
369
|
+
itemKey?: never;
|
|
370
|
+
wrapComponent?: ElementType;
|
|
371
|
+
itemProps?: TObj | ((_: Record<string, never>, ext: ExtendedProps) => TObj);
|
|
372
|
+
wrapProps?: TObj | ((_: Record<string, never>, ext: ExtendedProps) => TObj);
|
|
373
|
+
};
|
|
374
|
+
type PropsCallback = TObj | ((itemProps: Record<string, never> | Record<string, SimpleValue> | ObjectValue, extendedProps: ExtendedProps) => TObj);
|
|
375
|
+
type LooseProps = Partial<{
|
|
326
376
|
children: ReactNode;
|
|
327
|
-
/**
|
|
328
|
-
* Array of data passed to `component` prop
|
|
329
|
-
*/
|
|
330
377
|
data: Array<SimpleValue | ObjectValue | MaybeNull>;
|
|
331
|
-
/**
|
|
332
|
-
* A React component to be rendered within list
|
|
333
|
-
*/
|
|
334
378
|
component: ElementType;
|
|
335
|
-
/**
|
|
336
|
-
* Defines name of the prop to be passed to the iteration component
|
|
337
|
-
* when **data** prop is type of `string[]`, `number[]` or combination
|
|
338
|
-
* of both. Otherwise ignored.
|
|
339
|
-
*/
|
|
340
379
|
valueName: string;
|
|
341
|
-
/**
|
|
342
|
-
* A React component to be rendered within list. `wrapComponent`
|
|
343
|
-
* wraps `component`. Therefore it can be used to enhance the behavior
|
|
344
|
-
* of the list component
|
|
345
|
-
*/
|
|
346
380
|
wrapComponent: ElementType;
|
|
347
|
-
/**
|
|
348
|
-
* Extension of **item** `component` props to be passed
|
|
349
|
-
*/
|
|
350
381
|
itemProps: PropsCallback;
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
*/
|
|
354
|
-
wrapProps?: PropsCallback;
|
|
355
|
-
/**
|
|
356
|
-
* Extension of **item** `wrapComponent` props to be passed
|
|
357
|
-
*/
|
|
358
|
-
itemKey?: keyof ObjectValue | ((item: SimpleValue | Omit<ObjectValue, 'component'>, index: number) => SimpleValue);
|
|
382
|
+
wrapProps: PropsCallback;
|
|
383
|
+
itemKey: keyof ObjectValue | ((item: SimpleValue | Omit<ObjectValue, 'component'>, index: number) => SimpleValue);
|
|
359
384
|
}>;
|
|
385
|
+
type Props$1<T = unknown> = unknown extends T ? LooseProps : T extends SimpleValue ? SimpleProps<T> : T extends ObjectValue ? ObjectProps<T> : ChildrenProps;
|
|
360
386
|
//#endregion
|
|
361
387
|
//#region src/List/component.d.ts
|
|
362
|
-
type
|
|
388
|
+
type ListOnly = {
|
|
363
389
|
/**
|
|
364
390
|
* A boolean value. When set to `false`, component returns `React.Fragment`
|
|
365
391
|
* When set to `true`, component returns as the **root** element `Element`
|
|
@@ -369,14 +395,46 @@ type ListProps = {
|
|
|
369
395
|
/**
|
|
370
396
|
* Label prop from `Element` component is being ignored.
|
|
371
397
|
*/
|
|
372
|
-
label
|
|
398
|
+
label?: never;
|
|
373
399
|
/**
|
|
374
400
|
* Content prop from `Element` component is being ignored.
|
|
375
401
|
*/
|
|
376
|
-
content
|
|
402
|
+
content?: never;
|
|
377
403
|
};
|
|
378
|
-
|
|
379
|
-
|
|
404
|
+
/**
|
|
405
|
+
* Props that List accepts on top of the Iterator branch — the Element prop
|
|
406
|
+
* surface (so `tag`, `direction`, `alignX`, etc. forward when
|
|
407
|
+
* `rootElement` is true) plus the List-only toggle.
|
|
408
|
+
*/
|
|
409
|
+
type ListExtras = Props & ListOnly;
|
|
410
|
+
/**
|
|
411
|
+
* Public Props — generic over the data element type so callers get the same
|
|
412
|
+
* inference Iterator does, plus the List-specific `rootElement` toggle and
|
|
413
|
+
* Element prop forwarding.
|
|
414
|
+
*
|
|
415
|
+
* Props<string> → SimpleProps & ListExtras (valueName REQUIRED)
|
|
416
|
+
* Props<{ id; name }> → ObjectProps & ListExtras (valueName FORBIDDEN)
|
|
417
|
+
* Props<unknown> / Props → LooseProps & ListExtras (today's behavior)
|
|
418
|
+
*/
|
|
419
|
+
type Props$2<T = unknown> = MergeTypes<[Props$1<T>, ListExtras]>;
|
|
420
|
+
/**
|
|
421
|
+
* Ref slot — forwarded to the inner `<Element>` when `rootElement` is true,
|
|
422
|
+
* a no-op otherwise. Typed loosely (`Ref<any>`) because the underlying
|
|
423
|
+
* element type depends on the `tag` prop, which would require deeper
|
|
424
|
+
* conditional typing to resolve precisely.
|
|
425
|
+
*/
|
|
426
|
+
type RefExtra = {
|
|
427
|
+
ref?: Ref<any>;
|
|
428
|
+
};
|
|
429
|
+
interface ListComponent {
|
|
430
|
+
<T extends SimpleValue>(props: SimpleProps<T> & ListExtras & RefExtra): ReactNode;
|
|
431
|
+
<T extends ObjectValue>(props: ObjectProps<T> & ListExtras & RefExtra): ReactNode;
|
|
432
|
+
(props: ChildrenProps & ListExtras & RefExtra): ReactNode;
|
|
433
|
+
displayName?: string;
|
|
434
|
+
pkgName?: string;
|
|
435
|
+
VITUS_LABS__COMPONENT?: string;
|
|
436
|
+
}
|
|
437
|
+
declare const _default: ListComponent;
|
|
380
438
|
//#endregion
|
|
381
439
|
//#region src/Overlay/context.d.ts
|
|
382
440
|
interface Context {
|
|
@@ -384,7 +442,7 @@ interface Context {
|
|
|
384
442
|
setBlocked: () => void;
|
|
385
443
|
setUnblocked: () => void;
|
|
386
444
|
}
|
|
387
|
-
declare const Component$
|
|
445
|
+
declare const Component$2: FC<Context & {
|
|
388
446
|
children: ReactNode;
|
|
389
447
|
}>;
|
|
390
448
|
//#endregion
|
|
@@ -571,7 +629,7 @@ type Props$3 = {
|
|
|
571
629
|
*/
|
|
572
630
|
contentRefName?: string;
|
|
573
631
|
} & UseOverlayProps;
|
|
574
|
-
declare const Component$
|
|
632
|
+
declare const Component$1: VLComponent<Props$3>;
|
|
575
633
|
//#endregion
|
|
576
634
|
//#region src/Portal/component.d.ts
|
|
577
635
|
interface Props$4 {
|
|
@@ -589,7 +647,7 @@ interface Props$4 {
|
|
|
589
647
|
*/
|
|
590
648
|
tag?: string;
|
|
591
649
|
}
|
|
592
|
-
declare const Component$
|
|
650
|
+
declare const Component$3: VLComponent<Props$4>;
|
|
593
651
|
//#endregion
|
|
594
652
|
//#region src/Text/component.d.ts
|
|
595
653
|
type Props$5 = Partial<{
|
|
@@ -614,7 +672,7 @@ type Props$5 = Partial<{
|
|
|
614
672
|
*/
|
|
615
673
|
css: ExtendCss;
|
|
616
674
|
}>;
|
|
617
|
-
declare const Component$
|
|
675
|
+
declare const Component$4: VLComponent<Props$5> & {
|
|
618
676
|
isText?: true;
|
|
619
677
|
};
|
|
620
678
|
//#endregion
|
|
@@ -633,7 +691,7 @@ interface Props$6 {
|
|
|
633
691
|
*/
|
|
634
692
|
style?: Record<string, unknown>;
|
|
635
693
|
}
|
|
636
|
-
declare const Component$
|
|
694
|
+
declare const Component$5: VLComponent<Props$6>;
|
|
637
695
|
//#endregion
|
|
638
|
-
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, type Props$1 as IteratorProps,
|
|
696
|
+
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, type Props$1 as IteratorProps, _default as List, type Props$2 as ListProps, 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 Responsive, type ResponsiveBoolType, Component$4 as Text, type Props$5 as TextProps, type UseOverlayProps, Component$5 as Util, type Props$6 as UtilProps, type VLStatic, useOverlay };
|
|
639
697
|
//# sourceMappingURL=index2.d.ts.map
|
package/lib/index.js
CHANGED
|
@@ -125,11 +125,11 @@ const Component$9 = ({ contentType, tag, parentDirection, direction, alignX, ali
|
|
|
125
125
|
children: render(children)
|
|
126
126
|
});
|
|
127
127
|
};
|
|
128
|
-
var component_default
|
|
128
|
+
var component_default = memo(Component$9);
|
|
129
129
|
|
|
130
130
|
//#endregion
|
|
131
131
|
//#region src/helpers/Content/index.ts
|
|
132
|
-
var Content_default = component_default
|
|
132
|
+
var Content_default = component_default;
|
|
133
133
|
|
|
134
134
|
//#endregion
|
|
135
135
|
//#region src/helpers/Wrapper/styled.ts
|
|
@@ -623,14 +623,14 @@ const Component$6 = ({ itemKey, valueName, children, component, data, wrapCompon
|
|
|
623
623
|
const total = specs.length;
|
|
624
624
|
return Children.toArray(specs.map((spec, i) => renderSpec(spec, buildExtendedProps(i, total), itemProps, wrapProps, Wrapper)));
|
|
625
625
|
};
|
|
626
|
-
|
|
626
|
+
const Iterator = Object.assign(memo(Component$6), {
|
|
627
627
|
isIterator: true,
|
|
628
628
|
RESERVED_PROPS
|
|
629
629
|
});
|
|
630
630
|
|
|
631
631
|
//#endregion
|
|
632
632
|
//#region src/helpers/Iterator/index.ts
|
|
633
|
-
var Iterator_default =
|
|
633
|
+
var Iterator_default = Iterator;
|
|
634
634
|
|
|
635
635
|
//#endregion
|
|
636
636
|
//#region src/List/component.tsx
|
|
@@ -124,11 +124,11 @@ const Component$6 = ({ contentType, tag, parentDirection, direction, alignX, ali
|
|
|
124
124
|
children: render(children)
|
|
125
125
|
});
|
|
126
126
|
};
|
|
127
|
-
var component_default
|
|
127
|
+
var component_default = memo(Component$6);
|
|
128
128
|
|
|
129
129
|
//#endregion
|
|
130
130
|
//#region src/helpers/Content/index.ts
|
|
131
|
-
var Content_default = component_default
|
|
131
|
+
var Content_default = component_default;
|
|
132
132
|
|
|
133
133
|
//#endregion
|
|
134
134
|
//#region src/helpers/Wrapper/styled.ts
|
|
@@ -481,14 +481,14 @@ const Component$3 = ({ itemKey, valueName, children, component, data, wrapCompon
|
|
|
481
481
|
const total = specs.length;
|
|
482
482
|
return Children.toArray(specs.map((spec, i) => renderSpec(spec, buildExtendedProps(i, total), itemProps, wrapProps, Wrapper)));
|
|
483
483
|
};
|
|
484
|
-
|
|
484
|
+
const Iterator = Object.assign(memo(Component$3), {
|
|
485
485
|
isIterator: true,
|
|
486
486
|
RESERVED_PROPS
|
|
487
487
|
});
|
|
488
488
|
|
|
489
489
|
//#endregion
|
|
490
490
|
//#region src/helpers/Iterator/index.ts
|
|
491
|
-
var Iterator_default =
|
|
491
|
+
var Iterator_default = Iterator;
|
|
492
492
|
|
|
493
493
|
//#endregion
|
|
494
494
|
//#region src/List/component.tsx
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitus-labs/elements",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Vit Bokisch <vit@bokisch.cz>",
|
|
6
6
|
"maintainers": [
|
|
@@ -54,12 +54,11 @@
|
|
|
54
54
|
"test:coverage": "vitest run --coverage",
|
|
55
55
|
"test:watch": "vitest",
|
|
56
56
|
"cover": "coveralls < .coverage/lcov.info",
|
|
57
|
-
"typecheck": "tsc --noEmit"
|
|
58
|
-
"version": "node ../../scripts/sync-peer-deps.mjs"
|
|
57
|
+
"typecheck": "tsc --noEmit"
|
|
59
58
|
},
|
|
60
59
|
"peerDependencies": {
|
|
61
|
-
"@vitus-labs/core": "
|
|
62
|
-
"@vitus-labs/unistyle": "
|
|
60
|
+
"@vitus-labs/core": "workspace:^",
|
|
61
|
+
"@vitus-labs/unistyle": "workspace:^",
|
|
63
62
|
"react": ">= 19",
|
|
64
63
|
"react-dom": ">= 19",
|
|
65
64
|
"react-native": ">= 0.76"
|