@stokr/components-library 2.0.1 → 2.0.2
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/dist/components/Card/Card.styles.js +69 -0
- package/dist/components/ComponentWrapper/ComponentWrapper.styles.js +3 -1
- package/dist/components/Input/InputWithButton.js +64 -0
- package/dist/components/Input/InputWithButton.stories.js +79 -0
- package/dist/components/Input/InputWithButton.styles.js +37 -0
- package/dist/components/Pagination/Pagination.js +85 -0
- package/dist/components/Pagination/Pagination.stories.js +90 -0
- package/dist/components/Pagination/Pagination.styles.js +27 -0
- package/dist/components/Pagination/usePagination.js +92 -0
- package/dist/index.js +11 -0
- package/package.json +1 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.CardTitleContainer = exports.CardTitle = exports.CardRightText = exports.CardLeftText = exports.CardHeaderRegular = exports.CardHeader = exports.Card = void 0;
|
|
8
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
|
+
var _rwd = _interopRequireDefault(require("../../styles/rwd"));
|
|
10
|
+
var _Select = require("../Input/Select.styles");
|
|
11
|
+
var _theme = _interopRequireDefault(require("../../styles/theme"));
|
|
12
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
17
|
+
var Card = _styledComponents.default.div.withConfig({
|
|
18
|
+
displayName: "Cardstyles__Card",
|
|
19
|
+
componentId: "sc-16hwkn5-0"
|
|
20
|
+
})(["padding:28px 22px;background:", ";", " ", " ", " ", ""], _theme.default.cWhite, _rwd.default.Medium(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 40px 50px;\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n "])), function (props) {
|
|
21
|
+
return props.lessPadding && (0, _styledComponents.css)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding: 28px 22px;\n "])));
|
|
22
|
+
}, function (props) {
|
|
23
|
+
return props.lessPaddingHorizontal && (0, _styledComponents.css)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n padding: 40px 22px;\n "])));
|
|
24
|
+
}, function (props) {
|
|
25
|
+
return props.lessPaddingVertical && (0, _styledComponents.css)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n padding: 28px 50px;\n "])));
|
|
26
|
+
}, function (props) {
|
|
27
|
+
return props.chartPadding && (0, _styledComponents.css)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n padding: 20px;\n "])));
|
|
28
|
+
}, function (props) {
|
|
29
|
+
return props.noPadding && (0, _styledComponents.css)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n padding: 0;\n "])));
|
|
30
|
+
}), function (props) {
|
|
31
|
+
return props.chartPadding && (0, _styledComponents.css)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n padding: 10px;\n "])));
|
|
32
|
+
}, function (props) {
|
|
33
|
+
return props.noPadding && (0, _styledComponents.css)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n padding: 0;\n "])));
|
|
34
|
+
}, function (props) {
|
|
35
|
+
return props.grow && "\n flex-grow: ".concat(props.grow, ";\n ");
|
|
36
|
+
});
|
|
37
|
+
exports.Card = Card;
|
|
38
|
+
var CardTitle = _styledComponents.default.div.withConfig({
|
|
39
|
+
displayName: "Cardstyles__CardTitle",
|
|
40
|
+
componentId: "sc-16hwkn5-1"
|
|
41
|
+
})(["font-size:16px;line-height:22px;font-weight:600;"]);
|
|
42
|
+
exports.CardTitle = CardTitle;
|
|
43
|
+
var CardTitleContainer = _styledComponents.default.div.withConfig({
|
|
44
|
+
displayName: "Cardstyles__CardTitleContainer",
|
|
45
|
+
componentId: "sc-16hwkn5-2"
|
|
46
|
+
})(["display:flex;flex-direction:row;align-items:center;"]);
|
|
47
|
+
exports.CardTitleContainer = CardTitleContainer;
|
|
48
|
+
var CardRightText = _styledComponents.default.div.withConfig({
|
|
49
|
+
displayName: "Cardstyles__CardRightText",
|
|
50
|
+
componentId: "sc-16hwkn5-3"
|
|
51
|
+
})(["margin-left:auto;font-size:16px;"]);
|
|
52
|
+
exports.CardRightText = CardRightText;
|
|
53
|
+
var CardLeftText = _styledComponents.default.div.withConfig({
|
|
54
|
+
displayName: "Cardstyles__CardLeftText",
|
|
55
|
+
componentId: "sc-16hwkn5-4"
|
|
56
|
+
})(["margin-left:18px;font-size:16px;"]);
|
|
57
|
+
exports.CardLeftText = CardLeftText;
|
|
58
|
+
var CardHeader = _styledComponents.default.div.withConfig({
|
|
59
|
+
displayName: "Cardstyles__CardHeader",
|
|
60
|
+
componentId: "sc-16hwkn5-5"
|
|
61
|
+
})(["display:flex;flex-direction:row;justify-content:space-between;align-items:center;flex-wrap:wrap;", " ", "{height:22px;margin-top:-8px;}"], function (props) {
|
|
62
|
+
return props.paddingRight && (0, _styledComponents.css)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n padding-right: ", ";\n "])), props.paddingRight);
|
|
63
|
+
}, _Select.SelectWrapper);
|
|
64
|
+
exports.CardHeader = CardHeader;
|
|
65
|
+
var CardHeaderRegular = _styledComponents.default.div.withConfig({
|
|
66
|
+
displayName: "Cardstyles__CardHeaderRegular",
|
|
67
|
+
componentId: "sc-16hwkn5-6"
|
|
68
|
+
})(["font-weight:400;display:inline-block;"]);
|
|
69
|
+
exports.CardHeaderRegular = CardHeaderRegular;
|
|
@@ -16,7 +16,7 @@ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(
|
|
|
16
16
|
var ComponentWrapper = _styledComponents.default.div.withConfig({
|
|
17
17
|
displayName: "ComponentWrapperstyles__ComponentWrapper",
|
|
18
18
|
componentId: "sc-1w1v084-0"
|
|
19
|
-
})(["position:relative;padding:32px;text-align:left !important;", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " @media screen and (max-width:767px){padding:32px;", "}", " ", " ", ""], _rwd.default.Large(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 32px 64px;\n "]))), function (props) {
|
|
19
|
+
})(["position:relative;padding:32px;text-align:left !important;", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " @media screen and (max-width:767px){padding:32px;", "}", " ", " ", " ", ""], _rwd.default.Large(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 32px 64px;\n "]))), function (props) {
|
|
20
20
|
return props.borderLeft && (0, _styledComponents.css)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n border-left: 1px solid ", ";\n "])), _theme.default.cLightGrey);
|
|
21
21
|
}, function (props) {
|
|
22
22
|
return props.borderRight && (0, _styledComponents.css)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n border-right: 1px solid ", ";\n "])), _theme.default.cLightGrey);
|
|
@@ -64,6 +64,8 @@ var ComponentWrapper = _styledComponents.default.div.withConfig({
|
|
|
64
64
|
return props.marginTop && (0, _styledComponents.css)(_templateObject24 || (_templateObject24 = _taggedTemplateLiteral(["\n margin-top: ", ";\n "])), props.marginTop);
|
|
65
65
|
}, function (props) {
|
|
66
66
|
return props.isAddMember && (0, _styledComponents.css)(_templateObject25 || (_templateObject25 = _taggedTemplateLiteral(["\n @media screen and (min-width: 768px) {\n padding-left: 10px !important;\n padding-right: 10px !important;\n }\n "])));
|
|
67
|
+
}, function (props) {
|
|
68
|
+
return props.flex && "\n display:flex;\n align-items: center;\n ";
|
|
67
69
|
});
|
|
68
70
|
exports.ComponentWrapper = ComponentWrapper;
|
|
69
71
|
var _default = ComponentWrapper;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.InputWithButton = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _InputWithButton = require("./InputWithButton.styles");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
var InputWithButton = function InputWithButton(_ref) {
|
|
12
|
+
var children = _ref.children,
|
|
13
|
+
type = _ref.type,
|
|
14
|
+
id = _ref.id,
|
|
15
|
+
name = _ref.name,
|
|
16
|
+
placeholder = _ref.placeholder,
|
|
17
|
+
value = _ref.value,
|
|
18
|
+
error = _ref.error,
|
|
19
|
+
touched = _ref.touched,
|
|
20
|
+
onChange = _ref.onChange,
|
|
21
|
+
onBlur = _ref.onBlur,
|
|
22
|
+
onFocus = _ref.onFocus,
|
|
23
|
+
separatorTop = _ref.separatorTop;
|
|
24
|
+
return /*#__PURE__*/_react.default.createElement(_InputWithButton.Container, {
|
|
25
|
+
separatorTop: separatorTop
|
|
26
|
+
}, /*#__PURE__*/_react.default.createElement(_InputWithButton.InputWrap, null, /*#__PURE__*/_react.default.createElement(_InputWithButton.Input, {
|
|
27
|
+
type: type,
|
|
28
|
+
id: id,
|
|
29
|
+
name: name,
|
|
30
|
+
value: value,
|
|
31
|
+
onChange: onChange,
|
|
32
|
+
onBlur: onBlur,
|
|
33
|
+
onFocus: onFocus,
|
|
34
|
+
placeholder: placeholder
|
|
35
|
+
})), /*#__PURE__*/_react.default.createElement(_InputWithButton.ButtonWrap, null, children));
|
|
36
|
+
};
|
|
37
|
+
exports.InputWithButton = InputWithButton;
|
|
38
|
+
InputWithButton.propTypes = {
|
|
39
|
+
children: _propTypes.default.node.isRequired,
|
|
40
|
+
type: _propTypes.default.string,
|
|
41
|
+
id: _propTypes.default.string.isRequired,
|
|
42
|
+
name: _propTypes.default.string.isRequired,
|
|
43
|
+
placeholder: _propTypes.default.string,
|
|
44
|
+
value: _propTypes.default.string,
|
|
45
|
+
error: _propTypes.default.bool,
|
|
46
|
+
touched: _propTypes.default.bool,
|
|
47
|
+
onChange: _propTypes.default.func,
|
|
48
|
+
onBlur: _propTypes.default.func,
|
|
49
|
+
onFocus: _propTypes.default.func,
|
|
50
|
+
separatorTop: _propTypes.default.bool
|
|
51
|
+
};
|
|
52
|
+
InputWithButton.defaultProps = {
|
|
53
|
+
type: 'search',
|
|
54
|
+
placeholder: '',
|
|
55
|
+
value: '',
|
|
56
|
+
error: false,
|
|
57
|
+
touched: false,
|
|
58
|
+
onChange: function onChange() {},
|
|
59
|
+
onBlur: function onBlur() {},
|
|
60
|
+
onFocus: function onFocus() {},
|
|
61
|
+
separatorTop: false
|
|
62
|
+
};
|
|
63
|
+
var _default = InputWithButton;
|
|
64
|
+
exports.default = _default;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.InputButton = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _InputWithButton = require("./InputWithButton");
|
|
9
|
+
var _ComponentWrapper = require("../ComponentWrapper/ComponentWrapper.styles");
|
|
10
|
+
var _global = _interopRequireDefault(require("../../styles/global"));
|
|
11
|
+
var _Button = require("../Button/Button.styles");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
var _default = {
|
|
14
|
+
title: 'Components Library/Inputs/Input With Button',
|
|
15
|
+
component: _InputWithButton.InputWithButton,
|
|
16
|
+
argTypes: {
|
|
17
|
+
type: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
defaultValue: 'number'
|
|
20
|
+
},
|
|
21
|
+
id: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
required: true
|
|
24
|
+
},
|
|
25
|
+
name: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
required: true
|
|
28
|
+
},
|
|
29
|
+
label: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
defaultValue: ''
|
|
32
|
+
},
|
|
33
|
+
value: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
defaultValue: ''
|
|
36
|
+
},
|
|
37
|
+
error: {
|
|
38
|
+
type: 'boolean',
|
|
39
|
+
defaultValue: false
|
|
40
|
+
},
|
|
41
|
+
touched: {
|
|
42
|
+
type: 'boolean',
|
|
43
|
+
defaultValue: false
|
|
44
|
+
},
|
|
45
|
+
onChange: {
|
|
46
|
+
action: 'change',
|
|
47
|
+
type: 'function'
|
|
48
|
+
},
|
|
49
|
+
onBlur: {
|
|
50
|
+
action: 'blur',
|
|
51
|
+
type: 'function'
|
|
52
|
+
},
|
|
53
|
+
onFocus: {
|
|
54
|
+
action: 'hasFocus',
|
|
55
|
+
type: 'function'
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
exports.default = _default;
|
|
60
|
+
var Template = function Template(args) {
|
|
61
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_global.default, null), /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement(_InputWithButton.InputWithButton, null, /*#__PURE__*/_react.default.createElement(_Button.Button, null, "apply")), /*#__PURE__*/_react.default.createElement(_InputWithButton.InputWithButton, args)));
|
|
62
|
+
};
|
|
63
|
+
var InputButton = Template.bind({});
|
|
64
|
+
exports.InputButton = InputButton;
|
|
65
|
+
InputButton.args = {
|
|
66
|
+
placeholder: 'Page size',
|
|
67
|
+
onChange: function onChange() {
|
|
68
|
+
console.log('changed');
|
|
69
|
+
}
|
|
70
|
+
//label: 'test',
|
|
71
|
+
//value: 'test',
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// export const PasswordStrength = Template.bind({})
|
|
75
|
+
// PasswordStrength.args = {
|
|
76
|
+
// label: 'input description (label) - PASSWORD',
|
|
77
|
+
// value: 'your password (value)',
|
|
78
|
+
// showStrength: true,
|
|
79
|
+
// }
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.InputWrap = exports.Input = exports.Container = exports.ButtonWrap = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
+
var _theme = _interopRequireDefault(require("../../styles/theme"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
var Container = _styledComponents.default.div.withConfig({
|
|
11
|
+
displayName: "InputWithButtonstyles__Container",
|
|
12
|
+
componentId: "sc-ulpczh-0"
|
|
13
|
+
})(["position:relative;display:flex;flex-direction:row;align-items:center;", ""], function (props) {
|
|
14
|
+
return props.separatorTop && "\n padding-top: 20px;\n margin-top: 20px;\n border-top: 1px solid ".concat(_theme.default.cLightGrey, ";\n ");
|
|
15
|
+
});
|
|
16
|
+
exports.Container = Container;
|
|
17
|
+
var InputWrap = _styledComponents.default.div.withConfig({
|
|
18
|
+
displayName: "InputWithButtonstyles__InputWrap",
|
|
19
|
+
componentId: "sc-ulpczh-1"
|
|
20
|
+
})(["flex-grow:1;z-index:0;position:relative;margin-right:-40px;"]);
|
|
21
|
+
exports.InputWrap = InputWrap;
|
|
22
|
+
var ButtonWrap = _styledComponents.default.div.withConfig({
|
|
23
|
+
displayName: "InputWithButtonstyles__ButtonWrap",
|
|
24
|
+
componentId: "sc-ulpczh-2"
|
|
25
|
+
})(["z-index:1;position:relative;"]);
|
|
26
|
+
exports.ButtonWrap = ButtonWrap;
|
|
27
|
+
var Input = _styledComponents.default.input.withConfig({
|
|
28
|
+
displayName: "InputWithButtonstyles__Input",
|
|
29
|
+
componentId: "sc-ulpczh-3"
|
|
30
|
+
})(["display:block;border:0;height:40px;width:100%;padding:9px 23px;padding-right:63px;font-family:'Open Sans';font-size:14px;line-height:20px;border:1px solid ", ";border-radius:20px;outline:0;transition:border-color 0.2s;&:focus,&:hover{border:1px solid ", ";}&::placeholder{color:", ";opacity:1;}"], function (props) {
|
|
31
|
+
return _theme.default.cLightGrey;
|
|
32
|
+
}, function (props) {
|
|
33
|
+
return _theme.default.cPrimary;
|
|
34
|
+
}, function (props) {
|
|
35
|
+
return _theme.default.cGrey2;
|
|
36
|
+
});
|
|
37
|
+
exports.Input = Input;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.Pagination = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _usePagination = require("./usePagination");
|
|
10
|
+
var _Pagination = require("./Pagination.styles");
|
|
11
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
+
var _Icon = _interopRequireWildcard(require("../Icon/Icon.style"));
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
var Pagination = function Pagination(props) {
|
|
17
|
+
var onPageChange = props.onPageChange,
|
|
18
|
+
totalCount = props.totalCount,
|
|
19
|
+
siblingCount = props.siblingCount,
|
|
20
|
+
currentPage = props.currentPage,
|
|
21
|
+
pageSize = props.pageSize;
|
|
22
|
+
var paginationRange = (0, _usePagination.usePagination)({
|
|
23
|
+
currentPage: currentPage,
|
|
24
|
+
totalCount: totalCount,
|
|
25
|
+
siblingCount: siblingCount,
|
|
26
|
+
pageSize: pageSize
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// If there are less than 2 times in pagination range we shall not render the component
|
|
30
|
+
if (currentPage === 0 || paginationRange.length < 2) {
|
|
31
|
+
onPageChange(1);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
var onNext = function onNext() {
|
|
35
|
+
onPageChange(currentPage + 1);
|
|
36
|
+
};
|
|
37
|
+
var onPrevious = function onPrevious() {
|
|
38
|
+
onPageChange(currentPage - 1);
|
|
39
|
+
};
|
|
40
|
+
var lastPage = paginationRange[paginationRange.length - 1];
|
|
41
|
+
return /*#__PURE__*/_react.default.createElement(_Pagination.StyledList, null, /*#__PURE__*/_react.default.createElement(_Pagination.StyledList.Item, {
|
|
42
|
+
disabled: currentPage === 1,
|
|
43
|
+
onClick: onPrevious,
|
|
44
|
+
arrow: true
|
|
45
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
46
|
+
icon: _Icon.iconsMap.arrowLeft
|
|
47
|
+
})), paginationRange.map(function (pageNumber) {
|
|
48
|
+
// If the pageItem is a DOT, render the DOTS unicode character
|
|
49
|
+
if (pageNumber === _usePagination.DOTS) {
|
|
50
|
+
return /*#__PURE__*/_react.default.createElement(_Pagination.StyledList.Item, {
|
|
51
|
+
dots: true,
|
|
52
|
+
key: pageNumber
|
|
53
|
+
}, "\u2026");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Render our Page Pills
|
|
57
|
+
return /*#__PURE__*/_react.default.createElement(_Pagination.StyledList.Item, {
|
|
58
|
+
key: pageNumber,
|
|
59
|
+
selected: pageNumber === currentPage,
|
|
60
|
+
onClick: function onClick() {
|
|
61
|
+
return onPageChange(pageNumber);
|
|
62
|
+
}
|
|
63
|
+
}, pageNumber);
|
|
64
|
+
}), /*#__PURE__*/_react.default.createElement(_Pagination.StyledList.Item, {
|
|
65
|
+
disabled: currentPage === lastPage,
|
|
66
|
+
onClick: onNext,
|
|
67
|
+
arrow: true
|
|
68
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
69
|
+
icon: _Icon.iconsMap.arrowRight
|
|
70
|
+
})));
|
|
71
|
+
};
|
|
72
|
+
exports.Pagination = Pagination;
|
|
73
|
+
Pagination.propTypes = {
|
|
74
|
+
onPageChange: _propTypes.default.func.isRequired,
|
|
75
|
+
totalCount: _propTypes.default.number.isRequired,
|
|
76
|
+
currentPage: _propTypes.default.number.isRequired,
|
|
77
|
+
siblingCount: _propTypes.default.number,
|
|
78
|
+
pageSize: _propTypes.default.number
|
|
79
|
+
};
|
|
80
|
+
Pagination.defaultProps = {
|
|
81
|
+
siblingCount: 1,
|
|
82
|
+
pageSize: 10
|
|
83
|
+
};
|
|
84
|
+
var _default = Pagination;
|
|
85
|
+
exports.default = _default;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.PaginationWithInput = exports.PaginationExample = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _Pagination = require("./Pagination");
|
|
9
|
+
var _ComponentWrapper = require("../ComponentWrapper/ComponentWrapper.styles");
|
|
10
|
+
var _global = _interopRequireDefault(require("../../styles/global"));
|
|
11
|
+
var _InputWithButton = require("../Input/InputWithButton");
|
|
12
|
+
var _Button = require("../Button/Button.styles");
|
|
13
|
+
var _Card = require("../Card/Card.styles");
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
var _default = {
|
|
16
|
+
title: 'Components Library/Pagination',
|
|
17
|
+
component: _Pagination.Pagination,
|
|
18
|
+
argTypes: {
|
|
19
|
+
currentPage: {
|
|
20
|
+
type: 'number',
|
|
21
|
+
defaultValue: 0
|
|
22
|
+
},
|
|
23
|
+
totalCount: {
|
|
24
|
+
type: 'number',
|
|
25
|
+
defaultValue: 0
|
|
26
|
+
},
|
|
27
|
+
pageSize: {
|
|
28
|
+
type: 'number',
|
|
29
|
+
defaultValue: 10
|
|
30
|
+
},
|
|
31
|
+
siblingCount: {
|
|
32
|
+
type: 'number',
|
|
33
|
+
defaultValue: 0
|
|
34
|
+
},
|
|
35
|
+
onPageChange: {
|
|
36
|
+
type: 'function',
|
|
37
|
+
required: true
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.default = _default;
|
|
42
|
+
var Template = function Template(args) {
|
|
43
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_global.default, null), /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement(_Pagination.Pagination, args)));
|
|
44
|
+
};
|
|
45
|
+
var TemplateWithInput = function TemplateWithInput(args) {
|
|
46
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_global.default, null), /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, {
|
|
47
|
+
noPaddingHorizontal: true,
|
|
48
|
+
flex: true,
|
|
49
|
+
style: {
|
|
50
|
+
justifyContent: 'space-between',
|
|
51
|
+
flexWrap: 'wrap'
|
|
52
|
+
}
|
|
53
|
+
}, /*#__PURE__*/_react.default.createElement(_Pagination.Pagination, args), /*#__PURE__*/_react.default.createElement(_Card.Card, {
|
|
54
|
+
noPadding: true
|
|
55
|
+
}, /*#__PURE__*/_react.default.createElement(_Card.CardTitle, {
|
|
56
|
+
style: {
|
|
57
|
+
padding: '2px 20px'
|
|
58
|
+
}
|
|
59
|
+
}, "Page Size:"), /*#__PURE__*/_react.default.createElement(_InputWithButton.InputWithButton, {
|
|
60
|
+
id: "pageSize",
|
|
61
|
+
name: "pageSize",
|
|
62
|
+
type: "number",
|
|
63
|
+
placeholder: 'Page size'
|
|
64
|
+
// onChange={(e) => setinputPageSize(e.target.value)}
|
|
65
|
+
}, /*#__PURE__*/_react.default.createElement(_Button.Button
|
|
66
|
+
// onClick={() => setpageSize(Number(inputPageSize))}
|
|
67
|
+
, null, "apply")))));
|
|
68
|
+
};
|
|
69
|
+
var PaginationExample = Template.bind({});
|
|
70
|
+
exports.PaginationExample = PaginationExample;
|
|
71
|
+
PaginationExample.args = {
|
|
72
|
+
currentPage: 1,
|
|
73
|
+
totalCount: 100,
|
|
74
|
+
pageSize: 10,
|
|
75
|
+
siblingCount: 1,
|
|
76
|
+
onPageChange: function onPageChange(page) {
|
|
77
|
+
console.log('page changed to', page);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
var PaginationWithInput = TemplateWithInput.bind({});
|
|
81
|
+
exports.PaginationWithInput = PaginationWithInput;
|
|
82
|
+
PaginationWithInput.args = {
|
|
83
|
+
currentPage: 1,
|
|
84
|
+
totalCount: 100,
|
|
85
|
+
pageSize: 10,
|
|
86
|
+
siblingCount: 1,
|
|
87
|
+
onPageChange: function onPageChange(page) {
|
|
88
|
+
console.log('page changed to', page);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StyledList = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
+
var _theme = _interopRequireDefault(require("../../styles/theme"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
var StyledList = _styledComponents.default.ul.withConfig({
|
|
11
|
+
displayName: "Paginationstyles__StyledList",
|
|
12
|
+
componentId: "sc-7ltpvr-0"
|
|
13
|
+
})(["display:flex;list-style-type:none;"]);
|
|
14
|
+
exports.StyledList = StyledList;
|
|
15
|
+
var ListItem = _styledComponents.default.li.withConfig({
|
|
16
|
+
displayName: "Paginationstyles__ListItem",
|
|
17
|
+
componentId: "sc-7ltpvr-1"
|
|
18
|
+
})(["padding:0 12px;height:32px;text-align:center;margin:auto 4px;color:", ";display:flex;align-items:center;letter-spacing:0.01071em;border-radius:16px;line-height:1.43;font-size:15px;font-weight:500;min-width:32px;", " &:hover{background-color:", ";color:", ";cursor:pointer;}", " ", " ", ""], _theme.default.cBlack, function (props) {
|
|
19
|
+
return props.arrow && "\n padding:0 9px;\n ";
|
|
20
|
+
}, _theme.default.cPrimary, _theme.default.cWhite, function (props) {
|
|
21
|
+
return props.selected && "\n color: ".concat(_theme.default.cWhite, ";\n background-color: ").concat(_theme.default.cPrimary, ";\n ");
|
|
22
|
+
}, function (props) {
|
|
23
|
+
return props.disabled && "\n pointer-events:none;\n opacity: 0.6;\n ";
|
|
24
|
+
}, function (props) {
|
|
25
|
+
return props.dots && "\n &:hover{\n background-color: transparent;\n cursor: default;\n color:".concat(_theme.default.cBlack, "\n }\n ");
|
|
26
|
+
});
|
|
27
|
+
StyledList.Item = ListItem;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.usePagination = exports.DOTS = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
9
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
12
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
13
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
14
|
+
var DOTS = '...';
|
|
15
|
+
exports.DOTS = DOTS;
|
|
16
|
+
var range = function range(start, end) {
|
|
17
|
+
var length = end - start + 1;
|
|
18
|
+
/*
|
|
19
|
+
Create an array of certain length and set the elements within it from
|
|
20
|
+
start value to end value.
|
|
21
|
+
*/
|
|
22
|
+
return Array.from({
|
|
23
|
+
length: length
|
|
24
|
+
}, function (_, idx) {
|
|
25
|
+
return idx + start;
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
var usePagination = function usePagination(_ref) {
|
|
29
|
+
var totalCount = _ref.totalCount,
|
|
30
|
+
pageSize = _ref.pageSize,
|
|
31
|
+
_ref$siblingCount = _ref.siblingCount,
|
|
32
|
+
siblingCount = _ref$siblingCount === void 0 ? 1 : _ref$siblingCount,
|
|
33
|
+
currentPage = _ref.currentPage;
|
|
34
|
+
var paginationRange = (0, _react.useMemo)(function () {
|
|
35
|
+
//The Math.ceil() function always rounds a number up to the next largest integer.
|
|
36
|
+
var totalPageCount = Math.ceil(totalCount / pageSize);
|
|
37
|
+
|
|
38
|
+
// Pages count is determined as siblingCount + firstPage + lastPage + currentPage + 2*DOTS
|
|
39
|
+
var totalPageNumbers = siblingCount + 5;
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
Case 1:
|
|
43
|
+
If the number of pages is less than the page numbers we want to show in our
|
|
44
|
+
paginationComponent, we return the range [1..totalPageCount]
|
|
45
|
+
*/
|
|
46
|
+
if (totalPageNumbers >= totalPageCount) {
|
|
47
|
+
return range(1, totalPageCount);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/*
|
|
51
|
+
Calculate left and right sibling index and make sure they are within range 1 and totalPageCount
|
|
52
|
+
*/
|
|
53
|
+
var leftSiblingIndex = Math.max(currentPage - siblingCount, 1);
|
|
54
|
+
var rightSiblingIndex = Math.min(currentPage + siblingCount, totalPageCount);
|
|
55
|
+
|
|
56
|
+
/*
|
|
57
|
+
We do not show dots just when there is just one page number to be inserted between the extremes of sibling and the page limits i.e 1 and totalPageCount. Hence we are using leftSiblingIndex > 2 and rightSiblingIndex < totalPageCount - 2
|
|
58
|
+
*/
|
|
59
|
+
var shouldShowLeftDots = leftSiblingIndex > 2;
|
|
60
|
+
var shouldShowRightDots = rightSiblingIndex < totalPageCount - 2;
|
|
61
|
+
var firstPageIndex = 1;
|
|
62
|
+
var lastPageIndex = totalPageCount;
|
|
63
|
+
|
|
64
|
+
/*
|
|
65
|
+
Case 2: No left dots to show, but rights dots to be shown
|
|
66
|
+
*/
|
|
67
|
+
if (!shouldShowLeftDots && shouldShowRightDots) {
|
|
68
|
+
var leftItemCount = 3 + 2 * siblingCount;
|
|
69
|
+
var leftRange = range(1, leftItemCount);
|
|
70
|
+
return [].concat(_toConsumableArray(leftRange), [DOTS, totalPageCount]);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/*
|
|
74
|
+
Case 3: No right dots to show, but left dots to be shown
|
|
75
|
+
*/
|
|
76
|
+
if (shouldShowLeftDots && !shouldShowRightDots) {
|
|
77
|
+
var rightItemCount = 3 + 2 * siblingCount;
|
|
78
|
+
var rightRange = range(totalPageCount - rightItemCount + 1, totalPageCount);
|
|
79
|
+
return [firstPageIndex, DOTS].concat(_toConsumableArray(rightRange));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/*
|
|
83
|
+
Case 4: Both left and right dots to be shown
|
|
84
|
+
*/
|
|
85
|
+
if (shouldShowLeftDots && shouldShowRightDots) {
|
|
86
|
+
var middleRange = range(leftSiblingIndex, rightSiblingIndex);
|
|
87
|
+
return [firstPageIndex, DOTS].concat(_toConsumableArray(middleRange), [DOTS, lastPageIndex]);
|
|
88
|
+
}
|
|
89
|
+
}, [totalCount, pageSize, siblingCount, currentPage]);
|
|
90
|
+
return paginationRange;
|
|
91
|
+
};
|
|
92
|
+
exports.usePagination = usePagination;
|
package/dist/index.js
CHANGED
|
@@ -1114,6 +1114,17 @@ Object.keys(_headerHo).forEach(function (key) {
|
|
|
1114
1114
|
}
|
|
1115
1115
|
});
|
|
1116
1116
|
});
|
|
1117
|
+
var _Pagination = require("./components/Pagination/Pagination");
|
|
1118
|
+
Object.keys(_Pagination).forEach(function (key) {
|
|
1119
|
+
if (key === "default" || key === "__esModule") return;
|
|
1120
|
+
if (key in exports && exports[key] === _Pagination[key]) return;
|
|
1121
|
+
Object.defineProperty(exports, key, {
|
|
1122
|
+
enumerable: true,
|
|
1123
|
+
get: function get() {
|
|
1124
|
+
return _Pagination[key];
|
|
1125
|
+
}
|
|
1126
|
+
});
|
|
1127
|
+
});
|
|
1117
1128
|
var _List = require("./components/landing-page/List");
|
|
1118
1129
|
Object.keys(_List).forEach(function (key) {
|
|
1119
1130
|
if (key === "default" || key === "__esModule") return;
|