@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,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 320 512";
5
+ }, "children" | "viewBox">;
6
+ export default _default;
@@ -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 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("path", { d: "M137.4 374.6c12.5 12.5 32.8 12.5 45.3 0l128-128c9.2-9.2 11.9-22.9 6.9-34.9s-16.6-19.8-29.6-19.8L32 192c-12.9 0-24.6 7.8-29.6 19.8s-2.2 25.7 6.9 34.9l128 128z" }),
11
+ viewBox: '0 0 320 512',
12
+ }) ``;
@@ -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 320 512";
5
+ }, "children" | "viewBox">;
6
+ export default _default;
@@ -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 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("path", { d: "M182.6 137.4c-12.5-12.5-32.8-12.5-45.3 0l-128 128c-9.2 9.2-11.9 22.9-6.9 34.9s16.6 19.8 29.6 19.8H288c12.9 0 24.6-7.8 29.6-19.8s2.2-25.7-6.9-34.9l-128-128z" }),
11
+ viewBox: '0 0 320 512',
12
+ }) ``;
package/index.d.ts CHANGED
@@ -5,6 +5,8 @@ export { default as Badge } from './Badge';
5
5
  export { default as BadgeIcon } from './Badge/BadgeIcon';
6
6
  export { default as BadgeList } from './Badge/BadgeList';
7
7
  export * from './Breadcrumb';
8
+ export { default as Checkbox } from './Checkbox';
9
+ export { default as CheckboxGroup } from './Checkbox/CheckboxGroup';
8
10
  export { default as Dropdown } from './Dropdown';
9
11
  export { default as DropdownArrowIcon } from './Dropdown/DropdownArrowIcon';
10
12
  export { default as DropdownCategory } from './Dropdown/DropdownCategory';
@@ -12,9 +14,19 @@ export { default as DropdownItem } from './Dropdown/DropdownItem';
12
14
  export { default as DropdownList } from './Dropdown/DropdownList';
13
15
  export { default as FixedBox } from './FixedBox';
14
16
  export * from './Grid';
17
+ export { default as Input } from './Input';
18
+ export { default as InputAddon } from './Input/InputAddon';
19
+ export { default as InputFile } from './Input/InputFile';
20
+ export { default as InputNumber } from './Input/InputNumber';
15
21
  export { default as Loading } from './Loading';
16
22
  export { default as Overlay } from './Overlay';
23
+ export * from './Pagination';
17
24
  export { default as Popover } from './Popover';
18
25
  export { default as ProgressBar } from './ProgressBar';
26
+ export { default as Radio } from './Radio';
27
+ export { default as RadioGroup } from './Radio/RadioGroup';
28
+ export { default as Switch } from './Switch';
29
+ export { default as SwitchGroup } from './Switch/SwitchGroup';
30
+ export { default as Textarea } from './Textarea';
19
31
  export { default as Tooltip } from './Tooltip';
20
32
  export { default as WaveEffect } from './WaveEffect';
package/index.js CHANGED
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.WaveEffect = exports.Tooltip = exports.ProgressBar = exports.Popover = exports.Overlay = exports.Loading = exports.FixedBox = exports.DropdownList = exports.DropdownItem = exports.DropdownCategory = exports.DropdownArrowIcon = exports.Dropdown = exports.BadgeList = exports.BadgeIcon = exports.Badge = exports.AlertIcon = exports.AlertCloseIcon = exports.Alert = void 0;
20
+ exports.WaveEffect = exports.Tooltip = exports.Textarea = exports.SwitchGroup = exports.Switch = exports.RadioGroup = exports.Radio = exports.ProgressBar = exports.Popover = exports.Overlay = exports.Loading = exports.InputNumber = exports.InputFile = exports.InputAddon = exports.Input = exports.FixedBox = exports.DropdownList = exports.DropdownItem = exports.DropdownCategory = exports.DropdownArrowIcon = exports.Dropdown = exports.CheckboxGroup = exports.Checkbox = exports.BadgeList = exports.BadgeIcon = exports.Badge = exports.AlertIcon = exports.AlertCloseIcon = exports.Alert = void 0;
21
21
  var Alert_1 = require("./Alert");
22
22
  Object.defineProperty(exports, "Alert", { enumerable: true, get: function () { return __importDefault(Alert_1).default; } });
23
23
  var AlertCloseIcon_1 = require("./Alert/AlertCloseIcon");
@@ -31,6 +31,10 @@ Object.defineProperty(exports, "BadgeIcon", { enumerable: true, get: function ()
31
31
  var BadgeList_1 = require("./Badge/BadgeList");
32
32
  Object.defineProperty(exports, "BadgeList", { enumerable: true, get: function () { return __importDefault(BadgeList_1).default; } });
33
33
  __exportStar(require("./Breadcrumb"), exports);
34
+ var Checkbox_1 = require("./Checkbox");
35
+ Object.defineProperty(exports, "Checkbox", { enumerable: true, get: function () { return __importDefault(Checkbox_1).default; } });
36
+ var CheckboxGroup_1 = require("./Checkbox/CheckboxGroup");
37
+ Object.defineProperty(exports, "CheckboxGroup", { enumerable: true, get: function () { return __importDefault(CheckboxGroup_1).default; } });
34
38
  var Dropdown_1 = require("./Dropdown");
35
39
  Object.defineProperty(exports, "Dropdown", { enumerable: true, get: function () { return __importDefault(Dropdown_1).default; } });
36
40
  var DropdownArrowIcon_1 = require("./Dropdown/DropdownArrowIcon");
@@ -44,14 +48,33 @@ Object.defineProperty(exports, "DropdownList", { enumerable: true, get: function
44
48
  var FixedBox_1 = require("./FixedBox");
45
49
  Object.defineProperty(exports, "FixedBox", { enumerable: true, get: function () { return __importDefault(FixedBox_1).default; } });
46
50
  __exportStar(require("./Grid"), exports);
51
+ var Input_1 = require("./Input");
52
+ Object.defineProperty(exports, "Input", { enumerable: true, get: function () { return __importDefault(Input_1).default; } });
53
+ var InputAddon_1 = require("./Input/InputAddon");
54
+ Object.defineProperty(exports, "InputAddon", { enumerable: true, get: function () { return __importDefault(InputAddon_1).default; } });
55
+ var InputFile_1 = require("./Input/InputFile");
56
+ Object.defineProperty(exports, "InputFile", { enumerable: true, get: function () { return __importDefault(InputFile_1).default; } });
57
+ var InputNumber_1 = require("./Input/InputNumber");
58
+ Object.defineProperty(exports, "InputNumber", { enumerable: true, get: function () { return __importDefault(InputNumber_1).default; } });
47
59
  var Loading_1 = require("./Loading");
48
60
  Object.defineProperty(exports, "Loading", { enumerable: true, get: function () { return __importDefault(Loading_1).default; } });
49
61
  var Overlay_1 = require("./Overlay");
50
62
  Object.defineProperty(exports, "Overlay", { enumerable: true, get: function () { return __importDefault(Overlay_1).default; } });
63
+ __exportStar(require("./Pagination"), exports);
51
64
  var Popover_1 = require("./Popover");
52
65
  Object.defineProperty(exports, "Popover", { enumerable: true, get: function () { return __importDefault(Popover_1).default; } });
53
66
  var ProgressBar_1 = require("./ProgressBar");
54
67
  Object.defineProperty(exports, "ProgressBar", { enumerable: true, get: function () { return __importDefault(ProgressBar_1).default; } });
68
+ var Radio_1 = require("./Radio");
69
+ Object.defineProperty(exports, "Radio", { enumerable: true, get: function () { return __importDefault(Radio_1).default; } });
70
+ var RadioGroup_1 = require("./Radio/RadioGroup");
71
+ Object.defineProperty(exports, "RadioGroup", { enumerable: true, get: function () { return __importDefault(RadioGroup_1).default; } });
72
+ var Switch_1 = require("./Switch");
73
+ Object.defineProperty(exports, "Switch", { enumerable: true, get: function () { return __importDefault(Switch_1).default; } });
74
+ var SwitchGroup_1 = require("./Switch/SwitchGroup");
75
+ Object.defineProperty(exports, "SwitchGroup", { enumerable: true, get: function () { return __importDefault(SwitchGroup_1).default; } });
76
+ var Textarea_1 = require("./Textarea");
77
+ Object.defineProperty(exports, "Textarea", { enumerable: true, get: function () { return __importDefault(Textarea_1).default; } });
55
78
  var Tooltip_1 = require("./Tooltip");
56
79
  Object.defineProperty(exports, "Tooltip", { enumerable: true, get: function () { return __importDefault(Tooltip_1).default; } });
57
80
  var WaveEffect_1 = require("./WaveEffect");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smart-react-components/ui",
3
- "version": "2.0.0-alpha-3",
3
+ "version": "2.0.0-alpha-5",
4
4
  "license": "MIT",
5
5
  "main": "index.js",
6
6
  "description": "SRC UI includes React and Styled components.",
@@ -64,9 +64,9 @@
64
64
  "test": "jest"
65
65
  },
66
66
  "devDependencies": {
67
- "@smart-react-components/core": "2.0.0-alpha-10",
68
- "@smart-react-components/router": "2.0.0-alpha-5",
69
- "@smart-react-components/transition": "2.0.0-alpha-6",
67
+ "@smart-react-components/core": "2.0.0-alpha-11",
68
+ "@smart-react-components/router": "2.0.0-alpha-7",
69
+ "@smart-react-components/transition": "2.0.0-alpha-7",
70
70
  "@testing-library/react": "13.4.0",
71
71
  "@types/jest": "29.0.1",
72
72
  "@types/react": "18.0.19",
@@ -83,9 +83,9 @@
83
83
  "typescript": "4.8.3"
84
84
  },
85
85
  "peerDependencies": {
86
- "@smart-react-components/core": "^2.0.0-alpha-10",
87
- "@smart-react-components/router": "^2.0.0-alpha-5",
88
- "@smart-react-components/transition": "^2.0.0-alpha-6",
86
+ "@smart-react-components/core": "^2.0.0-alpha-11",
87
+ "@smart-react-components/router": "^2.0.0-alpha-7",
88
+ "@smart-react-components/transition": "^2.0.0-alpha-7",
89
89
  "react": "^18.2.0",
90
90
  "react-dom": "^18.2.0",
91
91
  "styled-components": "^5.3.5"
package/types/index.d.ts CHANGED
@@ -1,3 +1,13 @@
1
+ import { Value } from '@smart-react-components/core/types';
2
+ export declare type FormValue = Value | boolean;
3
+ export declare enum InputType {
4
+ EMAIL = "email",
5
+ PASSWORD = "password",
6
+ SEARCH = "search",
7
+ TEL = "tel",
8
+ TEXT = "text",
9
+ URL = "url"
10
+ }
1
11
  export declare enum OrderPosition {
2
12
  LEFT = 1,
3
13
  RIGHT = 2
package/types/index.js CHANGED
@@ -1,6 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TriggerInteraction = exports.Position = exports.OrderPosition = void 0;
3
+ exports.TriggerInteraction = exports.Position = exports.OrderPosition = exports.InputType = void 0;
4
+ var InputType;
5
+ (function (InputType) {
6
+ InputType["EMAIL"] = "email";
7
+ InputType["PASSWORD"] = "password";
8
+ InputType["SEARCH"] = "search";
9
+ InputType["TEL"] = "tel";
10
+ InputType["TEXT"] = "text";
11
+ InputType["URL"] = "url";
12
+ })(InputType = exports.InputType || (exports.InputType = {}));
4
13
  var OrderPosition;
5
14
  (function (OrderPosition) {
6
15
  OrderPosition[OrderPosition["LEFT"] = 1] = "LEFT";
package/util/css.d.ts CHANGED
@@ -1,4 +1,9 @@
1
1
  import { Value } from '@smart-react-components/core/types';
2
+ /**
3
+ * Takes a CSS number value as JavaScript string or number.
4
+ * Extracts the unit and returns the number part of the value.
5
+ */
6
+ export declare const extractNumberUnit: (input: Value) => number;
2
7
  /**
3
8
  * Takes a CSS number as JavaScript string or number.
4
9
  * Splits the given input in two as value and unit parts.
package/util/css.js CHANGED
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toCSSValue = void 0;
3
+ exports.toCSSValue = exports.extractNumberUnit = void 0;
4
+ /**
5
+ * Takes a CSS number value as JavaScript string or number.
6
+ * Extracts the unit and returns the number part of the value.
7
+ */
8
+ const extractNumberUnit = (input) => typeof input === 'number' ? input : Number(input.replace(/[A-z|%]+/, ''));
9
+ exports.extractNumberUnit = extractNumberUnit;
4
10
  /**
5
11
  * Takes a CSS number as JavaScript string or number.
6
12
  * Splits the given input in two as value and unit parts.
package/util/dom.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export declare const mouseWheel: string[];
2
+ export declare const placeholder: string[];
2
3
  /**
3
4
  * Calculates the left, top, width and height of the element shown on the screen.
4
5
  */
package/util/dom.js CHANGED
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isTargetClickable = exports.getScrollParent = exports.canBeRenderedInPortal = exports.calculateShownPart = exports.mouseWheel = void 0;
3
+ exports.isTargetClickable = exports.getScrollParent = exports.canBeRenderedInPortal = exports.calculateShownPart = exports.placeholder = exports.mouseWheel = void 0;
4
4
  const dom_1 = require("@smart-react-components/core/util/dom");
5
5
  exports.mouseWheel = ['wheel', 'mousewheel', 'DOMMouseScroll'];
6
+ exports.placeholder = ['::-webkit-input-placeholder', '::-moz-placeholder', ':-moz-placeholder', ':-ms-input-placeholder', '::placeholder'];
6
7
  /**
7
8
  * Calculates the left, top, width and height of the element shown on the screen.
8
9
  */
package/util/form.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Calculates margin X value of the form label.
3
+ */
4
+ export declare const calculateFormLabelMarginX: (value: number) => string;
package/util/form.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateFormLabelMarginX = void 0;
4
+ /**
5
+ * Calculates margin X value of the form label.
6
+ */
7
+ const calculateFormLabelMarginX = (value) => (value / 1.0667).toFixed(5);
8
+ exports.calculateFormLabelMarginX = calculateFormLabelMarginX;
package/util/props.d.ts CHANGED
@@ -1,18 +1,4 @@
1
- import { ContentElement } from '@smart-react-components/core/types';
2
- import { StyledComponent } from 'styled-components';
3
1
  import { OrderPosition } from '../types';
4
- /**
5
- * Extracts icon elements out of children.
6
- *
7
- * @params children - children prop given to the component.
8
- * @params Content - The component that wraps all children except for icons.
9
- * @params props - props given to the icon component.
10
- */
11
- export declare const extractIconsOutOfChildren: (children: ContentElement, Content: StyledComponent<'div', any>, props: object) => {
12
- children: JSX.Element;
13
- hasIconLeft: boolean;
14
- hasIconRight: boolean;
15
- };
16
2
  /**
17
3
  * Returns reverse value of the order position.
18
4
  * If value is left, returns right.
package/util/props.js CHANGED
@@ -1,52 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getReverseOrderPosition = exports.extractIconsOutOfChildren = void 0;
7
- const react_1 = __importDefault(require("react"));
3
+ exports.getReverseOrderPosition = void 0;
8
4
  const types_1 = require("../types");
9
- /**
10
- * Extracts icon elements out of children.
11
- *
12
- * @params children - children prop given to the component.
13
- * @params Content - The component that wraps all children except for icons.
14
- * @params props - props given to the icon component.
15
- */
16
- const extractIconsOutOfChildren = (children, Content, props) => {
17
- var _a, _b, _c;
18
- if (!Array.isArray(children)) {
19
- return {
20
- children: react_1.default.createElement(Content, null, children),
21
- hasIconLeft: false,
22
- hasIconRight: false,
23
- };
24
- }
25
- let iconLeft = null;
26
- let iconRight = null;
27
- const content = [];
28
- for (let idx = 0; idx < children.length; idx++) {
29
- const item = children[idx];
30
- if (idx === 0 && ((_a = item.type) === null || _a === void 0 ? void 0 : _a.displayName) === 'SRCIcon') {
31
- iconLeft = react_1.default.cloneElement(item, Object.assign(Object.assign({}, props), { iconPosition: types_1.OrderPosition.LEFT }));
32
- continue;
33
- }
34
- if (idx === children.length - 1 && ((_b = item.type) === null || _b === void 0 ? void 0 : _b.displayName) === 'SRCIcon') {
35
- iconRight = react_1.default.cloneElement(item, Object.assign(Object.assign({}, props), { iconPosition: types_1.OrderPosition.RIGHT }));
36
- continue;
37
- }
38
- content.push(react_1.default.cloneElement(item, { key: (_c = item.key) !== null && _c !== void 0 ? _c : idx }));
39
- }
40
- return {
41
- children: (react_1.default.createElement(react_1.default.Fragment, null,
42
- iconLeft && iconLeft,
43
- react_1.default.createElement(Content, null, content),
44
- iconRight && iconRight)),
45
- hasIconLeft: !!iconLeft,
46
- hasIconRight: !!iconRight,
47
- };
48
- };
49
- exports.extractIconsOutOfChildren = extractIconsOutOfChildren;
50
5
  /**
51
6
  * Returns reverse value of the order position.
52
7
  * If value is left, returns right.
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Calculates the inner circle size value of the radio element.
3
+ */
4
+ export declare const calculateRadioInnerCircleSize: (size: number) => number;
package/util/radio.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateRadioInnerCircleSize = void 0;
4
+ /**
5
+ * Calculates the inner circle size value of the radio element.
6
+ */
7
+ const calculateRadioInnerCircleSize = (size) => {
8
+ let value = Math.max(Math.round(size / 5), 2);
9
+ if (value % 2 > 0) {
10
+ value++;
11
+ }
12
+ return value;
13
+ };
14
+ exports.calculateRadioInnerCircleSize = calculateRadioInnerCircleSize;