@plasmicpkgs/plasmic-tabs
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -14,6 +14,5 @@ 'use strict'; | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
@@ -25,6 +24,4 @@ if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
@@ -34,3 +31,2 @@ } | ||
var noop = function noop() {}; | ||
function defaultButtonChildren(label) { | ||
@@ -48,16 +44,11 @@ return { | ||
} | ||
var DebugContext = /*#__PURE__*/React.createContext(false); | ||
function useTabsData(_ref) { | ||
var initialKey = _ref.initialKey; | ||
var _useState = React.useState(initialKey), | ||
tabKey = _useState[0], | ||
setTabKey = _useState[1]; | ||
tabKey = _useState[0], | ||
setTabKey = _useState[1]; | ||
var _useState2 = React.useState(undefined), | ||
bbox = _useState2[0], | ||
setBbox = _useState2[1]; | ||
bbox = _useState2[0], | ||
setBbox = _useState2[1]; | ||
return { | ||
@@ -70,7 +61,5 @@ tabKey: tabKey, | ||
} | ||
var _constate = /*#__PURE__*/constate(useTabsData), | ||
TabsProvider = _constate[0], | ||
useTabsContextUnsafe = _constate[1]; | ||
TabsProvider = _constate[0], | ||
useTabsContextUnsafe = _constate[1]; | ||
function useTabsContext() { | ||
@@ -80,3 +69,2 @@ var result = useTabsContextUnsafe(); | ||
} | ||
var modulePath = "@plasmicpkgs/plasmic-tabs"; | ||
@@ -161,6 +149,6 @@ var TabsContainerMeta = { | ||
var children = _ref2.children, | ||
initialKey = _ref2.initialKey, | ||
previewKey = _ref2.previewKey, | ||
_ref2$previewAll = _ref2.previewAll, | ||
previewAll = _ref2$previewAll === void 0 ? false : _ref2$previewAll; | ||
initialKey = _ref2.initialKey, | ||
previewKey = _ref2.previewKey, | ||
_ref2$previewAll = _ref2.previewAll, | ||
previewAll = _ref2$previewAll === void 0 ? false : _ref2$previewAll; | ||
var inEditor = !!host.usePlasmicCanvasContext(); | ||
@@ -175,3 +163,2 @@ return React__default.createElement(TabsProvider, { | ||
} | ||
function ensure(x) { | ||
@@ -181,14 +168,10 @@ if (!x) { | ||
} | ||
return x; | ||
} | ||
function Helper(_ref3) { | ||
var children = _ref3.children, | ||
previewKey = _ref3.previewKey; | ||
previewKey = _ref3.previewKey; | ||
var inEditor = host.usePlasmicCanvasContext(); | ||
var _ensure = ensure(useTabsContext()), | ||
tabKey = _ensure.tabKey; | ||
tabKey = _ensure.tabKey; | ||
var effectiveKey = inEditor ? previewKey || tabKey : tabKey; | ||
@@ -200,3 +183,2 @@ return React__default.createElement(host.DataProvider, { | ||
} | ||
var TabUnderlineMeta = { | ||
@@ -219,10 +201,7 @@ name: "hostless-tab-underline", | ||
var _useTabsContext; | ||
var className = _ref4.className; | ||
var _ref5 = (_useTabsContext = useTabsContext()) != null ? _useTabsContext : { | ||
bbox: undefined | ||
}, | ||
bbox = _ref5.bbox; | ||
bbox: undefined | ||
}, | ||
bbox = _ref5.bbox; | ||
return bbox ? React__default.createElement("div", { | ||
@@ -260,18 +239,16 @@ className: className, | ||
var className = _ref6.className, | ||
children = _ref6.children, | ||
tabKey = _ref6.tabKey; | ||
children = _ref6.children, | ||
tabKey = _ref6.tabKey; | ||
var tabsContext = useTabsContext(); | ||
var ref = React.useRef(null); | ||
var _ref7 = tabsContext != null ? tabsContext : { | ||
tabKey: undefined, | ||
setTabKey: noop, | ||
bbox: undefined, | ||
setBbox: noop | ||
}, | ||
activeKey = _ref7.tabKey, | ||
setTabKey = _ref7.setTabKey, | ||
bbox = _ref7.bbox, | ||
setBbox = _ref7.setBbox; | ||
tabKey: undefined, | ||
setTabKey: noop, | ||
bbox: undefined, | ||
setBbox: noop | ||
}, | ||
activeKey = _ref7.tabKey, | ||
setTabKey = _ref7.setTabKey, | ||
bbox = _ref7.bbox, | ||
setBbox = _ref7.setBbox; | ||
React.useEffect(function () { | ||
@@ -320,11 +297,9 @@ if (tabKey === activeKey) { | ||
var children = _ref8.children, | ||
tabKey = _ref8.tabKey; | ||
tabKey = _ref8.tabKey; | ||
var tabsContext = useTabsContext(); | ||
var previewAll = React.useContext(DebugContext); | ||
var _ref9 = tabsContext != null ? tabsContext : { | ||
tabKey: undefined | ||
}, | ||
activeKey = _ref9.tabKey; | ||
tabKey: undefined | ||
}, | ||
activeKey = _ref9.tabKey; | ||
return React__default.createElement(React__default.Fragment, null, tabsContext === undefined || activeKey === tabKey || previewAll ? children : null); | ||
@@ -341,9 +316,5 @@ } | ||
}; | ||
_registerComponent(TabsContainer, TabsContainerMeta); | ||
_registerComponent(TabUnderline, TabUnderlineMeta); | ||
_registerComponent(TabButton, TabButtonMeta); | ||
_registerComponent(TabContent, TabContentMeta); | ||
@@ -350,0 +321,0 @@ } |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("@plasmicapp/host/registerComponent")),n=require("@plasmicapp/host"),a=e(require("constate")),r=require("react"),o=e(r);function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e}).apply(this,arguments)}var s=function(){};function l(e){return{type:"default-component",kind:"button",props:{children:{type:"text",value:e}}}}var p=r.createContext(!1);function c(e){var t=r.useState(e.initialKey),n=t[0],a=t[1],o=r.useState(void 0);return{tabKey:n,bbox:o[0],setTabKey:a,setBbox:o[1]}}var b=a(c),u=b[0],d=b[1];function y(){var e=d();return"setTabKey"in e?e:void 0}var h="@plasmicpkgs/plasmic-tabs",m={name:"hostless-tabs-container",displayName:"Tabs Container",importName:"TabsContainer",importPath:h,providesData:!0,defaultStyles:{width:"stretch",padding:"8px"},props:{initialKey:{type:"string",description:"Key of the initially selected tab",defaultValue:"tab1"},previewKey:{type:"string",description:"SShow this key while editing in Plasmic Studio"},previewAll:{type:"boolean",description:"Reveal all tab contents while editing in Plasmic Studio"},children:{type:"slot",defaultValue:{type:"vbox",children:[{type:"hbox",children:[{type:"component",name:"hostless-tab-button",props:{tabKey:"tab1",children:l("Tab 1")}},{type:"component",name:"hostless-tab-button",props:{tabKey:"tab2",children:l("Tab 2")}},{type:"component",name:"hostless-tab-underline"}]},{type:"vbox",children:[{type:"component",name:"hostless-tab-content",props:{tabKey:"tab1",children:[{type:"vbox",children:["Some content for tab 1"]}]}},{type:"component",name:"hostless-tab-content",props:{tabKey:"tab2",children:[{type:"vbox",children:["Some content for tab 2"]}]}}]}]}}}};function v(e){var t=e.children,a=e.initialKey,r=e.previewKey,i=e.previewAll,s=void 0!==i&&i,l=!!n.usePlasmicCanvasContext();return o.createElement(u,{initialKey:a},o.createElement(p.Provider,{value:l&&s},o.createElement(f,{previewKey:r||a},t)))}function f(e){var t=e.children,a=e.previewKey,r=n.usePlasmicCanvasContext(),i=function(e){if(!e)throw new Error("unexpected nil");return e}(y()).tabKey;return o.createElement(n.DataProvider,{name:"currentTabKey",data:r&&a||i},t)}var x={name:"hostless-tab-underline",displayName:"Tab Underline",importName:"TabUnderline",importPath:h,props:{children:{type:"slot"}},defaultStyles:{background:"#7777ff",height:"2px"}};function K(e){var t,n=e.className,a=(null!=(t=y())?t:{bbox:void 0}).bbox;return a?o.createElement("div",{className:n,style:i({},JSON.parse(JSON.stringify(a)),{top:void 0,bottom:0,position:"absolute",transition:".4s ease all"})}):null}var T={name:"hostless-tab-button",isAttachment:!0,displayName:"Tab Button",importName:"TabButton",importPath:h,props:{tabKey:{type:"string",description:"The answer value selecting this choice sets"},children:{type:"slot",defaultValue:l("Some tab")}},defaultStyles:{width:"hug"}};function g(e){var t=e.className,n=e.children,a=e.tabKey,i=y(),l=r.useRef(null),p=null!=i?i:{tabKey:void 0,setTabKey:s,bbox:void 0,setBbox:s},c=p.tabKey,b=p.setTabKey,u=p.setBbox;return r.useEffect((function(){a===c&&u({width:l.current.offsetWidth,left:l.current.offsetLeft})}),[l.current,u,JSON.stringify(p.bbox),a,c]),o.createElement("div",{className:t,ref:l},r.cloneElement(o.Children.toArray(n)[0],{isActive:a&&c&&c===a,onClick:function(){b(a)}}))}var C={name:"hostless-tab-content",isAttachment:!0,displayName:"Tab Content",importName:"TabContent",importPath:h,props:{tabKey:{type:"string",description:"The answer value selecting this choice sets"},children:{type:"slot",defaultValue:{type:"vbox",children:{type:"text",value:"This is some tab content"}}}}};function w(e){var t=e.children,n=e.tabKey,a=y(),i=r.useContext(p);return o.createElement(o.Fragment,null,void 0===a||(null!=a?a:{tabKey:void 0}).tabKey===n||i?t:null)}exports.TabButton=g,exports.TabButtonMeta=T,exports.TabContent=w,exports.TabContentMeta=C,exports.TabUnderline=K,exports.TabUnderlineMeta=x,exports.TabsContainer=v,exports.TabsContainerMeta=m,exports.registerAll=function(e){var n=function(n,a){e?e.registerComponent(n,a):t(n,a)};n(v,m),n(K,x),n(g,T),n(w,C)}; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("@plasmicapp/host/registerComponent")),n=require("@plasmicapp/host"),a=e(require("constate")),r=require("react"),i=e(r);function o(){return(o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e}).apply(this,arguments)}var s=function(){};function l(e){return{type:"default-component",kind:"button",props:{children:{type:"text",value:e}}}}var p=r.createContext(!1);function c(e){var t=r.useState(e.initialKey),n=t[0],a=t[1],i=r.useState(void 0);return{tabKey:n,bbox:i[0],setTabKey:a,setBbox:i[1]}}var b=a(c),u=b[0],d=b[1];function y(){var e=d();return"setTabKey"in e?e:void 0}var h="@plasmicpkgs/plasmic-tabs",m={name:"hostless-tabs-container",displayName:"Tabs Container",importName:"TabsContainer",importPath:h,providesData:!0,defaultStyles:{width:"stretch",padding:"8px"},props:{initialKey:{type:"string",description:"Key of the initially selected tab",defaultValue:"tab1"},previewKey:{type:"string",description:"SShow this key while editing in Plasmic Studio"},previewAll:{type:"boolean",description:"Reveal all tab contents while editing in Plasmic Studio"},children:{type:"slot",defaultValue:{type:"vbox",children:[{type:"hbox",children:[{type:"component",name:"hostless-tab-button",props:{tabKey:"tab1",children:l("Tab 1")}},{type:"component",name:"hostless-tab-button",props:{tabKey:"tab2",children:l("Tab 2")}},{type:"component",name:"hostless-tab-underline"}]},{type:"vbox",children:[{type:"component",name:"hostless-tab-content",props:{tabKey:"tab1",children:[{type:"vbox",children:["Some content for tab 1"]}]}},{type:"component",name:"hostless-tab-content",props:{tabKey:"tab2",children:[{type:"vbox",children:["Some content for tab 2"]}]}}]}]}}}};function v(e){var t=e.children,a=e.initialKey,r=e.previewKey,o=e.previewAll,s=void 0!==o&&o,l=!!n.usePlasmicCanvasContext();return i.createElement(u,{initialKey:a},i.createElement(p.Provider,{value:l&&s},i.createElement(f,{previewKey:r||a},t)))}function f(e){var t=e.children,a=e.previewKey,r=n.usePlasmicCanvasContext(),o=function(e){if(!e)throw new Error("unexpected nil");return e}(y()).tabKey;return i.createElement(n.DataProvider,{name:"currentTabKey",data:r&&a||o},t)}var x={name:"hostless-tab-underline",displayName:"Tab Underline",importName:"TabUnderline",importPath:h,props:{children:{type:"slot"}},defaultStyles:{background:"#7777ff",height:"2px"}};function K(e){var t,n=e.className,a=(null!=(t=y())?t:{bbox:void 0}).bbox;return a?i.createElement("div",{className:n,style:o({},JSON.parse(JSON.stringify(a)),{top:void 0,bottom:0,position:"absolute",transition:".4s ease all"})}):null}var T={name:"hostless-tab-button",isAttachment:!0,displayName:"Tab Button",importName:"TabButton",importPath:h,props:{tabKey:{type:"string",description:"The answer value selecting this choice sets"},children:{type:"slot",defaultValue:l("Some tab")}},defaultStyles:{width:"hug"}};function g(e){var t=e.className,n=e.children,a=e.tabKey,o=y(),l=r.useRef(null),p=null!=o?o:{tabKey:void 0,setTabKey:s,bbox:void 0,setBbox:s},c=p.tabKey,b=p.setTabKey,u=p.setBbox;return r.useEffect((function(){a===c&&u({width:l.current.offsetWidth,left:l.current.offsetLeft})}),[l.current,u,JSON.stringify(p.bbox),a,c]),i.createElement("div",{className:t,ref:l},r.cloneElement(i.Children.toArray(n)[0],{isActive:a&&c&&c===a,onClick:function(){b(a)}}))}var C={name:"hostless-tab-content",isAttachment:!0,displayName:"Tab Content",importName:"TabContent",importPath:h,props:{tabKey:{type:"string",description:"The answer value selecting this choice sets"},children:{type:"slot",defaultValue:{type:"vbox",children:{type:"text",value:"This is some tab content"}}}}};function w(e){var t=e.children,n=e.tabKey,a=y(),o=r.useContext(p);return i.createElement(i.Fragment,null,void 0===a||(null!=a?a:{tabKey:void 0}).tabKey===n||o?t:null)}exports.TabButton=g,exports.TabButtonMeta=T,exports.TabContent=w,exports.TabContentMeta=C,exports.TabUnderline=K,exports.TabUnderlineMeta=x,exports.TabsContainer=v,exports.TabsContainerMeta=m,exports.registerAll=function(e){var n=function(n,a){e?e.registerComponent(n,a):t(n,a)};n(v,m),n(K,x),n(g,T),n(w,C)}; | ||
//# sourceMappingURL=plasmic-tabs.cjs.production.min.js.map |
@@ -7,6 +7,5 @@ import registerComponent from '@plasmicapp/host/registerComponent'; | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
@@ -18,6 +17,4 @@ if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
@@ -27,3 +24,2 @@ } | ||
var noop = function noop() {}; | ||
function defaultButtonChildren(label) { | ||
@@ -41,16 +37,11 @@ return { | ||
} | ||
var DebugContext = /*#__PURE__*/createContext(false); | ||
function useTabsData(_ref) { | ||
var initialKey = _ref.initialKey; | ||
var _useState = useState(initialKey), | ||
tabKey = _useState[0], | ||
setTabKey = _useState[1]; | ||
tabKey = _useState[0], | ||
setTabKey = _useState[1]; | ||
var _useState2 = useState(undefined), | ||
bbox = _useState2[0], | ||
setBbox = _useState2[1]; | ||
bbox = _useState2[0], | ||
setBbox = _useState2[1]; | ||
return { | ||
@@ -63,7 +54,5 @@ tabKey: tabKey, | ||
} | ||
var _constate = /*#__PURE__*/constate(useTabsData), | ||
TabsProvider = _constate[0], | ||
useTabsContextUnsafe = _constate[1]; | ||
TabsProvider = _constate[0], | ||
useTabsContextUnsafe = _constate[1]; | ||
function useTabsContext() { | ||
@@ -73,3 +62,2 @@ var result = useTabsContextUnsafe(); | ||
} | ||
var modulePath = "@plasmicpkgs/plasmic-tabs"; | ||
@@ -154,6 +142,6 @@ var TabsContainerMeta = { | ||
var children = _ref2.children, | ||
initialKey = _ref2.initialKey, | ||
previewKey = _ref2.previewKey, | ||
_ref2$previewAll = _ref2.previewAll, | ||
previewAll = _ref2$previewAll === void 0 ? false : _ref2$previewAll; | ||
initialKey = _ref2.initialKey, | ||
previewKey = _ref2.previewKey, | ||
_ref2$previewAll = _ref2.previewAll, | ||
previewAll = _ref2$previewAll === void 0 ? false : _ref2$previewAll; | ||
var inEditor = !!usePlasmicCanvasContext(); | ||
@@ -168,3 +156,2 @@ return React.createElement(TabsProvider, { | ||
} | ||
function ensure(x) { | ||
@@ -174,14 +161,10 @@ if (!x) { | ||
} | ||
return x; | ||
} | ||
function Helper(_ref3) { | ||
var children = _ref3.children, | ||
previewKey = _ref3.previewKey; | ||
previewKey = _ref3.previewKey; | ||
var inEditor = usePlasmicCanvasContext(); | ||
var _ensure = ensure(useTabsContext()), | ||
tabKey = _ensure.tabKey; | ||
tabKey = _ensure.tabKey; | ||
var effectiveKey = inEditor ? previewKey || tabKey : tabKey; | ||
@@ -193,3 +176,2 @@ return React.createElement(DataProvider, { | ||
} | ||
var TabUnderlineMeta = { | ||
@@ -212,10 +194,7 @@ name: "hostless-tab-underline", | ||
var _useTabsContext; | ||
var className = _ref4.className; | ||
var _ref5 = (_useTabsContext = useTabsContext()) != null ? _useTabsContext : { | ||
bbox: undefined | ||
}, | ||
bbox = _ref5.bbox; | ||
bbox: undefined | ||
}, | ||
bbox = _ref5.bbox; | ||
return bbox ? React.createElement("div", { | ||
@@ -253,18 +232,16 @@ className: className, | ||
var className = _ref6.className, | ||
children = _ref6.children, | ||
tabKey = _ref6.tabKey; | ||
children = _ref6.children, | ||
tabKey = _ref6.tabKey; | ||
var tabsContext = useTabsContext(); | ||
var ref = useRef(null); | ||
var _ref7 = tabsContext != null ? tabsContext : { | ||
tabKey: undefined, | ||
setTabKey: noop, | ||
bbox: undefined, | ||
setBbox: noop | ||
}, | ||
activeKey = _ref7.tabKey, | ||
setTabKey = _ref7.setTabKey, | ||
bbox = _ref7.bbox, | ||
setBbox = _ref7.setBbox; | ||
tabKey: undefined, | ||
setTabKey: noop, | ||
bbox: undefined, | ||
setBbox: noop | ||
}, | ||
activeKey = _ref7.tabKey, | ||
setTabKey = _ref7.setTabKey, | ||
bbox = _ref7.bbox, | ||
setBbox = _ref7.setBbox; | ||
useEffect(function () { | ||
@@ -313,11 +290,9 @@ if (tabKey === activeKey) { | ||
var children = _ref8.children, | ||
tabKey = _ref8.tabKey; | ||
tabKey = _ref8.tabKey; | ||
var tabsContext = useTabsContext(); | ||
var previewAll = useContext(DebugContext); | ||
var _ref9 = tabsContext != null ? tabsContext : { | ||
tabKey: undefined | ||
}, | ||
activeKey = _ref9.tabKey; | ||
tabKey: undefined | ||
}, | ||
activeKey = _ref9.tabKey; | ||
return React.createElement(React.Fragment, null, tabsContext === undefined || activeKey === tabKey || previewAll ? children : null); | ||
@@ -334,9 +309,5 @@ } | ||
}; | ||
_registerComponent(TabsContainer, TabsContainerMeta); | ||
_registerComponent(TabUnderline, TabUnderlineMeta); | ||
_registerComponent(TabButton, TabButtonMeta); | ||
_registerComponent(TabContent, TabContentMeta); | ||
@@ -343,0 +314,0 @@ } |
{ | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"license": "MIT", | ||
@@ -53,7 +53,7 @@ "main": "dist/index.js", | ||
"@size-limit/preset-small-lib": "^7.0.4", | ||
"@types/react": "^17.0.37", | ||
"@types/react-dom": "^17.0.11", | ||
"@types/react": "^18.0.27", | ||
"@types/react-dom": "^18.0.10", | ||
"husky": "^7.0.4", | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"size-limit": "^7.0.4", | ||
@@ -67,3 +67,3 @@ "tsdx": "^0.14.1", | ||
}, | ||
"gitHead": "2d047d6d5f65d2c1f150eeff290663f58cab0e17" | ||
"gitHead": "1a11e260711c67b16c0703de62e6d108a12fa2d9" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70719