@vitus-labs/elements 1.4.2 → 1.4.3-alpha.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/lib/index.d.ts CHANGED
@@ -270,195 +270,18 @@ type Props = Partial<{
270
270
  */
271
271
  css: ExtendCss;
272
272
  /**
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
- * ```
273
+ * An additional prop for extending styling of the **content** wrapper element.
274
+ * Accepts the same formats as `css` — template literal, string, css function, or callback.
334
275
  */
335
276
  contentCss: ExtendCss;
336
277
  /**
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
- * ```
278
+ * An additional prop for extending styling of the **beforeContent** wrapper element.
279
+ * Accepts the same formats as `css` — template literal, string, css function, or callback.
398
280
  */
399
281
  beforeContentCss: ExtendCss;
400
282
  /**
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
- * ```
283
+ * An additional prop for extending styling of the **afterContent** wrapper element.
284
+ * Accepts the same formats as `css` — template literal, string, css function, or callback.
462
285
  */
463
286
  afterContentCss: ExtendCss;
464
287
  }>;
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Provider, alignContent, extendCss, makeItResponsive, value } from "@vitus-labs/unistyle";
2
2
  import { config, context, isEmpty, omit, pick, render, throttle } from "@vitus-labs/core";
3
- import { Children, createContext, forwardRef, memo, useCallback, useContext, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
3
+ import { Children, createContext, createElement, forwardRef, memo, useCallback, useContext, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
4
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
5
  import { isFragment } from "react-is";
6
6
  import { createPortal } from "react-dom";
@@ -12,104 +12,6 @@ const PKG_NAME = "@vitus-labs/elements";
12
12
  //#region src/utils.ts
13
13
  const IS_DEVELOPMENT = process.env.NODE_ENV !== "production";
14
14
 
15
- //#endregion
16
- //#region src/helpers/Content/styled.ts
17
- /**
18
- * Styled component for content areas (before/content/after). Applies
19
- * responsive flex alignment, gap spacing between slots based on parent
20
- * direction (margin-right for inline, margin-bottom for rows), and
21
- * equalCols flex distribution. The "content" slot gets `flex: 1` to
22
- * fill remaining space between before and after.
23
- */
24
- const { styled: styled$2, css: css$2, component: component$2 } = config;
25
- const equalColsCSS = `
26
- flex: 1;
27
- `;
28
- const typeContentCSS = `
29
- flex: 1;
30
- `;
31
- const gapDimensions = {
32
- inline: {
33
- before: "margin-right",
34
- after: "margin-left"
35
- },
36
- reverseInline: {
37
- before: "margin-right",
38
- after: "margin-left"
39
- },
40
- rows: {
41
- before: "margin-bottom",
42
- after: "margin-top"
43
- },
44
- reverseRows: {
45
- before: "margin-bottom",
46
- after: "margin-top"
47
- }
48
- };
49
- const calculateGap = ({ direction, type, value }) => {
50
- if (!direction || !type || type === "content") return void 0;
51
- return `${gapDimensions[direction][type]}: ${value};`;
52
- };
53
- const styles$2 = ({ css, theme: t, rootSize }) => css`
54
- ${alignContent({
55
- direction: t.direction,
56
- alignX: t.alignX,
57
- alignY: t.alignY
58
- })};
59
-
60
- ${t.equalCols && equalColsCSS};
61
-
62
- ${t.gap && t.contentType && calculateGap({
63
- direction: t.parentDirection,
64
- type: t.contentType,
65
- value: value(t.gap, rootSize)
66
- })};
67
-
68
- ${t.extraStyles && extendCss(t.extraStyles)};
69
- `;
70
- const StyledComponent = styled$2(component$2)`
71
- ${`box-sizing: border-box;`};
72
-
73
- display: flex;
74
- align-self: stretch;
75
- flex-wrap: wrap;
76
-
77
- ${({ $contentType }) => $contentType === "content" && typeContentCSS};
78
-
79
- ${makeItResponsive({
80
- key: "$element",
81
- styles: styles$2,
82
- css: css$2,
83
- normalize: true
84
- })};
85
- `;
86
-
87
- //#endregion
88
- //#region src/helpers/Content/component.tsx
89
- const Component$9 = ({ contentType, tag, parentDirection, direction, alignX, alignY, equalCols, gap, extendCss, ...props }) => {
90
- return /* @__PURE__ */ jsx(StyledComponent, {
91
- as: tag,
92
- $contentType: contentType,
93
- $element: {
94
- contentType,
95
- parentDirection,
96
- direction,
97
- alignX,
98
- alignY,
99
- equalCols,
100
- gap,
101
- extraStyles: extendCss
102
- },
103
- ...IS_DEVELOPMENT ? { "data-vl-element": contentType } : {},
104
- ...props
105
- });
106
- };
107
- var component_default = memo(Component$9);
108
-
109
- //#endregion
110
- //#region src/helpers/Content/index.ts
111
- var Content_default = component_default;
112
-
113
15
  //#endregion
114
16
  //#region src/helpers/Wrapper/styled.ts
115
17
  /**
@@ -208,36 +110,52 @@ const Component$8 = forwardRef(({ children, tag, block, extendCss, direction, al
208
110
  ref,
209
111
  as: tag
210
112
  };
211
- if (!(!props.dangerouslySetInnerHTML && isWebFixNeeded(tag)) || false) return /* @__PURE__ */ jsx(styled_default$1, {
113
+ const needsFix = !props.dangerouslySetInnerHTML && isWebFixNeeded(tag);
114
+ const normalElement = useMemo(() => ({
115
+ block,
116
+ direction,
117
+ alignX,
118
+ alignY,
119
+ equalCols,
120
+ extraStyles: extendCss
121
+ }), [
122
+ block,
123
+ direction,
124
+ alignX,
125
+ alignY,
126
+ equalCols,
127
+ extendCss
128
+ ]);
129
+ const parentFixElement = useMemo(() => ({
130
+ parentFix: true,
131
+ block,
132
+ extraStyles: extendCss
133
+ }), [block, extendCss]);
134
+ const childFixElement = useMemo(() => ({
135
+ childFix: true,
136
+ direction,
137
+ alignX,
138
+ alignY,
139
+ equalCols
140
+ }), [
141
+ direction,
142
+ alignX,
143
+ alignY,
144
+ equalCols
145
+ ]);
146
+ if (!needsFix || false) return /* @__PURE__ */ jsx(styled_default$1, {
212
147
  ...COMMON_PROPS,
213
- $element: {
214
- block,
215
- direction,
216
- alignX,
217
- alignY,
218
- equalCols,
219
- extraStyles: extendCss
220
- },
148
+ $element: normalElement,
221
149
  children
222
150
  });
223
151
  const asTag = isInline ? "span" : "div";
224
152
  return /* @__PURE__ */ jsx(styled_default$1, {
225
153
  ...COMMON_PROPS,
226
- $element: {
227
- parentFix: true,
228
- block,
229
- extraStyles: extendCss
230
- },
154
+ $element: parentFixElement,
231
155
  children: /* @__PURE__ */ jsx(styled_default$1, {
232
156
  as: asTag,
233
157
  $childFix: true,
234
- $element: {
235
- childFix: true,
236
- direction,
237
- alignX,
238
- alignY,
239
- equalCols
240
- },
158
+ $element: childFixElement,
241
159
  children
242
160
  })
243
161
  });
@@ -247,6 +165,73 @@ const Component$8 = forwardRef(({ children, tag, block, extendCss, direction, al
247
165
  //#region src/helpers/Wrapper/index.ts
248
166
  var Wrapper_default = Component$8;
249
167
 
168
+ //#endregion
169
+ //#region src/Element/slotStyles.ts
170
+ /**
171
+ * Slot styling logic extracted from Content/styled.ts for use with the
172
+ * useCSS hook. Handles responsive flex alignment, gap spacing, equalCols,
173
+ * and extendCss injection for before/content/after slots.
174
+ */
175
+ const gapDimensions = {
176
+ inline: {
177
+ before: "margin-right",
178
+ after: "margin-left"
179
+ },
180
+ reverseInline: {
181
+ before: "margin-right",
182
+ after: "margin-left"
183
+ },
184
+ rows: {
185
+ before: "margin-bottom",
186
+ after: "margin-top"
187
+ },
188
+ reverseRows: {
189
+ before: "margin-bottom",
190
+ after: "margin-top"
191
+ }
192
+ };
193
+ const calculateGap = ({ direction, type, value: v }) => {
194
+ if (!direction || !type || type === "content") return void 0;
195
+ return `${gapDimensions[direction][type]}: ${v};`;
196
+ };
197
+ const slotStyles = ({ css, theme: t, rootSize }) => css`
198
+ ${alignContent({
199
+ direction: t.direction,
200
+ alignX: t.alignX,
201
+ alignY: t.alignY
202
+ })};
203
+
204
+ ${t.equalCols && "flex: 1;"};
205
+
206
+ ${t.gap && t.contentType && calculateGap({
207
+ direction: t.parentDirection,
208
+ type: t.contentType,
209
+ value: value(t.gap, rootSize)
210
+ })};
211
+
212
+ ${t.extraStyles && extendCss(t.extraStyles)};
213
+ `;
214
+ let _template = null;
215
+ const getSlotTemplate = () => {
216
+ if (!_template) {
217
+ const { css } = config;
218
+ _template = css`
219
+ ${"box-sizing: border-box;"};
220
+ display: flex;
221
+ align-self: stretch;
222
+ flex-wrap: wrap;
223
+ ${({ $contentType }) => $contentType === "content" && "flex: 1;"};
224
+ ${makeItResponsive({
225
+ key: "$element",
226
+ styles: slotStyles,
227
+ css,
228
+ normalize: true
229
+ })};
230
+ `;
231
+ }
232
+ return _template;
233
+ };
234
+
250
235
  //#endregion
251
236
  //#region src/Element/constants.ts
252
237
  /**
@@ -331,7 +316,11 @@ const getShouldBeEmpty = (tag) => {
331
316
  * to avoid an unnecessary nesting layer. Handles HTML-specific edge cases
332
317
  * like void elements (input, img) and inline elements (span, a) by
333
318
  * skipping children or switching sub-tags accordingly.
319
+ *
320
+ * Slot elements (before/content/after) use `useCSS` for direct className
321
+ * injection — no styled component wrapper overhead per slot.
334
322
  */
323
+ const { useCSS } = config;
335
324
  const defaultDirection = "inline";
336
325
  const defaultContentDirection = "rows";
337
326
  const defaultAlignX = "left";
@@ -341,7 +330,7 @@ const Component$7 = forwardRef(({ innerRef, tag, label, content, children, befor
341
330
  const isSimpleElement = !beforeContent && !afterContent;
342
331
  const CHILDREN = children ?? content ?? label;
343
332
  const isInline = isInlineElement(tag);
344
- const SUB_TAG = isInline ? "span" : void 0;
333
+ const SUB_TAG = isInline ? "span" : "div";
345
334
  const { wrapperDirection, wrapperAlignX, wrapperAlignY } = useMemo(() => {
346
335
  let wrapperDirection = direction;
347
336
  let wrapperAlignX = alignX;
@@ -366,6 +355,45 @@ const Component$7 = forwardRef(({ innerRef, tag, label, content, children, befor
366
355
  alignY,
367
356
  direction
368
357
  ]);
358
+ const slotTemplate = getSlotTemplate();
359
+ const beforeClass = useCSS(slotTemplate, {
360
+ $element: {
361
+ contentType: "before",
362
+ parentDirection: wrapperDirection,
363
+ direction: beforeContentDirection,
364
+ alignX: beforeContentAlignX,
365
+ alignY: beforeContentAlignY,
366
+ equalCols,
367
+ gap,
368
+ extraStyles: beforeContentCss
369
+ },
370
+ $contentType: "before"
371
+ });
372
+ const contentClass = useCSS(slotTemplate, {
373
+ $element: {
374
+ contentType: "content",
375
+ parentDirection: wrapperDirection,
376
+ direction: contentDirection,
377
+ alignX: contentAlignX,
378
+ alignY: contentAlignY,
379
+ equalCols,
380
+ extraStyles: contentCss
381
+ },
382
+ $contentType: "content"
383
+ });
384
+ const afterClass = useCSS(slotTemplate, {
385
+ $element: {
386
+ contentType: "after",
387
+ parentDirection: wrapperDirection,
388
+ direction: afterContentDirection,
389
+ alignX: afterContentAlignX,
390
+ alignY: afterContentAlignY,
391
+ equalCols,
392
+ gap,
393
+ extraStyles: afterContentCss
394
+ },
395
+ $contentType: "after"
396
+ });
369
397
  const WRAPPER_PROPS = {
370
398
  ref: ref ?? innerRef,
371
399
  extendCss: css,
@@ -386,41 +414,18 @@ const Component$7 = forwardRef(({ innerRef, tag, label, content, children, befor
386
414
  ...WRAPPER_PROPS,
387
415
  isInline,
388
416
  children: [
389
- beforeContent && /* @__PURE__ */ jsx(Content_default, {
390
- tag: SUB_TAG,
391
- contentType: "before",
392
- parentDirection: wrapperDirection,
393
- extendCss: beforeContentCss,
394
- direction: beforeContentDirection,
395
- alignX: beforeContentAlignX,
396
- alignY: beforeContentAlignY,
397
- equalCols,
398
- gap,
399
- children: render(beforeContent)
400
- }),
401
- isSimpleElement ? contentRenderOutput : /* @__PURE__ */ jsx(Content_default, {
402
- tag: SUB_TAG,
403
- contentType: "content",
404
- parentDirection: wrapperDirection,
405
- extendCss: contentCss,
406
- direction: contentDirection,
407
- alignX: contentAlignX,
408
- alignY: contentAlignY,
409
- equalCols,
410
- children: contentRenderOutput
411
- }),
412
- afterContent && /* @__PURE__ */ jsx(Content_default, {
413
- tag: SUB_TAG,
414
- contentType: "after",
415
- parentDirection: wrapperDirection,
416
- extendCss: afterContentCss,
417
- direction: afterContentDirection,
418
- alignX: afterContentAlignX,
419
- alignY: afterContentAlignY,
420
- equalCols,
421
- gap,
422
- children: render(afterContent)
423
- })
417
+ beforeContent && createElement(SUB_TAG, {
418
+ className: beforeClass,
419
+ "data-vl-slot": "before"
420
+ }, render(beforeContent)),
421
+ isSimpleElement ? contentRenderOutput : createElement(SUB_TAG, {
422
+ className: contentClass,
423
+ "data-vl-slot": "content"
424
+ }, contentRenderOutput),
425
+ afterContent && createElement(SUB_TAG, {
426
+ className: afterClass,
427
+ "data-vl-slot": "after"
428
+ }, render(afterContent))
424
429
  ]
425
430
  });
426
431
  });
@@ -464,7 +469,12 @@ const withEqualBeforeAfter = (WrappedComponent) => {
464
469
  const beforeEl = el.firstElementChild;
465
470
  const afterEl = el.lastElementChild;
466
471
  if (beforeEl && afterEl && beforeEl !== afterEl) equalize(beforeEl, afterEl, direction === "rows" ? "height" : "width");
467
- });
472
+ }, [
473
+ equalBeforeAfter,
474
+ beforeContent,
475
+ afterContent,
476
+ direction
477
+ ]);
468
478
  return /* @__PURE__ */ jsx(WrappedComponent, {
469
479
  ...rest,
470
480
  afterContent,
@@ -633,12 +643,14 @@ const Component$6 = (props) => {
633
643
  };
634
644
  return renderItems();
635
645
  };
636
- Component$6.isIterator = true;
637
- Component$6.RESERVED_PROPS = RESERVED_PROPS;
646
+ var component_default = Object.assign(memo(Component$6), {
647
+ isIterator: true,
648
+ RESERVED_PROPS
649
+ });
638
650
 
639
651
  //#endregion
640
652
  //#region src/helpers/Iterator/index.ts
641
- var Iterator_default = Component$6;
653
+ var Iterator_default = component_default;
642
654
 
643
655
  //#endregion
644
656
  //#region src/List/component.tsx
@@ -1,6 +1,6 @@
1
1
  import { Provider, alignContent, extendCss, makeItResponsive, value } from "@vitus-labs/unistyle";
2
2
  import { config, context, isEmpty, omit, pick, render, throttle } from "@vitus-labs/core";
3
- import { Children, createContext, forwardRef, memo, useCallback, useContext, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
3
+ import { Children, createContext, createElement, forwardRef, memo, useCallback, useContext, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
4
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
5
  import { isFragment } from "react-is";
6
6
  import { createPortal } from "react-dom";
@@ -12,104 +12,6 @@ const PKG_NAME = "@vitus-labs/elements";
12
12
  //#region src/utils.ts
13
13
  const IS_DEVELOPMENT = process.env.NODE_ENV !== "production";
14
14
 
15
- //#endregion
16
- //#region src/helpers/Content/styled.ts
17
- /**
18
- * Styled component for content areas (before/content/after). Applies
19
- * responsive flex alignment, gap spacing between slots based on parent
20
- * direction (margin-right for inline, margin-bottom for rows), and
21
- * equalCols flex distribution. The "content" slot gets `flex: 1` to
22
- * fill remaining space between before and after.
23
- */
24
- const { styled: styled$2, css: css$2, component: component$2 } = config;
25
- const equalColsCSS = `
26
- flex: 1;
27
- `;
28
- const typeContentCSS = `
29
- flex: 1;
30
- `;
31
- const gapDimensions = {
32
- inline: {
33
- before: "margin-right",
34
- after: "margin-left"
35
- },
36
- reverseInline: {
37
- before: "margin-right",
38
- after: "margin-left"
39
- },
40
- rows: {
41
- before: "margin-bottom",
42
- after: "margin-top"
43
- },
44
- reverseRows: {
45
- before: "margin-bottom",
46
- after: "margin-top"
47
- }
48
- };
49
- const calculateGap = ({ direction, type, value }) => {
50
- if (!direction || !type || type === "content") return void 0;
51
- return `${gapDimensions[direction][type]}: ${value};`;
52
- };
53
- const styles$2 = ({ css, theme: t, rootSize }) => css`
54
- ${alignContent({
55
- direction: t.direction,
56
- alignX: t.alignX,
57
- alignY: t.alignY
58
- })};
59
-
60
- ${t.equalCols && equalColsCSS};
61
-
62
- ${t.gap && t.contentType && calculateGap({
63
- direction: t.parentDirection,
64
- type: t.contentType,
65
- value: value(t.gap, rootSize)
66
- })};
67
-
68
- ${t.extraStyles && extendCss(t.extraStyles)};
69
- `;
70
- const StyledComponent = styled$2(component$2)`
71
- ${""};
72
-
73
- display: flex;
74
- align-self: stretch;
75
- flex-wrap: wrap;
76
-
77
- ${({ $contentType }) => $contentType === "content" && typeContentCSS};
78
-
79
- ${makeItResponsive({
80
- key: "$element",
81
- styles: styles$2,
82
- css: css$2,
83
- normalize: true
84
- })};
85
- `;
86
-
87
- //#endregion
88
- //#region src/helpers/Content/component.tsx
89
- const Component$9 = ({ contentType, tag, parentDirection, direction, alignX, alignY, equalCols, gap, extendCss, ...props }) => {
90
- return /* @__PURE__ */ jsx(StyledComponent, {
91
- as: tag,
92
- $contentType: contentType,
93
- $element: {
94
- contentType,
95
- parentDirection,
96
- direction,
97
- alignX,
98
- alignY,
99
- equalCols,
100
- gap,
101
- extraStyles: extendCss
102
- },
103
- ...IS_DEVELOPMENT ? { "data-vl-element": contentType } : {},
104
- ...props
105
- });
106
- };
107
- var component_default = memo(Component$9);
108
-
109
- //#endregion
110
- //#region src/helpers/Content/index.ts
111
- var Content_default = component_default;
112
-
113
15
  //#endregion
114
16
  //#region src/helpers/Wrapper/styled.ts
115
17
  /**
@@ -172,19 +74,47 @@ var styled_default$1 = styled$1(component$1)`
172
74
  */
173
75
  const DEV_PROPS = IS_DEVELOPMENT ? { "data-vl-element": "Element" } : {};
174
76
  const Component$8 = forwardRef(({ children, tag, block, extendCss, direction, alignX, alignY, equalCols, isInline, ...props }, ref) => {
175
- return /* @__PURE__ */ jsx(styled_default$1, {
77
+ const COMMON_PROPS = {
176
78
  ...props,
177
79
  ...DEV_PROPS,
178
80
  ref,
179
- as: tag,
180
- $element: {
181
- block,
182
- direction,
183
- alignX,
184
- alignY,
185
- equalCols,
186
- extraStyles: extendCss
187
- },
81
+ as: tag
82
+ };
83
+ const normalElement = useMemo(() => ({
84
+ block,
85
+ direction,
86
+ alignX,
87
+ alignY,
88
+ equalCols,
89
+ extraStyles: extendCss
90
+ }), [
91
+ block,
92
+ direction,
93
+ alignX,
94
+ alignY,
95
+ equalCols,
96
+ extendCss
97
+ ]);
98
+ useMemo(() => ({
99
+ parentFix: true,
100
+ block,
101
+ extraStyles: extendCss
102
+ }), [block, extendCss]);
103
+ useMemo(() => ({
104
+ childFix: true,
105
+ direction,
106
+ alignX,
107
+ alignY,
108
+ equalCols
109
+ }), [
110
+ direction,
111
+ alignX,
112
+ alignY,
113
+ equalCols
114
+ ]);
115
+ return /* @__PURE__ */ jsx(styled_default$1, {
116
+ ...COMMON_PROPS,
117
+ $element: normalElement,
188
118
  children
189
119
  });
190
120
  });
@@ -193,6 +123,73 @@ const Component$8 = forwardRef(({ children, tag, block, extendCss, direction, al
193
123
  //#region src/helpers/Wrapper/index.ts
194
124
  var Wrapper_default = Component$8;
195
125
 
126
+ //#endregion
127
+ //#region src/Element/slotStyles.ts
128
+ /**
129
+ * Slot styling logic extracted from Content/styled.ts for use with the
130
+ * useCSS hook. Handles responsive flex alignment, gap spacing, equalCols,
131
+ * and extendCss injection for before/content/after slots.
132
+ */
133
+ const gapDimensions = {
134
+ inline: {
135
+ before: "margin-right",
136
+ after: "margin-left"
137
+ },
138
+ reverseInline: {
139
+ before: "margin-right",
140
+ after: "margin-left"
141
+ },
142
+ rows: {
143
+ before: "margin-bottom",
144
+ after: "margin-top"
145
+ },
146
+ reverseRows: {
147
+ before: "margin-bottom",
148
+ after: "margin-top"
149
+ }
150
+ };
151
+ const calculateGap = ({ direction, type, value: v }) => {
152
+ if (!direction || !type || type === "content") return void 0;
153
+ return `${gapDimensions[direction][type]}: ${v};`;
154
+ };
155
+ const slotStyles = ({ css, theme: t, rootSize }) => css`
156
+ ${alignContent({
157
+ direction: t.direction,
158
+ alignX: t.alignX,
159
+ alignY: t.alignY
160
+ })};
161
+
162
+ ${t.equalCols && "flex: 1;"};
163
+
164
+ ${t.gap && t.contentType && calculateGap({
165
+ direction: t.parentDirection,
166
+ type: t.contentType,
167
+ value: value(t.gap, rootSize)
168
+ })};
169
+
170
+ ${t.extraStyles && extendCss(t.extraStyles)};
171
+ `;
172
+ let _template = null;
173
+ const getSlotTemplate = () => {
174
+ if (!_template) {
175
+ const { css } = config;
176
+ _template = css`
177
+ ${""};
178
+ display: flex;
179
+ align-self: stretch;
180
+ flex-wrap: wrap;
181
+ ${({ $contentType }) => $contentType === "content" && "flex: 1;"};
182
+ ${makeItResponsive({
183
+ key: "$element",
184
+ styles: slotStyles,
185
+ css,
186
+ normalize: true
187
+ })};
188
+ `;
189
+ }
190
+ return _template;
191
+ };
192
+
196
193
  //#endregion
197
194
  //#region src/Element/component.tsx
198
195
  /**
@@ -202,7 +199,11 @@ var Wrapper_default = Component$8;
202
199
  * to avoid an unnecessary nesting layer. Handles HTML-specific edge cases
203
200
  * like void elements (input, img) and inline elements (span, a) by
204
201
  * skipping children or switching sub-tags accordingly.
202
+ *
203
+ * Slot elements (before/content/after) use `useCSS` for direct className
204
+ * injection — no styled component wrapper overhead per slot.
205
205
  */
206
+ const { useCSS } = config;
206
207
  const defaultDirection = "inline";
207
208
  const defaultContentDirection = "rows";
208
209
  const defaultAlignX = "left";
@@ -211,7 +212,7 @@ const Component$7 = forwardRef(({ innerRef, tag, label, content, children, befor
211
212
  const isSimpleElement = !beforeContent && !afterContent;
212
213
  const CHILDREN = children ?? content ?? label;
213
214
  const isInline = false;
214
- const SUB_TAG = void 0;
215
+ const SUB_TAG = "div";
215
216
  const { wrapperDirection, wrapperAlignX, wrapperAlignY } = useMemo(() => {
216
217
  let wrapperDirection = direction;
217
218
  let wrapperAlignX = alignX;
@@ -236,6 +237,45 @@ const Component$7 = forwardRef(({ innerRef, tag, label, content, children, befor
236
237
  alignY,
237
238
  direction
238
239
  ]);
240
+ const slotTemplate = getSlotTemplate();
241
+ const beforeClass = useCSS(slotTemplate, {
242
+ $element: {
243
+ contentType: "before",
244
+ parentDirection: wrapperDirection,
245
+ direction: beforeContentDirection,
246
+ alignX: beforeContentAlignX,
247
+ alignY: beforeContentAlignY,
248
+ equalCols,
249
+ gap,
250
+ extraStyles: beforeContentCss
251
+ },
252
+ $contentType: "before"
253
+ });
254
+ const contentClass = useCSS(slotTemplate, {
255
+ $element: {
256
+ contentType: "content",
257
+ parentDirection: wrapperDirection,
258
+ direction: contentDirection,
259
+ alignX: contentAlignX,
260
+ alignY: contentAlignY,
261
+ equalCols,
262
+ extraStyles: contentCss
263
+ },
264
+ $contentType: "content"
265
+ });
266
+ const afterClass = useCSS(slotTemplate, {
267
+ $element: {
268
+ contentType: "after",
269
+ parentDirection: wrapperDirection,
270
+ direction: afterContentDirection,
271
+ alignX: afterContentAlignX,
272
+ alignY: afterContentAlignY,
273
+ equalCols,
274
+ gap,
275
+ extraStyles: afterContentCss
276
+ },
277
+ $contentType: "after"
278
+ });
239
279
  const WRAPPER_PROPS = {
240
280
  ref: ref ?? innerRef,
241
281
  extendCss: css,
@@ -252,41 +292,18 @@ const Component$7 = forwardRef(({ innerRef, tag, label, content, children, befor
252
292
  ...WRAPPER_PROPS,
253
293
  isInline,
254
294
  children: [
255
- beforeContent && /* @__PURE__ */ jsx(Content_default, {
256
- tag: SUB_TAG,
257
- contentType: "before",
258
- parentDirection: wrapperDirection,
259
- extendCss: beforeContentCss,
260
- direction: beforeContentDirection,
261
- alignX: beforeContentAlignX,
262
- alignY: beforeContentAlignY,
263
- equalCols,
264
- gap,
265
- children: render(beforeContent)
266
- }),
267
- isSimpleElement ? contentRenderOutput : /* @__PURE__ */ jsx(Content_default, {
268
- tag: SUB_TAG,
269
- contentType: "content",
270
- parentDirection: wrapperDirection,
271
- extendCss: contentCss,
272
- direction: contentDirection,
273
- alignX: contentAlignX,
274
- alignY: contentAlignY,
275
- equalCols,
276
- children: contentRenderOutput
277
- }),
278
- afterContent && /* @__PURE__ */ jsx(Content_default, {
279
- tag: SUB_TAG,
280
- contentType: "after",
281
- parentDirection: wrapperDirection,
282
- extendCss: afterContentCss,
283
- direction: afterContentDirection,
284
- alignX: afterContentAlignX,
285
- alignY: afterContentAlignY,
286
- equalCols,
287
- gap,
288
- children: render(afterContent)
289
- })
295
+ beforeContent && createElement(SUB_TAG, {
296
+ className: beforeClass,
297
+ "data-vl-slot": "before"
298
+ }, render(beforeContent)),
299
+ isSimpleElement ? contentRenderOutput : createElement(SUB_TAG, {
300
+ className: contentClass,
301
+ "data-vl-slot": "content"
302
+ }, contentRenderOutput),
303
+ afterContent && createElement(SUB_TAG, {
304
+ className: afterClass,
305
+ "data-vl-slot": "after"
306
+ }, render(afterContent))
290
307
  ]
291
308
  });
292
309
  });
@@ -330,7 +347,12 @@ const withEqualBeforeAfter = (WrappedComponent) => {
330
347
  const beforeEl = el.firstElementChild;
331
348
  const afterEl = el.lastElementChild;
332
349
  if (beforeEl && afterEl && beforeEl !== afterEl) equalize(beforeEl, afterEl, direction === "rows" ? "height" : "width");
333
- });
350
+ }, [
351
+ equalBeforeAfter,
352
+ beforeContent,
353
+ afterContent,
354
+ direction
355
+ ]);
334
356
  return /* @__PURE__ */ jsx(WrappedComponent, {
335
357
  ...rest,
336
358
  afterContent,
@@ -499,12 +521,14 @@ const Component$6 = (props) => {
499
521
  };
500
522
  return renderItems();
501
523
  };
502
- Component$6.isIterator = true;
503
- Component$6.RESERVED_PROPS = RESERVED_PROPS;
524
+ var component_default = Object.assign(memo(Component$6), {
525
+ isIterator: true,
526
+ RESERVED_PROPS
527
+ });
504
528
 
505
529
  //#endregion
506
530
  //#region src/helpers/Iterator/index.ts
507
- var Iterator_default = Component$6;
531
+ var Iterator_default = component_default;
508
532
 
509
533
  //#endregion
510
534
  //#region src/List/component.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitus-labs/elements",
3
- "version": "1.4.2",
3
+ "version": "1.4.3-alpha.1+cf4e0a6",
4
4
  "license": "MIT",
5
5
  "author": "Vit Bokisch <vit@bokisch.cz>",
6
6
  "maintainers": [
@@ -9,6 +9,7 @@
9
9
  "type": "module",
10
10
  "sideEffects": false,
11
11
  "exports": {
12
+ "source": "./src/index.ts",
12
13
  "import": "./lib/index.js",
13
14
  "types": "./lib/index.d.ts"
14
15
  },
@@ -57,19 +58,18 @@
57
58
  "@vitus-labs/core": "^1.4.0",
58
59
  "@vitus-labs/unistyle": "^1.4.0",
59
60
  "react": ">= 19",
60
- "react-dom": ">= 19",
61
- "styled-components": ">= 6"
61
+ "react-dom": ">= 19"
62
62
  },
63
63
  "devDependencies": {
64
- "@vitus-labs/core": "1.4.2",
65
- "@vitus-labs/rocketstyle": "1.4.2",
64
+ "@vitus-labs/core": "1.4.3-alpha.1+cf4e0a6",
65
+ "@vitus-labs/rocketstyle": "1.4.3-alpha.1+cf4e0a6",
66
66
  "@vitus-labs/tools-rolldown": "^1.6.0",
67
67
  "@vitus-labs/tools-storybook": "^1.6.0",
68
68
  "@vitus-labs/tools-typescript": "^1.6.0",
69
- "@vitus-labs/unistyle": "1.4.2"
69
+ "@vitus-labs/unistyle": "1.4.3-alpha.1+cf4e0a6"
70
70
  },
71
71
  "dependencies": {
72
72
  "react-is": "^19.2.3"
73
73
  },
74
- "gitHead": "f12f43c61149964ff4f3f4b80cb6f92da2825915"
74
+ "gitHead": "cf4e0a6230687c5c7acc2e07a3248bae4ae55f07"
75
75
  }