@cleartrip/ct-design-bulleted-list 4.0.0-SNAPSHOT-test.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 +151 -0
- package/dist/BulletedList.d.ts +6 -0
- package/dist/BulletedList.d.ts.map +1 -0
- package/dist/ct-design-bulleted-list.browser.cjs.js +2 -0
- package/dist/ct-design-bulleted-list.browser.cjs.js.map +1 -0
- package/dist/ct-design-bulleted-list.browser.esm.js +2 -0
- package/dist/ct-design-bulleted-list.browser.esm.js.map +1 -0
- package/dist/ct-design-bulleted-list.cjs.js +53 -0
- package/dist/ct-design-bulleted-list.cjs.js.map +1 -0
- package/dist/ct-design-bulleted-list.esm.js +51 -0
- package/dist/ct-design-bulleted-list.esm.js.map +1 -0
- package/dist/ct-design-bulleted-list.umd.js +54 -0
- package/dist/ct-design-bulleted-list.umd.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.native.d.ts +3 -0
- package/dist/index.native.d.ts.map +1 -0
- package/dist/style.d.ts +24 -0
- package/dist/style.d.ts.map +1 -0
- package/dist/type.d.ts +18 -0
- package/dist/type.d.ts.map +1 -0
- package/package.json +57 -0
- package/src/BulletedList.tsx +101 -0
- package/src/index.native.ts +5 -0
- package/src/index.ts +2 -0
- package/src/style.ts +33 -0
- package/src/type.ts +67 -0
package/README.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# BulletedList
|
|
2
|
+
|
|
3
|
+
BulletedList renders a list of items with customizable markers (bullets or numbers) and flexible item rendering.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @cleartrip/ct-design-bulleted-list
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @cleartrip/ct-design-bulleted-list
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Peer dependencies
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Required for all targets
|
|
19
|
+
npm install react
|
|
20
|
+
|
|
21
|
+
# Web only
|
|
22
|
+
npm install react-dom
|
|
23
|
+
|
|
24
|
+
# React Native only
|
|
25
|
+
npm install react-native
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
### Basic ordered list
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { BulletedList } from '@cleartrip/ct-design-bulleted-list';
|
|
36
|
+
|
|
37
|
+
const items = [
|
|
38
|
+
{ id: '1', title: 'First Item', content: 'Description here' },
|
|
39
|
+
{ id: '2', title: 'Second Item', content: 'Another description' },
|
|
40
|
+
{ id: '3', title: 'Third Item', content: 'More content' },
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
function Example() {
|
|
44
|
+
return (
|
|
45
|
+
<BulletedList
|
|
46
|
+
list={items}
|
|
47
|
+
listType="ol"
|
|
48
|
+
renderItem={(item, index) => (
|
|
49
|
+
<div>
|
|
50
|
+
<strong>{item.title}</strong>
|
|
51
|
+
<p>{item.content}</p>
|
|
52
|
+
</div>
|
|
53
|
+
)}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Bullet list (unordered)
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
<BulletedList
|
|
63
|
+
list={items}
|
|
64
|
+
listType="ul"
|
|
65
|
+
renderItem={(item) => <span>{item.title}</span>}
|
|
66
|
+
/>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Style overrides
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
<BulletedList
|
|
73
|
+
list={items}
|
|
74
|
+
listType="ol"
|
|
75
|
+
renderItem={(item) => <span>{item.title}</span>}
|
|
76
|
+
styleConfig={{
|
|
77
|
+
itemWrapper: [{ padding: 12, borderBottom: '1px solid #eee' }],
|
|
78
|
+
marker: [{ color: '#007bff', fontWeight: 'bold' }],
|
|
79
|
+
}}
|
|
80
|
+
/>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Props
|
|
86
|
+
|
|
87
|
+
| Prop | Type | Default | Required | Description |
|
|
88
|
+
|------|------|---------|----------|-------------|
|
|
89
|
+
| `list` | `T[]` | — | Yes | Items to render in the list |
|
|
90
|
+
| `renderItem` | `(item: T, index: number) => ReactNode` | — | Yes | Callback that renders each list item |
|
|
91
|
+
| `listType` | `'ol' \| 'ul'` | `'ol'` | No | Type of marker to display |
|
|
92
|
+
| `styleConfig` | `IBulletedListStyleConfig` | — | No | Style configuration overrides |
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## List Types
|
|
97
|
+
|
|
98
|
+
- `'ol'` — Numbered list (1. 2. 3.)
|
|
99
|
+
- `'ul'` — Bullet list (•)
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## styleConfig
|
|
104
|
+
|
|
105
|
+
The `styleConfig` interface allows fine-grained style customization:
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
interface IBulletedListStyleConfig {
|
|
109
|
+
itemWrapper?: Styles[];
|
|
110
|
+
placeHolder?: Styles[];
|
|
111
|
+
itemContent?: Styles[];
|
|
112
|
+
marker?: Styles[];
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Slots
|
|
117
|
+
|
|
118
|
+
| Slot | Description |
|
|
119
|
+
|------|-------------|
|
|
120
|
+
| `itemWrapper` | Styles for the outer row container wrapping each list item |
|
|
121
|
+
| `placeHolder` | Styles for the marker container (bullet/number placeholder area) |
|
|
122
|
+
| `itemContent` | Styles for the content container where renderItem output is displayed |
|
|
123
|
+
| `marker` | Styles for the marker row (number + dot on ordered lists) |
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Item Keys
|
|
128
|
+
|
|
129
|
+
- Items with an `id` property use that as the React key
|
|
130
|
+
- Items without `id` use the array index as the key
|
|
131
|
+
- For optimal performance, provide unique `id` values for each item
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Accessibility
|
|
136
|
+
|
|
137
|
+
- Ordered lists use semantic `<ol>` elements
|
|
138
|
+
- Unordered lists use semantic `<ul>` elements
|
|
139
|
+
- Each item is wrapped in `<li>` elements for proper screen reader support
|
|
140
|
+
- Consider adding ARIA labels for complex list items
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Migration
|
|
145
|
+
|
|
146
|
+
If migrating from a previous version:
|
|
147
|
+
|
|
148
|
+
```diff
|
|
149
|
+
- import { BulletedList } from 'old-package';
|
|
150
|
+
+ import { BulletedList } from '@cleartrip/ct-design-bulleted-list';
|
|
151
|
+
```
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IBulletedListProps } from './type';
|
|
2
|
+
declare const BulletedList: <T extends {
|
|
3
|
+
id?: string | number;
|
|
4
|
+
}>({ list, renderItem, listType, styleConfig, }: IBulletedListProps<T>) => import("react/jsx-runtime").JSX.Element | null;
|
|
5
|
+
export default BulletedList;
|
|
6
|
+
//# sourceMappingURL=BulletedList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BulletedList.d.ts","sourceRoot":"","sources":["../packages/components/BulletedList/src/BulletedList.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAuBjD,QAAA,MAAM,YAAY,GAAI,CAAC,SAAS;IAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EAAE,8CAKvD,kBAAkB,CAAC,CAAC,CAAC,mDAiEvB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("@cleartrip/ct-design-container"),t=require("@cleartrip/ct-design-typography"),n=require("@cleartrip/ct-design-style-manager");const i=n.makeStyles(e=>({itemWrapper:{flexDirection:"row",alignItems:"flex-start",columnGap:null==e?void 0:e.spacing[1]},placeHolder:{flexShrink:0,color:null==e?void 0:e.color.text.primary,minWidth:20,alignItems:"center",justifyContent:"center"},itemContent:{flex:1},marker:{flexDirection:"row",alignItems:"center",justifyContent:"center"}}));exports.BulletedList=({list:l,renderItem:o,listType:a="ol",styleConfig:s})=>{const{itemWrapper:c=[],placeHolder:p=[],itemContent:d=[],marker:m=[]}=s||{},y=(null==l?void 0:l.length)||0,g=12*String(y).length,u=n.useStyles(()=>({root:{width:g}}),[g]);return l&&0!==l.length?e.jsx(e.Fragment,{children:l.map((n,l)=>{var s;return e.jsxs(r.Container,{styleConfig:{root:[i.itemWrapper,...c]},children:[e.jsx(r.Container,{styleConfig:{root:[i.placeHolder,...p]},children:"ol"===a?e.jsxs(r.Container,{styleConfig:{root:[i.marker,null==u?void 0:u.root,...m]},children:[e.jsx(t.Typography,{variant:"B2",color:"primary",children:l+1}),e.jsx(t.Typography,{variant:"B2",color:"primary",children:"."})]}):e.jsx(t.Typography,{variant:"B2",color:"primary",children:"•"})}),e.jsx(r.Container,{styleConfig:{root:[i.itemContent,...d]},children:o(n,l)})]},null!==(s=null==n?void 0:n.id)&&void 0!==s?s:l)})}):null};
|
|
2
|
+
//# sourceMappingURL=ct-design-bulleted-list.browser.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ct-design-bulleted-list.browser.cjs.js","sources":["../packages/components/BulletedList/src/style.ts","../packages/components/BulletedList/src/BulletedList.tsx"],"sourcesContent":[null,null],"names":["staticBulletedListStyles","makeStyles","theme","itemWrapper","flexDirection","alignItems","columnGap","spacing","placeHolder","flexShrink","color","text","primary","minWidth","justifyContent","itemContent","flex","marker","list","renderItem","listType","styleConfig","customItemWrapper","customPlaceHolder","customItemContent","customMarker","maxNumber","length","numberWidth","String","dynamicNumberWidth","useStyles","root","width","_jsx","jsx","_Fragment","Fragment","children","map","item","index","_jsxs","Container","jsxs","Typography","variant","_a","id"],"mappings":"yLASA,MAAMA,EAA2BC,EAAAA,WAAYC,IAAW,CACtDC,YAAa,CACXC,cAAe,MACfC,WAAY,aACZC,UAAWJ,aAAK,EAALA,EAAOK,QAAQ,IAE5BC,YAAa,CACXC,WAAY,EACZC,MAAOR,aAAK,EAALA,EAAOQ,MAAMC,KAAKC,QACzBC,SAAU,GACVR,WAAY,SACZS,eAAgB,UAElBC,YAAa,CACXC,KAAM,GAERC,OAAQ,CACNb,cAAe,MACfC,WAAY,SACZS,eAAgB,kCCAC,EACnBI,OACAC,aACAC,WAAW,KACXC,kBAEA,MACElB,YAAamB,EAAoB,GACjCd,YAAae,EAAoB,GACjCR,YAAaS,EAAoB,GACjCP,OAAQQ,EAAe,IACrBJ,GAAe,GAEbK,GAAYR,aAAA,EAAAA,EAAMS,SAAU,EAQ5BC,EAAgC,GAHdC,OAAOH,GAAWC,OAKpCG,EAAqBC,EAAAA,UACzB,KAAO,CACLC,KAAM,CACJC,MAAOL,KAGX,CAACA,IAGH,OAAKV,GAAwB,IAAhBA,EAAKS,OAKhBO,EACGC,IAAAC,EAAAC,SAAA,CAAAC,SAAApB,EAAKqB,IAAI,CAACC,EAAMC,WAAU,OACzBC,OAACC,EAASA,UAAA,CACRtB,YAAa,CAAEW,KAAM,CAAChC,EAAyBG,eAAgBmB,IAG/DgB,SAAA,CAAAJ,EAAAC,IAACQ,EAASA,UAAA,CAACtB,YAAa,CAAEW,KAAM,CAAChC,EAAyBQ,eAAgBe,IAAoBe,SAC9E,OAAblB,EACCsB,EAACE,KAAAD,EAASA,UACR,CAAAtB,YAAa,CACXW,KAAM,CAAChC,EAAyBiB,OAAQa,aAAkB,EAAlBA,EAAoBE,QAASP,IACtEa,SAAA,CAEDJ,MAACW,EAAUA,WAAA,CAACC,QAAQ,KAAKpC,MAAM,UAAS4B,SACrCG,EAAQ,IAEXP,EAAAC,IAACU,EAAUA,WAAC,CAAAC,QAAQ,KAAKpC,MAAM,UAElB4B,SAAA,SAGfJ,EAAAC,IAACU,EAAUA,WAAC,CAAAC,QAAQ,KAAKpC,MAAM,UAC5B4B,SAAA,QAIPJ,EAAAA,IAACS,EAAAA,WAAUtB,YAAa,CAAEW,KAAM,CAAChC,EAAyBe,eAAgBS,IACvEc,SAAAnB,EAAWqB,EAAMC,eAvBfM,EAAAP,aAAI,EAAJA,EAAMQ,kBAAMP,OARhB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as r,Fragment as e,jsxs as t}from"react/jsx-runtime";import{Container as i}from"@cleartrip/ct-design-container";import{Typography as n}from"@cleartrip/ct-design-typography";import{makeStyles as o,useStyles as l}from"@cleartrip/ct-design-style-manager";const a=o(r=>({itemWrapper:{flexDirection:"row",alignItems:"flex-start",columnGap:null==r?void 0:r.spacing[1]},placeHolder:{flexShrink:0,color:null==r?void 0:r.color.text.primary,minWidth:20,alignItems:"center",justifyContent:"center"},itemContent:{flex:1},marker:{flexDirection:"row",alignItems:"center",justifyContent:"center"}})),c=({list:o,renderItem:c,listType:m="ol",styleConfig:p})=>{const{itemWrapper:d=[],placeHolder:s=[],itemContent:g=[],marker:f=[]}=p||{},h=(null==o?void 0:o.length)||0,y=12*String(h).length,u=l(()=>({root:{width:y}}),[y]);return o&&0!==o.length?r(e,{children:o.map((e,o)=>{var l;return t(i,{styleConfig:{root:[a.itemWrapper,...d]},children:[r(i,{styleConfig:{root:[a.placeHolder,...s]},children:"ol"===m?t(i,{styleConfig:{root:[a.marker,null==u?void 0:u.root,...f]},children:[r(n,{variant:"B2",color:"primary",children:o+1}),r(n,{variant:"B2",color:"primary",children:"."})]}):r(n,{variant:"B2",color:"primary",children:"•"})}),r(i,{styleConfig:{root:[a.itemContent,...g]},children:c(e,o)})]},null!==(l=null==e?void 0:e.id)&&void 0!==l?l:o)})}):null};export{c as BulletedList};
|
|
2
|
+
//# sourceMappingURL=ct-design-bulleted-list.browser.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ct-design-bulleted-list.browser.esm.js","sources":["../packages/components/BulletedList/src/style.ts","../packages/components/BulletedList/src/BulletedList.tsx"],"sourcesContent":[null,null],"names":["staticBulletedListStyles","makeStyles","theme","itemWrapper","flexDirection","alignItems","columnGap","spacing","placeHolder","flexShrink","color","text","primary","minWidth","justifyContent","itemContent","flex","marker","BulletedList","list","renderItem","listType","styleConfig","customItemWrapper","customPlaceHolder","customItemContent","customMarker","maxNumber","length","numberWidth","String","dynamicNumberWidth","useStyles","root","width","_jsx","_Fragment","children","map","item","index","_jsxs","Container","Typography","variant","_a","id"],"mappings":"uQASA,MAAMA,EAA2BC,EAAYC,IAAW,CACtDC,YAAa,CACXC,cAAe,MACfC,WAAY,aACZC,UAAWJ,aAAK,EAALA,EAAOK,QAAQ,IAE5BC,YAAa,CACXC,WAAY,EACZC,MAAOR,aAAK,EAALA,EAAOQ,MAAMC,KAAKC,QACzBC,SAAU,GACVR,WAAY,SACZS,eAAgB,UAElBC,YAAa,CACXC,KAAM,GAERC,OAAQ,CACNb,cAAe,MACfC,WAAY,SACZS,eAAgB,aCAdI,EAAe,EACnBC,OACAC,aACAC,WAAW,KACXC,kBAEA,MACEnB,YAAaoB,EAAoB,GACjCf,YAAagB,EAAoB,GACjCT,YAAaU,EAAoB,GACjCR,OAAQS,EAAe,IACrBJ,GAAe,GAEbK,GAAYR,aAAA,EAAAA,EAAMS,SAAU,EAQ5BC,EAAgC,GAHdC,OAAOH,GAAWC,OAKpCG,EAAqBC,EACzB,KAAO,CACLC,KAAM,CACJC,MAAOL,KAGX,CAACA,IAGH,OAAKV,GAAwB,IAAhBA,EAAKS,OAKhBO,EACGC,EAAA,CAAAC,SAAAlB,EAAKmB,IAAI,CAACC,EAAMC,WAAU,OACzBC,EAACC,EAAS,CACRpB,YAAa,CAAEW,KAAM,CAACjC,EAAyBG,eAAgBoB,IAG/Dc,SAAA,CAAAF,EAACO,EAAS,CAACpB,YAAa,CAAEW,KAAM,CAACjC,EAAyBQ,eAAgBgB,IAAoBa,SAC9E,OAAbhB,EACCoB,EAACC,EACC,CAAApB,YAAa,CACXW,KAAM,CAACjC,EAAyBiB,OAAQc,aAAkB,EAAlBA,EAAoBE,QAASP,IACtEW,SAAA,CAEDF,EAACQ,EAAU,CAACC,QAAQ,KAAKlC,MAAM,UAAS2B,SACrCG,EAAQ,IAEXL,EAACQ,EAAW,CAAAC,QAAQ,KAAKlC,MAAM,UAElB2B,SAAA,SAGfF,EAACQ,EAAW,CAAAC,QAAQ,KAAKlC,MAAM,UAC5B2B,SAAA,QAIPF,EAACO,GAAUpB,YAAa,CAAEW,KAAM,CAACjC,EAAyBe,eAAgBU,IACvEY,SAAAjB,EAAWmB,EAAMC,eAvBfK,EAAAN,aAAI,EAAJA,EAAMO,kBAAMN,OARhB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var ctDesignContainer = require('@cleartrip/ct-design-container');
|
|
5
|
+
var ctDesignTypography = require('@cleartrip/ct-design-typography');
|
|
6
|
+
var ctDesignStyleManager = require('@cleartrip/ct-design-style-manager');
|
|
7
|
+
|
|
8
|
+
const staticBulletedListStyles = ctDesignStyleManager.makeStyles((theme) => ({
|
|
9
|
+
itemWrapper: {
|
|
10
|
+
flexDirection: 'row',
|
|
11
|
+
alignItems: 'flex-start',
|
|
12
|
+
columnGap: theme === null || theme === void 0 ? void 0 : theme.spacing[1],
|
|
13
|
+
},
|
|
14
|
+
placeHolder: {
|
|
15
|
+
flexShrink: 0,
|
|
16
|
+
color: theme === null || theme === void 0 ? void 0 : theme.color.text.primary,
|
|
17
|
+
minWidth: 20,
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
justifyContent: 'center',
|
|
20
|
+
},
|
|
21
|
+
itemContent: {
|
|
22
|
+
flex: 1,
|
|
23
|
+
},
|
|
24
|
+
marker: {
|
|
25
|
+
flexDirection: 'row',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
justifyContent: 'center',
|
|
28
|
+
},
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
const BulletedList = ({ list, renderItem, listType = 'ol', styleConfig, }) => {
|
|
32
|
+
const { itemWrapper: customItemWrapper = [], placeHolder: customPlaceHolder = [], itemContent: customItemContent = [], marker: customMarker = [], } = styleConfig || {};
|
|
33
|
+
const maxNumber = (list === null || list === void 0 ? void 0 : list.length) || 0;
|
|
34
|
+
const maxNumberDigits = String(maxNumber).length;
|
|
35
|
+
const numberWidth = maxNumberDigits * 12;
|
|
36
|
+
const dynamicNumberWidth = ctDesignStyleManager.useStyles(() => ({
|
|
37
|
+
root: {
|
|
38
|
+
width: numberWidth,
|
|
39
|
+
},
|
|
40
|
+
}), [numberWidth]);
|
|
41
|
+
if (!list || list.length === 0) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: list.map((item, index) => {
|
|
45
|
+
var _a;
|
|
46
|
+
return (jsxRuntime.jsxs(ctDesignContainer.Container, { styleConfig: { root: [staticBulletedListStyles.itemWrapper, ...customItemWrapper] }, children: [jsxRuntime.jsx(ctDesignContainer.Container, { styleConfig: { root: [staticBulletedListStyles.placeHolder, ...customPlaceHolder] }, children: listType === 'ol' ? (jsxRuntime.jsxs(ctDesignContainer.Container, { styleConfig: {
|
|
47
|
+
root: [staticBulletedListStyles.marker, dynamicNumberWidth === null || dynamicNumberWidth === void 0 ? void 0 : dynamicNumberWidth.root, ...customMarker],
|
|
48
|
+
}, children: [jsxRuntime.jsx(ctDesignTypography.Typography, { variant: 'B2', color: 'primary', children: index + 1 }), jsxRuntime.jsx(ctDesignTypography.Typography, { variant: 'B2', color: 'primary', children: "." })] })) : (jsxRuntime.jsx(ctDesignTypography.Typography, { variant: 'B2', color: 'primary', children: '\u2022' })) }), jsxRuntime.jsx(ctDesignContainer.Container, { styleConfig: { root: [staticBulletedListStyles.itemContent, ...customItemContent] }, children: renderItem(item, index) })] }, (_a = item === null || item === void 0 ? void 0 : item.id) !== null && _a !== void 0 ? _a : index));
|
|
49
|
+
}) }));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
exports.BulletedList = BulletedList;
|
|
53
|
+
//# sourceMappingURL=ct-design-bulleted-list.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ct-design-bulleted-list.cjs.js","sources":["../packages/components/BulletedList/src/style.ts","../packages/components/BulletedList/src/BulletedList.tsx"],"sourcesContent":[null,null],"names":["makeStyles","useStyles","_jsx","_Fragment","_jsxs","Container","Typography"],"mappings":";;;;;;;AASA,MAAM,wBAAwB,GAAGA,+BAAU,CAAC,CAAC,KAAK,MAAM;AACtD,IAAA,WAAW,EAAE;AACX,QAAA,aAAa,EAAE,KAAc;AAC7B,QAAA,UAAU,EAAE,YAAqB;QACjC,SAAS,EAAE,KAAK,KAAA,IAAA,IAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,OAAO,CAAC,CAAC,CAAC;AAC7B,KAAA;AACD,IAAA,WAAW,EAAE;AACX,QAAA,UAAU,EAAE,CAAC;QACb,KAAK,EAAE,KAAK,KAAA,IAAA,IAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,KAAK,CAAC,IAAI,CAAC,OAAO;AAChC,QAAA,QAAQ,EAAE,EAAE;AACZ,QAAA,UAAU,EAAE,QAAiB;AAC7B,QAAA,cAAc,EAAE,QAAiB;AAClC,KAAA;AACD,IAAA,WAAW,EAAE;AACX,QAAA,IAAI,EAAE,CAAC;AACR,KAAA;AACD,IAAA,MAAM,EAAE;AACN,QAAA,aAAa,EAAE,KAAc;AAC7B,QAAA,UAAU,EAAE,QAAiB;AAC7B,QAAA,c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'@cleartrip/ct-design-typography';
|
|
4
|
+
import { makeStyles, useStyles } from '@cleartrip/ct-design-style-manager';
|
|
5
|
+
|
|
6
|
+
const staticBulletedListStyles = makeStyles((theme) => ({
|
|
7
|
+
itemWrapper: {
|
|
8
|
+
flexDirection: 'row',
|
|
9
|
+
alignItems: 'flex-start',
|
|
10
|
+
columnGap: theme === null || theme === void 0 ? void 0 : theme.spacing[1],
|
|
11
|
+
},
|
|
12
|
+
placeHolder: {
|
|
13
|
+
flexShrink: 0,
|
|
14
|
+
color: theme === null || theme === void 0 ? void 0 : theme.color.text.primary,
|
|
15
|
+
minWidth: 20,
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
justifyContent: 'center',
|
|
18
|
+
},
|
|
19
|
+
itemContent: {
|
|
20
|
+
flex: 1,
|
|
21
|
+
},
|
|
22
|
+
marker: {
|
|
23
|
+
flexDirection: 'row',
|
|
24
|
+
alignItems: 'center',
|
|
25
|
+
justifyContent: 'center',
|
|
26
|
+
},
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
const BulletedList = ({ list, renderItem, listType = 'ol', styleConfig, }) => {
|
|
30
|
+
const { itemWrapper: customItemWrapper = [], placeHolder: customPlaceHolder = [], itemContent: customItemContent = [], marker: customMarker = [], } = styleConfig || {};
|
|
31
|
+
const maxNumber = (list === null || list === void 0 ? void 0 : list.length) || 0;
|
|
32
|
+
const maxNumberDigits = String(maxNumber).length;
|
|
33
|
+
const numberWidth = maxNumberDigits * 12;
|
|
34
|
+
const dynamicNumberWidth = useStyles(() => ({
|
|
35
|
+
root: {
|
|
36
|
+
width: numberWidth,
|
|
37
|
+
},
|
|
38
|
+
}), [numberWidth]);
|
|
39
|
+
if (!list || list.length === 0) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return (jsx(Fragment, { children: list.map((item, index) => {
|
|
43
|
+
var _a;
|
|
44
|
+
return (jsxs(Container, { styleConfig: { root: [staticBulletedListStyles.itemWrapper, ...customItemWrapper] }, children: [jsx(Container, { styleConfig: { root: [staticBulletedListStyles.placeHolder, ...customPlaceHolder] }, children: listType === 'ol' ? (jsxs(Container, { styleConfig: {
|
|
45
|
+
root: [staticBulletedListStyles.marker, dynamicNumberWidth === null || dynamicNumberWidth === void 0 ? void 0 : dynamicNumberWidth.root, ...customMarker],
|
|
46
|
+
}, children: [jsx(Typography, { variant: 'B2', color: 'primary', children: index + 1 }), jsx(Typography, { variant: 'B2', color: 'primary', children: "." })] })) : (jsx(Typography, { variant: 'B2', color: 'primary', children: '\u2022' })) }), jsx(Container, { styleConfig: { root: [staticBulletedListStyles.itemContent, ...customItemContent] }, children: renderItem(item, index) })] }, (_a = item === null || item === void 0 ? void 0 : item.id) !== null && _a !== void 0 ? _a : index));
|
|
47
|
+
}) }));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export { BulletedList };
|
|
51
|
+
//# sourceMappingURL=ct-design-bulleted-list.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ct-design-bulleted-list.esm.js","sources":["../packages/components/BulletedList/src/style.ts","../packages/components/BulletedList/src/BulletedList.tsx"],"sourcesContent":[null,null],"names":["_jsx","_Fragment","_jsxs"],"mappings":";;;;;AASA,MAAM,wBAAwB,GAAG,UAAU,CAAC,CAAC,KAAK,MAAM;AACtD,IAAA,WAAW,EAAE;AACX,QAAA,aAAa,EAAE,KAAc;AAC7B,QAAA,UAAU,EAAE,YAAqB;QACjC,SAAS,EAAE,KAAK,KAAA,IAAA,IAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,OAAO,CAAC,CAAC,CAAC;AAC7B,KAAA;AACD,IAAA,WAAW,EAAE;AACX,QAAA,UAAU,EAAE,CAAC;QACb,KAAK,EAAE,KAAK,KAAA,IAAA,IAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,KAAK,CAAC,IAAI,CAAC,OAAO;AAChC,QA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A,KAAA,CAAA,GAAJ,IAAI,CAAE,EAAE,mCAAI,KAAK,CAyBZ,EACb;SAAA,CAAC,EAAA,CACD,EACH;AACJ;;;;"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('@cleartrip/ct-design-container'), require('@cleartrip/ct-design-typography'), require('@cleartrip/ct-design-style-manager')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', '@cleartrip/ct-design-container', '@cleartrip/ct-design-typography', '@cleartrip/ct-design-style-manager'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.CTDesignSystemBulletedList = {}, global.jsxRuntime, global.ctDesignContainer, global.ctDesignTypography, global.ctDesignStyleManager));
|
|
5
|
+
})(this, (function (exports, jsxRuntime, ctDesignContainer, ctDesignTypography, ctDesignStyleManager) { 'use strict';
|
|
6
|
+
|
|
7
|
+
const staticBulletedListStyles = ctDesignStyleManager.makeStyles((theme) => ({
|
|
8
|
+
itemWrapper: {
|
|
9
|
+
flexDirection: 'row',
|
|
10
|
+
alignItems: 'flex-start',
|
|
11
|
+
columnGap: theme === null || theme === void 0 ? void 0 : theme.spacing[1],
|
|
12
|
+
},
|
|
13
|
+
placeHolder: {
|
|
14
|
+
flexShrink: 0,
|
|
15
|
+
color: theme === null || theme === void 0 ? void 0 : theme.color.text.primary,
|
|
16
|
+
minWidth: 20,
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
justifyContent: 'center',
|
|
19
|
+
},
|
|
20
|
+
itemContent: {
|
|
21
|
+
flex: 1,
|
|
22
|
+
},
|
|
23
|
+
marker: {
|
|
24
|
+
flexDirection: 'row',
|
|
25
|
+
alignItems: 'center',
|
|
26
|
+
justifyContent: 'center',
|
|
27
|
+
},
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
const BulletedList = ({ list, renderItem, listType = 'ol', styleConfig, }) => {
|
|
31
|
+
const { itemWrapper: customItemWrapper = [], placeHolder: customPlaceHolder = [], itemContent: customItemContent = [], marker: customMarker = [], } = styleConfig || {};
|
|
32
|
+
const maxNumber = (list === null || list === void 0 ? void 0 : list.length) || 0;
|
|
33
|
+
const maxNumberDigits = String(maxNumber).length;
|
|
34
|
+
const numberWidth = maxNumberDigits * 12;
|
|
35
|
+
const dynamicNumberWidth = ctDesignStyleManager.useStyles(() => ({
|
|
36
|
+
root: {
|
|
37
|
+
width: numberWidth,
|
|
38
|
+
},
|
|
39
|
+
}), [numberWidth]);
|
|
40
|
+
if (!list || list.length === 0) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: list.map((item, index) => {
|
|
44
|
+
var _a;
|
|
45
|
+
return (jsxRuntime.jsxs(ctDesignContainer.Container, { styleConfig: { root: [staticBulletedListStyles.itemWrapper, ...customItemWrapper] }, children: [jsxRuntime.jsx(ctDesignContainer.Container, { styleConfig: { root: [staticBulletedListStyles.placeHolder, ...customPlaceHolder] }, children: listType === 'ol' ? (jsxRuntime.jsxs(ctDesignContainer.Container, { styleConfig: {
|
|
46
|
+
root: [staticBulletedListStyles.marker, dynamicNumberWidth === null || dynamicNumberWidth === void 0 ? void 0 : dynamicNumberWidth.root, ...customMarker],
|
|
47
|
+
}, children: [jsxRuntime.jsx(ctDesignTypography.Typography, { variant: 'B2', color: 'primary', children: index + 1 }), jsxRuntime.jsx(ctDesignTypography.Typography, { variant: 'B2', color: 'primary', children: "." })] })) : (jsxRuntime.jsx(ctDesignTypography.Typography, { variant: 'B2', color: 'primary', children: '\u2022' })) }), jsxRuntime.jsx(ctDesignContainer.Container, { styleConfig: { root: [staticBulletedListStyles.itemContent, ...customItemContent] }, children: renderItem(item, index) })] }, (_a = item === null || item === void 0 ? void 0 : item.id) !== null && _a !== void 0 ? _a : index));
|
|
48
|
+
}) }));
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
exports.BulletedList = BulletedList;
|
|
52
|
+
|
|
53
|
+
}));
|
|
54
|
+
//# sourceMappingURL=ct-design-bulleted-list.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ct-design-bulleted-list.umd.js","sources":["../packages/components/BulletedList/src/style.ts","../packages/components/BulletedList/src/BulletedList.tsx"],"sourcesContent":[null,null],"names":["makeStyles","useStyles","_jsx","_Fragment","_jsxs","Container","Typography"],"mappings":";;;;;;IASA,MAAM,wBAAwB,GAAGA,+BAAU,CAAC,CAAC,KAAK,MAAM;IACtD,IAAA,WAAW,EAAE;IACX,QAAA,aAAa,EAAE,KAAc;IAC7B,QAAA,UAAU,EAAE,YAAqB;YACjC,SAAS,EAAE,KAAK,KAAA,IAAA,IAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,OAAO,CAAC,CAAC,CAAC;IAC7B,KAAA;IACD,IAAA,WAAW,EAAE;IACX,QAAA,UAAU,EAAE,CAAC;YACb,KAAK,EAAE,KAAK,KAAA,IAAA,IAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,KAAK,CAAC,IAAI,CAAC,OAAO;IAChC,QAAA,QAAQ,EAAE,EAAE;IACZ,QAAA,UAAU,EAAE,QAAiB;IAC7B,QAAA,cAAc,EAAE,QAAiB;IAClC,KAAA;IACD,IAAA,WAAW,EAAE;IACX,QAAA,IAAI,EAAE,CAAC;IACR,KAAA;IACD,IAAA,MAAM,EAAE;IACN,QAAA,aAAa,EAAE,KAAc;IAC7B,QAAA,UAAU,EAAE,QAAiB;IAC7B,QAAA,cAAc,EAAE,QAAiB;IAClC,KAAA;IACF,CAAA,CAAC,CAAC;;ACFH,UAAM,YAAY,GAAG,CAAqC,EACxD,IAAI,EACJ,UAAU,EACV,QAAQ,GAAG,IAAI,EACf,WAAW,GACW,KAAI;IAC1B,IAAA,MAAM,EAC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,wBAAwB,CAAC,MAAM,EAAE,kBAAkB,KAAA,IAAA,IAAlB,kBAAkB,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAlB,kBAAkB,CAAE,IAAI,EAAE,GAAG,YAAY,CAAC;IACnF,6BAAA,EAAA,QAAA,EAAA,CAEDH,eAACI,6BAAU,EAAA,EAAC,OAAO,EAAC,IAAI,EAAC,KAAK,EAAC,SAAS,EAAA,QAAA,EACrC,KAAK,GAAG,CAAC,GACC,EACbJ,cAAA,CAACI,6BAAU,EAAC,EAAA,OAAO,EAAC,IAAI,EAAC,KAAK,EAAC,SAAS,EAE3B,QAAA,EAAA,GAAA,EAAA,CAAA,CAAA,EAAA,CACH,KAEZJ,cAAA,CAACI,6BAAU,EAAC,EAAA,OAAO,EAAC,IAAI,EAAC,KAAK,EAAC,SAAS,EACrC,QAAA,EAAA,QAAQ,GACE,CACd,EAAA,CACS,EACZJ,cAAC,CAAAG,2BAAS,IAAC,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,wBAAwB,CAAC,WAAW,EAAE,GAAG,iBAAiB,CAAC,EAAE,EAC3F,QAAA,EAAA,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,EAAA,CACd,KAxBP,CAAA,EAAA,GAAA,IAAI,aAAJ,IAAI,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAJ,IAAI,CAAE,EAAE,mCAAI,KAAK,CAyBZ,EACb;aAAA,CAAC,EAAA,CACD,EACH;IACJ;;;;;;;;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../packages/components/BulletedList/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.native.d.ts","sourceRoot":"","sources":["../packages/components/BulletedList/src/index.native.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,cAAc,QAAQ,CAAC"}
|
package/dist/style.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare const staticBulletedListStyles: {
|
|
2
|
+
itemWrapper: {
|
|
3
|
+
flexDirection: "row";
|
|
4
|
+
alignItems: "flex-start";
|
|
5
|
+
columnGap: 4;
|
|
6
|
+
};
|
|
7
|
+
placeHolder: {
|
|
8
|
+
flexShrink: number;
|
|
9
|
+
color: string;
|
|
10
|
+
minWidth: number;
|
|
11
|
+
alignItems: "center";
|
|
12
|
+
justifyContent: "center";
|
|
13
|
+
};
|
|
14
|
+
itemContent: {
|
|
15
|
+
flex: number;
|
|
16
|
+
};
|
|
17
|
+
marker: {
|
|
18
|
+
flexDirection: "row";
|
|
19
|
+
alignItems: "center";
|
|
20
|
+
justifyContent: "center";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export default staticBulletedListStyles;
|
|
24
|
+
//# sourceMappingURL=style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../packages/components/BulletedList/src/style.ts"],"names":[],"mappings":"AASA,QAAA,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;CAqB3B,CAAC;AAEJ,eAAe,wBAAwB,CAAC"}
|
package/dist/type.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { Styles } from '@cleartrip/ct-design-types';
|
|
3
|
+
export type BulletedListType = 'ol' | 'ul';
|
|
4
|
+
export interface IBulletedListStyleConfig {
|
|
5
|
+
itemWrapper?: Styles[];
|
|
6
|
+
placeHolder?: Styles[];
|
|
7
|
+
itemContent?: Styles[];
|
|
8
|
+
marker?: Styles[];
|
|
9
|
+
}
|
|
10
|
+
export interface IBulletedListProps<T extends {
|
|
11
|
+
id?: string | number;
|
|
12
|
+
}> {
|
|
13
|
+
list: T[];
|
|
14
|
+
renderItem: (item: T, index: number) => ReactNode;
|
|
15
|
+
listType?: BulletedListType;
|
|
16
|
+
styleConfig?: IBulletedListStyleConfig;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../packages/components/BulletedList/src/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAOzD,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,IAAI,CAAC;AAK3C,MAAM,WAAW,wBAAwB;IAIvC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAKvB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAMvB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAKvB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AASD,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS;IAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE;IAKpE,IAAI,EAAE,CAAC,EAAE,CAAC;IAMV,UAAU,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC;IAKlD,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAK5B,WAAW,CAAC,EAAE,wBAAwB,CAAC;CACxC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cleartrip/ct-design-bulleted-list",
|
|
3
|
+
"version": "4.0.0-SNAPSHOT-test.0",
|
|
4
|
+
"description": "BulletedList Component — ordered (ol) and unordered (ul) list renderer.",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"main": "./dist/ct-design-bulleted-list.cjs.js",
|
|
7
|
+
"react-native": "src/index.native.ts",
|
|
8
|
+
"jsnext:main": "dist/ct-design-bulleted-list.esm.js",
|
|
9
|
+
"module": "dist/ct-design-bulleted-list.esm.js",
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/ct-design-bulleted-list.d.ts",
|
|
14
|
+
"import": "./dist/ct-design-bulleted-list.esm.js",
|
|
15
|
+
"default": "./dist/ct-design-bulleted-list.cjs.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"browser": {
|
|
19
|
+
"./dist/ct-design-bulleted-list.esm.js": "./dist/ct-design-bulleted-list.browser.esm.js",
|
|
20
|
+
"./dist/ct-design-bulleted-list.cjs.js": "./dist/ct-design-bulleted-list.browser.cjs.js"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"src"
|
|
25
|
+
],
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@cleartrip/ct-design-container": "4.0.0-SNAPSHOT-test.0",
|
|
28
|
+
"@cleartrip/ct-design-style-manager": "4.0.0-SNAPSHOT-test.0",
|
|
29
|
+
"@cleartrip/ct-design-theme": "4.0.0-SNAPSHOT-test.0",
|
|
30
|
+
"@cleartrip/ct-design-typography": "4.0.0-SNAPSHOT-test.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@cleartrip/ct-design-types": "4.0.0-SNAPSHOT-test.0"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"react": ">=16.8.0",
|
|
37
|
+
"react-dom": ">=16.8.0",
|
|
38
|
+
"react-native": ">=0.68.0"
|
|
39
|
+
},
|
|
40
|
+
"peerDependenciesMeta": {
|
|
41
|
+
"react-native": {
|
|
42
|
+
"optional": true
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"author": "Cleartrip",
|
|
49
|
+
"license": "ISC",
|
|
50
|
+
"scripts": {
|
|
51
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
52
|
+
"watch-package": "rollup -c -w",
|
|
53
|
+
"build-package": "rollup -c",
|
|
54
|
+
"build-package:clean": "rm -rf dist && rollup -c",
|
|
55
|
+
"publish-package:local": "yalc publish"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Container } from '@cleartrip/ct-design-container';
|
|
2
|
+
import { Typography } from '@cleartrip/ct-design-typography';
|
|
3
|
+
import { useStyles } from '@cleartrip/ct-design-style-manager';
|
|
4
|
+
|
|
5
|
+
import staticBulletedListStyles from './style';
|
|
6
|
+
import type { IBulletedListProps } from './type';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* BulletedList
|
|
10
|
+
*
|
|
11
|
+
* A flexible list renderer that supports ordered (`ol`) and unordered
|
|
12
|
+
* (`ul`) list markers. Each row shows a marker (number or bullet)
|
|
13
|
+
* followed by arbitrary content returned from `renderItem`.
|
|
14
|
+
*
|
|
15
|
+
* The ordered-list marker width auto-scales with the largest row
|
|
16
|
+
* number so every digit column lines up — one extra pixel of slot
|
|
17
|
+
* width per digit so a 10-item list stays aligned with a 100-item
|
|
18
|
+
* list.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <BulletedList
|
|
23
|
+
* list={faqItems}
|
|
24
|
+
* listType="ol"
|
|
25
|
+
* renderItem={(item) => <Typography variant="P2">{item.title}</Typography>}
|
|
26
|
+
* />
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
const BulletedList = <T extends { id?: string | number }>({
|
|
30
|
+
list,
|
|
31
|
+
renderItem,
|
|
32
|
+
listType = 'ol',
|
|
33
|
+
styleConfig,
|
|
34
|
+
}: IBulletedListProps<T>) => {
|
|
35
|
+
const {
|
|
36
|
+
itemWrapper: customItemWrapper = [],
|
|
37
|
+
placeHolder: customPlaceHolder = [],
|
|
38
|
+
itemContent: customItemContent = [],
|
|
39
|
+
marker: customMarker = [],
|
|
40
|
+
} = styleConfig || {};
|
|
41
|
+
|
|
42
|
+
const maxNumber = list?.length || 0;
|
|
43
|
+
|
|
44
|
+
// Character count of the largest row number — drives the marker
|
|
45
|
+
// column width so every item's digit group lines up regardless of
|
|
46
|
+
// 1/2/3-digit transitions.
|
|
47
|
+
const maxNumberDigits = String(maxNumber).length;
|
|
48
|
+
|
|
49
|
+
// Width of the number column based on the digit count.
|
|
50
|
+
const numberWidth = maxNumberDigits * 12;
|
|
51
|
+
|
|
52
|
+
const dynamicNumberWidth = useStyles(
|
|
53
|
+
() => ({
|
|
54
|
+
root: {
|
|
55
|
+
width: numberWidth,
|
|
56
|
+
},
|
|
57
|
+
}),
|
|
58
|
+
[numberWidth],
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
if (!list || list.length === 0) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<>
|
|
67
|
+
{list.map((item, index) => (
|
|
68
|
+
<Container
|
|
69
|
+
styleConfig={{ root: [staticBulletedListStyles.itemWrapper, ...customItemWrapper] }}
|
|
70
|
+
key={item?.id ?? index}
|
|
71
|
+
>
|
|
72
|
+
<Container styleConfig={{ root: [staticBulletedListStyles.placeHolder, ...customPlaceHolder] }}>
|
|
73
|
+
{listType === 'ol' ? (
|
|
74
|
+
<Container
|
|
75
|
+
styleConfig={{
|
|
76
|
+
root: [staticBulletedListStyles.marker, dynamicNumberWidth?.root, ...customMarker],
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
<Typography variant='B2' color='primary'>
|
|
80
|
+
{index + 1}
|
|
81
|
+
</Typography>
|
|
82
|
+
<Typography variant='B2' color='primary'>
|
|
83
|
+
.
|
|
84
|
+
</Typography>
|
|
85
|
+
</Container>
|
|
86
|
+
) : (
|
|
87
|
+
<Typography variant='B2' color='primary'>
|
|
88
|
+
{'\u2022'}
|
|
89
|
+
</Typography>
|
|
90
|
+
)}
|
|
91
|
+
</Container>
|
|
92
|
+
<Container styleConfig={{ root: [staticBulletedListStyles.itemContent, ...customItemContent] }}>
|
|
93
|
+
{renderItem(item, index)}
|
|
94
|
+
</Container>
|
|
95
|
+
</Container>
|
|
96
|
+
))}
|
|
97
|
+
</>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export default BulletedList;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Native and web share the same implementation — both rely on
|
|
2
|
+
// platform-agnostic primitives (Container, Typography, useStyles,
|
|
3
|
+
// makeStyles) and contain no emotion-specific code.
|
|
4
|
+
export { default as BulletedList } from './BulletedList';
|
|
5
|
+
export * from './type';
|
package/src/index.ts
ADDED
package/src/style.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { makeStyles } from '@cleartrip/ct-design-style-manager';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Static styles shared by both web and native implementations. All
|
|
5
|
+
* values are pure theme lookups and layout primitives that work
|
|
6
|
+
* identically across platforms; dynamic width (based on the maximum
|
|
7
|
+
* number of digits in the list length) is applied on top via
|
|
8
|
+
* `useStyles` inside the component.
|
|
9
|
+
*/
|
|
10
|
+
const staticBulletedListStyles = makeStyles((theme) => ({
|
|
11
|
+
itemWrapper: {
|
|
12
|
+
flexDirection: 'row' as const,
|
|
13
|
+
alignItems: 'flex-start' as const,
|
|
14
|
+
columnGap: theme?.spacing[1],
|
|
15
|
+
},
|
|
16
|
+
placeHolder: {
|
|
17
|
+
flexShrink: 0,
|
|
18
|
+
color: theme?.color.text.primary,
|
|
19
|
+
minWidth: 20,
|
|
20
|
+
alignItems: 'center' as const,
|
|
21
|
+
justifyContent: 'center' as const,
|
|
22
|
+
},
|
|
23
|
+
itemContent: {
|
|
24
|
+
flex: 1,
|
|
25
|
+
},
|
|
26
|
+
marker: {
|
|
27
|
+
flexDirection: 'row' as const,
|
|
28
|
+
alignItems: 'center' as const,
|
|
29
|
+
justifyContent: 'center' as const,
|
|
30
|
+
},
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
export default staticBulletedListStyles;
|
package/src/type.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { Styles } from '@cleartrip/ct-design-types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Type of marker displayed for each list item.
|
|
7
|
+
* - `'ol'` — numbered list (1. 2. 3.)
|
|
8
|
+
* - `'ul'` — bullet list (•)
|
|
9
|
+
*/
|
|
10
|
+
export type BulletedListType = 'ol' | 'ul';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* `styleConfig` slots for fine-grained style overrides on BulletedList.
|
|
14
|
+
*/
|
|
15
|
+
export interface IBulletedListStyleConfig {
|
|
16
|
+
/**
|
|
17
|
+
* Styles for the outer row container wrapping each list item.
|
|
18
|
+
*/
|
|
19
|
+
itemWrapper?: Styles[];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Styles for the marker container (bullet/number placeholder area).
|
|
23
|
+
*/
|
|
24
|
+
placeHolder?: Styles[];
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Styles for the content container where `renderItem` output is
|
|
28
|
+
* displayed.
|
|
29
|
+
*/
|
|
30
|
+
itemContent?: Styles[];
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Styles for the marker row (number + dot on ordered lists).
|
|
34
|
+
*/
|
|
35
|
+
marker?: Styles[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Props for the BulletedList component.
|
|
40
|
+
*
|
|
41
|
+
* @typeParam T - Shape of each list item. An optional `id` property,
|
|
42
|
+
* if present, is used as the React key; otherwise the array index is
|
|
43
|
+
* used.
|
|
44
|
+
*/
|
|
45
|
+
export interface IBulletedListProps<T extends { id?: string | number }> {
|
|
46
|
+
/**
|
|
47
|
+
* Items to render. Keys come from `item.id` when defined, else the
|
|
48
|
+
* row index.
|
|
49
|
+
*/
|
|
50
|
+
list: T[];
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Callback that receives the current item and its index, returning
|
|
54
|
+
* the React content for that row.
|
|
55
|
+
*/
|
|
56
|
+
renderItem: (item: T, index: number) => ReactNode;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Type of marker to display. Defaults to `'ol'`.
|
|
60
|
+
*/
|
|
61
|
+
listType?: BulletedListType;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* `styleConfig` slots for fine-grained style overrides.
|
|
65
|
+
*/
|
|
66
|
+
styleConfig?: IBulletedListStyleConfig;
|
|
67
|
+
}
|