Commit b353755e authored by Mickaël Bourgier's avatar Mickaël Bourgier
Browse files

Prepare for npm publication

parent d32aee44
Pipeline #971 failed with stage
in 1 minute and 44 seconds
/dist/
/docs/dist/ /docs/dist/
/node_modules/ /node_modules/
/package-json.lock /package-json.lock
......
image: node:12.8.1-alpine
test:
stage: test
coverage: '/^\s*Lines\s*:\s*(\d+.\d+\%)/'
before_script:
- yarn install
script:
- yarn test --coverage
const tasks = arr => arr.join(' && ');
module.exports = {
hooks: {
'pre-commit': tasks(['yarn pretty-quick --staged', 'yarn lint'])
}
};
MIT License
Copyright (c) 2019 Web|Alternatif
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# React Webf
[![pipeline status](https://git.webalternatif.com/webf/react-webf/badges/master/pipeline.svg)](https://git.webalternatif.com/webf/react-webf/commits/master)
[![coverage report](https://git.webalternatif.com/webf/react-webf/badges/master/coverage.svg)](https://git.webalternatif.com/webf/react-webf/commits/master)
## Installation and usage
Check out the [documentation website](https://react.webf.fr).
## Run tests
```shell script
yarn test
```
const test = process.env.NODE_ENV === 'test'; const test = process.env.NODE_ENV === 'test';
const cjs = process.env.BABEL_ENV === 'cjs'; const cjs = process.env.BABEL_ENV === 'cjs';
const es = process.env.BABEL_ENV === 'es';
module.exports = { module.exports = {
presets: [ presets: [
...@@ -14,5 +15,8 @@ module.exports = { ...@@ -14,5 +15,8 @@ module.exports = {
plugins: ['@babel/plugin-proposal-class-properties', 'dev-expression'], plugins: ['@babel/plugin-proposal-class-properties', 'dev-expression'],
ignore: test ? [] : [/\.test\.js/] ignore: [
...(cjs || es ? [/demos\/.+\.js/] : []),
...(test ? [] : [/\.test\.js/])
]
}; };
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));
var _styles = require("../styles");
var _Anchor = _interopRequireDefault(require("./Anchor.styles"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
/**
* @summary Insert une ancre décalée par rapport au composant
*
* Insert une ancre décalée par rapport au composant pour prendre en compte une éventuelle AppBar en position `fixed`
* qui passerait par dessus.
*/
var Anchor =
/*#__PURE__*/
function (_Component) {
_inherits(Anchor, _Component);
function Anchor() {
_classCallCheck(this, Anchor);
return _possibleConstructorReturn(this, _getPrototypeOf(Anchor).apply(this, arguments));
}
_createClass(Anchor, [{
key: "render",
value: function render() {
var _this$props = this.props,
Component = _this$props.component,
children = _this$props.children,
classes = _this$props.classes,
className = _this$props.className,
id = _this$props.id,
offset = _this$props.offset,
props = _objectWithoutProperties(_this$props, ["component", "children", "classes", "className", "id", "offset"]);
return _react.default.createElement(Component, _extends({
className: (0, _classnames.default)(classes.root, className)
}, props), _react.default.createElement("div", {
className: classes.anchor,
id: id
}), children);
}
}]);
return Anchor;
}(_react.Component);
Anchor.propTypes = {
/**
* Contenu du composant
*/
children: _propTypes.default.node,
/**
* Objet permettant de modifier les classes utilisées par le composant
*/
classes: _propTypes.default.object,
/**
* Nom(s) de classe(s) CSS à inclure dans le composant racine
*/
className: _propTypes.default.string,
/**
* Composant à utiliser en tant que composant racine
*/
component: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func, _propTypes.default.object]),
/**
* Identifiant de l'ancre
*/
id: _propTypes.default.string.isRequired,
/**
* Décalage de l'ancre en pixels, utilise par défaut la valeur de `theme.mixins.toolbar[.*].height`
*/
offset: _propTypes.default.number
};
Anchor.defaultProps = {
component: 'div'
};
var _default = (0, _styles.withStyles)(_Anchor.default)(Anchor);
exports.default = _default;
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _core = require("@webf/core");
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _default = function _default(theme) {
return _objectSpread({
root: {
position: 'relative'
},
anchor: function anchor(_ref) {
var offset = _ref.offset;
var toolbar = theme.mixins.toolbar;
return {
position: 'absolute',
top: (0, _core.isNumber)(offset) ? -offset : -toolbar.height
};
}
}, Object.assign.apply(Object, [{}].concat(_toConsumableArray(Object.keys(theme.mixins.toolbar).filter(function (key) {
return key.startsWith('@media') && 'height' in theme.mixins.toolbar[key];
}).map(function (key) {
return _defineProperty({}, key, {
anchor: function anchor(_ref2) {
var offset = _ref2.offset;
return (0, _core.isNumber)(offset) ? {
top: -offset
} : {
top: -theme.mixins.toolbar[key].height
};
}
});
})))));
};
exports.default = _default;
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _react2 = require("@webf/react");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var styles = {
anchor: {
marginBottom: 200
},
links: {
marginTop: 300,
marginBottom: 500
}
};
var UsageExample = function UsageExample(_ref) {
var classes = _ref.classes;
return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_react2.Anchor, {
className: classes.anchor,
id: "anchor-1",
offset: 0
}, "\u2693 Ancre sans offset"), _react.default.createElement(_react2.Anchor, {
className: classes.anchor,
id: "anchor-2"
}, "\u2693 Ancre avec offset par d\xE9faut"), _react.default.createElement(_react2.Anchor, {
className: classes.anchor,
id: "anchor-3",
offset: 100
}, "\u2693 Ancre avec offset fixe de 100"), _react.default.createElement("ul", {
className: classes.links
}, _react.default.createElement("li", null, _react.default.createElement("a", {
href: "#anchor-1"
}, "Lien vers l'ancre 1 (sans offset)")), _react.default.createElement("li", null, _react.default.createElement("a", {
href: "#anchor-2"
}, "Lien vers l'ancre 2 (avec offset par d\xE9faut)")), _react.default.createElement("li", null, _react.default.createElement("a", {
href: "#anchor-3"
}, "Lien vers l'ancre 3 (avec offset fixe de 100)"))));
};
var _default = (0, _react2.withStyles)(styles)(UsageExample);
exports.default = _default;
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function get() {
return _Anchor.default;
}
});
var _Anchor = _interopRequireDefault(require("./Anchor"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));
var _Paper = _interopRequireDefault(require("../Paper"));
var _styles = require("../styles");
var _AppBar = _interopRequireDefault(require("./AppBar.styles"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
/**
* @summary Sert de barre principale à une application
*
* Le composant AppBar permet d'afficher des informations et actions en rapport avec la page courante.
* Il est conseillé de l'utiliser avec avec le composant [Toolbar](/components/toolbar).
*/
var AppBar =
/*#__PURE__*/
function (_Component) {
_inherits(AppBar, _Component);
function AppBar() {
_classCallCheck(this, AppBar);
return _possibleConstructorReturn(this, _getPrototypeOf(AppBar).apply(this, arguments));
}
_createClass(AppBar, [{
key: "render",
value: function render() {
var _this$props = this.props,
classes = _this$props.classes,
className = _this$props.className,
color = _this$props.color,
fixed = _this$props.fixed,
otherProps = _objectWithoutProperties(_this$props, ["classes", "className", "color", "fixed"]);
return _react.default.createElement(_Paper.default, _extends({}, otherProps, {
component: "header",
elevation: 4,
className: (0, _classnames.default)(classes.root, classes["".concat(color, "Color")], _defineProperty({}, classes.fixed, fixed), className),
square: true
}));
}
}]);
return AppBar;
}(_react.Component);
AppBar.propTypes = {
/**
* Nom(s) de classe(s) CSS à inclure dans le composant racine
*/
className: _propTypes.default.string,
/**
* Objet permettant de modifier les classes utilisées par le composant
*/
classes: _propTypes.default.object,
/**
* Contenu du composant
*/
children: _propTypes.default.node,
/**
* Couleur de fond de l'AppBar
*/
color: _propTypes.default.oneOf(['primary', 'success', 'info', 'warning', 'danger', 'light', 'dark']),
/**
* Active ou non le positionnement `fixed`
*/
fixed: _propTypes.default.bool
};
AppBar.defaultProps = {
fixed: false,
color: 'primary'
};
var _default = (0, _styles.withStyles)(_AppBar.default)(AppBar);
exports.default = _default;
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = function _default(theme) {
return {
root: {
display: 'flex',
flexDirection: 'column',
width: '100%',
zIndex: theme.zIndex.AppBar
},
fixed: {
position: 'fixed'
},
primaryColor: {
backgroundColor: theme.palette.primary,
color: theme.palette.light
},
successColor: {
backgroundColor: theme.palette.success,
color: theme.palette.light
},
infoColor: {
backgroundColor: theme.palette.info,
color: theme.palette.light
},
warningColor: {
backgroundColor: theme.palette.warning,
color: theme.palette.light
},
dangerColor: {
backgroundColor: theme.palette.danger,
color: theme.palette.light
},
lightColor: {
backgroundColor: theme.palette.light,
color: theme.palette.dark
},
darkColor: {
backgroundColor: theme.palette.dark,
color: theme.palette.light
}
};
};
exports.default = _default;
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _react2 = require("@webf/react");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var colors = ['primary', 'success', 'info', 'warning', 'danger', 'light', 'dark'];
var styles = function styles() {
return {
colorChoice: {
textAlign: 'center'
}
};
};
var ColorSwitchAppBar =
/*#__PURE__*/
function (_Component) {
_inherits(ColorSwitchAppBar, _Component);
function ColorSwitchAppBar() {
var _getPrototypeOf2;
var _this;
_classCallCheck(this, ColorSwitchAppBar);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}