@snack-uikit/fields 0.8.3-preview-85c5f47b.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 (172) hide show
  1. package/CHANGELOG.md +655 -0
  2. package/LICENSE +201 -0
  3. package/README.md +329 -0
  4. package/dist/components/FieldDate/FieldDate.d.ts +29 -0
  5. package/dist/components/FieldDate/FieldDate.js +152 -0
  6. package/dist/components/FieldDate/constants.d.ts +10 -0
  7. package/dist/components/FieldDate/constants.js +28 -0
  8. package/dist/components/FieldDate/hooks/index.d.ts +1 -0
  9. package/dist/components/FieldDate/hooks/index.js +1 -0
  10. package/dist/components/FieldDate/hooks/useDateField.d.ts +20 -0
  11. package/dist/components/FieldDate/hooks/useDateField.js +180 -0
  12. package/dist/components/FieldDate/hooks/useDateFieldHelpers.d.ts +10 -0
  13. package/dist/components/FieldDate/hooks/useDateFieldHelpers.js +66 -0
  14. package/dist/components/FieldDate/hooks/useFocusHandlers.d.ts +15 -0
  15. package/dist/components/FieldDate/hooks/useFocusHandlers.js +33 -0
  16. package/dist/components/FieldDate/hooks/useHandlers.d.ts +6 -0
  17. package/dist/components/FieldDate/hooks/useHandlers.js +9 -0
  18. package/dist/components/FieldDate/index.d.ts +1 -0
  19. package/dist/components/FieldDate/index.js +1 -0
  20. package/dist/components/FieldDate/styles.module.css +44 -0
  21. package/dist/components/FieldDate/types.d.ts +6 -0
  22. package/dist/components/FieldDate/types.js +1 -0
  23. package/dist/components/FieldDate/utils.d.ts +5 -0
  24. package/dist/components/FieldDate/utils.js +39 -0
  25. package/dist/components/FieldDecorator/FieldDecorator.d.ts +20 -0
  26. package/dist/components/FieldDecorator/FieldDecorator.js +26 -0
  27. package/dist/components/FieldDecorator/Footer.d.ts +24 -0
  28. package/dist/components/FieldDecorator/Footer.js +39 -0
  29. package/dist/components/FieldDecorator/Header.d.ts +20 -0
  30. package/dist/components/FieldDecorator/Header.js +8 -0
  31. package/dist/components/FieldDecorator/index.d.ts +1 -0
  32. package/dist/components/FieldDecorator/index.js +1 -0
  33. package/dist/components/FieldDecorator/styles.module.css +177 -0
  34. package/dist/components/FieldSecure/FieldSecure.d.ts +29 -0
  35. package/dist/components/FieldSecure/FieldSecure.js +55 -0
  36. package/dist/components/FieldSecure/index.d.ts +1 -0
  37. package/dist/components/FieldSecure/index.js +1 -0
  38. package/dist/components/FieldSelect/FieldSelect.d.ts +16 -0
  39. package/dist/components/FieldSelect/FieldSelect.js +34 -0
  40. package/dist/components/FieldSelect/FieldSelectBase.d.ts +30 -0
  41. package/dist/components/FieldSelect/FieldSelectBase.js +51 -0
  42. package/dist/components/FieldSelect/FieldSelectMulti.d.ts +36 -0
  43. package/dist/components/FieldSelect/FieldSelectMulti.js +89 -0
  44. package/dist/components/FieldSelect/FieldSelectSingle.d.ts +35 -0
  45. package/dist/components/FieldSelect/FieldSelectSingle.js +76 -0
  46. package/dist/components/FieldSelect/constants.d.ts +3 -0
  47. package/dist/components/FieldSelect/constants.js +2 -0
  48. package/dist/components/FieldSelect/helpers/getArrowIcon.d.ts +8 -0
  49. package/dist/components/FieldSelect/helpers/getArrowIcon.js +5 -0
  50. package/dist/components/FieldSelect/helpers/getDisplayedValue.d.ts +9 -0
  51. package/dist/components/FieldSelect/helpers/getDisplayedValue.js +12 -0
  52. package/dist/components/FieldSelect/helpers/index.d.ts +2 -0
  53. package/dist/components/FieldSelect/helpers/index.js +2 -0
  54. package/dist/components/FieldSelect/hooks/index.d.ts +3 -0
  55. package/dist/components/FieldSelect/hooks/index.js +3 -0
  56. package/dist/components/FieldSelect/hooks/useFilteredOptions.d.ts +7 -0
  57. package/dist/components/FieldSelect/hooks/useFilteredOptions.js +6 -0
  58. package/dist/components/FieldSelect/hooks/useList.d.ts +36 -0
  59. package/dist/components/FieldSelect/hooks/useList.js +52 -0
  60. package/dist/components/FieldSelect/hooks/useListNavigation.d.ts +26 -0
  61. package/dist/components/FieldSelect/hooks/useListNavigation.js +48 -0
  62. package/dist/components/FieldSelect/index.d.ts +1 -0
  63. package/dist/components/FieldSelect/index.js +1 -0
  64. package/dist/components/FieldSelect/styles.module.css +74 -0
  65. package/dist/components/FieldSelect/types.d.ts +53 -0
  66. package/dist/components/FieldSelect/types.js +5 -0
  67. package/dist/components/FieldText/FieldText.d.ts +25 -0
  68. package/dist/components/FieldText/FieldText.js +52 -0
  69. package/dist/components/FieldText/index.d.ts +1 -0
  70. package/dist/components/FieldText/index.js +1 -0
  71. package/dist/components/FieldTextArea/FieldTextArea.d.ts +30 -0
  72. package/dist/components/FieldTextArea/FieldTextArea.js +54 -0
  73. package/dist/components/FieldTextArea/index.d.ts +1 -0
  74. package/dist/components/FieldTextArea/index.js +1 -0
  75. package/dist/components/FieldTextArea/styles.module.css +48 -0
  76. package/dist/components/index.d.ts +6 -0
  77. package/dist/components/index.js +6 -0
  78. package/dist/constants.d.ts +10 -0
  79. package/dist/constants.js +12 -0
  80. package/dist/helperComponents/ButtonCopyValue/ButtonCopyValue.d.ts +11 -0
  81. package/dist/helperComponents/ButtonCopyValue/ButtonCopyValue.js +24 -0
  82. package/dist/helperComponents/ButtonCopyValue/helpers.d.ts +7 -0
  83. package/dist/helperComponents/ButtonCopyValue/helpers.js +14 -0
  84. package/dist/helperComponents/ButtonCopyValue/index.d.ts +1 -0
  85. package/dist/helperComponents/ButtonCopyValue/index.js +1 -0
  86. package/dist/helperComponents/ButtonCopyValue/styles.module.css +47 -0
  87. package/dist/helperComponents/ButtonHideValue/ButtonHideValue.d.ts +12 -0
  88. package/dist/helperComponents/ButtonHideValue/ButtonHideValue.js +15 -0
  89. package/dist/helperComponents/ButtonHideValue/index.d.ts +1 -0
  90. package/dist/helperComponents/ButtonHideValue/index.js +1 -0
  91. package/dist/helperComponents/ButtonHideValue/styles.module.css +47 -0
  92. package/dist/helperComponents/FieldContainerPrivate/FieldContainerPrivate.d.ts +21 -0
  93. package/dist/helperComponents/FieldContainerPrivate/FieldContainerPrivate.js +27 -0
  94. package/dist/helperComponents/FieldContainerPrivate/index.d.ts +1 -0
  95. package/dist/helperComponents/FieldContainerPrivate/index.js +1 -0
  96. package/dist/helperComponents/FieldContainerPrivate/styles.module.css +197 -0
  97. package/dist/helperComponents/TextArea/TextArea.d.ts +32 -0
  98. package/dist/helperComponents/TextArea/TextArea.js +27 -0
  99. package/dist/helperComponents/TextArea/index.d.ts +1 -0
  100. package/dist/helperComponents/TextArea/index.js +1 -0
  101. package/dist/helperComponents/TextArea/styles.module.css +32 -0
  102. package/dist/helperComponents/index.d.ts +4 -0
  103. package/dist/helperComponents/index.js +4 -0
  104. package/dist/hooks/index.d.ts +2 -0
  105. package/dist/hooks/index.js +2 -0
  106. package/dist/hooks/useCopyButton.d.ts +10 -0
  107. package/dist/hooks/useCopyButton.js +12 -0
  108. package/dist/hooks/useHideButton.d.ts +12 -0
  109. package/dist/hooks/useHideButton.js +20 -0
  110. package/dist/index.d.ts +1 -0
  111. package/dist/index.js +1 -0
  112. package/dist/styles.module.css +0 -0
  113. package/package.json +53 -0
  114. package/src/components/FieldDate/FieldDate.tsx +339 -0
  115. package/src/components/FieldDate/constants.ts +33 -0
  116. package/src/components/FieldDate/hooks/index.ts +1 -0
  117. package/src/components/FieldDate/hooks/useDateField.ts +227 -0
  118. package/src/components/FieldDate/hooks/useDateFieldHelpers.ts +96 -0
  119. package/src/components/FieldDate/hooks/useFocusHandlers.ts +46 -0
  120. package/src/components/FieldDate/hooks/useHandlers.ts +15 -0
  121. package/src/components/FieldDate/index.ts +1 -0
  122. package/src/components/FieldDate/styles.module.scss +58 -0
  123. package/src/components/FieldDate/types.ts +6 -0
  124. package/src/components/FieldDate/utils.ts +44 -0
  125. package/src/components/FieldDecorator/FieldDecorator.tsx +69 -0
  126. package/src/components/FieldDecorator/Footer.tsx +105 -0
  127. package/src/components/FieldDecorator/Header.tsx +52 -0
  128. package/src/components/FieldDecorator/index.ts +1 -0
  129. package/src/components/FieldDecorator/styles.module.scss +176 -0
  130. package/src/components/FieldSecure/FieldSecure.tsx +170 -0
  131. package/src/components/FieldSecure/index.ts +1 -0
  132. package/src/components/FieldSelect/FieldSelect.tsx +41 -0
  133. package/src/components/FieldSelect/FieldSelectBase.tsx +221 -0
  134. package/src/components/FieldSelect/FieldSelectMulti.tsx +161 -0
  135. package/src/components/FieldSelect/FieldSelectSingle.tsx +131 -0
  136. package/src/components/FieldSelect/constants.ts +4 -0
  137. package/src/components/FieldSelect/helpers/getArrowIcon.ts +6 -0
  138. package/src/components/FieldSelect/helpers/getDisplayedValue.ts +24 -0
  139. package/src/components/FieldSelect/helpers/index.ts +2 -0
  140. package/src/components/FieldSelect/hooks/index.ts +3 -0
  141. package/src/components/FieldSelect/hooks/useFilteredOptions.ts +23 -0
  142. package/src/components/FieldSelect/hooks/useList.ts +85 -0
  143. package/src/components/FieldSelect/hooks/useListNavigation.ts +81 -0
  144. package/src/components/FieldSelect/index.ts +1 -0
  145. package/src/components/FieldSelect/styles.module.scss +87 -0
  146. package/src/components/FieldSelect/types.ts +78 -0
  147. package/src/components/FieldText/FieldText.tsx +154 -0
  148. package/src/components/FieldText/index.ts +1 -0
  149. package/src/components/FieldTextArea/FieldTextArea.tsx +171 -0
  150. package/src/components/FieldTextArea/index.ts +1 -0
  151. package/src/components/FieldTextArea/styles.module.scss +41 -0
  152. package/src/components/index.ts +6 -0
  153. package/src/constants.ts +11 -0
  154. package/src/helperComponents/ButtonCopyValue/ButtonCopyValue.tsx +55 -0
  155. package/src/helperComponents/ButtonCopyValue/helpers.tsx +19 -0
  156. package/src/helperComponents/ButtonCopyValue/index.ts +1 -0
  157. package/src/helperComponents/ButtonCopyValue/styles.module.scss +5 -0
  158. package/src/helperComponents/ButtonHideValue/ButtonHideValue.tsx +55 -0
  159. package/src/helperComponents/ButtonHideValue/index.ts +1 -0
  160. package/src/helperComponents/ButtonHideValue/styles.module.scss +5 -0
  161. package/src/helperComponents/FieldContainerPrivate/FieldContainerPrivate.tsx +78 -0
  162. package/src/helperComponents/FieldContainerPrivate/index.ts +1 -0
  163. package/src/helperComponents/FieldContainerPrivate/styles.module.scss +162 -0
  164. package/src/helperComponents/TextArea/TextArea.tsx +102 -0
  165. package/src/helperComponents/TextArea/index.ts +1 -0
  166. package/src/helperComponents/TextArea/styles.module.scss +35 -0
  167. package/src/helperComponents/index.ts +4 -0
  168. package/src/hooks/index.ts +2 -0
  169. package/src/hooks/useCopyButton.tsx +24 -0
  170. package/src/hooks/useHideButton.tsx +50 -0
  171. package/src/index.ts +1 -0
  172. package/src/styles.module.scss +55 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2023 Cloud technology Limited (Ltd.)
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,329 @@
1
+ # Fields
2
+
3
+ ## Todo
4
+ - сделать режим выбора периода в FieldDate.
5
+ - сделать маску ввода серого цвета в FieldDate
6
+ - сбрасывать состояние tabIndex-ов при потере фокуса c кнопок
7
+
8
+ ## Installation
9
+ `npm i @snack-uikit/fields`
10
+
11
+ [Changelog](./CHANGELOG.md)
12
+
13
+ Поля для форм
14
+
15
+ ## Example
16
+
17
+ ```tsx
18
+ import { useState } from 'react';
19
+ import { FieldDate, FieldSecure, FieldSelect, FieldText, FieldTextArea } from '@snack-uikit/fields';
20
+ import { PlaceholderSVG } from '@snack-uikit/icons';
21
+
22
+ const [value, setValue] = useState('11.11.1111');
23
+ const [isOpen, setIsOpen] = useState(false);
24
+
25
+ <FieldDate
26
+ value={value}
27
+ onChange={setValue}
28
+ open={isOpen}
29
+ onOpenChange={setIsOpen}
30
+ id='field-1'
31
+ name='field-1'
32
+ disabled={false}
33
+ readonly={false}
34
+ showCopyButton={true}
35
+ onFocus={() => {}}
36
+ onBlur={() => {}}
37
+ label='Select date'
38
+ labelTooltip='You can choose any date'
39
+ required={true}
40
+ hint='You have entered wrong date'
41
+ size={FieldDate.sizes.S}
42
+ validationState={FieldDate.validationStates.Default}
43
+ />
44
+
45
+ ...
46
+
47
+ const [value, setValue] = useState('1234');
48
+ const [isHidden, setIsHidden] = useState(false);
49
+
50
+ <FieldSecure
51
+ value={value}
52
+ onChange={setValue}
53
+ hidden={isHidden}
54
+ onHiddenChange={setIsHidden}
55
+ id='field-1'
56
+ name='field-1'
57
+ placeholder='Enter password'
58
+ maxLength={20}
59
+ allowMoreThanMaxLength={false}
60
+ disabled={false}
61
+ readonly={false}
62
+ showCopyButton={true}
63
+ onFocus={() => {}}
64
+ onBlur={() => {}}
65
+ label='Enter password'
66
+ labelTooltip='You can enter password here'
67
+ required={true}
68
+ hint='You have entered wrong password'
69
+ size={FieldSecure.sizes.S}
70
+ validationState={FieldSecure.validationStates.Error}
71
+ prefixIcon={<PlaceholderSVG/>}
72
+ />
73
+
74
+ ...
75
+
76
+ const [value, setValue] = useState('abc');
77
+
78
+ <FieldText
79
+ value={value}
80
+ onChange={setValue}
81
+ id='field-1'
82
+ name='field-1'
83
+ placeholder='Enter text'
84
+ maxLength={20}
85
+ allowMoreThanMaxLength={false}
86
+ disabled={false}
87
+ readonly={false}
88
+ showCopyButton={true}
89
+ onFocus={() => {}}
90
+ onBlur={() => {}}
91
+ label='Enter text'
92
+ labelTooltip='You can input any text'
93
+ required={true}
94
+ hint='You have entered wrong answer'
95
+ size={FieldText.sizes.S}
96
+ validationState={FieldText.validationStates.Error}
97
+ prefixIcon={<PlaceholderSVG/>}
98
+ />
99
+
100
+ ...
101
+
102
+ const [value, setValue] = useState('abc');
103
+
104
+ <FieldTextArea
105
+ value={value}
106
+ onChange={setValue}
107
+ id='field-1'
108
+ name='field-1'
109
+ placeholder='Enter text'
110
+ maxLength={20}
111
+ maxRows={8}
112
+ resizable={true}
113
+ allowMoreThanMaxLength={true}
114
+ disabled={false}
115
+ readonly={false}
116
+ showCopyButton={true}
117
+ onFocus={() => {}}
118
+ onBlur={() => {}}
119
+ label='Enter text'
120
+ labelTooltip='You can input any text'
121
+ required={true}
122
+ hint='You have entered wrong answer'
123
+ size={FieldTextArea.sizes.S}
124
+ validationState={FieldTextArea.validationStates.Error}
125
+ />
126
+
127
+ ...
128
+
129
+ const [value, setValue] = useState('1234');
130
+ const [isOpen, setIsOpen] = useState(false);
131
+
132
+ <FieldSelect
133
+ mode={FieldSelect.selectionModes.Single}
134
+ value={value}
135
+ onChange={setValue}
136
+ options={[{value: 'op1', label: 'Option 1'}, {value: 'op2', label: 'Option 2'}]}
137
+ open={isHidden}
138
+ onOpenChange={setIsOpen}
139
+ id='field-1'
140
+ name='field-1'
141
+ placeholder='Select an item'
142
+ noDataText={'No data'}
143
+ searchable={true}
144
+ disabled={false}
145
+ readonly={false}
146
+ showCopyButton={true}
147
+ onFocus={() => {}}
148
+ onBlur={() => {}}
149
+ label='Select an item'
150
+ labelTooltip='You can choose any option'
151
+ required={true}
152
+ hint='You have chosen wrong item'
153
+ size={FieldSelect.sizes.S}
154
+ validationState={FieldSelect.validationStates.Error}
155
+ prefixIcon={<PlaceholderSVG/>}
156
+ />
157
+ ```
158
+
159
+ [//]: DOCUMENTATION_SECTION_START
160
+ [//]: THIS_SECTION_IS_AUTOGENERATED_PLEASE_DONT_EDIT_IT
161
+ ## FieldDecorator
162
+ ### Props
163
+ | name | type | default value | description |
164
+ |------|------|---------------|-------------|
165
+ | children* | `ReactNode` | - | Контент |
166
+ | className | `string` | - | CSS-класс |
167
+ | disabled | `boolean` | - | Деактивирован ли элемент Является ли поле деактивированным |
168
+ | readonly | `boolean` | - | Является ли поле доступным только на чтение Доступно ли поле только на чтение |
169
+ | label | `string` | - | Лейбл |
170
+ | labelTooltip | `string` | - | Всплывающая подсказка лейбла |
171
+ | labelFor | `string` | - | Аттрибут for |
172
+ | required | `boolean` | - | Является ли поле обязательным |
173
+ | size | enum Size: `"s"`, `"m"`, `"l"` | Size.S | Размер |
174
+ | labelTooltipPlacement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | Tooltip.placements.Top | Расположение подсказки лейбла |
175
+ | length | `{ current: number; max?: number; }` | - | Допустимая длинна текста |
176
+ | hint | `string` | - | Подсказка внизу |
177
+ | validationState | enum ValidationState: `"default"`, `"error"`, `"warning"`, `"success"` | ValidationState.Default | Состояние валидации |
178
+ | showHintIcon | `boolean` | - | Отображать иконку подсказки |
179
+ ## FieldText
180
+ ### Props
181
+ | name | type | default value | description |
182
+ |------|------|---------------|-------------|
183
+ | showCopyButton | `boolean` | - | Показывать ли кнопку Копировать для поля (актуально только для `readonly = true`) |
184
+ | allowMoreThanMaxLength | `boolean` | - | Можно ли вводить больше разрешённого кол-ва символов |
185
+ | prefixIcon | `ReactElement<any, string \| JSXElementConstructor<any>>` | - | Иконка-префикс для поля |
186
+ | value | `string` | - | Значение input |
187
+ | onChange | `(value: string, e?: ChangeEvent<HTMLInputElement>) => void` | - | Колбек смены значения |
188
+ | disabled | `boolean` | - | Является ли поле деактивированным |
189
+ | readonly | `boolean` | - | Является ли поле доступным только для чтения |
190
+ | id | `string` | - | Значение html-атрибута id |
191
+ | name | `string` | - | Значение html-атрибута name |
192
+ | placeholder | `string` | - | Значение плейсхолдера |
193
+ | maxLength | `number` | - | |
194
+ | onFocus | `FocusEventHandler<HTMLInputElement>` | - | Колбек обработки получения фокуса |
195
+ | onBlur | `FocusEventHandler<HTMLInputElement>` | - | Колбек обработки потери фокуса |
196
+ | className | `string` | - | CSS-класс |
197
+ | label | `string` | - | Лейбл |
198
+ | labelTooltip | `string` | - | Всплывающая подсказка лейбла |
199
+ | required | `boolean` | - | Является ли поле обязательным |
200
+ | size | enum Size: `"s"`, `"m"`, `"l"` | Size.S | Размер |
201
+ | labelTooltipPlacement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | Tooltip.placements.Top | Расположение подсказки лейбла |
202
+ | hint | `string` | - | Подсказка внизу |
203
+ | validationState | enum ValidationState: `"default"`, `"error"`, `"warning"`, `"success"` | ValidationState.Default | Состояние валидации |
204
+ | showHintIcon | `boolean` | - | Отображать иконку подсказки |
205
+ | ref | `Ref<HTMLInputElement>` | - | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom |
206
+ | key | `Key` | - | |
207
+ ## FieldTextArea
208
+ ### Props
209
+ | name | type | default value | description |
210
+ |------|------|---------------|-------------|
211
+ | maxRows | `number` | - | Максимальное кол-во строк, до которого размер поля может быть увеличен |
212
+ | resizable | `boolean` | - | Может ли ли пользователь изменять размеры поля (если св-во не включено, поле автоматически меняет свой размер) |
213
+ | onChange | `(value: string, e?: ChangeEvent<HTMLTextAreaElement>) => void` | - | Колбек смены значения |
214
+ | showCopyButton | `boolean` | - | Показывать ли кнопку Копировать для поля (актуально только для `readonly = true`) |
215
+ | allowMoreThanMaxLength | `boolean` | true | Можно ли вводить больше разрешённого кол-ва символов |
216
+ | value | `string` | - | HTML-аттрибут value |
217
+ | disabled | `boolean` | - | Является ли поле деактивированным |
218
+ | readonly | `boolean` | - | Является ли поле доступным только на чтение |
219
+ | id | `string` | - | HTML-аттрибут id |
220
+ | name | `string` | - | HTML-аттрибут name |
221
+ | placeholder | `string` | - | Плейсхолдер |
222
+ | maxLength | `number` | - | Максимальное кол-во символов |
223
+ | onFocus | `FocusEventHandler<HTMLTextAreaElement>` | - | Колбек получения фокуса |
224
+ | onBlur | `FocusEventHandler<HTMLTextAreaElement>` | - | Колбек потери фокуса |
225
+ | className | `string` | - | CSS-класс |
226
+ | label | `string` | - | Лейбл |
227
+ | labelTooltip | `string` | - | Всплывающая подсказка лейбла |
228
+ | required | `boolean` | - | Является ли поле обязательным |
229
+ | size | enum Size: `"s"`, `"m"`, `"l"` | Size.S | Размер |
230
+ | labelTooltipPlacement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | Tooltip.placements.Top | Расположение подсказки лейбла |
231
+ | hint | `string` | - | Подсказка внизу |
232
+ | validationState | enum ValidationState: `"default"`, `"error"`, `"warning"`, `"success"` | ValidationState.Default | Состояние валидации |
233
+ | showHintIcon | `boolean` | - | Отображать иконку подсказки |
234
+ | ref | `Ref<HTMLTextAreaElement>` | - | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom |
235
+ | key | `Key` | - | |
236
+ ## FieldSecure
237
+ ### Props
238
+ | name | type | default value | description |
239
+ |------|------|---------------|-------------|
240
+ | hidden | `boolean` | - | Замаскированно ли значение поля |
241
+ | onHiddenChange | `(value: boolean) => void` | - | Колбек смены маскирования |
242
+ | showCopyButton | `boolean` | - | Отображать ли кнопку копирования |
243
+ | allowMoreThanMaxLength | `boolean` | - | Можно ли вводить больше разрешённого кол-ва символов |
244
+ | prefixIcon | `ReactElement<any, string \| JSXElementConstructor<any>>` | - | Иконка-префикс для поля |
245
+ | value | `string` | - | Значение input |
246
+ | onChange | `(value: string, e?: ChangeEvent<HTMLInputElement>) => void` | - | Колбек смены значения |
247
+ | disabled | `boolean` | - | Является ли поле деактивированным |
248
+ | readonly | `boolean` | - | Является ли поле доступным только для чтения |
249
+ | id | `string` | - | Значение html-атрибута id |
250
+ | name | `string` | - | Значение html-атрибута name |
251
+ | placeholder | `string` | - | Значение плейсхолдера |
252
+ | maxLength | `number` | - | |
253
+ | onFocus | `FocusEventHandler<HTMLInputElement>` | - | Колбек обработки получения фокуса |
254
+ | onBlur | `FocusEventHandler<HTMLInputElement>` | - | Колбек обработки потери фокуса |
255
+ | className | `string` | - | CSS-класс |
256
+ | label | `string` | - | Лейбл |
257
+ | labelTooltip | `string` | - | Всплывающая подсказка лейбла |
258
+ | required | `boolean` | - | Является ли поле обязательным |
259
+ | size | enum Size: `"s"`, `"m"`, `"l"` | Size.S | Размер |
260
+ | labelTooltipPlacement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | Tooltip.placements.Top | Расположение подсказки лейбла |
261
+ | hint | `string` | - | Подсказка внизу |
262
+ | validationState | enum ValidationState: `"default"`, `"error"`, `"warning"`, `"success"` | ValidationState.Default | Состояние валидации |
263
+ | showHintIcon | `boolean` | - | Отображать иконку подсказки |
264
+ | ref | `Ref<HTMLInputElement>` | - | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom |
265
+ | key | `Key` | - | |
266
+ ## FieldDate
267
+ ### Props
268
+ | name | type | default value | description |
269
+ |------|------|---------------|-------------|
270
+ | value* | `string` | - | Значение input |
271
+ | open | `boolean` | - | Открыт date-picker |
272
+ | onOpenChange | `(value: boolean) => void` | - | Колбек открытия пикера |
273
+ | onChange | `(value: string) => void` | - | Колбек смены значения |
274
+ | showCopyButton | `boolean` | - | Отображать ли кнопку копирования |
275
+ | locale | `Locale` | new Intl.Locale('ru-RU') | Текущая локаль календаря |
276
+ | disabled | `boolean` | - | Является ли поле деактивированным |
277
+ | readonly | `boolean` | - | Является ли поле доступным только для чтения |
278
+ | id | `string` | - | Значение html-атрибута id |
279
+ | name | `string` | - | Значение html-атрибута name |
280
+ | onFocus | `FocusEventHandler<HTMLInputElement>` | - | Колбек обработки получения фокуса |
281
+ | onBlur | `FocusEventHandler<HTMLInputElement>` | - | Колбек обработки потери фокуса |
282
+ | className | `string` | - | CSS-класс |
283
+ | label | `string` | - | Лейбл |
284
+ | labelTooltip | `string` | - | Всплывающая подсказка лейбла |
285
+ | required | `boolean` | - | Является ли поле обязательным |
286
+ | size | enum Size: `"s"`, `"m"`, `"l"` | Size.S | Размер |
287
+ | labelTooltipPlacement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | Tooltip.placements.Top | Расположение подсказки лейбла |
288
+ | hint | `string` | - | Подсказка внизу |
289
+ | validationState | enum ValidationState: `"default"`, `"error"`, `"warning"`, `"success"` | ValidationState.Default | Состояние валидации |
290
+ | showHintIcon | `boolean` | - | Отображать иконку подсказки |
291
+ | ref | `Ref<HTMLInputElement>` | - | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom |
292
+ | key | `Key` | - | |
293
+ ## FieldSelect
294
+ ### Props
295
+ | name | type | default value | description |
296
+ |------|------|---------------|-------------|
297
+ | options* | `Option[]` | - | Массив опций выпадающего списка |
298
+ | selectionMode | enum SelectionMode: `"single"`, `"multi"` | SelectionMode.Single | |
299
+ | open | `boolean` | - | Открыт ли выпадающий список |
300
+ | onOpenChange | `(value: boolean) => void` | - | Колбек открытия выпадающего списка |
301
+ | searchable | `boolean` | - | Можно ли искать опции внутри списка |
302
+ | showCopyButton | `boolean` | - | Показывать ли кнопку Копировать для поля (актуально только для readonly = true) |
303
+ | prefixIcon | `ReactElement<any, string \| JSXElementConstructor<any>>` | - | Иконка-префикс для поля |
304
+ | noDataText | `string` | - | Текст отсутствия доступных значений |
305
+ | locale | `Locale` | - | Текущая локаль |
306
+ | disabled | `boolean` | false | Является ли поле деактивированным |
307
+ | readonly | `boolean` | false | Является ли поле доступным только для чтения |
308
+ | id | `string` | - | Значение html-атрибута id |
309
+ | name | `string` | - | Значение html-атрибута name |
310
+ | placeholder | `string` | - | Значение плейсхолдера |
311
+ | onFocus | `FocusEventHandler<HTMLInputElement>` | - | Колбек обработки получения фокуса |
312
+ | onBlur | `FocusEventHandler<HTMLInputElement>` | - | Колбек обработки потери фокуса |
313
+ | className | `string` | - | CSS-класс |
314
+ | label | `string` | - | Лейбл |
315
+ | labelTooltip | `string` | - | Всплывающая подсказка лейбла |
316
+ | required | `boolean` | - | Является ли поле обязательным |
317
+ | size | enum Size: `"s"`, `"m"`, `"l"` | - | Размер |
318
+ | labelTooltipPlacement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | Tooltip.placements.Top | Расположение подсказки лейбла |
319
+ | hint | `string` | - | Подсказка внизу |
320
+ | validationState | enum ValidationState: `"default"`, `"error"`, `"warning"`, `"success"` | - | Состояние валидации |
321
+ | showHintIcon | `boolean` | - | Отображать иконку подсказки |
322
+ | value | `string \| string[]` | - | Выбранное значение: <br> - одно для single mode <br> - массив для multi mode |
323
+ | onChange | `((value: string) => void) \| ((value: string[]) => void)` | - | Колбек смены значения |
324
+ | ref | `Ref<HTMLInputElement>` | - | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom |
325
+ | key | `Key` | - | |
326
+ | getSelectedItemsText | `(amount: number) => string` | - | Колбек формирования текста |
327
+
328
+
329
+ [//]: DOCUMENTATION_SECTION_END
@@ -0,0 +1,29 @@
1
+ /// <reference types="react" />
2
+ import { InputPrivateProps, Size } from '@snack-uikit/input-private';
3
+ import { Tooltip } from '@snack-uikit/tooltip';
4
+ import { WithSupportProps } from '@snack-uikit/utils';
5
+ import { ValidationState } from '../../constants';
6
+ import { FieldDecoratorProps } from '../FieldDecorator';
7
+ type InputProps = Pick<InputPrivateProps, 'id' | 'name' | 'value' | 'disabled' | 'readonly' | 'onFocus' | 'onBlur'>;
8
+ type WrapperProps = Pick<FieldDecoratorProps, 'className' | 'label' | 'labelTooltip' | 'required' | 'hint' | 'showHintIcon' | 'size' | 'validationState' | 'labelTooltipPlacement'>;
9
+ type FieldDateOwnProps = {
10
+ /** Открыт date-picker */
11
+ open?: boolean;
12
+ /** Колбек открытия пикера */
13
+ onOpenChange?(value: boolean): void;
14
+ /** Колбек смены значения */
15
+ onChange?(value: string): void;
16
+ /** Отображать ли кнопку копирования */
17
+ showCopyButton?: boolean;
18
+ /** Текущая локаль календаря */
19
+ locale?: Intl.Locale;
20
+ };
21
+ export type FieldDateProps = WithSupportProps<FieldDateOwnProps & InputProps & WrapperProps>;
22
+ export declare const FieldDate: import("react").ForwardRefExoticComponent<{
23
+ 'data-test-id'?: string | undefined;
24
+ } & import("react").AriaAttributes & FieldDateOwnProps & InputProps & WrapperProps & import("react").RefAttributes<HTMLInputElement>> & {
25
+ sizes: typeof Size;
26
+ validationStates: typeof ValidationState;
27
+ labelTooltipPlacements: typeof Tooltip.placements;
28
+ };
29
+ export {};