@panneau/core 1.0.1-alpha.0 → 1.0.3-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/contexts.js +1 -1
- package/es/contexts.js +1740 -0
- package/es/hooks.js +1116 -0
- package/es/index.js +991 -9
- package/es/utils.js +329 -1
- package/hooks.js +1 -0
- package/lib/contexts.js +1871 -0
- package/lib/hooks.js +1167 -0
- package/lib/index.js +1003 -44
- package/lib/utils.js +371 -12
- package/package.json +79 -49
- package/utils.js +1 -1
- package/components.js +0 -1
- package/es/components/Button.js +0 -157
- package/es/components/ButtonGroup.js +0 -87
- package/es/components/Errors.js +0 -33
- package/es/components/Label.js +0 -32
- package/es/components/Loading.js +0 -56
- package/es/components/index.js +0 -6
- package/es/contexts/Components.js +0 -52
- package/es/contexts/Definition.js +0 -21
- package/es/contexts/UrlGenerator.js +0 -33
- package/es/contexts/index.js +0 -3
- package/es/lib/ComponentsCollection.js +0 -107
- package/es/lib/Definition.js +0 -134
- package/es/lib/PropTypes.js +0 -75
- package/es/lib/Resource.js +0 -93
- package/es/lib/ResourceApi.js +0 -139
- package/es/lib/UrlGenerator.js +0 -66
- package/es/lib/requests.js +0 -165
- package/es/lib/useResourceApi.js +0 -19
- package/es/lib/utils.js +0 -19
- package/es/requests.js +0 -1
- package/lib/components/Button.js +0 -182
- package/lib/components/ButtonGroup.js +0 -104
- package/lib/components/Errors.js +0 -49
- package/lib/components/Label.js +0 -47
- package/lib/components/Loading.js +0 -70
- package/lib/components/index.js +0 -47
- package/lib/contexts/Components.js +0 -78
- package/lib/contexts/Definition.js +0 -45
- package/lib/contexts/UrlGenerator.js +0 -53
- package/lib/contexts/index.js +0 -73
- package/lib/lib/ComponentsCollection.js +0 -117
- package/lib/lib/Definition.js +0 -145
- package/lib/lib/PropTypes.js +0 -152
- package/lib/lib/Resource.js +0 -104
- package/lib/lib/ResourceApi.js +0 -154
- package/lib/lib/UrlGenerator.js +0 -76
- package/lib/lib/requests.js +0 -206
- package/lib/lib/useResourceApi.js +0 -33
- package/lib/lib/utils.js +0 -35
- package/lib/requests.js +0 -17
- package/requests.js +0 -1
- package/src/components/Button.jsx +0 -186
- package/src/components/ButtonGroup.jsx +0 -98
- package/src/components/Errors.jsx +0 -46
- package/src/components/Label.jsx +0 -32
- package/src/components/Loading.jsx +0 -51
- package/src/components/index.js +0 -7
- package/src/contexts/Components.jsx +0 -49
- package/src/contexts/Definition.jsx +0 -21
- package/src/contexts/UrlGenerator.jsx +0 -35
- package/src/contexts/index.js +0 -12
- package/src/index.js +0 -8
- package/src/lib/ComponentsCollection.js +0 -81
- package/src/lib/Definition.js +0 -87
- package/src/lib/PropTypes.js +0 -117
- package/src/lib/Resource.js +0 -65
- package/src/lib/ResourceApi.js +0 -114
- package/src/lib/UrlGenerator.js +0 -55
- package/src/lib/requests.js +0 -120
- package/src/lib/useResourceApi.jsx +0 -20
- package/src/lib/utils.js +0 -13
- package/src/requests.js +0 -1
- package/src/styles/components/button-group.scss +0 -10
- package/src/styles/components/errors.scss +0 -5
- package/src/styles/components/loading.scss +0 -36
- package/src/styles/variables.scss +0 -5
- package/src/utils.js +0 -1
package/es/components/Button.js
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
-
|
|
7
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
8
|
-
|
|
9
|
-
/* eslint-disable jsx-a11y/anchor-is-valid, react/button-has-type, react/jsx-props-no-spreading */
|
|
10
|
-
import React from 'react';
|
|
11
|
-
import PropTypes from 'prop-types';
|
|
12
|
-
import classNames from 'classnames';
|
|
13
|
-
import isString from 'lodash/isString';
|
|
14
|
-
import { Link } from 'react-router-dom';
|
|
15
|
-
import { injectIntl } from 'react-intl';
|
|
16
|
-
import Label from './Label';
|
|
17
|
-
import * as PanneauPropTypes from '../lib/PropTypes';
|
|
18
|
-
import { isMessage } from '../lib/utils';
|
|
19
|
-
var propTypes = {
|
|
20
|
-
intl: PanneauPropTypes.intl.isRequired,
|
|
21
|
-
type: PropTypes.string,
|
|
22
|
-
size: PanneauPropTypes.buttonSize,
|
|
23
|
-
style: PanneauPropTypes.buttonStyle,
|
|
24
|
-
href: PropTypes.string,
|
|
25
|
-
target: PropTypes.string,
|
|
26
|
-
external: PropTypes.bool,
|
|
27
|
-
dropdown: PanneauPropTypes.dropdownItems,
|
|
28
|
-
icon: PropTypes.string,
|
|
29
|
-
disabled: PropTypes.bool,
|
|
30
|
-
className: PropTypes.string,
|
|
31
|
-
title: PanneauPropTypes.message,
|
|
32
|
-
label: PanneauPropTypes.label,
|
|
33
|
-
children: PanneauPropTypes.label,
|
|
34
|
-
onClick: PropTypes.func,
|
|
35
|
-
onItemClick: PropTypes.func
|
|
36
|
-
};
|
|
37
|
-
var defaultProps = {
|
|
38
|
-
type: 'button',
|
|
39
|
-
size: null,
|
|
40
|
-
style: 'primary',
|
|
41
|
-
href: null,
|
|
42
|
-
target: null,
|
|
43
|
-
external: false,
|
|
44
|
-
dropdown: null,
|
|
45
|
-
icon: null,
|
|
46
|
-
disabled: false,
|
|
47
|
-
className: null,
|
|
48
|
-
title: null,
|
|
49
|
-
label: null,
|
|
50
|
-
children: null,
|
|
51
|
-
onClick: null,
|
|
52
|
-
onItemClick: null
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
var Button = function Button(_ref) {
|
|
56
|
-
var _classNames;
|
|
57
|
-
|
|
58
|
-
var intl = _ref.intl,
|
|
59
|
-
type = _ref.type,
|
|
60
|
-
size = _ref.size,
|
|
61
|
-
style = _ref.style,
|
|
62
|
-
href = _ref.href,
|
|
63
|
-
external = _ref.external,
|
|
64
|
-
target = _ref.target,
|
|
65
|
-
icon = _ref.icon,
|
|
66
|
-
dropdown = _ref.dropdown,
|
|
67
|
-
label = _ref.label,
|
|
68
|
-
title = _ref.title,
|
|
69
|
-
disabled = _ref.disabled,
|
|
70
|
-
children = _ref.children,
|
|
71
|
-
className = _ref.className,
|
|
72
|
-
onClick = _ref.onClick,
|
|
73
|
-
onItemClick = _ref.onItemClick,
|
|
74
|
-
props = _objectWithoutProperties(_ref, ["intl", "type", "size", "style", "href", "external", "target", "icon", "dropdown", "label", "title", "disabled", "children", "className", "onClick", "onItemClick"]);
|
|
75
|
-
|
|
76
|
-
var hasDropdown = dropdown !== null && dropdown.length > 0;
|
|
77
|
-
|
|
78
|
-
var buttonProps = _objectSpread({
|
|
79
|
-
className: classNames(['btn'], (_classNames = {}, _defineProperty(_classNames, "btn-".concat(style), style !== null), _defineProperty(_classNames, "btn-".concat(size), !hasDropdown && size !== null), _defineProperty(_classNames, 'dropdown-toggle', hasDropdown), _defineProperty(_classNames, "disabled", disabled), _defineProperty(_classNames, className, className !== null), _classNames)),
|
|
80
|
-
title: isMessage(title) ? intl.formatMessage(title) : title
|
|
81
|
-
}, props);
|
|
82
|
-
|
|
83
|
-
if (hasDropdown) {
|
|
84
|
-
buttonProps['data-toggle'] = 'dropdown';
|
|
85
|
-
buttonProps['aria-haspopup'] = 'true';
|
|
86
|
-
buttonProps['aria-expanded'] = 'false';
|
|
87
|
-
} else {
|
|
88
|
-
buttonProps.onClick = onClick;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
var finalLabel = children || label;
|
|
92
|
-
var inner = React.createElement(React.Fragment, null, isString(icon) ? React.createElement("span", {
|
|
93
|
-
className: classNames([icon, {
|
|
94
|
-
'mr-2': finalLabel !== null
|
|
95
|
-
}])
|
|
96
|
-
}) : icon, React.createElement(Label, null, finalLabel), hasDropdown ? React.createElement("span", {
|
|
97
|
-
className: "caret"
|
|
98
|
-
}) : null);
|
|
99
|
-
var button;
|
|
100
|
-
|
|
101
|
-
if (!hasDropdown && href !== null) {
|
|
102
|
-
button = external ? React.createElement("a", _extends({
|
|
103
|
-
href: href
|
|
104
|
-
}, buttonProps, {
|
|
105
|
-
target: target,
|
|
106
|
-
"aria-disabled": disabled ? 'true' : 'false'
|
|
107
|
-
}), inner) : React.createElement(Link, _extends({
|
|
108
|
-
to: href
|
|
109
|
-
}, buttonProps, {
|
|
110
|
-
"aria-disabled": disabled ? 'true' : 'false'
|
|
111
|
-
}), inner);
|
|
112
|
-
} else {
|
|
113
|
-
button = React.createElement("button", _extends({
|
|
114
|
-
type: type
|
|
115
|
-
}, buttonProps, {
|
|
116
|
-
disabled: disabled
|
|
117
|
-
}), inner);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return hasDropdown ? React.createElement("div", {
|
|
121
|
-
className: classNames(['btn-group', _defineProperty({}, "btn-group-".concat(size), hasDropdown && size !== null)])
|
|
122
|
-
}, button, React.createElement("ul", {
|
|
123
|
-
className: "dropdown-menu"
|
|
124
|
-
}, dropdown.map(function (it, index) {
|
|
125
|
-
var itemHref = it.href,
|
|
126
|
-
itemLabel = it.label,
|
|
127
|
-
_it$external = it.external,
|
|
128
|
-
itemExternal = _it$external === void 0 ? false : _it$external,
|
|
129
|
-
_it$target = it.target,
|
|
130
|
-
itemTarget = _it$target === void 0 ? null : _it$target,
|
|
131
|
-
_it$onClick = it.onClick,
|
|
132
|
-
itemOnClick = _it$onClick === void 0 ? null : _it$onClick;
|
|
133
|
-
var itemProps = {
|
|
134
|
-
className: 'dropdown-item',
|
|
135
|
-
key: "dropdown-".concat(index),
|
|
136
|
-
onClick: function onClick(e) {
|
|
137
|
-
if (itemOnClick !== null) {
|
|
138
|
-
itemOnClick(e, it, index);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (onItemClick !== null) {
|
|
142
|
-
onItemClick(e, it, index);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
return itemExternal ? React.createElement("a", _extends({}, itemProps, {
|
|
147
|
-
href: itemHref,
|
|
148
|
-
target: itemTarget
|
|
149
|
-
}), React.createElement(Label, null, itemLabel)) : React.createElement(Link, _extends({}, itemProps, {
|
|
150
|
-
to: itemHref
|
|
151
|
-
}), React.createElement(Label, null, itemLabel));
|
|
152
|
-
}))) : button;
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
Button.propTypes = propTypes;
|
|
156
|
-
Button.defaultProps = defaultProps;
|
|
157
|
-
export default injectIntl(Button);
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
|
|
5
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import PropTypes from 'prop-types';
|
|
8
|
-
import classNames from 'classnames';
|
|
9
|
-
import * as PanneauPropTypes from '../lib/PropTypes';
|
|
10
|
-
import Button from './Button';
|
|
11
|
-
var styles = {
|
|
12
|
-
"container": "panneau-core-button-group-container",
|
|
13
|
-
"noWrap": "panneau-core-button-group-noWrap",
|
|
14
|
-
"button": "panneau-core-button-group-button"
|
|
15
|
-
};
|
|
16
|
-
var propTypes = {
|
|
17
|
-
buttons: PanneauPropTypes.buttons,
|
|
18
|
-
size: PanneauPropTypes.buttonSize,
|
|
19
|
-
style: PanneauPropTypes.buttonStyle,
|
|
20
|
-
href: PropTypes.string,
|
|
21
|
-
onClick: PropTypes.func,
|
|
22
|
-
noWrap: PropTypes.bool,
|
|
23
|
-
toggle: PropTypes.bool,
|
|
24
|
-
className: PropTypes.string,
|
|
25
|
-
buttonClassName: PropTypes.string
|
|
26
|
-
};
|
|
27
|
-
var defaultProps = {
|
|
28
|
-
buttons: [],
|
|
29
|
-
size: null,
|
|
30
|
-
style: 'outline-secondary',
|
|
31
|
-
href: null,
|
|
32
|
-
noWrap: false,
|
|
33
|
-
toggle: false,
|
|
34
|
-
onClick: null,
|
|
35
|
-
className: null,
|
|
36
|
-
buttonClassName: null
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
var ButtonGroup = function ButtonGroup(_ref) {
|
|
40
|
-
var _ref2;
|
|
41
|
-
|
|
42
|
-
var buttons = _ref.buttons,
|
|
43
|
-
style = _ref.style,
|
|
44
|
-
size = _ref.size,
|
|
45
|
-
noWrap = _ref.noWrap,
|
|
46
|
-
toggle = _ref.toggle,
|
|
47
|
-
className = _ref.className,
|
|
48
|
-
buttonClassName = _ref.buttonClassName,
|
|
49
|
-
onClick = _ref.onClick,
|
|
50
|
-
props = _objectWithoutProperties(_ref, ["buttons", "style", "size", "noWrap", "toggle", "className", "buttonClassName", "onClick"]);
|
|
51
|
-
|
|
52
|
-
return React.createElement("div", _extends({
|
|
53
|
-
className: classNames(['btn-group', styles.container, (_ref2 = {}, _defineProperty(_ref2, "btn-group-".concat(size), size !== null), _defineProperty(_ref2, styles.noWrap, noWrap), _defineProperty(_ref2, className, className !== null), _ref2)])
|
|
54
|
-
}, toggle ? {
|
|
55
|
-
'data-toggle': 'buttons'
|
|
56
|
-
} : null, props), buttons.map(function (button, index) {
|
|
57
|
-
var _ref3;
|
|
58
|
-
|
|
59
|
-
var key = "button-".concat(button.name || button.id || index);
|
|
60
|
-
|
|
61
|
-
if (React.isValidElement(button)) {
|
|
62
|
-
return React.cloneElement(button, {
|
|
63
|
-
key: key
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
var _button$className = button.className,
|
|
68
|
-
customClassName = _button$className === void 0 ? null : _button$className,
|
|
69
|
-
_button$style = button.style,
|
|
70
|
-
buttonStyle = _button$style === void 0 ? style : _button$style,
|
|
71
|
-
_button$active = button.active,
|
|
72
|
-
active = _button$active === void 0 ? false : _button$active,
|
|
73
|
-
buttonProps = _objectWithoutProperties(button, ["className", "style", "active"]);
|
|
74
|
-
|
|
75
|
-
return React.createElement(Button, _extends({}, buttonProps, {
|
|
76
|
-
style: buttonStyle,
|
|
77
|
-
key: key,
|
|
78
|
-
className: classNames([styles.button, (_ref3 = {
|
|
79
|
-
'active': active
|
|
80
|
-
}, _defineProperty(_ref3, buttonClassName, buttonClassName !== null), _defineProperty(_ref3, customClassName, customClassName !== null), _ref3)])
|
|
81
|
-
}));
|
|
82
|
-
}));
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
ButtonGroup.propTypes = propTypes;
|
|
86
|
-
ButtonGroup.defaultProps = defaultProps;
|
|
87
|
-
export default ButtonGroup;
|
package/es/components/Errors.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import classNames from 'classnames';
|
|
5
|
-
import isArray from 'lodash/isArray';
|
|
6
|
-
import { errors as errorsPropTypes } from '../lib/PropTypes';
|
|
7
|
-
var styles = {
|
|
8
|
-
"container": "panneau-core-errors-container"
|
|
9
|
-
};
|
|
10
|
-
var propTypes = {
|
|
11
|
-
errors: errorsPropTypes,
|
|
12
|
-
className: PropTypes.string
|
|
13
|
-
};
|
|
14
|
-
var defaultProps = {
|
|
15
|
-
errors: [],
|
|
16
|
-
className: null
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
var Errors = function Errors(_ref) {
|
|
20
|
-
var errors = _ref.errors,
|
|
21
|
-
className = _ref.className;
|
|
22
|
-
return errors !== null && errors.length > 0 ? React.createElement("div", {
|
|
23
|
-
className: classNames(['alert', 'alert-danger', styles.container, _defineProperty({}, className, className !== null)])
|
|
24
|
-
}, isArray(errors) ? React.createElement("ul", null, errors.map(function (error) {
|
|
25
|
-
return React.createElement("li", {
|
|
26
|
-
key: "error-".concat(error)
|
|
27
|
-
}, error);
|
|
28
|
-
})) : errors) : null;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
Errors.propTypes = propTypes;
|
|
32
|
-
Errors.defaultProps = defaultProps;
|
|
33
|
-
export default Errors;
|
package/es/components/Label.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
6
|
-
import { FormattedMessage, FormattedHTMLMessage } from 'react-intl';
|
|
7
|
-
import { label as labelPropTypes } from '../lib/PropTypes';
|
|
8
|
-
import { isMessage } from '../lib/utils';
|
|
9
|
-
var propTypes = {
|
|
10
|
-
children: labelPropTypes.isRequired,
|
|
11
|
-
isHtml: PropTypes.bool,
|
|
12
|
-
values: PropTypes.object // eslint-disable-line react/forbid-prop-types
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
var defaultProps = {
|
|
16
|
-
isHtml: false,
|
|
17
|
-
values: {}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
var Label = function Label(_ref) {
|
|
21
|
-
var children = _ref.children,
|
|
22
|
-
isHtml = _ref.isHtml,
|
|
23
|
-
values = _ref.values;
|
|
24
|
-
var Message = isHtml ? FormattedHTMLMessage : FormattedMessage;
|
|
25
|
-
return isMessage(children) ? React.createElement(Message, _extends({
|
|
26
|
-
values: values
|
|
27
|
-
}, children)) : children;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
Label.propTypes = propTypes;
|
|
31
|
-
Label.defaultProps = defaultProps;
|
|
32
|
-
export default Label;
|
package/es/components/Loading.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import classNames from 'classnames';
|
|
5
|
-
var styles = {
|
|
6
|
-
"component": "panneau-core-loading-component",
|
|
7
|
-
"dot": "panneau-core-loading-dot",
|
|
8
|
-
"pulse": "panneau-core-loading-pulse"
|
|
9
|
-
};
|
|
10
|
-
var propTypes = {
|
|
11
|
-
loading: PropTypes.bool,
|
|
12
|
-
color: PropTypes.string,
|
|
13
|
-
size: PropTypes.number,
|
|
14
|
-
margin: PropTypes.string,
|
|
15
|
-
sizeUnit: PropTypes.string,
|
|
16
|
-
className: PropTypes.string
|
|
17
|
-
};
|
|
18
|
-
var defaultProps = {
|
|
19
|
-
loading: true,
|
|
20
|
-
color: '#000000',
|
|
21
|
-
size: 15,
|
|
22
|
-
margin: '2px',
|
|
23
|
-
sizeUnit: 'px',
|
|
24
|
-
className: null
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
var Loader = function Loader(_ref) {
|
|
28
|
-
var loading = _ref.loading,
|
|
29
|
-
color = _ref.color,
|
|
30
|
-
size = _ref.size,
|
|
31
|
-
sizeUnit = _ref.sizeUnit,
|
|
32
|
-
margin = _ref.margin,
|
|
33
|
-
className = _ref.className;
|
|
34
|
-
var dotStyle = {
|
|
35
|
-
backgroundColor: color,
|
|
36
|
-
width: "".concat(size).concat(sizeUnit),
|
|
37
|
-
height: "".concat(size).concat(sizeUnit),
|
|
38
|
-
margin: margin
|
|
39
|
-
};
|
|
40
|
-
return loading ? React.createElement("div", {
|
|
41
|
-
className: classNames([styles.component, _defineProperty({}, className, className !== null)])
|
|
42
|
-
}, React.createElement("div", {
|
|
43
|
-
className: styles.dot,
|
|
44
|
-
style: dotStyle
|
|
45
|
-
}), React.createElement("div", {
|
|
46
|
-
className: styles.dot,
|
|
47
|
-
style: dotStyle
|
|
48
|
-
}), React.createElement("div", {
|
|
49
|
-
className: styles.dot,
|
|
50
|
-
style: dotStyle
|
|
51
|
-
})) : null;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
Loader.propTypes = propTypes;
|
|
55
|
-
Loader.defaultProps = defaultProps;
|
|
56
|
-
export default Loader;
|
package/es/components/index.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import React, { useContext, useMemo } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import ComponentsCollection from '../lib/ComponentsCollection';
|
|
4
|
-
export var ComponentsContext = React.createContext(new ComponentsCollection());
|
|
5
|
-
export var useComponents = function useComponents() {
|
|
6
|
-
var namespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
7
|
-
var customComponents = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
8
|
-
var contextCollection = useContext(ComponentsContext);
|
|
9
|
-
var collection = useMemo(function () {
|
|
10
|
-
if (customComponents !== null) {
|
|
11
|
-
return ComponentsCollection.make(customComponents);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return namespace !== null ? contextCollection.getCollection(namespace) : contextCollection;
|
|
15
|
-
}, [namespace, customComponents, contextCollection]);
|
|
16
|
-
return collection;
|
|
17
|
-
};
|
|
18
|
-
export var useComponent = function useComponent() {
|
|
19
|
-
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
20
|
-
var namespace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
21
|
-
var customComponents = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
22
|
-
var collection = useComponents(namespace, customComponents);
|
|
23
|
-
var component = useMemo(function () {
|
|
24
|
-
return collection.getComponent(name);
|
|
25
|
-
}, [collection, name]);
|
|
26
|
-
return component;
|
|
27
|
-
};
|
|
28
|
-
var propTypes = {
|
|
29
|
-
children: PropTypes.node.isRequired,
|
|
30
|
-
components: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object])),
|
|
31
|
-
collection: PropTypes.instanceOf(ComponentsCollection)
|
|
32
|
-
};
|
|
33
|
-
var defaultProps = {
|
|
34
|
-
components: null,
|
|
35
|
-
collection: null
|
|
36
|
-
};
|
|
37
|
-
export var ComponentsProvider = function ComponentsProvider(_ref) {
|
|
38
|
-
var children = _ref.children,
|
|
39
|
-
components = _ref.components,
|
|
40
|
-
collection = _ref.collection;
|
|
41
|
-
// const value = useMemo(
|
|
42
|
-
// () => (collection !== null ? collection : new ComponentsCollection(components)),
|
|
43
|
-
// [components, collection],
|
|
44
|
-
// );
|
|
45
|
-
var value = collection !== null ? collection : new ComponentsCollection(components);
|
|
46
|
-
return React.createElement(ComponentsContext.Provider, {
|
|
47
|
-
value: value
|
|
48
|
-
}, children);
|
|
49
|
-
};
|
|
50
|
-
ComponentsProvider.propTypes = propTypes;
|
|
51
|
-
ComponentsProvider.defaultProps = defaultProps;
|
|
52
|
-
export default ComponentsContext;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import * as PanneauPropTypes from '../lib/PropTypes';
|
|
4
|
-
import Definition from '../lib/Definition';
|
|
5
|
-
export var DefinitionContext = React.createContext(new Definition());
|
|
6
|
-
export var useDefinition = function useDefinition() {
|
|
7
|
-
return useContext(DefinitionContext);
|
|
8
|
-
};
|
|
9
|
-
var propTypes = {
|
|
10
|
-
children: PropTypes.node.isRequired,
|
|
11
|
-
definition: PanneauPropTypes.definition.isRequired
|
|
12
|
-
};
|
|
13
|
-
export var DefinitionProvider = function DefinitionProvider(_ref) {
|
|
14
|
-
var children = _ref.children,
|
|
15
|
-
definition = _ref.definition;
|
|
16
|
-
return React.createElement(DefinitionContext.Provider, {
|
|
17
|
-
value: definition
|
|
18
|
-
}, children);
|
|
19
|
-
};
|
|
20
|
-
DefinitionProvider.propTypes = propTypes;
|
|
21
|
-
export default DefinitionContext;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React, { useContext, useMemo } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import UrlGenerator from '../lib/UrlGenerator';
|
|
4
|
-
export var UrlGeneratorContext = React.createContext(null);
|
|
5
|
-
export var useUrlGenerator = function useUrlGenerator() {
|
|
6
|
-
return useContext(UrlGeneratorContext);
|
|
7
|
-
};
|
|
8
|
-
var propTypes = {
|
|
9
|
-
children: PropTypes.node.isRequired,
|
|
10
|
-
routes: PropTypes.objectOf(PropTypes.string),
|
|
11
|
-
urlGenerator: PropTypes.instanceOf(UrlGenerator)
|
|
12
|
-
};
|
|
13
|
-
var defaultProps = {
|
|
14
|
-
routes: null,
|
|
15
|
-
urlGenerator: null
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
var UrlGeneratorProvider = function UrlGeneratorProvider(_ref) {
|
|
19
|
-
var children = _ref.children,
|
|
20
|
-
routes = _ref.routes,
|
|
21
|
-
urlGenerator = _ref.urlGenerator;
|
|
22
|
-
var value = useMemo(function () {
|
|
23
|
-
return urlGenerator !== null ? urlGenerator : new UrlGenerator(routes);
|
|
24
|
-
}, [routes, urlGenerator]);
|
|
25
|
-
return React.createElement(UrlGeneratorContext.Provider, {
|
|
26
|
-
value: value
|
|
27
|
-
}, children);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
UrlGeneratorProvider.propTypes = propTypes;
|
|
31
|
-
UrlGeneratorProvider.defaultProps = defaultProps;
|
|
32
|
-
export { UrlGeneratorProvider };
|
|
33
|
-
export default UrlGeneratorContext;
|
package/es/contexts/index.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { default as ComponentsContext, useComponents, useComponent, ComponentsProvider } from './Components';
|
|
2
|
-
export { default as DefinitionContext, useDefinition, DefinitionProvider } from './Definition';
|
|
3
|
-
export { default as UrlGeneratorContext, useUrlGenerator, UrlGeneratorProvider } from './UrlGenerator';
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
-
|
|
7
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
8
|
-
|
|
9
|
-
var ComponentsCollection =
|
|
10
|
-
/*#__PURE__*/
|
|
11
|
-
function () {
|
|
12
|
-
_createClass(ComponentsCollection, null, [{
|
|
13
|
-
key: "make",
|
|
14
|
-
value: function make(components) {
|
|
15
|
-
return components instanceof ComponentsCollection ? components : new ComponentsCollection(components);
|
|
16
|
-
}
|
|
17
|
-
}, {
|
|
18
|
-
key: "normalizeKey",
|
|
19
|
-
value: function normalizeKey(key) {
|
|
20
|
-
return key.replace(/[^A-Za-z0-9.]/gi, '').toLowerCase();
|
|
21
|
-
}
|
|
22
|
-
}]);
|
|
23
|
-
|
|
24
|
-
function ComponentsCollection(components) {
|
|
25
|
-
_classCallCheck(this, ComponentsCollection);
|
|
26
|
-
|
|
27
|
-
this.components = {};
|
|
28
|
-
this.addComponents(components || {});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
_createClass(ComponentsCollection, [{
|
|
32
|
-
key: "addComponent",
|
|
33
|
-
value: function addComponent(key, Component, namespace) {
|
|
34
|
-
var componentKey = ComponentsCollection.normalizeKey("".concat(typeof namespace !== 'undefined' ? "".concat(namespace, ".") : '').concat(key));
|
|
35
|
-
this.components[componentKey] = Component;
|
|
36
|
-
}
|
|
37
|
-
}, {
|
|
38
|
-
key: "addComponents",
|
|
39
|
-
value: function addComponents(components, namespace) {
|
|
40
|
-
var _this = this;
|
|
41
|
-
|
|
42
|
-
var items = components instanceof ComponentsCollection ? components.getComponents() : components;
|
|
43
|
-
Object.keys(items).forEach(function (key) {
|
|
44
|
-
_this.addComponent(key, items[key], namespace);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}, {
|
|
48
|
-
key: "getCollection",
|
|
49
|
-
value: function getCollection(namespace) {
|
|
50
|
-
var components = this.getComponents(namespace);
|
|
51
|
-
var collection = new ComponentsCollection(components);
|
|
52
|
-
return collection;
|
|
53
|
-
}
|
|
54
|
-
}, {
|
|
55
|
-
key: "getComponents",
|
|
56
|
-
value: function getComponents(namespace) {
|
|
57
|
-
var _this2 = this;
|
|
58
|
-
|
|
59
|
-
return Object.keys(this.components).reduce(function (components, key) {
|
|
60
|
-
if (typeof namespace !== 'undefined') {
|
|
61
|
-
var namespaceKey = ComponentsCollection.normalizeKey(namespace); // eslint-disable-next-line no-useless-escape
|
|
62
|
-
|
|
63
|
-
var matches = key.match(new RegExp("^".concat(namespaceKey, ".(.*)$"), 'i'));
|
|
64
|
-
return matches ? _objectSpread({}, components, _defineProperty({}, matches[1], _this2.components[key])) : components;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return _objectSpread({}, components, _defineProperty({}, key, _this2.components[key]));
|
|
68
|
-
}, {});
|
|
69
|
-
}
|
|
70
|
-
}, {
|
|
71
|
-
key: "setComponents",
|
|
72
|
-
value: function setComponents(components, namespace) {
|
|
73
|
-
var _this3 = this;
|
|
74
|
-
|
|
75
|
-
var items = components instanceof ComponentsCollection ? components.getComponents() : components;
|
|
76
|
-
|
|
77
|
-
if (typeof namespace !== 'undefined') {
|
|
78
|
-
Object.keys(items).forEach(function (key) {
|
|
79
|
-
_this3.components["".concat(namespace, ".").concat(key)] = items[key];
|
|
80
|
-
});
|
|
81
|
-
} else {
|
|
82
|
-
this.components = items;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return this;
|
|
86
|
-
}
|
|
87
|
-
}, {
|
|
88
|
-
key: "getComponent",
|
|
89
|
-
value: function getComponent() {
|
|
90
|
-
var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
91
|
-
|
|
92
|
-
if (key === null) {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
var normalizedKey = ComponentsCollection.normalizeKey(key);
|
|
97
|
-
var foundKey = Object.keys(this.components).find(function (fieldKey) {
|
|
98
|
-
return fieldKey === normalizedKey;
|
|
99
|
-
});
|
|
100
|
-
return typeof foundKey !== 'undefined' && foundKey !== null ? this.components[foundKey] : null;
|
|
101
|
-
}
|
|
102
|
-
}]);
|
|
103
|
-
|
|
104
|
-
return ComponentsCollection;
|
|
105
|
-
}();
|
|
106
|
-
|
|
107
|
-
export default ComponentsCollection;
|