tabler-react-2 0.1.94 → 0.1.96

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
@@ -192,17 +192,5 @@ Object.keys(_index18).forEach(function (key) {
192
192
  }
193
193
  });
194
194
  });
195
- var _index19 = require("./segmentedControl/index");
196
- Object.keys(_index19).forEach(function (key) {
197
- if (key === "default" || key === "__esModule") return;
198
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
199
- if (key in exports && exports[key] === _index19[key]) return;
200
- Object.defineProperty(exports, key, {
201
- enumerable: true,
202
- get: function get() {
203
- return _index19[key];
204
- }
205
- });
206
- });
207
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); }
208
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; }
@@ -5,9 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.EnclosedSelectGroup = void 0;
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
10
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
11
+ 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); }
12
+ 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; }
11
13
  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
14
  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
15
  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; }
@@ -18,30 +20,23 @@ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread n
18
20
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
19
21
  function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
20
22
  function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
21
- 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; } /*
22
- <label class="form-selectgroup-item flex-fill">
23
- <input type="radio" name="form-payment" value="mastercard" class="form-selectgroup-input" checked />
24
- <div class="form-selectgroup-label d-flex align-items-center p-3">
25
- <div class="me-3">
26
- <span class="form-selectgroup-check"></span>
27
- </div>
28
- <div>
29
- ending in <strong>2807</strong>
30
- </div>
31
- </div>
32
- </label>
33
-
34
- */
23
+ 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; }
35
24
  var EnclosedSelectGroup = exports.EnclosedSelectGroup = function EnclosedSelectGroup(_ref) {
36
25
  var items = _ref.items,
37
26
  value = _ref.value,
38
27
  onChange = _ref.onChange,
28
+ _ref$multiple = _ref.multiple,
29
+ multiple = _ref$multiple === void 0 ? false : _ref$multiple,
39
30
  _ref$direction = _ref.direction,
40
31
  direction = _ref$direction === void 0 ? "row" : _ref$direction,
41
- itemClassName = _ref.itemClassName,
42
- style = _ref.style,
43
- itemStyle = _ref.itemStyle;
44
- var multiple = false;
32
+ _ref$itemClassName = _ref.itemClassName,
33
+ itemClassName = _ref$itemClassName === void 0 ? "" : _ref$itemClassName,
34
+ _ref$style = _ref.style,
35
+ style = _ref$style === void 0 ? {} : _ref$style,
36
+ _ref$itemStyle = _ref.itemStyle,
37
+ itemStyle = _ref$itemStyle === void 0 ? {} : _ref$itemStyle;
38
+ // generate a unique name for each instance so radio groups don't collide
39
+ var groupName = (0, _react.useId)();
45
40
  var handleChange = function handleChange(selectedItem) {
46
41
  if (multiple) {
47
42
  if (value.some(function (item) {
@@ -58,43 +53,40 @@ var EnclosedSelectGroup = exports.EnclosedSelectGroup = function EnclosedSelectG
58
53
  }
59
54
  };
60
55
  var isChecked = function isChecked(item) {
61
- if (multiple) {
62
- return value.some(function (val) {
63
- return val.value === item.value;
64
- });
65
- }
66
- return (value === null || value === void 0 ? void 0 : value.value) === item.value;
56
+ return multiple ? value.some(function (val) {
57
+ return val.value === item.value;
58
+ }) : (value === null || value === void 0 ? void 0 : value.value) === item.value;
67
59
  };
68
60
  return /*#__PURE__*/_react["default"].createElement("div", {
69
61
  className: "form-selectgroup",
70
62
  style: _objectSpread({
63
+ display: "flex",
71
64
  flexDirection: direction
72
65
  }, style)
73
66
  }, items.map(function (item) {
74
67
  return /*#__PURE__*/_react["default"].createElement("label", {
68
+ key: "".concat(groupName, "-").concat(item.value),
75
69
  className: "form-selectgroup-item flex-fill ".concat(itemClassName),
76
- key: item.value,
77
70
  style: _objectSpread({
78
- pointerEvents: item.disabled,
79
- cursor: item.disabled ? "not-allowed" : null
71
+ pointerEvents: item.disabled ? "none" : undefined,
72
+ cursor: item.disabled ? "not-allowed" : undefined
80
73
  }, itemStyle)
81
74
  }, /*#__PURE__*/_react["default"].createElement("input", {
82
- type: "radio",
83
- className: "form-selectgroup-input",
84
- name: item.label,
75
+ type: multiple ? "checkbox" : "radio",
76
+ name: groupName,
77
+ id: "".concat(groupName, "-").concat(item.value),
85
78
  value: item.value,
86
79
  checked: isChecked(item),
87
80
  onChange: function onChange() {
88
- return handleChange({
89
- value: item.value
90
- });
81
+ return handleChange(item);
91
82
  },
92
- disabled: item.disabled
83
+ disabled: item.disabled,
84
+ className: "form-selectgroup-input"
93
85
  }), /*#__PURE__*/_react["default"].createElement("div", {
94
- className: "form-selectgroup-label d-flex p-3 ".concat((item === null || item === void 0 ? void 0 : item.disabled) && "bg-gray-400"),
86
+ className: "form-selectgroup-label d-flex p-3 ".concat(item.disabled ? "bg-gray-400" : ""),
95
87
  style: {
96
- pointerEvents: item.disabled,
97
- cursor: item.disabled ? "not-allowed" : null
88
+ pointerEvents: item.disabled ? "none" : undefined,
89
+ cursor: item.disabled ? "not-allowed" : undefined
98
90
  }
99
91
  }, /*#__PURE__*/_react["default"].createElement("div", {
100
92
  className: "me-3"
@@ -104,21 +96,26 @@ var EnclosedSelectGroup = exports.EnclosedSelectGroup = function EnclosedSelectG
104
96
  style: {
105
97
  textAlign: "left"
106
98
  }
107
- }, item.content)));
99
+ }, item.label)));
108
100
  }));
109
101
  };
110
102
  EnclosedSelectGroup.propTypes = {
111
103
  items: _propTypes["default"].arrayOf(_propTypes["default"].shape({
112
104
  value: _propTypes["default"].string.isRequired,
113
- content: _propTypes["default"].string.isRequired
105
+ label: _propTypes["default"].node.isRequired,
106
+ disabled: _propTypes["default"].bool
114
107
  })).isRequired,
115
108
  value: _propTypes["default"].oneOfType([_propTypes["default"].shape({
116
109
  value: _propTypes["default"].string.isRequired,
117
- label: _propTypes["default"].string.isRequired
110
+ label: _propTypes["default"].any
118
111
  }), _propTypes["default"].arrayOf(_propTypes["default"].shape({
119
112
  value: _propTypes["default"].string.isRequired,
120
- label: _propTypes["default"].string.isRequired
113
+ label: _propTypes["default"].any
121
114
  }))]).isRequired,
122
115
  onChange: _propTypes["default"].func.isRequired,
123
- multiple: _propTypes["default"].bool.isRequired
116
+ multiple: _propTypes["default"].bool,
117
+ direction: _propTypes["default"].oneOf(["row", "column"]),
118
+ itemClassName: _propTypes["default"].string,
119
+ style: _propTypes["default"].object,
120
+ itemStyle: _propTypes["default"].object
124
121
  };
@@ -100,7 +100,7 @@ var Input = exports.Input = function Input(_ref) {
100
100
  }, renderInput()), /*#__PURE__*/_react["default"].createElement("div", {
101
101
  className: "col-auto"
102
102
  }, /*#__PURE__*/_react["default"].createElement("a", {
103
- href: appendedLinkHref ? appendedLinkHref : "#",
103
+ href: appendedLinkHref ? appendedLinkHref : "javascript:void(0);",
104
104
  onClick: appendedLinkOnClick,
105
105
  className: "btn btn-icon",
106
106
  "aria-label": "Button"
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.93"
25
+ "tabler-react-2": "^0.1.95"
26
26
  },
27
27
  "devDependencies": {},
28
28
  "keywords": [
@@ -168,3 +168,9 @@ export const Navbar = loadable(() =>
168
168
  return mod.Navbar;
169
169
  })
170
170
  );
171
+ export const SelectGroup = loadable(() =>
172
+ import("tabler-react-2").then((mod) => mod.SelectGroup)
173
+ );
174
+ export const EnclosedSelectGroup = loadable(() =>
175
+ import("tabler-react-2").then((mod) => mod.EnclosedSelectGroup)
176
+ );
@@ -14,6 +14,16 @@
14
14
  link: "/components/cards"
15
15
  - label: "Buttons"
16
16
  link: "/components/buttons"
17
+ - label: "Inputs"
18
+ link: "/components/input"
19
+ - label: "Dropdown"
20
+ link: "/components/dropdown"
21
+ - label: "Dropdown Input"
22
+ link: "/components/dropdown-input"
23
+ - label: "Select Group"
24
+ link: "/components/select-group"
25
+ - label: "Enclosed Select Group"
26
+ link: "/components/enclosed-select-group"
17
27
  - label: "Horizontal Rule"
18
28
  link: "/components/hr"
19
29
  - label: "Alerts"
@@ -22,10 +32,6 @@
22
32
  link: "/components/avatar"
23
33
  - label: "Badges"
24
34
  link: "/components/badges"
25
- - label: "Dropdown"
26
- link: "/components/dropdown"
27
- - label: "Dropdown Input"
28
- link: "/components/dropdown-input"
29
35
  - label: "Modals"
30
36
  link: "/components/modals"
31
37
  - label: "Hook-driven modals"
@@ -0,0 +1,149 @@
1
+ ---
2
+ title: Enclosed Select Group
3
+ ---
4
+
5
+ import { EnclosedSelectGroup } from "../../components/LoadableTabler.jsx";
6
+ import { Excerpt } from "../../components/Excerpt.jsx";
7
+ import { useState } from "react";
8
+
9
+ Enclosed Select Groups are used to mask radio and checkbox inputs in boxes with a label.
10
+
11
+ ## Signature
12
+
13
+ export const ControlledEnclosedSelectGroup = (props) => {
14
+ const [selectValue, setSelectValue] = useState();
15
+ return (
16
+ <>
17
+ <EnclosedSelectGroup
18
+ multiple
19
+ direction="column"
20
+ value={selectValue}
21
+ onChange={(v) => {
22
+ console.log(v);
23
+ setSelectValue(v);
24
+ }}
25
+ items={[
26
+ { value: "one", content: <b>One</b> },
27
+ { value: "two", content: "Two" },
28
+ { value: "three", content: "Three" },
29
+ ]}
30
+ />
31
+ </>
32
+ );
33
+ };
34
+
35
+ ```jsx
36
+ import { EnclosedSelectGroup } from "tabler-react-2";
37
+
38
+ <EnclosedSelectGroup
39
+ items={[
40
+ { value: "one", label: <b>One</b> },
41
+ { value: "two", label: "Two" },
42
+ { value: "three", label: "Three" },
43
+ ]}
44
+ value={null}
45
+ onChange={console.log}
46
+ />;
47
+ ```
48
+
49
+ ### Props
50
+
51
+ | Prop | Required | Type | Default | Description |
52
+ | ----------- | -------- | -------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
53
+ | `items` | Yes | Array of objects | | The items to be shown in the select group. Each item should have a `value` and `label` prop. |
54
+ | `value` | Yes | Object or Array of Objects if multiple | | The value of the select group. If the value is an array, multiple items can be selected. The value of each item should be the same as the `value` prop of the item. |
55
+ | `onChange` | Yes | Function | | The function to be called when the value of the select group changes. It is called with the new value as the argument, not the event. If the value is an array, the new value is an array of objects. The value of each item should be the same as the `value` prop of the item. |
56
+ | `multiple` | No | Boolean | | Whether multiple items can be selected. |
57
+ | `direction` | No | String | "row" | The direction of the items. Can be "row" or "column". |
58
+
59
+ ## Basic Usage
60
+
61
+ The `EnclosedSelectGroup` component is used to mask radio and checkbox inputs in boxes with a label.
62
+
63
+ <Excerpt>
64
+ <ControlledEnclosedSelectGroup
65
+ items={[
66
+ { value: "one", label: <u>One</u> },
67
+ { value: "two", label: "Two" },
68
+ { value: "three", label: "Three" },
69
+ ]}
70
+ value={null}
71
+ onChange={console.log}
72
+ />
73
+ </Excerpt>
74
+
75
+ ```jsx
76
+ <EnclosedSelectGroup
77
+ items={[
78
+ { value: "one", label: <u>One</u> },
79
+ { value: "two", label: "Two" },
80
+ { value: "three", label: "Three" },
81
+ ]}
82
+ value={null}
83
+ onChange={console.log}
84
+ />
85
+ ```
86
+
87
+ ## Multiple Select
88
+
89
+ The `multiple` prop can be used to allow multiple items to be selected.
90
+
91
+ <Excerpt>
92
+ <ControlledEnclosedSelectGroup
93
+ items={[
94
+ { value: "one", label: <u>One</u> },
95
+ { value: "two", label: "Two" },
96
+ { value: "three", label: "Three" },
97
+ ]}
98
+ value={[
99
+ {
100
+ value: "one",
101
+ },
102
+ ]}
103
+ onChange={console.log}
104
+ multiple
105
+ />
106
+ </Excerpt>
107
+
108
+ ```jsx
109
+ <EnclosedSelectGroup
110
+ items={[
111
+ { value: "one", label: <u>One</u> },
112
+ { value: "two", label: "Two" },
113
+ { value: "three", label: "Three" },
114
+ ]}
115
+ value={[]}
116
+ onChange={console.log}
117
+ multiple
118
+ />
119
+ ```
120
+
121
+ ## Direction
122
+
123
+ The `direction` prop can be used to change the direction of the items.
124
+
125
+ <Excerpt>
126
+ <ControlledEnclosedSelectGroup
127
+ items={[
128
+ { value: "one", label: <u>One</u> },
129
+ { value: "two", label: "Two" },
130
+ { value: "three", label: "Three" },
131
+ ]}
132
+ value={null}
133
+ onChange={console.log}
134
+ direction="column"
135
+ />
136
+ </Excerpt>
137
+
138
+ ```jsx
139
+ <EnclosedSelectGroup
140
+ items={[
141
+ { value: "one", label: <u>One</u> },
142
+ { value: "two", label: "Two" },
143
+ { value: "three", label: "Three" },
144
+ ]}
145
+ value={null}
146
+ onChange={console.log}
147
+ direction="column"
148
+ />
149
+ ```
@@ -0,0 +1,430 @@
1
+ ---
2
+ title: Input
3
+ ---
4
+
5
+ import { Input } from "../../components/LoadableTabler";
6
+ import { Excerpt } from "../../components/Excerpt.jsx";
7
+ import { IconAerialLift } from "@tabler/icons-react";
8
+
9
+ Inputs are used to collect user input.
10
+
11
+ ## Signature
12
+
13
+ ```jsx
14
+ import { Input } from "tabler-react-2";
15
+
16
+ <Input {...props}>{children}</Input>;
17
+ ```
18
+
19
+ ### Props
20
+
21
+ | Prop | Required | Type | Default | Description |
22
+ | --------------------- | -------- | -------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------- |
23
+ | `type` | No | [InputType](#inputtype) | `text` | The type of input. |
24
+ | `label` | No | String | | The label of the input to be shown above the input box. |
25
+ | `placeholder` | No | String | | The placeholder text to be shown in the input box. |
26
+ | `value` | No | String | | The value of the input. |
27
+ | `onChange` | No | Function | | The function to be called when the input value changes. It is called with the new value as the argument, not the event. |
28
+ | `onInput` | No | Function | | The function to be called when the input value changes. It is called with the new value as the argument, not the event. |
29
+ | `onRawChange` | No | Function | | The function to be called when the input value changes. It is called with the event as the argument. |
30
+ | `icon` | No | Node | | The icon to be shown in the input. |
31
+ | `iconPos` | No | [`leading` \| `trailing`] | `leading` | The position of the icon. |
32
+ | `loader` | No | Boolean | | Whether the input should show a spinner. |
33
+ | `separated` | No | Boolean | | Whether the input should be separated from an appended button. |
34
+ | `prependedText` | No | String | | The text to be shown before the input in the box. |
35
+ | `appendedText` | No | String | | The text to be shown after the input in the box. |
36
+ | `appendedLinkText` | No | String | | The text to be shown in the appended link. |
37
+ | `appendedLinkHref` | No | String | | The href of the appended link. |
38
+ | `appendedLinkOnClick` | No | Function | | The function to be called when the appended link is clicked. |
39
+ | `datalistItems` | No | Array of Strings | | The list of items to be shown in the datalist. |
40
+ | `variant` | No | [color](/utilities/colors) | | The color variant of the button. |
41
+ | `size` | No | [`sm`, `md`, `lg`] | `md` | The size of the button. |
42
+ | `inputProps` | No | Object | | The props to be passed to the input. |
43
+
44
+ ## Basic Usage
45
+
46
+ The `Input` component is used to collect user input.
47
+
48
+ <Excerpt>
49
+ <Input
50
+ label="Input"
51
+ placeholder="Type here..."
52
+ value={"Starting value"}
53
+ onInput={console.log}
54
+ />
55
+ </Excerpt>
56
+
57
+ ```jsx
58
+ <Input
59
+ label="Input"
60
+ placeholder="Type here..."
61
+ value={"Starting value"}
62
+ onInput={console.log}
63
+ />
64
+ ```
65
+
66
+ ## Labels and Placeholders
67
+
68
+ The `Input` component can be used to collect user input. The `label` and `placeholder` props are used to show a label and placeholder text in the input box. Traditionally, the `label` should describe the input, and the `placeholder` should provide a hint or an example. This way the user can still understand what a field is asking for even when the input is not empty.
69
+
70
+ <Excerpt>
71
+ <Input label="Your Name" placeholder="Johnny Appleseed" />
72
+ </Excerpt>
73
+
74
+ ```jsx
75
+ <Input label="Your Name" placeholder="Johnny Appleseed" />
76
+ ```
77
+
78
+ ## Input Types
79
+
80
+ The `Input` component can be used to collect different types of input. The `type` prop accepts a string value of any [input type](#inputtype).
81
+
82
+ <Excerpt>
83
+ <Input
84
+ label="Email input"
85
+ placeholder="Type here..."
86
+ onInput={console.log}
87
+ type="email"
88
+ />
89
+ <Input
90
+ label="Password input"
91
+ placeholder="Type here..."
92
+ onInput={console.log}
93
+ type="password"
94
+ />
95
+ <Input
96
+ label="Number input"
97
+ placeholder="Type here..."
98
+ onInput={console.log}
99
+ type="number"
100
+ />
101
+ <Input
102
+ label="Date input"
103
+ placeholder="Type here..."
104
+ onInput={console.log}
105
+ type="date"
106
+ />
107
+ <Input
108
+ label="Datetime input"
109
+ placeholder="Type here..."
110
+ onInput={console.log}
111
+ type="datetime-local"
112
+ />
113
+ <Input
114
+ label="Month input"
115
+ placeholder="Type here..."
116
+ onInput={console.log}
117
+ type="month"
118
+ />
119
+ <Input
120
+ label="Time input"
121
+ placeholder="Type here..."
122
+ onInput={console.log}
123
+ type="time"
124
+ />
125
+ <Input
126
+ label="URL input"
127
+ placeholder="Type here..."
128
+ onInput={console.log}
129
+ type="url"
130
+ />
131
+ </Excerpt>
132
+
133
+ ```jsx highlight={4,9,14,19,24,29,34,39}
134
+ <Input
135
+ label="Email input"
136
+ placeholder="Type here..."
137
+ type="email"
138
+ />
139
+ <Input
140
+ label="Password input"
141
+ placeholder="Type here..."
142
+ type="password"
143
+ />
144
+ <Input
145
+ label="Number input"
146
+ placeholder="Type here..."
147
+ type="number"
148
+ />
149
+ <Input
150
+ label="Date input"
151
+ placeholder="Type here..."
152
+ type="date"
153
+ />
154
+ <Input
155
+ label="Datetime input"
156
+ placeholder="Type here..."
157
+ type="datetime-local"
158
+ />
159
+ <Input
160
+ label="Month input"
161
+ placeholder="Type here..."
162
+ type="month"
163
+ />
164
+ <Input
165
+ label="Time input"
166
+ placeholder="Type here..."
167
+ type="time"
168
+ />
169
+ <Input
170
+ label="URL input"
171
+ placeholder="Type here..."
172
+ type="url"
173
+ />
174
+ ```
175
+
176
+ ## `onChange`, `onInput` and `onRawChange` callbacks
177
+
178
+ The `Input` component can call back to provided functions of `onChange` or `onInput` (which are the same), or `onRawChange`. The `onChange` and `onInput` callbacks are called with the new value as the argument, not the event. The `onRawChange` callback is called with the event as the argument.
179
+
180
+ <Excerpt>
181
+ <Input
182
+ label="Input"
183
+ placeholder="Type here..."
184
+ value={"Starting value"}
185
+ onChange={console.log}
186
+ onInput={console.log}
187
+ onRawChange={console.log}
188
+ />
189
+ </Excerpt>
190
+
191
+ ```jsx highlight={5-7}
192
+ <Input
193
+ label="Input"
194
+ placeholder="Type here..."
195
+ value={"Starting value"}
196
+ onChange={console.log}
197
+ onInput={console.log}
198
+ onRawChange={console.log}
199
+ />
200
+ ```
201
+
202
+ When this example is run, the following will be logged to the console:
203
+
204
+ ```js
205
+ "Starting value"
206
+ "Starting value"
207
+ {
208
+ ...
209
+ target: {
210
+ ...
211
+ value: "Starting value"
212
+ }
213
+ }
214
+ ```
215
+
216
+ ## Icon
217
+
218
+ You can supply an icon to the `Input` component. The `icon` prop accepts a node.
219
+
220
+ <Excerpt>
221
+ <Input label="Input" placeholder="Type here..." icon={<IconAerialLift />} />
222
+ <Input
223
+ label="Input with icon on the right"
224
+ placeholder="Type here..."
225
+ icon={<IconAerialLift />}
226
+ iconPos="trailing"
227
+ />
228
+ </Excerpt>
229
+
230
+ ```jsx highlight={4,9-10}
231
+ <Input
232
+ label="Input"
233
+ placeholder="Type here..."
234
+ icon={<IconAerialLift />}
235
+ />
236
+ <Input
237
+ label="Input with icon on the right"
238
+ placeholder="Type here..."
239
+ icon={<IconAerialLift />}
240
+ iconPos="trailing"
241
+ />
242
+ ```
243
+
244
+ ## Loader
245
+
246
+ You can supply a boolean value to the `loader` prop to show a spinner.
247
+
248
+ <Excerpt>
249
+ <Input label="Input" placeholder="Type here..." loader />
250
+ </Excerpt>
251
+
252
+ ```jsx
253
+ <Input label="Input" placeholder="Type here..." loader />
254
+ ```
255
+
256
+ ## Separated
257
+
258
+ You can create seperate inputs by passing the `separated` prop. If you do this, you must also provide either an icon or loader, and use the `appendedLinkOnClick` or `appendedLinkHref` props to handle press events.
259
+
260
+ <Excerpt>
261
+ <Input
262
+ label="Input"
263
+ placeholder="Type here..."
264
+ appendedLinkOnClick={() => alert("Clicked")}
265
+ icon={<IconAerialLift size={18} />}
266
+ separated
267
+ />
268
+ <Input
269
+ label="Input"
270
+ placeholder="Type here..."
271
+ appendedLinkOnClick={() => alert("Clicked")}
272
+ loader
273
+ separated
274
+ />
275
+ </Excerpt>
276
+
277
+ ```jsx
278
+ <Input
279
+ label="Input"
280
+ placeholder="Type here..."
281
+ appendedLinkOnClick={() => alert("Clicked")}
282
+ icon={<IconAerialLift size={18} />}
283
+ separated
284
+ />
285
+ <Input
286
+ label="Input"
287
+ placeholder="Type here..."
288
+ appendedLinkOnClick={() => alert("Clicked")}
289
+ icon={<IconAerialLift size={18} />}
290
+ separated
291
+ />
292
+ ```
293
+
294
+ ## Prepended and Appended Text or Links
295
+
296
+ You can embed text or links in the input box by passing the `prependedText` or `appendedText` props. You can also pass an `appendedLinkText` prop to show a link in the text. The `appendedLinkHref` prop is used to set the href of the link. The `appendedLinkOnClick` prop is used to handle the click event of the link. You can only add event handlers to the appended link. If using links, you cannot also use a prependedText.
297
+
298
+ <Excerpt>
299
+ <Input
300
+ label="Input"
301
+ placeholder="Type here..."
302
+ prependedText="https://"
303
+ appendedText=".com"
304
+ />
305
+ <Input
306
+ label="Input"
307
+ placeholder="Type here..."
308
+ appendedLinkText="Link"
309
+ appendedLinkHref="javascript:void(0);"
310
+ appendedLinkOnClick={() => alert("Clicked")}
311
+ />
312
+ </Excerpt>
313
+
314
+ ```jsx
315
+ <Input
316
+ label="Input"
317
+ placeholder="Type here..."
318
+ prependedText="https://"
319
+ appendedText=".com"
320
+ />
321
+ <Input
322
+ label="Input"
323
+ placeholder="Type here..."
324
+ appendedLinkText="Link"
325
+ appendedLinkHref="javascript:void(0);"
326
+ appendedLinkOnClick={() => alert("Clicked")}
327
+ />
328
+ ```
329
+
330
+ ## Variants
331
+
332
+ You can pass a `variant` prop to the `Input` component to change the color of the input box.
333
+
334
+ <Excerpt>
335
+ {[
336
+ "primary",
337
+ "secondary",
338
+ "success",
339
+ "danger",
340
+ "warning",
341
+ "info",
342
+ "light",
343
+ "dark",
344
+ "pink",
345
+ "yellow",
346
+ ].map((color) => (
347
+ <Input
348
+ key={color}
349
+ label="Input"
350
+ placeholder="Type here..."
351
+ variant={color}
352
+ />
353
+ ))}
354
+ </Excerpt>
355
+
356
+ ```jsx
357
+ <Input
358
+ label="Input"
359
+ placeholder="Type here..."
360
+ variant="primary"
361
+ />
362
+ <Input
363
+ label="Input"
364
+ placeholder="Type here..."
365
+ variant="secondary"
366
+ />
367
+ ...
368
+ ```
369
+
370
+ ## Invalid
371
+
372
+ There is not `invalid` prop. You can use the `variant` prop to change the color of the input box to indicate an invalid state.
373
+
374
+ <Excerpt>
375
+ <Input label="Input" placeholder="Type here..." variant="danger" />
376
+ </Excerpt>
377
+
378
+ ```jsx
379
+ <Input label="Input" placeholder="Type here..." variant="danger" />
380
+ ```
381
+
382
+ ## Sizes
383
+
384
+ You can pass a `size` prop to the `Input` component to change the size of the input box.
385
+
386
+ <Excerpt>
387
+ {["sm", "md", "lg"].map((size) => (
388
+ <Input key={size} label="Input" placeholder="Type here..." size={size} />
389
+ ))}
390
+ </Excerpt>
391
+
392
+ ```jsx
393
+ <Input
394
+ label="Input"
395
+ placeholder="Type here..."
396
+ size="sm"
397
+ />
398
+ <Input
399
+ label="Input"
400
+ placeholder="Type here..."
401
+ size="md"
402
+ />
403
+ <Input
404
+ label="Input"
405
+ placeholder="Type here..."
406
+ size="lg"
407
+ />
408
+ ```
409
+
410
+ ## Datalist (Autocomplete)
411
+
412
+ You can supply a list of items to the `datalistItems` prop to show a datalist. The `datalistItems` prop accepts an array of strings.
413
+
414
+ <Excerpt>
415
+ <Input
416
+ label="Input"
417
+ placeholder="Type here..."
418
+ datalistItems={["One", "Two", "Three"]}
419
+ />
420
+ </Excerpt>
421
+
422
+ ```jsx
423
+ <Input
424
+ label="Input"
425
+ placeholder="Type here..."
426
+ datalistItems={["One", "Two", "Three"]}
427
+ />
428
+ ```
429
+
430
+ This is different than a DropdownInput because the datalist is not exclusive, meaning the user can use a value that is not in the list.
@@ -0,0 +1,105 @@
1
+ ---
2
+ title: Select Group
3
+ ---
4
+
5
+ import {
6
+ SelectGroup,
7
+ EnclosedSelectGroup,
8
+ } from "../../components/LoadableTabler.jsx";
9
+ import { Excerpt } from "../../components/Excerpt.jsx";
10
+ import { useState } from "react";
11
+
12
+ Select Groups are used to mask radio and checkbox inputs in boxes with a label.
13
+
14
+ ## Signature
15
+
16
+ export const ControlledSelectGroup = (props) => {
17
+ const [value, setValue] = useState(props.value);
18
+ return (
19
+ <>
20
+ <SelectGroup
21
+ {...props}
22
+ value={value}
23
+ onChange={(d) => {
24
+ setValue(d);
25
+ props.onChange && props.onChange(d);
26
+ }}
27
+ />
28
+ </>
29
+ );
30
+ };
31
+
32
+ ```jsx
33
+ import { SelectGroup } from "tabler-react-2";
34
+
35
+ <SelectGroup {...props} />;
36
+ ```
37
+
38
+ ### Props
39
+
40
+ | Prop | Required | Type | Default | Description |
41
+ | ---------- | -------- | -------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
42
+ | `items` | Yes | Array of objects | | The items to be shown in the select group. Each item should have a `value` and `label` prop. |
43
+ | `value` | Yes | Object or Array of Objects if multiple | | The value of the select group. If the value is an array, multiple items can be selected. The value of each item should be the same as the `value` prop of the item. |
44
+ | `onChange` | Yes | Function | | The function to be called when the value of the select group changes. It is called with the new value as the argument, not the event. If the value is an array, the new value is an array of objects. The value of each item should be the same as the `value` prop of the item. |
45
+ | `multiple` | No | Boolean | | Whether multiple items can be selected. |
46
+
47
+ ## Basic Usage
48
+
49
+ The `SelectGroup` component is used to mask radio and checkbox inputs in boxes with a label.
50
+
51
+ <Excerpt>
52
+ <ControlledSelectGroup
53
+ items={[
54
+ { value: "one", label: "One" },
55
+ { value: "two", label: "Two" },
56
+ { value: "three", label: "Three" },
57
+ ]}
58
+ value={null}
59
+ onChange={console.log}
60
+ />
61
+
62
+ </Excerpt>
63
+
64
+ ```jsx
65
+ <SelectGroup
66
+ items={[
67
+ { value: "one", label: "One" },
68
+ { value: "two", label: "Two" },
69
+ { value: "three", label: "Three" },
70
+ ]}
71
+ value={null}
72
+ onChange={console.log}
73
+ />
74
+ ```
75
+
76
+ ## Multiple Select
77
+
78
+ The `multiple` prop can be used to allow multiple items to be selected.
79
+
80
+ <Excerpt>
81
+ <ControlledSelectGroup
82
+ items={[
83
+ { value: "one", label: "One" },
84
+ { value: "two", label: "Two" },
85
+ { value: "three", label: "Three" },
86
+ ]}
87
+ value={[]}
88
+ onChange={console.log}
89
+ multiple
90
+ />
91
+
92
+ </Excerpt>
93
+
94
+ ```jsx
95
+ <SelectGroup
96
+ items={[
97
+ { value: "one", label: "One" },
98
+ { value: "two", label: "Two" },
99
+ { value: "three", label: "Three" },
100
+ ]}
101
+ value={null}
102
+ onChange={console.log}
103
+ multiple
104
+ />
105
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tabler-react-2",
3
- "version": "0.1.94",
3
+ "version": "0.1.96",
4
4
  "description": "A react implementation of Tabler ui",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {