@unbxd-ui/unbxd-react-components 0.2.221 → 0.3.0
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/README.md +17 -1
- package/components/Accordian/Accordian.js +14 -11
- package/components/Accordian/Accordian.stories.js +141 -118
- package/components/Accordian/index.js +1 -1
- package/components/Button/Button.js +4 -4
- package/components/Button/Button.stories.js +168 -62
- package/components/Button/DropdownButton.js +5 -6
- package/components/Button/buttonTheme.css +1 -1
- package/components/Button/index.js +2 -3
- package/components/DataLoader/DataLoader.js +6 -7
- package/components/DataLoader/DataLoader.stories.js +244 -58
- package/components/DataLoader/index.js +1 -1
- package/components/Form/Checkbox.js +12 -11
- package/components/Form/DragDropFileUploader.js +6 -7
- package/components/Form/Dropdown.js +14 -12
- package/components/Form/FileUploader.js +3 -4
- package/components/Form/Form.js +6 -7
- package/components/Form/FormElementWrapper.js +1 -1
- package/components/Form/Input.js +24 -15
- package/components/Form/RadioList.js +8 -9
- package/components/Form/RangeSlider.js +12 -13
- package/components/Form/SearchableDropdown.js +563 -0
- package/components/Form/ServerPaginatedDDList.js +53 -44
- package/components/Form/Textarea.js +26 -10
- package/components/Form/Toggle.js +6 -7
- package/components/Form/formCore.css +1 -1
- package/components/Form/formTheme.css +1 -1
- package/components/Form/index.js +8 -1
- package/components/Form/stories/Checkbox.stories.js +139 -40
- package/components/Form/stories/Dropdown.stories.js +323 -92
- package/components/Form/stories/FileUploader.stories.js +178 -19
- package/components/Form/stories/Input.stories.js +115 -0
- package/components/Form/stories/RangeSlider.stories.js +162 -64
- package/components/Form/stories/SearchableDropdown.stories.js +189 -0
- package/components/Form/stories/ServerPaginatedDropdown.stories.js +365 -0
- package/components/Form/stories/Textarea.stories.js +113 -34
- package/components/Form/stories/Toggle.stories.js +193 -14
- package/components/Form/variables.css +0 -0
- package/components/InlineModal/InlineModal.js +119 -21
- package/components/InlineModal/InlineModal.stories.js +239 -45
- package/components/InlineModal/index.js +1 -2
- package/components/InlineModal/inlineModalCore.css +1 -1
- package/components/List/List.js +11 -8
- package/components/List/List.stories.js +238 -0
- package/components/List/index.js +1 -1
- package/components/Modal/Modal.js +67 -20
- package/components/Modal/Modal.stories.js +257 -38
- package/components/Modal/index.js +1 -1
- package/components/Modal/modalCore.css +1 -1
- package/components/NoDataPlaceholder/NoDataPlaceholder.js +41 -0
- package/components/NoDataPlaceholder/NoDataPlaceholder.stories.js +42 -0
- package/components/NoDataPlaceholder/index.js +9 -0
- package/components/NoDataPlaceholder/noDataPlaceholderCore.css +1 -0
- package/components/NotificationComponent/NotificationComponent.js +20 -10
- package/components/NotificationComponent/NotificationComponent.stories.js +171 -19
- package/components/NotificationComponent/index.js +1 -1
- package/components/NotificationComponent/notificationTheme.css +1 -1
- package/components/PageLoader/PageLoader.js +84 -0
- package/components/PageLoader/PageLoader.stories.js +276 -0
- package/components/PageLoader/index.js +9 -0
- package/components/PageLoader/pageLoaderCore.css +1 -0
- package/components/ProgressBar/ProgressBar.css +0 -0
- package/components/ProgressBar/ProgressBar.js +1 -1
- package/components/ProgressBar/ProgressBar.stories.js +203 -10
- package/components/ProgressBar/index.js +1 -1
- package/components/ProgressBar/progressBarCore.css +1 -1
- package/components/Table/BaseTable.js +86 -342
- package/components/Table/PaginationComponent.js +4 -4
- package/components/Table/Table.js +7 -326
- package/components/Table/Table.stories.js +2117 -158
- package/components/Table/TableChild.js +383 -0
- package/components/Table/TableConstants.js +15 -0
- package/components/Table/hooks/usePrevious.js +14 -0
- package/components/Table/index.js +14 -1
- package/components/Table/tableCore.css +1 -1
- package/components/TableOld/BaseTable.js +373 -0
- package/components/TableOld/PaginationComponent.js +86 -0
- package/components/TableOld/TableOld.js +367 -0
- package/components/TableOld/index.js +15 -0
- package/components/TabsComponent/TabsComponent.js +6 -7
- package/components/TabsComponent/TabsComponent.stories.js +291 -53
- package/components/TabsComponent/index.js +1 -1
- package/components/ToastNotification/ToastNotificationWrapper.js +212 -0
- package/components/ToastNotification/ToastNotificationWrapper.stories.js +554 -0
- package/components/ToastNotification/index.js +40 -0
- package/components/ToastNotification/toastNotificationCore.css +1 -0
- package/components/Tooltip/Tooltip.js +231 -56
- package/components/Tooltip/Tooltip.stories.js +380 -15
- package/components/Tooltip/index.js +1 -1
- package/components/Tooltip/tooltipCore.css +1 -1
- package/components/Tooltip/tooltipTheme.css +1 -1
- package/components/common/NoDataDropdown.js +50 -0
- package/components/common/common.css +1 -0
- package/components/core.css +2 -3
- package/components/core.scss +20 -1
- package/components/index.js +66 -3
- package/components/theme.css +2 -3
- package/core/Validators.js +1 -1
- package/core/customHooks.js +4 -4
- package/core/dataLoader.js +58 -17
- package/core/index.js +1 -1
- package/core/utils.js +15 -4
- package/index.js +54 -0
- package/package.json +41 -28
- package/components/Button/DropdownButton.stories.js +0 -49
- package/components/Form/stories/DragDropFileUploader.stories.js +0 -25
- package/components/Form/stories/FormDefault.stories.js +0 -115
- package/components/Form/stories/RadioList.stories.js +0 -53
- package/components/Form/stories/TextInput.stories.js +0 -76
- package/components/Form/stories/form.stories.js +0 -233
- package/components/List/list.stories.js +0 -35
- package/core/dataLoader.stories.js +0 -119
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = exports.MultiSelect = exports.Default = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _Dropdown = _interopRequireDefault(require("../Dropdown"));
|
|
10
|
+
var _dataLoader = _interopRequireDefault(require("../../../core/dataLoader"));
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
13
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
14
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
15
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
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; }
|
|
17
|
+
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; }
|
|
18
|
+
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; }
|
|
19
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
20
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
21
|
+
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); }
|
|
22
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
23
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
24
|
+
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; } }
|
|
25
|
+
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; }
|
|
26
|
+
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; } }
|
|
27
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
28
|
+
// Set up all request configurations globally
|
|
29
|
+
_dataLoader["default"].addRequestConfig('getUsers', {
|
|
30
|
+
url: 'https://jsonplaceholder.typicode.com/users',
|
|
31
|
+
method: 'GET'
|
|
32
|
+
});
|
|
33
|
+
var meta = {
|
|
34
|
+
title: 'Components/Form/Dropdown/ServerPaginated',
|
|
35
|
+
component: _Dropdown["default"],
|
|
36
|
+
parameters: {
|
|
37
|
+
layout: 'centered'
|
|
38
|
+
},
|
|
39
|
+
tags: ['autodocs']
|
|
40
|
+
};
|
|
41
|
+
var _default = exports["default"] = meta;
|
|
42
|
+
var Default = exports.Default = {
|
|
43
|
+
args: {
|
|
44
|
+
showSearch: true,
|
|
45
|
+
searchPlaceholder: 'Search with id only',
|
|
46
|
+
searchAttribute: 'id',
|
|
47
|
+
multiSelect: false,
|
|
48
|
+
idAttribute: 'id',
|
|
49
|
+
nameAttribute: 'name',
|
|
50
|
+
pageSize: 2,
|
|
51
|
+
maxHeight: 80,
|
|
52
|
+
perPageKey: '_limit',
|
|
53
|
+
pageNoKey: '_page',
|
|
54
|
+
ddItemHeight: 40,
|
|
55
|
+
paginationType: 'SERVER'
|
|
56
|
+
},
|
|
57
|
+
argTypes: {
|
|
58
|
+
showSearch: {
|
|
59
|
+
control: 'boolean',
|
|
60
|
+
description: 'Enable search functionality'
|
|
61
|
+
},
|
|
62
|
+
searchPlaceholder: {
|
|
63
|
+
control: 'text',
|
|
64
|
+
description: 'Placeholder text for search input'
|
|
65
|
+
},
|
|
66
|
+
searchAttribute: {
|
|
67
|
+
control: 'text',
|
|
68
|
+
description: 'Field to search against'
|
|
69
|
+
},
|
|
70
|
+
multiSelect: {
|
|
71
|
+
control: 'boolean',
|
|
72
|
+
description: 'Allow multiple selections'
|
|
73
|
+
},
|
|
74
|
+
idAttribute: {
|
|
75
|
+
control: 'text',
|
|
76
|
+
description: 'Field to use as unique identifier'
|
|
77
|
+
},
|
|
78
|
+
nameAttribute: {
|
|
79
|
+
control: 'text',
|
|
80
|
+
description: 'Field to display as item label'
|
|
81
|
+
},
|
|
82
|
+
pageSize: {
|
|
83
|
+
control: 'number',
|
|
84
|
+
description: 'Number of items per page'
|
|
85
|
+
},
|
|
86
|
+
maxHeight: {
|
|
87
|
+
control: 'number',
|
|
88
|
+
description: 'Maximum height of dropdown list'
|
|
89
|
+
},
|
|
90
|
+
perPageKey: {
|
|
91
|
+
control: 'text',
|
|
92
|
+
description: 'Query parameter for items per page'
|
|
93
|
+
},
|
|
94
|
+
pageNoKey: {
|
|
95
|
+
control: 'text',
|
|
96
|
+
description: 'Query parameter for page number'
|
|
97
|
+
},
|
|
98
|
+
ddItemHeight: {
|
|
99
|
+
control: 'number',
|
|
100
|
+
description: 'Height of each dropdown item'
|
|
101
|
+
},
|
|
102
|
+
paginationType: {
|
|
103
|
+
control: 'select',
|
|
104
|
+
options: ['SERVER', 'CLIENT'],
|
|
105
|
+
description: 'Type of pagination'
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
render: function render(args) {
|
|
109
|
+
var _React$useState = _react["default"].useState(null),
|
|
110
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
111
|
+
selectedValue = _React$useState2[0],
|
|
112
|
+
setSelectedValue = _React$useState2[1];
|
|
113
|
+
var ddRef = _react["default"].useRef(null);
|
|
114
|
+
var valuesResponseFormatter = function valuesResponseFormatter(response) {
|
|
115
|
+
return {
|
|
116
|
+
entries: response.map(function (user) {
|
|
117
|
+
return {
|
|
118
|
+
name: user.name,
|
|
119
|
+
id: user.id
|
|
120
|
+
};
|
|
121
|
+
}),
|
|
122
|
+
total: response.length ? 10 : 0
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
var ValueDropdownItem = function ValueDropdownItem(props) {
|
|
126
|
+
var index = props.index,
|
|
127
|
+
data = props.data;
|
|
128
|
+
var items = data.items;
|
|
129
|
+
if (items.length === 0) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
var itemData = data.items[index];
|
|
133
|
+
if (!itemData) return null;
|
|
134
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
135
|
+
style: {
|
|
136
|
+
width: '300px'
|
|
137
|
+
},
|
|
138
|
+
className: "RCB-list-item"
|
|
139
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
140
|
+
onClick: function onClick() {
|
|
141
|
+
setSelectedValue(itemData);
|
|
142
|
+
ddRef.current.closeDropdown();
|
|
143
|
+
}
|
|
144
|
+
}, /*#__PURE__*/_react["default"].createElement("div", null, "Name: ".concat(itemData.name, ", Id: ").concat(itemData.id))));
|
|
145
|
+
};
|
|
146
|
+
var PageLoader = function PageLoader(_ref) {
|
|
147
|
+
var className = _ref.className;
|
|
148
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
149
|
+
className: "loading-spinner ".concat(className || '')
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
var NoDataComponent = function NoDataComponent() {
|
|
153
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
154
|
+
style: {
|
|
155
|
+
padding: '10px',
|
|
156
|
+
textAlign: 'center',
|
|
157
|
+
color: '#666',
|
|
158
|
+
fontSize: '14px'
|
|
159
|
+
}
|
|
160
|
+
}, "No matching results found");
|
|
161
|
+
};
|
|
162
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
163
|
+
style: {
|
|
164
|
+
width: '300px',
|
|
165
|
+
height: '150px'
|
|
166
|
+
}
|
|
167
|
+
}, /*#__PURE__*/_react["default"].createElement(_Dropdown["default"], _extends({}, args, {
|
|
168
|
+
ref: ddRef,
|
|
169
|
+
className: "users-dd demo-dropdown",
|
|
170
|
+
name: "usersDD",
|
|
171
|
+
requestId: "getUsers",
|
|
172
|
+
DropdownItem: ValueDropdownItem,
|
|
173
|
+
responseFormatter: valuesResponseFormatter,
|
|
174
|
+
value: selectedValue,
|
|
175
|
+
onChange: function onChange(value) {
|
|
176
|
+
return setSelectedValue(value);
|
|
177
|
+
},
|
|
178
|
+
LoaderComponent: /*#__PURE__*/_react["default"].createElement(PageLoader, {
|
|
179
|
+
className: "search-loader"
|
|
180
|
+
}),
|
|
181
|
+
NoDataComponent: NoDataComponent
|
|
182
|
+
})));
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
var MultiSelect = exports.MultiSelect = {
|
|
186
|
+
args: _objectSpread(_objectSpread({}, Default.args), {}, {
|
|
187
|
+
multiSelect: true,
|
|
188
|
+
noSelectionLabel: 'Select users',
|
|
189
|
+
searchPlaceholder: 'Search users by id'
|
|
190
|
+
}),
|
|
191
|
+
argTypes: Default.argTypes,
|
|
192
|
+
render: function render(args) {
|
|
193
|
+
var _React$useState3 = _react["default"].useState([]),
|
|
194
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
195
|
+
selectedValues = _React$useState4[0],
|
|
196
|
+
setSelectedValues = _React$useState4[1];
|
|
197
|
+
var ddRef = _react["default"].useRef(null);
|
|
198
|
+
var valuesResponseFormatter = function valuesResponseFormatter(response) {
|
|
199
|
+
return {
|
|
200
|
+
entries: response.map(function (user) {
|
|
201
|
+
return {
|
|
202
|
+
name: user.name,
|
|
203
|
+
id: user.id
|
|
204
|
+
};
|
|
205
|
+
}),
|
|
206
|
+
total: response.length ? 10 : 0
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
var ValueDropdownItem = function ValueDropdownItem(props) {
|
|
210
|
+
var index = props.index,
|
|
211
|
+
data = props.data;
|
|
212
|
+
var items = data.items;
|
|
213
|
+
if (items.length === 0) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
var itemData = data.items[index];
|
|
217
|
+
if (!itemData) return null;
|
|
218
|
+
var isSelected = selectedValues.some(function (val) {
|
|
219
|
+
return val.id === itemData.id;
|
|
220
|
+
});
|
|
221
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
222
|
+
style: {
|
|
223
|
+
width: '300px'
|
|
224
|
+
},
|
|
225
|
+
className: "RCB-list-item"
|
|
226
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
227
|
+
onClick: function onClick() {
|
|
228
|
+
if (isSelected) {
|
|
229
|
+
setSelectedValues(selectedValues.filter(function (val) {
|
|
230
|
+
return val.id !== itemData.id;
|
|
231
|
+
}));
|
|
232
|
+
} else {
|
|
233
|
+
setSelectedValues([].concat(_toConsumableArray(selectedValues), [itemData]));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
237
|
+
style: {
|
|
238
|
+
display: 'flex',
|
|
239
|
+
alignItems: 'center',
|
|
240
|
+
gap: '8px'
|
|
241
|
+
}
|
|
242
|
+
}, /*#__PURE__*/_react["default"].createElement("input", {
|
|
243
|
+
type: "checkbox",
|
|
244
|
+
checked: isSelected,
|
|
245
|
+
readOnly: true
|
|
246
|
+
}), /*#__PURE__*/_react["default"].createElement("span", null, "Name: ".concat(itemData.name, ", Id: ").concat(itemData.id)))));
|
|
247
|
+
};
|
|
248
|
+
var PageLoader = function PageLoader(_ref2) {
|
|
249
|
+
var className = _ref2.className;
|
|
250
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
251
|
+
className: "loading-spinner ".concat(className || '')
|
|
252
|
+
});
|
|
253
|
+
};
|
|
254
|
+
var NoDataComponent = function NoDataComponent() {
|
|
255
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
256
|
+
style: {
|
|
257
|
+
padding: '10px',
|
|
258
|
+
textAlign: 'center',
|
|
259
|
+
color: '#666',
|
|
260
|
+
fontSize: '14px'
|
|
261
|
+
}
|
|
262
|
+
}, "No matching results found");
|
|
263
|
+
};
|
|
264
|
+
var SelectionSummary = function SelectionSummary() {
|
|
265
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
266
|
+
style: {
|
|
267
|
+
display: 'flex',
|
|
268
|
+
flexWrap: 'wrap',
|
|
269
|
+
gap: '4px'
|
|
270
|
+
}
|
|
271
|
+
}, selectedValues.length > 0 ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
272
|
+
style: {
|
|
273
|
+
display: 'flex',
|
|
274
|
+
flexWrap: 'wrap',
|
|
275
|
+
gap: '4px'
|
|
276
|
+
}
|
|
277
|
+
}, selectedValues.map(function (value) {
|
|
278
|
+
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
279
|
+
key: value.id,
|
|
280
|
+
style: {
|
|
281
|
+
background: '#e2e8f0',
|
|
282
|
+
padding: '2px 8px',
|
|
283
|
+
borderRadius: '4px',
|
|
284
|
+
fontSize: '14px',
|
|
285
|
+
display: 'flex',
|
|
286
|
+
alignItems: 'center',
|
|
287
|
+
gap: '4px'
|
|
288
|
+
}
|
|
289
|
+
}, value.name, /*#__PURE__*/_react["default"].createElement("button", {
|
|
290
|
+
onClick: function onClick(e) {
|
|
291
|
+
e.stopPropagation();
|
|
292
|
+
setSelectedValues(selectedValues.filter(function (val) {
|
|
293
|
+
return val.id !== value.id;
|
|
294
|
+
}));
|
|
295
|
+
},
|
|
296
|
+
style: {
|
|
297
|
+
border: 'none',
|
|
298
|
+
background: 'none',
|
|
299
|
+
padding: '0',
|
|
300
|
+
cursor: 'pointer',
|
|
301
|
+
fontSize: '14px',
|
|
302
|
+
color: '#666'
|
|
303
|
+
}
|
|
304
|
+
}, "\xD7"));
|
|
305
|
+
})) : /*#__PURE__*/_react["default"].createElement("span", null, "Select users"));
|
|
306
|
+
};
|
|
307
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
308
|
+
style: {
|
|
309
|
+
width: '300px',
|
|
310
|
+
height: '150px'
|
|
311
|
+
}
|
|
312
|
+
}, /*#__PURE__*/_react["default"].createElement(_Dropdown["default"], _extends({}, args, {
|
|
313
|
+
ref: ddRef,
|
|
314
|
+
className: "users-dd demo-dropdown",
|
|
315
|
+
name: "usersDD",
|
|
316
|
+
requestId: "getUsers",
|
|
317
|
+
DropdownItem: ValueDropdownItem,
|
|
318
|
+
SelectionSummary: SelectionSummary,
|
|
319
|
+
responseFormatter: valuesResponseFormatter,
|
|
320
|
+
value: selectedValues,
|
|
321
|
+
onChange: function onChange(value) {
|
|
322
|
+
return setSelectedValues(value);
|
|
323
|
+
},
|
|
324
|
+
LoaderComponent: /*#__PURE__*/_react["default"].createElement(PageLoader, {
|
|
325
|
+
className: "search-loader"
|
|
326
|
+
}),
|
|
327
|
+
NoDataComponent: NoDataComponent
|
|
328
|
+
})));
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
// Documentation
|
|
333
|
+
// Default.parameters = {
|
|
334
|
+
// docs: {
|
|
335
|
+
// description: {
|
|
336
|
+
|
|
337
|
+
// story: `
|
|
338
|
+
// ### Server Paginated Props
|
|
339
|
+
|
|
340
|
+
// | Prop | Type | Description | Example |
|
|
341
|
+
// |------|------|-------------|---------|
|
|
342
|
+
// | requestId | string | Identifier for the API request configuration | 'getUsers' |
|
|
343
|
+
// | showSearch | boolean | Enable search functionality | true |
|
|
344
|
+
// | searchPlaceholder | string | Placeholder text for search input | 'Search with id only' |
|
|
345
|
+
// | searchAttribute | string | Field to search against | 'id' |
|
|
346
|
+
// | multiSelect | boolean | Allow multiple selections | false |
|
|
347
|
+
// | idAttribute | string | Field to use as unique identifier | 'id' |
|
|
348
|
+
// | nameAttribute | string | Field to display as item label | 'name' |
|
|
349
|
+
// | responseFormatter | function | Function to format API response | \`(response) => ({ entries: response, total: 10 })\` |
|
|
350
|
+
// | pageSize | number | Number of items per page | 2 |
|
|
351
|
+
// | maxHeight | number | Maximum height of dropdown list | 80 |
|
|
352
|
+
// | perPageKey | string | Query parameter for items per page | '_limit' |
|
|
353
|
+
// | pageNoKey | string | Query parameter for page number | '_page' |
|
|
354
|
+
// | ddItemHeight | number | Height of each dropdown item | 40 |
|
|
355
|
+
// | paginationType | string | Type of pagination | 'SERVER' |
|
|
356
|
+
|
|
357
|
+
// ### Usage Notes:
|
|
358
|
+
// - The dropdown uses JSONPlaceholder's /users endpoint for demonstration
|
|
359
|
+
// - Search is configured to filter by user ID
|
|
360
|
+
// - Response formatter transforms the API data to match required format
|
|
361
|
+
// - Uses ref to programmatically control dropdown visibility
|
|
362
|
+
// `
|
|
363
|
+
// }
|
|
364
|
+
// }
|
|
365
|
+
// };
|
|
@@ -1,46 +1,125 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports["default"] = exports.
|
|
6
|
+
exports["default"] = exports.WithLabel = exports.Disabled = exports.Default = exports.CustomRows = exports.ControlledTextarea = void 0;
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
function
|
|
14
|
-
function
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return /*#__PURE__*/_react["default"].createElement(_Form["default"], {
|
|
21
|
-
onSubmit: onSubmit
|
|
22
|
-
}, /*#__PURE__*/_react["default"].createElement(_Textarea2["default"], {
|
|
23
|
-
name: "description",
|
|
24
|
-
label: "Description",
|
|
25
|
-
placeholder: "Enter your description",
|
|
26
|
-
appearance: "block"
|
|
27
|
-
}), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
28
|
-
appearance: _Button.ButtonAppearance.PRIMARY,
|
|
29
|
-
className: "full-width-btn"
|
|
30
|
-
}, "Submit"));
|
|
31
|
-
};
|
|
32
|
-
_Textarea.story = {
|
|
8
|
+
var _Textarea = _interopRequireDefault(require("../Textarea"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
11
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
+
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; } }
|
|
13
|
+
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; }
|
|
14
|
+
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; } }
|
|
15
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
16
|
+
var meta = {
|
|
17
|
+
title: 'Components/Form/Textarea',
|
|
18
|
+
component: _Textarea["default"],
|
|
33
19
|
parameters: {
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
layout: 'centered'
|
|
21
|
+
},
|
|
22
|
+
tags: ['autodocs'],
|
|
23
|
+
argTypes: {
|
|
24
|
+
placeholder: {
|
|
25
|
+
control: 'text',
|
|
26
|
+
description: 'Placeholder text'
|
|
27
|
+
},
|
|
28
|
+
rows: {
|
|
29
|
+
control: 'number',
|
|
30
|
+
description: 'Number of visible text lines'
|
|
31
|
+
},
|
|
32
|
+
disabled: {
|
|
33
|
+
control: 'boolean',
|
|
34
|
+
description: 'Whether the textarea is disabled'
|
|
35
|
+
},
|
|
36
|
+
className: {
|
|
37
|
+
control: 'text',
|
|
38
|
+
description: 'Additional CSS classes'
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
41
|
};
|
|
39
|
-
var _default = exports["default"] =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
var _default = exports["default"] = meta;
|
|
43
|
+
var Default = exports.Default = {
|
|
44
|
+
render: function render() {
|
|
45
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
46
|
+
style: {
|
|
47
|
+
width: '300px'
|
|
48
|
+
}
|
|
49
|
+
}, /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
50
|
+
placeholder: "Enter your message...",
|
|
51
|
+
onChange: function onChange(value) {
|
|
52
|
+
return console.log('Textarea changed:', value);
|
|
53
|
+
}
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var WithLabel = exports.WithLabel = {
|
|
58
|
+
render: function render() {
|
|
59
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
60
|
+
style: {
|
|
61
|
+
width: '300px'
|
|
62
|
+
}
|
|
63
|
+
}, /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
64
|
+
label: "Message",
|
|
65
|
+
placeholder: "Type your message here",
|
|
66
|
+
onChange: function onChange(value) {
|
|
67
|
+
return console.log('Textarea changed:', value);
|
|
68
|
+
}
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var CustomRows = exports.CustomRows = {
|
|
73
|
+
render: function render() {
|
|
74
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
75
|
+
style: {
|
|
76
|
+
width: '300px'
|
|
77
|
+
}
|
|
78
|
+
}, /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
79
|
+
label: "Description",
|
|
80
|
+
rows: 5,
|
|
81
|
+
placeholder: "Enter a detailed description",
|
|
82
|
+
onChange: function onChange(value) {
|
|
83
|
+
return console.log('Textarea changed:', value);
|
|
84
|
+
}
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
var Disabled = exports.Disabled = {
|
|
89
|
+
render: function render() {
|
|
90
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
91
|
+
style: {
|
|
92
|
+
width: '300px'
|
|
93
|
+
}
|
|
94
|
+
}, /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
95
|
+
label: "Read-only content",
|
|
96
|
+
disabled: true,
|
|
97
|
+
value: "This content cannot be edited",
|
|
98
|
+
onChange: function onChange(value) {
|
|
99
|
+
return console.log('Textarea changed:', value);
|
|
100
|
+
}
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
var ControlledTextarea = exports.ControlledTextarea = {
|
|
105
|
+
render: function render() {
|
|
106
|
+
var _React$useState = _react["default"].useState(''),
|
|
107
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
108
|
+
textAreaValue = _React$useState2[0],
|
|
109
|
+
setTextAreaValue = _React$useState2[1];
|
|
110
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
111
|
+
style: {
|
|
112
|
+
width: '300px'
|
|
113
|
+
}
|
|
114
|
+
}, /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
115
|
+
label: "Controlled Textarea",
|
|
116
|
+
rows: 3,
|
|
117
|
+
value: textAreaValue,
|
|
118
|
+
placeholder: "Enter a detailed description",
|
|
119
|
+
onChange: function onChange(value) {
|
|
120
|
+
console.log('Textarea changed:', value);
|
|
121
|
+
setTextAreaValue(value);
|
|
122
|
+
}
|
|
123
|
+
}));
|
|
45
124
|
}
|
|
46
125
|
};
|