@fluentui/state
Advanced tools
Comparing version 0.65.0 to 0.66.0
@@ -5,41 +5,32 @@ "use strict"; | ||
exports.createManager = void 0; | ||
var createManager = function createManager(config) { | ||
var actions = config.actions, | ||
debug = config.debug, | ||
_config$middleware = config.middleware, | ||
middleware = _config$middleware === void 0 ? [] : _config$middleware, | ||
_config$sideEffects = config.sideEffects, | ||
sideEffects = _config$sideEffects === void 0 ? [] : _config$sideEffects, | ||
state = config.state; | ||
debug = config.debug, | ||
_config$middleware = config.middleware, | ||
middleware = _config$middleware === void 0 ? [] : _config$middleware, | ||
_config$sideEffects = config.sideEffects, | ||
sideEffects = _config$sideEffects === void 0 ? [] : _config$sideEffects, | ||
state = config.state; | ||
var _state = Object.assign({}, state); | ||
var getState = function getState() { | ||
return Object.assign({}, _state); | ||
}; | ||
var setState = function setState(partial) { | ||
return Object.assign(_state, partial); | ||
}; | ||
var manager = { | ||
actions: {}, | ||
get state() { | ||
return getState(); | ||
} | ||
}; | ||
}; // assign actions to manager's api | ||
// assign actions to manager's api | ||
Object.keys(actions).forEach(function (actionName) { | ||
var enhancedAction = actions[actionName]; | ||
var action = function action() { | ||
var prevState = getState(); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
applyAction.apply(void 0, [enhancedAction].concat(args)); | ||
@@ -49,6 +40,4 @@ applyMiddleware(prevState); | ||
}; | ||
manager.actions[actionName] = action; | ||
}); | ||
var applyAction = function applyAction(action) { | ||
@@ -61,9 +50,6 @@ if (process.env.NODE_ENV !== 'production') { | ||
} | ||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
args[_key2 - 1] = arguments[_key2]; | ||
} | ||
var actionResult = action.apply(void 0, args)(getState(), manager.actions); | ||
if (actionResult) { | ||
@@ -73,3 +59,2 @@ setState(actionResult); | ||
}; | ||
var applyMiddleware = function applyMiddleware(prevState) { | ||
@@ -86,7 +71,5 @@ middleware.forEach(function (middlewareItem, index) { | ||
} | ||
setState(middlewareItem(prevState, getState(), manager.actions)); | ||
}); | ||
}; | ||
var applySideEffects = function applySideEffects(prevState) { | ||
@@ -100,11 +83,8 @@ sideEffects.forEach(function (sideEffect, index) { | ||
} | ||
sideEffect(prevState, manager.state); | ||
}); | ||
}; | ||
return manager; | ||
}; | ||
exports.createManager = createManager; | ||
//# sourceMappingURL=createManager.js.map |
@@ -8,5 +8,3 @@ "use strict"; | ||
exports.createManager = void 0; | ||
var _checkboxManager = require("./managers/checkboxManager"); | ||
Object.keys(_checkboxManager).forEach(function (key) { | ||
@@ -18,5 +16,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _carouselManager = require("./managers/carouselManager"); | ||
Object.keys(_carouselManager).forEach(function (key) { | ||
@@ -28,5 +24,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _dialogManager = require("./managers/dialogManager"); | ||
Object.keys(_dialogManager).forEach(function (key) { | ||
@@ -38,5 +32,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _sliderManager = require("./managers/sliderManager"); | ||
Object.keys(_sliderManager).forEach(function (key) { | ||
@@ -48,9 +40,5 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _createManager = require("./createManager"); | ||
exports.createManager = _createManager.createManager; | ||
var _types = require("./types"); | ||
Object.keys(_types).forEach(function (key) { | ||
@@ -57,0 +45,0 @@ if (key === "default" || key === "__esModule") return; |
@@ -5,5 +5,3 @@ "use strict"; | ||
exports.createCarouselManager = void 0; | ||
var _createManager = require("../createManager"); | ||
var createCarouselManager = function createCarouselManager(config) { | ||
@@ -13,3 +11,2 @@ if (config === void 0) { | ||
} | ||
return (0, _createManager.createManager)(Object.assign({}, config, { | ||
@@ -54,4 +51,3 @@ state: Object.assign({ | ||
}; | ||
exports.createCarouselManager = createCarouselManager; | ||
//# sourceMappingURL=carouselManager.js.map |
@@ -5,5 +5,3 @@ "use strict"; | ||
exports.createCheckboxManager = void 0; | ||
var _createManager = require("../createManager"); | ||
var createCheckboxManager = function createCheckboxManager(config) { | ||
@@ -13,3 +11,2 @@ if (config === void 0) { | ||
} | ||
return (0, _createManager.createManager)(Object.assign({}, config, { | ||
@@ -30,4 +27,3 @@ state: Object.assign({ | ||
}; | ||
exports.createCheckboxManager = createCheckboxManager; | ||
//# sourceMappingURL=checkboxManager.js.map |
@@ -5,5 +5,3 @@ "use strict"; | ||
exports.createDialogManager = void 0; | ||
var _createManager = require("../createManager"); | ||
var createDialogManager = function createDialogManager(config) { | ||
@@ -13,3 +11,2 @@ if (config === void 0) { | ||
} | ||
return (0, _createManager.createManager)(Object.assign({}, config, { | ||
@@ -37,4 +34,3 @@ state: Object.assign({ | ||
}; | ||
exports.createDialogManager = createDialogManager; | ||
//# sourceMappingURL=dialogManager.js.map |
@@ -5,5 +5,3 @@ "use strict"; | ||
exports.createSliderManager = void 0; | ||
var _createManager = require("../createManager"); | ||
var createSliderManager = function createSliderManager(config) { | ||
@@ -13,3 +11,2 @@ if (config === void 0) { | ||
} | ||
return (0, _createManager.createManager)(Object.assign({}, config, { | ||
@@ -30,4 +27,3 @@ state: Object.assign({ | ||
}; | ||
exports.createSliderManager = createSliderManager; | ||
//# sourceMappingURL=sliderManager.js.map |
export var createManager = function createManager(config) { | ||
var actions = config.actions, | ||
debug = config.debug, | ||
_config$middleware = config.middleware, | ||
middleware = _config$middleware === void 0 ? [] : _config$middleware, | ||
_config$sideEffects = config.sideEffects, | ||
sideEffects = _config$sideEffects === void 0 ? [] : _config$sideEffects, | ||
state = config.state; | ||
debug = config.debug, | ||
_config$middleware = config.middleware, | ||
middleware = _config$middleware === void 0 ? [] : _config$middleware, | ||
_config$sideEffects = config.sideEffects, | ||
sideEffects = _config$sideEffects === void 0 ? [] : _config$sideEffects, | ||
state = config.state; | ||
var _state = Object.assign({}, state); | ||
var getState = function getState() { | ||
return Object.assign({}, _state); | ||
}; | ||
var setState = function setState(partial) { | ||
return Object.assign(_state, partial); | ||
}; | ||
var manager = { | ||
actions: {}, | ||
get state() { | ||
return getState(); | ||
} | ||
}; | ||
}; // assign actions to manager's api | ||
// assign actions to manager's api | ||
Object.keys(actions).forEach(function (actionName) { | ||
var enhancedAction = actions[actionName]; | ||
var action = function action() { | ||
var prevState = getState(); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
applyAction.apply(void 0, [enhancedAction].concat(args)); | ||
@@ -43,6 +35,4 @@ applyMiddleware(prevState); | ||
}; | ||
manager.actions[actionName] = action; | ||
}); | ||
var applyAction = function applyAction(action) { | ||
@@ -55,9 +45,6 @@ if (process.env.NODE_ENV !== 'production') { | ||
} | ||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
args[_key2 - 1] = arguments[_key2]; | ||
} | ||
var actionResult = action.apply(void 0, args)(getState(), manager.actions); | ||
if (actionResult) { | ||
@@ -67,3 +54,2 @@ setState(actionResult); | ||
}; | ||
var applyMiddleware = function applyMiddleware(prevState) { | ||
@@ -80,7 +66,5 @@ middleware.forEach(function (middlewareItem, index) { | ||
} | ||
setState(middlewareItem(prevState, getState(), manager.actions)); | ||
}); | ||
}; | ||
var applySideEffects = function applySideEffects(prevState) { | ||
@@ -94,9 +78,7 @@ sideEffects.forEach(function (sideEffect, index) { | ||
} | ||
sideEffect(prevState, manager.state); | ||
}); | ||
}; | ||
return manager; | ||
}; | ||
//# sourceMappingURL=createManager.js.map |
@@ -6,3 +6,2 @@ import { createManager } from '../createManager'; | ||
} | ||
return createManager(Object.assign({}, config, { | ||
@@ -9,0 +8,0 @@ state: Object.assign({ |
@@ -6,3 +6,2 @@ import { createManager } from '../createManager'; | ||
} | ||
return createManager(Object.assign({}, config, { | ||
@@ -9,0 +8,0 @@ state: Object.assign({ |
@@ -6,3 +6,2 @@ import { createManager } from '../createManager'; | ||
} | ||
return createManager(Object.assign({}, config, { | ||
@@ -9,0 +8,0 @@ state: Object.assign({ |
@@ -6,3 +6,2 @@ import { createManager } from '../createManager'; | ||
} | ||
return createManager(Object.assign({}, config, { | ||
@@ -9,0 +8,0 @@ state: Object.assign({ |
{ | ||
"name": "@fluentui/state", | ||
"description": "A set of utils to create framework agnostic and reusable state managers", | ||
"version": "0.65.0", | ||
"version": "0.66.0", | ||
"author": "Oleksandr Fediashov <a@fedyashov.com>", | ||
@@ -12,3 +12,3 @@ "bugs": "https://github.com/microsoft/fluentui/issues", | ||
"@fluentui/eslint-plugin": "*", | ||
"@fluentui/scripts": "^1.0.0", | ||
"@fluentui/scripts": "*", | ||
"lerna-alias": "^3.0.3-0" | ||
@@ -37,3 +37,3 @@ }, | ||
"types": "dist/es/index.d.ts", | ||
"gitHead": "e8c6fd4d0f1073c1f5f686bc625893b9c35c73f9" | ||
"gitHead": "1c49e0284bf9c89074740890b6da2ebdbdd0bcb3" | ||
} |
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
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
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
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
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
74010
798