@coorpacademy/components 11.40.6-alpha.7 → 11.40.6
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/es/atom/button-link/index.d.ts +8 -15
- package/es/atom/button-link/index.d.ts.map +1 -1
- package/es/atom/button-link/index.js +37 -75
- package/es/atom/button-link/index.js.map +1 -1
- package/es/atom/button-link/types.d.ts +14 -20
- package/es/atom/button-link/types.d.ts.map +1 -1
- package/es/atom/button-link/types.js +3 -4
- package/es/atom/button-link/types.js.map +1 -1
- package/es/atom/button-menu/index.d.ts +3 -1
- package/es/atom/button-menu/index.d.ts.map +1 -1
- package/es/atom/button-menu/index.js +7 -1
- package/es/atom/button-menu/index.js.map +1 -1
- package/es/atom/button-menu/types.d.ts +6 -2
- package/es/atom/button-menu/types.d.ts.map +1 -1
- package/es/atom/radio-with-title/index.d.ts +8 -15
- package/es/atom/radio-with-title/index.d.ts.map +1 -1
- package/es/atom/radio-with-title/types.d.ts +8 -15
- package/es/atom/radio-with-title/types.d.ts.map +1 -1
- package/es/atom/title/index.d.ts +8 -15
- package/es/molecule/bullet-point-menu-button/index.d.ts +3 -1
- package/es/molecule/bullet-point-menu-button/index.d.ts.map +1 -1
- package/es/molecule/bullet-point-menu-button/types.d.ts +3 -1
- package/es/molecule/bullet-point-menu-button/types.d.ts.map +1 -1
- package/es/molecule/button-menu-action/index.d.ts +11 -19
- package/es/molecule/button-menu-action/index.d.ts.map +1 -1
- package/es/molecule/button-menu-action/index.js +3 -27
- package/es/molecule/button-menu-action/index.js.map +1 -1
- package/es/molecule/button-menu-action/types.d.ts +12 -22
- package/es/molecule/button-menu-action/types.d.ts.map +1 -1
- package/es/molecule/button-menu-action/types.js +2 -7
- package/es/molecule/button-menu-action/types.js.map +1 -1
- package/es/molecule/cm-popin/types.d.ts +85 -133
- package/es/molecule/cm-popin/types.d.ts.map +1 -1
- package/es/molecule/expandible-actionable-table/index.d.ts +14 -17
- package/es/molecule/expandible-actionable-table/index.d.ts.map +1 -1
- package/es/molecule/expandible-actionable-table/types.d.ts +14 -17
- package/es/molecule/expandible-actionable-table/types.d.ts.map +1 -1
- package/es/molecule/quick-filters/index.d.ts +8 -15
- package/es/molecule/quick-filters/index.d.ts.map +1 -1
- package/es/molecule/quick-filters/types.d.ts +8 -15
- package/es/molecule/quick-filters/types.d.ts.map +1 -1
- package/es/molecule/title-and-checkbox-wrapper/index.d.ts +8 -15
- package/es/molecule/title-radio-wrapper/index.d.ts +8 -15
- package/es/molecule/title-radio-wrapper/index.d.ts.map +1 -1
- package/es/molecule/title-radio-wrapper/types.d.ts +8 -15
- package/es/molecule/title-radio-wrapper/types.d.ts.map +1 -1
- package/es/organism/content-skill-modal/index.d.ts +68 -115
- package/es/organism/content-skill-modal/index.d.ts.map +1 -1
- package/es/organism/content-skill-modal/types.d.ts +68 -115
- package/es/organism/content-skill-modal/types.d.ts.map +1 -1
- package/es/organism/icon-editor/index.d.ts +8 -15
- package/es/organism/icon-editor/index.d.ts.map +1 -1
- package/es/organism/icon-editor/types.d.ts +8 -15
- package/es/organism/icon-editor/types.d.ts.map +1 -1
- package/es/organism/list-items/index.d.ts +68 -115
- package/es/organism/rewards-form/index.d.ts +8 -15
- package/es/organism/select-opponents/index.d.ts +8 -15
- package/es/organism/select-opponents/index.d.ts.map +1 -1
- package/es/organism/select-opponents/types.d.ts +8 -15
- package/es/organism/select-opponents/types.d.ts.map +1 -1
- package/es/organism/setup-header/index.d.ts +32 -60
- package/es/organism/title-and-input/index.d.ts +24 -45
- package/es/organism/title-and-input/index.d.ts.map +1 -1
- package/es/organism/title-and-input/types.d.ts +24 -45
- package/es/organism/title-and-input/types.d.ts.map +1 -1
- package/es/organism/wizard-contents/index.d.ts +38 -62
- package/es/template/app-player/loading/index.d.ts +85 -133
- package/es/template/app-player/player/index.d.ts +170 -274
- package/es/template/app-player/player/slides/header/index.d.ts +0 -8
- package/es/template/app-player/player/slides/header/index.d.ts.map +1 -1
- package/es/template/app-player/player/slides/header/index.js +3 -92
- package/es/template/app-player/player/slides/header/index.js.map +1 -1
- package/es/template/app-player/player/slides/header/style.css +1 -1
- package/es/template/app-player/player/slides/index.d.ts +85 -141
- package/es/template/app-player/player/slides/index.d.ts.map +1 -1
- package/es/template/app-player/popin-correction/index.d.ts +85 -133
- package/es/template/app-player/popin-correction/index.d.ts.map +1 -1
- package/es/template/app-player/popin-end/index.d.ts +85 -141
- package/es/template/app-review/index.d.ts +85 -133
- package/es/template/app-review/index.d.ts.map +1 -1
- package/es/template/app-review/player/prop-types.d.ts +85 -133
- package/es/template/app-review/player/prop-types.d.ts.map +1 -1
- package/es/template/app-review/prop-types.d.ts +85 -133
- package/es/template/app-review/prop-types.d.ts.map +1 -1
- package/es/template/back-office/brand-create/index.d.ts +32 -60
- package/es/template/back-office/brand-create/index.d.ts.map +1 -1
- package/es/template/back-office/brand-list/index.d.ts +32 -60
- package/es/template/back-office/brand-list/index.d.ts.map +1 -1
- package/es/template/back-office/brand-update/index.d.ts +292 -486
- package/es/template/back-office/dashboard-preview/index.d.ts +32 -60
- package/es/template/back-office/layout/index.d.ts +32 -60
- package/es/template/back-office/layout/index.d.ts.map +1 -1
- package/es/template/common/dashboard/index.d.ts +170 -266
- package/es/template/common/search-page/index.d.ts +85 -133
- package/es/template/external-course/index.d.ts +85 -133
- package/es/variables/colors.d.ts +0 -1
- package/es/variables/colors.d.ts.map +1 -1
- package/es/variables/colors.js +0 -1
- package/es/variables/colors.js.map +1 -1
- package/lib/atom/button-link/index.d.ts +8 -15
- package/lib/atom/button-link/index.d.ts.map +1 -1
- package/lib/atom/button-link/index.js +37 -75
- package/lib/atom/button-link/index.js.map +1 -1
- package/lib/atom/button-link/types.d.ts +14 -20
- package/lib/atom/button-link/types.d.ts.map +1 -1
- package/lib/atom/button-link/types.js +3 -4
- package/lib/atom/button-link/types.js.map +1 -1
- package/lib/atom/button-menu/index.d.ts +3 -1
- package/lib/atom/button-menu/index.d.ts.map +1 -1
- package/lib/atom/button-menu/index.js +7 -1
- package/lib/atom/button-menu/index.js.map +1 -1
- package/lib/atom/button-menu/types.d.ts +6 -2
- package/lib/atom/button-menu/types.d.ts.map +1 -1
- package/lib/atom/radio-with-title/index.d.ts +8 -15
- package/lib/atom/radio-with-title/index.d.ts.map +1 -1
- package/lib/atom/radio-with-title/types.d.ts +8 -15
- package/lib/atom/radio-with-title/types.d.ts.map +1 -1
- package/lib/atom/title/index.d.ts +8 -15
- package/lib/molecule/bullet-point-menu-button/index.d.ts +3 -1
- package/lib/molecule/bullet-point-menu-button/index.d.ts.map +1 -1
- package/lib/molecule/bullet-point-menu-button/types.d.ts +3 -1
- package/lib/molecule/bullet-point-menu-button/types.d.ts.map +1 -1
- package/lib/molecule/button-menu-action/index.d.ts +11 -19
- package/lib/molecule/button-menu-action/index.d.ts.map +1 -1
- package/lib/molecule/button-menu-action/index.js +2 -26
- package/lib/molecule/button-menu-action/index.js.map +1 -1
- package/lib/molecule/button-menu-action/types.d.ts +12 -22
- package/lib/molecule/button-menu-action/types.d.ts.map +1 -1
- package/lib/molecule/button-menu-action/types.js +2 -7
- package/lib/molecule/button-menu-action/types.js.map +1 -1
- package/lib/molecule/cm-popin/types.d.ts +85 -133
- package/lib/molecule/cm-popin/types.d.ts.map +1 -1
- package/lib/molecule/expandible-actionable-table/index.d.ts +14 -17
- package/lib/molecule/expandible-actionable-table/index.d.ts.map +1 -1
- package/lib/molecule/expandible-actionable-table/types.d.ts +14 -17
- package/lib/molecule/expandible-actionable-table/types.d.ts.map +1 -1
- package/lib/molecule/quick-filters/index.d.ts +8 -15
- package/lib/molecule/quick-filters/index.d.ts.map +1 -1
- package/lib/molecule/quick-filters/types.d.ts +8 -15
- package/lib/molecule/quick-filters/types.d.ts.map +1 -1
- package/lib/molecule/title-and-checkbox-wrapper/index.d.ts +8 -15
- package/lib/molecule/title-radio-wrapper/index.d.ts +8 -15
- package/lib/molecule/title-radio-wrapper/index.d.ts.map +1 -1
- package/lib/molecule/title-radio-wrapper/types.d.ts +8 -15
- package/lib/molecule/title-radio-wrapper/types.d.ts.map +1 -1
- package/lib/organism/content-skill-modal/index.d.ts +68 -115
- package/lib/organism/content-skill-modal/index.d.ts.map +1 -1
- package/lib/organism/content-skill-modal/types.d.ts +68 -115
- package/lib/organism/content-skill-modal/types.d.ts.map +1 -1
- package/lib/organism/icon-editor/index.d.ts +8 -15
- package/lib/organism/icon-editor/index.d.ts.map +1 -1
- package/lib/organism/icon-editor/types.d.ts +8 -15
- package/lib/organism/icon-editor/types.d.ts.map +1 -1
- package/lib/organism/list-items/index.d.ts +68 -115
- package/lib/organism/rewards-form/index.d.ts +8 -15
- package/lib/organism/select-opponents/index.d.ts +8 -15
- package/lib/organism/select-opponents/index.d.ts.map +1 -1
- package/lib/organism/select-opponents/types.d.ts +8 -15
- package/lib/organism/select-opponents/types.d.ts.map +1 -1
- package/lib/organism/setup-header/index.d.ts +32 -60
- package/lib/organism/title-and-input/index.d.ts +24 -45
- package/lib/organism/title-and-input/index.d.ts.map +1 -1
- package/lib/organism/title-and-input/types.d.ts +24 -45
- package/lib/organism/title-and-input/types.d.ts.map +1 -1
- package/lib/organism/wizard-contents/index.d.ts +38 -62
- package/lib/template/app-player/loading/index.d.ts +85 -133
- package/lib/template/app-player/player/index.d.ts +170 -274
- package/lib/template/app-player/player/slides/header/index.d.ts +0 -8
- package/lib/template/app-player/player/slides/header/index.d.ts.map +1 -1
- package/lib/template/app-player/player/slides/header/index.js +3 -92
- package/lib/template/app-player/player/slides/header/index.js.map +1 -1
- package/lib/template/app-player/player/slides/header/style.css +1 -1
- package/lib/template/app-player/player/slides/index.d.ts +85 -141
- package/lib/template/app-player/player/slides/index.d.ts.map +1 -1
- package/lib/template/app-player/popin-correction/index.d.ts +85 -133
- package/lib/template/app-player/popin-correction/index.d.ts.map +1 -1
- package/lib/template/app-player/popin-end/index.d.ts +85 -141
- package/lib/template/app-review/index.d.ts +85 -133
- package/lib/template/app-review/index.d.ts.map +1 -1
- package/lib/template/app-review/player/prop-types.d.ts +85 -133
- package/lib/template/app-review/player/prop-types.d.ts.map +1 -1
- package/lib/template/app-review/prop-types.d.ts +85 -133
- package/lib/template/app-review/prop-types.d.ts.map +1 -1
- package/lib/template/back-office/brand-create/index.d.ts +32 -60
- package/lib/template/back-office/brand-create/index.d.ts.map +1 -1
- package/lib/template/back-office/brand-list/index.d.ts +32 -60
- package/lib/template/back-office/brand-list/index.d.ts.map +1 -1
- package/lib/template/back-office/brand-update/index.d.ts +292 -486
- package/lib/template/back-office/dashboard-preview/index.d.ts +32 -60
- package/lib/template/back-office/layout/index.d.ts +32 -60
- package/lib/template/back-office/layout/index.d.ts.map +1 -1
- package/lib/template/common/dashboard/index.d.ts +170 -266
- package/lib/template/common/search-page/index.d.ts +85 -133
- package/lib/template/external-course/index.d.ts +85 -133
- package/lib/variables/colors.d.ts +0 -1
- package/lib/variables/colors.d.ts.map +1 -1
- package/lib/variables/colors.js +0 -1
- package/lib/variables/colors.js.map +1 -1
- package/locales/bs/global.json +2 -1
- package/locales/cs/global.json +2 -1
- package/locales/de/global.json +2 -1
- package/locales/en/global.json +2 -1
- package/locales/es/global.json +2 -1
- package/locales/et/global.json +2 -1
- package/locales/fi/global.json +2 -1
- package/locales/fr/global.json +2 -1
- package/locales/hr/global.json +2 -1
- package/locales/hu/global.json +2 -1
- package/locales/hy/global.json +2 -1
- package/locales/it/global.json +2 -1
- package/locales/ja/global.json +2 -1
- package/locales/ko/global.json +2 -1
- package/locales/lt/global.json +2 -1
- package/locales/nl/global.json +2 -1
- package/locales/pl/global.json +2 -1
- package/locales/pt/global.json +2 -1
- package/locales/ro/global.json +2 -1
- package/locales/ru/global.json +2 -1
- package/locales/sk/global.json +2 -1
- package/locales/sl/global.json +2 -1
- package/locales/sv/global.json +2 -1
- package/locales/tl/global.json +2 -1
- package/locales/tr/global.json +2 -1
- package/locales/uk/global.json +2 -1
- package/locales/vi/global.json +2 -1
- package/locales/zh/global.json +2 -1
- package/locales/zh_TW/global.json +2 -1
- package/package.json +2 -2
|
@@ -12,7 +12,7 @@ declare const ButtonLink: {
|
|
|
12
12
|
tooltipPlacement: import("prop-types").Requireable<string>;
|
|
13
13
|
'data-name': import("prop-types").Requireable<string>;
|
|
14
14
|
'data-testid': import("prop-types").Requireable<string>;
|
|
15
|
-
icon: import("prop-types").Requireable<
|
|
15
|
+
icon: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
16
16
|
position: import("prop-types").Requireable<string>;
|
|
17
17
|
type: import("prop-types").Requireable<string>;
|
|
18
18
|
faIcon: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
@@ -20,19 +20,11 @@ declare const ButtonLink: {
|
|
|
20
20
|
color: import("prop-types").Requireable<string>;
|
|
21
21
|
backgroundColor: import("prop-types").Requireable<string>;
|
|
22
22
|
size: import("prop-types").Requireable<number>;
|
|
23
|
-
customStyle: import("prop-types").Requireable<
|
|
23
|
+
customStyle: import("prop-types").Requireable<{
|
|
24
|
+
[x: string]: NonNullable<string | number | null | undefined> | null | undefined;
|
|
25
|
+
}>;
|
|
24
26
|
}>>;
|
|
25
|
-
}
|
|
26
|
-
position: import("prop-types").Requireable<string>;
|
|
27
|
-
type: import("prop-types").Requireable<string>;
|
|
28
|
-
faIcon: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
29
|
-
name: import("prop-types").Validator<string>;
|
|
30
|
-
color: import("prop-types").Requireable<string>;
|
|
31
|
-
backgroundColor: import("prop-types").Requireable<string>;
|
|
32
|
-
size: import("prop-types").Requireable<number>;
|
|
33
|
-
customStyle: import("prop-types").Requireable<object>;
|
|
34
|
-
}>>;
|
|
35
|
-
}> | null | undefined)[] | null | undefined>>;
|
|
27
|
+
}>>;
|
|
36
28
|
onClick: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
37
29
|
link: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
38
30
|
href: import("prop-types").Requireable<string>;
|
|
@@ -43,8 +35,9 @@ declare const ButtonLink: {
|
|
|
43
35
|
hoverColor: import("prop-types").Requireable<string>;
|
|
44
36
|
disabled: import("prop-types").Requireable<boolean>;
|
|
45
37
|
className: import("prop-types").Requireable<string>;
|
|
46
|
-
customStyle: import("prop-types").Requireable<
|
|
47
|
-
|
|
38
|
+
customStyle: import("prop-types").Requireable<{
|
|
39
|
+
[x: string]: NonNullable<string | number | null | undefined> | null | undefined;
|
|
40
|
+
}>;
|
|
48
41
|
useTitle: import("prop-types").Requireable<boolean>;
|
|
49
42
|
customLabelClassName: import("prop-types").Requireable<string>;
|
|
50
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/button-link/index.tsx"],"names":[],"mappings":";AAQA,OAAkB,EAAC,eAAe,EAAW,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/button-link/index.tsx"],"names":[],"mappings":";AAQA,OAAkB,EAAC,eAAe,EAAW,MAAM,SAAS,CAAC;AA8D7D,QAAA,MAAM,UAAU;YAAW,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqJzC,CAAC;AAIF,eAAe,UAAU,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _noop from "lodash/fp/noop";
|
|
2
|
-
import _isEmpty from "lodash/fp/isEmpty";
|
|
3
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
4
3
|
import React, { useCallback, useState, useMemo } from 'react';
|
|
5
4
|
import classnames from 'classnames';
|
|
@@ -10,85 +9,49 @@ import ToolTip from '../tooltip';
|
|
|
10
9
|
import Tag from '../tag';
|
|
11
10
|
import propTypes from './types';
|
|
12
11
|
import style from './style.css';
|
|
13
|
-
const
|
|
14
|
-
className: classnames(style.buttonContent, customClass)
|
|
15
|
-
}, typeof content === 'string' ? /*#__PURE__*/React.createElement("span", {
|
|
16
|
-
className: classnames(style.label, customClass)
|
|
17
|
-
// eslint-disable-next-line react/no-danger
|
|
18
|
-
,
|
|
19
|
-
dangerouslySetInnerHTML: {
|
|
20
|
-
__html: content
|
|
21
|
-
}
|
|
22
|
-
}) : /*#__PURE__*/React.createElement("span", {
|
|
23
|
-
className: classnames(style.label, customClass)
|
|
24
|
-
}, content));
|
|
25
|
-
const buildFaIcon = (faIcon, hoverOptions) => {
|
|
26
|
-
if (_isEmpty(faIcon)) return null;
|
|
27
|
-
const {
|
|
28
|
-
name,
|
|
29
|
-
size,
|
|
30
|
-
backgroundColor,
|
|
31
|
-
customStyle,
|
|
32
|
-
color
|
|
33
|
-
} = faIcon;
|
|
12
|
+
const getButtonContent = (icon, content, hovered, hoverBackgroundColor, hoverColor, customLabelClassName, tag) => {
|
|
34
13
|
const {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
} =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
14
|
+
type,
|
|
15
|
+
faIcon,
|
|
16
|
+
position
|
|
17
|
+
} = icon || {
|
|
18
|
+
type: '',
|
|
19
|
+
position: ''
|
|
20
|
+
};
|
|
21
|
+
const Icon = type && ICONS[type];
|
|
22
|
+
if (!Icon && !faIcon) {
|
|
23
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
24
|
+
className: (style.buttonContent, customLabelClassName)
|
|
25
|
+
}, typeof content === 'string' ? /*#__PURE__*/React.createElement("span", {
|
|
26
|
+
className: (style.label, customLabelClassName)
|
|
27
|
+
// eslint-disable-next-line react/no-danger
|
|
28
|
+
,
|
|
29
|
+
dangerouslySetInnerHTML: {
|
|
30
|
+
__html: content
|
|
31
|
+
}
|
|
32
|
+
}) : /*#__PURE__*/React.createElement("span", {
|
|
33
|
+
className: (style.label, customLabelClassName)
|
|
34
|
+
}, content));
|
|
35
|
+
}
|
|
36
|
+
const iconComponent = faIcon ? /*#__PURE__*/React.createElement(FaIcon, {
|
|
37
|
+
iconName: faIcon.name,
|
|
38
|
+
iconColor: hovered && hoverColor ? hoverColor : faIcon.color ?? DEFAULT_ICON_COLOR,
|
|
42
39
|
// eslint-disable-next-line no-nested-ternary
|
|
43
|
-
backgroundColor: !backgroundColor ? null : hovered && hoverBackgroundColor ? hoverBackgroundColor : backgroundColor,
|
|
40
|
+
backgroundColor: !faIcon?.backgroundColor ? null : hovered && hoverBackgroundColor ? hoverBackgroundColor : faIcon.backgroundColor,
|
|
44
41
|
size: {
|
|
45
|
-
faSize: size,
|
|
46
|
-
wrapperSize: size
|
|
42
|
+
faSize: faIcon.size,
|
|
43
|
+
wrapperSize: faIcon.size
|
|
47
44
|
},
|
|
48
|
-
customStyle
|
|
49
|
-
})
|
|
50
|
-
};
|
|
51
|
-
const renderIcon = (icon, options) => {
|
|
52
|
-
if (_isEmpty(icon)) return null;
|
|
53
|
-
const {
|
|
54
|
-
type,
|
|
55
|
-
faIcon
|
|
56
|
-
} = icon;
|
|
57
|
-
const Icon = type && ICONS[type];
|
|
58
|
-
if (faIcon) return buildFaIcon(faIcon, options);
|
|
59
|
-
if (Icon) return /*#__PURE__*/React.createElement(Icon, {
|
|
45
|
+
customStyle: faIcon.customStyle
|
|
46
|
+
}) : /*#__PURE__*/React.createElement(Icon, {
|
|
60
47
|
className: style.icon,
|
|
61
48
|
theme: "coorpmanager"
|
|
62
49
|
});
|
|
63
|
-
return null;
|
|
64
|
-
};
|
|
65
|
-
const getButtonContent = (icon, content, hovered, hoverBackgroundColor, hoverColor, customLabelClassName, tag, contentCustomStyle) => {
|
|
66
|
-
// eslint-disable-next-line no-nested-ternary
|
|
67
|
-
const iconArr = !_isEmpty(icon) ? Array.isArray(icon) ? icon : [icon] : [];
|
|
68
|
-
const leftIcon = iconArr.find(({
|
|
69
|
-
position
|
|
70
|
-
}) => position === 'left');
|
|
71
|
-
const rightIcon = iconArr.find(({
|
|
72
|
-
position
|
|
73
|
-
}) => position === 'right');
|
|
74
|
-
|
|
75
|
-
// no fa icons
|
|
76
|
-
// nor ICONS
|
|
77
|
-
if (!leftIcon?.faIcon && !(leftIcon?.type && ICONS[leftIcon.type]) && !rightIcon?.faIcon && !(rightIcon?.type && ICONS[rightIcon.type])) return renderNoIcons(content, customLabelClassName);
|
|
78
50
|
return /*#__PURE__*/React.createElement("div", {
|
|
79
|
-
className: style.buttonContent
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
hoverBackgroundColor,
|
|
84
|
-
hoverColor
|
|
85
|
-
}), content ? /*#__PURE__*/React.createElement("span", {
|
|
86
|
-
className: classnames(style.label, customLabelClassName)
|
|
87
|
-
}, content) : null, tag ? /*#__PURE__*/React.createElement(Tag, tag) : null, renderIcon(rightIcon, {
|
|
88
|
-
hovered,
|
|
89
|
-
hoverBackgroundColor,
|
|
90
|
-
hoverColor
|
|
91
|
-
}));
|
|
51
|
+
className: style.buttonContent
|
|
52
|
+
}, position === 'left' ? iconComponent : null, content ? /*#__PURE__*/React.createElement("span", {
|
|
53
|
+
className: style.label
|
|
54
|
+
}, content) : null, tag ? /*#__PURE__*/React.createElement(Tag, tag) : null, position === 'right' ? iconComponent : null);
|
|
92
55
|
};
|
|
93
56
|
const ButtonLink = props => {
|
|
94
57
|
const {
|
|
@@ -110,7 +73,6 @@ const ButtonLink = props => {
|
|
|
110
73
|
onKeyDown = _noop,
|
|
111
74
|
className,
|
|
112
75
|
customStyle,
|
|
113
|
-
contentCustomStyle,
|
|
114
76
|
useTitle = true,
|
|
115
77
|
customLabelClassName,
|
|
116
78
|
tag
|
|
@@ -161,7 +123,7 @@ const ButtonLink = props => {
|
|
|
161
123
|
hoverBackgroundColor: hoverBackgroundColor,
|
|
162
124
|
onMouseEnter: handleMouseOver,
|
|
163
125
|
onMouseLeave: handleMouseLeave
|
|
164
|
-
}), getButtonContent(icon, content ?? label, hovered, hoverBackgroundColor, hoverColor, customLabelClassName, tag
|
|
126
|
+
}), getButtonContent(icon, content ?? label, hovered, hoverBackgroundColor, hoverColor, customLabelClassName, tag), renderToolTip());
|
|
165
127
|
}
|
|
166
128
|
return /*#__PURE__*/React.createElement("button", _extends({}, useTitle && {
|
|
167
129
|
title: ariaLabel || label
|
|
@@ -182,7 +144,7 @@ const ButtonLink = props => {
|
|
|
182
144
|
onMouseLeave: handleMouseLeave,
|
|
183
145
|
tabIndex: 0,
|
|
184
146
|
disabled: disabled
|
|
185
|
-
}), getButtonContent(icon, content ?? label, hovered, hoverBackgroundColor, hoverColor, customLabelClassName, tag
|
|
147
|
+
}), getButtonContent(icon, content ?? label, hovered, hoverBackgroundColor, hoverColor, customLabelClassName, tag), renderToolTip());
|
|
186
148
|
};
|
|
187
149
|
ButtonLink.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
|
|
188
150
|
export default ButtonLink;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useCallback","useState","useMemo","classnames","Link","FaIcon","DEFAULT_ICON_COLOR","ICONS","ToolTip","Tag","propTypes","style","renderNoIcons","content","customClass","createElement","className","buttonContent","label","dangerouslySetInnerHTML","__html","buildFaIcon","faIcon","hoverOptions","_isEmpty","name","size","backgroundColor","customStyle","color","hovered","hoverBackgroundColor","hoverColor","iconName","iconColor","faSize","wrapperSize","renderIcon","icon","options","type","Icon","theme","getButtonContent","customLabelClassName","tag","contentCustomStyle","iconArr","Array","isArray","leftIcon","find","position","rightIcon","ButtonLink","props","usage","disabled","dataName","dataTestId","ariaLabel","tooltipText","tooltipPlacement","link","onClick","_noop","onKeyDown","useTitle","styleButton","button","iconButton","primary","secondary","tertiary","text","dangerous","setHovered","handleOnClick","event","handleOnKeyDown","handleMouseOver","handleMouseLeave","TooltipContent","tooltipContentWrapper","renderToolTip","closeToolTipInformationTextAriaLabel","fontSize","anchorId","toolTipIsVisible","placement","_customStyle","_extends","title","onMouseEnter","onMouseLeave","onMouseOver","tabIndex","process","env","NODE_ENV"],"sources":["../../../src/atom/button-link/index.tsx"],"sourcesContent":["import React, {useCallback, useState, useMemo} from 'react';\nimport {isEmpty, noop} from 'lodash/fp';\nimport classnames from 'classnames';\nimport Link from '../link';\nimport FaIcon, {DEFAULT_ICON_COLOR, IconProps} from '../icon';\nimport {ICONS} from '../../util/button-icons';\nimport ToolTip from '../tooltip';\nimport Tag from '../tag';\nimport propTypes, {ButtonLinkProps, IconType} from './types';\nimport style from './style.css';\n\nconst renderNoIcons = (\n content: string | React.ReactNode | undefined,\n customClass: string | undefined\n) => (\n <div className={classnames(style.buttonContent, customClass)}>\n {typeof content === 'string' ? (\n <span\n className={classnames(style.label, customClass)}\n // eslint-disable-next-line react/no-danger\n dangerouslySetInnerHTML={{__html: content}}\n />\n ) : (\n <span className={classnames(style.label, customClass)}>{content}</span>\n )}\n </div>\n);\n\nconst buildFaIcon = (\n faIcon: IconType['faIcon'],\n hoverOptions: {hovered?: boolean; hoverBackgroundColor?: string; hoverColor?: string}\n) => {\n if (isEmpty(faIcon)) return null;\n\n const {name, size, backgroundColor, customStyle, color} = faIcon;\n const {hovered, hoverBackgroundColor, hoverColor} = hoverOptions;\n\n return (\n <FaIcon\n {...({\n iconName: name,\n iconColor: hovered && hoverColor ? hoverColor : color ?? DEFAULT_ICON_COLOR,\n // eslint-disable-next-line no-nested-ternary\n backgroundColor: !backgroundColor\n ? null\n : hovered && hoverBackgroundColor\n ? hoverBackgroundColor\n : backgroundColor,\n size: {\n faSize: size,\n wrapperSize: size\n },\n customStyle\n } as IconProps)}\n />\n );\n};\n\nconst renderIcon = (\n icon: IconType | undefined,\n options: {hovered?: boolean; hoverBackgroundColor?: string; hoverColor?: string}\n) => {\n if (isEmpty(icon)) return null;\n\n const {type, faIcon} = icon;\n const Icon = type && ICONS[type];\n\n if (faIcon) return buildFaIcon(faIcon, options);\n if (Icon) return <Icon className={style.icon} theme=\"coorpmanager\" />;\n\n return null;\n};\n\nconst getButtonContent = (\n icon?: IconType | IconType[],\n content?: string | React.ReactNode,\n hovered?: boolean,\n hoverBackgroundColor?: string,\n hoverColor?: string,\n customLabelClassName?: string,\n tag?: React.ComponentProps<typeof Tag>,\n contentCustomStyle?: React.CSSProperties\n) => {\n // eslint-disable-next-line no-nested-ternary\n const iconArr = !isEmpty(icon) ? (Array.isArray(icon) ? icon : [icon]) : [];\n\n const leftIcon = iconArr.find(({position}) => position === 'left');\n const rightIcon = iconArr.find(({position}) => position === 'right');\n\n // no fa icons\n // nor ICONS\n if (\n !leftIcon?.faIcon &&\n !(leftIcon?.type && ICONS[leftIcon.type]) &&\n !rightIcon?.faIcon &&\n !(rightIcon?.type && ICONS[rightIcon.type])\n )\n return renderNoIcons(content, customLabelClassName);\n\n return (\n <div className={style.buttonContent} style={contentCustomStyle}>\n {renderIcon(leftIcon, {hovered, hoverBackgroundColor, hoverColor})}\n {content ? (\n <span className={classnames(style.label, customLabelClassName)}>{content}</span>\n ) : null}\n {tag ? <Tag {...tag} /> : null}\n {renderIcon(rightIcon, {hovered, hoverBackgroundColor, hoverColor})}\n </div>\n );\n};\n\nconst ButtonLink = (props: ButtonLinkProps) => {\n const {\n type,\n usage = 'button',\n label,\n content,\n hoverBackgroundColor,\n hoverColor,\n disabled = false,\n icon,\n 'data-name': dataName,\n 'data-testid': dataTestId = 'button-link',\n 'aria-label': ariaLabel,\n tooltipText,\n tooltipPlacement = 'left',\n link,\n onClick = noop,\n onKeyDown = noop,\n className,\n customStyle,\n contentCustomStyle,\n useTitle = true,\n customLabelClassName,\n tag\n } = props;\n const styleButton = classnames(\n link && style.link,\n className,\n style.button,\n !label && style.iconButton,\n type === 'primary' && style.primary,\n type === 'secondary' && style.secondary,\n type === 'tertiary' && style.tertiary,\n type === 'text' && style.text,\n type === 'dangerous' && style.dangerous,\n disabled && style.disabled\n );\n\n const [hovered, setHovered] = useState(false);\n\n const handleOnClick = useCallback(event => onClick(event), [onClick]);\n\n const handleOnKeyDown = useCallback(event => onKeyDown(event), [onKeyDown]);\n\n const handleMouseOver = useCallback(() => {\n setHovered(true);\n }, [setHovered]);\n\n const handleMouseLeave = useCallback(() => setHovered(false), [setHovered]);\n\n const TooltipContent = useCallback(\n () => <span className={style.tooltipContentWrapper}>{tooltipText || ariaLabel}</span>,\n [tooltipText, ariaLabel]\n );\n\n const renderToolTip = () => {\n const closeToolTipInformationTextAriaLabel = tooltipText || ariaLabel;\n if (!closeToolTipInformationTextAriaLabel) return null;\n return (\n <ToolTip\n fontSize={12}\n anchorId=\"button-icon\"\n toolTipIsVisible={hovered}\n placement={tooltipPlacement}\n TooltipContent={TooltipContent}\n closeToolTipInformationTextAriaLabel={closeToolTipInformationTextAriaLabel}\n />\n );\n };\n const _customStyle = useMemo(() => {\n return {\n ...customStyle,\n ...((hoverBackgroundColor || hoverColor) && hovered\n ? {\n backgroundColor: hoverBackgroundColor,\n color: hoverColor\n }\n : null)\n };\n }, [hoverBackgroundColor, hoverColor, hovered, customStyle]);\n\n if (link) {\n return (\n <Link\n {...link}\n {...(useTitle && {\n title: ariaLabel || label\n })}\n className={styleButton}\n style={customStyle}\n data-name={dataName}\n data-testid={dataTestId}\n onClick={handleOnClick}\n aria-label={ariaLabel || label}\n hoverColor={hoverColor}\n hoverBackgroundColor={hoverBackgroundColor}\n onMouseEnter={handleMouseOver}\n onMouseLeave={handleMouseLeave}\n >\n {getButtonContent(\n icon,\n content ?? label,\n hovered,\n hoverBackgroundColor,\n hoverColor,\n customLabelClassName,\n tag,\n contentCustomStyle\n )}\n {renderToolTip()}\n </Link>\n );\n }\n\n return (\n <button\n {...(useTitle && {\n title: ariaLabel || label\n })}\n {...(ariaLabel && !label\n ? {\n 'data-for': 'button-icon',\n 'data-tip': hovered\n }\n : {})}\n // eslint-disable-next-line react/button-has-type\n type={usage}\n aria-label={ariaLabel || label}\n data-name={dataName}\n data-testid={dataTestId}\n style={_customStyle}\n className={styleButton}\n onClick={handleOnClick}\n onKeyDown={handleOnKeyDown}\n onMouseOver={handleMouseOver}\n onMouseLeave={handleMouseLeave}\n tabIndex={0}\n disabled={disabled}\n >\n {getButtonContent(\n icon,\n content ?? label,\n hovered,\n hoverBackgroundColor,\n hoverColor,\n customLabelClassName,\n tag,\n contentCustomStyle\n )}\n {renderToolTip()}\n </button>\n );\n};\n\nButtonLink.propTypes = propTypes;\n\nexport default ButtonLink;\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAGC,WAAW,EAAEC,QAAQ,EAAEC,OAAO,QAAO,OAAO;AAE3D,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,IAAI,MAAM,SAAS;AAC1B,OAAOC,MAAM,IAAGC,kBAAkB,QAAkB,SAAS;AAC7D,SAAQC,KAAK,QAAO,yBAAyB;AAC7C,OAAOC,OAAO,MAAM,YAAY;AAChC,OAAOC,GAAG,MAAM,QAAQ;AACxB,OAAOC,SAAS,MAAmC,SAAS;AAC5D,OAAOC,KAAK,MAAM,aAAa;AAE/B,MAAMC,aAAa,GAAGA,CACpBC,OAA6C,EAC7CC,WAA+B,kBAE/Bf,KAAA,CAAAgB,aAAA;EAAKC,SAAS,EAAEb,UAAU,CAACQ,KAAK,CAACM,aAAa,EAAEH,WAAW;AAAE,GAC1D,OAAOD,OAAO,KAAK,QAAQ,gBAC1Bd,KAAA,CAAAgB,aAAA;EACEC,SAAS,EAAEb,UAAU,CAACQ,KAAK,CAACO,KAAK,EAAEJ,WAAW;EAC9C;EAAA;EACAK,uBAAuB,EAAE;IAACC,MAAM,EAAEP;EAAO;AAAE,CAC5C,CAAC,gBAEFd,KAAA,CAAAgB,aAAA;EAAMC,SAAS,EAAEb,UAAU,CAACQ,KAAK,CAACO,KAAK,EAAEJ,WAAW;AAAE,GAAED,OAAc,CAErE,CACN;AAED,MAAMQ,WAAW,GAAGA,CAClBC,MAA0B,EAC1BC,YAAqF,KAClF;EACH,IAAIC,QAAA,CAAQF,MAAM,CAAC,EAAE,OAAO,IAAI;EAEhC,MAAM;IAACG,IAAI;IAAEC,IAAI;IAAEC,eAAe;IAAEC,WAAW;IAAEC;EAAK,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,QAAA,oBAAGzF,SAAS;AAEhC,eAAe4C,UAAU","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","useState","useMemo","classnames","Link","FaIcon","DEFAULT_ICON_COLOR","ICONS","ToolTip","Tag","propTypes","style","getButtonContent","icon","content","hovered","hoverBackgroundColor","hoverColor","customLabelClassName","tag","type","faIcon","position","Icon","createElement","className","buttonContent","label","dangerouslySetInnerHTML","__html","iconComponent","iconName","name","iconColor","color","backgroundColor","size","faSize","wrapperSize","customStyle","theme","ButtonLink","props","usage","disabled","dataName","dataTestId","ariaLabel","tooltipText","tooltipPlacement","link","onClick","_noop","onKeyDown","useTitle","styleButton","button","iconButton","primary","secondary","tertiary","text","dangerous","setHovered","handleOnClick","event","handleOnKeyDown","handleMouseOver","handleMouseLeave","TooltipContent","tooltipContentWrapper","renderToolTip","closeToolTipInformationTextAriaLabel","fontSize","anchorId","toolTipIsVisible","placement","_customStyle","_extends","title","onMouseEnter","onMouseLeave","onMouseOver","tabIndex","process","env","NODE_ENV"],"sources":["../../../src/atom/button-link/index.tsx"],"sourcesContent":["import React, {useCallback, useState, useMemo} from 'react';\nimport {noop} from 'lodash/fp';\nimport classnames from 'classnames';\nimport Link from '../link';\nimport FaIcon, {DEFAULT_ICON_COLOR, IconProps} from '../icon';\nimport {ICONS} from '../../util/button-icons';\nimport ToolTip from '../tooltip';\nimport Tag from '../tag';\nimport propTypes, {ButtonLinkProps, IconType} from './types';\nimport style from './style.css';\n\nconst getButtonContent = (\n icon?: IconType,\n content?: string | React.ReactNode,\n hovered?: boolean,\n hoverBackgroundColor?: string,\n hoverColor?: string,\n customLabelClassName?: string,\n tag?: React.ComponentProps<typeof Tag>\n) => {\n const {type, faIcon, position} = icon || {type: '', position: ''};\n const Icon = type && ICONS[type];\n\n if (!Icon && !faIcon) {\n return (\n <div className={(style.buttonContent, customLabelClassName)}>\n {typeof content === 'string' ? (\n <span\n className={(style.label, customLabelClassName)}\n // eslint-disable-next-line react/no-danger\n dangerouslySetInnerHTML={{__html: content}}\n />\n ) : (\n <span className={(style.label, customLabelClassName)}>{content}</span>\n )}\n </div>\n );\n }\n\n const iconComponent = faIcon ? (\n <FaIcon\n {...({\n iconName: faIcon.name,\n iconColor: hovered && hoverColor ? hoverColor : faIcon.color ?? DEFAULT_ICON_COLOR,\n // eslint-disable-next-line no-nested-ternary\n backgroundColor: !faIcon?.backgroundColor\n ? null\n : hovered && hoverBackgroundColor\n ? hoverBackgroundColor\n : faIcon.backgroundColor,\n size: {\n faSize: faIcon.size,\n wrapperSize: faIcon.size\n },\n customStyle: faIcon.customStyle\n } as IconProps)}\n />\n ) : (\n <Icon className={style.icon} theme=\"coorpmanager\" />\n );\n return (\n <div className={style.buttonContent}>\n {position === 'left' ? iconComponent : null}\n {content ? <span className={style.label}>{content}</span> : null}\n {tag ? <Tag {...tag} /> : null}\n {position === 'right' ? iconComponent : null}\n </div>\n );\n};\n\nconst ButtonLink = (props: ButtonLinkProps) => {\n const {\n type,\n usage = 'button',\n label,\n content,\n hoverBackgroundColor,\n hoverColor,\n disabled = false,\n icon,\n 'data-name': dataName,\n 'data-testid': dataTestId = 'button-link',\n 'aria-label': ariaLabel,\n tooltipText,\n tooltipPlacement = 'left',\n link,\n onClick = noop,\n onKeyDown = noop,\n className,\n customStyle,\n useTitle = true,\n customLabelClassName,\n tag\n } = props;\n const styleButton = classnames(\n link && style.link,\n className,\n style.button,\n !label && style.iconButton,\n type === 'primary' && style.primary,\n type === 'secondary' && style.secondary,\n type === 'tertiary' && style.tertiary,\n type === 'text' && style.text,\n type === 'dangerous' && style.dangerous,\n disabled && style.disabled\n );\n\n const [hovered, setHovered] = useState(false);\n\n const handleOnClick = useCallback(event => onClick(event), [onClick]);\n\n const handleOnKeyDown = useCallback(event => onKeyDown(event), [onKeyDown]);\n\n const handleMouseOver = useCallback(() => {\n setHovered(true);\n }, [setHovered]);\n\n const handleMouseLeave = useCallback(() => setHovered(false), [setHovered]);\n\n const TooltipContent = useCallback(\n () => <span className={style.tooltipContentWrapper}>{tooltipText || ariaLabel}</span>,\n [tooltipText, ariaLabel]\n );\n\n const renderToolTip = () => {\n const closeToolTipInformationTextAriaLabel = tooltipText || ariaLabel;\n if (!closeToolTipInformationTextAriaLabel) return null;\n return (\n <ToolTip\n fontSize={12}\n anchorId=\"button-icon\"\n toolTipIsVisible={hovered}\n placement={tooltipPlacement}\n TooltipContent={TooltipContent}\n closeToolTipInformationTextAriaLabel={closeToolTipInformationTextAriaLabel}\n />\n );\n };\n const _customStyle = useMemo(() => {\n return {\n ...customStyle,\n ...((hoverBackgroundColor || hoverColor) && hovered\n ? {\n backgroundColor: hoverBackgroundColor,\n color: hoverColor\n }\n : null)\n };\n }, [hoverBackgroundColor, hoverColor, hovered, customStyle]);\n\n if (link) {\n return (\n <Link\n {...link}\n {...(useTitle && {\n title: ariaLabel || label\n })}\n className={styleButton}\n style={customStyle}\n data-name={dataName}\n data-testid={dataTestId}\n onClick={handleOnClick}\n aria-label={ariaLabel || label}\n hoverColor={hoverColor}\n hoverBackgroundColor={hoverBackgroundColor}\n onMouseEnter={handleMouseOver}\n onMouseLeave={handleMouseLeave}\n >\n {getButtonContent(\n icon,\n content ?? label,\n hovered,\n hoverBackgroundColor,\n hoverColor,\n customLabelClassName,\n tag\n )}\n {renderToolTip()}\n </Link>\n );\n }\n\n return (\n <button\n {...(useTitle && {\n title: ariaLabel || label\n })}\n {...(ariaLabel && !label\n ? {\n 'data-for': 'button-icon',\n 'data-tip': hovered\n }\n : {})}\n // eslint-disable-next-line react/button-has-type\n type={usage}\n aria-label={ariaLabel || label}\n data-name={dataName}\n data-testid={dataTestId}\n style={_customStyle}\n className={styleButton}\n onClick={handleOnClick}\n onKeyDown={handleOnKeyDown}\n onMouseOver={handleMouseOver}\n onMouseLeave={handleMouseLeave}\n tabIndex={0}\n disabled={disabled}\n >\n {getButtonContent(\n icon,\n content ?? label,\n hovered,\n hoverBackgroundColor,\n hoverColor,\n customLabelClassName,\n tag\n )}\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
|
backgroundColor: PropTypes.Requireable<string>;
|
|
12
12
|
size: PropTypes.Requireable<number>;
|
|
13
|
-
customStyle: PropTypes.Requireable<
|
|
13
|
+
customStyle: PropTypes.Requireable<{
|
|
14
|
+
[x: string]: NonNullable<string | number | null | undefined> | null | undefined;
|
|
15
|
+
}>;
|
|
14
16
|
}>>;
|
|
15
17
|
};
|
|
16
18
|
declare const propTypes: {
|
|
@@ -23,7 +25,7 @@ declare const propTypes: {
|
|
|
23
25
|
tooltipPlacement: PropTypes.Requireable<string>;
|
|
24
26
|
'data-name': PropTypes.Requireable<string>;
|
|
25
27
|
'data-testid': PropTypes.Requireable<string>;
|
|
26
|
-
icon: PropTypes.Requireable<
|
|
28
|
+
icon: PropTypes.Requireable<PropTypes.InferProps<{
|
|
27
29
|
position: PropTypes.Requireable<string>;
|
|
28
30
|
type: PropTypes.Requireable<string>;
|
|
29
31
|
faIcon: PropTypes.Requireable<PropTypes.InferProps<{
|
|
@@ -31,19 +33,11 @@ declare const propTypes: {
|
|
|
31
33
|
color: PropTypes.Requireable<string>;
|
|
32
34
|
backgroundColor: PropTypes.Requireable<string>;
|
|
33
35
|
size: PropTypes.Requireable<number>;
|
|
34
|
-
customStyle: PropTypes.Requireable<
|
|
36
|
+
customStyle: PropTypes.Requireable<{
|
|
37
|
+
[x: string]: NonNullable<string | number | null | undefined> | null | undefined;
|
|
38
|
+
}>;
|
|
35
39
|
}>>;
|
|
36
|
-
}
|
|
37
|
-
position: PropTypes.Requireable<string>;
|
|
38
|
-
type: PropTypes.Requireable<string>;
|
|
39
|
-
faIcon: PropTypes.Requireable<PropTypes.InferProps<{
|
|
40
|
-
name: PropTypes.Validator<string>;
|
|
41
|
-
color: PropTypes.Requireable<string>;
|
|
42
|
-
backgroundColor: PropTypes.Requireable<string>;
|
|
43
|
-
size: PropTypes.Requireable<number>;
|
|
44
|
-
customStyle: PropTypes.Requireable<object>;
|
|
45
|
-
}>>;
|
|
46
|
-
}> | null | undefined)[] | null | undefined>>;
|
|
40
|
+
}>>;
|
|
47
41
|
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
48
42
|
link: PropTypes.Requireable<PropTypes.InferProps<{
|
|
49
43
|
href: PropTypes.Requireable<string>;
|
|
@@ -54,8 +48,9 @@ declare const propTypes: {
|
|
|
54
48
|
hoverColor: PropTypes.Requireable<string>;
|
|
55
49
|
disabled: PropTypes.Requireable<boolean>;
|
|
56
50
|
className: PropTypes.Requireable<string>;
|
|
57
|
-
customStyle: PropTypes.Requireable<
|
|
58
|
-
|
|
51
|
+
customStyle: PropTypes.Requireable<{
|
|
52
|
+
[x: string]: NonNullable<string | number | null | undefined> | null | undefined;
|
|
53
|
+
}>;
|
|
59
54
|
useTitle: PropTypes.Requireable<boolean>;
|
|
60
55
|
customLabelClassName: PropTypes.Requireable<string>;
|
|
61
56
|
};
|
|
@@ -64,7 +59,7 @@ export declare type FaIconType = {
|
|
|
64
59
|
color?: string;
|
|
65
60
|
backgroundColor?: string;
|
|
66
61
|
size?: number;
|
|
67
|
-
customStyle?:
|
|
62
|
+
customStyle?: Record<string, number | string>;
|
|
68
63
|
};
|
|
69
64
|
export declare type IconType = {
|
|
70
65
|
position: 'right' | 'left';
|
|
@@ -81,7 +76,7 @@ export declare type ButtonLinkProps = {
|
|
|
81
76
|
tooltipPlacement?: 'left' | 'right' | 'top' | 'bottom';
|
|
82
77
|
'data-name'?: string;
|
|
83
78
|
'data-testid'?: string;
|
|
84
|
-
icon?: IconType
|
|
79
|
+
icon?: IconType;
|
|
85
80
|
onClick?: () => void;
|
|
86
81
|
onKeyDown?: () => void;
|
|
87
82
|
link?: {
|
|
@@ -93,8 +88,7 @@ export declare type ButtonLinkProps = {
|
|
|
93
88
|
hoverColor?: string;
|
|
94
89
|
disabled?: boolean;
|
|
95
90
|
className?: string;
|
|
96
|
-
customStyle?:
|
|
97
|
-
contentCustomStyle?: React.CSSProperties;
|
|
91
|
+
customStyle?: Record<string, string | number>;
|
|
98
92
|
useTitle?: boolean;
|
|
99
93
|
customLabelClassName?: string;
|
|
100
94
|
tag?: React.ComponentProps<typeof Tag>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/atom/button-link/types.ts"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAC,KAAK,EAAC,MAAM,yBAAyB,CAAC;AAC9C,OAAO,GAAG,MAAM,QAAQ,CAAC;AAUzB,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/atom/button-link/types.ts"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAC,KAAK,EAAC,MAAM,yBAAyB,CAAC;AAC9C,OAAO,GAAG,MAAM,QAAQ,CAAC;AAUzB,eAAO,MAAM,aAAa;;;;;;;;;;;;CAIzB,CAAC;AAEF,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwBd,CAAC;AAEF,oBAAY,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CAC/C,CAAC;AAEF,oBAAY,QAAQ,GAAG;IACrB,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,OAAO,KAAK,CAAC;IAC1B,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF,oBAAY,eAAe,GAAG;IAC5B,IAAI,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,WAAW,CAAC;IACnE,KAAK,CAAC,EAAE,QAAQ,GAAG,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.number,
|
|
9
|
-
customStyle: PropTypes.
|
|
9
|
+
customStyle: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]))
|
|
10
10
|
};
|
|
11
11
|
export const iconPropTypes = {
|
|
12
12
|
position: PropTypes.oneOf(['right', 'left']),
|
|
@@ -23,7 +23,7 @@ const propTypes = {
|
|
|
23
23
|
tooltipPlacement: PropTypes.oneOf(['left', 'right', 'top', 'bottom']),
|
|
24
24
|
'data-name': PropTypes.string,
|
|
25
25
|
'data-testid': PropTypes.string,
|
|
26
|
-
icon: PropTypes.
|
|
26
|
+
icon: PropTypes.shape(iconPropTypes),
|
|
27
27
|
onClick: PropTypes.func,
|
|
28
28
|
link: PropTypes.shape({
|
|
29
29
|
href: PropTypes.string,
|
|
@@ -34,8 +34,7 @@ const propTypes = {
|
|
|
34
34
|
hoverColor: PropTypes.string,
|
|
35
35
|
disabled: PropTypes.bool,
|
|
36
36
|
className: PropTypes.string,
|
|
37
|
-
customStyle: PropTypes.
|
|
38
|
-
contentCustomStyle: PropTypes.object,
|
|
37
|
+
customStyle: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
|
|
39
38
|
useTitle: PropTypes.bool,
|
|
40
39
|
customLabelClassName: PropTypes.string
|
|
41
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["PropTypes","ICONS","faIconPropTypes","name","string","isRequired","color","backgroundColor","size","number","customStyle","
|
|
1
|
+
{"version":3,"file":"types.js","names":["PropTypes","ICONS","faIconPropTypes","name","string","isRequired","color","backgroundColor","size","number","customStyle","objectOf","oneOfType","iconPropTypes","position","oneOf","type","_keys","faIcon","shape","propTypes","usage","label","content","node","tooltipText","tooltipPlacement","icon","onClick","func","link","href","download","bool","target","hoverBackgroundColor","hoverColor","disabled","className","useTitle","customLabelClassName"],"sources":["../../../src/atom/button-link/types.ts"],"sourcesContent":["import PropTypes from 'prop-types';\nimport {keys} from 'lodash/fp';\nimport {ICONS} from '../../util/button-icons';\nimport Tag from '../tag';\n\nconst faIconPropTypes = {\n name: PropTypes.string.isRequired,\n color: PropTypes.string,\n backgroundColor: PropTypes.string,\n size: PropTypes.number,\n customStyle: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]))\n};\n\nexport const iconPropTypes = {\n position: PropTypes.oneOf(['right', 'left']),\n type: PropTypes.oneOf(keys(ICONS)),\n faIcon: PropTypes.shape(faIconPropTypes)\n};\n\nconst propTypes = {\n type: PropTypes.oneOf(['primary', 'secondary', 'tertiary', 'text', 'dangerous']),\n usage: PropTypes.oneOf(['button', 'submit', 'reset']),\n label: PropTypes.string,\n content: PropTypes.node,\n 'aria-label': PropTypes.string,\n tooltipText: PropTypes.string,\n tooltipPlacement: PropTypes.oneOf(['left', 'right', 'top', 'bottom']),\n 'data-name': PropTypes.string,\n 'data-testid': PropTypes.string,\n icon: PropTypes.shape(iconPropTypes),\n onClick: PropTypes.func,\n link: PropTypes.shape({\n href: PropTypes.string,\n download: PropTypes.bool,\n target: PropTypes.oneOf(['_self', '_blank', '_parent', '_top'])\n }),\n hoverBackgroundColor: PropTypes.string,\n hoverColor: PropTypes.string,\n disabled: PropTypes.bool,\n className: PropTypes.string,\n customStyle: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),\n useTitle: PropTypes.bool,\n customLabelClassName: PropTypes.string\n};\n\nexport type FaIconType = {\n name: string;\n color?: string;\n backgroundColor?: string;\n size?: number;\n customStyle?: Record<string, number | string>;\n};\n\nexport type IconType = {\n position: 'right' | 'left';\n type?: keyof typeof ICONS;\n faIcon?: FaIconType;\n};\n\nexport type ButtonLinkProps = {\n type?: 'primary' | 'secondary' | 'tertiary' | 'text' | 'dangerous';\n usage?: 'button' | 'submit' | 'reset';\n label?: string;\n content?: PropTypes.ReactNodeLike;\n 'aria-label'?: string;\n tooltipText?: string;\n tooltipPlacement?: 'left' | 'right' | 'top' | 'bottom';\n 'data-name'?: string;\n 'data-testid'?: string;\n icon?: IconType;\n onClick?: () => void;\n onKeyDown?: () => void;\n link?: {\n href?: string;\n download?: boolean;\n target?: '_self' | '_blank' | '_parent' | '_top';\n };\n hoverBackgroundColor?: string;\n hoverColor?: string;\n disabled?: boolean;\n className?: string;\n customStyle?: Record<string, string | number>;\n useTitle?: boolean;\n customLabelClassName?: string;\n tag?: React.ComponentProps<typeof Tag>;\n};\n\nexport type Fixture = {props: ButtonLinkProps};\n\nexport default propTypes;\n"],"mappings":";AAAA,OAAOA,SAAS,MAAM,YAAY;AAElC,SAAQC,KAAK,QAAO,yBAAyB;AAG7C,MAAMC,eAAe,GAAG;EACtBC,IAAI,EAAEH,SAAS,CAACI,MAAM,CAACC,UAAU;EACjCC,KAAK,EAAEN,SAAS,CAACI,MAAM;EACvBG,eAAe,EAAEP,SAAS,CAACI,MAAM;EACjCI,IAAI,EAAER,SAAS,CAACS,MAAM;EACtBC,WAAW,EAAEV,SAAS,CAACW,QAAQ,CAACX,SAAS,CAACY,SAAS,CAAC,CAACZ,SAAS,CAACI,MAAM,EAAEJ,SAAS,CAACS,MAAM,CAAC,CAAC;AAC3F,CAAC;AAED,OAAO,MAAMI,aAAa,GAAG;EAC3BC,QAAQ,EAAEd,SAAS,CAACe,KAAK,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;EAC5CC,IAAI,EAAEhB,SAAS,CAACe,KAAK,CAACE,KAAA,CAAKhB,KAAK,CAAC,CAAC;EAClCiB,MAAM,EAAElB,SAAS,CAACmB,KAAK,CAACjB,eAAe;AACzC,CAAC;AAED,MAAMkB,SAAS,GAAG;EAChBJ,IAAI,EAAEhB,SAAS,CAACe,KAAK,CAAC,CAAC,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;EAChFM,KAAK,EAAErB,SAAS,CAACe,KAAK,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;EACrDO,KAAK,EAAEtB,SAAS,CAACI,MAAM;EACvBmB,OAAO,EAAEvB,SAAS,CAACwB,IAAI;EACvB,YAAY,EAAExB,SAAS,CAACI,MAAM;EAC9BqB,WAAW,EAAEzB,SAAS,CAACI,MAAM;EAC7BsB,gBAAgB,EAAE1B,SAAS,CAACe,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;EACrE,WAAW,EAAEf,SAAS,CAACI,MAAM;EAC7B,aAAa,EAAEJ,SAAS,CAACI,MAAM;EAC/BuB,IAAI,EAAE3B,SAAS,CAACmB,KAAK,CAACN,aAAa,CAAC;EACpCe,OAAO,EAAE5B,SAAS,CAAC6B,IAAI;EACvBC,IAAI,EAAE9B,SAAS,CAACmB,KAAK,CAAC;IACpBY,IAAI,EAAE/B,SAAS,CAACI,MAAM;IACtB4B,QAAQ,EAAEhC,SAAS,CAACiC,IAAI;IACxBC,MAAM,EAAElC,SAAS,CAACe,KAAK,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC;EAChE,CAAC,CAAC;EACFoB,oBAAoB,EAAEnC,SAAS,CAACI,MAAM;EACtCgC,UAAU,EAAEpC,SAAS,CAACI,MAAM;EAC5BiC,QAAQ,EAAErC,SAAS,CAACiC,IAAI;EACxBK,SAAS,EAAEtC,SAAS,CAACI,MAAM;EAC3BM,WAAW,EAAEV,SAAS,CAACW,QAAQ,CAACX,SAAS,CAACY,SAAS,CAAC,CAACZ,SAAS,CAACI,MAAM,EAAEJ,SAAS,CAACS,MAAM,CAAC,CAAC,CAAC;EAC1F8B,QAAQ,EAAEvC,SAAS,CAACiC,IAAI;EACxBO,oBAAoB,EAAExC,SAAS,CAACI;AAClC,CAAC;AA8CD,eAAegB,SAAS","ignoreList":[]}
|
|
@@ -19,7 +19,9 @@ declare const ButtonMenu: {
|
|
|
19
19
|
color: import("prop-types").Requireable<string>;
|
|
20
20
|
backgroundColor: import("prop-types").Requireable<string>;
|
|
21
21
|
size: import("prop-types").Requireable<number>;
|
|
22
|
-
customStyle: import("prop-types").Requireable<
|
|
22
|
+
customStyle: import("prop-types").Requireable<{
|
|
23
|
+
[x: string]: NonNullable<string | number | null | undefined> | null | undefined;
|
|
24
|
+
}>;
|
|
23
25
|
}>>;
|
|
24
26
|
}>>;
|
|
25
27
|
customStyle: import("prop-types").Requireable<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/button-menu/index.tsx"],"names":[],"mappings":";AAMA,OAAkB,EAAC,eAAe,EAA+B,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/button-menu/index.tsx"],"names":[],"mappings":";AAMA,OAAkB,EAAC,eAAe,EAA+B,MAAM,SAAS,CAAC;AAmEjF,QAAA,MAAM,UAAU;YAAW,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqBzC,CAAC;AAIF,eAAe,UAAU,CAAC"}
|
|
@@ -37,6 +37,8 @@ const Button = props => {
|
|
|
37
37
|
type = 'default',
|
|
38
38
|
buttonLinkType,
|
|
39
39
|
icon,
|
|
40
|
+
customStyle = {},
|
|
41
|
+
customLabelClassName,
|
|
40
42
|
...rest
|
|
41
43
|
} = props;
|
|
42
44
|
const styleButton = classnames(style.button, type === 'default' && style.defaultStyle, type === 'defaultLeft' && style.defaultLeft, type === 'dangerous' && style.dangerous, type === 'dangerousLeft' && style.dangerousLeft, disabled && style.disabled);
|
|
@@ -49,7 +51,11 @@ const Button = props => {
|
|
|
49
51
|
type: buttonLinkType,
|
|
50
52
|
onClick: handleOnClick,
|
|
51
53
|
'data-name': dataName,
|
|
52
|
-
className: styleButton
|
|
54
|
+
className: styleButton,
|
|
55
|
+
customStyle: {
|
|
56
|
+
...customStyle
|
|
57
|
+
},
|
|
58
|
+
customLabelClassName
|
|
53
59
|
};
|
|
54
60
|
const iconProps = buildCustomIconByTheme(icon);
|
|
55
61
|
return /*#__PURE__*/React.createElement(ButtonLink, _extends({}, buttonLinkProps, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useMemo","useCallback","map","classnames","ButtonLink","style","propTypes","buttonPropTypes","DEFAULT_ICON_STYLE","THEMES","buildCustomIconByTheme","icon","theme","iconProps","custom","customProps","faIcon","Button","props","dataName","ariaLabel","disabled","label","onClick","_noop","type","buttonLinkType","rest","styleButton","button","defaultStyle","defaultLeft","dangerous","dangerousLeft","handleOnClick","buttonLinkProps","className","createElement","_extends","process","env","NODE_ENV","ButtonMenu","buttons","enableScroll","buildButton","index","key","buttonList","convert","cap","containerStyle","buttonMenuContainer","scrollable"],"sources":["../../../src/atom/button-menu/index.tsx"],"sourcesContent":["import React, {useMemo, useCallback} from 'react';\nimport map from 'lodash/fp/map';\nimport classnames from 'classnames';\nimport {noop} from 'lodash/fp';\nimport ButtonLink from '../button-link';\nimport style from './style.css';\nimport propTypes, {ButtonMenuProps, ButtonProps, buttonPropTypes} from './types';\nimport {DEFAULT_ICON_STYLE, THEMES} from './utils';\n\nconst buildCustomIconByTheme = (icon: ButtonProps['icon']) => {\n if (!icon) return;\n\n const {theme, ...iconProps} = icon;\n const custom = theme && THEMES[theme];\n if (!custom) return iconProps;\n\n const customProps = custom\n ? {\n ...DEFAULT_ICON_STYLE,\n faIcon: {...DEFAULT_ICON_STYLE.faIcon, ...custom}\n }\n : null;\n\n return {\n ...iconProps,\n ...customProps\n };\n};\n\nconst Button = (props: ButtonProps) => {\n const {\n 'data-name': dataName,\n 'aria-label': ariaLabel,\n disabled,\n label,\n onClick = noop,\n type = 'default',\n buttonLinkType,\n icon,\n ...rest\n } = props;\n const styleButton = classnames(\n style.button,\n type === 'default' && style.defaultStyle,\n type === 'defaultLeft' && style.defaultLeft,\n type === 'dangerous' && style.dangerous,\n type === 'dangerousLeft' && style.dangerousLeft,\n disabled && style.disabled\n );\n const handleOnClick = useCallback(() => onClick(), [onClick]);\n\n const buttonLinkProps = {\n ...rest,\n 'aria-label': ariaLabel || label,\n disabled,\n label,\n type: buttonLinkType,\n onClick: handleOnClick,\n 'data-name': dataName,\n className: styleButton\n };\n\n const iconProps = buildCustomIconByTheme(icon);\n\n return <ButtonLink {...buttonLinkProps} icon={iconProps} />;\n};\n\nButton.propTypes = buttonPropTypes;\n\nconst ButtonMenu = (props: ButtonMenuProps) => {\n const {buttons, 'data-name': dataName, enableScroll = false} = props;\n const buildButton = useCallback((button: ButtonProps, index) => {\n return <Button {...button} key={button.label + index} />;\n }, []);\n\n const buttonList = useMemo(\n // @ts-expect-error (to avoid using map as any)\n () => map.convert({cap: false})(buildButton, buttons),\n [buttons, buildButton]\n );\n\n const containerStyle = classnames(style.buttonMenuContainer, {\n [style.scrollable]: enableScroll\n });\n\n return (\n <div data-name={dataName} className={containerStyle}>\n {buttonList}\n </div>\n );\n};\n\nButtonMenu.propTypes = propTypes;\n\nexport default ButtonMenu;\n"],"mappings":";;AAAA,OAAOA,KAAK,IAAGC,OAAO,EAAEC,WAAW,QAAO,OAAO;AACjD,OAAOC,GAAG,MAAM,eAAe;AAC/B,OAAOC,UAAU,MAAM,YAAY;AAEnC,OAAOC,UAAU,MAAM,gBAAgB;AACvC,OAAOC,KAAK,MAAM,aAAa;AAC/B,OAAOC,SAAS,IAAiCC,eAAe,QAAO,SAAS;AAChF,SAAQC,kBAAkB,EAAEC,MAAM,QAAO,SAAS;AAElD,MAAMC,sBAAsB,GAAIC,IAAyB,IAAK;EAC5D,IAAI,CAACA,IAAI,EAAE;EAEX,MAAM;IAACC,KAAK;IAAE,GAAGC;EAAS,CAAC,GAAGF,IAAI;EAClC,MAAMG,MAAM,GAAGF,KAAK,IAAIH,MAAM,CAACG,KAAK,CAAC;EACrC,IAAI,CAACE,MAAM,EAAE,OAAOD,SAAS;EAE7B,MAAME,WAAW,GAAGD,MAAM,GACtB;IACE,GAAGN,kBAAkB;IACrBQ,MAAM,EAAE;MAAC,GAAGR,kBAAkB,CAACQ,MAAM;MAAE,GAAGF;IAAM;EAClD,CAAC,GACD,IAAI;EAER,OAAO;IACL,GAAGD,SAAS;IACZ,GAAGE;EACL,CAAC;AACH,CAAC;AAED,MAAME,MAAM,GAAIC,KAAkB,IAAK;EACrC,MAAM;IACJ,WAAW,EAAEC,QAAQ;IACrB,YAAY,EAAEC,SAAS;IACvBC,QAAQ;IACRC,KAAK;IACLC,OAAO,GAAAC,KAAO;IACdC,IAAI,GAAG,SAAS;IAChBC,cAAc;IACdf,IAAI;
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useMemo","useCallback","map","classnames","ButtonLink","style","propTypes","buttonPropTypes","DEFAULT_ICON_STYLE","THEMES","buildCustomIconByTheme","icon","theme","iconProps","custom","customProps","faIcon","Button","props","dataName","ariaLabel","disabled","label","onClick","_noop","type","buttonLinkType","customStyle","customLabelClassName","rest","styleButton","button","defaultStyle","defaultLeft","dangerous","dangerousLeft","handleOnClick","buttonLinkProps","className","createElement","_extends","process","env","NODE_ENV","ButtonMenu","buttons","enableScroll","buildButton","index","key","buttonList","convert","cap","containerStyle","buttonMenuContainer","scrollable"],"sources":["../../../src/atom/button-menu/index.tsx"],"sourcesContent":["import React, {useMemo, useCallback} from 'react';\nimport map from 'lodash/fp/map';\nimport classnames from 'classnames';\nimport {noop} from 'lodash/fp';\nimport ButtonLink from '../button-link';\nimport style from './style.css';\nimport propTypes, {ButtonMenuProps, ButtonProps, buttonPropTypes} from './types';\nimport {DEFAULT_ICON_STYLE, THEMES} from './utils';\n\nconst buildCustomIconByTheme = (icon: ButtonProps['icon']) => {\n if (!icon) return;\n\n const {theme, ...iconProps} = icon;\n const custom = theme && THEMES[theme];\n if (!custom) return iconProps;\n\n const customProps = custom\n ? {\n ...DEFAULT_ICON_STYLE,\n faIcon: {...DEFAULT_ICON_STYLE.faIcon, ...custom}\n }\n : null;\n\n return {\n ...iconProps,\n ...customProps\n };\n};\n\nconst Button = (props: ButtonProps) => {\n const {\n 'data-name': dataName,\n 'aria-label': ariaLabel,\n disabled,\n label,\n onClick = noop,\n type = 'default',\n buttonLinkType,\n icon,\n customStyle = {},\n customLabelClassName,\n ...rest\n } = props;\n const styleButton = classnames(\n style.button,\n type === 'default' && style.defaultStyle,\n type === 'defaultLeft' && style.defaultLeft,\n type === 'dangerous' && style.dangerous,\n type === 'dangerousLeft' && style.dangerousLeft,\n disabled && style.disabled\n );\n const handleOnClick = useCallback(() => onClick(), [onClick]);\n\n const buttonLinkProps = {\n ...rest,\n 'aria-label': ariaLabel || label,\n disabled,\n label,\n type: buttonLinkType,\n onClick: handleOnClick,\n 'data-name': dataName,\n className: styleButton,\n customStyle: {...customStyle},\n customLabelClassName\n };\n\n const iconProps = buildCustomIconByTheme(icon);\n\n return <ButtonLink {...buttonLinkProps} icon={iconProps} />;\n};\n\nButton.propTypes = buttonPropTypes;\n\nconst ButtonMenu = (props: ButtonMenuProps) => {\n const {buttons, 'data-name': dataName, enableScroll = false} = props;\n const buildButton = useCallback((button: ButtonProps, index) => {\n return <Button {...button} key={button.label + index} />;\n }, []);\n\n const buttonList = useMemo(\n // @ts-expect-error (to avoid using map as any)\n () => map.convert({cap: false})(buildButton, buttons),\n [buttons, buildButton]\n );\n\n const containerStyle = classnames(style.buttonMenuContainer, {\n [style.scrollable]: enableScroll\n });\n\n return (\n <div data-name={dataName} className={containerStyle}>\n {buttonList}\n </div>\n );\n};\n\nButtonMenu.propTypes = propTypes;\n\nexport default ButtonMenu;\n"],"mappings":";;AAAA,OAAOA,KAAK,IAAGC,OAAO,EAAEC,WAAW,QAAO,OAAO;AACjD,OAAOC,GAAG,MAAM,eAAe;AAC/B,OAAOC,UAAU,MAAM,YAAY;AAEnC,OAAOC,UAAU,MAAM,gBAAgB;AACvC,OAAOC,KAAK,MAAM,aAAa;AAC/B,OAAOC,SAAS,IAAiCC,eAAe,QAAO,SAAS;AAChF,SAAQC,kBAAkB,EAAEC,MAAM,QAAO,SAAS;AAElD,MAAMC,sBAAsB,GAAIC,IAAy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;EAAe,GACjDH,UACE,CAAC;AAEV,CAAC;AAEDN,UAAU,CAACtC,SAAS,GAAAmC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAGrC,SAAS;AAEhC,eAAesC,UAAU","ignoreList":[]}
|
|
@@ -16,7 +16,9 @@ export declare const buttonPropTypes: {
|
|
|
16
16
|
color: PropTypes.Requireable<string>;
|
|
17
17
|
backgroundColor: PropTypes.Requireable<string>;
|
|
18
18
|
size: PropTypes.Requireable<number>;
|
|
19
|
-
customStyle: PropTypes.Requireable<
|
|
19
|
+
customStyle: PropTypes.Requireable<{
|
|
20
|
+
[x: string]: NonNullable<string | number | null | undefined> | null | undefined;
|
|
21
|
+
}>;
|
|
20
22
|
}>>;
|
|
21
23
|
}>>;
|
|
22
24
|
customStyle: PropTypes.Requireable<{
|
|
@@ -41,7 +43,9 @@ declare const propTypes: {
|
|
|
41
43
|
color: PropTypes.Requireable<string>;
|
|
42
44
|
backgroundColor: PropTypes.Requireable<string>;
|
|
43
45
|
size: PropTypes.Requireable<number>;
|
|
44
|
-
customStyle: PropTypes.Requireable<
|
|
46
|
+
customStyle: PropTypes.Requireable<{
|
|
47
|
+
[x: string]: NonNullable<string | number | null | undefined> | null | undefined;
|
|
48
|
+
}>;
|
|
45
49
|
}>>;
|
|
46
50
|
}>>;
|
|
47
51
|
customStyle: PropTypes.Requireable<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/atom/button-menu/types.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAC,eAAe,EAAE,QAAQ,EAAgB,MAAM,sBAAsB,CAAC;AAE9E,eAAO,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/atom/button-menu/types.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAC,eAAe,EAAE,QAAQ,EAAgB,MAAM,sBAAsB,CAAC;AAE9E,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;CAa3B,CAAC;AAEF,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKd,CAAC;AAEF,eAAe,SAAS,CAAC;AAEzB,oBAAY,KAAK,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,CAAC;AAEzD,oBAAY,WAAW,GAAG,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG;IACjE,IAAI,CAAC,EAAE,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,eAAe,CAAC;IACjE,cAAc,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IACzC,IAAI,CAAC,EAAE,QAAQ,GAAG;QAAC,KAAK,CAAC,EAAE,KAAK,CAAA;KAAC,CAAC;IAClC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF,oBAAY,eAAe,GAAG;IAC5B,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,oBAAY,sBAAsB,GAAG;IAAC,KAAK,EAAE,eAAe,CAAA;CAAC,CAAC"}
|
|
@@ -41,17 +41,7 @@ declare const RadioWithTitle: {
|
|
|
41
41
|
tooltipPlacement: import("prop-types").Requireable<string>;
|
|
42
42
|
'data-name': import("prop-types").Requireable<string>;
|
|
43
43
|
'data-testid': import("prop-types").Requireable<string>;
|
|
44
|
-
icon: import("prop-types").Requireable<
|
|
45
|
-
position: import("prop-types").Requireable<string>;
|
|
46
|
-
type: import("prop-types").Requireable<string>;
|
|
47
|
-
faIcon: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
48
|
-
name: import("prop-types").Validator<string>;
|
|
49
|
-
color: import("prop-types").Requireable<string>;
|
|
50
|
-
backgroundColor: import("prop-types").Requireable<string>;
|
|
51
|
-
size: import("prop-types").Requireable<number>;
|
|
52
|
-
customStyle: import("prop-types").Requireable<object>;
|
|
53
|
-
}>>;
|
|
54
|
-
}> | (import("prop-types").InferProps<{
|
|
44
|
+
icon: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
55
45
|
position: import("prop-types").Requireable<string>;
|
|
56
46
|
type: import("prop-types").Requireable<string>;
|
|
57
47
|
faIcon: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
@@ -59,9 +49,11 @@ declare const RadioWithTitle: {
|
|
|
59
49
|
color: import("prop-types").Requireable<string>;
|
|
60
50
|
backgroundColor: import("prop-types").Requireable<string>;
|
|
61
51
|
size: import("prop-types").Requireable<number>;
|
|
62
|
-
customStyle: import("prop-types").Requireable<
|
|
52
|
+
customStyle: import("prop-types").Requireable<{
|
|
53
|
+
[x: string]: NonNullable<string | number | null | undefined> | null | undefined;
|
|
54
|
+
}>;
|
|
63
55
|
}>>;
|
|
64
|
-
}
|
|
56
|
+
}>>;
|
|
65
57
|
onClick: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
66
58
|
link: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
67
59
|
href: import("prop-types").Requireable<string>;
|
|
@@ -72,8 +64,9 @@ declare const RadioWithTitle: {
|
|
|
72
64
|
hoverColor: import("prop-types").Requireable<string>;
|
|
73
65
|
disabled: import("prop-types").Requireable<boolean>;
|
|
74
66
|
className: import("prop-types").Requireable<string>;
|
|
75
|
-
customStyle: import("prop-types").Requireable<
|
|
76
|
-
|
|
67
|
+
customStyle: import("prop-types").Requireable<{
|
|
68
|
+
[x: string]: NonNullable<string | number | null | undefined> | null | undefined;
|
|
69
|
+
}>;
|
|
77
70
|
useTitle: import("prop-types").Requireable<boolean>;
|
|
78
71
|
customLabelClassName: import("prop-types").Requireable<string>;
|
|
79
72
|
}>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/radio-with-title/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAIzC,OAAO,EAAY,mBAAmB,EAAC,MAAM,SAAS,CAAC;AAEvD,QAAA,MAAM,cAAc;YAAW,mBAAmB
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/radio-with-title/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAIzC,OAAO,EAAY,mBAAmB,EAAC,MAAM,SAAS,CAAC;AAEvD,QAAA,MAAM,cAAc;YAAW,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwBjD,CAAC;AAIF,eAAe,cAAc,CAAC"}
|