@kubed/components 0.0.35 → 0.0.38
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/CHANGELOG.md +29 -0
- package/cjs/Button/Button.styles.js +12 -13
- package/cjs/Button/Button.styles.js.map +1 -1
- package/cjs/Loading/Loading.js +1 -12
- package/cjs/Loading/Loading.js.map +1 -1
- package/cjs/Loading/loaders/Circle.js +13 -0
- package/cjs/Loading/loaders/Circle.js.map +1 -0
- package/cjs/Loading/loaders/Oval.js +6 -0
- package/cjs/Loading/loaders/Oval.js.map +1 -0
- package/cjs/ShowMore/ShowMore.js +11 -0
- package/cjs/ShowMore/ShowMore.js.map +1 -0
- package/cjs/Steps/Step/Step.js +2 -0
- package/cjs/Steps/Step/Step.js.map +1 -0
- package/cjs/Steps/Step/Step.styles.js +59 -0
- package/cjs/Steps/Step/Step.styles.js.map +1 -0
- package/cjs/Steps/StepCompleted/StepCompleted.js +2 -0
- package/cjs/Steps/StepCompleted/StepCompleted.js.map +1 -0
- package/cjs/Steps/Steps.js +2 -0
- package/cjs/Steps/Steps.js.map +1 -0
- package/cjs/Steps/Steps.styles.js +48 -0
- package/cjs/Steps/Steps.styles.js.map +1 -0
- package/cjs/Steps/TabStep/TabStep.js +2 -0
- package/cjs/Steps/TabStep/TabStep.js.map +1 -0
- package/cjs/Steps/TabStep/TabStep.styles.js +84 -0
- package/cjs/Steps/TabStep/TabStep.styles.js.map +1 -0
- package/cjs/Tabs/Tabs.js +1 -1
- package/cjs/Tabs/Tabs.js.map +1 -1
- package/cjs/Tabs/Tabs.styles.js +12 -12
- package/cjs/Tabs/Tabs.styles.js.map +1 -1
- package/cjs/Tag/Tag.js +13 -4
- package/cjs/Tag/Tag.js.map +1 -1
- package/cjs/TypeSelect/TypeSelect.js +2 -0
- package/cjs/TypeSelect/TypeSelect.js.map +1 -0
- package/cjs/TypeSelect/TypeSelect.styles.js +54 -0
- package/cjs/TypeSelect/TypeSelect.styles.js.map +1 -0
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/utils/toArray.js.map +1 -1
- package/cjs/utils/types.js.map +1 -1
- package/esm/Button/Button.styles.js +41 -42
- package/esm/Button/Button.styles.js.map +1 -1
- package/esm/Loading/Loading.js +1 -12
- package/esm/Loading/Loading.js.map +1 -1
- package/esm/Loading/loaders/Circle.js +13 -0
- package/esm/Loading/loaders/Circle.js.map +1 -0
- package/esm/Loading/loaders/Oval.js +6 -0
- package/esm/Loading/loaders/Oval.js.map +1 -0
- package/esm/ShowMore/ShowMore.js +11 -0
- package/esm/ShowMore/ShowMore.js.map +1 -0
- package/esm/Steps/Step/Step.js +2 -0
- package/esm/Steps/Step/Step.js.map +1 -0
- package/esm/Steps/Step/Step.styles.js +59 -0
- package/esm/Steps/Step/Step.styles.js.map +1 -0
- package/esm/Steps/StepCompleted/StepCompleted.js +2 -0
- package/esm/Steps/StepCompleted/StepCompleted.js.map +1 -0
- package/esm/Steps/Steps.js +2 -0
- package/esm/Steps/Steps.js.map +1 -0
- package/esm/Steps/Steps.styles.js +48 -0
- package/esm/Steps/Steps.styles.js.map +1 -0
- package/esm/Steps/TabStep/TabStep.js +2 -0
- package/esm/Steps/TabStep/TabStep.js.map +1 -0
- package/esm/Steps/TabStep/TabStep.styles.js +84 -0
- package/esm/Steps/TabStep/TabStep.styles.js.map +1 -0
- package/esm/Tabs/Tabs.js +1 -1
- package/esm/Tabs/Tabs.js.map +1 -1
- package/esm/Tabs/Tabs.styles.js +30 -30
- package/esm/Tabs/Tabs.styles.js.map +1 -1
- package/esm/Tag/Tag.js +18 -9
- package/esm/Tag/Tag.js.map +1 -1
- package/esm/TypeSelect/TypeSelect.js +2 -0
- package/esm/TypeSelect/TypeSelect.js.map +1 -0
- package/esm/TypeSelect/TypeSelect.styles.js +54 -0
- package/esm/TypeSelect/TypeSelect.styles.js.map +1 -0
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/utils/toArray.js.map +1 -1
- package/esm/utils/types.js.map +1 -1
- package/lib/src/Button/Button.styles.d.ts.map +1 -1
- package/lib/src/Loading/Loading.d.ts +10 -2
- package/lib/src/Loading/Loading.d.ts.map +1 -1
- package/lib/src/Loading/loaders/Circle.d.ts +12 -0
- package/lib/src/Loading/loaders/Circle.d.ts.map +1 -0
- package/lib/src/Loading/loaders/Oval.d.ts +4 -0
- package/lib/src/Loading/loaders/Oval.d.ts.map +1 -0
- package/lib/src/ShowMore/ShowMore.d.ts +18 -0
- package/lib/src/ShowMore/ShowMore.d.ts.map +1 -0
- package/lib/src/Slider/Slider.d.ts.map +1 -1
- package/lib/src/Steps/Step/Step.d.ts +38 -0
- package/lib/src/Steps/Step/Step.d.ts.map +1 -0
- package/lib/src/Steps/Step/Step.styles.d.ts +8 -0
- package/lib/src/Steps/Step/Step.styles.d.ts.map +1 -0
- package/lib/src/Steps/StepCompleted/StepCompleted.d.ts +10 -0
- package/lib/src/Steps/StepCompleted/StepCompleted.d.ts.map +1 -0
- package/lib/src/Steps/Steps.d.ts +37 -0
- package/lib/src/Steps/Steps.d.ts.map +1 -0
- package/lib/src/Steps/Steps.styles.d.ts +10 -0
- package/lib/src/Steps/Steps.styles.d.ts.map +1 -0
- package/lib/src/Steps/TabStep/TabStep.d.ts +42 -0
- package/lib/src/Steps/TabStep/TabStep.d.ts.map +1 -0
- package/lib/src/Steps/TabStep/TabStep.styles.d.ts +8 -0
- package/lib/src/Steps/TabStep/TabStep.styles.d.ts.map +1 -0
- package/lib/src/Tabs/Tabs.d.ts.map +1 -1
- package/lib/src/Tabs/Tabs.styles.d.ts +1 -1
- package/lib/src/Tabs/Tabs.styles.d.ts.map +1 -1
- package/lib/src/Tag/Tag.d.ts +8 -1
- package/lib/src/Tag/Tag.d.ts.map +1 -1
- package/lib/src/TypeSelect/TypeSelect.d.ts +20 -0
- package/lib/src/TypeSelect/TypeSelect.d.ts.map +1 -0
- package/lib/src/TypeSelect/TypeSelect.styles.d.ts +10 -0
- package/lib/src/TypeSelect/TypeSelect.styles.d.ts.map +1 -0
- package/lib/src/index.d.ts +3 -0
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/utils/toArray.d.ts.map +1 -1
- package/lib/src/utils/types.d.ts +3 -0
- package/lib/src/utils/types.d.ts.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var styled=require("styled-components"),utils=require("../../theme/utils.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e.default:e}var styled__default=_interopDefaultLegacy(styled);const StepWrapper=styled__default.div`
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: row;
|
|
4
|
+
cursor: pointer;
|
|
5
|
+
align-items: center;
|
|
6
|
+
text-align: left;
|
|
7
|
+
min-width: 180px;
|
|
8
|
+
height: 100%;
|
|
9
|
+
padding: 12px 15px;
|
|
10
|
+
&[data-progress='true'] {
|
|
11
|
+
background-color: ${({theme:e})=>e.palette.background};
|
|
12
|
+
}
|
|
13
|
+
`,StepBody=styled__default.div`
|
|
14
|
+
margin-left: 12px;
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
`,StepLabel=styled__default.div`
|
|
18
|
+
font-size: 12px;
|
|
19
|
+
font-weight: 700;
|
|
20
|
+
line-height: 1.67;
|
|
21
|
+
text-align: left;
|
|
22
|
+
color: ${({theme:e})=>e.palette.accents_8};
|
|
23
|
+
`,StepDescription=styled__default.div`
|
|
24
|
+
text-align: left;
|
|
25
|
+
line-height: 1.67;
|
|
26
|
+
color: ${({theme:e})=>e.palette.accents_5};
|
|
27
|
+
`,StepIcon=styled__default.div`
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
justify-content: center;
|
|
31
|
+
position: relative;
|
|
32
|
+
font-weight: 700;
|
|
33
|
+
width: 40px;
|
|
34
|
+
height: 40px;
|
|
35
|
+
min-height: 40px;
|
|
36
|
+
//border-radius: 32px;
|
|
37
|
+
font-size: 16px;
|
|
38
|
+
//border: 2px solid ${({theme:e})=>e.palette.accents_2};
|
|
39
|
+
transition: background-color 150ms ease, border-color 150ms ease;
|
|
40
|
+
//background-color: ${({theme:e})=>e.palette.accents_2};
|
|
41
|
+
color: ${({theme:e})=>e.palette.accents_7};
|
|
42
|
+
&[data-progress='true'] {
|
|
43
|
+
&:after {
|
|
44
|
+
border-color: ${({theme:e})=>utils.default.getPrimaryColor(e)};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
&[data-completed='true'] {
|
|
48
|
+
color: #fff;
|
|
49
|
+
&:after {
|
|
50
|
+
border-color: ${({theme:e})=>utils.default.getPrimaryColor(e)};
|
|
51
|
+
background-color: ${({theme:e})=>utils.default.getPrimaryColor(e)};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.kubed-icon {
|
|
56
|
+
width: 40px;
|
|
57
|
+
height: 40px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
&:after {
|
|
61
|
+
position: absolute;
|
|
62
|
+
right: 0;
|
|
63
|
+
bottom: 0;
|
|
64
|
+
content: ' ';
|
|
65
|
+
border: 2px solid ${({theme:e})=>e.palette.accents_3};
|
|
66
|
+
background-color: ${({theme:e})=>e.palette.background};
|
|
67
|
+
display: block;
|
|
68
|
+
width: 12px;
|
|
69
|
+
height: 12px;
|
|
70
|
+
border-radius: 50%;
|
|
71
|
+
}
|
|
72
|
+
`,StepIconWrapper=styled__default.div`
|
|
73
|
+
position: relative;
|
|
74
|
+
overflow: hidden;
|
|
75
|
+
flex-shrink: 0;
|
|
76
|
+
`,StepCompletedIcon=styled__default.div`
|
|
77
|
+
position: absolute;
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
justify-content: center;
|
|
81
|
+
color: #fff;
|
|
82
|
+
inset: 0;
|
|
83
|
+
`;exports.StepBody=StepBody,exports.StepCompletedIcon=StepCompletedIcon,exports.StepDescription=StepDescription,exports.StepIcon=StepIcon,exports.StepIconWrapper=StepIconWrapper,exports.StepLabel=StepLabel,exports.StepWrapper=StepWrapper;
|
|
84
|
+
//# sourceMappingURL=TabStep.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabStep.styles.js","sources":["../../../src/Steps/TabStep/TabStep.styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { KubedTheme, themeUtils } from '../../theme';\n\nexport const StepWrapper = styled.div`\n display: flex;\n flex-direction: row;\n cursor: pointer;\n align-items: center;\n text-align: left;\n min-width: 180px;\n height: 100%;\n padding: 12px 15px;\n &[data-progress='true'] {\n background-color: ${({ theme }) => theme.palette.background};\n }\n`;\n\nexport const StepBody = styled.div`\n margin-left: 12px;\n display: flex;\n flex-direction: column;\n`;\n\nexport const StepLabel = styled.div`\n font-size: 12px;\n font-weight: 700;\n line-height: 1.67;\n text-align: left;\n color: ${({ theme }) => theme.palette.accents_8};\n`;\n\nexport const StepDescription = styled.div`\n text-align: left;\n line-height: 1.67;\n color: ${({ theme }) => theme.palette.accents_5};\n`;\n\nexport const StepIcon = styled.div`\n display: flex;\n align-items: center;\n justify-content: center;\n position: relative;\n font-weight: 700;\n width: 40px;\n height: 40px;\n min-height: 40px;\n //border-radius: 32px;\n font-size: 16px;\n //border: 2px solid ${({ theme }) => theme.palette.accents_2};\n transition: background-color 150ms ease, border-color 150ms ease;\n //background-color: ${({ theme }) => theme.palette.accents_2};\n color: ${({ theme }) => theme.palette.accents_7};\n &[data-progress='true'] {\n &:after {\n border-color: ${({ theme }) => themeUtils.getPrimaryColor(theme)};\n }\n }\n &[data-completed='true'] {\n color: #fff;\n &:after {\n border-color: ${({ theme }) => themeUtils.getPrimaryColor(theme)};\n background-color: ${({ theme }) => themeUtils.getPrimaryColor(theme)};\n }\n }\n\n .kubed-icon {\n width: 40px;\n height: 40px;\n }\n\n &:after {\n position: absolute;\n right: 0;\n bottom: 0;\n content: ' ';\n border: 2px solid ${({ theme }) => theme.palette.accents_3};\n background-color: ${({ theme }) => theme.palette.background};\n display: block;\n width: 12px;\n height: 12px;\n border-radius: 50%;\n }\n`;\n\nexport const StepIconWrapper = styled.div`\n position: relative;\n overflow: hidden;\n flex-shrink: 0;\n`;\n\nexport const StepCompletedIcon = styled.div`\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n color: #fff;\n inset: 0;\n`;\n"],"names":["styled","themeUtils"],"mappings":";;;;;;;;;;;AAEY,MAAC,WAAW,GAAGA,eAAM,CAAC,GAAG,CAAC;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;AAChE;AACA,EAAE;AACU,MAAC,QAAQ,GAAGA,eAAM,CAAC,GAAG,CAAC;AACnC;AACA;AACA;AACA,EAAE;AACU,MAAC,SAAS,GAAGA,eAAM,CAAC,GAAG,CAAC;AACpC;AACA;AACA;AACA;AACA,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;AAClD,EAAE;AACU,MAAC,eAAe,GAAGA,eAAM,CAAC,GAAG,CAAC;AAC1C;AACA;AACA,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;AAClD,EAAE;AACU,MAAC,QAAQ,GAAGA,eAAM,CAAC,GAAG,CAAC;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;AAC/D;AACA,sBAAsB,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;AAC/D,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;AAClD;AACA;AACA,oBAAoB,EAAE,CAAC,EAAE,KAAK,EAAE,KAAKC,gBAAU,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;AACvE;AACA;AACA;AACA;AACA;AACA,oBAAoB,EAAE,CAAC,EAAE,KAAK,EAAE,KAAKA,gBAAU,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;AACvE,wBAAwB,EAAE,CAAC,EAAE,KAAK,EAAE,KAAKA,gBAAU,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;AAC/D,sBAAsB,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;AAChE;AACA;AACA;AACA;AACA;AACA,EAAE;AACU,MAAC,eAAe,GAAGD,eAAM,CAAC,GAAG,CAAC;AAC1C;AACA;AACA;AACA,EAAE;AACU,MAAC,iBAAiB,GAAGA,eAAM,CAAC,GAAG,CAAC;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;"}
|
package/cjs/Tabs/Tabs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),cx=require("classnames"),hooks=require("@kubed/hooks"),Group=require("../Group/Group.js"),toArray=require("../utils/toArray.js"),Tabs_styles=require("./Tabs.styles.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e.default:e}var React__default=_interopDefaultLegacy(React),cx__default=_interopDefaultLegacy(cx),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__objRest=(e,t)=>{var r={};for(var n in e)__hasOwnProp.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&__getOwnPropSymbols)for(var n of __getOwnPropSymbols(e))t.indexOf(n)<0&&__propIsEnum.call(e,n)&&(r[n]=e[n]);return r};const directionMapping={horizontal:"row",vertical:"column"},findDefaultTab=e=>{for(let t=0;t<e.length;t+=1)if(!e[t].disabled)return e[t].key;return-1},parseTabList=e=>toArray.default(e).map(t=>{if(React__default.isValidElement(t)){const r=t.key!==void 0?String(t.key):void 0;return __spreadProps(__spreadValues({key:r},t.props),{node:t})}return null});function Tabs(e){var t=e,{children:r,name:n,variant:i="pills",activeKey:P,defaultActiveKey:w,onTabChange:T,color:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),cx=require("classnames"),hooks=require("@kubed/hooks"),Group=require("../Group/Group.js"),toArray=require("../utils/toArray.js"),Tabs_styles=require("./Tabs.styles.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e.default:e}var React__default=_interopDefaultLegacy(React),cx__default=_interopDefaultLegacy(cx),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__objRest=(e,t)=>{var r={};for(var n in e)__hasOwnProp.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&__getOwnPropSymbols)for(var n of __getOwnPropSymbols(e))t.indexOf(n)<0&&__propIsEnum.call(e,n)&&(r[n]=e[n]);return r};const directionMapping={horizontal:"row",vertical:"column"},findDefaultTab=e=>{for(let t=0;t<e.length;t+=1)if(!e[t].disabled)return e[t].key;return-1},parseTabList=e=>toArray.default(e).map(t=>{if(React__default.isValidElement(t)){const r=t.key!==void 0?String(t.key):void 0;return __spreadProps(__spreadValues({key:r},t.props),{node:t})}return null});function Tabs(e){var t=e,{children:r,name:n,variant:i="pills",activeKey:P,defaultActiveKey:w,onTabChange:T,color:p,grow:h,radius:v="lg",size:_="sm",position:u="left",direction:d="horizontal",tabPadding:O="xs",transitionDuration:R=150,transitionTimingFunction:E}=t,A=__objRest(t,["children","name","variant","activeKey","defaultActiveKey","onTabChange","color","grow","radius","size","position","direction","tabPadding","transitionDuration","transitionTimingFunction"]);const[y,C]=React.useState(!1),m=parseTabList(r),[o,j]=hooks.useUncontrolled({value:P,defaultValue:w,finalValue:findDefaultTab(m),onChange:T,rule:a=>!!a}),[s,D]=React.useState({width:0,height:0,translate:0,translateY:0}),k=hooks.useId(n),x=hooks.useReducedMotion(),b=React.useRef({}),f=React.useRef(null);React.useEffect(()=>{if(i==="outline")return null;const a=new ResizeObserver(()=>{if(o in b.current&&f.current){const c=b.current[o].getBoundingClientRect();D({width:c.width,height:c.height,translate:c.x-f.current.getBoundingClientRect().x-Tabs_styles.WRAPPER_PADDING,translateY:c.y-f.current.getBoundingClientRect().y-Tabs_styles.WRAPPER_PADDING}),y||setTimeout(()=>{C(!0)},4)}});return a.observe(f.current),()=>a.disconnect()},[o]);const N=m.map(a=>{const{key:l,label:c}=a,g=o===l;return React__default.createElement(Tabs_styles.TabControl,{key:l,active:g,radius:v,size:_,reduceMotion:x||!y,transitionTimingFunction:E,transitionDuration:R,className:cx__default("tab-item",{"tab-item__active":g})},React__default.createElement(Tabs_styles.TabControlLabel,{active:g,htmlFor:`${k}-${l}`,ref:q=>{b.current[l]=q},onClick:()=>j(l),className:"tab-label"},c))});return React__default.createElement(Tabs_styles.TabsContainer,__spreadValues({variant:i,direction:d,position:u},A),React__default.createElement(Tabs_styles.TabControlList,{variant:i,fullWidth:h,radius:v,size:_,position:u,direction:d,color:p,ref:f},!!o&&i!=="outline"&&(i==="pills"?React__default.createElement(Tabs_styles.PillsBg,{variant:i,radius:v,color:p,width:s.width,transform:s.translate}):React__default.createElement(Tabs_styles.LineBg,{variant:i,radius:v,color:p,direction:d,position:u,width:s.width,height:s.height,transform:s.translate,translateY:s.translateY,className:"line-bg"})),React__default.createElement(Group.Group,{grow:h,spacing:0,position:u,direction:directionMapping[d],className:"tab-group"},N)),React__default.createElement(Tabs_styles.TabPanel,{direction:d,position:u,variant:i,tabPadding:O},m.map(a=>a.key===o?a.children:null)))}Tabs.displayName="@kubed/components/Tabs",exports.Tabs=Tabs;
|
|
2
2
|
//# sourceMappingURL=Tabs.js.map
|
package/cjs/Tabs/Tabs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.js","sources":["../../src/Tabs/Tabs.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport cx from 'classnames';\nimport { useId, useUncontrolled, useReducedMotion } from '@kubed/hooks';\nimport { KubedNumberSize, KubedSizes } from '../theme';\nimport { Group, GroupPosition, GroupDirection } from '../Group/Group';\nimport { Tab, TabProps } from './Tab/Tab';\nimport toArray from '../utils/toArray';\n\nimport {\n TabsContainer,\n TabControlList,\n TabControl,\n TabControlLabel,\n TabPanel,\n WRAPPER_PADDING,\n PillsBg,\n LineBg,\n} from './Tabs.styles';\n\nexport { Tab };\nexport type { TabProps };\n\nconst directionMapping = {\n horizontal: 'row',\n vertical: 'column',\n};\n\nconst findDefaultTab = (tabs: TabProps[]) => {\n for (let i = 0; i < tabs.length; i += 1) {\n if (!tabs[i].disabled) {\n return tabs[i].key;\n }\n }\n\n return -1;\n};\n\nexport interface TabsProps\n extends Omit<React.ComponentPropsWithoutRef<'div'>, 'value' | 'onChange'> {\n /** Current selected value */\n variant?: 'pills' | 'line' | 'outline';\n\n /** Current selected value */\n activeKey?: string;\n\n /** Default value for uncontrolled component */\n defaultActiveKey?: string;\n\n /** Called when value changes */\n onChange?(value: string): void;\n\n /** Name of the radio group, default to random id */\n name?: string;\n\n /** True if component should have 100% width */\n grow?: boolean;\n\n /** Active control color from theme, defaults to white in light color scheme and theme.colors.dark[9] in dark */\n color?: string | 'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'error';\n\n /** Controls font-size, paddings and height */\n size?: KubedSizes;\n\n /** Border-radius from theme or number to set border-radius in px */\n radius?: KubedNumberSize;\n\n /** Tab controls position */\n position?: GroupPosition;\n\n /** Tab controls direction */\n direction?: 'horizontal' | 'vertical';\n\n /** Controls tab content padding-top */\n tabPadding?: KubedNumberSize;\n\n /** Called when tab control is clicked with tab index */\n onTabChange?(tabKey: string): void;\n\n /** Transition duration in ms, set to 0 to turn off transitions */\n transitionDuration?: number;\n\n /** Transition timing function for all transitions, defaults to theme.transitionTimingFunction */\n transitionTimingFunction?: string;\n}\n\nconst parseTabList = (children: React.ReactNode): TabProps[] => {\n return toArray(children).map((node: React.ReactElement<TabProps>) => {\n if (React.isValidElement(node)) {\n const key = node.key !== undefined ? String(node.key) : undefined;\n return {\n key,\n ...node.props,\n node,\n };\n }\n return null;\n });\n};\n\nexport function Tabs({\n children,\n name,\n variant = 'pills',\n activeKey,\n defaultActiveKey,\n onTabChange,\n color,\n grow,\n radius = 'lg',\n size = 'sm',\n position = 'left',\n direction = 'horizontal',\n tabPadding = 'xs',\n transitionDuration = 150,\n transitionTimingFunction,\n ...others\n}: TabsProps) {\n const [shouldAnimate, setShouldAnimate] = useState(false);\n const tabs = parseTabList(children);\n\n const [_activeKey, handleActiveTabChange] = useUncontrolled({\n value: activeKey,\n defaultValue: defaultActiveKey,\n finalValue: findDefaultTab(tabs),\n onChange: onTabChange,\n rule: (val) => !!val,\n });\n\n const [activePosition, setActivePosition] = useState({\n width: 0,\n height: 0,\n translate: 0,\n translateY: 0,\n });\n const uuid = useId(name);\n const reduceMotion = useReducedMotion();\n const refs = useRef<Record<string, HTMLLabelElement>>({});\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (variant === 'outline') return null;\n const observer = new ResizeObserver(() => {\n if (_activeKey in refs.current && wrapperRef.current) {\n const element = refs.current[_activeKey];\n const rect = element.getBoundingClientRect();\n setActivePosition({\n width: rect.width,\n height: rect.height,\n translate: rect.x - wrapperRef.current.getBoundingClientRect().x - WRAPPER_PADDING,\n translateY: rect.y - wrapperRef.current.getBoundingClientRect().y - WRAPPER_PADDING,\n });\n\n if (!shouldAnimate) {\n setTimeout(() => {\n setShouldAnimate(true);\n }, 4);\n }\n }\n });\n observer.observe(wrapperRef.current);\n return () => observer.disconnect();\n }, [_activeKey]);\n\n const items = tabs.map((item) => {\n const { key, label } = item;\n const isActive = _activeKey === key;\n return (\n <TabControl\n key={key}\n active={isActive}\n radius={radius}\n size={size}\n reduceMotion={reduceMotion || !shouldAnimate}\n transitionTimingFunction={transitionTimingFunction}\n transitionDuration={transitionDuration}\n className={cx('tab-item', { 'tab-item__active': isActive })}\n >\n <TabControlLabel\n active={isActive}\n htmlFor={`${uuid}-${key}`}\n ref={(node) => {\n refs.current[key] = node;\n }}\n onClick={() => handleActiveTabChange(key)}\n >\n {label}\n </TabControlLabel>\n </TabControl>\n );\n });\n\n return (\n <TabsContainer variant={variant} direction={direction} position={position} {...others}>\n <TabControlList\n variant={variant}\n fullWidth={grow}\n radius={radius}\n size={size}\n position={position}\n direction={direction}\n ref={wrapperRef}\n >\n {!!_activeKey &&\n variant !== 'outline' &&\n (variant === 'pills' ? (\n <PillsBg\n variant={variant}\n radius={radius}\n color={color}\n width={activePosition.width}\n transform={activePosition.translate}\n />\n ) : (\n <LineBg\n variant={variant}\n radius={radius}\n color={color}\n direction={direction}\n position={position}\n width={activePosition.width}\n height={activePosition.height}\n transform={activePosition.translate}\n translateY={activePosition.translateY}\n />\n ))}\n <Group\n grow={grow}\n spacing={0}\n position={position}\n direction={directionMapping[direction] as GroupDirection}\n className=\"tab-group\"\n >\n {items}\n </Group>\n </TabControlList>\n\n <TabPanel direction={direction} position={position} variant={variant} tabPadding={tabPadding}>\n {tabs.map((tab) => {\n if (tab.key === _activeKey) {\n return tab.children;\n }\n return null;\n })}\n </TabPanel>\n </TabsContainer>\n );\n}\n\nTabs.displayName = '@kubed/components/Tabs';\n"],"names":["toArray","React","useState","useUncontrolled","useId","useReducedMotion","useRef","useEffect","WRAPPER_PADDING","TabControl","cx","TabControlLabel","TabsContainer","TabControlList","PillsBg","LineBg","Group","TabPanel"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,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C;AAC1C,IAAI,SAAS,EAAE,WAAW;AAC1B,GAAG,EAAE,KAAK,CAAC,CAAC,kBAAkBf,cAAK,CAAC,aAAa,CAACgB,oBAAQ,EAAE;AAC5D,IAAI,SAAS;AACb,IAAI,QAAQ;AACZ,IAAI,OAAO;AACX,IAAI,UAAU;AACd,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK;AACvB,IAAI,IAAI,GAAG,CAAC,GAAG,KAAK,UAAU,EAAE;AAChC,MAAM,OAAO,GAAG,CAAC,QAAQ,CAAC;AAC1B,KAAK;AACL,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG,CAAC,CAAC,CAAC,CAAC;AACP,CAAC;AACD,IAAI,CAAC,WAAW,GAAG,wBAAwB;;;;"}
|
|
1
|
+
{"version":3,"file":"Tabs.js","sources":["../../src/Tabs/Tabs.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport cx from 'classnames';\nimport { useId, useUncontrolled, useReducedMotion } from '@kubed/hooks';\nimport { KubedNumberSize, KubedSizes } from '../theme';\nimport { Group, GroupPosition, GroupDirection } from '../Group/Group';\nimport { Tab, TabProps } from './Tab/Tab';\nimport toArray from '../utils/toArray';\n\nimport {\n TabsContainer,\n TabControlList,\n TabControl,\n TabControlLabel,\n TabPanel,\n WRAPPER_PADDING,\n PillsBg,\n LineBg,\n} from './Tabs.styles';\n\nexport { Tab };\nexport type { TabProps };\n\nconst directionMapping = {\n horizontal: 'row',\n vertical: 'column',\n};\n\nconst findDefaultTab = (tabs: TabProps[]) => {\n for (let i = 0; i < tabs.length; i += 1) {\n if (!tabs[i].disabled) {\n return tabs[i].key;\n }\n }\n\n return -1;\n};\n\nexport interface TabsProps\n extends Omit<React.ComponentPropsWithoutRef<'div'>, 'value' | 'onChange'> {\n /** Current selected value */\n variant?: 'pills' | 'line' | 'outline';\n\n /** Current selected value */\n activeKey?: string;\n\n /** Default value for uncontrolled component */\n defaultActiveKey?: string;\n\n /** Called when value changes */\n onChange?(value: string): void;\n\n /** Name of the radio group, default to random id */\n name?: string;\n\n /** True if component should have 100% width */\n grow?: boolean;\n\n /** Active control color from theme, defaults to white in light color scheme and theme.colors.dark[9] in dark */\n color?: string | 'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'error';\n\n /** Controls font-size, paddings and height */\n size?: KubedSizes;\n\n /** Border-radius from theme or number to set border-radius in px */\n radius?: KubedNumberSize;\n\n /** Tab controls position */\n position?: GroupPosition;\n\n /** Tab controls direction */\n direction?: 'horizontal' | 'vertical';\n\n /** Controls tab content padding-top */\n tabPadding?: KubedNumberSize;\n\n /** Called when tab control is clicked with tab index */\n onTabChange?(tabKey: string): void;\n\n /** Transition duration in ms, set to 0 to turn off transitions */\n transitionDuration?: number;\n\n /** Transition timing function for all transitions, defaults to theme.transitionTimingFunction */\n transitionTimingFunction?: string;\n}\n\nconst parseTabList = (children: React.ReactNode): TabProps[] => {\n return toArray(children).map((node: React.ReactElement<TabProps>) => {\n if (React.isValidElement(node)) {\n const key = node.key !== undefined ? String(node.key) : undefined;\n return {\n key,\n ...node.props,\n node,\n };\n }\n return null;\n });\n};\n\nexport function Tabs({\n children,\n name,\n variant = 'pills',\n activeKey,\n defaultActiveKey,\n onTabChange,\n color,\n grow,\n radius = 'lg',\n size = 'sm',\n position = 'left',\n direction = 'horizontal',\n tabPadding = 'xs',\n transitionDuration = 150,\n transitionTimingFunction,\n ...others\n}: TabsProps) {\n const [shouldAnimate, setShouldAnimate] = useState(false);\n const tabs = parseTabList(children);\n\n const [_activeKey, handleActiveTabChange] = useUncontrolled({\n value: activeKey,\n defaultValue: defaultActiveKey,\n finalValue: findDefaultTab(tabs),\n onChange: onTabChange,\n rule: (val) => !!val,\n });\n\n const [activePosition, setActivePosition] = useState({\n width: 0,\n height: 0,\n translate: 0,\n translateY: 0,\n });\n const uuid = useId(name);\n const reduceMotion = useReducedMotion();\n const refs = useRef<Record<string, HTMLLabelElement>>({});\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (variant === 'outline') return null;\n const observer = new ResizeObserver(() => {\n if (_activeKey in refs.current && wrapperRef.current) {\n const element = refs.current[_activeKey];\n const rect = element.getBoundingClientRect();\n setActivePosition({\n width: rect.width,\n height: rect.height,\n translate: rect.x - wrapperRef.current.getBoundingClientRect().x - WRAPPER_PADDING,\n translateY: rect.y - wrapperRef.current.getBoundingClientRect().y - WRAPPER_PADDING,\n });\n\n if (!shouldAnimate) {\n setTimeout(() => {\n setShouldAnimate(true);\n }, 4);\n }\n }\n });\n observer.observe(wrapperRef.current);\n return () => observer.disconnect();\n }, [_activeKey]);\n\n const items = tabs.map((item) => {\n const { key, label } = item;\n const isActive = _activeKey === key;\n return (\n <TabControl\n key={key}\n active={isActive}\n radius={radius}\n size={size}\n reduceMotion={reduceMotion || !shouldAnimate}\n transitionTimingFunction={transitionTimingFunction}\n transitionDuration={transitionDuration}\n className={cx('tab-item', { 'tab-item__active': isActive })}\n >\n <TabControlLabel\n active={isActive}\n htmlFor={`${uuid}-${key}`}\n ref={(node) => {\n refs.current[key] = node;\n }}\n onClick={() => handleActiveTabChange(key)}\n className=\"tab-label\"\n >\n {label}\n </TabControlLabel>\n </TabControl>\n );\n });\n\n return (\n <TabsContainer variant={variant} direction={direction} position={position} {...others}>\n <TabControlList\n variant={variant}\n fullWidth={grow}\n radius={radius}\n size={size}\n position={position}\n direction={direction}\n color={color}\n ref={wrapperRef}\n >\n {!!_activeKey &&\n variant !== 'outline' &&\n (variant === 'pills' ? (\n <PillsBg\n variant={variant}\n radius={radius}\n color={color}\n width={activePosition.width}\n transform={activePosition.translate}\n />\n ) : (\n <LineBg\n variant={variant}\n radius={radius}\n color={color}\n direction={direction}\n position={position}\n width={activePosition.width}\n height={activePosition.height}\n transform={activePosition.translate}\n translateY={activePosition.translateY}\n className=\"line-bg\"\n />\n ))}\n <Group\n grow={grow}\n spacing={0}\n position={position}\n direction={directionMapping[direction] as GroupDirection}\n className=\"tab-group\"\n >\n {items}\n </Group>\n </TabControlList>\n\n <TabPanel direction={direction} position={position} variant={variant} tabPadding={tabPadding}>\n {tabs.map((tab) => {\n if (tab.key === _activeKey) {\n return tab.children;\n }\n return null;\n })}\n </TabPanel>\n </TabsContainer>\n );\n}\n\nTabs.displayName = '@kubed/components/Tabs';\n"],"names":["toArray","React","useState","useUncontrolled","useId","useReducedMotion","useRef","useEffect","WRAPPER_PADDING","TabControl","cx","TabControlLabel","TabsContainer","TabControlList","PillsBg","LineBg","Group","TabPanel"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AAClC,MAAM,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,EAAE,IA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QAAQ,CAAC;AAC1B,KAAK;AACL,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG,CAAC,CAAC,CAAC,CAAC;AACP,CAAC;AACD,IAAI,CAAC,WAAW,GAAG,wBAAwB;;;;"}
|
package/cjs/Tabs/Tabs.styles.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var styled=require("styled-components"),utils=require("../theme/utils.js");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t.default:t}var styled__default=_interopDefaultLegacy(styled);const{getSizeValue}=utils.default,WRAPPER_PADDING=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var styled=require("styled-components"),utils=require("../theme/utils.js");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t.default:t}var styled__default=_interopDefaultLegacy(styled);const{getSizeValue}=utils.default,WRAPPER_PADDING=0,sizes={xs:{fontSize:"10px",height:"26px"},sm:{fontSize:"12px",height:"28px"},md:{fontSize:"14px",height:"36px"},lg:{fontSize:"16px",height:"48px"},xl:{fontSize:"18px",height:"56px"}},getColor=(t,r)=>{const{palette:e}=r;return e[t]?e[t]:e.colors[t]?e.colors[t][2]:e.accents_7},getOutlineControlBorder=(t,r,e,i)=>{const o=`1px solid ${r.palette.border}`;if(e==="vertical"){if(i==="left")return styled.css`
|
|
2
2
|
border-right: ${o};
|
|
3
3
|
|
|
4
4
|
.tab-item {
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
.tab-group {
|
|
60
60
|
width: 100%;
|
|
61
61
|
}
|
|
62
|
-
`},getContainerStyles=(t,r,e,i,o)=>{const{palette:
|
|
62
|
+
`},getContainerStyles=(t,r,e,i,o,n)=>{const{palette:s,layout:a}=r;return t==="pills"?styled.css`
|
|
63
63
|
padding: 1px;
|
|
64
|
-
border-radius: ${getSizeValue(e,
|
|
65
|
-
background-color: ${
|
|
66
|
-
border: 1px solid ${
|
|
64
|
+
border-radius: ${getSizeValue(e,a.radius)};
|
|
65
|
+
background-color: ${s.accents_0};
|
|
66
|
+
border: 1px solid ${s.border};
|
|
67
67
|
|
|
68
68
|
.tab-item {
|
|
69
69
|
font-weight: 500;
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
|
|
73
73
|
.tab-item__active {
|
|
74
74
|
label {
|
|
75
|
-
color: ${
|
|
75
|
+
color: ${s.background};
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
`:t==="outline"?styled.css`
|
|
@@ -89,10 +89,10 @@
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
.tab-item__active {
|
|
92
|
-
background-color: ${
|
|
93
|
-
border-color: ${
|
|
92
|
+
background-color: ${s.background};
|
|
93
|
+
border-color: ${s.border};
|
|
94
94
|
label {
|
|
95
|
-
color: ${
|
|
95
|
+
color: ${s.accents_8};
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
`:styled.css`
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
|
|
107
107
|
.tab-item__active {
|
|
108
108
|
label {
|
|
109
|
-
color: ${n.
|
|
109
|
+
color: ${n?utils.default.getColor(n,r):s.accents_7};
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
`},getPanelPadding=(t,r,e,i)=>{const o=getSizeValue(e,i.layout.spacing);return t==="horizontal"?styled.css`
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
display: ${({fullWidth:t,variant:r})=>t||r!=="pills"?"flex":"inline-flex"};
|
|
139
139
|
font-size: ${({size:t})=>sizes[t].fontSize};
|
|
140
140
|
align-items: center;
|
|
141
|
-
${({variant:t,theme:r,radius:e,direction:i,position:o})=>getContainerStyles(t,r,e,i,o)};
|
|
141
|
+
${({variant:t,theme:r,radius:e,direction:i,position:o,color:n})=>getContainerStyles(t,r,e,i,o,n)};
|
|
142
142
|
`,TabPanel=styled__default("div")`
|
|
143
143
|
display: block;
|
|
144
144
|
${({direction:t,position:r,tabPadding:e,theme:i})=>getPanelPadding(t,r,e,i)};
|
|
@@ -171,7 +171,7 @@ margin-right: -1px;`};
|
|
|
171
171
|
position: absolute;
|
|
172
172
|
box-sizing: border-box;
|
|
173
173
|
z-index: 1;
|
|
174
|
-
background-color: ${({theme:t,color:r})=>getColor(r,t)};
|
|
174
|
+
background-color: ${({theme:t,color:r})=>r?utils.default.getColor(r,t):t.palette.accents_7};
|
|
175
175
|
transition: transform 150ms ease 0s, width 100ms linear 0s;
|
|
176
176
|
${({width:t,height:r,direction:e,position:i,transform:o,translateY:n})=>getLineBgStyles(t,r,e,i,o,n)};
|
|
177
177
|
`;exports.LineBg=LineBg,exports.PillsBg=PillsBg,exports.TabControl=TabControl,exports.TabControlLabel=TabControlLabel,exports.TabControlList=TabControlList,exports.TabPanel=TabPanel,exports.TabsContainer=TabsContainer,exports.WRAPPER_PADDING=WRAPPER_PADDING;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.styles.js","sources":["../../src/Tabs/Tabs.styles.ts"],"sourcesContent":["import React from 'react';\nimport styled, { css } from 'styled-components';\nimport { KubedNumberSize, KubedSizes, KubedTheme, themeUtils } from '../theme';\n\nconst { getSizeValue } = themeUtils;\n\nexport const WRAPPER_PADDING = 2;\n\nconst sizes = {\n xs: {\n fontSize: '10px',\n height: '26px',\n },\n sm: {\n fontSize: '12px',\n height: '28px',\n },\n md: {\n fontSize: '14px',\n height: '36px',\n },\n lg: {\n fontSize: '16px',\n height: '48px',\n },\n xl: {\n fontSize: '18px',\n height: '56px',\n },\n};\n\nconst getColor = (color, theme: KubedTheme) => {\n const { palette } = theme;\n if (palette[color]) {\n return palette[color];\n }\n if (palette.colors[color]) {\n return palette.colors[color][2];\n }\n return palette.accents_7;\n};\n\nconst getOutlineControlBorder = (variant, theme: KubedTheme, direction, position) => {\n const border = `1px solid ${theme.palette.border}`;\n if (direction === 'vertical') {\n if (position === 'left') {\n return css`\n border-right: ${border};\n\n .tab-item {\n width: 100%;\n border-top-left-radius: 4px;\n border-bottom-left-radius: 4px;\n border-width: 1px 0 1px 1px;\n }\n .tab-group {\n margin-right: -1px;\n }\n `;\n }\n if (position === 'right') {\n return css`\n border-left: ${border};\n .tab-item {\n width: 100%;\n border-top-right-radius: 4px;\n border-bottom-right-radius: 4px;\n border-width: 1px 1px 1px 0;\n }\n .tab-group {\n margin-left: -1px;\n }\n `;\n }\n }\n return css`\n border-bottom: ${border};\n .tab-item {\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-width: 1px 1px 0;\n }\n .tab-group {\n width: 100%;\n margin-bottom: -1px;\n }\n `;\n};\n\nconst getLineControlBorder = (variant, theme: KubedTheme, direction, position) => {\n const border = `1px solid ${theme.palette.border}`;\n if (direction === 'vertical') {\n if (position === 'left') {\n return css`\n border-right: ${border};\n\n .tab-item {\n padding: 0 15px;\n width: 100%;\n }\n .tab-group {\n margin-right: -1px;\n }\n `;\n }\n if (position === 'right') {\n return css`\n border-left: ${border};\n .tab-item {\n padding: 0 15px;\n width: 100%;\n }\n .tab-group {\n margin-left: -1px;\n }\n `;\n }\n }\n return css`\n border-bottom: ${border};\n .tab-item {\n margin: 0 15px;\n }\n .tab-group {\n width: 100%;\n }\n `;\n};\n\nconst getContainerStyles = (variant, theme: KubedTheme, radius, direction, position) => {\n const { palette, layout } = theme;\n if (variant === 'pills') {\n return css`\n padding: 1px;\n border-radius: ${getSizeValue(radius, layout.radius)};\n background-color: ${palette.accents_0};\n border: 1px solid ${palette.border};\n\n .tab-item {\n font-weight: 500;\n min-width: 117px;\n }\n\n .tab-item__active {\n label {\n color: ${palette.background};\n }\n }\n `;\n }\n if (variant === 'outline') {\n return css`\n ${getOutlineControlBorder(variant, theme, direction, position)};\n\n .tab-item {\n padding: 0 15px;\n background-color: transparent;\n border-style: solid;\n border-color: transparent;\n &:first-of-type {\n margin-left: 0;\n }\n }\n\n .tab-item__active {\n background-color: ${palette.background};\n border-color: ${palette.border};\n label {\n color: ${palette.accents_8};\n }\n }\n `;\n }\n\n return css`\n ${getLineControlBorder(variant, theme, direction, position)};\n\n .tab-item {\n &:first-of-type {\n margin-left: 0;\n }\n }\n\n .tab-item__active {\n label {\n color: ${palette.accents_8};\n }\n }\n `;\n};\n\ninterface TabsStyles extends React.ComponentPropsWithoutRef<any> {\n theme?: KubedTheme;\n fullWidth?: boolean;\n color?: string;\n radius?: KubedNumberSize;\n reduceMotion?: boolean;\n transitionDuration?: number;\n transitionTimingFunction?: string;\n size?: KubedSizes;\n direction?: 'horizontal' | 'vertical';\n variant?: 'pills' | 'line' | 'outline';\n active?: boolean;\n}\n\nconst getPanelPadding = (direction, position, tabPadding, theme) => {\n const padding = getSizeValue(tabPadding, theme.layout.spacing);\n if (direction === 'horizontal') {\n return css`\n padding-top: ${padding};\n `;\n }\n return css`\n padding-${position}: ${padding};\n `;\n};\n\nexport const TabControl = styled('div')<TabsStyles>`\n position: relative;\n box-sizing: border-box;\n flex: 1;\n z-index: 2;\n line-height: ${({ size }) => sizes[size].height};\n transition: ${({ reduceMotion, transitionDuration, transitionTimingFunction }) =>\n `border-left-color ${reduceMotion ? 0 : transitionDuration}ms ${\n transitionTimingFunction || 'cubic-bezier(.51,.3,0,1.21)'\n }`};\n`;\n\nexport const TabControlLabel = styled('label')<TabsStyles>`\n display: block;\n cursor: pointer;\n text-overflow: ellipsis;\n text-align: center;\n color: ${({ theme }) => theme.palette.accents_7};\n white-space: nowrap;\n -webkit-tap-highlight-color: transparent;\n transition: color 150ms ease 0s;\n`;\n\nexport const TabsContainer = styled('div')<TabsStyles>`\n position: relative;\n display: ${({ direction }) => (direction === 'vertical' ? 'flex' : 'block')};\n ${({ direction, position }) =>\n direction === 'vertical' && position === 'right' ? 'flex-direction: row-reverse' : null};\n`;\n\nexport const TabControlList = styled('div')<TabsStyles>`\n position: relative;\n display: ${({ fullWidth, variant }) =>\n fullWidth || variant !== 'pills' ? 'flex' : 'inline-flex'};\n font-size: ${({ size }) => sizes[size].fontSize};\n align-items: center;\n ${({ variant, theme, radius, direction, position }) =>\n getContainerStyles(variant, theme, radius, direction, position)};\n`;\n\nexport const TabPanel = styled('div')<TabsStyles>`\n display: block;\n ${({ direction, position, tabPadding, theme }) =>\n getPanelPadding(direction, position, tabPadding, theme)};\n`;\n\ninterface BgSpanStyles extends React.ComponentPropsWithoutRef<any> {}\n\nexport const PillsBg = styled('span')<BgSpanStyles>`\n border-radius: ${({ radius, theme }) => getSizeValue(radius, theme.layout.radius)};\n position: absolute;\n box-sizing: border-box;\n top: 1px;\n bottom: 1px;\n z-index: 1;\n background-color: ${({ theme, color }) => getColor(color, theme)};\n width: ${({ width }) => width}px;\n transform: translateX(${({ transform }) => transform}px);\n transition: transform 150ms ease 0s, width 100ms linear 0s;\n`;\n\nconst getLineBgStyles = (width, height, direction, position, translate, translateY) => {\n if (direction === 'vertical') {\n return css`\n width: 2px;\n height: ${height}px;\n transform: translateY(${translateY}px);\n top: 0;\n ${position === 'right' ? 'left: 0;\\nmargin-left: -1px;' : 'right: 0;\\nmargin-right: -1px;'};\n `;\n }\n\n return css`\n height: 2px;\n width: ${width}px;\n transform: translateX(${translate}px);\n bottom: 0;\n margin-bottom: -1px;\n `;\n};\n\nexport const LineBg = styled('span')<BgSpanStyles>`\n position: absolute;\n box-sizing: border-box;\n z-index: 1;\n background-color: ${({ theme, color }) => getColor(color, theme)};\n transition: transform 150ms ease 0s, width 100ms linear 0s;\n ${({ width, height, direction, position, transform, translateY }) =>\n getLineBgStyles(width, height, direction, position, transform, translateY)};\n`;\n"],"names":["themeUtils","css","styled"],"mappings":";;;;;;;;;;;AAEA,MAAM,EAAE,YAAY,EAAE,GAAGA,gBAAU,CAAC;AACxB,MAAC,eAAe,GAAG,EAAE;AACjC,MAAM,KAAK,GAAG;AACd,EAAE,EAAE,EAAE;AACN,IAAI,QAAQ,EAAE,MAAM;AACpB,IAAI,MAAM,EAAE,MAAM;AAClB,GAAG;AACH,EAAE,EAAE,EAAE;AACN,IAAI,QAAQ,EAAE,MAAM;AACpB,IA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,GAAG,8BAA8B,GAAG,gCAAgC,CAAC;AACjG,IAAI,CAAC,CAAC;AACN,GAAG;AACH,EAAE,OAAOA,UAAG,CAAC;AACb;AACA,WAAW,EAAE,KAAK,CAAC;AACnB,0BAA0B,EAAE,SAAS,CAAC;AACtC;AACA;AACA,EAAE,CAAC,CAAC;AACJ,CAAC,CAAC;AACU,MAAC,MAAM,GAAGC,eAAM,CAAC,MAAM,CAAC,CAAC;AACrC;AACA;AACA;AACA,oBAAoB,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACnE;AACA,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AAClJ;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"Tabs.styles.js","sources":["../../src/Tabs/Tabs.styles.ts"],"sourcesContent":["import React from 'react';\nimport styled, { css } from 'styled-components';\nimport { KubedNumberSize, KubedSizes, KubedTheme, themeUtils } from '../theme';\n\nconst { getSizeValue } = themeUtils;\n\nexport const WRAPPER_PADDING = 0;\n\nconst sizes = {\n xs: {\n fontSize: '10px',\n height: '26px',\n },\n sm: {\n fontSize: '12px',\n height: '28px',\n },\n md: {\n fontSize: '14px',\n height: '36px',\n },\n lg: {\n fontSize: '16px',\n height: '48px',\n },\n xl: {\n fontSize: '18px',\n height: '56px',\n },\n};\n\nconst getColor = (color, theme: KubedTheme) => {\n const { palette } = theme;\n if (palette[color]) {\n return palette[color];\n }\n if (palette.colors[color]) {\n return palette.colors[color][2];\n }\n return palette.accents_7;\n};\n\nconst getOutlineControlBorder = (variant, theme: KubedTheme, direction, position) => {\n const border = `1px solid ${theme.palette.border}`;\n if (direction === 'vertical') {\n if (position === 'left') {\n return css`\n border-right: ${border};\n\n .tab-item {\n width: 100%;\n border-top-left-radius: 4px;\n border-bottom-left-radius: 4px;\n border-width: 1px 0 1px 1px;\n }\n .tab-group {\n margin-right: -1px;\n }\n `;\n }\n if (position === 'right') {\n return css`\n border-left: ${border};\n .tab-item {\n width: 100%;\n border-top-right-radius: 4px;\n border-bottom-right-radius: 4px;\n border-width: 1px 1px 1px 0;\n }\n .tab-group {\n margin-left: -1px;\n }\n `;\n }\n }\n return css`\n border-bottom: ${border};\n .tab-item {\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-width: 1px 1px 0;\n }\n .tab-group {\n width: 100%;\n margin-bottom: -1px;\n }\n `;\n};\n\nconst getLineControlBorder = (variant, theme: KubedTheme, direction, position) => {\n const border = `1px solid ${theme.palette.border}`;\n if (direction === 'vertical') {\n if (position === 'left') {\n return css`\n border-right: ${border};\n\n .tab-item {\n padding: 0 15px;\n width: 100%;\n }\n .tab-group {\n margin-right: -1px;\n }\n `;\n }\n if (position === 'right') {\n return css`\n border-left: ${border};\n .tab-item {\n padding: 0 15px;\n width: 100%;\n }\n .tab-group {\n margin-left: -1px;\n }\n `;\n }\n }\n return css`\n border-bottom: ${border};\n .tab-item {\n margin: 0 15px;\n }\n .tab-group {\n width: 100%;\n }\n `;\n};\n\nconst getContainerStyles = (variant, theme: KubedTheme, radius, direction, position, color) => {\n const { palette, layout } = theme;\n\n if (variant === 'pills') {\n return css`\n padding: 1px;\n border-radius: ${getSizeValue(radius, layout.radius)};\n background-color: ${palette.accents_0};\n border: 1px solid ${palette.border};\n\n .tab-item {\n font-weight: 500;\n min-width: 117px;\n }\n\n .tab-item__active {\n label {\n color: ${palette.background};\n }\n }\n `;\n }\n if (variant === 'outline') {\n return css`\n ${getOutlineControlBorder(variant, theme, direction, position)};\n\n .tab-item {\n padding: 0 15px;\n background-color: transparent;\n border-style: solid;\n border-color: transparent;\n &:first-of-type {\n margin-left: 0;\n }\n }\n\n .tab-item__active {\n background-color: ${palette.background};\n border-color: ${palette.border};\n label {\n color: ${palette.accents_8};\n }\n }\n `;\n }\n\n return css`\n ${getLineControlBorder(variant, theme, direction, position)};\n\n .tab-item {\n &:first-of-type {\n margin-left: 0;\n }\n }\n\n .tab-item__active {\n label {\n color: ${color ? themeUtils.getColor(color, theme) : palette.accents_7};\n }\n }\n `;\n};\n\ninterface TabsStyles extends React.ComponentPropsWithoutRef<any> {\n theme?: KubedTheme;\n fullWidth?: boolean;\n color?: string;\n radius?: KubedNumberSize;\n reduceMotion?: boolean;\n transitionDuration?: number;\n transitionTimingFunction?: string;\n size?: KubedSizes;\n direction?: 'horizontal' | 'vertical';\n variant?: 'pills' | 'line' | 'outline';\n active?: boolean;\n}\n\nconst getPanelPadding = (direction, position, tabPadding, theme) => {\n const padding = getSizeValue(tabPadding, theme.layout.spacing);\n if (direction === 'horizontal') {\n return css`\n padding-top: ${padding};\n `;\n }\n return css`\n padding-${position}: ${padding};\n `;\n};\n\nexport const TabControl = styled('div')<TabsStyles>`\n position: relative;\n box-sizing: border-box;\n flex: 1;\n z-index: 2;\n line-height: ${({ size }) => sizes[size].height};\n transition: ${({ reduceMotion, transitionDuration, transitionTimingFunction }) =>\n `border-left-color ${reduceMotion ? 0 : transitionDuration}ms ${\n transitionTimingFunction || 'cubic-bezier(.51,.3,0,1.21)'\n }`};\n`;\n\nexport const TabControlLabel = styled('label')<TabsStyles>`\n display: block;\n cursor: pointer;\n text-overflow: ellipsis;\n text-align: center;\n color: ${({ theme }) => theme.palette.accents_7};\n white-space: nowrap;\n -webkit-tap-highlight-color: transparent;\n transition: color 150ms ease 0s;\n`;\n\nexport const TabsContainer = styled('div')<TabsStyles>`\n position: relative;\n display: ${({ direction }) => (direction === 'vertical' ? 'flex' : 'block')};\n ${({ direction, position }) =>\n direction === 'vertical' && position === 'right' ? 'flex-direction: row-reverse' : null};\n`;\n\nexport const TabControlList = styled('div')<TabsStyles>`\n position: relative;\n display: ${({ fullWidth, variant }) =>\n fullWidth || variant !== 'pills' ? 'flex' : 'inline-flex'};\n font-size: ${({ size }) => sizes[size].fontSize};\n align-items: center;\n ${({ variant, theme, radius, direction, position, color }) =>\n getContainerStyles(variant, theme, radius, direction, position, color)};\n`;\n\nexport const TabPanel = styled('div')<TabsStyles>`\n display: block;\n ${({ direction, position, tabPadding, theme }) =>\n getPanelPadding(direction, position, tabPadding, theme)};\n`;\n\ninterface BgSpanStyles extends React.ComponentPropsWithoutRef<any> {}\n\nexport const PillsBg = styled('span')<BgSpanStyles>`\n border-radius: ${({ radius, theme }) => getSizeValue(radius, theme.layout.radius)};\n position: absolute;\n box-sizing: border-box;\n top: 1px;\n bottom: 1px;\n z-index: 1;\n background-color: ${({ theme, color }) => getColor(color, theme)};\n width: ${({ width }) => width}px;\n transform: translateX(${({ transform }) => transform}px);\n transition: transform 150ms ease 0s, width 100ms linear 0s;\n`;\n\nconst getLineBgStyles = (width, height, direction, position, translate, translateY) => {\n if (direction === 'vertical') {\n return css`\n width: 2px;\n height: ${height}px;\n transform: translateY(${translateY}px);\n top: 0;\n ${position === 'right' ? 'left: 0;\\nmargin-left: -1px;' : 'right: 0;\\nmargin-right: -1px;'};\n `;\n }\n\n return css`\n height: 2px;\n width: ${width}px;\n transform: translateX(${translate}px);\n bottom: 0;\n margin-bottom: -1px;\n `;\n};\n\nexport const LineBg = styled('span')<BgSpanStyles>`\n position: absolute;\n box-sizing: border-box;\n z-index: 1;\n background-color: ${({ theme, color }) =>\n color ? themeUtils.getColor(color, theme) : theme.palette.accents_7};\n transition: transform 150ms ease 0s, width 100ms linear 0s;\n ${({ width, height, direction, position, transform, translateY }) =>\n getLineBgStyles(width, height, direction, position, transform, translateY)};\n`;\n"],"names":["themeUtils","css","styled"],"mappings":";;;;;;;;;;;AAEA,MAAM,EAAE,YAAY,EAAE,GAAGA,gBAAU,CAAC;AACxB,MAAC,eAAe,GAAG,EAAE;AACjC,MAAM,KAAK,GAAG;AACd,EAAE,EAAE,EAAE;AACN,IAAI,QAAQ,EA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,QAAQ,EAAE,SAAS,EAAE,UAAU,KAAK;AACvF,EAAE,IAAI,SAAS,KAAK,UAAU,EAAE;AAChC,IAAI,OAAOD,UAAG,CAAC;AACf;AACA,cAAc,EAAE,MAAM,CAAC;AACvB,4BAA4B,EAAE,UAAU,CAAC;AACzC;AACA,MAAM,EAAE,QAAQ,KAAK,OAAO,GAAG,8BAA8B,GAAG,gCAAgC,CAAC;AACjG,IAAI,CAAC,CAAC;AACN,GAAG;AACH,EAAE,OAAOA,UAAG,CAAC;AACb;AACA,WAAW,EAAE,KAAK,CAAC;AACnB,0BAA0B,EAAE,SAAS,CAAC;AACtC;AACA;AACA,EAAE,CAAC,CAAC;AACJ,CAAC,CAAC;AACU,MAAC,MAAM,GAAGC,eAAM,CAAC,MAAM,CAAC,CAAC;AACrC;AACA;AACA;AACA,oBAAoB,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,KAAK,GAAGF,gBAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;AAChH;AACA,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AAClJ;;;;;;;;;;;"}
|
package/cjs/Tag/Tag.js
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),styled=require("styled-components"),forwardRef=require("../utils/forwardRef.js"),utils=require("../theme/utils.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e.default:e}var React__default=_interopDefaultLegacy(React),styled__default=_interopDefaultLegacy(styled),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,r,t)=>r in e?__defProp(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,__spreadValues=(e,r)=>{for(var t in r||(r={}))__hasOwnProp.call(r,t)&&__defNormalProp(e,t,r[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(r))__propIsEnum.call(r,t)&&__defNormalProp(e,t,r[t]);return e},__objRest=(e,r)=>{var t={};for(var
|
|
2
|
-
background-color: ${
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),styled=require("styled-components"),icons=require("@kubed/icons"),forwardRef=require("../utils/forwardRef.js"),color=require("../utils/color.js"),utils=require("../theme/utils.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e.default:e}var React__default=_interopDefaultLegacy(React),styled__default=_interopDefaultLegacy(styled),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,r,t)=>r in e?__defProp(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,__spreadValues=(e,r)=>{for(var t in r||(r={}))__hasOwnProp.call(r,t)&&__defNormalProp(e,t,r[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(r))__propIsEnum.call(r,t)&&__defNormalProp(e,t,r[t]);return e},__objRest=(e,r)=>{var t={};for(var o in e)__hasOwnProp.call(e,o)&&r.indexOf(o)<0&&(t[o]=e[o]);if(e!=null&&__getOwnPropSymbols)for(var o of __getOwnPropSymbols(e))r.indexOf(o)<0&&__propIsEnum.call(e,o)&&(t[o]=e[o]);return t};const colorMap={default:{color:"background",background:"accents_8"},primary:{color:"green4",background:"green0"},success:{color:"green4",background:"green0"},secondary:{color:"accents_7",background:"accents_2"},warning:{color:"yellow4",background:"yellow0"},error:{color:"red4",background:"red0"},info:{color:"blue4",background:"blue0"}},getColor=(e="default",r)=>{const t=utils.default.getColor(colorMap[e].color,r),o=utils.default.getColor(colorMap[e].background,r);return styled.css`
|
|
2
|
+
background-color: ${o};
|
|
3
3
|
color: ${t};
|
|
4
4
|
`},TagWrapper=styled__default("div")`
|
|
5
5
|
display: inline-flex;
|
|
6
6
|
align-items: center;
|
|
7
7
|
padding: ${({title:e})=>e?"0 6px 0 2px":"0 4px"};
|
|
8
8
|
line-height: 20px;
|
|
9
|
-
border-radius: ${({title:e})=>e?"3px":"2px"};
|
|
9
|
+
border-radius: ${({title:e,radius:r,theme:t})=>r?utils.default.getSizeValue(r,t.layout.radius):e?"3px":"2px"};
|
|
10
10
|
word-break: break-all;
|
|
11
11
|
white-space: normal;
|
|
12
12
|
font-weight: 600;
|
|
13
13
|
${({color:e,theme:r})=>getColor(e,r)};
|
|
14
|
+
|
|
15
|
+
.tag-close {
|
|
16
|
+
margin-left: 6px;
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
border-radius: 3px;
|
|
19
|
+
&:hover {
|
|
20
|
+
background-color: ${({theme:e})=>color.addColorAlpha(e.palette.accents_6,.6)};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
14
23
|
`,TagTitle=styled__default("span")`
|
|
15
24
|
display: inline-flex;
|
|
16
25
|
padding: 0 6px;
|
|
@@ -20,5 +29,5 @@
|
|
|
20
29
|
background-color: ${({theme:e})=>e.palette.accents_7};
|
|
21
30
|
border-radius: 1px;
|
|
22
31
|
font-weight: 500;
|
|
23
|
-
`,Tag=forwardRef.default((e,r)=>{var t=e,{title:
|
|
32
|
+
`,Tag=forwardRef.default((e,r)=>{var t=e,{radius:o,title:l,titleStyle:s,color:d,onClose:i,children:u,prepend:p,append:f,closable:g}=t,a=__objRest(t,["radius","title","titleStyle","color","onClose","children","prepend","append","closable"]);const[b,c]=React.useState(!0);React.useEffect(()=>{"visible"in a&&c(a.visible)},[a.visible]);const v=n=>{n.stopPropagation(),i==null||i(n),!n.defaultPrevented&&("visible"in a||c(!1))};return b?React__default.createElement(TagWrapper,__spreadValues({ref:r,radius:o,title:l,color:d},a),p,l&&React__default.createElement(TagTitle,{style:s},l),u,f,g&&React__default.createElement(icons.Close,{variant:"light",className:"tag-close",onClick:v})):null});Tag.displayName="@kubed/components/Tag",exports.Tag=Tag;
|
|
24
33
|
//# sourceMappingURL=Tag.js.map
|
package/cjs/Tag/Tag.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.js","sources":["../../src/Tag/Tag.tsx"],"sourcesContent":["import React from 'react';\nimport styled, { css } from 'styled-components';\nimport forwardRef from '../utils/forwardRef';\nimport { DefaultProps, KubedTheme, themeUtils } from '../theme';\n\nconst colorMap = {\n default: {\n color: 'background',\n background: 'accents_8',\n },\n primary: {\n color: 'green4',\n background: 'green0',\n },\n success: {\n color: 'green4',\n background: 'green0',\n },\n secondary: {\n color: 'accents_7',\n background: 'accents_2',\n },\n warning: {\n color: 'yellow4',\n background: 'yellow0',\n },\n error: {\n color: 'red4',\n background: 'red0',\n },\n info: {\n color: 'blue4',\n background: 'blue0',\n },\n};\n\nconst getColor = (color = 'default', theme: KubedTheme) => {\n const colorValue = themeUtils.getColor(colorMap[color].color, theme);\n const background = themeUtils.getColor(colorMap[color].background, theme);\n\n return css`\n background-color: ${background};\n color: ${colorValue};\n `;\n};\n\nconst TagWrapper = styled('div')<TagProps>`\n display: inline-flex;\n align-items: center;\n padding: ${({ title }) => (title ? '0 6px 0 2px' : '0 4px')};\n line-height: 20px;\n border-radius: ${({ title })
|
|
1
|
+
{"version":3,"file":"Tag.js","sources":["../../src/Tag/Tag.tsx"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport styled, { css } from 'styled-components';\nimport { Close } from '@kubed/icons';\nimport forwardRef from '../utils/forwardRef';\nimport { DefaultProps, KubedTheme, KubedNumberSize, themeUtils } from '../theme';\nimport { addColorAlpha } from '../utils/color';\n\nconst colorMap = {\n default: {\n color: 'background',\n background: 'accents_8',\n },\n primary: {\n color: 'green4',\n background: 'green0',\n },\n success: {\n color: 'green4',\n background: 'green0',\n },\n secondary: {\n color: 'accents_7',\n background: 'accents_2',\n },\n warning: {\n color: 'yellow4',\n background: 'yellow0',\n },\n error: {\n color: 'red4',\n background: 'red0',\n },\n info: {\n color: 'blue4',\n background: 'blue0',\n },\n};\n\nconst getColor = (color = 'default', theme: KubedTheme) => {\n const colorValue = themeUtils.getColor(colorMap[color].color, theme);\n const background = themeUtils.getColor(colorMap[color].background, theme);\n\n return css`\n background-color: ${background};\n color: ${colorValue};\n `;\n};\n\nconst TagWrapper = styled('div')<TagProps>`\n display: inline-flex;\n align-items: center;\n padding: ${({ title }) => (title ? '0 6px 0 2px' : '0 4px')};\n line-height: 20px;\n border-radius: ${({ title, radius, theme }) =>\n radius ? themeUtils.getSizeValue(radius, theme.layout.radius) : title ? '3px' : '2px'};\n word-break: break-all;\n white-space: normal;\n font-weight: 600;\n ${({ color, theme }) => getColor(color, theme)};\n\n .tag-close {\n margin-left: 6px;\n cursor: pointer;\n border-radius: 3px;\n &:hover {\n background-color: ${({ theme }) => addColorAlpha(theme.palette.accents_6, 0.6)};\n }\n }\n`;\n\nconst TagTitle = styled('span')`\n display: inline-flex;\n padding: 0 6px;\n margin: 2px 6px 2px 0;\n line-height: 16px;\n color: ${({ theme }) => theme.palette.background};\n background-color: ${({ theme }) => theme.palette.accents_7};\n border-radius: 1px;\n font-weight: 500;\n`;\n\nexport interface TagProps extends DefaultProps {\n /** Title of the tag */\n title?: React.ReactNode;\n\n /** Style of title */\n titleStyle?: React.CSSProperties;\n\n /** Tag color from theme */\n color?: 'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'error' | 'info' | string;\n\n /** Append element of the tag */\n append?: React.ReactNode;\n\n /** Prepend element of the tag */\n prepend?: React.ReactNode;\n\n /** Radius of the tag */\n radius?: KubedNumberSize;\n\n visible?: boolean;\n\n closable?: boolean;\n\n onClose?: (e: React.MouseEvent<SVGElement>) => void;\n}\n\nexport const Tag = forwardRef<TagProps, 'div'>(\n (\n { radius, title, titleStyle, color, onClose, children, prepend, append, closable, ...rest },\n ref\n ) => {\n const [visible, setVisible] = useState(true);\n\n useEffect(() => {\n if ('visible' in rest) {\n setVisible(rest.visible!);\n }\n }, [rest.visible]);\n\n const handleClose = (e: React.MouseEvent<SVGElement>) => {\n e.stopPropagation();\n onClose?.(e);\n\n if (e.defaultPrevented) {\n return;\n }\n if (!('visible' in rest)) {\n setVisible(false);\n }\n };\n\n if (!visible) return null;\n\n return (\n <TagWrapper ref={ref} radius={radius} title={title} color={color} {...rest}>\n {prepend}\n {title && <TagTitle style={titleStyle}>{title}</TagTitle>}\n {children}\n {append}\n {closable && <Close variant=\"light\" className=\"tag-close\" onClick={handleClose} />}\n </TagWrapper>\n );\n }\n);\n\nTag.displayName = '@kubed/components/Tag';\n"],"names":["themeUtils","css","styled","addColorAlpha","forwardRef","useState","useEffect","React","Close"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AA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;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),lodash=require("lodash"),cx=require("classnames"),icons=require("@kubed/icons"),hooks=require("@kubed/hooks"),forwardRef=require("../utils/forwardRef.js"),Field=require("../Entity/Field.js"),TypeSelect_styles=require("./TypeSelect.styles.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e.default:e}var React__default=_interopDefaultLegacy(React),cx__default=_interopDefaultLegacy(cx);const TypeSelect=forwardRef.default(({options:e,value:n,defaultValue:i,className:v,onChange:d},m)=>{const[a,l]=React.useState(!1),y=hooks.useClickOutside(()=>{l(!1)}),k=hooks.useMergedRef(m,y),s=r=>lodash.isUndefined(r)?!1:e.some(t=>t.value===r),E=()=>s(n)?n:s(i)?i:e[0].value,[p,f]=React.useState(E());React.useEffect(()=>{s(n)&&f(n)},[n]);const w=()=>{const r=e.find(u=>u.value===p),{label:t,description:o,icon:c}=r;return React__default.createElement(TypeSelect_styles.ControlWrapper,{onClick:()=>{l(!a)},$expanded:a},React__default.createElement(Field.Field,{label:o,value:t,avatar:c}))},b=r=>{lodash.isUndefined(n)&&f(r.value),l(!1),d&&d(r.value,r)},_=()=>e.filter(t=>t.value!==p).map(t=>{const{label:o,description:c,icon:u,value:q}=t;return React__default.createElement(TypeSelect_styles.DropdownOption,{key:q,onClick:()=>b(t)},React__default.createElement(Field.Field,{label:c,value:o,avatar:u}))});return React__default.createElement(TypeSelect_styles.TypeSelectWrapper,{ref:k,className:cx__default(v,{"is-expand":a})},w(),a&&React__default.createElement(TypeSelect_styles.DropdownWrapper,null,_()),!a&&React__default.createElement(TypeSelect_styles.DropdownArrow,null,React__default.createElement(icons.ChevronDown,null)))});TypeSelect.displayName="@kubed/components/TypeSelect",exports.TypeSelect=TypeSelect;
|
|
2
|
+
//# sourceMappingURL=TypeSelect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeSelect.js","sources":["../../src/TypeSelect/TypeSelect.tsx"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport { isUndefined } from 'lodash';\nimport cx from 'classnames';\nimport { ChevronDown } from '@kubed/icons';\nimport { useClickOutside, useMergedRef } from '@kubed/hooks';\nimport { DefaultProps } from '../theme';\nimport forwardRef from '../utils/forwardRef';\nimport { Field } from '../Entity/Field';\nimport {\n TypeSelectWrapper,\n ControlWrapper,\n DropdownWrapper,\n DropdownOption,\n DropdownArrow,\n} from './TypeSelect.styles';\n\ninterface OptionProps {\n /** Field label */\n label: React.ReactNode;\n\n /** Field description */\n description?: React.ReactNode;\n\n value: React.ReactNode;\n\n /** Field avatar */\n icon?: React.ReactNode;\n}\n\nexport interface TypeSelectProps extends DefaultProps {\n value?: any;\n defaultValue?: any;\n options: OptionProps[];\n onChange?: (value: any, option: OptionProps) => void;\n}\n\nexport const TypeSelect = forwardRef<TypeSelectProps, 'div'>(\n ({ options, value, defaultValue, className, onChange }, ref) => {\n const [expanded, setExpanded] = useState(false);\n\n const useClickOutsideRef = useClickOutside(() => {\n setExpanded(false);\n });\n const mergedRef = useMergedRef(ref, useClickOutsideRef);\n\n const isValidValue = (v) => {\n if (isUndefined(v)) {\n return false;\n }\n return options.some((option) => option.value === v);\n };\n\n const getInitialValue = () => {\n if (isValidValue(value)) {\n return value;\n }\n if (isValidValue(defaultValue)) {\n return defaultValue;\n }\n return options[0].value;\n };\n\n const [_value, setValue] = useState(getInitialValue());\n\n useEffect(() => {\n if (isValidValue(value)) {\n setValue(value);\n }\n }, [value]);\n\n const renderControl = () => {\n const currentOption = options.find((option) => option.value === _value);\n const { label, description, icon } = currentOption;\n return (\n <ControlWrapper\n onClick={() => {\n setExpanded(!expanded);\n }}\n $expanded={expanded}\n >\n <Field label={description} value={label} avatar={icon} />\n </ControlWrapper>\n );\n };\n\n const onOptionClick = (option) => {\n if (isUndefined(value)) {\n setValue(option.value);\n }\n setExpanded(false);\n onChange && onChange(option.value, option);\n };\n\n const renderDropdown = () => {\n const dropdownOptions = options.filter((option) => option.value !== _value);\n return dropdownOptions.map((option) => {\n const { label, description, icon, value: optionValue } = option;\n return (\n // @ts-ignore\n <DropdownOption key={optionValue} onClick={() => onOptionClick(option)}>\n <Field label={description} value={label} avatar={icon} />\n </DropdownOption>\n );\n });\n };\n\n return (\n <TypeSelectWrapper ref={mergedRef} className={cx(className, { 'is-expand': expanded })}>\n {renderControl()}\n {expanded && <DropdownWrapper>{renderDropdown()}</DropdownWrapper>}\n {!expanded && (\n <DropdownArrow>\n <ChevronDown />\n </DropdownArrow>\n )}\n </TypeSelectWrapper>\n );\n }\n);\n\nTypeSelect.displayName = '@kubed/components/TypeSelect';\n"],"names":["forwardRef","useState","useClickOutside","useMergedRef","isUndefined","useEffect","React","ControlWrapper","Field","DropdownOption","TypeSelectWrapper","cx","DropdownWrapper","DropdownArrow","ChevronDown"],"mappings":";;;;;;;;;;;;;;;;;;AAcY,MAAC,UAAU,GAAGA,qBAAU,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,GAAG,KAAK;AACrG,EAAE,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAGC,cAAQ,CAAC,KAAK,CAAC,CAAC;AAClD,EAAE,MAAM,kBAAkB,GAAGC,qBAAe,CAAC,MAAM;AACnD,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC;AACvB,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,SAAS,GAAGC,kBAAY,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;AAC1D,EAAE,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK;AAC9B,IAAI,IAAIC,kBAAW,CAAC,CAAC,CAAC,EAAE;AACxB,MAAM,OAAO,KAAK,CAAC;AACnB,KAAK;AACL,IAAI,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC;AAC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,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC,QAAQ,oBAAoBN,cAAK,CAAC,aAAa,CAACO,+BAAa,EAAE,IAAI,kBAAkBP,cAAK,CAAC,aAAa,CAACQ,iBAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AAC/O,CAAC,EAAE;AACH,UAAU,CAAC,WAAW,GAAG,8BAA8B;;;;"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var styled=require("styled-components");function _interopDefaultLegacy(o){return o&&typeof o=="object"&&"default"in o?o.default:o}var styled__default=_interopDefaultLegacy(styled);const getExpandedStyle=(o,r)=>o?styled.css`
|
|
2
|
+
border-color: ${r.palette.accents_5};
|
|
3
|
+
border-bottom: 0;
|
|
4
|
+
border-bottom-right-radius: 0;
|
|
5
|
+
border-bottom-left-radius: 0;
|
|
6
|
+
transition: none;
|
|
7
|
+
background-color: ${r.palette.accents_1};
|
|
8
|
+
`:null,TypeSelectWrapper=styled__default("div")`
|
|
9
|
+
position: relative;
|
|
10
|
+
border-radius: 4px;
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
`,ControlWrapper=styled__default("div")`
|
|
13
|
+
border-radius: 4px;
|
|
14
|
+
border: 1px solid ${({theme:o})=>o.palette.border};
|
|
15
|
+
height: 64px;
|
|
16
|
+
padding: 12px 64px 12px 12px;
|
|
17
|
+
transition: all 0.3s ease-in-out;
|
|
18
|
+
background-color: #fff;
|
|
19
|
+
|
|
20
|
+
&:hover {
|
|
21
|
+
border-color: ${({theme:o})=>o.palette.accents_5};
|
|
22
|
+
}
|
|
23
|
+
${({$expanded:o,theme:r})=>getExpandedStyle(o,r)};
|
|
24
|
+
`,DropdownArrow=styled__default.div`
|
|
25
|
+
position: absolute;
|
|
26
|
+
height: 16px;
|
|
27
|
+
top: 50%;
|
|
28
|
+
right: 12px;
|
|
29
|
+
transform: translateY(-50%);
|
|
30
|
+
&:hover {
|
|
31
|
+
background-color: ${({theme:o})=>o.palette.accents_1};
|
|
32
|
+
}
|
|
33
|
+
z-index: 999;
|
|
34
|
+
`,DropdownWrapper=styled__default.div`
|
|
35
|
+
position: absolute;
|
|
36
|
+
top: 63px;
|
|
37
|
+
left: 0px;
|
|
38
|
+
width: 100%;
|
|
39
|
+
border: 1px solid ${({theme:o})=>o.palette.accents_5};
|
|
40
|
+
border-radius: 4px;
|
|
41
|
+
border-top-right-radius: 0;
|
|
42
|
+
border-top-left-radius: 0;
|
|
43
|
+
border-top: 0;
|
|
44
|
+
background-color: ${({theme:o})=>o.palette.background};
|
|
45
|
+
z-index: 9999;
|
|
46
|
+
//box-sizing: content-box;
|
|
47
|
+
`,DropdownOption=styled__default.div`
|
|
48
|
+
height: 64px;
|
|
49
|
+
padding: 12px 64px 12px 12px;
|
|
50
|
+
&:hover {
|
|
51
|
+
background-color: ${({theme:o})=>o.palette.accents_0};
|
|
52
|
+
}
|
|
53
|
+
`;exports.ControlWrapper=ControlWrapper,exports.DropdownArrow=DropdownArrow,exports.DropdownOption=DropdownOption,exports.DropdownWrapper=DropdownWrapper,exports.TypeSelectWrapper=TypeSelectWrapper;
|
|
54
|
+
//# sourceMappingURL=TypeSelect.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeSelect.styles.js","sources":["../../src/TypeSelect/TypeSelect.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\n\ninterface ControlWrapperProps {\n $expanded: boolean;\n}\n\nconst getExpandedStyle = (expanded: boolean, theme) => {\n if (expanded) {\n return css`\n border-color: ${theme.palette.accents_5};\n border-bottom: 0;\n border-bottom-right-radius: 0;\n border-bottom-left-radius: 0;\n transition: none;\n background-color: ${theme.palette.accents_1};\n `;\n }\n return null;\n};\n\nexport const TypeSelectWrapper = styled('div')`\n position: relative;\n border-radius: 4px;\n cursor: pointer;\n`;\n\nexport const ControlWrapper = styled('div')<ControlWrapperProps>`\n border-radius: 4px;\n border: 1px solid ${({ theme }) => theme.palette.border};\n height: 64px;\n padding: 12px 64px 12px 12px;\n transition: all 0.3s ease-in-out;\n background-color: #fff;\n\n &:hover {\n border-color: ${({ theme }) => theme.palette.accents_5};\n }\n ${({ $expanded, theme }) => getExpandedStyle($expanded, theme)};\n`;\n\nexport const DropdownArrow = styled.div`\n position: absolute;\n height: 16px;\n top: 50%;\n right: 12px;\n transform: translateY(-50%);\n &:hover {\n background-color: ${({ theme }) => theme.palette.accents_1};\n }\n z-index: 999;\n`;\n\nexport const DropdownWrapper = styled.div`\n position: absolute;\n top: 63px;\n left: 0px;\n width: 100%;\n border: 1px solid ${({ theme }) => theme.palette.accents_5};\n border-radius: 4px;\n border-top-right-radius: 0;\n border-top-left-radius: 0;\n border-top: 0;\n background-color: ${({ theme }) => theme.palette.background};\n z-index: 9999;\n //box-sizing: content-box;\n`;\n\nexport const DropdownOption = styled.div`\n height: 64px;\n padding: 12px 64px 12px 12px;\n &:hover {\n background-color: ${({ theme }) => theme.palette.accents_0};\n }\n`;\n"],"names":["css","styled"],"mappings":";;;;;;;;;;AACA,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,KAAK,KAAK;AAC9C,EAAE,IAAI,QAAQ,EAAE;AAChB,IAAI,OAAOA,UAAG,CAAC;AACf,oBAAoB,EAAE,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;AAC9C;AACA;AACA;AACA;AACA,wBAAwB,EAAE,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;AAClD,IAAI,CAAC,CAAC;AACN,GAAG;AACH,EAAE,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AACU,MAAC,iBAAiB,GAAGC,eAAM,CAAC,KAAK,CAAC,CAAC;AAC/C;AACA;AACA;AACA,EAAE;AACU,MAAC,cAAc,GAAGA,eAAM,CAAC,KAAK,CAAC,CAAC;AAC5C;AACA,oBAAoB,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;AAC3D;AACA,EAAE,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,gBAAgB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AACjE,EAAE;AACU,MAAC,aAAa,GAAGA,eAAM,CAAC,GAAG,CAAC;AACxC;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;AAC/D;AACA;AACA,EAAE;AACU,MAAC,eAAe,GAAGA,eAAM,CAAC,GAAG,CAAC;AAC1C;AACA;AACA;AACA;AACA,oBAAoB,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;AAC7D;AACA;AACA;AACA;AACA,oBAAoB,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;AAC9D;AACA;AACA,EAAE;AACU,MAAC,cAAc,GAAGA,eAAM,CAAC,GAAG,CAAC;AACzC;AACA;AACA;AACA,sBAAsB,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;AAC/D;AACA;;;;;;;;"}
|
package/cjs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var index=require("./ConfigProvider/index.js"),Button=require("./Button/Button.js"),Group=require("./Group/Group.js"),Container=require("./Container/Container.js"),Center=require("./Center/Center.js"),Row=require("./Grid/Row.js"),Navs=require("./Navs/Navs.js"),Snippet=require("./Snippet/Snippet.js"),Tabs=require("./Tabs/Tabs.js"),Text=require("./Text/Text.js"),Tooltip=require("./Tooltip/Tooltip.js"),Popover=require("./Popover/Popover.js"),Divider=require("./Divider/Divider.js"),Menu=require("./Menu/Menu.js"),StatusDot=require("./StatusDot/StatusDot.js"),Tag=require("./Tag/Tag.js"),Badge=require("./Badge/Badge.js"),Alert=require("./Alert/Alert.js"),Card=require("./Card/Card.js"),Descriptions=require("./Descriptions/Descriptions.js"),Entity=require("./Entity/Entity.js"),Dropdown=require("./Dropdown/Dropdown.js"),Loading=require("./Loading/Loading.js"),LoadingOverlay=require("./LoadingOverlay/LoadingOverlay.js"),Input=require("./Input/Input.js"),InputPassword=require("./InputPassword/InputPassword.js"),FilterInput=require("./FilterInput/FilterInput.js"),Empty=require("./Empty/Empty.js"),Form=require("./Form/Form.js"),Select=require("./Select/Select.js"),Checkbox=require("./Checkbox/Checkbox.js"),Radio=require("./Radio/Radio.js"),Switch=require("./Switch/Switch.js"),InputNumber=require("./InputNumber/InputNumber.js"),DatePicker=require("./DatePicker/DatePicker.js"),TimePicker=require("./TimePicker/TimePicker.js"),Banner=require("./Banner/Banner.js"),Notify=require("./Notify/Notify.js"),AutoComplete=require("./AutoComplete/AutoComplete.js"),ActionConfirm=require("./ActionConfirm/ActionConfirm.js"),Progress=require("./Progress/Progress.js"),color=require("./utils/color.js"),Drawer=require("./Drawer/Drawer.js"),Collapse=require("./Collapse/Collapse.js"),forwardRef=require("./utils/forwardRef.js"),toArray=require("./utils/toArray.js"),useForm=require("./Form/hooks/useForm.js"),Col=require("./Grid/Col.js"),Tab=require("./Tabs/Tab/Tab.js"),MenuLabel=require("./Menu/MenuLabel/MenuLabel.js"),MenuItem=require("./Menu/MenuItem/MenuItem.js"),BadgeAnchor=require("./Badge/BadgeAnchor.js"),Description=require("./Descriptions/Description.js"),Field=require("./Entity/Field.js"),Modal=require("./Modal/Modal.js"),ModalContext=require("./Modal/ModalProvider/ModalContext.js"),CheckboxGroup=require("./Checkbox/CheckboxGroup.js"),RadioGroup=require("./Radio/RadioGroup.js"),BannerTip=require("./Banner/BannerTip.js"),toast=require("react-hot-toast"),Slider=require("./Slider/Slider/Slider.js"),RangeSlider=require("./Slider/RangeSlider/RangeSlider.js"),CssBaseline=require("./theme/CssBaseline.js"),ThemeContext=require("./theme/ThemeContext.js"),utils=require("./theme/utils.js"),FieldForm=require("rc-field-form"),FormItem=require("./Form/FormItem/FormItem.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e.default:e}var toast__default=_interopDefaultLegacy(toast);exports.KubedConfigProvider=index.KubedConfigProvider,exports.Button=Button.Button,exports.Group=Group.Group,exports.Container=Container.Container,exports.Center=Center.Center,exports.Row=Row.Row,exports.Navs=Navs.Navs,exports.Snippet=Snippet.Snippet,exports.Tabs=Tabs.Tabs,exports.Text=Text.Text,exports.Tooltip=Tooltip.Tooltip,exports.Popover=Popover.Popover,exports.Divider=Divider.Divider,exports.Menu=Menu.Menu,exports.StatusDot=StatusDot.StatusDot,exports.Tag=Tag.Tag,exports.Badge=Badge.Badge,exports.Alert=Alert.Alert,exports.Card=Card.Card,exports.Descriptions=Descriptions.Descriptions,exports.Entity=Entity.Entity,exports.Dropdown=Dropdown.Dropdown,exports.Loading=Loading.Loading,exports.LoadingOverlay=LoadingOverlay.LoadingOverlay,exports.Input=Input.Input,exports.InputPassword=InputPassword.InputPassword,exports.FilterInput=FilterInput.FilterInput,exports.Empty=Empty.Empty,exports.Form=Form.Form,exports.Select=Select.Select,exports.Checkbox=Checkbox.Checkbox,exports.Radio=Radio.Radio,exports.Switch=Switch.Switch,exports.InputNumber=InputNumber.InputNumber,exports.DatePicker=DatePicker.DatePicker,exports.TimePicker=TimePicker.default,exports.Banner=Banner.Banner,exports.Notify=Notify.Notify,exports.AutoComplete=AutoComplete.AutoComplete,exports.ActionConfirm=ActionConfirm.ActionConfirm,exports.Progress=Progress.Progress,exports.addColorAlpha=color.addColorAlpha,exports.colorToRgbValues=color.colorToRgbValues,exports.Drawer=Drawer.default,exports.Collapse=Collapse.default,exports.forwardRef=forwardRef.default,exports.toArray=toArray.default,exports.useForm=useForm.default,exports.Col=Col.Col,exports.Tab=Tab.Tab,exports.MenuLabel=MenuLabel.MenuLabel,exports.MenuItem=MenuItem.MenuItem,exports.BadgeAnchor=BadgeAnchor.BadgeAnchor,exports.Description=Description.Description,exports.Field=Field.Field,exports.Modal=Modal.Modal,exports.useModal=ModalContext.useModal,exports.CheckboxGroup=CheckboxGroup.CheckboxGroup,exports.RadioGroup=RadioGroup.RadioGroup,exports.BannerTip=BannerTip.BannerTip,exports.notify=toast__default,exports.Slider=Slider.Slider,exports.RangeSlider=RangeSlider.RangeSlider,exports.CssBaseline=CssBaseline.default,exports.useTheme=ThemeContext.useTheme,exports.themeUtils=utils.default,exports.FormList=FieldForm.List,exports.FormItem=FormItem.FormItem;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var index=require("./ConfigProvider/index.js"),Button=require("./Button/Button.js"),Group=require("./Group/Group.js"),Container=require("./Container/Container.js"),Center=require("./Center/Center.js"),Row=require("./Grid/Row.js"),Navs=require("./Navs/Navs.js"),Snippet=require("./Snippet/Snippet.js"),Tabs=require("./Tabs/Tabs.js"),Text=require("./Text/Text.js"),Tooltip=require("./Tooltip/Tooltip.js"),Popover=require("./Popover/Popover.js"),Divider=require("./Divider/Divider.js"),Menu=require("./Menu/Menu.js"),StatusDot=require("./StatusDot/StatusDot.js"),Tag=require("./Tag/Tag.js"),Badge=require("./Badge/Badge.js"),Alert=require("./Alert/Alert.js"),Card=require("./Card/Card.js"),Descriptions=require("./Descriptions/Descriptions.js"),Entity=require("./Entity/Entity.js"),Dropdown=require("./Dropdown/Dropdown.js"),Loading=require("./Loading/Loading.js"),LoadingOverlay=require("./LoadingOverlay/LoadingOverlay.js"),Input=require("./Input/Input.js"),InputPassword=require("./InputPassword/InputPassword.js"),FilterInput=require("./FilterInput/FilterInput.js"),Empty=require("./Empty/Empty.js"),Form=require("./Form/Form.js"),Select=require("./Select/Select.js"),Checkbox=require("./Checkbox/Checkbox.js"),Radio=require("./Radio/Radio.js"),Switch=require("./Switch/Switch.js"),InputNumber=require("./InputNumber/InputNumber.js"),DatePicker=require("./DatePicker/DatePicker.js"),TimePicker=require("./TimePicker/TimePicker.js"),Banner=require("./Banner/Banner.js"),Notify=require("./Notify/Notify.js"),AutoComplete=require("./AutoComplete/AutoComplete.js"),ActionConfirm=require("./ActionConfirm/ActionConfirm.js"),Progress=require("./Progress/Progress.js"),color=require("./utils/color.js"),Steps=require("./Steps/Steps.js"),TypeSelect=require("./TypeSelect/TypeSelect.js"),ShowMore=require("./ShowMore/ShowMore.js"),Drawer=require("./Drawer/Drawer.js"),Collapse=require("./Collapse/Collapse.js"),forwardRef=require("./utils/forwardRef.js"),toArray=require("./utils/toArray.js"),useForm=require("./Form/hooks/useForm.js"),Col=require("./Grid/Col.js"),Tab=require("./Tabs/Tab/Tab.js"),MenuLabel=require("./Menu/MenuLabel/MenuLabel.js"),MenuItem=require("./Menu/MenuItem/MenuItem.js"),BadgeAnchor=require("./Badge/BadgeAnchor.js"),Description=require("./Descriptions/Description.js"),Field=require("./Entity/Field.js"),Modal=require("./Modal/Modal.js"),ModalContext=require("./Modal/ModalProvider/ModalContext.js"),CheckboxGroup=require("./Checkbox/CheckboxGroup.js"),RadioGroup=require("./Radio/RadioGroup.js"),BannerTip=require("./Banner/BannerTip.js"),toast=require("react-hot-toast"),Slider=require("./Slider/Slider/Slider.js"),RangeSlider=require("./Slider/RangeSlider/RangeSlider.js"),Step=require("./Steps/Step/Step.js"),StepCompleted=require("./Steps/StepCompleted/StepCompleted.js"),TabStep=require("./Steps/TabStep/TabStep.js"),CssBaseline=require("./theme/CssBaseline.js"),ThemeContext=require("./theme/ThemeContext.js"),utils=require("./theme/utils.js"),FieldForm=require("rc-field-form"),FormItem=require("./Form/FormItem/FormItem.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e.default:e}var toast__default=_interopDefaultLegacy(toast);exports.KubedConfigProvider=index.KubedConfigProvider,exports.Button=Button.Button,exports.Group=Group.Group,exports.Container=Container.Container,exports.Center=Center.Center,exports.Row=Row.Row,exports.Navs=Navs.Navs,exports.Snippet=Snippet.Snippet,exports.Tabs=Tabs.Tabs,exports.Text=Text.Text,exports.Tooltip=Tooltip.Tooltip,exports.Popover=Popover.Popover,exports.Divider=Divider.Divider,exports.Menu=Menu.Menu,exports.StatusDot=StatusDot.StatusDot,exports.Tag=Tag.Tag,exports.Badge=Badge.Badge,exports.Alert=Alert.Alert,exports.Card=Card.Card,exports.Descriptions=Descriptions.Descriptions,exports.Entity=Entity.Entity,exports.Dropdown=Dropdown.Dropdown,exports.Loading=Loading.Loading,exports.LoadingOverlay=LoadingOverlay.LoadingOverlay,exports.Input=Input.Input,exports.InputPassword=InputPassword.InputPassword,exports.FilterInput=FilterInput.FilterInput,exports.Empty=Empty.Empty,exports.Form=Form.Form,exports.Select=Select.Select,exports.Checkbox=Checkbox.Checkbox,exports.Radio=Radio.Radio,exports.Switch=Switch.Switch,exports.InputNumber=InputNumber.InputNumber,exports.DatePicker=DatePicker.DatePicker,exports.TimePicker=TimePicker.default,exports.Banner=Banner.Banner,exports.Notify=Notify.Notify,exports.AutoComplete=AutoComplete.AutoComplete,exports.ActionConfirm=ActionConfirm.ActionConfirm,exports.Progress=Progress.Progress,exports.addColorAlpha=color.addColorAlpha,exports.colorToRgbValues=color.colorToRgbValues,exports.Steps=Steps.Steps,exports.TypeSelect=TypeSelect.TypeSelect,exports.ShowMore=ShowMore.ShowMore,exports.Drawer=Drawer.default,exports.Collapse=Collapse.default,exports.forwardRef=forwardRef.default,exports.toArray=toArray.default,exports.useForm=useForm.default,exports.Col=Col.Col,exports.Tab=Tab.Tab,exports.MenuLabel=MenuLabel.MenuLabel,exports.MenuItem=MenuItem.MenuItem,exports.BadgeAnchor=BadgeAnchor.BadgeAnchor,exports.Description=Description.Description,exports.Field=Field.Field,exports.Modal=Modal.Modal,exports.useModal=ModalContext.useModal,exports.CheckboxGroup=CheckboxGroup.CheckboxGroup,exports.RadioGroup=RadioGroup.RadioGroup,exports.BannerTip=BannerTip.BannerTip,exports.notify=toast__default,exports.Slider=Slider.Slider,exports.RangeSlider=RangeSlider.RangeSlider,exports.Step=Step.Step,exports.StepCompleted=StepCompleted.StepCompleted,exports.TabStep=TabStep.TabStep,exports.CssBaseline=CssBaseline.default,exports.useTheme=ThemeContext.useTheme,exports.themeUtils=utils.default,exports.FormList=FieldForm.List,exports.FormItem=FormItem.FormItem;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/cjs/utils/toArray.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toArray.js","sources":["../../src/utils/toArray.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"toArray.js","sources":["../../src/utils/toArray.ts"],"sourcesContent":["// https://github.com/react-component/util/blob/master/src/Children/toArray.ts\nimport React from 'react';\nimport { isFragment } from 'react-is';\n\nexport interface Option {\n keepEmpty?: boolean;\n}\n\nexport default function toArray(\n children: React.ReactNode,\n option: Option = {}\n): React.ReactElement[] {\n let ret: React.ReactElement[] = [];\n\n React.Children.forEach(children, (child: any) => {\n if ((child === undefined || child === null) && !option.keepEmpty) {\n return;\n }\n\n if (Array.isArray(child)) {\n ret = ret.concat(toArray(child));\n } else if (isFragment(child) && child.props) {\n ret = ret.concat(toArray(child.props.children, option));\n } else {\n ret.push(child);\n }\n });\n\n return ret;\n}\n"],"names":["React","isFragment"],"mappings":";;;;;;;;;;;AAEe,SAAS,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,EAAE,EAAE;AACvD,EAAE,IAAI,GAAG,GAAG,EAAE,CAAC;AACf,EAAEA,cAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,KAAK;AAC9C,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,KAAK,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE;AACnE,MAAM,OAAO;AACb,KAAK;AACL,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AAC9B,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AACvC,KAAK,MAAM,IAAIC,kBAAU,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE;AACjD,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AAC9D,KAAK,MAAM;AACX,MAAM,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACtB,KAAK;AACL,GAAG,CAAC,CAAC;AACL,EAAE,OAAO,GAAG,CAAC;AACb;;;;"}
|
package/cjs/utils/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../src/utils/types.ts"],"sourcesContent":["import React from 'react';\n\nexport type DeepPartial<T> = {\n [P in keyof T]?: T[P] extends Record<string, any> ? DeepPartial<T[P]> : T[P];\n};\n\nexport const tuple = <T extends string[]>(...args: T) => args;\n\nexport type ComponentPassThrough<T extends React.ElementType, Props> = Props &\n React.ComponentPropsWithoutRef<T> & {\n /** Element or component that will be used as root element */\n component?: T;\n };\n\nexport type As<Props = any> = React.ElementType<Props>;\n\n/**\n * Extract the props of a React element or component\n */\nexport type PropsOf<T extends As> = React.ComponentPropsWithoutRef<T> & {\n as?: As;\n};\n\nexport type OmitCommonProps<Target, OmitAdditionalProps extends keyof any = never> = Omit<\n Target,\n 'transition' | 'as' | 'color' | OmitAdditionalProps\n>;\n\nexport type RightJoinProps<\n SourceProps extends object = {},\n OverrideProps extends object = {}\n> = OmitCommonProps<SourceProps, keyof OverrideProps> & OverrideProps;\n\nexport type MergeWithAs<\n ComponentProps extends object,\n AsProps extends object,\n AdditionalProps extends object = {},\n AsComponent extends As = As\n> = RightJoinProps<ComponentProps, AdditionalProps> &\n RightJoinProps<AsProps, AdditionalProps> & {\n as?: AsComponent;\n };\n\nexport type ComponentWithAs<Component extends As, Props extends object = {}> = {\n <AsComponent extends As>(\n props: MergeWithAs<\n React.ComponentProps<Component>,\n React.ComponentProps<AsComponent>,\n Props,\n AsComponent\n >\n ): JSX.Element;\n\n displayName?: string;\n propTypes?: React.WeakValidationMap<any>;\n contextTypes?: React.ValidationMap<any>;\n defaultProps?: Partial<any>;\n id?: string;\n};\n"],"names":[],"mappings":";;;;AAAY,MAAC,KAAK,GAAG,CAAC,GAAG,IAAI,KAAK;;;;"}
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../src/utils/types.ts"],"sourcesContent":["import React from 'react';\n\nexport type DeepPartial<T> = {\n [P in keyof T]?: T[P] extends Record<string, any> ? DeepPartial<T[P]> : T[P];\n};\n\nexport const tuple = <T extends string[]>(...args: T) => args;\n\nexport type ComponentPassThrough<T extends React.ElementType, Props> = Props &\n React.ComponentPropsWithoutRef<T> & {\n /** Element or component that will be used as root element */\n component?: T;\n };\n\nexport type As<Props = any> = React.ElementType<Props>;\n\n/**\n * Extract the props of a React element or component\n */\nexport type PropsOf<T extends As> = React.ComponentPropsWithoutRef<T> & {\n as?: As;\n};\n\nexport type OmitCommonProps<Target, OmitAdditionalProps extends keyof any = never> = Omit<\n Target,\n 'transition' | 'as' | 'color' | OmitAdditionalProps\n>;\n\nexport type RightJoinProps<\n SourceProps extends object = {},\n OverrideProps extends object = {}\n> = OmitCommonProps<SourceProps, keyof OverrideProps> & OverrideProps;\n\nexport type MergeWithAs<\n ComponentProps extends object,\n AsProps extends object,\n AdditionalProps extends object = {},\n AsComponent extends As = As\n> = RightJoinProps<ComponentProps, AdditionalProps> &\n RightJoinProps<AsProps, AdditionalProps> & {\n as?: AsComponent;\n };\n\nexport type ComponentWithAs<Component extends As, Props extends object = {}> = {\n <AsComponent extends As>(\n props: MergeWithAs<\n React.ComponentProps<Component>,\n React.ComponentProps<AsComponent>,\n Props,\n AsComponent\n >\n ): JSX.Element;\n\n displayName?: string;\n propTypes?: React.WeakValidationMap<any>;\n contextTypes?: React.ValidationMap<any>;\n defaultProps?: Partial<any>;\n id?: string;\n};\n\nexport type ForwardRefWithStaticComponents<\n Props extends Record<string, any>,\n Static extends Record<string, any>\n> = ((props: Props) => React.ReactElement) &\n Static & {\n displayName: string;\n };\n"],"names":[],"mappings":";;;;AAAY,MAAC,KAAK,GAAG,CAAC,GAAG,IAAI,KAAK;;;;"}
|