@convertkit/design
Advanced tools
Comparing version 0.0.18-beta.4 to 0.0.18-beta.5
@@ -7,3 +7,11 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
import React from "react"; | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } | ||
function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
import React, { useState } from "react"; | ||
import Button from "../buttons"; | ||
@@ -17,2 +25,22 @@ | ||
function usePopover() { | ||
var _useState = useState(false), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
active = _useState2[0], | ||
setActive = _useState2[1]; | ||
return { | ||
active: active, | ||
show: function show() { | ||
return setActive(true); | ||
}, | ||
hide: function hide() { | ||
return setActive(false); | ||
}, | ||
toggle: function toggle() { | ||
return setActive(!active); | ||
} | ||
}; | ||
} | ||
function PopoverButton(_ref, ref) { | ||
@@ -36,8 +64,13 @@ var children = _ref.children, | ||
var label = _ref3.label, | ||
props = _objectWithoutProperties(_ref3, ["label"]); | ||
providedPopover = _ref3.popover, | ||
props = _objectWithoutProperties(_ref3, ["label", "popover"]); | ||
var internalPopover = usePopover(); | ||
var popover = providedPopover || internalPopover; | ||
var children = React.Children.toArray(props.children); | ||
var button = children.find(byType(PopoverButton)); | ||
var content = children.find(byType(PopoverContent)); | ||
return React.createElement(React.Fragment, null, button, React.createElement("div", { | ||
return React.createElement(React.Fragment, null, React.cloneElement(button, { | ||
onClick: toggle | ||
}), popover.active && React.createElement("div", { | ||
"data-testid": "popover-content" | ||
@@ -44,0 +77,0 @@ }, content)); |
{ | ||
"name": "@convertkit/design", | ||
"version": "0.0.18-beta.4", | ||
"version": "0.0.18-beta.5", | ||
"description": "Design System for ConvertKit", | ||
@@ -56,2 +56,8 @@ "main": "index.js", | ||
"/badge/index.js": "/badge/index.js", | ||
"/icon/icons.js": "/icon/icons.js", | ||
"/icon/index.js": "/icon/index.js", | ||
"/icon/library.js": "/icon/library.js", | ||
"/card/card.js": "/card/card.js", | ||
"/card/index.js": "/card/index.js", | ||
"/card/cards.js": "/card/cards.js", | ||
"/buttons/button-group.js": "/buttons/button-group.js", | ||
@@ -61,10 +67,4 @@ "/buttons/button.js": "/buttons/button.js", | ||
"/buttons/index.js": "/buttons/index.js", | ||
"/card/card.js": "/card/card.js", | ||
"/card/cards.js": "/card/cards.js", | ||
"/card/index.js": "/card/index.js", | ||
"/icon/icons.js": "/icon/icons.js", | ||
"/icon/index.js": "/icon/index.js", | ||
"/icon/library.js": "/icon/library.js", | ||
"/jest-mocks/popover-mock.js": "/jest-mocks/popover-mock.js", | ||
"/jest-mocks/index.js": "/jest-mocks/index.js", | ||
"/jest-mocks/popover-mock.js": "/jest-mocks/popover-mock.js", | ||
"/modals/action.js": "/modals/action.js", | ||
@@ -75,7 +75,7 @@ "/modals/confirm-modal.js": "/modals/confirm-modal.js", | ||
"/modals/modal.js": "/modals/modal.js", | ||
"/note/index.js": "/note/index.js", | ||
"/popover/index.js": "/popover/index.js", | ||
"/popover/popover.js": "/popover/popover.js", | ||
"/note/index.js": "/note/index.js", | ||
"/select-menu/index.js": "/select-menu/index.js", | ||
"/utils/partition.js": "/utils/partition.js", | ||
"/select-menu/index.js": "/select-menu/index.js", | ||
"/filter/add-filter.js": "/filter/add-filter.js", | ||
@@ -85,9 +85,9 @@ "/filter/edit-filter.js": "/filter/edit-filter.js", | ||
"/filter/filter-type-context.js": "/filter/filter-type-context.js", | ||
"/filter/index.js": "/filter/index.js", | ||
"/filter/filter.js": "/filter/filter.js", | ||
"/filter/index.js": "/filter/index.js", | ||
"/filter/types/all-subscribers.js": "/filter/types/all-subscribers.js", | ||
"/filter/types/cold-subscribers.js": "/filter/types/cold-subscribers.js", | ||
"/filter/types/custom-field.js": "/filter/types/custom-field.js", | ||
"/filter/types/first-name.js": "/filter/types/first-name.js", | ||
"/filter/types/email-address.js": "/filter/types/email-address.js", | ||
"/filter/types/first-name.js": "/filter/types/first-name.js", | ||
"/filter/types/index.js": "/filter/types/index.js", | ||
@@ -94,0 +94,0 @@ "/filter/types/location.js": "/filter/types/location.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
436731
19924