@bodynarf/react.components 1.8.21 → 1.9.0

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 (256) hide show
  1. package/common.scss +3 -2
  2. package/components/accordion/component/index.d.ts +2 -2
  3. package/components/accordion/component/index.d.ts.map +1 -1
  4. package/components/accordion/component/index.js +4 -4
  5. package/components/accordion/types.d.ts +1 -1
  6. package/components/accordion/types.d.ts.map +1 -1
  7. package/components/anchor/component/index.d.ts +1 -1
  8. package/components/anchor/component/index.d.ts.map +1 -1
  9. package/components/anchor/component/index.js +6 -6
  10. package/components/anchor/components/anchorWithIcon/index.d.ts +3 -2
  11. package/components/anchor/components/anchorWithIcon/index.d.ts.map +1 -1
  12. package/components/anchor/components/anchorWithIcon/index.js +14 -9
  13. package/components/anchor/components/simpleAnchor/index.d.ts +3 -2
  14. package/components/anchor/components/simpleAnchor/index.d.ts.map +1 -1
  15. package/components/anchor/components/simpleAnchor/index.js +8 -2
  16. package/components/anchor/types.d.ts +2 -6
  17. package/components/anchor/types.d.ts.map +1 -1
  18. package/components/breadcrumbs/component/index.d.ts +34 -0
  19. package/components/breadcrumbs/component/index.d.ts.map +1 -0
  20. package/components/breadcrumbs/component/index.js +21 -0
  21. package/components/breadcrumbs/index.d.ts +3 -0
  22. package/components/breadcrumbs/index.d.ts.map +1 -0
  23. package/components/breadcrumbs/index.js +2 -0
  24. package/components/breadcrumbs/types.d.ts +13 -0
  25. package/components/breadcrumbs/types.d.ts.map +1 -0
  26. package/components/button/component/index.d.ts +1 -1
  27. package/components/button/component/index.d.ts.map +1 -1
  28. package/components/button/component/index.js +4 -8
  29. package/components/button/components/buttonWithIcon/index.d.ts +3 -2
  30. package/components/button/components/buttonWithIcon/index.d.ts.map +1 -1
  31. package/components/button/components/buttonWithIcon/index.js +14 -9
  32. package/components/button/components/simpleButton/index.d.ts +3 -2
  33. package/components/button/components/simpleButton/index.d.ts.map +1 -1
  34. package/components/button/components/simpleButton/index.js +8 -2
  35. package/components/button/types.d.ts +1 -1
  36. package/components/button/types.d.ts.map +1 -1
  37. package/components/button/types.js +0 -3
  38. package/components/dropdown/component/index.d.ts +1 -1
  39. package/components/dropdown/component/index.d.ts.map +1 -1
  40. package/components/dropdown/component/index.js +5 -8
  41. package/components/dropdown/component/style.scss +5 -1
  42. package/components/dropdown/components/compact/index.d.ts +2 -2
  43. package/components/dropdown/components/compact/index.d.ts.map +1 -1
  44. package/components/dropdown/components/compact/index.js +12 -9
  45. package/components/dropdown/components/item/index.d.ts +1 -1
  46. package/components/dropdown/components/item/index.d.ts.map +1 -1
  47. package/components/dropdown/components/item/index.js +34 -2
  48. package/components/dropdown/components/label/index.d.ts +1 -1
  49. package/components/dropdown/components/label/index.d.ts.map +1 -1
  50. package/components/dropdown/components/label/index.js +41 -9
  51. package/components/dropdown/components/withLabel/index.d.ts +2 -2
  52. package/components/dropdown/components/withLabel/index.d.ts.map +1 -1
  53. package/components/dropdown/components/withLabel/index.js +14 -12
  54. package/components/dropdown/types.d.ts +13 -2
  55. package/components/dropdown/types.d.ts.map +1 -1
  56. package/components/icon/component/index.d.ts +2 -2
  57. package/components/icon/component/index.d.ts.map +1 -1
  58. package/components/icon/component/index.js +9 -5
  59. package/components/icon/types.d.ts +2 -4
  60. package/components/icon/types.d.ts.map +1 -1
  61. package/components/index.d.ts +0 -1
  62. package/components/index.d.ts.map +1 -1
  63. package/components/index.js +0 -1
  64. package/components/paginator/component/index.d.ts +2 -2
  65. package/components/paginator/component/index.d.ts.map +1 -1
  66. package/components/paginator/component/index.js +19 -14
  67. package/components/paginator/types.d.ts +3 -5
  68. package/components/paginator/types.d.ts.map +1 -1
  69. package/components/primitives/checkbox/component/index.d.ts +2 -2
  70. package/components/primitives/checkbox/component/index.d.ts.map +1 -1
  71. package/components/primitives/checkbox/component/index.js +15 -17
  72. package/components/primitives/checkbox/types.d.ts +2 -2
  73. package/components/primitives/checkbox/types.d.ts.map +1 -1
  74. package/components/primitives/color/component/index.d.ts.map +1 -1
  75. package/components/primitives/color/components/picker/index.d.ts +11 -29
  76. package/components/primitives/color/components/picker/index.d.ts.map +1 -1
  77. package/components/primitives/color/components/picker/index.js +20 -17
  78. package/components/primitives/color/components/withLabel/index.d.ts +1 -1
  79. package/components/primitives/color/components/withLabel/index.d.ts.map +1 -1
  80. package/components/primitives/color/components/withLabel/index.js +8 -30
  81. package/components/primitives/color/components/withoutLabel/index.d.ts +1 -1
  82. package/components/primitives/color/components/withoutLabel/index.d.ts.map +1 -1
  83. package/components/primitives/color/components/withoutLabel/index.js +3 -13
  84. package/components/primitives/color/types.d.ts +1 -1
  85. package/components/primitives/color/types.d.ts.map +1 -1
  86. package/components/primitives/date/component/index.d.ts +2 -2
  87. package/components/primitives/date/component/index.d.ts.map +1 -1
  88. package/components/primitives/date/component/index.js +12 -27
  89. package/components/primitives/date/types.d.ts +2 -2
  90. package/components/primitives/date/types.d.ts.map +1 -1
  91. package/components/primitives/index.d.ts +0 -1
  92. package/components/primitives/index.d.ts.map +1 -1
  93. package/components/primitives/index.js +0 -1
  94. package/components/primitives/internal/componentWithLabel/index.d.ts +17 -0
  95. package/components/primitives/internal/componentWithLabel/index.d.ts.map +1 -0
  96. package/components/primitives/internal/componentWithLabel/index.js +26 -0
  97. package/components/primitives/internal/hint/index.d.ts +13 -0
  98. package/components/primitives/internal/hint/index.d.ts.map +1 -0
  99. package/components/primitives/internal/hint/index.js +47 -0
  100. package/components/primitives/multiline/component/index.d.ts +1 -1
  101. package/components/primitives/multiline/component/index.d.ts.map +1 -1
  102. package/components/primitives/multiline/component/index.js +5 -8
  103. package/components/primitives/multiline/components/withLabel/index.d.ts +6 -0
  104. package/components/primitives/multiline/components/withLabel/index.d.ts.map +1 -0
  105. package/components/primitives/multiline/components/withLabel/index.js +29 -0
  106. package/components/primitives/multiline/components/withoutLabel/index.d.ts +6 -0
  107. package/components/primitives/multiline/components/withoutLabel/index.d.ts.map +1 -0
  108. package/components/primitives/multiline/components/withoutLabel/index.js +28 -0
  109. package/components/primitives/multiline/types.d.ts +1 -1
  110. package/components/primitives/multiline/types.d.ts.map +1 -1
  111. package/components/primitives/number/component/index.d.ts +1 -1
  112. package/components/primitives/number/component/index.d.ts.map +1 -1
  113. package/components/primitives/number/component/index.js +5 -8
  114. package/components/primitives/number/components/withLabel/index.d.ts +2 -2
  115. package/components/primitives/number/components/withLabel/index.d.ts.map +1 -1
  116. package/components/primitives/number/components/withLabel/index.js +12 -27
  117. package/components/primitives/number/components/withoutLabel/index.d.ts +2 -2
  118. package/components/primitives/number/components/withoutLabel/index.d.ts.map +1 -1
  119. package/components/primitives/number/components/withoutLabel/index.js +11 -9
  120. package/components/primitives/number/types.d.ts +1 -1
  121. package/components/primitives/number/types.d.ts.map +1 -1
  122. package/components/primitives/password/component/index.d.ts +1 -1
  123. package/components/primitives/password/component/index.d.ts.map +1 -1
  124. package/components/primitives/password/component/index.js +5 -6
  125. package/components/primitives/password/components/withLabel/index.d.ts +2 -2
  126. package/components/primitives/password/components/withLabel/index.d.ts.map +1 -1
  127. package/components/primitives/password/components/withLabel/index.js +14 -30
  128. package/components/primitives/password/components/withoutLabel/index.d.ts +2 -2
  129. package/components/primitives/password/components/withoutLabel/index.d.ts.map +1 -1
  130. package/components/primitives/password/components/withoutLabel/index.js +13 -11
  131. package/components/primitives/password/types.d.ts +1 -1
  132. package/components/primitives/password/types.d.ts.map +1 -1
  133. package/components/primitives/text/component/index.d.ts +1 -1
  134. package/components/primitives/text/component/index.d.ts.map +1 -1
  135. package/components/primitives/text/component/index.js +5 -8
  136. package/components/primitives/text/components/withLabel/index.d.ts +6 -0
  137. package/components/primitives/text/components/withLabel/index.d.ts.map +1 -0
  138. package/components/primitives/text/components/withLabel/index.js +29 -0
  139. package/components/primitives/text/components/withoutLabel/index.d.ts +6 -0
  140. package/components/primitives/text/components/withoutLabel/index.d.ts.map +1 -0
  141. package/components/primitives/text/components/withoutLabel/index.js +28 -0
  142. package/components/primitives/text/types.d.ts +1 -1
  143. package/components/primitives/text/types.d.ts.map +1 -1
  144. package/components/search/component/index.d.ts +2 -2
  145. package/components/search/component/index.d.ts.map +1 -1
  146. package/components/search/component/index.js +16 -10
  147. package/components/search/types.d.ts +2 -2
  148. package/components/search/types.d.ts.map +1 -1
  149. package/components/table/component/index.d.ts +43 -0
  150. package/components/table/component/index.d.ts.map +1 -0
  151. package/components/table/component/index.js +27 -0
  152. package/components/table/components/heading/index.d.ts +13 -0
  153. package/components/table/components/heading/index.d.ts.map +1 -0
  154. package/components/table/components/heading/index.js +21 -0
  155. package/components/table/index.d.ts +3 -0
  156. package/components/table/index.d.ts.map +1 -0
  157. package/components/table/index.js +2 -0
  158. package/components/table/types.d.ts +18 -0
  159. package/components/table/types.d.ts.map +1 -0
  160. package/components/tabs/component/index.d.ts +3 -3
  161. package/components/tabs/component/index.d.ts.map +1 -1
  162. package/components/tabs/component/index.js +14 -8
  163. package/components/tabs/components/item/index.d.ts +1 -1
  164. package/components/tabs/components/item/index.d.ts.map +1 -1
  165. package/components/tabs/components/item/index.js +4 -3
  166. package/components/tabs/types.d.ts +1 -12
  167. package/components/tabs/types.d.ts.map +1 -1
  168. package/components/tabs/types.js +0 -12
  169. package/components/tag/component/index.d.ts +2 -2
  170. package/components/tag/component/index.d.ts.map +1 -1
  171. package/components/tag/component/index.js +13 -7
  172. package/components/tag/types.d.ts +1 -1
  173. package/components/tag/types.d.ts.map +1 -1
  174. package/hooks/usePagination.d.ts.map +1 -1
  175. package/hooks/usePagination.js +11 -2
  176. package/index.d.ts +1 -0
  177. package/index.d.ts.map +1 -1
  178. package/index.js +1 -0
  179. package/package.json +11 -4
  180. package/readme.md +2 -0
  181. package/tsconfig.tsbuildinfo +1 -1
  182. package/types/baseElementProps.d.ts +11 -0
  183. package/types/baseElementProps.d.ts.map +1 -0
  184. package/types/baseElementProps.js +1 -0
  185. package/{components/primitives/types/baseProps.d.ts → types/baseInputElementProps.d.ts} +10 -4
  186. package/types/baseInputElementProps.d.ts.map +1 -0
  187. package/types/baseInputElementProps.js +1 -0
  188. package/types/dataAttributes.d.ts +9 -0
  189. package/types/dataAttributes.d.ts.map +1 -0
  190. package/types/dataAttributes.js +1 -0
  191. package/types/elementColor.d.ts +18 -0
  192. package/types/elementColor.d.ts.map +1 -0
  193. package/types/elementColor.js +18 -0
  194. package/types/elementIcon.d.ts +22 -0
  195. package/types/elementIcon.d.ts.map +1 -0
  196. package/types/elementIcon.js +1 -0
  197. package/types/elementPosition.d.ts +12 -0
  198. package/types/elementPosition.d.ts.map +1 -0
  199. package/types/elementPosition.js +10 -0
  200. package/types/elementSize.d.ts +12 -0
  201. package/types/elementSize.d.ts.map +1 -0
  202. package/types/elementSize.js +12 -0
  203. package/types/hintConfiguration.d.ts +13 -0
  204. package/types/hintConfiguration.d.ts.map +1 -0
  205. package/types/hintConfiguration.js +1 -0
  206. package/types/index.d.ts +11 -0
  207. package/types/index.d.ts.map +1 -0
  208. package/types/index.js +10 -0
  209. package/{components/primitives/types/label.d.ts → types/labelConfiguration.d.ts} +3 -3
  210. package/types/labelConfiguration.d.ts.map +1 -0
  211. package/types/labelConfiguration.js +1 -0
  212. package/{components/primitives/types → types}/validation/index.d.ts +1 -1
  213. package/types/validation/index.d.ts.map +1 -0
  214. package/{components/primitives/types → types}/validation/index.js +1 -1
  215. package/{components/primitives/types → types}/validation/state.d.ts +2 -2
  216. package/types/validation/state.d.ts.map +1 -0
  217. package/{components/primitives/types → types}/validation/state.js +0 -1
  218. package/{components/primitives/types → types}/validation/status.d.ts +1 -1
  219. package/types/validation/status.d.ts.map +1 -0
  220. package/{components/primitives/types → types}/validation/status.js +1 -2
  221. package/utils/dataAttributes.d.ts +1 -1
  222. package/utils/dataAttributes.d.ts.map +1 -1
  223. package/utils/index.d.ts +1 -1
  224. package/utils/index.d.ts.map +1 -1
  225. package/utils/index.js +1 -1
  226. package/utils/validation.d.ts +11 -0
  227. package/utils/validation.d.ts.map +1 -0
  228. package/utils/validation.js +20 -0
  229. package/components/primitives/multiline/components/multilineWithLabel/index.d.ts +0 -6
  230. package/components/primitives/multiline/components/multilineWithLabel/index.d.ts.map +0 -1
  231. package/components/primitives/multiline/components/multilineWithLabel/index.js +0 -44
  232. package/components/primitives/multiline/components/multilineWithoutLabel/index.d.ts +0 -6
  233. package/components/primitives/multiline/components/multilineWithoutLabel/index.d.ts.map +0 -1
  234. package/components/primitives/multiline/components/multilineWithoutLabel/index.js +0 -26
  235. package/components/primitives/text/components/textWithLabel/index.d.ts +0 -6
  236. package/components/primitives/text/components/textWithLabel/index.d.ts.map +0 -1
  237. package/components/primitives/text/components/textWithLabel/index.js +0 -44
  238. package/components/primitives/text/components/textWithoutLabel/index.d.ts +0 -6
  239. package/components/primitives/text/components/textWithoutLabel/index.d.ts.map +0 -1
  240. package/components/primitives/text/components/textWithoutLabel/index.js +0 -26
  241. package/components/primitives/types/baseProps.d.ts.map +0 -1
  242. package/components/primitives/types/index.d.ts +0 -4
  243. package/components/primitives/types/index.d.ts.map +0 -1
  244. package/components/primitives/types/index.js +0 -3
  245. package/components/primitives/types/label.d.ts.map +0 -1
  246. package/components/primitives/types/validation/index.d.ts.map +0 -1
  247. package/components/primitives/types/validation/state.d.ts.map +0 -1
  248. package/components/primitives/types/validation/status.d.ts.map +0 -1
  249. package/components/types.d.ts +0 -78
  250. package/components/types.d.ts.map +0 -1
  251. package/components/types.js +0 -41
  252. package/utils/formValidation.d.ts +0 -16
  253. package/utils/formValidation.d.ts.map +0 -1
  254. package/utils/formValidation.js +0 -35
  255. /package/components/{primitives/types/baseProps.js → breadcrumbs/types.js} +0 -0
  256. /package/components/{primitives/types/label.js → table/types.js} +0 -0
@@ -1,14 +1,11 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { isNullOrUndefined } from "@bodynarf/utils";
3
- import NumberWithLabel from "../../number/components/withLabel";
4
- import NumberWithoutLabel from "../../number/components/withoutLabel";
3
+ import NumberWithLabel from "../components/withLabel";
4
+ import NumberWithoutLabel from "../components/withoutLabel";
5
5
  /** Number input component */
6
6
  const Number = (props) => {
7
- if (isNullOrUndefined(props.label)) {
8
- return (_jsx(NumberWithoutLabel, { ...props }));
9
- }
10
- else {
11
- return (_jsx(NumberWithLabel, { ...props }));
12
- }
7
+ return isNullOrUndefined(props.label)
8
+ ? _jsx(NumberWithoutLabel, { ...props })
9
+ : _jsx(NumberWithLabel, { ...props });
13
10
  };
14
11
  export default Number;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { NumberProps } from "../../../number";
2
+ import { NumberProps } from "../..";
3
3
  /** Number component with label */
4
- declare const NumberWithLabel: ({ onValueChange, readonly, disabled, defaultValue, validationState, name, className, size, style, rounded, loading, label, placeholder, onBlur, step, }: NumberProps) => JSX.Element;
4
+ declare const NumberWithLabel: ({ onValueChange, readonly, disabled, defaultValue, validationState, name, size, style, rounded, loading, label, placeholder, onBlur, step, className, title, data, hint, }: NumberProps) => JSX.Element;
5
5
  export default NumberWithLabel;
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/number/components/withLabel/index.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,kCAAkC;AAClC,QAAA,MAAM,eAAe,4JAOlB,WAAW,KAAG,WA2GhB,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/number/components/withLabel/index.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,kCAAkC;AAClC,QAAA,MAAM,eAAe,+KAUlB,WAAW,KAAG,WA0DhB,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1,44 +1,29 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback } from "react";
3
- import { generateGuid, getClassName, getValueOrDefault, isStringEmpty } from "@bodynarf/utils";
4
- import { ElementSize } from "../../../..";
5
- import { getValidationValues } from "../../../../../utils";
3
+ import { generateGuid, getClassName, getValueOrDefault, isNullOrUndefined, isStringEmpty } from "@bodynarf/utils";
4
+ import { ElementSize } from "../../../../../types";
5
+ import { getStyleClassName, mapDataAttributes } from "../../../../../utils";
6
+ import ComponentWithLabel from "../../../internal/componentWithLabel";
7
+ import InternalHint from "../../../internal/hint";
6
8
  /** Number component with label */
7
- const NumberWithLabel = ({ onValueChange, readonly, disabled, defaultValue, validationState, name, className, size, style, rounded = false, loading = false, label, placeholder, onBlur, step = 1, }) => {
9
+ const NumberWithLabel = ({ onValueChange, readonly, disabled, defaultValue, validationState, name, size, style, rounded = false, loading = false, label, placeholder, onBlur, step = 1, className, title, data, hint, }) => {
8
10
  const onChange = useCallback((event) => onValueChange(isStringEmpty(event.target.value) ? undefined : +event.target.value), [onValueChange]);
9
- const id = name || generateGuid();
11
+ const id = name ?? generateGuid();
10
12
  const elSizeClassName = "is-{0}".format(getValueOrDefault(size, ElementSize.Normal));
11
- const [isValidationDefined, styleClassName, validationMessages] = getValidationValues(style, validationState);
12
13
  const elClassName = getClassName([
13
14
  className,
14
15
  elSizeClassName,
15
16
  rounded ? "is-rounded" : "",
16
- styleClassName,
17
+ getStyleClassName(style, validationState),
17
18
  "input",
18
19
  ]);
19
20
  const inputContainerClassName = getClassName([
20
21
  "control",
21
22
  loading ? "is-loading" : "",
22
23
  ]);
23
- const labelClassName = getClassName([
24
- "label",
25
- !label.horizontal ? elSizeClassName : "",
26
- label.className
27
- ]);
28
- if (label.horizontal) {
29
- const labelContainerClassName = getClassName([
30
- "field-label",
31
- elSizeClassName,
32
- label.horizontalContainerClassName
33
- ]);
34
- const fieldContainerClassName = getClassName([
35
- "field-body",
36
- label.horizontalFieldContainerClassName
37
- ]);
38
- return (_jsxs("div", { className: "bbr-input field is-horizontal", children: [_jsx("div", { className: labelContainerClassName, children: _jsx("label", { className: labelClassName, htmlFor: id, children: label.caption }) }), _jsx("div", { className: fieldContainerClassName, children: _jsxs("div", { className: "field", children: [_jsx("div", { className: inputContainerClassName, children: _jsx("input", { type: "number", className: elClassName, placeholder: placeholder, readOnly: readonly, disabled: disabled, defaultValue: defaultValue, onChange: onChange, onBlur: onBlur, name: id, id: id, step: step }) }), isValidationDefined && validationMessages.length > 0 &&
39
- _jsx("p", { className: `help m-help ${styleClassName}`, children: validationMessages.join("\n") })] }) })] }));
40
- }
41
- return (_jsxs("div", { className: "bbr-input field", children: [_jsx("label", { className: labelClassName, htmlFor: id, children: label.caption }), _jsx("div", { className: inputContainerClassName, children: _jsx("input", { type: "number", className: elClassName, placeholder: placeholder, readOnly: readonly, disabled: disabled, defaultValue: defaultValue, onChange: onChange, onBlur: onBlur, name: id, id: id, step: step }) }), isValidationDefined && validationMessages.length > 0 &&
42
- _jsx("p", { className: `help m-help ${styleClassName}`, children: validationMessages.join("\n") })] }));
24
+ const dataAttributes = isNullOrUndefined(data)
25
+ ? undefined
26
+ : mapDataAttributes(data);
27
+ return (_jsxs(ComponentWithLabel, { id: id, label: label, size: getValueOrDefault(size, ElementSize.Normal), children: [_jsx("div", { className: inputContainerClassName, children: _jsx("input", { type: "number", id: id, name: id, step: step, onBlur: onBlur, onChange: onChange, readOnly: readonly, disabled: disabled, className: elClassName, placeholder: placeholder, defaultValue: defaultValue, title: title, ...dataAttributes }) }), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
43
28
  };
44
29
  export default NumberWithLabel;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { NumberProps } from "../../../number";
2
+ import { NumberProps } from "../..";
3
3
  /** Number component without label */
4
- declare const NumberWithoutLabel: ({ onValueChange, readonly, disabled, defaultValue, validationState, name, className, size, style, rounded, loading, placeholder, onBlur, step, }: NumberProps) => JSX.Element;
4
+ declare const NumberWithoutLabel: ({ onValueChange, readonly, disabled, defaultValue, validationState, name, size, style, rounded, loading, placeholder, onBlur, step, className, title, data, hint, }: NumberProps) => JSX.Element;
5
5
  export default NumberWithoutLabel;
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/number/components/withoutLabel/index.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,qCAAqC;AACrC,QAAA,MAAM,kBAAkB,qJAOrB,WAAW,KAAG,WA8ChB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/number/components/withoutLabel/index.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,qCAAqC;AACrC,QAAA,MAAM,kBAAkB,wKAUrB,WAAW,KAAG,WAqDhB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -1,17 +1,17 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback } from "react";
3
- import { generateGuid, getClassName, getValueOrDefault } from "@bodynarf/utils";
4
- import { ElementSize } from "../../../..";
5
- import { getValidationValues } from "../../../../../utils";
3
+ import { generateGuid, getClassName, getValueOrDefault, isNullOrUndefined } from "@bodynarf/utils";
4
+ import { ElementSize } from "../../../../../types";
5
+ import { getStyleClassName, mapDataAttributes } from "../../../../../utils";
6
+ import InternalHint from "../../../internal/hint";
6
7
  /** Number component without label */
7
- const NumberWithoutLabel = ({ onValueChange, readonly, disabled, defaultValue, validationState, name, className, size, style, rounded = false, loading = false, placeholder, onBlur, step = 1, }) => {
8
+ const NumberWithoutLabel = ({ onValueChange, readonly, disabled, defaultValue, validationState, name, size, style, rounded = false, loading = false, placeholder, onBlur, step = 1, className, title, data, hint, }) => {
8
9
  const onChange = useCallback((event) => onValueChange(+event.target.value), [onValueChange]);
9
- const [isValidationDefined, styleClassName, validationMessages] = getValidationValues(style, validationState);
10
10
  const elClassName = getClassName([
11
11
  className,
12
12
  "is-{0}".format(getValueOrDefault(size, ElementSize.Normal)),
13
13
  rounded ? "is-rounded" : "",
14
- styleClassName,
14
+ getStyleClassName(style, validationState),
15
15
  "input",
16
16
  ]);
17
17
  const containerClassName = getClassName([
@@ -19,8 +19,10 @@ const NumberWithoutLabel = ({ onValueChange, readonly, disabled, defaultValue, v
19
19
  "bbr-input",
20
20
  loading ? "is-loading" : "",
21
21
  ]);
22
- const id = name || generateGuid();
23
- return (_jsxs(_Fragment, { children: [_jsx("div", { className: containerClassName, children: _jsx("input", { type: "number", className: elClassName, placeholder: placeholder, readOnly: readonly, disabled: disabled, defaultValue: defaultValue, onChange: onChange, onBlur: onBlur, name: id, id: id, step: step }) }), isValidationDefined && validationMessages.length > 0 &&
24
- _jsx("p", { className: `help m-help ${styleClassName}`, children: validationMessages.join("\n") })] }));
22
+ const id = name ?? generateGuid();
23
+ const dataAttributes = isNullOrUndefined(data)
24
+ ? undefined
25
+ : mapDataAttributes(data);
26
+ return (_jsxs(_Fragment, { children: [_jsx("div", { className: containerClassName, children: _jsx("input", { type: "number", id: id, name: id, step: step, onBlur: onBlur, onChange: onChange, readOnly: readonly, disabled: disabled, className: elClassName, placeholder: placeholder, defaultValue: defaultValue, title: title, ...dataAttributes }) }), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
25
27
  };
26
28
  export default NumberWithoutLabel;
@@ -1,4 +1,4 @@
1
- import { BaseInputElementProps } from "../..";
1
+ import { BaseInputElementProps } from "../../../types";
2
2
  /** Number component props type */
3
3
  export interface NumberProps extends BaseInputElementProps<number> {
4
4
  /** Focus out event handler */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/number/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,kCAAkC;AAClC,MAAM,WAAW,WAAY,SAAQ,qBAAqB,CAAC,MAAM,CAAC;IAC9D,8BAA8B;IAC9B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IAEpB;;;;MAIE;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/number/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,kCAAkC;AAClC,MAAM,WAAW,WAAY,SAAQ,qBAAqB,CAAC,MAAM,CAAC;IAC9D,8BAA8B;IAC9B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IAEpB;;;;MAIE;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB"}
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import "./style.scss";
3
- import { PasswordProps } from "../../password";
3
+ import { PasswordProps } from "../..";
4
4
  /** Password input component */
5
5
  declare const Password: (props: PasswordProps) => JSX.Element;
6
6
  export default Password;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/password/component/index.tsx"],"names":[],"mappings":";AAEA,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAKzD,+BAA+B;AAC/B,QAAA,MAAM,QAAQ,UAAW,aAAa,KAAG,WAMxC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/password/component/index.tsx"],"names":[],"mappings":";AAEA,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAItC,+BAA+B;AAC/B,QAAA,MAAM,QAAQ,UAAW,aAAa,KAAG,WAIxC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -1,13 +1,12 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { isNullOrUndefined } from "@bodynarf/utils";
3
3
  import "./style.scss";
4
- import PasswordWithLabel from "../../password/components/withLabel";
5
- import PasswordWithoutLabel from "../../password/components/withoutLabel";
4
+ import PasswordWithLabel from "../components/withLabel";
5
+ import PasswordWithoutLabel from "../components/withoutLabel";
6
6
  /** Password input component */
7
7
  const Password = (props) => {
8
- if (isNullOrUndefined(props.label)) {
9
- return _jsx(PasswordWithoutLabel, { ...props });
10
- }
11
- return _jsx(PasswordWithLabel, { ...props });
8
+ return isNullOrUndefined(props.label)
9
+ ? _jsx(PasswordWithoutLabel, { ...props })
10
+ : _jsx(PasswordWithLabel, { ...props });
12
11
  };
13
12
  export default Password;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { PasswordProps } from "../../../password";
3
- declare const PasswordWithLabel: ({ onValueChange, disabled, validationState, name, className, size, style, rounded, loading, label, placeholder, canShowPassword, }: PasswordProps) => JSX.Element;
2
+ import { PasswordProps } from "../..";
3
+ declare const PasswordWithLabel: ({ onValueChange, disabled, validationState, name, size, style, rounded, loading, label, placeholder, canShowPassword, className, title, data, hint, }: PasswordProps) => JSX.Element;
4
4
  export default PasswordWithLabel;
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/password/components/withLabel/index.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,QAAA,MAAM,iBAAiB,uIAOpB,aAAa,KAAG,WAgIlB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/password/components/withLabel/index.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,QAAA,MAAM,iBAAiB,0JAUpB,aAAa,KAAG,WAwElB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -1,22 +1,23 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useState } from "react";
3
- import { generateGuid, getClassName, getValueOrDefault } from "@bodynarf/utils";
4
- import { getValidationValues } from "../../../../../utils";
5
- import { ElementSize } from "../../../..";
3
+ import { generateGuid, getClassName, getValueOrDefault, isNullOrUndefined } from "@bodynarf/utils";
4
+ import { ElementSize } from "../../../../../types";
5
+ import { getStyleClassName, mapDataAttributes } from "../../../../../utils";
6
6
  import Icon from "../../../../icon";
7
- const PasswordWithLabel = ({ onValueChange, disabled, validationState, name, className, size, style, rounded = false, loading = false, label, placeholder, canShowPassword = false, }) => {
7
+ import ComponentWithLabel from "../../../internal/componentWithLabel";
8
+ import InternalHint from "../../../internal/hint";
9
+ const PasswordWithLabel = ({ onValueChange, disabled, validationState, name, size, style, rounded = false, loading = false, label, placeholder, canShowPassword = false, className, title, data, hint, }) => {
8
10
  const onChange = useCallback((event) => onValueChange(event.target.value), [onValueChange]);
9
11
  const [contentIsHidden, setContentIsHidden] = useState(true);
10
12
  const onIconClick = useCallback(() => setContentIsHidden(state => !state), [setContentIsHidden]);
11
- const [isValidationDefined, styleClassName, validationMessages] = getValidationValues(style, validationState);
12
13
  const elSizeClassName = "is-{0}".format(getValueOrDefault(size, ElementSize.Normal));
13
- const id = name || generateGuid();
14
+ const id = name ?? generateGuid();
14
15
  const elClassName = getClassName([
16
+ "bbr-password",
15
17
  className,
16
18
  elSizeClassName,
17
19
  rounded ? "is-rounded" : "",
18
- styleClassName,
19
- "bbr-password",
20
+ getStyleClassName(style, validationState),
20
21
  "input",
21
22
  ]);
22
23
  const inputContainerClassName = getClassName([
@@ -25,27 +26,10 @@ const PasswordWithLabel = ({ onValueChange, disabled, validationState, name, cla
25
26
  canShowPassword ? "has-icons-right" : "",
26
27
  "bbr-password__wrapper",
27
28
  ]);
28
- const labelClassName = getClassName([
29
- "label",
30
- !label.horizontal ? elSizeClassName : "",
31
- label.className
32
- ]);
33
- if (label.horizontal) {
34
- const labelContainerClassName = getClassName([
35
- "field-label",
36
- elSizeClassName,
37
- label.horizontalContainerClassName
38
- ]);
39
- const fieldContainerClassName = getClassName([
40
- "field-body",
41
- label.horizontalFieldContainerClassName
42
- ]);
43
- return (_jsxs("div", { className: "bbr-input field is-horizontal", children: [_jsx("div", { className: labelContainerClassName, children: _jsx("label", { className: labelClassName, htmlFor: id, children: label.caption }) }), _jsx("div", { className: fieldContainerClassName, children: _jsxs("div", { className: "field", children: [_jsxs("div", { className: inputContainerClassName, children: [_jsx("input", { type: contentIsHidden ? "password" : "text", className: elClassName, placeholder: placeholder, disabled: disabled, onChange: onChange, name: id, id: id }), canShowPassword && !loading &&
44
- _jsx("span", { className: `icon is-right ${elSizeClassName}`, onMouseEnter: onIconClick, onMouseLeave: onIconClick, title: "Show password", children: _jsx(Icon, { name: contentIsHidden ? "eye" : "eye-slash", size: ElementSize.Medium }) })] }), isValidationDefined && validationMessages.length > 0 &&
45
- _jsx("p", { className: `help m-help ${styleClassName}`, children: validationMessages.join("\n") })] }) })] }));
46
- }
47
- return (_jsxs("div", { className: "bbr-input field", children: [_jsx("label", { className: labelClassName, htmlFor: id, children: label.caption }), _jsxs("div", { className: inputContainerClassName, children: [_jsx("input", { type: contentIsHidden ? "password" : "text", className: elClassName, placeholder: placeholder, disabled: disabled, onChange: onChange, name: id, id: id }), canShowPassword && !loading &&
48
- _jsx("span", { className: `icon is-right ${elSizeClassName}`, onMouseEnter: onIconClick, onMouseLeave: onIconClick, children: _jsx(Icon, { name: contentIsHidden ? "eye" : "eye-slash", size: ElementSize.Medium }) })] }), isValidationDefined && validationMessages.length > 0 &&
49
- _jsx("p", { className: `help m-help ${styleClassName}`, children: validationMessages.join("\n") })] }));
29
+ const dataAttributes = isNullOrUndefined(data)
30
+ ? undefined
31
+ : mapDataAttributes(data);
32
+ return (_jsxs(ComponentWithLabel, { id: id, label: label, size: getValueOrDefault(size, ElementSize.Normal), children: [_jsxs("div", { className: inputContainerClassName, children: [_jsx("input", { type: contentIsHidden ? "password" : "text", id: id, name: id, disabled: disabled, onChange: onChange, className: elClassName, placeholder: placeholder, title: title, ...dataAttributes }), canShowPassword && !loading &&
33
+ _jsx("span", { className: `icon is-right ${elSizeClassName}`, onMouseEnter: onIconClick, onMouseLeave: onIconClick, title: "Show password", children: _jsx(Icon, { name: contentIsHidden ? "eye" : "eye-slash", size: ElementSize.Medium }) })] }), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
50
34
  };
51
35
  export default PasswordWithLabel;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { PasswordProps } from "../../../password";
3
- declare const PasswordWithoutLabel: ({ onValueChange, disabled, validationState, name, className, size, style, rounded, loading, placeholder, canShowPassword, }: PasswordProps) => JSX.Element;
2
+ import { PasswordProps } from "../..";
3
+ declare const PasswordWithoutLabel: ({ onValueChange, disabled, validationState, name, size, style, rounded, loading, placeholder, canShowPassword, className, title, data, hint, }: PasswordProps) => JSX.Element;
4
4
  export default PasswordWithoutLabel;
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/password/components/withoutLabel/index.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,QAAA,MAAM,oBAAoB,gIAOvB,aAAa,KAAG,WA4DlB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/password/components/withoutLabel/index.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,QAAA,MAAM,oBAAoB,mJAUvB,aAAa,KAAG,WAoElB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -1,22 +1,22 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useCallback, useState } from "react";
3
- import { generateGuid, getClassName, getValueOrDefault } from "@bodynarf/utils";
4
- import { ElementSize } from "../../../..";
5
- import { getValidationValues } from "../../../../../utils";
3
+ import { generateGuid, getClassName, getValueOrDefault, isNullOrUndefined } from "@bodynarf/utils";
4
+ import { ElementSize } from "../../../../../types";
5
+ import { getStyleClassName, mapDataAttributes } from "../../../../../utils";
6
6
  import Icon from "../../../../icon";
7
- const PasswordWithoutLabel = ({ onValueChange, disabled, validationState, name, className, size, style, rounded = false, loading = false, placeholder, canShowPassword = false, }) => {
7
+ import InternalHint from "../../../internal/hint";
8
+ const PasswordWithoutLabel = ({ onValueChange, disabled, validationState, name, size, style, rounded = false, loading = false, placeholder, canShowPassword = false, className, title, data, hint, }) => {
8
9
  const onChange = useCallback((event) => onValueChange(event.target.value), [onValueChange]);
9
10
  const [contentIsHidden, setContentIsHidden] = useState(true);
10
11
  const onIconClick = useCallback(() => setContentIsHidden(state => !state), [setContentIsHidden]);
11
- const [isValidationDefined, styleClassName, validationMessages] = getValidationValues(style, validationState);
12
12
  const elSizeClassName = "is-{0}".format(getValueOrDefault(size, ElementSize.Normal));
13
- const id = name || generateGuid();
13
+ const id = name ?? generateGuid();
14
14
  const elClassName = getClassName([
15
+ "bbr-password",
15
16
  className,
16
17
  elSizeClassName,
17
18
  rounded ? "is-rounded" : "",
18
- styleClassName,
19
- "bbr-password",
19
+ getStyleClassName(style, validationState),
20
20
  "input",
21
21
  ]);
22
22
  const containerClassName = getClassName([
@@ -26,8 +26,10 @@ const PasswordWithoutLabel = ({ onValueChange, disabled, validationState, name,
26
26
  canShowPassword ? "has-icons-right" : "",
27
27
  "bbr-password__wrapper",
28
28
  ]);
29
- return (_jsxs(_Fragment, { children: [_jsxs("div", { className: containerClassName, children: [_jsx("input", { type: contentIsHidden ? "password" : "text", className: elClassName, placeholder: placeholder, disabled: disabled, onChange: onChange, name: id, id: id }), canShowPassword && !loading &&
30
- _jsx("span", { className: `icon is-right ${elSizeClassName}`, onMouseEnter: onIconClick, onMouseLeave: onIconClick, children: _jsx(Icon, { name: contentIsHidden ? "eye" : "eye-slash", size: ElementSize.Medium }) })] }), isValidationDefined && validationMessages.length > 0 &&
31
- _jsx("p", { className: `help m-help ${styleClassName}`, children: validationMessages.join("\n") })] }));
29
+ const dataAttributes = isNullOrUndefined(data)
30
+ ? undefined
31
+ : mapDataAttributes(data);
32
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: containerClassName, children: [_jsx("input", { type: contentIsHidden ? "password" : "text", id: id, name: id, disabled: disabled, onChange: onChange, className: elClassName, placeholder: placeholder, title: title, ...dataAttributes }), canShowPassword && !loading &&
33
+ _jsx("span", { className: `icon is-right ${elSizeClassName}`, onMouseEnter: onIconClick, onMouseLeave: onIconClick, children: _jsx(Icon, { name: contentIsHidden ? "eye" : "eye-slash", size: ElementSize.Medium }) })] }), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
32
34
  };
33
35
  export default PasswordWithoutLabel;
@@ -1,4 +1,4 @@
1
- import { BaseInputElementProps } from "../..";
1
+ import { BaseInputElementProps } from "../../../types";
2
2
  /** Password component props type */
3
3
  export interface PasswordProps extends Omit<BaseInputElementProps<string>, "defaultValue" | "readonly"> {
4
4
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/password/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,oCAAoC;AACpC,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC;IACnG;;;MAGE;IACF,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/password/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,oCAAoC;AACpC,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC;IACnG;;;MAGE;IACF,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B"}
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import "../../../../common.scss";
3
- import { TextProps } from "../../..";
3
+ import { TextProps } from "..";
4
4
  /** Textual input component */
5
5
  declare const Text: (props: TextProps) => JSX.Element;
6
6
  export default Text;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/text/component/index.tsx"],"names":[],"mappings":";AAEA,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK5C,8BAA8B;AAC9B,QAAA,MAAM,IAAI,UAAW,SAAS,KAAG,WAOhC,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/text/component/index.tsx"],"names":[],"mappings":";AAEA,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAI/B,8BAA8B;AAC9B,QAAA,MAAM,IAAI,UAAW,SAAS,KAAG,WAIhC,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -1,15 +1,12 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { isNullOrUndefined } from "@bodynarf/utils";
3
3
  import "../../../../common.scss";
4
- import TextWithLabel from "../../text/components/textWithLabel";
5
- import TextWithoutLabel from "../../text/components/textWithoutLabel";
4
+ import TextWithLabel from "../components/withLabel";
5
+ import TextWithoutLabel from "../components/withoutLabel";
6
6
  /** Textual input component */
7
7
  const Text = (props) => {
8
- if (isNullOrUndefined(props.label)) {
9
- return (_jsx(TextWithoutLabel, { ...props }));
10
- }
11
- else {
12
- return (_jsx(TextWithLabel, { ...props }));
13
- }
8
+ return isNullOrUndefined(props.label)
9
+ ? _jsx(TextWithoutLabel, { ...props })
10
+ : _jsx(TextWithLabel, { ...props });
14
11
  };
15
12
  export default Text;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { TextProps } from "../..";
3
+ /** Textual input with describing label */
4
+ declare const TextWithLabel: ({ onValueChange, readonly, disabled, defaultValue, validationState, name, size, style, rounded, loading, label, placeholder, onBlur, className, title, data, hint, }: TextProps) => JSX.Element;
5
+ export default TextWithLabel;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/text/components/withLabel/index.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,0CAA0C;AAC1C,QAAA,MAAM,aAAa,yKAUhB,SAAS,KAAG,WAwDd,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback } from "react";
3
+ import { generateGuid, getClassName, getValueOrDefault, isNullOrUndefined, } from "@bodynarf/utils";
4
+ import { ElementSize } from "../../../../../types";
5
+ import { getStyleClassName, mapDataAttributes } from "../../../../../utils";
6
+ import InternalHint from "../../../internal/hint";
7
+ import ComponentWithLabel from "../../../internal/componentWithLabel";
8
+ /** Textual input with describing label */
9
+ const TextWithLabel = ({ onValueChange, readonly, disabled, defaultValue, validationState, name, size, style, rounded = false, loading = false, label, placeholder, onBlur, className, title, data, hint, }) => {
10
+ const onChange = useCallback((event) => onValueChange(event.target.value), [onValueChange]);
11
+ const id = name ?? generateGuid();
12
+ const elSizeClassName = "is-{0}".format(getValueOrDefault(size, ElementSize.Normal));
13
+ const elClassName = getClassName([
14
+ className,
15
+ elSizeClassName,
16
+ rounded ? "is-rounded" : "",
17
+ getStyleClassName(style, validationState),
18
+ "input",
19
+ ]);
20
+ const inputContainerClassName = getClassName([
21
+ "control",
22
+ loading ? "is-loading" : "",
23
+ ]);
24
+ const dataAttributes = isNullOrUndefined(data)
25
+ ? undefined
26
+ : mapDataAttributes(data);
27
+ return (_jsxs(ComponentWithLabel, { id: id, label: label, size: getValueOrDefault(size, ElementSize.Normal), children: [_jsx("div", { className: inputContainerClassName, children: _jsx("input", { type: "text", id: id, name: id, onBlur: onBlur, readOnly: readonly, disabled: disabled, onChange: onChange, className: elClassName, placeholder: placeholder, defaultValue: defaultValue, title: title, ...dataAttributes }) }), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
28
+ };
29
+ export default TextWithLabel;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { TextProps } from "../..";
3
+ /** Textual input without describing label */
4
+ declare const TextWithoutLabel: ({ onValueChange, readonly, disabled, defaultValue, validationState, name, size, style, rounded, loading, placeholder, onBlur, className, title, data, hint, }: TextProps) => JSX.Element;
5
+ export default TextWithoutLabel;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/text/components/withoutLabel/index.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,6CAA6C;AAC7C,QAAA,MAAM,gBAAgB,kKAUnB,SAAS,KAAG,WAoDd,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback } from "react";
3
+ import { generateGuid, getClassName, getValueOrDefault, isNullOrUndefined } from "@bodynarf/utils";
4
+ import { ElementSize } from "../../../../../types";
5
+ import { getStyleClassName, mapDataAttributes } from "../../../../../utils";
6
+ import InternalHint from "../../../internal/hint";
7
+ /** Textual input without describing label */
8
+ const TextWithoutLabel = ({ onValueChange, readonly, disabled, defaultValue, validationState, name, size, style, rounded = false, loading = false, placeholder, onBlur, className, title, data, hint, }) => {
9
+ const onChange = useCallback((event) => onValueChange(event.target.value), [onValueChange]);
10
+ const elClassName = getClassName([
11
+ className,
12
+ "is-{0}".format(getValueOrDefault(size, ElementSize.Normal)),
13
+ rounded ? "is-rounded" : "",
14
+ getStyleClassName(style, validationState),
15
+ "input",
16
+ ]);
17
+ const containerClassName = getClassName([
18
+ "control",
19
+ "bbr-input",
20
+ loading ? "is-loading" : "",
21
+ ]);
22
+ const id = name ?? generateGuid();
23
+ const dataAttributes = isNullOrUndefined(data)
24
+ ? undefined
25
+ : mapDataAttributes(data);
26
+ return (_jsxs(_Fragment, { children: [_jsx("div", { className: containerClassName, children: _jsx("input", { type: "text", id: id, name: id, onBlur: onBlur, readOnly: readonly, disabled: disabled, onChange: onChange, className: elClassName, placeholder: placeholder, defaultValue: defaultValue, title: title, ...dataAttributes }) }), _jsx(InternalHint, { hint: hint, validationState: validationState })] }));
27
+ };
28
+ export default TextWithoutLabel;
@@ -1,4 +1,4 @@
1
- import { BaseInputElementProps } from "../..";
1
+ import { BaseInputElementProps } from "../../../types";
2
2
  /** Text input component props type */
3
3
  export interface TextProps extends BaseInputElementProps<string> {
4
4
  /** Focus out event handler */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/text/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,sCAAsC;AACtC,MAAM,WAAW,SAAU,SAAQ,qBAAqB,CAAC,MAAM,CAAC;IAC5D,8BAA8B;IAC9B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/text/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,sCAAsC;AACtC,MAAM,WAAW,SAAU,SAAQ,qBAAqB,CAAC,MAAM,CAAC;IAC5D,8BAA8B;IAC9B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB"}
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import "./style.scss";
3
- import { SearchProps } from "../../search";
3
+ import { SearchProps } from "..";
4
4
  /** Search component */
5
- export default function Search({ searchType, onSearch, caption, name, defaultValue, size, isLoading, rounded, disabled, }: SearchProps): JSX.Element;
5
+ export default function Search({ searchType, onSearch, caption, name, defaultValue, size, isLoading, rounded, disabled, className, title, data, }: SearchProps): JSX.Element;
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/search/component/index.tsx"],"names":[],"mappings":";AAIA,OAAO,cAAc,CAAC;AAItB,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,uBAAuB;AACvB,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAC3B,UAAU,EAAE,QAAQ,EAAE,OAAO,EAC7B,IAAI,EAAE,YAAY,EAClB,IAAI,EACJ,SAAiB,EAAE,OAAe,EAAE,QAAQ,GAC/C,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CAyE3B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/search/component/index.tsx"],"names":[],"mappings":";AAQA,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAEjC,uBAAuB;AACvB,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAC3B,UAAU,EAAE,QAAQ,EAAE,OAAO,EAC7B,IAAI,EAAE,YAAY,EAClB,IAAI,EACJ,SAAiB,EAAE,OAAe,EAAE,QAAQ,EAE5C,SAAS,EAAE,KAAK,EAAE,IAAI,GACzB,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CAqF3B"}
@@ -1,12 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useState } from "react";
3
- import { generateGuid, getClassName } from "@bodynarf/utils";
4
- import "./style.scss";
3
+ import { generateGuid, getClassName, isNullOrUndefined } from "@bodynarf/utils";
4
+ import { ElementSize } from "../../../types";
5
+ import { mapDataAttributes } from "../../../utils";
5
6
  import Button from "../../button";
7
+ import "./style.scss";
6
8
  /** Search component */
7
- export default function Search({ searchType, onSearch, caption, name, defaultValue, size, isLoading = false, rounded = false, disabled, }) {
8
- const [elementName] = useState(name || generateGuid());
9
- const [searchValue, setSearchValue] = useState(defaultValue || "");
9
+ export default function Search({ searchType, onSearch, caption, name, defaultValue, size, isLoading = false, rounded = false, disabled, className, title, data, }) {
10
+ const [elementName] = useState(name ?? generateGuid());
11
+ const [searchValue, setSearchValue] = useState(defaultValue ?? "");
10
12
  const onChange = useCallback((event) => {
11
13
  const elementValue = event.target.value;
12
14
  if (searchType === "byTyping") {
@@ -15,23 +17,27 @@ export default function Search({ searchType, onSearch, caption, name, defaultVal
15
17
  setSearchValue(elementValue);
16
18
  }, [onSearch, searchType]);
17
19
  const onSearchButtonClick = useCallback(() => onSearch(searchValue), [onSearch, searchValue]);
18
- const className = getClassName([
20
+ const elClassName = getClassName([
19
21
  "bbr-search",
20
22
  "control",
21
- `is-${(size || "normal")}`,
23
+ className,
24
+ `is-${(size ?? ElementSize.Normal)}`,
22
25
  isLoading ? "is-loading" : "",
23
26
  searchType === "byButton" ? "is-expanded" : "",
24
27
  ]);
25
28
  const inputClassName = getClassName([
26
29
  "input",
27
30
  "is-unselectable",
28
- `is-${(size || "normal")}`,
31
+ `is-${(size ?? ElementSize.Normal)}`,
29
32
  rounded ? "is-rounded" : "",
30
33
  ]);
34
+ const dataAttributes = isNullOrUndefined(data)
35
+ ? undefined
36
+ : mapDataAttributes(data);
31
37
  if (searchType === "byButton") {
32
- return (_jsxs("div", { className: "field has-addons", children: [_jsx("div", { className: className, children: _jsx("input", { type: "search", name: elementName, defaultValue: searchValue, className: inputClassName, disabled: disabled, onChange: onChange, placeholder: caption }) }), _jsx("div", { className: "control", children: _jsx(Button, { caption: "Search", type: "info", onClick: onSearchButtonClick, isLoading: isLoading, size: size }) })] }));
38
+ return (_jsxs("div", { className: "field has-addons", children: [_jsx("div", { className: elClassName, children: _jsx("input", { type: "search", name: elementName, disabled: disabled, onChange: onChange, placeholder: caption, defaultValue: searchValue, className: inputClassName, title: title, ...dataAttributes }) }), _jsx("div", { className: "control", children: _jsx(Button, { type: "info", size: size, caption: "Search", disabled: disabled, isLoading: isLoading, onClick: onSearchButtonClick }) })] }));
33
39
  }
34
40
  else {
35
- return (_jsx("div", { className: className, children: _jsx("input", { type: "search", name: elementName, defaultValue: searchValue, className: inputClassName, disabled: disabled, onChange: onChange, placeholder: caption }) }));
41
+ return (_jsx("div", { className: elClassName, children: _jsx("input", { type: "search", name: elementName, disabled: disabled, onChange: onChange, placeholder: caption, defaultValue: searchValue, className: inputClassName, title: title, ...dataAttributes }) }));
36
42
  }
37
43
  }
@@ -1,6 +1,6 @@
1
- import { ElementSize } from "..";
1
+ import { BaseElementProps, ElementSize } from "../../types";
2
2
  /** Search component props type */
3
- export interface SearchProps {
3
+ export interface SearchProps extends BaseElementProps {
4
4
  /**
5
5
  * Search type: by typing, starts from minimum characters to search
6
6
  * or by clicking on button next to search bar.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/search/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,kCAAkC;AAClC,MAAM,WAAW,WAAW;IACxB;;;;MAIE;IACF,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;IAEpC,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAEhB,qBAAqB;IACrB,QAAQ,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;IAE1C,2BAA2B;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,yBAAyB;IACzB,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB,mCAAmC;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,qDAAqD;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/search/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE3D,kCAAkC;AAClC,MAAM,WAAW,WAAY,SAAQ,gBAAgB;IACjD;;;;MAIE;IACF,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;IAEpC,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAEhB,qBAAqB;IACrB,QAAQ,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;IAE1C,2BAA2B;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,yBAAyB;IACzB,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB,mCAAmC;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,qDAAqD;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB"}