@commercetools-uikit/selectable-search-input 0.0.0-canary-20230223135944

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) commercetools GmbH
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,159 @@
1
+ <!-- THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -->
2
+ <!-- This file is created by the `yarn generate-readme` script. -->
3
+
4
+ # SelectableSearchInput
5
+
6
+ ## Description
7
+
8
+ A controlled selectable search input component for single-line strings with validation states.
9
+
10
+ ## Installation
11
+
12
+ ```
13
+ yarn add @commercetools-uikit/selectable-search-input
14
+ ```
15
+
16
+ ```
17
+ npm --save install @commercetools-uikit/selectable-search-input
18
+ ```
19
+
20
+ Additionally install the peer dependencies (if not present)
21
+
22
+ ```
23
+ yarn add react react-intl
24
+ ```
25
+
26
+ ```
27
+ npm --save install react react-intl
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ ```jsx
33
+ import SelectableSearchInput from '@commercetools-uikit/selectable-search-input';
34
+
35
+ const value = {
36
+ text: 'foo',
37
+ option: 'bar',
38
+ };
39
+
40
+ const Example = () => (
41
+ <SelectableSearchInput
42
+ value={value}
43
+ onChange={(event) => alert(event.target.value)}
44
+ onSubmit={(val) => alert(val)}
45
+ onReset={() => alert('reset')}
46
+ options={[
47
+ { value: 'one', label: 'One' },
48
+ { value: 'two', label: 'Two' },
49
+ ]}
50
+ />
51
+ );
52
+
53
+ export default Example;
54
+ ```
55
+
56
+ ## Properties
57
+
58
+ | Props | Type | Required | Default | Description |
59
+ | -------------------------- | -------------------------------------------------------------------------------------- | :------: | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
60
+ | `id` | `string` | | | Used as HTML id property. An id is auto-generated when it is not specified. |
61
+ | `autoComplete` | `string` | | | Used as HTML autocomplete property |
62
+ | `aria-invalid` | `boolean` | | | Indicate if the value entered in the input is invalid. |
63
+ | `aria-errormessage` | `string` | | | HTML ID of an element containing an error message related to the input. |
64
+ | `name` | `string` | | | Used as HTML name of the input component property. |
65
+ | `value` | `Object`<br/>[See signature.](#signature-value) | ✅ | | Value of the input. Consists of text input and selected option. |
66
+ | `onChange` | `Function`<br/>[See signature.](#signature-onChange) | | | Called with the event of the input or dropdown when either the selectable dropdown or the text input have changed.&#xA;The change event from the text input has a suffix of `.textInput` and the change event from the dropdown has a suffix of `.dropdown`. |
67
+ | `onBlur` | `Function`<br/>[See signature.](#signature-onBlur) | | | Called when input is blurred |
68
+ | `onFocus` | `Function`<br/>[See signature.](#signature-onFocus) | | | Called when input is focused |
69
+ | `onSubmit` | `Function`<br/>[See signature.](#signature-onSubmit) | ✅ | | Handler when the search button is clicked. |
70
+ | `onReset` | `Function`<br/>[See signature.](#signature-onReset) | | | Handler when the clear button is clicked. |
71
+ | `isAutofocussed` | `boolean` | | | Focus the input on initial render |
72
+ | `isDisabled` | `boolean` | | | Indicates that the input cannot be modified (e.g not authorized, or changes currently saving). |
73
+ | `isReadOnly` | `boolean` | | | Indicates that the field is displaying read-only content |
74
+ | `hasError` | `boolean` | | | Indicates if the input has invalid values |
75
+ | `hasWarning` | `boolean` | | | Indicates if the input has warning values |
76
+ | `placeholder` | `string` | | | Placeholder text for the input |
77
+ | `isClearable` | `boolean` | | `true` | Indicates if the input should be cleared when the clear button is clicked.&#xA;Defaults to true. |
78
+ | `horizontalConstraint` | `union`<br/>Possible values:<br/>`10 , 11 , 12 , 13 , 14 , 15 , 16 , 'scale' , 'auto'` | | `'scale'` | Horizontal size limit of the input fields. |
79
+ | `options` | `union`<br/>Possible values:<br/>`TOption[] , TOptionObject[]` | ✅ | | Array of options that populate the select menu |
80
+ | `menuPortalZIndex` | `number` | | | z-index value for the menu portal |
81
+ | `menuPortalTarget` | `ReactSelectProps['menuPortalTarget']` | | | Dom element to portal the select menu to&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
82
+ | `menuShouldBlockScroll` | `ReactSelectProps['menuShouldBlockScroll']` | | | whether the menu should block scroll while open&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
83
+ | `onMenuInputChange` | `ReactSelectProps['onInputChange']` | | | Handle change events on the menu input&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
84
+ | `noMenuOptionsMessage` | `ReactSelectProps['noOptionsMessage']` | | | Can be used to render a custom value when there are no options (either because of no search results, or all options have been used, or there were none in the first place). Gets called with { inputValue: String }.&#xA;<br />&#xA;`inputValue` will be an empty string when no search text is present.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
85
+ | `isMenuSearchable` | `ReactSelectProps['isSearchable']` | | | Whether to enable search functionality.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
86
+ | `maxMenuHeight` | `ReactSelectProps['maxMenuHeight']` | | | Maximum height of the menu before scrolling&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
87
+ | `closeMenuOnSelect` | `ReactSelectProps['closeMenuOnSelect']` | | | Whether the menu should close after a value is selected. Defaults to `true`.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
88
+ | `menuHorizontalConstraint` | `union`<br/>Possible values:<br/>`3 , 4 , 5` | | `3` | Horizontal size limit for the dropdown menu. |
89
+ | `showSubmitButton` | `boolean` | | `true` | Show submit button in the input |
90
+
91
+ ## Signatures
92
+
93
+ ### Signature `value`
94
+
95
+ ```ts
96
+ {
97
+ text: string;
98
+ option: string;
99
+ }
100
+ ```
101
+
102
+ ### Signature `onChange`
103
+
104
+ ```ts
105
+ (event: TCustomEvent) => void
106
+ ```
107
+
108
+ ### Signature `onBlur`
109
+
110
+ ```ts
111
+ (event: TCustomEvent) => void
112
+ ```
113
+
114
+ ### Signature `onFocus`
115
+
116
+ ```ts
117
+ (event: TCustomEvent) => void
118
+ ```
119
+
120
+ ### Signature `onSubmit`
121
+
122
+ ```ts
123
+ (value: TValue) => void
124
+ ```
125
+
126
+ ### Signature `onReset`
127
+
128
+ ```ts
129
+ () => void
130
+ ```
131
+
132
+ ## `data-*` props
133
+
134
+ The component further forwards all `data-` attributes to the underlying `input` component.
135
+
136
+ ## Static methods
137
+
138
+ ### `SelectableSearchInput.isEmpty`
139
+
140
+ Returns `true` when the value is considered empty, which is when the value is empty or consists of spaces only.
141
+
142
+ ```js
143
+ SelectableSearchInput.isEmpty({
144
+ text: '',
145
+ option: '',
146
+ }); // -> true
147
+ SelectableSearchInput.isEmpty({
148
+ text: ' ',
149
+ option: 'bar',
150
+ }); // -> true
151
+ SelectableSearchInput.isEmpty({
152
+ text: 'foo',
153
+ option: 'bar',
154
+ }); // -> false
155
+ ```
156
+
157
+ ## Main Functions and use cases are:
158
+
159
+ - Input field for single-line strings. Used for selectable search.
@@ -0,0 +1,2 @@
1
+ export * from "./declarations/src/index";
2
+ export { default } from "./declarations/src/index";