tabler-react-2 0.1.139 → 0.1.141
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/dist/index.js +13 -1
- package/dist/modal/confirm.js +28 -26
- package/dist/modal/modal.js +1 -1
- package/dist/segmentedControl/index.js +48 -45
- package/docs/package.json +1 -1
- package/docs/src/components/LoadableTabler.jsx +3 -0
- package/docs/src/components/Tabler.jsx +2 -1
- package/docs/src/config/sidebar.yml +2 -0
- package/docs/src/docs/changelog.mdx +12 -0
- package/docs/src/docs/components/segmented-control.mdx +69 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -192,7 +192,7 @@ Object.keys(_index18).forEach(function (key) {
|
|
|
192
192
|
}
|
|
193
193
|
});
|
|
194
194
|
});
|
|
195
|
-
var _index19 = require("./
|
|
195
|
+
var _index19 = require("./segmentedControl/index");
|
|
196
196
|
Object.keys(_index19).forEach(function (key) {
|
|
197
197
|
if (key === "default" || key === "__esModule") return;
|
|
198
198
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -204,5 +204,17 @@ Object.keys(_index19).forEach(function (key) {
|
|
|
204
204
|
}
|
|
205
205
|
});
|
|
206
206
|
});
|
|
207
|
+
var _index20 = require("./offcanvas/index");
|
|
208
|
+
Object.keys(_index20).forEach(function (key) {
|
|
209
|
+
if (key === "default" || key === "__esModule") return;
|
|
210
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
211
|
+
if (key in exports && exports[key] === _index20[key]) return;
|
|
212
|
+
Object.defineProperty(exports, key, {
|
|
213
|
+
enumerable: true,
|
|
214
|
+
get: function get() {
|
|
215
|
+
return _index20[key];
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
});
|
|
207
219
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
208
220
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
package/dist/modal/confirm.js
CHANGED
|
@@ -10,6 +10,7 @@ var _modal = require("./modal");
|
|
|
10
10
|
var _button = require("../button");
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _typography = require("../typography");
|
|
13
|
+
var _excluded = ["open", "onDecision", "children", "modalId", "status"];
|
|
13
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
14
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
15
16
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -23,6 +24,9 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
23
24
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
24
25
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
25
26
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
27
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
28
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
29
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
26
30
|
var IconAlertTriangle = function IconAlertTriangle(_ref) {
|
|
27
31
|
var size = _ref.size,
|
|
28
32
|
strokeWidth = _ref.strokeWidth;
|
|
@@ -54,15 +58,16 @@ var ConfirmBase = function ConfirmBase(_ref2) {
|
|
|
54
58
|
onDecision = _ref2.onDecision,
|
|
55
59
|
children = _ref2.children,
|
|
56
60
|
modalId = _ref2.modalId,
|
|
57
|
-
status = _ref2.status
|
|
58
|
-
|
|
61
|
+
status = _ref2.status,
|
|
62
|
+
props = _objectWithoutProperties(_ref2, _excluded);
|
|
63
|
+
return /*#__PURE__*/_react["default"].createElement(_modal.Modal, _extends({
|
|
59
64
|
open: open,
|
|
60
65
|
onClose: function onClose() {
|
|
61
66
|
return onDecision(false);
|
|
62
67
|
},
|
|
63
68
|
modalId: modalId,
|
|
64
69
|
status: "danger"
|
|
65
|
-
}, children);
|
|
70
|
+
}, props), children);
|
|
66
71
|
};
|
|
67
72
|
var DangerConfirm = function DangerConfirm(_ref3) {
|
|
68
73
|
var open = _ref3.open,
|
|
@@ -74,7 +79,25 @@ var DangerConfirm = function DangerConfirm(_ref3) {
|
|
|
74
79
|
return /*#__PURE__*/_react["default"].createElement(ConfirmBase, {
|
|
75
80
|
open: open,
|
|
76
81
|
onDecision: onDecision,
|
|
77
|
-
modalId: "asdfpiuhs987huyoasidfa"
|
|
82
|
+
modalId: "asdfpiuhs987huyoasidfa",
|
|
83
|
+
buttons: [{
|
|
84
|
+
text: cancelText,
|
|
85
|
+
onClick: function onClick() {
|
|
86
|
+
return onDecision(false);
|
|
87
|
+
},
|
|
88
|
+
style: {
|
|
89
|
+
flex: 1
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
text: commitText,
|
|
93
|
+
onClick: function onClick() {
|
|
94
|
+
return onDecision(true);
|
|
95
|
+
},
|
|
96
|
+
variant: "danger",
|
|
97
|
+
style: {
|
|
98
|
+
flex: 1
|
|
99
|
+
}
|
|
100
|
+
}]
|
|
78
101
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
79
102
|
"class": "modal-body text-center py-4"
|
|
80
103
|
}, /*#__PURE__*/_react["default"].createElement(_util.Color, {
|
|
@@ -84,28 +107,7 @@ var DangerConfirm = function DangerConfirm(_ref3) {
|
|
|
84
107
|
strokeWidth: 1
|
|
85
108
|
})), /*#__PURE__*/_react["default"].createElement(_typography.H3, null, title), /*#__PURE__*/_react["default"].createElement(_typography.Text, {
|
|
86
109
|
className: "text-secondary"
|
|
87
|
-
}, text))
|
|
88
|
-
"class": "modal-footer"
|
|
89
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
90
|
-
"class": "w-100"
|
|
91
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
92
|
-
"class": "row"
|
|
93
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
94
|
-
"class": "col"
|
|
95
|
-
}, /*#__PURE__*/_react["default"].createElement(_button.Button, {
|
|
96
|
-
className: "w-100",
|
|
97
|
-
onClick: function onClick() {
|
|
98
|
-
return onDecision(false);
|
|
99
|
-
}
|
|
100
|
-
}, cancelText)), /*#__PURE__*/_react["default"].createElement("div", {
|
|
101
|
-
"class": "col"
|
|
102
|
-
}, /*#__PURE__*/_react["default"].createElement(_button.Button, {
|
|
103
|
-
className: "w-100",
|
|
104
|
-
color: "danger",
|
|
105
|
-
onClick: function onClick() {
|
|
106
|
-
return onDecision(true);
|
|
107
|
-
}
|
|
108
|
-
}, commitText))))));
|
|
110
|
+
}, text)));
|
|
109
111
|
};
|
|
110
112
|
var useConfirm = exports.useConfirm = function useConfirm() {
|
|
111
113
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
package/dist/modal/modal.js
CHANGED
|
@@ -74,7 +74,7 @@ var Modal = exports.Modal = function Modal(_ref) {
|
|
|
74
74
|
return /*#__PURE__*/_react["default"].createElement(_button.Button, _extends({
|
|
75
75
|
variant: button.variant,
|
|
76
76
|
key: index
|
|
77
|
-
}, button
|
|
77
|
+
}, button, {
|
|
78
78
|
onClick: button.onClick
|
|
79
79
|
}), button.text);
|
|
80
80
|
}))))), open && /*#__PURE__*/_react["default"].createElement("div", {
|
|
@@ -7,60 +7,63 @@ exports.SegmentedControl = void 0;
|
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
-
function
|
|
10
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
11
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
15
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // SegmentedControl.js
|
|
11
16
|
var SegmentedControl = exports.SegmentedControl = function SegmentedControl(_ref) {
|
|
12
|
-
var
|
|
13
|
-
orientation = _ref.orientation,
|
|
14
|
-
value = _ref.value,
|
|
17
|
+
var value = _ref.value,
|
|
15
18
|
onChange = _ref.onChange,
|
|
16
|
-
items = _ref.items
|
|
17
|
-
|
|
19
|
+
items = _ref.items,
|
|
20
|
+
_ref$vertical = _ref.vertical,
|
|
21
|
+
vertical = _ref$vertical === void 0 ? false : _ref$vertical,
|
|
22
|
+
size = _ref.size,
|
|
23
|
+
className = _ref.className,
|
|
24
|
+
buttonClassName = _ref.buttonClassName,
|
|
25
|
+
style = _ref.style,
|
|
26
|
+
buttonStyle = _ref.buttonStyle;
|
|
27
|
+
var _value = (value === null || value === void 0 ? void 0 : value.id) || value;
|
|
28
|
+
var navClasses = ["nav", "nav-segmented", vertical ? "nav-segmented-vertical" : null, size ? "nav-".concat(size) : null, className].filter(Boolean).join(" ");
|
|
18
29
|
return /*#__PURE__*/_react["default"].createElement("nav", {
|
|
19
30
|
className: navClasses,
|
|
20
|
-
role: "tablist"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
icon = _ref2.icon;
|
|
26
|
-
var isActive = id === value;
|
|
27
|
-
return /*#__PURE__*/_react["default"].createElement("button", _extends({
|
|
28
|
-
key: id,
|
|
31
|
+
role: "tablist",
|
|
32
|
+
style: style
|
|
33
|
+
}, items.map(function (item) {
|
|
34
|
+
return /*#__PURE__*/_react["default"].createElement("button", {
|
|
35
|
+
key: item.id,
|
|
29
36
|
type: "button",
|
|
30
|
-
className: "nav-link".concat(
|
|
37
|
+
className: "nav-link".concat(_value === item.id ? " active" : "").concat(item.disabled ? " disabled" : "", " ").concat(item.className, " ").concat(buttonClassName),
|
|
31
38
|
role: "tab",
|
|
32
|
-
"
|
|
33
|
-
"aria-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
}), icon && /*#__PURE__*/_react["default"].createElement("span", {
|
|
43
|
-
className: "me-2"
|
|
44
|
-
}, icon), label);
|
|
39
|
+
"aria-selected": _value === item.id,
|
|
40
|
+
"aria-current": _value === item.id ? "page" : undefined,
|
|
41
|
+
tabIndex: _value === item.id ? 0 : -1,
|
|
42
|
+
disabled: item.disabled,
|
|
43
|
+
onClick: function onClick() {
|
|
44
|
+
return !item.disabled && onChange(item);
|
|
45
|
+
},
|
|
46
|
+
style: _objectSpread(_objectSpread({}, buttonStyle), item.style)
|
|
47
|
+
}, item.icon, item.label);
|
|
45
48
|
}));
|
|
46
49
|
};
|
|
47
50
|
SegmentedControl.propTypes = {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
orientation: _propTypes["default"].oneOf(["horizontal", "vertical"]),
|
|
52
|
-
/** the id of the currently selected item */
|
|
53
|
-
value: _propTypes["default"].string.isRequired,
|
|
54
|
-
/** callback called with the id of the clicked item */
|
|
51
|
+
value: _propTypes["default"].oneOfType([_propTypes["default"].shape({
|
|
52
|
+
id: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]).isRequired
|
|
53
|
+
}), _propTypes["default"].string, _propTypes["default"].number]),
|
|
55
54
|
onChange: _propTypes["default"].func.isRequired,
|
|
56
55
|
items: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|
|
57
|
-
id: _propTypes["default"].string.isRequired,
|
|
58
|
-
label: _propTypes["default"].
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
size:
|
|
56
|
+
id: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]).isRequired,
|
|
57
|
+
label: _propTypes["default"].string.isRequired,
|
|
58
|
+
icon: _propTypes["default"].node,
|
|
59
|
+
disabled: _propTypes["default"].bool,
|
|
60
|
+
className: _propTypes["default"].string,
|
|
61
|
+
style: _propTypes["default"].object
|
|
62
|
+
})),
|
|
63
|
+
vertical: _propTypes["default"].bool,
|
|
64
|
+
size: _propTypes["default"].oneOf(["sm", "lg"]),
|
|
65
|
+
className: _propTypes["default"].string,
|
|
66
|
+
buttonClassName: _propTypes["default"].string,
|
|
67
|
+
style: _propTypes["default"].object,
|
|
68
|
+
buttonStyle: _propTypes["default"].object
|
|
66
69
|
};
|
package/docs/package.json
CHANGED
|
@@ -174,3 +174,6 @@ export const SelectGroup = loadable(() =>
|
|
|
174
174
|
export const EnclosedSelectGroup = loadable(() =>
|
|
175
175
|
import("tabler-react-2").then((mod) => mod.EnclosedSelectGroup)
|
|
176
176
|
);
|
|
177
|
+
export const SegmentedControl = loadable(() =>
|
|
178
|
+
import("tabler-react-2").then((mod) => mod.SegmentedControl)
|
|
179
|
+
);
|
|
@@ -16,7 +16,8 @@ export const Tabler = ({ children }) => {
|
|
|
16
16
|
// Inject Tabler stylesheet
|
|
17
17
|
const styleLink = document.createElement("link");
|
|
18
18
|
styleLink.rel = "stylesheet";
|
|
19
|
-
styleLink.href =
|
|
19
|
+
styleLink.href =
|
|
20
|
+
"https://cdn.jsdelivr.net/npm/@tabler/core@1.3.2/dist/css/tabler.min.css";
|
|
20
21
|
|
|
21
22
|
// Create a wrapper div for children
|
|
22
23
|
const wrapperDiv = document.createElement("div");
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
link: "/components/select-group"
|
|
27
27
|
- label: "Enclosed Select Group"
|
|
28
28
|
link: "/components/enclosed-select-group"
|
|
29
|
+
- label: "Segmented Control"
|
|
30
|
+
link: "/components/segmented-control"
|
|
29
31
|
- label: "Horizontal Rule"
|
|
30
32
|
link: "/components/hr"
|
|
31
33
|
- label: "Alerts"
|
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
title: Changelog
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
# 0.1.141
|
|
6
|
+
|
|
7
|
+
- Fix button formatting in confirm modals
|
|
8
|
+
|
|
9
|
+
# 0.1.140
|
|
10
|
+
|
|
11
|
+
- Added the `SegmentedControl` component.
|
|
12
|
+
|
|
13
|
+
# 0.1.139
|
|
14
|
+
|
|
15
|
+
- Added `inputClassName` prop to the `Input` component.
|
|
16
|
+
|
|
5
17
|
# 0.1.138
|
|
6
18
|
|
|
7
19
|
- Added `autofocusSearch` prop to the `DropdownInput` component.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Segmented Control
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import { SegmentedControl } from "../../components/LoadableTabler";
|
|
6
|
+
import { Excerpt } from "../../components/Excerpt.jsx";
|
|
7
|
+
|
|
8
|
+
Segmented controls allow a user to select a value from a set of options.
|
|
9
|
+
|
|
10
|
+
## Signature
|
|
11
|
+
|
|
12
|
+
```jsx
|
|
13
|
+
import { SegmentedControl } from "tabler-react-2";
|
|
14
|
+
|
|
15
|
+
<SegmentedControl {...props} />;
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Props
|
|
19
|
+
|
|
20
|
+
| Prop | Required | Type | Default | Description |
|
|
21
|
+
| ----------------- | -------- | ---------------------------------------------------------- | ------- | ------------------------------------------------------------- |
|
|
22
|
+
| `value` | No | String or Number | | The value of the selected option. |
|
|
23
|
+
| `onChange` | No | function (called with object) | | A function that fires when the user selects a new option. |
|
|
24
|
+
| `items` | Yes | Array of [SegmentedControlItems](#segmented-control-items) | | An array of options to be displayed in the segmented control. |
|
|
25
|
+
| `vertical` | No | Boolean | false | Whether the segmented control should be displayed vertically. |
|
|
26
|
+
| `size` | No | String [sm \| lg] | | The size of the segmented control. |
|
|
27
|
+
| `className` | No | String | | A class name to be added to the segmented control. |
|
|
28
|
+
| `buttonClassName` | No | String | | A class name to be added to the segmented control buttons. |
|
|
29
|
+
| `style` | No | Object | | A style object to be added to the segmented control. |
|
|
30
|
+
| `buttonStyle` | No | Object | | A style object to be added to the segmented control buttons. |
|
|
31
|
+
|
|
32
|
+
## Basic Usage
|
|
33
|
+
|
|
34
|
+
The `SegmentedControl` component is used to display a segmented control.
|
|
35
|
+
|
|
36
|
+
<Excerpt>
|
|
37
|
+
<SegmentedControl
|
|
38
|
+
value="one"
|
|
39
|
+
onChange={(v) => alert(`Selected ${v.label}`)}
|
|
40
|
+
items={[
|
|
41
|
+
{ id: "one", label: "One" },
|
|
42
|
+
{ id: "two", label: "Two" },
|
|
43
|
+
{ id: "three", label: "Three" },
|
|
44
|
+
]}
|
|
45
|
+
/>
|
|
46
|
+
</Excerpt>
|
|
47
|
+
|
|
48
|
+
```jsx
|
|
49
|
+
<SegmentedControl
|
|
50
|
+
value="one"
|
|
51
|
+
onChange={(v) => alert(`Selected ${v.label}`)}
|
|
52
|
+
items={[
|
|
53
|
+
{ id: "one", label: "One" },
|
|
54
|
+
{ id: "two", label: "Two" },
|
|
55
|
+
{ id: "three", label: "Three" },
|
|
56
|
+
]}
|
|
57
|
+
/>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Segmented Control Items
|
|
61
|
+
|
|
62
|
+
| Prop | Required | Type | Default | Description |
|
|
63
|
+
| ----------- | -------- | ----------------- | ------- | ----------------------------------------------------------- |
|
|
64
|
+
| `id` | Yes | String | | The value of the option. |
|
|
65
|
+
| `label` | Yes | String | | The label of the option. |
|
|
66
|
+
| `icon` | No | `React.ReactNode` | | An icon to be displayed in the segmented control. |
|
|
67
|
+
| `disabled` | No | Boolean | false | Whether the option should be disabled. |
|
|
68
|
+
| `className` | No | String | | A class name to be added to the segmented control option. |
|
|
69
|
+
| `style` | No | Object | | A style object to be added to the segmented control option. |
|