tabler-react-2 0.1.91 → 0.1.92

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.
@@ -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")));
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": "0.1.91"
26
26
  },
27
27
  "devDependencies": {},
28
28
  "keywords": [
@@ -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
  />
@@ -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.92",
4
4
  "description": "A react implementation of Tabler ui",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {