@smart-react-components/ui 2.0.0-alpha-6 → 2.0.0-alpha-8
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/Button/ButtonAddon/index.d.ts +14 -0
- package/Button/ButtonAddon/index.js +17 -0
- package/Button/ButtonGroup/index.d.ts +6 -0
- package/Button/ButtonGroup/index.js +10 -0
- package/Button/ButtonLink/index.d.ts +8 -0
- package/Button/ButtonLink/index.js +26 -0
- package/Button/ButtonList/index.d.ts +8 -0
- package/Button/ButtonList/index.js +38 -0
- package/Button/ButtonLoading/index.d.ts +7 -0
- package/Button/ButtonLoading/index.js +18 -0
- package/Button/ButtonSelect/index.d.ts +12 -0
- package/Button/ButtonSelect/index.js +64 -0
- package/Button/index.d.ts +11 -0
- package/Button/index.js +90 -0
- package/Input/InputAddon/index.js +1 -1
- package/Input/InputFile/index.js +18 -14
- package/Input/InputNumber/index.js +18 -14
- package/Input/index.js +18 -14
- package/Modal/ModalBody/index.d.ts +3 -0
- package/Modal/ModalBody/index.js +16 -0
- package/Modal/ModalCloseIcon/index.d.ts +2 -0
- package/Modal/ModalCloseIcon/index.js +7 -0
- package/Modal/ModalFooter/index.d.ts +6 -0
- package/Modal/ModalFooter/index.js +21 -0
- package/Modal/ModalHeader/index.d.ts +6 -0
- package/Modal/ModalHeader/index.js +30 -0
- package/Modal/ModalTitle/index.d.ts +3 -0
- package/Modal/ModalTitle/index.js +11 -0
- package/Modal/index.d.ts +27 -0
- package/Modal/index.js +18 -0
- package/Overlay/OverlayElement.d.ts +4 -3
- package/Overlay/index.d.ts +1 -0
- package/Overlay/index.js +5 -1
- package/PopUp/Alert/index.d.ts +24 -0
- package/PopUp/Alert/index.js +50 -0
- package/PopUp/Confirm/index.d.ts +26 -0
- package/PopUp/Confirm/index.js +53 -0
- package/PopUp/Prompt/index.d.ts +28 -0
- package/PopUp/Prompt/index.js +64 -0
- package/Select/SelectBox/index.js +20 -42
- package/Select/index.js +18 -14
- package/components/Button/ButtonAddon/index.d.ts +15 -0
- package/components/Button/ButtonAddon/index.js +110 -0
- package/components/Button/ButtonContent/index.d.ts +2 -0
- package/components/Button/ButtonContent/index.js +20 -0
- package/components/Button/ButtonGroup/index.d.ts +3 -0
- package/components/Button/ButtonGroup/index.js +41 -0
- package/components/Button/ButtonList/index.d.ts +9 -0
- package/components/Button/ButtonList/index.js +31 -0
- package/components/Button/ButtonLoading/index.d.ts +6 -0
- package/components/Button/ButtonLoading/index.js +45 -0
- package/components/Button/index.d.ts +21 -0
- package/components/Button/index.js +268 -0
- package/components/Modal/Overlay/index.d.ts +7 -0
- package/components/Modal/Overlay/index.js +62 -0
- package/components/Modal/index.d.ts +11 -0
- package/components/Modal/index.js +65 -0
- package/hooks/useAddons.d.ts +16 -0
- package/hooks/{useInputAddons.js → useAddons.js} +8 -22
- package/hooks/useSelectBoxItemList.d.ts +14 -0
- package/hooks/useSelectBoxItemList.js +41 -0
- package/index.d.ts +16 -0
- package/index.js +33 -1
- package/package.json +7 -7
- package/types/button.d.ts +40 -0
- package/types/button.js +9 -0
- package/util/wave-effect.d.ts +21 -0
- package/util/wave-effect.js +43 -0
- package/hooks/useInputAddons.d.ts +0 -18
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ClickEvents } from '@smart-react-components/core/element-props/click-events';
|
|
2
|
+
import { ContentElement, PaletteProp, ResponsiveProp, SizeProp } from '@smart-react-components/core/types';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export interface Props extends Partial<ResponsiveProp<'size', SizeProp>>, ClickEvents {
|
|
5
|
+
children: ContentElement;
|
|
6
|
+
isDisabled?: boolean;
|
|
7
|
+
isOutline?: boolean;
|
|
8
|
+
isSeparated?: boolean;
|
|
9
|
+
isSoft?: boolean;
|
|
10
|
+
palette?: PaletteProp;
|
|
11
|
+
waveEffectPalette?: PaletteProp;
|
|
12
|
+
}
|
|
13
|
+
declare const ButtonAddon: React.FC<Props>;
|
|
14
|
+
export default ButtonAddon;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const element_props_1 = __importDefault(require("@smart-react-components/core/element-props"));
|
|
7
|
+
const click_events_1 = __importDefault(require("@smart-react-components/core/element-props/click-events"));
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const WaveEffect_1 = __importDefault(require("../../WaveEffect"));
|
|
10
|
+
const ButtonAddon_1 = __importDefault(require("../../components/Button/ButtonAddon"));
|
|
11
|
+
const wave_effect_1 = require("../../util/wave-effect");
|
|
12
|
+
const ButtonAddon = (props) => {
|
|
13
|
+
const El = (react_1.default.createElement(ButtonAddon_1.default, Object.assign({ addonPosition: props.position, buttonSize: props.size, buttonSizeSm: props.sizeSm, buttonSizeMd: props.sizeMd, buttonSizeLg: props.sizeLg, buttonSizeXl: props.sizeXl, hasHover: props.hasHover, isDisabled: props.isDisabled, isOutline: props.isOutline, isSeparated: props.isSeparated, isSoft: props.isSoft, palette: props.palette, shape: props.shape }, (!props.isDisabled && (0, element_props_1.default)(props, [click_events_1.default]))), props.children));
|
|
14
|
+
return props.isSeparated && props.hasWaveEffect ? react_1.default.createElement(WaveEffect_1.default, { palette: (0, wave_effect_1.getWaveEffectPalette)(props.waveEffectPalette, props.palette, props.isSoft) }, El) : El;
|
|
15
|
+
};
|
|
16
|
+
ButtonAddon.displayName = 'SRCAddon';
|
|
17
|
+
exports.default = ButtonAddon;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const ButtonGroup_1 = __importDefault(require("../../components/Button/ButtonGroup"));
|
|
8
|
+
const ButtonList_1 = __importDefault(require("../ButtonList"));
|
|
9
|
+
const ButtonGroup = props => (react_1.default.createElement(ButtonList_1.default, Object.assign({}, props, { hasSpace: false, template: react_1.default.createElement(ButtonGroup_1.default, null) }), props.children));
|
|
10
|
+
exports.default = ButtonGroup;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ContentElement } from '@smart-react-components/core/types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ButtonGenericProps } from '../../types/button';
|
|
4
|
+
export interface Props extends ButtonGenericProps<ContentElement> {
|
|
5
|
+
to: string;
|
|
6
|
+
}
|
|
7
|
+
declare const ButtonLink: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLAnchorElement>>;
|
|
8
|
+
export default ButtonLink;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const useLink_1 = __importDefault(require("@smart-react-components/router/hooks/useLink"));
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const __1 = __importDefault(require("../"));
|
|
9
|
+
const ButtonLink = react_1.default.forwardRef((props, forwardRef) => {
|
|
10
|
+
const { children, handleOnClick } = (0, useLink_1.default)({
|
|
11
|
+
children: props.children,
|
|
12
|
+
isDisabled: props.isDisabled,
|
|
13
|
+
to: props.to,
|
|
14
|
+
});
|
|
15
|
+
return (react_1.default.createElement(__1.default, Object.assign({}, props, { as: "a", elementProps: Object.assign(Object.assign({}, props.elementProps), { href: props.to, textDecoration: 'none' }), onClick: handleOnClick }), children));
|
|
16
|
+
});
|
|
17
|
+
ButtonLink.defaultProps = {
|
|
18
|
+
elementProps: {},
|
|
19
|
+
hasHover: true,
|
|
20
|
+
hasWaveEffect: true,
|
|
21
|
+
isLink: true,
|
|
22
|
+
palette: 'primary',
|
|
23
|
+
shape: 'rectangle',
|
|
24
|
+
size: 'medium',
|
|
25
|
+
};
|
|
26
|
+
exports.default = ButtonLink;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ButtonListGenericProps } from '../../types/button';
|
|
3
|
+
export interface Props extends ButtonListGenericProps {
|
|
4
|
+
hasSpace?: boolean;
|
|
5
|
+
template?: JSX.Element;
|
|
6
|
+
}
|
|
7
|
+
declare const ButtonList: React.FC<Props>;
|
|
8
|
+
export default ButtonList;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const element_props_1 = __importDefault(require("@smart-react-components/core/element-props"));
|
|
7
|
+
const intrinsic_styled_props_1 = __importDefault(require("@smart-react-components/core/element-props/intrinsic-styled-props"));
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const ButtonList_1 = __importDefault(require("../../components/Button/ButtonList"));
|
|
10
|
+
const ButtonList = props => {
|
|
11
|
+
var _a;
|
|
12
|
+
return react_1.default.cloneElement(props.template, Object.assign(Object.assign(Object.assign(Object.assign({}, (0, element_props_1.default)(props, [intrinsic_styled_props_1.default])), { buttonSize: (_a = props.size) !== null && _a !== void 0 ? _a : 'medium', buttonSizeSm: props.sizeSm, buttonSizeMd: props.sizeMd, buttonSizeLg: props.sizeLg, buttonSizeXl: props.sizeXl, hasSpace: props.hasSpace, isBlock: props.isBlock, length: props.children.length }), props.template.props), { children: props.children.map((item, idx) => {
|
|
13
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
14
|
+
return react_1.default.cloneElement(item, {
|
|
15
|
+
key: (_a = item.key) !== null && _a !== void 0 ? _a : idx,
|
|
16
|
+
hasHover: (_b = props.hasHover) !== null && _b !== void 0 ? _b : item.props.hasHover,
|
|
17
|
+
hasSpace: (_c = props.hasSpace) !== null && _c !== void 0 ? _c : item.props.hasSpace,
|
|
18
|
+
hasWaveEffect: (_d = props.hasWaveEffect) !== null && _d !== void 0 ? _d : item.props.hasWaveEffect,
|
|
19
|
+
isBlock: (_e = props.isBlock) !== null && _e !== void 0 ? _e : item.props.isBlock,
|
|
20
|
+
isLink: (_f = props.isLink) !== null && _f !== void 0 ? _f : item.props.isLink,
|
|
21
|
+
isOutline: (_g = props.isOutline) !== null && _g !== void 0 ? _g : item.props.isOutline,
|
|
22
|
+
isSoft: (_h = props.isSoft) !== null && _h !== void 0 ? _h : item.props.isSoft,
|
|
23
|
+
palette: (_j = props.palette) !== null && _j !== void 0 ? _j : item.props.palette,
|
|
24
|
+
shape: (_k = props.shape) !== null && _k !== void 0 ? _k : item.props.shape,
|
|
25
|
+
size: (_l = props.size) !== null && _l !== void 0 ? _l : item.props.size,
|
|
26
|
+
sizeSm: (_m = props.sizeSm) !== null && _m !== void 0 ? _m : item.props.sizeSm,
|
|
27
|
+
sizeMd: (_o = props.sizeMd) !== null && _o !== void 0 ? _o : item.props.sizeMd,
|
|
28
|
+
sizeLg: (_p = props.sizeLg) !== null && _p !== void 0 ? _p : item.props.sizeLg,
|
|
29
|
+
sizeXl: (_q = props.sizeXl) !== null && _q !== void 0 ? _q : item.props.sizeXl,
|
|
30
|
+
waveEffectPalette: props.waveEffectPalette,
|
|
31
|
+
});
|
|
32
|
+
}) }));
|
|
33
|
+
};
|
|
34
|
+
ButtonList.defaultProps = {
|
|
35
|
+
hasSpace: true,
|
|
36
|
+
template: react_1.default.createElement(ButtonList_1.default, null),
|
|
37
|
+
};
|
|
38
|
+
exports.default = ButtonList;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const CSSTransition_1 = __importDefault(require("@smart-react-components/transition/CSSTransition"));
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const ButtonLoading_1 = __importDefault(require("../../components/Button/ButtonLoading"));
|
|
9
|
+
const Loading_1 = __importDefault(require("../../Loading"));
|
|
10
|
+
const ButtonLoading = ({ children, hasAnimation = true, isOutline, isSoft, palette, status }) => {
|
|
11
|
+
const getColor = () => `!${palette}.${!isSoft
|
|
12
|
+
? !isOutline ? 'font' : 'main'
|
|
13
|
+
: !isOutline ? 'softFont' : 'soft'}`;
|
|
14
|
+
return (react_1.default.createElement(CSSTransition_1.default, { className: "src-button-loading", duration: 300, hasHideAnimation: hasAnimation, hasShowAnimation: hasAnimation, status: status },
|
|
15
|
+
react_1.default.createElement(ButtonLoading_1.default, { hasAnimation: hasAnimation }, children !== null && children !== void 0 ? children : react_1.default.createElement(Loading_1.default, { color: getColor() }))));
|
|
16
|
+
};
|
|
17
|
+
ButtonLoading.displayName = 'SRCLoading';
|
|
18
|
+
exports.default = ButtonLoading;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SetState } from '@smart-react-components/core/types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { FormValue } from '../../types';
|
|
4
|
+
import { ButtonGenericProps } from '../../types/button';
|
|
5
|
+
interface Props extends ButtonGenericProps<JSX.Element> {
|
|
6
|
+
active: FormValue | FormValue[];
|
|
7
|
+
hasHover?: boolean;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
setActive: SetState<FormValue | FormValue[]>;
|
|
10
|
+
}
|
|
11
|
+
declare const ButtonSelect: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
|
|
12
|
+
export default ButtonSelect;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const useChangeEffect_1 = __importDefault(require("@smart-react-components/core/hooks/useChangeEffect"));
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const __1 = __importDefault(require("../"));
|
|
9
|
+
const __2 = require("../..");
|
|
10
|
+
const Dropdown_1 = __importDefault(require("../../Dropdown"));
|
|
11
|
+
const DropdownListElement_1 = __importDefault(require("../../Dropdown/DropdownList/DropdownListElement"));
|
|
12
|
+
const useSelectBoxItemList_1 = __importDefault(require("../../hooks/useSelectBoxItemList"));
|
|
13
|
+
const ButtonSelect = react_1.default.forwardRef((props, forwardRef) => {
|
|
14
|
+
const ref = react_1.default.useRef(null);
|
|
15
|
+
const { itemList } = (0, useSelectBoxItemList_1.default)({ children: props.children });
|
|
16
|
+
const getContent = () => {
|
|
17
|
+
var _a;
|
|
18
|
+
if (typeof props.active === 'undefined'
|
|
19
|
+
|| props.active === null
|
|
20
|
+
|| props.active.length === 0) {
|
|
21
|
+
return props.placeholder;
|
|
22
|
+
}
|
|
23
|
+
if (!Array.isArray(props.active)) {
|
|
24
|
+
return (_a = itemList[String(props.active)]) === null || _a === void 0 ? void 0 : _a.children;
|
|
25
|
+
}
|
|
26
|
+
return (react_1.default.createElement("span", null, props.active
|
|
27
|
+
.sort((a, b) => itemList[String(a)].idx < itemList[String(b)].idx ? -1 : 1)
|
|
28
|
+
.map((item, idx) => (react_1.default.createElement(react_1.default.Fragment, { key: String(item) },
|
|
29
|
+
react_1.default.createElement("span", null, itemList[String(item)].children),
|
|
30
|
+
idx + 1 < props.active.length ? ', ' : '')))));
|
|
31
|
+
};
|
|
32
|
+
const [content, setContent] = react_1.default.useState(() => getContent());
|
|
33
|
+
const [dropdownStatus, setDropdownStatus] = react_1.default.useState(false);
|
|
34
|
+
(0, useChangeEffect_1.default)(() => {
|
|
35
|
+
setContent(getContent());
|
|
36
|
+
}, [props.active, props.placeholder, itemList]);
|
|
37
|
+
(0, useChangeEffect_1.default)(() => {
|
|
38
|
+
const event = new Event('src.fixedBox.setPosition');
|
|
39
|
+
(forwardRef !== null && forwardRef !== void 0 ? forwardRef : ref).current.dispatchEvent(event);
|
|
40
|
+
}, [content]);
|
|
41
|
+
const handleOptionClick = active => {
|
|
42
|
+
props.setActive(active);
|
|
43
|
+
if (!Array.isArray(active)) {
|
|
44
|
+
setDropdownStatus(false);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return (react_1.default.createElement(Dropdown_1.default, { status: dropdownStatus, setStatus: setDropdownStatus },
|
|
48
|
+
react_1.default.createElement(__1.default, Object.assign({}, props, { as: "div", ref: forwardRef !== null && forwardRef !== void 0 ? forwardRef : ref }),
|
|
49
|
+
react_1.default.createElement("span", null, content),
|
|
50
|
+
react_1.default.createElement(__2.DropdownArrowIcon, null)),
|
|
51
|
+
react_1.default.createElement(DropdownListElement_1.default, { dropdownListSize: props.size, dropdownListSizeSm: props.sizeSm, dropdownListSizeMd: props.sizeMd, dropdownListSizeLg: props.sizeLg, dropdownListSizeXl: props.sizeXl, isOutline: props.isOutline, isSoft: props.isSoft, palette: props.palette }, (Array.isArray(props.children) ? props.children : [props.children]).map((item, idx) => {
|
|
52
|
+
var _a;
|
|
53
|
+
return react_1.default.cloneElement(item, Object.assign({ key: (_a = item.key) !== null && _a !== void 0 ? _a : idx, active: props.active, hasHover: props.hasHover, hasWaveEffect: props.hasWaveEffect, isEmbedded: false, isOutline: props.isOutline, isSoft: props.isSoft, palette: props.palette, setActive: handleOptionClick, waveEffectPalette: props.waveEffectPalette }, (props.isDisabled && { isDisabled: true })));
|
|
54
|
+
}))));
|
|
55
|
+
});
|
|
56
|
+
ButtonSelect.defaultProps = {
|
|
57
|
+
hasHover: true,
|
|
58
|
+
hasWaveEffect: true,
|
|
59
|
+
palette: 'primary',
|
|
60
|
+
shape: 'rectangle',
|
|
61
|
+
size: 'medium',
|
|
62
|
+
waveEffectPalette: 'light',
|
|
63
|
+
};
|
|
64
|
+
exports.default = ButtonSelect;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ClickEvents } from '@smart-react-components/core/element-props/click-events';
|
|
2
|
+
import { ContentElement } from '@smart-react-components/core/types';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { StyledComponent } from 'styled-components';
|
|
5
|
+
import { ButtonGenericProps, ButtonType } from '../types/button';
|
|
6
|
+
export interface Props extends ButtonGenericProps<ContentElement>, ClickEvents {
|
|
7
|
+
as?: string | StyledComponent<any, any>;
|
|
8
|
+
type?: ButtonType;
|
|
9
|
+
}
|
|
10
|
+
declare const Button: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLElement>>;
|
|
11
|
+
export default Button;
|
package/Button/index.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Div_1 = __importDefault(require("@smart-react-components/core/Element/Div"));
|
|
7
|
+
const element_props_1 = __importDefault(require("@smart-react-components/core/element-props"));
|
|
8
|
+
const click_events_1 = __importDefault(require("@smart-react-components/core/element-props/click-events"));
|
|
9
|
+
const intrinsic_styled_props_1 = __importDefault(require("@smart-react-components/core/element-props/intrinsic-styled-props"));
|
|
10
|
+
const react_1 = __importDefault(require("react"));
|
|
11
|
+
const styled_components_1 = require("styled-components");
|
|
12
|
+
const ButtonAddon_1 = __importDefault(require("./ButtonAddon"));
|
|
13
|
+
const Button_1 = __importDefault(require("../components/Button"));
|
|
14
|
+
const ButtonContent_1 = __importDefault(require("../components/Button/ButtonContent"));
|
|
15
|
+
const useAddons_1 = __importDefault(require("../hooks/useAddons"));
|
|
16
|
+
const wave_effect_1 = require("../util/wave-effect");
|
|
17
|
+
const WaveEffect_1 = __importDefault(require("../WaveEffect"));
|
|
18
|
+
const useChangeEffect_1 = __importDefault(require("@smart-react-components/core/hooks/useChangeEffect"));
|
|
19
|
+
const ButtonLoading_1 = __importDefault(require("./ButtonLoading"));
|
|
20
|
+
const button_1 = require("../types/button");
|
|
21
|
+
const Button = react_1.default.forwardRef((props, forwardRef) => {
|
|
22
|
+
var _a, _b, _c, _d, _e, _f;
|
|
23
|
+
const theme = react_1.default.useContext(styled_components_1.ThemeContext);
|
|
24
|
+
const { leftAddon, rightAddon } = (0, useAddons_1.default)({
|
|
25
|
+
Component: ButtonAddon_1.default,
|
|
26
|
+
leftAddon: props.leftAddon,
|
|
27
|
+
rightAddon: props.rightAddon,
|
|
28
|
+
props: {
|
|
29
|
+
hasHover: props.hasHover,
|
|
30
|
+
hasWaveEffect: props.hasWaveEffect,
|
|
31
|
+
isOutline: props.isOutline,
|
|
32
|
+
isSoft: props.isSoft,
|
|
33
|
+
palette: props.palette,
|
|
34
|
+
shape: props.shape,
|
|
35
|
+
size: props.size,
|
|
36
|
+
sizeSm: props.sizeSm,
|
|
37
|
+
sizeMd: props.sizeMd,
|
|
38
|
+
sizeLg: props.sizeLg,
|
|
39
|
+
sizeXl: props.sizeXl,
|
|
40
|
+
waveEffectPalette: props.waveEffectPalette,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
const getLoadingEl = () => {
|
|
44
|
+
var _a;
|
|
45
|
+
if (!props.loading) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const loadingProps = {
|
|
49
|
+
isOutline: props.isOutline,
|
|
50
|
+
isSoft: props.isSoft,
|
|
51
|
+
palette: props.palette,
|
|
52
|
+
status: props.isLoading,
|
|
53
|
+
};
|
|
54
|
+
if (((_a = props.loading.type) === null || _a === void 0 ? void 0 : _a.displayName) === 'SRCLoading') {
|
|
55
|
+
return react_1.default.cloneElement(props.loading, loadingProps);
|
|
56
|
+
}
|
|
57
|
+
return react_1.default.createElement(ButtonLoading_1.default, Object.assign({}, loadingProps), props.loading);
|
|
58
|
+
};
|
|
59
|
+
const [loadingEl, setLoadingEl] = react_1.default.useState(() => getLoadingEl());
|
|
60
|
+
(0, useChangeEffect_1.default)(() => {
|
|
61
|
+
setLoadingEl(getLoadingEl());
|
|
62
|
+
}, [props.loading, props.isLoading]);
|
|
63
|
+
const applyIntrinsicStyledProps = () => (Object.assign(Object.assign({}, (0, element_props_1.default)(props, [intrinsic_styled_props_1.default])), (props.hasSpace && Object.assign(Object.assign(Object.assign(Object.assign({ margin: `$size.button.${props.size}.margin.y $size.button.${props.size}.margin.x` }, (props.sizeSm && { marginSm: `$size.button.${props.sizeSm}.margin.y $size.button.${props.sizeSm}.margin.x` })), (props.sizeMd && { marginMd: `$size.button.${props.sizeMd}.margin.y $size.button.${props.sizeMd}.margin.x` })), (props.sizeLg && { marginLg: `$size.button.${props.sizeLg}.margin.y $size.button.${props.sizeLg}.margin.x` })), (props.sizeXl && { marginXl: `$size.button.${props.sizeXl}.margin.y $size.button.${props.sizeXl}.margin.x` })))));
|
|
64
|
+
const hasButtonContainer = ((_a = leftAddon === null || leftAddon === void 0 ? void 0 : leftAddon.props) === null || _a === void 0 ? void 0 : _a.isSeparated) || ((_b = rightAddon === null || rightAddon === void 0 ? void 0 : rightAddon.props) === null || _b === void 0 ? void 0 : _b.isSeparated);
|
|
65
|
+
let Element = (react_1.default.createElement(Button_1.default, Object.assign({}, props.elementProps, ((!props.isDisabled && !props.isLoading) && (0, element_props_1.default)(props, [click_events_1.default])), (!hasButtonContainer && applyIntrinsicStyledProps()), (props.as && { as: props.as }), { buttonSize: props.size, buttonSizeSm: props.sizeSm, buttonSizeMd: props.sizeMd, buttonSizeLg: props.sizeLg, buttonSizeXl: props.sizeXl, hasButtonContainer: hasButtonContainer, hasHover: props.hasHover, hasLeftAddon: !!leftAddon, hasRightAddon: !!rightAddon, hasSeparatedLeftAddon: !!((_c = leftAddon === null || leftAddon === void 0 ? void 0 : leftAddon.props) === null || _c === void 0 ? void 0 : _c.isSeparated), hasSeparatedRightAddon: !!((_d = rightAddon === null || rightAddon === void 0 ? void 0 : rightAddon.props) === null || _d === void 0 ? void 0 : _d.isSeparated), isBlock: props.isBlock, isDisabled: props.isDisabled, isFixedSize: props.isFixedSize, isLink: props.isLink, isLoading: props.isLoading, isSoft: props.isSoft, isOutline: props.isOutline, palette: props.palette, ref: forwardRef, shape: props.shape }),
|
|
66
|
+
loadingEl && loadingEl,
|
|
67
|
+
(leftAddon && !leftAddon.props.isSeparated) && leftAddon,
|
|
68
|
+
react_1.default.createElement(ButtonContent_1.default, null, props.children),
|
|
69
|
+
(rightAddon && !rightAddon.props.isSeparated) && rightAddon));
|
|
70
|
+
if (props.hasWaveEffect) {
|
|
71
|
+
Element = react_1.default.createElement(WaveEffect_1.default, { palette: (0, wave_effect_1.getWaveEffectPalette)(props.waveEffectPalette, props.palette, props.isSoft, props.isLink, theme.$.vars.isDarkMode) }, Element);
|
|
72
|
+
}
|
|
73
|
+
if (hasButtonContainer) {
|
|
74
|
+
Element = (react_1.default.createElement(Div_1.default, Object.assign({}, applyIntrinsicStyledProps(), { display: props.isBlock ? 'flex' : 'inline-flex' }),
|
|
75
|
+
((_e = leftAddon === null || leftAddon === void 0 ? void 0 : leftAddon.props) === null || _e === void 0 ? void 0 : _e.isSeparated) && leftAddon,
|
|
76
|
+
Element,
|
|
77
|
+
((_f = rightAddon === null || rightAddon === void 0 ? void 0 : rightAddon.props) === null || _f === void 0 ? void 0 : _f.isSeparated) && rightAddon));
|
|
78
|
+
}
|
|
79
|
+
return Element;
|
|
80
|
+
});
|
|
81
|
+
Button.defaultProps = {
|
|
82
|
+
elementProps: {},
|
|
83
|
+
hasHover: true,
|
|
84
|
+
hasWaveEffect: true,
|
|
85
|
+
palette: 'primary',
|
|
86
|
+
shape: 'rectangle',
|
|
87
|
+
size: 'medium',
|
|
88
|
+
type: button_1.ButtonType.BUTTON,
|
|
89
|
+
};
|
|
90
|
+
exports.default = Button;
|
|
@@ -8,5 +8,5 @@ const click_events_1 = __importDefault(require("@smart-react-components/core/ele
|
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const InputAddonElement_1 = __importDefault(require("./InputAddonElement"));
|
|
10
10
|
const InputAddon = (props) => (react_1.default.createElement(InputAddonElement_1.default, Object.assign({ addonPosition: props.position, hasBorder: props.hasBorder, inputSize: props.size, inputSizeSm: props.sizeSm, inputSizeMd: props.sizeMd, inputSizeLg: props.sizeLg, inputSizeXl: props.sizeXl, isDisabled: props.isDisabled, isFocused: props.isFocused, isOutline: props.isOutline, isSeparated: props.isSeparated, isSoft: props.isSoft, palette: props.palette, shape: props.shape }, (0, element_props_1.default)(props, [click_events_1.default])), props.children));
|
|
11
|
-
InputAddon.displayName = '
|
|
11
|
+
InputAddon.displayName = 'SRCAddon';
|
|
12
12
|
exports.default = InputAddon;
|
package/Input/InputFile/index.js
CHANGED
|
@@ -8,10 +8,11 @@ const element_props_1 = __importDefault(require("@smart-react-components/core/el
|
|
|
8
8
|
const intrinsic_styled_props_1 = __importDefault(require("@smart-react-components/core/element-props/intrinsic-styled-props"));
|
|
9
9
|
const react_1 = __importDefault(require("react"));
|
|
10
10
|
const FormBlockLabel_1 = __importDefault(require("../../components/FormBlockLabel"));
|
|
11
|
-
const
|
|
11
|
+
const useAddons_1 = __importDefault(require("../../hooks/useAddons"));
|
|
12
12
|
const InputFileTemplate_1 = __importDefault(require("./InputFileTemplate"));
|
|
13
13
|
const HiddenInput_1 = __importDefault(require("../../components/HiddenInput"));
|
|
14
14
|
const useInputMethods_1 = __importDefault(require("../../hooks/useInputMethods"));
|
|
15
|
+
const InputAddon_1 = __importDefault(require("../InputAddon"));
|
|
15
16
|
const InputFile = react_1.default.forwardRef((props, forwardRef) => {
|
|
16
17
|
var _a, _b;
|
|
17
18
|
const ref = react_1.default.useRef(null);
|
|
@@ -19,21 +20,24 @@ const InputFile = react_1.default.forwardRef((props, forwardRef) => {
|
|
|
19
20
|
isDisabled: props.isDisabled,
|
|
20
21
|
isReadOnly: false,
|
|
21
22
|
});
|
|
22
|
-
const { leftAddon, rightAddon } = (0,
|
|
23
|
-
|
|
24
|
-
isDisabled: props.isDisabled,
|
|
25
|
-
isFocused,
|
|
26
|
-
isOutline: props.isOutline,
|
|
27
|
-
isSoft: props.isSoft,
|
|
23
|
+
const { leftAddon, rightAddon } = (0, useAddons_1.default)({
|
|
24
|
+
Component: InputAddon_1.default,
|
|
28
25
|
leftAddon: props.leftAddon,
|
|
29
|
-
palette: props.palette,
|
|
30
26
|
rightAddon: props.rightAddon,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
props: {
|
|
28
|
+
hasBorder: props.hasBorder,
|
|
29
|
+
isDisabled: props.isDisabled,
|
|
30
|
+
isFocused,
|
|
31
|
+
isOutline: props.isOutline,
|
|
32
|
+
isSoft: props.isSoft,
|
|
33
|
+
palette: props.palette,
|
|
34
|
+
shape: props.shape,
|
|
35
|
+
size: props.size,
|
|
36
|
+
sizeSm: props.sizeSm,
|
|
37
|
+
sizeMd: props.sizeMd,
|
|
38
|
+
sizeLg: props.sizeLg,
|
|
39
|
+
sizeXl: props.sizeXl,
|
|
40
|
+
},
|
|
37
41
|
});
|
|
38
42
|
const handleOnChange = (e) => {
|
|
39
43
|
if (props.isDisabled) {
|
|
@@ -11,9 +11,10 @@ const intrinsic_styled_props_1 = __importDefault(require("@smart-react-component
|
|
|
11
11
|
const keyboard_events_1 = __importDefault(require("@smart-react-components/core/element-props/keyboard-events"));
|
|
12
12
|
const react_1 = __importDefault(require("react"));
|
|
13
13
|
const FormBlockLabel_1 = __importDefault(require("../../components/FormBlockLabel"));
|
|
14
|
-
const
|
|
14
|
+
const useAddons_1 = __importDefault(require("../../hooks/useAddons"));
|
|
15
15
|
const useInputMethods_1 = __importDefault(require("../../hooks/useInputMethods"));
|
|
16
16
|
const InputNumberTemplate_1 = __importDefault(require("./InputNumberTemplate"));
|
|
17
|
+
const InputAddon_1 = __importDefault(require("../InputAddon"));
|
|
17
18
|
const InputNumber = react_1.default.forwardRef((props, forwardRef) => {
|
|
18
19
|
var _a, _b, _c, _d;
|
|
19
20
|
/**
|
|
@@ -44,21 +45,24 @@ const InputNumber = react_1.default.forwardRef((props, forwardRef) => {
|
|
|
44
45
|
onFocus: props.onFocus,
|
|
45
46
|
setValue: value => { var _a; return (_a = props.setValue) === null || _a === void 0 ? void 0 : _a.call(props, applyNumberFormat(value)); },
|
|
46
47
|
});
|
|
47
|
-
const { leftAddon, rightAddon } = (0,
|
|
48
|
-
|
|
49
|
-
isDisabled: props.isDisabled,
|
|
50
|
-
isFocused,
|
|
51
|
-
isOutline: props.isOutline,
|
|
52
|
-
isSoft: props.isSoft,
|
|
48
|
+
const { leftAddon, rightAddon } = (0, useAddons_1.default)({
|
|
49
|
+
Component: InputAddon_1.default,
|
|
53
50
|
leftAddon: props.leftAddon,
|
|
54
|
-
palette: props.palette,
|
|
55
51
|
rightAddon: props.rightAddon,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
props: {
|
|
53
|
+
hasBorder: props.hasBorder,
|
|
54
|
+
isDisabled: props.isDisabled,
|
|
55
|
+
isFocused,
|
|
56
|
+
isOutline: props.isOutline,
|
|
57
|
+
isSoft: props.isSoft,
|
|
58
|
+
palette: props.palette,
|
|
59
|
+
shape: props.shape,
|
|
60
|
+
size: props.size,
|
|
61
|
+
sizeSm: props.sizeSm,
|
|
62
|
+
sizeMd: props.sizeMd,
|
|
63
|
+
sizeLg: props.sizeLg,
|
|
64
|
+
sizeXl: props.sizeXl,
|
|
65
|
+
},
|
|
62
66
|
});
|
|
63
67
|
return (react_1.default.createElement(FormBlockLabel_1.default, Object.assign({}, (0, element_props_1.default)(props, [intrinsic_styled_props_1.default]), { formSize: props.size, formSizeSm: props.sizeSm, formSizeMd: props.sizeMd, formSizeLg: props.sizeLg, formSizeXl: props.sizeXl, isBlock: props.isBlock, isDisabled: props.isDisabled }),
|
|
64
68
|
props.label && react_1.default.createElement("span", null, props.label),
|
package/Input/index.js
CHANGED
|
@@ -11,10 +11,11 @@ const intrinsic_styled_props_1 = __importDefault(require("@smart-react-component
|
|
|
11
11
|
const keyboard_events_1 = __importDefault(require("@smart-react-components/core/element-props/keyboard-events"));
|
|
12
12
|
const react_1 = __importDefault(require("react"));
|
|
13
13
|
const FormBlockLabel_1 = __importDefault(require("../components/FormBlockLabel"));
|
|
14
|
-
const
|
|
14
|
+
const useAddons_1 = __importDefault(require("../hooks/useAddons"));
|
|
15
15
|
const useInputMethods_1 = __importDefault(require("../hooks/useInputMethods"));
|
|
16
16
|
const types_1 = require("../types");
|
|
17
17
|
const InputElement_1 = __importDefault(require("./InputElement"));
|
|
18
|
+
const InputAddon_1 = __importDefault(require("./InputAddon"));
|
|
18
19
|
const Input = react_1.default.forwardRef((props, forwardRef) => {
|
|
19
20
|
var _a, _b;
|
|
20
21
|
const { handleOnBlur, handleOnChange, handleOnFocus, isFocused } = (0, useInputMethods_1.default)({
|
|
@@ -25,21 +26,24 @@ const Input = react_1.default.forwardRef((props, forwardRef) => {
|
|
|
25
26
|
onFocus: props.onFocus,
|
|
26
27
|
setValue: props.setValue,
|
|
27
28
|
});
|
|
28
|
-
const { leftAddon, rightAddon } = (0,
|
|
29
|
-
|
|
30
|
-
isDisabled: props.isDisabled,
|
|
31
|
-
isFocused,
|
|
32
|
-
isOutline: props.isOutline,
|
|
33
|
-
isSoft: props.isSoft,
|
|
29
|
+
const { leftAddon, rightAddon } = (0, useAddons_1.default)({
|
|
30
|
+
Component: InputAddon_1.default,
|
|
34
31
|
leftAddon: props.leftAddon,
|
|
35
|
-
palette: props.palette,
|
|
36
32
|
rightAddon: props.rightAddon,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
props: {
|
|
34
|
+
hasBorder: props.hasBorder,
|
|
35
|
+
isDisabled: props.isDisabled,
|
|
36
|
+
isFocused,
|
|
37
|
+
isOutline: props.isOutline,
|
|
38
|
+
isSoft: props.isSoft,
|
|
39
|
+
palette: props.palette,
|
|
40
|
+
shape: props.shape,
|
|
41
|
+
size: props.size,
|
|
42
|
+
sizeSm: props.sizeSm,
|
|
43
|
+
sizeMd: props.sizeMd,
|
|
44
|
+
sizeLg: props.sizeLg,
|
|
45
|
+
sizeXl: props.sizeXl,
|
|
46
|
+
},
|
|
43
47
|
});
|
|
44
48
|
return (react_1.default.createElement(FormBlockLabel_1.default, Object.assign({}, (0, element_props_1.default)(props, [intrinsic_styled_props_1.default]), { formSize: props.size, formSizeSm: props.sizeSm, formSizeMd: props.sizeMd, formSizeLg: props.sizeLg, formSizeXl: props.sizeXl, isBlock: props.isBlock, isDisabled: props.isDisabled }),
|
|
45
49
|
props.label && react_1.default.createElement("span", null, props.label),
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Section_1 = __importDefault(require("@smart-react-components/core/Element/Section"));
|
|
7
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
8
|
+
exports.default = (0, styled_components_1.default)(Section_1.default) `
|
|
9
|
+
flex: 1 1 auto;
|
|
10
|
+
min-height: 1px;
|
|
11
|
+
overflow: auto;
|
|
12
|
+
|
|
13
|
+
> :last-child {
|
|
14
|
+
margin-bottom: 0;
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Close_1 = __importDefault(require("../../icons/Close"));
|
|
7
|
+
exports.default = Close_1.default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StyledProps } from '@smart-react-components/core/styled-props';
|
|
2
|
+
interface Props extends StyledProps {
|
|
3
|
+
hasBorder?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare const _default: import("styled-components").StyledComponent<"footer", any, StyledProps & Props, never>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Footer_1 = __importDefault(require("@smart-react-components/core/Element/Footer"));
|
|
7
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
8
|
+
const ButtonList_1 = __importDefault(require("../../components/Button/ButtonList"));
|
|
9
|
+
exports.default = (0, styled_components_1.default)(Footer_1.default)(({ theme, hasBorder = true }) => `
|
|
10
|
+
flex: 0 0 auto;
|
|
11
|
+
|
|
12
|
+
${hasBorder
|
|
13
|
+
? `
|
|
14
|
+
border-top: solid 1px ${theme.$.color.dynamic.accent};
|
|
15
|
+
`
|
|
16
|
+
: ''}
|
|
17
|
+
|
|
18
|
+
${ButtonList_1.default} {
|
|
19
|
+
justify-content: flex-end;
|
|
20
|
+
}
|
|
21
|
+
`);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StyledProps } from '@smart-react-components/core/styled-props';
|
|
2
|
+
interface Props extends StyledProps {
|
|
3
|
+
hasBorder?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare const _default: import("styled-components").StyledComponent<"header", any, StyledProps & Props, never>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Header_1 = __importDefault(require("@smart-react-components/core/Element/Header"));
|
|
7
|
+
const Svg_1 = __importDefault(require("@smart-react-components/core/Element/Svg"));
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
exports.default = (0, styled_components_1.default)(Header_1.default)(({ theme, hasBorder = true }) => `
|
|
10
|
+
align-items: center;
|
|
11
|
+
display: flex;
|
|
12
|
+
flex: 0 0 auto;
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
|
|
15
|
+
${hasBorder
|
|
16
|
+
? `
|
|
17
|
+
border-bottom: solid 1px ${theme.$.color.dynamic.accent};
|
|
18
|
+
`
|
|
19
|
+
: ''}
|
|
20
|
+
|
|
21
|
+
> ${Svg_1.default} {
|
|
22
|
+
box-sizing: content-box;
|
|
23
|
+
flex: 0 0 auto;
|
|
24
|
+
opacity: .5;
|
|
25
|
+
|
|
26
|
+
&:hover {
|
|
27
|
+
opacity: 1;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`);
|