@smart-react-components/ui 2.0.0-alpha-4 → 2.0.0-alpha-5

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.
Files changed (103) hide show
  1. package/Alert/AlertIcon/index.js +1 -1
  2. package/Alert/index.d.ts +1 -1
  3. package/Alert/index.js +38 -11
  4. package/Badge/BadgeElement.d.ts +1 -1
  5. package/Badge/BadgeElement.js +2 -2
  6. package/Badge/BadgeIcon/index.js +4 -2
  7. package/Badge/BadgeList/index.js +19 -7
  8. package/Badge/index.d.ts +1 -1
  9. package/Badge/index.js +37 -9
  10. package/Checkbox/CheckboxElement.d.ts +11 -0
  11. package/Checkbox/CheckboxElement.js +79 -0
  12. package/Checkbox/CheckboxGroup/index.d.ts +21 -0
  13. package/Checkbox/CheckboxGroup/index.js +17 -0
  14. package/Checkbox/index.d.ts +25 -0
  15. package/Checkbox/index.js +72 -0
  16. package/Input/InputAddon/InputAddonElement.d.ts +16 -0
  17. package/Input/InputAddon/InputAddonElement.js +90 -0
  18. package/Input/InputAddon/index.d.ts +12 -0
  19. package/Input/InputAddon/index.js +12 -0
  20. package/Input/InputElement.d.ts +19 -0
  21. package/Input/InputElement.js +154 -0
  22. package/Input/InputFile/InputFileTemplate.d.ts +21 -0
  23. package/Input/InputFile/InputFileTemplate.js +51 -0
  24. package/Input/InputFile/index.d.ts +23 -0
  25. package/Input/InputFile/index.js +95 -0
  26. package/Input/InputNumber/InputNumberTemplate.d.ts +16 -0
  27. package/Input/InputNumber/InputNumberTemplate.js +62 -0
  28. package/Input/InputNumber/InputNumberTemplateElement.d.ts +6 -0
  29. package/Input/InputNumber/InputNumberTemplateElement.js +58 -0
  30. package/Input/InputNumber/index.d.ts +30 -0
  31. package/Input/InputNumber/index.js +79 -0
  32. package/Input/index.d.ts +29 -0
  33. package/Input/index.js +61 -0
  34. package/Pagination/PaginationItem/PaginationItemElement.d.ts +13 -0
  35. package/Pagination/PaginationItem/PaginationItemElement.js +139 -0
  36. package/Pagination/PaginationItem/index.d.ts +21 -0
  37. package/Pagination/PaginationItem/index.js +17 -0
  38. package/Pagination/PaginationLink/index.d.ts +6 -0
  39. package/Pagination/PaginationLink/index.js +27 -0
  40. package/Pagination/PaginationList/PaginationListElement.d.ts +3 -0
  41. package/Pagination/PaginationList/PaginationListElement.js +15 -0
  42. package/Pagination/PaginationList/index.d.ts +16 -0
  43. package/Pagination/PaginationList/index.js +29 -0
  44. package/Pagination/PaginationNextIcon/index.d.ts +2 -0
  45. package/Pagination/PaginationNextIcon/index.js +7 -0
  46. package/Pagination/PaginationPrevIcon/index.d.ts +2 -0
  47. package/Pagination/PaginationPrevIcon/index.js +7 -0
  48. package/Pagination/index.d.ts +5 -0
  49. package/Pagination/index.js +16 -0
  50. package/Popover/PopoverElement.js +18 -18
  51. package/ProgressBar/ProgressBarElement.js +8 -7
  52. package/Radio/RadioElement.d.ts +10 -0
  53. package/Radio/RadioElement.js +74 -0
  54. package/Radio/RadioGroup/index.d.ts +20 -0
  55. package/Radio/RadioGroup/index.js +17 -0
  56. package/Radio/index.d.ts +22 -0
  57. package/Radio/index.js +46 -0
  58. package/Switch/SwitchElement.d.ts +3 -0
  59. package/Switch/SwitchElement.js +71 -0
  60. package/Switch/SwitchGroup/index.d.ts +6 -0
  61. package/Switch/SwitchGroup/index.js +11 -0
  62. package/Switch/index.d.ts +6 -0
  63. package/Switch/index.js +14 -0
  64. package/Textarea/TextareaAddon/index.d.ts +2 -0
  65. package/Textarea/TextareaAddon/index.js +7 -0
  66. package/Textarea/index.d.ts +10 -0
  67. package/Textarea/index.js +44 -0
  68. package/Tooltip/TooltipElement.js +5 -5
  69. package/components/FormBlockLabel/index.d.ts +8 -0
  70. package/components/FormBlockLabel/index.js +56 -0
  71. package/components/FormGroup/index.d.ts +6 -0
  72. package/components/FormGroup/index.js +17 -0
  73. package/components/FormInlineLabel/index.d.ts +10 -0
  74. package/components/FormInlineLabel/index.js +66 -0
  75. package/components/HiddenInput/index.d.ts +2 -0
  76. package/components/HiddenInput/index.js +15 -0
  77. package/hooks/useInputAddons.d.ts +18 -0
  78. package/hooks/useInputAddons.js +47 -0
  79. package/hooks/useInputMethods.d.ts +18 -0
  80. package/hooks/useInputMethods.js +49 -0
  81. package/icons/ArrowLeft.d.ts +6 -0
  82. package/icons/ArrowLeft.js +14 -0
  83. package/icons/ArrowRight.d.ts +6 -0
  84. package/icons/ArrowRight.js +14 -0
  85. package/icons/CaretDown.d.ts +6 -0
  86. package/icons/CaretDown.js +12 -0
  87. package/icons/CaretUp.d.ts +6 -0
  88. package/icons/CaretUp.js +12 -0
  89. package/index.d.ts +12 -0
  90. package/index.js +24 -1
  91. package/package.json +7 -7
  92. package/types/index.d.ts +10 -0
  93. package/types/index.js +10 -1
  94. package/util/css.d.ts +5 -0
  95. package/util/css.js +7 -1
  96. package/util/dom.d.ts +1 -0
  97. package/util/dom.js +2 -1
  98. package/util/form.d.ts +4 -0
  99. package/util/form.js +8 -0
  100. package/util/props.d.ts +0 -14
  101. package/util/props.js +1 -46
  102. package/util/radio.d.ts +4 -0
  103. package/util/radio.js +14 -0
@@ -0,0 +1,22 @@
1
+ import { IntrinsicStyledProps } from '@smart-react-components/core/element-props/intrinsic-styled-props';
2
+ import { ContentElement, PaletteProp, Partial, ResponsiveProp, SetState, SizeProp } from '@smart-react-components/core/types';
3
+ import React from 'react';
4
+ import { FormValue, OrderPosition } from '../types';
5
+ export { OrderPosition as Position } from '../types';
6
+ export interface Props extends Partial<ResponsiveProp<'size', SizeProp>>, IntrinsicStyledProps {
7
+ active?: FormValue;
8
+ isBlock?: boolean;
9
+ isDisabled?: boolean;
10
+ isOutline?: boolean;
11
+ isRequired?: boolean;
12
+ isSoft?: boolean;
13
+ label?: ContentElement;
14
+ name?: string;
15
+ palette?: PaletteProp;
16
+ position?: OrderPosition;
17
+ setActive?: SetState<FormValue>;
18
+ template?: JSX.Element;
19
+ value: FormValue;
20
+ }
21
+ declare const Radio: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLInputElement>>;
22
+ export default Radio;
package/Radio/index.js ADDED
@@ -0,0 +1,46 @@
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
+ exports.Position = void 0;
7
+ const element_props_1 = __importDefault(require("@smart-react-components/core/element-props"));
8
+ const intrinsic_styled_props_1 = __importDefault(require("@smart-react-components/core/element-props/intrinsic-styled-props"));
9
+ const react_1 = __importDefault(require("react"));
10
+ const FormInlineLabel_1 = __importDefault(require("../components/FormInlineLabel"));
11
+ const HiddenInput_1 = __importDefault(require("../components/HiddenInput"));
12
+ const types_1 = require("../types");
13
+ const RadioElement_1 = __importDefault(require("./RadioElement"));
14
+ var types_2 = require("../types");
15
+ Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return types_2.OrderPosition; } });
16
+ const Radio = react_1.default.forwardRef((props, forwardRef) => {
17
+ const handleOnChange = () => {
18
+ if (!props.isDisabled) {
19
+ props.setActive(props.value);
20
+ }
21
+ };
22
+ const input = (react_1.default.createElement(HiddenInput_1.default, Object.assign({ checked: props.value === props.active, onChange: handleOnChange, ref: forwardRef, type: "radio" }, (props.isDisabled && { disabled: true }), (props.isRequired && { required: true }), (props.name && { name: props.name }))));
23
+ return (react_1.default.createElement(FormInlineLabel_1.default, Object.assign({ formSize: props.size, formSizeSm: props.sizeSm, formSizeMd: props.sizeMd, formSizeLg: props.sizeLg, formSizeXl: props.sizeXl, isBlock: props.isBlock, isDisabled: props.isDisabled, labelPosition: props.position }, (0, element_props_1.default)(props, [intrinsic_styled_props_1.default])),
24
+ react_1.default.cloneElement(props.template, {
25
+ children: (react_1.default.createElement(react_1.default.Fragment, null,
26
+ input,
27
+ props.template.props.children)),
28
+ isChecked: props.value === props.active,
29
+ isOutline: props.isOutline,
30
+ isSoft: props.isSoft,
31
+ palette: props.palette,
32
+ radioSize: props.size,
33
+ radioSizeSm: props.sizeSm,
34
+ radioSizeMd: props.sizeMd,
35
+ radioSizeLg: props.sizeLg,
36
+ radioSizeXl: props.sizeXl,
37
+ }),
38
+ props.label && react_1.default.createElement("span", null, props.label)));
39
+ });
40
+ Radio.defaultProps = {
41
+ palette: 'primary',
42
+ position: types_1.OrderPosition.RIGHT,
43
+ size: 'medium',
44
+ template: react_1.default.createElement(RadioElement_1.default, null),
45
+ };
46
+ exports.default = Radio;
@@ -0,0 +1,3 @@
1
+ import { Props } from '../Checkbox/CheckboxElement';
2
+ declare const _default: import("styled-components").StyledComponent<"div", any, import("@smart-react-components/core").StyledProps & Props, never>;
3
+ export default _default;
@@ -0,0 +1,71 @@
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 react_1 = __importDefault(require("react"));
8
+ const styled_components_1 = __importDefault(require("styled-components"));
9
+ const css_1 = require("../util/css");
10
+ const Slider = styled_components_1.default.div(({ theme }) => `
11
+ background: ${theme.$.color.dynamic.background};
12
+ border-radius: 100%;
13
+ box-shadow: 0 1px 3px rgba(0,0,0,.4);
14
+ left: 0;
15
+ position: absolute;
16
+ top: 0;
17
+ transition: 200ms 0s ease-in-out;
18
+ transition-property: left, right;
19
+ `);
20
+ exports.default = (0, styled_components_1.default)(Div_1.default).attrs(({ children, isChecked }) => ({
21
+ children: (react_1.default.createElement(react_1.default.Fragment, null,
22
+ children,
23
+ react_1.default.createElement(Slider, null))),
24
+ getCheckboxSize: (v, t) => `
25
+ height: ${t.$.size.switch[v].height};
26
+ width: ${t.$.size.switch[v].width};
27
+
28
+ ${Slider} {
29
+ height: ${t.$.size.switch[v].slider};
30
+ width: ${t.$.size.switch[v].slider};
31
+
32
+ ${isChecked
33
+ ? `
34
+ left: ${(0, css_1.toCSSValue)(t.$.size.switch[v].width)(width => width - (0, css_1.extractNumberUnit)(t.$.size.switch[v].slider) - 2)};
35
+ `
36
+ : ''}
37
+ }
38
+ `,
39
+ }))(({ theme, isChecked, isOutline, isSoft, palette }) => `
40
+ border: solid 1px ${theme.$.color.dynamic.accent};
41
+ border-radius: 20px;
42
+ box-sizing: border-box;
43
+ position: relative;
44
+ transition: 400ms 0s ease-in-out;
45
+ transition-property: border, box-shadow;
46
+
47
+ ${!isOutline
48
+ ? `
49
+ background: ${theme.$.color.dynamic.accent};
50
+ box-shadow: ${theme.$.color.dynamic.accent} 0 0 0 0 inset;
51
+ `
52
+ : ''}
53
+
54
+ ${isChecked
55
+ ? `
56
+ transition: border 400ms 0s ease-in-out, box-shadow 400ms 0s ease-in-out, background 0s 400ms ease-in-out;
57
+
58
+ ${!isSoft
59
+ ? `
60
+ background: ${theme.$.palette[palette].main};
61
+ border-color: ${theme.$.palette[palette].main};
62
+ box-shadow: ${theme.$.palette[palette].main} 0 0 0 11px inset;
63
+ `
64
+ : `
65
+ background: ${theme.$.palette[palette].soft};
66
+ border-color: ${theme.$.palette[palette].soft};
67
+ box-shadow: ${theme.$.palette[palette].soft} 0 0 0 11px inset;
68
+ `}
69
+ `
70
+ : ''}
71
+ `);
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { Props as CheckboxGroupProps } from '../../Checkbox/CheckboxGroup';
3
+ export { OrderPosition as Position } from '../../types';
4
+ export declare type Props = Omit<CheckboxGroupProps, 'shape'>;
5
+ declare const SwitchGroup: React.FC<Props>;
6
+ export default SwitchGroup;
@@ -0,0 +1,11 @@
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
+ exports.Position = void 0;
7
+ const CheckboxGroup_1 = __importDefault(require("../../Checkbox/CheckboxGroup"));
8
+ var types_1 = require("../../types");
9
+ Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return types_1.OrderPosition; } });
10
+ const SwitchGroup = CheckboxGroup_1.default;
11
+ exports.default = SwitchGroup;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { Props as CheckboxProps } from '../Checkbox';
3
+ export { OrderPosition as Position } from '../types';
4
+ export declare type Props = Omit<CheckboxProps, 'shape'>;
5
+ declare const Switch: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLInputElement>>;
6
+ export default Switch;
@@ -0,0 +1,14 @@
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
+ exports.Position = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const Checkbox_1 = __importDefault(require("../Checkbox"));
9
+ const SwitchElement_1 = __importDefault(require("./SwitchElement"));
10
+ var types_1 = require("../types");
11
+ Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return types_1.OrderPosition; } });
12
+ const Switch = react_1.default.forwardRef((props, forwardRef) => react_1.default.createElement(Checkbox_1.default, Object.assign({}, props, { ref: forwardRef })));
13
+ Switch.defaultProps = Object.assign(Object.assign({}, Checkbox_1.default.defaultProps), { template: react_1.default.createElement(SwitchElement_1.default, null) });
14
+ exports.default = Switch;
@@ -0,0 +1,2 @@
1
+ import InputAddon from '../../Input/InputAddon';
2
+ export default InputAddon;
@@ -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 InputAddon_1 = __importDefault(require("../../Input/InputAddon"));
7
+ exports.default = InputAddon_1.default;
@@ -0,0 +1,10 @@
1
+ import { Property, Resize } from '@smart-react-components/core/styled-props/css-properties';
2
+ import React from 'react';
3
+ import { Props as InputProps } from '../Input';
4
+ export interface Props extends Omit<InputProps, 'type'> {
5
+ areaMaxHeight?: number;
6
+ areaMinHeight?: number;
7
+ resize?: Property<Resize>;
8
+ }
9
+ declare const Textarea: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLInputElement>>;
10
+ export default Textarea;
@@ -0,0 +1,44 @@
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 dom_1 = require("@smart-react-components/core/util/dom");
7
+ const react_1 = __importDefault(require("react"));
8
+ const Input_1 = __importDefault(require("../Input"));
9
+ const InputElement_1 = __importDefault(require("../Input/InputElement"));
10
+ const Textarea = react_1.default.forwardRef((props, forwardRef) => {
11
+ const ref = react_1.default.useRef(null);
12
+ const calculateHeight = () => {
13
+ const el = (forwardRef !== null && forwardRef !== void 0 ? forwardRef : ref).current;
14
+ if (!el) {
15
+ return;
16
+ }
17
+ el.style.height = 'auto';
18
+ let height = el.scrollHeight + 5;
19
+ if (height < props.areaMinHeight) {
20
+ height = props.areaMinHeight;
21
+ }
22
+ else if (props.areaMaxHeight > -1 && height > props.areaMaxHeight) {
23
+ height = props.areaMaxHeight;
24
+ }
25
+ el.style.height = `${height}px`;
26
+ };
27
+ react_1.default.useEffect(() => {
28
+ if (props.areaMaxHeight > -1 || props.areaMinHeight > -1) {
29
+ const calculateHeightDebounce = (0, dom_1.debounce)(calculateHeight);
30
+ (0, dom_1.addEventListener)(window, ['resize'], calculateHeightDebounce);
31
+ return () => {
32
+ (0, dom_1.removeEventListener)(window, ['resize'], calculateHeightDebounce);
33
+ };
34
+ }
35
+ }, [props.areaMaxHeight, props.areaMinHeight]);
36
+ react_1.default.useEffect(() => {
37
+ if (props.areaMaxHeight > -1 || props.areaMinHeight > -1) {
38
+ calculateHeight();
39
+ }
40
+ }, [props.value, props.areaMaxHeight, props.areaMinHeight]);
41
+ return (react_1.default.createElement(Input_1.default, Object.assign({}, props, { ref: forwardRef !== null && forwardRef !== void 0 ? forwardRef : ref, template: react_1.default.cloneElement(props.template, { resize: props.resize }) })));
42
+ });
43
+ Textarea.defaultProps = Object.assign(Object.assign({}, Input_1.default.defaultProps), { areaMaxHeight: 350, areaMinHeight: 150, resize: 'none', template: react_1.default.createElement(InputElement_1.default, { as: "textarea" }) });
44
+ exports.default = Textarea;
@@ -22,13 +22,13 @@ exports.default = (0, styled_components_1.default)(Div_1.default).attrs({
22
22
 
23
23
  ${isSoft
24
24
  ? `
25
- background: ${theme.$.palette[palette].tooltip.softBackground};
26
- color: ${theme.$.palette[palette].tooltip.softFont};
27
- fill: ${theme.$.palette[palette].tooltip.softFont};
25
+ background: ${theme.$.palette[palette].soft};
26
+ color: ${theme.$.palette[palette].softFont};
27
+ fill: ${theme.$.palette[palette].softFont};
28
28
 
29
29
  ${PopoverArrow_1.default} {
30
- fill: ${theme.$.palette[palette].tooltip.softBackground};
31
- stroke: ${theme.$.palette[palette].tooltip.softBackground};
30
+ fill: ${theme.$.palette[palette].soft};
31
+ stroke: ${theme.$.palette[palette].soft};
32
32
  }
33
33
  `
34
34
  : `
@@ -0,0 +1,8 @@
1
+ import { StyledProps } from '@smart-react-components/core/styled-props';
2
+ import { ResponsiveProp, SizeProp } from '@smart-react-components/core/types';
3
+ interface Props extends StyledProps, ResponsiveProp<'formSize', SizeProp> {
4
+ isBlock: boolean;
5
+ isDisabled: boolean;
6
+ }
7
+ declare const _default: import("styled-components").StyledComponent<"label", any, StyledProps & Props, never>;
8
+ export default _default;
@@ -0,0 +1,56 @@
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 Label_1 = __importDefault(require("@smart-react-components/core/Element/Label"));
7
+ const styled_components_1 = __importDefault(require("styled-components"));
8
+ const css_1 = require("../../util/css");
9
+ const form_1 = require("../../util/form");
10
+ exports.default = (0, styled_components_1.default)(Label_1.default).attrs(({ isBlock }) => ({
11
+ getFormSize: (v, t) => `
12
+ ${isBlock
13
+ ? `
14
+ > span {
15
+ margin-bottom: ${t.$.size.form.blockLabel[v].margin};
16
+ }
17
+ `
18
+ : `
19
+ margin-bottom: ${t.$.size.form.blockLabel[v].margin};
20
+
21
+ > span {
22
+ margin-right: ${(0, css_1.toCSSValue)(t.$.size.form.blockLabel[v].margin)(form_1.calculateFormLabelMarginX)};
23
+ }
24
+ `}
25
+ `,
26
+ }))(({ theme, isBlock, isDisabled }) => `
27
+ > span {
28
+ display: block;
29
+ word-break: break-word;
30
+ word-wrap: break-word;
31
+ -webkit-tap-highlight-color: transparent;
32
+ }
33
+
34
+ ${!isBlock
35
+ ? `
36
+ display: flex;
37
+
38
+ > span {
39
+ align-self: center;
40
+ }
41
+
42
+ > div {
43
+ align-self: flex-start;
44
+ }
45
+ `
46
+ : ''}
47
+
48
+ ${isDisabled
49
+ ? `
50
+ > span {
51
+ opacity: ${theme.$.opacity.formDisabled};
52
+ pointer-events: none;
53
+ }
54
+ `
55
+ : ''}
56
+ `);
@@ -0,0 +1,6 @@
1
+ import { StyledProps } from '@smart-react-components/core/styled-props';
2
+ interface Props extends StyledProps {
3
+ isBlock: boolean;
4
+ }
5
+ declare const _default: import("styled-components").StyledComponent<"div", any, StyledProps & Props, never>;
6
+ export default _default;
@@ -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 Div_1 = __importDefault(require("@smart-react-components/core/Element/Div"));
7
+ const styled_components_1 = __importDefault(require("styled-components"));
8
+ exports.default = (0, styled_components_1.default)(Div_1.default)(({ isBlock }) => `
9
+ ${!isBlock
10
+ ? `
11
+ align-items: center;
12
+ display: flex;
13
+ flex-wrap: wrap;
14
+ justify-content: flex-start;
15
+ `
16
+ : ''}
17
+ `);
@@ -0,0 +1,10 @@
1
+ import { StyledProps } from '@smart-react-components/core/styled-props';
2
+ import { ResponsiveProp, SizeProp } from '@smart-react-components/core/types';
3
+ import { OrderPosition } from '../../types';
4
+ interface Props extends StyledProps, ResponsiveProp<'formSize', SizeProp> {
5
+ isBlock: boolean;
6
+ isDisabled: boolean;
7
+ labelPosition: OrderPosition;
8
+ }
9
+ declare const _default: import("styled-components").StyledComponent<"label", any, StyledProps & Props, never>;
10
+ export default _default;
@@ -0,0 +1,66 @@
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 Label_1 = __importDefault(require("@smart-react-components/core/Element/Label"));
7
+ const styled_components_1 = __importDefault(require("styled-components"));
8
+ const types_1 = require("../../types");
9
+ const css_1 = require("../../util/css");
10
+ const form_1 = require("../../util/form");
11
+ const props_1 = require("../../util/props");
12
+ exports.default = (0, styled_components_1.default)(Label_1.default).attrs(({ isBlock, labelPosition }) => ({
13
+ getFormSize: (v, t) => `
14
+ ${!isBlock
15
+ ? `
16
+ margin: ${t.$.size.form.inlineLabel[v].margin.y} ${t.$.size.form.inlineLabel[v].margin.x};
17
+ `
18
+ : `
19
+ margin-bottom: ${t.$.size.form.inlineLabel[v].margin.x};
20
+ `}
21
+
22
+ > span {
23
+ font-size: ${t.$.size.form.inlineLabel[v].fontSize};
24
+ margin-${types_1.OrderPosition[(0, props_1.getReverseOrderPosition)(labelPosition)].toLowerCase()}: ${(0, css_1.toCSSValue)(t.$.size.form.inlineLabel[v].margin.x)(form_1.calculateFormLabelMarginX)};
25
+ }
26
+ `,
27
+ }))(({ theme, isBlock, isDisabled, labelPosition }) => `
28
+ align-items: center;
29
+ cursor: default;
30
+ display: ${isBlock ? 'flex' : 'inline-flex'};
31
+ justify-content: space-between;
32
+ position: relative;
33
+
34
+ > div {
35
+ flex: 0 0 auto;
36
+ }
37
+
38
+ > span {
39
+ color: ${theme.$.color.dynamic.font};
40
+ display: inline-flex;
41
+ flex: 1 1 auto;
42
+ font-family: ${theme.$.fontFamily.form};
43
+ word-break: break-word;
44
+ word-wrap: break-word;
45
+ -webkit-tap-highlight-color: transparent;
46
+ }
47
+
48
+ ${isDisabled
49
+ ? `
50
+ opacity: ${theme.$.opacity.formDisabled};
51
+ pointer-events: none;
52
+ `
53
+ : ''}
54
+
55
+ ${labelPosition === types_1.OrderPosition.LEFT
56
+ ? `
57
+ > span {
58
+ order: 1;
59
+ }
60
+
61
+ > div {
62
+ order: 2;
63
+ }
64
+ `
65
+ : ''}
66
+ `);
@@ -0,0 +1,2 @@
1
+ declare const _default: import("styled-components").StyledComponent<"input", any, {}, never>;
2
+ export default _default;
@@ -0,0 +1,15 @@
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 styled_components_1 = __importDefault(require("styled-components"));
7
+ exports.default = styled_components_1.default.input `
8
+ height: 100%;
9
+ left: 0;
10
+ opacity: 0;
11
+ pointer-events: none;
12
+ position: absolute;
13
+ top: 0;
14
+ width: 100%;
15
+ `;
@@ -0,0 +1,18 @@
1
+ import { ContentElement, PaletteProp, ResponsiveProp, ShapeProp, SizeProp } from '@smart-react-components/core/types';
2
+ interface Props extends ResponsiveProp<'size', SizeProp> {
3
+ hasBorder: boolean;
4
+ isDisabled: boolean;
5
+ isFocused: boolean;
6
+ isOutline: boolean;
7
+ isSoft: boolean;
8
+ leftAddon: ContentElement | null;
9
+ rightAddon: ContentElement | null;
10
+ palette: PaletteProp;
11
+ shape: ShapeProp;
12
+ }
13
+ interface Return {
14
+ leftAddon: JSX.Element | null;
15
+ rightAddon: JSX.Element | null;
16
+ }
17
+ declare const useInputAddons: ({ hasBorder, isDisabled, isFocused, isOutline, isSoft, leftAddon, rightAddon, palette, shape, size, sizeSm, sizeMd, sizeLg, sizeXl }: Props) => Return;
18
+ export default useInputAddons;
@@ -0,0 +1,47 @@
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 InputAddon_1 = __importDefault(require("../Input/InputAddon"));
9
+ const types_1 = require("../types");
10
+ const useInputAddons = ({ hasBorder, isDisabled, isFocused, isOutline, isSoft, leftAddon, rightAddon, palette, shape, size, sizeSm, sizeMd, sizeLg, sizeXl }) => {
11
+ const generateAddonEl = (item, position) => {
12
+ if (!item) {
13
+ return null;
14
+ }
15
+ const props = {
16
+ hasBorder,
17
+ isFocused,
18
+ isOutline,
19
+ isSoft,
20
+ palette,
21
+ position,
22
+ shape,
23
+ size,
24
+ sizeSm,
25
+ sizeMd,
26
+ sizeLg,
27
+ sizeXl,
28
+ };
29
+ if ((item === null || item === void 0 ? void 0 : item.displayName) === 'SRCInputAddon') {
30
+ return react_1.default.cloneElement(item, Object.assign(Object.assign({}, props), item.props));
31
+ }
32
+ return (react_1.default.createElement(InputAddon_1.default, Object.assign({}, props), item));
33
+ };
34
+ const [leftAddonEl, setLeftAddonEl] = react_1.default.useState(() => generateAddonEl(leftAddon, types_1.OrderPosition.LEFT));
35
+ const [rightAddonEl, setRightAddonEl] = react_1.default.useState(() => generateAddonEl(rightAddon, types_1.OrderPosition.RIGHT));
36
+ (0, useChangeEffect_1.default)(() => {
37
+ setLeftAddonEl(generateAddonEl(leftAddon, types_1.OrderPosition.LEFT));
38
+ }, [leftAddon, isDisabled, isFocused]);
39
+ (0, useChangeEffect_1.default)(() => {
40
+ setRightAddonEl(generateAddonEl(rightAddon, types_1.OrderPosition.RIGHT));
41
+ }, [rightAddon, isDisabled, isFocused]);
42
+ return {
43
+ leftAddon: leftAddonEl,
44
+ rightAddon: rightAddonEl,
45
+ };
46
+ };
47
+ exports.default = useInputAddons;
@@ -0,0 +1,18 @@
1
+ import { SetState } from '@smart-react-components/core/types';
2
+ import { ChangeEvent, FocusEvent } from 'react';
3
+ interface Props<DOMElement> {
4
+ isDisabled: boolean;
5
+ isReadOnly: boolean;
6
+ onBlur?: (e: FocusEvent<DOMElement>) => void;
7
+ onChange?: (e: ChangeEvent<DOMElement>) => void;
8
+ onFocus?: (e: FocusEvent<DOMElement>) => void;
9
+ setValue?: SetState<string>;
10
+ }
11
+ interface Return<DOMElement> {
12
+ handleOnBlur?: (e: FocusEvent<DOMElement>) => void;
13
+ handleOnChange?: (e: ChangeEvent<DOMElement>) => void;
14
+ handleOnFocus?: (e: FocusEvent<DOMElement>) => void;
15
+ isFocused: boolean;
16
+ }
17
+ export default function useInputMethods<DOMElement extends HTMLInputElement | HTMLTextAreaElement>({ isDisabled, isReadOnly, onBlur, onChange, onFocus, setValue }: Props<DOMElement>): Return<DOMElement>;
18
+ export {};
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_1 = require("react");
4
+ function useInputMethods({ isDisabled, isReadOnly, onBlur, onChange, onFocus, setValue }) {
5
+ const [isFocused, setFocused] = (0, react_1.useState)(false);
6
+ /**
7
+ * Calls onBlur methhod.
8
+ * Sets focus status if event is not prevented.
9
+ */
10
+ const handleOnBlur = (e) => {
11
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
12
+ if (!e.defaultPrevented) {
13
+ setFocused(false);
14
+ }
15
+ };
16
+ /**
17
+ * Calls onChange method.
18
+ * Sets value if event is not prevented.
19
+ */
20
+ const handleOnChange = (e) => {
21
+ if (isDisabled || isReadOnly) {
22
+ return;
23
+ }
24
+ onChange === null || onChange === void 0 ? void 0 : onChange(e);
25
+ if (!e.defaultPrevented) {
26
+ setValue === null || setValue === void 0 ? void 0 : setValue(e.target.value);
27
+ }
28
+ };
29
+ /**
30
+ * Calls onFocus method.
31
+ * Sets focus status if event is not prevented.
32
+ */
33
+ const handleOnFocus = (e) => {
34
+ if (isDisabled) {
35
+ return;
36
+ }
37
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
38
+ if (!e.defaultPrevented) {
39
+ setFocused(true);
40
+ }
41
+ };
42
+ return {
43
+ handleOnBlur,
44
+ handleOnChange,
45
+ handleOnFocus,
46
+ isFocused,
47
+ };
48
+ }
49
+ exports.default = useInputMethods;
@@ -0,0 +1,6 @@
1
+ import { StyledProps } from '@smart-react-components/core/styled-props';
2
+ declare const _default: import("styled-components").StyledComponent<"svg", any, StyledProps & {
3
+ children: JSX.Element;
4
+ viewBox: "0 0 24 24";
5
+ }, "children" | "viewBox">;
6
+ export default _default;
@@ -0,0 +1,14 @@
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 Svg_1 = __importDefault(require("@smart-react-components/core/Element/Svg"));
7
+ const react_1 = __importDefault(require("react"));
8
+ const styled_components_1 = __importDefault(require("styled-components"));
9
+ exports.default = (0, styled_components_1.default)(Svg_1.default).attrs({
10
+ children: react_1.default.createElement(react_1.default.Fragment, null,
11
+ react_1.default.createElement("path", { d: "M0 0h24v24H0V0z", fill: "none" }),
12
+ react_1.default.createElement("path", { d: "M15.41 16.59L10.83 12l4.58-4.59L14 6l-6 6 6 6 1.41-1.41z" })),
13
+ viewBox: '0 0 24 24',
14
+ }) ``;
@@ -0,0 +1,6 @@
1
+ import { StyledProps } from '@smart-react-components/core/styled-props';
2
+ declare const _default: import("styled-components").StyledComponent<"svg", any, StyledProps & {
3
+ children: JSX.Element;
4
+ viewBox: "0 0 24 24";
5
+ }, "children" | "viewBox">;
6
+ export default _default;
@@ -0,0 +1,14 @@
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 Svg_1 = __importDefault(require("@smart-react-components/core/Element/Svg"));
7
+ const react_1 = __importDefault(require("react"));
8
+ const styled_components_1 = __importDefault(require("styled-components"));
9
+ exports.default = (0, styled_components_1.default)(Svg_1.default).attrs({
10
+ children: react_1.default.createElement(react_1.default.Fragment, null,
11
+ react_1.default.createElement("path", { d: "M0 0h24v24H0V0z", fill: "none" }),
12
+ react_1.default.createElement("path", { d: "M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z" })),
13
+ viewBox: '0 0 24 24',
14
+ }) ``;