@vitus-labs/elements 2.0.0-alpha.9 → 2.0.0-beta.1

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 CHANGED
@@ -16,12 +16,12 @@ Five composable components for building buttons, cards, lists, dropdowns, toolti
16
16
  - **Portal** — React Portal wrapper for DOM appending
17
17
  - **Util** — non-rendering utility for injecting className and style
18
18
  - **Responsive everything** — single value, array, or breakpoint object on every layout prop
19
- - **Selection state** — `withActiveState` HOC for single/multi item selection on List
19
+ - **Equal before/after** — `equalBeforeAfter` prop on Element to equalize slot dimensions
20
20
 
21
21
  ## Installation
22
22
 
23
23
  ```bash
24
- npm install @vitus-labs/elements @vitus-labs/core @vitus-labs/unistyle styled-components
24
+ npm install @vitus-labs/elements @vitus-labs/core @vitus-labs/unistyle
25
25
  ```
26
26
 
27
27
  ## Components
@@ -161,33 +161,6 @@ import { List, Element } from '@vitus-labs/elements'
161
161
 
162
162
  `index`, `first`, `last`, `odd`, `even`, `position` (1-based)
163
163
 
164
- ### withActiveState
165
-
166
- HOC that adds selection state management to List.
167
-
168
- ```tsx
169
- import { List, withActiveState } from '@vitus-labs/elements'
170
-
171
- const SelectableList = withActiveState(List)
172
-
173
- <SelectableList
174
- type="single"
175
- component={ListItem}
176
- data={items}
177
- activeItems="item-1"
178
- />
179
-
180
- <SelectableList
181
- type="multi"
182
- component={ListItem}
183
- data={items}
184
- activeItems={['item-1', 'item-3']}
185
- activeItemRequired
186
- />
187
- ```
188
-
189
- Each item receives: `active`, `handleItemActive`, `setItemActive`, `unsetItemActive`, `toggleItemActive`.
190
-
191
164
  ### Overlay
192
165
 
193
166
  Portal-based overlay with intelligent positioning and event management.
@@ -298,6 +271,10 @@ Every layout prop (direction, alignX, alignY, gap, block, equalCols) supports th
298
271
  <Element direction={{ xs: 'rows', md: 'inline', lg: 'inline' }} />
299
272
  ```
300
273
 
274
+ ## React Native
275
+
276
+ Elements includes a native entry point (`index.native.ts`) that excludes Portal and Overlay (which depend on `react-dom`). Element, Text, List, and Util work on React Native when initialized with `@vitus-labs/connector-native`.
277
+
301
278
  ## Peer Dependencies
302
279
 
303
280
  | Package | Version |
@@ -306,7 +283,7 @@ Every layout prop (direction, alignX, alignY, gap, block, equalCols) supports th
306
283
  | react-dom | >= 19 |
307
284
  | @vitus-labs/core | * |
308
285
  | @vitus-labs/unistyle | * |
309
- | styled-components | >= 6 |
286
+ | react-native | >= 0.76 (optional) |
310
287
 
311
288
  ## License
312
289
 
package/lib/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { Provider } from "@vitus-labs/unistyle";
2
2
  import { BreakpointKeys, HTMLTags, HTMLTextTags, config, render } from "@vitus-labs/core";
3
- import * as react from "react";
4
- import { ComponentType, FC, ForwardRefExoticComponent, ForwardedRef, PropsWithoutRef, ReactNode, Ref, RefAttributes } from "react";
5
- import * as react_jsx_runtime0 from "react/jsx-runtime";
3
+ import * as _$react from "react";
4
+ import { ComponentType, FC, ForwardRefExoticComponent, ForwardedRef, ReactElement, ReactNode } from "react";
6
5
 
7
6
  //#region src/types.d.ts
8
7
  type ExtractNullableKeys<T> = { [P in keyof T as T[P] extends null | undefined ? never : P]: T[P] };
@@ -10,7 +9,6 @@ type Id<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;
10
9
  type SpreadTwo<L, R> = Id<Pick<L, Exclude<keyof L, keyof R>> & R>;
11
10
  type Spread<A extends readonly [...any]> = A extends [infer L, ...infer R] ? SpreadTwo<L, Spread<R>> : unknown;
12
11
  type MergeTypes<A extends readonly [...any]> = ExtractNullableKeys<Spread<A>>;
13
- type SimpleHoc<P extends Record<string, unknown> = {}> = (WrappedComponent: ComponentType<P>) => ComponentType<P>;
14
12
  type InnerRef = ForwardedRef<any>;
15
13
  type CssCallback = (css: typeof config.css) => ReturnType<typeof css>;
16
14
  type Css = CssCallback | ReturnType<typeof config.css> | string;
@@ -26,8 +24,9 @@ type Direction = ContentDirection | ContentDirection[] | Partial<Record<Breakpoi
26
24
  type ResponsiveBoolType = ContentBoolean | ContentBoolean[] | Partial<Record<BreakpointKeys, ContentBoolean>>;
27
25
  type Responsive = ContentSimpleValue | ContentSimpleValue[] | Partial<Record<BreakpointKeys, number | string>>;
28
26
  type ExtendCss = Css | Css[] | Partial<Record<BreakpointKeys, Css>>;
29
- type VLForwardedComponent<P extends Record<string, unknown> = {}> = ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<any>> & VLStatic;
30
- type VLComponent<P extends Record<string, any> = {}> = FC<P> & VLStatic;
27
+ type VLComponent<P extends Record<string, any> = {}> = ((props: P & {
28
+ ref?: any;
29
+ }) => ReactElement | null) & VLStatic;
31
30
  interface VLStatic {
32
31
  /**
33
32
  * React displayName
@@ -109,6 +108,14 @@ type Props = Partial<{
109
108
  * (have the same width or height)
110
109
  */
111
110
  equalCols: ResponsiveBoolType;
111
+ /**
112
+ * When true, measures the `beforeContent` and `afterContent` slot wrappers
113
+ * after render and sets both to the larger dimension so they match.
114
+ * Uses width for inline direction and height for rows direction.
115
+ * Useful for centering the main content when before/after slots have
116
+ * different intrinsic sizes.
117
+ */
118
+ equalBeforeAfter: boolean;
112
119
  /**
113
120
  * Defines a `gap` spacing between inner wrappers between `beforeContent` and `children`
114
121
  * and `children` and `afterContent`
@@ -270,220 +277,28 @@ type Props = Partial<{
270
277
  */
271
278
  css: ExtendCss;
272
279
  /**
273
- * An additional prop for extending styling of the **content** wrapper element
274
- *
275
- * #### [A] Template literals
276
- *
277
- * (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
278
- *
279
- * ```jsx
280
- * export default () => (
281
- * <Element
282
- * label="This is an element"
283
- * css={`
284
- * text-color: red;
285
- * `}
286
- * />
287
- * )
288
- * ```
289
- *
290
- * #### [B] String
291
- *
292
- * (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
293
- *
294
- * ```jsx
295
- * export default () => (
296
- * <Element
297
- * label="This is an element"
298
- * css="text-color: red;"
299
- * />
300
- * )
301
- * ```
302
- *
303
- * #### [C] Css Function
304
- *
305
- * (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
306
- *
307
- * ```jsx
308
- * import { css } from 'styled-components'
309
- *
310
- * export default () => (
311
- * <Element
312
- * label="This is an element"
313
- * css={css`
314
- * text-color: red;
315
- * `}
316
- * />
317
- * )
318
- * ```
319
- *
320
- * #### [D] Css Callback
321
- *
322
- * (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
323
- *
324
- * ```jsx
325
- * export default () => (
326
- * <Element
327
- * label="This is an element"
328
- * css={css => css`
329
- * text-color: red;
330
- * `}
331
- * />
332
- * )
333
- * ```
280
+ * An additional prop for extending styling of the **content** wrapper element.
281
+ * Accepts the same formats as `css` — template literal, string, css function, or callback.
334
282
  */
335
283
  contentCss: ExtendCss;
336
284
  /**
337
- * An additional prop for extending styling of the **beforeContent** wrapper element
338
- *
339
- * #### [A] Template literals
340
- *
341
- * (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
342
- *
343
- * ```jsx
344
- * export default () => (
345
- * <Element
346
- * label="This is an element"
347
- * css={`
348
- * text-color: red;
349
- * `}
350
- * />
351
- * )
352
- * ```
353
- *
354
- * #### [B] String
355
- *
356
- * (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
357
- *
358
- * ```jsx
359
- * export default () => (
360
- * <Element
361
- * label="This is an element"
362
- * css="text-color: red;"
363
- * />
364
- * )
365
- * ```
366
- *
367
- * #### [C] Css Function
368
- *
369
- * (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
370
- *
371
- * ```jsx
372
- * import { css } from 'styled-components'
373
- *
374
- * export default () => (
375
- * <Element
376
- * label="This is an element"
377
- * css={css`
378
- * text-color: red;
379
- * `}
380
- * />
381
- * )
382
- * ```
383
- *
384
- * #### [D] Css Callback
385
- *
386
- * (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
387
- *
388
- * ```jsx
389
- * export default () => (
390
- * <Element
391
- * label="This is an element"
392
- * css={css => css`
393
- * text-color: red;
394
- * `}
395
- * />
396
- * )
397
- * ```
285
+ * An additional prop for extending styling of the **beforeContent** wrapper element.
286
+ * Accepts the same formats as `css` — template literal, string, css function, or callback.
398
287
  */
399
288
  beforeContentCss: ExtendCss;
400
289
  /**
401
- * An additional prop for extending styling of the **afterContent** wrapper element
402
- *
403
- * #### [A] Template literals
404
- *
405
- * (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
406
- *
407
- * ```jsx
408
- * export default () => (
409
- * <Element
410
- * label="This is an element"
411
- * css={`
412
- * text-color: red;
413
- * `}
414
- * />
415
- * )
416
- * ```
417
- *
418
- * #### [B] String
419
- *
420
- * (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
421
- *
422
- * ```jsx
423
- * export default () => (
424
- * <Element
425
- * label="This is an element"
426
- * css="text-color: red;"
427
- * />
428
- * )
429
- * ```
430
- *
431
- * #### [C] Css Function
432
- *
433
- * (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
434
- *
435
- * ```jsx
436
- * import { css } from 'styled-components'
437
- *
438
- * export default () => (
439
- * <Element
440
- * label="This is an element"
441
- * css={css`
442
- * text-color: red;
443
- * `}
444
- * />
445
- * )
446
- * ```
447
- *
448
- * #### [D] Css Callback
449
- *
450
- * (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
451
- *
452
- * ```jsx
453
- * export default () => (
454
- * <Element
455
- * label="This is an element"
456
- * css={css => css`
457
- * text-color: red;
458
- * `}
459
- * />
460
- * )
461
- * ```
290
+ * An additional prop for extending styling of the **afterContent** wrapper element.
291
+ * Accepts the same formats as `css` — template literal, string, css function, or callback.
462
292
  */
463
293
  afterContentCss: ExtendCss;
464
294
  }>;
465
- type VLElement<P extends Record<string, unknown> = {}> = ForwardRefExoticComponent<PropsWithoutRef<Props & P> & RefAttributes<any>> & VLStatic;
295
+ type VLElement<P extends Record<string, unknown> = {}> = ((props: Props & P & {
296
+ ref?: any;
297
+ }) => ReactElement | null) & VLStatic;
466
298
  //#endregion
467
299
  //#region src/Element/component.d.ts
468
300
  declare const Component: VLElement;
469
301
  //#endregion
470
- //#region src/Element/withEqualSizeBeforeAfter.d.ts
471
- type Props$8 = Props & Partial<{
472
- equalBeforeAfter: boolean;
473
- ref: Ref<HTMLElement>;
474
- }>;
475
- declare const withEqualBeforeAfter: (WrappedComponent: any) => {
476
- ({
477
- equalBeforeAfter,
478
- direction,
479
- afterContent,
480
- beforeContent,
481
- ref,
482
- ...rest
483
- }: Props$8): react_jsx_runtime0.JSX.Element;
484
- displayName: string;
485
- };
486
- //#endregion
487
302
  //#region src/helpers/Iterator/types.d.ts
488
303
  type MaybeNull = undefined | null;
489
304
  type TObj = Record<string, unknown>;
@@ -563,16 +378,6 @@ type ListProps = {
563
378
  type Props$2 = MergeTypes<[Props$1, ListProps]>;
564
379
  declare const Component$1: VLElement<Props$2>;
565
380
  //#endregion
566
- //#region src/List/withActiveState.d.ts
567
- type Key = string | number;
568
- interface Props$7 {
569
- type?: 'single' | 'multi';
570
- activeItemRequired?: boolean;
571
- activeItems?: Key | (string | number)[];
572
- itemProps?: Record<string, unknown> | ((props: Record<string, unknown>) => Record<string, unknown>);
573
- }
574
- declare const component: SimpleHoc<Props$7>;
575
- //#endregion
576
381
  //#region src/Overlay/context.d.ts
577
382
  interface Context {
578
383
  blocked: boolean;
@@ -583,10 +388,13 @@ declare const Component$3: FC<Context & {
583
388
  children: ReactNode;
584
389
  }>;
585
390
  //#endregion
586
- //#region src/Overlay/useOverlay.d.ts
391
+ //#region src/Overlay/positionMath.d.ts
587
392
  type Align$1 = 'bottom' | 'top' | 'left' | 'right';
588
393
  type AlignX$2 = 'left' | 'center' | 'right';
589
394
  type AlignY$2 = 'bottom' | 'top' | 'center';
395
+ type OverlayType = 'dropdown' | 'tooltip' | 'popover' | 'modal' | 'custom';
396
+ //#endregion
397
+ //#region src/Overlay/useOverlay.d.ts
590
398
  type UseOverlayProps = Partial<{
591
399
  /**
592
400
  * Defines default state whether **Overlay** component should be active.
@@ -610,7 +418,7 @@ type UseOverlayProps = Partial<{
610
418
  * has different positioning calculations than others.
611
419
  * @defaultValue `dropdown`
612
420
  */
613
- type: 'dropdown' | 'tooltip' | 'popover' | 'modal' | 'custom';
421
+ type: OverlayType;
614
422
  /**
615
423
  * Defines how `content` is treated regarding CSS positioning.
616
424
  * @defaultValue `fixed`
@@ -659,6 +467,12 @@ type UseOverlayProps = Partial<{
659
467
  * @defaultValue `true`
660
468
  */
661
469
  closeOnEsc: boolean;
470
+ /**
471
+ * Delay in milliseconds before hiding content on hover leave. Bridges the
472
+ * gap between trigger and content elements to prevent flicker.
473
+ * @defaultValue `100`
474
+ */
475
+ hoverDelay: number;
662
476
  /**
663
477
  * When set to `true`, **Overlay** is automatically closed and is blocked for
664
478
  * being opened.
@@ -689,12 +503,13 @@ declare const useOverlay: ({
689
503
  throttleDelay,
690
504
  parentContainer,
691
505
  closeOnEsc,
506
+ hoverDelay,
692
507
  disabled,
693
508
  onOpen,
694
509
  onClose
695
510
  }?: Partial<UseOverlayProps>) => {
696
- triggerRef: react.RefObject<HTMLElement | null>;
697
- contentRef: (node: HTMLElement) => void;
511
+ triggerRef: _$react.RefObject<HTMLElement | null>;
512
+ contentRef: (node: HTMLElement | null) => void;
698
513
  active: boolean;
699
514
  align: Align$1;
700
515
  alignX: "left" | "right" | "center";
@@ -704,8 +519,8 @@ declare const useOverlay: ({
704
519
  blocked: boolean;
705
520
  setBlocked: () => void;
706
521
  setUnblocked: () => void;
707
- Provider: react.FC<Context & {
708
- children: react.ReactNode;
522
+ Provider: _$react.FC<Context & {
523
+ children: _$react.ReactNode;
709
524
  }>;
710
525
  };
711
526
  //#endregion
@@ -799,7 +614,7 @@ type Props$5 = Partial<{
799
614
  */
800
615
  css: ExtendCss;
801
616
  }>;
802
- declare const Component$5: VLForwardedComponent<Props$5> & {
617
+ declare const Component$5: VLComponent<Props$5> & {
803
618
  isText?: true;
804
619
  };
805
620
  //#endregion
@@ -820,5 +635,5 @@ interface Props$6 {
820
635
  }
821
636
  declare const Component$6: VLComponent<Props$6>;
822
637
  //#endregion
823
- 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, Component$1 as List, type Props$2 as ListProps, type ObjectValue, Component$2 as Overlay, type Props$3 as OverlayProps, Component$3 as OverlayProvider, Component$4 as Portal, type Props$4 as PortalProps, type PropsCallback, Provider, type Responsive, type ResponsiveBoolType, Component$5 as Text, type Props$5 as TextProps, type UseOverlayProps, Component$6 as Util, type Props$6 as UtilProps, type VLStatic, useOverlay, component as withActiveState, withEqualBeforeAfter as withEqualSizeBeforeAfter };
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, Component$1 as List, type Props$2 as ListProps, type ObjectValue, Component$2 as Overlay, type Props$3 as OverlayProps, Component$3 as OverlayProvider, Component$4 as Portal, type Props$4 as PortalProps, type PropsCallback, Provider, type Responsive, type ResponsiveBoolType, Component$5 as Text, type Props$5 as TextProps, type UseOverlayProps, Component$6 as Util, type Props$6 as UtilProps, type VLStatic, useOverlay };
824
639
  //# sourceMappingURL=index2.d.ts.map