@helpdice/ui 2.6.0-beta.1 → 2.6.0-beta.2

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.
@@ -1787,10 +1787,10 @@ var TextComponent = function TextComponent(_ref) {
1787
1787
  TextComponent.displayName = 'Text';
1788
1788
  var Text = withScale(TextComponent);
1789
1789
 
1790
- var InputBlockLabelComponent = function InputBlockLabelComponent(_ref) {
1791
- var children = _ref.children,
1792
- _ref$required = _ref.required,
1793
- required = _ref$required === void 0 ? false : _ref$required;
1790
+ var InputBlockLabelComponent = function InputBlockLabelComponent(_ref2) {
1791
+ var children = _ref2.children,
1792
+ _ref2$required = _ref2.required,
1793
+ required = _ref2$required === void 0 ? false : _ref2$required;
1794
1794
  var theme$1 = theme.useTheme();
1795
1795
  var _useScale = useScale(),
1796
1796
  SCALES = _useScale.SCALES;
@@ -1809,7 +1809,7 @@ var InputBlockLabelComponent = function InputBlockLabelComponent(_ref) {
1809
1809
  InputBlockLabelComponent.displayName = 'InputBlockLabel';
1810
1810
  var InputBlockLabel = /*#__PURE__*/React.memo(InputBlockLabelComponent);
1811
1811
 
1812
- var _excluded = ["type", "disabled", "readOnly", "onFocus", "onBlur", "className", "initialValue", "onChange", "value", "placeholder", "helperText", "error", "label", "resize"];
1812
+ var _excluded = ["type", "disabled", "readOnly", "onFocus", "onBlur", "className", "initialValue", "onChange", "value", "placeholder", "helperText", "error", "label", "required", "resize"];
1813
1813
  tuple('none', 'both', 'horizontal', 'vertical', 'initial', 'inherit');
1814
1814
  var TextareaComponent = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
1815
1815
  var _ref$type = _ref.type,
@@ -1830,6 +1830,7 @@ var TextareaComponent = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
1830
1830
  helperText = _ref.helperText,
1831
1831
  error = _ref.error,
1832
1832
  label = _ref.label,
1833
+ required = _ref.required,
1833
1834
  _ref$resize = _ref.resize,
1834
1835
  resize = _ref$resize === void 0 ? 'none' : _ref$resize,
1835
1836
  props = _objectWithoutProperties(_ref, _excluded);
@@ -1888,6 +1889,7 @@ var TextareaComponent = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
1888
1889
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
1889
1890
  className: "with-label",
1890
1891
  children: [label && /*#__PURE__*/jsxRuntime.jsx(InputBlockLabel, {
1892
+ required: required,
1891
1893
  children: label
1892
1894
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
1893
1895
  className: _JSXStyle.dynamic([["12276481", [theme$1.layout.radius, borderColor, color, SCALES.font(0.875), SCALES.height(1, 'auto'), SCALES.width(1, 'initial'), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), hoverBorder, theme$1.palette.accents_1, theme$1.palette.accents_2, theme$1.font.sans, SCALES.pt(0.5), SCALES.pr(0.5), SCALES.pb(0.5), SCALES.pl(0.5), resize, theme$1.palette.background]]]) + " " + (classes || ""),
@@ -15,6 +15,7 @@ interface Props {
15
15
  onBlur?: (e: React.FocusEvent<HTMLTextAreaElement>) => void;
16
16
  className?: string;
17
17
  error?: boolean;
18
+ required?: boolean;
18
19
  helperText?: string;
19
20
  label?: string;
20
21
  resize?: TextareaResizes;
package/esm/index.d.ts CHANGED
@@ -42,7 +42,7 @@ export { default as Container } from './container';
42
42
  export { default as HtmlRenderer } from './html-renderer';
43
43
  export { default as Image } from './image';
44
44
  export type { ImageProps, ImageBrowserProps } from './image';
45
- export { default as Input, getColors } from './input';
45
+ export { default as Input, getColors, InputLabel, InputError } from './input';
46
46
  export type { InputProps, InputPasswordProps } from './input';
47
47
  export { default as Keyboard } from './keyboard';
48
48
  export type { KeyboardProps } from './keyboard';
package/esm/index.js CHANGED
@@ -28,7 +28,7 @@ export { default as Grid } from './grid';
28
28
  export { default as Container } from './container';
29
29
  export { default as HtmlRenderer } from './html-renderer';
30
30
  export { default as Image } from './image';
31
- export { default as Input, getColors } from './input';
31
+ export { default as Input, getColors, InputLabel, InputError } from './input';
32
32
  export { default as Keyboard } from './keyboard';
33
33
  export { default as Link } from './link';
34
34
  export { default as Loading } from './loading';
@@ -14,5 +14,6 @@ export type { InputProps } from './input-field';
14
14
  export type { InputTypes } from './input-props';
15
15
  export type { InputPasswordProps } from './password';
16
16
  export type { TextareaProps } from '../textarea';
17
+ export { default as InputLabel, InputError } from "./input-block-label";
17
18
  declare const _default: InputComponentType;
18
19
  export default _default;
@@ -9,4 +9,5 @@ Input.Password = InputPassword;
9
9
  Input.Phone = PhoneInput;
10
10
  Input.Currency = CurrencyInput;
11
11
  export { getColors } from './styles';
12
+ export { default as InputLabel, InputError } from "./input-block-label";
12
13
  export default Input;
@@ -2,5 +2,9 @@ import React from 'react';
2
2
  export interface InputBlockLabelLabel {
3
3
  required?: boolean;
4
4
  }
5
+ export declare const InputError: React.FC<{
6
+ text: string;
7
+ error?: string;
8
+ }>;
5
9
  declare const InputBlockLabel: React.NamedExoticComponent<React.PropsWithChildren<InputBlockLabelLabel>>;
6
10
  export default InputBlockLabel;
@@ -2,10 +2,26 @@ import _JSXStyle from "../styled-jsx.es.js";
2
2
  import React from 'react';
3
3
  import { useTheme } from '@helpdice/theme';
4
4
  import useScale from '../use-scale';
5
- var InputBlockLabelComponent = function InputBlockLabelComponent(_ref) {
6
- var children = _ref.children,
7
- _ref$required = _ref.required,
8
- required = _ref$required === void 0 ? false : _ref$required;
5
+ import Text from '../text';
6
+ export var InputError = function InputError(_ref) {
7
+ var text = _ref.text,
8
+ error = _ref.error;
9
+ return /*#__PURE__*/React.createElement(Text, {
10
+ font: 0.8,
11
+ style: {
12
+ marginTop: 0.4,
13
+ marginRight: 0,
14
+ marginLeft: 0,
15
+ marginBottom: '0.4rem',
16
+ textAlign: 'left'
17
+ },
18
+ color: error ? "error" : 'default'
19
+ }, "\xA0", text);
20
+ };
21
+ var InputBlockLabelComponent = function InputBlockLabelComponent(_ref2) {
22
+ var children = _ref2.children,
23
+ _ref2$required = _ref2.required,
24
+ required = _ref2$required === void 0 ? false : _ref2$required;
9
25
  var theme = useTheme();
10
26
  var _useScale = useScale(),
11
27
  SCALES = _useScale.SCALES;
@@ -10,10 +10,9 @@ import _JSXStyle from "../styled-jsx.es.js";
10
10
  import React, { useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
11
11
  import { useTheme, useClasses } from '@helpdice/theme';
12
12
  import InputLabel from './input-label';
13
- import InputBlockLabel from './input-block-label';
13
+ import InputBlockLabel, { InputError } from './input-block-label';
14
14
  import InputIcon from './input-icon';
15
15
  import InputClearIcon from './input-icon-clear';
16
- import Text from '../text';
17
16
  import { getColors } from './styles';
18
17
  import useScale, { withScale } from '../use-scale';
19
18
  var simulateChangeEvent = function simulateChangeEvent(el, event) {
@@ -182,17 +181,10 @@ var InputComponent = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
182
181
  isRight: true
183
182
  }, labelRight), /*#__PURE__*/React.createElement("br", {
184
183
  className: _JSXStyle.dynamic([["2371903369", [SCALES.height(2.25), SCALES.font(0.875), SCALES.width(1, defaultWidth), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.width(1, defaultWidth), variant === 'normal' ? theme.layout.radius : '', variant === 'none' ? '' : variant === 'line' ? "border-bottom: 1px solid ".concat(borderColor) : "border: 1px solid ".concat(borderColor), theme.palette.accents_1, theme.palette.accents_2, hoverBorder, SCALES.font(0.875), theme.palette.foreground, theme.palette.accents_3, theme.palette.background, color]]])
185
- })), helperText && /*#__PURE__*/React.createElement(Text, {
186
- font: 0.8,
187
- style: {
188
- marginTop: 0.4,
189
- marginRight: 0,
190
- marginLeft: 0,
191
- marginBottom: '0.4rem',
192
- textAlign: 'left'
193
- },
194
- color: error ? "error" : 'default'
195
- }, "\xA0", helperText), /*#__PURE__*/React.createElement(_JSXStyle, {
184
+ })), helperText && /*#__PURE__*/React.createElement(InputError, {
185
+ text: helperText,
186
+ error: error
187
+ }), /*#__PURE__*/React.createElement(_JSXStyle, {
196
188
  id: "2371903369",
197
189
  dynamic: [SCALES.height(2.25), SCALES.font(0.875), SCALES.width(1, defaultWidth), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.width(1, defaultWidth), variant === 'normal' ? theme.layout.radius : '', variant === 'none' ? '' : variant === 'line' ? "border-bottom: 1px solid ".concat(borderColor) : "border: 1px solid ".concat(borderColor), theme.palette.accents_1, theme.palette.accents_2, hoverBorder, SCALES.font(0.875), theme.palette.foreground, theme.palette.accents_3, theme.palette.background, color]
198
190
  }, ".with-label.__jsx-style-dynamic-selector{display:inline-block;box-sizing:border-box;-webkit-box-align:center;--input-height:".concat(SCALES.height(2.25), ";font-size:").concat(SCALES.font(0.875), ";width:").concat(SCALES.width(1, defaultWidth), ";padding:").concat(SCALES.pt(0), " ").concat(SCALES.pr(0), " ").concat(SCALES.pb(0), " ").concat(SCALES.pl(0), ";margin:").concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";}.input-container.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;width:").concat(SCALES.width(1, defaultWidth), ";height:var(--input-height);}.input-wrapper.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;vertical-align:middle;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;height:100%;-webkit-flex:1;-ms-flex:1;flex:1;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border-radius:").concat(variant === 'normal' ? theme.layout.radius : '', ";").concat(variant === 'none' ? '' : variant === 'line' ? "border-bottom: 1px solid ".concat(borderColor) : "border: 1px solid ".concat(borderColor), ";-webkit-transition:border 0.2s ease 0s,color 0.2s ease 0s;transition:border 0.2s ease 0s,color 0.2s ease 0s;}.input-wrapper.left-label.__jsx-style-dynamic-selector{border-top-left-radius:0;border-bottom-left-radius:0;}.input-wrapper.right-label.__jsx-style-dynamic-selector{border-top-right-radius:0;border-bottom-right-radius:0;}.input-wrapper.disabled.__jsx-style-dynamic-selector{background-color:").concat(theme.palette.accents_1, ";border-color:").concat(theme.palette.accents_2, ";cursor:not-allowed;}input.disabled.__jsx-style-dynamic-selector{cursor:not-allowed;}.input-wrapper.hover.__jsx-style-dynamic-selector{border-color:").concat(hoverBorder, ";}input.__jsx-style-dynamic-selector{margin:0.25em 0.625em;padding:0;box-shadow:none;font-size:").concat(SCALES.font(0.875), ";background-color:transparent;border:none;color:").concat(theme.palette.foreground, ";outline:none;border-radius:0;width:100%;min-width:0;-webkit-appearance:none;}input.left-icon.__jsx-style-dynamic-selector{margin-left:0;}input.right-icon.__jsx-style-dynamic-selector{margin-right:0;}.__jsx-style-dynamic-selector::-webkit-input-placeholder,.__jsx-style-dynamic-selector::-moz-placeholder,.__jsx-style-dynamic-selector:-ms-input-placeholder,.__jsx-style-dynamic-selector::-webkit-input-placeholder{color:").concat(theme.palette.accents_3, ";}.__jsx-style-dynamic-selector::-moz-placeholder,.__jsx-style-dynamic-selector::-moz-placeholder,.__jsx-style-dynamic-selector:-ms-input-placeholder,.__jsx-style-dynamic-selector::-webkit-input-placeholder{color:").concat(theme.palette.accents_3, ";}.__jsx-style-dynamic-selector:-ms-input-placeholder,.__jsx-style-dynamic-selector::-moz-placeholder,.__jsx-style-dynamic-selector:-ms-input-placeholder,.__jsx-style-dynamic-selector::-webkit-input-placeholder{color:").concat(theme.palette.accents_3, ";}.__jsx-style-dynamic-selector::placeholder,.__jsx-style-dynamic-selector::-moz-placeholder,.__jsx-style-dynamic-selector:-ms-input-placeholder,.__jsx-style-dynamic-selector::-webkit-input-placeholder{color:").concat(theme.palette.accents_3, ";}.__jsx-style-dynamic-selector::-ms-reveal{display:none !important;}input.__jsx-style-dynamic-selector:-webkit-autofill,input.__jsx-style-dynamic-selector:-webkit-autofill.__jsx-style-dynamic-selector:hover,input.__jsx-style-dynamic-selector:-webkit-autofill.__jsx-style-dynamic-selector:active,input.__jsx-style-dynamic-selector:-webkit-autofill.__jsx-style-dynamic-selector:focus{-webkit-box-shadow:0 0 0 30px ").concat(theme.palette.background, " inset !important;-webkit-text-fill-color:").concat(color, " !important;}")));
@@ -24,6 +24,7 @@ interface Props {
24
24
  dropdownStyle?: CSSProperties;
25
25
  disableMatchWidth?: boolean;
26
26
  error?: boolean;
27
+ required?: boolean;
27
28
  helperText?: string;
28
29
  onDropdownVisibleChange?: (visible: boolean) => void;
29
30
  getPopupContainer?: () => HTMLElement | null;
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
3
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
- var _excluded = ["children", "label", "type", "disabled", "initialValue", "value", "icon", "onChange", "pure", "multiple", "fullWidth", "clearable", "placeholder", "className", "dropdownClassName", "dropdownStyle", "disableMatchWidth", "helperText", "error", "getPopupContainer", "onDropdownVisibleChange"];
5
+ var _excluded = ["children", "label", "type", "disabled", "initialValue", "value", "icon", "onChange", "pure", "multiple", "fullWidth", "clearable", "placeholder", "className", "dropdownClassName", "dropdownStyle", "disableMatchWidth", "helperText", "error", "required", "getPopupContainer", "onDropdownVisibleChange"];
6
6
  import _JSXStyle from "../styled-jsx.es.js";
7
7
  /* "use client" */
8
8
 
@@ -18,6 +18,7 @@ import { SelectContext } from './select-context';
18
18
  import { getColors } from './styles';
19
19
  import SelectInput from './select-input';
20
20
  import useScale, { withScale } from '../use-scale';
21
+ import InputBlockLabel from '../input/input-block-label';
21
22
  var SelectComponent = /*#__PURE__*/React.forwardRef(function (_ref, selectRef) {
22
23
  var children = _ref.children,
23
24
  label = _ref.label,
@@ -47,6 +48,7 @@ var SelectComponent = /*#__PURE__*/React.forwardRef(function (_ref, selectRef) {
47
48
  disableMatchWidth = _ref$disableMatchWidt === void 0 ? false : _ref$disableMatchWidt,
48
49
  helperText = _ref.helperText,
49
50
  error = _ref.error,
51
+ required = _ref.required,
50
52
  getPopupContainer = _ref.getPopupContainer,
51
53
  _ref$onDropdownVisibl = _ref.onDropdownVisibleChange,
52
54
  onDropdownVisibleChange = _ref$onDropdownVisibl === void 0 ? function () {} : _ref$onDropdownVisibl,
@@ -173,14 +175,8 @@ var SelectComponent = /*#__PURE__*/React.forwardRef(function (_ref, selectRef) {
173
175
  }, className);
174
176
  return /*#__PURE__*/React.createElement("div", {
175
177
  className: _JSXStyle.dynamic([["1795507141", [disabled ? 'not-allowed' : 'pointer', border, theme.layout.radius, disabled ? theme.palette.accents_1 : theme.palette.background, SCALES.font(0.875), SCALES.height(2.25), SCALES.width(1, fullWidth ? '100%' : 'initial'), SCALES.pt(0), SCALES.pr(0.334), SCALES.pb(0), SCALES.pl(0.667), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.pt(0.334), SCALES.pr(0.334), SCALES.pb(0.334), SCALES.pl(0.667), disabled ? theme.palette.border : borderActive, disabled ? theme.palette.accents_5 : borderActive, disabled ? theme.palette.accents_4 : theme.palette.foreground, placeholderColor, theme.layout.gapQuarter, visible ? '180' : '0', iconBorder]]])
176
- }, label && /*#__PURE__*/React.createElement("label", {
177
- style: {
178
- display: 'block',
179
- marginBottom: '0.4rem',
180
- fontSize: '14px',
181
- fontWeight: 'light'
182
- },
183
- className: _JSXStyle.dynamic([["1795507141", [disabled ? 'not-allowed' : 'pointer', border, theme.layout.radius, disabled ? theme.palette.accents_1 : theme.palette.background, SCALES.font(0.875), SCALES.height(2.25), SCALES.width(1, fullWidth ? '100%' : 'initial'), SCALES.pt(0), SCALES.pr(0.334), SCALES.pb(0), SCALES.pl(0.667), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.pt(0.334), SCALES.pr(0.334), SCALES.pb(0.334), SCALES.pl(0.667), disabled ? theme.palette.border : borderActive, disabled ? theme.palette.accents_5 : borderActive, disabled ? theme.palette.accents_4 : theme.palette.foreground, placeholderColor, theme.layout.gapQuarter, visible ? '180' : '0', iconBorder]]])
178
+ }, label && /*#__PURE__*/React.createElement(InputBlockLabel, {
179
+ required: required
184
180
  }, label), /*#__PURE__*/React.createElement(SelectContext.Provider, {
185
181
  value: initialValue
186
182
  }, /*#__PURE__*/React.createElement("div", _extends({
@@ -15,6 +15,7 @@ interface Props {
15
15
  onBlur?: (e: React.FocusEvent<HTMLTextAreaElement>) => void;
16
16
  className?: string;
17
17
  error?: boolean;
18
+ required?: boolean;
18
19
  helperText?: string;
19
20
  label?: string;
20
21
  resize?: TextareaResizes;
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- var _excluded = ["type", "disabled", "readOnly", "onFocus", "onBlur", "className", "initialValue", "onChange", "value", "placeholder", "helperText", "error", "label", "resize"];
4
+ var _excluded = ["type", "disabled", "readOnly", "onFocus", "onBlur", "className", "initialValue", "onChange", "value", "placeholder", "helperText", "error", "label", "required", "resize"];
5
5
  import _JSXStyle from "../styled-jsx.es.js";
6
6
  /* "use client" */
7
7
 
@@ -32,6 +32,7 @@ var TextareaComponent = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
32
32
  helperText = _ref.helperText,
33
33
  error = _ref.error,
34
34
  label = _ref.label,
35
+ required = _ref.required,
35
36
  _ref$resize = _ref.resize,
36
37
  resize = _ref$resize === void 0 ? 'none' : _ref$resize,
37
38
  props = _objectWithoutProperties(_ref, _excluded);
@@ -89,7 +90,9 @@ var TextareaComponent = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
89
90
  var textareaProps = _extends({}, props, controlledValue);
90
91
  return /*#__PURE__*/React.createElement("div", {
91
92
  className: "with-label"
92
- }, label && /*#__PURE__*/React.createElement(InputBlockLabel, null, label), /*#__PURE__*/React.createElement("div", {
93
+ }, label && /*#__PURE__*/React.createElement(InputBlockLabel, {
94
+ required: required
95
+ }, label), /*#__PURE__*/React.createElement("div", {
93
96
  className: _JSXStyle.dynamic([["12276481", [theme.layout.radius, borderColor, color, SCALES.font(0.875), SCALES.height(1, 'auto'), SCALES.width(1, 'initial'), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), hoverBorder, theme.palette.accents_1, theme.palette.accents_2, theme.font.sans, SCALES.pt(0.5), SCALES.pr(0.5), SCALES.pb(0.5), SCALES.pl(0.5), resize, theme.palette.background]]]) + " " + (classes || "")
94
97
  }, /*#__PURE__*/React.createElement("textarea", _extends({
95
98
  ref: textareaRef,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helpdice/ui",
3
- "version": "2.6.0-beta.1",
3
+ "version": "2.6.0-beta.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "esm/index.d.ts",
6
6
  "unpkg": "dist/index.min.js",