@smart-react-components/ui 2.0.0-alpha-3 → 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 (104) 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/Breadcrumb/BreadcrumbLink/index.js +2 -4
  11. package/Checkbox/CheckboxElement.d.ts +11 -0
  12. package/Checkbox/CheckboxElement.js +79 -0
  13. package/Checkbox/CheckboxGroup/index.d.ts +21 -0
  14. package/Checkbox/CheckboxGroup/index.js +17 -0
  15. package/Checkbox/index.d.ts +25 -0
  16. package/Checkbox/index.js +72 -0
  17. package/Input/InputAddon/InputAddonElement.d.ts +16 -0
  18. package/Input/InputAddon/InputAddonElement.js +90 -0
  19. package/Input/InputAddon/index.d.ts +12 -0
  20. package/Input/InputAddon/index.js +12 -0
  21. package/Input/InputElement.d.ts +19 -0
  22. package/Input/InputElement.js +154 -0
  23. package/Input/InputFile/InputFileTemplate.d.ts +21 -0
  24. package/Input/InputFile/InputFileTemplate.js +51 -0
  25. package/Input/InputFile/index.d.ts +23 -0
  26. package/Input/InputFile/index.js +95 -0
  27. package/Input/InputNumber/InputNumberTemplate.d.ts +16 -0
  28. package/Input/InputNumber/InputNumberTemplate.js +62 -0
  29. package/Input/InputNumber/InputNumberTemplateElement.d.ts +6 -0
  30. package/Input/InputNumber/InputNumberTemplateElement.js +58 -0
  31. package/Input/InputNumber/index.d.ts +30 -0
  32. package/Input/InputNumber/index.js +79 -0
  33. package/Input/index.d.ts +29 -0
  34. package/Input/index.js +61 -0
  35. package/Pagination/PaginationItem/PaginationItemElement.d.ts +13 -0
  36. package/Pagination/PaginationItem/PaginationItemElement.js +139 -0
  37. package/Pagination/PaginationItem/index.d.ts +21 -0
  38. package/Pagination/PaginationItem/index.js +17 -0
  39. package/Pagination/PaginationLink/index.d.ts +6 -0
  40. package/Pagination/PaginationLink/index.js +27 -0
  41. package/Pagination/PaginationList/PaginationListElement.d.ts +3 -0
  42. package/Pagination/PaginationList/PaginationListElement.js +15 -0
  43. package/Pagination/PaginationList/index.d.ts +16 -0
  44. package/Pagination/PaginationList/index.js +29 -0
  45. package/Pagination/PaginationNextIcon/index.d.ts +2 -0
  46. package/Pagination/PaginationNextIcon/index.js +7 -0
  47. package/Pagination/PaginationPrevIcon/index.d.ts +2 -0
  48. package/Pagination/PaginationPrevIcon/index.js +7 -0
  49. package/Pagination/index.d.ts +5 -0
  50. package/Pagination/index.js +16 -0
  51. package/Popover/PopoverElement.js +18 -18
  52. package/ProgressBar/ProgressBarElement.js +8 -7
  53. package/Radio/RadioElement.d.ts +10 -0
  54. package/Radio/RadioElement.js +74 -0
  55. package/Radio/RadioGroup/index.d.ts +20 -0
  56. package/Radio/RadioGroup/index.js +17 -0
  57. package/Radio/index.d.ts +22 -0
  58. package/Radio/index.js +46 -0
  59. package/Switch/SwitchElement.d.ts +3 -0
  60. package/Switch/SwitchElement.js +71 -0
  61. package/Switch/SwitchGroup/index.d.ts +6 -0
  62. package/Switch/SwitchGroup/index.js +11 -0
  63. package/Switch/index.d.ts +6 -0
  64. package/Switch/index.js +14 -0
  65. package/Textarea/TextareaAddon/index.d.ts +2 -0
  66. package/Textarea/TextareaAddon/index.js +7 -0
  67. package/Textarea/index.d.ts +10 -0
  68. package/Textarea/index.js +44 -0
  69. package/Tooltip/TooltipElement.js +5 -5
  70. package/components/FormBlockLabel/index.d.ts +8 -0
  71. package/components/FormBlockLabel/index.js +56 -0
  72. package/components/FormGroup/index.d.ts +6 -0
  73. package/components/FormGroup/index.js +17 -0
  74. package/components/FormInlineLabel/index.d.ts +10 -0
  75. package/components/FormInlineLabel/index.js +66 -0
  76. package/components/HiddenInput/index.d.ts +2 -0
  77. package/components/HiddenInput/index.js +15 -0
  78. package/hooks/useInputAddons.d.ts +18 -0
  79. package/hooks/useInputAddons.js +47 -0
  80. package/hooks/useInputMethods.d.ts +18 -0
  81. package/hooks/useInputMethods.js +49 -0
  82. package/icons/ArrowLeft.d.ts +6 -0
  83. package/icons/ArrowLeft.js +14 -0
  84. package/icons/ArrowRight.d.ts +6 -0
  85. package/icons/ArrowRight.js +14 -0
  86. package/icons/CaretDown.d.ts +6 -0
  87. package/icons/CaretDown.js +12 -0
  88. package/icons/CaretUp.d.ts +6 -0
  89. package/icons/CaretUp.js +12 -0
  90. package/index.d.ts +12 -0
  91. package/index.js +24 -1
  92. package/package.json +7 -7
  93. package/types/index.d.ts +10 -0
  94. package/types/index.js +10 -1
  95. package/util/css.d.ts +5 -0
  96. package/util/css.js +7 -1
  97. package/util/dom.d.ts +1 -0
  98. package/util/dom.js +2 -1
  99. package/util/form.d.ts +4 -0
  100. package/util/form.js +8 -0
  101. package/util/props.d.ts +0 -14
  102. package/util/props.js +1 -46
  103. package/util/radio.d.ts +4 -0
  104. package/util/radio.js +14 -0
@@ -0,0 +1,19 @@
1
+ import { StyledProps } from '@smart-react-components/core/styled-props';
2
+ import { PaletteProp, Partial, ResponsiveProp, ShapeProp, SizeProp } from '@smart-react-components/core/types';
3
+ export declare const InputPlaceholder: import("styled-components").StyledComponent<"div", any, StyledProps, never>;
4
+ interface Props extends StyledProps, Partial<ResponsiveProp<'inputSize', SizeProp>> {
5
+ hasBorder?: boolean;
6
+ hasLeftAddon?: boolean;
7
+ hasRightAddon?: boolean;
8
+ hasSeparatedLeftAddon?: boolean;
9
+ hasSeparatedRightAddon?: boolean;
10
+ isDisabled?: boolean;
11
+ isFocused?: boolean;
12
+ isInput?: boolean;
13
+ isOutline?: boolean;
14
+ isSoft?: boolean;
15
+ palette?: PaletteProp;
16
+ shape?: ShapeProp;
17
+ }
18
+ declare const _default: import("styled-components").StyledComponent<"input", any, StyledProps & Props, never>;
19
+ export default _default;
@@ -0,0 +1,154 @@
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.InputPlaceholder = void 0;
7
+ const Div_1 = __importDefault(require("@smart-react-components/core/Element/Div"));
8
+ const Input_1 = __importDefault(require("@smart-react-components/core/Element/Input"));
9
+ const color_1 = require("@smart-react-components/core/util/color");
10
+ const react_1 = __importDefault(require("react"));
11
+ const styled_components_1 = __importDefault(require("styled-components"));
12
+ const css_1 = require("../util/css");
13
+ const dom_1 = require("../util/dom");
14
+ exports.InputPlaceholder = (0, styled_components_1.default)(Div_1.default).attrs(({ children }) => (Object.assign({}, (!children && { children: react_1.default.createElement(react_1.default.Fragment, null, "\u00A0"), userSelect: 'none' })))) ``;
15
+ exports.default = (0, styled_components_1.default)(Input_1.default).attrs(({ hasLeftAddon, hasRightAddon, hasSeparatedLeftAddon, hasSeparatedRightAddon, isInput = true }) => (Object.assign(Object.assign({}, (!isInput && { as: 'div' })), { getInputSize: (v, t) => `
16
+ font-size: ${t.$.size.input[v].fontSize};
17
+ padding: ${t.$.size.input[v].padding.y} ${t.$.size.input[v].padding.x};
18
+
19
+ ${hasLeftAddon
20
+ ? `
21
+ padding-left: ${hasSeparatedLeftAddon ? (0, css_1.toCSSValue)(t.$.size.input[v].padding.x)(v => v / 2) : 0};
22
+ `
23
+ : ''}
24
+
25
+ ${hasRightAddon
26
+ ? `
27
+ padding-right: ${hasSeparatedRightAddon ? (0, css_1.toCSSValue)(t.$.size.input[v].padding.x)(v => v / 2) : 0};
28
+ `
29
+ : ''}
30
+ `, isInput })))(({ theme, hasBorder, hasLeftAddon, hasRightAddon, isDisabled, isFocused, isInput, isOutline, isSoft, palette, shape }) => `
31
+ border: ${hasBorder ? 'solid 1px' : '0'};
32
+ border-radius: ${theme.$.radius.input[shape]};
33
+ flex: 1 1 auto;
34
+ font-family: ${theme.$.fontFamily.input};
35
+ transition: 200ms 0s ease-in-out;
36
+ transition-property: background, border, color, fill;
37
+ -webkit-appearance: none;
38
+ -webkit-tap-highlight-color: transparent;
39
+
40
+ ${!isOutline
41
+ ? `
42
+ ${!isSoft
43
+ ? `
44
+ color: ${theme.$.palette[palette].font};
45
+
46
+ ${!isFocused
47
+ ? `
48
+ background: ${theme.$.palette[palette].main};
49
+ border-color: ${theme.$.palette[palette].dark};
50
+ `
51
+ : `
52
+ background: ${theme.$.palette[palette].dynamicer};
53
+ border-color: ${theme.$.palette[palette].dynamicest};
54
+ `}
55
+ `
56
+ : `
57
+ color: ${theme.$.palette[palette].softFont};
58
+
59
+ ${!isFocused
60
+ ? `
61
+ background: ${theme.$.palette[palette].soft};
62
+ border-color: ${theme.$.palette[palette].softDark};
63
+ `
64
+ : `
65
+ background: ${theme.$.palette[palette].softDarker};
66
+ border-color: ${theme.$.palette[palette].softDarkest};
67
+ `}
68
+ `}
69
+
70
+ ${!isInput
71
+ ? `
72
+ ${exports.InputPlaceholder} {
73
+ color: ${(0, color_1.getColor)(!isSoft ? theme.$.palette[palette].font : theme.$.palette[palette].softFont).alpha(theme.$.opacity.inputPlaceholder).rgb().toString()};
74
+ }
75
+ `
76
+ : `
77
+ ${dom_1.placeholder.map(item => `
78
+ &${item} {
79
+ color: ${(0, color_1.getColor)(!isSoft ? theme.$.palette[palette].font : theme.$.palette[palette].softFont).alpha(theme.$.opacity.inputPlaceholder).rgb().toString()};
80
+ opacity: 1;
81
+ }
82
+ `).join(' ')}
83
+ `}
84
+ `
85
+ : `
86
+ background: ${theme.$.color.dynamic.background};
87
+ border-color ${!isFocused ? theme.$.color.dynamic.accent : theme.$.palette[palette].main};
88
+ color: ${theme.$.color.dynamic.font};
89
+
90
+ ${!isInput
91
+ ? `
92
+ ${!isDisabled
93
+ ? `
94
+ ${exports.InputPlaceholder} {
95
+ color: ${theme.$.color.dynamic.accent};
96
+ }
97
+ `
98
+ : ''}
99
+ `
100
+ : `
101
+ ${dom_1.placeholder.map(item => `
102
+ &${item} {
103
+ opacity: 1;
104
+
105
+ ${!isDisabled
106
+ ? `
107
+ color: ${theme.$.color.dynamic.accent};
108
+ `
109
+ : ''}
110
+ }
111
+ `).join(' ')}
112
+ `}
113
+ `}
114
+
115
+ &:active,
116
+ &:focus {
117
+ outline: 0;
118
+ }
119
+
120
+ ${isDisabled
121
+ ? `
122
+ opacity: ${theme.$.opacity.formDisabled};
123
+
124
+ ${isOutline
125
+ ? `
126
+ background: ${theme.$.color.dynamic.accent};
127
+ color: ${theme.$.color.dynamic.gray};
128
+ `
129
+ : ''}
130
+ `
131
+ : ''}
132
+
133
+ ${hasLeftAddon
134
+ ? `
135
+ border-left: 0;
136
+ border-bottom-left-radius: 0;
137
+ border-top-left-radius: 0;
138
+ `
139
+ : ''}
140
+
141
+ ${hasRightAddon
142
+ ? `
143
+ border-right: 0;
144
+ border-bottom-right-radius: 0;
145
+ border-top-right-radius: 0;
146
+ `
147
+ : ''}
148
+
149
+ ${!isInput
150
+ ? `
151
+ position: relative;
152
+ `
153
+ : ''}
154
+ `);
@@ -0,0 +1,21 @@
1
+ import { PaletteProp, Partial, ResponsiveProp, SetState, ShapeProp, SizeProp } from '@smart-react-components/core/types';
2
+ import React from 'react';
3
+ interface Props extends Partial<ResponsiveProp<'inputSize', SizeProp>> {
4
+ children?: JSX.Element;
5
+ hasBorder?: boolean;
6
+ hasLeftAddon?: boolean;
7
+ hasRightAddon?: boolean;
8
+ hasSeparatedLeftAddon?: boolean;
9
+ hasSeparatedRightAddon?: boolean;
10
+ isDisabled?: boolean;
11
+ isFocused?: boolean;
12
+ isOutline?: boolean;
13
+ isSoft?: boolean;
14
+ palette?: PaletteProp;
15
+ placeholder?: string;
16
+ setValue?: SetState<File | File[]>;
17
+ shape?: ShapeProp;
18
+ value?: File | File[];
19
+ }
20
+ declare const InputFileTemplate: React.FC<Props>;
21
+ export default InputFileTemplate;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const react_1 = __importDefault(require("react"));
30
+ const Badge_1 = __importDefault(require("../../Badge"));
31
+ const BadgeIcon_1 = __importDefault(require("../../Badge/BadgeIcon"));
32
+ const BadgeList_1 = __importDefault(require("../../Badge/BadgeList"));
33
+ const Close_1 = __importDefault(require("../../icons/Close"));
34
+ const InputElement_1 = __importStar(require("../InputElement"));
35
+ const InputFileTemplate = ({ children, hasBorder, hasLeftAddon, hasRightAddon, hasSeparatedLeftAddon, hasSeparatedRightAddon, inputSize, inputSizeSm, inputSizeMd, inputSizeLg, inputSizeXl, isDisabled, isFocused, isOutline, isSoft, palette, placeholder, setValue, shape, value }) => {
36
+ const handleIconClick = (e, idx) => {
37
+ e.preventDefault();
38
+ setValue(value.filter((_, i) => i !== idx));
39
+ };
40
+ return (react_1.default.createElement(InputElement_1.default, { hasBorder: hasBorder, hasLeftAddon: hasLeftAddon, hasRightAddon: hasRightAddon, hasSeparatedLeftAddon: hasSeparatedLeftAddon, hasSeparatedRightAddon: hasSeparatedRightAddon, inputSize: inputSize, inputSizeSm: inputSizeSm, inputSizeMd: inputSizeMd, inputSizeLg: inputSizeLg, inputSizeXl: inputSizeXl, isDisabled: isDisabled, isFocused: isFocused, isInput: false, isOutline: isOutline, isSoft: isSoft, palette: palette, shape: shape },
41
+ children,
42
+ !value || value.length === 0
43
+ ? react_1.default.createElement(InputElement_1.InputPlaceholder, null, placeholder)
44
+ : (!Array.isArray(value)
45
+ ? value.name
46
+ : (react_1.default.createElement(BadgeList_1.default, { palette: palette, isSoft: isSoft, shape: shape, size: inputSize, sizeSm: inputSizeSm, sizeMd: inputSizeMd, sizeLg: inputSizeLg, sizeXl: inputSizeXl }, value.map((item, idx) => (react_1.default.createElement(Badge_1.default, { key: idx },
47
+ react_1.default.createElement(BadgeIcon_1.default, Object.assign({}, (!isDisabled && { onClick: e => handleIconClick(e, idx) })),
48
+ react_1.default.createElement(Close_1.default, null)),
49
+ item.name))))))));
50
+ };
51
+ exports.default = InputFileTemplate;
@@ -0,0 +1,23 @@
1
+ import { IntrinsicStyledProps } from '@smart-react-components/core/element-props/intrinsic-styled-props';
2
+ import { ContentElement, PaletteProp, Partial, ResponsiveProp, SetState, ShapeProp, SizeProp } from '@smart-react-components/core/types';
3
+ import React from 'react';
4
+ export interface Props extends Partial<ResponsiveProp<'size', SizeProp>>, IntrinsicStyledProps {
5
+ accept?: string;
6
+ hasBorder?: boolean;
7
+ isBlock?: boolean;
8
+ isDisabled?: boolean;
9
+ isRequired?: boolean;
10
+ isOutline?: boolean;
11
+ isSoft?: boolean;
12
+ label?: ContentElement;
13
+ leftAddon?: ContentElement;
14
+ palette?: PaletteProp;
15
+ placeholder?: string;
16
+ rightAddon?: ContentElement;
17
+ setValue: SetState<File | File[]>;
18
+ shape?: ShapeProp;
19
+ template?: JSX.Element;
20
+ value: File | File[] | null;
21
+ }
22
+ declare const InputFile: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLInputElement>>;
23
+ export default InputFile;
@@ -0,0 +1,95 @@
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 intrinsic_styled_props_1 = __importDefault(require("@smart-react-components/core/element-props/intrinsic-styled-props"));
9
+ const react_1 = __importDefault(require("react"));
10
+ const FormBlockLabel_1 = __importDefault(require("../../components/FormBlockLabel"));
11
+ const useInputAddons_1 = __importDefault(require("../../hooks/useInputAddons"));
12
+ const InputFileTemplate_1 = __importDefault(require("./InputFileTemplate"));
13
+ const HiddenInput_1 = __importDefault(require("../../components/HiddenInput"));
14
+ const useInputMethods_1 = __importDefault(require("../../hooks/useInputMethods"));
15
+ const InputFile = react_1.default.forwardRef((props, forwardRef) => {
16
+ var _a, _b;
17
+ const ref = react_1.default.useRef(null);
18
+ const { handleOnBlur, handleOnFocus, isFocused } = (0, useInputMethods_1.default)({
19
+ isDisabled: props.isDisabled,
20
+ isReadOnly: false,
21
+ });
22
+ const { leftAddon, rightAddon } = (0, useInputAddons_1.default)({
23
+ hasBorder: props.hasBorder,
24
+ isDisabled: props.isDisabled,
25
+ isFocused,
26
+ isOutline: props.isOutline,
27
+ isSoft: props.isSoft,
28
+ leftAddon: props.leftAddon,
29
+ palette: props.palette,
30
+ rightAddon: props.rightAddon,
31
+ shape: props.shape,
32
+ size: props.size,
33
+ sizeSm: props.sizeSm,
34
+ sizeMd: props.sizeMd,
35
+ sizeLg: props.sizeLg,
36
+ sizeXl: props.sizeXl,
37
+ });
38
+ const handleOnChange = (e) => {
39
+ if (props.isDisabled) {
40
+ return;
41
+ }
42
+ if (!Array.isArray(props.value)) {
43
+ setValue(e.target.files[0]);
44
+ }
45
+ else {
46
+ setValue([...props.value, ...e.target.files].filter(i => !!i));
47
+ }
48
+ };
49
+ const setValue = (value) => {
50
+ if (!value || value.length === 0) {
51
+ const el = (forwardRef !== null && forwardRef !== void 0 ? forwardRef : ref).current;
52
+ el.value = '';
53
+ }
54
+ props.setValue(value);
55
+ };
56
+ 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 }),
57
+ props.label && react_1.default.createElement("span", null, props.label),
58
+ react_1.default.createElement(Div_1.default, { display: "flex", flex: "1 1 auto" },
59
+ leftAddon && leftAddon,
60
+ react_1.default.cloneElement(props.template, {
61
+ children: (react_1.default.createElement(react_1.default.Fragment, null,
62
+ react_1.default.createElement(HiddenInput_1.default, Object.assign({}, (props.accept && { accept: props.accept }), (props.isDisabled && { disabled: true }), (props.isRequired && { required: true }), { multiple: Array.isArray(props.value), onBlur: handleOnBlur, onChange: handleOnChange, onFocus: handleOnFocus, ref: forwardRef !== null && forwardRef !== void 0 ? forwardRef : ref, type: "file" })),
63
+ props.template.props.children)),
64
+ hasBorder: props.hasBorder,
65
+ hasLeftAddon: !!leftAddon,
66
+ hasRightAddon: !!rightAddon,
67
+ hasSeparatedLeftAddon: (_a = leftAddon === null || leftAddon === void 0 ? void 0 : leftAddon.props) === null || _a === void 0 ? void 0 : _a.isSeparated,
68
+ hasSeparatedRightAddon: (_b = rightAddon === null || rightAddon === void 0 ? void 0 : rightAddon.props) === null || _b === void 0 ? void 0 : _b.isSeparated,
69
+ inputSize: props.size,
70
+ inputSizeSm: props.sizeSm,
71
+ inputSizeMd: props.sizeMd,
72
+ inputSizeLg: props.sizeLg,
73
+ inputSizeXl: props.sizeXl,
74
+ isDisabled: props.isDisabled,
75
+ isFocused,
76
+ isOutline: props.isOutline,
77
+ isSoft: props.isSoft,
78
+ palette: props.palette,
79
+ placeholder: props.placeholder,
80
+ setValue,
81
+ shape: props.shape,
82
+ value: props.value,
83
+ }),
84
+ rightAddon && rightAddon)));
85
+ });
86
+ InputFile.defaultProps = {
87
+ hasBorder: true,
88
+ isBlock: true,
89
+ isOutline: true,
90
+ palette: 'primary',
91
+ shape: 'rectangle',
92
+ size: 'medium',
93
+ template: react_1.default.createElement(InputFileTemplate_1.default, null),
94
+ };
95
+ exports.default = InputFile;
@@ -0,0 +1,16 @@
1
+ import { PaletteProp, Partial, ResponsiveProp, ShapeProp, SizeProp } from '@smart-react-components/core/types';
2
+ import React from 'react';
3
+ interface Props extends Partial<ResponsiveProp<'inputSize', SizeProp>> {
4
+ hasBorder?: boolean;
5
+ isDisabled?: boolean;
6
+ isFocused?: boolean;
7
+ isOutline?: boolean;
8
+ isSoft?: boolean;
9
+ min?: number;
10
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
11
+ palette?: PaletteProp;
12
+ shape?: ShapeProp;
13
+ value?: number;
14
+ }
15
+ declare const InputNumberTemplate: React.FC<Props>;
16
+ export default InputNumberTemplate;
@@ -0,0 +1,62 @@
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 CaretDown_1 = __importDefault(require("../../icons/CaretDown"));
9
+ const CaretUp_1 = __importDefault(require("../../icons/CaretUp"));
10
+ const types_1 = require("../../types");
11
+ const InputAddon_1 = __importDefault(require("../InputAddon"));
12
+ const InputElement_1 = __importDefault(require("../InputElement"));
13
+ const InputNumberTemplateElement_1 = __importDefault(require("./InputNumberTemplateElement"));
14
+ const InputNumberTemplate = props => {
15
+ const el = react_1.default.useRef(null);
16
+ const toggleValue = (isInc) => {
17
+ if (props.isDisabled) {
18
+ return;
19
+ }
20
+ let value = props.value;
21
+ if (value !== null) {
22
+ if (isInc) {
23
+ value++;
24
+ }
25
+ else {
26
+ value--;
27
+ }
28
+ }
29
+ else {
30
+ value = props.min;
31
+ if (isInc) {
32
+ value++;
33
+ }
34
+ }
35
+ const e = { target: { value: String(value) } };
36
+ props.onChange(e);
37
+ };
38
+ const addonProps = {
39
+ hasBorder: props.hasBorder,
40
+ isDisabled: props.isDisabled,
41
+ isFocused: props.isFocused,
42
+ isOutline: props.isOutline,
43
+ isSeparated: false,
44
+ isSoft: props.isSoft,
45
+ palette: props.palette,
46
+ position: types_1.OrderPosition.RIGHT,
47
+ shape: props.shape,
48
+ size: props.inputSize,
49
+ sizeSm: props.inputSizeSm,
50
+ sizeMd: props.inputSizeMd,
51
+ sizeLg: props.inputSizeLg,
52
+ sizeXl: props.inputSizeXl,
53
+ };
54
+ return (react_1.default.createElement(InputNumberTemplateElement_1.default, { inputSize: props.inputSize, inputSizeSm: props.inputSizeSm, inputSizeMd: props.inputSizeMd, inputSizeLg: props.inputSizeLg, inputSizeXl: props.inputSizeXl, ref: el },
55
+ react_1.default.createElement(InputElement_1.default, Object.assign({}, props, { hasRightAddon: true, hasSeparatedRightAddon: true, type: "number" })),
56
+ react_1.default.createElement(InputAddon_1.default, Object.assign({}, addonProps),
57
+ react_1.default.createElement(Div_1.default, { alignItems: "flex-end", onClick: () => toggleValue(true) },
58
+ react_1.default.createElement(CaretUp_1.default, null)),
59
+ react_1.default.createElement(Div_1.default, { alignItems: "flex-start", onClick: () => toggleValue(false) },
60
+ react_1.default.createElement(CaretDown_1.default, null)))));
61
+ };
62
+ exports.default = InputNumberTemplate;
@@ -0,0 +1,6 @@
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<'inputSize', SizeProp> {
4
+ }
5
+ declare const _default: import("styled-components").StyledComponent<"div", any, StyledProps & Props, never>;
6
+ export default _default;
@@ -0,0 +1,58 @@
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
+ const css_1 = require("../../util/css");
9
+ const InputAddonElement_1 = __importDefault(require("../InputAddon/InputAddonElement"));
10
+ const InputElement_1 = __importDefault(require("../InputElement"));
11
+ exports.default = (0, styled_components_1.default)(Div_1.default).attrs({
12
+ getInputSize: (v, t) => `
13
+ ${InputAddonElement_1.default} {
14
+ padding: 0;
15
+
16
+ > div {
17
+ padding: 0 ${(0, css_1.toCSSValue)(t.$.size.input[v].padding.x)(v => v / 2)};
18
+ }
19
+ }
20
+ `,
21
+ }) `
22
+ display: flex;
23
+ flex: 1 1 auto;
24
+
25
+ ${InputElement_1.default} {
26
+ -moz-appearance: textfield;
27
+
28
+ &::-webkit-inner-spin-button,
29
+ &::-webkit-outer-spin-button {
30
+ margin: 0;
31
+ -webkit-appearance: none;
32
+ }
33
+ }
34
+
35
+ ${InputAddonElement_1.default} {
36
+ flex-direction: column;
37
+ user-select: none;
38
+
39
+ > div {
40
+ display: flex;
41
+ height: 50%;
42
+ visibility: hidden;
43
+
44
+ > svg {
45
+ height: .65rem;
46
+ width: .65rem;
47
+ }
48
+
49
+ &:active {
50
+ opacity: .3;
51
+ }
52
+ }
53
+ }
54
+
55
+ &:hover ${InputAddonElement_1.default} > div {
56
+ visibility: visible;
57
+ }
58
+ `;
@@ -0,0 +1,30 @@
1
+ import { ChangeEvents } from '@smart-react-components/core/element-props/change-events';
2
+ import { FocusEvents } from '@smart-react-components/core/element-props/focus-events';
3
+ import { IntrinsicStyledProps } from '@smart-react-components/core/element-props/intrinsic-styled-props';
4
+ import { KeyboardEvents } from '@smart-react-components/core/element-props/keyboard-events';
5
+ import { ContentElement, PaletteProp, Partial, ResponsiveProp, SetState, ShapeProp, SizeProp } from '@smart-react-components/core/types';
6
+ import React from 'react';
7
+ export interface Props extends Partial<ResponsiveProp<'size', SizeProp>>, IntrinsicStyledProps, ChangeEvents, FocusEvents, KeyboardEvents {
8
+ defaultValue?: number;
9
+ hasBorder?: boolean;
10
+ isBlock?: boolean;
11
+ isDisabled?: boolean;
12
+ isOutline?: boolean;
13
+ isReadOnly?: boolean;
14
+ isRequired?: boolean;
15
+ isSoft?: boolean;
16
+ label?: ContentElement;
17
+ leftAddon?: ContentElement;
18
+ max?: number;
19
+ min?: number;
20
+ palette?: PaletteProp;
21
+ placeholder?: string;
22
+ rightAddon?: ContentElement;
23
+ setValue?: SetState<number>;
24
+ shape?: ShapeProp;
25
+ step?: number;
26
+ template?: JSX.Element;
27
+ value?: number;
28
+ }
29
+ declare const InputNumber: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLInputElement>>;
30
+ export default InputNumber;
@@ -0,0 +1,79 @@
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 change_events_1 = __importDefault(require("@smart-react-components/core/element-props/change-events"));
9
+ const focus_events_1 = __importDefault(require("@smart-react-components/core/element-props/focus-events"));
10
+ const intrinsic_styled_props_1 = __importDefault(require("@smart-react-components/core/element-props/intrinsic-styled-props"));
11
+ const keyboard_events_1 = __importDefault(require("@smart-react-components/core/element-props/keyboard-events"));
12
+ const react_1 = __importDefault(require("react"));
13
+ const FormBlockLabel_1 = __importDefault(require("../../components/FormBlockLabel"));
14
+ const useInputAddons_1 = __importDefault(require("../../hooks/useInputAddons"));
15
+ const useInputMethods_1 = __importDefault(require("../../hooks/useInputMethods"));
16
+ const InputNumberTemplate_1 = __importDefault(require("./InputNumberTemplate"));
17
+ const InputNumber = react_1.default.forwardRef((props, forwardRef) => {
18
+ var _a, _b, _c, _d;
19
+ /**
20
+ * Converts the input string value to number.
21
+ * If value cannot be number, returns the current value.
22
+ */
23
+ const applyNumberFormat = (value) => {
24
+ if (!value.trim()) {
25
+ return null;
26
+ }
27
+ if (isNaN(Number(value))) {
28
+ return props.value;
29
+ }
30
+ const i = parseInt(value);
31
+ if (typeof props.min !== 'undefined' && i < props.min) {
32
+ return props.value;
33
+ }
34
+ if (typeof props.max !== 'undefined' && i > props.max) {
35
+ return props.value;
36
+ }
37
+ return i;
38
+ };
39
+ const { handleOnBlur, handleOnChange, handleOnFocus, isFocused } = (0, useInputMethods_1.default)({
40
+ isDisabled: props.isDisabled,
41
+ isReadOnly: props.isReadOnly,
42
+ onBlur: props.onBlur,
43
+ onChange: props.onChange,
44
+ onFocus: props.onFocus,
45
+ setValue: value => { var _a; return (_a = props.setValue) === null || _a === void 0 ? void 0 : _a.call(props, applyNumberFormat(value)); },
46
+ });
47
+ const { leftAddon, rightAddon } = (0, useInputAddons_1.default)({
48
+ hasBorder: props.hasBorder,
49
+ isDisabled: props.isDisabled,
50
+ isFocused,
51
+ isOutline: props.isOutline,
52
+ isSoft: props.isSoft,
53
+ leftAddon: props.leftAddon,
54
+ palette: props.palette,
55
+ rightAddon: props.rightAddon,
56
+ shape: props.shape,
57
+ size: props.size,
58
+ sizeSm: props.sizeSm,
59
+ sizeMd: props.sizeMd,
60
+ sizeLg: props.sizeLg,
61
+ sizeXl: props.sizeXl,
62
+ });
63
+ 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
+ props.label && react_1.default.createElement("span", null, props.label),
65
+ react_1.default.createElement(Div_1.default, { display: "flex", flex: "1 1 auto" },
66
+ leftAddon && leftAddon,
67
+ react_1.default.cloneElement(props.template, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (0, element_props_1.default)(props, [change_events_1.default, focus_events_1.default, keyboard_events_1.default])), (typeof props.defaultValue !== 'undefined' && { defaultValue: ((_a = props.defaultValue) !== null && _a !== void 0 ? _a : '') })), (props.isDisabled && { disabled: true })), (props.isReadOnly && { readOnly: true })), (props.isRequired && { required: true })), (typeof props.max !== 'undefined' && { max: props.max })), (typeof props.min !== 'undefined' && { min: props.min })), (typeof props.step !== 'undefined' && { step: props.step })), (typeof props.value !== 'undefined' && { value: ((_b = props.value) !== null && _b !== void 0 ? _b : '') })), { hasBorder: props.hasBorder, 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, inputSize: props.size, inputSizeSm: props.sizeSm, inputSizeMd: props.sizeMd, inputSizeLg: props.sizeLg, inputSizeXl: props.sizeXl, isDisabled: props.isDisabled, isFocused, isOutline: props.isOutline, isSoft: props.isSoft, onBlur: handleOnBlur, onChange: handleOnChange, onFocus: handleOnFocus, palette: props.palette, ref: forwardRef, shape: props.shape })),
68
+ rightAddon && rightAddon)));
69
+ });
70
+ InputNumber.defaultProps = {
71
+ hasBorder: true,
72
+ isBlock: true,
73
+ isOutline: true,
74
+ palette: 'primary',
75
+ shape: 'rectangle',
76
+ size: 'medium',
77
+ template: react_1.default.createElement(InputNumberTemplate_1.default, null),
78
+ };
79
+ exports.default = InputNumber;
@@ -0,0 +1,29 @@
1
+ import { ChangeEvents } from '@smart-react-components/core/element-props/change-events';
2
+ import { FocusEvents } from '@smart-react-components/core/element-props/focus-events';
3
+ import { IntrinsicStyledProps } from '@smart-react-components/core/element-props/intrinsic-styled-props';
4
+ import { KeyboardEvents } from '@smart-react-components/core/element-props/keyboard-events';
5
+ import { ContentElement, PaletteProp, Partial, ResponsiveProp, SetState, ShapeProp, SizeProp } from '@smart-react-components/core/types';
6
+ import React from 'react';
7
+ import { InputType } from '../types';
8
+ export interface Props extends Partial<ResponsiveProp<'size', SizeProp>>, IntrinsicStyledProps, ChangeEvents, FocusEvents, KeyboardEvents {
9
+ defaultValue?: string;
10
+ hasBorder?: boolean;
11
+ isBlock?: boolean;
12
+ isDisabled?: boolean;
13
+ isOutline?: boolean;
14
+ isReadOnly?: boolean;
15
+ isRequired?: boolean;
16
+ isSoft?: boolean;
17
+ label?: ContentElement;
18
+ leftAddon?: ContentElement;
19
+ palette?: PaletteProp;
20
+ placeholder?: string;
21
+ rightAddon?: ContentElement;
22
+ setValue?: SetState<string>;
23
+ shape?: ShapeProp;
24
+ template?: JSX.Element;
25
+ type?: InputType;
26
+ value?: string;
27
+ }
28
+ declare const Input: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLInputElement>>;
29
+ export default Input;