colibri-ui 0.8.65 → 0.8.67

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 (260) hide show
  1. package/Accordion/Accordion.module.css +8 -7
  2. package/Accordion/index.js +1 -1
  3. package/Avatar/Avatar.module.css +50 -33
  4. package/Avatar/index.js +74 -37
  5. package/Badge/Badge.module.css +7 -7
  6. package/Badge/index.js +3 -9
  7. package/Badge/index.props.d.ts +0 -2
  8. package/Button/Button.module.css +95 -135
  9. package/Calendar/components/Month/Month.js +3 -5
  10. package/Calendar/components/Month/index.module.css +20 -19
  11. package/Calendar/components/Presets/index.module.css +4 -4
  12. package/Calendar/index.module.css +26 -23
  13. package/Calendar/utils/getPresets.js +2 -2
  14. package/Card/Card.d.ts +25 -0
  15. package/Card/Card.js +70 -0
  16. package/Card/Card.module.css +90 -0
  17. package/Card/index.d.ts +2 -0
  18. package/Card/index.js +9 -0
  19. package/Card/package.json +6 -0
  20. package/Checkbox/Checkbox.module.css +38 -28
  21. package/Checkbox/index.js +1 -0
  22. package/Chip/Chip.module.css +34 -24
  23. package/CodeField/CodeField.d.ts +29 -0
  24. package/CodeField/CodeField.js +316 -0
  25. package/CodeField/CodeField.module.css +211 -0
  26. package/CodeField/index.d.ts +2 -0
  27. package/CodeField/index.js +13 -0
  28. package/CodeField/package.json +6 -0
  29. package/Counter/Counter.module.css +11 -10
  30. package/Datepicker/Datepicker.module.css +1 -1
  31. package/Datepicker/components/DatePicker/index.module.css +22 -16
  32. package/Datepicker/components/TimePicker/index.module.css +21 -15
  33. package/DotsLoader/DotsLoader.module.css +5 -5
  34. package/DotsLoader/index.d.ts +1 -3
  35. package/DotsLoader/index.js +1 -14
  36. package/Drawer/Drawer.d.ts +43 -0
  37. package/Drawer/Drawer.js +227 -0
  38. package/Drawer/Drawer.module.css +280 -0
  39. package/Drawer/index.d.ts +2 -0
  40. package/Drawer/index.js +10 -0
  41. package/Drawer/package.json +6 -0
  42. package/Dropdown/Dropdown.module.css +6 -6
  43. package/Dropdown/index.js +26 -17
  44. package/Dropdown/index.props.d.ts +7 -6
  45. package/Dropzone/Dropzone.d.ts +30 -0
  46. package/Dropzone/Dropzone.js +258 -0
  47. package/Dropzone/Dropzone.module.css +164 -0
  48. package/Dropzone/index.d.ts +2 -0
  49. package/Dropzone/index.js +7 -0
  50. package/Dropzone/package.json +6 -0
  51. package/Editable/Editable.d.ts +18 -0
  52. package/Editable/Editable.js +166 -0
  53. package/Editable/Editable.module.css +61 -0
  54. package/Editable/index.d.ts +2 -0
  55. package/Editable/index.js +10 -0
  56. package/Editable/package.json +6 -0
  57. package/Grid/Grid.module.css +2 -2
  58. package/Grid/Item/Grid-Item.module.css +3 -3
  59. package/Grid/index.js +9 -6
  60. package/Grid/index.props.d.ts +4 -3
  61. package/Icons/Check.js +1 -1
  62. package/InputRadio/InputRadio.module.css +37 -34
  63. package/Menu/Menu.module.css +2 -2
  64. package/Menu/components/MenuItem/MenuItem.module.css +8 -8
  65. package/Modal/Modal.module.css +11 -11
  66. package/Modal/components/Close/Close.module.css +1 -1
  67. package/Modal/components/Content/Content.module.css +1 -1
  68. package/MultiSelect/components/MenuOverlay/index.js +2 -4
  69. package/MultiSelect/components/MenuOverlay/index.module.css +3 -3
  70. package/MultiSelect/index.js +1 -0
  71. package/MultiSelect/index.module.css +5 -5
  72. package/Progress/Progress.d.ts +20 -0
  73. package/Progress/Progress.js +109 -0
  74. package/Progress/Progress.module.css +191 -0
  75. package/Progress/index.d.ts +2 -0
  76. package/Progress/index.js +7 -0
  77. package/Progress/package.json +6 -0
  78. package/README.md +91 -2
  79. package/RadioGroup/RadioGroup.module.css +4 -4
  80. package/Rating/Rating.d.ts +24 -0
  81. package/Rating/Rating.js +131 -0
  82. package/Rating/Rating.module.css +219 -0
  83. package/Rating/index.d.ts +2 -0
  84. package/Rating/index.js +10 -0
  85. package/Rating/package.json +6 -0
  86. package/Select/components/MenuOverlay/index.module.css +1 -1
  87. package/Select/index.js +1 -0
  88. package/Select/index.module.css +3 -3
  89. package/Separator/Separator.module.css +2 -2
  90. package/Skeleton/Skeleton.module.css +4 -4
  91. package/Skeleton/index.js +10 -6
  92. package/Skeleton/index.props.d.ts +2 -2
  93. package/Status/index.module.css +18 -17
  94. package/Switch/Switch.module.css +41 -26
  95. package/Switch/index.js +1 -0
  96. package/TabsMenu/Tab/Tab.module.css +29 -26
  97. package/TabsMenu/TabsMenu.module.css +1 -1
  98. package/TextArea/TextArea.module.css +2 -2
  99. package/Theme/colors/index.d.ts +190 -38
  100. package/Theme/colors/theme_buenos_aires.d.ts +211 -31
  101. package/Theme/colors/theme_buenos_aires.js +139 -34
  102. package/Theme/colors/theme_jaipur.d.ts +251 -0
  103. package/Theme/colors/theme_jaipur.js +157 -0
  104. package/Theme/global.css +1 -1
  105. package/Theme/index.d.ts +973 -13
  106. package/Theme/index.js +2 -2
  107. package/Theme/themes/buenos_aires.d.ts +476 -0
  108. package/Theme/themes/buenos_aires.js +626 -150
  109. package/Theme/themes/jaipur.d.ts +628 -0
  110. package/Theme/themes/jaipur.js +635 -0
  111. package/Tooltip/Tooltip.module.css +8 -8
  112. package/Tooltip/index.js +4 -3
  113. package/Typography/Typography.module.css +151 -26
  114. package/Typography/index.props.d.ts +3 -3
  115. package/base/BaseInput/BaseInput.module.css +2 -2
  116. package/base/FormField/FormField.module.css +6 -2
  117. package/base/FormField/index.js +1 -0
  118. package/base/InputRoot/InputRoot.module.css +33 -26
  119. package/base/InputRoot/index.d.ts +1 -1
  120. package/base/InputRoot/index.js +3 -2
  121. package/base/InputRoot/index.props.d.ts +1 -0
  122. package/esm/Accordion/Accordion.module.css +8 -7
  123. package/esm/Accordion/index.js +1 -1
  124. package/esm/Avatar/Avatar.module.css +50 -33
  125. package/esm/Avatar/index.js +74 -37
  126. package/esm/Badge/Badge.module.css +7 -7
  127. package/esm/Badge/index.js +3 -9
  128. package/esm/Badge/index.props.d.ts +0 -2
  129. package/esm/Button/Button.module.css +95 -135
  130. package/esm/Calendar/components/Month/Month.js +3 -5
  131. package/esm/Calendar/components/Month/index.module.css +20 -19
  132. package/esm/Calendar/components/Presets/index.module.css +4 -4
  133. package/esm/Calendar/index.module.css +26 -23
  134. package/esm/Calendar/utils/getPresets.js +2 -2
  135. package/esm/Card/Card.d.ts +25 -0
  136. package/esm/Card/Card.js +61 -0
  137. package/esm/Card/Card.module.css +90 -0
  138. package/esm/Card/index.d.ts +2 -0
  139. package/esm/Checkbox/Checkbox.module.css +38 -28
  140. package/esm/Checkbox/index.js +1 -0
  141. package/esm/Chip/Chip.module.css +34 -24
  142. package/esm/CodeField/CodeField.d.ts +29 -0
  143. package/esm/CodeField/CodeField.js +303 -0
  144. package/esm/CodeField/CodeField.module.css +211 -0
  145. package/esm/CodeField/index.d.ts +2 -0
  146. package/esm/Counter/Counter.module.css +11 -10
  147. package/esm/Datepicker/Datepicker.module.css +1 -1
  148. package/esm/Datepicker/components/DatePicker/index.module.css +22 -16
  149. package/esm/Datepicker/components/TimePicker/index.module.css +21 -15
  150. package/esm/DotsLoader/DotsLoader.module.css +5 -5
  151. package/esm/DotsLoader/index.d.ts +1 -3
  152. package/esm/DotsLoader/index.js +1 -14
  153. package/esm/Drawer/Drawer.d.ts +43 -0
  154. package/esm/Drawer/Drawer.js +216 -0
  155. package/esm/Drawer/Drawer.module.css +280 -0
  156. package/esm/Drawer/index.d.ts +2 -0
  157. package/esm/Dropdown/Dropdown.module.css +6 -6
  158. package/esm/Dropdown/index.js +27 -18
  159. package/esm/Dropdown/index.props.d.ts +7 -6
  160. package/esm/Dropzone/Dropzone.d.ts +30 -0
  161. package/esm/Dropzone/Dropzone.js +248 -0
  162. package/esm/Dropzone/Dropzone.module.css +164 -0
  163. package/esm/Dropzone/index.d.ts +2 -0
  164. package/esm/Editable/Editable.d.ts +18 -0
  165. package/esm/Editable/Editable.js +157 -0
  166. package/esm/Editable/Editable.module.css +61 -0
  167. package/esm/Editable/index.d.ts +2 -0
  168. package/esm/Grid/Grid.module.css +2 -2
  169. package/esm/Grid/Item/Grid-Item.module.css +3 -3
  170. package/esm/Grid/index.js +9 -6
  171. package/esm/Grid/index.props.d.ts +4 -3
  172. package/esm/Icons/Check.js +1 -1
  173. package/esm/InputRadio/InputRadio.module.css +37 -34
  174. package/esm/Menu/Menu.module.css +2 -2
  175. package/esm/Menu/components/MenuItem/MenuItem.module.css +8 -8
  176. package/esm/Modal/Modal.module.css +11 -11
  177. package/esm/Modal/components/Close/Close.module.css +1 -1
  178. package/esm/Modal/components/Content/Content.module.css +1 -1
  179. package/esm/MultiSelect/components/MenuOverlay/index.js +2 -4
  180. package/esm/MultiSelect/components/MenuOverlay/index.module.css +3 -3
  181. package/esm/MultiSelect/index.js +1 -0
  182. package/esm/MultiSelect/index.module.css +5 -5
  183. package/esm/Progress/Progress.d.ts +20 -0
  184. package/esm/Progress/Progress.js +102 -0
  185. package/esm/Progress/Progress.module.css +191 -0
  186. package/esm/Progress/index.d.ts +2 -0
  187. package/esm/RadioGroup/RadioGroup.module.css +4 -4
  188. package/esm/Rating/Rating.d.ts +24 -0
  189. package/esm/Rating/Rating.js +121 -0
  190. package/esm/Rating/Rating.module.css +219 -0
  191. package/esm/Rating/index.d.ts +2 -0
  192. package/esm/Select/components/MenuOverlay/index.module.css +1 -1
  193. package/esm/Select/index.js +1 -0
  194. package/esm/Select/index.module.css +3 -3
  195. package/esm/Separator/Separator.module.css +2 -2
  196. package/esm/Skeleton/Skeleton.module.css +4 -4
  197. package/esm/Skeleton/index.js +10 -6
  198. package/esm/Skeleton/index.props.d.ts +2 -2
  199. package/esm/Status/index.module.css +18 -17
  200. package/esm/Switch/Switch.module.css +41 -26
  201. package/esm/Switch/index.js +1 -0
  202. package/esm/TabsMenu/Tab/Tab.module.css +29 -26
  203. package/esm/TabsMenu/TabsMenu.module.css +1 -1
  204. package/esm/TextArea/TextArea.module.css +2 -2
  205. package/esm/Theme/colors/index.d.ts +190 -38
  206. package/esm/Theme/colors/theme_buenos_aires.d.ts +211 -31
  207. package/esm/Theme/colors/theme_buenos_aires.js +132 -34
  208. package/esm/Theme/colors/theme_jaipur.d.ts +251 -0
  209. package/esm/Theme/colors/theme_jaipur.js +140 -0
  210. package/esm/Theme/global.css +1 -1
  211. package/esm/Theme/index.d.ts +973 -13
  212. package/esm/Theme/index.js +2 -2
  213. package/esm/Theme/themes/buenos_aires.d.ts +476 -0
  214. package/esm/Theme/themes/buenos_aires.js +618 -142
  215. package/esm/Theme/themes/jaipur.d.ts +628 -0
  216. package/esm/Theme/themes/jaipur.js +631 -0
  217. package/esm/Tooltip/Tooltip.module.css +8 -8
  218. package/esm/Tooltip/index.js +4 -3
  219. package/esm/Typography/Typography.module.css +151 -26
  220. package/esm/Typography/index.props.d.ts +3 -3
  221. package/esm/base/BaseInput/BaseInput.module.css +2 -2
  222. package/esm/base/FormField/FormField.module.css +6 -2
  223. package/esm/base/FormField/index.js +1 -0
  224. package/esm/base/InputRoot/InputRoot.module.css +33 -26
  225. package/esm/base/InputRoot/index.d.ts +1 -1
  226. package/esm/base/InputRoot/index.js +3 -2
  227. package/esm/base/InputRoot/index.props.d.ts +1 -0
  228. package/esm/hooks/useOnClickOutside/index.d.ts +1 -1
  229. package/esm/hooks/useOnClickOutside/index.js +2 -2
  230. package/esm/index.d.ts +12 -0
  231. package/esm/index.js +7 -0
  232. package/esm/theme_ba_variables.css +625 -149
  233. package/esm/theme_jaipur_variables.css +627 -0
  234. package/hooks/useOnClickOutside/index.d.ts +1 -1
  235. package/hooks/useOnClickOutside/index.js +2 -2
  236. package/index.d.ts +12 -0
  237. package/index.js +26 -0
  238. package/package.json +1 -1
  239. package/theme_ba_variables.css +625 -149
  240. package/theme_jaipur_variables.css +627 -0
  241. package/Avatar/assets/org-circle.svg.js +0 -64
  242. package/Avatar/assets/user-circle.svg.js +0 -43
  243. package/Theme/colors/common.d.ts +0 -39
  244. package/Theme/colors/common.js +0 -32
  245. package/Theme/colors/index.js +0 -11
  246. package/Theme/colors/theme_default.d.ts +0 -47
  247. package/Theme/colors/theme_default.js +0 -38
  248. package/Theme/themes/default.d.ts +0 -144
  249. package/Theme/themes/default.js +0 -151
  250. package/esm/Avatar/assets/org-circle.svg.js +0 -5
  251. package/esm/Avatar/assets/user-circle.svg.js +0 -5
  252. package/esm/Theme/colors/common.d.ts +0 -39
  253. package/esm/Theme/colors/common.js +0 -24
  254. package/esm/Theme/colors/index.js +0 -7
  255. package/esm/Theme/colors/theme_default.d.ts +0 -47
  256. package/esm/Theme/colors/theme_default.js +0 -29
  257. package/esm/Theme/themes/default.d.ts +0 -144
  258. package/esm/Theme/themes/default.js +0 -147
  259. package/esm/theme_default_variables.css +0 -143
  260. package/theme_default_variables.css +0 -143
@@ -0,0 +1,316 @@
1
+ 'use strict';
2
+
3
+ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
4
+ var tslib = require('tslib');
5
+ var React = require('react');
6
+ var styles = require('./CodeField.module.css');
7
+
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
+
10
+ var _slicedToArray__default = /*#__PURE__*/_interopDefault(_slicedToArray);
11
+ var React__default = /*#__PURE__*/_interopDefault(React);
12
+ var styles__default = /*#__PURE__*/_interopDefault(styles);
13
+
14
+ var ONLY_DIGITS_PATTERN = "^\\d+$";
15
+ var ONLY_CHARS_PATTERN = "^[a-zA-Z]+$";
16
+ var ONLY_DIGITS_AND_CHARS_PATTERN = "^[a-zA-Z0-9]+$";
17
+ var cx = function cx() {
18
+ for (var _len = arguments.length, classNames = new Array(_len), _key = 0; _key < _len; _key++) {
19
+ classNames[_key] = arguments[_key];
20
+ }
21
+ return classNames.filter(Boolean).join(" ");
22
+ };
23
+ var getPattern = function getPattern(pattern) {
24
+ return typeof pattern === "string" ? new RegExp(pattern) : pattern;
25
+ };
26
+ var testSymbol = function testSymbol(pattern, symbol) {
27
+ pattern.lastIndex = 0;
28
+ return pattern.test(symbol);
29
+ };
30
+ var getPlaceholder = function getPlaceholder(placeholder, length) {
31
+ if (!placeholder) return [];
32
+ return placeholder.length === 1 ? Array(length).fill(placeholder) : placeholder.slice(0, length).split("");
33
+ };
34
+ var CodeField = /*#__PURE__*/React.forwardRef(function CodeFieldComponent(_a, forwardedRef) {
35
+ var _b;
36
+ var value = _a.value,
37
+ placeholder = _a.placeholder,
38
+ _a$codeLength = _a.codeLength,
39
+ codeLength = _a$codeLength === void 0 ? 6 : _a$codeLength,
40
+ caption = _a.caption,
41
+ _a$captionAlign = _a.captionAlign,
42
+ captionAlign = _a$captionAlign === void 0 ? "left" : _a$captionAlign,
43
+ width = _a.width,
44
+ _a$view = _a.view,
45
+ view = _a$view === void 0 ? "default" : _a$view,
46
+ _a$shape = _a.shape,
47
+ shape = _a$shape === void 0 ? "default" : _a$shape,
48
+ _a$size = _a.size,
49
+ size = _a$size === void 0 ? "l" : _a$size,
50
+ _a$disabled = _a.disabled,
51
+ disabled = _a$disabled === void 0 ? false : _a$disabled,
52
+ _a$isError = _a.isError,
53
+ isError = _a$isError === void 0 ? false : _a$isError,
54
+ setIsError = _a.setIsError,
55
+ _a$allowedSymbols = _a.allowedSymbols,
56
+ allowedSymbols = _a$allowedSymbols === void 0 ? ONLY_DIGITS_PATTERN : _a$allowedSymbols,
57
+ _a$itemErrorBehavior = _a.itemErrorBehavior,
58
+ itemErrorBehavior = _a$itemErrorBehavior === void 0 ? "remove-symbol" : _a$itemErrorBehavior,
59
+ _a$codeErrorBehavior = _a.codeErrorBehavior,
60
+ codeErrorBehavior = _a$codeErrorBehavior === void 0 ? "remove-code" : _a$codeErrorBehavior,
61
+ _a$autoComplete = _a.autoComplete,
62
+ autoComplete = _a$autoComplete === void 0 ? "one-time-code" : _a$autoComplete,
63
+ _a$inputMode = _a.inputMode,
64
+ inputMode = _a$inputMode === void 0 ? "numeric" : _a$inputMode,
65
+ autoFocus = _a.autoFocus,
66
+ className = _a.className,
67
+ style = _a.style,
68
+ onChange = _a.onChange,
69
+ onFullCodeEnter = _a.onFullCodeEnter,
70
+ onClick = _a.onClick,
71
+ _onFocus = _a.onFocus,
72
+ _onBlur = _a.onBlur,
73
+ _onSelect = _a.onSelect,
74
+ _onPaste = _a.onPaste,
75
+ _onKeyDown = _a.onKeyDown,
76
+ inputProps = tslib.__rest(_a, ["value", "placeholder", "codeLength", "caption", "captionAlign", "width", "view", "shape", "size", "disabled", "isError", "setIsError", "allowedSymbols", "itemErrorBehavior", "codeErrorBehavior", "autoComplete", "inputMode", "autoFocus", "className", "style", "onChange", "onFullCodeEnter", "onClick", "onFocus", "onBlur", "onSelect", "onPaste", "onKeyDown"]);
77
+ var inputRef = React.useRef(null);
78
+ var _useState = React.useState((_b = value === null || value === void 0 ? void 0 : value.slice(0, codeLength)) !== null && _b !== void 0 ? _b : ""),
79
+ _useState2 = _slicedToArray__default.default(_useState, 2),
80
+ internalValue = _useState2[0],
81
+ setInternalValue = _useState2[1];
82
+ var _useState3 = React.useState(null),
83
+ _useState4 = _slicedToArray__default.default(_useState3, 2),
84
+ activeIndex = _useState4[0],
85
+ setActiveIndex = _useState4[1];
86
+ var _useState5 = React.useState(null),
87
+ _useState6 = _slicedToArray__default.default(_useState5, 2),
88
+ selectedIndex = _useState6[0],
89
+ setSelectedIndex = _useState6[1];
90
+ var _useState7 = React.useState(null),
91
+ _useState8 = _slicedToArray__default.default(_useState7, 2),
92
+ invalidIndex = _useState8[0],
93
+ setInvalidIndex = _useState8[1];
94
+ var _useState9 = React.useState(false),
95
+ _useState0 = _slicedToArray__default.default(_useState9, 2),
96
+ shaking = _useState0[0],
97
+ setShaking = _useState0[1];
98
+ var completedCode = React.useRef(null);
99
+ var fullCodeEffectMounted = React.useRef(false);
100
+ var errorEffectMounted = React.useRef(false);
101
+ var timerRef = React.useRef(null);
102
+ var pattern = React.useMemo(function () {
103
+ return getPattern(allowedSymbols);
104
+ }, [allowedSymbols]);
105
+ var currentValue = value === undefined ? internalValue : value.slice(0, codeLength);
106
+ var placeholders = getPlaceholder(placeholder, codeLength);
107
+ var items = Array.from({
108
+ length: codeLength
109
+ }, function (_, index) {
110
+ var _a;
111
+ return (_a = currentValue[index]) !== null && _a !== void 0 ? _a : "";
112
+ });
113
+ var setInputRef = function setInputRef(element) {
114
+ inputRef.current = element;
115
+ if (typeof forwardedRef === "function") forwardedRef(element);else if (forwardedRef) forwardedRef.current = element;
116
+ };
117
+ var publishValue = React.useCallback(function (nextValue) {
118
+ var normalized = nextValue.slice(0, codeLength);
119
+ if (value === undefined) setInternalValue(normalized);
120
+ onChange === null || onChange === void 0 ? void 0 : onChange(normalized);
121
+ }, [codeLength, onChange, value]);
122
+ var selectPosition = React.useCallback(function (position) {
123
+ var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : position;
124
+ var input = inputRef.current;
125
+ if (!input) return;
126
+ var safePosition = Math.min(position, currentValue.length, codeLength);
127
+ input.setSelectionRange(safePosition, Math.min(end, currentValue.length));
128
+ setActiveIndex(Math.min(safePosition, codeLength - 1));
129
+ setSelectedIndex(safePosition < end ? Math.min(safePosition, codeLength - 1) : null);
130
+ }, [codeLength, currentValue.length]);
131
+ var clearError = React.useCallback(function () {
132
+ setInvalidIndex(null);
133
+ setShaking(false);
134
+ if (isError) setIsError === null || setIsError === void 0 ? void 0 : setIsError(false);
135
+ }, [isError, setIsError]);
136
+ var showTemporaryItemError = React.useCallback(function (rawValue, index) {
137
+ if (timerRef.current) clearTimeout(timerRef.current);
138
+ setInvalidIndex(index);
139
+ setShaking(true);
140
+ if (itemErrorBehavior === "keep") {
141
+ publishValue(rawValue);
142
+ timerRef.current = setTimeout(function () {
143
+ return setShaking(false);
144
+ }, 300);
145
+ return;
146
+ }
147
+ if (value === undefined) setInternalValue(rawValue);
148
+ onChange === null || onChange === void 0 ? void 0 : onChange(rawValue);
149
+ timerRef.current = setTimeout(function () {
150
+ var cleaned = rawValue.split("").filter(function (symbol) {
151
+ return testSymbol(pattern, symbol);
152
+ }).join("");
153
+ setInvalidIndex(null);
154
+ setShaking(false);
155
+ publishValue(cleaned);
156
+ requestAnimationFrame(function () {
157
+ return selectPosition(index);
158
+ });
159
+ }, 300);
160
+ }, [itemErrorBehavior, onChange, pattern, publishValue, selectPosition, value]);
161
+ React.useEffect(function () {
162
+ if (value === undefined) setInternalValue(function (current) {
163
+ return current.slice(0, codeLength);
164
+ });
165
+ }, [codeLength, value]);
166
+ React.useEffect(function () {
167
+ return function () {
168
+ if (timerRef.current) clearTimeout(timerRef.current);
169
+ };
170
+ }, []);
171
+ React.useEffect(function () {
172
+ if (!fullCodeEffectMounted.current) {
173
+ fullCodeEffectMounted.current = true;
174
+ return;
175
+ }
176
+ if (currentValue.length !== codeLength) {
177
+ completedCode.current = null;
178
+ return;
179
+ }
180
+ if (completedCode.current !== currentValue) {
181
+ completedCode.current = currentValue;
182
+ onFullCodeEnter === null || onFullCodeEnter === void 0 ? void 0 : onFullCodeEnter(currentValue);
183
+ }
184
+ }, [codeLength, currentValue, onFullCodeEnter]);
185
+ React.useEffect(function () {
186
+ if (!errorEffectMounted.current) {
187
+ errorEffectMounted.current = true;
188
+ return;
189
+ }
190
+ if (!isError) return;
191
+ setShaking(true);
192
+ if (timerRef.current) clearTimeout(timerRef.current);
193
+ timerRef.current = setTimeout(function () {
194
+ setShaking(false);
195
+ if (codeErrorBehavior === "remove-code") publishValue("");
196
+ requestAnimationFrame(function () {
197
+ var _a;
198
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
199
+ selectPosition(codeErrorBehavior === "remove-code" ? 0 : codeLength - 1, codeLength);
200
+ });
201
+ }, 300);
202
+ }, [codeErrorBehavior, codeLength, isError, publishValue, selectPosition]);
203
+ var handleRootClick = function handleRootClick(event) {
204
+ var _a;
205
+ onClick === null || onClick === void 0 ? void 0 : onClick(event);
206
+ if (event.defaultPrevented || disabled) return;
207
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
208
+ selectPosition(currentValue.length);
209
+ };
210
+ var rootWidth = typeof width === "number" ? "".concat(width, "rem") : width;
211
+ var isGrouped = codeLength === 6;
212
+ return /*#__PURE__*/React__default.default.createElement("div", {
213
+ className: cx(styles__default.default.root, styles__default.default[view], styles__default.default[size], styles__default.default[shape], disabled && styles__default.default.disabled, className),
214
+ style: Object.assign(Object.assign({}, style), {
215
+ width: rootWidth
216
+ }),
217
+ onClick: handleRootClick,
218
+ role: "presentation"
219
+ }, /*#__PURE__*/React__default.default.createElement("div", {
220
+ className: cx(styles__default.default.code_wrapper, (isError || shaking) && styles__default.default.code_error, shaking && styles__default.default.shaking)
221
+ }, items.map(function (symbol, index) {
222
+ return /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, {
223
+ key: index
224
+ }, isGrouped && index === codeLength / 2 && (/*#__PURE__*/React__default.default.createElement("span", {
225
+ className: styles__default.default.separator
226
+ })), /*#__PURE__*/React__default.default.createElement("span", {
227
+ className: cx(styles__default.default.item, activeIndex === index && styles__default.default.focused, selectedIndex === index && styles__default.default.selected, invalidIndex === index && styles__default.default.item_error),
228
+ "aria-hidden": "true",
229
+ "data-code-field-item": ""
230
+ }, /*#__PURE__*/React__default.default.createElement("span", {
231
+ className: symbol ? styles__default.default.value : styles__default.default.placeholder
232
+ }, symbol || placeholders[index] || ""), activeIndex === index && selectedIndex === null && (/*#__PURE__*/React__default.default.createElement("span", {
233
+ className: styles__default.default.caret
234
+ }))));
235
+ }), /*#__PURE__*/React__default.default.createElement("input", Object.assign({}, inputProps, {
236
+ ref: setInputRef,
237
+ className: styles__default.default.native_input,
238
+ type: "text",
239
+ value: currentValue,
240
+ minLength: codeLength,
241
+ maxLength: codeLength,
242
+ autoComplete: autoComplete,
243
+ inputMode: inputMode,
244
+ autoFocus: autoFocus,
245
+ disabled: disabled,
246
+ spellCheck: false,
247
+ onChange: function onChange(event) {
248
+ if (disabled) return;
249
+ var rawValue = event.currentTarget.value.slice(0, codeLength);
250
+ var nextInvalidIndex = rawValue.split("").findIndex(function (symbol) {
251
+ return !testSymbol(pattern, symbol);
252
+ });
253
+ clearError();
254
+ if (nextInvalidIndex < 0) publishValue(rawValue);else if (itemErrorBehavior === "forbid-enter") {
255
+ var cleaned = rawValue.split("").filter(function (symbol) {
256
+ return testSymbol(pattern, symbol);
257
+ }).join("");
258
+ publishValue(cleaned);
259
+ requestAnimationFrame(function () {
260
+ return selectPosition(nextInvalidIndex);
261
+ });
262
+ } else showTemporaryItemError(rawValue, nextInvalidIndex);
263
+ },
264
+ onPaste: function onPaste(event) {
265
+ var _a, _b;
266
+ _onPaste === null || _onPaste === void 0 ? void 0 : _onPaste(event);
267
+ if (event.defaultPrevented || disabled) return;
268
+ event.preventDefault();
269
+ var pasted = event.clipboardData.getData("text/plain").split("").filter(function (symbol) {
270
+ return testSymbol(pattern, symbol);
271
+ });
272
+ var start = (_a = event.currentTarget.selectionStart) !== null && _a !== void 0 ? _a : 0;
273
+ var end = (_b = event.currentTarget.selectionEnd) !== null && _b !== void 0 ? _b : start;
274
+ var nextValue = (pasted.length >= codeLength ? pasted.join("") : "".concat(currentValue.slice(0, start)).concat(pasted.join("")).concat(currentValue.slice(end))).slice(0, codeLength);
275
+ clearError();
276
+ publishValue(nextValue);
277
+ requestAnimationFrame(function () {
278
+ return selectPosition(Math.min(start + pasted.length, nextValue.length));
279
+ });
280
+ },
281
+ onKeyDown: function onKeyDown(event) {
282
+ if (!disabled && ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Delete"].includes(event.key)) {
283
+ event.preventDefault();
284
+ }
285
+ _onKeyDown === null || _onKeyDown === void 0 ? void 0 : _onKeyDown(event);
286
+ },
287
+ onFocus: function onFocus(event) {
288
+ selectPosition(currentValue.length);
289
+ _onFocus === null || _onFocus === void 0 ? void 0 : _onFocus(event);
290
+ },
291
+ onBlur: function onBlur(event) {
292
+ setActiveIndex(null);
293
+ setSelectedIndex(null);
294
+ _onBlur === null || _onBlur === void 0 ? void 0 : _onBlur(event);
295
+ },
296
+ onSelect: function onSelect(event) {
297
+ var _a, _b;
298
+ var start = (_a = event.currentTarget.selectionStart) !== null && _a !== void 0 ? _a : currentValue.length;
299
+ var end = (_b = event.currentTarget.selectionEnd) !== null && _b !== void 0 ? _b : start;
300
+ setActiveIndex(Math.min(start, codeLength - 1));
301
+ setSelectedIndex(start < end ? Math.min(start, codeLength - 1) : null);
302
+ _onSelect === null || _onSelect === void 0 ? void 0 : _onSelect(event);
303
+ }
304
+ }))), caption && (/*#__PURE__*/React__default.default.createElement("div", {
305
+ className: cx(styles__default.default.caption, isError && styles__default.default.caption_error),
306
+ style: {
307
+ textAlign: captionAlign,
308
+ alignSelf: captionAlign === "left" ? "flex-start" : "center"
309
+ }
310
+ }, caption)));
311
+ });
312
+
313
+ exports.CodeField = CodeField;
314
+ exports.ONLY_CHARS_PATTERN = ONLY_CHARS_PATTERN;
315
+ exports.ONLY_DIGITS_AND_CHARS_PATTERN = ONLY_DIGITS_AND_CHARS_PATTERN;
316
+ exports.ONLY_DIGITS_PATTERN = ONLY_DIGITS_PATTERN;
@@ -0,0 +1,211 @@
1
+ .root {
2
+ --code-field-background: var(--component-input-bg, transparent);
3
+ --code-field-background-disabled: var(--component-input-bg-disabled);
4
+ --code-field-background-focus: var(--component-input-bg, transparent);
5
+ --code-field-background-hover: var(--component-input-bg, transparent);
6
+ --code-field-border-color: var(--component-input-border);
7
+ --code-field-border-disabled-color: var(--component-input-border-disabled);
8
+ --code-field-border-focus-color: var(--component-input-border-focus);
9
+ --code-field-border-hover-color: var(--component-input-border-hover);
10
+ --code-field-caption-color: var(--color-text-secondary);
11
+ --code-field-caret-color: var(--component-input-border-focus);
12
+ --code-field-color: var(--component-input-text);
13
+ --code-field-disabled-color: var(--component-input-text-disabled);
14
+ --code-field-error-color: var(--component-input-border-error);
15
+ --code-field-error-helper-color: var(
16
+ --component-input-helper-error,
17
+ var(--code-field-error-color)
18
+ );
19
+ --code-field-focus-ring-color: var(--component-input-focus-ring);
20
+ align-items: center;
21
+ display: flex;
22
+ flex-direction: column;
23
+ font-family: var(--font-family-ui);
24
+ justify-content: center;
25
+ width: min-content;
26
+ }
27
+
28
+ .code_wrapper {
29
+ align-items: center;
30
+ display: flex;
31
+ gap: var(--space-1);
32
+ position: relative;
33
+ }
34
+
35
+ .item {
36
+ align-items: center;
37
+ background: var(--code-field-background);
38
+ box-shadow: inset 0 0 0 var(--border-width-hairline) var(--code-field-border-color);
39
+ box-sizing: border-box;
40
+ color: var(--code-field-color);
41
+ display: flex;
42
+ flex: none;
43
+ font-weight: 600;
44
+ height: var(--code-field-height);
45
+ justify-content: center;
46
+ pointer-events: none;
47
+ position: relative;
48
+ text-align: center;
49
+ width: var(--code-field-width);
50
+ }
51
+
52
+ .code_error .item,
53
+ .item_error {
54
+ box-shadow: inset 0 0 0 var(--border-width-hairline) var(--code-field-error-color) !important;
55
+ color: var(--code-field-error-color);
56
+ }
57
+
58
+ .disabled .item {
59
+ background: var(--code-field-background-disabled);
60
+ box-shadow: inset 0 0 0 var(--border-width-hairline) var(--code-field-border-disabled-color);
61
+ color: var(--code-field-disabled-color);
62
+ }
63
+
64
+ .default .item {
65
+ border-radius: var(--code-field-radius);
66
+ }
67
+
68
+ .segmented .item {
69
+ border-radius: var(--code-field-segmented-radius);
70
+ }
71
+
72
+ .segmented .item:first-of-type {
73
+ border-radius: var(--code-field-radius) var(--code-field-segmented-radius) var(--code-field-segmented-radius) var(--code-field-radius);
74
+ }
75
+
76
+ .segmented .item:last-of-type {
77
+ border-radius: var(--code-field-segmented-radius) var(--code-field-radius) var(--code-field-radius) var(--code-field-segmented-radius);
78
+ }
79
+
80
+ .m {
81
+ --code-field-height: var(--component-code-field-height-m);
82
+ --code-field-radius: var(--radius-sm);
83
+ --code-field-segmented-radius: var(--radius-xs);
84
+ --code-field-width: var(--component-code-field-width-m);
85
+ font-size: var(--component-code-field-font-size-m);
86
+ gap: var(--space-3);
87
+ }
88
+
89
+ .l {
90
+ --code-field-height: var(--component-code-field-height-l);
91
+ --code-field-radius: var(--radius-sm);
92
+ --code-field-segmented-radius: var(--radius-xs);
93
+ --code-field-width: var(--component-code-field-width-l);
94
+ font-size: var(--component-code-field-font-size-l);
95
+ gap: var(--space-3);
96
+ }
97
+
98
+ .xl {
99
+ --code-field-height: var(--component-code-field-height-xl);
100
+ --code-field-radius: var(--radius-sm);
101
+ --code-field-segmented-radius: var(--radius-xs);
102
+ --code-field-width: var(--component-code-field-width-xl);
103
+ font-size: var(--component-code-field-font-size-xl);
104
+ gap: var(--space-3);
105
+ }
106
+
107
+ .separator {
108
+ width: var(--component-code-field-separator-width);
109
+ }
110
+
111
+ .value {
112
+ position: relative;
113
+ }
114
+
115
+ .placeholder {
116
+ opacity: 0.54;
117
+ }
118
+
119
+ .caret {
120
+ animation: caret-blink 1s step-end infinite;
121
+ background: var(--code-field-caret-color);
122
+ height: 1em;
123
+ position: absolute;
124
+ width: var(--component-code-field-caret-width);
125
+ }
126
+
127
+ .selected .value {
128
+ background: highlight;
129
+ color: highlighttext;
130
+ }
131
+
132
+ .native_input {
133
+ background: transparent;
134
+ border: 0;
135
+ box-sizing: border-box;
136
+ caret-color: transparent;
137
+ color: transparent;
138
+ cursor: text;
139
+ font-size: var(--code-field-height);
140
+ height: 100%;
141
+ inset: 0;
142
+ letter-spacing: -0.5em;
143
+ line-height: 1;
144
+ outline: 0;
145
+ padding: 0;
146
+ position: absolute;
147
+ width: 100%;
148
+ z-index: 1;
149
+ }
150
+
151
+ .native_input::selection {
152
+ background: transparent;
153
+ color: transparent;
154
+ }
155
+
156
+ .caption {
157
+ color: var(--code-field-caption-color);
158
+ font-size: var(--component-code-field-caption-font-size);
159
+ font-weight: 400;
160
+ white-space: pre-line;
161
+ width: 100%;
162
+ }
163
+
164
+ .caption_error {
165
+ color: var(--code-field-error-helper-color);
166
+ }
167
+
168
+ .shaking {
169
+ animation: shaking-error 0.3s;
170
+ }
171
+
172
+ .disabled {
173
+ cursor: not-allowed;
174
+ }
175
+
176
+ .disabled .native_input {
177
+ cursor: not-allowed;
178
+ }
179
+
180
+ .root:hover:not(.disabled) .item {
181
+ background: var(--code-field-background-hover);
182
+ box-shadow: inset 0 0 0 var(--border-width-hairline) var(--code-field-border-hover-color);
183
+ }
184
+
185
+ .root:focus-within .focused {
186
+ background: var(--code-field-background-focus);
187
+ box-shadow: inset 0 0 0 var(--border-width-hairline) var(--code-field-border-focus-color), 0 0 0 var(--focus-ring-width) var(--code-field-focus-ring-color);
188
+ }
189
+
190
+ @keyframes caret-blink {
191
+ 0%, 50% {
192
+ opacity: 1;
193
+ }
194
+ 50.01%, 100% {
195
+ opacity: 0;
196
+ }
197
+ }
198
+ @keyframes shaking-error {
199
+ 20%, 60% {
200
+ transform: translateX(-0.125rem);
201
+ }
202
+ 40%, 80% {
203
+ transform: translateX(0.125rem);
204
+ }
205
+ }
206
+ @media (prefers-reduced-motion: reduce) {
207
+ .caret,
208
+ .shaking {
209
+ animation: none;
210
+ }
211
+ }
@@ -0,0 +1,2 @@
1
+ export { CodeField as default, CodeField, ONLY_DIGITS_PATTERN, ONLY_CHARS_PATTERN, ONLY_DIGITS_AND_CHARS_PATTERN, } from "./CodeField";
2
+ export type { CodeFieldProps, CodeFieldShape, CodeFieldSize, ItemErrorBehavior, CodeErrorBehavior, } from "./CodeField";
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var CodeField = require('./CodeField.js');
6
+
7
+
8
+
9
+ exports.CodeField = CodeField.CodeField;
10
+ exports.ONLY_CHARS_PATTERN = CodeField.ONLY_CHARS_PATTERN;
11
+ exports.ONLY_DIGITS_AND_CHARS_PATTERN = CodeField.ONLY_DIGITS_AND_CHARS_PATTERN;
12
+ exports.ONLY_DIGITS_PATTERN = CodeField.ONLY_DIGITS_PATTERN;
13
+ exports.default = CodeField.CodeField;
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "module": "../esm/CodeField/index.js",
4
+ "main": "./index.js",
5
+ "types": "./index.d.ts"
6
+ }
@@ -1,11 +1,12 @@
1
1
  .root {
2
- background-color: var(--palette-white);
3
- block-size: 40px;
4
- border-radius: 4px;
2
+ background-color: var(--component-counter-bg);
3
+ block-size: var(--component-counter-block-size);
4
+ border-radius: var(--component-counter-radius);
5
5
  box-sizing: border-box;
6
+ color: var(--component-counter-text);
6
7
  display: inline-block;
7
- font-size: 16px;
8
- min-inline-size: 96px;
8
+ font-size: var(--component-control-font-size);
9
+ min-inline-size: var(--component-counter-min-inline-size);
9
10
  overflow: hidden;
10
11
  position: relative;
11
12
  }
@@ -15,9 +16,9 @@
15
16
 
16
17
  .control {
17
18
  align-items: center;
18
- block-size: 38px;
19
+ block-size: var(--component-counter-control-block-size);
19
20
  display: flex;
20
- gap: 4px;
21
+ gap: var(--space-1);
21
22
  justify-content: space-between;
22
23
  }
23
24
  .control_fullWidth {
@@ -25,9 +26,9 @@
25
26
  }
26
27
 
27
28
  .value {
28
- font-size: 18px;
29
- font-weight: 500;
30
- inline-size: 24px;
29
+ font-size: var(--font-size-text-lg);
30
+ font-weight: var(--font-weight-medium, 500);
31
+ inline-size: var(--component-counter-value-inline-size);
31
32
  text-align: center;
32
33
  user-select: none;
33
34
  }
@@ -1,4 +1,4 @@
1
1
  .root {
2
2
  display: flex;
3
- font-size: 14px;
3
+ font-size: var(--font-size-text-sm);
4
4
  }
@@ -1,12 +1,13 @@
1
1
  .input-container {
2
2
  align-items: center;
3
- border: 1px solid var(--palette-bg-3);
4
- border-bottom-right-radius: 0.375rem;
3
+ background-color: var(--component-input-bg);
4
+ border: var(--border-width-hairline) solid var(--component-input-border);
5
+ border-bottom-right-radius: var(--component-input-radius);
5
6
  border-left: none;
6
- border-top-right-radius: 0.375rem;
7
+ border-top-right-radius: var(--component-input-radius);
7
8
  box-sizing: border-box;
8
9
  display: flex;
9
- height: 36px;
10
+ height: var(--component-input-height-m);
10
11
  justify-content: center;
11
12
  }
12
13
 
@@ -16,41 +17,46 @@
16
17
  box-sizing: border-box;
17
18
  height: 100%;
18
19
  outline: none;
19
- padding: 4px;
20
+ padding: var(--space-1);
20
21
  text-align: center;
21
22
  width: 100%;
22
23
  }
23
24
 
24
25
  .input-date {
25
- border-bottom: 1px solid var(--palette-bg-3);
26
- border-right: 1px solid var(--palette-bg-3);
27
- border-top: 1px solid var(--palette-bg-3);
26
+ border-bottom: var(--border-width-hairline) solid var(--component-input-border);
27
+ border-right: var(--border-width-hairline) solid var(--component-input-border);
28
+ border-top: var(--border-width-hairline) solid var(--component-input-border);
29
+ color: var(--component-input-text);
28
30
  cursor: pointer;
29
31
  flex: 3;
30
32
  position: relative;
31
33
  }
32
34
 
35
+ .input-date:hover {
36
+ border-color: var(--component-input-border-hover);
37
+ }
38
+
33
39
  .input-date:focus-within {
34
- border-color: var(--palette-primary-3);
35
- box-shadow: 0 0 0 2px var(--palette-primary-2);
40
+ border-color: var(--component-input-border-focus);
41
+ box-shadow: 0 0 0 var(--focus-ring-width) var(--component-input-focus-ring);
36
42
  }
37
43
 
38
44
  .input-date:focus-within::before {
39
- background-color: var(--palette-primary-3);
45
+ background-color: var(--component-input-border-focus);
40
46
  content: "";
41
47
  height: 100%;
42
48
  left: 0;
43
49
  position: absolute;
44
- width: 1px;
50
+ width: var(--border-width-hairline);
45
51
  }
46
52
 
47
53
  .calendar {
48
- max-width: 250px;
54
+ max-width: var(--component-date-picker-calendar-max-width);
49
55
  }
50
56
 
51
57
  .calendar-icon {
52
58
  cursor: pointer;
53
- height: 24px;
54
- margin-right: 10px;
55
- width: 24px;
59
+ height: var(--space-6);
60
+ margin-right: var(--space-2);
61
+ width: var(--space-6);
56
62
  }