@vitus-labs/elements 2.0.0-alpha.9 → 2.0.0-beta.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/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
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";
4
+ import { ComponentType, FC, ForwardRefExoticComponent, ForwardedRef, PropsWithoutRef, ReactNode, RefAttributes } 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;
@@ -109,6 +107,14 @@ type Props = Partial<{
109
107
  * (have the same width or height)
110
108
  */
111
109
  equalCols: ResponsiveBoolType;
110
+ /**
111
+ * When true, measures the `beforeContent` and `afterContent` slot wrappers
112
+ * after render and sets both to the larger dimension so they match.
113
+ * Uses width for inline direction and height for rows direction.
114
+ * Useful for centering the main content when before/after slots have
115
+ * different intrinsic sizes.
116
+ */
117
+ equalBeforeAfter: boolean;
112
118
  /**
113
119
  * Defines a `gap` spacing between inner wrappers between `beforeContent` and `children`
114
120
  * and `children` and `afterContent`
@@ -270,195 +276,18 @@ type Props = Partial<{
270
276
  */
271
277
  css: ExtendCss;
272
278
  /**
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
- * ```
279
+ * An additional prop for extending styling of the **content** wrapper element.
280
+ * Accepts the same formats as `css` — template literal, string, css function, or callback.
334
281
  */
335
282
  contentCss: ExtendCss;
336
283
  /**
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
- * ```
284
+ * An additional prop for extending styling of the **beforeContent** wrapper element.
285
+ * Accepts the same formats as `css` — template literal, string, css function, or callback.
398
286
  */
399
287
  beforeContentCss: ExtendCss;
400
288
  /**
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
- * ```
289
+ * An additional prop for extending styling of the **afterContent** wrapper element.
290
+ * Accepts the same formats as `css` — template literal, string, css function, or callback.
462
291
  */
463
292
  afterContentCss: ExtendCss;
464
293
  }>;
@@ -467,23 +296,6 @@ type VLElement<P extends Record<string, unknown> = {}> = ForwardRefExoticCompone
467
296
  //#region src/Element/component.d.ts
468
297
  declare const Component: VLElement;
469
298
  //#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
299
  //#region src/helpers/Iterator/types.d.ts
488
300
  type MaybeNull = undefined | null;
489
301
  type TObj = Record<string, unknown>;
@@ -563,16 +375,6 @@ type ListProps = {
563
375
  type Props$2 = MergeTypes<[Props$1, ListProps]>;
564
376
  declare const Component$1: VLElement<Props$2>;
565
377
  //#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
378
  //#region src/Overlay/context.d.ts
577
379
  interface Context {
578
380
  blocked: boolean;
@@ -694,7 +496,7 @@ declare const useOverlay: ({
694
496
  onClose
695
497
  }?: Partial<UseOverlayProps>) => {
696
498
  triggerRef: react.RefObject<HTMLElement | null>;
697
- contentRef: (node: HTMLElement) => void;
499
+ contentRef: (node: HTMLElement | null) => void;
698
500
  active: boolean;
699
501
  align: Align$1;
700
502
  alignX: "left" | "right" | "center";
@@ -820,5 +622,5 @@ interface Props$6 {
820
622
  }
821
623
  declare const Component$6: VLComponent<Props$6>;
822
624
  //#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 };
625
+ 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
626
  //# sourceMappingURL=index2.d.ts.map