@itcase/ui 1.8.122 → 1.8.124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Avatar_cjs_mojzcWRL.js +161 -0
- package/dist/Avatar_es_BFom0nAS.js +157 -0
- package/dist/{Button_cjs_i0Dn1pkl.js → Button_cjs_CZz8OjWi.js} +42 -30
- package/dist/{Button_es_CtH5EKJd.js → Button_es_Cn3wtv3M.js} +42 -30
- package/dist/ChipsGroup_cjs_Dgskkc1e.js +344 -0
- package/dist/{ChipsGroup_es_ayPPUwQ7.js → ChipsGroup_es_BVQ7_n0k.js} +48 -35
- package/dist/DatePicker_cjs_Lzrr9Amf.js +182 -0
- package/dist/DatePicker_es_D1LvY5RT.js +178 -0
- package/dist/Divider_cjs_DrmV2ezS.js +105 -0
- package/dist/Divider_es_BiYozVBS.js +101 -0
- package/dist/DropdownItem_cjs_rKLdFxSj.js +211 -0
- package/dist/DropdownItem_es_B-1qtEa7.js +206 -0
- package/dist/Group_cjs_DmfeUcFI.js +59 -0
- package/dist/Group_es_BU5k8f5S.js +55 -0
- package/dist/{Icon_cjs_Cz6IyOkb.js → Icon_cjs_DpFxIFv5.js} +170 -121
- package/dist/{Icon_es_BrwLifge.js → Icon_es_D5eiycFI.js} +170 -121
- package/dist/Image_cjs_CBDMUzv_.js +29 -0
- package/dist/Image_es_BHec4iVN.js +27 -0
- package/dist/{Input_cjs_Du73R-wm.js → Input_cjs_DDi5JVAV.js} +27 -19
- package/dist/{Input_es_CiDHjDqJ.js → Input_es_BnCXATnh.js} +27 -19
- package/dist/{Label_cjs_DMoaOoHi.js → Label_cjs_C-x9blCL.js} +45 -33
- package/dist/{Label_es_SULlg9bL.js → Label_es_DCqpSw_F.js} +45 -33
- package/dist/{Link_cjs_C5UsZUiF.js → Link_cjs_qKXVfU8e.js} +43 -30
- package/dist/{Link_es_XiqbdwLp.js → Link_es_P2b6ya7P.js} +43 -30
- package/dist/Loader_cjs_DIDsIq3J.js +143 -0
- package/dist/Loader_es_CmSggwbR.js +139 -0
- package/dist/Overlay_cjs_tGA2fU43.js +42 -0
- package/dist/Overlay_es_BS7OTFoy.js +38 -0
- package/dist/{Scrollbar_cjs_DcKOfcNp.js → Scrollbar_cjs_Cp-7v2Mt.js} +1 -1
- package/dist/{Scrollbar_es_CThJeCLF.js → Scrollbar_es_CcMgNvGi.js} +1 -1
- package/dist/Text_cjs_BDTjOTVB.js +69 -0
- package/dist/Text_es_CnymlElo.js +65 -0
- package/dist/cjs/components/Accordion.js +37 -34
- package/dist/cjs/components/Avatar.js +5 -6
- package/dist/cjs/components/AvatarStack/stories/__mock__.js +1 -1
- package/dist/cjs/components/AvatarStack.js +17 -16
- package/dist/cjs/components/Badge.js +3 -4
- package/dist/cjs/components/Breadcrumbs/stories/__mock__.js +1 -1
- package/dist/cjs/components/Breadcrumbs.js +27 -23
- package/dist/cjs/components/Button.js +5 -6
- package/dist/cjs/components/Cell/stories/__mock__.js +1 -1
- package/dist/cjs/components/Cell.js +28 -25
- package/dist/cjs/components/Checkbox.js +33 -26
- package/dist/cjs/components/Checkmark.js +28 -23
- package/dist/cjs/components/Chips/stories/__mock__.js +1 -1
- package/dist/cjs/components/Chips.js +4 -5
- package/dist/cjs/components/Choice/stories/__mock__.js +2 -2
- package/dist/cjs/components/Choice.js +46 -40
- package/dist/cjs/components/Code.js +34 -26
- package/dist/cjs/components/CookiesWarning.js +23 -23
- package/dist/cjs/components/Dadata.js +14 -9
- package/dist/cjs/components/DatePeriod.js +32 -30
- package/dist/cjs/components/DatePicker.js +8 -9
- package/dist/cjs/components/Divider.js +1 -2
- package/dist/cjs/components/Dot.js +5 -6
- package/dist/cjs/components/Drawer.js +23 -21
- package/dist/cjs/components/Dropdown/stories/__mock__.js +6 -6
- package/dist/cjs/components/Dropdown.js +5 -6
- package/dist/cjs/components/Flex.js +11 -12
- package/dist/cjs/components/Grid.js +15 -16
- package/dist/cjs/components/Group.js +1 -2
- package/dist/cjs/components/HTMLContent.js +5 -6
- package/dist/cjs/components/HeroTitle.js +17 -16
- package/dist/cjs/components/Icon.js +3 -4
- package/dist/cjs/components/Image.js +1 -2
- package/dist/cjs/components/Input.js +1 -2
- package/dist/cjs/components/InputPassword.js +114 -84
- package/dist/cjs/components/Label.js +4 -5
- package/dist/cjs/components/Link.js +1 -2
- package/dist/cjs/components/List.js +39 -28
- package/dist/cjs/components/Loader.js +2 -3
- package/dist/cjs/components/Logo.js +10 -11
- package/dist/cjs/components/MenuItem.js +36 -33
- package/dist/cjs/components/Modal.js +40 -38
- package/dist/cjs/components/ModalSheetBottom.js +17 -18
- package/dist/cjs/components/Notification/stories/__mock__.js +1 -1
- package/dist/cjs/components/Notification.js +31 -24
- package/dist/cjs/components/Overlay.js +1 -2
- package/dist/cjs/components/Pagination.js +43 -41
- package/dist/cjs/components/Radio.js +34 -26
- package/dist/cjs/components/RangeSlider.js +8 -9
- package/dist/cjs/components/Response/img.js +1 -1
- package/dist/cjs/components/Response.js +102 -84
- package/dist/cjs/components/SVGContent.js +6 -7
- package/dist/cjs/components/ScrollOnDrag/stories/__mock__.js +2 -2
- package/dist/cjs/components/ScrollOnDrag.js +7 -8
- package/dist/cjs/components/ScrollToView.js +8 -9
- package/dist/cjs/components/Scrollbar/stories/__mock__.js +1 -1
- package/dist/cjs/components/Scrollbar.js +1 -1
- package/dist/cjs/components/Search.js +39 -31
- package/dist/cjs/components/Segmented/stories/__mock__.js +23 -10
- package/dist/cjs/components/Segmented.js +47 -42
- package/dist/cjs/components/Select.js +118 -113
- package/dist/cjs/components/Swiper/stories/__mock__.js +3 -3
- package/dist/cjs/components/Swiper.js +27 -29
- package/dist/cjs/components/Switch.js +33 -26
- package/dist/cjs/components/Tab/stories/__mock__.js +1 -1
- package/dist/cjs/components/Tab.js +59 -69
- package/dist/cjs/components/Text.js +1 -2
- package/dist/cjs/components/Textarea.js +26 -18
- package/dist/cjs/components/Tile.js +21 -17
- package/dist/cjs/components/Title.js +3 -4
- package/dist/cjs/components/Tooltip.js +3 -4
- package/dist/cjs/components/Video/stories/__mocks__.js +1 -1
- package/dist/cjs/components/Video.js +3 -4
- package/dist/cjs/components/Warning.js +26 -20
- package/dist/cjs/context/Notifications.js +38 -42
- package/dist/cjs/context/UIContext.js +19 -17
- package/dist/cjs/context/UrlAssetPrefix.js +3 -3
- package/dist/cjs/hoc/urlWithAssetPrefix.js +13 -16
- package/dist/cjs/hooks/useActiveClasses/useActiveClasses.helpers.js +13 -40
- package/dist/cjs/hooks/useActiveClasses/useActiveClasses.interface.js +1 -1
- package/dist/cjs/hooks/useActiveClasses/useActiveClasses.js +25 -29
- package/dist/cjs/hooks/useAppearanceConfig/useAppearanceConfig.js +13 -15
- package/dist/cjs/hooks/useAppearanceConfig.js +0 -1
- package/dist/cjs/hooks/useDevicePropsGenerator/useDevicePropsGenerator.js +21 -28
- package/dist/cjs/hooks/useDevicePropsGenerator.js +0 -1
- package/dist/cjs/hooks/useDeviceTargetClass.js +0 -1
- package/dist/cjs/hooks/useStyles/styleAttributes.js +1 -1
- package/dist/cjs/hooks/useStyles/useStyles.js +0 -1
- package/dist/cjs/hooks/useStyles.js +0 -1
- package/dist/cjs/hooks/useViewportFix.js +5 -5
- package/dist/cjs/hooks.js +1 -1
- package/dist/cjs/utils/setViewportProperty.js +3 -3
- package/dist/components/Accordion.js +37 -34
- package/dist/components/Avatar.js +5 -6
- package/dist/components/AvatarStack/stories/__mock__.js +1 -1
- package/dist/components/AvatarStack.js +17 -16
- package/dist/components/Badge.js +3 -4
- package/dist/components/Breadcrumbs/stories/__mock__.js +1 -1
- package/dist/components/Breadcrumbs.js +27 -23
- package/dist/components/Button.js +5 -6
- package/dist/components/Cell/stories/__mock__.js +1 -1
- package/dist/components/Cell.js +28 -25
- package/dist/components/Checkbox.js +33 -26
- package/dist/components/Checkmark.js +28 -23
- package/dist/components/Chips/stories/__mock__.js +1 -1
- package/dist/components/Chips.js +4 -5
- package/dist/components/Choice/stories/__mock__.js +2 -2
- package/dist/components/Choice.js +46 -40
- package/dist/components/Code.js +34 -26
- package/dist/components/CookiesWarning.js +23 -23
- package/dist/components/Dadata.js +14 -9
- package/dist/components/DatePeriod.js +32 -30
- package/dist/components/DatePicker.js +8 -9
- package/dist/components/Divider.js +1 -2
- package/dist/components/Dot.js +5 -6
- package/dist/components/Drawer.js +23 -21
- package/dist/components/Dropdown/stories/__mock__.js +6 -6
- package/dist/components/Dropdown.js +5 -6
- package/dist/components/Flex.js +11 -12
- package/dist/components/Grid.js +15 -16
- package/dist/components/Group.js +1 -2
- package/dist/components/HTMLContent.js +5 -6
- package/dist/components/HeroTitle.js +17 -16
- package/dist/components/Icon.js +3 -4
- package/dist/components/Image.js +1 -2
- package/dist/components/Input.js +1 -2
- package/dist/components/InputPassword.js +114 -84
- package/dist/components/Label.js +4 -5
- package/dist/components/Link.js +1 -2
- package/dist/components/List.js +39 -28
- package/dist/components/Loader.js +2 -3
- package/dist/components/Logo.js +10 -11
- package/dist/components/MenuItem.js +36 -33
- package/dist/components/Modal.js +40 -38
- package/dist/components/ModalSheetBottom.js +17 -18
- package/dist/components/Notification/stories/__mock__.js +1 -1
- package/dist/components/Notification.js +31 -24
- package/dist/components/Overlay.js +1 -2
- package/dist/components/Pagination.js +43 -41
- package/dist/components/Radio.js +34 -26
- package/dist/components/RangeSlider.js +8 -9
- package/dist/components/Response/img.js +1 -1
- package/dist/components/Response.js +102 -84
- package/dist/components/SVGContent.js +6 -7
- package/dist/components/ScrollOnDrag/stories/__mock__.js +2 -2
- package/dist/components/ScrollOnDrag.js +7 -8
- package/dist/components/ScrollToView.js +8 -9
- package/dist/components/Scrollbar/stories/__mock__.js +1 -1
- package/dist/components/Scrollbar.js +1 -1
- package/dist/components/Search.js +39 -31
- package/dist/components/Segmented/stories/__mock__.js +23 -10
- package/dist/components/Segmented.js +47 -42
- package/dist/components/Select.js +118 -113
- package/dist/components/Swiper/stories/__mock__.js +3 -3
- package/dist/components/Swiper.js +27 -29
- package/dist/components/Switch.js +33 -26
- package/dist/components/Tab/stories/__mock__.js +1 -1
- package/dist/components/Tab.js +59 -69
- package/dist/components/Text.js +1 -2
- package/dist/components/Textarea.js +26 -18
- package/dist/components/Tile.js +21 -17
- package/dist/components/Title.js +3 -4
- package/dist/components/Tooltip.js +3 -4
- package/dist/components/Video/stories/__mocks__.js +1 -1
- package/dist/components/Video.js +3 -4
- package/dist/components/Warning.js +26 -20
- package/dist/context/Notifications.js +38 -42
- package/dist/context/UIContext.js +19 -17
- package/dist/context/UrlAssetPrefix.js +3 -3
- package/dist/css/components/Checkmark/Checkmark.css +2 -0
- package/dist/css/components/DatePeriod/DatePeriod.css +3 -0
- package/dist/css/components/Input/Input.css +0 -8
- package/dist/css/components/InputPassword/InputPassword.css +34 -43
- package/dist/css/components/Tile/Tile.css +3 -3
- package/dist/hoc/urlWithAssetPrefix.js +13 -16
- package/dist/hooks/useActiveClasses/useActiveClasses.helpers.js +13 -40
- package/dist/hooks/useActiveClasses/useActiveClasses.interface.js +1 -1
- package/dist/hooks/useActiveClasses/useActiveClasses.js +25 -29
- package/dist/hooks/useAppearanceConfig/useAppearanceConfig.js +13 -15
- package/dist/hooks/useAppearanceConfig.js +0 -1
- package/dist/hooks/useDevicePropsGenerator/useDevicePropsGenerator.js +21 -28
- package/dist/hooks/useDevicePropsGenerator.js +0 -1
- package/dist/hooks/useDeviceTargetClass.js +0 -1
- package/dist/hooks/useStyles/styleAttributes.js +1 -1
- package/dist/hooks/useStyles/useStyles.js +0 -1
- package/dist/hooks/useStyles.js +0 -1
- package/dist/hooks/useViewportFix.js +5 -5
- package/dist/hooks.js +1 -1
- package/dist/types/components/InputPassword/InputPassword.appearance.d.ts +179 -2
- package/dist/types/components/InputPassword/appearance/inputPasswordDefault.d.ts +7 -4
- package/dist/types/components/InputPassword/appearance/inputPasswordDisabled.d.ts +6 -4
- package/dist/types/components/InputPassword/appearance/inputPasswordError.d.ts +6 -4
- package/dist/types/components/InputPassword/appearance/inputPasswordRequire.d.ts +6 -4
- package/dist/types/components/InputPassword/appearance/inputPasswordShape.d.ts +25 -0
- package/dist/types/components/InputPassword/appearance/inputPasswordSize.d.ts +14 -28
- package/dist/types/components/InputPassword/appearance/inputPasswordStyle.d.ts +5 -5
- package/dist/types/components/InputPassword/appearance/inputPasswordSuccess.d.ts +6 -4
- package/dist/types/components/Response/Response.constant.d.ts +32 -35
- package/dist/types/components/Response/appearance/responseConfirm.d.ts +1 -0
- package/dist/types/components/Response/appearance/responseDanger.d.ts +1 -0
- package/dist/types/components/Response/appearance/responseEmpty.d.ts +1 -0
- package/dist/types/components/Response/appearance/responseError.d.ts +1 -0
- package/dist/types/components/Response/appearance/responseFail.d.ts +1 -0
- package/dist/types/components/Response/appearance/responseNothingFound.d.ts +1 -0
- package/dist/types/components/Response/appearance/responseRefresh.d.ts +1 -0
- package/dist/types/components/Response/appearance/responseSuccess.d.ts +1 -0
- package/dist/types/components/Response/appearance/responseUnableLoadData.d.ts +1 -0
- package/dist/types/components/Response/appearance/responseWarning.d.ts +1 -0
- package/dist/types/components/Select/SelectContainer.d.ts +1 -1
- package/dist/types/components/Tab/appearance/tabSize.d.ts +0 -14
- package/dist/types/components/Tab/appearance/tabSurface.d.ts +7 -7
- package/dist/utils/setViewportProperty.js +3 -3
- package/package.json +14 -14
- package/dist/Avatar_cjs_kuE0Rueg.js +0 -157
- package/dist/Avatar_es_lx7s4Vla.js +0 -153
- package/dist/ChipsGroup_cjs_C8L3ZeD_.js +0 -331
- package/dist/DatePicker_cjs_DsIAoi01.js +0 -183
- package/dist/DatePicker_es_BP5BrEr-.js +0 -179
- package/dist/Divider_cjs_DUYtmwn2.js +0 -97
- package/dist/Divider_es_CCLBFIx6.js +0 -93
- package/dist/DropdownItem_cjs_Bhss6lyM.js +0 -207
- package/dist/DropdownItem_es_BXl6lPJx.js +0 -202
- package/dist/Group_cjs_CsJ6ICKK.js +0 -59
- package/dist/Group_es_DRqIIM9m.js +0 -55
- package/dist/Image_cjs_B6YlGx8G.js +0 -28
- package/dist/Image_es_BvYo_cHH.js +0 -26
- package/dist/Loader_cjs_D3lnxPlI.js +0 -132
- package/dist/Loader_es_BUSqFrCd.js +0 -128
- package/dist/Overlay_cjs_CcfJYN5o.js +0 -41
- package/dist/Overlay_es_DF3DAdxS.js +0 -37
- package/dist/Text_cjs_0EINiUq4.js +0 -68
- package/dist/Text_es_CwV9rjFD.js +0 -64
- package/dist/tslib.es6_cjs_CCZ3TN_7.js +0 -59
- package/dist/tslib.es6_es_Bwu1Cn-t.js +0 -56
|
@@ -1,84 +1,57 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const CLASS_RULES = {
|
|
4
4
|
fill: [
|
|
5
5
|
{
|
|
6
6
|
key: 'fillClass',
|
|
7
|
-
stateFn:
|
|
8
|
-
var isDisabled = _a.isDisabled, isActive = _a.isActive;
|
|
9
|
-
return !isActive && !isDisabled;
|
|
10
|
-
},
|
|
7
|
+
stateFn: ({ isDisabled, isActive }) => !isActive && !isDisabled,
|
|
11
8
|
},
|
|
12
9
|
{
|
|
13
10
|
key: 'fillHoverClass',
|
|
14
|
-
stateFn:
|
|
15
|
-
var isDisabled = _a.isDisabled, isActive = _a.isActive;
|
|
16
|
-
return !isActive && !isDisabled;
|
|
17
|
-
},
|
|
11
|
+
stateFn: ({ isDisabled, isActive }) => !isActive && !isDisabled,
|
|
18
12
|
},
|
|
19
13
|
{
|
|
20
14
|
key: 'fillActiveClass',
|
|
21
|
-
stateFn:
|
|
22
|
-
var isDisabled = _a.isDisabled, isActive = _a.isActive;
|
|
23
|
-
return Boolean(isActive) && !isDisabled;
|
|
24
|
-
},
|
|
15
|
+
stateFn: ({ isDisabled, isActive }) => Boolean(isActive) && !isDisabled,
|
|
25
16
|
},
|
|
26
17
|
{
|
|
27
18
|
key: 'fillActiveHoverClass',
|
|
28
|
-
stateFn:
|
|
29
|
-
var isDisabled = _a.isDisabled, isActive = _a.isActive;
|
|
30
|
-
return Boolean(isActive) && !isDisabled;
|
|
31
|
-
},
|
|
19
|
+
stateFn: ({ isDisabled, isActive }) => Boolean(isActive) && !isDisabled,
|
|
32
20
|
},
|
|
33
21
|
{
|
|
34
22
|
key: 'fillDisabledClass',
|
|
35
|
-
stateFn:
|
|
36
|
-
var isDisabled = _a.isDisabled, isActive = _a.isActive;
|
|
37
|
-
return !isActive && Boolean(isDisabled);
|
|
38
|
-
},
|
|
23
|
+
stateFn: ({ isDisabled, isActive }) => !isActive && Boolean(isDisabled),
|
|
39
24
|
},
|
|
40
25
|
],
|
|
41
26
|
borderColor: [
|
|
42
27
|
{
|
|
43
28
|
key: 'borderColorClass',
|
|
44
|
-
stateFn:
|
|
45
|
-
var isDisabled = _a.isDisabled, isActive = _a.isActive;
|
|
46
|
-
return !isActive && !isDisabled;
|
|
47
|
-
},
|
|
29
|
+
stateFn: ({ isDisabled, isActive }) => !isActive && !isDisabled,
|
|
48
30
|
},
|
|
49
31
|
{
|
|
50
32
|
key: 'borderColorHoverClass',
|
|
51
|
-
stateFn:
|
|
52
|
-
var isDisabled = _a.isDisabled, isActive = _a.isActive;
|
|
53
|
-
return !isActive && !isDisabled;
|
|
54
|
-
},
|
|
33
|
+
stateFn: ({ isDisabled, isActive }) => !isActive && !isDisabled,
|
|
55
34
|
},
|
|
56
35
|
{
|
|
57
36
|
key: 'borderColorActiveClass',
|
|
58
|
-
stateFn:
|
|
59
|
-
var isDisabled = _a.isDisabled, isActive = _a.isActive;
|
|
60
|
-
return Boolean(isActive) && !isDisabled;
|
|
61
|
-
},
|
|
37
|
+
stateFn: ({ isDisabled, isActive }) => Boolean(isActive) && !isDisabled,
|
|
62
38
|
},
|
|
63
39
|
],
|
|
64
40
|
textColor: [
|
|
65
41
|
{
|
|
66
42
|
key: 'textColorClass',
|
|
67
|
-
stateFn:
|
|
68
|
-
var isDisabled = _a.isDisabled, isActive = _a.isActive;
|
|
69
|
-
return !isActive && !isDisabled;
|
|
70
|
-
},
|
|
43
|
+
stateFn: ({ isDisabled, isActive }) => !isActive && !isDisabled,
|
|
71
44
|
},
|
|
72
45
|
],
|
|
73
46
|
};
|
|
74
|
-
|
|
47
|
+
const formatState = (key) => {
|
|
75
48
|
// Try to find one of the state tokens in the input key:
|
|
76
49
|
// - matches "ActiveHover", "Active", "Hover" or "Disabled"
|
|
77
50
|
// - case-insensitive because of the /i flag
|
|
78
51
|
// Examples of matches:
|
|
79
52
|
// "fillActiveHoverColor" -> match[0] === "ActiveHover"
|
|
80
53
|
// "borderDisabled" -> match[0] === "Disabled"
|
|
81
|
-
|
|
54
|
+
const stateMatch = key.match(/(ActiveHover|Active|Hover|Disabled)/i);
|
|
82
55
|
if (!stateMatch) {
|
|
83
56
|
return '';
|
|
84
57
|
}
|
|
@@ -111,7 +84,7 @@ var formatState = function (key) {
|
|
|
111
84
|
// Examples:
|
|
112
85
|
// "myTestString" -> "my-test-string"
|
|
113
86
|
// "borderColorActiveHover" -> "border-color-active-hover"
|
|
114
|
-
|
|
87
|
+
const toKebabCase = (str) => {
|
|
115
88
|
return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
116
89
|
};
|
|
117
90
|
|
|
@@ -3,61 +3,57 @@
|
|
|
3
3
|
var clsx = require('clsx');
|
|
4
4
|
var useActiveClasses_helpers = require('./useActiveClasses.helpers.js');
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Object.entries(useActiveClasses_helpers.CLASS_RULES).forEach(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var key = _a.key, stateFn = _a.stateFn;
|
|
14
|
-
var value = propsGenerator[key];
|
|
6
|
+
const useActiveClasses = (params) => {
|
|
7
|
+
const { isDisabled, propsGenerator, suffixes = [], isActive } = params;
|
|
8
|
+
const rootClassesArray = [];
|
|
9
|
+
Object.entries(useActiveClasses_helpers.CLASS_RULES).forEach(([rulesName, rules]) => {
|
|
10
|
+
const kebabRuleName = useActiveClasses_helpers.toKebabCase(rulesName);
|
|
11
|
+
rules.forEach(({ key, stateFn }) => {
|
|
12
|
+
const value = propsGenerator[key];
|
|
15
13
|
if (!value) {
|
|
16
14
|
return;
|
|
17
15
|
}
|
|
18
16
|
if (stateFn) {
|
|
19
|
-
|
|
17
|
+
const active = stateFn({ isDisabled, isActive });
|
|
20
18
|
if (!active) {
|
|
21
19
|
return;
|
|
22
20
|
}
|
|
23
21
|
}
|
|
24
|
-
|
|
25
|
-
rootClassesArray.push(
|
|
22
|
+
const stateName = useActiveClasses_helpers.formatState(key);
|
|
23
|
+
rootClassesArray.push(`${kebabRuleName}${stateName}_${value}`);
|
|
26
24
|
});
|
|
27
25
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
Object.entries(useActiveClasses_helpers.CLASS_RULES).forEach(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var propKey = rulesName + suffix + withoutPrefixRulesName;
|
|
37
|
-
var value = propsGenerator[propKey];
|
|
26
|
+
const rootClasses = clsx(rootClassesArray);
|
|
27
|
+
const suffixClasses = suffixes.reduce((acc, suffix) => {
|
|
28
|
+
const classes = [];
|
|
29
|
+
Object.entries(useActiveClasses_helpers.CLASS_RULES).forEach(([rulesName, rules]) => {
|
|
30
|
+
rules.forEach(({ key, stateFn }) => {
|
|
31
|
+
const withoutPrefixRulesName = key.replace(rulesName, '');
|
|
32
|
+
const propKey = rulesName + suffix + withoutPrefixRulesName;
|
|
33
|
+
const value = propsGenerator[propKey];
|
|
38
34
|
if (!value) {
|
|
39
35
|
return;
|
|
40
36
|
}
|
|
41
37
|
if (stateFn) {
|
|
42
|
-
|
|
38
|
+
const active = stateFn({ isDisabled, isActive });
|
|
43
39
|
if (!active) {
|
|
44
40
|
return;
|
|
45
41
|
}
|
|
46
42
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
classes.push(
|
|
43
|
+
const state = useActiveClasses_helpers.formatState(propKey);
|
|
44
|
+
const kebabName = useActiveClasses_helpers.toKebabCase(rulesName);
|
|
45
|
+
classes.push(`${kebabName}${state}_${value}`);
|
|
50
46
|
});
|
|
51
47
|
});
|
|
52
|
-
|
|
48
|
+
const suffixKey = suffix === 'HTMLContent'
|
|
53
49
|
? 'htmlContent'
|
|
54
50
|
: (suffix[0].toLowerCase() + suffix.slice(1));
|
|
55
51
|
acc[suffixKey] = clsx(classes);
|
|
56
52
|
return acc;
|
|
57
53
|
}, {});
|
|
58
54
|
return {
|
|
59
|
-
rootClasses
|
|
60
|
-
suffixClasses
|
|
55
|
+
rootClasses,
|
|
56
|
+
suffixClasses,
|
|
61
57
|
};
|
|
62
58
|
};
|
|
63
59
|
|
|
@@ -1,30 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var tslib_es6 = require('../../../tslib.es6_cjs_CCZ3TN_7.js');
|
|
4
3
|
var React = require('react');
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _a, _b, _c, _d, _e, _f;
|
|
5
|
+
const useAppearanceConfig = (appearance, componentConfig, isDisabled) => {
|
|
6
|
+
const appearanceConfig = React.useMemo(() => {
|
|
9
7
|
if (appearance) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}, {});
|
|
8
|
+
const appearanceProps = appearance.split(' ').reduce((resultConfig, appearanceKey) => ({
|
|
9
|
+
...resultConfig,
|
|
10
|
+
...componentConfig.appearance?.[appearanceKey],
|
|
11
|
+
}), {});
|
|
14
12
|
if (isDisabled &&
|
|
15
|
-
(
|
|
16
|
-
|
|
17
|
-
Object.assign(appearanceProps,
|
|
18
|
-
|
|
13
|
+
(componentConfig?.appearance?.disabled ||
|
|
14
|
+
componentConfig?.appearance?.disabledPrimary)) {
|
|
15
|
+
Object.assign(appearanceProps, componentConfig?.appearance?.disabled ||
|
|
16
|
+
componentConfig?.appearance?.disabledPrimary);
|
|
19
17
|
}
|
|
20
18
|
return appearanceProps;
|
|
21
19
|
}
|
|
22
20
|
if (isDisabled) {
|
|
23
|
-
return (
|
|
24
|
-
|
|
21
|
+
return (componentConfig?.appearance?.disabled ||
|
|
22
|
+
componentConfig?.appearance?.disabledPrimary);
|
|
25
23
|
}
|
|
26
24
|
return {};
|
|
27
|
-
}, [appearance, componentConfig
|
|
25
|
+
}, [appearance, componentConfig?.appearance, isDisabled]);
|
|
28
26
|
return appearanceConfig;
|
|
29
27
|
};
|
|
30
28
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var tslib_es6 = require('../../../tslib.es6_cjs_CCZ3TN_7.js');
|
|
4
3
|
var React = require('react');
|
|
5
4
|
var camelCase = require('lodash/camelCase');
|
|
6
5
|
var castArray = require('lodash/castArray');
|
|
@@ -50,17 +49,17 @@ function useDevicePropsGenerator(componentProps, appearanceConfig) {
|
|
|
50
49
|
* - titleTextSizeDesktop
|
|
51
50
|
* ---------
|
|
52
51
|
**/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
getProp
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
const { deviceCurrentMainType } = UIContext.useUserDeviceContext();
|
|
53
|
+
const devicePropsGenerator = React.useMemo(() => {
|
|
54
|
+
const propsGenerator = {
|
|
55
|
+
getProp(propKey) {
|
|
56
|
+
const propsForDeviceKey = `${propKey}${upperFirst(deviceCurrentMainType)}`;
|
|
57
|
+
const valueForDevice = componentProps[propsForDeviceKey];
|
|
58
|
+
const valueDefault = componentProps[propKey];
|
|
59
|
+
const appearanceForDevice = appearanceConfig?.[propsForDeviceKey];
|
|
60
|
+
const appearanceDefault = appearanceConfig?.[propKey];
|
|
62
61
|
// prettier-ignore
|
|
63
|
-
|
|
62
|
+
const targetPropsValue = (
|
|
64
63
|
// Value for device from props is first priority
|
|
65
64
|
valueForDevice ||
|
|
66
65
|
// Value without device from props is second priority
|
|
@@ -72,12 +71,10 @@ function useDevicePropsGenerator(componentProps, appearanceConfig) {
|
|
|
72
71
|
return targetPropsValue;
|
|
73
72
|
},
|
|
74
73
|
// eslint-disable-next-line perfectionist/sort-objects
|
|
75
|
-
getClassName
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return index_helpers.getStyleAttributeKey(attr);
|
|
80
|
-
});
|
|
74
|
+
getClassName(propKey, params) {
|
|
75
|
+
const { prefix = '', replace = [/([A-Z])/g, '-$1'] } = params || {};
|
|
76
|
+
const targetClassValue = this.getProp(String(propKey));
|
|
77
|
+
const styleAttributeKeys = styleAttributes.default.map((attr) => index_helpers.getStyleAttributeKey(attr));
|
|
81
78
|
if (styleAttributeKeys.includes(String(propKey)) &&
|
|
82
79
|
(typeof targetClassValue === 'number' ||
|
|
83
80
|
(typeof targetClassValue === 'string' &&
|
|
@@ -85,36 +82,32 @@ function useDevicePropsGenerator(componentProps, appearanceConfig) {
|
|
|
85
82
|
return '';
|
|
86
83
|
}
|
|
87
84
|
if (targetClassValue) {
|
|
88
|
-
|
|
85
|
+
let cleanClassValue = String(targetClassValue);
|
|
89
86
|
if (!cleanClassValue.includes('.')) {
|
|
90
87
|
cleanClassValue = camelCase(cleanClassValue);
|
|
91
88
|
}
|
|
92
89
|
if (replace) {
|
|
93
|
-
|
|
90
|
+
const replaceList = castArray(replace);
|
|
94
91
|
cleanClassValue = cleanClassValue.replace(replaceList[0],
|
|
95
92
|
// @ts-expect-error
|
|
96
93
|
replaceList[1] || '');
|
|
97
94
|
}
|
|
98
95
|
// prettier-ignore
|
|
99
|
-
return
|
|
96
|
+
return `${prefix}${cleanClassValue}`.toLowerCase();
|
|
100
97
|
}
|
|
101
98
|
// If target key not exists in props and appearance config - return empty class
|
|
102
99
|
return '';
|
|
103
100
|
},
|
|
104
101
|
};
|
|
105
|
-
|
|
106
|
-
get
|
|
107
|
-
var args = [];
|
|
108
|
-
for (var _i = 3; _i < arguments.length; _i++) {
|
|
109
|
-
args[_i - 3] = arguments[_i];
|
|
110
|
-
}
|
|
102
|
+
const generatorProxyHandler = {
|
|
103
|
+
get(target, propKey, receiver, ...args) {
|
|
111
104
|
if (typeof propKey === 'string') {
|
|
112
105
|
// If object does not have the property being retrieved
|
|
113
106
|
if (!Reflect.has(target, propKey)) {
|
|
114
107
|
// And property ended on "Class" keyword
|
|
115
108
|
if (propKey.endsWith('Class')) {
|
|
116
109
|
// prettier-ignore
|
|
117
|
-
|
|
110
|
+
const shortProp = propKey.substring(0, propKey.lastIndexOf('Class'));
|
|
118
111
|
// Return prop from props for device as formatted class name
|
|
119
112
|
return target.getClassName(shortProp);
|
|
120
113
|
}
|
|
@@ -123,7 +116,7 @@ function useDevicePropsGenerator(componentProps, appearanceConfig) {
|
|
|
123
116
|
}
|
|
124
117
|
// Return object property. Original "get".
|
|
125
118
|
// @ts-expect-error
|
|
126
|
-
return Reflect.get
|
|
119
|
+
return Reflect.get(target, propKey, receiver, ...args);
|
|
127
120
|
}
|
|
128
121
|
// In some cases, like in Chrome browser, sometime "prop" is not string.
|
|
129
122
|
// We return this object as is.
|
|
@@ -4,7 +4,6 @@ var React = require('react');
|
|
|
4
4
|
var camelCase = require('lodash/camelCase');
|
|
5
5
|
var castArray = require('lodash/castArray');
|
|
6
6
|
var UIContext = require('../context/UIContext.js');
|
|
7
|
-
require('../../tslib.es6_cjs_CCZ3TN_7.js');
|
|
8
7
|
require('react/jsx-runtime');
|
|
9
8
|
require('./useMediaQueries/useMediaQueries.js');
|
|
10
9
|
require('react-responsive');
|
|
@@ -37,7 +37,7 @@ var styleAttributes = [
|
|
|
37
37
|
/**
|
|
38
38
|
* Grid
|
|
39
39
|
*/
|
|
40
|
-
'gridTemplateColumns', 'gridArea', 'gridAutoColumns', 'gridAutoFlow', 'gridAutoRows', 'gridTemplate', 'gridTemplateAreas', 'gridTemplateRows', 'gridColumn', 'gridColumnGap', 'gridRow', 'gridRowGap',
|
|
40
|
+
'gridTemplateColumns', 'gridArea', 'gridAutoColumns', 'gridAutoFlow', 'gridAutoRows', 'gridTemplate', 'gridTemplateAreas', 'gridTemplateRows', 'gridColumn', 'gridColumnStart', 'gridColumnEnd', 'gridColumnGap', 'gridRow', 'gridRowStart', 'gridRowEnd', 'gridRowGap',
|
|
41
41
|
/**
|
|
42
42
|
* Filter
|
|
43
43
|
*/
|
|
@@ -8,7 +8,6 @@ require('../../context/Notifications.js');
|
|
|
8
8
|
var UIContext = require('../../context/UIContext.js');
|
|
9
9
|
var index_helpers = require('../../hooks.js');
|
|
10
10
|
var styleAttributes = require('./styleAttributes.js');
|
|
11
|
-
require('../../../tslib.es6_cjs_CCZ3TN_7.js');
|
|
12
11
|
require('react/jsx-runtime');
|
|
13
12
|
require('uuid');
|
|
14
13
|
require('@itcase/common');
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
|
|
5
5
|
function useViewportFix() {
|
|
6
|
-
React.useEffect(
|
|
6
|
+
React.useEffect(() => {
|
|
7
7
|
// https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
|
|
8
|
-
|
|
8
|
+
const setViewportProperty = () => {
|
|
9
9
|
// "vh" unit is equal to 1% of the height of the initial containing block
|
|
10
10
|
// https://www.w3.org/R/css-values-3/#viewport-relative-lengths
|
|
11
|
-
|
|
11
|
+
const vh = window.innerHeight * 0.01;
|
|
12
12
|
/** NOTE:
|
|
13
13
|
* In JavaScript, you can always get the value of the current viewport
|
|
14
14
|
* by using the global variable window.innerHeight. This value takes
|
|
@@ -28,13 +28,13 @@ function useViewportFix() {
|
|
|
28
28
|
* to assign as our viewport height unit value.
|
|
29
29
|
* Then we politely asked JS to create the CSS variable "--vh" at the ":root":
|
|
30
30
|
*/
|
|
31
|
-
document.documentElement.style.setProperty('--vh',
|
|
31
|
+
document.documentElement.style.setProperty('--vh', `${vh}px`);
|
|
32
32
|
};
|
|
33
33
|
// Update the value of "--vh" after render
|
|
34
34
|
setViewportProperty();
|
|
35
35
|
// Update the value of "--vh" by listening to the window resize event
|
|
36
36
|
window.addEventListener('resize', setViewportProperty);
|
|
37
|
-
return
|
|
37
|
+
return () => {
|
|
38
38
|
window.removeEventListener('resize', setViewportProperty);
|
|
39
39
|
};
|
|
40
40
|
}, []);
|
package/dist/cjs/hooks.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
document.documentElement.style.setProperty('--vh',
|
|
3
|
+
const setViewportProperty = () => {
|
|
4
|
+
const vh = window.innerHeight * 0.01;
|
|
5
|
+
document.documentElement.style.setProperty('--vh', `${vh}px`);
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
exports.setViewportProperty = setViewportProperty;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { _ as __assign, a as __spreadArray } from '../tslib.es6_es_Bwu1Cn-t.js';
|
|
2
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
2
|
import React, { useCallback, useState, useMemo } from 'react';
|
|
4
3
|
import clsx from 'clsx';
|
|
@@ -6,9 +5,9 @@ import castArray from 'lodash/castArray';
|
|
|
6
5
|
import { useDevicePropsGenerator } from '../hooks/useDevicePropsGenerator/useDevicePropsGenerator.js';
|
|
7
6
|
import { useStyles } from '../hooks/useStyles/useStyles.js';
|
|
8
7
|
import { useAppearanceConfig } from '../hooks/useAppearanceConfig/useAppearanceConfig.js';
|
|
9
|
-
import { B as Badge, I as Icon } from '../
|
|
10
|
-
import { D as Divider } from '../
|
|
11
|
-
import { T as Text } from '../
|
|
8
|
+
import { B as Badge, I as Icon } from '../Icon_es_D5eiycFI.js';
|
|
9
|
+
import { D as Divider } from '../Divider_es_BiYozVBS.js';
|
|
10
|
+
import { T as Text } from '../Text_es_CnymlElo.js';
|
|
12
11
|
import { icons16 } from '@itcase/icons/default';
|
|
13
12
|
import 'lodash/camelCase';
|
|
14
13
|
import 'lodash/upperFirst';
|
|
@@ -25,9 +24,9 @@ import 'lodash/maxBy';
|
|
|
25
24
|
import 'react-inlinesvg';
|
|
26
25
|
import '../hoc/urlWithAssetPrefix.js';
|
|
27
26
|
import '../context/UrlAssetPrefix.js';
|
|
28
|
-
import '../
|
|
27
|
+
import '../Link_es_P2b6ya7P.js';
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
const accordionAppearanceSize = {
|
|
31
30
|
sizeXXL: {
|
|
32
31
|
size: 'xxl',
|
|
33
32
|
titleTextSize: 'h3',
|
|
@@ -78,7 +77,7 @@ var accordionAppearanceSize = {
|
|
|
78
77
|
},
|
|
79
78
|
};
|
|
80
79
|
|
|
81
|
-
|
|
80
|
+
const accordionAppearanceStyle = {
|
|
82
81
|
solid: {
|
|
83
82
|
borderColor: 'none',
|
|
84
83
|
},
|
|
@@ -92,7 +91,7 @@ var accordionAppearanceStyle = {
|
|
|
92
91
|
},
|
|
93
92
|
};
|
|
94
93
|
|
|
95
|
-
|
|
94
|
+
const accordionAppearanceSurface = {
|
|
96
95
|
surfacePrimary: {
|
|
97
96
|
fill: 'surfacePrimary',
|
|
98
97
|
fillHover: 'surfacePrimaryHover',
|
|
@@ -128,19 +127,23 @@ var accordionAppearanceSurface = {
|
|
|
128
127
|
},
|
|
129
128
|
};
|
|
130
129
|
|
|
131
|
-
|
|
130
|
+
const accordionAppearance = {
|
|
131
|
+
...accordionAppearanceSize,
|
|
132
|
+
...accordionAppearanceStyle,
|
|
133
|
+
...accordionAppearanceSurface,
|
|
134
|
+
};
|
|
132
135
|
|
|
133
|
-
|
|
136
|
+
const accordionItemConfig = {
|
|
134
137
|
appearance: accordionAppearance,
|
|
135
|
-
setAppearance:
|
|
138
|
+
setAppearance: (appearanceConfig) => {
|
|
136
139
|
accordionItemConfig.appearance = appearanceConfig;
|
|
137
140
|
},
|
|
138
141
|
};
|
|
139
142
|
function AccordionItem(props) {
|
|
140
|
-
|
|
141
|
-
|
|
143
|
+
const { id, className, appearance, title, afterContent, beforeContent, content, isExpanded, onClick, children, } = props;
|
|
144
|
+
const onClickTitle = useCallback(() => {
|
|
142
145
|
// "!isExpanded" - is next state of expanded
|
|
143
|
-
|
|
146
|
+
const thisItemData = {
|
|
144
147
|
id: id,
|
|
145
148
|
title: title,
|
|
146
149
|
content: content,
|
|
@@ -148,27 +151,27 @@ function AccordionItem(props) {
|
|
|
148
151
|
};
|
|
149
152
|
onClick && onClick(thisItemData);
|
|
150
153
|
}, [id, title, content, isExpanded, onClick]);
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return (jsxs("div", { className: clsx('accordion-item', className, zeroPadding && 'accordion-item_zero-padding', zeroGap && 'accordion-item_zero-gap', borderColorClass &&
|
|
154
|
+
const appearanceConfig = useAppearanceConfig(appearance, accordionItemConfig);
|
|
155
|
+
const propsGenerator = useDevicePropsGenerator(props, appearanceConfig);
|
|
156
|
+
const { fillClass, fillHoverClass, titleBorderColorClass, titleFillClass, titleFillHoverClass, titleTextColor, titleTextSize, titleTextWeight, titleWidthClass, borderColorClass, badgeAppearance, badgeAppearanceSize, badgeShape, badgeSize, badgeTextColor, badgeTextSize, badgeValue, contentTextColor, contentTextSize, contentTextWeight, dividerDirection, dividerFill, dividerSize, icon, iconFill, iconFillIcon, iconFillSize, iconShape, iconSize, iconSrc, shapeClass, shapeStrengthClass, showDivider, sizeClass, zeroGap, zeroPadding, } = propsGenerator;
|
|
157
|
+
const { styles } = useStyles(props);
|
|
158
|
+
return (jsxs("div", { className: clsx('accordion-item', className, zeroPadding && 'accordion-item_zero-padding', zeroGap && 'accordion-item_zero-gap', borderColorClass && `border-color_${borderColorClass}`, shapeClass && `shape_${shapeClass}`, shapeStrengthClass && `shape-strength_${shapeStrengthClass}`, sizeClass && `accordion-item_size_${sizeClass}`, isExpanded && 'accordion-item_state_open'), style: styles, children: [jsxs("div", { className: clsx('accordion-item__header', fillClass && `fill_${fillClass}`, fillHoverClass && `fill_hover_${fillHoverClass}`), children: [jsx(Text, { className: clsx('accordion-item__title', titleBorderColorClass && `border-color_${titleBorderColorClass}`, titleFillClass && `fill_${titleFillClass}`, titleFillHoverClass && `fill_hover_${titleFillHoverClass}`, titleWidthClass && `width_${titleWidthClass}`, onClickTitle && 'cursor_type_pointer'), size: titleTextSize, textColor: titleTextColor, textWeight: titleTextWeight, onClick: onClickTitle, children: title }), jsxs("div", { className: "accordion-item__action", children: [badgeValue && (jsx(Badge, { className: "accordion-item__badge", appearance: `${badgeAppearance} ${badgeAppearanceSize}`, size: badgeSize, textColor: badgeTextColor, textSize: badgeTextSize, shape: badgeShape, value: badgeValue })), (icon || iconSrc) && (jsx(Icon, { className: clsx('accordion-item__icon'), fill: iconFill, fillSize: iconFillSize, iconFill: iconFillIcon, iconSize: iconSize, imageSrc: iconSrc, shape: iconShape, SvgImage: icon, onClick: onClickTitle }))] }), showDivider && (jsx(Divider, { width: "fill", direction: dividerDirection, size: dividerSize, fill: dividerFill || 'surfaceTertiary' }))] }), beforeContent, isExpanded && (jsxs("div", { className: clsx('accordion-item__content'), children: [content && (jsx("div", { className: clsx('accordion-item__content-inner', fillClass && `fill_${fillClass}`), children: jsx(Text, { size: contentTextSize, textColor: contentTextColor, textWeight: contentTextWeight, children: content }) })), children] })), afterContent] }));
|
|
156
159
|
}
|
|
157
160
|
|
|
158
161
|
function Accordion(props) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
setExpandedItems(
|
|
163
|
-
|
|
162
|
+
const { className, appearance, initial = [], items, isMultiple, onClickItem, children, } = props;
|
|
163
|
+
const [expandedItems, setExpandedItems] = useState(() => castArray(initial));
|
|
164
|
+
const onClickAccordionItem = useCallback((targetItem) => {
|
|
165
|
+
setExpandedItems((prevState) => {
|
|
166
|
+
const isExpanded = prevState.find((id) => id === targetItem.id);
|
|
164
167
|
if (isMultiple) {
|
|
165
168
|
if (isExpanded) {
|
|
166
169
|
// ... without target id
|
|
167
|
-
return prevState.filter(
|
|
170
|
+
return prevState.filter((id) => id !== targetItem.id);
|
|
168
171
|
}
|
|
169
172
|
else {
|
|
170
173
|
// ... with target id
|
|
171
|
-
return
|
|
174
|
+
return [...prevState, targetItem.id];
|
|
172
175
|
}
|
|
173
176
|
}
|
|
174
177
|
else {
|
|
@@ -182,15 +185,15 @@ function Accordion(props) {
|
|
|
182
185
|
});
|
|
183
186
|
onClickItem && onClickItem(targetItem);
|
|
184
187
|
}, [isMultiple, onClickItem]);
|
|
185
|
-
|
|
188
|
+
const accordionItemsList = useMemo(() => {
|
|
186
189
|
if (items) {
|
|
187
|
-
return items.map(
|
|
190
|
+
return items.map((item, i) => (jsx(AccordionItem, { id: item.id, appearance: appearance, title: item.title, content: item.content, isExpanded: expandedItems.includes(item.id), onClick: onClickAccordionItem }, `accordionItem_${item.id || i + 1}`)));
|
|
188
191
|
}
|
|
189
192
|
if (children) {
|
|
190
193
|
// @ts-ignore
|
|
191
|
-
return React.Children.toArray(children).map(
|
|
194
|
+
return React.Children.toArray(children).map((child) => {
|
|
192
195
|
if (React.isValidElement(child)) {
|
|
193
|
-
|
|
196
|
+
const childID = child.props.id || child.key;
|
|
194
197
|
return React.cloneElement(child, {
|
|
195
198
|
id: childID,
|
|
196
199
|
isExpanded: expandedItems.includes(childID),
|
|
@@ -202,10 +205,10 @@ function Accordion(props) {
|
|
|
202
205
|
}
|
|
203
206
|
return [];
|
|
204
207
|
}, [children, items, expandedItems, onClickAccordionItem]);
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
return (jsx("div", { className: clsx(className, 'accordion', borderColorClass &&
|
|
208
|
+
const propsGenerator = useDevicePropsGenerator(props);
|
|
209
|
+
const { fillClass, borderColorClass, shapeClass, shapeStrengthClass, widthClass, } = propsGenerator;
|
|
210
|
+
const { styles: accordionStyles } = useStyles(props);
|
|
211
|
+
return (jsx("div", { className: clsx(className, 'accordion', borderColorClass && `border-color_${borderColorClass}`, fillClass && `fill_${fillClass}`, shapeClass && `shape_${shapeClass}`, shapeStrengthClass && `shape-strength_${shapeStrengthClass}`, widthClass && `width_${widthClass}`), style: accordionStyles, children: accordionItemsList }));
|
|
209
212
|
}
|
|
210
213
|
|
|
211
214
|
export { Accordion, AccordionItem, accordionAppearance, accordionItemConfig };
|