UNPKG

@nivo/theming

Version:
3 lines (2 loc) 3.86 kB
"use strict";var t=require("react"),e=require("lodash/merge.js"),i=require("lodash/get.js"),n=require("lodash/set.js"),o=require("react/jsx-runtime");function r(){return r=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)({}).hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t},r.apply(null,arguments)}function l(t,e){if(null==t)return{};var i={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(-1!==e.indexOf(n))continue;i[n]=t[n]}return i}var s=["outlineWidth","outlineColor","outlineOpacity"],a=["fill","outlineWidth","outlineColor","outlineOpacity"],u={textAlign:{start:"start",center:"middle",end:"end"},textBaseline:{top:"text-before-edge",center:"middle",bottom:"text-after-edge"}},d={textAlign:{start:"left",center:"center",end:"right"},textBaseline:{top:"top",center:"middle",bottom:"bottom"}},f={textAlign:{start:"left",center:"center",end:"right"},textBaseline:{top:"top",center:"middle",bottom:"bottom"}},x={svg:u,css:d,canvas:f},c=["axis.ticks.text","axis.legend.text","legends.title.text","legends.text","legends.ticks.text","legends.title.text","labels.text","dots.text","markers.text","annotations.text"],p=function(t,e){return r({},e,t)},h=function(t,o){var r=e({},t,o);return c.forEach((function(t){n(r,t,p(i(r,t),r.text))})),r},g=function(t,i){return i?e({},t,i):t},m={background:"transparent",text:{fontFamily:"sans-serif",fontSize:11,fill:"#333333",outlineWidth:0,outlineColor:"#ffffff",outlineOpacity:1},axis:{domain:{line:{stroke:"transparent",strokeWidth:1}},ticks:{line:{stroke:"#777777",strokeWidth:1},text:{}},legend:{text:{fontSize:12}}},grid:{line:{stroke:"#dddddd",strokeWidth:1}},legends:{hidden:{symbol:{fill:"#333333",opacity:.6},text:{fill:"#333333",opacity:.6}},text:{},ticks:{line:{stroke:"#777777",strokeWidth:1},text:{fontSize:10}},title:{text:{}}},labels:{text:{}},markers:{lineColor:"#000000",lineStrokeWidth:1,text:{}},dots:{text:{}},tooltip:{container:{background:"white",color:"inherit",fontSize:"inherit",borderRadius:"2px",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.25)",padding:"5px 9px"},basic:{whiteSpace:"pre",display:"flex",alignItems:"center"},chip:{marginRight:7},table:{},tableCell:{padding:"3px 5px"},tableCellValue:{fontWeight:"bold"}},crosshair:{line:{stroke:"#000000",strokeWidth:1,strokeOpacity:.75,strokeDasharray:"6 6"}},annotations:{text:{fontSize:13,outlineWidth:2,outlineColor:"#ffffff",outlineOpacity:1},link:{stroke:"#000000",strokeWidth:1,outlineWidth:2,outlineColor:"#ffffff",outlineOpacity:1},outline:{fill:"none",stroke:"#000000",strokeWidth:2,outlineWidth:2,outlineColor:"#ffffff",outlineOpacity:1},symbol:{fill:"#000000",outlineWidth:2,outlineColor:"#ffffff",outlineOpacity:1}}},b=function(e){return t.useMemo((function(){return h(m,e)}),[e])},y=t.createContext(null),k={};exports.ThemeContext=y,exports.ThemeProvider=function(t){var e=t.theme,i=void 0===e?k:e,n=t.children,r=b(i);return o.jsx(y.Provider,{value:r,children:n})},exports.canvasStyleAttributesMapping=f,exports.convertStyleAttribute=function(t,e,i){return x[t][e][i]},exports.cssStyleAttributesMapping=d,exports.defaultTheme=m,exports.extendAxisTheme=g,exports.extendDefaultTheme=h,exports.inheritRootThemeText=p,exports.sanitizeHtmlTextStyle=function(t){var e=t.fill;return t.outlineWidth,t.outlineColor,t.outlineOpacity,r({},l(t,a),{color:e})},exports.sanitizeSvgTextStyle=function(t){return t.outlineWidth,t.outlineColor,t.outlineOpacity,l(t,s)},exports.styleAttributesMapping=x,exports.svgStyleAttributesMapping=u,exports.useExtendedAxisTheme=function(e,i){return t.useMemo((function(){return g(e,i)}),[e,i])},exports.usePartialTheme=b,exports.useTheme=function(){var e=t.useContext(y);if(null===e)throw new Error("Unable to find the theme, did you forget to wrap your component with ThemeProvider?");return e}; //# sourceMappingURL=nivo-theming.cjs.js.map