@coreui/react 5.0.0-alpha.2 → 5.0.0-alpha.3

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 CHANGED
@@ -46,7 +46,7 @@
46
46
 
47
47
  Several quick start options are available:
48
48
 
49
- - [Download the latest release](https://github.com/coreui/coreui-react/archive/v5.0.0-alpha.2.zip)
49
+ - [Download the latest release](https://github.com/coreui/coreui-react/archive/v5.0.0-alpha.3.zip)
50
50
  - Clone the repo: `git clone https://github.com/coreui/coreui-react.git`
51
51
  - Install with [npm](https://www.npmjs.com/): `npm install @coreui/react`
52
52
  - Install with [yarn](https://yarnpkg.com/): `yarn add @coreui/react`
@@ -10,6 +10,12 @@ export interface CDropdownToggleProps extends Omit<CButtonProps, 'type'> {
10
10
  * Create a custom toggler which accepts any content.
11
11
  */
12
12
  custom?: boolean;
13
+ /**
14
+ * If a dropdown `variant` is set to `nav-item` then render the toggler as a link instead of a button.
15
+ *
16
+ * @since v5.0.0-alpha.3
17
+ */
18
+ navLink?: boolean;
13
19
  /**
14
20
  * Similarly, create split button dropdowns with virtually the same markup as single button dropdowns, but with the addition of `.dropdown-toggle-split` className for proper spacing around the dropdown caret.
15
21
  */
package/dist/index.es.js CHANGED
@@ -5457,8 +5457,8 @@ CDropdownMenu.propTypes = {
5457
5457
  CDropdownMenu.displayName = 'CDropdownMenu';
5458
5458
 
5459
5459
  var CDropdownToggle = function (_a) {
5460
- var children = _a.children, _b = _a.caret, caret = _b === void 0 ? true : _b, custom = _a.custom, className = _a.className, split = _a.split, _c = _a.trigger, trigger = _c === void 0 ? 'click' : _c, rest = __rest(_a, ["children", "caret", "custom", "className", "split", "trigger"]);
5461
- var _d = useContext(CDropdownContext), dropdownToggleRef = _d.dropdownToggleRef, visible = _d.visible, setVisible = _d.setVisible;
5460
+ var children = _a.children, _b = _a.caret, caret = _b === void 0 ? true : _b, custom = _a.custom, className = _a.className, _c = _a.navLink, navLink = _c === void 0 ? true : _c, split = _a.split, _d = _a.trigger, trigger = _d === void 0 ? 'click' : _d, rest = __rest(_a, ["children", "caret", "custom", "className", "navLink", "split", "trigger"]);
5461
+ var _e = useContext(CDropdownContext), dropdownToggleRef = _e.dropdownToggleRef, variant = _e.variant, visible = _e.visible, setVisible = _e.setVisible;
5462
5462
  var triggers = __assign(__assign({}, ((trigger === 'click' || trigger.includes('click')) && {
5463
5463
  onClick: function (event) {
5464
5464
  event.preventDefault();
@@ -5469,6 +5469,7 @@ var CDropdownToggle = function (_a) {
5469
5469
  onBlur: function () { return setVisible(false); },
5470
5470
  }));
5471
5471
  var togglerProps = __assign({ className: classNames({
5472
+ 'nav-link': variant === 'nav-item' && navLink,
5472
5473
  'dropdown-toggle': caret,
5473
5474
  'dropdown-toggle-split': split,
5474
5475
  show: visible,
@@ -5477,6 +5478,9 @@ var CDropdownToggle = function (_a) {
5477
5478
  if (custom && React.isValidElement(children)) {
5478
5479
  return (React.createElement(React.Fragment, null, React.cloneElement(children, __assign(__assign({ 'aria-expanded': visible }, (!rest.disabled && __assign({}, triggers))), { ref: dropdownToggleRef }))));
5479
5480
  }
5481
+ if (variant === 'nav-item' && navLink) {
5482
+ return (React.createElement("a", __assign({ href: "#" }, togglerProps, { role: "button", ref: dropdownToggleRef }), children));
5483
+ }
5480
5484
  return (React.createElement(CButton, __assign({}, togglerProps, { tabIndex: 0 }, rest, { ref: dropdownToggleRef }),
5481
5485
  children,
5482
5486
  split && React.createElement("span", { className: "visually-hidden" }, "Toggle Dropdown")));