Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 82648c0

Browse files
committedMay 1, 2021
feat(react-native-li): new Container prop
1 parent 90d71a9 commit 82648c0

File tree

7 files changed

+30
-7
lines changed

7 files changed

+30
-7
lines changed
 

‎packages/react-native-li/docs/react-native-li.markedlist.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ See [CSS Lists and Counters Module Level 3, Markers](https://www.w3.org/TR/css-l
1111
<b>Signature:</b>
1212

1313
```typescript
14-
export default function MarkedList({ children, ...props }: PropsWithChildren<MarkedListProps>): React.FunctionComponentElement<{}>;
14+
export default function MarkedList({ children, Container, ...props }: PropsWithChildren<MarkedListProps>): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
1515
```
1616

1717
## Parameters
1818

1919
| Parameter | Type | Description |
2020
| --- | --- | --- |
21-
| { children, ...props } | PropsWithChildren&lt;[MarkedListProps](./react-native-li.markedlistprops.md)<!-- -->&gt; | |
21+
| { children, Container, ...props } | PropsWithChildren&lt;[MarkedListProps](./react-native-li.markedlistprops.md)<!-- -->&gt; | |
2222

2323
<b>Returns:</b>
2424

25-
React.FunctionComponentElement&lt;{}&gt;
25+
React.ReactElement&lt;any, string \| React.JSXElementConstructor&lt;any&gt;&gt;
2626

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@jsamr/react-native-li](./react-native-li.md) &gt; [MarkedListProps](./react-native-li.markedlistprops.md) &gt; [Container](./react-native-li.markedlistprops.container.md)
4+
5+
## MarkedListProps.Container property
6+
7+
The component used to wrap list elements.
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
Container?: ComponentType<any>;
13+
```

‎packages/react-native-li/docs/react-native-li.markedlistprops.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface MarkedListProps
1717
| Property | Type | Description |
1818
| --- | --- | --- |
1919
| [computeMarkerBoxWidth?](./react-native-li.markedlistprops.computemarkerboxwidth.md) | (maxCodepointsLengthInRange: number, fontSize: number) =&gt; number | <i>(Optional)</i> A function to compute marker box width depending on the maximum length of the marker string in range. |
20+
| [Container?](./react-native-li.markedlistprops.container.md) | ComponentType&lt;any&gt; | <i>(Optional)</i> The component used to wrap list elements. |
2021
| [counterRenderer](./react-native-li.markedlistprops.counterrenderer.md) | CounterStyleRenderer | The counter renderer for this list. |
2122
| [lineStyle?](./react-native-li.markedlistprops.linestyle.md) | StyleProp&lt;ViewStyle&gt; | <i>(Optional)</i> Style for the line wrapper. |
2223
| [markerBoxStyle?](./react-native-li.markedlistprops.markerboxstyle.md) | StyleProp&lt;ViewStyle&gt; | <i>(Optional)</i> Style for the marker box container. It is discouraged to set <code>(min,max)width</code> that way. Use [MarkedListProps.computeMarkerBoxWidth](./react-native-li.markedlistprops.computemarkerboxwidth.md) instead. |

‎packages/react-native-li/docs/react-native-li.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
| Function | Description |
1010
| --- | --- |
11-
| [MarkedList({ children, ...props })](./react-native-li.markedlist.md) | A component which given a counter style, wraps each of its children with a [MarkedListItem()](./react-native-li.markedlistitem.md)<!-- -->. The latter prepends the child with a marker box containing a marker string representation for this child index.<!-- -->See [CSS Lists and Counters Module Level 3, Markers](https://www.w3.org/TR/css-lists-3/#markers)<!-- -->. |
11+
| [MarkedList({ children, Container, ...props })](./react-native-li.markedlist.md) | A component which given a counter style, wraps each of its children with a [MarkedListItem()](./react-native-li.markedlistitem.md)<!-- -->. The latter prepends the child with a marker box containing a marker string representation for this child index.<!-- -->See [CSS Lists and Counters Module Level 3, Markers](https://www.w3.org/TR/css-lists-3/#markers)<!-- -->. |
1212
| [MarkedListItem({ counterRenderer, index, startIndex, rtlLineReversed, rtlMarkerReversed, markerTextStyle, markerBoxStyle, maxNumOfCodepoints, markerTextWidth, style, renderMarker, children })](./react-native-li.markedlistitem.md) | A component which reproduces CSS3 <code>display: list-item;</code> behavior. It prepends its child with a marker box containing a marker string representation for this child index.<!-- -->See [CSS Lists and Counters Module Level 3, Markers](https://www.w3.org/TR/css-lists-3/#markers)<!-- -->. |
1313
| [MarkerBox({ style, counterRenderer, counterIndex, markerTextStyle, markerTextWidth })](./react-native-li.markerbox.md) | Default component to render the list marker.<!-- -->See [CSS Lists and Counters Module Level 3, Markers](https://www.w3.org/TR/css-lists-3/#marker-pseudo) |
1414
| [useMarkedList({ counterRenderer, startIndex, lineStyle, rtlLineReversed, rtlMarkerReversed, markerTextStyle, markerBoxStyle, length, renderMarker, computeMarkerBoxWidth })](./react-native-li.usemarkedlist.md) | A hook to reuse MarkedList logic to render custom lists components in combination with [MarkedListItem()](./react-native-li.markedlistitem.md)<!-- -->. |

‎packages/react-native-li/etc/react-native-li.api.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
```ts
66

7+
import type { ComponentType } from 'react';
78
import type { CounterStyleRenderer } from '@jsamr/counter-style';
89
import { PropsWithChildren } from 'react';
910
import { default as React_2 } from 'react';
@@ -14,7 +15,7 @@ import type { TextStyle } from 'react-native';
1415
import { ViewStyle } from 'react-native';
1516

1617
// @public
17-
function MarkedList({ children, ...props }: PropsWithChildren<MarkedListProps>): React_2.FunctionComponentElement<{}>;
18+
function MarkedList({ children, Container, ...props }: PropsWithChildren<MarkedListProps>): React_2.ReactElement<any, string | React_2.JSXElementConstructor<any>>;
1819

1920
export { MarkedList }
2021

@@ -34,6 +35,7 @@ export type MarkedListItemProps = Required<Pick<MarkedListProps, 'counterRendere
3435
// @public
3536
export interface MarkedListProps {
3637
computeMarkerBoxWidth?: (maxCodepointsLengthInRange: number, fontSize: number) => number;
38+
Container?: ComponentType<any>;
3739
counterRenderer: CounterStyleRenderer;
3840
lineStyle?: StyleProp<ViewStyle>;
3941
markerBoxStyle?: StyleProp<ViewStyle>;

‎packages/react-native-li/src/MarkedList.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ import useMarkedList from './useMarkedList';
1414
*/
1515
export default function MarkedList({
1616
children,
17+
Container = Fragment,
1718
...props
1819
}: PropsWithChildren<MarkedListProps>) {
1920
const normalChildren = Children.toArray(children);
2021
const listProps = useMarkedList({ ...props, length: normalChildren.length });
2122
return React.createElement(
22-
Fragment,
23+
Container,
2324
{},
2425
normalChildren.map((child, index) => {
2526
return (

‎packages/react-native-li/src/shared-types.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { CounterStyleRenderer, RtlOptions } from '@jsamr/counter-style';
2-
import type { ReactNode } from 'react';
2+
import type { ComponentType, ReactNode } from 'react';
33
import type { StyleProp, ViewStyle, TextStyle } from 'react-native';
44

55
/**
@@ -108,4 +108,10 @@ export interface MarkedListProps {
108108
* @remarks You are advised to use {@link MarkerBox} component.
109109
*/
110110
renderMarker?: (props: MarkerBoxProps) => ReactNode;
111+
/**
112+
* The component used to wrap list elements.
113+
*
114+
* @defaultValue Fragment
115+
*/
116+
Container?: ComponentType<any>;
111117
}

0 commit comments

Comments
 (0)