@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
@@ -11,5 +11,5 @@ const AlertIcon = (props) => {
11
11
  var _a;
12
12
  return (react_1.default.createElement(AlertIconElement_1.default, Object.assign({ alertPalette: props.alertPalette, alertIconSize: props.size, alertIconSizeSm: props.sizeSm, alertIconSizeMd: props.sizeMd, alertIconSizeLg: props.sizeLg, alertIconSizeXl: props.sizeXl, hasBackground: props.hasBackground, hasHover: props.hasHover, isSoft: props.isSoft, palette: (_a = props.palette) !== null && _a !== void 0 ? _a : props.alertPalette }, (0, element_props_1.default)(props, [click_events_1.default])), props.children));
13
13
  };
14
- AlertIcon.displayName = 'SRCIcon';
14
+ AlertIcon.displayName = 'SRCAlertIcon';
15
15
  exports.default = AlertIcon;
package/Alert/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { IntrinsicStyledProps } from '@smart-react-components/core/element-props
3
3
  import { ContentElement, JSXElementProps, PaletteProp, Partial, ResponsiveProp, ShapeProp, SizeProp } from '@smart-react-components/core/types';
4
4
  import React from 'react';
5
5
  export interface Props extends Partial<ResponsiveProp<'size', SizeProp>>, ClickEvents, IntrinsicStyledProps {
6
- children: ContentElement;
6
+ children: ContentElement | ContentElement[];
7
7
  elementProps?: JSXElementProps;
8
8
  isOutline?: boolean;
9
9
  isSoft?: boolean;
package/Alert/index.js CHANGED
@@ -31,22 +31,49 @@ const click_events_1 = __importDefault(require("@smart-react-components/core/ele
31
31
  const intrinsic_styled_props_1 = __importDefault(require("@smart-react-components/core/element-props/intrinsic-styled-props"));
32
32
  const useChangeEffect_1 = __importDefault(require("@smart-react-components/core/hooks/useChangeEffect"));
33
33
  const react_1 = __importDefault(require("react"));
34
- const props_1 = require("../util/props");
35
34
  const AlertElement_1 = __importStar(require("./AlertElement"));
36
35
  const Alert = props => {
37
- const getContent = () => (0, props_1.extractIconsOutOfChildren)(props.children, AlertElement_1.Content, {
38
- alertPalette: props.palette,
39
- isSoft: props.isSoft,
40
- size: props.size,
41
- sizeSm: props.sizeSm,
42
- sizeMd: props.sizeMd,
43
- sizeLg: props.sizeLg,
44
- sizeXl: props.sizeXl,
45
- });
36
+ const getContent = () => {
37
+ var _a, _b;
38
+ const children = !Array.isArray(props.children) ? [props.children] : props.children;
39
+ const content = [];
40
+ let iconLeft = null;
41
+ let iconRight = null;
42
+ for (let i = 0; i < children.length; i++) {
43
+ const item = children[i];
44
+ if (((_a = item.type) === null || _a === void 0 ? void 0 : _a.displayName) === 'SRCAlertIcon') {
45
+ const iconEl = react_1.default.cloneElement(item, {
46
+ alertPalette: props.palette,
47
+ isSoft: props.isSoft,
48
+ size: props.size,
49
+ sizeSm: props.sizeSm,
50
+ sizeMd: props.sizeMd,
51
+ sizeLg: props.sizeLg,
52
+ sizeXl: props.sizeXl,
53
+ });
54
+ if (i === 0) {
55
+ iconLeft = iconEl;
56
+ }
57
+ else if (i === children.length - 1) {
58
+ iconRight = iconEl;
59
+ }
60
+ continue;
61
+ }
62
+ content.push(typeof children[i] === 'string' ? children[i] : react_1.default.cloneElement(item, { key: (_b = item.key) !== null && _b !== void 0 ? _b : i }));
63
+ }
64
+ return {
65
+ children: (react_1.default.createElement(react_1.default.Fragment, null,
66
+ iconLeft && iconLeft,
67
+ react_1.default.createElement(AlertElement_1.Content, null, content),
68
+ iconRight && iconRight)),
69
+ hasIconLeft: !!iconLeft,
70
+ hasIconRight: !!iconRight,
71
+ };
72
+ };
46
73
  const [{ children, hasIconLeft, hasIconRight }, setContent] = react_1.default.useState(() => getContent());
47
74
  (0, useChangeEffect_1.default)(() => {
48
75
  setContent(getContent());
49
- }, [props.children, props.isSoft, props.palette, props.size, props.sizeSm, props.sizeMd, props.sizeLg, props.sizeXl]);
76
+ }, [props.children]);
50
77
  return (react_1.default.createElement(AlertElement_1.default, Object.assign({ alertSize: props.size, alertSizeSm: props.sizeSm, alertSizeMd: props.sizeMd, alertSizeLg: props.sizeLg, alertSizeXl: props.sizeXl, hasIconLeft: hasIconLeft, hasIconRight: hasIconRight, isOutline: props.isOutline, isSoft: props.isSoft, palette: props.palette, shape: props.shape }, (0, element_props_1.default)(props, [click_events_1.default, intrinsic_styled_props_1.default])), children));
51
78
  };
52
79
  Alert.defaultProps = {
@@ -3,6 +3,7 @@ import { PaletteProp, ResponsiveProp, ShapeProp, SizeProp } from '@smart-react-c
3
3
  import { Position } from '../types';
4
4
  export declare const Content: import("styled-components").StyledComponent<"div", any, {}, never>;
5
5
  interface Props extends StyledProps, ResponsiveProp<'badgeSize', SizeProp> {
6
+ badgeOffset: number;
6
7
  badgePosition: Position;
7
8
  hasIconLeft: boolean;
8
9
  hasIconRight: boolean;
@@ -12,7 +13,6 @@ interface Props extends StyledProps, ResponsiveProp<'badgeSize', SizeProp> {
12
13
  isFixedSize: boolean;
13
14
  isOutline: boolean;
14
15
  isSoft: boolean;
15
- offset: number;
16
16
  palette: PaletteProp;
17
17
  shape: ShapeProp;
18
18
  }
@@ -59,7 +59,7 @@ exports.default = (0, styled_components_1.default)(Div_1.default).attrs(({ hasIc
59
59
  font-size: ${t.$.size.badge[v].iconSize};
60
60
  }
61
61
  `,
62
- }))(({ theme, badgePosition, hasIconLeft, hasIconRight, isAbsolute, isClickable, isFixedSize, isOutline, isSoft, offset, palette, shape }) => `
62
+ }))(({ theme, badgeOffset, badgePosition, hasIconLeft, hasIconRight, isAbsolute, isClickable, isFixedSize, isOutline, isSoft, palette, shape }) => `
63
63
  display: inline-flex;
64
64
  font-family: ${theme.$.fontFamily.badge};
65
65
  word-break: break-word;
@@ -200,7 +200,7 @@ exports.default = (0, styled_components_1.default)(Div_1.default).attrs(({ hasIc
200
200
  ${isAbsolute
201
201
  ? `
202
202
  position: absolute;
203
- ${types_1.Position[badgePosition].toLowerCase()}: ${offset}px;
203
+ ${types_1.Position[badgePosition].toLowerCase()}: ${badgeOffset}px;
204
204
  `
205
205
  : ''}
206
206
  `);
@@ -3,9 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
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"));
6
8
  const mouse_click_events_1 = __importDefault(require("@smart-react-components/core/element-props/mouse-click-events"));
7
9
  const react_1 = __importDefault(require("react"));
8
10
  const BadgeIconElement_1 = __importDefault(require("./BadgeIconElement"));
9
- const BadgeIcon = (props) => (react_1.default.createElement(BadgeIconElement_1.default, { iconPosition: props.iconPosition, isClickable: !!mouse_click_events_1.default.find(i => props[i]), isOutline: props.isOutline, isSoft: props.isSoft, palette: props.palette, shape: props.shape }, props.children));
10
- BadgeIcon.displayName = 'SRCIcon';
11
+ const BadgeIcon = (props) => (react_1.default.createElement(BadgeIconElement_1.default, Object.assign({}, (0, element_props_1.default)(props, [click_events_1.default]), { iconPosition: props.position, isClickable: !!mouse_click_events_1.default.find(i => props[i]), isOutline: props.isOutline, isSoft: props.isSoft, palette: props.palette, shape: props.shape }), props.children));
12
+ BadgeIcon.displayName = 'SRCBadgeIcon';
11
13
  exports.default = BadgeIcon;
@@ -7,12 +7,24 @@ const element_props_1 = __importDefault(require("@smart-react-components/core/el
7
7
  const intrinsic_styled_props_1 = __importDefault(require("@smart-react-components/core/element-props/intrinsic-styled-props"));
8
8
  const react_1 = __importDefault(require("react"));
9
9
  const BadgeListElement_1 = __importDefault(require("./BadgeListElement"));
10
- const BadgeList = props => (react_1.default.createElement(BadgeListElement_1.default, Object.assign({ badgeListSize: props.size, badgeListSizeSm: props.sizeSm, badgeListSizeMd: props.sizeMd, badgeListSizeLg: props.sizeLg, badgeListSizeXl: props.sizeXl, hasSpace: props.hasSpace }, (0, element_props_1.default)(props, [intrinsic_styled_props_1.default]), props.elementProps), props.children.map((item, index) => {
11
- var _a;
12
- return react_1.default.cloneElement(item, Object.assign({ key: (_a = item.key) !== null && _a !== void 0 ? _a : index, hasSpace: props.hasSpace, isFixedSizze: props.isFixedSize, isOutline: props.isOutline, isSoft: props.isSoft, palette: props.palette, shape: props.shape, size: props.size, sizeSm: props.sizeSm, sizeMd: props.sizeMd, sizeLg: props.sizeLg, sizeXl: props.sizeXl }, item.props));
13
- })));
14
- BadgeList.defaultProps = {
15
- hasSpace: true,
16
- size: 'medium',
10
+ const BadgeList = props => {
11
+ var _a, _b;
12
+ return (react_1.default.createElement(BadgeListElement_1.default, Object.assign({ badgeListSize: (_a = props.size) !== null && _a !== void 0 ? _a : 'medium', badgeListSizeSm: props.sizeSm, badgeListSizeMd: props.sizeMd, badgeListSizeLg: props.sizeLg, badgeListSizeXl: props.sizeXl, hasSpace: (_b = props.hasSpace) !== null && _b !== void 0 ? _b : true }, (0, element_props_1.default)(props, [intrinsic_styled_props_1.default]), props.elementProps), props.children.map((item, index) => {
13
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
14
+ return react_1.default.cloneElement(item, {
15
+ key: (_a = item.key) !== null && _a !== void 0 ? _a : index,
16
+ hasSpace: (_c = (_b = props.hasSpace) !== null && _b !== void 0 ? _b : item.props.hasSpace) !== null && _c !== void 0 ? _c : true,
17
+ isFixedSize: (_d = props.isFixedSize) !== null && _d !== void 0 ? _d : item.props.isFixedSize,
18
+ isOutline: (_e = props.isOutline) !== null && _e !== void 0 ? _e : item.props.isOutline,
19
+ isSoft: (_f = props.isSoft) !== null && _f !== void 0 ? _f : item.props.isSoft,
20
+ palette: (_g = props.palette) !== null && _g !== void 0 ? _g : item.props.palette,
21
+ shape: (_h = props.shape) !== null && _h !== void 0 ? _h : item.props.shape,
22
+ size: (_j = props.size) !== null && _j !== void 0 ? _j : item.props.size,
23
+ sizeSm: (_k = props.sizeSm) !== null && _k !== void 0 ? _k : item.props.sizeSm,
24
+ sizeMd: (_l = props.sizeMd) !== null && _l !== void 0 ? _l : item.props.sizeMd,
25
+ sizeLg: (_m = props.sizeLg) !== null && _m !== void 0 ? _m : item.props.sizeLg,
26
+ sizeXl: (_o = props.sizeXl) !== null && _o !== void 0 ? _o : item.props.sizeXl,
27
+ });
28
+ })));
17
29
  };
18
30
  exports.default = BadgeList;
package/Badge/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { ContentElement, PaletteProp, ResponsiveProp, ShapeProp, SizeProp } from
4
4
  import React from 'react';
5
5
  import { Position } from '../types';
6
6
  export interface Props extends Partial<ResponsiveProp<'size', SizeProp>>, ClickEvents, IntrinsicStyledProps {
7
- children: ContentElement;
7
+ children: ContentElement | ContentElement[];
8
8
  hasSpace?: boolean;
9
9
  isAbsolute?: boolean;
10
10
  isFixedSize?: boolean;
package/Badge/index.js CHANGED
@@ -33,21 +33,49 @@ const mouse_click_events_1 = __importDefault(require("@smart-react-components/co
33
33
  const useChangeEffect_1 = __importDefault(require("@smart-react-components/core/hooks/useChangeEffect"));
34
34
  const react_1 = __importDefault(require("react"));
35
35
  const types_1 = require("../types");
36
- const props_1 = require("../util/props");
37
36
  const BadgeElement_1 = __importStar(require("./BadgeElement"));
38
37
  const Badge = props => {
39
38
  var _a;
40
- const getContent = () => (0, props_1.extractIconsOutOfChildren)(props.children, BadgeElement_1.Content, {
41
- isOutline: props.isOutline,
42
- isSoft: props.isSoft,
43
- palette: props.palette,
44
- shape: props.shape,
45
- });
39
+ const getContent = () => {
40
+ var _a, _b;
41
+ const children = !Array.isArray(props.children) ? [props.children] : props.children;
42
+ const content = [];
43
+ let iconLeft = null;
44
+ let iconRight = null;
45
+ for (let i = 0; i < children.length; i++) {
46
+ const item = children[i];
47
+ if (((_a = item.type) === null || _a === void 0 ? void 0 : _a.displayName) === 'SRCBadgeIcon') {
48
+ const iconEl = react_1.default.cloneElement(item, {
49
+ isOutline: props.isOutline,
50
+ isSoft: props.isSoft,
51
+ palette: props.palette,
52
+ position: i === 0 ? types_1.OrderPosition.LEFT : types_1.OrderPosition.RIGHT,
53
+ shape: props.shape,
54
+ });
55
+ if (i === 0) {
56
+ iconLeft = iconEl;
57
+ }
58
+ else if (i === children.length - 1) {
59
+ iconRight = iconEl;
60
+ }
61
+ continue;
62
+ }
63
+ content.push(typeof children[i] === 'string' ? children[i] : react_1.default.cloneElement(item, { key: (_b = item.key) !== null && _b !== void 0 ? _b : i }));
64
+ }
65
+ return {
66
+ children: (react_1.default.createElement(react_1.default.Fragment, null,
67
+ iconLeft && iconLeft,
68
+ react_1.default.createElement(BadgeElement_1.Content, null, content),
69
+ iconRight && iconRight)),
70
+ hasIconLeft: !!iconLeft,
71
+ hasIconRight: !!iconRight,
72
+ };
73
+ };
46
74
  const [{ children, hasIconLeft, hasIconRight }, setContent] = react_1.default.useState(() => getContent());
47
75
  (0, useChangeEffect_1.default)(() => {
48
76
  setContent(getContent());
49
- }, [props.children, props.isSoft, props.palette, props.size, props.sizeSm, props.sizeMd, props.sizeLg, props.sizeXl]);
50
- return (react_1.default.createElement(BadgeElement_1.default, Object.assign({ badgePosition: props.position, badgeSize: props.size, badgeSizeSm: props.sizeSm, badgeSizeMd: props.sizeMd, badgeSizeLg: props.sizeLg, badgeSizeXl: props.sizeXl, hasIconLeft: hasIconLeft, hasIconRight: hasIconRight, hasSpace: (_a = props.hasSpace) !== null && _a !== void 0 ? _a : !props.isAbsolute, isAbsolute: props.isAbsolute, isClickable: !!mouse_click_events_1.default.find(i => props[i]), isFixedSize: props.isFixedSize, isOutline: props.isOutline, isSoft: props.isSoft, offset: props.offset, palette: props.palette, shape: props.shape }, (0, element_props_1.default)(props, [click_events_1.default, intrinsic_styled_props_1.default])), children));
77
+ }, [props.children]);
78
+ return (react_1.default.createElement(BadgeElement_1.default, Object.assign({ badgeOffset: props.offset, badgePosition: props.position, badgeSize: props.size, badgeSizeSm: props.sizeSm, badgeSizeMd: props.sizeMd, badgeSizeLg: props.sizeLg, badgeSizeXl: props.sizeXl, hasIconLeft: hasIconLeft, hasIconRight: hasIconRight, hasSpace: (_a = props.hasSpace) !== null && _a !== void 0 ? _a : !props.isAbsolute, isAbsolute: props.isAbsolute, isClickable: !!mouse_click_events_1.default.find(i => props[i]), isFixedSize: props.isFixedSize, isOutline: props.isOutline, isSoft: props.isSoft, palette: props.palette, shape: props.shape }, (0, element_props_1.default)(props, [click_events_1.default, intrinsic_styled_props_1.default])), children));
51
79
  };
52
80
  Badge.defaultProps = {
53
81
  offset: 10,
@@ -0,0 +1,11 @@
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 interface Props extends StyledProps, Partial<ResponsiveProp<'checkboxSize', SizeProp>> {
4
+ isChecked?: boolean;
5
+ isOutline?: boolean;
6
+ isSoft?: boolean;
7
+ palette?: PaletteProp;
8
+ shape?: ShapeProp;
9
+ }
10
+ declare const _default: import("styled-components").StyledComponent<"div", any, StyledProps & Props, never>;
11
+ export default _default;
@@ -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 react_1 = __importDefault(require("react"));
8
+ const styled_components_1 = __importDefault(require("styled-components"));
9
+ const Container = styled_components_1.default.div(({ theme }) => `
10
+ border: solid 2px ${theme.$.color.dynamic.accent};
11
+ box-sizing: border-box;
12
+ display: flex;
13
+ height: 100%;
14
+ justify-content: center;
15
+ position: relative;
16
+ `);
17
+ const Rectangle = styled_components_1.default.div `
18
+ position: absolute;
19
+ left: -2px;
20
+ height: calc(100% + 4px);
21
+ top: -2px;
22
+ transition: background 200ms 0s ease-in-out;
23
+ width: calc(100% + 4px);
24
+ `;
25
+ const Svg = styled_components_1.default.svg.attrs({
26
+ children: react_1.default.createElement("path", { d: "M3.5,17.2l7.6,7.6L28.5,7.3" }),
27
+ viewBox: '0 0 32 32',
28
+ })(({ theme }) => `
29
+ flex: 0 0 auto;
30
+ position: relative;
31
+
32
+ > path {
33
+ fill: transparent;
34
+ stroke: ${theme.$.color.dynamic.background};
35
+ stroke-width: 4px;
36
+ stroke-dasharray: 36px;
37
+ stroke-dashoffset: 36px;
38
+ transition: stroke-dashoffset 200ms 0s ease-in-out;
39
+ }
40
+ `);
41
+ exports.default = (0, styled_components_1.default)(Div_1.default).attrs(({ children }) => ({
42
+ children: (react_1.default.createElement(react_1.default.Fragment, null,
43
+ children && children,
44
+ react_1.default.createElement(Container, null,
45
+ react_1.default.createElement(Rectangle, null),
46
+ react_1.default.createElement(Svg, null)))),
47
+ getCheckboxSize: (v, t) => `
48
+ height: ${t.$.size.checkbox[v]};
49
+ width: ${t.$.size.checkbox[v]};
50
+ `,
51
+ }))(({ theme, isChecked, isOutline, isSoft, palette, shape }) => `
52
+ position: relative;
53
+
54
+ ${Container} {
55
+ border-radius: ${theme.$.radius.checkbox[shape]};
56
+
57
+ ${!isOutline
58
+ ? `
59
+ background: ${theme.$.color.dynamic.accent};
60
+ `
61
+ : ''}
62
+ }
63
+
64
+ ${Rectangle} {
65
+ border-radius: ${theme.$.radius.checkbox[shape]};
66
+ }
67
+
68
+ ${isChecked
69
+ ? `
70
+ ${Rectangle} {
71
+ background: ${!isSoft ? theme.$.palette[palette].main : theme.$.palette[palette].soft};
72
+ }
73
+
74
+ ${Svg} > path {
75
+ stroke-dashoffset: 0;
76
+ }
77
+ `
78
+ : ''}
79
+ `);
@@ -0,0 +1,21 @@
1
+ import { IntrinsicStyledProps } from '@smart-react-components/core/element-props/intrinsic-styled-props';
2
+ import { PaletteProp, Partial, ResponsiveProp, SetState, ShapeProp, 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
+ children: JSX.Element[];
9
+ isBlock?: boolean;
10
+ isOutline?: boolean;
11
+ isRequired?: boolean;
12
+ isSoft?: boolean;
13
+ name?: string;
14
+ palette?: PaletteProp;
15
+ position?: OrderPosition;
16
+ setActive?: SetState<FormValue[]>;
17
+ shape?: ShapeProp;
18
+ template?: JSX.Element;
19
+ }
20
+ declare const CheckboxGroup: React.FC<Props>;
21
+ export default CheckboxGroup;
@@ -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
+ 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 FormGroup_1 = __importDefault(require("../../components/FormGroup"));
11
+ var types_1 = require("../../types");
12
+ Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return types_1.OrderPosition; } });
13
+ const CheckboxGroup = props => (react_1.default.createElement(FormGroup_1.default, Object.assign({ isBlock: props.isBlock }, (0, element_props_1.default)(props, [intrinsic_styled_props_1.default])), props.children.map((item, idx) => {
14
+ var _a;
15
+ return react_1.default.cloneElement(item, Object.assign({ key: (_a = item.key) !== null && _a !== void 0 ? _a : idx, active: props.active, isBlock: props.isBlock, isOutline: props.isOutline, isRequired: props.isRequired, isSoft: props.isSoft, name: props.name, palette: props.palette, position: props.position, setActive: props.setActive, shape: props.shape, template: props.template }, item.props));
16
+ })));
17
+ exports.default = CheckboxGroup;
@@ -0,0 +1,25 @@
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
+ 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
+ isChecked?: boolean;
10
+ isDisabled?: boolean;
11
+ isOutline?: boolean;
12
+ isRequired?: boolean;
13
+ isSoft?: boolean;
14
+ label?: ContentElement;
15
+ name?: string;
16
+ palette?: PaletteProp;
17
+ position?: OrderPosition;
18
+ setActive?: SetState<FormValue[]>;
19
+ setChecked?: SetState<boolean>;
20
+ shape?: ShapeProp;
21
+ template?: JSX.Element;
22
+ value?: FormValue;
23
+ }
24
+ declare const Checkbox: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLInputElement>>;
25
+ export default Checkbox;
@@ -0,0 +1,72 @@
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 useChangeEffect_1 = __importDefault(require("@smart-react-components/core/hooks/useChangeEffect"));
10
+ const react_1 = __importDefault(require("react"));
11
+ const FormInlineLabel_1 = __importDefault(require("../components/FormInlineLabel"));
12
+ const HiddenInput_1 = __importDefault(require("../components/HiddenInput"));
13
+ const types_1 = require("../types");
14
+ const CheckboxElement_1 = __importDefault(require("./CheckboxElement"));
15
+ var types_2 = require("../types");
16
+ Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return types_2.OrderPosition; } });
17
+ const Checkbox = react_1.default.forwardRef((props, forwardRef) => {
18
+ const getChecked = () => {
19
+ if (props.setChecked) {
20
+ return props.isChecked;
21
+ }
22
+ if (props.setActive) {
23
+ return typeof props.active.find(v => v === props.value) !== 'undefined';
24
+ }
25
+ return false;
26
+ };
27
+ const [isChecked, setChecked] = react_1.default.useState(() => getChecked());
28
+ (0, useChangeEffect_1.default)(() => {
29
+ setChecked(getChecked());
30
+ }, [props.active, props.isChecked]);
31
+ const handleOnChange = () => {
32
+ if (!props.isDisabled) {
33
+ if (props.setChecked) {
34
+ props.setChecked(!props.isChecked);
35
+ }
36
+ else if (props.setActive) {
37
+ if (!props.active.includes(props.value)) {
38
+ props.setActive([...props.active, props.value]);
39
+ }
40
+ else {
41
+ props.setActive(props.active.filter(item => item !== props.value));
42
+ }
43
+ }
44
+ }
45
+ };
46
+ const input = (react_1.default.createElement(HiddenInput_1.default, Object.assign({ checked: isChecked, onChange: handleOnChange, ref: forwardRef, type: "checkbox" }, (props.isDisabled && { disabled: true }), (props.isRequired && { required: true }), (props.name && { name: props.name }))));
47
+ 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])),
48
+ react_1.default.cloneElement(props.template, {
49
+ checkboxSize: props.size,
50
+ checkboxSizeSm: props.sizeSm,
51
+ checkboxSizeMd: props.sizeMd,
52
+ checkboxSizeLg: props.sizeLg,
53
+ checkboxSizeXl: props.sizeXl,
54
+ children: (react_1.default.createElement(react_1.default.Fragment, null,
55
+ input,
56
+ props.template.props.children)),
57
+ isChecked,
58
+ isOutline: props.isOutline,
59
+ isSoft: props.isSoft,
60
+ palette: props.palette,
61
+ shape: props.shape,
62
+ }),
63
+ props.label && react_1.default.createElement("span", null, props.label)));
64
+ });
65
+ Checkbox.defaultProps = {
66
+ palette: 'primary',
67
+ position: types_1.OrderPosition.RIGHT,
68
+ shape: 'rectangle',
69
+ size: 'medium',
70
+ template: react_1.default.createElement(CheckboxElement_1.default, null),
71
+ };
72
+ exports.default = Checkbox;
@@ -0,0 +1,16 @@
1
+ import { StyledProps } from '@smart-react-components/core/styled-props';
2
+ import { PaletteProp, ResponsiveProp, ShapeProp, SizeProp } from '@smart-react-components/core/types';
3
+ import { OrderPosition } from '../../types';
4
+ interface Props extends StyledProps, ResponsiveProp<'inputSize', SizeProp> {
5
+ addonPosition: OrderPosition;
6
+ hasBorder: boolean;
7
+ isDisabled: boolean;
8
+ isFocused: boolean;
9
+ isOutline: boolean;
10
+ isSeparated: boolean;
11
+ isSoft: boolean;
12
+ palette: PaletteProp;
13
+ shape?: ShapeProp;
14
+ }
15
+ declare const _default: import("styled-components").StyledComponent<"div", any, StyledProps & Props, never>;
16
+ export default _default;
@@ -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 Label_1 = __importDefault(require("@smart-react-components/core/Element/Label"));
8
+ const styled_components_1 = __importDefault(require("styled-components"));
9
+ const types_1 = require("../../types");
10
+ const css_1 = require("../../util/css");
11
+ const props_1 = require("../../util/props");
12
+ exports.default = (0, styled_components_1.default)(Div_1.default).attrs(({ isSeparated }) => (Object.assign(Object.assign({}, (isSeparated && { as: Label_1.default })), { getInputSize: (v, t) => `
13
+ font-size: ${t.$.size.form.blockLabel[v].fontSize};
14
+ padding: ${isSeparated ? t.$.size.input[v].padding.y : 0} ${(0, css_1.toCSSValue)(t.$.size.input[v].padding.x)(v => v / 2)};
15
+ ` })))(({ theme, addonPosition, hasBorder, isDisabled, isFocused, isOutline, isSeparated, isSoft, palette, shape }) => `
16
+ align-items: center;
17
+ border-bottom-${types_1.OrderPosition[addonPosition].toLowerCase()}-radius: ${theme.$.radius.input[shape]};
18
+ border-top-${types_1.OrderPosition[addonPosition].toLowerCase()}-radius: ${theme.$.radius.input[shape]};
19
+ box-sizing: border-box;
20
+ display: inline-flex;
21
+ flex: 0 0 auto;
22
+ justify-content: center;
23
+ transition: 200ms 0s ease-in-out;
24
+ transition-property: background, border, color, fill;
25
+
26
+ ${isSeparated
27
+ ? `
28
+ align-self: flex-start;
29
+ `
30
+ : ''}
31
+
32
+ ${hasBorder
33
+ ? `
34
+ border: solid 1px;
35
+ border-${types_1.OrderPosition[(0, props_1.getReverseOrderPosition)(addonPosition)].toLowerCase()}: 0;
36
+ `
37
+ : ''}
38
+
39
+ ${!isOutline
40
+ ? `
41
+ ${!isSoft
42
+ ? `
43
+ color: ${theme.$.palette[palette].font};
44
+ fill: ${theme.$.palette[palette].font};
45
+
46
+ ${(isSeparated || !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
+ fill: ${theme.$.palette[palette].softFont};
59
+
60
+ ${(isSeparated || !isFocused)
61
+ ? `
62
+ background: ${theme.$.palette[palette].soft};
63
+ border-color: ${theme.$.palette[palette].softDark};
64
+ `
65
+ : `
66
+ background: ${theme.$.palette[palette].softDarker};
67
+ border-color: ${theme.$.palette[palette].softDarkest};
68
+ `}
69
+ `}
70
+ `
71
+ : `
72
+ background: ${theme.$.color.dynamic.background};
73
+ border-color ${(isSeparated || !isFocused) ? theme.$.color.dynamic.accent : theme.$.palette[palette].main};
74
+ color: ${theme.$.color.dynamic.font};
75
+ fill: ${theme.$.color.dynamic.font};
76
+ `}
77
+
78
+ ${(!isSeparated && isDisabled)
79
+ ? `
80
+ opacity: ${theme.$.opacity.formDisabled};
81
+
82
+ ${isOutline
83
+ ? `
84
+ background: ${theme.$.color.dynamic.accent};
85
+ color: ${theme.$.color.dynamic.gray};
86
+ `
87
+ : ''}
88
+ `
89
+ : ''}
90
+ `);
@@ -0,0 +1,12 @@
1
+ import { ClickEvents } from '@smart-react-components/core/element-props/click-events';
2
+ import { ContentElement, PaletteProp, Partial, 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
+ isOutline?: boolean;
7
+ isSeparated?: boolean;
8
+ isSoft?: boolean;
9
+ palette?: PaletteProp;
10
+ }
11
+ declare const InputAddon: React.FC<Props>;
12
+ export default InputAddon;
@@ -0,0 +1,12 @@
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 InputAddonElement_1 = __importDefault(require("./InputAddonElement"));
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 = 'SRCInputAddon';
12
+ exports.default = InputAddon;
@@ -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;