@spaced-out/ui-design-system 0.1.94 → 0.1.95
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/CHANGELOG.md +12 -0
- package/lib/components/ButtonTabs/ButtonTab/ButtonTab.js +5 -1
- package/lib/components/ButtonTabs/ButtonTab/ButtonTab.js.flow +6 -0
- package/lib/components/ButtonTabs/ButtonTab/ButtonTab.module.css +44 -15
- package/lib/components/ButtonTabs/ButtonTabs.js +18 -3
- package/lib/components/ButtonTabs/ButtonTabs.js.flow +23 -2
- package/lib/components/ButtonTabs/ButtonTabs.module.css +34 -8
- package/lib/components/Dropdown/Dropdown.js +2 -1
- package/lib/components/Dropdown/Dropdown.js.flow +2 -1
- package/lib/utils/string/string.js +9 -2
- package/lib/utils/string/string.js.flow +10 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.1.95](https://github.com/spaced-out/ui-design-system/compare/v0.1.94...v0.1.95) (2024-05-23)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* button tabs update ([#217](https://github.com/spaced-out/ui-design-system/issues/217)) ([b670334](https://github.com/spaced-out/ui-design-system/commit/b67033454127b0ca7de9f7a1ec95f7d0aa64a311))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* [GDS-349] dropdown doesn't close on keypress and truncateString utility ([#214](https://github.com/spaced-out/ui-design-system/issues/214)) ([d852102](https://github.com/spaced-out/ui-design-system/commit/d852102c4e9f2404b33b1c6c81b6bf5a08c1382a))
|
|
16
|
+
|
|
5
17
|
### [0.1.94](https://github.com/spaced-out/ui-design-system/compare/v0.1.94-beta.8...v0.1.94) (2024-05-22)
|
|
6
18
|
|
|
7
19
|
### [0.1.94-beta.8](https://github.com/spaced-out/ui-design-system/compare/v0.1.94-beta.7...v0.1.94-beta.8) (2024-05-22)
|
|
@@ -23,6 +23,8 @@ const ButtonTab = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
23
23
|
id,
|
|
24
24
|
selectedButtonTabId,
|
|
25
25
|
disabled,
|
|
26
|
+
isLeftCurved,
|
|
27
|
+
isRightCurved,
|
|
26
28
|
...props
|
|
27
29
|
} = _ref;
|
|
28
30
|
return /*#__PURE__*/React.createElement(_Button.Button, _extends({}, props, {
|
|
@@ -37,7 +39,9 @@ const ButtonTab = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
37
39
|
[_ButtonTabModule.default.onlyIcon]: iconName && !children,
|
|
38
40
|
[_ButtonTabModule.default.isSelected]: id === selectedButtonTabId,
|
|
39
41
|
[_ButtonTabModule.default.isUnSelected]: id !== selectedButtonTabId,
|
|
40
|
-
[_ButtonTabModule.default.disabled]: disabled
|
|
42
|
+
[_ButtonTabModule.default.disabled]: disabled,
|
|
43
|
+
[_ButtonTabModule.default.leftCurved]: isLeftCurved,
|
|
44
|
+
[_ButtonTabModule.default.rightCurved]: isRightCurved
|
|
41
45
|
}, classNames?.wrapper),
|
|
42
46
|
icon: _ButtonTabModule.default.icon
|
|
43
47
|
},
|
|
@@ -24,6 +24,8 @@ export type ButtonTabProps = {
|
|
|
24
24
|
id: string,
|
|
25
25
|
selectedButtonTabId?: string,
|
|
26
26
|
isLoading?: boolean,
|
|
27
|
+
isLeftCurved?: boolean,
|
|
28
|
+
isRightCurved?: boolean,
|
|
27
29
|
...
|
|
28
30
|
};
|
|
29
31
|
|
|
@@ -42,6 +44,8 @@ export const ButtonTab: React$AbstractComponent<
|
|
|
42
44
|
id,
|
|
43
45
|
selectedButtonTabId,
|
|
44
46
|
disabled,
|
|
47
|
+
isLeftCurved,
|
|
48
|
+
isRightCurved,
|
|
45
49
|
...props
|
|
46
50
|
}: ButtonTabProps,
|
|
47
51
|
ref,
|
|
@@ -62,6 +66,8 @@ export const ButtonTab: React$AbstractComponent<
|
|
|
62
66
|
[css.isSelected]: id === selectedButtonTabId,
|
|
63
67
|
[css.isUnSelected]: id !== selectedButtonTabId,
|
|
64
68
|
[css.disabled]: disabled,
|
|
69
|
+
[css.leftCurved]: isLeftCurved,
|
|
70
|
+
[css.rightCurved]: isRightCurved,
|
|
65
71
|
},
|
|
66
72
|
classNames?.wrapper,
|
|
67
73
|
),
|
|
@@ -1,12 +1,28 @@
|
|
|
1
|
-
@value (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
@value (
|
|
2
|
+
colorTextDisabled,
|
|
3
|
+
colorBorderPrimary,
|
|
4
|
+
colorTextPrimary,
|
|
5
|
+
colorTextSecondary,
|
|
6
|
+
colorFillSecondary
|
|
7
|
+
) from '../../../styles/variables/_color.css';
|
|
8
|
+
@value (
|
|
9
|
+
size42,
|
|
10
|
+
size34
|
|
11
|
+
) from '../../../styles/variables/_size.css';
|
|
12
|
+
@value (
|
|
13
|
+
spaceSmall
|
|
14
|
+
) from '../../../styles/variables/_space.css';
|
|
15
|
+
@value (
|
|
16
|
+
borderWidthPrimary,
|
|
17
|
+
borderWidthNone,
|
|
18
|
+
borderRadiusNone,
|
|
19
|
+
borderRadiusMedium
|
|
20
|
+
) from '../../../styles/variables/_border.css';
|
|
5
21
|
|
|
6
|
-
|
|
22
|
+
.buttonTabWrapper {
|
|
7
23
|
padding-left: spaceSmall;
|
|
8
24
|
padding-right: spaceSmall;
|
|
9
|
-
height:
|
|
25
|
+
height: size42;
|
|
10
26
|
color: colorTextSecondary;
|
|
11
27
|
min-width: initial;
|
|
12
28
|
text-align: left;
|
|
@@ -16,21 +32,21 @@ button.buttonTabWrapper {
|
|
|
16
32
|
color: colorTextSecondary;
|
|
17
33
|
}
|
|
18
34
|
|
|
19
|
-
|
|
35
|
+
.buttonTabWrapper:hover {
|
|
20
36
|
color: colorTextPrimary;
|
|
21
37
|
background-color: initial;
|
|
22
38
|
}
|
|
23
39
|
|
|
24
|
-
|
|
40
|
+
.buttonTabWrapper:hover .icon {
|
|
25
41
|
color: colorTextPrimary;
|
|
26
42
|
}
|
|
27
43
|
|
|
28
44
|
.buttonTabWrapper.mediumButtonTab {
|
|
29
|
-
height:
|
|
45
|
+
height: size42;
|
|
30
46
|
}
|
|
31
47
|
|
|
32
48
|
.buttonTabWrapper.smallButtonTab {
|
|
33
|
-
height:
|
|
49
|
+
height: size34;
|
|
34
50
|
}
|
|
35
51
|
|
|
36
52
|
.onlyIcon {
|
|
@@ -40,20 +56,34 @@ button.buttonTabWrapper:hover .icon {
|
|
|
40
56
|
}
|
|
41
57
|
|
|
42
58
|
.mediumButtonTab.onlyIcon {
|
|
43
|
-
max-width:
|
|
59
|
+
max-width: size42;
|
|
44
60
|
}
|
|
45
61
|
|
|
46
62
|
.smallButtonTab.onlyIcon {
|
|
47
|
-
max-width:
|
|
63
|
+
max-width: size34;
|
|
48
64
|
}
|
|
49
65
|
|
|
50
66
|
.buttonTabWrapper.isSelected {
|
|
51
|
-
background-color:
|
|
67
|
+
background-color: colorFillSecondary;
|
|
52
68
|
color: colorTextPrimary;
|
|
69
|
+
border-width: borderWidthPrimary borderWidthPrimary borderWidthPrimary
|
|
70
|
+
borderWidthNone;
|
|
71
|
+
border-style: solid;
|
|
72
|
+
border-color: colorBorderPrimary;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.buttonTabWrapper.leftCurved {
|
|
76
|
+
border-radius: borderRadiusMedium borderRadiusNone borderRadiusNone
|
|
77
|
+
borderRadiusMedium;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.buttonTabWrapper.rightCurved {
|
|
81
|
+
border-radius: borderRadiusNone borderRadiusMedium borderRadiusMedium
|
|
82
|
+
borderRadiusNone;
|
|
53
83
|
}
|
|
54
84
|
|
|
55
85
|
.buttonTabWrapper.isSelected:hover {
|
|
56
|
-
background-color:
|
|
86
|
+
background-color: colorFillSecondary;
|
|
57
87
|
}
|
|
58
88
|
|
|
59
89
|
.buttonTabWrapper.isSelected .icon {
|
|
@@ -71,5 +101,4 @@ button.buttonTabWrapper:hover .icon {
|
|
|
71
101
|
.buttonTabWrapper.isUnSelected {
|
|
72
102
|
padding-left: spaceSmall;
|
|
73
103
|
padding-right: spaceSmall;
|
|
74
|
-
border: borderWidthPrimary solid colorButtonFillTertiaryEnabled;
|
|
75
104
|
}
|
|
@@ -21,18 +21,33 @@ const ButtonTabs = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
21
21
|
selectedButtonTabId,
|
|
22
22
|
onButtonTabSelect
|
|
23
23
|
} = _ref;
|
|
24
|
-
const
|
|
24
|
+
const childrenArray = React.Children.toArray(children);
|
|
25
|
+
const childrenWithProps = childrenArray.map((child, index) => {
|
|
25
26
|
if ( /*#__PURE__*/React.isValidElement(child)) {
|
|
26
27
|
const {
|
|
27
|
-
disabled: disabledChild
|
|
28
|
+
disabled: disabledChild,
|
|
29
|
+
classNames: classNamesChild
|
|
28
30
|
} = child.props;
|
|
31
|
+
const isFirst = index === 0;
|
|
32
|
+
const isLast = index === childrenArray.length - 1;
|
|
33
|
+
const isSingleChild = childrenArray.length === 1;
|
|
29
34
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
30
35
|
...child.props,
|
|
31
36
|
isFluid,
|
|
32
37
|
size,
|
|
38
|
+
isLeftCurved: isFirst && !isSingleChild,
|
|
39
|
+
isRightCurved: isLast && !isSingleChild,
|
|
33
40
|
disabled: disabledChild || disabled,
|
|
34
41
|
selectedButtonTabId,
|
|
35
|
-
onButtonTabSelect
|
|
42
|
+
onButtonTabSelect,
|
|
43
|
+
classNames: {
|
|
44
|
+
wrapper: (0, _classify.default)(_ButtonTabsModule.default.buttonTab, {
|
|
45
|
+
[_ButtonTabsModule.default.firstChild]: isFirst && !isSingleChild,
|
|
46
|
+
[_ButtonTabsModule.default.lastChild]: isLast && !isSingleChild,
|
|
47
|
+
[_ButtonTabsModule.default.children]: !isFirst && !isLast,
|
|
48
|
+
[_ButtonTabsModule.default.singleChild]: isSingleChild
|
|
49
|
+
}, classNamesChild?.wrapper)
|
|
50
|
+
}
|
|
36
51
|
});
|
|
37
52
|
}
|
|
38
53
|
return child;
|
|
@@ -35,16 +35,37 @@ export const ButtonTabs: React$AbstractComponent<
|
|
|
35
35
|
}: ButtonTabsProps,
|
|
36
36
|
ref,
|
|
37
37
|
): React.Node => {
|
|
38
|
-
const
|
|
38
|
+
const childrenArray = React.Children.toArray(children);
|
|
39
|
+
|
|
40
|
+
const childrenWithProps = childrenArray.map((child, index) => {
|
|
39
41
|
if (React.isValidElement(child)) {
|
|
40
|
-
const {disabled: disabledChild} =
|
|
42
|
+
const {disabled: disabledChild, classNames: classNamesChild} =
|
|
43
|
+
child.props;
|
|
44
|
+
const isFirst = index === 0;
|
|
45
|
+
const isLast = index === childrenArray.length - 1;
|
|
46
|
+
const isSingleChild = childrenArray.length === 1;
|
|
47
|
+
|
|
41
48
|
return React.cloneElement(child, {
|
|
42
49
|
...child.props,
|
|
43
50
|
isFluid,
|
|
44
51
|
size,
|
|
52
|
+
isLeftCurved: isFirst && !isSingleChild,
|
|
53
|
+
isRightCurved: isLast && !isSingleChild,
|
|
45
54
|
disabled: disabledChild || disabled,
|
|
46
55
|
selectedButtonTabId,
|
|
47
56
|
onButtonTabSelect,
|
|
57
|
+
classNames: {
|
|
58
|
+
wrapper: classify(
|
|
59
|
+
css.buttonTab,
|
|
60
|
+
{
|
|
61
|
+
[css.firstChild]: isFirst && !isSingleChild,
|
|
62
|
+
[css.lastChild]: isLast && !isSingleChild,
|
|
63
|
+
[css.children]: !isFirst && !isLast,
|
|
64
|
+
[css.singleChild]: isSingleChild,
|
|
65
|
+
},
|
|
66
|
+
classNamesChild?.wrapper,
|
|
67
|
+
),
|
|
68
|
+
},
|
|
48
69
|
});
|
|
49
70
|
}
|
|
50
71
|
return child;
|
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
@value (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
@value (
|
|
2
|
+
colorBackgroundTertiary,
|
|
3
|
+
colorBorderPrimary
|
|
4
|
+
) from '../../styles/variables/_color.css';
|
|
5
|
+
@value (
|
|
6
|
+
size42,
|
|
7
|
+
size34,
|
|
8
|
+
sizeFluid
|
|
9
|
+
) from '../../styles/variables/_size.css';
|
|
10
|
+
@value (
|
|
11
|
+
borderWidthNone,
|
|
12
|
+
borderWidthPrimary,
|
|
13
|
+
borderRadiusMedium,
|
|
14
|
+
borderRadiusNone
|
|
15
|
+
) from '../../styles/variables/_border.css';
|
|
5
16
|
|
|
6
17
|
.buttonTabsWrapper {
|
|
7
18
|
display: flex;
|
|
8
|
-
|
|
9
|
-
background-color: colorBackgroundSecondary;
|
|
19
|
+
background-color: colorBackgroundTertiary;
|
|
10
20
|
align-items: center;
|
|
11
|
-
padding-left: calc(spaceXXSmall / 2);
|
|
12
|
-
padding-right: calc(spaceXXSmall / 2);
|
|
13
21
|
width: fit-content;
|
|
22
|
+
composes: borderTopPrimary from '../../styles/border.module.css';
|
|
23
|
+
composes: borderBottomPrimary from '../../styles/border.module.css';
|
|
14
24
|
border-radius: borderRadiusMedium;
|
|
15
25
|
}
|
|
16
26
|
|
|
@@ -25,3 +35,19 @@
|
|
|
25
35
|
.buttonTabsWrapper.isFluid {
|
|
26
36
|
width: sizeFluid;
|
|
27
37
|
}
|
|
38
|
+
|
|
39
|
+
.buttonTab {
|
|
40
|
+
border-color: colorBorderPrimary;
|
|
41
|
+
border-width: borderWidthNone borderWidthPrimary;
|
|
42
|
+
border-style: none solid;
|
|
43
|
+
border-radius: borderRadiusNone;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.children,
|
|
47
|
+
.lastChild {
|
|
48
|
+
border-left-width: borderWidthNone;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.singleChild {
|
|
52
|
+
border-radius: borderRadiusMedium;
|
|
53
|
+
}
|
|
@@ -69,7 +69,7 @@ const Dropdown = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
69
69
|
onKeyDown: e => {
|
|
70
70
|
if (e.keyCode === 32) {
|
|
71
71
|
e.preventDefault();
|
|
72
|
-
onOpen();
|
|
72
|
+
isOpen ? clickAway() : onOpen();
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
75
|
boxRef: refs.setReference,
|
|
@@ -100,6 +100,7 @@ const Dropdown = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
100
100
|
onChange && onChange(option, e);
|
|
101
101
|
if (!menu.optionsVariant || menu.optionsVariant === 'normal') {
|
|
102
102
|
clickAway();
|
|
103
|
+
refs.reference.current.querySelector('input').focus();
|
|
103
104
|
}
|
|
104
105
|
},
|
|
105
106
|
size: menu.size || size,
|
|
@@ -89,7 +89,7 @@ export const Dropdown: React$AbstractComponent<
|
|
|
89
89
|
onKeyDown={(e) => {
|
|
90
90
|
if (e.keyCode === 32) {
|
|
91
91
|
e.preventDefault();
|
|
92
|
-
onOpen();
|
|
92
|
+
isOpen ? clickAway() : onOpen();
|
|
93
93
|
}
|
|
94
94
|
}}
|
|
95
95
|
boxRef={refs.setReference}
|
|
@@ -126,6 +126,7 @@ export const Dropdown: React$AbstractComponent<
|
|
|
126
126
|
menu.optionsVariant === 'normal'
|
|
127
127
|
) {
|
|
128
128
|
clickAway();
|
|
129
|
+
refs.reference.current.querySelector('input').focus();
|
|
129
130
|
}
|
|
130
131
|
}}
|
|
131
132
|
size={menu.size || size}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.formatWord = exports.escapeRegExp = exports.capitalize = void 0;
|
|
6
|
+
exports.truncateString = exports.formatWord = exports.escapeRegExp = exports.capitalize = void 0;
|
|
7
7
|
|
|
8
8
|
const capitalize = word => {
|
|
9
9
|
if (!word) {
|
|
@@ -15,4 +15,11 @@ exports.capitalize = capitalize;
|
|
|
15
15
|
const escapeRegExp = str => str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
16
16
|
exports.escapeRegExp = escapeRegExp;
|
|
17
17
|
const formatWord = (word, count) => count === 1 ? word : word + 's';
|
|
18
|
-
exports.formatWord = formatWord;
|
|
18
|
+
exports.formatWord = formatWord;
|
|
19
|
+
const truncateString = (inputString, maxLength) => {
|
|
20
|
+
if (inputString.length > maxLength) {
|
|
21
|
+
return inputString.substring(0, maxLength - 3) + '...';
|
|
22
|
+
}
|
|
23
|
+
return inputString;
|
|
24
|
+
};
|
|
25
|
+
exports.truncateString = truncateString;
|
|
@@ -14,3 +14,13 @@ export const escapeRegExp = (str: string): string =>
|
|
|
14
14
|
|
|
15
15
|
export const formatWord = (word: string, count: number): string =>
|
|
16
16
|
count === 1 ? word : word + 's';
|
|
17
|
+
|
|
18
|
+
export const truncateString = (
|
|
19
|
+
inputString: string,
|
|
20
|
+
maxLength: number,
|
|
21
|
+
): string => {
|
|
22
|
+
if (inputString.length > maxLength) {
|
|
23
|
+
return inputString.substring(0, maxLength - 3) + '...';
|
|
24
|
+
}
|
|
25
|
+
return inputString;
|
|
26
|
+
};
|