Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

terra-disclosure-manager

Package Overview
Dependencies
Maintainers
9
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

terra-disclosure-manager - npm Package Compare versions

Comparing version 4.13.0 to 4.14.0

8

CHANGELOG.md

@@ -7,2 +7,10 @@ ChangeLog

4.14.0 - (July 2, 2019)
------------------
### Fixed
* Fixed bug where afterdismiss promise was getting resolved prior to dismissing.
### Changed
* Export context and delegate
4.13.0 - (June 19, 2019)

@@ -9,0 +17,0 @@ ------------------

48

lib/DisclosureManager.js

@@ -8,2 +8,14 @@ "use strict";

});
Object.defineProperty(exports, "DisclosureManagerDelegate", {
enumerable: true,
get: function get() {
return _DisclosureManagerDelegate.default;
}
});
Object.defineProperty(exports, "DisclosureManagerContext", {
enumerable: true,
get: function get() {
return _DisclosureManagerContext.default;
}
});
Object.defineProperty(exports, "withDisclosureManager", {

@@ -373,11 +385,18 @@ enumerable: true,

key: "popDisclosure",
value: function popDisclosure() {
var newState = DisclosureManager.cloneDisclosureState(this.state);
newState.disclosureComponentData[newState.disclosureComponentKeys.pop()] = undefined;
newState.disclosureComponentDelegates.pop();
this.setState(newState);
value: function popDisclosure(callbackfunction) {
/**
* If there is only one disclosed component, the disclosure is closed and all state is reset.
*/
if (this.state.disclosureComponentKeys.length === 1) {
this.closeDisclosure(callbackfunction);
} else {
var newState = DisclosureManager.cloneDisclosureState(this.state);
newState.disclosureComponentData[newState.disclosureComponentKeys.pop()] = undefined;
newState.disclosureComponentDelegates.pop();
this.setState(newState, callbackfunction);
}
}
}, {
key: "closeDisclosure",
value: function closeDisclosure() {
value: function closeDisclosure(callbackfunction) {
this.setState({

@@ -392,3 +411,3 @@ disclosureIsOpen: false,

disclosureComponentDelegates: []
});
}, callbackfunction);
}

@@ -534,15 +553,10 @@ }, {

return promiseRoot.then(function () {
var callbackfunction = function callbackfunction() {
_this10.dismissChecks[key] = undefined;
_this10.resolveDismissPromise(key);
}).then(function () {
if (disclosureComponentKeys.length === 1) {
/**
* If there is only one disclosed component, the disclosure is closed and all state is reset.
*/
_this10.closeDisclosure();
} else {
_this10.popDisclosure();
}
};
return promiseRoot.then(function () {
_this10.popDisclosure(callbackfunction);
});

@@ -549,0 +563,0 @@ };

{
"name": "terra-disclosure-manager",
"main": "lib/DisclosureManager.js",
"version": "4.13.0",
"version": "4.14.0",
"description": "A stateful component used to manage disclosure presentation.",

@@ -6,0 +6,0 @@ "repository": {

@@ -298,12 +298,19 @@ import React from 'react';

popDisclosure() {
const newState = DisclosureManager.cloneDisclosureState(this.state);
popDisclosure(callbackfunction) {
/**
* If there is only one disclosed component, the disclosure is closed and all state is reset.
*/
if (this.state.disclosureComponentKeys.length === 1) {
this.closeDisclosure(callbackfunction);
} else {
const newState = DisclosureManager.cloneDisclosureState(this.state);
newState.disclosureComponentData[newState.disclosureComponentKeys.pop()] = undefined;
newState.disclosureComponentDelegates.pop();
newState.disclosureComponentData[newState.disclosureComponentKeys.pop()] = undefined;
newState.disclosureComponentDelegates.pop();
this.setState(newState);
this.setState(newState, callbackfunction);
}
}
closeDisclosure() {
closeDisclosure(callbackfunction) {
this.setState({

@@ -318,3 +325,3 @@ disclosureIsOpen: false,

disclosureComponentDelegates: [],
});
}, callbackfunction);
}

@@ -429,16 +436,10 @@

const callbackfunction = () => {
this.dismissChecks[key] = undefined;
this.resolveDismissPromise(key);
};
return promiseRoot
.then(() => {
this.dismissChecks[key] = undefined;
this.resolveDismissPromise(key);
})
.then(() => {
if (disclosureComponentKeys.length === 1) {
/**
* If there is only one disclosed component, the disclosure is closed and all state is reset.
*/
this.closeDisclosure();
} else {
this.popDisclosure();
}
this.popDisclosure(callbackfunction);
});

@@ -498,2 +499,4 @@ };

export default withDisclosureManager(DisclosureManager);
export { withDisclosureManager, disclosureManagerShape };
export {
withDisclosureManager, disclosureManagerShape, DisclosureManagerContext, DisclosureManagerDelegate,
};

@@ -675,2 +675,82 @@ import React from 'react';

});
it('should provide afterDismiss promise to resolve after dismissing', async () => {
let dismissDisclosureInstance;
let afterDismissPromise;
let childApp2DisclosureManager;
const wrapper = mountDisclosureManager(['test'], manager => (
<div id="wrapper">
{manager.children.components}
{manager.disclosure.components}
</div>
));
validateInitialState(wrapper);
validateChildDelegate(wrapper);
await new Promise((resolve, reject) => {
const childApp1DisclosureManager = wrapper.find('#child1').getElements()[1].props.disclosureManager;
childApp1DisclosureManager.disclose({
preferredType: 'test',
size: 'large',
content: {
key: 'DISCLOSE_KEY',
component: <TestChild id="component-B" />,
},
}).then(resolve).catch(reject);
});
wrapper.update();
await new Promise((resolve, reject) => {
childApp2DisclosureManager = wrapper.find('#component-B').getElements()[1].props.disclosureManager;
childApp2DisclosureManager.disclose({
preferredType: 'test',
size: 'large',
content: {
key: 'Nested',
component: <TestChild id="component-C" />,
},
}).then(({ dismissDisclosure, afterDismiss }) => {
dismissDisclosureInstance = dismissDisclosure;
afterDismissPromise = afterDismiss;
resolve();
}).catch(reject);
});
wrapper.update();
expect(wrapper.state().disclosureIsOpen).toBeTruthy();
expect(wrapper.state().disclosureIsFocused).toBeTruthy();
expect(wrapper.state().disclosureIsMaximized).toBeFalsy();
expect(wrapper.state().disclosureSize).toBe('large');
expect(wrapper.state().disclosureComponentKeys).toEqual(['DISCLOSE_KEY', 'Nested']);
expect(wrapper.state().disclosureComponentData.Nested.key).toEqual('Nested');
expect(wrapper.state().disclosureComponentData.Nested.component.props.id).toEqual('component-C');
expect(wrapper.state().disclosureComponentDelegates.length).toEqual(2);
/**
* Due to the asynchronous execution of the afterDismiss promise, failed expectations
* within the promise handler cannot actually fail the test. Instead, we use a flag to
* and write expectations around the flag after awaiting the promise below.
*/
let afterDismissResolvedAfterStateUpdate = false;
afterDismissPromise.then(() => {
if (wrapper.state().disclosureComponentKeys.indexOf('Nested') === -1) {
afterDismissResolvedAfterStateUpdate = true;
}
});
await dismissDisclosureInstance();
await expect(afterDismissPromise).resolves.toBe(undefined);
expect(afterDismissResolvedAfterStateUpdate).toBeTruthy();
await childApp2DisclosureManager.closeDisclosure();
wrapper.update();
expect(wrapper.state().disclosureIsOpen).toBeFalsy();
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc