@chayns-components/core 5.0.0-beta.453 → 5.0.0-beta.456

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.
@@ -1,9 +1,10 @@
1
1
  import clsx from 'clsx';
2
2
  import { AnimatePresence } from 'framer-motion';
3
3
  import React from 'react';
4
+ import { useTheme } from 'styled-components';
4
5
  import Icon from '../icon/Icon';
5
6
  import SmallWaitCursor, { SmallWaitCursorSize } from '../small-wait-cursor/SmallWaitCursor';
6
- import { StyledButton, StyledIconWrapper, StyledMotionChildrenWrapper, StyledMotionWaitCursorWrapper } from './Button.styles';
7
+ import { StyledIconWrapper, StyledMotionButton, StyledMotionChildrenWrapper, StyledMotionWaitCursorWrapper } from './Button.styles';
7
8
  const Button = _ref => {
8
9
  let {
9
10
  children,
@@ -22,14 +23,21 @@ const Button = _ref => {
22
23
  onClick(event);
23
24
  };
24
25
  const buttonClasses = clsx('beta-chayns-button ellipsis', className);
25
- return /*#__PURE__*/React.createElement(StyledButton, {
26
+ const theme = useTheme();
27
+ return /*#__PURE__*/React.createElement(StyledMotionButton, {
26
28
  className: buttonClasses,
27
29
  disabled: isDisabled,
28
30
  isDisabled: isDisabled,
29
31
  hasChildren: !!children,
30
32
  hasIcon: typeof icon === 'string' && icon !== '',
31
33
  isSecondary: isSecondary,
32
- onClick: handleClick
34
+ onClick: handleClick,
35
+ whileTap: isDisabled ? {} : {
36
+ backgroundColor: isSecondary ? theme['201'] : theme['407']
37
+ },
38
+ whileHover: isDisabled ? {} : {
39
+ backgroundColor: isSecondary ? theme['203'] : theme['409']
40
+ }
33
41
  }, /*#__PURE__*/React.createElement(AnimatePresence, {
34
42
  initial: false
35
43
  }, icon && /*#__PURE__*/React.createElement(StyledIconWrapper, null, /*#__PURE__*/React.createElement(Icon, {
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","names":["clsx","AnimatePresence","React","Icon","SmallWaitCursor","SmallWaitCursorSize","StyledButton","StyledIconWrapper","StyledMotionChildrenWrapper","StyledMotionWaitCursorWrapper","Button","_ref","children","className","icon","isDisabled","isSecondary","onClick","shouldShowWaitCursor","shouldStopPropagation","handleClick","event","stopPropagation","buttonClasses","createElement","disabled","hasChildren","hasIcon","initial","color","icons","animate","opacity","width","exit","key","style","overflow","transition","duration","shouldHideBackground","size","Small","displayName"],"sources":["../../../src/components/button/Button.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport { AnimatePresence } from 'framer-motion';\nimport React, { FC, MouseEventHandler, ReactNode } from 'react';\nimport Icon from '../icon/Icon';\nimport SmallWaitCursor, { SmallWaitCursorSize } from '../small-wait-cursor/SmallWaitCursor';\nimport {\n StyledButton,\n StyledIconWrapper,\n StyledMotionChildrenWrapper,\n StyledMotionWaitCursorWrapper,\n} from './Button.styles';\n\nexport type ButtonProps = {\n /**\n * The label of the button\n */\n children?: ReactNode;\n /**\n * Additional class names for the button element\n */\n className?: string;\n /**\n * An icon that is displayed on the left-hand side of the button text\n */\n icon?: string;\n /**\n * Disables the button so that it cannot be clicked anymore\n */\n isDisabled?: boolean;\n /**\n * Displays the button in the secondary style\n */\n isSecondary?: boolean;\n /**\n * Function to be executed when the button is clicked\n */\n onClick: MouseEventHandler<HTMLButtonElement>;\n /**\n * Shows a wait cursor instead of button text\n */\n shouldShowWaitCursor?: boolean;\n /**\n * Stops event propagation on click\n */\n shouldStopPropagation?: boolean;\n};\n\nconst Button: FC<ButtonProps> = ({\n children,\n className,\n icon,\n isDisabled,\n isSecondary,\n onClick,\n shouldShowWaitCursor,\n shouldStopPropagation,\n}) => {\n const handleClick: MouseEventHandler<HTMLButtonElement> = (event) => {\n if (shouldStopPropagation) {\n event.stopPropagation();\n }\n\n onClick(event);\n };\n\n const buttonClasses = clsx('beta-chayns-button ellipsis', className);\n\n return (\n <StyledButton\n className={buttonClasses}\n disabled={isDisabled}\n isDisabled={isDisabled}\n hasChildren={!!children}\n hasIcon={typeof icon === 'string' && icon !== ''}\n isSecondary={isSecondary}\n onClick={handleClick}\n >\n <AnimatePresence initial={false}>\n {icon && (\n <StyledIconWrapper>\n <Icon color=\"white\" icons={[icon]} />\n </StyledIconWrapper>\n )}\n {shouldShowWaitCursor && (\n <StyledMotionWaitCursorWrapper\n animate={{ opacity: 1, width: 40 }}\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n key=\"wait-cursor\"\n style={{ overflow: 'hidden' }}\n transition={{ duration: 0.2 }}\n >\n <SmallWaitCursor\n color=\"white\"\n shouldHideBackground\n size={SmallWaitCursorSize.Small}\n />\n </StyledMotionWaitCursorWrapper>\n )}\n {!shouldShowWaitCursor && children && (\n <StyledMotionChildrenWrapper\n animate={{ opacity: 1, width: 'auto' }}\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n key=\"children\"\n style={{ overflow: 'hidden' }}\n transition={{ duration: 0.2 }}\n >\n {children}\n </StyledMotionChildrenWrapper>\n )}\n </AnimatePresence>\n </StyledButton>\n );\n};\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,MAAM;AACvB,SAASC,eAAe,QAAQ,eAAe;AAC/C,OAAOC,KAAK,MAA4C,OAAO;AAC/D,OAAOC,IAAI,MAAM,cAAc;AAC/B,OAAOC,eAAe,IAAIC,mBAAmB,QAAQ,sCAAsC;AAC3F,SACIC,YAAY,EACZC,iBAAiB,EACjBC,2BAA2B,EAC3BC,6BAA6B,QAC1B,iBAAiB;AAqCxB,MAAMC,MAAuB,GAAGC,IAAA,IAS1B;EAAA,IAT2B;IAC7BC,QAAQ;IACRC,SAAS;IACTC,IAAI;IACJC,UAAU;IACVC,WAAW;IACXC,OAAO;IACPC,oBAAoB;IACpBC;EACJ,CAAC,GAAAR,IAAA;EACG,MAAMS,WAAiD,GAAIC,KAAK,IAAK;IACjE,IAAIF,qBAAqB,EAAE;MACvBE,KAAK,CAACC,eAAe,CAAC,CAAC;IAC3B;IAEAL,OAAO,CAACI,KA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AC9BV,KAAA,CAAAsB,aAAA,CAAChB,2BAA2B;IACxBuB,OAAO,EAAE;MAAEC,OAAO,EAAE,CAAC;MAAEC,KAAK,EAAE;IAAO,CAAE;IACvCC,IAAI,EAAE;MAAEF,OAAO,EAAE,CAAC;MAAEC,KAAK,EAAE;IAAE,CAAE;IAC/BL,OAAO,EAAE;MAAEI,OAAO,EAAE,CAAC;MAAEC,KAAK,EAAE;IAAE,CAAE;IAClCE,GAAG,EAAC,UAAU;IACdC,KAAK,EAAE;MAAEC,QAAQ,EAAE;IAAS,CAAE;IAC9BC,UAAU,EAAE;MAAEC,QAAQ,EAAE;IAAI;EAAE,GAE7B3B,QACwB,CAEpB,CACP,CAAC;AAEvB,CAAC;AAEDF,MAAM,CAACiC,WAAW,GAAG,QAAQ;AAE7B,eAAejC,MAAM"}
1
+ {"version":3,"file":"Button.js","names":["clsx","AnimatePresence","React","useTheme","Icon","SmallWaitCursor","SmallWaitCursorSize","StyledIconWrapper","StyledMotionButton","StyledMotionChildrenWrapper","StyledMotionWaitCursorWrapper","Button","_ref","children","className","icon","isDisabled","isSecondary","onClick","shouldShowWaitCursor","shouldStopPropagation","handleClick","event","stopPropagation","buttonClasses","theme","createElement","disabled","hasChildren","hasIcon","whileTap","backgroundColor","whileHover","initial","color","icons","animate","opacity","width","exit","key","style","overflow","transition","duration","shouldHideBackground","size","Small","displayName"],"sources":["../../../src/components/button/Button.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport { AnimatePresence } from 'framer-motion';\nimport React, { FC, MouseEventHandler, ReactNode } from 'react';\nimport { useTheme } from 'styled-components';\nimport type { Theme } from '../color-scheme-provider/ColorSchemeProvider';\nimport Icon from '../icon/Icon';\nimport SmallWaitCursor, { SmallWaitCursorSize } from '../small-wait-cursor/SmallWaitCursor';\nimport {\n StyledIconWrapper,\n StyledMotionButton,\n StyledMotionChildrenWrapper,\n StyledMotionWaitCursorWrapper,\n} from './Button.styles';\n\nexport type ButtonProps = {\n /**\n * The label of the button\n */\n children?: ReactNode;\n /**\n * Additional class names for the button element\n */\n className?: string;\n /**\n * An icon that is displayed on the left-hand side of the button text\n */\n icon?: string;\n /**\n * Disables the button so that it cannot be clicked anymore\n */\n isDisabled?: boolean;\n /**\n * Displays the button in the secondary style\n */\n isSecondary?: boolean;\n /**\n * Function to be executed when the button is clicked\n */\n onClick: MouseEventHandler<HTMLButtonElement>;\n /**\n * Shows a wait cursor instead of button text\n */\n shouldShowWaitCursor?: boolean;\n /**\n * Stops event propagation on click\n */\n shouldStopPropagation?: boolean;\n};\n\nconst Button: FC<ButtonProps> = ({\n children,\n className,\n icon,\n isDisabled,\n isSecondary,\n onClick,\n shouldShowWaitCursor,\n shouldStopPropagation,\n}) => {\n const handleClick: MouseEventHandler<HTMLButtonElement> = (event) => {\n if (shouldStopPropagation) {\n event.stopPropagation();\n }\n\n onClick(event);\n };\n\n const buttonClasses = clsx('beta-chayns-button ellipsis', className);\n\n const theme: Theme = useTheme();\n\n return (\n <StyledMotionButton\n className={buttonClasses}\n disabled={isDisabled}\n isDisabled={isDisabled}\n hasChildren={!!children}\n hasIcon={typeof icon === 'string' && icon !== ''}\n isSecondary={isSecondary}\n onClick={handleClick}\n whileTap={\n isDisabled ? {} : { backgroundColor: isSecondary ? theme['201'] : theme['407'] }\n }\n whileHover={\n isDisabled ? {} : { backgroundColor: isSecondary ? theme['203'] : theme['409'] }\n }\n >\n <AnimatePresence initial={false}>\n {icon && (\n <StyledIconWrapper>\n <Icon color=\"white\" icons={[icon]} />\n </StyledIconWrapper>\n )}\n {shouldShowWaitCursor && (\n <StyledMotionWaitCursorWrapper\n animate={{ opacity: 1, width: 40 }}\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n key=\"wait-cursor\"\n style={{ overflow: 'hidden' }}\n transition={{ duration: 0.2 }}\n >\n <SmallWaitCursor\n color=\"white\"\n shouldHideBackground\n size={SmallWaitCursorSize.Small}\n />\n </StyledMotionWaitCursorWrapper>\n )}\n {!shouldShowWaitCursor && children && (\n <StyledMotionChildrenWrapper\n animate={{ opacity: 1, width: 'auto' }}\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n key=\"children\"\n style={{ overflow: 'hidden' }}\n transition={{ duration: 0.2 }}\n >\n {children}\n </StyledMotionChildrenWrapper>\n )}\n </AnimatePresence>\n </StyledMotionButton>\n );\n};\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,MAAM;AACvB,SAASC,eAAe,QAAQ,eAAe;AAC/C,OAAOC,KAAK,MAA4C,OAAO;AAC/D,SAASC,QAAQ,QAAQ,mBAAmB;AAE5C,OAAOC,IAAI,MAAM,cAAc;AAC/B,OAAOC,eAAe,IAAIC,mBAAmB,QAAQ,sCAAsC;AAC3F,SACIC,iBAAiB,EACjBC,kBAAkB,EAClBC,2BAA2B,EAC3BC,6BAA6B,QAC1B,iBAAiB;AAqCxB,MAAMC,MAAuB,GAAGC,IAAA,IAS1B;EAAA,IAT2B;IAC7BC,QAAQ;IACRC,SAAS;IACTC,IAAI;IACJC,UAAU;IACVC,WAAW;IACXC,OAAO;IACPC,oBAAoB;IACpBC;EACJ,CAAC,GAAAR,IAAA;EACG,MAAMS,WAAiD,GAAIC,KAAK,IAAK;IACjE,IAAIF,qBAAqB,EAAE;MACvBE,KAAK,CAACC,eAAe,CAAC,CAAC;IAC3B;IAEAL,OAAO,CAACI,KAAK,CAAC;EAClB,CAAC;EAED,MAAME,aAAa,GAAGxB,IAAI,CAAC,6BAA6B,EAAEc,SAAS,CAAC;EAEpE,MAAMW,KAAY,GAAGtB,QAAQ,CAAC,CAAC;EAE/B,oBACID,KAAA,CAAAwB,aAAA,CAAClB,kBAAkB;IACfM,SAAS,EAAEU,aAAc;IACzBG,QAAQ,EAAEX,UAAW;IACrBA,UAAU,EAAEA,UAAW;IACvBY,WAAW,EAAE,CAAC,CAACf,QAAS;IACxBgB,OAAO,EAAE,OAAOd,IAAI,KA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Q,iBAC9BX,KAAA,CAAAwB,aAAA,CAACjB,2BAA2B;IACxB2B,OAAO,EAAE;MAAEC,OAAO,EAAE,CAAC;MAAEC,KAAK,EAAE;IAAO,CAAE;IACvCC,IAAI,EAAE;MAAEF,OAAO,EAAE,CAAC;MAAEC,KAAK,EAAE;IAAE,CAAE;IAC/BL,OAAO,EAAE;MAAEI,OAAO,EAAE,CAAC;MAAEC,KAAK,EAAE;IAAE,CAAE;IAClCE,GAAG,EAAC,UAAU;IACdC,KAAK,EAAE;MAAEC,QAAQ,EAAE;IAAS,CAAE;IAC9BC,UAAU,EAAE;MAAEC,QAAQ,EAAE;IAAI;EAAE,GAE7B/B,QACwB,CAEpB,CACD,CAAC;AAE7B,CAAC;AAEDF,MAAM,CAACqC,WAAW,GAAG,QAAQ;AAE7B,eAAerC,MAAM"}
@@ -7,7 +7,279 @@ type StyledButtonProps = ButtonProps & WithTheme<{
7
7
  hasChildren: boolean;
8
8
  isDisabled?: boolean;
9
9
  }>;
10
- export declare const StyledButton: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, StyledButtonProps>>;
10
+ export declare const StyledMotionButton: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<{
11
+ form?: string | undefined;
12
+ slot?: string | undefined;
13
+ title?: string | undefined;
14
+ value?: string | number | readonly string[] | undefined;
15
+ onScroll?: import("react").UIEventHandler<HTMLButtonElement> | undefined;
16
+ defaultChecked?: boolean | undefined;
17
+ defaultValue?: string | number | readonly string[] | undefined;
18
+ suppressContentEditableWarning?: boolean | undefined;
19
+ suppressHydrationWarning?: boolean | undefined;
20
+ accessKey?: string | undefined;
21
+ autoFocus?: boolean | undefined;
22
+ className?: string | undefined;
23
+ contentEditable?: "inherit" | (boolean | "true" | "false") | "plaintext-only" | undefined;
24
+ contextMenu?: string | undefined;
25
+ dir?: string | undefined;
26
+ draggable?: (boolean | "true" | "false") | undefined;
27
+ hidden?: boolean | undefined;
28
+ id?: string | undefined;
29
+ lang?: string | undefined;
30
+ nonce?: string | undefined;
31
+ spellCheck?: (boolean | "true" | "false") | undefined;
32
+ tabIndex?: number | undefined;
33
+ translate?: "yes" | "no" | undefined;
34
+ radioGroup?: string | undefined;
35
+ role?: import("react").AriaRole | undefined;
36
+ about?: string | undefined;
37
+ content?: string | undefined;
38
+ datatype?: string | undefined;
39
+ inlist?: any;
40
+ prefix?: string | undefined;
41
+ property?: string | undefined;
42
+ rel?: string | undefined;
43
+ resource?: string | undefined;
44
+ rev?: string | undefined;
45
+ typeof?: string | undefined;
46
+ vocab?: string | undefined;
47
+ autoCapitalize?: string | undefined;
48
+ autoCorrect?: string | undefined;
49
+ autoSave?: string | undefined;
50
+ color?: string | undefined;
51
+ itemProp?: string | undefined;
52
+ itemScope?: boolean | undefined;
53
+ itemType?: string | undefined;
54
+ itemID?: string | undefined;
55
+ itemRef?: string | undefined;
56
+ results?: number | undefined;
57
+ security?: string | undefined;
58
+ unselectable?: "on" | "off" | undefined;
59
+ inputMode?: "search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined;
60
+ is?: string | undefined;
61
+ "aria-activedescendant"?: string | undefined;
62
+ "aria-atomic"?: (boolean | "true" | "false") | undefined;
63
+ "aria-autocomplete"?: "list" | "none" | "both" | "inline" | undefined;
64
+ "aria-braillelabel"?: string | undefined;
65
+ "aria-brailleroledescription"?: string | undefined;
66
+ "aria-busy"?: (boolean | "true" | "false") | undefined;
67
+ "aria-checked"?: boolean | "true" | "false" | "mixed" | undefined;
68
+ "aria-colcount"?: number | undefined;
69
+ "aria-colindex"?: number | undefined;
70
+ "aria-colindextext"?: string | undefined;
71
+ "aria-colspan"?: number | undefined;
72
+ "aria-controls"?: string | undefined;
73
+ "aria-current"?: boolean | "time" | "true" | "false" | "page" | "step" | "location" | "date" | undefined;
74
+ "aria-describedby"?: string | undefined;
75
+ "aria-description"?: string | undefined;
76
+ "aria-details"?: string | undefined;
77
+ "aria-disabled"?: (boolean | "true" | "false") | undefined;
78
+ "aria-dropeffect"?: "link" | "none" | "copy" | "move" | "execute" | "popup" | undefined;
79
+ "aria-errormessage"?: string | undefined;
80
+ "aria-expanded"?: (boolean | "true" | "false") | undefined;
81
+ "aria-flowto"?: string | undefined;
82
+ "aria-grabbed"?: (boolean | "true" | "false") | undefined;
83
+ "aria-haspopup"?: boolean | "dialog" | "menu" | "true" | "false" | "grid" | "listbox" | "tree" | undefined;
84
+ "aria-hidden"?: (boolean | "true" | "false") | undefined;
85
+ "aria-invalid"?: boolean | "true" | "false" | "grammar" | "spelling" | undefined;
86
+ "aria-keyshortcuts"?: string | undefined;
87
+ "aria-label"?: string | undefined;
88
+ "aria-labelledby"?: string | undefined;
89
+ "aria-level"?: number | undefined;
90
+ "aria-live"?: "off" | "assertive" | "polite" | undefined;
91
+ "aria-modal"?: (boolean | "true" | "false") | undefined;
92
+ "aria-multiline"?: (boolean | "true" | "false") | undefined;
93
+ "aria-multiselectable"?: (boolean | "true" | "false") | undefined;
94
+ "aria-orientation"?: "horizontal" | "vertical" | undefined;
95
+ "aria-owns"?: string | undefined;
96
+ "aria-placeholder"?: string | undefined;
97
+ "aria-posinset"?: number | undefined;
98
+ "aria-pressed"?: boolean | "true" | "false" | "mixed" | undefined;
99
+ "aria-readonly"?: (boolean | "true" | "false") | undefined;
100
+ "aria-relevant"?: "text" | "all" | "additions" | "additions removals" | "additions text" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals" | undefined;
101
+ "aria-required"?: (boolean | "true" | "false") | undefined;
102
+ "aria-roledescription"?: string | undefined;
103
+ "aria-rowcount"?: number | undefined;
104
+ "aria-rowindex"?: number | undefined;
105
+ "aria-rowindextext"?: string | undefined;
106
+ "aria-rowspan"?: number | undefined;
107
+ "aria-selected"?: (boolean | "true" | "false") | undefined;
108
+ "aria-setsize"?: number | undefined;
109
+ "aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
110
+ "aria-valuemax"?: number | undefined;
111
+ "aria-valuemin"?: number | undefined;
112
+ "aria-valuenow"?: number | undefined;
113
+ "aria-valuetext"?: string | undefined;
114
+ dangerouslySetInnerHTML?: {
115
+ __html: string | TrustedHTML;
116
+ } | undefined;
117
+ onCopy?: import("react").ClipboardEventHandler<HTMLButtonElement> | undefined;
118
+ onCopyCapture?: import("react").ClipboardEventHandler<HTMLButtonElement> | undefined;
119
+ onCut?: import("react").ClipboardEventHandler<HTMLButtonElement> | undefined;
120
+ onCutCapture?: import("react").ClipboardEventHandler<HTMLButtonElement> | undefined;
121
+ onPaste?: import("react").ClipboardEventHandler<HTMLButtonElement> | undefined;
122
+ onPasteCapture?: import("react").ClipboardEventHandler<HTMLButtonElement> | undefined;
123
+ onCompositionEnd?: import("react").CompositionEventHandler<HTMLButtonElement> | undefined;
124
+ onCompositionEndCapture?: import("react").CompositionEventHandler<HTMLButtonElement> | undefined;
125
+ onCompositionStart?: import("react").CompositionEventHandler<HTMLButtonElement> | undefined;
126
+ onCompositionStartCapture?: import("react").CompositionEventHandler<HTMLButtonElement> | undefined;
127
+ onCompositionUpdate?: import("react").CompositionEventHandler<HTMLButtonElement> | undefined;
128
+ onCompositionUpdateCapture?: import("react").CompositionEventHandler<HTMLButtonElement> | undefined;
129
+ onFocus?: import("react").FocusEventHandler<HTMLButtonElement> | undefined;
130
+ onFocusCapture?: import("react").FocusEventHandler<HTMLButtonElement> | undefined;
131
+ onBlur?: import("react").FocusEventHandler<HTMLButtonElement> | undefined;
132
+ onBlurCapture?: import("react").FocusEventHandler<HTMLButtonElement> | undefined;
133
+ onChange?: import("react").FormEventHandler<HTMLButtonElement> | undefined;
134
+ onChangeCapture?: import("react").FormEventHandler<HTMLButtonElement> | undefined;
135
+ onBeforeInput?: import("react").FormEventHandler<HTMLButtonElement> | undefined;
136
+ onBeforeInputCapture?: import("react").FormEventHandler<HTMLButtonElement> | undefined;
137
+ onInput?: import("react").FormEventHandler<HTMLButtonElement> | undefined;
138
+ onInputCapture?: import("react").FormEventHandler<HTMLButtonElement> | undefined;
139
+ onReset?: import("react").FormEventHandler<HTMLButtonElement> | undefined;
140
+ onResetCapture?: import("react").FormEventHandler<HTMLButtonElement> | undefined;
141
+ onSubmit?: import("react").FormEventHandler<HTMLButtonElement> | undefined;
142
+ onSubmitCapture?: import("react").FormEventHandler<HTMLButtonElement> | undefined;
143
+ onInvalid?: import("react").FormEventHandler<HTMLButtonElement> | undefined;
144
+ onInvalidCapture?: import("react").FormEventHandler<HTMLButtonElement> | undefined;
145
+ onLoad?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
146
+ onLoadCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
147
+ onError?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
148
+ onErrorCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
149
+ onKeyDown?: import("react").KeyboardEventHandler<HTMLButtonElement> | undefined;
150
+ onKeyDownCapture?: import("react").KeyboardEventHandler<HTMLButtonElement> | undefined;
151
+ onKeyPress?: import("react").KeyboardEventHandler<HTMLButtonElement> | undefined;
152
+ onKeyPressCapture?: import("react").KeyboardEventHandler<HTMLButtonElement> | undefined;
153
+ onKeyUp?: import("react").KeyboardEventHandler<HTMLButtonElement> | undefined;
154
+ onKeyUpCapture?: import("react").KeyboardEventHandler<HTMLButtonElement> | undefined;
155
+ onAbort?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
156
+ onAbortCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
157
+ onCanPlay?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
158
+ onCanPlayCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
159
+ onCanPlayThrough?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
160
+ onCanPlayThroughCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
161
+ onDurationChange?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
162
+ onDurationChangeCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
163
+ onEmptied?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
164
+ onEmptiedCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
165
+ onEncrypted?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
166
+ onEncryptedCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
167
+ onEnded?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
168
+ onEndedCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
169
+ onLoadedData?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
170
+ onLoadedDataCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
171
+ onLoadedMetadata?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
172
+ onLoadedMetadataCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
173
+ onLoadStart?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
174
+ onLoadStartCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
175
+ onPause?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
176
+ onPauseCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
177
+ onPlay?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
178
+ onPlayCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
179
+ onPlaying?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
180
+ onPlayingCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
181
+ onProgress?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
182
+ onProgressCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
183
+ onRateChange?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
184
+ onRateChangeCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
185
+ onResize?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
186
+ onResizeCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
187
+ onSeeked?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
188
+ onSeekedCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
189
+ onSeeking?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
190
+ onSeekingCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
191
+ onStalled?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
192
+ onStalledCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
193
+ onSuspend?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
194
+ onSuspendCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
195
+ onTimeUpdate?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
196
+ onTimeUpdateCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
197
+ onVolumeChange?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
198
+ onVolumeChangeCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
199
+ onWaiting?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
200
+ onWaitingCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
201
+ onAuxClick?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
202
+ onAuxClickCapture?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
203
+ onClick?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
204
+ onClickCapture?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
205
+ onContextMenu?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
206
+ onContextMenuCapture?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
207
+ onDoubleClick?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
208
+ onDoubleClickCapture?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
209
+ onDragCapture?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
210
+ onDragEndCapture?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
211
+ onDragEnter?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
212
+ onDragEnterCapture?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
213
+ onDragExit?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
214
+ onDragExitCapture?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
215
+ onDragLeave?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
216
+ onDragLeaveCapture?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
217
+ onDragOver?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
218
+ onDragOverCapture?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
219
+ onDragStartCapture?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
220
+ onDrop?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
221
+ onDropCapture?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
222
+ onMouseDown?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
223
+ onMouseDownCapture?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
224
+ onMouseEnter?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
225
+ onMouseLeave?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
226
+ onMouseMove?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
227
+ onMouseMoveCapture?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
228
+ onMouseOut?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
229
+ onMouseOutCapture?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
230
+ onMouseOver?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
231
+ onMouseOverCapture?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
232
+ onMouseUp?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
233
+ onMouseUpCapture?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
234
+ onSelect?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
235
+ onSelectCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
236
+ onTouchCancel?: import("react").TouchEventHandler<HTMLButtonElement> | undefined;
237
+ onTouchCancelCapture?: import("react").TouchEventHandler<HTMLButtonElement> | undefined;
238
+ onTouchEnd?: import("react").TouchEventHandler<HTMLButtonElement> | undefined;
239
+ onTouchEndCapture?: import("react").TouchEventHandler<HTMLButtonElement> | undefined;
240
+ onTouchMove?: import("react").TouchEventHandler<HTMLButtonElement> | undefined;
241
+ onTouchMoveCapture?: import("react").TouchEventHandler<HTMLButtonElement> | undefined;
242
+ onTouchStart?: import("react").TouchEventHandler<HTMLButtonElement> | undefined;
243
+ onTouchStartCapture?: import("react").TouchEventHandler<HTMLButtonElement> | undefined;
244
+ onPointerDown?: import("react").PointerEventHandler<HTMLButtonElement> | undefined;
245
+ onPointerDownCapture?: import("react").PointerEventHandler<HTMLButtonElement> | undefined;
246
+ onPointerMove?: import("react").PointerEventHandler<HTMLButtonElement> | undefined;
247
+ onPointerMoveCapture?: import("react").PointerEventHandler<HTMLButtonElement> | undefined;
248
+ onPointerUp?: import("react").PointerEventHandler<HTMLButtonElement> | undefined;
249
+ onPointerUpCapture?: import("react").PointerEventHandler<HTMLButtonElement> | undefined;
250
+ onPointerCancel?: import("react").PointerEventHandler<HTMLButtonElement> | undefined;
251
+ onPointerCancelCapture?: import("react").PointerEventHandler<HTMLButtonElement> | undefined;
252
+ onPointerEnter?: import("react").PointerEventHandler<HTMLButtonElement> | undefined;
253
+ onPointerEnterCapture?: import("react").PointerEventHandler<HTMLButtonElement> | undefined;
254
+ onPointerLeave?: import("react").PointerEventHandler<HTMLButtonElement> | undefined;
255
+ onPointerLeaveCapture?: import("react").PointerEventHandler<HTMLButtonElement> | undefined;
256
+ onPointerOver?: import("react").PointerEventHandler<HTMLButtonElement> | undefined;
257
+ onPointerOverCapture?: import("react").PointerEventHandler<HTMLButtonElement> | undefined;
258
+ onPointerOut?: import("react").PointerEventHandler<HTMLButtonElement> | undefined;
259
+ onPointerOutCapture?: import("react").PointerEventHandler<HTMLButtonElement> | undefined;
260
+ onGotPointerCapture?: import("react").PointerEventHandler<HTMLButtonElement> | undefined;
261
+ onGotPointerCaptureCapture?: import("react").PointerEventHandler<HTMLButtonElement> | undefined;
262
+ onLostPointerCapture?: import("react").PointerEventHandler<HTMLButtonElement> | undefined;
263
+ onLostPointerCaptureCapture?: import("react").PointerEventHandler<HTMLButtonElement> | undefined;
264
+ onScrollCapture?: import("react").UIEventHandler<HTMLButtonElement> | undefined;
265
+ onWheel?: import("react").WheelEventHandler<HTMLButtonElement> | undefined;
266
+ onWheelCapture?: import("react").WheelEventHandler<HTMLButtonElement> | undefined;
267
+ onAnimationStartCapture?: import("react").AnimationEventHandler<HTMLButtonElement> | undefined;
268
+ onAnimationEnd?: import("react").AnimationEventHandler<HTMLButtonElement> | undefined;
269
+ onAnimationEndCapture?: import("react").AnimationEventHandler<HTMLButtonElement> | undefined;
270
+ onAnimationIteration?: import("react").AnimationEventHandler<HTMLButtonElement> | undefined;
271
+ onAnimationIterationCapture?: import("react").AnimationEventHandler<HTMLButtonElement> | undefined;
272
+ onTransitionEnd?: import("react").TransitionEventHandler<HTMLButtonElement> | undefined;
273
+ onTransitionEndCapture?: import("react").TransitionEventHandler<HTMLButtonElement> | undefined;
274
+ disabled?: boolean | undefined;
275
+ name?: string | undefined;
276
+ type?: "button" | "reset" | "submit" | undefined;
277
+ formAction?: string | undefined;
278
+ formEncType?: string | undefined;
279
+ formMethod?: string | undefined;
280
+ formNoValidate?: boolean | undefined;
281
+ formTarget?: string | undefined;
282
+ } & import("framer-motion").MotionProps & import("react").RefAttributes<HTMLButtonElement>, StyledButtonProps>> & Omit<import("framer-motion").ForwardRefComponent<HTMLButtonElement, import("framer-motion").HTMLMotionProps<"button">>, keyof import("react").Component<any, {}, any>>;
11
283
  export declare const StyledIconWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>>;
12
284
  export declare const StyledMotionChildrenWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<{
13
285
  slot?: string | undefined;
@@ -1,6 +1,6 @@
1
1
  import { motion } from 'framer-motion';
2
2
  import styled, { css } from 'styled-components';
3
- export const StyledButton = styled.button`
3
+ export const StyledMotionButton = styled(motion.button)`
4
4
  align-items: center;
5
5
  background-color: ${_ref => {
6
6
  let {
@@ -1 +1 @@
1
- {"version":3,"file":"Button.styles.js","names":["motion","styled","css","StyledButton","button","_ref","isSecondary","theme","_ref2","text","_ref3","isDisabled","_ref4","disabled","_ref5","hasIcon","hasChildren","StyledIconWrapper","span","StyledMotionChildrenWrapper","div","StyledMotionWaitCursorWrapper"],"sources":["../../../src/components/button/Button.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\nimport styled, { css } from 'styled-components';\nimport type { FramerMotionBugFix, WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { ButtonProps } from './Button';\n\ntype StyledButtonProps = ButtonProps &\n WithTheme<{\n hasIcon: boolean;\n hasChildren: boolean;\n isDisabled?: boolean;\n }>;\n\nexport const StyledButton = styled.button<StyledButtonProps>`\n align-items: center;\n background-color: ${({ isSecondary, theme }: StyledButtonProps) =>\n isSecondary ? theme['202'] : theme['408']};\n border-radius: 3px;\n box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.2);\n border: none;\n color: ${({ isSecondary, theme }: StyledButtonProps) => (isSecondary ? theme.text : 'white')};\n cursor: ${({ isDisabled }) => (isDisabled ? 'default' : 'pointer')};\n display: inline-flex;\n line-height: 1.15;\n min-height: 32px;\n opacity: ${({ disabled }) => (disabled ? 0.5 : 1)};\n position: relative;\n user-select: none;\n transition: opacity 0.3s ease;\n\n ${({ hasIcon, hasChildren }) => {\n if (hasIcon) {\n if (hasChildren) {\n return css`\n padding: 7px 12px 7px 42px;\n `;\n }\n return css`\n padding: 7px 12px 7px 18px;\n `;\n }\n return css`\n padding: 7px 12px 7px 12px;\n `;\n }}\n`;\n\nexport const StyledIconWrapper = styled.span`\n align-items: center;\n background-color: rgba(255, 255, 255, 0.2);\n bottom: 0;\n display: flex;\n justify-content: center;\n left: 0;\n position: absolute;\n top: 0;\n width: 30px;\n`;\n\nexport const StyledMotionChildrenWrapper = styled(motion.div)<FramerMotionBugFix>``;\n\nexport const StyledMotionWaitCursorWrapper = styled(motion.div)<FramerMotionBugFix>`\n align-items: center;\n display: flex;\n justify-content: center;\n`;\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,eAAe;AACtC,OAAOC,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAW/C,OAAO,MAAMC,YAAY,GAAGF,MAAM,CAACG,MAA0B;AAC7D;AACA,wBAAwBC,IAAA;EAAA,IAAC;IAAEC,WAAW;IAAEC;EAAyB,CAAC,GAAAF,IAAA;EAAA,OAC1DC,WAAW,GAAGC,KAAK,CAAC,KAAK,CAAC,GAAGA,KAAK,CAAC,KAAK,CAAC;AAAA,CAAC;AAClD;AACA;AACA;AACA,aAAaC,KAAA;EAAA,IAAC;IAAEF,WAAW;IAAEC;EAAyB,CAAC,GAAAC,KAAA;EAAA,OAAMF,WAAW,GAAGC,KAAK,CAACE,IAAI,GAAG,OAAO;AAAA,CAAE;AACjG,cAAcC,KAAA;EAAA,IAAC;IAAEC;EAAW,CAAC,GAAAD,KAAA;EAAA,OAAMC,UAAU,GAAG,SAAS,GAAG,SAAS;AAAA,CAAE;AACvE;AACA;AACA;AACA,eAAeC,KAAA;EAAA,IAAC;IAAEC;EAAS,CAAC,GAAAD,KAAA;EAAA,OAAMC,QAAQ,GAAG,GAAG,GAAG,CAAC;AAAA,CAAE;AACtD;AACA;AACA;AACA;AACA,MAAMC,KAAA,IAA8B;EAAA,IAA7B;IAAEC,OAAO;IAAEC;EAAY,CAAC,GAAAF,KAAA;EACvB,IAAIC,OAAO,EAAE;IACT,IAAIC,WAAW,EAAE;MACb,OAAOd,GAAI;AAC3B;AACA,iBAAiB;IACL;IACA,OAAOA,GAAI;AACvB;AACA,aAAa;EACL;EACA,OAAOA,GAAI;AACnB;AACA,SAAS;AACL,CAAE;AACN,CAAC;AAED,OAAO,MAAMe,iBAAiB,GAAGhB,MAAM,CAACiB,IAAK;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,2BAA2B,GAAGlB,MAAM,CAACD,MAAM,CAACoB,GAAG,CAAsB,EAAC;AAEnF,OAAO,MAAMC,6BAA6B,GAAGpB,MAAM,CAACD,MAAM,CAACoB,GAAG,CAAsB;AACpF;AACA;AACA;AACA,CAAC"}
1
+ {"version":3,"file":"Button.styles.js","names":["motion","styled","css","StyledMotionButton","button","_ref","isSecondary","theme","_ref2","text","_ref3","isDisabled","_ref4","disabled","_ref5","hasIcon","hasChildren","StyledIconWrapper","span","StyledMotionChildrenWrapper","div","StyledMotionWaitCursorWrapper"],"sources":["../../../src/components/button/Button.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\nimport styled, { css } from 'styled-components';\nimport type { FramerMotionBugFix, WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { ButtonProps } from './Button';\n\ntype StyledButtonProps = ButtonProps &\n WithTheme<{\n hasIcon: boolean;\n hasChildren: boolean;\n isDisabled?: boolean;\n }>;\n\nexport const StyledMotionButton = styled(motion.button)<StyledButtonProps>`\n align-items: center;\n background-color: ${({ isSecondary, theme }: StyledButtonProps) =>\n isSecondary ? theme['202'] : theme['408']};\n border-radius: 3px;\n box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.2);\n border: none;\n color: ${({ isSecondary, theme }: StyledButtonProps) => (isSecondary ? theme.text : 'white')};\n cursor: ${({ isDisabled }) => (isDisabled ? 'default' : 'pointer')};\n display: inline-flex;\n line-height: 1.15;\n min-height: 32px;\n opacity: ${({ disabled }) => (disabled ? 0.5 : 1)};\n position: relative;\n user-select: none;\n transition: opacity 0.3s ease;\n\n ${({ hasIcon, hasChildren }) => {\n if (hasIcon) {\n if (hasChildren) {\n return css`\n padding: 7px 12px 7px 42px;\n `;\n }\n return css`\n padding: 7px 12px 7px 18px;\n `;\n }\n return css`\n padding: 7px 12px 7px 12px;\n `;\n }}\n`;\n\nexport const StyledIconWrapper = styled.span`\n align-items: center;\n background-color: rgba(255, 255, 255, 0.2);\n bottom: 0;\n display: flex;\n justify-content: center;\n left: 0;\n position: absolute;\n top: 0;\n width: 30px;\n`;\n\nexport const StyledMotionChildrenWrapper = styled(motion.div)<FramerMotionBugFix>``;\n\nexport const StyledMotionWaitCursorWrapper = styled(motion.div)<FramerMotionBugFix>`\n align-items: center;\n display: flex;\n justify-content: center;\n`;\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,eAAe;AACtC,OAAOC,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAW/C,OAAO,MAAMC,kBAAkB,GAAGF,MAAM,CAACD,MAAM,CAACI,MAAM,CAAqB;AAC3E;AACA,wBAAwBC,IAAA;EAAA,IAAC;IAAEC,WAAW;IAAEC;EAAyB,CAAC,GAAAF,IAAA;EAAA,OAC1DC,WAAW,GAAGC,KAAK,CAAC,KAAK,CAAC,GAAGA,KAAK,CAAC,KAAK,CAAC;AAAA,CAAC;AAClD;AACA;AACA;AACA,aAAaC,KAAA;EAAA,IAAC;IAAEF,WAAW;IAAEC;EAAyB,CAAC,GAAAC,KAAA;EAAA,OAAMF,WAAW,GAAGC,KAAK,CAACE,IAAI,GAAG,OAAO;AAAA,CAAE;AACjG,cAAcC,KAAA;EAAA,IAAC;IAAEC;EAAW,CAAC,GAAAD,KAAA;EAAA,OAAMC,UAAU,GAAG,SAAS,GAAG,SAAS;AAAA,CAAE;AACvE;AACA;AACA;AACA,eAAeC,KAAA;EAAA,IAAC;IAAEC;EAAS,CAAC,GAAAD,KAAA;EAAA,OAAMC,QAAQ,GAAG,GAAG,GAAG,CAAC;AAAA,CAAE;AACtD;AACA;AACA;AACA;AACA,MAAMC,KAAA,IAA8B;EAAA,IAA7B;IAAEC,OAAO;IAAEC;EAAY,CAAC,GAAAF,KAAA;EACvB,IAAIC,OAAO,EAAE;IACT,IAAIC,WAAW,EAAE;MACb,OAAOd,GAAI;AAC3B;AACA,iBAAiB;IACL;IACA,OAAOA,GAAI;AACvB;AACA,aAAa;EACL;EACA,OAAOA,GAAI;AACnB;AACA,SAAS;AACL,CAAE;AACN,CAAC;AAED,OAAO,MAAMe,iBAAiB,GAAGhB,MAAM,CAACiB,IAAK;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,2BAA2B,GAAGlB,MAAM,CAACD,MAAM,CAACoB,GAAG,CAAsB,EAAC;AAEnF,OAAO,MAAMC,6BAA6B,GAAGpB,MAAM,CAACD,MAAM,CAACoB,GAAG,CAAsB;AACpF;AACA;AACA;AACA,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
2
2
  import { useTheme } from 'styled-components';
3
3
  import Icon from '../icon/Icon';
4
- import { StyledInput, StyledInputContent, StyledInputContentWrapper, StyledInputField, StyledInputIconWrapper, StyledInputRightElement, StyledMotionInputClearIcon, StyledMotionInputLabel } from './Input.styles';
4
+ import { StyledInput, StyledInputContent, StyledInputContentWrapper, StyledInputField, StyledInputIconWrapper, StyledInputLabel, StyledInputRightElement, StyledMotionInputClearIcon, StyledMotionInputLabelWrapper } from './Input.styles';
5
5
  const Input = /*#__PURE__*/forwardRef((_ref, ref) => {
6
6
  let {
7
7
  iconElement,
@@ -23,6 +23,7 @@ const Input = /*#__PURE__*/forwardRef((_ref, ref) => {
23
23
  id
24
24
  } = _ref;
25
25
  const [hasValue, setHasValue] = useState(typeof value === 'string' && value !== '');
26
+ const [width, setWidth] = useState(0);
26
27
  const theme = useTheme();
27
28
  const inputRef = useRef(null);
28
29
  const handleClearIconClick = useCallback(() => {
@@ -36,6 +37,21 @@ const Input = /*#__PURE__*/forwardRef((_ref, ref) => {
36
37
  }
37
38
  }
38
39
  }, [onChange]);
40
+ useEffect(() => {
41
+ if (inputRef.current) {
42
+ const resizeObserver = new ResizeObserver(entries => {
43
+ if (entries && entries[0]) {
44
+ const observedWidth = entries[0].contentRect.width;
45
+ setWidth(observedWidth);
46
+ }
47
+ });
48
+ resizeObserver.observe(inputRef.current);
49
+ return () => {
50
+ resizeObserver.disconnect();
51
+ };
52
+ }
53
+ return () => {};
54
+ }, []);
39
55
  const handleInputFieldChange = useCallback(event => {
40
56
  setHasValue(event.target.value !== '');
41
57
  if (typeof onChange === 'function') {
@@ -82,7 +98,7 @@ const Input = /*#__PURE__*/forwardRef((_ref, ref) => {
82
98
  autoFocus: shouldUseAutoFocus,
83
99
  inputMode: inputMode,
84
100
  isInvalid: isInvalid
85
- }), /*#__PURE__*/React.createElement(StyledMotionInputLabel, {
101
+ }), /*#__PURE__*/React.createElement(StyledMotionInputLabelWrapper, {
86
102
  animate: {
87
103
  fontSize: hasValue ? '10px' : '16px'
88
104
  },
@@ -95,8 +111,10 @@ const Input = /*#__PURE__*/forwardRef((_ref, ref) => {
95
111
  type: 'tween',
96
112
  duration: 0.3
97
113
  },
114
+ width: width
115
+ }, placeholderElement, /*#__PURE__*/React.createElement(StyledInputLabel, {
98
116
  isInvalid: isInvalid
99
- }, placeholderElement, placeholder)), shouldShowClearIcon && /*#__PURE__*/React.createElement(StyledMotionInputClearIcon, {
117
+ }, placeholder))), shouldShowClearIcon && /*#__PURE__*/React.createElement(StyledMotionInputClearIcon, {
100
118
  shouldShowOnlyBottomBorder: shouldShowOnlyBottomBorder,
101
119
  animate: {
102
120
  opacity: hasValue ? 1 : 0
@@ -1 +1 @@
1
- {"version":3,"file":"Input.js","names":["React","forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","useRef","useState","useTheme","Icon","StyledInput","StyledInputContent","StyledInputContentWrapper","StyledInputField","StyledInputIconWrapper","StyledInputRightElement","StyledMotionInputClearIcon","StyledMotionInputLabel","Input","_ref","ref","iconElement","inputMode","isDisabled","onBlur","onChange","onFocus","onKeyDown","placeholder","placeholderElement","rightElement","shouldShowOnlyBottomBorder","shouldShowClearIcon","type","value","shouldUseAutoFocus","isInvalid","id","hasValue","setHasValue","theme","inputRef","handleClearIconClick","current","target","handleInputFieldChange","event","focus","labelPosition","bottom","right","left","top","createElement","className","shouldRoundRightCorners","disabled","autoFocus","animate","fontSize","initial","layout","style","transition","duration","opacity","onClick","icons","color","wrong","undefined","displayName"],"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 * The id of the input\n */\n id?: string;\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 id,\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 id={id}\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>\n {rightElement && <StyledInputRightElement>{rightElement}</StyledInputRightElement>}\n </StyledInput>\n );\n },\n);\n\nInput.displayName = 'Input';\n\nexport default Input;\n"],"mappings":"AAAA,OAAOA,KAAK,IAIRC,UAAU,EAIVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,QAAQ,QAAQ,mBAAmB;AAE5C,OAAOC,IAAI,MAAM,cAAc;AAC/B,SACIC,WAA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Ref","useCallback","useEffect","useImperativeHandle","useMemo","useRef","useState","useTheme","Icon","StyledInput","StyledInputContent","StyledInputContentWrapper","StyledInputField","StyledInputIconWrapper","StyledInputLabel","StyledInputRightElement","StyledMotionInputClearIcon","StyledMotionInputLabelWrapper","Input","_ref","ref","iconElement","inputMode","isDisabled","onBlur","onChange","onFocus","onKeyDown","placeholder","placeholderElement","rightElement","shouldShowOnlyBottomBorder","shouldShowClearIcon","type","value","shouldUseAutoFocus","isInvalid","id","hasValue","setHasValue","width","setWidth","theme","inputRef","handleClearIconClick","current","target","resizeObserver","ResizeObserver","entries","observedWidth","contentRect","observe","disconnect","handleInputFieldChange","event","focus","labelPosition","bottom","right","left","top","createElement","className","shouldRoundRightCorners","disabled","autoFocus","animate","fontSize","initial","layout","style","transition","duration","opacity","onClick","icons","color","wrong","undefined","displayName"],"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 StyledInputLabel,\n StyledInputRightElement,\n StyledMotionInputClearIcon,\n StyledMotionInputLabelWrapper,\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 * The id of the input\n */\n id?: string;\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 id,\n },\n ref,\n ) => {\n const [hasValue, setHasValue] = useState(typeof value === 'string' && value !== '');\n const [width, setWidth] = useState(0);\n\n const theme = useTheme() as Theme;\n\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 useEffect(() => {\n if (inputRef.current) {\n const resizeObserver = new ResizeObserver((entries) => {\n if (entries && entries[0]) {\n const observedWidth = entries[0].contentRect.width;\n setWidth(observedWidth);\n }\n });\n\n resizeObserver.observe(inputRef.current);\n\n return () => {\n resizeObserver.disconnect();\n };\n }\n\n return () => {};\n }, []);\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 id={id}\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 <StyledMotionInputLabelWrapper\n animate={{\n fontSize: hasValue ? '10px' : '16px',\n }}\n initial={false}\n layout\n style={{ ...labelPosition }}\n transition={{ type: 'tween', duration: 0.3 }}\n width={width}\n >\n {placeholderElement}\n <StyledInputLabel isInvalid={isInvalid}>{placeholder}</StyledInputLabel>\n </StyledMotionInputLabelWrapper>\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>\n {rightElement && <StyledInputRightElement>{rightElement}</StyledInputRightElement>}\n </StyledInput>\n );\n },\n);\n\nInput.displayName = 'Input';\n\nexport default Input;\n"],"mappings":"AAAA,OAAOA,KAAK,IAIRC,UAAU,EAIVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,QAAQ,QAAQ,mBAAmB;AAE5C,OAAOC,IAAI,MAAM,cAAc;AAC/B,SACIC,WAAW,EACXC,kBAAkB,EAClBC,yBAAyB,EACzBC,gBAAgB,EAChBC,sBAAsB,EACtBC,gBAAgB,EAChBC,uBAAuB,EACvBC,0BAA0B,EAC1BC,6BAA6B,QAC1B,gBAAgB;AAwFvB,MAAMC,KAAK,gBAAGlB,UAAU,CACpB,CAAAmB,IAAA,EAoBIC,GAAG,KACF;EAAA,IApBD;IACIC,WAAW;IACXC,SAAS;IACTC,UAAU;IACVC,MAAM;IACNC,QAAQ;IACRC,OAAO;IACPC,SAAS;IACTC,WAAW;IACXC,kBAAkB;IAClBC,YAAY;IACZC,0BAA0B;IAC1BC,mBAAmB,GAAG,KAAK;IAC3BC,IAAI,GAAG,MAAM;IACbC,KAAK;IACLC,kBAAkB,GAAG,KAAK;IAC1BC,SAAS,GAAG,KAAK;IACjBC;EACJ,CAAC,GAAAlB,IAAA;EAGD,MAAM,CAACmB,QAAQ,EAAEC,WAAW,CAAC,GAAGjC,QAAQ,CAAC,OAAO4B,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,EAAE,CAAC;EACnF,MAAM,CAACM,KAAK,EAAEC,QAAQ,CAAC,GAAGnC,QAAQ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12
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>>;
13
13
  type StyledInputFieldProps = WithTheme<Pick<InputProps, 'isInvalid'>>;
14
14
  export declare const StyledInputField: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, StyledInputFieldProps>>;
15
- type StyledMotionInputLabelProps = WithTheme<Pick<InputProps, 'isInvalid'>>;
16
- export declare const StyledMotionInputLabel: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<{
15
+ type StyledMotionInputLabelWrapperProps = WithTheme<{
16
+ width: number;
17
+ }>;
18
+ export declare const StyledMotionInputLabelWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<{
17
19
  form?: string | undefined;
18
20
  slot?: string | undefined;
19
21
  title?: string | undefined;
@@ -277,7 +279,9 @@ export declare const StyledMotionInputLabel: import("styled-components").IStyled
277
279
  onTransitionEnd?: import("react").TransitionEventHandler<HTMLLabelElement> | undefined;
278
280
  onTransitionEndCapture?: import("react").TransitionEventHandler<HTMLLabelElement> | undefined;
279
281
  htmlFor?: string | undefined;
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>>;
282
+ } & import("framer-motion").MotionProps & import("react").RefAttributes<HTMLLabelElement>, StyledMotionInputLabelWrapperProps>> & Omit<import("framer-motion").ForwardRefComponent<HTMLLabelElement, import("framer-motion").HTMLMotionProps<"label">>, keyof import("react").Component<any, {}, any>>;
283
+ type StyledInputLabelProps = WithTheme<Pick<InputProps, 'isInvalid'>>;
284
+ export declare const StyledInputLabel: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, StyledInputLabelProps>>;
281
285
  type StyledMotionInputClearIconProps = WithTheme<{
282
286
  shouldShowOnlyBottomBorder?: boolean;
283
287
  }>;
@@ -84,7 +84,7 @@ export const StyledInputField = styled.input`
84
84
  padding: 0;
85
85
  width: 100%;
86
86
  `;
87
- export const StyledMotionInputLabel = styled(motion.label)`
87
+ export const StyledMotionInputLabelWrapper = styled(motion.label)`
88
88
  align-items: baseline;
89
89
  display: flex;
90
90
  flex: 0 0 auto;
@@ -93,20 +93,34 @@ export const StyledMotionInputLabel = styled(motion.label)`
93
93
  pointer-events: none;
94
94
  position: absolute;
95
95
  user-select: none;
96
- color: ${_ref7 => {
96
+ max-width: ${_ref7 => {
97
+ let {
98
+ width
99
+ } = _ref7;
100
+ return width;
101
+ }}px;
102
+ `;
103
+ export const StyledInputLabel = styled.label`
104
+ line-height: 1.3;
105
+ pointer-events: none;
106
+ width: 100%;
107
+ white-space: nowrap;
108
+ overflow: hidden;
109
+ text-overflow: ellipsis;
110
+ color: ${_ref8 => {
97
111
  let {
98
112
  theme,
99
113
  isInvalid
100
- } = _ref7;
114
+ } = _ref8;
101
115
  return isInvalid ? theme.wrong : undefined;
102
116
  }};
103
117
  `;
104
118
  export const StyledMotionInputClearIcon = styled(motion.div)`
105
119
  align-items: center;
106
- border-left: ${_ref8 => {
120
+ border-left: ${_ref9 => {
107
121
  let {
108
122
  shouldShowOnlyBottomBorder
109
- } = _ref8;
123
+ } = _ref9;
110
124
  return shouldShowOnlyBottomBorder ? 'none' : '1px solid rgba(160, 160, 160, 0.3)';
111
125
  }};
112
126
  cursor: pointer;
@@ -1 +1 @@
1
- {"version":3,"file":"Input.styles.js","names":["motion","styled","css","StyledInput","div","_ref","isDisabled","StyledInputContentWrapper","_ref2","theme","_ref3","isInvalid","wrong","_ref4","_ref5","shouldRoundRightCorners","shouldShowOnlyBottomBorder","StyledInputContent","StyledInputField","input","_ref6","text","StyledMotionInputLabel","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 width: 100%;\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,SAASA,MAAM,QAAQ,eAAe;AACtC,OAAOC,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAM/C,OAAO,MAAMC,WAAW,GAAGF,MAAM,CAACG,GAAsB;AACxD,eAAeC,IAAA;EAAA,IAAC;IAAEC;EAAW,CAAC,GAAAD,IAAA;EAAA,OAAMC,UAAU,GAAG,GAAG,GAAG,CAAC;AAAA,CAAE;AAC1D;AACA;AACA,CAAC;AAOD,OAAO,MAAMC,yBAAyB,GAAGN,MAAM,CAACG,GAAoC;AACpF;AACA,wBAAwBI,KAAA;EAAA,IAAC;IAAEC;EAAwB,CAAC,GAAAD,KAAA;E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AAA;EAAA,OACvDb,SAAS,GAAGF,KAAK,CAACG,KAAK,GAAGa,SAAS;AAAA,CAAC;AAC5C,CAAC;AAID,OAAO,MAAMC,0BAA0B,GAAGzB,MAAM,CAACD,MAAM,CAACI,GAAG,CAAmC;AAC9F;AACA,mBAAmBuB,KAAA;EAAA,IAAC;IAAEX;EAA2B,CAAC,GAAAW,KAAA;EAAA,OAC1CX,0BAA0B,GAAG,MAAM,GAAG,oCAAoC;AAAA,CAAC;AACnF;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMY,sBAAsB,GAAG3B,MAAM,CAACG,GAAI;AACjD;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMyB,uBAAuB,GAAG5B,MAAM,CAACG,GAAI;AAClD;AACA;AACA;AACA;AACA,CAAC"}
1
+ {"version":3,"file":"Input.styles.js","names":["motion","styled","css","StyledInput","div","_ref","isDisabled","StyledInputContentWrapper","_ref2","theme","_ref3","isInvalid","wrong","_ref4","_ref5","shouldRoundRightCorners","shouldShowOnlyBottomBorder","StyledInputContent","StyledInputField","input","_ref6","text","StyledMotionInputLabelWrapper","label","_ref7","width","StyledInputLabel","_ref8","undefined","StyledMotionInputClearIcon","_ref9","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 width: 100%;\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 StyledMotionInputLabelWrapperProps = WithTheme<{ width: number }>;\n\nexport const StyledMotionInputLabelWrapper = styled(\n motion.label,\n)<StyledMotionInputLabelWrapperProps>`\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 max-width: ${({ width }) => width}px;\n`;\n\ntype StyledInputLabelProps = WithTheme<Pick<InputProps, 'isInvalid'>>;\n\nexport const StyledInputLabel = styled.label<StyledInputLabelProps>`\n line-height: 1.3;\n pointer-events: none;\n width: 100%;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n color: ${({ theme, isInvalid }: StyledInputLabelProps) =>\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,SAASA,MAAM,QAAQ,eAAe;AACtC,OAAOC,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAM/C,OAAO,MAAMC,WAAW,GAAGF,MAAM,CAACG,GAAsB;AACxD,eAAeC,IAAA;EAAA,IAAC;IAAEC;EAAW,CAAC,GAAAD,IAAA;EAAA,OAAMC,UAAU,GAAG,GAAG,GAAG,CAAC;AAAA,CAAE;AAC1D;AACA;AACA,CAAC;AAOD,OAAO,MAAMC,yBAAyB,GAAGN,MAAM,CAACG,GAAoC;AACpF;AACA,wBAAwBI,KAAA;EAAA,IAAC;IAAEC;EAAwB,CAAC,GAAAD,KAAA;EAAA,OAAKC,KAAK,CAAC,KAAK,CAAC;AAAA,CAAC;AACtE;AACA,UAAUC,KAAA;EAAA,IAAC;IAAED,KAAK;IAAEE;EAA4B,CAAC,GAAAD,KAAA;EAAA,OACrCC,SAAS,GAAGF,KAAK,CAACG,KAAK,GAAG,0BAA0B;AAAA,CAAC;AACjE,aAAaC,KAAA;EAAA,IAAC;IAAEJ;EAAwB,CAAC,GAAAI,KAAA;EAAA,OAAKJ,KAAK,CAAC,KAAK,CAAC;AAAA,CAAC;AAC3D;AACA;AACA;AACA;AACA;A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GAAG,CAAmC;AAC9F;AACA,mBAAmB0B,KAAA;EAAA,IAAC;IAAEd;EAA2B,CAAC,GAAAc,KAAA;EAAA,OAC1Cd,0BAA0B,GAAG,MAAM,GAAG,oCAAoC;AAAA,CAAC;AACnF;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMe,sBAAsB,GAAG9B,MAAM,CAACG,GAAI;AACjD;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAM4B,uBAAuB,GAAG/B,MAAM,CAACG,GAAI;AAClD;AACA;AACA;AACA;AACA,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { getDevice } from 'chayns-api';
2
2
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
- import { StyledTextArea, StyledTextAreaInput, StyledTextAreaLabel } from './TextArea.styles';
3
+ import { StyledTextArea, StyledTextAreaInput, StyledTextAreaLabel, StyledTextAreaLabelWrapper } from './TextArea.styles';
4
4
  const TextArea = _ref => {
5
5
  let {
6
6
  placeholder,
@@ -42,7 +42,7 @@ const TextArea = _ref => {
42
42
  minHeight: minHeight,
43
43
  isOverflowing: isOverflowing,
44
44
  rows: 1
45
- }), !value && /*#__PURE__*/React.createElement(StyledTextAreaLabel, null, placeholder)), [browser?.name, isOverflowing, maxHeight, minHeight, onBlur, onChange, placeholder, value]);
45
+ }), !value && /*#__PURE__*/React.createElement(StyledTextAreaLabelWrapper, null, ' ', /*#__PURE__*/React.createElement(StyledTextAreaLabel, null, placeholder))), [browser?.name, isOverflowing, maxHeight, minHeight, onBlur, onChange, placeholder, value]);
46
46
  };
47
47
  TextArea.displayName = 'TextArea';
48
48
  export default TextArea;
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.js","names":["getDevice","React","useCallback","useEffect","useMemo","useRef","useState","StyledTextArea","StyledTextAreaInput","StyledTextAreaLabel","TextArea","_ref","placeholder","value","onChange","onBlur","maxHeight","minHeight","isOverflowing","setIsOverflowing","textareaRef","browser","adjustTextareaHeight","current","style","height","scrollHeight","parseInt","toString","length","createElement","name","ref","rows","displayName"],"sources":["../../../src/components/text-area/TextArea.tsx"],"sourcesContent":["import { getDevice } from 'chayns-api';\nimport React, {\n ChangeEventHandler,\n CSSProperties,\n FC,\n FocusEventHandler,\n ReactElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { StyledTextArea, StyledTextAreaInput, StyledTextAreaLabel } from './TextArea.styles';\n\nexport type TextAreaProps = {\n /**\n * The maximum height of the text area.\n */\n maxHeight?: CSSProperties['maxHeight'];\n /**\n * The minimum height of the text area.\n */\n minHeight?: CSSProperties['minHeight'];\n /**\n * Function that is executed when the text area loses focus.\n */\n onBlur?: FocusEventHandler<HTMLTextAreaElement>;\n /**\n * Function that is executed when the text of the text area changes.\n */\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n /**\n * Placeholder for the text area field.\n */\n placeholder?: string | ReactElement;\n /**\n * Value if the text area should be controlled.\n */\n value?: string;\n};\n\nconst TextArea: FC<TextAreaProps> = ({\n placeholder,\n value,\n onChange,\n onBlur,\n maxHeight = '120px',\n minHeight = '41px',\n}) => {\n const [isOverflowing, setIsOverflowing] = useState(false);\n\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n const { browser } = getDevice();\n\n const adjustTextareaHeight = useCallback(() => {\n if (textareaRef.current) {\n textareaRef.current.style.height = 'auto';\n textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`;\n\n setIsOverflowing(textareaRef.current.scrollHeight > parseInt(maxHeight.toString(), 10));\n }\n }, [maxHeight]);\n\n /**\n * This hook calculates the height of the TextArea after the displayValue is changed and the content is inside the \"textareaRef\".\n * To maintain the functionality while clearing the input, the length need to be greater than -1.\n */\n useEffect(() => {\n if (value && value.length > -1) {\n adjustTextareaHeight();\n }\n }, [adjustTextareaHeight, value]);\n\n return useMemo(\n () => (\n <StyledTextArea>\n <StyledTextAreaInput\n browser={browser?.name}\n ref={textareaRef}\n value={value}\n onBlur={onBlur}\n onChange={onChange}\n maxHeight={maxHeight}\n minHeight={minHeight}\n isOverflowing={isOverflowing}\n rows={1}\n />\n {!value && <StyledTextAreaLabel>{placeholder}</StyledTextAreaLabel>}\n </StyledTextArea>\n ),\n [browser?.name, isOverflowing, maxHeight, minHeight, onBlur, onChange, placeholder, value],\n );\n};\n\nTextArea.displayName = 'TextArea';\n\nexport default TextArea;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,YAAY;AACtC,OAAOC,KAAK,IAMRC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,cAAc,EAAEC,mBAAmB,EAAEC,mBAAmB,QAAQ,mBAAmB;AA6B5F,MAAMC,QAA2B,GAAGC,IAAA,IAO9B;EAAA,IAP+B;IACjCC,WAAW;IACXC,KAAK;IACLC,QAAQ;IACRC,MAAM;IACNC,SAAS,GAAG,OAAO;IACnBC,SAAS,GAAG;EAChB,CAAC,GAAAN,IAAA;EACG,MAAM,CAACO,aAAa,EAAEC,gBAAgB,CAAC,GAAGb,QAAQ,CAAC,KAAK,CAAC;EAEzD,MAAMc,WAAW,GAAGf,MAAM,CAAsB,IAAI,CAAC;EAErD,MAAM;IAAEgB;EAAQ,CAAC,GAAGrB,SAAS,CAAC,CAAC;EAE/B,MAAMsB,oBAAoB,GAAGpB,WAAW,CAAC,MAAM;IAC3C,IAAIkB,WAAW,CAACG,OAAO,EAAE;MACrBH,WAAW,CAACG,OAAO,CAACC,KAAK,CAACC,MAAM,GAAG,MAAM;MACzCL,WAAW,CAACG,OAAO,CAACC,KAAK,CAACC,MAAM,GAAI,GAAEL,WAAW,CAACG,OAAO,CAACG,YAAa,IAAG;MAE1EP,gBAAgB,CAACC,WAAW,CAACG,OAAO,CAACG,YAAY,GAAGC,QAAQ,CAACX,SAAS,CAACY,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3F;EACJ,CAAC,EAAE,CAACZ,SAAS,CAAC,CAAC;;EAEf;AACJ;AACA;AACA;EACIb,SAAS,CAAC,MAAM;IACZ,IAAIU,KAAK,IAAIA,KAAK,CAACgB,MAAM,GAAG,CAAC,CAAC,EAAE;MAC5BP,oBAAoB,CAAC,CAAC;IAC1B;EACJ,CAAC,EAAE,CAACA,oBAAoB,EAAET,KAAK,CAAC,CAAC;EAEjC,OAAOT,OAAO,CACV,mBACIH,KAAA,CAAA6B,aAAA,CAACvB,cAAc,qBACXN,KAAA,CAAA6B,aAAA,CAACtB,mBAAmB;IAChBa,OAAO,EAAEA,OAAO,EAAEU,IAAK;IACvBC,GAAG,EAAEZ,WAAY;IACjBP,KAAK,EAAEA,KAAM;IACbE,MAAM,EAAEA,MAAO;IACfD,QAAQ,EAAEA,QAAS;IACnBE,SAAS,EAAEA,SAAU;IACrBC,SAAS,EAAEA,SAAU;IACrBC,aAAa,EAAEA,aAAc;IAC7Be,IAAI,EAAE;EAAE,CACX,CAAC,EACD,CAACpB,KAAK,iBAAIZ,KAAA,CAAA6B,aAAA,CAACrB,mBAAmB,QAAEG,WAAiC,CACtD,CACnB,EACD,CAACS,OAAO,EAAEU,IAAI,EAAEb,aAAa,EAAEF,SAAS,EAAEC,SAAS,EAAEF,MAAM,EAAED,QAAQ,EAAEF,WAAW,EAAEC,KAAK,CAC7F,CAAC;AACL,CAAC;AAEDH,QAAQ,CAACwB,WAAW,GAAG,UAAU;AAEjC,eAAexB,QAAQ"}
1
+ {"version":3,"file":"TextArea.js","names":["getDevice","React","useCallback","useEffect","useMemo","useRef","useState","StyledTextArea","StyledTextAreaInput","StyledTextAreaLabel","StyledTextAreaLabelWrapper","TextArea","_ref","placeholder","value","onChange","onBlur","maxHeight","minHeight","isOverflowing","setIsOverflowing","textareaRef","browser","adjustTextareaHeight","current","style","height","scrollHeight","parseInt","toString","length","createElement","name","ref","rows","displayName"],"sources":["../../../src/components/text-area/TextArea.tsx"],"sourcesContent":["import { getDevice } from 'chayns-api';\nimport React, {\n ChangeEventHandler,\n CSSProperties,\n FC,\n FocusEventHandler,\n ReactElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport {\n StyledTextArea,\n StyledTextAreaInput,\n StyledTextAreaLabel,\n StyledTextAreaLabelWrapper,\n} from './TextArea.styles';\n\nexport type TextAreaProps = {\n /**\n * The maximum height of the text area.\n */\n maxHeight?: CSSProperties['maxHeight'];\n /**\n * The minimum height of the text area.\n */\n minHeight?: CSSProperties['minHeight'];\n /**\n * Function that is executed when the text area loses focus.\n */\n onBlur?: FocusEventHandler<HTMLTextAreaElement>;\n /**\n * Function that is executed when the text of the text area changes.\n */\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n /**\n * Placeholder for the text area field.\n */\n placeholder?: string | ReactElement;\n /**\n * Value if the text area should be controlled.\n */\n value?: string;\n};\n\nconst TextArea: FC<TextAreaProps> = ({\n placeholder,\n value,\n onChange,\n onBlur,\n maxHeight = '120px',\n minHeight = '41px',\n}) => {\n const [isOverflowing, setIsOverflowing] = useState(false);\n\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n const { browser } = getDevice();\n\n const adjustTextareaHeight = useCallback(() => {\n if (textareaRef.current) {\n textareaRef.current.style.height = 'auto';\n textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`;\n\n setIsOverflowing(textareaRef.current.scrollHeight > parseInt(maxHeight.toString(), 10));\n }\n }, [maxHeight]);\n\n /**\n * This hook calculates the height of the TextArea after the displayValue is changed and the content is inside the \"textareaRef\".\n * To maintain the functionality while clearing the input, the length need to be greater than -1.\n */\n useEffect(() => {\n if (value && value.length > -1) {\n adjustTextareaHeight();\n }\n }, [adjustTextareaHeight, value]);\n\n return useMemo(\n () => (\n <StyledTextArea>\n <StyledTextAreaInput\n browser={browser?.name}\n ref={textareaRef}\n value={value}\n onBlur={onBlur}\n onChange={onChange}\n maxHeight={maxHeight}\n minHeight={minHeight}\n isOverflowing={isOverflowing}\n rows={1}\n />\n {!value && (\n <StyledTextAreaLabelWrapper>\n {' '}\n <StyledTextAreaLabel>{placeholder}</StyledTextAreaLabel>\n </StyledTextAreaLabelWrapper>\n )}\n </StyledTextArea>\n ),\n [browser?.name, isOverflowing, maxHeight, minHeight, onBlur, onChange, placeholder, value],\n );\n};\n\nTextArea.displayName = 'TextArea';\n\nexport default TextArea;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,YAAY;AACtC,OAAOC,KAAK,IAMRC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SACIC,cAAc,EACdC,mBAAmB,EACnBC,mBAAmB,EACnBC,0BAA0B,QACvB,mBAAmB;AA6B1B,MAAMC,QAA2B,GAAGC,IAAA,IAO9B;EAAA,IAP+B;IACjCC,WAAW;IACXC,KAAK;IACLC,QAAQ;IACRC,MAAM;IACNC,SAAS,GAAG,OAAO;IACnBC,SAAS,GAAG;EAChB,CAAC,GAAAN,IAAA;EACG,MAAM,CAACO,aAAa,EAAEC,gBAAgB,CAAC,GAAGd,QAAQ,CAAC,KAAK,CAAC;EAEzD,MAAMe,WAAW,GAAGhB,MAAM,CAAsB,IAAI,CAAC;EAErD,MAAM;IAAEiB;EAAQ,CAAC,GAAGtB,SAAS,CAAC,CAAC;EAE/B,MAAMuB,oBAAoB,GAAGrB,WAAW,CAAC,MAAM;IAC3C,IAAImB,WAAW,CAACG,OAAO,EAAE;MACrBH,WAAW,CAACG,OAAO,CAACC,KAAK,CAACC,MAAM,GAAG,MAAM;MACzCL,WAAW,CAACG,OAAO,CAACC,KAAK,CAACC,MAAM,GAAI,GAAEL,WAAW,CAACG,OAAO,CAACG,YAAa,IAAG;MAE1EP,gBAAgB,CAACC,WAAW,CAACG,OAAO,CAACG,YAAY,GAAGC,QAAQ,CAACX,SAAS,CAACY,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3F;EACJ,CAAC,EAAE,CAACZ,SAAS,CAAC,CAAC;;EAEf;AACJ;AACA;AACA;EACId,SAAS,CAAC,MAAM;IACZ,IAAIW,KAAK,IAAIA,KAAK,CAACgB,MAAM,GAAG,CAAC,CAAC,EAAE;MAC5BP,oBAAoB,CAAC,CAAC;IAC1B;EACJ,CAAC,EAAE,CAACA,oBAAoB,EAAET,KAAK,CAAC,CAAC;EAEjC,OAAOV,OAAO,CACV,mBACIH,KAAA,CAAA8B,aAAA,CAACxB,cAAc,qBACXN,KAAA,CAAA8B,aAAA,CAACvB,mBAAmB;IAChBc,OAAO,EAAEA,OAAO,EAAEU,IAAK;IACvBC,GAAG,EAAEZ,WAAY;IACjBP,KAAK,EAAEA,KAAM;IACbE,MAAM,EAAEA,MAAO;IACfD,QAAQ,EAAEA,QAAS;IACnBE,SAAS,EAAEA,SAAU;IACrBC,SAAS,EAAEA,SAAU;IACrBC,aAAa,EAAEA,aAAc;IAC7Be,IAAI,EAAE;EAAE,CACX,CAAC,EACD,CAACpB,KAAK,iBACHb,KAAA,CAAA8B,aAAA,CAACrB,0BAA0B,QACtB,GAAG,eACJT,KAAA,CAAA8B,aAAA,CAACtB,mBAAmB,QAAEI,WAAiC,CAC/B,CAEpB,CACnB,EACD,CAACS,OAAO,EAAEU,IAAI,EAAEb,aAAa,EAAEF,SAAS,EAAEC,SAAS,EAAEF,MAAM,EAAED,QAAQ,EAAEF,WAAW,EAAEC,KAAK,CAC7F,CAAC;AACL,CAAC;AAEDH,QAAQ,CAACwB,WAAW,GAAG,UAAU;AAEjC,eAAexB,QAAQ"}
@@ -9,6 +9,7 @@ type StyledTextAreaInputProps = WithTheme<{
9
9
  browser: Browser | 'bot' | null | undefined;
10
10
  }>;
11
11
  export declare const StyledTextAreaInput: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, StyledTextAreaInputProps>>;
12
+ export declare const StyledTextAreaLabelWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, never>>;
12
13
  export declare const StyledTextAreaLabel: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, {
13
14
  theme: import("../color-scheme-provider/ColorSchemeProvider").Theme;
14
15
  }>>;
@@ -72,13 +72,7 @@ export const StyledTextAreaInput = styled.textarea`
72
72
  `;
73
73
  }}
74
74
  `;
75
- export const StyledTextAreaLabel = styled.label`
76
- color: rgba(${_ref7 => {
77
- let {
78
- theme
79
- } = _ref7;
80
- return theme['text-rgb'];
81
- }}, 0.45);
75
+ export const StyledTextAreaLabelWrapper = styled.label`
82
76
  left: 10px;
83
77
  top: 12px;
84
78
  align-items: baseline;
@@ -89,5 +83,19 @@ export const StyledTextAreaLabel = styled.label`
89
83
  pointer-events: none;
90
84
  position: absolute;
91
85
  user-select: none;
86
+ width: calc(100% - 20px);
87
+ `;
88
+ export const StyledTextAreaLabel = styled.label`
89
+ color: rgba(${_ref7 => {
90
+ let {
91
+ theme
92
+ } = _ref7;
93
+ return theme['text-rgb'];
94
+ }}, 0.45);
95
+ line-height: 1.3;
96
+ width: 100%;
97
+ white-space: nowrap;
98
+ overflow: hidden;
99
+ text-overflow: ellipsis;
92
100
  `;
93
101
  //# sourceMappingURL=TextArea.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.styles.js","names":["styled","css","StyledTextArea","div","StyledTextAreaInput","textarea","_ref","theme","_ref2","text","_ref3","isOverflowing","_ref4","maxHeight","_ref5","minHeight","_ref6","browser","StyledTextAreaLabel","label","_ref7"],"sources":["../../../src/components/text-area/TextArea.styles.ts"],"sourcesContent":["import type { Browser } from 'detect-browser';\nimport type { CSSProperties } from 'react';\nimport styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\nexport const StyledTextArea = styled.div`\n display: flex;\n flex: 1 1 auto;\n min-width: 0;\n position: relative;\n`;\n\ntype StyledTextAreaInputProps = WithTheme<{\n maxHeight: CSSProperties['maxHeight'];\n minHeight: CSSProperties['minHeight'];\n isOverflowing: boolean;\n browser: Browser | 'bot' | null | undefined;\n}>;\n\nexport const StyledTextAreaInput = styled.textarea<StyledTextAreaInputProps>`\n border-radius: 3px;\n border: 1px solid rgba(160, 160, 160, 0.3);\n background-color: ${({ theme }: StyledTextAreaInputProps) => theme['100']};\n color: ${({ theme }: StyledTextAreaInputProps) => theme.text};\n resize: none;\n overflow-y: ${({ isOverflowing }) => (isOverflowing ? 'scroll' : 'hidden')};\n max-height: ${({ maxHeight }: StyledTextAreaInputProps) => maxHeight};\n min-height: ${({ minHeight }: StyledTextAreaInputProps) => minHeight};\n width: 100%;\n padding: 8px 10px;\n\n // Styles for custom scrollbar\n ${({ browser, theme }: StyledTextAreaInputProps) =>\n browser === 'firefox'\n ? css`\n scrollbar-color: rgba(${theme['text-rgb']}, 0.15) transparent;\n scrollbar-width: thin;\n `\n : css`\n &::-webkit-scrollbar {\n width: 5px;\n }\n\n &::-webkit-scrollbar-track {\n background-color: transparent;\n }\n\n &::-webkit-scrollbar-button {\n background-color: transparent;\n height: 5px;\n }\n\n &::-webkit-scrollbar-thumb {\n background-color: rgba(${theme['text-rgb']}, 0.15);\n border-radius: 20px;\n }\n `}\n`;\n\ntype StyledTextAreaLabelProps = WithTheme<unknown>;\n\nexport const StyledTextAreaLabel = styled.label<StyledTextAreaLabelProps>`\n color: rgba(${({ theme }: StyledTextAreaLabelProps) => theme['text-rgb']}, 0.45);\n left: 10px;\n top: 12px;\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`;\n"],"mappings":"AAEA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAG/C,OAAO,MAAMC,cAAc,GAAGF,MAAM,CAACG,GAAI;AACzC;AACA;AAC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AC"}
1
+ {"version":3,"file":"TextArea.styles.js","names":["styled","css","StyledTextArea","div","StyledTextAreaInput","textarea","_ref","theme","_ref2","text","_ref3","isOverflowing","_ref4","maxHeight","_ref5","minHeight","_ref6","browser","StyledTextAreaLabelWrapper","label","StyledTextAreaLabel","_ref7"],"sources":["../../../src/components/text-area/TextArea.styles.ts"],"sourcesContent":["import type { Browser } from 'detect-browser';\nimport type { CSSProperties } from 'react';\nimport styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\nexport const StyledTextArea = styled.div`\n display: flex;\n flex: 1 1 auto;\n min-width: 0;\n position: relative;\n`;\n\ntype StyledTextAreaInputProps = WithTheme<{\n maxHeight: CSSProperties['maxHeight'];\n minHeight: CSSProperties['minHeight'];\n isOverflowing: boolean;\n browser: Browser | 'bot' | null | undefined;\n}>;\n\nexport const StyledTextAreaInput = styled.textarea<StyledTextAreaInputProps>`\n border-radius: 3px;\n border: 1px solid rgba(160, 160, 160, 0.3);\n background-color: ${({ theme }: StyledTextAreaInputProps) => theme['100']};\n color: ${({ theme }: StyledTextAreaInputProps) => theme.text};\n resize: none;\n overflow-y: ${({ isOverflowing }) => (isOverflowing ? 'scroll' : 'hidden')};\n max-height: ${({ maxHeight }: StyledTextAreaInputProps) => maxHeight};\n min-height: ${({ minHeight }: StyledTextAreaInputProps) => minHeight};\n width: 100%;\n padding: 8px 10px;\n\n // Styles for custom scrollbar\n ${({ browser, theme }: StyledTextAreaInputProps) =>\n browser === 'firefox'\n ? css`\n scrollbar-color: rgba(${theme['text-rgb']}, 0.15) transparent;\n scrollbar-width: thin;\n `\n : css`\n &::-webkit-scrollbar {\n width: 5px;\n }\n\n &::-webkit-scrollbar-track {\n background-color: transparent;\n }\n\n &::-webkit-scrollbar-button {\n background-color: transparent;\n height: 5px;\n }\n\n &::-webkit-scrollbar-thumb {\n background-color: rgba(${theme['text-rgb']}, 0.15);\n border-radius: 20px;\n }\n `}\n`;\n\nexport const StyledTextAreaLabelWrapper = styled.label`\n left: 10px;\n top: 12px;\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 width: calc(100% - 20px);\n`;\n\ntype StyledTextAreaLabelProps = WithTheme<unknown>;\n\nexport const StyledTextAreaLabel = styled.label<StyledTextAreaLabelProps>`\n color: rgba(${({ theme }: StyledTextAreaLabelProps) => theme['text-rgb']}, 0.45);\n line-height: 1.3;\n width: 100%;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n`;\n"],"mappings":"AAEA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAG/C,OAAO,MAAMC,cAAc,GAAGF,MAAM,CAACG,GAAI;AACzC;AACA;AACA;AACA;AACA,CAAC;AASD,OAAO,MAAMC,mBAAmB,GAAGJ,MAAM,CAACK,QAAmC;AAC7E;AACA;AACA,wBAAwBC,IAAA;EAAA,IAAC;IAAEC;EAAgC,CAAC,GAAAD,IAAA;EAAA,OAAKC,KAAK,CAAC,KAAK,CAAC;AAAA,CAAC;AAC9E,aAAaC,KAAA;EAAA,IAAC;IAAED;EAAgC,CAAC,GAAAC,KAAA;EAAA,OAAKD,KAAK,CAACE,IAAI;AAAA,CAAC;AACjE;AACA,kBAAkBC,KAAA;EAAA,IAAC;IAAEC;EAAc,CAAC,GAAAD,KAAA;EAAA,OAAMC,aAAa,GAAG,QAAQ,GAAG,QAAQ;AAAA,CAAE;AAC/E,kBAAkBC,KAAA;EAAA,IAAC;IAAEC;EAAoC,CAAC,GAAAD,KAAA;EAAA,OAAKC,SAAS;AAAA,CAAC;AACzE,kBAAkBC,KAAA;EAAA,IAAC;IAAEC;EAAoC,CAAC,GAAAD,KAAA;EAAA,OAAKC,SAAS;AAAA,CAAC;AACzE;AACA;AACA;AACA;AACA,MAAMC,KAAA;EAAA,IAAC;IAAEC,OAAO;IAAEV;EAAgC,CAAC,GAAAS,KAAA;EAAA,OAC3CC,OAAO,KAAK,SAAS,GACfhB,GAAI;AAClB,0CAA0CM,KAAK,CAAC,UAAU,CAAE;AAC5D;AACA,eAAe,GACDN,GAAI;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+CM,KAAK,CAAC,UAAU,CAAE;AACjE;AACA;AACA,eAAe;AAAA,CAAC;AAChB,CAAC;AAED,OAAO,MAAMW,0BAA0B,GAAGlB,MAAM,CAACmB,KAAM;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAID,OAAO,MAAMC,mBAAmB,GAAGpB,MAAM,CAACmB,KAAgC;AAC1E,kBAAkBE,KAAA;EAAA,IAAC;IAAEd;EAAgC,CAAC,GAAAc,KAAA;EAAA,OAAKd,KAAK,CAAC,UAAU,CAAC;AAAA,CAAC;AAC7E;AACA;AACA;AACA;AACA;AACA,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chayns-components/core",
3
- "version": "5.0.0-beta.453",
3
+ "version": "5.0.0-beta.456",
4
4
  "description": "A set of beautiful React components for developing your own applications with chayns.",
5
5
  "sideEffects": false,
6
6
  "browserslist": [
@@ -72,5 +72,5 @@
72
72
  "publishConfig": {
73
73
  "access": "public"
74
74
  },
75
- "gitHead": "8af34a47a6289bd94888da368898c5ffb8aaef91"
75
+ "gitHead": "703953eb5eba477163504a0acf90495d559446ff"
76
76
  }