tabler-react-2 0.1.140 → 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.
@@ -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
- return /*#__PURE__*/_react["default"].createElement(_modal.Modal, {
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)), /*#__PURE__*/_react["default"].createElement("div", {
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] : {};
@@ -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.attrs, {
77
+ }, button, {
78
78
  onClick: button.onClick
79
79
  }), button.text);
80
80
  }))))), open && /*#__PURE__*/_react["default"].createElement("div", {
package/docs/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "react": "^18.2.0",
23
23
  "react-dom": "^18.2.0",
24
24
  "styled-components": "^6.1.15",
25
- "tabler-react-2": "^0.1.122"
25
+ "tabler-react-2": "^0.1.140"
26
26
  },
27
27
  "devDependencies": {},
28
28
  "keywords": [
@@ -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 = "/tabler.replaced.css";
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,14 @@
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
+
5
13
  # 0.1.139
6
14
 
7
15
  - Added `inputClassName` prop to the `Input` component.
@@ -3,5 +3,67 @@ title: Segmented Control
3
3
  ---
4
4
 
5
5
  import { SegmentedControl } from "../../components/LoadableTabler";
6
+ import { Excerpt } from "../../components/Excerpt.jsx";
6
7
 
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. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tabler-react-2",
3
- "version": "0.1.140",
3
+ "version": "0.1.141",
4
4
  "description": "A react implementation of Tabler ui",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {