code7-leia 0.1.5 → 0.1.6

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.
@@ -4,15 +4,117 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
6
 
7
- var React = _interopDefault(require('react'));
7
+ var React = require('react');
8
+ var React__default = _interopDefault(React);
9
+ var reactRouterDom = require('react-router-dom');
10
+ var PropTypes = _interopDefault(require('prop-types'));
11
+ var cc = _interopDefault(require('classcat'));
12
+ var styled = _interopDefault(require('styled-components'));
13
+
14
+ function _objectWithoutPropertiesLoose(source, excluded) {
15
+ if (source == null) return {};
16
+ var target = {};
17
+ var sourceKeys = Object.keys(source);
18
+ var key, i;
19
+ for (i = 0; i < sourceKeys.length; i++) {
20
+ key = sourceKeys[i];
21
+ if (excluded.indexOf(key) >= 0) continue;
22
+ target[key] = source[key];
23
+ }
24
+ return target;
25
+ }
26
+ function _taggedTemplateLiteralLoose(strings, raw) {
27
+ if (!raw) {
28
+ raw = strings.slice(0);
29
+ }
30
+ strings.raw = raw;
31
+ return strings;
32
+ }
33
+
34
+ var _templateObject, _templateObject2;
35
+ var TabsPane = /*#__PURE__*/styled.ul(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: max-content;\n display: flex;\n align-items: center;\n border-bottom: 1px solid var(--neutral-1);\n"])));
36
+ var Tab = /*#__PURE__*/styled.li(_templateObject2 || (_templateObject2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n padding: 12px;\n color: var(--neutral-3);\n font-size: 0.875rem;\n font-weight: normal;\n position: relative;\n cursor: pointer;\n\n svg {\n fill: var(--neutral-3) !important;\n margin-left: 8px;\n }\n\n &.active {\n color: var(--primary-700-light);\n\n svg {\n fill: var(--primary-700-light) !important;\n }\n\n ::after {\n content: '';\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n height: 2px;\n background-color: var(--primary-700-light);\n }\n }\n\n &:not(:last-child) {\n margin-right: 8px;\n }\n"])));
37
+
38
+ var _excluded = ["active", "children"],
39
+ _excluded2 = ["children", "value", "onChange"];
40
+ var Tab$1 = function Tab$1(_ref) {
41
+ var active = _ref.active,
42
+ children = _ref.children,
43
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
44
+ return React__default.createElement(Tab, Object.assign({
45
+ className: cc({
46
+ active: active
47
+ })
48
+ }, rest), children);
49
+ };
50
+ Tab$1.propTypes = {
51
+ children: /*#__PURE__*/PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.node]).isRequired,
52
+ onChange: PropTypes.func,
53
+ value: PropTypes.string,
54
+ active: PropTypes.bool
55
+ };
56
+ Tab$1.defaultProps = {
57
+ onChange: function onChange() {},
58
+ value: '',
59
+ active: false
60
+ };
61
+ var Tabs = function Tabs(_ref2) {
62
+ var childrenProp = _ref2.children,
63
+ value = _ref2.value,
64
+ onChange = _ref2.onChange,
65
+ rest = _objectWithoutPropertiesLoose(_ref2, _excluded2);
66
+ var children = React__default.Children.map(childrenProp, function (child) {
67
+ var _child$props, _child$props3;
68
+ if (!React__default.isValidElement(child)) {
69
+ return null;
70
+ }
71
+ if (Array.isArray((_child$props = child.props) == null ? void 0 : _child$props.children)) {
72
+ var _child$props2;
73
+ return React__default.cloneElement(child, {
74
+ active: ((_child$props2 = child.props) == null ? void 0 : _child$props2.value) === value,
75
+ value: value,
76
+ onChange: onChange
77
+ });
78
+ }
79
+ return React__default.cloneElement(child, {
80
+ active: ((_child$props3 = child.props) == null ? void 0 : _child$props3.value) === value,
81
+ onClick: function onClick() {
82
+ var _child$props4;
83
+ return onChange((_child$props4 = child.props) == null ? void 0 : _child$props4.value);
84
+ }
85
+ });
86
+ });
87
+ return React__default.createElement(TabsPane, Object.assign({}, rest), children);
88
+ };
89
+ Tabs.propTypes = {
90
+ children: PropTypes.node.isRequired,
91
+ value: /*#__PURE__*/PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
92
+ onChange: PropTypes.func.isRequired
93
+ };
8
94
 
9
95
  var Leia = function Leia(props) {
96
+ var match = reactRouterDom.useRouteMatch();
97
+ var _useLocation = reactRouterDom.useLocation(),
98
+ pathname = _useLocation.pathname;
99
+ var history = reactRouterDom.useHistory();
10
100
  console.log('Props', props);
11
- return React.createElement("div", null, "Aqui \xE9 a Leia, seu id \xE9 ", props.id);
101
+ var activeTab = React.useMemo(function () {
102
+ return pathname.split('/')[5] || 'files';
103
+ }, [pathname]);
104
+ return React__default.createElement(Tabs, {
105
+ value: activeTab,
106
+ onChange: function onChange(value) {
107
+ return history.push(match.url + "/" + value);
108
+ }
109
+ }, React__default.createElement(Tab$1, {
110
+ value: "files"
111
+ }, "Files"), React__default.createElement(Tab$1, {
112
+ value: "test"
113
+ }, "Test"));
12
114
  };
13
115
 
14
116
  function Code7(props) {
15
- return React.createElement(Leia, Object.assign({}, props));
117
+ return React__default.createElement(Leia, Object.assign({}, props));
16
118
  }
17
119
 
18
120
  exports.Code7 = Code7;
@@ -1 +1 @@
1
- {"version":3,"file":"code7-leia.cjs.development.js","sources":["../src/Leia.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { Props } from './index';\n\nexport const Leia = (props: Props) => {\n\n console.log('Props', props);\n\n return (\n <div>Aqui é a Leia, seu id é {props.id}</div>\n );\n};","import type { PropsWithChildren } from 'react';\nimport React from 'react';\nimport { Leia } from './Leia';\n\nexport type Props = PropsWithChildren<{\n id: string;\n}>;\n\nexport function Code7(props: Props) {\n return <Leia {...props} />;\n}"],"names":["Leia","props","console","log","React","id","Code7"],"mappings":";;;;;;;;AAIO,IAAMA,IAAI,GAAG,SAAPA,IAAIA,CAAIC,KAAY;EAE/BC,OAAO,CAACC,GAAG,CAAC,OAAO,EAAEF,KAAK,CAAC;EAE3B,OACEG,mEAA8BH,KAAK,CAACI,EAAE,CAAO;AAEjD,CAAC;;SCHeC,KAAKA,CAACL,KAAY;EAChC,OAAOG,oBAACJ,IAAI,oBAAKC,KAAK,EAAI;AAC5B;;;;"}
1
+ {"version":3,"file":"code7-leia.cjs.development.js","sources":["../src/components/Tabs/styles.tsx","../src/components/Tabs/index.tsx","../src/Leia.tsx","../src/index.tsx"],"sourcesContent":["import styled from 'styled-components';\nimport { ReactNode } from 'react';\n\ninterface TabProps {\n children: ReactNode;\n}\n\ninterface OptionProps {\n children: ReactNode;\n onClick: () => void;\n}\n\nexport const TabsPane = styled.ul`\n width: max-content;\n display: flex;\n align-items: center;\n border-bottom: 1px solid var(--neutral-1);\n`;\n\nexport const Tab = styled.li<TabProps>`\n padding: 12px;\n color: var(--neutral-3);\n font-size: 0.875rem;\n font-weight: normal;\n position: relative;\n cursor: pointer;\n\n svg {\n fill: var(--neutral-3) !important;\n margin-left: 8px;\n }\n\n &.active {\n color: var(--primary-700-light);\n\n svg {\n fill: var(--primary-700-light) !important;\n }\n\n ::after {\n content: '';\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n height: 2px;\n background-color: var(--primary-700-light);\n }\n }\n\n &:not(:last-child) {\n margin-right: 8px;\n }\n`;\n\nexport const DropdownContainer = styled.div`\n position: absolute;\n left: 0px;\n top: 40px;\n display: flex;\n flex-direction: column;\n\n background: #ffffff;\n\n border: 1px solid #979aa5;\n box-sizing: border-box;\n box-shadow: 0px 6px 12px -6px rgba(24, 39, 75, 0.12),\n 0px 8px 24px -4px rgba(24, 39, 75, 0.08);\n border-radius: 4px;\n padding: 8px;\n z-index: 2;\n`;\n\nexport const Option = styled.div<OptionProps>`\n padding: 8px;\n font-size: 14px;\n border-radius: 4px;\n cursor: pointer;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n\n &:hover {\n background-color: var(--primary-800-light);\n color: white;\n }\n`;\n","import React, { ReactNode } from 'react';\nimport PropTypes from 'prop-types';\nimport cc from 'classcat';\n\nimport * as S from './styles';\n\ninterface TabProps {\n children: ReactNode;\n active?: boolean;\n}\n\ninterface ITabsProps {\n children: ReactNode;\n value: string | number;\n onChange: (e: any) => void;\n active?: boolean;\n}\n\nexport const Tab = ({ active, children, ...rest }: TabProps) => {\n return (\n <S.Tab className={cc({ active })} {...rest}>\n {children}\n </S.Tab>\n );\n};\n\nTab.propTypes = {\n children: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.element,\n PropTypes.node,\n ]).isRequired,\n onChange: PropTypes.func,\n value: PropTypes.string,\n active: PropTypes.bool,\n};\n\nTab.defaultProps = {\n onChange: () => {},\n value: '',\n active: false,\n};\n\nexport const Tabs = ({ children: childrenProp, value, onChange, ...rest }: ITabsProps) => {\n const children = React.Children.map(childrenProp, (child) => {\n if (!React.isValidElement(child)) {\n return null;\n }\n\n if (Array.isArray(child.props?.children)) {\n return React.cloneElement(child as React.ReactElement<any>, {\n active: child.props?.value === value,\n value,\n onChange,\n });\n }\n\n return React.cloneElement(child as React.ReactElement<any>, {\n active: child.props?.value === value,\n onClick: () => onChange(child.props?.value),\n });\n });\n\n return <S.TabsPane {...rest}>{children}</S.TabsPane>;\n};\n\nTabs.propTypes = {\n children: PropTypes.node.isRequired,\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,\n onChange: PropTypes.func.isRequired,\n};\n","import React, { useMemo } from 'react';\n\nimport { useLocation, useRouteMatch, useHistory } from 'react-router-dom';\n\nimport type { Props } from './index';\nimport { Tab, Tabs } from './components/Tabs'\n\nexport const Leia = (props: Props) => {\n const match = useRouteMatch();\n const { pathname } = useLocation();\n const history = useHistory();\n\n console.log('Props', props);\n\n const activeTab = useMemo(() => {\n return pathname.split('/')[5] || 'files';\n }, [pathname]);\n\n return (\n <Tabs\n value={activeTab}\n onChange={(value) => history.push(`${match.url}/${value}`)}\n >\n <Tab value=\"files\">Files</Tab>\n <Tab value=\"test\">Test</Tab>\n </Tabs>\n );\n};","import type { PropsWithChildren } from 'react';\nimport React from 'react';\nimport { Leia } from './Leia';\n\nexport type Props = PropsWithChildren<{\n id: string;\n activeTab: string;\n}>;\n\nexport function Code7(props: Props) {\n return <Leia {...props} />;\n}"],"names":["TabsPane","styled","ul","_templateObject","_taggedTemplateLiteralLoose","Tab","li","_templateObject2","_ref","active","children","rest","_objectWithoutPropertiesLoose","_excluded","React","S","className","cc","propTypes","PropTypes","oneOfType","string","element","node","isRequired","onChange","func","value","bool","defaultProps","Tabs","_ref2","childrenProp","_excluded2","Children","map","child","isValidElement","Array","isArray","_child$props","props","_child$props2","cloneElement","_child$props3","onClick","_child$props4","number","Leia","match","useRouteMatch","_useLocation","useLocation","pathname","history","useHistory","console","log","activeTab","useMemo","split","push","url","Code7"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYO,IAAMA,QAAQ,gBAAGC,MAAM,CAACC,EAAE,CAAAC,eAAA,KAAAA,eAAA,gBAAAC,2BAAA,yHAKhC;AAEM,IAAMC,GAAG,gBAAGJ,MAAM,CAACK,EAAE,CAAAC,gBAAA,KAAAA,gBAAA,gBAAAH,2BAAA,8lBAkC3B;;;;ACrDD,AAkBO,IAAMC,KAAG,GAAG,SAANA,KAAGA,CAAAG,IAAA;MAAMC,MAAM,GAAAD,IAAA,CAANC,MAAM;IAAEC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IAAKC,IAAI,GAAAC,6BAAA,CAAAJ,IAAA,EAAAK,SAAA;EAC7C,OACEC,6BAACC,GAAK;IAACC,SAAS,EAAEC,EAAE,CAAC;MAAER,MAAM,EAANA;KAAQ;KAAOE,IAAI,GACvCD,QAAQ,CACH;AAEZ,CAAC;AAEDL,KAAG,CAACa,SAAS,GAAG;EACdR,QAAQ,eAAES,SAAS,CAACC,SAAS,CAAC,CAC5BD,SAAS,CAACE,MAAM,EAChBF,SAAS,CAACG,OAAO,EACjBH,SAAS,CAACI,IAAI,CACf,CAAC,CAACC,UAAU;EACbC,QAAQ,EAAEN,SAAS,CAACO,IAAI;EACxBC,KAAK,EAAER,SAAS,CAACE,MAAM;EACvBZ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&&"object"==typeof e&&"default"in e?e.default:e,r=function(e){return console.log("Props",e),t.createElement("div",null,"Aqui é a Leia, seu id é ",e.id)};exports.Code7=function(e){return t.createElement(r,Object.assign({},e))};
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n,r,t=require("react"),i=e(t),a=require("react-router-dom"),l=e(require("prop-types")),o=e(require("classcat")),u=e(require("styled-components"));function c(e,n){if(null==e)return{};var r,t,i={},a=Object.keys(e);for(t=0;t<a.length;t++)n.indexOf(r=a[t])>=0||(i[r]=e[r]);return i}function s(e,n){return n||(n=e.slice(0)),e.raw=n,e}var p=u.ul(n||(n=s(["\n width: max-content;\n display: flex;\n align-items: center;\n border-bottom: 1px solid var(--neutral-1);\n"]))),v=u.li(r||(r=s(["\n padding: 12px;\n color: var(--neutral-3);\n font-size: 0.875rem;\n font-weight: normal;\n position: relative;\n cursor: pointer;\n\n svg {\n fill: var(--neutral-3) !important;\n margin-left: 8px;\n }\n\n &.active {\n color: var(--primary-700-light);\n\n svg {\n fill: var(--primary-700-light) !important;\n }\n\n ::after {\n content: '';\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n height: 2px;\n background-color: var(--primary-700-light);\n }\n }\n\n &:not(:last-child) {\n margin-right: 8px;\n }\n"]))),d=["active","children"],f=["children","value","onChange"],m=function(e){var n=e.active,r=e.children,t=c(e,d);return i.createElement(v,Object.assign({className:o({active:n})},t),r)};m.propTypes={children:l.oneOfType([l.string,l.element,l.node]).isRequired,onChange:l.func,value:l.string,active:l.bool},m.defaultProps={onChange:function(){},value:"",active:!1};var h=function(e){var n=e.children,r=e.value,t=e.onChange,a=c(e,f),l=i.Children.map(n,(function(e){var n,a,l;return i.isValidElement(e)?Array.isArray(null==(n=e.props)?void 0:n.children)?i.cloneElement(e,{active:(null==(l=e.props)?void 0:l.value)===r,value:r,onChange:t}):i.cloneElement(e,{active:(null==(a=e.props)?void 0:a.value)===r,onClick:function(){var n;return t(null==(n=e.props)?void 0:n.value)}}):null}));return i.createElement(p,Object.assign({},a),l)};h.propTypes={children:l.node.isRequired,value:l.oneOfType([l.string,l.number]).isRequired,onChange:l.func.isRequired};var g=function(e){var n=a.useRouteMatch(),r=a.useLocation().pathname,l=a.useHistory();console.log("Props",e);var o=t.useMemo((function(){return r.split("/")[5]||"files"}),[r]);return i.createElement(h,{value:o,onChange:function(e){return l.push(n.url+"/"+e)}},i.createElement(m,{value:"files"},"Files"),i.createElement(m,{value:"test"},"Test"))};exports.Code7=function(e){return i.createElement(g,Object.assign({},e))};
2
2
  //# sourceMappingURL=code7-leia.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"code7-leia.cjs.production.min.js","sources":["../src/Leia.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { Props } from './index';\n\nexport const Leia = (props: Props) => {\n\n console.log('Props', props);\n\n return (\n <div>Aqui é a Leia, seu id é {props.id}</div>\n );\n};","import type { PropsWithChildren } from 'react';\nimport React from 'react';\nimport { Leia } from './Leia';\n\nexport type Props = PropsWithChildren<{\n id: string;\n}>;\n\nexport function Code7(props: Props) {\n return <Leia {...props} />;\n}"],"names":["Leia","props","console","log","React","id"],"mappings":"gJAIaA,EAAO,SAACC,GAInB,OAFAC,QAAQC,IAAI,QAASF,GAGnBG,sDAA8BH,EAAMI,4BCDlBJ,GACpB,OAAOG,gBAACJ,mBAASC"}
1
+ {"version":3,"file":"code7-leia.cjs.production.min.js","sources":["../src/components/Tabs/styles.tsx","../src/components/Tabs/index.tsx","../src/Leia.tsx","../src/index.tsx"],"sourcesContent":["import styled from 'styled-components';\nimport { ReactNode } from 'react';\n\ninterface TabProps {\n children: ReactNode;\n}\n\ninterface OptionProps {\n children: ReactNode;\n onClick: () => void;\n}\n\nexport const TabsPane = styled.ul`\n width: max-content;\n display: flex;\n align-items: center;\n border-bottom: 1px solid var(--neutral-1);\n`;\n\nexport const Tab = styled.li<TabProps>`\n padding: 12px;\n color: var(--neutral-3);\n font-size: 0.875rem;\n font-weight: normal;\n position: relative;\n cursor: pointer;\n\n svg {\n fill: var(--neutral-3) !important;\n margin-left: 8px;\n }\n\n &.active {\n color: var(--primary-700-light);\n\n svg {\n fill: var(--primary-700-light) !important;\n }\n\n ::after {\n content: '';\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n height: 2px;\n background-color: var(--primary-700-light);\n }\n }\n\n &:not(:last-child) {\n margin-right: 8px;\n }\n`;\n\nexport const DropdownContainer = styled.div`\n position: absolute;\n left: 0px;\n top: 40px;\n display: flex;\n flex-direction: column;\n\n background: #ffffff;\n\n border: 1px solid #979aa5;\n box-sizing: border-box;\n box-shadow: 0px 6px 12px -6px rgba(24, 39, 75, 0.12),\n 0px 8px 24px -4px rgba(24, 39, 75, 0.08);\n border-radius: 4px;\n padding: 8px;\n z-index: 2;\n`;\n\nexport const Option = styled.div<OptionProps>`\n padding: 8px;\n font-size: 14px;\n border-radius: 4px;\n cursor: pointer;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n\n &:hover {\n background-color: var(--primary-800-light);\n color: white;\n }\n`;\n","import React, { ReactNode } from 'react';\nimport PropTypes from 'prop-types';\nimport cc from 'classcat';\n\nimport * as S from './styles';\n\ninterface TabProps {\n children: ReactNode;\n active?: boolean;\n}\n\ninterface ITabsProps {\n children: ReactNode;\n value: string | number;\n onChange: (e: any) => void;\n active?: boolean;\n}\n\nexport const Tab = ({ active, children, ...rest }: TabProps) => {\n return (\n <S.Tab className={cc({ active })} {...rest}>\n {children}\n </S.Tab>\n );\n};\n\nTab.propTypes = {\n children: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.element,\n PropTypes.node,\n ]).isRequired,\n onChange: PropTypes.func,\n value: PropTypes.string,\n active: PropTypes.bool,\n};\n\nTab.defaultProps = {\n onChange: () => {},\n value: '',\n active: false,\n};\n\nexport const Tabs = ({ children: childrenProp, value, onChange, ...rest }: ITabsProps) => {\n const children = React.Children.map(childrenProp, (child) => {\n if (!React.isValidElement(child)) {\n return null;\n }\n\n if (Array.isArray(child.props?.children)) {\n return React.cloneElement(child as React.ReactElement<any>, {\n active: child.props?.value === value,\n value,\n onChange,\n });\n }\n\n return React.cloneElement(child as React.ReactElement<any>, {\n active: child.props?.value === value,\n onClick: () => onChange(child.props?.value),\n });\n });\n\n return <S.TabsPane {...rest}>{children}</S.TabsPane>;\n};\n\nTabs.propTypes = {\n children: PropTypes.node.isRequired,\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,\n onChange: PropTypes.func.isRequired,\n};\n","import React, { useMemo } from 'react';\n\nimport { useLocation, useRouteMatch, useHistory } from 'react-router-dom';\n\nimport type { Props } from './index';\nimport { Tab, Tabs } from './components/Tabs'\n\nexport const Leia = (props: Props) => {\n const match = useRouteMatch();\n const { pathname } = useLocation();\n const history = useHistory();\n\n console.log('Props', props);\n\n const activeTab = useMemo(() => {\n return pathname.split('/')[5] || 'files';\n }, [pathname]);\n\n return (\n <Tabs\n value={activeTab}\n onChange={(value) => history.push(`${match.url}/${value}`)}\n >\n <Tab value=\"files\">Files</Tab>\n <Tab value=\"test\">Test</Tab>\n </Tabs>\n );\n};","import type { PropsWithChildren } from 'react';\nimport React from 'react';\nimport { Leia } from './Leia';\n\nexport type Props = PropsWithChildren<{\n id: string;\n activeTab: string;\n}>;\n\nexport function Code7(props: Props) {\n return <Leia {...props} />;\n}"],"names":["TabsPane","styled","ul","_templateObject","_taggedTemplateLiteralLoose","Tab","li","_templateObject2","_ref","active","children","rest","_objectWithoutPropertiesLoose","_excluded","React","S","className","cc","propTypes","PropTypes","oneOfType","string","element","node","isRequired","onChange","func","value","bool","defaultProps","Tabs","_ref2","childrenProp","_excluded2","Children","map","child","_child$props2","isValidElement","Array","isArray","_child$props","props","cloneElement","_child$props3","onClick","_child$props4","number","Leia","match","useRouteMatch","pathname","useLocation","history","useHistory","console","log","activeTab","useMemo","split","push","url"],"mappings":"udAYO,IAAMA,EAAWC,E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MO,EAAQC,kBACNC,EAAaC,gBAAbD,SACFE,EAAUC,eAEhBC,QAAQC,IAAI,QAASd,GAErB,IAAMe,EAAYC,WAAQ,WACxB,OAAOP,EAASQ,MAAM,KAAK,IAAM,UAChC,CAACR,IAEJ,OACErC,gBAACgB,GACCH,MAAO8B,EACPhC,SAAU,SAACE,GAAK,OAAK0B,EAAQO,KAAQX,EAAMY,QAAOlC,KAElDb,gBAACT,GAAIsB,MAAM,kBACXb,gBAACT,GAAIsB,MAAM,yCCfKe,GACpB,OAAO5B,gBAACkC,mBAASN"}
@@ -1,8 +1,109 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
+ import { useRouteMatch, useLocation, useHistory } from 'react-router-dom';
3
+ import PropTypes from 'prop-types';
4
+ import cc from 'classcat';
5
+ import styled from 'styled-components';
6
+
7
+ function _objectWithoutPropertiesLoose(source, excluded) {
8
+ if (source == null) return {};
9
+ var target = {};
10
+ var sourceKeys = Object.keys(source);
11
+ var key, i;
12
+ for (i = 0; i < sourceKeys.length; i++) {
13
+ key = sourceKeys[i];
14
+ if (excluded.indexOf(key) >= 0) continue;
15
+ target[key] = source[key];
16
+ }
17
+ return target;
18
+ }
19
+ function _taggedTemplateLiteralLoose(strings, raw) {
20
+ if (!raw) {
21
+ raw = strings.slice(0);
22
+ }
23
+ strings.raw = raw;
24
+ return strings;
25
+ }
26
+
27
+ var _templateObject, _templateObject2;
28
+ var TabsPane = /*#__PURE__*/styled.ul(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: max-content;\n display: flex;\n align-items: center;\n border-bottom: 1px solid var(--neutral-1);\n"])));
29
+ var Tab = /*#__PURE__*/styled.li(_templateObject2 || (_templateObject2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n padding: 12px;\n color: var(--neutral-3);\n font-size: 0.875rem;\n font-weight: normal;\n position: relative;\n cursor: pointer;\n\n svg {\n fill: var(--neutral-3) !important;\n margin-left: 8px;\n }\n\n &.active {\n color: var(--primary-700-light);\n\n svg {\n fill: var(--primary-700-light) !important;\n }\n\n ::after {\n content: '';\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n height: 2px;\n background-color: var(--primary-700-light);\n }\n }\n\n &:not(:last-child) {\n margin-right: 8px;\n }\n"])));
30
+
31
+ var _excluded = ["active", "children"],
32
+ _excluded2 = ["children", "value", "onChange"];
33
+ var Tab$1 = function Tab$1(_ref) {
34
+ var active = _ref.active,
35
+ children = _ref.children,
36
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
37
+ return React.createElement(Tab, Object.assign({
38
+ className: cc({
39
+ active: active
40
+ })
41
+ }, rest), children);
42
+ };
43
+ Tab$1.propTypes = {
44
+ children: /*#__PURE__*/PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.node]).isRequired,
45
+ onChange: PropTypes.func,
46
+ value: PropTypes.string,
47
+ active: PropTypes.bool
48
+ };
49
+ Tab$1.defaultProps = {
50
+ onChange: function onChange() {},
51
+ value: '',
52
+ active: false
53
+ };
54
+ var Tabs = function Tabs(_ref2) {
55
+ var childrenProp = _ref2.children,
56
+ value = _ref2.value,
57
+ onChange = _ref2.onChange,
58
+ rest = _objectWithoutPropertiesLoose(_ref2, _excluded2);
59
+ var children = React.Children.map(childrenProp, function (child) {
60
+ var _child$props, _child$props3;
61
+ if (!React.isValidElement(child)) {
62
+ return null;
63
+ }
64
+ if (Array.isArray((_child$props = child.props) == null ? void 0 : _child$props.children)) {
65
+ var _child$props2;
66
+ return React.cloneElement(child, {
67
+ active: ((_child$props2 = child.props) == null ? void 0 : _child$props2.value) === value,
68
+ value: value,
69
+ onChange: onChange
70
+ });
71
+ }
72
+ return React.cloneElement(child, {
73
+ active: ((_child$props3 = child.props) == null ? void 0 : _child$props3.value) === value,
74
+ onClick: function onClick() {
75
+ var _child$props4;
76
+ return onChange((_child$props4 = child.props) == null ? void 0 : _child$props4.value);
77
+ }
78
+ });
79
+ });
80
+ return React.createElement(TabsPane, Object.assign({}, rest), children);
81
+ };
82
+ Tabs.propTypes = {
83
+ children: PropTypes.node.isRequired,
84
+ value: /*#__PURE__*/PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
85
+ onChange: PropTypes.func.isRequired
86
+ };
2
87
 
3
88
  var Leia = function Leia(props) {
89
+ var match = useRouteMatch();
90
+ var _useLocation = useLocation(),
91
+ pathname = _useLocation.pathname;
92
+ var history = useHistory();
4
93
  console.log('Props', props);
5
- return React.createElement("div", null, "Aqui \xE9 a Leia, seu id \xE9 ", props.id);
94
+ var activeTab = useMemo(function () {
95
+ return pathname.split('/')[5] || 'files';
96
+ }, [pathname]);
97
+ return React.createElement(Tabs, {
98
+ value: activeTab,
99
+ onChange: function onChange(value) {
100
+ return history.push(match.url + "/" + value);
101
+ }
102
+ }, React.createElement(Tab$1, {
103
+ value: "files"
104
+ }, "Files"), React.createElement(Tab$1, {
105
+ value: "test"
106
+ }, "Test"));
6
107
  };
7
108
 
8
109
  function Code7(props) {
@@ -1 +1 @@
1
- {"version":3,"file":"code7-leia.esm.js","sources":["../src/Leia.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { Props } from './index';\n\nexport const Leia = (props: Props) => {\n\n console.log('Props', props);\n\n return (\n <div>Aqui é a Leia, seu id é {props.id}</div>\n );\n};","import type { PropsWithChildren } from 'react';\nimport React from 'react';\nimport { Leia } from './Leia';\n\nexport type Props = PropsWithChildren<{\n id: string;\n}>;\n\nexport function Code7(props: Props) {\n return <Leia {...props} />;\n}"],"names":["Leia","props","console","log","React","id","Code7"],"mappings":";;AAIO,IAAMA,IAAI,GAAG,SAAPA,IAAIA,CAAIC,KAAY;EAE/BC,OAAO,CAACC,GAAG,CAAC,OAAO,EAAEF,KAAK,CAAC;EAE3B,OACEG,mEAA8BH,KAAK,CAACI,EAAE,CAAO;AAEjD,CAAC;;SCHeC,KAAKA,CAACL,KAAY;EAChC,OAAOG,oBAACJ,IAAI,oBAAKC,KAAK,EAAI;AAC5B;;;;"}
1
+ {"version":3,"file":"code7-leia.esm.js","sources":["../src/components/Tabs/styles.tsx","../src/components/Tabs/index.tsx","../src/Leia.tsx","../src/index.tsx"],"sourcesContent":["import styled from 'styled-components';\nimport { ReactNode } from 'react';\n\ninterface TabProps {\n children: ReactNode;\n}\n\ninterface OptionProps {\n children: ReactNode;\n onClick: () => void;\n}\n\nexport const TabsPane = styled.ul`\n width: max-content;\n display: flex;\n align-items: center;\n border-bottom: 1px solid var(--neutral-1);\n`;\n\nexport const Tab = styled.li<TabProps>`\n padding: 12px;\n color: var(--neutral-3);\n font-size: 0.875rem;\n font-weight: normal;\n position: relative;\n cursor: pointer;\n\n svg {\n fill: var(--neutral-3) !important;\n margin-left: 8px;\n }\n\n &.active {\n color: var(--primary-700-light);\n\n svg {\n fill: var(--primary-700-light) !important;\n }\n\n ::after {\n content: '';\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n height: 2px;\n background-color: var(--primary-700-light);\n }\n }\n\n &:not(:last-child) {\n margin-right: 8px;\n }\n`;\n\nexport const DropdownContainer = styled.div`\n position: absolute;\n left: 0px;\n top: 40px;\n display: flex;\n flex-direction: column;\n\n background: #ffffff;\n\n border: 1px solid #979aa5;\n box-sizing: border-box;\n box-shadow: 0px 6px 12px -6px rgba(24, 39, 75, 0.12),\n 0px 8px 24px -4px rgba(24, 39, 75, 0.08);\n border-radius: 4px;\n padding: 8px;\n z-index: 2;\n`;\n\nexport const Option = styled.div<OptionProps>`\n padding: 8px;\n font-size: 14px;\n border-radius: 4px;\n cursor: pointer;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n\n &:hover {\n background-color: var(--primary-800-light);\n color: white;\n }\n`;\n","import React, { ReactNode } from 'react';\nimport PropTypes from 'prop-types';\nimport cc from 'classcat';\n\nimport * as S from './styles';\n\ninterface TabProps {\n children: ReactNode;\n active?: boolean;\n}\n\ninterface ITabsProps {\n children: ReactNode;\n value: string | number;\n onChange: (e: any) => void;\n active?: boolean;\n}\n\nexport const Tab = ({ active, children, ...rest }: TabProps) => {\n return (\n <S.Tab className={cc({ active })} {...rest}>\n {children}\n </S.Tab>\n );\n};\n\nTab.propTypes = {\n children: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.element,\n PropTypes.node,\n ]).isRequired,\n onChange: PropTypes.func,\n value: PropTypes.string,\n active: PropTypes.bool,\n};\n\nTab.defaultProps = {\n onChange: () => {},\n value: '',\n active: false,\n};\n\nexport const Tabs = ({ children: childrenProp, value, onChange, ...rest }: ITabsProps) => {\n const children = React.Children.map(childrenProp, (child) => {\n if (!React.isValidElement(child)) {\n return null;\n }\n\n if (Array.isArray(child.props?.children)) {\n return React.cloneElement(child as React.ReactElement<any>, {\n active: child.props?.value === value,\n value,\n onChange,\n });\n }\n\n return React.cloneElement(child as React.ReactElement<any>, {\n active: child.props?.value === value,\n onClick: () => onChange(child.props?.value),\n });\n });\n\n return <S.TabsPane {...rest}>{children}</S.TabsPane>;\n};\n\nTabs.propTypes = {\n children: PropTypes.node.isRequired,\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,\n onChange: PropTypes.func.isRequired,\n};\n","import React, { useMemo } from 'react';\n\nimport { useLocation, useRouteMatch, useHistory } from 'react-router-dom';\n\nimport type { Props } from './index';\nimport { Tab, Tabs } from './components/Tabs'\n\nexport const Leia = (props: Props) => {\n const match = useRouteMatch();\n const { pathname } = useLocation();\n const history = useHistory();\n\n console.log('Props', props);\n\n const activeTab = useMemo(() => {\n return pathname.split('/')[5] || 'files';\n }, [pathname]);\n\n return (\n <Tabs\n value={activeTab}\n onChange={(value) => history.push(`${match.url}/${value}`)}\n >\n <Tab value=\"files\">Files</Tab>\n <Tab value=\"test\">Test</Tab>\n </Tabs>\n );\n};","import type { PropsWithChildren } from 'react';\nimport React from 'react';\nimport { Leia } from './Leia';\n\nexport type Props = PropsWithChildren<{\n id: string;\n activeTab: string;\n}>;\n\nexport function Code7(props: Props) {\n return <Leia {...props} />;\n}"],"names":["TabsPane","styled","ul","_templateObject","_taggedTemplateLiteralLoose","Tab","li","_templateObject2","_ref","active","children","rest","_objectWithoutPropertiesLoose","_excluded","React","S","className","cc","propTypes","PropTypes","oneOfType","string","element","node","isRequired","onChange","func","value","bool","defaultProps","Tabs","_ref2","childrenProp","_excluded2","Children","map","child","isValidElement","Array","isArray","_child$props","props","_child$props2","cloneElement","_child$props3","onClick","_child$props4","number","Leia","match","useRouteMatch","_useLocation","useLocation","pathname","history","useHistory","console","log","activeTab","useMemo","split","push","url","Code7"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAYO,IAAMA,QAAQ,gBAAGC,MAAM,CAACC,EAAE,CAAAC,eAAA,KAAAA,eAAA,gBAAAC,2BAAA,yHAKhC;AAEM,IAAMC,GAAG,gBAAGJ,MAAM,CAACK,EAAE,CAAAC,gBAAA,KAAAA,gBAAA,gBAAAH,2BAAA,8lBAkC3B;;;;ACrDD,AAkBO,IAAMC,KAAG,GAAG,SAANA,KAAGA,CAAAG,IAAA;MAAMC,MAAM,GAAAD,IAAA,CAANC,MAAM;IAAEC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IAAKC,IAAI,GAAAC,6BAAA,CAAAJ,IAAA,EAAAK,SAAA;EAC7C,OACEC,oBAACC,GAAK;IAACC,SAAS,EAAEC,EAAE,CAAC;MAAER,MAAM,EAANA;KAAQ;KAAOE,IAAI,GACvCD,QAAQ,CACH;AAEZ,CAAC;AAEDL,KAAG,CAACa,SAAS,GAAG;EACdR,QAAQ,eAAES,SAAS,CAACC,SAAS,CAAC,CAC5BD,SAAS,CAACE,MAAM,EAChBF,SAAS,CAACG,OAAO,EACjBH,SAAS,CAACI,IAAI,CACf,CAAC,CAACC,UAAU;EACbC,QAAQ,EAAEN,SAAS,CAACO,IAAI;EACxBC,KAAK,EAAER,SAAS,CAACE,MAAM;EACvBZ,MAAM,EAAEU,SAAS,CAACS;CACnB;AAEDvB,KAAG,CAACwB,YAAY,GAAG;EACjBJ,QAAQ,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DoB,IAAI,CAACZ,SAAS,GAAG;EACfR,QAAQ,EAAES,SAAS,CAACI,IAAI,CAACC,UAAU;EACnCG,KAAK,eAAER,SAAS,CAACC,SAAS,CAAC,CAACD,SAAS,CAACE,MAAM,EAAEF,SAAS,CAAC4B,MAAM,CAAC,CAAC,CAACvB,UAAU;EAC3EC,QAAQ,EAAEN,SAAS,CAACO,IAAI,CAACF;CAC1B;;AC/DM,IAAMwB,IAAI,GAAG,SAAPA,IAAIA,CAAIP,KAAY;EAC/B,IAAMQ,KAAK,GAAGC,aAAa,EAAE;EAC7B,IAAAC,YAAA,GAAqBC,WAAW,EAAE;IAA1BC,QAAQ,GAAAF,YAAA,CAARE,QAAQ;EAChB,IAAMC,OAAO,GAAGC,UAAU,EAAE;EAE5BC,OAAO,CAACC,GAAG,CAAC,OAAO,EAAEhB,KAAK,CAAC;EAE3B,IAAMiB,SAAS,GAAGC,OAAO,CAAC;IACxB,OAAON,QAAQ,CAACO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO;GACzC,EAAE,CAACP,QAAQ,CAAC,CAAC;EAEd,OACEvC,oBAACgB,IAAI;IACHH,KAAK,EAAE+B,SAAS;IAChBjC,QAAQ,EAAE,SAAAA,SAACE,KAAK;MAAA,OAAK2B,OAAO,CAACO,IAAI,CAAIZ,KAAK,CAACa,GAAG,SAAInC,KAAO,CAAC;;KAE1Db,oBAACT,KAAG;IAACsB,KAAK,EAAC;aAAmB,EAC9Bb,oBAACT,KAAG;IAACsB,KAAK,EAAC;YAAiB,CACvB;AAEX,CAAC;;SClBeoC,KAAKA,CAACtB,KAAY;EAChC,OAAO3B,oBAACkC,IAAI,oBAAKP,KAAK,EAAI;AAC5B;;;;"}
@@ -0,0 +1,35 @@
1
+ import React, { ReactNode } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ interface TabProps {
4
+ children: ReactNode;
5
+ active?: boolean;
6
+ }
7
+ interface ITabsProps {
8
+ children: ReactNode;
9
+ value: string | number;
10
+ onChange: (e: any) => void;
11
+ active?: boolean;
12
+ }
13
+ export declare const Tab: {
14
+ ({ active, children, ...rest }: TabProps): React.JSX.Element;
15
+ propTypes: {
16
+ children: PropTypes.Validator<string | number | boolean | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
17
+ onChange: PropTypes.Requireable<(...args: any[]) => any>;
18
+ value: PropTypes.Requireable<string>;
19
+ active: PropTypes.Requireable<boolean>;
20
+ };
21
+ defaultProps: {
22
+ onChange: () => void;
23
+ value: string;
24
+ active: boolean;
25
+ };
26
+ };
27
+ export declare const Tabs: {
28
+ ({ children: childrenProp, value, onChange, ...rest }: ITabsProps): React.JSX.Element;
29
+ propTypes: {
30
+ children: PropTypes.Validator<string | number | boolean | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
31
+ value: PropTypes.Validator<string | number>;
32
+ onChange: PropTypes.Validator<(...args: any[]) => any>;
33
+ };
34
+ };
35
+ export {};
@@ -0,0 +1,13 @@
1
+ import { ReactNode } from 'react';
2
+ interface TabProps {
3
+ children: ReactNode;
4
+ }
5
+ interface OptionProps {
6
+ children: ReactNode;
7
+ onClick: () => void;
8
+ }
9
+ export declare const TabsPane: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, never>>;
10
+ export declare const Tab: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, TabProps>>;
11
+ export declare const DropdownContainer: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
12
+ export declare const Option: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, OptionProps>>;
13
+ export {};
package/dist/index.d.ts CHANGED
@@ -2,5 +2,6 @@ import type { PropsWithChildren } from 'react';
2
2
  import React from 'react';
3
3
  export declare type Props = PropsWithChildren<{
4
4
  id: string;
5
+ activeTab: string;
5
6
  }>;
6
7
  export declare function Code7(props: Props): React.JSX.Element;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.5",
2
+ "version": "0.1.6",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -51,6 +51,7 @@
51
51
  "@size-limit/preset-small-lib": "^11.0.2",
52
52
  "@types/react": "^18.2.48",
53
53
  "@types/react-dom": "^18.2.18",
54
+ "@types/react-router-dom": "^5.3.3",
54
55
  "husky": "^9.0.6",
55
56
  "react": "^18.2.0",
56
57
  "react-dom": "^18.2.0",
@@ -58,5 +59,10 @@
58
59
  "tsdx": "^0.14.1",
59
60
  "tslib": "^2.6.2",
60
61
  "typescript": "^5.3.3"
62
+ },
63
+ "dependencies": {
64
+ "classcat": "^5.0.4",
65
+ "react-router-dom": "^5.1.2",
66
+ "styled-components": "^6.1.8"
61
67
  }
62
68
  }
package/src/Leia.tsx CHANGED
@@ -1,12 +1,28 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
+
3
+ import { useLocation, useRouteMatch, useHistory } from 'react-router-dom';
2
4
 
3
5
  import type { Props } from './index';
6
+ import { Tab, Tabs } from './components/Tabs'
4
7
 
5
8
  export const Leia = (props: Props) => {
9
+ const match = useRouteMatch();
10
+ const { pathname } = useLocation();
11
+ const history = useHistory();
6
12
 
7
13
  console.log('Props', props);
8
14
 
15
+ const activeTab = useMemo(() => {
16
+ return pathname.split('/')[5] || 'files';
17
+ }, [pathname]);
18
+
9
19
  return (
10
- <div>Aqui é a Leia, seu id é {props.id}</div>
20
+ <Tabs
21
+ value={activeTab}
22
+ onChange={(value) => history.push(`${match.url}/${value}`)}
23
+ >
24
+ <Tab value="files">Files</Tab>
25
+ <Tab value="test">Test</Tab>
26
+ </Tabs>
11
27
  );
12
28
  };
@@ -0,0 +1,71 @@
1
+ import React, { ReactNode } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import cc from 'classcat';
4
+
5
+ import * as S from './styles';
6
+
7
+ interface TabProps {
8
+ children: ReactNode;
9
+ active?: boolean;
10
+ }
11
+
12
+ interface ITabsProps {
13
+ children: ReactNode;
14
+ value: string | number;
15
+ onChange: (e: any) => void;
16
+ active?: boolean;
17
+ }
18
+
19
+ export const Tab = ({ active, children, ...rest }: TabProps) => {
20
+ return (
21
+ <S.Tab className={cc({ active })} {...rest}>
22
+ {children}
23
+ </S.Tab>
24
+ );
25
+ };
26
+
27
+ Tab.propTypes = {
28
+ children: PropTypes.oneOfType([
29
+ PropTypes.string,
30
+ PropTypes.element,
31
+ PropTypes.node,
32
+ ]).isRequired,
33
+ onChange: PropTypes.func,
34
+ value: PropTypes.string,
35
+ active: PropTypes.bool,
36
+ };
37
+
38
+ Tab.defaultProps = {
39
+ onChange: () => {},
40
+ value: '',
41
+ active: false,
42
+ };
43
+
44
+ export const Tabs = ({ children: childrenProp, value, onChange, ...rest }: ITabsProps) => {
45
+ const children = React.Children.map(childrenProp, (child) => {
46
+ if (!React.isValidElement(child)) {
47
+ return null;
48
+ }
49
+
50
+ if (Array.isArray(child.props?.children)) {
51
+ return React.cloneElement(child as React.ReactElement<any>, {
52
+ active: child.props?.value === value,
53
+ value,
54
+ onChange,
55
+ });
56
+ }
57
+
58
+ return React.cloneElement(child as React.ReactElement<any>, {
59
+ active: child.props?.value === value,
60
+ onClick: () => onChange(child.props?.value),
61
+ });
62
+ });
63
+
64
+ return <S.TabsPane {...rest}>{children}</S.TabsPane>;
65
+ };
66
+
67
+ Tabs.propTypes = {
68
+ children: PropTypes.node.isRequired,
69
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
70
+ onChange: PropTypes.func.isRequired,
71
+ };
@@ -0,0 +1,87 @@
1
+ import styled from 'styled-components';
2
+ import { ReactNode } from 'react';
3
+
4
+ interface TabProps {
5
+ children: ReactNode;
6
+ }
7
+
8
+ interface OptionProps {
9
+ children: ReactNode;
10
+ onClick: () => void;
11
+ }
12
+
13
+ export const TabsPane = styled.ul`
14
+ width: max-content;
15
+ display: flex;
16
+ align-items: center;
17
+ border-bottom: 1px solid var(--neutral-1);
18
+ `;
19
+
20
+ export const Tab = styled.li<TabProps>`
21
+ padding: 12px;
22
+ color: var(--neutral-3);
23
+ font-size: 0.875rem;
24
+ font-weight: normal;
25
+ position: relative;
26
+ cursor: pointer;
27
+
28
+ svg {
29
+ fill: var(--neutral-3) !important;
30
+ margin-left: 8px;
31
+ }
32
+
33
+ &.active {
34
+ color: var(--primary-700-light);
35
+
36
+ svg {
37
+ fill: var(--primary-700-light) !important;
38
+ }
39
+
40
+ ::after {
41
+ content: '';
42
+ position: absolute;
43
+ bottom: 0;
44
+ left: 0;
45
+ width: 100%;
46
+ height: 2px;
47
+ background-color: var(--primary-700-light);
48
+ }
49
+ }
50
+
51
+ &:not(:last-child) {
52
+ margin-right: 8px;
53
+ }
54
+ `;
55
+
56
+ export const DropdownContainer = styled.div`
57
+ position: absolute;
58
+ left: 0px;
59
+ top: 40px;
60
+ display: flex;
61
+ flex-direction: column;
62
+
63
+ background: #ffffff;
64
+
65
+ border: 1px solid #979aa5;
66
+ box-sizing: border-box;
67
+ box-shadow: 0px 6px 12px -6px rgba(24, 39, 75, 0.12),
68
+ 0px 8px 24px -4px rgba(24, 39, 75, 0.08);
69
+ border-radius: 4px;
70
+ padding: 8px;
71
+ z-index: 2;
72
+ `;
73
+
74
+ export const Option = styled.div<OptionProps>`
75
+ padding: 8px;
76
+ font-size: 14px;
77
+ border-radius: 4px;
78
+ cursor: pointer;
79
+ overflow: hidden;
80
+ text-overflow: ellipsis;
81
+ white-space: nowrap;
82
+
83
+ &:hover {
84
+ background-color: var(--primary-800-light);
85
+ color: white;
86
+ }
87
+ `;
package/src/index.tsx CHANGED
@@ -4,6 +4,7 @@ import { Leia } from './Leia';
4
4
 
5
5
  export type Props = PropsWithChildren<{
6
6
  id: string;
7
+ activeTab: string;
7
8
  }>;
8
9
 
9
10
  export function Code7(props: Props) {