@chayns-components/core 5.0.0-beta.410 → 5.0.0-beta.413

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 (48) hide show
  1. package/lib/components/checkbox/Checkbox.d.ts +1 -1
  2. package/lib/components/checkbox/Checkbox.js.map +1 -1
  3. package/lib/components/input/Input.d.ts +4 -0
  4. package/lib/components/input/Input.js +5 -3
  5. package/lib/components/input/Input.js.map +1 -1
  6. package/lib/components/input/Input.styles.d.ts +4 -1
  7. package/lib/components/input/Input.styles.js +29 -10
  8. package/lib/components/input/Input.styles.js.map +1 -1
  9. package/lib/components/number-input/NumberInput.d.ts +9 -1
  10. package/lib/components/number-input/NumberInput.js +40 -21
  11. package/lib/components/number-input/NumberInput.js.map +1 -1
  12. package/lib/components/number-input/constants/number.d.ts +1 -0
  13. package/lib/components/number-input/constants/number.js +3 -2
  14. package/lib/components/number-input/constants/number.js.map +1 -1
  15. package/lib/components/number-input/utils/number.d.ts +4 -2
  16. package/lib/components/number-input/utils/number.js +30 -2
  17. package/lib/components/number-input/utils/number.js.map +1 -1
  18. package/lib/components/opening-times/OpeningTimes.d.ts +19 -0
  19. package/lib/components/opening-times/OpeningTimes.js +92 -0
  20. package/lib/components/opening-times/OpeningTimes.js.map +1 -0
  21. package/lib/components/opening-times/OpeningTimes.styles.d.ts +8 -0
  22. package/lib/components/opening-times/OpeningTimes.styles.js +19 -0
  23. package/lib/components/opening-times/OpeningTimes.styles.js.map +1 -0
  24. package/lib/components/opening-times/opening-inputs/OpeningInputs.d.ts +10 -0
  25. package/lib/components/opening-times/opening-inputs/OpeningInputs.js +95 -0
  26. package/lib/components/opening-times/opening-inputs/OpeningInputs.js.map +1 -0
  27. package/lib/components/opening-times/opening-inputs/OpeningInputs.styles.d.ts +2 -0
  28. package/lib/components/opening-times/opening-inputs/OpeningInputs.styles.js +13 -0
  29. package/lib/components/opening-times/opening-inputs/OpeningInputs.styles.js.map +1 -0
  30. package/lib/components/opening-times/opening-inputs/opening-input/OpeningInput.d.ts +14 -0
  31. package/lib/components/opening-times/opening-inputs/opening-input/OpeningInput.js +100 -0
  32. package/lib/components/opening-times/opening-inputs/opening-input/OpeningInput.js.map +1 -0
  33. package/lib/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.d.ts +274 -0
  34. package/lib/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js +46 -0
  35. package/lib/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js.map +1 -0
  36. package/lib/components/progress-bar/ProgressBar.d.ts +2 -2
  37. package/lib/components/progress-bar/ProgressBar.js +2 -2
  38. package/lib/components/progress-bar/ProgressBar.js.map +1 -1
  39. package/lib/components/slider/Slider.d.ts +2 -2
  40. package/lib/components/slider/Slider.js +4 -4
  41. package/lib/components/slider/Slider.js.map +1 -1
  42. package/lib/index.d.ts +2 -0
  43. package/lib/index.js +7 -0
  44. package/lib/index.js.map +1 -1
  45. package/lib/types/openingTimes.d.ts +19 -0
  46. package/lib/types/openingTimes.js +13 -0
  47. package/lib/types/openingTimes.js.map +1 -0
  48. package/package.json +2 -2
@@ -3,7 +3,7 @@ export type CheckboxProps = {
3
3
  /**
4
4
  * Text for checkbox or switch
5
5
  */
6
- children?: ReactElement;
6
+ children?: ReactElement | string;
7
7
  /**
8
8
  * Indicates whether the checkbox or switch is selected
9
9
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.js","names":["_react","_interopRequireWildcard","require","_uuid","_calculate","_Checkbox","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","Checkbox","_ref","children","isChecked","isDisabled","labelClassName","onChange","shouldShowAsSwitch","shouldShowCentered","isActive","setIsActive","useState","handleChange","useCallback","event","target","checked","uuid","useUuid","lineHeight","useMemo","undefined","getHeightOfSingleTextLine","createElement","StyledCheckbox","StyledCheckboxInput","disabled","id","type","StyledCheckboxLabel","className","htmlFor","displayName","_default","exports"],"sources":["../../../src/components/checkbox/Checkbox.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n ChangeEventHandler,\n FC,\n ReactElement,\n useCallback,\n useMemo,\n useState,\n} from 'react';\nimport { useUuid } from '../../hooks/uuid';\nimport { getHeightOfSingleTextLine } from '../../utils/calculate';\nimport { StyledCheckbox, StyledCheckboxInput, StyledCheckboxLabel } from './Checkbox.styles';\n\nexport type CheckboxProps = {\n /**\n * Text for checkbox or switch\n */\n children?: ReactElement;\n /**\n * Indicates whether the checkbox or switch is selected\n */\n isChecked?: boolean;\n /**\n * Disables the checkbox or switch so it cannot be toggled\n */\n isDisabled?: boolean;\n /**\n * Classname for the label\n */\n labelClassName?: string;\n /**\n * Function to be executed if the checked value changes\n */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Changes the design to use switch instead of checkbox\n */\n shouldShowAsSwitch?: boolean;\n /**\n * Whether the Checkbox should be displayed centered to the label or at the top\n */\n shouldShowCentered?: boolean;\n};\n\nconst Checkbox: FC<CheckboxProps> = ({\n children,\n isChecked,\n isDisabled,\n labelClassName,\n onChange,\n shouldShowAsSwitch,\n shouldShowCentered = false,\n}) => {\n const [isActive, setIsActive] = useState(isChecked ?? false);\n\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setIsActive(event.target.checked);\n\n if (typeof onChange === 'function') {\n onChange(event);\n }\n },\n [onChange],\n );\n\n const uuid = useUuid();\n\n const lineHeight = useMemo(\n () => (shouldShowCentered ? undefined : getHeightOfSingleTextLine()),\n [shouldShowCentered],\n );\n\n return (\n <StyledCheckbox>\n <StyledCheckboxInput\n checked={isChecked}\n disabled={isDisabled}\n id={uuid}\n onChange={handleChange}\n type=\"checkbox\"\n />\n <StyledCheckboxLabel\n className={labelClassName}\n htmlFor={uuid}\n isChecked={isChecked ?? isActive}\n isDisabled={isDisabled}\n shouldShowAsSwitch={shouldShowAsSwitch}\n lineHeight={lineHeight}\n >\n {children}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,OAAO,EAAEd,IAAK;IACdd,SAAS,EAAEA,SAAS,IAAIM,QAAS;IACjCL,UAAU,EAAEA,UAAW;IACvBG,kBAAkB,EAAEA,kBAAmB;IACvCY,UAAU,EAAEA;EAAW,GAEtBjB,QACgB,CACT,CAAC;AAEzB,CAAC;AAEDF,QAAQ,CAACgC,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAjD,OAAA,GAEnBe,QAAQ"}
1
+ {"version":3,"file":"Checkbox.js","names":["_react","_interopRequireWildcard","require","_uuid","_calculate","_Checkbox","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","Checkbox","_ref","children","isChecked","isDisabled","labelClassName","onChange","shouldShowAsSwitch","shouldShowCentered","isActive","setIsActive","useState","handleChange","useCallback","event","target","checked","uuid","useUuid","lineHeight","useMemo","undefined","getHeightOfSingleTextLine","createElement","StyledCheckbox","StyledCheckboxInput","disabled","id","type","StyledCheckboxLabel","className","htmlFor","displayName","_default","exports"],"sources":["../../../src/components/checkbox/Checkbox.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n ChangeEventHandler,\n FC,\n ReactElement,\n useCallback,\n useMemo,\n useState,\n} from 'react';\nimport { useUuid } from '../../hooks/uuid';\nimport { getHeightOfSingleTextLine } from '../../utils/calculate';\nimport { StyledCheckbox, StyledCheckboxInput, StyledCheckboxLabel } from './Checkbox.styles';\n\nexport type CheckboxProps = {\n /**\n * Text for checkbox or switch\n */\n children?: ReactElement | string;\n /**\n * Indicates whether the checkbox or switch is selected\n */\n isChecked?: boolean;\n /**\n * Disables the checkbox or switch so it cannot be toggled\n */\n isDisabled?: boolean;\n /**\n * Classname for the label\n */\n labelClassName?: string;\n /**\n * Function to be executed if the checked value changes\n */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Changes the design to use switch instead of checkbox\n */\n shouldShowAsSwitch?: boolean;\n /**\n * Whether the Checkbox should be displayed centered to the label or at the top\n */\n shouldShowCentered?: boolean;\n};\n\nconst Checkbox: FC<CheckboxProps> = ({\n children,\n isChecked,\n isDisabled,\n labelClassName,\n onChange,\n shouldShowAsSwitch,\n shouldShowCentered = false,\n}) => {\n const [isActive, setIsActive] = useState(isChecked ?? false);\n\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setIsActive(event.target.checked);\n\n if (typeof onChange === 'function') {\n onChange(event);\n }\n },\n [onChange],\n );\n\n const uuid = useUuid();\n\n const lineHeight = useMemo(\n () => (shouldShowCentered ? undefined : getHeightOfSingleTextLine()),\n [shouldShowCentered],\n );\n\n return (\n <StyledCheckbox>\n <StyledCheckboxInput\n checked={isChecked}\n disabled={isDisabled}\n id={uuid}\n onChange={handleChange}\n type=\"checkbox\"\n />\n <StyledCheckboxLabel\n className={labelClassName}\n htmlFor={uuid}\n isChecked={isChecked ?? isActive}\n isDisabled={isDisabled}\n shouldShowAsSwitch={shouldShowAsSwitch}\n lineHeight={lineHeight}\n >\n {children}\n </StyledCheckboxLabel>\n </StyledCheckbox>\n );\n};\n\nCheckbox.displayName = 'Checkbox';\n\nexport default Checkbox;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AASA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAA6F,SAAAI,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAA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,CAACQ,KAAK,CAAC;IACnB;EACJ,CAAC,EACD,CAACR,QAAQ,CACb,CAAC;EAED,MAAMW,IAAI,GAAG,IAAAC,aAAO,EAAC,CAAC;EAEtB,MAAMC,UAAU,GAAG,IAAAC,cAAO,EACtB,MAAOZ,kBAAkB,GAAGa,SAAS,GAAG,IAAAC,oCAAyB,EAAC,CAAE,EACpE,CAACd,kBAAkB,CACvB,CAAC;EAED,oBACInC,MAAA,CAAAY,OAAA,CAAAsC,aAAA,CAAC7C,SAAA,CAAA8C,cAAc,qBACXnD,MAAA,CAAAY,OAAA,CAAAsC,aAAA,CAAC7C,SAAA,CAAA+C,mBAAmB;IAChBT,OAAO,EAAEb,SAAU;IACnBuB,QAAQ,EAAEtB,UAAW;IACrBuB,EAAE,EAAEV,IAAK;IACTX,QAAQ,EAAEM,YAAa;IACvBgB,IAAI,EAAC;EAAU,CAClB,CAAC,eACFvD,MAAA,CAAAY,OAAA,CAAAsC,aAAA,CAAC7C,SAAA,CAAAmD,mBAAmB;IAChBC,SAAS,EAAEzB,cAAe;IAC1B0B,OAAO,EAAEd,IAAK;IACdd,SAAS,EAAEA,SAAS,IAAIM,QAAS;IACjCL,UAAU,EAAEA,UAAW;IACvBG,kBAAkB,EAAEA,kBAAmB;IACvCY,UAAU,EAAEA;EAAW,GAEtBjB,QACgB,CACT,CAAC;AAEzB,CAAC;AAEDF,QAAQ,CAACgC,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAjD,OAAA,GAEnBe,QAAQ"}
@@ -56,6 +56,10 @@ export type InputProps = {
56
56
  * Value if the input field should be controlled
57
57
  */
58
58
  value?: string;
59
+ /**
60
+ * Whether only the bottom border should be displayed
61
+ */
62
+ shouldShowOnlyBottomBorder?: boolean;
59
63
  /**
60
64
  * If true, the input field is focused when the component is mounted
61
65
  */
@@ -23,6 +23,7 @@ const Input = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
23
23
  placeholder,
24
24
  placeholderElement,
25
25
  rightElement,
26
+ shouldShowOnlyBottomBorder,
26
27
  shouldShowClearIcon = false,
27
28
  type = 'text',
28
29
  value,
@@ -74,7 +75,8 @@ const Input = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
74
75
  isDisabled: isDisabled,
75
76
  isInvalid: isInvalid
76
77
  }, /*#__PURE__*/_react.default.createElement(_Input.StyledInputContentWrapper, {
77
- shouldRoundRightCorners: !rightElement
78
+ shouldRoundRightCorners: !rightElement,
79
+ shouldShowOnlyBottomBorder: shouldShowOnlyBottomBorder
78
80
  }, iconElement && /*#__PURE__*/_react.default.createElement(_Input.StyledInputIconWrapper, null, iconElement), /*#__PURE__*/_react.default.createElement(_Input.StyledInputContent, null, /*#__PURE__*/_react.default.createElement(_Input.StyledInputField, {
79
81
  disabled: isDisabled,
80
82
  onBlur: onBlur,
@@ -102,6 +104,7 @@ const Input = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
102
104
  },
103
105
  isInvalid: isInvalid
104
106
  }, placeholderElement, placeholder)), shouldShowClearIcon && /*#__PURE__*/_react.default.createElement(_Input.StyledMotionInputClearIcon, {
107
+ shouldShowOnlyBottomBorder: shouldShowOnlyBottomBorder,
105
108
  animate: {
106
109
  opacity: hasValue ? 1 : 0
107
110
  },
@@ -109,8 +112,7 @@ const Input = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
109
112
  onClick: handleClearIconClick,
110
113
  transition: {
111
114
  type: 'tween'
112
- },
113
- isInvalid: isInvalid
115
+ }
114
116
  }, /*#__PURE__*/_react.default.createElement(_Icon.default, {
115
117
  icons: ['fa fa-times'],
116
118
  color: isInvalid ? theme.wrong : undefined
@@ -1 +1 @@
1
- {"version":3,"file":"Input.js","names":["_react","_interopRequireWildcard","require","_styledComponents","_Icon","_interopRequireDefault","_Input","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","Input","forwardRef","_ref","ref","iconElement","inputMode","isDisabled","onBlur","onChange","onFocus","onKeyDown","placeholder","placeholderElement","rightElement","shouldShowClearIcon","type","value","shouldUseAutoFocus","isInvalid","hasValue","setHasValue","useState","theme","useTheme","inputRef","useRef","handleClearIconClick","useCallback","current","target","handleInputFieldChange","event","useImperativeHandle","focus","useEffect","labelPosition","useMemo","bottom","right","left","top","createElement","StyledInput","className","StyledInputContentWrapper","shouldRoundRightCorners","StyledInputIconWrapper","StyledInputContent","StyledInputField","disabled","autoFocus","StyledMotionInputLabel","animate","fontSize","initial","layout","style","transition","duration","StyledMotionInputClearIcon","opacity","onClick","icons","color","wrong","undefined","StyledInputRightElement","displayName","_default","exports"],"sources":["../../../src/components/input/Input.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n ChangeEventHandler,\n FocusEventHandler,\n forwardRef,\n HTMLInputTypeAttribute,\n KeyboardEventHandler,\n ReactNode,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useTheme } from 'styled-components';\nimport type { Theme } from '../color-scheme-provider/ColorSchemeProvider';\nimport Icon from '../icon/Icon';\nimport {\n StyledInput,\n StyledInputContent,\n StyledInputContentWrapper,\n StyledInputField,\n StyledInputIconWrapper,\n StyledInputRightElement,\n StyledMotionInputClearIcon,\n StyledMotionInputLabel,\n} from './Input.styles';\n\nexport type InputRef = {\n focus: VoidFunction;\n};\n\ntype InputMode =\n | 'email'\n | 'search'\n | 'tel'\n | 'text'\n | 'url'\n | 'none'\n | 'numeric'\n | 'decimal'\n | undefined;\n\nexport type InputProps = {\n /**\n * Icon element to be displayed on the left side of the input field\n */\n iconElement?: ReactNode;\n /**\n * Defines the input mode of the input\n */\n inputMode?: InputMode;\n /**\n * Disables the input so that it cannot be changed anymore\n */\n isDisabled?: boolean;\n /**\n * Function that is executed when the input field loses focus\n */\n onBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when the text of the input changes\n */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when the input field is focused\n */\n onFocus?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when a letter is pressed\n */\n onKeyDown?: KeyboardEventHandler<HTMLInputElement>;\n /**\n * Placeholder for the input field\n */\n placeholder?: string;\n /**\n * Element to be displayed next to or instead of the \"placeholder\"\n */\n placeholderElement?: ReactNode;\n /**\n * An element that should be displayed on the right side of the Input.\n */\n rightElement?: ReactNode;\n /**\n * If true, a clear icon is displayed at the end of the input field\n */\n shouldShowClearIcon?: boolean;\n /**\n * Input type set for input element (e.g. 'text', 'number' or 'password')\n */\n type?: HTMLInputTypeAttribute;\n /**\n * Value if the input field should be controlled\n */\n value?: string;\n /**\n * If true, the input field is focused when the component is mounted\n */\n shouldUseAutoFocus?: boolean;\n /**\n * If true, the input field is marked as invalid\n */\n isInvalid?: boolean;\n};\n\nconst Input = forwardRef<InputRef, InputProps>(\n (\n {\n iconElement,\n inputMode,\n isDisabled,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n placeholder,\n placeholderElement,\n rightElement,\n shouldShowClearIcon = false,\n type = 'text',\n value,\n shouldUseAutoFocus = false,\n isInvalid = false,\n },\n ref\n ) => {\n const [hasValue, setHasValue] = useState(typeof value === 'string' && value !== '');\n const theme = useTheme() as Theme;\n const inputRef = useRef<HTMLInputElement>(null);\n\n const handleClearIconClick = useCallback(() => {\n if (inputRef.current) {\n inputRef.current.value = '';\n\n setHasValue(false);\n\n if (typeof onChange === 'function') {\n onChange({ target: inputRef.current } as ChangeEvent<HTMLInputElement>);\n }\n }\n }, [onChange]);\n\n const handleInputFieldChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setHasValue(event.target.value !== '');\n\n if (typeof onChange === 'function') {\n onChange(event);\n }\n },\n [onChange]\n );\n\n useImperativeHandle(\n ref,\n () => ({\n focus: () => inputRef.current?.focus(),\n }),\n []\n );\n\n useEffect(() => {\n if (typeof value === 'string') {\n setHasValue(value !== '');\n }\n }, [value]);\n\n const labelPosition = useMemo(() => {\n if (hasValue) {\n return { bottom: -8, right: -6 };\n }\n\n return { left: 0, top: 0 };\n }, [hasValue]);\n\n return (\n <StyledInput\n className=\"beta-chayns-input\"\n isDisabled={isDisabled}\n isInvalid={isInvalid}\n >\n <StyledInputContentWrapper shouldRoundRightCorners={!rightElement}>\n {iconElement && <StyledInputIconWrapper>{iconElement}</StyledInputIconWrapper>}\n <StyledInputContent>\n <StyledInputField\n disabled={isDisabled}\n onBlur={onBlur}\n onChange={handleInputFieldChange}\n onFocus={onFocus}\n onKeyDown={onKeyDown}\n ref={inputRef}\n type={type}\n value={value}\n autoFocus={shouldUseAutoFocus}\n inputMode={inputMode}\n isInvalid={isInvalid}\n />\n <StyledMotionInputLabel\n animate={{\n fontSize: hasValue ? '10px' : '16px',\n }}\n initial={false}\n layout\n style={{ ...labelPosition }}\n transition={{ type: 'tween', duration: 0.3 }}\n isInvalid={isInvalid}\n >\n {placeholderElement}\n {placeholder}\n </StyledMotionInputLabel>\n </StyledInputContent>\n {shouldShowClearIcon && (\n <StyledMotionInputClearIcon\n animate={{ opacity: hasValue ? 1 : 0 }}\n initial={false}\n onClick={handleClearIconClick}\n transition={{ type: 'tween' }}\n isInvalid={isInvalid}\n >\n <Icon\n icons={['fa fa-times']}\n color={isInvalid ? theme.wrong : undefined}\n />\n </StyledMotionInputClearIcon>\n )}\n </StyledInputContentWrapper>\n {rightElement && <StyledInputRightElement>{rightElement}</StyledInputRightElement>}\n </StyledInput>\n );\n }\n);\n\nInput.displayName = 'Input';\n\nexport default Input;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAeA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,KAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AASwB,SAAAG,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GA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":3,"file":"Input.js","names":["_react","_interopRequireWildcard","require","_styledComponents","_Icon","_interopRequireDefault","_Input","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","Input","forwardRef","_ref","ref","iconElement","inputMode","isDisabled","onBlur","onChange","onFocus","onKeyDown","placeholder","placeholderElement","rightElement","shouldShowOnlyBottomBorder","shouldShowClearIcon","type","value","shouldUseAutoFocus","isInvalid","hasValue","setHasValue","useState","theme","useTheme","inputRef","useRef","handleClearIconClick","useCallback","current","target","handleInputFieldChange","event","useImperativeHandle","focus","useEffect","labelPosition","useMemo","bottom","right","left","top","createElement","StyledInput","className","StyledInputContentWrapper","shouldRoundRightCorners","StyledInputIconWrapper","StyledInputContent","StyledInputField","disabled","autoFocus","StyledMotionInputLabel","animate","fontSize","initial","layout","style","transition","duration","StyledMotionInputClearIcon","opacity","onClick","icons","color","wrong","undefined","StyledInputRightElement","displayName","_default","exports"],"sources":["../../../src/components/input/Input.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n ChangeEventHandler,\n FocusEventHandler,\n forwardRef,\n HTMLInputTypeAttribute,\n KeyboardEventHandler,\n ReactNode,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useTheme } from 'styled-components';\nimport type { Theme } from '../color-scheme-provider/ColorSchemeProvider';\nimport Icon from '../icon/Icon';\nimport {\n StyledInput,\n StyledInputContent,\n StyledInputContentWrapper,\n StyledInputField,\n StyledInputIconWrapper,\n StyledInputRightElement,\n StyledMotionInputClearIcon,\n StyledMotionInputLabel,\n} from './Input.styles';\n\nexport type InputRef = {\n focus: VoidFunction;\n};\n\ntype InputMode =\n | 'email'\n | 'search'\n | 'tel'\n | 'text'\n | 'url'\n | 'none'\n | 'numeric'\n | 'decimal'\n | undefined;\n\nexport type InputProps = {\n /**\n * Icon element to be displayed on the left side of the input field\n */\n iconElement?: ReactNode;\n /**\n * Defines the input mode of the input\n */\n inputMode?: InputMode;\n /**\n * Disables the input so that it cannot be changed anymore\n */\n isDisabled?: boolean;\n /**\n * Function that is executed when the input field loses focus\n */\n onBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when the text of the input changes\n */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when the input field is focused\n */\n onFocus?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when a letter is pressed\n */\n onKeyDown?: KeyboardEventHandler<HTMLInputElement>;\n /**\n * Placeholder for the input field\n */\n placeholder?: string;\n /**\n * Element to be displayed next to or instead of the \"placeholder\"\n */\n placeholderElement?: ReactNode;\n /**\n * An element that should be displayed on the right side of the Input.\n */\n rightElement?: ReactNode;\n /**\n * If true, a clear icon is displayed at the end of the input field\n */\n shouldShowClearIcon?: boolean;\n /**\n * Input type set for input element (e.g. 'text', 'number' or 'password')\n */\n type?: HTMLInputTypeAttribute;\n /**\n * Value if the input field should be controlled\n */\n value?: string;\n /**\n * Whether only the bottom border should be displayed\n */\n shouldShowOnlyBottomBorder?: boolean;\n /**\n * If true, the input field is focused when the component is mounted\n */\n shouldUseAutoFocus?: boolean;\n /**\n * If true, the input field is marked as invalid\n */\n isInvalid?: boolean;\n};\n\nconst Input = forwardRef<InputRef, InputProps>(\n (\n {\n iconElement,\n inputMode,\n isDisabled,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n placeholder,\n placeholderElement,\n rightElement,\n shouldShowOnlyBottomBorder,\n shouldShowClearIcon = false,\n type = 'text',\n value,\n shouldUseAutoFocus = false,\n isInvalid = false,\n },\n ref,\n ) => {\n const [hasValue, setHasValue] = useState(typeof value === 'string' && value !== '');\n const theme = useTheme() as Theme;\n const inputRef = useRef<HTMLInputElement>(null);\n\n const handleClearIconClick = useCallback(() => {\n if (inputRef.current) {\n inputRef.current.value = '';\n\n setHasValue(false);\n\n if (typeof onChange === 'function') {\n onChange({ target: inputRef.current } as ChangeEvent<HTMLInputElement>);\n }\n }\n }, [onChange]);\n\n const handleInputFieldChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setHasValue(event.target.value !== '');\n\n if (typeof onChange === 'function') {\n onChange(event);\n }\n },\n [onChange],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n focus: () => inputRef.current?.focus(),\n }),\n [],\n );\n\n useEffect(() => {\n if (typeof value === 'string') {\n setHasValue(value !== '');\n }\n }, [value]);\n\n const labelPosition = useMemo(() => {\n if (hasValue) {\n return { bottom: -8, right: -6 };\n }\n\n return { left: 0, top: 0 };\n }, [hasValue]);\n\n return (\n <StyledInput\n className=\"beta-chayns-input\"\n isDisabled={isDisabled}\n isInvalid={isInvalid}\n >\n <StyledInputContentWrapper\n shouldRoundRightCorners={!rightElement}\n shouldShowOnlyBottomBorder={shouldShowOnlyBottomBorder}\n >\n {iconElement && <StyledInputIconWrapper>{iconElement}</StyledInputIconWrapper>}\n <StyledInputContent>\n <StyledInputField\n disabled={isDisabled}\n onBlur={onBlur}\n onChange={handleInputFieldChange}\n onFocus={onFocus}\n onKeyDown={onKeyDown}\n ref={inputRef}\n type={type}\n value={value}\n autoFocus={shouldUseAutoFocus}\n inputMode={inputMode}\n isInvalid={isInvalid}\n />\n <StyledMotionInputLabel\n animate={{\n fontSize: hasValue ? '10px' : '16px',\n }}\n initial={false}\n layout\n style={{ ...labelPosition }}\n transition={{ type: 'tween', duration: 0.3 }}\n isInvalid={isInvalid}\n >\n {placeholderElement}\n {placeholder}\n </StyledMotionInputLabel>\n </StyledInputContent>\n {shouldShowClearIcon && (\n <StyledMotionInputClearIcon\n shouldShowOnlyBottomBorder={shouldShowOnlyBottomBorder}\n animate={{ opacity: hasValue ? 1 : 0 }}\n initial={false}\n onClick={handleClearIconClick}\n transition={{ type: 'tween' }}\n >\n <Icon\n icons={['fa fa-times']}\n color={isInvalid ? theme.wrong : undefined}\n />\n </StyledMotionInputClearIcon>\n )}\n </StyledInputContentWrapper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CAACnE,KAAA,CAAAK,OAAI;IACDmF,KAAK,EAAE,CAAC,aAAa,CAAE;IACvBC,KAAK,EAAE7C,SAAS,GAAGI,KAAK,CAAC0C,KAAK,GAAGC;EAAU,CAC9C,CACuB,CAET,CAAC,EAC3BrD,YAAY,iBAAI1C,MAAA,CAAAS,OAAA,CAAA8D,aAAA,CAACjE,MAAA,CAAA0F,uBAAuB,QAAEtD,YAAsC,CACxE,CAAC;AAEtB,CACJ,CAAC;AAEDb,KAAK,CAACoE,WAAW,GAAG,OAAO;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA1F,OAAA,GAEboB,KAAK"}
@@ -6,6 +6,7 @@ type StyledInputProps = WithTheme<Pick<InputProps, 'isDisabled' | 'isInvalid'>>;
6
6
  export declare const StyledInput: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledInputProps>>;
7
7
  type StyledInputContentWrapperProps = WithTheme<{
8
8
  shouldRoundRightCorners: boolean;
9
+ shouldShowOnlyBottomBorder?: boolean;
9
10
  }>;
10
11
  export declare const StyledInputContentWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledInputContentWrapperProps>>;
11
12
  export declare const StyledInputContent: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
@@ -277,7 +278,9 @@ export declare const StyledMotionInputLabel: import("styled-components").IStyled
277
278
  onTransitionEndCapture?: import("react").TransitionEventHandler<HTMLLabelElement> | undefined;
278
279
  htmlFor?: string | undefined;
279
280
  } & import("framer-motion").MotionProps & import("react").RefAttributes<HTMLLabelElement>, StyledMotionInputLabelProps>> & Omit<import("framer-motion").ForwardRefComponent<HTMLLabelElement, import("framer-motion").HTMLMotionProps<"label">>, keyof import("react").Component<any, {}, any>>;
280
- type StyledMotionInputClearIconProps = WithTheme<Pick<InputProps, 'isInvalid'>>;
281
+ type StyledMotionInputClearIconProps = WithTheme<{
282
+ shouldShowOnlyBottomBorder?: boolean;
283
+ }>;
281
284
  export declare const StyledMotionInputClearIcon: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<{
282
285
  slot?: string | undefined;
283
286
  title?: string | undefined;
@@ -44,18 +44,32 @@ const StyledInputContentWrapper = exports.StyledInputContentWrapper = _styledCom
44
44
  min-height: 42px;
45
45
  width: 100%;
46
46
  transition: opacity 0.3s ease;
47
- border-bottom-left-radius: 3px;
48
- border-top-left-radius: 3px;
49
-
50
- ${_ref5 => {
47
+
48
+ ${_ref5 => {
51
49
  let {
52
- shouldRoundRightCorners
50
+ shouldRoundRightCorners,
51
+ shouldShowOnlyBottomBorder,
52
+ theme
53
53
  } = _ref5;
54
- return shouldRoundRightCorners && (0, _styledComponents.css)`
55
- border-bottom-right-radius: 3px;
56
- border-top-right-radius: 3px;
54
+ if (shouldShowOnlyBottomBorder) {
55
+ return (0, _styledComponents.css)`
56
+ border-top: none;
57
+ border-right: none;
58
+ border-left: none;
59
+ background-color: transparent;
60
+ border-color: ${theme['408']};
61
+ `;
62
+ }
63
+ if (shouldRoundRightCorners) {
64
+ return (0, _styledComponents.css)`
65
+ border-radius: 3px;
57
66
  `;
58
- }}}
67
+ }
68
+ return (0, _styledComponents.css)`
69
+ border-bottom-left-radius: 3px;
70
+ border-top-left-radius: 3px;
71
+ `;
72
+ }}
59
73
  `;
60
74
  const StyledInputContent = exports.StyledInputContent = _styledComponents.default.div`
61
75
  display: flex;
@@ -96,7 +110,12 @@ const StyledMotionInputLabel = exports.StyledMotionInputLabel = (0, _styledCompo
96
110
  `;
97
111
  const StyledMotionInputClearIcon = exports.StyledMotionInputClearIcon = (0, _styledComponents.default)(_framerMotion.motion.div)`
98
112
  align-items: center;
99
- border-left: 1px solid rgba(160, 160, 160, 0.3);
113
+ border-left: ${_ref8 => {
114
+ let {
115
+ shouldShowOnlyBottomBorder
116
+ } = _ref8;
117
+ return shouldShowOnlyBottomBorder ? 'none' : '1px solid rgba(160, 160, 160, 0.3)';
118
+ }};
100
119
  cursor: pointer;
101
120
  display: flex;
102
121
  flex: 0 0 auto;
@@ -1 +1 @@
1
- {"version":3,"file":"Input.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","StyledInput","exports","styled","div","_ref","isDisabled","StyledInputContentWrapper","_ref2","theme","_ref3","isInvalid","wrong","_ref4","_ref5","shouldRoundRightCorners","css","StyledInputContent","StyledInputField","input","_ref6","text","StyledMotionInputLabel","motion","label","_ref7","undefined","StyledMotionInputClearIcon","StyledInputIconWrapper","StyledInputRightElement"],"sources":["../../../src/components/input/Input.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\nimport styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { InputProps } from './Input';\n\ntype StyledInputProps = WithTheme<Pick<InputProps, 'isDisabled' | 'isInvalid'>>;\n\nexport const StyledInput = styled.div<StyledInputProps>`\n opacity: ${({ isDisabled }) => (isDisabled ? 0.5 : 1)};\n display: flex;\n`;\n\ntype StyledInputContentWrapperProps = WithTheme<{ shouldRoundRightCorners: boolean }>;\n\nexport const StyledInputContentWrapper = styled.div<StyledInputContentWrapperProps>`\n align-items: center;\n background-color: ${({ theme }: StyledInputProps) => theme['100']};\n border: 1px solid\n ${({ theme, isInvalid }: StyledInputProps) =>\n isInvalid ? theme.wrong : 'rgba(160, 160, 160, 0.3)'};\n color: ${({ theme }: StyledInputProps) => theme['006']};\n display: flex;\n justify-content: space-between;\n min-height: 42px;\n width: 100%;\n transition: opacity 0.3s ease;\n border-bottom-left-radius: 3px;\n border-top-left-radius: 3px;\n \n ${({ shouldRoundRightCorners }) =>\n shouldRoundRightCorners &&\n css`\n border-bottom-right-radius: 3px;\n border-top-right-radius: 3px;\n `}}\n`;\n\nexport const StyledInputContent = styled.div`\n display: flex;\n flex: 1 1 auto;\n min-width: 0;\n margin: 8px 10px;\n position: relative;\n`;\n\ntype StyledInputFieldProps = WithTheme<Pick<InputProps, 'isInvalid'>>;\n\nexport const StyledInputField = styled.input<StyledInputFieldProps>`\n background: none;\n border: none;\n color: ${({ theme, isInvalid }: StyledInputFieldProps) =>\n isInvalid ? theme.wrong : theme.text};\n padding: 0;\n width: 100%;\n`;\n\ntype StyledMotionInputLabelProps = WithTheme<Pick<InputProps, 'isInvalid'>>;\n\nexport const StyledMotionInputLabel = styled(motion.label)<StyledMotionInputLabelProps>`\n align-items: baseline;\n display: flex;\n flex: 0 0 auto;\n gap: 4px;\n line-height: 1.3;\n pointer-events: none;\n position: absolute;\n user-select: none;\n color: ${({ theme, isInvalid }: StyledMotionInputLabelProps) =>\n isInvalid ? theme.wrong : undefined};\n`;\n\ntype StyledMotionInputClearIconProps = WithTheme<Pick<InputProps, 'isInvalid'>>;\n\nexport const StyledMotionInputClearIcon = styled(motion.div)<StyledMotionInputClearIconProps>`\n align-items: center;\n border-left: 1px solid rgba(160, 160, 160, 0.3);\n cursor: pointer;\n display: flex;\n flex: 0 0 auto;\n height: 40px;\n justify-content: center;\n width: 40px;\n`;\n\nexport const StyledInputIconWrapper = styled.div`\n align-items: baseline;\n display: flex;\n flex: 0 0 auto;\n justify-content: center;\n margin-left: 10px;\n`;\n\nexport const StyledInputRightElement = styled.div`\n border-bottom-right-radius: 3px;\n border-top-right-radius: 3px;\n overflow: hidden;\n flex: 0 0 auto;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,uBAAA,CAAAF,OAAA;AAAgD,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OA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;EAAA,IAAC;IAAEhB,KAAK;IAAEE;EAAuC,CAAC,GAAAc,KAAA;EAAA,OACvDd,SAAS,GAAGF,KAAK,CAACG,KAAK,GAAGc,SAAS;AAAA,CAAC;AAC5C,CAAC;AAIM,MAAMC,0BAA0B,GAAAzB,OAAA,CAAAyB,0BAAA,GAAG,IAAAxB,yBAAM,EAACoB,oBAAM,CAACnB,GAAG,CAAmC;AAC9F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMwB,sBAAsB,GAAA1B,OAAA,CAAA0B,sBAAA,GAAGzB,yBAAM,CAACC,GAAI;AACjD;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMyB,uBAAuB,GAAA3B,OAAA,CAAA2B,uBAAA,GAAG1B,yBAAM,CAACC,GAAI;AAClD;AACA;AACA;AACA;AACA,CAAC"}
1
+ {"version":3,"file":"Input.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","StyledInput","exports","styled","div","_ref","isDisabled","StyledInputContentWrapper","_ref2","theme","_ref3","isInvalid","wrong","_ref4","_ref5","shouldRoundRightCorners","shouldShowOnlyBottomBorder","css","StyledInputContent","StyledInputField","input","_ref6","text","StyledMotionInputLabel","motion","label","_ref7","undefined","StyledMotionInputClearIcon","_ref8","StyledInputIconWrapper","StyledInputRightElement"],"sources":["../../../src/components/input/Input.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\nimport styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { InputProps } from './Input';\n\ntype StyledInputProps = WithTheme<Pick<InputProps, 'isDisabled' | 'isInvalid'>>;\n\nexport const StyledInput = styled.div<StyledInputProps>`\n opacity: ${({ isDisabled }) => (isDisabled ? 0.5 : 1)};\n display: flex;\n`;\n\ntype StyledInputContentWrapperProps = WithTheme<{\n shouldRoundRightCorners: boolean;\n shouldShowOnlyBottomBorder?: boolean;\n}>;\n\nexport const StyledInputContentWrapper = styled.div<StyledInputContentWrapperProps>`\n align-items: center;\n background-color: ${({ theme }: StyledInputProps) => theme['100']};\n border: 1px solid\n ${({ theme, isInvalid }: StyledInputProps) =>\n isInvalid ? theme.wrong : 'rgba(160, 160, 160, 0.3)'};\n color: ${({ theme }: StyledInputProps) => theme['006']};\n display: flex;\n justify-content: space-between;\n min-height: 42px;\n width: 100%;\n transition: opacity 0.3s ease;\n\n ${({ shouldRoundRightCorners, shouldShowOnlyBottomBorder, theme }) => {\n if (shouldShowOnlyBottomBorder) {\n return css`\n border-top: none;\n border-right: none;\n border-left: none;\n background-color: transparent;\n border-color: ${theme['408']};\n `;\n }\n\n if (shouldRoundRightCorners) {\n return css`\n border-radius: 3px;\n `;\n }\n\n return css`\n border-bottom-left-radius: 3px;\n border-top-left-radius: 3px;\n `;\n }}\n`;\n\nexport const StyledInputContent = styled.div`\n display: flex;\n flex: 1 1 auto;\n min-width: 0;\n margin: 8px 10px;\n position: relative;\n`;\n\ntype StyledInputFieldProps = WithTheme<Pick<InputProps, 'isInvalid'>>;\n\nexport const StyledInputField = styled.input<StyledInputFieldProps>`\n background: none;\n border: none;\n color: ${({ theme, isInvalid }: StyledInputFieldProps) =>\n isInvalid ? theme.wrong : theme.text};\n padding: 0;\n width: 100%;\n`;\n\ntype StyledMotionInputLabelProps = WithTheme<Pick<InputProps, 'isInvalid'>>;\n\nexport const StyledMotionInputLabel = styled(motion.label)<StyledMotionInputLabelProps>`\n align-items: baseline;\n display: flex;\n flex: 0 0 auto;\n gap: 4px;\n line-height: 1.3;\n pointer-events: none;\n position: absolute;\n user-select: none;\n color: ${({ theme, isInvalid }: StyledMotionInputLabelProps) =>\n isInvalid ? theme.wrong : undefined};\n`;\n\ntype StyledMotionInputClearIconProps = WithTheme<{ shouldShowOnlyBottomBorder?: boolean }>;\n\nexport const StyledMotionInputClearIcon = styled(motion.div)<StyledMotionInputClearIconProps>`\n align-items: center;\n border-left: ${({ shouldShowOnlyBottomBorder }) =>\n shouldShowOnlyBottomBorder ? 'none' : '1px solid rgba(160, 160, 160, 0.3)'};\n cursor: pointer;\n display: flex;\n flex: 0 0 auto;\n height: 40px;\n justify-content: center;\n width: 40px;\n`;\n\nexport const StyledInputIconWrapper = styled.div`\n align-items: baseline;\n display: flex;\n flex: 0 0 auto;\n justify-content: center;\n margin-left: 10px;\n`;\n\nexport const StyledInputRightElement = styled.div`\n border-bottom-right-radius: 3px;\n border-top-right-radius: 3px;\n overflow: hidden;\n flex: 0 0 auto;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,uBAAA,CAAAF,OAAA;AAAgD,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAF,wBAAAE,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAc,CAAA,SAAAI,CAAA,GA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AC;AAEM,MAAMc,sBAAsB,GAAA5B,OAAA,CAAA4B,sBAAA,GAAG3B,yBAAM,CAACC,GAAI;AACjD;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAM2B,uBAAuB,GAAA7B,OAAA,CAAA6B,uBAAA,GAAG5B,yBAAM,CAACC,GAAI;AAClD;AACA;AACA;AACA;AACA,CAAC"}
@@ -14,6 +14,10 @@ export type NumberInputProps = {
14
14
  * Rules: only two decimal places, one zero before the comma
15
15
  */
16
16
  isMoneyInput?: boolean;
17
+ /**
18
+ * Whether the value should be formatted as a time.
19
+ */
20
+ isTimeInput?: boolean;
17
21
  /**
18
22
  * Limits the number to this value
19
23
  */
@@ -25,7 +29,7 @@ export type NumberInputProps = {
25
29
  /**
26
30
  * Callback function that is called when the input gets out of focus
27
31
  */
28
- onBlur?: (newNumber: number | null, isInvalid: boolean) => void;
32
+ onBlur?: (newNumber: number | string | null, isInvalid: boolean) => void;
29
33
  /**
30
34
  * Callback function that is called when the input changes
31
35
  * It will pass the text from the input
@@ -35,6 +39,10 @@ export type NumberInputProps = {
35
39
  * Placeholder for the input field
36
40
  */
37
41
  placeholder?: string;
42
+ /**
43
+ * Whether only the bottom border should be displayed
44
+ */
45
+ shouldShowOnlyBottomBorder?: boolean;
38
46
  /**
39
47
  * The value, that should be displayed in the input, when it is in focus.
40
48
  * You can also pass a stringified number as default value.
@@ -15,12 +15,14 @@ const NumberInput = _ref => {
15
15
  let {
16
16
  isDecimalInput,
17
17
  isMoneyInput,
18
+ isTimeInput,
18
19
  maxNumber = Infinity,
19
20
  value,
20
21
  placeholder,
21
22
  onBlur,
22
23
  isDisabled,
23
24
  onChange,
25
+ shouldShowOnlyBottomBorder,
24
26
  minNumber = -Infinity
25
27
  } = _ref;
26
28
  // the plainText will be shown in the input, when it is in focus
@@ -32,6 +34,9 @@ const NumberInput = _ref => {
32
34
  const localPlaceholder = placeholder ?? (isMoneyInput ? '€' : undefined);
33
35
  const onLocalChange = event => {
34
36
  const newValue = event.target.value;
37
+ if (newValue.replaceAll(':', '').length > 4) {
38
+ return;
39
+ }
35
40
  const sanitizedValueString = newValue
36
41
  // Removes everything except numbers, commas and points
37
42
  .replace(_number.NUMBER_CLEAR_REGEX, '');
@@ -39,7 +44,8 @@ const NumberInput = _ref => {
39
44
  if (!(0, _number2.isValidString)({
40
45
  string: valueToCheck,
41
46
  isMoneyInput,
42
- isDecimalInput
47
+ isDecimalInput,
48
+ isTimeInput
43
49
  })) {
44
50
  return;
45
51
  }
@@ -51,17 +57,21 @@ const NumberInput = _ref => {
51
57
  const onLocalBlur = () => {
52
58
  const sanitizedValue = plainText.length === 0 ? '0' : plainText;
53
59
  let isInvalid = false;
54
- const parsedNumber = (0, _number2.parseFloatWithDecimals)({
55
- stringValue: sanitizedValue.replace(',', '.'),
56
- decimals: isMoneyInput ? 2 : undefined
57
- });
58
- if (parsedNumber !== 0 && (parsedNumber > maxNumber || parsedNumber < minNumber)) {
59
- isInvalid = true;
60
+ let parsedNumber = null;
61
+ if (!isTimeInput) {
62
+ parsedNumber = (0, _number2.parseFloatWithDecimals)({
63
+ stringValue: sanitizedValue.replace(',', '.').replaceAll(':', ''),
64
+ decimals: isMoneyInput ? 2 : undefined
65
+ });
66
+ if (parsedNumber !== 0 && (parsedNumber > maxNumber || parsedNumber < minNumber)) {
67
+ isInvalid = true;
68
+ }
69
+ setIsValueInvalid(isInvalid);
60
70
  }
61
- setIsValueInvalid(isInvalid);
62
71
  const newStringValue = plainText.length === 0 ? '' : (0, _number2.formateNumber)({
63
- number: parsedNumber,
64
- isMoneyInput
72
+ number: isTimeInput ? sanitizedValue : parsedNumber,
73
+ isMoneyInput,
74
+ isTimeInput
65
75
  });
66
76
  setFormattedValue(newStringValue);
67
77
  setPlainText(newStringValue.replaceAll('.', ''));
@@ -70,7 +80,11 @@ const NumberInput = _ref => {
70
80
  onChange(newStringValue.replaceAll('.', ''));
71
81
  }
72
82
  if (typeof onBlur === 'function') {
73
- onBlur(parsedNumber === 0 ? null : parsedNumber, isInvalid);
83
+ if (isTimeInput) {
84
+ onBlur(newStringValue, isInvalid);
85
+ } else {
86
+ onBlur(parsedNumber === 0 ? null : parsedNumber, isInvalid);
87
+ }
74
88
  }
75
89
  };
76
90
  const onLocalFocus = () => {
@@ -88,26 +102,31 @@ const NumberInput = _ref => {
88
102
 
89
103
  // updates the formattedValue, when the value changes
90
104
  (0, _react.useEffect)(() => {
91
- const parsedNumber = (0, _number2.parseFloatWithDecimals)({
92
- stringValue: plainText.replace(',', '.'),
93
- decimals: isMoneyInput ? 2 : undefined
94
- });
105
+ let parsedNumber = null;
106
+ if (!isTimeInput) {
107
+ parsedNumber = (0, _number2.parseFloatWithDecimals)({
108
+ stringValue: plainText.replace(',', '.').replaceAll(':', ''),
109
+ decimals: isMoneyInput ? 2 : undefined
110
+ });
95
111
 
96
- // checks, if a given number is invalid, if the input is not in focus
97
- if (!hasFocus) {
98
- setIsValueInvalid(parsedNumber > maxNumber || parsedNumber < minNumber);
112
+ // checks, if a given number is invalid, if the input is not in focus
113
+ if (!hasFocus) {
114
+ setIsValueInvalid(parsedNumber > maxNumber || parsedNumber < minNumber);
115
+ }
99
116
  }
100
117
  setFormattedValue(plainText.length === 0 ? '' : (0, _number2.formateNumber)({
101
- number: parsedNumber,
102
- isMoneyInput
118
+ number: isTimeInput ? plainText : parsedNumber,
119
+ isMoneyInput,
120
+ isTimeInput
103
121
  }));
104
- }, [hasFocus, isMoneyInput, maxNumber, minNumber, plainText]);
122
+ }, [hasFocus, isMoneyInput, isTimeInput, maxNumber, minNumber, plainText]);
105
123
  (0, _react.useEffect)(() => {
106
124
  if (typeof value === 'string') {
107
125
  setPlainText(value);
108
126
  }
109
127
  }, [value]);
110
128
  return /*#__PURE__*/_react.default.createElement(_Input.default, {
129
+ shouldShowOnlyBottomBorder: shouldShowOnlyBottomBorder,
111
130
  inputMode: "decimal",
112
131
  onChange: onLocalChange,
113
132
  value: hasFocus ? plainText : formattedValue,
@@ -1 +1 @@
1
- {"version":3,"file":"NumberInput.js","names":["_react","_interopRequireWildcard","require","_Input","_interopRequireDefault","_number","_number2","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","NumberInput","_ref","isDecimalInput","isMoneyInput","maxNumber","Infinity","value","placeholder","onBlur","isDisabled","onChange","minNumber","plainText","setPlainText","useState","formattedValue","setFormattedValue","hasFocus","setHasFocus","isValueInvalid","setIsValueInvalid","localPlaceholder","undefined","onLocalChange","event","newValue","target","sanitizedValueString","replace","NUMBER_CLEAR_REGEX","valueToCheck","replaceAll","isValidString","string","onLocalBlur","sanitizedValue","length","isInvalid","parsedNumber","parseFloatWithDecimals","stringValue","decimals","newStringValue","formateNumber","number","onLocalFocus","useEffect","createElement","inputMode","onFocus","displayName","_default","exports"],"sources":["../../../src/components/number-input/NumberInput.tsx"],"sourcesContent":["import React, { ChangeEventHandler, FC, useEffect, useState } from 'react';\nimport Input from '../input/Input';\nimport { NUMBER_CLEAR_REGEX } from './constants/number';\nimport { formateNumber, isValidString, parseFloatWithDecimals } from './utils/number';\n\nexport type NumberInputProps = {\n /**\n * Applies rules for decimal input.\n * Enables the user to input one zero as number before the comma\n */\n isDecimalInput?: boolean;\n /**\n * Whether the input is disabled\n */\n isDisabled?: boolean;\n /**\n * Applies rules for money input.\n * Rules: only two decimal places, one zero before the comma\n */\n isMoneyInput?: boolean;\n /**\n * Limits the number to this value\n */\n maxNumber?: number;\n /**\n * Limits the number to this value\n */\n minNumber?: number;\n /**\n * Callback function that is called when the input gets out of focus\n */\n onBlur?: (newNumber: number | null, isInvalid: boolean) => void;\n /**\n * Callback function that is called when the input changes\n * It will pass the text from the input\n */\n onChange?: (newValue: string) => void;\n /**\n * Placeholder for the input field\n */\n placeholder?: string;\n /**\n * The value, that should be displayed in the input, when it is in focus.\n * You can also pass a stringified number as default value.\n * NOTE: If you pass a stringified number, it will be formatted to the selected format\n */\n value?: string;\n};\n\nconst NumberInput: FC<NumberInputProps> = (\n {\n isDecimalInput,\n isMoneyInput,\n maxNumber = Infinity,\n value,\n placeholder,\n onBlur,\n isDisabled,\n onChange,\n minNumber = -Infinity\n }) => {\n // the plainText will be shown in the input, when it is in focus\n const [plainText, setPlainText] = useState<string>('');\n // the formattedValue will be shown in the input, when it is not in focus\n const [formattedValue, setFormattedValue] = useState<string>('');\n const [hasFocus, setHasFocus] = useState<boolean>(false);\n\n const [isValueInvalid, setIsValueInvalid] = useState(false);\n const localPlaceholder = placeholder ?? (isMoneyInput ? '€' : undefined);\n\n\n const onLocalChange: ChangeEventHandler<HTMLInputElement> =\n (event) => {\n const newValue = event.target.value;\n\n const sanitizedValueString = newValue\n // Removes everything except numbers, commas and points\n .replace(NUMBER_CLEAR_REGEX, '');\n\n const valueToCheck = sanitizedValueString.replaceAll(',', '.');\n\n if (!isValidString({ string: valueToCheck, isMoneyInput, isDecimalInput })) {\n return;\n }\n\n setPlainText(sanitizedValueString.replaceAll('.', ','));\n\n if (typeof onChange === 'function') {\n onChange(sanitizedValueString.replaceAll('.', ','));\n }\n };\n\n const onLocalBlur = () => {\n const sanitizedValue = plainText.length === 0 ? '0' : plainText;\n let isInvalid = false;\n\n const parsedNumber = parseFloatWithDecimals({\n stringValue: sanitizedValue.replace(',', '.'),\n decimals: isMoneyInput ? 2 : undefined\n });\n\n if (parsedNumber !== 0 && (parsedNumber > maxNumber || parsedNumber < minNumber)) {\n isInvalid = true;\n }\n\n setIsValueInvalid(isInvalid);\n\n const newStringValue = plainText.length === 0\n ? ''\n : formateNumber({\n number: parsedNumber,\n isMoneyInput,\n });\n\n setFormattedValue(newStringValue);\n setPlainText(newStringValue.replaceAll('.', ''));\n setHasFocus(false);\n\n if (typeof onChange === 'function') {\n onChange(newStringValue.replaceAll('.', ''));\n }\n\n if (typeof onBlur === 'function') {\n onBlur(parsedNumber === 0 ? null : parsedNumber, isInvalid);\n }\n };\n\n const onLocalFocus = () => {\n // formattedValue will be a number string with german number format (e.g. 1.000,00)\n // It will remove all dots, so that the user can type in the number\n setPlainText(formattedValue.replaceAll('.', ''));\n\n // This will update the external state\n if (typeof onChange === 'function') {\n onChange(formattedValue.replaceAll('.', ''));\n }\n\n setIsValueInvalid(false);\n setHasFocus(true);\n };\n\n // updates the formattedValue, when the value changes\n useEffect(() => {\n const parsedNumber = parseFloatWithDecimals({\n stringValue: plainText.replace(',', '.'),\n decimals: isMoneyInput ? 2 : undefined\n });\n\n // checks, if a given number is invalid, if the input is not in focus\n if (!hasFocus) {\n setIsValueInvalid(parsedNumber > maxNumber || parsedNumber < minNumber);\n }\n\n setFormattedValue(plainText.length === 0\n ? ''\n : formateNumber({\n number: parsedNumber,\n isMoneyInput,\n }));\n }, [hasFocus, isMoneyInput, maxNumber, minNumber, plainText]);\n\n useEffect(() => {\n if (typeof value === 'string') {\n setPlainText(value);\n }\n }, [value]);\n\n return (\n <Input\n inputMode=\"decimal\"\n onChange={onLocalChange}\n value={hasFocus ? plainText : formattedValue}\n placeholder={localPlaceholder}\n onBlur={onLocalBlur}\n onFocus={onLocalFocus}\n isDisabled={isDisabled}\n isInvalid={isValueInvalid}\n />\n );\n};\n\nNumberInput.displayName = 'NumberInput';\n\nexport default NumberInput;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAAsF,SAAAE,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KA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E5B,SAAS,CAACgB,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;MACxCa,QAAQ,EAAEtC,YAAY,GAAG,CAAC,GAAGmB;IACjC,CAAC,CAAC;;IAEF;IACA,IAAI,CAACL,QAAQ,EAAE;MACXG,iBAAiB,CAACkB,YAAY,GAAGlC,SAAS,IAAIkC,YAAY,GAAG3B,SAAS,CAAC;IAC3E;IAEAK,iBAAiB,CAACJ,SAAS,CAACwB,MAAM,KAAK,CAAC,GAClC,EAAE,GACF,IAAAO,sBAAa,EAAC;MACZC,MAAM,EAAEN,YAAY;MACpBnC;IACJ,CAAC,CAAC,CAAC;EACX,CAAC,EAAE,CAACc,QAAQ,EAAEd,YAAY,EAAEC,SAAS,EAAEO,SAAS,EAAEC,SAAS,CAAC,CAAC;EAE7D,IAAAkC,gBAAS,EAAC,MAAM;IACZ,IAAI,OAAOxC,KAAK,KAAK,QAAQ,EAAE;MAC3BO,YAAY,CAACP,KAAK,CAAC;IACvB;EACJ,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAEX,oBACInC,MAAA,CAAAS,OAAA,CAAAmE,aAAA,CAACzE,MAAA,CAAAM,OAAK;IACFoE,SAAS,EAAC,SAAS;IACnBtC,QAAQ,EAAEa,aAAc;IACxBjB,KAAK,EAAEW,QAAQ,GAAGL,SAAS,GAAGG,cAAe;IAC7CR,WAAW,EAAEc,gBAAiB;IAC9Bb,MAAM,EAAE0B,WAAY;IACpBe,OAAO,EAAEJ,YAAa;IACtBpC,UAAU,EAAEA,UAAW;IACvB4B,SAAS,EAAElB;EAAe,CAC7B,CAAC;AAEV,CAAC;AAEDnB,WAAW,CAACkD,WAAW,GAAG,aAAa;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAxE,OAAA,GAEzBoB,WAAW"}
1
+ {"version":3,"file":"NumberInput.js","names":["_react","_interopRequireWildcard","require","_Input","_interopRequireDefault","_number","_number2","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","NumberInput","_ref","isDecimalInput","isMoneyInput","isTimeInput","maxNumber","Infinity","value","placeholder","onBlur","isDisabled","onChange","shouldShowOnlyBottomBorder","minNumber","plainText","setPlainText","useState","formattedValue","setFormattedValue","hasFocus","setHasFocus","isValueInvalid","setIsValueInvalid","localPlaceholder","undefined","onLocalChange","event","newValue","target","replaceAll","length","sanitizedValueString","replace","NUMBER_CLEAR_REGEX","valueToCheck","isValidString","string","onLocalBlur","sanitizedValue","isInvalid","parsedNumber","parseFloatWithDecimals","stringValue","decimals","newStringValue","formateNumber","number","onLocalFocus","useEffect","createElement","inputMode","onFocus","displayName","_default","exports"],"sources":["../../../src/components/number-input/NumberInput.tsx"],"sourcesContent":["import React, { ChangeEventHandler, FC, useEffect, useState } from 'react';\nimport Input from '../input/Input';\nimport { NUMBER_CLEAR_REGEX } from './constants/number';\nimport { formateNumber, isValidString, parseFloatWithDecimals } from './utils/number';\n\nexport type NumberInputProps = {\n /**\n * Applies rules for decimal input.\n * Enables the user to input one zero as number before the comma\n */\n isDecimalInput?: boolean;\n /**\n * Whether the input is disabled\n */\n isDisabled?: boolean;\n /**\n * Applies rules for money input.\n * Rules: only two decimal places, one zero before the comma\n */\n isMoneyInput?: boolean;\n /**\n * Whether the value should be formatted as a time.\n */\n isTimeInput?: boolean;\n /**\n * Limits the number to this value\n */\n maxNumber?: number;\n /**\n * Limits the number to this value\n */\n minNumber?: number;\n /**\n * Callback function that is called when the input gets out of focus\n */\n onBlur?: (newNumber: number | string | null, isInvalid: boolean) => void;\n /**\n * Callback function that is called when the input changes\n * It will pass the text from the input\n */\n onChange?: (newValue: string) => void;\n /**\n * Placeholder for the input field\n */\n placeholder?: string;\n /**\n * Whether only the bottom border should be displayed\n */\n shouldShowOnlyBottomBorder?: boolean;\n /**\n * The value, that should be displayed in the input, when it is in focus.\n * You can also pass a stringified number as default value.\n * NOTE: If you pass a stringified number, it will be formatted to the selected format\n */\n value?: string;\n};\n\nconst NumberInput: FC<NumberInputProps> = ({\n isDecimalInput,\n isMoneyInput,\n isTimeInput,\n maxNumber = Infinity,\n value,\n placeholder,\n onBlur,\n isDisabled,\n onChange,\n shouldShowOnlyBottomBorder,\n minNumber = -Infinity,\n}) => {\n // the plainText will be shown in the input, when it is in focus\n const [plainText, setPlainText] = useState<string>('');\n // the formattedValue will be shown in the input, when it is not in focus\n const [formattedValue, setFormattedValue] = useState<string>('');\n const [hasFocus, setHasFocus] = useState<boolean>(false);\n\n const [isValueInvalid, setIsValueInvalid] = useState(false);\n const localPlaceholder = placeholder ?? (isMoneyInput ? '€' : undefined);\n\n const onLocalChange: ChangeEventHandler<HTMLInputElement> = (event) => {\n const newValue = event.target.value;\n\n if (newValue.replaceAll(':', '').length > 4) {\n return;\n }\n\n const sanitizedValueString = newValue\n // Removes everything except numbers, commas and points\n .replace(NUMBER_CLEAR_REGEX, '');\n\n const valueToCheck = sanitizedValueString.replaceAll(',', '.');\n\n if (!isValidString({ string: valueToCheck, isMoneyInput, isDecimalInput, isTimeInput })) {\n return;\n }\n\n setPlainText(sanitizedValueString.replaceAll('.', ','));\n\n if (typeof onChange === 'function') {\n onChange(sanitizedValueString.replaceAll('.', ','));\n }\n };\n\n const onLocalBlur = () => {\n const sanitizedValue = plainText.length === 0 ? '0' : plainText;\n let isInvalid = false;\n let parsedNumber = null;\n\n if (!isTimeInput) {\n parsedNumber = parseFloatWithDecimals({\n stringValue: sanitizedValue.replace(',', '.').replaceAll(':', ''),\n decimals: isMoneyInput ? 2 : undefined,\n });\n\n if (parsedNumber !== 0 && (parsedNumber > maxNumber || parsedNumber < minNumber)) {\n isInvalid = true;\n }\n\n setIsValueInvalid(isInvalid);\n }\n\n const newStringValue =\n plainText.length === 0\n ? ''\n : formateNumber({\n number: isTimeInput ? sanitizedValue : parsedNumber,\n isMoneyInput,\n isTimeInput,\n });\n\n setFormattedValue(newStringValue);\n setPlainText(newStringValue.replaceAll('.', ''));\n setHasFocus(false);\n\n if (typeof onChange === 'function') {\n onChange(newStringValue.replaceAll('.', ''));\n }\n\n if (typeof onBlur === 'function') {\n if (isTimeInput) {\n onBlur(newStringValue, isInvalid);\n } else {\n onBlur(parsedNumber === 0 ? null : parsedNumber, isInvalid);\n }\n }\n };\n\n const onLocalFocus = () => {\n // formattedValue will be a number string with german number format (e.g. 1.000,00)\n // It will remove all dots, so that the user can type in the number\n setPlainText(formattedValue.replaceAll('.', ''));\n\n // This will update the external state\n if (typeof onChange === 'function') {\n onChange(formattedValue.replaceAll('.', ''));\n }\n\n setIsValueInvalid(false);\n setHasFocus(true);\n };\n\n // updates the formattedValue, when the value changes\n useEffect(() => {\n let parsedNumber = null;\n\n if (!isTimeInput) {\n parsedNumber = parseFloatWithDecimals({\n stringValue: plainText.replace(',', '.').replaceAll(':', ''),\n decimals: isMoneyInput ? 2 : undefined,\n });\n\n // checks, if a given number is invalid, if the input is not in focus\n if (!hasFocus) {\n setIsValueInvalid(parsedNumber > maxNumber || parsedNumber < minNumber);\n }\n }\n\n setFormattedValue(\n plainText.length === 0\n ? ''\n : formateNumber({\n number: isTimeInput ? plainText : parsedNumber,\n isMoneyInput,\n isTimeInput,\n }),\n );\n }, [hasFocus, isMoneyInput, isTimeInput, maxNumber, minNumber, plainText]);\n\n useEffect(() => {\n if (typeof value === 'string') {\n setPlainText(value);\n }\n }, [value]);\n\n return (\n <Input\n shouldShowOnlyBottomBorder={shouldShowOnlyBottomBorder}\n inputMode=\"decimal\"\n onChange={onLocalChange}\n value={hasFocus ? plainText : formattedValue}\n placeholder={localPlaceholder}\n onBlur={onLocalBlur}\n onFocus={onLocalFocus}\n isDisabled={isDisabled}\n isInvalid={isValueInvalid}\n />\n );\n};\n\nNumberInput.displayName = 'NumberInput';\n\nexport default NumberInput;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IA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MACZC;IACJ,CAAC,CACX,CAAC;EACL,CAAC,EAAE,CAACe,QAAQ,EAAEhB,YAAY,EAAEC,WAAW,EAAEC,SAAS,EAAEQ,SAAS,EAAEC,SAAS,CAAC,CAAC;EAE1E,IAAAkC,gBAAS,EAAC,MAAM;IACZ,IAAI,OAAOzC,KAAK,KAAK,QAAQ,EAAE;MAC3BQ,YAAY,CAACR,KAAK,CAAC;IACvB;EACJ,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAEX,oBACIpC,MAAA,CAAAS,OAAA,CAAAqE,aAAA,CAAC3E,MAAA,CAAAM,OAAK;IACFgC,0BAA0B,EAAEA,0BAA2B;IACvDsC,SAAS,EAAC,SAAS;IACnBvC,QAAQ,EAAEc,aAAc;IACxBlB,KAAK,EAAEY,QAAQ,GAAGL,SAAS,GAAGG,cAAe;IAC7CT,WAAW,EAAEe,gBAAiB;IAC9Bd,MAAM,EAAE4B,WAAY;IACpBc,OAAO,EAAEJ,YAAa;IACtBrC,UAAU,EAAEA,UAAW;IACvB6B,SAAS,EAAElB;EAAe,CAC7B,CAAC;AAEV,CAAC;AAEDrB,WAAW,CAACoD,WAAW,GAAG,aAAa;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA1E,OAAA,GAEzBoB,WAAW"}
@@ -2,3 +2,4 @@ export declare const NUMBER_CLEAR_REGEX: RegExp;
2
2
  export declare const INTEGER_TEST: RegExp;
3
3
  export declare const DECIMAL_TEST: RegExp;
4
4
  export declare const MONEY_TEST: RegExp;
5
+ export declare const TIME_TEST: RegExp;
@@ -3,9 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.NUMBER_CLEAR_REGEX = exports.MONEY_TEST = exports.INTEGER_TEST = exports.DECIMAL_TEST = void 0;
7
- const NUMBER_CLEAR_REGEX = exports.NUMBER_CLEAR_REGEX = /[^\d,.]/gi;
6
+ exports.TIME_TEST = exports.NUMBER_CLEAR_REGEX = exports.MONEY_TEST = exports.INTEGER_TEST = exports.DECIMAL_TEST = void 0;
7
+ const NUMBER_CLEAR_REGEX = exports.NUMBER_CLEAR_REGEX = /[^\d,.:]/gi;
8
8
  const INTEGER_TEST = exports.INTEGER_TEST = /^[1-9][0-9]*$/;
9
9
  const DECIMAL_TEST = exports.DECIMAL_TEST = /^(0|[1-9][0-9]*)?(\.[0-9]*)?$/;
10
10
  const MONEY_TEST = exports.MONEY_TEST = /^(0|[1-9][0-9]*)?(\.[0-9]{0,2})?$/;
11
+ const TIME_TEST = exports.TIME_TEST = /^\d{1,2}(:\d{1,2})?$/;
11
12
  //# sourceMappingURL=number.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"number.js","names":["NUMBER_CLEAR_REGEX","exports","INTEGER_TEST","DECIMAL_TEST","MONEY_TEST"],"sources":["../../../../src/components/number-input/constants/number.ts"],"sourcesContent":["export const NUMBER_CLEAR_REGEX = /[^\\d,.]/gi;\nexport const INTEGER_TEST = /^[1-9][0-9]*$/;\nexport const DECIMAL_TEST = /^(0|[1-9][0-9]*)?(\\.[0-9]*)?$/;\nexport const MONEY_TEST = /^(0|[1-9][0-9]*)?(\\.[0-9]{0,2})?$/;\n"],"mappings":";;;;;;AAAO,MAAMA,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,WAAW;AACtC,MAAME,YAAY,GAAAD,OAAA,CAAAC,YAAA,GAAG,eAAe;AACpC,MAAMC,YAAY,GAAAF,OAAA,CAAAE,YAAA,GAAG,+BAA+B;AACpD,MAAMC,UAAU,GAAAH,OAAA,CAAAG,UAAA,GAAG,mCAAmC"}
1
+ {"version":3,"file":"number.js","names":["NUMBER_CLEAR_REGEX","exports","INTEGER_TEST","DECIMAL_TEST","MONEY_TEST","TIME_TEST"],"sources":["../../../../src/components/number-input/constants/number.ts"],"sourcesContent":["export const NUMBER_CLEAR_REGEX = /[^\\d,.:]/gi;\nexport const INTEGER_TEST = /^[1-9][0-9]*$/;\nexport const DECIMAL_TEST = /^(0|[1-9][0-9]*)?(\\.[0-9]*)?$/;\nexport const MONEY_TEST = /^(0|[1-9][0-9]*)?(\\.[0-9]{0,2})?$/;\nexport const TIME_TEST = /^\\d{1,2}(:\\d{1,2})?$/;\n"],"mappings":";;;;;;AAAO,MAAMA,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,YAAY;AACvC,MAAME,YAAY,GAAAD,OAAA,CAAAC,YAAA,GAAG,eAAe;AACpC,MAAMC,YAAY,GAAAF,OAAA,CAAAE,YAAA,GAAG,+BAA+B;AACpD,MAAMC,UAAU,GAAAH,OAAA,CAAAG,UAAA,GAAG,mCAAmC;AACtD,MAAMC,SAAS,GAAAJ,OAAA,CAAAI,SAAA,GAAG,sBAAsB"}
@@ -6,15 +6,17 @@ interface ParseFloatWithDecimals {
6
6
  }
7
7
  export declare const parseFloatWithDecimals: ParseFloatWithDecimals;
8
8
  interface FormateNumberOptions {
9
- number: number | null;
9
+ number: number | string | null;
10
10
  isMoneyInput?: boolean;
11
+ isTimeInput?: boolean;
11
12
  }
12
- export declare const formateNumber: ({ number, isMoneyInput }: FormateNumberOptions) => string;
13
+ export declare const formateNumber: ({ number, isMoneyInput, isTimeInput }: FormateNumberOptions) => string;
13
14
  interface IsValidString {
14
15
  (config: {
15
16
  string: string;
16
17
  isDecimalInput?: boolean;
17
18
  isMoneyInput?: boolean;
19
+ isTimeInput?: boolean;
18
20
  }): boolean;
19
21
  }
20
22
  export declare const isValidString: IsValidString;
@@ -20,8 +20,32 @@ exports.parseFloatWithDecimals = parseFloatWithDecimals;
20
20
  const formateNumber = _ref2 => {
21
21
  let {
22
22
  number,
23
- isMoneyInput
23
+ isMoneyInput,
24
+ isTimeInput
24
25
  } = _ref2;
26
+ if (isTimeInput && typeof number === 'string') {
27
+ let hours = 0;
28
+ let minutes = 0;
29
+ const firstTwoNumbers = Number(number.substring(0, 2));
30
+ let lastTwoNumbers = 0;
31
+ let lastTwoNumbersLength = 0;
32
+ if (number.includes(':')) {
33
+ lastTwoNumbers = Number(number.substring(3, 5));
34
+ lastTwoNumbersLength = number.substring(3, 5).length;
35
+ } else {
36
+ lastTwoNumbers = Number(number.substring(2, 4));
37
+ lastTwoNumbersLength = number.substring(2, 4).length;
38
+ }
39
+ hours = firstTwoNumbers > 23 ? 23 : firstTwoNumbers;
40
+ if (lastTwoNumbers < 7 && lastTwoNumbersLength === 1) {
41
+ minutes = lastTwoNumbers * 10;
42
+ } else {
43
+ minutes = lastTwoNumbers > 59 ? 59 : lastTwoNumbers;
44
+ }
45
+ const hoursStr = hours < 10 ? `0${hours}` : `${hours}`;
46
+ const minutesStr = minutes < 10 ? `0${minutes}` : `${minutes}`;
47
+ return `${hoursStr}:${minutesStr}`;
48
+ }
25
49
  if (typeof number !== 'number') {
26
50
  return '';
27
51
  }
@@ -37,6 +61,7 @@ const isValidString = _ref3 => {
37
61
  let {
38
62
  isDecimalInput,
39
63
  isMoneyInput,
64
+ isTimeInput,
40
65
  string
41
66
  } = _ref3;
42
67
  let isValid = false;
@@ -50,9 +75,12 @@ const isValidString = _ref3 => {
50
75
  if (isMoneyInput && _number.MONEY_TEST.test(string)) {
51
76
  isValid = true;
52
77
  }
78
+ if (isTimeInput && _number.TIME_TEST) {
79
+ isValid = true;
80
+ }
53
81
 
54
82
  // Allows numbers but excludes numbers with leading 0
55
- if (!isDecimalInput && !isMoneyInput && _number.INTEGER_TEST.test(string)) {
83
+ if (!isDecimalInput && !isMoneyInput && !isTimeInput && _number.INTEGER_TEST.test(string)) {
56
84
  isValid = true;
57
85
  }
58
86
  if (string.length === 0) {