@@ -80,6 +80,7 @@ React Dynamic Tabs with full API
80
80
``` js
81
81
$ npm install react- dyn- tabs -- save
82
82
```
83
+
83
84
or
84
85
85
86
``` js
@@ -89,7 +90,7 @@ $ yarn add react-dyn-tabs
89
90
## Syntax
90
91
91
92
``` js
92
- [TabList,PanelList,ready] = useDynTabs (initialOptions,plugins);
93
+ [TabList, PanelList, ready] = useDynTabs (initialOptions, plugins);
93
94
```
94
95
95
96
## Minimal Usage Example
@@ -155,14 +156,14 @@ export default () => {
155
156
const [TabList , PanelList , ready ] = useDynTabs (initialOptions);
156
157
const addTab3 = function () {
157
158
ready ((instance ) => {
158
- // open tab 3
159
- instance .open ({id: ' 3' , title: ' Tab 3' , panelComponent : (porps ) => < p> panel 3 < / p> }).then (() => {
160
- console .log (' tab 3 is open' );
161
- });
162
- // switch to tab 3
163
- instance .select (' 3' ).then (() => {
164
- console .log (' tab 3 is selected' );
165
- });
159
+ // open tab 3
160
+ instance .open ({id: ' 3' , title: ' Tab 3' , panelComponent : (porps ) => < p> panel 3 < / p> }).then (() => {
161
+ console .log (' tab 3 is open' );
162
+ });
163
+ // switch to tab 3
164
+ instance .select (' 3' ).then (() => {
165
+ console .log (' tab 3 is selected' );
166
+ });
166
167
});
167
168
};
168
169
@@ -180,12 +181,11 @@ export default () => {
180
181
181
182
- Use ` ready ` function to access the ` instance ` object
182
183
183
- ``` js
184
- ready ((instance ) => {
185
- // manipulate tabs using instance object here
186
- });
187
-
188
- ```
184
+ ``` js
185
+ ready ((instance ) => {
186
+ // manipulate tabs using instance object here
187
+ });
188
+ ```
189
189
190
190
- ` ready ` function accepts a ` callback ` as its parameter and executes it as soon as Tabs get mounted.
191
191
@@ -372,8 +372,6 @@ const [TabList, PanelList, ready] = useDynTabs({
372
372
});
373
373
```
374
374
375
-
376
-
377
375
### accessibility
378
376
379
377
<table >
@@ -886,7 +884,7 @@ Parameters:
886
884
** Example**
887
885
888
886
``` js
889
- const {id ,title ,tooltip ,disable ,lazy ,iconClass ,closable ,panelComponent } = instance .getTab (' contactID' );
887
+ const {id , title , tooltip , disable , lazy , iconClass , closable , panelComponent } = instance .getTab (' contactID' );
890
888
console .log (id); // contactID
891
889
```
892
890
@@ -1197,7 +1195,6 @@ export default () => {
1197
1195
< / div>
1198
1196
);
1199
1197
};
1200
-
1201
1198
```
1202
1199
1203
1200
** Options**
@@ -1207,69 +1204,76 @@ export default () => {
1207
1204
<tr>
1208
1205
<th>option name</th>
1209
1206
<th>type</th>
1210
- <th>default value</th>
1211
1207
<th>description</th>
1212
1208
</tr>
1213
1209
<tr>
1214
- <td>moreButtonPlugin_buttonComponent *</td>
1215
- <td>React Component</td>
1216
- <td></td>
1217
- <td>customize button component of more button plugin</td>
1210
+ <td>moreButtonPlugin_buttonComponent</td>
1211
+ <td>React Function Component</td>
1212
+ <td>customize root component of more button</td>
1218
1213
</tr>
1219
1214
<tr>
1220
- <td>moreButtonPlugin_iconComponent *</td>
1221
- <td>React Component</td>
1215
+ <td>moreButtonPlugin_iconComponent</td>
1216
+ <td>React Function Component</td>
1217
+ <td>customize icon component of more button</td>
1218
+ </tr>
1219
+ <tr>
1220
+ <td>moreButtonPlugin_buttonTooltip</td>
1221
+ <td>string</td>
1222
1222
<td></td>
1223
- <td>customize icon component of more button plugin</td>
1224
1223
</tr>
1225
1224
</tbody >
1226
1225
</table >
1227
1226
1228
1227
** Example**
1229
1228
1230
1229
``` js
1231
- useDynamicTabs ({
1232
- moreButtonPlugin_iconComponent : ({ instance }) => {
1233
- return < i className= {` fa fa-chevron-${ instance .getOption (' direction' ) === ' rtl' ? ' left' : ' right' } ` } / >
1234
- }
1235
- }, [MoreButtonPlugin]);
1230
+ useDynamicTabs (
1231
+ {
1232
+ moreButtonPlugin_iconComponent : ({instance}) => {
1233
+ return < i className= {` fa fa-chevron-${ instance .getOption (' direction' ) === ' rtl' ? ' left' : ' right' } ` } / > ;
1234
+ },
1235
+ },
1236
+ [MoreButtonPlugin],
1237
+ );
1236
1238
```
1237
1239
1238
1240
## Render custom components at the end of the Tablist
1239
1241
1240
1242
- render ` new tab ` button example :
1241
- ``` js
1242
- const [TabList , PanelList , ready ] = useDynTabs (initialOptions, [MoreButtonPlugin]);
1243
- return (
1244
- < div>
1245
- < TabList>
1246
- < button onClick= {()=> { ready (instance => instance .open ({title: ' new tab' })) }}>
1247
- NEW
1248
- < / button>
1249
- < / TabList>
1250
- < PanelList>< / PanelList>
1251
- < / div>
1252
- );
1253
- };
1254
-
1255
- ```
1243
+
1244
+ ``` js
1245
+ const [TabList , PanelList , ready ] = useDynTabs (initialOptions, [MoreButtonPlugin]);
1246
+ return (
1247
+ < div>
1248
+ < TabList>
1249
+ < button onClick= {()=> { ready (instance => instance .open ({title: ' new tab' })) }}>
1250
+ NEW
1251
+ < / button>
1252
+ < / TabList>
1253
+ < PanelList>< / PanelList>
1254
+ < / div>
1255
+ );
1256
+ };
1257
+
1258
+ ```
1256
1259
1257
1260
- render ` close all ` button example :
1258
- ` ` ` js
1259
- const [TabList, PanelList, ready] = useDynTabs(initialOptions, [MoreButtonPlugin]);
1260
- return (
1261
- <div>
1262
- <TabList>
1263
- <button onClick={()=>{ ready(instance=>{ instance.getData().openTabIDs.forEach(id=>instance.close(id,false)); })}}>
1264
- CLOSE ALL
1265
- </button>
1266
- </TabList>
1267
- <PanelList></PanelList>
1268
- </div>
1269
- );
1270
- };
1271
-
1272
- ` ` `
1261
+
1262
+ ``` js
1263
+ const [TabList , PanelList , ready ] = useDynTabs (initialOptions, [MoreButtonPlugin]);
1264
+ return (
1265
+ < div>
1266
+ < TabList>
1267
+ < button onClick= {()=> { ready (instance => { instance .getData ().openTabIDs .forEach (id => instance .close (id,false )); })}}>
1268
+ CLOSE ALL
1269
+ < / button>
1270
+ < / TabList>
1271
+ < PanelList>< / PanelList>
1272
+ < / div>
1273
+ );
1274
+ };
1275
+
1276
+ ```
1273
1277
1274
1278
## Styling
1275
1279
0 commit comments