widenarrow-ui 1.0.21 → 1.0.23
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/lib/components/DropDownItem/DropDownItem.types.d.ts +1 -0
- package/lib/index.css +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.esm.css +1 -1
- package/lib/index.esm.js +49 -47
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +49 -47
- package/lib/index.js.map +1 -1
- package/package.json +5 -3
- package/src/components/DropDown/DropDown.stories.tsx +15 -3
- package/src/components/DropDown/DropDown.tsx +4 -7
- package/src/components/DropDownItem/DropDownItem.tsx +4 -1
- package/src/components/DropDownItem/DropDownItem.types.ts +1 -0
- package/src/components/SwitchButton/SwitchButton.module.scss +20 -2
- package/src/components/SwitchButton/SwitchButton.tsx +10 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "widenarrow-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
4
4
|
"description": "A storybook 6 typeScript component library used for Wide Narrow by infodesk",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.esm.js",
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
"typescript": "4.7.3"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
+
"@types/react": ">= 17.0.2",
|
|
67
68
|
"lazysizes": "5.2.2",
|
|
68
69
|
"ramda": "0.26.1",
|
|
69
|
-
"@types/react": ">= 17.0.2",
|
|
70
70
|
"react": ">= 17.0.2",
|
|
71
71
|
"react-dom": ">= 17.0.2",
|
|
72
72
|
"react-intersection-observer": "8.31.0",
|
|
@@ -80,9 +80,11 @@
|
|
|
80
80
|
"scripts": {
|
|
81
81
|
"lint": "eslint .",
|
|
82
82
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
83
|
+
"build-storybook": "storybook build",
|
|
83
84
|
"storybook": "storybook dev -p 6006",
|
|
85
|
+
"predeploy": "npm run build-storybook",
|
|
86
|
+
"start:production": "npx http-server ./storybook-static",
|
|
84
87
|
"start": "storybook dev -p 6006",
|
|
85
|
-
"build-storybook": "storybook build",
|
|
86
88
|
"build": "rollup -c",
|
|
87
89
|
"prepublishOnly": "yarn build"
|
|
88
90
|
}
|
|
@@ -23,7 +23,7 @@ const meta: Meta<typeof DropDown> = {
|
|
|
23
23
|
buttonCallbackName={'onRightClickCallback'}
|
|
24
24
|
title={'Filter on portal status'}
|
|
25
25
|
>
|
|
26
|
-
<DropDownItem text={'Item with placeholder'} size={size} onClickCallback={() => undefined}
|
|
26
|
+
<DropDownItem text={'Item with placeholder'} size={size} onClickCallback={() => undefined} closeDropDownOnClick />
|
|
27
27
|
<DropDownItem
|
|
28
28
|
text={'Item 2'}
|
|
29
29
|
onClickCallback={() => undefined}
|
|
@@ -32,23 +32,35 @@ const meta: Meta<typeof DropDown> = {
|
|
|
32
32
|
leftIcon={IconTypes.ADD_POST}
|
|
33
33
|
rightIcon={IconTypes.CHEVRON_RIGHT}
|
|
34
34
|
size={size}
|
|
35
|
+
closeDropDownOnClick
|
|
36
|
+
/>
|
|
37
|
+
<DropDownItem
|
|
38
|
+
text={'Item 3'}
|
|
39
|
+
onClickCallback={() => {
|
|
40
|
+
console.log('clicked');
|
|
41
|
+
}}
|
|
42
|
+
iconColor={ColorTypes.BLUE}
|
|
43
|
+
size={size}
|
|
44
|
+
closeDropDownOnClick
|
|
45
|
+
active
|
|
35
46
|
/>
|
|
36
|
-
<DropDownItem text={'Item 3'} onClickCallback={() => undefined} iconColor={ColorTypes.BLUE} size={size} active />
|
|
37
47
|
<DropDownItem
|
|
38
48
|
text={'Item 4'}
|
|
39
49
|
onClickCallback={() => undefined}
|
|
40
50
|
type={HierarchyTypes.SECONDARY}
|
|
41
51
|
iconColor={ColorTypes.WHITE}
|
|
42
52
|
size={size}
|
|
53
|
+
closeDropDownOnClick
|
|
43
54
|
active
|
|
44
55
|
/>
|
|
45
|
-
<DropDownItem text={'Item 5'} onClickCallback={() => undefined} size={size}
|
|
56
|
+
<DropDownItem text={'Item 5'} onClickCallback={() => undefined} size={size} closeDropDownOnClick />
|
|
46
57
|
<DropDownItem
|
|
47
58
|
text={'Unpin from menu'}
|
|
48
59
|
onClickCallback={() => undefined}
|
|
49
60
|
leftIcon={IconTypes.PIN}
|
|
50
61
|
size={size}
|
|
51
62
|
iconColor={ColorTypes.ORANGE}
|
|
63
|
+
closeDropDownOnClick
|
|
52
64
|
/>
|
|
53
65
|
</DropDown>
|
|
54
66
|
</div>
|
|
@@ -34,10 +34,7 @@ const DropDown: FC<DropDownProps> = ({
|
|
|
34
34
|
loading,
|
|
35
35
|
withArrow = true,
|
|
36
36
|
childrenIsList = true,
|
|
37
|
-
withVisibleOverflow
|
|
38
|
-
// eslint-disable-next-line
|
|
39
|
-
// @ts-ignore
|
|
40
|
-
closeDropDownOnClick = true // eslint-disable-line
|
|
37
|
+
withVisibleOverflow
|
|
41
38
|
}) => {
|
|
42
39
|
const [isOpen, setIsOpen] = useState(false);
|
|
43
40
|
const [referenceElement, setReferenceElement] = useState<HTMLDivElement | null>(null);
|
|
@@ -78,11 +75,11 @@ const DropDown: FC<DropDownProps> = ({
|
|
|
78
75
|
|
|
79
76
|
// If a child has an onClickCallback, we want to close the DropDown when it is clicked.
|
|
80
77
|
const cloneChildWithCloseCallback = (c: ReactNode) => {
|
|
81
|
-
if (isValidElement(c) && is(Function, c.props
|
|
78
|
+
if (isValidElement(c) && is(Function, c.props.onClickCallback)) {
|
|
82
79
|
return cloneElement(c, {
|
|
83
80
|
key: c.key || uuid(),
|
|
84
|
-
|
|
85
|
-
c.props
|
|
81
|
+
onClickCallback: (event: unknown) => {
|
|
82
|
+
c.props.onClickCallback(event);
|
|
86
83
|
if (c.props.closeDropDownOnClick) {
|
|
87
84
|
onClose();
|
|
88
85
|
}
|
|
@@ -31,7 +31,10 @@ const DropDownItem: FC<DropDownItemProps> = ({
|
|
|
31
31
|
iconSize,
|
|
32
32
|
withEllipsis,
|
|
33
33
|
iconClassName,
|
|
34
|
-
wrapperElement
|
|
34
|
+
wrapperElement,
|
|
35
|
+
// eslint-disable-next-line
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
closeDropDownOnClick = true // eslint-disable-line
|
|
35
38
|
}) => {
|
|
36
39
|
const getIcon = () => {
|
|
37
40
|
if (is(Boolean, active)) {
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
|
|
17
17
|
&_isDisabled {
|
|
18
18
|
pointer-events: none;
|
|
19
|
-
opacity: $disabled-opacity;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
&_withInlineLabel {
|
|
@@ -95,9 +94,17 @@
|
|
|
95
94
|
height: 100%;
|
|
96
95
|
border-radius: 20px;
|
|
97
96
|
|
|
97
|
+
&_isDisabled {
|
|
98
|
+
background: $grey-disabled;
|
|
99
|
+
}
|
|
100
|
+
|
|
98
101
|
&_isActive {
|
|
99
102
|
background: $blue;
|
|
100
103
|
}
|
|
104
|
+
|
|
105
|
+
&_isActiveAndDisabled {
|
|
106
|
+
background: $blue-disabled;
|
|
107
|
+
}
|
|
101
108
|
}
|
|
102
109
|
|
|
103
110
|
.circle {
|
|
@@ -105,7 +112,6 @@
|
|
|
105
112
|
left: 2px;
|
|
106
113
|
position: absolute;
|
|
107
114
|
transition: transform 200ms ease;
|
|
108
|
-
background: $grey-4;
|
|
109
115
|
transform: translateX(0px);
|
|
110
116
|
display: block;
|
|
111
117
|
height: 16px;
|
|
@@ -125,9 +131,17 @@
|
|
|
125
131
|
border-radius: 50%;
|
|
126
132
|
}
|
|
127
133
|
|
|
134
|
+
&_isDisabled {
|
|
135
|
+
background: $grey-1;
|
|
136
|
+
}
|
|
137
|
+
|
|
128
138
|
&_isActive {
|
|
129
139
|
transform: translateX(28px);
|
|
130
140
|
}
|
|
141
|
+
|
|
142
|
+
&_isActiveAndDisabled {
|
|
143
|
+
background: $white;
|
|
144
|
+
}
|
|
131
145
|
}
|
|
132
146
|
|
|
133
147
|
.label {
|
|
@@ -143,4 +157,8 @@
|
|
|
143
157
|
&_alignCenter {
|
|
144
158
|
text-align: center;
|
|
145
159
|
}
|
|
160
|
+
|
|
161
|
+
&_isDisabled {
|
|
162
|
+
color: $text-disabled;
|
|
163
|
+
}
|
|
146
164
|
}
|
|
@@ -26,7 +26,10 @@ const SwitchButton: FC<SwitchButtonProps> = ({
|
|
|
26
26
|
})}
|
|
27
27
|
>
|
|
28
28
|
{label ? (
|
|
29
|
-
<label
|
|
29
|
+
<label
|
|
30
|
+
className={s('label', { label_alignCenter: alignCenter, label_inlineLabel: inlineLabel, label_isDisabled: disabled })}
|
|
31
|
+
htmlFor={name}
|
|
32
|
+
>
|
|
30
33
|
{label}
|
|
31
34
|
</label>
|
|
32
35
|
) : null}
|
|
@@ -46,13 +49,17 @@ const SwitchButton: FC<SwitchButtonProps> = ({
|
|
|
46
49
|
/>
|
|
47
50
|
<span
|
|
48
51
|
className={s('line', {
|
|
49
|
-
line_isActive: checked
|
|
52
|
+
line_isActive: checked,
|
|
53
|
+
line_isDisabled: disabled,
|
|
54
|
+
line_isActiveAndDisabled: checked && disabled
|
|
50
55
|
})}
|
|
51
56
|
/>
|
|
52
57
|
<span
|
|
53
58
|
className={s('circle', {
|
|
54
59
|
circle_isNotActive: !checked,
|
|
55
|
-
circle_isActive: checked
|
|
60
|
+
circle_isActive: checked,
|
|
61
|
+
circle_isDisabled: disabled,
|
|
62
|
+
circle_isActiveAndDisabled: checked && disabled
|
|
56
63
|
})}
|
|
57
64
|
/>
|
|
58
65
|
</div>
|