UNPKG

@figlinq/react-chart-editor

Version:
2 lines 17.9 kB
function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==typeof i?i:i+""}function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}import{Numeric,Info}from"../../fields";import{LayoutPanel,PlotlyFold,PlotlySection}from"..";import{TestEditor,fixtures,mount}from"../../../lib/test-utils";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";describe("Basic PlotlyPanel rules",()=>{describe("no PlotlyPanel, no context for Fields",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsxs("div",{children:[_jsx("div",{id:"thediv",children:" ok "}),_jsx(Numeric,{attr:"title"})]})})));it("HIDES Field",()=>expect(wrapper.find("input").length).toEqual(0));it("SHOWS div which does not need context",()=>expect(wrapper.find("input").length).toEqual(0))});describe("PlotlyPanel gives context to Field",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(Numeric,{attr:"title"})})})));it("SHOWS Field",()=>expect(wrapper.find("input").length).toEqual(1))});describe("no PlotlyPanel, does not affect PlotlySection",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx("div",{children:_jsxs(PlotlySection,{children:[_jsx("div",{id:"thediv",children:" ok "}),_jsx(Numeric,{attr:"title"})]})})})));it("SHOWS PlotlySection and #thediv",()=>{expect(wrapper.find("div.section").length).toEqual(1);expect(wrapper.find("#thediv").length).toEqual(1)});it("HIDES Field because it needs context from PlotlyPanel",()=>expect(wrapper.find("input").length).toEqual(0))})});describe("Basic PlotlySection rules",()=>{describe("hides itself when it has no visible children",()=>{describe("PlotlyPanel > PlotlySection > Field-with-no-visible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlySection,{children:_jsx(Numeric,{attr:"not_an_attr"})})})})));it("HIDES PlotlySection",()=>expect(wrapper.find("div.section").length).toEqual(0));it("HIDES Field",()=>expect(wrapper.find("input").length).toEqual(0))});describe("PlotlyPanel > PlotlySection > Field-with-no-visible-attr-based-on-customConfig",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter({customConfig:{visibility_rules:{blacklist:[{type:"attrName",regex_match:"color"}]}}})),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlySection,{children:_jsx(Numeric,{attr:"title.font.color"})})})})));it("HIDES Field based on customConfig",()=>expect(wrapper.find("input").length).toEqual(0));it("HIDES PlotlySection because no visible children according to custom config",()=>expect(wrapper.find("div.section").length).toEqual(0))});describe("PlotlyPanel > PlotlySection > Field-with-no-visible-attr-based-on-customConfig",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter({customConfig:{visibility_rules:{blacklist:[{type:"attrName",regex_match:"color"}]}}})),{},{children:_jsx(LayoutPanel,{children:_jsxs(PlotlySection,{attr:"title",children:[_jsx(Numeric,{attr:"title.font.color"}),_jsx(Numeric,{attr:"title"})]})})})));it("HIDES the title.font.color Field based on customConfig",()=>expect(wrapper.find("input").length).toEqual(1));it("SHOWS PlotlySection if it has an attr that is accepted by customConfig",()=>expect(wrapper.find("div.section").length).toEqual(1))});describe("div > PlotlySection > Field-with-visible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx("div",{children:_jsx(PlotlySection,{children:_jsx(Numeric,{attr:"title"})})})})));it("HIDES PlotlySection",()=>expect(wrapper.find("div.section").length).toEqual(0));it("HIDES Field",()=>expect(wrapper.find("input").length).toEqual(0))})});describe("shows itself when it has visible children",()=>{describe("PlotlyPanel > PlotlySection > Field-with-visible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlySection,{children:_jsx(Numeric,{attr:"title"})})})})));it("SHOWS PlotlySection",()=>expect(wrapper.find("div.section").length).toEqual(1));it("SHOWS Field",()=>expect(wrapper.find("input").length).toEqual(1))});describe("PlotlyPanel > PlotlySection > div",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsxs(PlotlySection,{children:[_jsx("div",{id:"thediv"}),_jsx(Numeric,{attr:"not_an_attr"})]})})})));it("SHOWS PlotlySection",()=>expect(wrapper.find("div.section").length).toEqual(1));it("HIDES Field",()=>expect(wrapper.find("input").length).toEqual(0));it("SHOWS div",()=>expect(wrapper.find("#thediv").length).toEqual(1))})})});describe("Basic PlotlyFold rules",()=>{describe("when children have an attr prop",()=>{describe("Field-with-visible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(Numeric,{attr:"title"})})})})));it("SHOWS PlotlyFold",()=>expect(wrapper.find("div.fold").length).toEqual(1));it("SHOWS Field",()=>expect(wrapper.find("input").length).toEqual(1))});describe("Field-with-invisible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(Numeric,{attr:"not_an_attr"})})})})));it("HIDES PlotlyFold",()=>expect(wrapper.find("div.fold").length).toEqual(0));it("HIDES Field",()=>expect(wrapper.find("input").length).toEqual(0))})});describe("when childen do not have an attr prop",()=>{describe("div",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx("div",{id:"thediv",children:" ok "})})})})));it("SHOWS PlotlyFold",()=>expect(wrapper.find("div.fold").length).toEqual(1));it("SHOWS div",()=>expect(wrapper.find("#thediv").length).toEqual(1))});describe("when children have a no_visibility_forcing, plotly_editor_trait",()=>{describe("PlotlySection",()=>{describe("div",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(PlotlySection,{children:_jsx("div",{id:"thediv",children:" ok "})})})})})));it("HIDES PlotlyFold",()=>expect(wrapper.find("div.fold").length).toEqual(0));it("HIDES PlotlySection",()=>expect(wrapper.find("div.section").length).toEqual(0));it("HIDES div",()=>expect(wrapper.find("#thediv").length).toEqual(0))});describe("Field-with-visible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(PlotlySection,{children:_jsx(Numeric,{attr:"title"})})})})})));it("HIDES PlotlyFold",()=>expect(wrapper.find("div.fold").length).toEqual(0));it("HIDES PlotlySection",()=>expect(wrapper.find("div.section").length).toEqual(0));it("HIDES Field",()=>expect(wrapper.find("input").length).toEqual(0))});describe("Field-with-invisible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(PlotlySection,{children:_jsx(Numeric,{attr:"not_an_attr"})})})})})));it("HIDES PlotlyFold",()=>expect(wrapper.find("div.fold").length).toEqual(0));it("HIDES PlotlySection",()=>expect(wrapper.find("div.section").length).toEqual(0));it("HIDES Field",()=>expect(wrapper.find("input").length).toEqual(0))})})});describe("PlotlyPanel",()=>{describe("Field-with-visible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(LayoutPanel,{children:_jsx(Numeric,{attr:"title"})})})})})));it("HIDES PlotlyFold",()=>expect(wrapper.find("div.fold").length).toEqual(0));it("HIDES inner PlotlyPanel",()=>expect(wrapper.find("div.panel").length).toEqual(1));it("HIDES Field",()=>expect(wrapper.find("input").length).toEqual(0))})});describe("Info",()=>{describe("Field-with-visible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(Info,{children:_jsx(Numeric,{attr:"title"})})})})})));it("HIDES PlotlyFold",()=>expect(wrapper.find("div.fold").length).toEqual(0));it("HIDES Info",()=>expect(wrapper.find(".js-test-info").length).toEqual(0));it("HIDES Field",()=>expect(wrapper.find("input").length).toEqual(0))})});describe("no_visibility_forcing containers can be visibility forcing with a visible attr",()=>{describe("PlotlySection-with-visible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(PlotlySection,{attr:"title",children:_jsx(Numeric,{attr:"not_an_attr"})})})})})));it("SHOWS PlotlyFold",()=>expect(wrapper.find("div.fold").length).toEqual(1));it("SHOWS PlotlySection",()=>expect(wrapper.find("div.section").length).toEqual(1));it("HIDES Field",()=>expect(wrapper.find("input").length).toEqual(0))});describe("PlotlySection-with-invisible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(PlotlySection,{attr:"not_an_attr",children:_jsx(Numeric,{attr:"title"})})})})})));it("HIDES PlotlyFold",()=>expect(wrapper.find("div.fold").length).toEqual(0));it("HIDES PlotlySection",()=>expect(wrapper.find("div.section").length).toEqual(0));it("HIDES Field",()=>expect(wrapper.find("input").length).toEqual(0))})})})});describe("Other ways to force PlotlyFold visibility",()=>{describe("Adding a custom component as child of PlotlyFold",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsxs(PlotlyFold,{children:[_jsx("p",{children:"I force visibility of the fold"}),_jsx(PlotlySection,{children:_jsx("div",{id:"thediv",children:" ok "})})]})})})));it("shows PlotlyFold",()=>expect(wrapper.find("div.fold").length).toEqual(1));it("shows PlotlySection",()=>expect(wrapper.find("div.section").length).toEqual(1));it("shows div",()=>expect(wrapper.find("#thediv").length).toEqual(1))});describe("adding a Field with visible attr as child of PlotlyFold",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsxs(PlotlyFold,{children:[_jsx(Numeric,{attr:"width"}),_jsxs(PlotlySection,{children:[_jsx("div",{id:"thediv",children:" ok "}),_jsx(Numeric,{attr:"title"})]})]})})})));it("shows PlotlyFold",()=>expect(wrapper.find("div.fold").length).toEqual(1));it("shows PlotlySection",()=>expect(wrapper.find("div.section").length).toEqual(1));it("shows div",()=>expect(wrapper.find("#thediv").length).toEqual(1));it("shows Field in PlotlySection",()=>expect(wrapper.find("input").length).toEqual(2))});describe("adding a Field with invisible attr will hide PlotlyFold",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsxs(PlotlyFold,{children:[_jsx(Numeric,{attr:"not_an_attr"}),_jsx(PlotlySection,{children:_jsx(Numeric,{attr:"not_an_attr"})})]})})})));it("HIDES PlotlyFold",()=>expect(wrapper.find("div.fold").length).toEqual(0));it("HIDES PlotlySection",()=>expect(wrapper.find("div.section").length).toEqual(0));it("HIDES Field in PlotlySection",()=>expect(wrapper.find("input").length).toEqual(0))})});describe("PlotlyPanel > PlotlyFold > PlotlyPanel > PlotlyFold",()=>{describe("div",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx("div",{id:"thediv",children:" ok "})})})})})})));it("HIDES PlotlyFold",()=>expect(wrapper.find("div.fold").length).toEqual(0));it("HIDES div",()=>expect(wrapper.find("#thediv").length).toEqual(0))});describe("Field-with-visible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(Numeric,{attr:"title"})})})})})})));it("HIDES PlotlyFold",()=>expect(wrapper.find("div.fold").length).toEqual(0));it("HIDES Field",()=>expect(wrapper.find("input").length).toEqual(0))});describe("Field-with-invisible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(Numeric,{attr:"not_an_attr"})})})})})})));it("HIDES PlotlyFold",()=>expect(wrapper.find("div.fold").length).toEqual(0));it("HIDES Field",()=>expect(wrapper.find("input").length).toEqual(0))})});describe("PlotlyPanel > PlotlyFold > PlotlyPanel > PlotlyFold > PlotlySection",()=>{describe("div",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(PlotlySection,{children:_jsx("div",{id:"thediv",children:" ok "})})})})})})})));it("HIDES PlotlyFold",()=>expect(wrapper.find("div.fold").length).toEqual(0));it("HIDES PlotlySection",()=>expect(wrapper.find("div.section").length).toEqual(0));it("HIDES div",()=>expect(wrapper.find("#thediv").length).toEqual(0))});describe("Field-with-visible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(PlotlySection,{children:_jsx(Numeric,{attr:"title"})})})})})})})));it("HIDES PlotlyFold",()=>expect(wrapper.find("div.fold").length).toEqual(0));it("HIDES PlotlySection",()=>expect(wrapper.find("div.section").length).toEqual(0));it("HIDES Field",()=>expect(wrapper.find("input").length).toEqual(0))});describe("Field-with-invisible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(PlotlySection,{children:_jsx(Numeric,{attr:"not_an_attr"})})})})})})})));it("HIDES PlotlyFold",()=>expect(wrapper.find("div.fold").length).toEqual(0));it("HIDES PlotlySection",()=>expect(wrapper.find("div.section").length).toEqual(0));it("HIDES Field",()=>expect(wrapper.find("input").length).toEqual(0))})});describe("PlotlyPanel > PlotlyFold > PlotlyPanel-with-visible-attr > PlotlyFold > PlotlySection-with-visible-attr",()=>{describe("div",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(LayoutPanel,{attr:"title",children:_jsx(PlotlyFold,{children:_jsx(PlotlySection,{attr:"title",children:_jsx("div",{id:"thediv",children:" ok "})})})})})})})));it("shows 2 PlotlyFolds",()=>expect(wrapper.find("div.fold").length).toEqual(2));it("shows PlotlySection",()=>expect(wrapper.find("div.section").length).toEqual(1));it("shows div",()=>expect(wrapper.find("#thediv").length).toEqual(1))});describe("Field-with-visible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(LayoutPanel,{attr:"title",children:_jsx(PlotlyFold,{children:_jsx(PlotlySection,{attr:"title",children:_jsx(Numeric,{attr:"title"})})})})})})})));it("shows 2 PlotlyFolds",()=>expect(wrapper.find("div.fold").length).toEqual(2));it("shows PlotlySection",()=>expect(wrapper.find("div.section").length).toEqual(1));it("shows Field",()=>expect(wrapper.find("input").length).toEqual(1))});describe("Field-with-invisible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(PlotlyFold,{children:_jsx(LayoutPanel,{attr:"title",children:_jsx(PlotlyFold,{children:_jsx(PlotlySection,{attr:"title",children:_jsx(Numeric,{attr:"not_an_attr"})})})})})})})));it("shows 2 PlotlyFolds",()=>expect(wrapper.find("div.fold").length).toEqual(2));it("shows PlotlySection",()=>expect(wrapper.find("div.section").length).toEqual(1));it("HIDES Field",()=>expect(wrapper.find("input").length).toEqual(0))})}); //# sourceMappingURL=ConnectedContainersVisibility-test.js.map