@ohos-ports/s-ui-react-atom-input 5.51.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +227 -0
  3. package/lib/Container/InputContainer.js +19 -0
  4. package/lib/Container/index.scss +25 -0
  5. package/lib/Input/Component/index.js +141 -0
  6. package/lib/Input/Component/index.scss +93 -0
  7. package/lib/Input/Component/settings.scss +30 -0
  8. package/lib/Input/Wrappers/Addons/InputAddons.js +32 -0
  9. package/lib/Input/Wrappers/Addons/config.js +12 -0
  10. package/lib/Input/Wrappers/Addons/index.scss +35 -0
  11. package/lib/Input/Wrappers/Addons/settings.scss +7 -0
  12. package/lib/Input/Wrappers/Button/InputButton.js +21 -0
  13. package/lib/Input/Wrappers/Button/config.js +2 -0
  14. package/lib/Input/Wrappers/Button/index.scss +13 -0
  15. package/lib/Input/Wrappers/Icons/InputIcons.js +34 -0
  16. package/lib/Input/Wrappers/Icons/config.js +12 -0
  17. package/lib/Input/Wrappers/Icons/index.scss +44 -0
  18. package/lib/Input/Wrappers/Icons/settings.scss +10 -0
  19. package/lib/Input/Wrappers/index.scss +3 -0
  20. package/lib/Input/Wrappers/settings.scss +2 -0
  21. package/lib/Input/index.js +49 -0
  22. package/lib/Mask/iMask.js +19 -0
  23. package/lib/Mask/index.js +48 -0
  24. package/lib/Password/config.js +5 -0
  25. package/lib/Password/index.js +60 -0
  26. package/lib/Password/index.scss +2 -0
  27. package/lib/Password/styles/index.scss +58 -0
  28. package/lib/Password/styles/settings.scss +3 -0
  29. package/lib/config.js +55 -0
  30. package/lib/helpers/getComponentAndProps.js +22 -0
  31. package/lib/helpers/isValidInputValue.js +16 -0
  32. package/lib/index.js +33 -0
  33. package/lib/index.scss +4 -0
  34. package/lib/mixins.scss +75 -0
  35. package/lib/settings.scss +5 -0
  36. package/lib/styles/index.scss +6 -0
  37. package/lib/styles/settings.scss +3 -0
  38. package/package.json +49 -0
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 SUI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,227 @@
1
+ # AtomInput
2
+
3
+ > Inputs are the text fields that users fill in with different types of information. These include dates, passwords or even short answers. It’s a field where users can write alphanumeric texts.
4
+
5
+ [![documentation](https://img.shields.io/badge/read%20the%20doc-black?logo=readthedocs)](https://sui-components.vercel.app/workbench/atom/input/)
6
+ [![issue](https://img.shields.io/badge/report%20a%20bug-black?logo=openbugbounty&logoColor=red)](https://github.com/SUI-Components/sui-components/issues/new?&projects=4&template=bug-report.yml&assignees=&template=report-a-bug.yml&title=🪲+&labels=bug,component,atom,input)
7
+ [![npm](https://img.shields.io/npm/dt/%40s-ui/react-atom-input?logo=npm&labelColor=black)](https://www.npmjs.com/package/@s-ui/react-atom-input)
8
+
9
+ [![Issues open](https://img.shields.io/github/issues-search/SUI-Components/sui-components?query=is%3Aopen%20label%3Acomponent%20label%3Ainput&logo=openbugbounty&logoColor=red&label=issues%20open&color=red)](https://github.com/SUI-Components/sui-components/issues?q=is%3Aopen+label%3Acomponent+label%3Ainput)
10
+ [![NPM](https://img.shields.io/npm/l/%40s-ui%2Freact-atom-input)](https://github.com/SUI-Components/sui-components/blob/main/components/atom/input/LICENSE.md)
11
+
12
+ ## Installation
13
+
14
+ ```sh
15
+ ƛ npm install @s-ui/react-atom-input --save
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ### Add styles
21
+
22
+ To use the component's own styles, create a .scss file and import them inside.
23
+
24
+ ```scss
25
+ @import '~@s-ui/react-atom-input/lib/index';
26
+ ```
27
+
28
+ If you want to customize your components, create your own theme and add it to your component just **before**.
29
+
30
+ ```scss
31
+ @import 'custom-settings';
32
+ @import '~@s-ui/react-atom-input/lib/index';
33
+ ```
34
+
35
+ ### You can use native types like this
36
+
37
+ ```js
38
+ import AtomInput from '@s-ui/react-atom-input'
39
+
40
+ return <AtomInput type="number" /> // possible type options: text, number, date and password
41
+ ```
42
+
43
+ ### Non native Inputs
44
+
45
+ #### SUI-Password
46
+
47
+ In order to use SUI defined Password Input pass the prop `type='sui-password'` to the Input component.
48
+
49
+ ```js
50
+ import AtomInput from '@s-ui/react-atom-input'
51
+
52
+ return <AtomInput type="sui-password" />
53
+ ```
54
+
55
+ #### Mask
56
+
57
+ Wraps the https://unmanner.github.io/imaskjs/ lib, used if the input must follow a regex or a specific format/pattern . Using `type='mask'` activates this input, which will be expecting the `mask` prop type to be passed by.
58
+
59
+ ```js
60
+ const bankAccountMask = {
61
+ // checkout all options here https://unmanner.github.io/imaskjs/guide.html
62
+ mask: 'ES00 0000 0000 00 0000000000'
63
+ }
64
+
65
+ return <AtomInput type="mask" mask={bankAccountMask} placeholder="ES00 0000 0000 00 0000000000" />
66
+ ```
67
+
68
+ ### Sizes
69
+
70
+ There are defined 3 sizes (`MEDIUM`, `SMALL` and `XSMALL`) available at the exported object `inputSizes` and that can be set through the prop `size`
71
+
72
+ Related size Sass vars are:
73
+
74
+ ```scss
75
+ $h-atom-input--m: 40px;
76
+ $h-atom-input--s: 32px;
77
+ $h-atom-input--xs: 24px;
78
+ ```
79
+
80
+ ```js
81
+ <AtomInput size={inputSizes.SMALL} name="first" placeholder="Small input" />
82
+ ```
83
+
84
+ ### Addons
85
+
86
+ > [What are addons?](https://paper.dropbox.com/doc/SUI-Input-03mHJFkOCjviSZevsaTwm#:uid=125362683844628624581838&h2=Icons-and-addons-inside-the-in)
87
+
88
+ Addons are passed as prop, use **leftAddon** or **rightAddon** in order to set the position inside the Input
89
+
90
+ #### Addon usage
91
+
92
+ ```js
93
+ import AtomInput from '@s-ui/react-atom-input'
94
+
95
+ return <AtomInput leftAddon="http://" rightAddon="@schibsted.com" />
96
+ ```
97
+
98
+ ### Icons
99
+
100
+ Icons are passed as prop, use **leftIcon** or **rightIcon** in order to set the position inside the Input
101
+
102
+ ```js
103
+ import AtomInput from '@s-ui/react-atom-input'
104
+
105
+ const logo = 'my_logo.svg'
106
+ const leftIcon = () => <img src={logo} />
107
+
108
+ <AtomInput leftIcon={leftIcon} />
109
+ ```
110
+
111
+ You can also pass a handler for each Icon using the props **onClickLeftIcon** or **onClickRightIcon**
112
+
113
+ ```js
114
+ <AtomInput
115
+ name="second"
116
+ placeholder="Medium Input"
117
+ leftIcon={LeftIcon}
118
+ rightIcon={IconLocation}
119
+ onClickRightIcon={e => alert('clicked right icon')}
120
+ />
121
+ ```
122
+
123
+ ### Error states
124
+
125
+ There are 3 error states:
126
+
127
+ - error state = **true**, will show a **red** border around the input field
128
+ - error state = **false**, will show a **green** border around the input field
129
+ - error state = **null**, will show the by **default** border around the input field
130
+
131
+ ```js
132
+ <AtomInput name="second" placeholder="Success input" errorState={false} />
133
+ ```
134
+
135
+ ### Input states
136
+
137
+ There are 3 error states:
138
+
139
+ - input state = **'error'**, will show a **red** border around the input field
140
+ - input state = **'success'**, will show a **green** border around the input field
141
+ - input state = **'alert'**, will show a **orange** border around the input field
142
+ - input state = **null**, will show the by **default** border around the input field
143
+
144
+ ```js
145
+ <AtomInput name="second" placeholder="Success input" state="alert" />
146
+ ```
147
+
148
+ ### Form Usage
149
+
150
+ Each field returns its value on every onChange event so you can save it inside your form state.
151
+
152
+ ```jsx
153
+ import React from 'react'
154
+ import ReactDOM from 'react-dom'
155
+ import Input from '@s-ui/react-atom-input'
156
+ import Button from '@s-ui/react-atom-button'
157
+
158
+ class SimpleLoginForm extends React.Component {
159
+ constructor() {
160
+ super()
161
+ this.state = {
162
+ email: {
163
+ value: '',
164
+ errorState: null
165
+ },
166
+ password: {
167
+ value: '',
168
+ errorState: null
169
+ }
170
+ }
171
+
172
+ this.onChange = this.onChange.bind(this)
173
+ this.onSubmit = this.onSubmit.bind(this)
174
+ this.onBlur = this.onBlur.bind(this)
175
+ }
176
+
177
+ isEmail(value) {
178
+ return /(.+)@(.+){2,}\.(.+){2,}/.test(value)
179
+ }
180
+
181
+ onChange({value, field}) {
182
+ this.setState(
183
+ Object.assign({}, this.state, {
184
+ [field]: {
185
+ value,
186
+ errorState: null
187
+ }
188
+ })
189
+ )
190
+ }
191
+
192
+ onBlur({value, field}) {
193
+ let errorState = !this.isEmail(value)
194
+ this.setState({
195
+ [field]: {errorState, value}
196
+ })
197
+ }
198
+
199
+ onSubmit(ev) {
200
+ ev.preventDefault()
201
+ ev.stopPropagation()
202
+
203
+ window.alert(JSON.stringify(this.state))
204
+ }
205
+
206
+ render() {
207
+ const {email, password} = this.state
208
+ return (
209
+ <form>
210
+ <Input
211
+ type="text"
212
+ value={email.value}
213
+ onChange={({ev, value}) => this.onChange({value, field: 'email', ev})}
214
+ onBlur={ev => this.onBlur({value: ev.target.value, field: 'email'})}
215
+ errorState={this.state.email.errorState}
216
+ />
217
+ <Input
218
+ type="sui-password"
219
+ value={password.value}
220
+ onChange={({ev, value}) => this.onChange({value, field: 'password', ev})}
221
+ />
222
+ <Button onClick={this.onSubmit}>Login</Button>
223
+ </form>
224
+ )
225
+ }
226
+ }
227
+ ```
@@ -0,0 +1,19 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ var _excluded = ["children", "shape", "noBorder"];
4
+ import cx from 'classnames';
5
+ import PropTypes from 'prop-types';
6
+ import { BASE, INPUT_SHAPES } from '../config.js';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ var InputContainer = function InputContainer(_ref) {
9
+ var children = _ref.children,
10
+ shape = _ref.shape,
11
+ noBorder = _ref.noBorder,
12
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
13
+ return /*#__PURE__*/_jsx("div", _extends({
14
+ className: cx(BASE + "_Container", shape && BASE + "_Container-shape-" + shape, noBorder && BASE + "_Container-noBorder")
15
+ }, props, {
16
+ children: children
17
+ }));
18
+ };
19
+ export default InputContainer;
@@ -0,0 +1,25 @@
1
+ $base-class-container: '#{$base-class}_Container';
2
+
3
+ #{$base-class-container} {
4
+ display: flex;
5
+ flex-grow: 1;
6
+ width: 100%;
7
+ border-radius: $bdrs-atom-input;
8
+ $this: &;
9
+ &:not(#{$base-class-container}-noBorder) {
10
+ border-radius: $bdrs-atom-input;
11
+ &#{$this}-shape {
12
+ @each $shapeMapKey, $shapeMapValue in $bdrs-atom-input-shapes {
13
+ &-#{$shapeMapKey} {
14
+ border-radius: $shapeMapValue;
15
+ }
16
+ }
17
+ }
18
+ &#{$this}:focus-within:has(#{$base-class-input}:focus-visible) {
19
+ outline-style: solid;
20
+ outline-color: transparentize($c-primary, 0.2);
21
+ outline-width: 2px;
22
+ outline-offset: 2px;
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,141 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ var _excluded = ["as", "disabled", "readOnly", "hideInput", "noBorder", "id", "name", "onBlur", "onFocus", "onPaste", "onCopy", "placeholder", "reference", "size", "errorState", "state", "type", "value", "charsSize", "tabIndex", "ariaLabel", "maxLength", "minLength", "defaultValue", "min", "max", "step", "autoComplete", "autoFocus", "onChange", "onEnter", "onEnterKey", "onKeyDown", "onKeyPress", "required", "pattern", "inputMode", "shape", "children", "className"];
4
+ import { forwardRef } from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import useMergeRefs from '@s-ui/react-hooks/lib/useMergeRefs';
7
+ import PolymorphicElement from '@s-ui/react-primitive-polymorphic-element';
8
+ import { getClassNames, INPUT_SHAPES, INPUT_STATES, noop, SIZES } from '../../config.js';
9
+ import isValidInputValue from '../../helpers/isValidInputValue.js';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ var Input = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
12
+ var _ref$as = _ref.as,
13
+ as = _ref$as === void 0 ? 'input' : _ref$as,
14
+ disabled = _ref.disabled,
15
+ readOnly = _ref.readOnly,
16
+ hideInput = _ref.hideInput,
17
+ noBorder = _ref.noBorder,
18
+ id = _ref.id,
19
+ name = _ref.name,
20
+ onBlur = _ref.onBlur,
21
+ onFocus = _ref.onFocus,
22
+ onPaste = _ref.onPaste,
23
+ onCopy = _ref.onCopy,
24
+ placeholder = _ref.placeholder,
25
+ reference = _ref.reference,
26
+ size = _ref.size,
27
+ errorState = _ref.errorState,
28
+ state = _ref.state,
29
+ type = _ref.type,
30
+ value = _ref.value,
31
+ charsSize = _ref.charsSize,
32
+ tabIndex = _ref.tabIndex,
33
+ ariaLabel = _ref.ariaLabel,
34
+ maxLength = _ref.maxLength,
35
+ minLength = _ref.minLength,
36
+ defaultValue = _ref.defaultValue,
37
+ min = _ref.min,
38
+ max = _ref.max,
39
+ step = _ref.step,
40
+ autoComplete = _ref.autoComplete,
41
+ autoFocus = _ref.autoFocus,
42
+ _ref$onChange = _ref.onChange,
43
+ onChange = _ref$onChange === void 0 ? noop : _ref$onChange,
44
+ _ref$onEnter = _ref.onEnter,
45
+ onEnter = _ref$onEnter === void 0 ? noop : _ref$onEnter,
46
+ _ref$onEnterKey = _ref.onEnterKey,
47
+ onEnterKey = _ref$onEnterKey === void 0 ? 'Enter' : _ref$onEnterKey,
48
+ _ref$onKeyDown = _ref.onKeyDown,
49
+ onKeyDown = _ref$onKeyDown === void 0 ? noop : _ref$onKeyDown,
50
+ _ref$onKeyPress = _ref.onKeyPress,
51
+ onKeyPress = _ref$onKeyPress === void 0 ? noop : _ref$onKeyPress,
52
+ required = _ref.required,
53
+ pattern = _ref.pattern,
54
+ inputMode = _ref.inputMode,
55
+ shape = _ref.shape,
56
+ children = _ref.children,
57
+ classNameProp = _ref.className,
58
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
59
+ var changeHandler = function changeHandler(ev) {
60
+ var _ev$target = ev.target,
61
+ value = _ev$target.value,
62
+ name = _ev$target.name;
63
+ onChange(ev, {
64
+ value: value,
65
+ name: name
66
+ });
67
+ };
68
+ var handleKeyDown = function handleKeyDown(ev) {
69
+ var _ev$target2 = ev.target,
70
+ value = _ev$target2.value,
71
+ name = _ev$target2.name;
72
+ var key = ev.key;
73
+ if (isValidInputValue(event, {
74
+ type: type,
75
+ onEnterKey: onEnterKey
76
+ })) {
77
+ onKeyDown(ev, {
78
+ value: value,
79
+ name: name
80
+ });
81
+ if (typeof onEnterKey === 'string') {
82
+ key === onEnterKey && onEnter(ev, {
83
+ value: value,
84
+ name: name
85
+ });
86
+ } else if (Array.isArray(onEnterKey)) {
87
+ onEnterKey.includes(key) && onEnter(ev, {
88
+ value: value,
89
+ name: name
90
+ });
91
+ }
92
+ }
93
+ };
94
+ var className = getClassNames({
95
+ size: size,
96
+ charsSize: charsSize,
97
+ hideInput: hideInput,
98
+ noBorder: noBorder,
99
+ readOnly: readOnly,
100
+ errorState: errorState,
101
+ state: state,
102
+ shape: shape,
103
+ className: classNameProp
104
+ });
105
+ return /*#__PURE__*/_jsx(PolymorphicElement, _extends({
106
+ as: as,
107
+ className: className,
108
+ tabIndex: tabIndex,
109
+ "aria-label": ariaLabel,
110
+ disabled: disabled,
111
+ readOnly: readOnly,
112
+ id: id,
113
+ name: name,
114
+ onChange: changeHandler,
115
+ onFocus: onFocus,
116
+ onPaste: onPaste,
117
+ onCopy: onCopy,
118
+ onBlur: onBlur,
119
+ onKeyDown: handleKeyDown,
120
+ onKeyPress: onKeyPress,
121
+ placeholder: placeholder,
122
+ ref: useMergeRefs.apply(void 0, [reference, forwardedRef].filter(Boolean)),
123
+ type: type,
124
+ value: value,
125
+ size: charsSize,
126
+ defaultValue: defaultValue,
127
+ maxLength: maxLength,
128
+ minLength: minLength,
129
+ max: max,
130
+ min: min,
131
+ step: step,
132
+ autoComplete: autoComplete,
133
+ autoFocus: autoFocus,
134
+ required: required,
135
+ pattern: pattern,
136
+ inputMode: inputMode,
137
+ children: as === 'input' ? undefined : children
138
+ }, props));
139
+ });
140
+ export default Input;
141
+ export { SIZES as inputSizes, INPUT_STATES as inputStates };
@@ -0,0 +1,93 @@
1
+ $base-class-input: '#{$base-class}-input';
2
+ $class-read-only: '#{$base-class-input}--readOnly';
3
+
4
+ #{$base-class-input} {
5
+ appearance: none;
6
+ -moz-appearance: none;
7
+ -webkit-appearance: none;
8
+
9
+ @include sui-atom-input-input;
10
+ border-radius: $bdrs-atom-input;
11
+ min-height: auto;
12
+ text-overflow: $tov-atom-input-placeholder;
13
+ flex-grow: 1;
14
+ &--charsSize {
15
+ width: inherit;
16
+ }
17
+
18
+ &--hidden {
19
+ display: none;
20
+ }
21
+
22
+ &--readOnly {
23
+ background: $bgc-atom-input-read-only;
24
+ border: $bd-atom-input-read-only;
25
+ color: $c-atom-input-read-only;
26
+ }
27
+
28
+ @include atom-input-shape-wrapper(
29
+ $base-class,
30
+ $base-class-input,
31
+ $bdrs-atom-input-shapes,
32
+ $sizes-atom-input,
33
+ $bdrs-atom-input,
34
+ $h-atom-input--m
35
+ );
36
+
37
+ &#{$base-class-input}--noBorder,
38
+ &#{$base-class-input}--noBorder:disabled {
39
+ border: 0;
40
+ &:focus {
41
+ border: 0;
42
+ box-shadow: none;
43
+ outline: 0;
44
+ }
45
+ }
46
+
47
+ &::placeholder {
48
+ color: $c-atom-input-placeholder;
49
+ }
50
+
51
+ &:disabled {
52
+ pointer-events: none;
53
+
54
+ &:not(#{$class-read-only}) {
55
+ -webkit-text-fill-color: $c-atom-input-disabled;
56
+
57
+ background: $bgc-atom-input-disabled;
58
+ color: $c-atom-input-disabled;
59
+ }
60
+ }
61
+
62
+ &:focus {
63
+ //@include sui-atom-input-input-focus;
64
+ outline: none;
65
+ }
66
+
67
+ @each $type, $attr in $sizes-atom-input {
68
+ &-size-#{$type} {
69
+ height: $attr;
70
+ min-height: $attr;
71
+ }
72
+ }
73
+
74
+ @each $state, $color in $states-atom-input {
75
+ &.sui-AtomInput-input--state-#{$state} {
76
+ border-color: $color;
77
+
78
+ &:focus {
79
+ //box-shadow: $bxsh-atom-input-size $color;
80
+ }
81
+ }
82
+ }
83
+
84
+ &[type='number'] {
85
+ -moz-appearance: textfield;
86
+
87
+ &::-webkit-outer-spin-button,
88
+ &::-webkit-inner-spin-button {
89
+ appearance: none;
90
+ margin: 0;
91
+ }
92
+ }
93
+ }
@@ -0,0 +1,30 @@
1
+ $bgc-atom-input-disabled: $c-gray-lightest !default;
2
+ $c-atom-input-placeholder: $c-gray-dark !default;
3
+ $c-atom-input-disabled: $c-atom-input-placeholder !default;
4
+ $bd-atom-input-disabled: $bd-atom-input-base !default;
5
+ $m-atom-input-type-left: $m-m !default;
6
+ $m-atom-input-type-right: $m-m !default;
7
+ $bdrs-atom-input: $bdrs-m !default;
8
+ $bdrs-atom-input-shapes: (
9
+ square: $bdrs-none,
10
+ rounded: $bdrs-m,
11
+ circle: 100dvh
12
+ ) !default;
13
+ $tov-atom-input-placeholder: unset !default;
14
+ $h-atom-input--xl: 7 * $sz-base !default; // 56px
15
+ $h-atom-input--l: 6 * $sz-base !default; // 48px
16
+ $h-atom-input--m: 5 * $sz-base !default; // 40px
17
+ $h-atom-input--s: 4 * $sz-base !default; // 32px
18
+ $h-atom-input--xs: 3 * $sz-base !default; // 24px
19
+
20
+ $c-atom-input--success: $c-success !default;
21
+ $c-atom-input--error: $c-error !default;
22
+ $c-atom-input--alert: $c-alert !default;
23
+
24
+ $sizes-atom-input: xl $h-atom-input--xl, l $h-atom-input--l, m $h-atom-input--m, xs $h-atom-input--xs,
25
+ s $h-atom-input--s !default;
26
+ $states-atom-input: success $c-atom-input--success, error $c-atom-input--error, alert $c-atom-input--alert !default;
27
+
28
+ $bgc-atom-input-read-only: $bgc-atom-input !default;
29
+ $c-atom-input-read-only: $c-atom-input !default;
30
+ $bd-atom-input-read-only: $bd-atom-input-base !default;
@@ -0,0 +1,32 @@
1
+ import cx from 'classnames';
2
+ import PropTypes from 'prop-types';
3
+ import { INPUT_SHAPES, SIZES } from '../../../config.js';
4
+ import { ADDON_TYPES, BASE_CLASS_ADDON_WRAPPER, getClassName } from './config.js';
5
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
+ var InputAddon = function InputAddon(_ref) {
7
+ var leftAddon = _ref.leftAddon,
8
+ rightAddon = _ref.rightAddon,
9
+ shape = _ref.shape,
10
+ size = _ref.size,
11
+ children = _ref.children;
12
+ if (!(leftAddon || rightAddon)) {
13
+ return children;
14
+ }
15
+ return /*#__PURE__*/_jsxs("div", {
16
+ className: cx(BASE_CLASS_ADDON_WRAPPER, shape && BASE_CLASS_ADDON_WRAPPER + "-shape-" + shape, size && BASE_CLASS_ADDON_WRAPPER + "-size-" + size),
17
+ children: [leftAddon && /*#__PURE__*/_jsx("span", {
18
+ className: getClassName({
19
+ type: ADDON_TYPES.LEFT,
20
+ shape: shape
21
+ }),
22
+ children: leftAddon
23
+ }), children, rightAddon && /*#__PURE__*/_jsx("span", {
24
+ className: getClassName({
25
+ type: ADDON_TYPES.RIGHT,
26
+ shape: shape
27
+ }),
28
+ children: rightAddon
29
+ })]
30
+ });
31
+ };
32
+ export default InputAddon;
@@ -0,0 +1,12 @@
1
+ import cx from 'classnames';
2
+ import { BASE } from '../../../config.js';
3
+ export var BASE_CLASS_ADDON = BASE + "--withAddon";
4
+ export var BASE_CLASS_ADDON_WRAPPER = BASE_CLASS_ADDON + "Wrapper";
5
+ export var ADDON_TYPES = {
6
+ LEFT: 'left',
7
+ RIGHT: 'right'
8
+ };
9
+ export var getClassName = function getClassName(_ref) {
10
+ var type = _ref.type;
11
+ return cx(BASE_CLASS_ADDON, BASE_CLASS_ADDON + "--" + type);
12
+ };
@@ -0,0 +1,35 @@
1
+ #{$base-class}--withAddon {
2
+ align-items: center;
3
+ background-color: $bgc-atom-input-addon;
4
+ border-color: $bdc-atom-input-addon;
5
+ border-style: solid;
6
+ color: $c-atom-input-addon;
7
+ display: flex;
8
+ flex-direction: column;
9
+ height: inherit;
10
+ justify-content: center;
11
+ line-height: inherit;
12
+ padding-left: $p-atom-input-addon-left;
13
+ padding-right: $p-atom-input-addon-right;
14
+
15
+ &--right {
16
+ border-width: $bdw-atom-input-addon-right;
17
+ }
18
+
19
+ &--left {
20
+ border-width: $bdw-atom-input-addon-left;
21
+ }
22
+
23
+ &Wrapper {
24
+ display: flex;
25
+ flex-grow: 1;
26
+ @include atom-input-shape-wrapper(
27
+ $base-class,
28
+ #{'.sui-AtomInput--withAddonWrapper'},
29
+ $bdrs-atom-input-shapes,
30
+ $sizes-atom-input,
31
+ $bdrs-atom-input,
32
+ $h-atom-input--m
33
+ );
34
+ }
35
+ }
@@ -0,0 +1,7 @@
1
+ $bdw-atom-input-addon-right: $bdw-s $bdw-s $bdw-s 0 !default;
2
+ $bdw-atom-input-addon-left: $bdw-s 0 $bdw-s $bdw-s !default;
3
+ $bgc-atom-input-addon: $c-gray-light-5 !default;
4
+ $bdc-atom-input-addon: $c-gray-light !default;
5
+ $c-atom-input-addon: $c-gray-light-1 !default;
6
+ $p-atom-input-addon-left: $p-l !default;
7
+ $p-atom-input-addon-right: $p-l !default;
@@ -0,0 +1,21 @@
1
+ import PropTypes from 'prop-types';
2
+ import { BASE_CLASS_BUTTON } from './config.js';
3
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
+ var InputButton = function InputButton(_ref) {
5
+ var button = _ref.button,
6
+ children = _ref.children;
7
+ if (button === undefined) {
8
+ return children;
9
+ }
10
+ return /*#__PURE__*/_jsxs("div", {
11
+ className: BASE_CLASS_BUTTON,
12
+ children: [/*#__PURE__*/_jsx("div", {
13
+ className: BASE_CLASS_BUTTON + "-input",
14
+ children: children
15
+ }), /*#__PURE__*/_jsx("div", {
16
+ className: BASE_CLASS_BUTTON + "-button",
17
+ children: button
18
+ })]
19
+ });
20
+ };
21
+ export default InputButton;
@@ -0,0 +1,2 @@
1
+ import { BASE } from '../../../config.js';
2
+ export var BASE_CLASS_BUTTON = BASE + "--withButton";
@@ -0,0 +1,13 @@
1
+ #{$base-class}--withButton {
2
+ display: flex;
3
+ width: 100%;
4
+
5
+ &-input {
6
+ flex: 1;
7
+ width: 100%;
8
+ }
9
+
10
+ &-button {
11
+ margin-left: $m-m;
12
+ }
13
+ }