@unbxd-ui/unbxd-react-components 0.3.1 → 0.3.2-beta.1
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/assets/desktop.svg +6 -0
- package/assets/map-pin.svg +6 -0
- package/assets/p1.svg +20 -0
- package/assets/p2.svg +22 -0
- package/assets/p3.svg +19 -0
- package/assets/p4.svg +22 -0
- package/assets/p5.svg +23 -0
- package/components/Form/Dropdown.js +77 -10
- package/components/Form/SearchableDropdown.js +22 -15
- package/components/Form/SelectedPills.js +126 -0
- package/components/Form/SummarySelection.js +46 -0
- package/components/Form/formCore.css +1 -1
- package/components/Form/stories/Dropdown.stories.js +160 -2
- package/components/Form/stories/SearchableDropdown.stories.js +173 -3
- package/components/Form/stories/ServerPaginatedDropdown.stories.js +166 -94
- package/components/Form/summarySelection.css +1 -0
- package/components/Link/linkCore.css +1 -1
- package/components/PIDItemComponent/PIDItemComponent.js +72 -0
- package/components/PIDItemComponent/PIDItemComponent.stories.js +175 -0
- package/components/PIDItemComponent/PIDItemComponentCore.css +1 -0
- package/components/PIDItemComponent/index.js +9 -0
- package/components/UIDItemComponent/UIDItemComponent.js +138 -0
- package/components/UIDItemComponent/UIDItemComponent.stories.js +51 -0
- package/components/UIDItemComponent/UIDItemComponentCore.css +1 -0
- package/components/UIDItemComponent/index.js +9 -0
- package/components/core.css +2 -2
- package/components/core.scss +12 -10
- package/components/index.js +25 -11
- package/components/theme.css +2 -2
- package/components/theme.scss +2 -1
- package/core/index.js +7 -0
- package/core/lazyLoadImage.js +56 -0
- package/core/utils.js +6 -1
- package/index.js +48 -0
- package/package.json +5 -4
|
@@ -4,10 +4,12 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports["default"] = exports.MultiSelect = exports.Default = void 0;
|
|
7
|
+
exports["default"] = exports.PIDServerDropdown = exports.MultiSelect = exports.Default = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _Dropdown = _interopRequireDefault(require("../Dropdown"));
|
|
10
9
|
var _dataLoader = _interopRequireDefault(require("../../../core/dataLoader"));
|
|
10
|
+
var _PIDItemComponent = _interopRequireDefault(require("../../PIDItemComponent/PIDItemComponent"));
|
|
11
|
+
var _Dropdown = _interopRequireDefault(require("../Dropdown"));
|
|
12
|
+
var _SummarySelection = _interopRequireDefault(require("../SummarySelection"));
|
|
11
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
14
|
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
13
15
|
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."); }
|
|
@@ -182,6 +184,136 @@ var Default = exports.Default = {
|
|
|
182
184
|
})));
|
|
183
185
|
}
|
|
184
186
|
};
|
|
187
|
+
var PIDServerDropdown = exports.PIDServerDropdown = {
|
|
188
|
+
args: {
|
|
189
|
+
showSearch: true,
|
|
190
|
+
searchPlaceholder: 'Search with id only',
|
|
191
|
+
searchAttribute: 'id',
|
|
192
|
+
multiSelect: false,
|
|
193
|
+
idAttribute: 'id',
|
|
194
|
+
nameAttribute: 'name',
|
|
195
|
+
pageSize: 20,
|
|
196
|
+
maxHeight: 180,
|
|
197
|
+
perPageKey: '_limit',
|
|
198
|
+
pageNoKey: '_page',
|
|
199
|
+
ddItemHeight: 60,
|
|
200
|
+
paginationType: 'SERVER'
|
|
201
|
+
},
|
|
202
|
+
argTypes: {
|
|
203
|
+
showSearch: {
|
|
204
|
+
control: 'boolean',
|
|
205
|
+
description: 'Enable search functionality'
|
|
206
|
+
},
|
|
207
|
+
searchPlaceholder: {
|
|
208
|
+
control: 'text',
|
|
209
|
+
description: 'Placeholder text for search input'
|
|
210
|
+
},
|
|
211
|
+
searchAttribute: {
|
|
212
|
+
control: 'text',
|
|
213
|
+
description: 'Field to search against'
|
|
214
|
+
},
|
|
215
|
+
multiSelect: {
|
|
216
|
+
control: 'boolean',
|
|
217
|
+
description: 'Allow multiple selections'
|
|
218
|
+
},
|
|
219
|
+
idAttribute: {
|
|
220
|
+
control: 'text',
|
|
221
|
+
description: 'Field to use as unique identifier'
|
|
222
|
+
},
|
|
223
|
+
nameAttribute: {
|
|
224
|
+
control: 'text',
|
|
225
|
+
description: 'Field to display as item label'
|
|
226
|
+
},
|
|
227
|
+
pageSize: {
|
|
228
|
+
control: 'number',
|
|
229
|
+
description: 'Number of items per page'
|
|
230
|
+
},
|
|
231
|
+
maxHeight: {
|
|
232
|
+
control: 'number',
|
|
233
|
+
description: 'Maximum height of dropdown list'
|
|
234
|
+
},
|
|
235
|
+
perPageKey: {
|
|
236
|
+
control: 'text',
|
|
237
|
+
description: 'Query parameter for items per page'
|
|
238
|
+
},
|
|
239
|
+
pageNoKey: {
|
|
240
|
+
control: 'text',
|
|
241
|
+
description: 'Query parameter for page number'
|
|
242
|
+
},
|
|
243
|
+
ddItemHeight: {
|
|
244
|
+
control: 'number',
|
|
245
|
+
description: 'Height of each dropdown item'
|
|
246
|
+
},
|
|
247
|
+
paginationType: {
|
|
248
|
+
control: 'select',
|
|
249
|
+
options: ['SERVER', 'CLIENT'],
|
|
250
|
+
description: 'Type of pagination'
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
render: function render(args) {
|
|
254
|
+
var _React$useState3 = _react["default"].useState(null),
|
|
255
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
256
|
+
selectedValue = _React$useState4[0],
|
|
257
|
+
setSelectedValue = _React$useState4[1];
|
|
258
|
+
var ddRef = _react["default"].useRef(null);
|
|
259
|
+
var valuesResponseFormatter = function valuesResponseFormatter(response) {
|
|
260
|
+
return {
|
|
261
|
+
entries: response.map(function (user) {
|
|
262
|
+
return {
|
|
263
|
+
name: user.name,
|
|
264
|
+
id: user.id,
|
|
265
|
+
imageUrl: "https://images.unsplash.com/photo-1560343090-f0409e92791a?w=300"
|
|
266
|
+
};
|
|
267
|
+
}),
|
|
268
|
+
total: response.length ? 10 : 0
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
var keysMap = {
|
|
272
|
+
uniqueIdMap: 'id',
|
|
273
|
+
imageUrlMap: 'imageUrl',
|
|
274
|
+
titleMap: 'name'
|
|
275
|
+
};
|
|
276
|
+
var PageLoader = function PageLoader(_ref2) {
|
|
277
|
+
var className = _ref2.className;
|
|
278
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
279
|
+
className: "loading-spinner ".concat(className || '')
|
|
280
|
+
});
|
|
281
|
+
};
|
|
282
|
+
var NoDataComponent = function NoDataComponent() {
|
|
283
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
284
|
+
style: {
|
|
285
|
+
padding: '10px',
|
|
286
|
+
textAlign: 'center',
|
|
287
|
+
color: '#666',
|
|
288
|
+
fontSize: '14px'
|
|
289
|
+
}
|
|
290
|
+
}, "No matching results found");
|
|
291
|
+
};
|
|
292
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
293
|
+
style: {
|
|
294
|
+
width: '300px',
|
|
295
|
+
height: '150px'
|
|
296
|
+
}
|
|
297
|
+
}, /*#__PURE__*/_react["default"].createElement(_Dropdown["default"], _extends({}, args, {
|
|
298
|
+
ref: ddRef,
|
|
299
|
+
className: "users-dd demo-dropdown",
|
|
300
|
+
name: "usersDD",
|
|
301
|
+
requestId: "getUsers",
|
|
302
|
+
DropdownItem: _PIDItemComponent["default"],
|
|
303
|
+
responseFormatter: valuesResponseFormatter,
|
|
304
|
+
value: selectedValue,
|
|
305
|
+
keysMap: keysMap,
|
|
306
|
+
onChange: function onChange(value) {
|
|
307
|
+
return setSelectedValue(value);
|
|
308
|
+
},
|
|
309
|
+
LoaderComponent: /*#__PURE__*/_react["default"].createElement(PageLoader, {
|
|
310
|
+
className: "search-loader"
|
|
311
|
+
}),
|
|
312
|
+
NoDataComponent: NoDataComponent,
|
|
313
|
+
paginationType: "SERVER"
|
|
314
|
+
})));
|
|
315
|
+
}
|
|
316
|
+
};
|
|
185
317
|
var MultiSelect = exports.MultiSelect = {
|
|
186
318
|
args: _objectSpread(_objectSpread({}, Default.args), {}, {
|
|
187
319
|
multiSelect: true,
|
|
@@ -190,10 +322,10 @@ var MultiSelect = exports.MultiSelect = {
|
|
|
190
322
|
}),
|
|
191
323
|
argTypes: Default.argTypes,
|
|
192
324
|
render: function render(args) {
|
|
193
|
-
var _React$
|
|
194
|
-
_React$
|
|
195
|
-
selectedValues = _React$
|
|
196
|
-
setSelectedValues = _React$
|
|
325
|
+
var _React$useState5 = _react["default"].useState([]),
|
|
326
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
327
|
+
selectedValues = _React$useState6[0],
|
|
328
|
+
setSelectedValues = _React$useState6[1];
|
|
197
329
|
var ddRef = _react["default"].useRef(null);
|
|
198
330
|
var valuesResponseFormatter = function valuesResponseFormatter(response) {
|
|
199
331
|
return {
|
|
@@ -206,47 +338,8 @@ var MultiSelect = exports.MultiSelect = {
|
|
|
206
338
|
total: response.length ? 10 : 0
|
|
207
339
|
};
|
|
208
340
|
};
|
|
209
|
-
var
|
|
210
|
-
var
|
|
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;
|
|
341
|
+
var PageLoader = function PageLoader(_ref3) {
|
|
342
|
+
var className = _ref3.className;
|
|
250
343
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
251
344
|
className: "loading-spinner ".concat(className || '')
|
|
252
345
|
});
|
|
@@ -261,48 +354,21 @@ var MultiSelect = exports.MultiSelect = {
|
|
|
261
354
|
}
|
|
262
355
|
}, "No matching results found");
|
|
263
356
|
};
|
|
264
|
-
var
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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"));
|
|
357
|
+
var handleDelete = function handleDelete(value) {
|
|
358
|
+
setSelectedValues(selectedValues.filter(function (val) {
|
|
359
|
+
return val.id !== value;
|
|
360
|
+
}));
|
|
361
|
+
};
|
|
362
|
+
var onCheckboxChange = function onCheckboxChange(val) {
|
|
363
|
+
var item = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
364
|
+
var findItemWithId = arguments.length > 2 ? arguments[2] : undefined;
|
|
365
|
+
if (findItemWithId()) {
|
|
366
|
+
setSelectedValues(selectedValues.filter(function (val) {
|
|
367
|
+
return val.id !== item.id;
|
|
368
|
+
}));
|
|
369
|
+
} else {
|
|
370
|
+
setSelectedValues([].concat(_toConsumableArray(selectedValues), [item]));
|
|
371
|
+
}
|
|
306
372
|
};
|
|
307
373
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
308
374
|
style: {
|
|
@@ -314,13 +380,19 @@ var MultiSelect = exports.MultiSelect = {
|
|
|
314
380
|
className: "users-dd demo-dropdown",
|
|
315
381
|
name: "usersDD",
|
|
316
382
|
requestId: "getUsers",
|
|
317
|
-
|
|
318
|
-
|
|
383
|
+
selectedItems: selectedValues,
|
|
384
|
+
onDelete: handleDelete,
|
|
385
|
+
selectionKey: "name",
|
|
386
|
+
deleteKey: "id",
|
|
387
|
+
isDeletable: true,
|
|
388
|
+
showAllTags: false,
|
|
389
|
+
count: 3,
|
|
390
|
+
onChange: onCheckboxChange
|
|
391
|
+
// DropdownItem={ValueDropdownItem}
|
|
392
|
+
,
|
|
393
|
+
SelectionSummary: _SummarySelection["default"],
|
|
319
394
|
responseFormatter: valuesResponseFormatter,
|
|
320
395
|
value: selectedValues,
|
|
321
|
-
onChange: function onChange(value) {
|
|
322
|
-
return setSelectedValues(value);
|
|
323
|
-
},
|
|
324
396
|
LoaderComponent: /*#__PURE__*/_react["default"].createElement(PageLoader, {
|
|
325
397
|
className: "search-loader"
|
|
326
398
|
}),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.summary-tags-wrapper{display:flex;flex-wrap:wrap;align-items:center;gap:6px;width:calc(100% - 40px)}.summary-tags-wrapper .RCB-list{display:flex;flex-wrap:wrap;align-items:center;gap:6px}.summary-tags-wrapper .light-close-icon{font-size:12px;color:#6f6f8d;cursor:pointer;margin-left:6px}.merch-dd-icon{position:absolute;right:15px;top:16px}.merch-tag-box{display:flex;align-items:center;justify-content:center;border:1px solid #dae1e9;border-radius:4px;background-color:#ffffff;padding:5px 10px 5px 10px;font-size:12px;text-transform:capitalize}.new-summary-tag{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:120px}.summary-pill-tag{margin-right:6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:120px;border-radius:4px;border:1px solid #dae1e9;background-color:#ffffff;padding:5px 10px 5px 10px;font-size:12px;text-transform:capitalize;display:flex;align-items:center;justify-content:center;max-height:28px;min-width:36px;margin-left:6px}.custom-attribute{position:absolute;top:0;left:0;height:100%;display:flex;align-items:center}.filters-sub-header{color:#616e7a;font-size:14px;font-weight:600;line-height:19.1px;padding-top:20px}.view-more-link{color:#3E71F2;cursor:pointer;font-size:14px;text-decoration:none;padding-left:10px;white-space:nowrap;display:inline-flex;align-items:center;flex-shrink:0}.view-more-link:active{color:#0056b3}.RCB-inline-modal-btn{display:flex;justify-content:space-between}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.RCB-link{display:inline;cursor:pointer;font-family:inherit;transition:color 0.2s ease, text-decoration 0.2s ease;background:none;border:none;padding:0;margin:0;font-weight:
|
|
1
|
+
.RCB-link{display:inline;cursor:pointer;font-family:inherit;transition:color 0.2s ease, text-decoration 0.2s ease;background:none;border:none;padding:0;margin:0;font-weight:600}.RCB-link-disabled{cursor:not-allowed;opacity:0.6}.RCB-link-underline{text-decoration:underline}.RCB-link-none{text-decoration:none}.RCB-link-overline{text-decoration:overline}.RCB-link-line-through{text-decoration:line-through}.RCB-link-underline-on-hover:hover{text-decoration:underline}.RCB-link-external-icon{margin-left:4px;font-size:0.8em;line-height:1;display:inline}.RCB-link-small{font-size:12px;line-height:1.4}.RCB-link-medium{font-size:14px;line-height:1.5}.RCB-link-large{font-size:16px;line-height:1.6}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = PIDItemComponent;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _lazyLoadImage = _interopRequireDefault(require("../../core/lazyLoadImage"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
+
function PIDItemComponent(props) {
|
|
11
|
+
var DEFAULT_IMAGE = "https://libraries.unbxdapi.com/sdk-assets/defaultImage.svg";
|
|
12
|
+
|
|
13
|
+
// Desrructure props that are needed for client as well as server pagination types.
|
|
14
|
+
var _props$itemData = props.itemData,
|
|
15
|
+
itemData = _props$itemData === void 0 ? {} : _props$itemData,
|
|
16
|
+
_props$paginationType = props.paginationType,
|
|
17
|
+
clientPaginationType = _props$paginationType === void 0 ? "" : _props$paginationType,
|
|
18
|
+
_props$selectItem = props.selectItem,
|
|
19
|
+
clientSelectItem = _props$selectItem === void 0 ? function () {} : _props$selectItem,
|
|
20
|
+
_props$keysMap = props.keysMap,
|
|
21
|
+
clientKeysMap = _props$keysMap === void 0 ? {} : _props$keysMap,
|
|
22
|
+
_props$data = props.data,
|
|
23
|
+
data = _props$data === void 0 ? {} : _props$data,
|
|
24
|
+
_props$index = props.index,
|
|
25
|
+
index = _props$index === void 0 ? 0 : _props$index,
|
|
26
|
+
_props$style = props.style,
|
|
27
|
+
style = _props$style === void 0 ? {} : _props$style;
|
|
28
|
+
var _data$items = data.items,
|
|
29
|
+
items = _data$items === void 0 ? [] : _data$items,
|
|
30
|
+
_data$paginationType = data.paginationType,
|
|
31
|
+
serverPaginationType = _data$paginationType === void 0 ? "" : _data$paginationType,
|
|
32
|
+
_data$selectItem = data.selectItem,
|
|
33
|
+
serverSelectItem = _data$selectItem === void 0 ? function () {} : _data$selectItem,
|
|
34
|
+
_data$keysMap = data.keysMap,
|
|
35
|
+
serverKeysMap = _data$keysMap === void 0 ? {} : _data$keysMap;
|
|
36
|
+
|
|
37
|
+
// Determine the pagination type
|
|
38
|
+
var paginationType = clientPaginationType ? "CLIENT" : serverPaginationType;
|
|
39
|
+
|
|
40
|
+
// Update the item data and select item function based on the pagination type
|
|
41
|
+
var updatedItemData = paginationType !== 'SERVER' ? itemData : items[index] || {};
|
|
42
|
+
var updatedSelectItem = paginationType !== 'SERVER' ? clientSelectItem : serverSelectItem;
|
|
43
|
+
var updatedKeysMap = paginationType !== 'SERVER' ? clientKeysMap : serverKeysMap || {};
|
|
44
|
+
|
|
45
|
+
// Destructue the items value with its respective keys map provided in the props
|
|
46
|
+
var _updatedKeysMap$uniqu = updatedKeysMap.uniqueIdMap,
|
|
47
|
+
uniqueIdMap = _updatedKeysMap$uniqu === void 0 ? "uniqueId" : _updatedKeysMap$uniqu,
|
|
48
|
+
_updatedKeysMap$image = updatedKeysMap.imageUrlMap,
|
|
49
|
+
imageUrlMap = _updatedKeysMap$image === void 0 ? "imageUrl" : _updatedKeysMap$image,
|
|
50
|
+
_updatedKeysMap$title = updatedKeysMap.titleMap,
|
|
51
|
+
titleMap = _updatedKeysMap$title === void 0 ? "title" : _updatedKeysMap$title;
|
|
52
|
+
var title = updatedItemData[titleMap];
|
|
53
|
+
var imageUrl = Array.isArray(updatedItemData[imageUrlMap]) ? updatedItemData[imageUrlMap][0] : updatedItemData[imageUrlMap] ? updatedItemData[imageUrlMap] : DEFAULT_IMAGE;
|
|
54
|
+
var uniqueId = updatedItemData[uniqueIdMap];
|
|
55
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
56
|
+
className: "RCB-list-item RCB-pid-dd-item",
|
|
57
|
+
style: style,
|
|
58
|
+
onClick: function onClick() {
|
|
59
|
+
return updatedSelectItem(updatedItemData);
|
|
60
|
+
}
|
|
61
|
+
}, /*#__PURE__*/_react["default"].createElement(_lazyLoadImage["default"], {
|
|
62
|
+
id: uniqueId,
|
|
63
|
+
key: uniqueId,
|
|
64
|
+
className: "RCB-pid-product-image",
|
|
65
|
+
src: imageUrl
|
|
66
|
+
}), /*#__PURE__*/_react["default"].createElement("div", null, title && /*#__PURE__*/_react["default"].createElement("span", {
|
|
67
|
+
className: "RCB-title",
|
|
68
|
+
title: title
|
|
69
|
+
}, title), /*#__PURE__*/_react["default"].createElement("span", {
|
|
70
|
+
className: "RCB-pid-id show small-text text-transform-none clip-content"
|
|
71
|
+
}, " ID: ", uniqueId, " ")));
|
|
72
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = exports.WithoutTitle = exports.WithDefaultImage = exports.WithArrayImage = exports.MultipleProducts = exports.LongTitle = exports.Default = exports.CustomKeyMapping = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _PIDItemComponent = _interopRequireDefault(require("./PIDItemComponent"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
+
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); }
|
|
11
|
+
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
|
+
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
|
+
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; }
|
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
15
|
+
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); }
|
|
16
|
+
var meta = {
|
|
17
|
+
title: 'Components/PIDItemComponent',
|
|
18
|
+
component: _PIDItemComponent["default"],
|
|
19
|
+
parameters: {
|
|
20
|
+
layout: 'centered'
|
|
21
|
+
},
|
|
22
|
+
tags: ['autodocs'],
|
|
23
|
+
argTypes: {
|
|
24
|
+
props: {
|
|
25
|
+
description: 'Props object containing itemData and keysMap configuration'
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var _default = exports["default"] = meta;
|
|
30
|
+
var Default = exports.Default = {
|
|
31
|
+
args: {
|
|
32
|
+
props: {
|
|
33
|
+
itemData: {
|
|
34
|
+
uniqueId: 'PROD-12345',
|
|
35
|
+
imageUrl: 'https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=300',
|
|
36
|
+
title: 'Premium Wireless Headphones with Noise Cancellation'
|
|
37
|
+
},
|
|
38
|
+
keysMap: {
|
|
39
|
+
uniqueIdMap: 'uniqueId',
|
|
40
|
+
imageUrlMap: 'imageUrl',
|
|
41
|
+
titleMap: 'title'
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
var WithArrayImage = exports.WithArrayImage = {
|
|
47
|
+
args: {
|
|
48
|
+
props: {
|
|
49
|
+
itemData: {
|
|
50
|
+
uniqueId: 'PROD-67890',
|
|
51
|
+
imageUrl: ['https://images.unsplash.com/photo-1523275335684-37898b6baf30?w=300', 'https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=300'],
|
|
52
|
+
title: 'Smartwatch with Fitness Tracking'
|
|
53
|
+
},
|
|
54
|
+
keysMap: {
|
|
55
|
+
uniqueIdMap: 'uniqueId',
|
|
56
|
+
imageUrlMap: 'imageUrl',
|
|
57
|
+
titleMap: 'title'
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var WithDefaultImage = exports.WithDefaultImage = {
|
|
63
|
+
args: {
|
|
64
|
+
props: {
|
|
65
|
+
itemData: {
|
|
66
|
+
uniqueId: 'PROD-11111',
|
|
67
|
+
imageUrl: '',
|
|
68
|
+
title: 'Product Without Image'
|
|
69
|
+
},
|
|
70
|
+
keysMap: {
|
|
71
|
+
uniqueIdMap: 'uniqueId',
|
|
72
|
+
imageUrlMap: 'imageUrl',
|
|
73
|
+
titleMap: 'title'
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var WithoutTitle = exports.WithoutTitle = {
|
|
79
|
+
args: {
|
|
80
|
+
props: {
|
|
81
|
+
itemData: {
|
|
82
|
+
uniqueId: 'PROD-22222',
|
|
83
|
+
imageUrl: 'https://images.unsplash.com/photo-1526170375885-4d8ecf77b99f?w=300',
|
|
84
|
+
title: ''
|
|
85
|
+
},
|
|
86
|
+
keysMap: {
|
|
87
|
+
uniqueIdMap: 'uniqueId',
|
|
88
|
+
imageUrlMap: 'imageUrl',
|
|
89
|
+
titleMap: 'title'
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
var LongTitle = exports.LongTitle = {
|
|
95
|
+
args: {
|
|
96
|
+
props: {
|
|
97
|
+
itemData: {
|
|
98
|
+
uniqueId: 'PROD-99999',
|
|
99
|
+
imageUrl: 'https://images.unsplash.com/photo-1572635196237-14b3f281503f?w=300',
|
|
100
|
+
title: 'This is a very long product title that should be clipped or truncated to fit within the available space without breaking the layout'
|
|
101
|
+
},
|
|
102
|
+
keysMap: {
|
|
103
|
+
uniqueIdMap: 'uniqueId',
|
|
104
|
+
imageUrlMap: 'imageUrl',
|
|
105
|
+
titleMap: 'title'
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var CustomKeyMapping = exports.CustomKeyMapping = {
|
|
111
|
+
args: {
|
|
112
|
+
props: {
|
|
113
|
+
itemData: {
|
|
114
|
+
product_id: 'CUSTOM-001',
|
|
115
|
+
product_image: 'https://images.unsplash.com/photo-1560343090-f0409e92791a?w=300',
|
|
116
|
+
product_name: 'Laptop with Custom Key Mapping'
|
|
117
|
+
},
|
|
118
|
+
keysMap: {
|
|
119
|
+
uniqueIdMap: 'product_id',
|
|
120
|
+
imageUrlMap: 'product_image',
|
|
121
|
+
titleMap: 'product_name'
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var MultipleProducts = exports.MultipleProducts = {
|
|
127
|
+
render: function render() {
|
|
128
|
+
var products = [{
|
|
129
|
+
itemData: {
|
|
130
|
+
uniqueId: 'PROD-001',
|
|
131
|
+
imageUrl: 'https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=300',
|
|
132
|
+
title: 'Premium Wireless Headphones'
|
|
133
|
+
}
|
|
134
|
+
}, {
|
|
135
|
+
itemData: {
|
|
136
|
+
uniqueId: 'PROD-002',
|
|
137
|
+
imageUrl: 'https://images.unsplash.com/photo-1523275335684-37898b6baf30?w=300',
|
|
138
|
+
title: 'Smart Watch'
|
|
139
|
+
}
|
|
140
|
+
}, {
|
|
141
|
+
itemData: {
|
|
142
|
+
uniqueId: 'PROD-003',
|
|
143
|
+
imageUrl: 'https://images.unsplash.com/photo-1572635196237-14b3f281503f?w=300',
|
|
144
|
+
title: 'Professional Camera'
|
|
145
|
+
}
|
|
146
|
+
}, {
|
|
147
|
+
itemData: {
|
|
148
|
+
uniqueId: 'PROD-004',
|
|
149
|
+
imageUrl: 'https://images.unsplash.com/photo-1560343090-f0409e92791a?w=300',
|
|
150
|
+
title: 'Gaming Laptop'
|
|
151
|
+
}
|
|
152
|
+
}];
|
|
153
|
+
var keysMap = {
|
|
154
|
+
uniqueIdMap: 'uniqueId',
|
|
155
|
+
imageUrlMap: 'imageUrl',
|
|
156
|
+
titleMap: 'title'
|
|
157
|
+
};
|
|
158
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
159
|
+
style: {
|
|
160
|
+
display: 'flex',
|
|
161
|
+
flexDirection: 'column',
|
|
162
|
+
width: '300px',
|
|
163
|
+
border: '1px solid #ddd',
|
|
164
|
+
borderRadius: '8px'
|
|
165
|
+
}
|
|
166
|
+
}, products.map(function (product, index) {
|
|
167
|
+
return /*#__PURE__*/_react["default"].createElement(_PIDItemComponent["default"], {
|
|
168
|
+
key: index,
|
|
169
|
+
props: _objectSpread(_objectSpread({}, product), {}, {
|
|
170
|
+
keysMap: keysMap
|
|
171
|
+
})
|
|
172
|
+
});
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.RCB-pid-dd-item{display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;cursor:pointer;padding-bottom:8px;padding-left:13px;padding-top:8px;width:100%}.RCB-pid-dd-item .RCB-pid-product-image{height:35px;margin-right:5px;-o-object-fit:contain;object-fit:contain;width:30px}.RCB-pid-dd-item .RCB-title{font-size:12px;font-weight:600;-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.RCB-pid-dd-item .RCB-pid-id{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:240px;text-transform:none;font-size:12px}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _PIDItemComponent = _interopRequireDefault(require("./PIDItemComponent"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
+
var _default = exports["default"] = _PIDItemComponent["default"];
|