terra-disclosure-manager
Advanced tools
Comparing version 4.42.0 to 4.43.0
@@ -5,2 +5,7 @@ # Changelog | ||
## 4.43.0 - (July 25, 2023) | ||
* Added | ||
* Added heights `'280'`, `'380'`, `'460'` and widths `'400'`, `'600'`, `'700'`. | ||
## 4.42.0 - (March 15, 2022) | ||
@@ -7,0 +12,0 @@ |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -39,41 +38,21 @@ value: true | ||
}); | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); | ||
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _DisclosureManagerDelegate = _interopRequireDefault(require("./DisclosureManagerDelegate")); | ||
var _DisclosureManagerContext = _interopRequireDefault(require("./DisclosureManagerContext")); | ||
var _DisclosureManagerHeaderAdapterContext = _interopRequireDefault(require("./DisclosureManagerHeaderAdapterContext")); | ||
var _DisclosureManagerHeaderAdapter = _interopRequireDefault(require("./DisclosureManagerHeaderAdapter")); | ||
var _withDisclosureManager = _interopRequireDefault(require("./withDisclosureManager")); | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
var availableDisclosureSizes = { | ||
@@ -85,13 +64,14 @@ TINY: 'tiny', | ||
HUGE: 'huge', | ||
FULLSCREEN: 'fullscreen' | ||
FULLSCREEN: 'fullscreen', | ||
FUSION_SMALL: 'fusion-small', | ||
FUSION_MEDIUM: 'fusion-medium', | ||
FUSION_LARGE: 'fusion-large' | ||
}; | ||
exports.availableDisclosureSizes = availableDisclosureSizes; | ||
var arrayReducer = function arrayReducer(mappingObject, value) { | ||
return _objectSpread((0, _defineProperty2.default)({}, "".concat(value), value), mappingObject); | ||
}; | ||
var availableDisclosureHeights = [240, 420, 600, 690, 780, 870, 960, 1140].reduce(arrayReducer, {}); | ||
var availableDisclosureHeights = [240, 280, 380, 420, 460, 600, 690, 780, 870, 960, 1140].reduce(arrayReducer, {}); | ||
exports.availableDisclosureHeights = availableDisclosureHeights; | ||
var availableDisclosureWidths = [320, 480, 560, 640, 800, 960, 1120, 1280, 1440, 1600, 1760, 1920].reduce(arrayReducer, {}); | ||
var availableDisclosureWidths = [320, 400, 480, 560, 600, 640, 700, 800, 960, 1120, 1280, 1440, 1600, 1760, 1920].reduce(arrayReducer, {}); | ||
exports.availableDisclosureWidths = availableDisclosureWidths; | ||
@@ -103,11 +83,8 @@ var defaultDimensions = { | ||
var defaultSize = availableDisclosureSizes.SMALL; | ||
var isValidDimensions = function isValidDimensions(dimensions) { | ||
return availableDisclosureHeights[dimensions.height] && availableDisclosureWidths[dimensions.width]; | ||
}; | ||
var isValidSize = function isValidSize(size) { | ||
return !!availableDisclosureSizes[size.toUpperCase()]; | ||
return !!availableDisclosureSizes[size.toUpperCase().replace(/-/g, '_')]; | ||
}; | ||
var propTypes = { | ||
@@ -118,3 +95,2 @@ /** | ||
children: _propTypes.default.node, | ||
/** | ||
@@ -124,3 +100,2 @@ * A function used to provide rendering capabilities to the DisclosureManager. | ||
render: _propTypes.default.func.isRequired, | ||
/** | ||
@@ -131,3 +106,2 @@ * An array of disclosure types that the DisclosureManager should support. If an unsupported disclosure request occurs, the DisclosureManager will | ||
supportedDisclosureTypes: _propTypes.default.array, | ||
/** | ||
@@ -138,3 +112,2 @@ * A boolean indicating whether or not the DisclosureManager should handle all nested disclosure requests. When enabled, the DisclosureManager will handle all | ||
trapNestedDisclosureRequests: _propTypes.default.bool, | ||
/** | ||
@@ -146,3 +119,2 @@ * @private | ||
disclosureManager: _DisclosureManagerDelegate.default.propType, | ||
/** | ||
@@ -157,11 +129,7 @@ * @private | ||
}; | ||
var DisclosureManager = /*#__PURE__*/function (_React$Component) { | ||
(0, _inherits2.default)(DisclosureManager, _React$Component); | ||
var _super = _createSuper(DisclosureManager); | ||
function DisclosureManager(props) { | ||
var _this; | ||
(0, _classCallCheck2.default)(this, DisclosureManager); | ||
@@ -185,4 +153,5 @@ _this = _super.call(this, props); | ||
_this.maximizeDisclosure = _this.maximizeDisclosure.bind((0, _assertThisInitialized2.default)(_this)); | ||
_this.minimizeDisclosure = _this.minimizeDisclosure.bind((0, _assertThisInitialized2.default)(_this)); // These cached functions are stored outside of state to prevent unnecessary rerenders. | ||
_this.minimizeDisclosure = _this.minimizeDisclosure.bind((0, _assertThisInitialized2.default)(_this)); | ||
// These cached functions are stored outside of state to prevent unnecessary rerenders. | ||
_this.dismissChecks = {}; | ||
@@ -204,3 +173,2 @@ _this.onDismissResolvers = {}; | ||
} | ||
(0, _createClass2.default)(DisclosureManager, [{ | ||
@@ -210,8 +178,6 @@ key: "generateHeaderContextValue", | ||
var _this2 = this; | ||
return { | ||
register: function register(_ref) { | ||
var title = _ref.title, | ||
collapsibleMenuView = _ref.collapsibleMenuView; | ||
collapsibleMenuView = _ref.collapsibleMenuView; | ||
_this2.setState(function (state) { | ||
@@ -234,3 +200,2 @@ return { | ||
var _this3 = this; | ||
return _DisclosureManagerDelegate.default.create({ | ||
@@ -245,4 +210,2 @@ disclose: function disclose(data) { | ||
*/ | ||
return { | ||
@@ -255,3 +218,2 @@ /** | ||
}), | ||
/** | ||
@@ -265,3 +227,2 @@ * The dismissDisclosure value is a function that the disclosing component can use to manually close the disclosure. | ||
} | ||
return _this3.props.disclosureManager.disclose(data); | ||
@@ -275,8 +236,7 @@ } | ||
var _this4 = this; | ||
var disclosureComponentKeys = disclosureState.disclosureComponentKeys, | ||
disclosureComponentData = disclosureState.disclosureComponentData, | ||
disclosureIsMaximized = disclosureState.disclosureIsMaximized, | ||
disclosureIsFocused = disclosureState.disclosureIsFocused, | ||
disclosureSize = disclosureState.disclosureSize; | ||
disclosureComponentData = disclosureState.disclosureComponentData, | ||
disclosureIsMaximized = disclosureState.disclosureIsMaximized, | ||
disclosureIsFocused = disclosureState.disclosureIsFocused, | ||
disclosureSize = disclosureState.disclosureSize; | ||
var componentData = disclosureComponentData[componentKey]; | ||
@@ -287,6 +247,6 @@ var isFullscreen = disclosureSize === availableDisclosureSizes.FULLSCREEN; | ||
var delegate = {}; | ||
/** | ||
* The disclose function provided will push content onto the disclosure stack. | ||
*/ | ||
delegate.disclose = function (data) { | ||
@@ -296,3 +256,2 @@ if (_this4.props.trapNestedDisclosureRequests || _this4.disclosureTypeIsSupported(data.preferredType)) { | ||
_this4.pushDisclosure(data); | ||
return { | ||
@@ -306,5 +265,5 @@ afterDismiss: new Promise(function (resolve) { | ||
} | ||
return _this4.props.disclosureManager.disclose(data); | ||
}; | ||
/** | ||
@@ -314,10 +273,9 @@ * Allows a component to remove itself from the disclosure stack. If the component is the only element in the disclosure stack, | ||
*/ | ||
delegate.dismiss = popContent; | ||
delegate.dismiss = popContent; | ||
/** | ||
* Allows a component to close the entire disclosure stack. | ||
*/ | ||
delegate.closeDisclosure = this.safelyCloseDisclosure; | ||
delegate.closeDisclosure = this.safelyCloseDisclosure; | ||
/** | ||
@@ -327,36 +285,35 @@ * Allows a component to remove itself from the disclosure stack. Functionally similar to `dismiss`, however `onBack` is | ||
*/ | ||
delegate.goBack = componentIndex > 0 ? popContent : undefined; | ||
delegate.goBack = componentIndex > 0 ? popContent : undefined; | ||
/** | ||
* Allows a component to request focus from the disclosure in the event that the disclosure mechanism in use utilizes a focus trap. | ||
*/ | ||
delegate.requestFocus = disclosureIsFocused ? function () { | ||
return Promise.resolve().then(_this4.releaseDisclosureFocus); | ||
} : undefined; | ||
/** | ||
* Allows a component to release focus from itself and return it to the disclosure. | ||
*/ | ||
delegate.releaseFocus = !disclosureIsFocused ? function () { | ||
return Promise.resolve().then(_this4.requestDisclosureFocus); | ||
} : undefined; | ||
/** | ||
* Allows a component to maximize its presentation size. This is only provided if the component is not already maximized. | ||
*/ | ||
delegate.maximize = !isFullscreen && !disclosureIsMaximized ? function () { | ||
return Promise.resolve().then(_this4.maximizeDisclosure); | ||
} : undefined; | ||
/** | ||
* Allows a component to minimize its presentation size. This is only provided if the component is currently maximized. | ||
*/ | ||
delegate.minimize = !isFullscreen && disclosureIsMaximized ? function () { | ||
return Promise.resolve().then(_this4.minimizeDisclosure); | ||
} : undefined; | ||
/** | ||
* Allows a component to register a function with the DisclosureManager that will be called before the component is dismissed for any reason. | ||
*/ | ||
delegate.registerDismissCheck = function (checkFunc) { | ||
@@ -366,5 +323,5 @@ _this4.dismissChecks[componentData.key] = checkFunc; | ||
}; | ||
return _DisclosureManagerDelegate.default.create(delegate); | ||
} | ||
/** | ||
@@ -374,3 +331,2 @@ * Determines if the provided disclosure type is supported by the DisclosureManager. | ||
*/ | ||
}, { | ||
@@ -380,4 +336,4 @@ key: "disclosureTypeIsSupported", | ||
var _this$props = this.props, | ||
disclosureManager = _this$props.disclosureManager, | ||
supportedDisclosureTypes = _this$props.supportedDisclosureTypes; | ||
disclosureManager = _this$props.disclosureManager, | ||
supportedDisclosureTypes = _this$props.supportedDisclosureTypes; | ||
return supportedDisclosureTypes.indexOf(type) >= 0 || !disclosureManager; | ||
@@ -389,11 +345,9 @@ } | ||
var dimensions = data.dimensions; | ||
if (dimensions && !isValidDimensions(dimensions)) { | ||
// dimensions were provided, but are invalid, set the default | ||
dimensions = defaultDimensions; | ||
} // eslint-disable-next-line prefer-destructuring | ||
} | ||
// eslint-disable-next-line prefer-destructuring | ||
var size = data.size; | ||
if (!size || size && !isValidSize(size)) { | ||
@@ -404,8 +358,6 @@ // no valid size passed | ||
dimensions = defaultDimensions; | ||
} // ensure size set for passivity | ||
} | ||
// ensure size set for passivity | ||
size = defaultSize; | ||
} | ||
var newState = { | ||
@@ -488,3 +440,2 @@ disclosureIsOpen: true, | ||
var _this5 = this; | ||
var newState = DisclosureManager.cloneDisclosureState(this.state); | ||
@@ -501,3 +452,2 @@ newState.disclosureIsFocused = true; | ||
var _this6 = this; | ||
var newState = DisclosureManager.cloneDisclosureState(this.state); | ||
@@ -514,3 +464,2 @@ newState.disclosureIsFocused = false; | ||
var _this7 = this; | ||
var newState = DisclosureManager.cloneDisclosureState(this.state); | ||
@@ -527,3 +476,2 @@ newState.disclosureIsMaximized = true; | ||
var _this8 = this; | ||
var newState = DisclosureManager.cloneDisclosureState(this.state); | ||
@@ -536,2 +484,3 @@ newState.disclosureIsMaximized = false; | ||
} | ||
/** | ||
@@ -541,3 +490,2 @@ * Looks up the deferred afterDismiss promise for the provided disclosure key and | ||
*/ | ||
}, { | ||
@@ -547,9 +495,8 @@ key: "resolveDismissPromise", | ||
var resolve = this.onDismissResolvers[key]; | ||
if (resolve) { | ||
resolve(); | ||
} | ||
this.onDismissResolvers[key] = undefined; | ||
} | ||
/** | ||
@@ -559,3 +506,2 @@ * Resolves the dismiss checks for the current disclosure components in sequence. The Promise will either resolve if all checks resolve or | ||
*/ | ||
}, { | ||
@@ -565,3 +511,2 @@ key: "resolveDismissChecksInSequence", | ||
var _this9 = this; | ||
return new Promise(function (resolve, reject) { | ||
@@ -572,5 +517,3 @@ if (!keys.length) { | ||
} | ||
var key = keys.pop(); | ||
_this9.generatePopFunction(key)().then(function () { | ||
@@ -583,2 +526,3 @@ _this9.resolveDismissChecksInSequence(keys).then(resolve).catch(reject); | ||
} | ||
/** | ||
@@ -588,3 +532,2 @@ * Closes the disclosure after calling all checks and resolving all deferred promises. | ||
*/ | ||
}, { | ||
@@ -594,4 +537,4 @@ key: "safelyCloseDisclosure", | ||
var _this10 = this; | ||
var disclosureKeys = (0, _extends2.default)([], this.state.disclosureComponentKeys); | ||
var disclosureKeys = (0, _extends2.default)([], this.state.disclosureComponentKeys); | ||
/** | ||
@@ -602,13 +545,11 @@ * Before closing the disclosure, the dismiss checks for components in the stack are | ||
*/ | ||
return this.resolveDismissChecksInSequence(disclosureKeys).then(function () { | ||
_this10.dismissChecks = {}; | ||
_this10.closeDisclosure(); | ||
}); | ||
} | ||
/** | ||
* Creates an instance of a pop function for the component represented by the given key. | ||
*/ | ||
}, { | ||
@@ -618,6 +559,4 @@ key: "generatePopFunction", | ||
var _this11 = this; | ||
return function () { | ||
var disclosureComponentKeys = _this11.state.disclosureComponentKeys; | ||
if (disclosureComponentKeys[disclosureComponentKeys.length - 1] !== key) { | ||
@@ -630,16 +569,11 @@ /** | ||
} | ||
var promiseRoot = Promise.resolve(); | ||
var dismissCheck = _this11.dismissChecks[key]; | ||
if (dismissCheck) { | ||
promiseRoot = dismissCheck(); | ||
} | ||
var callbackfunction = function callbackfunction() { | ||
_this11.dismissChecks[key] = undefined; | ||
_this11.resolveDismissPromise(key); | ||
}; | ||
return promiseRoot.then(function () { | ||
@@ -654,5 +588,5 @@ _this11.popDisclosure(callbackfunction); | ||
var _this$state = this.state, | ||
disclosureComponentKeys = _this$state.disclosureComponentKeys, | ||
disclosureComponentData = _this$state.disclosureComponentData, | ||
disclosureComponentDelegates = _this$state.disclosureComponentDelegates; | ||
disclosureComponentKeys = _this$state.disclosureComponentKeys, | ||
disclosureComponentData = _this$state.disclosureComponentData, | ||
disclosureComponentDelegates = _this$state.disclosureComponentDelegates; | ||
return disclosureComponentKeys.reduce(function (accumulator, key, index) { | ||
@@ -677,21 +611,18 @@ var componentData = disclosureComponentData[key]; | ||
var _this12 = this; | ||
var _this$props2 = this.props, | ||
withDisclosureContainer = _this$props2.withDisclosureContainer, | ||
render = _this$props2.render, | ||
children = _this$props2.children; | ||
withDisclosureContainer = _this$props2.withDisclosureContainer, | ||
render = _this$props2.render, | ||
children = _this$props2.children; | ||
var _this$state2 = this.state, | ||
childComponentDelegate = _this$state2.childComponentDelegate, | ||
disclosureIsOpen = _this$state2.disclosureIsOpen, | ||
disclosureIsFocused = _this$state2.disclosureIsFocused, | ||
disclosureIsMaximized = _this$state2.disclosureIsMaximized, | ||
disclosureSize = _this$state2.disclosureSize, | ||
disclosureDimensions = _this$state2.disclosureDimensions, | ||
disclosureComponentKeys = _this$state2.disclosureComponentKeys, | ||
disclosureTypeConfig = _this$state2.disclosureTypeConfig; | ||
childComponentDelegate = _this$state2.childComponentDelegate, | ||
disclosureIsOpen = _this$state2.disclosureIsOpen, | ||
disclosureIsFocused = _this$state2.disclosureIsFocused, | ||
disclosureIsMaximized = _this$state2.disclosureIsMaximized, | ||
disclosureSize = _this$state2.disclosureSize, | ||
disclosureDimensions = _this$state2.disclosureDimensions, | ||
disclosureComponentKeys = _this$state2.disclosureComponentKeys, | ||
disclosureTypeConfig = _this$state2.disclosureTypeConfig; | ||
if (!render) { | ||
return null; | ||
} | ||
var disclosureComponentMappingForRender = this.generateDisclosureComponentMappingForRender(withDisclosureContainer); | ||
@@ -723,3 +654,2 @@ return render({ | ||
}, | ||
/** | ||
@@ -742,3 +672,2 @@ * The below values were added to give DisclosureManager implementations more control over the rendering of the disclosed components. | ||
var newState = _objectSpread({}, state); | ||
newState.disclosureComponentKeys = (0, _extends2.default)([], newState.disclosureComponentKeys); | ||
@@ -752,3 +681,2 @@ newState.disclosureComponentData = _objectSpread({}, newState.disclosureComponentData); | ||
}(_react.default.Component); | ||
DisclosureManager.propTypes = propTypes; | ||
@@ -758,5 +686,3 @@ DisclosureManager.defaultProps = defaultProps; | ||
exports.disclosureManagerShape = disclosureManagerShape; | ||
var _default = (0, _withDisclosureManager.default)(DisclosureManager); | ||
exports.default = _default; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,8 +8,5 @@ value: true | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
var DisclosureManagerContext = /*#__PURE__*/_react.default.createContext(); | ||
var _default = DisclosureManagerContext; | ||
exports.default = _default; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,13 +8,8 @@ value: true | ||
exports.default = void 0; | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var supportedAttributes = ['disclose', 'dismiss', 'closeDisclosure', 'goBack', 'maximize', 'minimize', 'requestFocus', 'releaseFocus', 'registerDismissCheck']; | ||
var DisclosureManagerDelegateInstance = /*#__PURE__*/(0, _createClass2.default)(function DisclosureManagerDelegateInstance(data) { | ||
var _this = this; | ||
(0, _classCallCheck2.default)(this, DisclosureManagerDelegateInstance); | ||
@@ -28,7 +22,5 @@ supportedAttributes.forEach(function (attribute) { | ||
}); | ||
var create = function create(data) { | ||
return Object.freeze(new DisclosureManagerDelegateInstance(data)); | ||
}; | ||
var clone = function clone(delegate, data) { | ||
@@ -42,3 +34,2 @@ var ancestorDelegate = delegate || {}; | ||
}; | ||
var isEqual = function isEqual(delegateA, delegateB) { | ||
@@ -48,7 +39,5 @@ if (!delegateA || !delegateB) { | ||
} | ||
if (delegateA === delegateB) { | ||
return true; | ||
} | ||
return !supportedAttributes.some(function (attribute) { | ||
@@ -58,3 +47,2 @@ return delegateA[attribute] !== delegateB[attribute]; | ||
}; | ||
var DisclosureManagerDelegate = { | ||
@@ -65,3 +53,2 @@ propType: _propTypes.default.objectOf(function (propValue, key, componentName, location, propFullName) { | ||
} | ||
return true; | ||
@@ -68,0 +55,0 @@ }), |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,9 +8,5 @@ value: true | ||
exports.default = void 0; | ||
var _react = require("react"); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _DisclosureManagerHeaderAdapterContext = _interopRequireDefault(require("./DisclosureManagerHeaderAdapterContext")); | ||
var propTypes = { | ||
@@ -22,3 +17,2 @@ /** | ||
title: _propTypes.default.string, | ||
/** | ||
@@ -29,9 +23,9 @@ * A CollapsibleMenuView component to render within the DisclosureManager's header. | ||
}; | ||
/** | ||
* A component used to register header data with the DisclosureManager. | ||
*/ | ||
var DisclosureManagerHeaderAdapter = function DisclosureManagerHeaderAdapter(_ref) { | ||
var title = _ref.title, | ||
collapsibleMenuView = _ref.collapsibleMenuView; | ||
collapsibleMenuView = _ref.collapsibleMenuView; | ||
var adapterContext = (0, _react.useContext)(_DisclosureManagerHeaderAdapterContext.default); | ||
@@ -46,5 +40,4 @@ (0, _react.useLayoutEffect)(function () { | ||
}; | ||
DisclosureManagerHeaderAdapter.propTypes = propTypes; | ||
var _default = DisclosureManagerHeaderAdapter; | ||
exports.default = _default; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,5 +8,3 @@ value: true | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
var DisclosureManagerHeaderAdapterContext = /*#__PURE__*/_react.default.createContext({ | ||
@@ -22,4 +19,3 @@ register: function register() { | ||
}); | ||
var _default = DisclosureManagerHeaderAdapterContext; | ||
exports.default = _default; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,13 +8,8 @@ value: true | ||
exports.default = void 0; | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _DisclosureManagerContext = _interopRequireDefault(require("./DisclosureManagerContext")); | ||
var getDisplayName = function getDisplayName(Component) { | ||
return Component.displayName || Component.name || 'Component'; | ||
}; | ||
var withDisclosureManager = function withDisclosureManager(WrappedComponent) { | ||
@@ -29,3 +23,2 @@ var WithDisclosureManagerComp = function WithDisclosureManagerComp(props) { | ||
}; | ||
WithDisclosureManagerComp.displayName = "withDisclosureManager(".concat(getDisplayName(WrappedComponent), ")"); | ||
@@ -35,4 +28,3 @@ WithDisclosureManagerComp.WrappedComponent = WrappedComponent; | ||
}; | ||
var _default = withDisclosureManager; | ||
exports.default = _default; |
{ | ||
"name": "terra-disclosure-manager", | ||
"main": "lib/DisclosureManager.js", | ||
"version": "4.42.0", | ||
"version": "4.43.0", | ||
"description": "A stateful component used to manage disclosure presentation.", | ||
@@ -41,3 +41,3 @@ "repository": { | ||
}, | ||
"gitHead": "40ac61f9fd7360971f1a38dda1fbfe871d0486cf" | ||
"gitHead": "74c83e876cf98148ec786a9990ec1c3e3416c069" | ||
} |
@@ -17,7 +17,10 @@ import React from 'react'; | ||
FULLSCREEN: 'fullscreen', | ||
FUSION_SMALL: 'fusion-small', | ||
FUSION_MEDIUM: 'fusion-medium', | ||
FUSION_LARGE: 'fusion-large', | ||
}; | ||
const arrayReducer = (mappingObject, value) => ({ [`${value}`]: value, ...mappingObject }); | ||
const availableDisclosureHeights = [240, 420, 600, 690, 780, 870, 960, 1140].reduce(arrayReducer, {}); | ||
const availableDisclosureWidths = [320, 480, 560, 640, 800, 960, 1120, 1280, 1440, 1600, 1760, 1920].reduce(arrayReducer, {}); | ||
const availableDisclosureHeights = [240, 280, 380, 420, 460, 600, 690, 780, 870, 960, 1140].reduce(arrayReducer, {}); | ||
const availableDisclosureWidths = [320, 400, 480, 560, 600, 640, 700, 800, 960, 1120, 1280, 1440, 1600, 1760, 1920].reduce(arrayReducer, {}); | ||
@@ -29,3 +32,3 @@ const defaultDimensions = { height: availableDisclosureHeights['690'], width: availableDisclosureWidths['1120'] }; | ||
const isValidSize = size => !!availableDisclosureSizes[size.toUpperCase()]; | ||
const isValidSize = size => !!availableDisclosureSizes[size.toUpperCase().replace(/-/g, '_')]; | ||
@@ -32,0 +35,0 @@ export { availableDisclosureSizes, availableDisclosureHeights, availableDisclosureWidths }; |
import React from 'react'; | ||
import DisclosureManager, { withDisclosureManager, DisclosureManagerHeaderAdapter } from '../../src/DisclosureManager'; | ||
import DisclosureManager, { withDisclosureManager, DisclosureManagerHeaderAdapter, availableDisclosureSizes } from '../../src/DisclosureManager'; | ||
@@ -161,2 +161,194 @@ const TestChild = withDisclosureManager(({ id }) => <div id={id} />); | ||
it('renders disclosed content in the disclosure wrapper with default size of "small" when none provided', () => { | ||
const triggerChildDiscloseDefaultSize = (wrapper) => ( | ||
new Promise((resolve, reject) => { | ||
const childDisclosureManager1 = wrapper.find('#child1').getElements()[1].props.disclosureManager; | ||
childDisclosureManager1.disclose({ | ||
preferredType: 'test', | ||
size: null, | ||
content: { | ||
key: 'DISCLOSE_KEY', | ||
component: <TestChild id="disclosure-component" />, | ||
}, | ||
}).then(resolve).catch(reject); | ||
}) | ||
.then(() => { | ||
wrapper.update(); | ||
}) | ||
); | ||
const wrapper = mount( | ||
<DisclosureManager.WrappedComponent | ||
render={(manager) => ( | ||
<div id="content"> | ||
{manager.children.components} | ||
{manager.disclosure.components} | ||
</div> | ||
)} | ||
withDisclosureContainer={(content) => ( | ||
<div id="disclosure-container"> | ||
{content} | ||
</div> | ||
)} | ||
supportedDisclosureTypes={['test']} | ||
> | ||
<TestChild id="child1" /> | ||
<TestChild id="child2" /> | ||
</DisclosureManager.WrappedComponent>, | ||
); | ||
validateInitialState(wrapper); | ||
validateChildDelegate(wrapper); | ||
return triggerChildDiscloseDefaultSize(wrapper).then(() => { | ||
expect(wrapper.exists('#disclosure-container')).toBe(true); | ||
expect(wrapper.state().disclosureSize).toBe('small'); | ||
}); | ||
}); | ||
it('renders disclosed content in the disclosure wrapper with a "fusion" size when provided', () => { | ||
const triggerChildDiscloseFusionSize = (wrapper) => ( | ||
new Promise((resolve, reject) => { | ||
const childDisclosureManager1 = wrapper.find('#child1').getElements()[1].props.disclosureManager; | ||
childDisclosureManager1.disclose({ | ||
preferredType: 'test', | ||
size: availableDisclosureSizes.FUSION_MEDIUM, | ||
content: { | ||
key: 'DISCLOSE_KEY', | ||
component: <TestChild id="disclosure-component" />, | ||
}, | ||
}).then(resolve).catch(reject); | ||
}) | ||
.then(() => { | ||
wrapper.update(); | ||
}) | ||
); | ||
const wrapper = mount( | ||
<DisclosureManager.WrappedComponent | ||
render={(manager) => ( | ||
<div id="content"> | ||
{manager.children.components} | ||
{manager.disclosure.components} | ||
</div> | ||
)} | ||
withDisclosureContainer={(content) => ( | ||
<div id="disclosure-container"> | ||
{content} | ||
</div> | ||
)} | ||
supportedDisclosureTypes={['test']} | ||
> | ||
<TestChild id="child1" /> | ||
<TestChild id="child2" /> | ||
</DisclosureManager.WrappedComponent>, | ||
); | ||
validateInitialState(wrapper); | ||
validateChildDelegate(wrapper); | ||
return triggerChildDiscloseFusionSize(wrapper).then(() => { | ||
expect(wrapper.exists('#disclosure-container')).toBe(true); | ||
expect(wrapper.state().disclosureSize).toBe('fusion-medium'); | ||
}); | ||
}); | ||
it('renders disclosed content in the disclosure wrapper with default dimensions when invalid height is provided', () => { | ||
const defaultHeight = 690; | ||
const defaultWidth = 1120; | ||
const triggerChildDiscloseInvalidHeight = (wrapper) => ( | ||
new Promise((resolve, reject) => { | ||
const childDisclosureManager1 = wrapper.find('#child1').getElements()[1].props.disclosureManager; | ||
childDisclosureManager1.disclose({ | ||
preferredType: 'test', | ||
dimensions: { height: 1234, width: 560 }, | ||
content: { | ||
key: 'DISCLOSE_KEY', | ||
component: <TestChild id="disclosure-component" />, | ||
}, | ||
}).then(resolve).catch(reject); | ||
}) | ||
.then(() => { | ||
wrapper.update(); | ||
}) | ||
); | ||
const wrapper = mount( | ||
<DisclosureManager.WrappedComponent | ||
render={(manager) => ( | ||
<div id="content"> | ||
{manager.children.components} | ||
{manager.disclosure.components} | ||
</div> | ||
)} | ||
withDisclosureContainer={(content) => ( | ||
<div id="disclosure-container"> | ||
{content} | ||
</div> | ||
)} | ||
supportedDisclosureTypes={['test']} | ||
> | ||
<TestChild id="child1" /> | ||
<TestChild id="child2" /> | ||
</DisclosureManager.WrappedComponent>, | ||
); | ||
validateInitialState(wrapper); | ||
validateChildDelegate(wrapper); | ||
return triggerChildDiscloseInvalidHeight(wrapper).then(() => { | ||
expect(wrapper.exists('#disclosure-container')).toBe(true); | ||
expect(wrapper.state().disclosureDimensions).toEqual({ height: defaultHeight, width: defaultWidth }); | ||
}); | ||
}); | ||
it('renders disclosed content in the disclosure wrapper with default dimensions when invalid width is provided', () => { | ||
const defaultHeight = 690; | ||
const defaultWidth = 1120; | ||
const triggerChildDiscloseInvalidWidth = (wrapper) => ( | ||
new Promise((resolve, reject) => { | ||
const childDisclosureManager1 = wrapper.find('#child1').getElements()[1].props.disclosureManager; | ||
childDisclosureManager1.disclose({ | ||
preferredType: 'test', | ||
dimensions: { height: 380, width: 1234 }, | ||
content: { | ||
key: 'DISCLOSE_KEY', | ||
component: <TestChild id="disclosure-component" />, | ||
}, | ||
}).then(resolve).catch(reject); | ||
}) | ||
.then(() => { | ||
wrapper.update(); | ||
}) | ||
); | ||
const wrapper = mount( | ||
<DisclosureManager.WrappedComponent | ||
render={(manager) => ( | ||
<div id="content"> | ||
{manager.children.components} | ||
{manager.disclosure.components} | ||
</div> | ||
)} | ||
withDisclosureContainer={(content) => ( | ||
<div id="disclosure-container"> | ||
{content} | ||
</div> | ||
)} | ||
supportedDisclosureTypes={['test']} | ||
> | ||
<TestChild id="child1" /> | ||
<TestChild id="child2" /> | ||
</DisclosureManager.WrappedComponent>, | ||
); | ||
validateInitialState(wrapper); | ||
validateChildDelegate(wrapper); | ||
return triggerChildDiscloseInvalidWidth(wrapper).then(() => { | ||
expect(wrapper.exists('#disclosure-container')).toBe(true); | ||
expect(wrapper.state().disclosureDimensions).toEqual({ height: defaultHeight, width: defaultWidth }); | ||
}); | ||
}); | ||
describe('discloses content with header title', () => { | ||
@@ -163,0 +355,0 @@ it('renders with title', () => { |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
138384
2506