tabler-react-2 0.1.92 → 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; }
@@ -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.91"
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"
@@ -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
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tabler-react-2",
3
- "version": "0.1.92",
3
+ "version": "0.1.93",
4
4
  "description": "A react implementation of Tabler ui",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {