@ilokesto/utilinent 1.0.5 → 1.0.6

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.
@@ -1,14 +1,15 @@
1
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
1
+ import { Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { createElement, forwardRef } from "react";
3
3
  import { htmlTags } from "../constants/htmlTags";
4
- function BaseFor({ each, children, fallback = null, }) {
5
- return _jsx(_Fragment, { children: each && each.length > 0 ? each.map(children) : fallback });
4
+ function BaseFor({ each, children, fallback = null, before, after, }) {
5
+ const content = each && each.length > 0 ? each.map(children) : fallback;
6
+ return (_jsxs(_Fragment, { children: [before, content, after] }));
6
7
  }
7
8
  const renderForTag = (tag) =>
8
9
  // forward ref so consumers can attach a ref to the underlying DOM element
9
- forwardRef(({ each, children, fallback = null, ...props }, ref) => {
10
+ forwardRef(({ each, children, fallback = null, before, after, ...props }, ref) => {
10
11
  const content = each && each.length > 0 ? each.map(children) : fallback;
11
- return createElement(tag, { ...props, ref }, content);
12
+ return createElement(tag, { ...props, ref }, before, content, after);
12
13
  });
13
14
  const tagEntries = htmlTags.reduce((acc, tag) => {
14
15
  acc[tag] = renderForTag(tag);
@@ -1,8 +1,10 @@
1
- import { ComponentPropsWithRef } from "react";
1
+ import { ComponentPropsWithRef, ReactNode } from "react";
2
2
  import { Fallback } from ".";
3
3
  export interface ForProps<T extends Array<unknown>> extends Fallback {
4
4
  each: T | null | undefined;
5
5
  children: (item: T[number], index: number) => React.ReactNode;
6
+ before?: ReactNode;
7
+ after?: ReactNode;
6
8
  }
7
9
  type ForTagHelper<K extends keyof JSX.IntrinsicElements> = {
8
10
  <T extends Array<unknown>>(props: ForProps<T> & Omit<ComponentPropsWithRef<K>, 'children'>): React.ReactNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ilokesto/utilinent",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ilokesto/utilinent.git"