tabler-react-2 0.1.91 → 0.1.93

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 CHANGED
@@ -180,5 +180,17 @@ Object.keys(_index17).forEach(function (key) {
180
180
  }
181
181
  });
182
182
  });
183
+ var _index18 = require("./navbar/index");
184
+ Object.keys(_index18).forEach(function (key) {
185
+ if (key === "default" || key === "__esModule") return;
186
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
187
+ if (key in exports && exports[key] === _index18[key]) return;
188
+ Object.defineProperty(exports, key, {
189
+ enumerable: true,
190
+ get: function get() {
191
+ return _index18[key];
192
+ }
193
+ });
194
+ });
183
195
  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); }
184
196
  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; }
@@ -44,6 +44,17 @@ var DropdownInput = exports.DropdownInput = function DropdownInput(_ref) {
44
44
  // Allow aliasing: pass either `values` or `items`
45
45
  var values = ivalues || items || [];
46
46
 
47
+ // Helper: extract text from label or dropdownText for filtering
48
+ var getLabelText = function getLabelText(val) {
49
+ var _val$dropdownText;
50
+ var node = (_val$dropdownText = val.dropdownText) !== null && _val$dropdownText !== void 0 ? _val$dropdownText : val.label;
51
+ if (typeof node === "string" || typeof node === "number") return String(node);
52
+ var children = _react.Children.toArray(node);
53
+ return children.map(function (child) {
54
+ return typeof child === "string" ? child : "";
55
+ }).join("");
56
+ };
57
+
47
58
  // When loading, show a Button in a container with an optional label.
48
59
  if (loading) {
49
60
  return /*#__PURE__*/_react["default"].createElement(_index.Util.Col, null, showLabel && label && /*#__PURE__*/_react["default"].createElement("label", {
@@ -92,17 +103,15 @@ var DropdownInput = exports.DropdownInput = function DropdownInput(_ref) {
92
103
  setSelectedValue(matchedValue);
93
104
  }, [value, values]);
94
105
 
95
- // Filter values based on the search query.
106
+ // Filter values based on the search query using getLabelText
96
107
  (0, _react.useEffect)(function () {
97
108
  setFilteredValues(values.filter(function (val) {
98
- return JSON.stringify(val).toLowerCase().includes(searchQuery.toLowerCase());
109
+ return getLabelText(val).toLowerCase().includes(searchQuery.toLowerCase());
99
110
  }));
100
111
  }, [searchQuery, values]);
101
112
  var handleSelection = function handleSelection(val) {
102
113
  setSelectedValue(val);
103
- if (onChange) {
104
- onChange(val);
105
- }
114
+ if (onChange) onChange(val);
106
115
  };
107
116
 
108
117
  // The main dropdown markup.
@@ -123,6 +132,7 @@ var DropdownInput = exports.DropdownInput = function DropdownInput(_ref) {
123
132
  return setSearchQuery(value);
124
133
  }
125
134
  })), filteredValues.map(function (val, index) {
135
+ var _val$dropdownText2;
126
136
  return /*#__PURE__*/_react["default"].createElement("a", {
127
137
  key: index,
128
138
  className: "dropdown-item".concat(selectedValue && selectedValue.id === val.id ? " active" : ""),
@@ -132,7 +142,7 @@ var DropdownInput = exports.DropdownInput = function DropdownInput(_ref) {
132
142
  style: {
133
143
  cursor: "pointer"
134
144
  }
135
- }, val.dropdownText || val.label);
145
+ }, (_val$dropdownText2 = val.dropdownText) !== null && _val$dropdownText2 !== void 0 ? _val$dropdownText2 : val.label);
136
146
  }), filteredValues.length === 0 && /*#__PURE__*/_react["default"].createElement("div", {
137
147
  className: "dropdown-item text-muted"
138
148
  }, "No results found")));
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Navbar = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10
+ var Navbar = exports.Navbar = function Navbar(_ref) {
11
+ var type = _ref.type,
12
+ items = _ref.items;
13
+ // Determine the nav classes based on type: tabs, pills, underline, or default horizontal
14
+ var navTypeClass = type ? "nav-".concat(type) : "";
15
+ var navClass = ["nav", navTypeClass].filter(Boolean).join(" ");
16
+ var currentPath = window.location.pathname;
17
+ return /*#__PURE__*/_react["default"].createElement("ul", {
18
+ className: navClass
19
+ }, items.map(function (item, idx) {
20
+ // Dropdown
21
+ if (item.type === "dropdown") {
22
+ var isOpenOnThisPage = item.items.some(function (child) {
23
+ return child.href === currentPath;
24
+ });
25
+ return /*#__PURE__*/_react["default"].createElement("li", {
26
+ key: idx,
27
+ className: "nav-item dropdown"
28
+ }, /*#__PURE__*/_react["default"].createElement("a", {
29
+ href: "#",
30
+ className: "nav-link dropdown-toggle".concat(isOpenOnThisPage ? " active" : ""),
31
+ "data-bs-toggle": "dropdown",
32
+ role: "button",
33
+ "aria-expanded": isOpenOnThisPage,
34
+ "aria-current": isOpenOnThisPage ? "page" : undefined
35
+ }, item.text), /*#__PURE__*/_react["default"].createElement("ul", {
36
+ className: "dropdown-menu"
37
+ }, item.items.map(function (child, cidx) {
38
+ var isChildActive = child.href === currentPath;
39
+ return /*#__PURE__*/_react["default"].createElement("li", {
40
+ key: cidx
41
+ }, /*#__PURE__*/_react["default"].createElement("a", {
42
+ href: child.href,
43
+ className: "dropdown-item".concat(isChildActive ? " active" : "").concat(child.disabled ? " disabled" : ""),
44
+ "aria-disabled": child.disabled ? "true" : undefined,
45
+ "aria-current": isChildActive ? "page" : undefined,
46
+ onClick: function onClick(e) {
47
+ return child.disabled && e.preventDefault();
48
+ }
49
+ }, child.text));
50
+ })));
51
+ }
52
+
53
+ // Simple link
54
+ var isLinkActive = item.href === currentPath;
55
+ return /*#__PURE__*/_react["default"].createElement("li", {
56
+ key: idx,
57
+ className: "nav-item"
58
+ }, /*#__PURE__*/_react["default"].createElement("a", {
59
+ href: item.href,
60
+ className: "nav-link".concat(isLinkActive ? " active" : "").concat(item.disabled ? " disabled" : ""),
61
+ "aria-current": isLinkActive ? "page" : undefined,
62
+ "aria-disabled": item.disabled ? "true" : undefined,
63
+ onClick: function onClick(e) {
64
+ return item.disabled && e.preventDefault();
65
+ }
66
+ }, item.text));
67
+ }));
68
+ };
69
+ Navbar.propTypes = {
70
+ /** one of 'tabs', 'pills', 'underline'; omit or undefined for default horizontal */
71
+ type: _propTypes["default"].oneOf(["tabs", "pills", "underline"]),
72
+ items: _propTypes["default"].arrayOf(_propTypes["default"].shape({
73
+ type: _propTypes["default"].oneOf(["link", "dropdown"]).isRequired,
74
+ href: _propTypes["default"].string,
75
+ // for link
76
+ text: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].node]).isRequired,
77
+ /** only for dropdown */
78
+ items: _propTypes["default"].arrayOf(_propTypes["default"].shape({
79
+ href: _propTypes["default"].string.isRequired,
80
+ text: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].node]).isRequired,
81
+ disabled: _propTypes["default"].bool
82
+ })),
83
+ disabled: _propTypes["default"].bool
84
+ })).isRequired
85
+ };
86
+ Navbar.defaultProps = {
87
+ type: undefined
88
+ };
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.90"
25
+ "tabler-react-2": "file:../"
26
26
  },
27
27
  "devDependencies": {},
28
28
  "keywords": [
@@ -162,3 +162,9 @@ export const Typography = {
162
162
  export const TablerProvider = loadable(() =>
163
163
  import("tabler-react-2").then((mod) => mod.TablerProvider)
164
164
  );
165
+ export const Navbar = loadable(() =>
166
+ import("tabler-react-2").then((mod) => {
167
+ console.log(mod);
168
+ return mod.Navbar;
169
+ })
170
+ );
@@ -42,6 +42,8 @@
42
42
  link: "/components/tables"
43
43
  - label: "Timeline"
44
44
  link: "/components/timeline"
45
+ - label: "Navbar"
46
+ link: "/components/navbar"
45
47
  - label: "Utilities"
46
48
  items:
47
49
  - label: "Colors"
@@ -39,7 +39,7 @@ The `DropdownInput` component is used to select an option from a list of options
39
39
  values={[
40
40
  { id: 1, label: "Sam" },
41
41
  { id: 2, label: "Bob" },
42
- { id: 3, label: "John" },
42
+ { id: 3, label: <b>John</b> },
43
43
  ]}
44
44
  onChange={(value) => alert(`Selected value: ${JSON.stringify(value)}`)}
45
45
  />
@@ -0,0 +1,267 @@
1
+ ---
2
+ title: Navbar
3
+ ---
4
+
5
+ import { Navbar } from "../../components/LoadableTabler.jsx";
6
+ import { Excerpt } from "../../components/Excerpt.jsx";
7
+ import {
8
+ IconBrandTwitter,
9
+ IconCheck,
10
+ IconMessage,
11
+ IconUser,
12
+ } from "@tabler/icons-react";
13
+
14
+ Navbars are used to display navigation links. They can be used to display a list of links, or a list of dropdowns.
15
+
16
+ ## Signature
17
+
18
+ ```jsx
19
+ import { Navbar } from "tabler-react-2";
20
+
21
+ <Navbar {...props} />;
22
+ ```
23
+
24
+ ### Props
25
+
26
+ ## Basic Usage
27
+
28
+ The `Navbar` component is used to display a navbar.
29
+
30
+ <Excerpt>
31
+ <Navbar
32
+ items={[
33
+ {
34
+ type: "link",
35
+ href: "#",
36
+ text: "Link 1",
37
+ },
38
+ { type: "link", href: "#", text: "Link 2", disabled: true },
39
+ {
40
+ type: "dropdown",
41
+ text: "Drop 1",
42
+ items: [
43
+ {
44
+ type: "link",
45
+ href: "#",
46
+ text: "Link 1",
47
+ },
48
+ {
49
+ type: "link",
50
+ href: "#",
51
+ text: "Link 2",
52
+ },
53
+ ],
54
+ },
55
+ ]}
56
+ />
57
+ </Excerpt>
58
+
59
+ ```jsx
60
+ <Navbar
61
+ items={[
62
+ {
63
+ type: "link",
64
+ href: "#",
65
+ text: "Link 1",
66
+ },
67
+ {
68
+ type: "link",
69
+ href: "#",
70
+ text: "Link 2",
71
+ disabled: true,
72
+ },
73
+ {
74
+ type: "dropdown",
75
+ text: "Drop 1",
76
+ items: [
77
+ {
78
+ type: "link",
79
+ href: "#",
80
+ text: "Link 1",
81
+ },
82
+ {
83
+ type: "link",
84
+ href: "#",
85
+ text: "Link 2",
86
+ },
87
+ ],
88
+ },
89
+ ]}
90
+ />
91
+ ```
92
+
93
+ ## Tabs
94
+
95
+ Setting the `type` prop to `tabs` will display the navbar as tabs.
96
+
97
+ <Excerpt>
98
+ <Navbar
99
+ type="tabs"
100
+ items={[
101
+ {
102
+ type: "link",
103
+ href: "#",
104
+ text: "Link 1",
105
+ },
106
+ {
107
+ type: "link",
108
+ href: "#",
109
+ text: "Link 2",
110
+ },
111
+ {
112
+ type: "link",
113
+ disabled: true,
114
+ href: "#",
115
+ text: "Disabled",
116
+ },
117
+ ]}
118
+ />
119
+ </Excerpt>
120
+
121
+ ```jsx
122
+ <Navbar
123
+ type="tabs"
124
+ items={[
125
+ {
126
+ type: "link",
127
+ href: "#",
128
+ text: "Link 1",
129
+ },
130
+ {
131
+ type: "link",
132
+ href: "#",
133
+ text: "Link 2",
134
+ },
135
+ {
136
+ type: "link",
137
+ disabled: true,
138
+ href: "#",
139
+ text: "Disabled",
140
+ },
141
+ ]}
142
+ />
143
+ ```
144
+
145
+ ## Pills
146
+
147
+ Setting the `type` prop to `pills` will display the navbar as pills.
148
+
149
+ <Excerpt>
150
+ <Navbar
151
+ type="pills"
152
+ items={[
153
+ {
154
+ type: "link",
155
+ href: "#",
156
+ text: "Link 1",
157
+ },
158
+ {
159
+ type: "link",
160
+ href: "#",
161
+ text: "Link 2",
162
+ },
163
+ {
164
+ type: "link",
165
+ disabled: true,
166
+ href: "#",
167
+ text: "Disabled",
168
+ },
169
+ ]}
170
+ />
171
+ </Excerpt>
172
+
173
+ ```jsx
174
+ <Navbar
175
+ type="pills"
176
+ items={[
177
+ {
178
+ type: "link",
179
+ href: "#",
180
+ text: "Link 1",
181
+ },
182
+ {
183
+ type: "link",
184
+ href: "#",
185
+ text: "Link 2",
186
+ },
187
+ {
188
+ type: "link",
189
+ disabled: true,
190
+ href: "#",
191
+ text: "Disabled",
192
+ },
193
+ ]}
194
+ />
195
+ ```
196
+
197
+ ## Underline
198
+
199
+ Setting the `type` prop to `underline` will display the navbar as underline.
200
+
201
+ <Excerpt>
202
+ <Navbar
203
+ type="underline"
204
+ items={[
205
+ {
206
+ type: "link",
207
+ href: "#",
208
+ text: "Link 1",
209
+ },
210
+ {
211
+ type: "link",
212
+ href: "#",
213
+ text: "Link 2",
214
+ },
215
+ {
216
+ type: "link",
217
+ href: "#",
218
+ text: "Link 3",
219
+ },
220
+ {
221
+ type: "dropdown",
222
+ text: "Drop 1",
223
+ items: [
224
+ {
225
+ type: "link",
226
+ href: "#",
227
+ text: "Link 1",
228
+ },
229
+ {
230
+ type: "link",
231
+ href: "#",
232
+ text: "Link 2",
233
+ },
234
+ {
235
+ type: "link",
236
+ disabled: true,
237
+ href: "#",
238
+ text: "Disabled",
239
+ },
240
+ ],
241
+ },
242
+ ]}
243
+ />
244
+ </Excerpt>
245
+
246
+ ```jsx
247
+ <Navbar
248
+ type="underline"
249
+ items={[
250
+ {
251
+ type: "link",
252
+ href: "#",
253
+ text: "Link 1",
254
+ },
255
+ {
256
+ type: "link",
257
+ href: "#",
258
+ text: "Link 2",
259
+ },
260
+ {
261
+ type: "link",
262
+ href: "#",
263
+ text: "Link 3",
264
+ },
265
+ ]}
266
+ />
267
+ ```
@@ -4,7 +4,12 @@ title: Timeline
4
4
 
5
5
  import { Timeline } from "../../components/LoadableTabler";
6
6
  import { Excerpt } from "../../components/Excerpt.jsx";
7
- import { IconCheck, IconMessage, IconUser } from "@tabler/icons-react";
7
+ import {
8
+ IconBrandTwitter,
9
+ IconCheck,
10
+ IconMessage,
11
+ IconUser,
12
+ } from "@tabler/icons-react";
8
13
 
9
14
  Timeline is a component that displays a list of events. Used to communicate a series of related events, usually in a chronological order.
10
15
 
@@ -48,7 +53,106 @@ The `events` prop is an array of objects that define the events to display. Each
48
53
  title: "+1150 Followers",
49
54
  description: "Joined the community",
50
55
  },
56
+ {
57
+ icon: <IconMessage />,
58
+ time: "1 hr ago",
59
+ title: "New message",
60
+ description: "You have 1 new message",
61
+ },
62
+ {
63
+ icon: <IconUser />,
64
+ time: "1 hr ago",
65
+ title: "New user",
66
+ description: "You have 1 new user",
67
+ },
51
68
  ]}
52
69
  />
53
70
  </div>
54
71
  </Excerpt>
72
+
73
+ ```jsx
74
+ <Timeline
75
+ events={[
76
+ {
77
+ icon: <IconCheck />,
78
+ time: "10 hrs ago",
79
+ title: "+1150 Followers",
80
+ description: "Joined the community",
81
+ },
82
+ {
83
+ icon: <IconMessage />,
84
+ time: "1 hr ago",
85
+ title: "New message",
86
+ description: "You have 1 new message",
87
+ },
88
+ {
89
+ icon: <IconUser />,
90
+ time: "1 hr ago",
91
+ title: "New user",
92
+ description: "You have 1 new user",
93
+ },
94
+ ]}
95
+ />
96
+ ```
97
+
98
+ ## Colors
99
+
100
+ You can set the color of the icon using the `iconBgColor` prop to any of the [colors](/utilities/colors).
101
+
102
+ <Excerpt>
103
+ <div style={{ width: 400 }}>
104
+ <Timeline
105
+ dense
106
+ events={[
107
+ {
108
+ icon: <IconBrandTwitter />,
109
+ time: "10 hrs ago",
110
+ title: "+1150 Followers",
111
+ description: "New Twitter followers",
112
+ iconBgColor: "twitter",
113
+ },
114
+ {
115
+ icon: <IconMessage />,
116
+ time: "1 hr ago",
117
+ title: "New message",
118
+ description: "You have 1 new message",
119
+ iconBgColor: "red",
120
+ },
121
+ {
122
+ icon: <IconUser />,
123
+ time: "1 hr ago",
124
+ title: "New user",
125
+ description: "You have 1 new user",
126
+ },
127
+ ]}
128
+ />
129
+ </div>
130
+ </Excerpt>
131
+
132
+ ```jsx
133
+ <Timeline
134
+ dense
135
+ events={[
136
+ {
137
+ icon: <IconBrandTwitter />,
138
+ time: "10 hrs ago",
139
+ title: "+1150 Followers",
140
+ description: "New Twitter followers",
141
+ iconBgColor: "twitter",
142
+ },
143
+ {
144
+ icon: <IconMessage />,
145
+ time: "1 hr ago",
146
+ title: "New message",
147
+ description: "You have 1 new message",
148
+ iconBgColor: "red",
149
+ },
150
+ {
151
+ icon: <IconUser />,
152
+ time: "1 hr ago",
153
+ title: "New user",
154
+ description: "You have 1 new user",
155
+ },
156
+ ]}
157
+ />
158
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tabler-react-2",
3
- "version": "0.1.91",
3
+ "version": "0.1.93",
4
4
  "description": "A react implementation of Tabler ui",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {