@unbxd-ui/unbxd-react-components 0.3.0 → 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/Button/Button.js +4 -2
- package/components/Button/Button.stories.js +16 -3
- package/components/Button/buttonTheme.css +1 -1
- 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/Link.js +139 -0
- package/components/Link/Link.stories.js +489 -0
- package/components/Link/index.js +28 -0
- package/components/Link/linkCore.css +1 -0
- package/components/Link/linkTheme.css +1 -0
- 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 +13 -10
- package/components/index.js +49 -10
- package/components/theme.css +2 -2
- package/components/theme.scss +3 -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}
|
|
@@ -0,0 +1,139 @@
|
|
|
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.LinkTarget = exports.LinkSize = exports.LinkAppearance = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _excluded = ["children", "className", "disabled", "appearance", "size", "onClick", "href", "target", "textDecoration", "underlineOnHover", "external", "data-qa-id"];
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
|
+
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); }
|
|
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; }
|
|
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; }
|
|
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; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
17
|
+
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); }
|
|
18
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
19
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
20
|
+
/** LinkAppearance enum */
|
|
21
|
+
var LinkAppearance = exports.LinkAppearance = {
|
|
22
|
+
primary: "primary",
|
|
23
|
+
secondary: "secondary",
|
|
24
|
+
danger: "danger",
|
|
25
|
+
success: "success"
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** LinkSize enum */
|
|
29
|
+
var LinkSize = exports.LinkSize = {
|
|
30
|
+
SMALL: "small",
|
|
31
|
+
MEDIUM: "medium",
|
|
32
|
+
LARGE: "large"
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** LinkTarget enum */
|
|
36
|
+
var LinkTarget = exports.LinkTarget = {
|
|
37
|
+
SELF: "_self",
|
|
38
|
+
BLANK: "_blank",
|
|
39
|
+
PARENT: "_parent",
|
|
40
|
+
TOP: "_top"
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* Displays a Link component that looks and behaves like a traditional link
|
|
46
|
+
*/
|
|
47
|
+
var Link = function Link(props) {
|
|
48
|
+
var children = props.children,
|
|
49
|
+
className = props.className,
|
|
50
|
+
disabled = props.disabled,
|
|
51
|
+
appearance = props.appearance,
|
|
52
|
+
size = props.size,
|
|
53
|
+
onClick = props.onClick,
|
|
54
|
+
href = props.href,
|
|
55
|
+
target = props.target,
|
|
56
|
+
textDecoration = props.textDecoration,
|
|
57
|
+
underlineOnHover = props.underlineOnHover,
|
|
58
|
+
external = props.external,
|
|
59
|
+
dataQaId = props["data-qa-id"],
|
|
60
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
61
|
+
var linkClassName = ["RCB-link", "RCB-link-".concat(appearance), "RCB-link-".concat(size), "RCB-link-".concat(textDecoration), underlineOnHover && textDecoration !== "underline" && "RCB-link-underline-on-hover", disabled && "RCB-link-disabled", external && "RCB-link-external", className].filter(Boolean).join(" ");
|
|
62
|
+
var handleClick = function handleClick(e) {
|
|
63
|
+
if (disabled) {
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (onClick) {
|
|
68
|
+
onClick(e);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var linkProps = _objectSpread({
|
|
72
|
+
className: linkClassName,
|
|
73
|
+
onClick: handleClick
|
|
74
|
+
}, restProps);
|
|
75
|
+
|
|
76
|
+
// Always render as anchor tag for proper link appearance and semantics
|
|
77
|
+
// If no href provided, use href="#" and prevent default to handle as click handler
|
|
78
|
+
var linkHref = href || (onClick && !disabled ? "#" : undefined);
|
|
79
|
+
var handleLinkClick = function handleLinkClick(e) {
|
|
80
|
+
if (disabled) {
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// Prevent navigation for click handlers without href and execute onClick
|
|
85
|
+
if (!href && onClick) {
|
|
86
|
+
e.preventDefault();
|
|
87
|
+
onClick(e);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
return /*#__PURE__*/_react["default"].createElement("a", _extends({}, linkProps, {
|
|
91
|
+
href: disabled ? undefined : linkHref,
|
|
92
|
+
target: target,
|
|
93
|
+
rel: target === LinkTarget.BLANK ? "noopener noreferrer" : undefined,
|
|
94
|
+
onClick: handleLinkClick,
|
|
95
|
+
role: !href && onClick ? "button" : undefined,
|
|
96
|
+
tabIndex: disabled ? -1 : undefined,
|
|
97
|
+
"data-qa-id": dataQaId
|
|
98
|
+
}), children, external && target === LinkTarget.BLANK && /*#__PURE__*/_react["default"].createElement("span", {
|
|
99
|
+
className: "RCB-link-external-icon",
|
|
100
|
+
"aria-hidden": "true"
|
|
101
|
+
}, " \u2197"));
|
|
102
|
+
};
|
|
103
|
+
Link.propTypes = {
|
|
104
|
+
/** Add any additional classes to Link component */
|
|
105
|
+
className: _propTypes["default"].string,
|
|
106
|
+
/** Boolean indicating whether the link should render as disabled */
|
|
107
|
+
disabled: _propTypes["default"].bool,
|
|
108
|
+
/** Text decoration style for the link */
|
|
109
|
+
textDecoration: _propTypes["default"].oneOf(["underline", "none", "overline", "line-through"]),
|
|
110
|
+
/** Boolean indicating whether to show underline on hover (only if not already underlined) */
|
|
111
|
+
underlineOnHover: _propTypes["default"].bool,
|
|
112
|
+
/** Boolean indicating whether this is an external link (adds external icon) */
|
|
113
|
+
external: _propTypes["default"].bool,
|
|
114
|
+
/** URL for the link */
|
|
115
|
+
href: _propTypes["default"].string,
|
|
116
|
+
/** QA automation identifier */
|
|
117
|
+
"data-qa-id": _propTypes["default"].string,
|
|
118
|
+
/** Target for the link when href is provided */
|
|
119
|
+
target: _propTypes["default"].oneOf(Object.values(LinkTarget)),
|
|
120
|
+
appearance: _propTypes["default"].oneOf(Object.values(LinkAppearance)),
|
|
121
|
+
/** String indicating the size of the Link */
|
|
122
|
+
size: _propTypes["default"].oneOf(Object.values(LinkSize)),
|
|
123
|
+
/** Link onClick handler */
|
|
124
|
+
onClick: _propTypes["default"].func,
|
|
125
|
+
/** Link content */
|
|
126
|
+
children: _propTypes["default"].node.isRequired
|
|
127
|
+
};
|
|
128
|
+
Link.defaultProps = {
|
|
129
|
+
onClick: undefined,
|
|
130
|
+
appearance: LinkAppearance.primary,
|
|
131
|
+
size: LinkSize.MEDIUM,
|
|
132
|
+
className: "",
|
|
133
|
+
disabled: false,
|
|
134
|
+
textDecoration: "none",
|
|
135
|
+
underlineOnHover: false,
|
|
136
|
+
external: false,
|
|
137
|
+
target: LinkTarget.SELF
|
|
138
|
+
};
|
|
139
|
+
var _default = exports["default"] = Link;
|