@dxc-technology/halstack-react 0.0.0-7c194f8 → 0.0.0-7c2b794
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/HalstackContext.d.ts +29 -15
- package/HalstackContext.js +1 -1
- package/accordion/Accordion.js +1 -1
- package/accordion-group/AccordionGroup.d.ts +2 -3
- package/accordion-group/AccordionGroup.js +3 -3
- package/accordion-group/AccordionGroupAccordion.js +2 -2
- package/accordion-group/AccordionGroupContext.d.ts +3 -0
- package/accordion-group/AccordionGroupContext.js +8 -0
- package/action-icon/ActionIcon.d.ts +4 -0
- package/action-icon/ActionIcon.js +47 -0
- package/action-icon/ActionIcon.stories.tsx +41 -0
- package/action-icon/ActionIcon.test.js +64 -0
- package/action-icon/types.d.ts +26 -0
- package/action-icon/types.js +5 -0
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +140 -29
- package/badge/Badge.stories.tsx +210 -0
- package/badge/Badge.test.js +30 -0
- package/badge/types.d.ts +52 -3
- package/button/Button.js +3 -2
- package/button/Button.stories.tsx +32 -50
- package/button/Button.test.js +3 -1
- package/button/types.d.ts +1 -1
- package/common/coreTokens.js +2 -2
- package/common/variables.d.ts +29 -15
- package/common/variables.js +36 -22
- package/container/Container.js +1 -1
- package/contextual-menu/ContextualMenu.d.ts +7 -0
- package/contextual-menu/ContextualMenu.js +71 -0
- package/contextual-menu/ContextualMenu.stories.tsx +182 -0
- package/contextual-menu/ContextualMenu.test.js +71 -0
- package/contextual-menu/MenuItemAction.d.ts +4 -0
- package/contextual-menu/MenuItemAction.js +46 -0
- package/contextual-menu/types.d.ts +22 -0
- package/contextual-menu/types.js +5 -0
- package/date-input/types.d.ts +2 -2
- package/divider/Divider.d.ts +4 -0
- package/divider/Divider.js +36 -0
- package/divider/Divider.stories.tsx +223 -0
- package/divider/Divider.test.js +38 -0
- package/divider/types.d.ts +19 -0
- package/divider/types.js +5 -0
- package/dropdown/Dropdown.js +9 -7
- package/dropdown/types.d.ts +1 -1
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +25 -12
- package/footer/Footer.stories.tsx +19 -0
- package/footer/Icons.d.ts +1 -0
- package/footer/Icons.js +65 -1
- package/footer/types.d.ts +6 -0
- package/header/types.d.ts +2 -2
- package/icon/Icon.d.ts +4 -0
- package/icon/Icon.js +33 -0
- package/icon/Icon.stories.tsx +26 -0
- package/icon/types.d.ts +4 -0
- package/icon/types.js +5 -0
- package/image/Image.stories.tsx +3 -1
- package/layout/ApplicationLayout.d.ts +1 -1
- package/layout/ApplicationLayout.js +1 -1
- package/main.d.ts +5 -2
- package/main.js +22 -1
- package/nav-tabs/NavTabs.d.ts +1 -2
- package/nav-tabs/NavTabs.js +9 -6
- package/nav-tabs/NavTabs.stories.tsx +6 -4
- package/nav-tabs/NavTabs.test.js +3 -2
- package/nav-tabs/NavTabsContext.d.ts +3 -0
- package/nav-tabs/NavTabsContext.js +8 -0
- package/nav-tabs/Tab.js +8 -7
- package/number-input/NumberInput.d.ts +0 -7
- package/number-input/NumberInput.js +24 -5
- package/number-input/NumberInput.test.js +165 -6
- package/number-input/NumberInputContext.d.ts +3 -0
- package/number-input/NumberInputContext.js +8 -0
- package/number-input/types.d.ts +6 -0
- package/package.json +2 -2
- package/radio-group/RadioGroup.js +1 -1
- package/resultset-table/ResultsetTable.d.ts +4 -1
- package/resultset-table/ResultsetTable.js +13 -6
- package/resultset-table/ResultsetTable.stories.tsx +102 -5
- package/resultset-table/ResultsetTable.test.js +66 -0
- package/resultset-table/types.d.ts +6 -0
- package/select/Option.js +8 -1
- package/select/Select.js +33 -23
- package/select/types.d.ts +2 -2
- package/sidenav/Sidenav.js +3 -2
- package/slider/Slider.js +5 -6
- package/status-light/StatusLight.d.ts +4 -0
- package/status-light/StatusLight.js +51 -0
- package/status-light/StatusLight.stories.tsx +74 -0
- package/status-light/StatusLight.test.js +25 -0
- package/status-light/types.d.ts +17 -0
- package/status-light/types.js +5 -0
- package/table/DropdownTheme.js +62 -0
- package/table/Table.d.ts +6 -2
- package/table/Table.js +82 -8
- package/table/Table.stories.tsx +304 -2
- package/table/Table.test.js +92 -0
- package/table/types.d.ts +42 -0
- package/tabs/Tab.js +7 -4
- package/tabs/Tabs.js +4 -5
- package/tabs/Tabs.stories.tsx +1 -1
- package/text-input/TextInput.js +58 -71
- package/text-input/TextInput.test.js +96 -79
- package/useTheme.d.ts +29 -15
- package/utils/FocusLock.js +3 -0
- package/wizard/types.d.ts +1 -1
- package/common/OpenSans.css +0 -69
- package/common/fonts/OpenSans-Bold.ttf +0 -0
- package/common/fonts/OpenSans-BoldItalic.ttf +0 -0
- package/common/fonts/OpenSans-ExtraBold.ttf +0 -0
- package/common/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
- package/common/fonts/OpenSans-Italic.ttf +0 -0
- package/common/fonts/OpenSans-Light.ttf +0 -0
- package/common/fonts/OpenSans-LightItalic.ttf +0 -0
- package/common/fonts/OpenSans-Regular.ttf +0 -0
- package/common/fonts/OpenSans-SemiBold.ttf +0 -0
- package/common/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
- /package/{layout → sidenav}/SidenavContext.d.ts +0 -0
- /package/{layout → sidenav}/SidenavContext.js +0 -0
package/common/variables.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export declare const componentTokens: {
|
|
|
36
36
|
disabledIconColor: string;
|
|
37
37
|
iconSize: string;
|
|
38
38
|
iconMarginLeft: string;
|
|
39
|
-
|
|
39
|
+
iconMarginRight: string;
|
|
40
40
|
accordionGroupSeparatorBorderColor: string;
|
|
41
41
|
accordionGroupSeparatorBorderThickness: string;
|
|
42
42
|
accordionGroupSeparatorBorderRadius: string;
|
|
@@ -282,8 +282,14 @@ export declare const componentTokens: {
|
|
|
282
282
|
buttonPaddingBottom: string;
|
|
283
283
|
buttonPaddingLeft: string;
|
|
284
284
|
buttonPaddingRight: string;
|
|
285
|
+
buttonHeight: string;
|
|
286
|
+
buttonBorderRadius: string;
|
|
287
|
+
buttonBorderStyle: string;
|
|
288
|
+
buttonBorderThickness: string;
|
|
289
|
+
buttonBorderColor: string;
|
|
285
290
|
disabledColor: string;
|
|
286
291
|
disabledButtonBackgroundColor: string;
|
|
292
|
+
disabledButtonBorderColor: string;
|
|
287
293
|
disabledBorderColor: string;
|
|
288
294
|
optionBackgroundColor: string;
|
|
289
295
|
hoverOptionBackgroundColor: string;
|
|
@@ -846,8 +852,16 @@ export declare const componentTokens: {
|
|
|
846
852
|
dataPaddingBottom: string;
|
|
847
853
|
dataPaddingRight: string;
|
|
848
854
|
dataPaddingLeft: string;
|
|
855
|
+
dataPaddingTopReduced: string;
|
|
856
|
+
dataPaddingBottomReduced: string;
|
|
857
|
+
dataPaddingRightReduced: string;
|
|
858
|
+
dataPaddingLeftReduced: string;
|
|
849
859
|
dataTextAlign: string;
|
|
850
860
|
dataTextLineHeight: string;
|
|
861
|
+
firstChildPaddingLeft: string;
|
|
862
|
+
lastChildPaddingRight: string;
|
|
863
|
+
firstChildPaddingLeftReduced: string;
|
|
864
|
+
lastChildPaddingRightReduced: string;
|
|
851
865
|
headerBackgroundColor: string;
|
|
852
866
|
headerBorderRadius: string;
|
|
853
867
|
headerFontFamily: string;
|
|
@@ -860,11 +874,25 @@ export declare const componentTokens: {
|
|
|
860
874
|
headerPaddingBottom: string;
|
|
861
875
|
headerPaddingRight: string;
|
|
862
876
|
headerPaddingLeft: string;
|
|
877
|
+
headerPaddingTopReduced: string;
|
|
878
|
+
headerPaddingBottomReduced: string;
|
|
879
|
+
headerPaddingRightReduced: string;
|
|
880
|
+
headerPaddingLeftReduced: string;
|
|
863
881
|
headerTextAlign: string;
|
|
864
882
|
headerTextLineHeight: string;
|
|
865
883
|
scrollBarThumbColor: string;
|
|
866
884
|
scrollBarTrackColor: string;
|
|
867
885
|
sortIconColor: string;
|
|
886
|
+
actionIconColor: string;
|
|
887
|
+
disabledActionIconColor: string;
|
|
888
|
+
hoverActionIconColor: string;
|
|
889
|
+
focusActionIconColor: string;
|
|
890
|
+
activeActionIconColor: string;
|
|
891
|
+
actionBackgroundColor: string;
|
|
892
|
+
disabledActionBackgroundColor: string;
|
|
893
|
+
hoverActionBackgroundColor: string;
|
|
894
|
+
focusActionBorderColor: string;
|
|
895
|
+
activeActionBackgroundColor: string;
|
|
868
896
|
};
|
|
869
897
|
tabs: {
|
|
870
898
|
fontFamily: string;
|
|
@@ -883,7 +911,6 @@ export declare const componentTokens: {
|
|
|
883
911
|
disabledFontColor: string;
|
|
884
912
|
disabledIconColor: string;
|
|
885
913
|
disabledFontStyle: string;
|
|
886
|
-
disabledBadgeBackgroundColor: string;
|
|
887
914
|
hoverBackgroundColor: string;
|
|
888
915
|
pressedBackgroundColor: string;
|
|
889
916
|
pressedFontWeight: string;
|
|
@@ -891,19 +918,6 @@ export declare const componentTokens: {
|
|
|
891
918
|
dividerThickness: string;
|
|
892
919
|
focusOutline: string;
|
|
893
920
|
scrollButtonsWidth: string;
|
|
894
|
-
badgeBackgroundColor: string;
|
|
895
|
-
badgeFontFamily: string;
|
|
896
|
-
badgeFontSize: string;
|
|
897
|
-
badgeFontStyle: string;
|
|
898
|
-
badgeFontWeight: string;
|
|
899
|
-
badgeFontColor: string;
|
|
900
|
-
badgeLetterSpacing: string;
|
|
901
|
-
badgeWidth: string;
|
|
902
|
-
badgeHeight: string;
|
|
903
|
-
badgeRadius: string;
|
|
904
|
-
badgeWidthWithNotificationNumber: string;
|
|
905
|
-
badgeHeightWithNotificationNumber: string;
|
|
906
|
-
badgeRadiusWithNotificationNumber: string;
|
|
907
921
|
};
|
|
908
922
|
tag: {
|
|
909
923
|
fontFamily: string;
|
package/common/variables.js
CHANGED
|
@@ -44,7 +44,7 @@ var componentTokens = exports.componentTokens = {
|
|
|
44
44
|
disabledIconColor: _coreTokens["default"].color_grey_500,
|
|
45
45
|
iconSize: "24px",
|
|
46
46
|
iconMarginLeft: "0px",
|
|
47
|
-
|
|
47
|
+
iconMarginRight: "12px",
|
|
48
48
|
accordionGroupSeparatorBorderColor: _coreTokens["default"].color_grey_200_a,
|
|
49
49
|
accordionGroupSeparatorBorderThickness: "1px",
|
|
50
50
|
accordionGroupSeparatorBorderRadius: "0px",
|
|
@@ -290,8 +290,14 @@ var componentTokens = exports.componentTokens = {
|
|
|
290
290
|
buttonPaddingBottom: "0px",
|
|
291
291
|
buttonPaddingLeft: "16px",
|
|
292
292
|
buttonPaddingRight: "16px",
|
|
293
|
+
buttonHeight: "40px",
|
|
294
|
+
buttonBorderRadius: "4px",
|
|
295
|
+
buttonBorderStyle: _coreTokens["default"].border_none,
|
|
296
|
+
buttonBorderThickness: _coreTokens["default"].border_width_0,
|
|
297
|
+
buttonBorderColor: _coreTokens["default"].color_transparent,
|
|
293
298
|
disabledColor: _coreTokens["default"].color_grey_500,
|
|
294
299
|
disabledButtonBackgroundColor: _coreTokens["default"].color_transparent,
|
|
300
|
+
disabledButtonBorderColor: _coreTokens["default"].color_transparent,
|
|
295
301
|
disabledBorderColor: _coreTokens["default"].color_transparent,
|
|
296
302
|
optionBackgroundColor: _coreTokens["default"].color_white,
|
|
297
303
|
hoverOptionBackgroundColor: _coreTokens["default"].color_grey_100,
|
|
@@ -850,12 +856,20 @@ var componentTokens = exports.componentTokens = {
|
|
|
850
856
|
dataFontWeight: _coreTokens["default"].type_regular,
|
|
851
857
|
dataFontColor: _coreTokens["default"].color_black,
|
|
852
858
|
dataFontTextTransform: "none",
|
|
853
|
-
dataPaddingTop: "
|
|
854
|
-
dataPaddingBottom: "
|
|
859
|
+
dataPaddingTop: "16px",
|
|
860
|
+
dataPaddingBottom: "16px",
|
|
855
861
|
dataPaddingRight: "20px",
|
|
856
|
-
dataPaddingLeft: "
|
|
862
|
+
dataPaddingLeft: "20px",
|
|
863
|
+
dataPaddingTopReduced: _coreTokens["default"].spacing_8,
|
|
864
|
+
dataPaddingBottomReduced: _coreTokens["default"].spacing_8,
|
|
865
|
+
dataPaddingRightReduced: _coreTokens["default"].spacing_16,
|
|
866
|
+
dataPaddingLeftReduced: _coreTokens["default"].spacing_16,
|
|
857
867
|
dataTextAlign: "left",
|
|
858
868
|
dataTextLineHeight: "normal",
|
|
869
|
+
firstChildPaddingLeft: _coreTokens["default"].spacing_24,
|
|
870
|
+
lastChildPaddingRight: _coreTokens["default"].spacing_24,
|
|
871
|
+
firstChildPaddingLeftReduced: "20px",
|
|
872
|
+
lastChildPaddingRightReduced: "20px",
|
|
859
873
|
headerBackgroundColor: _coreTokens["default"].color_purple_700,
|
|
860
874
|
headerBorderRadius: "4px",
|
|
861
875
|
headerFontFamily: _coreTokens["default"].type_sans,
|
|
@@ -867,12 +881,26 @@ var componentTokens = exports.componentTokens = {
|
|
|
867
881
|
headerPaddingTop: "16px",
|
|
868
882
|
headerPaddingBottom: "16px",
|
|
869
883
|
headerPaddingRight: "20px",
|
|
870
|
-
headerPaddingLeft: "
|
|
884
|
+
headerPaddingLeft: "20px",
|
|
885
|
+
headerPaddingTopReduced: _coreTokens["default"].spacing_8,
|
|
886
|
+
headerPaddingBottomReduced: _coreTokens["default"].spacing_8,
|
|
887
|
+
headerPaddingRightReduced: _coreTokens["default"].spacing_16,
|
|
888
|
+
headerPaddingLeftReduced: _coreTokens["default"].spacing_16,
|
|
871
889
|
headerTextAlign: "left",
|
|
872
890
|
headerTextLineHeight: "normal",
|
|
873
891
|
scrollBarThumbColor: _coreTokens["default"].color_grey_700,
|
|
874
892
|
scrollBarTrackColor: _coreTokens["default"].color_grey_300,
|
|
875
|
-
sortIconColor: _coreTokens["default"].color_white
|
|
893
|
+
sortIconColor: _coreTokens["default"].color_white,
|
|
894
|
+
actionIconColor: _coreTokens["default"].color_purple_700,
|
|
895
|
+
disabledActionIconColor: _coreTokens["default"].color_grey_500,
|
|
896
|
+
hoverActionIconColor: _coreTokens["default"].color_purple_700,
|
|
897
|
+
focusActionIconColor: _coreTokens["default"].color_purple_700,
|
|
898
|
+
activeActionIconColor: _coreTokens["default"].color_purple_700,
|
|
899
|
+
actionBackgroundColor: _coreTokens["default"].color_transparent,
|
|
900
|
+
disabledActionBackgroundColor: _coreTokens["default"].color_transparent,
|
|
901
|
+
hoverActionBackgroundColor: _coreTokens["default"].color_grey_100,
|
|
902
|
+
focusActionBorderColor: _coreTokens["default"].color_blue_600,
|
|
903
|
+
activeActionBackgroundColor: _coreTokens["default"].color_grey_300
|
|
876
904
|
},
|
|
877
905
|
tabs: {
|
|
878
906
|
fontFamily: _coreTokens["default"].type_sans,
|
|
@@ -891,27 +919,13 @@ var componentTokens = exports.componentTokens = {
|
|
|
891
919
|
disabledFontColor: _coreTokens["default"].color_grey_500,
|
|
892
920
|
disabledIconColor: _coreTokens["default"].color_grey_500,
|
|
893
921
|
disabledFontStyle: _coreTokens["default"].type_normal,
|
|
894
|
-
disabledBadgeBackgroundColor: "#0000004d",
|
|
895
922
|
hoverBackgroundColor: _coreTokens["default"].color_purple_100,
|
|
896
923
|
pressedBackgroundColor: _coreTokens["default"].color_purple_200,
|
|
897
924
|
pressedFontWeight: _coreTokens["default"].type_semibold,
|
|
898
925
|
dividerColor: _coreTokens["default"].color_grey_400,
|
|
899
926
|
dividerThickness: "1px",
|
|
900
927
|
focusOutline: _coreTokens["default"].color_purple_700,
|
|
901
|
-
scrollButtonsWidth: "48px"
|
|
902
|
-
badgeBackgroundColor: _coreTokens["default"].color_red_700,
|
|
903
|
-
badgeFontFamily: _coreTokens["default"].type_sans,
|
|
904
|
-
badgeFontSize: "10px",
|
|
905
|
-
badgeFontStyle: _coreTokens["default"].type_normal,
|
|
906
|
-
badgeFontWeight: "500",
|
|
907
|
-
badgeFontColor: _coreTokens["default"].color_white,
|
|
908
|
-
badgeLetterSpacing: _coreTokens["default"].type_spacing_wide_02,
|
|
909
|
-
badgeWidth: "16px",
|
|
910
|
-
badgeHeight: "16px",
|
|
911
|
-
badgeRadius: "10px",
|
|
912
|
-
badgeWidthWithNotificationNumber: "23px",
|
|
913
|
-
badgeHeightWithNotificationNumber: "17px",
|
|
914
|
-
badgeRadiusWithNotificationNumber: "10px"
|
|
928
|
+
scrollButtonsWidth: "48px"
|
|
915
929
|
},
|
|
916
930
|
tag: {
|
|
917
931
|
fontFamily: _coreTokens["default"].type_sans,
|
|
@@ -1026,7 +1040,7 @@ var componentTokens = exports.componentTokens = {
|
|
|
1026
1040
|
errorListDialogBackgroundColor: _coreTokens["default"].color_red_50,
|
|
1027
1041
|
errorListDialogBorderColor: _coreTokens["default"].color_red_700,
|
|
1028
1042
|
hoverListOptionBackgroundColor: _coreTokens["default"].color_grey_100,
|
|
1029
|
-
activeListOptionBackgroundColor: _coreTokens["default"].
|
|
1043
|
+
activeListOptionBackgroundColor: _coreTokens["default"].color_grey_200,
|
|
1030
1044
|
focusListOptionBorderColor: _coreTokens["default"].color_blue_600
|
|
1031
1045
|
},
|
|
1032
1046
|
toggleGroup: {
|
package/container/Container.js
CHANGED
|
@@ -44,7 +44,7 @@ var getBorderStyles = function getBorderStyles(direction, borderProperties) {
|
|
|
44
44
|
var _borderProperties$wid, _borderProperties$sty, _getCoreColorToken;
|
|
45
45
|
return "border-".concat(direction, ": ").concat((_borderProperties$wid = borderProperties === null || borderProperties === void 0 ? void 0 : borderProperties.width) !== null && _borderProperties$wid !== void 0 ? _borderProperties$wid : "", " ").concat((_borderProperties$sty = borderProperties === null || borderProperties === void 0 ? void 0 : borderProperties.style) !== null && _borderProperties$sty !== void 0 ? _borderProperties$sty : "", " ").concat((_getCoreColorToken = (0, _coreTokens.getCoreColorToken)(borderProperties === null || borderProperties === void 0 ? void 0 : borderProperties.color)) !== null && _getCoreColorToken !== void 0 ? _getCoreColorToken : "", ";");
|
|
46
46
|
};
|
|
47
|
-
var Container = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: ", ";\n display: ", ";\n width: ", ";\n height: ", ";\n max-width: ", ";\n max-height: ", ";\n min-width: ", ";\n min-height: ", ";\n position: ", ";\n top: ", ";\n right: ", ";\n bottom: ", ";\n left: ", ";\n float: ", ";\n z-index: ", ";\n box-shadow: ", ";\n\n background-attachment: ", ";\n background-clip: ", ";\n background-color: ", ";\n background-image: ", ";\n background-origin: ", ";\n background-position: ", ";\n background-repeat: ", ";\n background-size: ", ";\n\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n border-
|
|
47
|
+
var Container = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: ", ";\n display: ", ";\n width: ", ";\n height: ", ";\n max-width: ", ";\n max-height: ", ";\n min-width: ", ";\n min-height: ", ";\n position: ", ";\n top: ", ";\n right: ", ";\n bottom: ", ";\n left: ", ";\n float: ", ";\n z-index: ", ";\n box-shadow: ", ";\n\n background-attachment: ", ";\n background-clip: ", ";\n background-color: ", ";\n background-image: ", ";\n background-origin: ", ";\n background-position: ", ";\n background-repeat: ", ";\n background-size: ", ";\n\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n border-color: ", ";\n\n ", ";\n\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n outline: ", ";\n outline-offset: ", ";\n\n overflow: ", ";\n overflow-x: ", ";\n overflow-y: ", ";\n\n padding: ", ";\n padding-top: ", ";\n padding-right: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n"])), function (_ref2) {
|
|
48
48
|
var boxSizing = _ref2.boxSizing;
|
|
49
49
|
return boxSizing;
|
|
50
50
|
}, function (_ref3) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import MenuPropsType, { BadgeProps as BadgePropsType } from "./types";
|
|
3
|
+
declare const DxcContextualMenu: {
|
|
4
|
+
({ items, defaultSelectedItemIndex }: MenuPropsType): React.JSX.Element;
|
|
5
|
+
Badge(props: BadgePropsType): React.JSX.Element;
|
|
6
|
+
};
|
|
7
|
+
export default DxcContextualMenu;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
14
|
+
var _coreTokens = _interopRequireDefault(require("../common/coreTokens"));
|
|
15
|
+
var _Badge = _interopRequireDefault(require("../badge/Badge"));
|
|
16
|
+
var _MenuItemAction = _interopRequireDefault(require("./MenuItemAction"));
|
|
17
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
18
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
19
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
20
|
+
var DxcContextualMenu = function DxcContextualMenu(_ref) {
|
|
21
|
+
var items = _ref.items,
|
|
22
|
+
_ref$defaultSelectedI = _ref.defaultSelectedItemIndex,
|
|
23
|
+
defaultSelectedItemIndex = _ref$defaultSelectedI === void 0 ? -1 : _ref$defaultSelectedI;
|
|
24
|
+
var _useState = (0, _react.useState)(defaultSelectedItemIndex),
|
|
25
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
26
|
+
selectedItemIndex = _useState2[0],
|
|
27
|
+
setSelectedItemIndex = _useState2[1];
|
|
28
|
+
var renderSingleItem = function renderSingleItem(item, index) {
|
|
29
|
+
return /*#__PURE__*/_react["default"].createElement(Li, {
|
|
30
|
+
key: "option-".concat(index),
|
|
31
|
+
role: "menuitem"
|
|
32
|
+
}, /*#__PURE__*/_react["default"].createElement(_MenuItemAction["default"], (0, _extends2["default"])({}, item, {
|
|
33
|
+
selected: selectedItemIndex === index,
|
|
34
|
+
onSelect: function onSelect() {
|
|
35
|
+
var _item$onSelect;
|
|
36
|
+
setSelectedItemIndex(index);
|
|
37
|
+
(_item$onSelect = item.onSelect) === null || _item$onSelect === void 0 ? void 0 : _item$onSelect.call(item);
|
|
38
|
+
}
|
|
39
|
+
})));
|
|
40
|
+
};
|
|
41
|
+
var accLength = 0;
|
|
42
|
+
var renderSection = function renderSection(section, currentSectionIndex, items) {
|
|
43
|
+
var startingIndex = accLength;
|
|
44
|
+
accLength += section.items.length;
|
|
45
|
+
return /*#__PURE__*/_react["default"].createElement(_react.Fragment, {
|
|
46
|
+
key: "separator-".concat(currentSectionIndex)
|
|
47
|
+
}, /*#__PURE__*/_react["default"].createElement(Li, {
|
|
48
|
+
role: "group"
|
|
49
|
+
}, section.title != null && /*#__PURE__*/_react["default"].createElement(Title, null, section.title), /*#__PURE__*/_react["default"].createElement(Section, null, section.items.map(function (item, index) {
|
|
50
|
+
return renderSingleItem(item, startingIndex + index);
|
|
51
|
+
}))), currentSectionIndex !== items.length - 1 && /*#__PURE__*/_react["default"].createElement(Divider, {
|
|
52
|
+
"aria-hidden": true
|
|
53
|
+
}));
|
|
54
|
+
};
|
|
55
|
+
return /*#__PURE__*/_react["default"].createElement(Menu, {
|
|
56
|
+
role: "menu"
|
|
57
|
+
}, items.map(function (item, index, items) {
|
|
58
|
+
return "items" in item ? renderSection(item, index, items) : renderSingleItem(item, index);
|
|
59
|
+
}));
|
|
60
|
+
};
|
|
61
|
+
var Menu = _styledComponents["default"].ul(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n margin: 0;\n border: 1px solid ", ";\n border-radius: 0.25rem;\n padding: ", " ", ";\n\n display: grid;\n gap: ", ";\n min-width: 248px;\n max-height: 100%;\n background-color: ", ";\n\n overflow-y: auto;\n &::-webkit-scrollbar {\n width: 8px;\n height: 8px;\n }\n &::-webkit-scrollbar-thumb {\n background-color: ", ";\n border-radius: 0.25rem;\n }\n &::-webkit-scrollbar-track {\n background-color: ", ";\n border-radius: 0.25rem;\n }\n"])), _coreTokens["default"].color_grey_200, _coreTokens["default"].spacing_16, _coreTokens["default"].spacing_8, _coreTokens["default"].spacing_4, _coreTokens["default"].color_white, _coreTokens["default"].color_grey_700, _coreTokens["default"].color_grey_300);
|
|
62
|
+
var Li = _styledComponents["default"].li(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: grid;\n"])));
|
|
63
|
+
var Section = _styledComponents["default"].ul(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n list-style: none;\n margin: 0;\n padding: 0;\n display: grid;\n gap: ", ";\n"])), _coreTokens["default"].spacing_4);
|
|
64
|
+
var Title = _styledComponents["default"].h2(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n margin: 0 0 ", " 0;\n padding: ", ";\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n line-height: 24px;\n\n & + ul > li > button {\n padding-left: ", " !important;\n }\n"])), _coreTokens["default"].spacing_4, _coreTokens["default"].spacing_4, _coreTokens["default"].color_grey_900, _coreTokens["default"].type_sans, _coreTokens["default"].type_scale_03, _coreTokens["default"].type_semibold, _coreTokens["default"].spacing_12);
|
|
65
|
+
var Divider = _styledComponents["default"].hr(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n margin: ", " 0;\n border: none;\n height: 1px;\n background: ", ";\n"])), _coreTokens["default"].spacing_4, _coreTokens["default"].color_grey_200);
|
|
66
|
+
DxcContextualMenu.Badge = function (props) {
|
|
67
|
+
return /*#__PURE__*/_react["default"].createElement(_Badge["default"], (0, _extends2["default"])({}, props, {
|
|
68
|
+
size: "small"
|
|
69
|
+
}));
|
|
70
|
+
};
|
|
71
|
+
var _default = exports["default"] = DxcContextualMenu;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Title from "../../.storybook/components/Title";
|
|
3
|
+
import DxcContextualMenu from "./ContextualMenu";
|
|
4
|
+
import DxcContainer from "../container/Container";
|
|
5
|
+
import MenuItemAction from "./MenuItemAction";
|
|
6
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: "Contextual Menu",
|
|
10
|
+
component: DxcContextualMenu,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const key_icon = (
|
|
14
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24" fill="currentColor">
|
|
15
|
+
<path d="M280-400q-33 0-56.5-23.5T200-480q0-33 23.5-56.5T280-560q33 0 56.5 23.5T360-480q0 33-23.5 56.5T280-400Zm0 160q-100 0-170-70T40-480q0-100 70-170t170-70q67 0 121.5 33t86.5 87h352l120 120-180 180-80-60-80 60-85-60h-47q-32 54-86.5 87T280-240Zm0-80q56 0 98.5-34t56.5-86h125l58 41 82-61 71 55 75-75-40-40H435q-14-52-56.5-86T280-640q-66 0-113 47t-47 113q0 66 47 113t113 47Z" />
|
|
16
|
+
</svg>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const fav_icon = (
|
|
20
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24" fill="currentColor">
|
|
21
|
+
<path d="m480-120-58-52q-101-91-167-157T150-447.5Q111-500 95.5-544T80-634q0-94 63-157t157-63q52 0 99 22t81 62q34-40 81-62t99-22q94 0 157 63t63 157q0 46-15.5 90T810-447.5Q771-395 705-329T538-172l-58 52Zm0-108q96-86 158-147.5t98-107q36-45.5 50-81t14-70.5q0-60-40-100t-100-40q-47 0-87 26.5T518-680h-76q-15-41-55-67.5T300-774q-60 0-100 40t-40 100q0 35 14 70.5t50 81q36 45.5 98 107T480-228Zm0-273Z" />
|
|
22
|
+
</svg>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const items = [{ label: "Item 1" }, { label: "Item 2" }, { label: "Item 3" }, { label: "Item 4" }];
|
|
26
|
+
|
|
27
|
+
const sections = [
|
|
28
|
+
{
|
|
29
|
+
title: "Team repositories",
|
|
30
|
+
items: [{ label: "Approved locations" }, { label: "Approved locations" }, { label: "Approved locations" }],
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
items: [{ label: "Approved locations" }, { label: "Approved locations" }, { label: "Approved locations" }],
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
const itemsWithIcon = [
|
|
38
|
+
{
|
|
39
|
+
label: "Item 1",
|
|
40
|
+
icon: key_icon,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
label: "Item 2",
|
|
44
|
+
icon: fav_icon,
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
const itemsWithSlot = [
|
|
49
|
+
{
|
|
50
|
+
label: "Item 1",
|
|
51
|
+
slot: <DxcContextualMenu.Badge color="green" label="New" />,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
label: "Item 2",
|
|
55
|
+
slot: (
|
|
56
|
+
<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
|
|
57
|
+
<path
|
|
58
|
+
d="M10.6667 10.6667H1.33333V1.33333H6V0H1.33333C0.593333 0 0 0.6 0 1.33333V10.6667C0 11.4 0.593333 12 1.33333 12H10.6667C11.4 12 12 11.4 12 10.6667V6H10.6667V10.6667ZM7.33333 0V1.33333H9.72667L3.17333 7.88667L4.11333 8.82667L10.6667 2.27333V4.66667H12V0H7.33333Z"
|
|
59
|
+
fill="#323232"
|
|
60
|
+
/>
|
|
61
|
+
</svg>
|
|
62
|
+
),
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
const sectionsWithScroll = [
|
|
67
|
+
{
|
|
68
|
+
title: "Team repositories",
|
|
69
|
+
items: [{ label: "Approved locations" }, { label: "Approved locations" }, { label: "Approved locations" }],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
items: [
|
|
73
|
+
{ label: "Approved locations" },
|
|
74
|
+
{ label: "Approved locations" },
|
|
75
|
+
{ label: "Approved locations" },
|
|
76
|
+
{ label: "Approved locations" },
|
|
77
|
+
{ label: "Approved locations" },
|
|
78
|
+
{ label: "Approved locations" },
|
|
79
|
+
{ label: "Approved locations" },
|
|
80
|
+
{ label: "Approved locations" },
|
|
81
|
+
{ label: "Approved locations" },
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
const itemsWithTruncatedText = [
|
|
87
|
+
{
|
|
88
|
+
label: "Item with a very long label that should be truncated",
|
|
89
|
+
slot: <DxcContextualMenu.Badge color="green" label="New" />,
|
|
90
|
+
icon: key_icon,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
label: "Item 2",
|
|
94
|
+
slot: (
|
|
95
|
+
<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
|
|
96
|
+
<path
|
|
97
|
+
d="M10.6667 10.6667H1.33333V1.33333H6V0H1.33333C0.593333 0 0 0.6 0 1.33333V10.6667C0 11.4 0.593333 12 1.33333 12H10.6667C11.4 12 12 11.4 12 10.6667V6H10.6667V10.6667ZM7.33333 0V1.33333H9.72667L3.17333 7.88667L4.11333 8.82667L10.6667 2.27333V4.66667H12V0H7.33333Z"
|
|
98
|
+
fill="#323232"
|
|
99
|
+
/>
|
|
100
|
+
</svg>
|
|
101
|
+
),
|
|
102
|
+
icon: fav_icon,
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
export const Chromatic = () => (
|
|
107
|
+
<>
|
|
108
|
+
<Title title="Default" theme="light" level={3} />
|
|
109
|
+
<ExampleContainer>
|
|
110
|
+
<DxcContextualMenu items={items} />
|
|
111
|
+
</ExampleContainer>
|
|
112
|
+
<Title title="With sections" theme="light" level={3} />
|
|
113
|
+
<ExampleContainer>
|
|
114
|
+
<DxcContainer width="300px">
|
|
115
|
+
<DxcContextualMenu items={sections} />
|
|
116
|
+
</DxcContainer>
|
|
117
|
+
</ExampleContainer>
|
|
118
|
+
<Title title="With icons" theme="light" level={3} />
|
|
119
|
+
<ExampleContainer>
|
|
120
|
+
<DxcContainer width="300px">
|
|
121
|
+
<DxcContextualMenu items={itemsWithIcon} defaultSelectedItemIndex={0} />
|
|
122
|
+
</DxcContainer>
|
|
123
|
+
</ExampleContainer>
|
|
124
|
+
<Title title="With slot" theme="light" level={3} />
|
|
125
|
+
<ExampleContainer>
|
|
126
|
+
<DxcContainer width="300px">
|
|
127
|
+
<DxcContextualMenu items={itemsWithSlot} />
|
|
128
|
+
</DxcContainer>
|
|
129
|
+
</ExampleContainer>
|
|
130
|
+
<Title title="With label truncated" theme="light" level={3} />
|
|
131
|
+
<ExampleContainer>
|
|
132
|
+
<DxcContainer width="300px">
|
|
133
|
+
<DxcContextualMenu items={itemsWithTruncatedText} />
|
|
134
|
+
</DxcContainer>
|
|
135
|
+
</ExampleContainer>
|
|
136
|
+
<Title title="With scroll" theme="light" level={3} />
|
|
137
|
+
<ExampleContainer>
|
|
138
|
+
<DxcContainer height="300px" width="300px">
|
|
139
|
+
<DxcContextualMenu items={sectionsWithScroll} />
|
|
140
|
+
</DxcContainer>
|
|
141
|
+
</ExampleContainer>
|
|
142
|
+
<Title title="Width doesn't go below 248px" theme="light" level={3} />
|
|
143
|
+
<ExampleContainer>
|
|
144
|
+
<DxcContainer width="200px">
|
|
145
|
+
<DxcContextualMenu items={items} />
|
|
146
|
+
</DxcContainer>
|
|
147
|
+
</ExampleContainer>
|
|
148
|
+
</>
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
export const MenuItemStates = () => (
|
|
152
|
+
<>
|
|
153
|
+
<Title title="Default" theme="light" level={3} />
|
|
154
|
+
<ExampleContainer>
|
|
155
|
+
<MenuItemAction {...items[0]} selected={false} />
|
|
156
|
+
</ExampleContainer>
|
|
157
|
+
<Title title="Focus" theme="light" level={3} />
|
|
158
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
159
|
+
<MenuItemAction {...items[0]} selected={false} />
|
|
160
|
+
</ExampleContainer>
|
|
161
|
+
<Title title="Hover" theme="light" level={3} />
|
|
162
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
163
|
+
<MenuItemAction {...items[0]} selected={false} />
|
|
164
|
+
</ExampleContainer>
|
|
165
|
+
<Title title="Active" theme="light" level={3} />
|
|
166
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
167
|
+
<MenuItemAction {...items[0]} selected={false} />
|
|
168
|
+
</ExampleContainer>
|
|
169
|
+
<Title title="Selected" theme="light" level={3} />
|
|
170
|
+
<ExampleContainer>
|
|
171
|
+
<MenuItemAction {...items[0]} selected />
|
|
172
|
+
</ExampleContainer>
|
|
173
|
+
<Title title="Selected hover" theme="light" level={3} />
|
|
174
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
175
|
+
<MenuItemAction {...items[0]} selected />
|
|
176
|
+
</ExampleContainer>
|
|
177
|
+
<Title title="Selected active" theme="light" level={3} />
|
|
178
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
179
|
+
<MenuItemAction {...items[0]} selected />
|
|
180
|
+
</ExampleContainer>
|
|
181
|
+
</>
|
|
182
|
+
);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _react = _interopRequireDefault(require("react"));
|
|
5
|
+
var _react2 = require("@testing-library/react");
|
|
6
|
+
var _ContextualMenu = _interopRequireDefault(require("./ContextualMenu.tsx"));
|
|
7
|
+
var items = [{
|
|
8
|
+
label: "Item 1"
|
|
9
|
+
}, {
|
|
10
|
+
label: "Item 2"
|
|
11
|
+
}, {
|
|
12
|
+
label: "Item 3"
|
|
13
|
+
}, {
|
|
14
|
+
label: "Item 4"
|
|
15
|
+
}];
|
|
16
|
+
var sections = [{
|
|
17
|
+
title: "Team repositories",
|
|
18
|
+
items: [{
|
|
19
|
+
label: "Approved locations"
|
|
20
|
+
}, {
|
|
21
|
+
label: "Approved locations"
|
|
22
|
+
}, {
|
|
23
|
+
label: "Approved locations"
|
|
24
|
+
}]
|
|
25
|
+
}, {
|
|
26
|
+
items: [{
|
|
27
|
+
label: "Approved locations"
|
|
28
|
+
}, {
|
|
29
|
+
label: "Approved locations"
|
|
30
|
+
}, {
|
|
31
|
+
label: "Approved locations"
|
|
32
|
+
}]
|
|
33
|
+
}];
|
|
34
|
+
describe("Context menu component tests", function () {
|
|
35
|
+
test("Context menu renders with correct aria attributes", function () {
|
|
36
|
+
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ContextualMenu["default"], {
|
|
37
|
+
items: items,
|
|
38
|
+
defaultSelectedItemIndex: 0
|
|
39
|
+
})),
|
|
40
|
+
getAllByRole = _render.getAllByRole,
|
|
41
|
+
getByRole = _render.getByRole;
|
|
42
|
+
expect(getAllByRole("menuitem").length).toBe(4);
|
|
43
|
+
var actions = getAllByRole("button");
|
|
44
|
+
expect(actions[0].getAttribute("aria-selected")).toBeTruthy();
|
|
45
|
+
expect(getByRole("menu")).toBeTruthy();
|
|
46
|
+
});
|
|
47
|
+
test("Context menu (with sections) renders with correct aria attributes", function () {
|
|
48
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ContextualMenu["default"], {
|
|
49
|
+
items: sections,
|
|
50
|
+
defaultSelectedItemIndex: 4
|
|
51
|
+
})),
|
|
52
|
+
getAllByRole = _render2.getAllByRole;
|
|
53
|
+
expect(getAllByRole("menuitem").length).toBe(6);
|
|
54
|
+
var actions = getAllByRole("button");
|
|
55
|
+
expect(actions[4].getAttribute("aria-selected")).toBeTruthy();
|
|
56
|
+
expect(getAllByRole("group").length).toBe(2);
|
|
57
|
+
});
|
|
58
|
+
test("onSelect event from each item is called correctly", function () {
|
|
59
|
+
var test = [{
|
|
60
|
+
label: "Tested item",
|
|
61
|
+
onSelect: jest.fn()
|
|
62
|
+
}];
|
|
63
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ContextualMenu["default"], {
|
|
64
|
+
items: test
|
|
65
|
+
})),
|
|
66
|
+
getByRole = _render3.getByRole;
|
|
67
|
+
var item = getByRole("button");
|
|
68
|
+
_react2.fireEvent.click(item);
|
|
69
|
+
expect(test[0].onSelect).toHaveBeenCalled();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
+
var _coreTokens = _interopRequireDefault(require("../common/coreTokens"));
|
|
12
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
13
|
+
var MenuItemAction = function MenuItemAction(_ref) {
|
|
14
|
+
var label = _ref.label,
|
|
15
|
+
icon = _ref.icon,
|
|
16
|
+
slot = _ref.slot,
|
|
17
|
+
selected = _ref.selected,
|
|
18
|
+
onSelect = _ref.onSelect;
|
|
19
|
+
return /*#__PURE__*/_react["default"].createElement(Action, {
|
|
20
|
+
"aria-selected": selected,
|
|
21
|
+
selected: selected,
|
|
22
|
+
onClick: function onClick() {
|
|
23
|
+
return onSelect();
|
|
24
|
+
}
|
|
25
|
+
}, /*#__PURE__*/_react["default"].createElement(Label, null, icon && /*#__PURE__*/_react["default"].createElement(Icon, {
|
|
26
|
+
"aria-hidden": true
|
|
27
|
+
}, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
28
|
+
src: icon
|
|
29
|
+
}) : icon), /*#__PURE__*/_react["default"].createElement(Text, {
|
|
30
|
+
onMouseEnter: function onMouseEnter(event) {
|
|
31
|
+
var text = event.currentTarget;
|
|
32
|
+
if (text.title === "" && text.scrollWidth > text.clientWidth) text.title = label;
|
|
33
|
+
}
|
|
34
|
+
}, label)), slot);
|
|
35
|
+
};
|
|
36
|
+
var Action = _styledComponents["default"].button(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n border: none;\n border-radius: 4px;\n padding: ", " ", ";\n box-shadow: inset 0 0 0 2px transparent;\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: ", ";\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n line-height: 24px;\n ", ";\n cursor: pointer;\n overflow: hidden;\n\n &:hover {\n ", ";\n }\n &:active {\n ", ";\n }\n &:focus {\n outline: 2px solid ", ";\n outline-offset: -1px;\n }\n"])), _coreTokens["default"].spacing_4, _coreTokens["default"].spacing_8, _coreTokens["default"].spacing_16, _coreTokens["default"].color_grey_900, _coreTokens["default"].type_sans, _coreTokens["default"].type_scale_02, function (props) {
|
|
37
|
+
return props.selected ? "background-color: ".concat(_coreTokens["default"].color_purple_100, "; font-weight: ").concat(_coreTokens["default"].type_semibold, ";") : "background-color: ".concat(_coreTokens["default"].color_transparent);
|
|
38
|
+
}, function (props) {
|
|
39
|
+
return props.selected ? "background-color: ".concat(_coreTokens["default"].color_purple_200, ";") : "background-color: ".concat(_coreTokens["default"].color_grey_100, ";");
|
|
40
|
+
}, function (props) {
|
|
41
|
+
return props.selected ? "background-color: ".concat(_coreTokens["default"].color_purple_200, ";") : "background-color: ".concat(_coreTokens["default"].color_grey_100, ";");
|
|
42
|
+
}, _coreTokens["default"].color_blue_600);
|
|
43
|
+
var Label = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n gap: ", ";\n overflow: hidden;\n"])), _coreTokens["default"].spacing_8);
|
|
44
|
+
var Text = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n"])));
|
|
45
|
+
var Icon = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n height: 16px;\n"])));
|
|
46
|
+
var _default = exports["default"] = /*#__PURE__*/_react["default"].memo(MenuItemAction);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { NotificationProps, CommonProps, ContextualProps } from "../badge/types";
|
|
3
|
+
type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
4
|
+
export type Item = {
|
|
5
|
+
label: string;
|
|
6
|
+
icon?: string | SVG;
|
|
7
|
+
slot?: React.ReactNode;
|
|
8
|
+
onSelect?: () => void;
|
|
9
|
+
};
|
|
10
|
+
export type Section = {
|
|
11
|
+
title?: string;
|
|
12
|
+
items: Item[];
|
|
13
|
+
};
|
|
14
|
+
type Props = {
|
|
15
|
+
defaultSelectedItemIndex?: number;
|
|
16
|
+
items: Item[] | Section[];
|
|
17
|
+
};
|
|
18
|
+
export type MenuItemActionProps = Item & {
|
|
19
|
+
selected: boolean;
|
|
20
|
+
};
|
|
21
|
+
export type BadgeProps = (ContextualProps | NotificationProps) & Omit<CommonProps, "size">;
|
|
22
|
+
export default Props;
|
package/date-input/types.d.ts
CHANGED
|
@@ -127,11 +127,11 @@ export type CalendarPropsType = {
|
|
|
127
127
|
*/
|
|
128
128
|
selectedDate: Dayjs;
|
|
129
129
|
/**
|
|
130
|
-
* Date
|
|
130
|
+
* Date shown by the calendar.
|
|
131
131
|
*/
|
|
132
132
|
innerDate: Dayjs;
|
|
133
133
|
/**
|
|
134
|
-
* Function called when the
|
|
134
|
+
* Function called when the shown date needs to be updated.
|
|
135
135
|
*/
|
|
136
136
|
onInnerDateChange: (date: Dayjs) => void;
|
|
137
137
|
/**
|