@dnanpm/styleguide 1.7.0 → 1.9.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/build/cjs/components/Accordion/Accordion.d.ts +38 -0
- package/build/cjs/components/Accordion/Accordion.js +35 -0
- package/build/cjs/components/Accordion/AccordionItem.d.ts +45 -0
- package/build/cjs/components/Accordion/AccordionItem.js +100 -0
- package/build/cjs/components/Accordion/index.d.ts +2 -0
- package/build/cjs/components/AmountSelector/AmountSelector.d.ts +66 -0
- package/build/cjs/components/AmountSelector/AmountSelector.js +84 -0
- package/build/cjs/components/Card/Card.js +1 -2
- package/build/cjs/components/Card/CardRow.js +0 -1
- package/build/cjs/components/Checkbox/Checkbox.d.ts +1 -0
- package/build/cjs/components/Checkbox/Checkbox.js +7 -2
- package/build/cjs/components/Footer/{index.d.ts → Footer.d.ts} +0 -1
- package/build/cjs/components/Footer/{index.js → Footer.js} +3 -2
- package/build/cjs/components/Footer/context/FooterContext.d.ts +1 -1
- package/build/{es/components/Helper/index.d.ts → cjs/components/Helper/Helper.d.ts} +1 -1
- package/build/cjs/components/Helper/{index.js → Helper.js} +0 -0
- package/build/cjs/components/Icon/Icons.d.ts +1 -0
- package/build/cjs/components/Icon/Icons.js +3 -0
- package/build/cjs/components/Image/{index.d.ts → Image.d.ts} +0 -0
- package/build/cjs/components/Image/{index.js → Image.js} +0 -0
- package/build/cjs/components/Input/Input.js +4 -4
- package/build/cjs/components/LabelText/LabelText.d.ts +2 -2
- package/build/cjs/components/LabelText/LabelText.js +1 -1
- package/build/cjs/components/MainNavigation/ChildComponents/BusinessMenu.js +3 -9
- package/build/cjs/components/MainNavigation/ChildComponents/DesktopMenu.js +9 -9
- package/build/cjs/components/MainNavigation/ChildComponents/LinkModifier.js +2 -2
- package/build/cjs/components/MainNavigation/ChildComponents/MainNavTooltipMenu.js +7 -5
- package/build/cjs/components/MainNavigation/ChildComponents/MinicartTooltip.js +6 -6
- package/build/cjs/components/MainNavigation/{index.d.ts → MainNavigation.d.ts} +0 -1
- package/build/cjs/components/MainNavigation/{index.js → MainNavigation.js} +3 -2
- package/build/cjs/components/Notification/Notification.d.ts +40 -17
- package/build/cjs/components/Notification/Notification.js +28 -48
- package/build/cjs/components/NotificationBadge/{index.d.ts → NotificationBadge.d.ts} +0 -0
- package/build/cjs/components/NotificationBadge/{index.js → NotificationBadge.js} +0 -0
- package/build/cjs/components/PixelLoader/PixelLoader.d.ts +1 -1
- package/build/cjs/components/PixelLoader/PixelLoader.js +1 -1
- package/build/cjs/components/ProgressIndicator/{index.d.ts → ProgressIndicator.d.ts} +2 -2
- package/build/cjs/components/ProgressIndicator/{index.js → ProgressIndicator.js} +1 -1
- package/build/cjs/components/RadioButton/RadioButton.d.ts +1 -1
- package/build/cjs/components/RadioButton/RadioButton.js +1 -1
- package/build/{es/components/ReadMore/index.d.ts → cjs/components/ReadMore/ReadMore.d.ts} +1 -1
- package/build/cjs/components/ReadMore/{index.js → ReadMore.js} +1 -1
- package/build/cjs/components/Ribbon/Ribbon.d.ts +57 -0
- package/build/cjs/components/Ribbon/Ribbon.js +80 -0
- package/build/cjs/components/Search/Search.d.ts +44 -5
- package/build/cjs/components/Search/Search.js +3 -3
- package/build/cjs/components/SecondaryNavigation/{index.d.ts → SecondaryNavigation.d.ts} +1 -0
- package/build/cjs/components/SecondaryNavigation/{index.js → SecondaryNavigation.js} +3 -2
- package/build/cjs/components/Selectbox/Selectbox.d.ts +8 -4
- package/build/cjs/components/Selectbox/Selectbox.js +8 -8
- package/build/cjs/components/Textarea/Textarea.d.ts +25 -0
- package/build/cjs/components/Textarea/Textarea.js +83 -0
- package/build/{es/components/Tooltip/index.d.ts → cjs/components/Tooltip/Tooltip.d.ts} +2 -1
- package/build/cjs/components/Tooltip/{index.js → Tooltip.js} +0 -1
- package/build/cjs/components/index.d.ts +14 -10
- package/build/cjs/hooks/useDebounceFunc.d.ts +1 -0
- package/build/cjs/hooks/useDebounceFunc.js +19 -0
- package/build/cjs/hooks/useDocHeight.d.ts +1 -0
- package/build/cjs/hooks/useDocHeight.js +25 -0
- package/build/cjs/hooks/useElementDimensions.d.ts +5 -0
- package/build/cjs/hooks/useElementDimensions.js +37 -0
- package/build/cjs/index.js +28 -18
- package/build/es/components/Accordion/Accordion.d.ts +38 -0
- package/build/es/components/Accordion/Accordion.js +27 -0
- package/build/es/components/Accordion/AccordionItem.d.ts +45 -0
- package/build/es/components/Accordion/AccordionItem.js +91 -0
- package/build/es/components/Accordion/index.d.ts +2 -0
- package/build/es/components/AmountSelector/AmountSelector.d.ts +66 -0
- package/build/es/components/AmountSelector/AmountSelector.js +76 -0
- package/build/es/components/Card/Card.js +1 -2
- package/build/es/components/Card/CardRow.js +0 -1
- package/build/es/components/Checkbox/Checkbox.d.ts +1 -0
- package/build/es/components/Checkbox/Checkbox.js +7 -2
- package/build/es/components/Footer/{index.d.ts → Footer.d.ts} +0 -1
- package/build/es/components/Footer/{index.js → Footer.js} +3 -2
- package/build/es/components/Footer/context/FooterContext.d.ts +1 -1
- package/build/{cjs/components/Helper/index.d.ts → es/components/Helper/Helper.d.ts} +1 -1
- package/build/es/components/Helper/{index.js → Helper.js} +0 -0
- package/build/es/components/Icon/Icons.d.ts +1 -0
- package/build/es/components/Icon/Icons.js +3 -1
- package/build/es/components/Image/{index.d.ts → Image.d.ts} +0 -0
- package/build/es/components/Image/{index.js → Image.js} +0 -0
- package/build/es/components/Input/Input.js +4 -4
- package/build/es/components/LabelText/LabelText.d.ts +2 -2
- package/build/es/components/LabelText/LabelText.js +1 -1
- package/build/es/components/MainNavigation/ChildComponents/BusinessMenu.js +3 -9
- package/build/es/components/MainNavigation/ChildComponents/DesktopMenu.js +9 -9
- package/build/es/components/MainNavigation/ChildComponents/LinkModifier.js +2 -2
- package/build/es/components/MainNavigation/ChildComponents/MainNavTooltipMenu.js +7 -5
- package/build/es/components/MainNavigation/ChildComponents/MinicartTooltip.js +5 -5
- package/build/es/components/MainNavigation/{index.d.ts → MainNavigation.d.ts} +0 -1
- package/build/es/components/MainNavigation/{index.js → MainNavigation.js} +3 -2
- package/build/es/components/Notification/Notification.d.ts +40 -17
- package/build/es/components/Notification/Notification.js +28 -48
- package/build/es/components/NotificationBadge/{index.d.ts → NotificationBadge.d.ts} +0 -0
- package/build/es/components/NotificationBadge/{index.js → NotificationBadge.js} +0 -0
- package/build/es/components/PixelLoader/PixelLoader.d.ts +1 -1
- package/build/es/components/PixelLoader/PixelLoader.js +1 -1
- package/build/es/components/ProgressIndicator/{index.d.ts → ProgressIndicator.d.ts} +2 -2
- package/build/es/components/ProgressIndicator/{index.js → ProgressIndicator.js} +1 -1
- package/build/es/components/RadioButton/RadioButton.d.ts +1 -1
- package/build/es/components/RadioButton/RadioButton.js +1 -1
- package/build/{cjs/components/ReadMore/index.d.ts → es/components/ReadMore/ReadMore.d.ts} +1 -1
- package/build/es/components/ReadMore/{index.js → ReadMore.js} +1 -1
- package/build/es/components/Ribbon/Ribbon.d.ts +57 -0
- package/build/es/components/Ribbon/Ribbon.js +71 -0
- package/build/es/components/Search/Search.d.ts +44 -5
- package/build/es/components/Search/Search.js +3 -3
- package/build/es/components/SecondaryNavigation/{index.d.ts → SecondaryNavigation.d.ts} +1 -0
- package/build/es/components/SecondaryNavigation/{index.js → SecondaryNavigation.js} +3 -2
- package/build/es/components/Selectbox/Selectbox.d.ts +8 -4
- package/build/es/components/Selectbox/Selectbox.js +8 -8
- package/build/es/components/Textarea/Textarea.d.ts +25 -0
- package/build/es/components/Textarea/Textarea.js +75 -0
- package/build/{cjs/components/Tooltip/index.d.ts → es/components/Tooltip/Tooltip.d.ts} +2 -1
- package/build/es/components/Tooltip/{index.js → Tooltip.js} +0 -1
- package/build/es/components/index.d.ts +14 -10
- package/build/es/hooks/useDebounceFunc.d.ts +1 -0
- package/build/es/hooks/useDebounceFunc.js +15 -0
- package/build/es/hooks/useDocHeight.d.ts +1 -0
- package/build/es/hooks/useDocHeight.js +21 -0
- package/build/es/hooks/useElementDimensions.d.ts +5 -0
- package/build/es/hooks/useElementDimensions.js +33 -0
- package/build/es/index.js +14 -9
- package/package.json +1 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface AccordionProps {
|
|
3
|
+
/**
|
|
4
|
+
* Allows to pass a custom className
|
|
5
|
+
*/
|
|
6
|
+
className?: string;
|
|
7
|
+
/**
|
|
8
|
+
* The actual content
|
|
9
|
+
* @type AccordionItem
|
|
10
|
+
*/
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
/** Allow multiple accordion items to be open
|
|
13
|
+
* @default true
|
|
14
|
+
*/
|
|
15
|
+
allowMultiOpen?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Display close button in the item content
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
hasCloseButton?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Title has color when item is open, hovered or focused
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
highlightSelected?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Label to show for the close button in the content
|
|
28
|
+
*/
|
|
29
|
+
openLabel?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Label to show for the close button in the content
|
|
32
|
+
*/
|
|
33
|
+
closeLabel?: string;
|
|
34
|
+
}
|
|
35
|
+
/** @visibleName Accordion */
|
|
36
|
+
declare const Accordion: ({ className, children, allowMultiOpen, highlightSelected, hasCloseButton, openLabel, closeLabel, }: AccordionProps) => JSX.Element;
|
|
37
|
+
/** @component */
|
|
38
|
+
export default Accordion;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var AccordionItem = require('./AccordionItem.js');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
11
|
+
|
|
12
|
+
/** @visibleName Accordion */
|
|
13
|
+
const Accordion = ({ className, children, allowMultiOpen = true, highlightSelected = true, hasCloseButton = false, openLabel, closeLabel, }) => {
|
|
14
|
+
const [activeItem, setActiveItem] = React.useState(null);
|
|
15
|
+
const handleItemOpen = (index) => {
|
|
16
|
+
if (allowMultiOpen) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
setActiveItem(index);
|
|
20
|
+
};
|
|
21
|
+
/** filter out immediate children that are not AccordionItems */
|
|
22
|
+
const accordionItems = React__default['default'].Children.map(children, (child, index) => {
|
|
23
|
+
if (React__default['default'].isValidElement(child) && child.type === AccordionItem['default']) {
|
|
24
|
+
return (React__default['default'].createElement(AccordionItem['default'], Object.assign({ closeFromParent: !allowMultiOpen && activeItem !== index, key: index + child.props.title, hasCloseButton: hasCloseButton, highlightSelected: highlightSelected, openLabel: openLabel, closeLabel: closeLabel,
|
|
25
|
+
// tslint:disable-next-line: jsx-no-lambda
|
|
26
|
+
onOpen: () => handleItemOpen(index) }, child.props), child.props.children));
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
if (!accordionItems) {
|
|
30
|
+
return React__default['default'].createElement(React__default['default'].Fragment, null);
|
|
31
|
+
}
|
|
32
|
+
return React__default['default'].createElement("div", { className: className }, accordionItems);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.default = Accordion;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface AccordionItemProps {
|
|
3
|
+
/**
|
|
4
|
+
* Allows to pass a custom className
|
|
5
|
+
*/
|
|
6
|
+
className?: string;
|
|
7
|
+
/**
|
|
8
|
+
* The actual content
|
|
9
|
+
*/
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Accordion item title
|
|
13
|
+
*/
|
|
14
|
+
title: string;
|
|
15
|
+
/**
|
|
16
|
+
* Display close button in the item content
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
hasCloseButton?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Title has color when item is open, hovered or focused
|
|
22
|
+
* @default true
|
|
23
|
+
*/
|
|
24
|
+
highlightSelected?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Label to show for the open icon for accessibility
|
|
27
|
+
*/
|
|
28
|
+
openLabel?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Label to show for the close button in the content
|
|
31
|
+
*/
|
|
32
|
+
closeLabel?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Accordion item is closed from a parent accordion
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
closeFromParent?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* callback to parent accordion when item is expanded
|
|
40
|
+
*/
|
|
41
|
+
onOpen?: () => void;
|
|
42
|
+
}
|
|
43
|
+
declare const AccordionItem: ({ title, children, hasCloseButton, highlightSelected, openLabel, closeLabel, closeFromParent, onOpen, ...props }: AccordionItemProps) => JSX.Element;
|
|
44
|
+
/** @component */
|
|
45
|
+
export default AccordionItem;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var styled = require('styled-components');
|
|
7
|
+
var useElementDimensions = require('../../hooks/useElementDimensions.js');
|
|
8
|
+
var styledUtils = require('../../utils/styledUtils.js');
|
|
9
|
+
var Icon = require('../Icon/Icon.js');
|
|
10
|
+
|
|
11
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
+
|
|
13
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
14
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
15
|
+
|
|
16
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
17
|
+
const AccordionItemTitle = styled__default['default'].div `
|
|
18
|
+
font-size: ${p => p.theme.fontSize.defaultFontSize};
|
|
19
|
+
font-weight: ${p => p.theme.fontWeight.bold};
|
|
20
|
+
display: flex;
|
|
21
|
+
justify-content: space-between;
|
|
22
|
+
flex-direction: row;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
color: ${p => p.isExpanded && p.highlightSelected ? p.theme.color.hotPink : p.theme.color.text};
|
|
25
|
+
padding: ${p => `${styledUtils.getMultipliedSize(p.theme.base.baseHeight, 1.6)} ${styledUtils.getMultipliedSize(p.theme.base.baseHeight, 2)}`};
|
|
26
|
+
transition: color 0.2s;
|
|
27
|
+
${p => p.highlightSelected &&
|
|
28
|
+
styled.css `
|
|
29
|
+
&:hover,
|
|
30
|
+
&:active,
|
|
31
|
+
&:focus {
|
|
32
|
+
color: ${p.theme.color.hotPink};
|
|
33
|
+
text-decoration: none;
|
|
34
|
+
}
|
|
35
|
+
`}
|
|
36
|
+
`;
|
|
37
|
+
const AccordionItemContainer = styled__default['default'].div `
|
|
38
|
+
margin: ${p => `0 ${styledUtils.getDividedSize(p.theme.base.baseHeight, 2.5)}}`};
|
|
39
|
+
border-bottom: 1px solid
|
|
40
|
+
${p => (p.isExpanded && p.highlightSelected ? p.theme.color.hotPink : p.theme.color.gray15)};
|
|
41
|
+
`;
|
|
42
|
+
const AccordionItemContent = styled__default['default'].div `
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
color: ${p => p.theme.color.slateGray};
|
|
45
|
+
transition: all 0.2s ease;
|
|
46
|
+
height: ${p => (p.isExpanded ? p.maxHeight / 16 + 1.25 : 0)}rem;
|
|
47
|
+
visibility: ${p => (p.isExpanded ? 'visible' : 'hidden')};
|
|
48
|
+
`;
|
|
49
|
+
const AccordionItemContentInner = styled__default['default'].div `
|
|
50
|
+
padding: ${p => `0 ${styledUtils.getMultipliedSize(p.theme.base.baseHeight, 2)} ${styledUtils.getMultipliedSize(p.theme.base.baseHeight, 2)}`};
|
|
51
|
+
`;
|
|
52
|
+
const CloseAccordionItemWrapper = styled__default['default'].div `
|
|
53
|
+
display: flex;
|
|
54
|
+
flex: 1;
|
|
55
|
+
justify-content: flex-end;
|
|
56
|
+
`;
|
|
57
|
+
const CloseAccordionItem = styled__default['default'].div `
|
|
58
|
+
display: flex;
|
|
59
|
+
gap: ${p => styledUtils.getMultipliedSize(p.theme.base.baseHeight, 1)};
|
|
60
|
+
color: ${p => p.theme.color.text};
|
|
61
|
+
cursor: pointer;
|
|
62
|
+
`;
|
|
63
|
+
const AccordionItem = ({ title, children, hasCloseButton = false, highlightSelected = true, openLabel, closeLabel, closeFromParent = false, onOpen, ...props }) => {
|
|
64
|
+
const [isExpanded, setExpanded] = React.useState(false);
|
|
65
|
+
const toggleExpanded = () => {
|
|
66
|
+
setExpanded(!isExpanded);
|
|
67
|
+
};
|
|
68
|
+
// get height when element dimensions change
|
|
69
|
+
const { height: contentHeight, ref: contentRef } = useElementDimensions['default']();
|
|
70
|
+
React.useEffect(() => {
|
|
71
|
+
if (closeFromParent) {
|
|
72
|
+
setExpanded(false);
|
|
73
|
+
}
|
|
74
|
+
}, [closeFromParent]);
|
|
75
|
+
React.useEffect(() => {
|
|
76
|
+
if (isExpanded && onOpen) {
|
|
77
|
+
onOpen();
|
|
78
|
+
}
|
|
79
|
+
}, [isExpanded]);
|
|
80
|
+
const handleKeyDown = (e) => {
|
|
81
|
+
const key = e.key;
|
|
82
|
+
if (key === 'Enter' || key === ' ') {
|
|
83
|
+
e.preventDefault();
|
|
84
|
+
setExpanded(!isExpanded);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
return (React__default['default'].createElement(AccordionItemContainer, { "aria-expanded": isExpanded, className: props.className, isExpanded: isExpanded, highlightSelected: highlightSelected },
|
|
88
|
+
React__default['default'].createElement(AccordionItemTitle, { tabIndex: 0, onKeyDown: handleKeyDown, isExpanded: isExpanded, highlightSelected: highlightSelected, onClick: toggleExpanded, role: "button" },
|
|
89
|
+
React__default['default'].createElement("span", null, title),
|
|
90
|
+
isExpanded ? (React__default['default'].createElement(Icon['default'], { name: "hlChevronUp", size: "1.5rem", right: true, "aria-label": closeLabel })) : (React__default['default'].createElement(Icon['default'], { name: "hlChevronDown", size: "1.5rem", right: true, "aria-label": openLabel }))),
|
|
91
|
+
React__default['default'].createElement(AccordionItemContent, { maxHeight: contentHeight, isExpanded: isExpanded },
|
|
92
|
+
React__default['default'].createElement(AccordionItemContentInner, { ref: contentRef },
|
|
93
|
+
children,
|
|
94
|
+
hasCloseButton && (React__default['default'].createElement(CloseAccordionItemWrapper, null,
|
|
95
|
+
React__default['default'].createElement(CloseAccordionItem, { onClick: toggleExpanded, "aria-label": closeLabel, tabIndex: 0, onKeyDown: handleKeyDown, role: "button" },
|
|
96
|
+
React__default['default'].createElement("span", null, closeLabel),
|
|
97
|
+
React__default['default'].createElement(Icon['default'], { name: "hlX", size: "1.5rem" }))))))));
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
exports.default = AccordionItem;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface Props {
|
|
3
|
+
/**
|
|
4
|
+
* Unique ID for the input element
|
|
5
|
+
*/
|
|
6
|
+
id: string;
|
|
7
|
+
/**
|
|
8
|
+
* On value change callback
|
|
9
|
+
*/
|
|
10
|
+
onChange: (val: number) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Name of the input element
|
|
13
|
+
*/
|
|
14
|
+
name?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Default value of input element
|
|
17
|
+
*
|
|
18
|
+
* @default 1
|
|
19
|
+
*/
|
|
20
|
+
value?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Allows to set step value for increase or decrease
|
|
23
|
+
*
|
|
24
|
+
* @default 1
|
|
25
|
+
*/
|
|
26
|
+
step?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Allows to set minimum value
|
|
29
|
+
*
|
|
30
|
+
* @default 1
|
|
31
|
+
*/
|
|
32
|
+
min?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Allows to set maximum value
|
|
35
|
+
*/
|
|
36
|
+
max?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Allows to disable the component functionality
|
|
39
|
+
*
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Controls if input element's value can be updated directly
|
|
45
|
+
*
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
readonly?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Allows to pass testid string for testing purposes
|
|
51
|
+
*/
|
|
52
|
+
'data-testid'?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Allows to pass a custom className
|
|
55
|
+
*/
|
|
56
|
+
className?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Allows the `onChange` function to be called even after `min` property value is reached.
|
|
59
|
+
* When defined and `min` property value is reached, the `hlMinus` button changes to `hlTrash` button
|
|
60
|
+
*/
|
|
61
|
+
removable?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/** @visibleName Amount Selector */
|
|
64
|
+
declare const AmountSelector: ({ onChange, value, step, min, max, disabled, readonly, "data-testid": dataTestId, ...props }: Props) => JSX.Element;
|
|
65
|
+
/** @component */
|
|
66
|
+
export default AmountSelector;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var styled = require('../../themes/styled.js');
|
|
7
|
+
var theme = require('../../themes/theme.js');
|
|
8
|
+
var styledUtils = require('../../utils/styledUtils.js');
|
|
9
|
+
require('../Buttons/ButtonBasicStyles.js');
|
|
10
|
+
require('../PixelLoader/PixelLoaderStyles.js');
|
|
11
|
+
require('../Buttons/ButtonPrimaryStyles.js');
|
|
12
|
+
var ButtonSecondary = require('../Buttons/ButtonSecondary.js');
|
|
13
|
+
require('../Buttons/ButtonTertiaryStyles.js');
|
|
14
|
+
require('../Buttons/ButtonRoundStyles.js');
|
|
15
|
+
require('../Buttons/CloseButton.js');
|
|
16
|
+
require('../Buttons/ButtonIconStyles.js');
|
|
17
|
+
var Icon = require('../Icon/Icon.js');
|
|
18
|
+
require('../Buttons/ButtonIconPrimaryStyles.js');
|
|
19
|
+
|
|
20
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
|
+
|
|
22
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
23
|
+
|
|
24
|
+
const Container = styled['default'].div `
|
|
25
|
+
display: flex;
|
|
26
|
+
width: ${styledUtils.getMultipliedSize(theme['default'].base.baseWidth, 12)};
|
|
27
|
+
|
|
28
|
+
input {
|
|
29
|
+
width: ${styledUtils.getMultipliedSize(theme['default'].base.baseWidth, 4)};
|
|
30
|
+
border: 0 none;
|
|
31
|
+
text-align: center;
|
|
32
|
+
outline: none;
|
|
33
|
+
-webkit-appearance: none;
|
|
34
|
+
-moz-appearance: textfield;
|
|
35
|
+
&::-webkit-outer-spin-button,
|
|
36
|
+
&::-webkit-inner-spin-button {
|
|
37
|
+
display: none;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
const StyledButtonSecondary = styled['default'](ButtonSecondary['default']) `
|
|
42
|
+
min-width: ${styledUtils.getMultipliedSize(theme['default'].base.baseWidth, 4)};
|
|
43
|
+
`;
|
|
44
|
+
/** @visibleName Amount Selector */
|
|
45
|
+
const AmountSelector = ({ onChange, value = 1, step = 1, min = 1, max, disabled = false, readonly = true, 'data-testid': dataTestId, ...props }) => {
|
|
46
|
+
const isMinReached = (val) => val < min;
|
|
47
|
+
const isMaxReached = (val) => Boolean(max && val > max);
|
|
48
|
+
const isInRange = (val) => !isMinReached(val) && !isMaxReached(val);
|
|
49
|
+
const increase = () => {
|
|
50
|
+
const newValue = value + step;
|
|
51
|
+
if (!isMaxReached(newValue) && !disabled) {
|
|
52
|
+
onChange(newValue);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const decrease = () => {
|
|
56
|
+
const newValue = value - step;
|
|
57
|
+
if (!disabled && (!isMinReached(newValue) || props.removable)) {
|
|
58
|
+
onChange(newValue);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const handleChange = (event) => {
|
|
62
|
+
if (event.target.value) {
|
|
63
|
+
const integerInputValue = parseInt(event.target.value, 10);
|
|
64
|
+
if (isInRange(integerInputValue)) {
|
|
65
|
+
onChange(integerInputValue);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
onChange(max && isMaxReached(integerInputValue) ? max : min);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
onChange(min);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
return (React__default['default'].createElement(Container, { disabled: disabled, "data-testid": dataTestId, className: props.className },
|
|
76
|
+
React__default['default'].createElement(StyledButtonSecondary, { disabled: disabled, onClick: decrease, "data-testid": dataTestId &&
|
|
77
|
+
`${dataTestId}${props.removable && isMinReached(value - step) ? '-remove' : '-decrease'}` },
|
|
78
|
+
React__default['default'].createElement(Icon['default'], { color: theme['default'].color.black, name: props.removable && isMinReached(value - step) ? 'hlTrash' : 'hlMinus' })),
|
|
79
|
+
React__default['default'].createElement("input", { id: props.id, name: props.name, type: "number", onChange: handleChange, value: value, readOnly: readonly || disabled, disabled: disabled }),
|
|
80
|
+
React__default['default'].createElement(StyledButtonSecondary, { disabled: disabled, onClick: increase, "data-testid": dataTestId ? `${dataTestId}-increase` : undefined },
|
|
81
|
+
React__default['default'].createElement(Icon['default'], { color: theme['default'].color.black, name: "hlPlus" }))));
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
exports.default = AmountSelector;
|
|
@@ -3,15 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var styledUtils = require('../../utils/styledUtils.js');
|
|
7
6
|
var styled = require('../../themes/styled.js');
|
|
8
7
|
var theme = require('../../themes/theme.js');
|
|
8
|
+
var styledUtils = require('../../utils/styledUtils.js');
|
|
9
9
|
|
|
10
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
11
|
|
|
12
12
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
13
13
|
|
|
14
|
-
/** @visibleName Cards */
|
|
15
14
|
const showing = styled.keyframes `
|
|
16
15
|
from {
|
|
17
16
|
opacity:0.3;
|
|
@@ -11,7 +11,6 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
11
11
|
|
|
12
12
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
13
13
|
|
|
14
|
-
/** @visibleName CardRow */
|
|
15
14
|
const CardElement = styled['default'].div `
|
|
16
15
|
display: flex;
|
|
17
16
|
justify-content: space-between;
|
|
@@ -77,7 +77,10 @@ const ErrorMessage = styled['default'].div `
|
|
|
77
77
|
color: ${props => props.theme.color.error};
|
|
78
78
|
margin-top: ${props => styledUtils.getMultipliedSize(props.theme.base.baseHeight, 1)};
|
|
79
79
|
`;
|
|
80
|
-
const
|
|
80
|
+
const Mandatory = styled['default'].span `
|
|
81
|
+
color: ${props => props.theme.color.hotPink};
|
|
82
|
+
`;
|
|
83
|
+
const Checkbox = ({ id, value, onChange, label, disabled, error, errorMessage, className, required, 'data-testid': dataTestId, }) => {
|
|
81
84
|
const handleChange = () => {
|
|
82
85
|
if (onChange && !disabled) {
|
|
83
86
|
onChange(!value);
|
|
@@ -85,7 +88,9 @@ const Checkbox = ({ id, value, onChange, label, disabled, error, errorMessage, c
|
|
|
85
88
|
};
|
|
86
89
|
return (React__default['default'].createElement(React__default['default'].Fragment, null,
|
|
87
90
|
React__default['default'].createElement(Input, { id: id, className: className, type: "checkbox", checked: Boolean(value), onChange: handleChange, disabled: disabled, "data-testid": dataTestId }),
|
|
88
|
-
React__default['default'].createElement(Label, { htmlFor: id, "data-testid": dataTestId && `${dataTestId}-label` },
|
|
91
|
+
React__default['default'].createElement(Label, { htmlFor: id, "data-testid": dataTestId && `${dataTestId}-label` },
|
|
92
|
+
label,
|
|
93
|
+
required && React__default['default'].createElement(Mandatory, null, " *")),
|
|
89
94
|
error && errorMessage && (React__default['default'].createElement(ErrorMessage, { "data-testid": dataTestId && `${dataTestId}-error` }, errorMessage))));
|
|
90
95
|
};
|
|
91
96
|
|
|
@@ -81,6 +81,7 @@ const initialCollapse = {
|
|
|
81
81
|
1: false,
|
|
82
82
|
2: false,
|
|
83
83
|
};
|
|
84
|
+
/** @visibleName Footer */
|
|
84
85
|
const Footer = ({ items = { businessId: 'NONE', footerNavigation: {} }, language = 'fi', zIndex = 1, isMobileFooter = false, collapseSize = 767, }) => {
|
|
85
86
|
// Resets menu states when menu content alters between mobile and desktop
|
|
86
87
|
const footerChanged = previousValue !== isMobileFooter;
|
|
@@ -126,6 +127,6 @@ const Footer = ({ items = { businessId: 'NONE', footerNavigation: {} }, language
|
|
|
126
127
|
/** @component */
|
|
127
128
|
// TODO: Remove ts-ignore after https://jira.dna.fi/browse/STYLE-232 is done
|
|
128
129
|
// @ts-ignore
|
|
129
|
-
var
|
|
130
|
+
var Footer$1 = withSizes__default['default'](mapSizesToProps)(Footer);
|
|
130
131
|
|
|
131
|
-
exports.default =
|
|
132
|
+
exports.default = Footer$1;
|
|
File without changes
|
|
@@ -283,6 +283,7 @@ export declare const hlMarker: ({ size, color, ...props }: IconProps) => JSX.Ele
|
|
|
283
283
|
export declare const hlMenu: ({ size, color, ...props }: IconProps) => JSX.Element;
|
|
284
284
|
export declare const hlMemory: ({ size, color, ...props }: IconProps) => JSX.Element;
|
|
285
285
|
export declare const hlMinimize: ({ size, color, ...props }: IconProps) => JSX.Element;
|
|
286
|
+
export declare const hlMinus: ({ size, color, ...props }: IconProps) => JSX.Element;
|
|
286
287
|
export declare const hlMobileData: ({ size, color, ...props }: IconProps) => JSX.Element;
|
|
287
288
|
export declare const hlMobilePayment: ({ size, color, ...props }: IconProps) => JSX.Element;
|
|
288
289
|
export declare const hlModem: ({ size, color, ...props }: IconProps) => JSX.Element;
|
|
@@ -689,6 +689,8 @@ const hlMemory = ({ size, color, ...props }) => (React__default['default'].creat
|
|
|
689
689
|
React__default['default'].createElement("path", { d: "M7.8 8.4a.6.6 0 0 1-.6-.6V5.4a.6.6 0 1 1 1.2 0v2.4a.6.6 0 0 1-.6.6zM10.8 8.4a.6.6 0 0 1-.6-.6V5.4a.6.6 0 0 1 1.2 0v2.4a.6.6 0 0 1-.6.6zM13.8 8.4a.6.6 0 0 1-.6-.6V5.4a.6.6 0 1 1 1.2 0v2.4a.6.6 0 0 1-.6.6z" })));
|
|
690
690
|
const hlMinimize = ({ size, color, ...props }) => (React__default['default'].createElement("svg", Object.assign({ viewBox: "0 0 24 24", fill: color, width: size, height: size }, props),
|
|
691
691
|
React__default['default'].createElement("path", { d: "M21 21.6H3a.6.6 0 0 1 0-1.2h18a.6.6 0 0 1 0 1.2z" })));
|
|
692
|
+
const hlMinus = ({ size, color, ...props }) => (React__default['default'].createElement("svg", Object.assign({ viewBox: "0 0 24 24", fill: color, width: size, height: size }, props),
|
|
693
|
+
React__default['default'].createElement("path", { d: "M21 12.6H3a.6.6 0 0 1 0-1.2h18a.6.6 0 1 1 0 1.2z" })));
|
|
692
694
|
const hlMobileData = ({ size, color, ...props }) => (React__default['default'].createElement("svg", Object.assign({ viewBox: "0 0 24 24", fill: color, width: size, height: size }, props),
|
|
693
695
|
React__default['default'].createElement("path", { d: "M18 12a.6.6 0 01-.42-1 5.4 5.4 0 000-7.64.601.601 0 11.85-.85 6.6 6.6 0 010 9.33.6.6 0 01-.43.16zM6 12a.6.6 0 01-.42-.18 6.6 6.6 0 010-9.33.601.601 0 11.85.85 5.4 5.4 0 000 7.64A.6.6 0 016 12zM15 10.2a.6.6 0 01-.42-1 2.79 2.79 0 000-4 .601.601 0 11.85-.85 4 4 0 010 5.65.6.6 0 01-.43.2zM9 10.2a.6.6 0 01-.42-.2 4 4 0 010-5.65.601.601 0 11.85.85 2.79 2.79 0 000 4 .6.6 0 01-.42 1H9zM13.2 7.2a1.2 1.2 0 10-1.8 1V21a.6.6 0 101.2 0V8.23a1.19 1.19 0 00.6-1.03z" })));
|
|
694
696
|
const hlMobilePayment = ({ size, color, ...props }) => (React__default['default'].createElement("svg", Object.assign({ viewBox: "0 0 24 24", fill: color, width: size, height: size }, props),
|
|
@@ -941,6 +943,7 @@ exports.hlMarker = hlMarker;
|
|
|
941
943
|
exports.hlMemory = hlMemory;
|
|
942
944
|
exports.hlMenu = hlMenu;
|
|
943
945
|
exports.hlMinimize = hlMinimize;
|
|
946
|
+
exports.hlMinus = hlMinus;
|
|
944
947
|
exports.hlMobileData = hlMobileData;
|
|
945
948
|
exports.hlMobilePayment = hlMobilePayment;
|
|
946
949
|
exports.hlModem = hlModem;
|
|
File without changes
|
|
File without changes
|
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var styled = require('../../themes/styled.js');
|
|
7
7
|
var styledUtils = require('../../utils/styledUtils.js');
|
|
8
|
-
var LabelText = require('../LabelText/LabelText.js');
|
|
9
8
|
var Icon = require('../Icon/Icon.js');
|
|
9
|
+
var LabelText = require('../LabelText/LabelText.js');
|
|
10
10
|
|
|
11
11
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
12
|
|
|
@@ -19,7 +19,7 @@ const Tag = styled['default'].input `
|
|
|
19
19
|
padding: 0 ${props => styledUtils.getMultipliedSize(props.theme.base.baseWidth, 1)};
|
|
20
20
|
font-size: ${props => props.theme.fontSize.defaultFontSize};
|
|
21
21
|
width: 100%;
|
|
22
|
-
height:
|
|
22
|
+
height: ${props => styledUtils.getMultipliedSize(props.theme.base.baseHeight, 4)};
|
|
23
23
|
border: 1px solid ${props => props.theme.color.gray15};
|
|
24
24
|
&::-ms-clear,
|
|
25
25
|
&::-ms-reveal {
|
|
@@ -51,8 +51,8 @@ const FieldWrapper = styled['default'].div `
|
|
|
51
51
|
position: absolute;
|
|
52
52
|
z-index: 1;
|
|
53
53
|
top: 0;
|
|
54
|
-
right:
|
|
55
|
-
height:
|
|
54
|
+
right: ${props => styledUtils.getMultipliedSize(props.theme.base.baseWidth, 1)};
|
|
55
|
+
height: ${props => styledUtils.getMultipliedSize(props.theme.base.baseHeight, 4)};
|
|
56
56
|
}
|
|
57
57
|
`;
|
|
58
58
|
const FieldContainer = styled['default'].div `
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @visibleName Label
|
|
1
|
+
/** @visibleName Label Text */
|
|
2
2
|
export declare const LabelText: import("styled-components").StyledComponent<"label", {
|
|
3
3
|
base: {
|
|
4
4
|
baseHeight: {
|
|
@@ -48,7 +48,7 @@ export declare const LabelText: import("styled-components").StyledComponent<"lab
|
|
|
48
48
|
gray5: string;
|
|
49
49
|
};
|
|
50
50
|
fontFamily: {
|
|
51
|
-
baseFontFamily: string; /** @visibleName Label
|
|
51
|
+
baseFontFamily: string; /** @visibleName Label Text */
|
|
52
52
|
};
|
|
53
53
|
fontSize: {
|
|
54
54
|
defaultFontSize: string;
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var styled = require('../../themes/styled.js');
|
|
6
6
|
var styledUtils = require('../../utils/styledUtils.js');
|
|
7
7
|
|
|
8
|
-
/** @visibleName Label
|
|
8
|
+
/** @visibleName Label Text */
|
|
9
9
|
const LabelText = styled['default'].label(({ theme, htmlFor }) => ({
|
|
10
10
|
fontSize: theme.fontSize.defaultFontSize,
|
|
11
11
|
display: 'block',
|
|
@@ -39,25 +39,19 @@ const BusinessMenuList = styled['default'].ul `
|
|
|
39
39
|
height: 100%;
|
|
40
40
|
`;
|
|
41
41
|
const BusinessMenu = () => {
|
|
42
|
-
const { items: data, lang: language, isMobileMenu, resetMenuEvents
|
|
42
|
+
const { items: data, lang: language, isMobileMenu, resetMenuEvents } = React.useContext(NavContext['default']);
|
|
43
43
|
const ref = React.useRef(null);
|
|
44
44
|
if (!data.businessId || (!data.businessSelector && data.businessSelector.items.length > 0)) {
|
|
45
45
|
return React__default['default'].createElement(React__default['default'].Fragment, null);
|
|
46
46
|
}
|
|
47
47
|
const currentBusinessId = data.businessId;
|
|
48
48
|
const businessMenuItems = data.businessSelector.items;
|
|
49
|
-
const getTabIndex = () => {
|
|
50
|
-
if ((scrollPosition && scrollPosition > 0) || !isMobileMenu) {
|
|
51
|
-
return -1;
|
|
52
|
-
}
|
|
53
|
-
return undefined;
|
|
54
|
-
};
|
|
55
49
|
if (!businessMenuItems.length) {
|
|
56
50
|
return React__default['default'].createElement(React__default['default'].Fragment, null);
|
|
57
51
|
}
|
|
58
52
|
return (React__default['default'].createElement(BusinessMenuList, { isMobileMenu: isMobileMenu, ref: ref, role: "menubar", "aria-hidden": "false", "data-testid": "business-menu-ul" }, businessMenuItems.map((item, index) => {
|
|
59
|
-
return (React__default['default'].createElement(BusinessMenuItem, { className: "menu-item", key: item.businessId, "data-testid": `business-menu-selection-item-${index + 1}
|
|
60
|
-
React__default['default'].createElement(BusinessMenuLink, { className: "menu-link", href: item.urls[language], onClick: resetMenuEvents,
|
|
53
|
+
return (React__default['default'].createElement(BusinessMenuItem, { className: "menu-item", key: item.businessId, "data-testid": `business-menu-selection-item-${index + 1}`, role: "none" },
|
|
54
|
+
React__default['default'].createElement(BusinessMenuLink, { className: "menu-link", href: item.urls[language], onClick: resetMenuEvents, isActive: item.businessId === currentBusinessId, isMobileMenu: isMobileMenu, role: "menuitem" }, item.titles[language])));
|
|
61
55
|
})));
|
|
62
56
|
};
|
|
63
57
|
|