Latest updates from IceHrmPro
This commit is contained in:
6
web/node_modules/mini-store/esm/PropTypes.js
generated
vendored
Normal file
6
web/node_modules/mini-store/esm/PropTypes.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import PropTypes from 'prop-types';
|
||||
export var storeShape = PropTypes.shape({
|
||||
subscribe: PropTypes.func.isRequired,
|
||||
setState: PropTypes.func.isRequired,
|
||||
getState: PropTypes.func.isRequired,
|
||||
});
|
||||
30
web/node_modules/mini-store/esm/Provider.js
generated
vendored
Normal file
30
web/node_modules/mini-store/esm/Provider.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
import React, { Component, createContext } from 'react';
|
||||
import { storeShape } from './PropTypes';
|
||||
export var MiniStoreContext = createContext(null);
|
||||
var Provider = /** @class */ (function (_super) {
|
||||
__extends(Provider, _super);
|
||||
function Provider() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
Provider.prototype.render = function () {
|
||||
return React.createElement(MiniStoreContext.Provider, { value: this.props.store }, this.props.children);
|
||||
};
|
||||
Provider.propTypes = {
|
||||
store: storeShape.isRequired,
|
||||
};
|
||||
return Provider;
|
||||
}(Component));
|
||||
export { Provider };
|
||||
15
web/node_modules/mini-store/esm/__tests__/Provider.test.js
generated
vendored
Normal file
15
web/node_modules/mini-store/esm/__tests__/Provider.test.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import React, { useContext } from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import { create, Provider } from '../index';
|
||||
import { MiniStoreContext } from '../Provider';
|
||||
test('store context', function (done) {
|
||||
var store = create({});
|
||||
var App = function () {
|
||||
var contextStore = useContext(MiniStoreContext);
|
||||
expect(contextStore).toBe(store);
|
||||
done();
|
||||
return React.createElement("div", null, "hello");
|
||||
};
|
||||
mount(React.createElement(Provider, { store: store },
|
||||
React.createElement(App, null)));
|
||||
});
|
||||
161
web/node_modules/mini-store/esm/__tests__/connect.test.js
generated
vendored
Normal file
161
web/node_modules/mini-store/esm/__tests__/connect.test.js
generated
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import { create, Provider, connect } from '../index';
|
||||
var StatelessApp;
|
||||
var Connected;
|
||||
var store;
|
||||
var wrapper;
|
||||
var StatefulApp = /** @class */ (function (_super) {
|
||||
__extends(StatefulApp, _super);
|
||||
function StatefulApp() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
StatefulApp.prototype.render = function () {
|
||||
return (React.createElement("div", null, this.props.msg));
|
||||
};
|
||||
return StatefulApp;
|
||||
}(React.Component));
|
||||
describe('stateless', function () {
|
||||
beforeEach(function () {
|
||||
StatelessApp = function (_a) {
|
||||
var msg = _a.msg;
|
||||
return React.createElement("div", null, msg);
|
||||
};
|
||||
Connected = connect(function (state) { return state; })(StatelessApp);
|
||||
store = create({ msg: 'hello', count: 0 });
|
||||
wrapper = mount(React.createElement(Provider, { store: store },
|
||||
React.createElement(Connected, null)));
|
||||
});
|
||||
test('map state to props', function () {
|
||||
expect(wrapper.text()).toBe('hello');
|
||||
});
|
||||
test('renrender as subscribed state changes', function () {
|
||||
store.setState({ msg: 'halo' });
|
||||
expect(wrapper.text()).toBe('halo');
|
||||
});
|
||||
test('on rerender when unsubscribed state changes', function () {
|
||||
store.setState({ count: 1 });
|
||||
expect(wrapper.text()).toBe('hello');
|
||||
});
|
||||
test('do not subscribe', function () {
|
||||
Connected = connect()(StatelessApp);
|
||||
wrapper = mount(React.createElement(Provider, { store: store },
|
||||
React.createElement(Connected, { msg: "hello" })));
|
||||
expect(wrapper.instance().unsubscribe).toBeUndefined();
|
||||
});
|
||||
test('pass own props to mapStateToProps', function () {
|
||||
Connected = connect(function (state, props) { return ({
|
||||
msg: state.msg + " " + props.name
|
||||
}); })(StatelessApp);
|
||||
wrapper = mount(React.createElement(Provider, { store: store },
|
||||
React.createElement(Connected, { name: "world" })));
|
||||
expect(wrapper.text()).toBe('hello world');
|
||||
});
|
||||
test('mapStateToProps is invoked when own props changes', function () {
|
||||
Connected = connect(function (state, props) { return ({
|
||||
msg: state.msg + " " + props.name
|
||||
}); })(StatelessApp);
|
||||
var App = /** @class */ (function (_super) {
|
||||
__extends(App, _super);
|
||||
function App() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.state = {
|
||||
name: 'world'
|
||||
};
|
||||
return _this;
|
||||
}
|
||||
App.prototype.render = function () {
|
||||
var _this = this;
|
||||
return (React.createElement("div", null,
|
||||
React.createElement("button", { onClick: function () { return _this.setState({ name: 'there' }); } }, "Click"),
|
||||
React.createElement(Connected, { name: this.state.name })));
|
||||
};
|
||||
return App;
|
||||
}(React.Component));
|
||||
wrapper = mount(React.createElement(Provider, { store: store },
|
||||
React.createElement(App, null)));
|
||||
wrapper.find('button').simulate('click');
|
||||
expect(wrapper.find(Connected).text()).toBe('hello there');
|
||||
});
|
||||
test('mapStateToProps is not invoked when own props is not used', function () {
|
||||
var mapStateToProps = jest.fn(function (state) { return ({ msg: state.msg }); });
|
||||
Connected = connect(mapStateToProps)(StatelessApp);
|
||||
var App = /** @class */ (function (_super) {
|
||||
__extends(App, _super);
|
||||
function App() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.state = {
|
||||
name: 'world'
|
||||
};
|
||||
return _this;
|
||||
}
|
||||
App.prototype.render = function () {
|
||||
var _this = this;
|
||||
return (React.createElement("div", null,
|
||||
React.createElement("button", { onClick: function () { return _this.setState({ name: 'there' }); } }, "Click"),
|
||||
React.createElement(Connected, { name: this.state.name })));
|
||||
};
|
||||
return App;
|
||||
}(React.Component));
|
||||
wrapper = mount(React.createElement(Provider, { store: store },
|
||||
React.createElement(App, null)));
|
||||
wrapper.find('button').simulate('click');
|
||||
expect(mapStateToProps).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
// https://github.com/ant-design/ant-design/issues/11723
|
||||
test('rerender component when props changes', function () {
|
||||
var Dummy = function (_a) {
|
||||
var visible = _a.visible;
|
||||
return React.createElement("div", null, visible && 'hello');
|
||||
};
|
||||
Connected = connect(function (state, props) { return ({
|
||||
visible: state.visible === false ? props.ownVisible : state.visible
|
||||
}); })(Dummy);
|
||||
var App = /** @class */ (function (_super) {
|
||||
__extends(App, _super);
|
||||
function App() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.state = {
|
||||
visible: true,
|
||||
};
|
||||
return _this;
|
||||
}
|
||||
App.prototype.render = function () {
|
||||
var _this = this;
|
||||
return (React.createElement("div", null,
|
||||
React.createElement("button", { onClick: function () { return _this.setState({ visible: false }); } }, "Click"),
|
||||
React.createElement(Connected, { ownVisible: this.state.visible })));
|
||||
};
|
||||
return App;
|
||||
}(React.Component));
|
||||
store = create({ visible: false });
|
||||
wrapper = mount(React.createElement(Provider, { store: store },
|
||||
React.createElement(App, null)));
|
||||
wrapper.find('button').simulate('click');
|
||||
expect(wrapper.find(Dummy).text()).toBe('');
|
||||
store.setState({ visible: true });
|
||||
wrapper.update();
|
||||
expect(wrapper.find(Dummy).text()).toBe('hello');
|
||||
});
|
||||
});
|
||||
describe('stateful', function () {
|
||||
beforeEach(function () {
|
||||
Connected = connect(function (state) { return state; })(StatefulApp);
|
||||
store = create({ msg: 'hello', count: 0 });
|
||||
wrapper = mount(React.createElement(Provider, { store: store },
|
||||
React.createElement(Connected, null)));
|
||||
});
|
||||
});
|
||||
20
web/node_modules/mini-store/esm/__tests__/create.test.js
generated
vendored
Normal file
20
web/node_modules/mini-store/esm/__tests__/create.test.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import { create } from '../index';
|
||||
test('create', function () {
|
||||
var store = create({ foo: true });
|
||||
expect(store.getState()).toEqual({ foo: true });
|
||||
});
|
||||
test('setState', function () {
|
||||
var store = create({ foo: false, bar: 1 });
|
||||
store.setState({ foo: false });
|
||||
expect(store.getState()).toEqual({ foo: false, bar: 1 });
|
||||
});
|
||||
test('subscribe', function () {
|
||||
var store = create({ foo: false });
|
||||
var listener1 = jest.fn();
|
||||
var listener2 = jest.fn();
|
||||
store.subscribe(listener1);
|
||||
store.subscribe(listener2);
|
||||
store.setState({ foo: false });
|
||||
expect(listener1).toBeCalled();
|
||||
expect(listener2).toBeCalled();
|
||||
});
|
||||
107
web/node_modules/mini-store/esm/connect.js
generated
vendored
Normal file
107
web/node_modules/mini-store/esm/connect.js
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
import { default as React, Component } from 'react';
|
||||
import shallowEqual from 'shallowequal';
|
||||
import hoistStatics from 'hoist-non-react-statics';
|
||||
import { polyfill } from 'react-lifecycles-compat';
|
||||
import { MiniStoreContext } from './Provider';
|
||||
function getDisplayName(WrappedComponent) {
|
||||
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
||||
}
|
||||
var defaultMapStateToProps = function () { return ({}); };
|
||||
export function connect(mapStateToProps, options) {
|
||||
if (options === void 0) { options = {}; }
|
||||
var shouldSubscribe = !!mapStateToProps;
|
||||
var finalMapStateToProps = mapStateToProps || defaultMapStateToProps;
|
||||
return function wrapWithConnect(WrappedComponent) {
|
||||
var Connect = /** @class */ (function (_super) {
|
||||
__extends(Connect, _super);
|
||||
function Connect(props, context) {
|
||||
var _this = _super.call(this, props, context) || this;
|
||||
_this.unsubscribe = null;
|
||||
_this.handleChange = function () {
|
||||
if (!_this.unsubscribe) {
|
||||
return;
|
||||
}
|
||||
var nextState = finalMapStateToProps(_this.store.getState(), _this.props);
|
||||
_this.setState({ subscribed: nextState });
|
||||
};
|
||||
_this.store = _this.context;
|
||||
_this.state = {
|
||||
subscribed: finalMapStateToProps(_this.store.getState(), props),
|
||||
store: _this.store,
|
||||
props: props,
|
||||
};
|
||||
return _this;
|
||||
}
|
||||
Connect.getDerivedStateFromProps = function (props, prevState) {
|
||||
// using ownProps
|
||||
if (mapStateToProps && mapStateToProps.length === 2 && props !== prevState.props) {
|
||||
return {
|
||||
subscribed: finalMapStateToProps(prevState.store.getState(), props),
|
||||
props: props,
|
||||
};
|
||||
}
|
||||
return { props: props };
|
||||
};
|
||||
Connect.prototype.componentDidMount = function () {
|
||||
this.trySubscribe();
|
||||
};
|
||||
Connect.prototype.componentWillUnmount = function () {
|
||||
this.tryUnsubscribe();
|
||||
};
|
||||
Connect.prototype.shouldComponentUpdate = function (nextProps, nextState) {
|
||||
return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state.subscribed, nextState.subscribed);
|
||||
};
|
||||
Connect.prototype.trySubscribe = function () {
|
||||
if (shouldSubscribe) {
|
||||
this.unsubscribe = this.store.subscribe(this.handleChange);
|
||||
this.handleChange();
|
||||
}
|
||||
};
|
||||
Connect.prototype.tryUnsubscribe = function () {
|
||||
if (this.unsubscribe) {
|
||||
this.unsubscribe();
|
||||
this.unsubscribe = null;
|
||||
}
|
||||
};
|
||||
Connect.prototype.render = function () {
|
||||
var props = __assign(__assign(__assign({}, this.props), this.state.subscribed), { store: this.store });
|
||||
return React.createElement(WrappedComponent, __assign({}, props, { ref: this.props.miniStoreForwardedRef }));
|
||||
};
|
||||
Connect.displayName = "Connect(" + getDisplayName(WrappedComponent) + ")";
|
||||
Connect.contextType = MiniStoreContext;
|
||||
return Connect;
|
||||
}(Component));
|
||||
polyfill(Connect);
|
||||
if (options.forwardRef) {
|
||||
var forwarded = React.forwardRef(function (props, ref) {
|
||||
return React.createElement(Connect, __assign({}, props, { miniStoreForwardedRef: ref }));
|
||||
});
|
||||
return hoistStatics(forwarded, WrappedComponent);
|
||||
}
|
||||
return hoistStatics(Connect, WrappedComponent);
|
||||
};
|
||||
}
|
||||
36
web/node_modules/mini-store/esm/create.js
generated
vendored
Normal file
36
web/node_modules/mini-store/esm/create.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
export function create(initialState) {
|
||||
var state = initialState;
|
||||
var listeners = [];
|
||||
function setState(partial) {
|
||||
state = __assign(__assign({}, state), partial);
|
||||
for (var i = 0; i < listeners.length; i++) {
|
||||
listeners[i]();
|
||||
}
|
||||
}
|
||||
function getState() {
|
||||
return state;
|
||||
}
|
||||
function subscribe(listener) {
|
||||
listeners.push(listener);
|
||||
return function unsubscribe() {
|
||||
var index = listeners.indexOf(listener);
|
||||
listeners.splice(index, 1);
|
||||
};
|
||||
}
|
||||
return {
|
||||
setState: setState,
|
||||
getState: getState,
|
||||
subscribe: subscribe,
|
||||
};
|
||||
}
|
||||
3
web/node_modules/mini-store/esm/index.js
generated
vendored
Normal file
3
web/node_modules/mini-store/esm/index.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export { Provider } from './Provider';
|
||||
export { connect } from './connect';
|
||||
export { create } from './create';
|
||||
21
web/node_modules/mini-store/esm/types.js
generated
vendored
Normal file
21
web/node_modules/mini-store/esm/types.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
// Type definitions for react-redux 7.1
|
||||
// Project: https://github.com/reduxjs/react-redux
|
||||
// Definitions by: Qubo <https://github.com/tkqubo>,
|
||||
// Kenzie Togami <https://github.com/kenzierocks>,
|
||||
// Curits Layne <https://github.com/clayne11>
|
||||
// Frank Tan <https://github.com/tansongyang>
|
||||
// Nicholas Boll <https://github.com/nicholasboll>
|
||||
// Dibyo Majumdar <https://github.com/mdibyo>
|
||||
// Thomas Charlat <https://github.com/kallikrein>
|
||||
// Valentin Descamps <https://github.com/val1984>
|
||||
// Johann Rakotoharisoa <https://github.com/jrakotoharisoa>
|
||||
// Anatoli Papirovski <https://github.com/apapirovski>
|
||||
// Boris Sergeyev <https://github.com/surgeboris>
|
||||
// Søren Bruus Frank <https://github.com/soerenbf>
|
||||
// Jonathan Ziller <https://github.com/mrwolfz>
|
||||
// Dylan Vann <https://github.com/dylanvann>
|
||||
// Yuki Ito <https://github.com/Lazyuki>
|
||||
// Kazuma Ebina <https://github.com/kazuma1989>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
;
|
||||
Reference in New Issue
Block a user