Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lendi-ui/accordion

Package Overview
Dependencies
Maintainers
26
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lendi-ui/accordion - npm Package Compare versions

Comparing version 3.3.0 to 3.3.1

dist/accordion.cjs.dev.js

12

CHANGELOG.md
## [3.2.1] 2020-3-25 [FUNNEL-1115](https://creditandfinance.atlassian.net/browse/FUNNEL-1115)
## 3.3.1
### Patch Changes
- fix publish issue
- Updated dependencies [undefined]
- @lendi-ui/icon@9.7.1
- @lendi-ui/color@5.1.1
- @lendi-ui/spacing@7.1.1
- @lendi-ui/typography@5.1.1
- @lendi-ui/utils@5.1.1
## 3.3.0

@@ -4,0 +16,0 @@

12

dist/accordion.cjs.d.ts

@@ -1,11 +0,1 @@

// are you seeing an error that a default export doesn't exist but your source file has a default export?
// you should run `yarn` or `yarn preconstruct dev` if preconstruct dev isn't in your postinstall hook
// curious why you need to?
// this file exists so that you can import from the entrypoint normally
// except that it points to your source file and you don't need to run build constantly
// which means we need to re-export all of the modules from your source file
// and since export * doesn't include default exports, we need to read your source file
// to check for a default export and re-export it if it exists
// it's not ideal, but it works pretty well ¯\_(ツ)_/¯
export * from "../src/index";
export * from "./declarations/src/index";

@@ -1,21 +0,7 @@

"use strict";
// this file might look strange and you might be wondering what it's for
// it's lets you import your source files by importing this entrypoint
// as you would import it if it was built with preconstruct build
// this file is slightly different to some others though
// it has a require hook which compiles your code with Babel
// this means that you don't have to set up @babel/register or anything like that
// but you can still require this module and it'll be compiled
'use strict';
const path = require("path");
// this bit of code imports the require hook and registers it
let unregister = require("../../../node_modules/@preconstruct/hook/dist/hook.cjs.js").___internalHook(path.resolve(__dirname, "../../.."), path.resolve(__dirname, ".."));
// this re-exports the source file
module.exports = require("../src/index.tsx");
// this unregisters the require hook so that any modules required after this one
// aren't compiled with the require hook in case you have some other require hook
// or something that should be used on other modules
unregister();
if (process.env.NODE_ENV === "production") {
module.exports = require("./accordion.cjs.prod.js");
} else {
module.exports = require("./accordion.cjs.dev.js");
}

@@ -1,15 +0,648 @@

// 👋 hey!!
// you might be reading this and seeing .esm in the filename
// and being confused why there is commonjs below this filename
// DON'T WORRY!
// this is intentional
// it's only commonjs with `preconstruct dev`
// when you run `preconstruct build`, it will be ESM
// why is it commonjs?
// we need to re-export every export from the source file
// but we can't do that with ESM without knowing what the exports are (because default exports aren't included in export/import *)
// and they could change after running `preconstruct dev` so we can't look at the file without forcing people to
// run preconstruct dev again which wouldn't be ideal
// this solution could change but for now, it's working
import { createContext, createElement, useContext, Fragment, Children, isValidElement, cloneElement } from 'react';
import cuid from 'cuid';
import styled, { css } from 'styled-components';
import { normalise, deriveSize } from '@lendi-ui/utils';
import { color, bg } from '@lendi-ui/color';
import { m, px, pl, mb, pb } from '@lendi-ui/spacing';
import { ArrowDropDown } from '@lendi-ui/icon';
import { body } from '@lendi-ui/typography';
module.exports = require("../src/index.tsx")
function _templateObject33() {
var data = _taggedTemplateLiteral(["\n display: block;\n "]);
_templateObject33 = function _templateObject33() {
return data;
};
return data;
}
function _templateObject32() {
var data = _taggedTemplateLiteral(["\n display: none;\n "]);
_templateObject32 = function _templateObject32() {
return data;
};
return data;
}
function _templateObject31() {
var data = _taggedTemplateLiteral(["\n transition: all 0.3s linear;\n ", ";\n ", ";\n"]);
_templateObject31 = function _templateObject31() {
return data;
};
return data;
}
function _templateObject30() {
var data = _taggedTemplateLiteral(["\n ", ";\n "]);
_templateObject30 = function _templateObject30() {
return data;
};
return data;
}
function _templateObject29() {
var data = _taggedTemplateLiteral(["\n ", ";\n ", ";\n "]);
_templateObject29 = function _templateObject29() {
return data;
};
return data;
}
function _templateObject28() {
var data = _taggedTemplateLiteral(["\n ", "\n"]);
_templateObject28 = function _templateObject28() {
return data;
};
return data;
}
function _templateObject27() {
var data = _taggedTemplateLiteral(["\n visibility: visible;\n "]);
_templateObject27 = function _templateObject27() {
return data;
};
return data;
}
function _templateObject26() {
var data = _taggedTemplateLiteral(["\n visibility: hidden;\n "]);
_templateObject26 = function _templateObject26() {
return data;
};
return data;
}
function _templateObject25() {
var data = _taggedTemplateLiteral(["\n transform: rotate(", ");\n "]);
_templateObject25 = function _templateObject25() {
return data;
};
return data;
}
function _templateObject24() {
var data = _taggedTemplateLiteral(["\n height: 20px;\n width: 20px;\n transform: rotate(-90deg);\n transition: transform 0.5s;\n\n ", "\n ", "\n"]);
_templateObject24 = function _templateObject24() {
return data;
};
return data;
}
function _templateObject23() {
var data = _taggedTemplateLiteral(["\n ", ";\n"]);
_templateObject23 = function _templateObject23() {
return data;
};
return data;
}
function _templateObject22() {
var data = _taggedTemplateLiteral(["\n ", "\n "]);
_templateObject22 = function _templateObject22() {
return data;
};
return data;
}
function _templateObject21() {
var data = _taggedTemplateLiteral(["\n ", "\n "]);
_templateObject21 = function _templateObject21() {
return data;
};
return data;
}
function _templateObject20() {
var data = _taggedTemplateLiteral(["\n background-color: transparent;\n "]);
_templateObject20 = function _templateObject20() {
return data;
};
return data;
}
function _templateObject19() {
var data = _taggedTemplateLiteral(["\n border-bottom: 1px solid ", ";\n\n &:first-child {\n border-top: 1px solid ", ";\n }\n "]);
_templateObject19 = function _templateObject19() {
return data;
};
return data;
}
function _templateObject18() {
var data = _taggedTemplateLiteral(["\n ", "\n\n &:last-child {\n ", "\n }\n\n border-bottom: 1px solid ", ";\n "]);
_templateObject18 = function _templateObject18() {
return data;
};
return data;
}
function _templateObject17() {
var data = _taggedTemplateLiteral(["\n ", "\n\n &:last-child {\n ", "\n }\n\n ", " {\n border-color: ", ";\n }\n "]);
_templateObject17 = function _templateObject17() {
return data;
};
return data;
}
function _templateObject16() {
var data = _taggedTemplateLiteral(["\n ", "\n\n ", "\n"]);
_templateObject16 = function _templateObject16() {
return data;
};
return data;
}
function _templateObject15() {
var data = _taggedTemplateLiteral(["\n ", ";\n"]);
_templateObject15 = function _templateObject15() {
return data;
};
return data;
}
function _templateObject14() {
var data = _taggedTemplateLiteral(["\n text-transform: uppercase;\n ", "\n "]);
_templateObject14 = function _templateObject14() {
return data;
};
return data;
}
function _templateObject13() {
var data = _taggedTemplateLiteral(["\n font-weight: normal;\n ", "\n "]);
_templateObject13 = function _templateObject13() {
return data;
};
return data;
}
function _templateObject12() {
var data = _taggedTemplateLiteral(["\n cursor: pointer;\n "]);
_templateObject12 = function _templateObject12() {
return data;
};
return data;
}
function _templateObject11() {
var data = _taggedTemplateLiteral(["\n cursor: not-allowed;\n opacity: 0.4;\n :hover,\n :active,\n :focus {\n pointer-events: inherit;\n cursor: not-allowed;\n box-shadow: none;\n transform: scale(1);\n }\n "]);
_templateObject11 = function _templateObject11() {
return data;
};
return data;
}
function _templateObject10() {
var data = _taggedTemplateLiteral(["\n ", "\n align-items: center;\n background-color: inherit;\n border: none;\n display: flex;\n font-size: ", ";\n font-weight: 600;\n height: 100%;\n text-align: left;\n width: 100%;\n\n ", "\n\n ", "\n"]);
_templateObject10 = function _templateObject10() {
return data;
};
return data;
}
function _templateObject9() {
var data = _taggedTemplateLiteral(["\n cursor: pointer;\n "]);
_templateObject9 = function _templateObject9() {
return data;
};
return data;
}
function _templateObject8() {
var data = _taggedTemplateLiteral(["\n cursor: not-allowed;\n opacity: 0.4;\n :hover,\n :active,\n :focus {\n pointer-events: inherit;\n cursor: not-allowed;\n box-shadow: none;\n transform: scale(1);\n }\n "]);
_templateObject8 = function _templateObject8() {
return data;
};
return data;
}
function _templateObject7() {
var data = _taggedTemplateLiteral(["\n ", "\n display: flex;\n\n ", "\n"]);
_templateObject7 = function _templateObject7() {
return data;
};
return data;
}
function _templateObject6() {
var data = _taggedTemplateLiteral(["\n word-wrap: break-word;\n ", ";\n"]);
_templateObject6 = function _templateObject6() {
return data;
};
return data;
}
function _templateObject5() {
var data = _taggedTemplateLiteral(["\n ", "\n "]);
_templateObject5 = function _templateObject5() {
return data;
};
return data;
}
function _templateObject4() {
var data = _taggedTemplateLiteral(["\n background-color: transparent;\n "]);
_templateObject4 = function _templateObject4() {
return data;
};
return data;
}
function _templateObject3() {
var data = _taggedTemplateLiteral(["\n border: 1px solid ", ";\n border-radius: 6px;\n\n ", " {\n ", "\n }\n "]);
_templateObject3 = function _templateObject3() {
return data;
};
return data;
}
function _templateObject2() {
var data = _taggedTemplateLiteral(["\n ", ";\n align-items: center;\n display: flex;\n height: 48px;\n justify-content: space-between;\n\n ", "\n\n ", "\n"]);
_templateObject2 = function _templateObject2() {
return data;
};
return data;
}
function _templateObject() {
var data = _taggedTemplateLiteral(["\n ", ";\n"]);
_templateObject = function _templateObject() {
return data;
};
return data;
}
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
var Wrapper = styled.div(_templateObject(), normalise);
var HeaderWrapper = styled.h3(_templateObject2(), m('nil'), (_ref) => {
var {
variant
} = _ref;
switch (variant) {
case 'emphasis':
return css(_templateObject3(), color('shade.100'), ArrowIcon, color('primary.500'));
case 'empty':
case 'primary':
default:
return null;
}
}, (_ref2) => {
var {
variant,
isTransparent
} = _ref2;
if (isTransparent) {
return css(_templateObject4());
}
switch (variant) {
case 'emphasis':
case 'empty':
return css(_templateObject5(), bg('shade.0'));
case 'primary':
default:
return null;
}
});
var HeaderContent = styled.span(_templateObject6(), px('xxxs'));
var HeaderAfterWrapper = styled.div(_templateObject7(), px('xs'), (_ref3) => {
var {
disabled
} = _ref3;
return disabled ? css(_templateObject8()) : css(_templateObject9());
});
var HeaderButtonWrapper = styled.button(_templateObject10(), px('xs'), deriveSize(1), (_ref4) => {
var {
disabled
} = _ref4;
return disabled ? css(_templateObject11()) : css(_templateObject12());
}, (_ref5) => {
var {
variant
} = _ref5;
switch (variant) {
case 'emphasis':
return css(_templateObject13(), body({
color: 'shade.700'
}));
case 'empty':
return null;
case 'primary':
default:
return css(_templateObject14(), body({
color: 'secondary.500'
}));
}
});
var HeaderContentWrapper = styled.div(_templateObject15(), pl('xs'));
var AccordionWrapper = styled.div(_templateObject16(), (_ref6) => {
var {
variant,
isSelected
} = _ref6;
switch (variant) {
case 'emphasis':
return css(_templateObject17(), mb('xxs'), mb('nil'), HeaderWrapper, isSelected ? color('primary.500') : null);
case 'empty':
return css(_templateObject18(), mb('sm'), mb('nil'), color('shade.100'));
case 'primary':
default:
return css(_templateObject19(), color('shade.100'), color('shade.100'));
}
}, (_ref7) => {
var {
variant,
isSelected,
isTransparent
} = _ref7;
if (isTransparent) {
return css(_templateObject20());
}
switch (variant) {
case 'empty':
return css(_templateObject21(), bg('shade.0'));
case 'primary':
case 'emphasis':
default:
return css(_templateObject22(), bg(isSelected ? 'shade.25' : 'shade.0'));
}
});
var IconWrapper = styled.div(_templateObject23(), px('sm'));
var ArrowIcon = styled(ArrowDropDown)(_templateObject24(), (_ref8) => {
var {
isRotate
} = _ref8;
return css(_templateObject25(), isRotate ? '0deg' : '-90deg');
}, (_ref9) => {
var {
isDisabled
} = _ref9;
return isDisabled ? css(_templateObject26()) : css(_templateObject27());
});
var PaddedItem = styled.div(_templateObject28(), (_ref10) => {
var {
variant
} = _ref10;
switch (variant) {
case 'empty':
return css(_templateObject29(), px('sm'), pb('sm'));
case 'emphasis':
case 'primary':
default:
return css(_templateObject30(), px('xxxs'));
}
});
var AccordionItemWrapper = styled.div(_templateObject31(), (_ref11) => {
var {
show
} = _ref11;
return !show ? css(_templateObject32()) : css(_templateObject33());
}, body());
var AccordionContext = /*#__PURE__*/createContext({
isOpen: false,
isDisabled: false,
isTransparent: false,
ariaId: '',
variant: 'primary'
});
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); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
var AccordionItem = (_ref) => {
var {
children
} = _ref,
otherAccordionItemProps = _objectWithoutProperties(_ref, ["children"]);
return /*#__PURE__*/createElement(AccordionContext.Consumer, null, (_ref2) => {
var {
isOpen,
ariaId,
variant
} = _ref2;
return /*#__PURE__*/createElement(AccordionItemWrapper, _extends({
role: "region",
"aria-labelledby": ariaId,
hidden: !isOpen,
"aria-hidden": !isOpen,
show: isOpen
}, otherAccordionItemProps), /*#__PURE__*/createElement(PaddedItem, {
variant: variant
}, children));
});
};
function _extends$1() { _extends$1 = 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$1.apply(this, arguments); }
function _objectWithoutProperties$1(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose$1(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose$1(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
var AccordionHeader = (_ref) => {
var {
children,
after,
onClick: _onClick = () => {}
} = _ref,
otherHeaderProps = _objectWithoutProperties$1(_ref, ["children", "after", "onClick"]);
return /*#__PURE__*/createElement(AccordionContext.Consumer, null, (_ref2) => {
var {
isOpen,
isDisabled,
isTransparent,
ariaId,
variant
} = _ref2;
var arrowIconColor = 'secondary.500';
if (['emphasis', 'empty'].indexOf(variant) !== -1) {
arrowIconColor = 'primary.500';
}
return /*#__PURE__*/createElement(HeaderWrapper, _extends$1({}, otherHeaderProps, {
isTransparent: isTransparent,
variant: variant
}), /*#__PURE__*/createElement(HeaderButtonWrapper, {
id: ariaId,
"aria-expanded": isOpen,
type: 'button',
onClick: e => {
if (isDisabled) {
return;
}
_onClick(e);
},
disabled: isDisabled,
variant: variant
}, /*#__PURE__*/createElement(ArrowIcon, {
isRotate: isOpen,
isDisabled: isDisabled,
color: arrowIconColor
}), /*#__PURE__*/createElement(HeaderContent, null, children)), after && /*#__PURE__*/createElement(HeaderAfterWrapper, {
disabled: isDisabled
}, after));
});
};
var AccordionGroupContext = /*#__PURE__*/createContext({
isOpen: false,
variant: 'primary'
});
function _extends$2() { _extends$2 = 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$2.apply(this, arguments); }
function _objectWithoutProperties$2(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose$2(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose$2(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function getChildrenOf(component, children) {
var foundChildren = Children.toArray(children).filter(child => /*#__PURE__*/isValidElement(child) && child.type === component && child);
return foundChildren || null;
}
var Accordion = props => {
var context = useContext(AccordionGroupContext);
var {
isOpen = false,
isDisabled = false,
isTransparent = false,
children
} = props,
otherAccordionProps = _objectWithoutProperties$2(props, ["isOpen", "isDisabled", "isTransparent", "children"]); // check isOpen on Accordion group and preference to be given to it otherwise take the indicidual accordions.
var isOpenValue = context.isOpen ? context.isOpen : isOpen;
var ariaId = cuid();
return /*#__PURE__*/createElement(AccordionContext.Provider, {
value: {
isOpen: isOpenValue,
variant: context.variant,
isDisabled,
isTransparent,
ariaId
}
}, /*#__PURE__*/createElement(AccordionWrapper, _extends$2({
isSelected: isOpenValue,
variant: context.variant,
isTransparent: isTransparent
}, otherAccordionProps), /*#__PURE__*/createElement(Fragment, null, getChildrenOf(Accordion.Header, children)), /*#__PURE__*/createElement(Fragment, null, getChildrenOf(Accordion.Content, children))));
};
Accordion.Header = AccordionHeader;
Accordion.Content = AccordionItem;
function _objectWithoutProperties$3(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose$3(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose$3(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function renderAccordions(child) {
if ( /*#__PURE__*/isValidElement(child)) {
return /*#__PURE__*/cloneElement(child);
}
return child;
}
var AccordionGroup = props => {
var {
children,
isOpen = false,
variant = 'primary'
} = props,
otherProps = _objectWithoutProperties$3(props, ["children", "isOpen", "variant"]);
return /*#__PURE__*/createElement(Wrapper, otherProps, /*#__PURE__*/createElement(AccordionGroupContext.Provider, {
value: {
isOpen,
variant
}
}, Children.map(children, renderAccordions)));
};
AccordionGroup.Accordion = Accordion;
export { Accordion, AccordionGroup };
{
"name": "@lendi-ui/accordion",
"version": "3.3.0",
"version": "3.3.1",
"license": "ISC",

@@ -26,9 +26,9 @@ "source": "src/index.tsx",

"dependencies": {
"@lendi-ui/color": "^5.1.0",
"@lendi-ui/icon": "^9.7.0",
"@lendi-ui/spacing": "^7.1.0",
"@lendi-ui/typography": "^5.1.0",
"@lendi-ui/utils": "^5.1.0",
"@lendi-ui/color": "^5.1.1",
"@lendi-ui/icon": "^9.7.1",
"@lendi-ui/spacing": "^7.1.1",
"@lendi-ui/typography": "^5.1.1",
"@lendi-ui/utils": "^5.1.1",
"cuid": "^2.1.8"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc