tabler-react-2 0.1.95 → 0.1.96
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/docs/package.json
CHANGED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Enclosed Select Group
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import { EnclosedSelectGroup } from "../../components/LoadableTabler.jsx";
|
|
6
|
+
import { Excerpt } from "../../components/Excerpt.jsx";
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
|
|
9
|
+
Enclosed Select Groups are used to mask radio and checkbox inputs in boxes with a label.
|
|
10
|
+
|
|
11
|
+
## Signature
|
|
12
|
+
|
|
13
|
+
export const ControlledEnclosedSelectGroup = (props) => {
|
|
14
|
+
const [selectValue, setSelectValue] = useState();
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
<EnclosedSelectGroup
|
|
18
|
+
multiple
|
|
19
|
+
direction="column"
|
|
20
|
+
value={selectValue}
|
|
21
|
+
onChange={(v) => {
|
|
22
|
+
console.log(v);
|
|
23
|
+
setSelectValue(v);
|
|
24
|
+
}}
|
|
25
|
+
items={[
|
|
26
|
+
{ value: "one", content: <b>One</b> },
|
|
27
|
+
{ value: "two", content: "Two" },
|
|
28
|
+
{ value: "three", content: "Three" },
|
|
29
|
+
]}
|
|
30
|
+
/>
|
|
31
|
+
</>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
```jsx
|
|
36
|
+
import { EnclosedSelectGroup } from "tabler-react-2";
|
|
37
|
+
|
|
38
|
+
<EnclosedSelectGroup
|
|
39
|
+
items={[
|
|
40
|
+
{ value: "one", label: <b>One</b> },
|
|
41
|
+
{ value: "two", label: "Two" },
|
|
42
|
+
{ value: "three", label: "Three" },
|
|
43
|
+
]}
|
|
44
|
+
value={null}
|
|
45
|
+
onChange={console.log}
|
|
46
|
+
/>;
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Props
|
|
50
|
+
|
|
51
|
+
| Prop | Required | Type | Default | Description |
|
|
52
|
+
| ----------- | -------- | -------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
53
|
+
| `items` | Yes | Array of objects | | The items to be shown in the select group. Each item should have a `value` and `label` prop. |
|
|
54
|
+
| `value` | Yes | Object or Array of Objects if multiple | | The value of the select group. If the value is an array, multiple items can be selected. The value of each item should be the same as the `value` prop of the item. |
|
|
55
|
+
| `onChange` | Yes | Function | | The function to be called when the value of the select group changes. It is called with the new value as the argument, not the event. If the value is an array, the new value is an array of objects. The value of each item should be the same as the `value` prop of the item. |
|
|
56
|
+
| `multiple` | No | Boolean | | Whether multiple items can be selected. |
|
|
57
|
+
| `direction` | No | String | "row" | The direction of the items. Can be "row" or "column". |
|
|
58
|
+
|
|
59
|
+
## Basic Usage
|
|
60
|
+
|
|
61
|
+
The `EnclosedSelectGroup` component is used to mask radio and checkbox inputs in boxes with a label.
|
|
62
|
+
|
|
63
|
+
<Excerpt>
|
|
64
|
+
<ControlledEnclosedSelectGroup
|
|
65
|
+
items={[
|
|
66
|
+
{ value: "one", label: <u>One</u> },
|
|
67
|
+
{ value: "two", label: "Two" },
|
|
68
|
+
{ value: "three", label: "Three" },
|
|
69
|
+
]}
|
|
70
|
+
value={null}
|
|
71
|
+
onChange={console.log}
|
|
72
|
+
/>
|
|
73
|
+
</Excerpt>
|
|
74
|
+
|
|
75
|
+
```jsx
|
|
76
|
+
<EnclosedSelectGroup
|
|
77
|
+
items={[
|
|
78
|
+
{ value: "one", label: <u>One</u> },
|
|
79
|
+
{ value: "two", label: "Two" },
|
|
80
|
+
{ value: "three", label: "Three" },
|
|
81
|
+
]}
|
|
82
|
+
value={null}
|
|
83
|
+
onChange={console.log}
|
|
84
|
+
/>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Multiple Select
|
|
88
|
+
|
|
89
|
+
The `multiple` prop can be used to allow multiple items to be selected.
|
|
90
|
+
|
|
91
|
+
<Excerpt>
|
|
92
|
+
<ControlledEnclosedSelectGroup
|
|
93
|
+
items={[
|
|
94
|
+
{ value: "one", label: <u>One</u> },
|
|
95
|
+
{ value: "two", label: "Two" },
|
|
96
|
+
{ value: "three", label: "Three" },
|
|
97
|
+
]}
|
|
98
|
+
value={[
|
|
99
|
+
{
|
|
100
|
+
value: "one",
|
|
101
|
+
},
|
|
102
|
+
]}
|
|
103
|
+
onChange={console.log}
|
|
104
|
+
multiple
|
|
105
|
+
/>
|
|
106
|
+
</Excerpt>
|
|
107
|
+
|
|
108
|
+
```jsx
|
|
109
|
+
<EnclosedSelectGroup
|
|
110
|
+
items={[
|
|
111
|
+
{ value: "one", label: <u>One</u> },
|
|
112
|
+
{ value: "two", label: "Two" },
|
|
113
|
+
{ value: "three", label: "Three" },
|
|
114
|
+
]}
|
|
115
|
+
value={[]}
|
|
116
|
+
onChange={console.log}
|
|
117
|
+
multiple
|
|
118
|
+
/>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Direction
|
|
122
|
+
|
|
123
|
+
The `direction` prop can be used to change the direction of the items.
|
|
124
|
+
|
|
125
|
+
<Excerpt>
|
|
126
|
+
<ControlledEnclosedSelectGroup
|
|
127
|
+
items={[
|
|
128
|
+
{ value: "one", label: <u>One</u> },
|
|
129
|
+
{ value: "two", label: "Two" },
|
|
130
|
+
{ value: "three", label: "Three" },
|
|
131
|
+
]}
|
|
132
|
+
value={null}
|
|
133
|
+
onChange={console.log}
|
|
134
|
+
direction="column"
|
|
135
|
+
/>
|
|
136
|
+
</Excerpt>
|
|
137
|
+
|
|
138
|
+
```jsx
|
|
139
|
+
<EnclosedSelectGroup
|
|
140
|
+
items={[
|
|
141
|
+
{ value: "one", label: <u>One</u> },
|
|
142
|
+
{ value: "two", label: "Two" },
|
|
143
|
+
{ value: "three", label: "Three" },
|
|
144
|
+
]}
|
|
145
|
+
value={null}
|
|
146
|
+
onChange={console.log}
|
|
147
|
+
direction="column"
|
|
148
|
+
/>
|
|
149
|
+
```
|
|
@@ -29,22 +29,6 @@ export const ControlledSelectGroup = (props) => {
|
|
|
29
29
|
);
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
export const ControlledEnclosedSelectGroup = (props) => {
|
|
33
|
-
const [value, setValue] = useState(props.value);
|
|
34
|
-
return (
|
|
35
|
-
<>
|
|
36
|
-
<EnclosedSelectGroup
|
|
37
|
-
{...props}
|
|
38
|
-
value={value}
|
|
39
|
-
onChange={(d) => {
|
|
40
|
-
setValue(d);
|
|
41
|
-
props.onChange && props.onChange(d);
|
|
42
|
-
}}
|
|
43
|
-
/>
|
|
44
|
-
</>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
32
|
```jsx
|
|
49
33
|
import { SelectGroup } from "tabler-react-2";
|
|
50
34
|
|
|
@@ -119,19 +103,3 @@ The `multiple` prop can be used to allow multiple items to be selected.
|
|
|
119
103
|
multiple
|
|
120
104
|
/>
|
|
121
105
|
```
|
|
122
|
-
|
|
123
|
-
## Enclosed Select Group
|
|
124
|
-
|
|
125
|
-
The `EnclosedSelectGroup` component is used to mask radio and checkbox inputs in boxes with a label.
|
|
126
|
-
|
|
127
|
-
<Excerpt>
|
|
128
|
-
<ControlledEnclosedSelectGroup
|
|
129
|
-
items={[
|
|
130
|
-
{ value: "one", content: <b>One</b> },
|
|
131
|
-
{ value: "two", content: "Two" },
|
|
132
|
-
{ value: "three", content: "Three" },
|
|
133
|
-
]}
|
|
134
|
-
value={null}
|
|
135
|
-
onChange={console.log}
|
|
136
|
-
/>
|
|
137
|
-
</Excerpt>
|