@cleartrip/ct-design-field 4.0.0 → 5.1.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 (134) hide show
  1. package/README.md +87 -0
  2. package/dist/Field.d.ts +4 -4
  3. package/dist/Field.d.ts.map +1 -1
  4. package/dist/FieldAction/index.d.ts +0 -1
  5. package/dist/FieldAction/index.d.ts.map +1 -1
  6. package/dist/FieldAction/type.d.ts +1 -1
  7. package/dist/FieldAction/type.d.ts.map +1 -1
  8. package/dist/FieldIcon/index.d.ts +0 -1
  9. package/dist/FieldIcon/index.d.ts.map +1 -1
  10. package/dist/FieldIcon/type.d.ts +4 -2
  11. package/dist/FieldIcon/type.d.ts.map +1 -1
  12. package/dist/Input.d.ts +8 -0
  13. package/dist/Input.d.ts.map +1 -0
  14. package/dist/Input.native.d.ts +7 -0
  15. package/dist/Input.native.d.ts.map +1 -0
  16. package/dist/InputField.d.ts +4 -0
  17. package/dist/InputField.d.ts.map +1 -0
  18. package/dist/Label.d.ts +6 -0
  19. package/dist/Label.d.ts.map +1 -0
  20. package/dist/Label.native.d.ts +6 -0
  21. package/dist/Label.native.d.ts.map +1 -0
  22. package/dist/TextArea.d.ts +7 -0
  23. package/dist/TextArea.d.ts.map +1 -0
  24. package/dist/TextAreaInput.d.ts +7 -0
  25. package/dist/TextAreaInput.d.ts.map +1 -0
  26. package/dist/TextAreaInput.native.d.ts +3 -0
  27. package/dist/TextAreaInput.native.d.ts.map +1 -0
  28. package/dist/constants.d.ts +10 -0
  29. package/dist/constants.d.ts.map +1 -0
  30. package/dist/ct-design-field.browser.cjs.js +11 -1
  31. package/dist/ct-design-field.browser.cjs.js.map +1 -1
  32. package/dist/ct-design-field.browser.esm.js +11 -1
  33. package/dist/ct-design-field.browser.esm.js.map +1 -1
  34. package/dist/ct-design-field.cjs.js +1003 -396
  35. package/dist/ct-design-field.cjs.js.map +1 -1
  36. package/dist/ct-design-field.esm.js +997 -387
  37. package/dist/ct-design-field.esm.js.map +1 -1
  38. package/dist/ct-design-field.umd.js +2721 -537
  39. package/dist/ct-design-field.umd.js.map +1 -1
  40. package/dist/index.d.ts +6 -9
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/style.d.ts +146 -38
  43. package/dist/style.d.ts.map +1 -1
  44. package/dist/type.d.ts +114 -25
  45. package/dist/type.d.ts.map +1 -1
  46. package/dist/variants/Card/index.d.ts +13 -0
  47. package/dist/variants/Card/index.d.ts.map +1 -0
  48. package/dist/variants/Card/index.native.d.ts +13 -0
  49. package/dist/variants/Card/index.native.d.ts.map +1 -0
  50. package/dist/variants/Card/type.d.ts +5 -0
  51. package/dist/variants/Card/type.d.ts.map +1 -0
  52. package/dist/variants/OTP/index.d.ts +4 -0
  53. package/dist/variants/OTP/index.d.ts.map +1 -0
  54. package/dist/variants/OTP/type.d.ts +25 -0
  55. package/dist/variants/OTP/type.d.ts.map +1 -0
  56. package/dist/variants/Phone/Prefix/index.d.ts +4 -0
  57. package/dist/variants/Phone/Prefix/index.d.ts.map +1 -0
  58. package/dist/variants/Phone/Prefix/type.d.ts.map +1 -0
  59. package/dist/variants/Phone/index.d.ts +5 -0
  60. package/dist/variants/Phone/index.d.ts.map +1 -0
  61. package/dist/variants/Phone/index.native.d.ts +5 -0
  62. package/dist/variants/Phone/index.native.d.ts.map +1 -0
  63. package/dist/variants/Phone/type.d.ts +7 -0
  64. package/dist/variants/Phone/type.d.ts.map +1 -0
  65. package/package.json +33 -19
  66. package/src/Field.tsx +201 -0
  67. package/src/FieldAction/index.tsx +47 -0
  68. package/src/FieldAction/type.ts +15 -0
  69. package/src/FieldIcon/index.tsx +48 -0
  70. package/src/FieldIcon/type.ts +52 -0
  71. package/src/Input.native.tsx +284 -0
  72. package/src/Input.tsx +242 -0
  73. package/src/InputField.tsx +22 -0
  74. package/src/Label.native.tsx +83 -0
  75. package/src/Label.tsx +91 -0
  76. package/src/TextArea.tsx +14 -0
  77. package/src/TextAreaInput.native.tsx +4 -0
  78. package/src/TextAreaInput.tsx +243 -0
  79. package/src/constants.ts +10 -0
  80. package/src/index.ts +8 -0
  81. package/src/style.ts +353 -0
  82. package/src/type.ts +243 -0
  83. package/src/variants/Card/index.native.tsx +46 -0
  84. package/src/variants/Card/index.tsx +89 -0
  85. package/src/variants/Card/type.ts +5 -0
  86. package/src/variants/OTP/index.tsx +343 -0
  87. package/src/variants/OTP/type.ts +34 -0
  88. package/src/variants/Phone/Prefix/index.tsx +87 -0
  89. package/src/variants/Phone/Prefix/type.ts +24 -0
  90. package/src/variants/Phone/index.native.tsx +84 -0
  91. package/src/variants/Phone/index.tsx +79 -0
  92. package/src/variants/Phone/type.ts +13 -0
  93. package/dist/CardField/CardField.d.ts +0 -6
  94. package/dist/CardField/CardField.d.ts.map +0 -1
  95. package/dist/CardField/index.d.ts +0 -3
  96. package/dist/CardField/index.d.ts.map +0 -1
  97. package/dist/CardField/type.d.ts +0 -16
  98. package/dist/CardField/type.d.ts.map +0 -1
  99. package/dist/OTPField/OTPField.d.ts +0 -6
  100. package/dist/OTPField/OTPField.d.ts.map +0 -1
  101. package/dist/OTPField/SingleOTPInput.d.ts +0 -6
  102. package/dist/OTPField/SingleOTPInput.d.ts.map +0 -1
  103. package/dist/OTPField/index.d.ts +0 -3
  104. package/dist/OTPField/index.d.ts.map +0 -1
  105. package/dist/OTPField/type.d.ts +0 -23
  106. package/dist/OTPField/type.d.ts.map +0 -1
  107. package/dist/PhoneField/PhoneField.d.ts +0 -6
  108. package/dist/PhoneField/PhoneField.d.ts.map +0 -1
  109. package/dist/PhoneField/index.d.ts +0 -3
  110. package/dist/PhoneField/index.d.ts.map +0 -1
  111. package/dist/PhoneField/type.d.ts +0 -11
  112. package/dist/PhoneField/type.d.ts.map +0 -1
  113. package/dist/PhoneFieldPrefix/index.d.ts +0 -5
  114. package/dist/PhoneFieldPrefix/index.d.ts.map +0 -1
  115. package/dist/PhoneFieldPrefix/type.d.ts.map +0 -1
  116. package/dist/StyledField/StyledField.d.ts +0 -7
  117. package/dist/StyledField/StyledField.d.ts.map +0 -1
  118. package/dist/StyledField/index.d.ts +0 -2
  119. package/dist/StyledField/index.d.ts.map +0 -1
  120. package/dist/StyledField/type.d.ts +0 -12
  121. package/dist/StyledField/type.d.ts.map +0 -1
  122. package/dist/StyledFieldContainer/StyledFieldContainer.d.ts +0 -7
  123. package/dist/StyledFieldContainer/StyledFieldContainer.d.ts.map +0 -1
  124. package/dist/StyledFieldContainer/index.d.ts +0 -2
  125. package/dist/StyledFieldContainer/index.d.ts.map +0 -1
  126. package/dist/StyledFieldContainer/type.d.ts +0 -8
  127. package/dist/StyledFieldContainer/type.d.ts.map +0 -1
  128. package/dist/StyledFieldPlaceholder/StyledFieldPlaceholder.d.ts +0 -7
  129. package/dist/StyledFieldPlaceholder/StyledFieldPlaceholder.d.ts.map +0 -1
  130. package/dist/StyledFieldPlaceholder/index.d.ts +0 -2
  131. package/dist/StyledFieldPlaceholder/index.d.ts.map +0 -1
  132. package/dist/StyledFieldPlaceholder/type.d.ts +0 -7
  133. package/dist/StyledFieldPlaceholder/type.d.ts.map +0 -1
  134. /package/dist/{PhoneFieldPrefix → variants/Phone/Prefix}/type.d.ts +0 -0
@@ -1,586 +1,2770 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('react'), require('@cleartrip/ct-design-theme'), require('@cleartrip/ct-design-typography'), require('@cleartrip/ct-design-box'), require('@cleartrip/ct-design-container'), require('styled-components'), require('@cleartrip/ct-design-common-constants'), require('@cleartrip/ct-design-common-utils'), require('@cleartrip/ct-design-divider'), require('@cleartrip/ct-design-dotted-loader'), require('@cleartrip/ct-design-card')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'react', '@cleartrip/ct-design-theme', '@cleartrip/ct-design-typography', '@cleartrip/ct-design-box', '@cleartrip/ct-design-container', 'styled-components', '@cleartrip/ct-design-common-constants', '@cleartrip/ct-design-common-utils', '@cleartrip/ct-design-divider', '@cleartrip/ct-design-dotted-loader', '@cleartrip/ct-design-card'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.CTDesignSystemField = {}, global.jsxRuntime, global.React, global.ctDesignTheme, global.ctDesignTypography, global.ctDesignBox, global.ctDesignContainer, global.styled, global.ctDesignCommonConstants, global.ctDesignCommonUtils, global.ctDesignDivider, global.ctDesignDottedLoader, global.ctDesignCard));
5
- })(this, (function (exports, jsxRuntime, react, ctDesignTheme, ctDesignTypography, ctDesignBox, ctDesignContainer, styled, ctDesignCommonConstants, ctDesignCommonUtils, ctDesignDivider, ctDesignDottedLoader, ctDesignCard) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('react'), require('@cleartrip/ct-design-box'), require('@cleartrip/ct-design-style-manager'), require('@cleartrip/ct-design-container'), require('@cleartrip/ct-design-typography'), require('@cleartrip/ct-design-divider'), require('@cleartrip/ct-design-common-constants'), require('@cleartrip/ct-design-theme'), require('@cleartrip/ct-design-common-utils'), require('@cleartrip/ct-design-use-merge-refs'), require('@cleartrip/ct-design-dotted-loader')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'react', '@cleartrip/ct-design-box', '@cleartrip/ct-design-style-manager', '@cleartrip/ct-design-container', '@cleartrip/ct-design-typography', '@cleartrip/ct-design-divider', '@cleartrip/ct-design-common-constants', '@cleartrip/ct-design-theme', '@cleartrip/ct-design-common-utils', '@cleartrip/ct-design-use-merge-refs', '@cleartrip/ct-design-dotted-loader'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.CTDesignSystemField = {}, global.jsxRuntime, global.React, global.ctDesignBox, global.ctDesignStyleManager, global.ctDesignContainer, global.ctDesignTypography, global.ctDesignDivider, global.ctDesignCommonConstants, global.ctDesignTheme, global.ctDesignCommonUtils, global.useMergeRefs, global.ctDesignDottedLoader));
5
+ })(this, (function (exports, jsxRuntime, react, ctDesignBox, ctDesignStyleManager, ctDesignContainer, ctDesignTypography, ctDesignDivider, ctDesignCommonConstants, ctDesignTheme, ctDesignCommonUtils, useMergeRefs, ctDesignDottedLoader) { 'use strict';
6
6
 
7
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
8
 
9
- var styled__default = /*#__PURE__*/_interopDefault(styled);
9
+ var useMergeRefs__default = /*#__PURE__*/_interopDefault(useMergeRefs);
10
10
 
11
- /******************************************************************************
12
- Copyright (c) Microsoft Corporation.
13
-
14
- Permission to use, copy, modify, and/or distribute this software for any
15
- purpose with or without fee is hereby granted.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
18
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
19
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
20
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
21
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
22
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23
- PERFORMANCE OF THIS SOFTWARE.
24
- ***************************************************************************** */
25
- /* global Reflect, Promise, SuppressedError, Symbol */
26
-
27
- var __assign = function () {
28
- __assign = Object.assign || function __assign(t) {
29
- for (var s, i = 1, n = arguments.length; i < n; i++) {
30
- s = arguments[i];
31
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
11
+ var isDevelopment$1 = false;
12
+
13
+ /*
14
+
15
+ Based off glamor's StyleSheet, thanks Sunil ❤️
16
+
17
+ high performance StyleSheet for css-in-js systems
18
+
19
+ - uses multiple style tags behind the scenes for millions of rules
20
+ - uses `insertRule` for appending in production for *much* faster performance
21
+
22
+ // usage
23
+
24
+ import { StyleSheet } from '@emotion/sheet'
25
+
26
+ let styleSheet = new StyleSheet({ key: '', container: document.head })
27
+
28
+ styleSheet.insert('#box { border: 1px solid red; }')
29
+ - appends a css rule into the stylesheet
30
+
31
+ styleSheet.flush()
32
+ - empties the stylesheet of all its contents
33
+
34
+ */
35
+
36
+ function sheetForTag(tag) {
37
+ if (tag.sheet) {
38
+ return tag.sheet;
39
+ } // this weirdness brought to you by firefox
40
+
41
+ /* istanbul ignore next */
42
+
43
+ for (var i = 0; i < document.styleSheets.length; i++) {
44
+ if (document.styleSheets[i].ownerNode === tag) {
45
+ return document.styleSheets[i];
46
+ }
47
+ } // this function should always return with a value
48
+ // TS can't understand it though so we make it stop complaining here
49
+
50
+ return undefined;
51
+ }
52
+ function createStyleElement(options) {
53
+ var tag = document.createElement('style');
54
+ tag.setAttribute('data-emotion', options.key);
55
+ if (options.nonce !== undefined) {
56
+ tag.setAttribute('nonce', options.nonce);
57
+ }
58
+ tag.appendChild(document.createTextNode(''));
59
+ tag.setAttribute('data-s', '');
60
+ return tag;
61
+ }
62
+ var StyleSheet = /*#__PURE__*/function () {
63
+ // Using Node instead of HTMLElement since container may be a ShadowRoot
64
+ function StyleSheet(options) {
65
+ var _this = this;
66
+ this._insertTag = function (tag) {
67
+ var before;
68
+ if (_this.tags.length === 0) {
69
+ if (_this.insertionPoint) {
70
+ before = _this.insertionPoint.nextSibling;
71
+ } else if (_this.prepend) {
72
+ before = _this.container.firstChild;
73
+ } else {
74
+ before = _this.before;
75
+ }
76
+ } else {
77
+ before = _this.tags[_this.tags.length - 1].nextSibling;
32
78
  }
33
- return t;
79
+ _this.container.insertBefore(tag, before);
80
+ _this.tags.push(tag);
34
81
  };
35
- return __assign.apply(this, arguments);
82
+ this.isSpeedy = options.speedy === undefined ? !isDevelopment$1 : options.speedy;
83
+ this.tags = [];
84
+ this.ctr = 0;
85
+ this.nonce = options.nonce; // key is the value of the data-emotion attribute, it's used to identify different sheets
86
+
87
+ this.key = options.key;
88
+ this.container = options.container;
89
+ this.prepend = options.prepend;
90
+ this.insertionPoint = options.insertionPoint;
91
+ this.before = null;
92
+ }
93
+ var _proto = StyleSheet.prototype;
94
+ _proto.hydrate = function hydrate(nodes) {
95
+ nodes.forEach(this._insertTag);
36
96
  };
37
- function __rest(s, e) {
38
- var t = {};
39
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
40
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
41
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
97
+ _proto.insert = function insert(rule) {
98
+ // the max length is how many rules we have per style tag, it's 65000 in speedy mode
99
+ // it's 1 in dev because we insert source maps that map a single rule to a location
100
+ // and you can only have one source map per style tag
101
+ if (this.ctr % (this.isSpeedy ? 65000 : 1) === 0) {
102
+ this._insertTag(createStyleElement(this));
42
103
  }
43
- return t;
44
- }
45
- function __spreadArray(to, from, pack) {
46
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
47
- if (ar || !(i in from)) {
48
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
49
- ar[i] = from[i];
50
- }
104
+ var tag = this.tags[this.tags.length - 1];
105
+ if (this.isSpeedy) {
106
+ var sheet = sheetForTag(tag);
107
+ try {
108
+ // this is the ultrafast version, works across browsers
109
+ // the big drawback is that the css won't be editable in devtools
110
+ sheet.insertRule(rule, sheet.cssRules.length);
111
+ } catch (e) {}
112
+ } else {
113
+ tag.appendChild(document.createTextNode(rule));
51
114
  }
52
- return to.concat(ar || Array.prototype.slice.call(from));
53
- }
54
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
55
- var e = new Error(message);
56
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
115
+ this.ctr++;
116
+ };
117
+ _proto.flush = function flush() {
118
+ this.tags.forEach(function (tag) {
119
+ var _tag$parentNode;
120
+ return (_tag$parentNode = tag.parentNode) == null ? void 0 : _tag$parentNode.removeChild(tag);
121
+ });
122
+ this.tags = [];
123
+ this.ctr = 0;
57
124
  };
125
+ return StyleSheet;
126
+ }();
58
127
 
59
- var StyledFieldContainer = styled__default.default.div(function (_a) {
60
- var borderColor = _a.borderColor, borderWidth = _a.borderWidth, theme = _a.theme, backgroundColor = _a.backgroundColor, cursor = _a.cursor, css = _a.css;
61
- return (__assign({ borderColor: borderColor, borderWidth: borderWidth, borderStyle: theme.border.style.solid, borderRadius: theme.border.radius[8], backgroundColor: backgroundColor, cursor: "".concat(cursor, " !important"), boxSizing: 'border-box', position: 'relative', display: 'flex', alignItems: 'center' }, css));
62
- });
128
+ var stylisExports = {};
129
+ var stylis = {
130
+ get exports(){ return stylisExports; },
131
+ set exports(v){ stylisExports = v; },
132
+ };
63
133
 
64
- var StyledFieldPlaceholder = styled__default.default.label(function (_a) {
65
- var position = _a.position, marginLeft = _a.marginLeft, top = _a.top, _b = _a.css, css = _b === void 0 ? {} : _b;
66
- return (__assign({ position: position || 'absolute', display: 'flex', alignItems: 'center', transition: 'position 1s ease-in-out', marginLeft: marginLeft, top: top, pointerEvents: 'none' }, css));
67
- });
134
+ (function (module, exports) {
135
+ (function (e, r) {
136
+ r(exports) ;
137
+ })(this, function (e) {
68
138
 
69
- var StyledField = styled__default.default.input(function (_a) {
70
- var theme = _a.theme, cursor = _a.cursor, color = _a.color, backgroundColor = _a.backgroundColor, height = _a.height, paddingTop = _a.paddingTop, paddingBottom = _a.paddingBottom, paddingLeft = _a.paddingLeft, marginLeft = _a.marginLeft, paddingRight = _a.paddingRight, _b = _a.css, css = _b === void 0 ? {} : _b;
71
- return (__assign({ width: '100%', border: 'none', outline: 'none', backgroundColor: backgroundColor, cursor: cursor, color: color, height: height, paddingTop: paddingTop, paddingBottom: paddingBottom, paddingRight: paddingRight, paddingLeft: paddingLeft, marginLeft: marginLeft, fontSize: theme.typography.size[16], fontWeight: theme.typography.weight.medium, lineHeight: theme.typography.lineHeight[24] }, css));
72
- });
73
-
74
- exports.FieldVariant = void 0;
75
- (function (FieldVariant) {
76
- FieldVariant["SM"] = "sm";
77
- FieldVariant["MD"] = "md";
78
- })(exports.FieldVariant || (exports.FieldVariant = {}));
79
- exports.FieldType = void 0;
80
- (function (FieldType) {
81
- FieldType["TEXT"] = "text";
82
- FieldType["NUMBER"] = "number";
83
- FieldType["PHONE"] = "phone";
84
- })(exports.FieldType || (exports.FieldType = {}));
85
-
86
- var getFieldContainerBorderStyle = function (_a) {
87
- var theme = _a.theme, hasError = _a.hasError, focus = _a.focus, disabled = _a.disabled;
88
- if (hasError) {
89
- return {
90
- borderColor: theme.color.border.warning,
91
- borderWidth: theme.border.width.md,
92
- };
93
- }
94
- if (focus && !disabled) {
95
- return {
96
- borderColor: theme.color.border.primary,
97
- borderWidth: theme.border.width.md,
98
- };
99
- }
139
+ var r = "-ms-";
140
+ var a = "-moz-";
141
+ var c = "-webkit-";
142
+ var n = "comm";
143
+ var t = "rule";
144
+ var s = "decl";
145
+ var i = "@page";
146
+ var u = "@media";
147
+ var o = "@import";
148
+ var f = "@charset";
149
+ var l = "@viewport";
150
+ var p = "@supports";
151
+ var h = "@document";
152
+ var v = "@namespace";
153
+ var d = "@keyframes";
154
+ var b = "@font-face";
155
+ var w = "@counter-style";
156
+ var m = "@font-feature-values";
157
+ var g = "@layer";
158
+ var k = Math.abs;
159
+ var $ = String.fromCharCode;
160
+ var x = Object.assign;
161
+ function E(e, r) {
162
+ return M(e, 0) ^ 45 ? (((r << 2 ^ M(e, 0)) << 2 ^ M(e, 1)) << 2 ^ M(e, 2)) << 2 ^ M(e, 3) : 0;
163
+ }
164
+ function y(e) {
165
+ return e.trim();
166
+ }
167
+ function T(e, r) {
168
+ return (e = r.exec(e)) ? e[0] : e;
169
+ }
170
+ function A(e, r, a) {
171
+ return e.replace(r, a);
172
+ }
173
+ function O(e, r) {
174
+ return e.indexOf(r);
175
+ }
176
+ function M(e, r) {
177
+ return e.charCodeAt(r) | 0;
178
+ }
179
+ function C(e, r, a) {
180
+ return e.slice(r, a);
181
+ }
182
+ function R(e) {
183
+ return e.length;
184
+ }
185
+ function S(e) {
186
+ return e.length;
187
+ }
188
+ function z(e, r) {
189
+ return r.push(e), e;
190
+ }
191
+ function N(e, r) {
192
+ return e.map(r).join("");
193
+ }
194
+ e.line = 1;
195
+ e.column = 1;
196
+ e.length = 0;
197
+ e.position = 0;
198
+ e.character = 0;
199
+ e.characters = "";
200
+ function P(r, a, c, n, t, s, i) {
100
201
  return {
101
- borderColor: theme.color.border.disabledDark,
102
- borderWidth: theme.border.width.sm,
202
+ value: r,
203
+ root: a,
204
+ parent: c,
205
+ type: n,
206
+ props: t,
207
+ children: s,
208
+ line: e.line,
209
+ column: e.column,
210
+ length: i,
211
+ return: ""
103
212
  };
104
- };
105
- var getFieldSpacingAndHeight = function (_a) {
106
- var _b, _c;
107
- var theme = _a.theme, variant = _a.variant, focus = _a.focus, value = _a.value, isPrefixComponent = _a.isPrefixComponent, disabledPlaceHolder = _a.disabledPlaceHolder;
108
- var isFieldNotEmpty = focus || value.length > 0;
109
- var valueWithPlaceholder = isFieldNotEmpty && !disabledPlaceHolder;
110
- var leftMargin = isPrefixComponent ? (_b = theme === null || theme === void 0 ? void 0 : theme.spacing) === null || _b === void 0 ? void 0 : _b[13] : (_c = theme === null || theme === void 0 ? void 0 : theme.spacing) === null || _c === void 0 ? void 0 : _c[4];
111
- var commonStyles = {
112
- paddingLeft: leftMargin,
113
- paddingRight: theme.spacing[4],
114
- };
115
- switch (variant) {
116
- case exports.FieldVariant.SM: {
117
- return __assign(__assign({}, commonStyles), { height: theme.size[10] });
118
- }
119
- case exports.FieldVariant.MD: {
120
- return __assign(__assign({}, commonStyles), { height: theme.size[14], paddingTop: valueWithPlaceholder ? theme.spacing[6] : theme.spacing[4], paddingBottom: valueWithPlaceholder ? theme.spacing[2] : theme.spacing[4] });
121
- }
122
- default: {
123
- return __assign(__assign({}, commonStyles), { height: theme.size[14], paddingTop: valueWithPlaceholder ? theme.spacing[6] : theme.spacing[4], paddingBottom: valueWithPlaceholder ? theme.spacing[2] : theme.spacing[4] });
124
- }
213
+ }
214
+ function j(e, r) {
215
+ return x(P("", null, null, "", null, null, 0), e, {
216
+ length: -e.length
217
+ }, r);
218
+ }
219
+ function U() {
220
+ return e.character;
221
+ }
222
+ function _() {
223
+ e.character = e.position > 0 ? M(e.characters, --e.position) : 0;
224
+ if (e.column--, e.character === 10) e.column = 1, e.line--;
225
+ return e.character;
226
+ }
227
+ function F() {
228
+ e.character = e.position < e.length ? M(e.characters, e.position++) : 0;
229
+ if (e.column++, e.character === 10) e.column = 1, e.line++;
230
+ return e.character;
231
+ }
232
+ function I() {
233
+ return M(e.characters, e.position);
234
+ }
235
+ function L() {
236
+ return e.position;
237
+ }
238
+ function D(r, a) {
239
+ return C(e.characters, r, a);
240
+ }
241
+ function Y(e) {
242
+ switch (e) {
243
+ case 0:
244
+ case 9:
245
+ case 10:
246
+ case 13:
247
+ case 32:
248
+ return 5;
249
+ case 33:
250
+ case 43:
251
+ case 44:
252
+ case 47:
253
+ case 62:
254
+ case 64:
255
+ case 126:
256
+ case 59:
257
+ case 123:
258
+ case 125:
259
+ return 4;
260
+ case 58:
261
+ return 3;
262
+ case 34:
263
+ case 39:
264
+ case 40:
265
+ case 91:
266
+ return 2;
267
+ case 41:
268
+ case 93:
269
+ return 1;
125
270
  }
126
- };
127
- var getFieldContainerStyles = function (_a) {
128
- var hasError = _a.hasError, theme = _a.theme, focus = _a.focus, disabled = _a.disabled;
129
- var fieldContainerBorderStyle = getFieldContainerBorderStyle({
130
- theme: theme,
131
- hasError: hasError,
132
- focus: focus,
133
- disabled: disabled,
134
- });
135
- return __assign(__assign({}, fieldContainerBorderStyle), { backgroundColor: disabled ? theme.color.background.disabled : theme.color.background.neutral, cursor: disabled ? 'not-allowed' : 'auto' });
136
- };
137
- var getFieldPlaceholderStyles = function (_a) {
138
- var _b, _c;
139
- var theme = _a.theme, isFocused = _a.isFocused; _a.disabled; var variant = _a.variant, fieldType = _a.fieldType, _d = _a.isPrefixComponent, isPrefixComponent = _d === void 0 ? false : _d;
140
- var leftMargin = isPrefixComponent ? (_b = theme === null || theme === void 0 ? void 0 : theme.spacing) === null || _b === void 0 ? void 0 : _b[13] : (_c = theme === null || theme === void 0 ? void 0 : theme.spacing) === null || _c === void 0 ? void 0 : _c[4];
141
- var fieldPlaceholderStyles = {
142
- position: 'absolute',
143
- marginLeft: leftMargin,
144
- };
145
- if (variant === exports.FieldVariant.SM || fieldType === exports.FieldType.PHONE) {
146
- return fieldPlaceholderStyles;
271
+ return 0;
272
+ }
273
+ function K(r) {
274
+ return e.line = e.column = 1, e.length = R(e.characters = r), e.position = 0, [];
275
+ }
276
+ function V(r) {
277
+ return e.characters = "", r;
278
+ }
279
+ function W(r) {
280
+ return y(D(e.position - 1, q(r === 91 ? r + 2 : r === 40 ? r + 1 : r)));
281
+ }
282
+ function B(e) {
283
+ return V(H(K(e)));
284
+ }
285
+ function G(r) {
286
+ while (e.character = I()) if (e.character < 33) F();else break;
287
+ return Y(r) > 2 || Y(e.character) > 3 ? "" : " ";
288
+ }
289
+ function H(r) {
290
+ while (F()) switch (Y(e.character)) {
291
+ case 0:
292
+ z(Q(e.position - 1), r);
293
+ break;
294
+ case 2:
295
+ z(W(e.character), r);
296
+ break;
297
+ default:
298
+ z($(e.character), r);
147
299
  }
148
- if (isFocused) {
149
- fieldPlaceholderStyles = __assign(__assign({}, fieldPlaceholderStyles), { top: theme === null || theme === void 0 ? void 0 : theme.spacing[2] });
300
+ return r;
301
+ }
302
+ function Z(r, a) {
303
+ while (--a && F()) if (e.character < 48 || e.character > 102 || e.character > 57 && e.character < 65 || e.character > 70 && e.character < 97) break;
304
+ return D(r, L() + (a < 6 && I() == 32 && F() == 32));
305
+ }
306
+ function q(r) {
307
+ while (F()) switch (e.character) {
308
+ case r:
309
+ return e.position;
310
+ case 34:
311
+ case 39:
312
+ if (r !== 34 && r !== 39) q(e.character);
313
+ break;
314
+ case 40:
315
+ if (r === 41) q(r);
316
+ break;
317
+ case 92:
318
+ F();
319
+ break;
150
320
  }
151
- return fieldPlaceholderStyles;
152
- };
153
- var getFieldStyles = function (_a) {
154
- var disabled = _a.disabled, theme = _a.theme, variant = _a.variant, focus = _a.focus, value = _a.value, type = _a.type, _b = _a.isPrefixComponent, isPrefixComponent = _b === void 0 ? false : _b, disabledPlaceHolder = _a.disabledPlaceHolder;
155
- var fieldSpacingAndHeight = getFieldSpacingAndHeight({
156
- theme: theme,
157
- variant: variant,
158
- focus: focus,
159
- value: value,
160
- type: type,
161
- isPrefixComponent: isPrefixComponent,
162
- disabledPlaceHolder: disabledPlaceHolder,
163
- });
164
- return __assign(__assign({}, fieldSpacingAndHeight), { cursor: disabled ? 'not-allowed' : 'auto', color: disabled ? theme.color.text.disabled : theme.color.text.primary, backgroundColor: disabled ? theme.color.background.disabled : 'transparent' });
165
- };
166
-
167
- var Field = react.forwardRef(function (_a, forwardedRef) {
168
- var _b = _a.value, value = _b === void 0 ? '' : _b, _c = _a.placeholder, placeholder = _c === void 0 ? '' : _c, onChange = _a.onChange, prefix = _a.prefix, suffix = _a.suffix, _d = _a.variant, variant = _d === void 0 ? exports.FieldVariant.MD : _d, _e = _a.type, type = _e === void 0 ? exports.FieldType.TEXT : _e, prompt = _a.prompt, _f = _a.disabled, disabled = _f === void 0 ? false : _f; _a.prefixGap; _a.suffixGap; var css = _a.css, id = _a.id, autoFocus = _a.autoFocus, rootCss = _a.rootCss, _g = _a.styleConfig, styleConfig = _g === void 0 ? {} : _g, onFocus = _a.onFocus, onBlur = _a.onBlur, rest = __rest(_a, ["value", "placeholder", "onChange", "prefix", "suffix", "variant", "type", "prompt", "disabled", "prefixGap", "suffixGap", "css", "id", "autoFocus", "rootCss", "styleConfig", "onFocus", "onBlur"]);
169
- var theme = ctDesignTheme.useTheme();
170
- var rootBox = styleConfig.rootBox, fieldContainer = styleConfig.fieldContainer, placeholderLabel = styleConfig.placeholderLabel, placeholderTypography = styleConfig.placeholderTypography, field = styleConfig.field, promptBox = styleConfig.promptBox, promptIconContainer = styleConfig.promptIconContainer, promptMessageTypography = styleConfig.promptMessageTypography;
171
- var _h = react.useState(autoFocus || false), focus = _h[0], setFocus = _h[1];
172
- var _j = prompt || {}, _k = _j.hasError, hasError = _k === void 0 ? false : _k, promptIcon = _j.Icon, promptMessage = _j.message;
173
- var isFocused = focus || value.length > 0;
174
- var isPrefixComponent = react.isValidElement(prefix);
175
- var disabledPlaceHolder = !(placeholder === null || placeholder === void 0 ? void 0 : placeholder.length);
176
- var fieldContainerStyles = getFieldContainerStyles({
177
- variant: variant,
178
- theme: theme,
179
- hasError: hasError,
180
- focus: focus,
181
- value: value,
182
- disabled: disabled,
183
- });
184
- var fieldPlaceholderStyles = getFieldPlaceholderStyles({
185
- isFocused: isFocused,
186
- theme: theme,
187
- disabled: disabled,
188
- variant: variant,
189
- fieldType: type,
190
- isPrefixComponent: isPrefixComponent,
191
- });
192
- var fieldStyles = getFieldStyles({
193
- disabled: disabled,
194
- theme: theme,
195
- variant: variant,
196
- focus: focus,
197
- value: value,
198
- type: type,
199
- isPrefixComponent: isPrefixComponent,
200
- disabledPlaceHolder: disabledPlaceHolder,
201
- });
202
- var onFieldChange = function (e) {
203
- var value = e.target.value;
204
- var isValidValue = true;
205
- switch (type) {
206
- case exports.FieldType.NUMBER: {
207
- if (value && !ctDesignCommonConstants.ONLY_NUMERIC.test(value)) {
208
- isValidValue = false;
209
- }
321
+ return e.position;
322
+ }
323
+ function J(r, a) {
324
+ while (F()) if (r + e.character === 47 + 10) break;else if (r + e.character === 42 + 42 && I() === 47) break;
325
+ return "/*" + D(a, e.position - 1) + "*" + $(r === 47 ? r : F());
326
+ }
327
+ function Q(r) {
328
+ while (!Y(I())) F();
329
+ return D(r, e.position);
330
+ }
331
+ function X(e) {
332
+ return V(ee("", null, null, null, [""], e = K(e), 0, [0], e));
333
+ }
334
+ function ee(e, r, a, c, n, t, s, i, u) {
335
+ var o = 0;
336
+ var f = 0;
337
+ var l = s;
338
+ var p = 0;
339
+ var h = 0;
340
+ var v = 0;
341
+ var d = 1;
342
+ var b = 1;
343
+ var w = 1;
344
+ var m = 0;
345
+ var g = "";
346
+ var k = n;
347
+ var x = t;
348
+ var E = c;
349
+ var y = g;
350
+ while (b) switch (v = m, m = F()) {
351
+ case 40:
352
+ if (v != 108 && M(y, l - 1) == 58) {
353
+ if (O(y += A(W(m), "&", "&\f"), "&\f") != -1) w = -1;
354
+ break;
355
+ }
356
+ case 34:
357
+ case 39:
358
+ case 91:
359
+ y += W(m);
360
+ break;
361
+ case 9:
362
+ case 10:
363
+ case 13:
364
+ case 32:
365
+ y += G(v);
366
+ break;
367
+ case 92:
368
+ y += Z(L() - 1, 7);
369
+ continue;
370
+ case 47:
371
+ switch (I()) {
372
+ case 42:
373
+ case 47:
374
+ z(ae(J(F(), L()), r, a), u);
375
+ break;
376
+ default:
377
+ y += "/";
378
+ }
379
+ break;
380
+ case 123 * d:
381
+ i[o++] = R(y) * w;
382
+ case 125 * d:
383
+ case 59:
384
+ case 0:
385
+ switch (m) {
386
+ case 0:
387
+ case 125:
388
+ b = 0;
389
+ case 59 + f:
390
+ if (w == -1) y = A(y, /\f/g, "");
391
+ if (h > 0 && R(y) - l) z(h > 32 ? ce(y + ";", c, a, l - 1) : ce(A(y, " ", "") + ";", c, a, l - 2), u);
392
+ break;
393
+ case 59:
394
+ y += ";";
395
+ default:
396
+ z(E = re(y, r, a, o, f, n, i, g, k = [], x = [], l), t);
397
+ if (m === 123) if (f === 0) ee(y, r, E, E, k, t, l, i, x);else switch (p === 99 && M(y, 3) === 110 ? 100 : p) {
398
+ case 100:
399
+ case 108:
400
+ case 109:
401
+ case 115:
402
+ ee(e, E, E, c && z(re(e, E, E, 0, 0, n, i, g, n, k = [], l), x), n, x, l, i, c ? k : x);
210
403
  break;
404
+ default:
405
+ ee(y, E, E, E, [""], x, 0, i, x);
211
406
  }
212
407
  }
213
- if (isValidValue) {
214
- onChange(e);
408
+ o = f = h = 0, d = w = 1, g = y = "", l = s;
409
+ break;
410
+ case 58:
411
+ l = 1 + R(y), h = v;
412
+ default:
413
+ if (d < 1) if (m == 123) --d;else if (m == 125 && d++ == 0 && _() == 125) continue;
414
+ switch (y += $(m), m * d) {
415
+ case 38:
416
+ w = f > 0 ? 1 : (y += "\f", -1);
417
+ break;
418
+ case 44:
419
+ i[o++] = (R(y) - 1) * w, w = 1;
420
+ break;
421
+ case 64:
422
+ if (I() === 45) y += W(F());
423
+ p = I(), f = l = R(g = y += Q(L())), m++;
424
+ break;
425
+ case 45:
426
+ if (v === 45 && R(y) == 2) d = 0;
215
427
  }
428
+ }
429
+ return t;
430
+ }
431
+ function re(e, r, a, c, n, s, i, u, o, f, l) {
432
+ var p = n - 1;
433
+ var h = n === 0 ? s : [""];
434
+ var v = S(h);
435
+ for (var d = 0, b = 0, w = 0; d < c; ++d) for (var m = 0, g = C(e, p + 1, p = k(b = i[d])), $ = e; m < v; ++m) if ($ = y(b > 0 ? h[m] + " " + g : A(g, /&\f/g, h[m]))) o[w++] = $;
436
+ return P(e, r, a, n === 0 ? t : u, o, f, l);
437
+ }
438
+ function ae(e, r, a) {
439
+ return P(e, r, a, n, $(U()), C(e, 2, -2), 0);
440
+ }
441
+ function ce(e, r, a, c) {
442
+ return P(e, r, a, s, C(e, 0, c), C(e, c + 1, -1), c);
443
+ }
444
+ function ne(e, n, t) {
445
+ switch (E(e, n)) {
446
+ case 5103:
447
+ return c + "print-" + e + e;
448
+ case 5737:
449
+ case 4201:
450
+ case 3177:
451
+ case 3433:
452
+ case 1641:
453
+ case 4457:
454
+ case 2921:
455
+ case 5572:
456
+ case 6356:
457
+ case 5844:
458
+ case 3191:
459
+ case 6645:
460
+ case 3005:
461
+ case 6391:
462
+ case 5879:
463
+ case 5623:
464
+ case 6135:
465
+ case 4599:
466
+ case 4855:
467
+ case 4215:
468
+ case 6389:
469
+ case 5109:
470
+ case 5365:
471
+ case 5621:
472
+ case 3829:
473
+ return c + e + e;
474
+ case 4789:
475
+ return a + e + e;
476
+ case 5349:
477
+ case 4246:
478
+ case 4810:
479
+ case 6968:
480
+ case 2756:
481
+ return c + e + a + e + r + e + e;
482
+ case 5936:
483
+ switch (M(e, n + 11)) {
484
+ case 114:
485
+ return c + e + r + A(e, /[svh]\w+-[tblr]{2}/, "tb") + e;
486
+ case 108:
487
+ return c + e + r + A(e, /[svh]\w+-[tblr]{2}/, "tb-rl") + e;
488
+ case 45:
489
+ return c + e + r + A(e, /[svh]\w+-[tblr]{2}/, "lr") + e;
490
+ }
491
+ case 6828:
492
+ case 4268:
493
+ case 2903:
494
+ return c + e + r + e + e;
495
+ case 6165:
496
+ return c + e + r + "flex-" + e + e;
497
+ case 5187:
498
+ return c + e + A(e, /(\w+).+(:[^]+)/, c + "box-$1$2" + r + "flex-$1$2") + e;
499
+ case 5443:
500
+ return c + e + r + "flex-item-" + A(e, /flex-|-self/g, "") + (!T(e, /flex-|baseline/) ? r + "grid-row-" + A(e, /flex-|-self/g, "") : "") + e;
501
+ case 4675:
502
+ return c + e + r + "flex-line-pack" + A(e, /align-content|flex-|-self/g, "") + e;
503
+ case 5548:
504
+ return c + e + r + A(e, "shrink", "negative") + e;
505
+ case 5292:
506
+ return c + e + r + A(e, "basis", "preferred-size") + e;
507
+ case 6060:
508
+ return c + "box-" + A(e, "-grow", "") + c + e + r + A(e, "grow", "positive") + e;
509
+ case 4554:
510
+ return c + A(e, /([^-])(transform)/g, "$1" + c + "$2") + e;
511
+ case 6187:
512
+ return A(A(A(e, /(zoom-|grab)/, c + "$1"), /(image-set)/, c + "$1"), e, "") + e;
513
+ case 5495:
514
+ case 3959:
515
+ return A(e, /(image-set\([^]*)/, c + "$1" + "$`$1");
516
+ case 4968:
517
+ return A(A(e, /(.+:)(flex-)?(.*)/, c + "box-pack:$3" + r + "flex-pack:$3"), /s.+-b[^;]+/, "justify") + c + e + e;
518
+ case 4200:
519
+ if (!T(e, /flex-|baseline/)) return r + "grid-column-align" + C(e, n) + e;
520
+ break;
521
+ case 2592:
522
+ case 3360:
523
+ return r + A(e, "template-", "") + e;
524
+ case 4384:
525
+ case 3616:
526
+ if (t && t.some(function (e, r) {
527
+ return n = r, T(e.props, /grid-\w+-end/);
528
+ })) {
529
+ return ~O(e + (t = t[n].value), "span") ? e : r + A(e, "-start", "") + e + r + "grid-row-span:" + (~O(t, "span") ? T(t, /\d+/) : +T(t, /\d+/) - +T(e, /\d+/)) + ";";
530
+ }
531
+ return r + A(e, "-start", "") + e;
532
+ case 4896:
533
+ case 4128:
534
+ return t && t.some(function (e) {
535
+ return T(e.props, /grid-\w+-start/);
536
+ }) ? e : r + A(A(e, "-end", "-span"), "span ", "") + e;
537
+ case 4095:
538
+ case 3583:
539
+ case 4068:
540
+ case 2532:
541
+ return A(e, /(.+)-inline(.+)/, c + "$1$2") + e;
542
+ case 8116:
543
+ case 7059:
544
+ case 5753:
545
+ case 5535:
546
+ case 5445:
547
+ case 5701:
548
+ case 4933:
549
+ case 4677:
550
+ case 5533:
551
+ case 5789:
552
+ case 5021:
553
+ case 4765:
554
+ if (R(e) - 1 - n > 6) switch (M(e, n + 1)) {
555
+ case 109:
556
+ if (M(e, n + 4) !== 45) break;
557
+ case 102:
558
+ return A(e, /(.+:)(.+)-([^]+)/, "$1" + c + "$2-$3" + "$1" + a + (M(e, n + 3) == 108 ? "$3" : "$2-$3")) + e;
559
+ case 115:
560
+ return ~O(e, "stretch") ? ne(A(e, "stretch", "fill-available"), n, t) + e : e;
561
+ }
562
+ break;
563
+ case 5152:
564
+ case 5920:
565
+ return A(e, /(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/, function (a, c, n, t, s, i, u) {
566
+ return r + c + ":" + n + u + (t ? r + c + "-span:" + (s ? i : +i - +n) + u : "") + e;
567
+ });
568
+ case 4949:
569
+ if (M(e, n + 6) === 121) return A(e, ":", ":" + c) + e;
570
+ break;
571
+ case 6444:
572
+ switch (M(e, M(e, 14) === 45 ? 18 : 11)) {
573
+ case 120:
574
+ return A(e, /(.+:)([^;\s!]+)(;|(\s+)?!.+)?/, "$1" + c + (M(e, 14) === 45 ? "inline-" : "") + "box$3" + "$1" + c + "$2$3" + "$1" + r + "$2box$3") + e;
575
+ case 100:
576
+ return A(e, ":", ":" + r) + e;
577
+ }
578
+ break;
579
+ case 5719:
580
+ case 2647:
581
+ case 2135:
582
+ case 3927:
583
+ case 2391:
584
+ return A(e, "scroll-", "scroll-snap-") + e;
585
+ }
586
+ return e;
587
+ }
588
+ function te(e, r) {
589
+ var a = "";
590
+ var c = S(e);
591
+ for (var n = 0; n < c; n++) a += r(e[n], n, e, r) || "";
592
+ return a;
593
+ }
594
+ function se(e, r, a, c) {
595
+ switch (e.type) {
596
+ case g:
597
+ if (e.children.length) break;
598
+ case o:
599
+ case s:
600
+ return e.return = e.return || e.value;
601
+ case n:
602
+ return "";
603
+ case d:
604
+ return e.return = e.value + "{" + te(e.children, c) + "}";
605
+ case t:
606
+ e.value = e.props.join(",");
607
+ }
608
+ return R(a = te(e.children, c)) ? e.return = e.value + "{" + a + "}" : "";
609
+ }
610
+ function ie(e) {
611
+ var r = S(e);
612
+ return function (a, c, n, t) {
613
+ var s = "";
614
+ for (var i = 0; i < r; i++) s += e[i](a, c, n, t) || "";
615
+ return s;
216
616
  };
217
- var customOnFocus = function (e) {
218
- setFocus(true);
219
- onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
220
- };
221
- var customOnBlur = function (e) {
222
- setFocus(false);
223
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
617
+ }
618
+ function ue(e) {
619
+ return function (r) {
620
+ if (!r.root) if (r = r.return) e(r);
224
621
  };
225
- var getFieldPlaceholder = function () {
226
- switch (variant) {
227
- case exports.FieldVariant.SM: {
228
- if (!value.length) {
229
- return (jsxRuntime.jsx(StyledFieldPlaceholder, __assign({}, fieldPlaceholderStyles, { htmlFor: id, className: placeholderLabel === null || placeholderLabel === void 0 ? void 0 : placeholderLabel.className, css: placeholderLabel === null || placeholderLabel === void 0 ? void 0 : placeholderLabel.css }, { children: jsxRuntime.jsx(ctDesignTypography.Typography, __assign({ variant: 'B1', color: 'tertiary', styleConfig: placeholderTypography }, { children: placeholder })) })));
622
+ }
623
+ function oe(e, n, i, u) {
624
+ if (e.length > -1) if (!e.return) switch (e.type) {
625
+ case s:
626
+ e.return = ne(e.value, e.length, i);
627
+ return;
628
+ case d:
629
+ return te([j(e, {
630
+ value: A(e.value, "@", "@" + c)
631
+ })], u);
632
+ case t:
633
+ if (e.length) return N(e.props, function (n) {
634
+ switch (T(n, /(::plac\w+|:read-\w+)/)) {
635
+ case ":read-only":
636
+ case ":read-write":
637
+ return te([j(e, {
638
+ props: [A(n, /:(read-\w+)/, ":" + a + "$1")]
639
+ })], u);
640
+ case "::placeholder":
641
+ return te([j(e, {
642
+ props: [A(n, /:(plac\w+)/, ":" + c + "input-$1")]
643
+ }), j(e, {
644
+ props: [A(n, /:(plac\w+)/, ":" + a + "$1")]
645
+ }), j(e, {
646
+ props: [A(n, /:(plac\w+)/, r + "input-$1")]
647
+ })], u);
648
+ }
649
+ return "";
650
+ });
651
+ }
652
+ }
653
+ function fe(e) {
654
+ switch (e.type) {
655
+ case t:
656
+ e.props = e.props.map(function (r) {
657
+ return N(B(r), function (r, a, c) {
658
+ switch (M(r, 0)) {
659
+ case 12:
660
+ return C(r, 1, R(r));
661
+ case 0:
662
+ case 40:
663
+ case 43:
664
+ case 62:
665
+ case 126:
666
+ return r;
667
+ case 58:
668
+ if (c[++a] === "global") c[a] = "", c[++a] = "\f" + C(c[a], a = 1, -1);
669
+ case 32:
670
+ return a === 1 ? "" : r;
671
+ default:
672
+ switch (a) {
673
+ case 0:
674
+ e = r;
675
+ return S(c) > 1 ? "" : r;
676
+ case a = S(c) - 1:
677
+ case 2:
678
+ return a === 2 ? r + e + e : r + e;
679
+ default:
680
+ return r;
230
681
  }
231
- break;
232
682
  }
233
- case exports.FieldVariant.MD: {
234
- if (type === exports.FieldType.PHONE && value.length)
235
- return;
236
- return (jsxRuntime.jsx(StyledFieldPlaceholder, __assign({}, fieldPlaceholderStyles, { htmlFor: id, className: placeholderLabel === null || placeholderLabel === void 0 ? void 0 : placeholderLabel.className, css: placeholderLabel === null || placeholderLabel === void 0 ? void 0 : placeholderLabel.css }, { children: jsxRuntime.jsx(ctDesignTypography.Typography, __assign({ variant: type === exports.FieldType.PHONE ? 'B1' : isFocused ? 'B3' : 'B1', color: 'tertiary', styleConfig: placeholderTypography }, { children: placeholder })) })));
237
- }
238
- default: {
239
- if (type === exports.FieldType.PHONE && value.length)
240
- return;
241
- return (jsxRuntime.jsx(StyledFieldPlaceholder, __assign({}, fieldPlaceholderStyles, { htmlFor: id, className: placeholderLabel === null || placeholderLabel === void 0 ? void 0 : placeholderLabel.className, css: placeholderLabel === null || placeholderLabel === void 0 ? void 0 : placeholderLabel.css }, { children: jsxRuntime.jsx(ctDesignTypography.Typography, __assign({ variant: type === exports.FieldType.PHONE ? 'B1' : isFocused ? 'B3' : 'B1', color: 'tertiary', styleConfig: placeholderTypography }, { children: placeholder })) })));
242
- }
243
- }
244
- };
245
- return (jsxRuntime.jsxs(ctDesignBox.Box, __assign({ boxSize: 'micro', className: rootBox === null || rootBox === void 0 ? void 0 : rootBox.className, css: (rootBox === null || rootBox === void 0 ? void 0 : rootBox.css) || rootCss }, { children: [jsxRuntime.jsxs(StyledFieldContainer, __assign({}, fieldContainerStyles, { className: fieldContainer === null || fieldContainer === void 0 ? void 0 : fieldContainer.className, css: (fieldContainer === null || fieldContainer === void 0 ? void 0 : fieldContainer.css) || css }, { children: [react.isValidElement(prefix) && react.cloneElement(prefix, { focus: focus }), !disabledPlaceHolder && getFieldPlaceholder(), jsxRuntime.jsx(StyledField, __assign({}, fieldStyles, { id: id, value: value, onChange: onFieldChange, autoComplete: 'off', disabled: disabled, ref: forwardedRef, autoFocus: autoFocus, onFocus: customOnFocus, onBlur: customOnBlur, css: field === null || field === void 0 ? void 0 : field.css, className: field === null || field === void 0 ? void 0 : field.className }, rest)), react.isValidElement(suffix) && react.cloneElement(suffix, { focus: focus })] })), (promptIcon || promptMessage) && (jsxRuntime.jsxs(ctDesignBox.Box, __assign({ boxSize: 'pico', horizontal: true, css: __assign({ paddingLeft: theme.spacing[4], paddingRight: theme.spacing[4], display: 'flex', alignItems: 'center' }, promptBox === null || promptBox === void 0 ? void 0 : promptBox.css), className: promptBox === null || promptBox === void 0 ? void 0 : promptBox.className }, { children: [promptIcon && (jsxRuntime.jsx(ctDesignContainer.Container, __assign({ css: __assign({ height: theme.size[4], width: theme.size[4], paddingRight: theme.spacing[1], display: 'flex', justifyContent: 'center', alignItems: 'center' }, promptIconContainer === null || promptIconContainer === void 0 ? void 0 : promptIconContainer.css), className: promptIconContainer === null || promptIconContainer === void 0 ? void 0 : promptIconContainer.className }, { children: promptIcon }))), promptMessage && (jsxRuntime.jsx(ctDesignTypography.Typography, __assign({ variant: 'B3', color: hasError ? 'warning' : 'success', styleConfig: promptMessageTypography }, { children: promptMessage })))] })))] })));
683
+ });
684
+ });
685
+ }
686
+ }
687
+ e.CHARSET = f;
688
+ e.COMMENT = n;
689
+ e.COUNTER_STYLE = w;
690
+ e.DECLARATION = s;
691
+ e.DOCUMENT = h;
692
+ e.FONT_FACE = b;
693
+ e.FONT_FEATURE_VALUES = m;
694
+ e.IMPORT = o;
695
+ e.KEYFRAMES = d;
696
+ e.LAYER = g;
697
+ e.MEDIA = u;
698
+ e.MOZ = a;
699
+ e.MS = r;
700
+ e.NAMESPACE = v;
701
+ e.PAGE = i;
702
+ e.RULESET = t;
703
+ e.SUPPORTS = p;
704
+ e.VIEWPORT = l;
705
+ e.WEBKIT = c;
706
+ e.abs = k;
707
+ e.alloc = K;
708
+ e.append = z;
709
+ e.assign = x;
710
+ e.caret = L;
711
+ e.char = U;
712
+ e.charat = M;
713
+ e.combine = N;
714
+ e.comment = ae;
715
+ e.commenter = J;
716
+ e.compile = X;
717
+ e.copy = j;
718
+ e.dealloc = V;
719
+ e.declaration = ce;
720
+ e.delimit = W;
721
+ e.delimiter = q;
722
+ e.escaping = Z;
723
+ e.from = $;
724
+ e.hash = E;
725
+ e.identifier = Q;
726
+ e.indexof = O;
727
+ e.match = T;
728
+ e.middleware = ie;
729
+ e.namespace = fe;
730
+ e.next = F;
731
+ e.node = P;
732
+ e.parse = ee;
733
+ e.peek = I;
734
+ e.prefix = ne;
735
+ e.prefixer = oe;
736
+ e.prev = _;
737
+ e.replace = A;
738
+ e.ruleset = re;
739
+ e.rulesheet = ue;
740
+ e.serialize = te;
741
+ e.sizeof = S;
742
+ e.slice = D;
743
+ e.stringify = se;
744
+ e.strlen = R;
745
+ e.substr = C;
746
+ e.token = Y;
747
+ e.tokenize = B;
748
+ e.tokenizer = H;
749
+ e.trim = y;
750
+ e.whitespace = G;
751
+ Object.defineProperty(e, "__esModule", {
752
+ value: true
753
+ });
246
754
  });
755
+ })(stylis, stylisExports);
756
+
757
+ var weakMemoize = function weakMemoize(func) {
758
+ var cache = new WeakMap();
759
+ return function (arg) {
760
+ if (cache.has(arg)) {
761
+ // Use non-null assertion because we just checked that the cache `has` it
762
+ // This allows us to remove `undefined` from the return value
763
+ return cache.get(arg);
764
+ }
765
+ var ret = func(arg);
766
+ cache.set(arg, ret);
767
+ return ret;
768
+ };
769
+ };
770
+
771
+ function memoize(fn) {
772
+ var cache = Object.create(null);
773
+ return function (arg) {
774
+ if (cache[arg] === undefined) cache[arg] = fn(arg);
775
+ return cache[arg];
776
+ };
777
+ }
778
+
779
+ var isBrowser$1 = typeof document !== 'undefined';
780
+ var identifierWithPointTracking = function identifierWithPointTracking(begin, points, index) {
781
+ var previous = 0;
782
+ var character = 0;
783
+ while (true) {
784
+ previous = character;
785
+ character = stylisExports.peek(); // &\f
786
+
787
+ if (previous === 38 && character === 12) {
788
+ points[index] = 1;
789
+ }
790
+ if (stylisExports.token(character)) {
791
+ break;
792
+ }
793
+ stylisExports.next();
794
+ }
795
+ return stylisExports.slice(begin, stylisExports.position);
796
+ };
797
+ var toRules = function toRules(parsed, points) {
798
+ // pretend we've started with a comma
799
+ var index = -1;
800
+ var character = 44;
801
+ do {
802
+ switch (stylisExports.token(character)) {
803
+ case 0:
804
+ // &\f
805
+ if (character === 38 && stylisExports.peek() === 12) {
806
+ // this is not 100% correct, we don't account for literal sequences here - like for example quoted strings
807
+ // stylis inserts \f after & to know when & where it should replace this sequence with the context selector
808
+ // and when it should just concatenate the outer and inner selectors
809
+ // it's very unlikely for this sequence to actually appear in a different context, so we just leverage this fact here
810
+ points[index] = 1;
811
+ }
812
+ parsed[index] += identifierWithPointTracking(stylisExports.position - 1, points, index);
813
+ break;
814
+ case 2:
815
+ parsed[index] += stylisExports.delimit(character);
816
+ break;
817
+ case 4:
818
+ // comma
819
+ if (character === 44) {
820
+ // colon
821
+ parsed[++index] = stylisExports.peek() === 58 ? '&\f' : '';
822
+ points[index] = parsed[index].length;
823
+ break;
824
+ }
825
+
826
+ // fallthrough
827
+
828
+ default:
829
+ parsed[index] += stylisExports.from(character);
830
+ }
831
+ } while (character = stylisExports.next());
832
+ return parsed;
833
+ };
834
+ var getRules = function getRules(value, points) {
835
+ return stylisExports.dealloc(toRules(stylisExports.alloc(value), points));
836
+ }; // WeakSet would be more appropriate, but only WeakMap is supported in IE11
837
+
838
+ var fixedElements = /* #__PURE__ */new WeakMap();
839
+ var compat = function compat(element) {
840
+ if (element.type !== 'rule' || !element.parent ||
841
+ // positive .length indicates that this rule contains pseudo
842
+ // negative .length indicates that this rule has been already prefixed
843
+ element.length < 1) {
844
+ return;
845
+ }
846
+ var value = element.value;
847
+ var parent = element.parent;
848
+ var isImplicitRule = element.column === parent.column && element.line === parent.line;
849
+ while (parent.type !== 'rule') {
850
+ parent = parent.parent;
851
+ if (!parent) return;
852
+ } // short-circuit for the simplest case
853
+
854
+ if (element.props.length === 1 && value.charCodeAt(0) !== 58
855
+ /* colon */ && !fixedElements.get(parent)) {
856
+ return;
857
+ } // if this is an implicitly inserted rule (the one eagerly inserted at the each new nested level)
858
+ // then the props has already been manipulated beforehand as they that array is shared between it and its "rule parent"
859
+
860
+ if (isImplicitRule) {
861
+ return;
862
+ }
863
+ fixedElements.set(element, true);
864
+ var points = [];
865
+ var rules = getRules(value, points);
866
+ var parentRules = parent.props;
867
+ for (var i = 0, k = 0; i < rules.length; i++) {
868
+ for (var j = 0; j < parentRules.length; j++, k++) {
869
+ element.props[k] = points[i] ? rules[i].replace(/&\f/g, parentRules[j]) : parentRules[j] + " " + rules[i];
870
+ }
871
+ }
872
+ };
873
+ var removeLabel = function removeLabel(element) {
874
+ if (element.type === 'decl') {
875
+ var value = element.value;
876
+ if (
877
+ // charcode for l
878
+ value.charCodeAt(0) === 108 &&
879
+ // charcode for b
880
+ value.charCodeAt(2) === 98) {
881
+ // this ignores label
882
+ element["return"] = '';
883
+ element.value = '';
884
+ }
885
+ }
886
+ };
247
887
 
248
- exports.CURSOR_OPERATION = void 0;
249
- (function (CURSOR_OPERATION) {
250
- CURSOR_OPERATION["NONE"] = "NONE";
251
- CURSOR_OPERATION["ADD"] = "ADD";
252
- CURSOR_OPERATION["SUBSTRACT"] = "SUBSTRACT";
253
- })(exports.CURSOR_OPERATION || (exports.CURSOR_OPERATION = {}));
254
-
255
- var CardField = react.forwardRef(function (_a, forwardedRef) {
256
- var onChange = _a.onChange, _b = _a.gap, gap = _b === void 0 ? 4 : _b, value = _a.value, rest = __rest(_a, ["onChange", "gap", "value"]);
257
- var cursorRef = react.useRef({
258
- cursorPos: 0,
259
- operation: exports.CURSOR_OPERATION.NONE,
888
+ /* eslint-disable no-fallthrough */
889
+
890
+ function prefix(value, length) {
891
+ switch (stylisExports.hash(value, length)) {
892
+ // color-adjust
893
+ case 5103:
894
+ return stylisExports.WEBKIT + 'print-' + value + value;
895
+ // animation, animation-(delay|direction|duration|fill-mode|iteration-count|name|play-state|timing-function)
896
+
897
+ case 5737:
898
+ case 4201:
899
+ case 3177:
900
+ case 3433:
901
+ case 1641:
902
+ case 4457:
903
+ case 2921: // text-decoration, filter, clip-path, backface-visibility, column, box-decoration-break
904
+
905
+ case 5572:
906
+ case 6356:
907
+ case 5844:
908
+ case 3191:
909
+ case 6645:
910
+ case 3005: // mask, mask-image, mask-(mode|clip|size), mask-(repeat|origin), mask-position, mask-composite,
911
+
912
+ case 6391:
913
+ case 5879:
914
+ case 5623:
915
+ case 6135:
916
+ case 4599:
917
+ case 4855: // background-clip, columns, column-(count|fill|gap|rule|rule-color|rule-style|rule-width|span|width)
918
+
919
+ case 4215:
920
+ case 6389:
921
+ case 5109:
922
+ case 5365:
923
+ case 5621:
924
+ case 3829:
925
+ return stylisExports.WEBKIT + value + value;
926
+ // appearance, user-select, transform, hyphens, text-size-adjust
927
+
928
+ case 5349:
929
+ case 4246:
930
+ case 4810:
931
+ case 6968:
932
+ case 2756:
933
+ return stylisExports.WEBKIT + value + stylisExports.MOZ + value + stylisExports.MS + value + value;
934
+ // flex, flex-direction
935
+
936
+ case 6828:
937
+ case 4268:
938
+ return stylisExports.WEBKIT + value + stylisExports.MS + value + value;
939
+ // order
940
+
941
+ case 6165:
942
+ return stylisExports.WEBKIT + value + stylisExports.MS + 'flex-' + value + value;
943
+ // align-items
944
+
945
+ case 5187:
946
+ return stylisExports.WEBKIT + value + stylisExports.replace(value, /(\w+).+(:[^]+)/, stylisExports.WEBKIT + 'box-$1$2' + stylisExports.MS + 'flex-$1$2') + value;
947
+ // align-self
948
+
949
+ case 5443:
950
+ return stylisExports.WEBKIT + value + stylisExports.MS + 'flex-item-' + stylisExports.replace(value, /flex-|-self/, '') + value;
951
+ // align-content
952
+
953
+ case 4675:
954
+ return stylisExports.WEBKIT + value + stylisExports.MS + 'flex-line-pack' + stylisExports.replace(value, /align-content|flex-|-self/, '') + value;
955
+ // flex-shrink
956
+
957
+ case 5548:
958
+ return stylisExports.WEBKIT + value + stylisExports.MS + stylisExports.replace(value, 'shrink', 'negative') + value;
959
+ // flex-basis
960
+
961
+ case 5292:
962
+ return stylisExports.WEBKIT + value + stylisExports.MS + stylisExports.replace(value, 'basis', 'preferred-size') + value;
963
+ // flex-grow
964
+
965
+ case 6060:
966
+ return stylisExports.WEBKIT + 'box-' + stylisExports.replace(value, '-grow', '') + stylisExports.WEBKIT + value + stylisExports.MS + stylisExports.replace(value, 'grow', 'positive') + value;
967
+ // transition
968
+
969
+ case 4554:
970
+ return stylisExports.WEBKIT + stylisExports.replace(value, /([^-])(transform)/g, '$1' + stylisExports.WEBKIT + '$2') + value;
971
+ // cursor
972
+
973
+ case 6187:
974
+ return stylisExports.replace(stylisExports.replace(stylisExports.replace(value, /(zoom-|grab)/, stylisExports.WEBKIT + '$1'), /(image-set)/, stylisExports.WEBKIT + '$1'), value, '') + value;
975
+ // background, background-image
976
+
977
+ case 5495:
978
+ case 3959:
979
+ return stylisExports.replace(value, /(image-set\([^]*)/, stylisExports.WEBKIT + '$1' + '$`$1');
980
+ // justify-content
981
+
982
+ case 4968:
983
+ return stylisExports.replace(stylisExports.replace(value, /(.+:)(flex-)?(.*)/, stylisExports.WEBKIT + 'box-pack:$3' + stylisExports.MS + 'flex-pack:$3'), /s.+-b[^;]+/, 'justify') + stylisExports.WEBKIT + value + value;
984
+ // (margin|padding)-inline-(start|end)
985
+
986
+ case 4095:
987
+ case 3583:
988
+ case 4068:
989
+ case 2532:
990
+ return stylisExports.replace(value, /(.+)-inline(.+)/, stylisExports.WEBKIT + '$1$2') + value;
991
+ // (min|max)?(width|height|inline-size|block-size)
992
+
993
+ case 8116:
994
+ case 7059:
995
+ case 5753:
996
+ case 5535:
997
+ case 5445:
998
+ case 5701:
999
+ case 4933:
1000
+ case 4677:
1001
+ case 5533:
1002
+ case 5789:
1003
+ case 5021:
1004
+ case 4765:
1005
+ // stretch, max-content, min-content, fill-available
1006
+ if (stylisExports.strlen(value) - 1 - length > 6) switch (stylisExports.charat(value, length + 1)) {
1007
+ // (m)ax-content, (m)in-content
1008
+ case 109:
1009
+ // -
1010
+ if (stylisExports.charat(value, length + 4) !== 45) break;
1011
+ // (f)ill-available, (f)it-content
1012
+
1013
+ case 102:
1014
+ return stylisExports.replace(value, /(.+:)(.+)-([^]+)/, '$1' + stylisExports.WEBKIT + '$2-$3' + '$1' + stylisExports.MOZ + (stylisExports.charat(value, length + 3) == 108 ? '$3' : '$2-$3')) + value;
1015
+ // (s)tretch
1016
+
1017
+ case 115:
1018
+ return ~stylisExports.indexof(value, 'stretch') ? prefix(stylisExports.replace(value, 'stretch', 'fill-available'), length) + value : value;
1019
+ }
1020
+ break;
1021
+ // position: sticky
1022
+
1023
+ case 4949:
1024
+ // (s)ticky?
1025
+ if (stylisExports.charat(value, length + 1) !== 115) break;
1026
+ // display: (flex|inline-flex)
1027
+
1028
+ case 6444:
1029
+ switch (stylisExports.charat(value, stylisExports.strlen(value) - 3 - (~stylisExports.indexof(value, '!important') && 10))) {
1030
+ // stic(k)y
1031
+ case 107:
1032
+ return stylisExports.replace(value, ':', ':' + stylisExports.WEBKIT) + value;
1033
+ // (inline-)?fl(e)x
1034
+
1035
+ case 101:
1036
+ return stylisExports.replace(value, /(.+:)([^;!]+)(;|!.+)?/, '$1' + stylisExports.WEBKIT + (stylisExports.charat(value, 14) === 45 ? 'inline-' : '') + 'box$3' + '$1' + stylisExports.WEBKIT + '$2$3' + '$1' + stylisExports.MS + '$2box$3') + value;
1037
+ }
1038
+ break;
1039
+ // writing-mode
1040
+
1041
+ case 5936:
1042
+ switch (stylisExports.charat(value, length + 11)) {
1043
+ // vertical-l(r)
1044
+ case 114:
1045
+ return stylisExports.WEBKIT + value + stylisExports.MS + stylisExports.replace(value, /[svh]\w+-[tblr]{2}/, 'tb') + value;
1046
+ // vertical-r(l)
1047
+
1048
+ case 108:
1049
+ return stylisExports.WEBKIT + value + stylisExports.MS + stylisExports.replace(value, /[svh]\w+-[tblr]{2}/, 'tb-rl') + value;
1050
+ // horizontal(-)tb
1051
+
1052
+ case 45:
1053
+ return stylisExports.WEBKIT + value + stylisExports.MS + stylisExports.replace(value, /[svh]\w+-[tblr]{2}/, 'lr') + value;
1054
+ }
1055
+ return stylisExports.WEBKIT + value + stylisExports.MS + value + value;
1056
+ }
1057
+ return value;
1058
+ }
1059
+ var prefixer = function prefixer(element, index, children, callback) {
1060
+ if (element.length > -1) if (!element["return"]) switch (element.type) {
1061
+ case stylisExports.DECLARATION:
1062
+ element["return"] = prefix(element.value, element.length);
1063
+ break;
1064
+ case stylisExports.KEYFRAMES:
1065
+ return stylisExports.serialize([stylisExports.copy(element, {
1066
+ value: stylisExports.replace(element.value, '@', '@' + stylisExports.WEBKIT)
1067
+ })], callback);
1068
+ case stylisExports.RULESET:
1069
+ if (element.length) return stylisExports.combine(element.props, function (value) {
1070
+ switch (stylisExports.match(value, /(::plac\w+|:read-\w+)/)) {
1071
+ // :read-(only|write)
1072
+ case ':read-only':
1073
+ case ':read-write':
1074
+ return stylisExports.serialize([stylisExports.copy(element, {
1075
+ props: [stylisExports.replace(value, /:(read-\w+)/, ':' + stylisExports.MOZ + '$1')]
1076
+ })], callback);
1077
+ // :placeholder
1078
+
1079
+ case '::placeholder':
1080
+ return stylisExports.serialize([stylisExports.copy(element, {
1081
+ props: [stylisExports.replace(value, /:(plac\w+)/, ':' + stylisExports.WEBKIT + 'input-$1')]
1082
+ }), stylisExports.copy(element, {
1083
+ props: [stylisExports.replace(value, /:(plac\w+)/, ':' + stylisExports.MOZ + '$1')]
1084
+ }), stylisExports.copy(element, {
1085
+ props: [stylisExports.replace(value, /:(plac\w+)/, stylisExports.MS + 'input-$1')]
1086
+ })], callback);
1087
+ }
1088
+ return '';
260
1089
  });
261
- react.useEffect(function () {
262
- var _a;
263
- (_a = forwardedRef === null || forwardedRef === void 0 ? void 0 : forwardedRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange(cursorRef.current.cursorPos, cursorRef.current.cursorPos);
264
- cursorRef.current = {
265
- cursorPos: cursorRef.current.cursorPos,
266
- operation: exports.CURSOR_OPERATION.NONE,
1090
+ }
1091
+ };
1092
+ var getServerStylisCache = isBrowser$1 ? undefined : weakMemoize(function () {
1093
+ return memoize(function () {
1094
+ return {};
1095
+ });
1096
+ });
1097
+ var defaultStylisPlugins = [prefixer];
1098
+ var createCache = function createCache(options) {
1099
+ var key = options.key;
1100
+ if (isBrowser$1 && key === 'css') {
1101
+ var ssrStyles = document.querySelectorAll("style[data-emotion]:not([data-s])"); // get SSRed styles out of the way of React's hydration
1102
+ // document.head is a safe place to move them to(though note document.head is not necessarily the last place they will be)
1103
+ // note this very very intentionally targets all style elements regardless of the key to ensure
1104
+ // that creating a cache works inside of render of a React component
1105
+
1106
+ Array.prototype.forEach.call(ssrStyles, function (node) {
1107
+ // we want to only move elements which have a space in the data-emotion attribute value
1108
+ // because that indicates that it is an Emotion 11 server-side rendered style elements
1109
+ // while we will already ignore Emotion 11 client-side inserted styles because of the :not([data-s]) part in the selector
1110
+ // Emotion 10 client-side inserted styles did not have data-s (but importantly did not have a space in their data-emotion attributes)
1111
+ // so checking for the space ensures that loading Emotion 11 after Emotion 10 has inserted some styles
1112
+ // will not result in the Emotion 10 styles being destroyed
1113
+ var dataEmotionAttribute = node.getAttribute('data-emotion');
1114
+ if (dataEmotionAttribute.indexOf(' ') === -1) {
1115
+ return;
1116
+ }
1117
+ document.head.appendChild(node);
1118
+ node.setAttribute('data-s', '');
1119
+ });
1120
+ }
1121
+ var stylisPlugins = options.stylisPlugins || defaultStylisPlugins;
1122
+ var inserted = {};
1123
+ var container;
1124
+ var nodesToHydrate = [];
1125
+ if (isBrowser$1) {
1126
+ container = options.container || document.head;
1127
+ Array.prototype.forEach.call(
1128
+ // this means we will ignore elements which don't have a space in them which
1129
+ // means that the style elements we're looking at are only Emotion 11 server-rendered style elements
1130
+ document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node) {
1131
+ var attrib = node.getAttribute("data-emotion").split(' ');
1132
+ for (var i = 1; i < attrib.length; i++) {
1133
+ inserted[attrib[i]] = true;
1134
+ }
1135
+ nodesToHydrate.push(node);
1136
+ });
1137
+ }
1138
+ var _insert;
1139
+ var omnipresentPlugins = [compat, removeLabel];
1140
+ if (!getServerStylisCache) {
1141
+ var currentSheet;
1142
+ var finalizingPlugins = [stylisExports.stringify, stylisExports.rulesheet(function (rule) {
1143
+ currentSheet.insert(rule);
1144
+ })];
1145
+ var serializer = stylisExports.middleware(omnipresentPlugins.concat(stylisPlugins, finalizingPlugins));
1146
+ var stylis = function stylis(styles) {
1147
+ return stylisExports.serialize(stylisExports.compile(styles), serializer);
1148
+ };
1149
+ _insert = function insert(selector, serialized, sheet, shouldCache) {
1150
+ currentSheet = sheet;
1151
+ stylis(selector ? selector + "{" + serialized.styles + "}" : serialized.styles);
1152
+ if (shouldCache) {
1153
+ cache.inserted[serialized.name] = true;
1154
+ }
1155
+ };
1156
+ } else {
1157
+ var _finalizingPlugins = [stylisExports.stringify];
1158
+ var _serializer = stylisExports.middleware(omnipresentPlugins.concat(stylisPlugins, _finalizingPlugins));
1159
+ var _stylis = function _stylis(styles) {
1160
+ return stylisExports.serialize(stylisExports.compile(styles), _serializer);
1161
+ };
1162
+ var serverStylisCache = getServerStylisCache(stylisPlugins)(key);
1163
+ var getRules = function getRules(selector, serialized) {
1164
+ var name = serialized.name;
1165
+ if (serverStylisCache[name] === undefined) {
1166
+ serverStylisCache[name] = _stylis(selector ? selector + "{" + serialized.styles + "}" : serialized.styles);
1167
+ }
1168
+ return serverStylisCache[name];
1169
+ };
1170
+ _insert = function _insert(selector, serialized, sheet, shouldCache) {
1171
+ var name = serialized.name;
1172
+ var rules = getRules(selector, serialized);
1173
+ if (cache.compat === undefined) {
1174
+ // in regular mode, we don't set the styles on the inserted cache
1175
+ // since we don't need to and that would be wasting memory
1176
+ // we return them so that they are rendered in a style tag
1177
+ if (shouldCache) {
1178
+ cache.inserted[name] = true;
1179
+ }
1180
+ return rules;
1181
+ } else {
1182
+ // in compat mode, we put the styles on the inserted cache so
1183
+ // that emotion-server can pull out the styles
1184
+ // except when we don't want to cache it which was in Global but now
1185
+ // is nowhere but we don't want to do a major right now
1186
+ // and just in case we're going to leave the case here
1187
+ // it's also not affecting client side bundle size
1188
+ // so it's really not a big deal
1189
+ if (shouldCache) {
1190
+ cache.inserted[name] = rules;
1191
+ } else {
1192
+ return rules;
1193
+ }
1194
+ }
1195
+ };
1196
+ }
1197
+ var cache = {
1198
+ key: key,
1199
+ sheet: new StyleSheet({
1200
+ key: key,
1201
+ container: container,
1202
+ nonce: options.nonce,
1203
+ speedy: options.speedy,
1204
+ prepend: options.prepend,
1205
+ insertionPoint: options.insertionPoint
1206
+ }),
1207
+ nonce: options.nonce,
1208
+ inserted: inserted,
1209
+ registered: {},
1210
+ insert: _insert
1211
+ };
1212
+ cache.sheet.hydrate(nodesToHydrate);
1213
+ return cache;
1214
+ };
1215
+
1216
+ /* eslint-disable */
1217
+ // Inspired by https://github.com/garycourt/murmurhash-js
1218
+ // Ported from https://github.com/aappleby/smhasher/blob/61a0530f28277f2e850bfc39600ce61d02b518de/src/MurmurHash2.cpp#L37-L86
1219
+ function murmur2(str) {
1220
+ // 'm' and 'r' are mixing constants generated offline.
1221
+ // They're not really 'magic', they just happen to work well.
1222
+ // const m = 0x5bd1e995;
1223
+ // const r = 24;
1224
+ // Initialize the hash
1225
+ var h = 0; // Mix 4 bytes at a time into the hash
1226
+
1227
+ var k,
1228
+ i = 0,
1229
+ len = str.length;
1230
+ for (; len >= 4; ++i, len -= 4) {
1231
+ k = str.charCodeAt(i) & 0xff | (str.charCodeAt(++i) & 0xff) << 8 | (str.charCodeAt(++i) & 0xff) << 16 | (str.charCodeAt(++i) & 0xff) << 24;
1232
+ k = /* Math.imul(k, m): */
1233
+ (k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16);
1234
+ k ^= /* k >>> r: */
1235
+ k >>> 24;
1236
+ h = /* Math.imul(k, m): */
1237
+ (k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16) ^ /* Math.imul(h, m): */
1238
+ (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
1239
+ } // Handle the last few bytes of the input array
1240
+
1241
+ switch (len) {
1242
+ case 3:
1243
+ h ^= (str.charCodeAt(i + 2) & 0xff) << 16;
1244
+ case 2:
1245
+ h ^= (str.charCodeAt(i + 1) & 0xff) << 8;
1246
+ case 1:
1247
+ h ^= str.charCodeAt(i) & 0xff;
1248
+ h = /* Math.imul(h, m): */
1249
+ (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
1250
+ } // Do a few final mixes of the hash to ensure the last few
1251
+ // bytes are well-incorporated.
1252
+
1253
+ h ^= h >>> 13;
1254
+ h = /* Math.imul(h, m): */
1255
+ (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
1256
+ return ((h ^ h >>> 15) >>> 0).toString(36);
1257
+ }
1258
+
1259
+ var unitlessKeys = {
1260
+ animationIterationCount: 1,
1261
+ aspectRatio: 1,
1262
+ borderImageOutset: 1,
1263
+ borderImageSlice: 1,
1264
+ borderImageWidth: 1,
1265
+ boxFlex: 1,
1266
+ boxFlexGroup: 1,
1267
+ boxOrdinalGroup: 1,
1268
+ columnCount: 1,
1269
+ columns: 1,
1270
+ flex: 1,
1271
+ flexGrow: 1,
1272
+ flexPositive: 1,
1273
+ flexShrink: 1,
1274
+ flexNegative: 1,
1275
+ flexOrder: 1,
1276
+ gridRow: 1,
1277
+ gridRowEnd: 1,
1278
+ gridRowSpan: 1,
1279
+ gridRowStart: 1,
1280
+ gridColumn: 1,
1281
+ gridColumnEnd: 1,
1282
+ gridColumnSpan: 1,
1283
+ gridColumnStart: 1,
1284
+ msGridRow: 1,
1285
+ msGridRowSpan: 1,
1286
+ msGridColumn: 1,
1287
+ msGridColumnSpan: 1,
1288
+ fontWeight: 1,
1289
+ lineHeight: 1,
1290
+ opacity: 1,
1291
+ order: 1,
1292
+ orphans: 1,
1293
+ scale: 1,
1294
+ tabSize: 1,
1295
+ widows: 1,
1296
+ zIndex: 1,
1297
+ zoom: 1,
1298
+ WebkitLineClamp: 1,
1299
+ // SVG-related properties
1300
+ fillOpacity: 1,
1301
+ floodOpacity: 1,
1302
+ stopOpacity: 1,
1303
+ strokeDasharray: 1,
1304
+ strokeDashoffset: 1,
1305
+ strokeMiterlimit: 1,
1306
+ strokeOpacity: 1,
1307
+ strokeWidth: 1
1308
+ };
1309
+
1310
+ var isDevelopment = false;
1311
+ var hyphenateRegex = /[A-Z]|^ms/g;
1312
+ var animationRegex = /_EMO_([^_]+?)_([^]*?)_EMO_/g;
1313
+ var isCustomProperty = function isCustomProperty(property) {
1314
+ return property.charCodeAt(1) === 45;
1315
+ };
1316
+ var isProcessableValue = function isProcessableValue(value) {
1317
+ return value != null && typeof value !== 'boolean';
1318
+ };
1319
+ var processStyleName = /* #__PURE__ */memoize(function (styleName) {
1320
+ return isCustomProperty(styleName) ? styleName : styleName.replace(hyphenateRegex, '-$&').toLowerCase();
1321
+ });
1322
+ var processStyleValue = function processStyleValue(key, value) {
1323
+ switch (key) {
1324
+ case 'animation':
1325
+ case 'animationName':
1326
+ {
1327
+ if (typeof value === 'string') {
1328
+ return value.replace(animationRegex, function (match, p1, p2) {
1329
+ cursor = {
1330
+ name: p1,
1331
+ styles: p2,
1332
+ next: cursor
1333
+ };
1334
+ return p1;
1335
+ });
1336
+ }
1337
+ }
1338
+ }
1339
+ if (unitlessKeys[key] !== 1 && !isCustomProperty(key) && typeof value === 'number' && value !== 0) {
1340
+ return value + 'px';
1341
+ }
1342
+ return value;
1343
+ };
1344
+ var noComponentSelectorMessage = 'Component selectors can only be used in conjunction with ' + '@emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware ' + 'compiler transform.';
1345
+ function handleInterpolation(mergedProps, registered, interpolation) {
1346
+ if (interpolation == null) {
1347
+ return '';
1348
+ }
1349
+ var componentSelector = interpolation;
1350
+ if (componentSelector.__emotion_styles !== undefined) {
1351
+ return componentSelector;
1352
+ }
1353
+ switch (typeof interpolation) {
1354
+ case 'boolean':
1355
+ {
1356
+ return '';
1357
+ }
1358
+ case 'object':
1359
+ {
1360
+ var keyframes = interpolation;
1361
+ if (keyframes.anim === 1) {
1362
+ cursor = {
1363
+ name: keyframes.name,
1364
+ styles: keyframes.styles,
1365
+ next: cursor
267
1366
  };
268
- }, [value]);
269
- var onFieldChange = function (e) {
270
- onChange(ctDesignCommonUtils.removeNonNumerals(ctDesignCommonUtils.removeSpace(e.target.value)), e);
271
- var selectionStart = e.target.selectionStart || 0;
272
- switch (cursorRef.current.operation) {
273
- case exports.CURSOR_OPERATION.SUBSTRACT: {
274
- --selectionStart;
275
- break;
276
- }
277
- case exports.CURSOR_OPERATION.ADD: {
278
- ++selectionStart;
279
- break;
280
- }
1367
+ return keyframes.name;
1368
+ }
1369
+ var serializedStyles = interpolation;
1370
+ if (serializedStyles.styles !== undefined) {
1371
+ var next = serializedStyles.next;
1372
+ if (next !== undefined) {
1373
+ // not the most efficient thing ever but this is a pretty rare case
1374
+ // and there will be very few iterations of this generally
1375
+ while (next !== undefined) {
1376
+ cursor = {
1377
+ name: next.name,
1378
+ styles: next.styles,
1379
+ next: cursor
1380
+ };
1381
+ next = next.next;
1382
+ }
281
1383
  }
282
- cursorRef.current = {
283
- cursorPos: selectionStart,
284
- operation: exports.CURSOR_OPERATION.NONE,
285
- };
286
- setTimeout(function () {
287
- var _a;
288
- (_a = forwardedRef === null || forwardedRef === void 0 ? void 0 : forwardedRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange(cursorRef.current.cursorPos, cursorRef.current.cursorPos);
289
- }, 0);
290
- };
291
- var onKeyDown = function (e) {
292
- var _a;
293
- var oldValues = ctDesignCommonUtils.removeNonNumerals(ctDesignCommonUtils.removeSpace(e.target.value));
294
- var cursorOpration = {
295
- cursorPos: cursorRef.current.cursorPos,
296
- operation: exports.CURSOR_OPERATION.NONE,
297
- };
298
- switch (e.code) {
299
- case 'Backspace': {
300
- cursorOpration.operation = exports.CURSOR_OPERATION.NONE;
301
- break;
302
- }
303
- case 'Space': {
304
- cursorOpration.operation = exports.CURSOR_OPERATION.SUBSTRACT;
305
- break;
1384
+ var styles = serializedStyles.styles + ";";
1385
+ return styles;
1386
+ }
1387
+ return createStringFromObject(mergedProps, registered, interpolation);
1388
+ }
1389
+ case 'function':
1390
+ {
1391
+ if (mergedProps !== undefined) {
1392
+ var previousCursor = cursor;
1393
+ var result = interpolation(mergedProps);
1394
+ cursor = previousCursor;
1395
+ return handleInterpolation(mergedProps, registered, result);
1396
+ }
1397
+ break;
1398
+ }
1399
+ } // finalize string values (regular strings and functions interpolated into css calls)
1400
+
1401
+ var asString = interpolation;
1402
+ if (registered == null) {
1403
+ return asString;
1404
+ }
1405
+ var cached = registered[asString];
1406
+ return cached !== undefined ? cached : asString;
1407
+ }
1408
+ function createStringFromObject(mergedProps, registered, obj) {
1409
+ var string = '';
1410
+ if (Array.isArray(obj)) {
1411
+ for (var i = 0; i < obj.length; i++) {
1412
+ string += handleInterpolation(mergedProps, registered, obj[i]) + ";";
1413
+ }
1414
+ } else {
1415
+ for (var key in obj) {
1416
+ var value = obj[key];
1417
+ if (typeof value !== 'object') {
1418
+ var asString = value;
1419
+ if (registered != null && registered[asString] !== undefined) {
1420
+ string += key + "{" + registered[asString] + "}";
1421
+ } else if (isProcessableValue(asString)) {
1422
+ string += processStyleName(key) + ":" + processStyleValue(key, asString) + ";";
1423
+ }
1424
+ } else {
1425
+ if (key === 'NO_COMPONENT_SELECTOR' && isDevelopment) {
1426
+ throw new Error(noComponentSelectorMessage);
1427
+ }
1428
+ if (Array.isArray(value) && typeof value[0] === 'string' && (registered == null || registered[value[0]] === undefined)) {
1429
+ for (var _i = 0; _i < value.length; _i++) {
1430
+ if (isProcessableValue(value[_i])) {
1431
+ string += processStyleName(key) + ":" + processStyleValue(key, value[_i]) + ";";
1432
+ }
1433
+ }
1434
+ } else {
1435
+ var interpolated = handleInterpolation(mergedProps, registered, value);
1436
+ switch (key) {
1437
+ case 'animation':
1438
+ case 'animationName':
1439
+ {
1440
+ string += processStyleName(key) + ":" + interpolated + ";";
1441
+ break;
306
1442
  }
307
- default: {
308
- if (oldValues.length % gap === 0) {
309
- cursorOpration.operation = exports.CURSOR_OPERATION.ADD;
310
- }
1443
+ default:
1444
+ {
1445
+ string += key + "{" + interpolated + "}";
311
1446
  }
312
1447
  }
313
- cursorRef.current = cursorOpration;
314
- (_a = rest === null || rest === void 0 ? void 0 : rest.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(rest, e);
315
- };
316
- return (jsxRuntime.jsx(Field, __assign({}, rest, { type: exports.FieldType.TEXT, ref: forwardedRef, onChange: onFieldChange, onKeyDown: onKeyDown, value: ctDesignCommonUtils.addSpaceAtInterval(value, gap) })));
317
- });
1448
+ }
1449
+ }
1450
+ }
1451
+ }
1452
+ return string;
1453
+ }
1454
+ var labelPattern = /label:\s*([^\s;{]+)\s*(;|$)/g; // this is the cursor for keyframes
1455
+ // keyframes are stored on the SerializedStyles object as a linked list
1456
+
1457
+ var cursor;
1458
+ function serializeStyles(args, registered, mergedProps) {
1459
+ if (args.length === 1 && typeof args[0] === 'object' && args[0] !== null && args[0].styles !== undefined) {
1460
+ return args[0];
1461
+ }
1462
+ var stringMode = true;
1463
+ var styles = '';
1464
+ cursor = undefined;
1465
+ var strings = args[0];
1466
+ if (strings == null || strings.raw === undefined) {
1467
+ stringMode = false;
1468
+ styles += handleInterpolation(mergedProps, registered, strings);
1469
+ } else {
1470
+ var asTemplateStringsArr = strings;
1471
+ styles += asTemplateStringsArr[0];
1472
+ } // we start at 1 since we've already handled the first arg
318
1473
 
319
- function CheckCircle(props) {
320
- return jsxRuntime.jsxs("svg", __assign({
321
- xmlns: 'http://www.w3.org/2000/svg',
322
- width: 16,
323
- height: 16,
324
- fill: 'none'
325
- }, props, {
326
- children: [jsxRuntime.jsx("mask", __assign({
327
- id: 'a',
328
- width: 16,
329
- height: 16,
330
- x: 0,
331
- y: 0,
332
- maskUnits: 'userSpaceOnUse',
333
- style: {
334
- maskType: 'alpha'
335
- }
336
- }, {
337
- children: jsxRuntime.jsx("path", {
338
- fill: '#D9D9D9',
339
- d: 'M0 0h16v16H0z'
340
- })
341
- })), jsxRuntime.jsx("g", __assign({
342
- mask: 'url(#a)'
343
- }, {
344
- children: jsxRuntime.jsx("path", {
345
- fill: '#11A670',
346
- d: 'M7.033 9.667 5.367 7.983a.293.293 0 0 0-.234-.092A.354.354 0 0 0 4.9 8a.32.32 0 0 0 0 .467l1.767 1.766c.1.1.225.15.374.15a.51.51 0 0 0 .376-.15l3.666-3.666a.293.293 0 0 0 .092-.234.354.354 0 0 0-.108-.233.32.32 0 0 0-.467 0L7.033 9.667ZM8 14a5.805 5.805 0 0 1-2.341-.475 6.096 6.096 0 0 1-1.9-1.284 6.095 6.095 0 0 1-1.284-1.9A5.806 5.806 0 0 1 2 8c0-.833.158-1.614.475-2.342a6.106 6.106 0 0 1 1.284-1.9 6.101 6.101 0 0 1 1.9-1.283A5.806 5.806 0 0 1 8 2a5.81 5.81 0 0 1 2.342.475 6.11 6.11 0 0 1 1.9 1.283c.539.54.966 1.172 1.283 1.9A5.81 5.81 0 0 1 14 8c0 .833-.158 1.614-.475 2.341a6.1 6.1 0 0 1-1.283 1.9c-.54.54-1.172.967-1.9 1.284A5.81 5.81 0 0 1 8 14Zm0-.667c1.478 0 2.736-.519 3.775-1.558 1.039-1.039 1.558-2.297 1.558-3.775 0-1.478-.519-2.736-1.558-3.775C10.736 3.186 9.478 2.667 8 2.667c-1.478 0-2.736.519-3.775 1.558C3.186 5.264 2.667 6.522 2.667 8c0 1.478.52 2.736 1.558 3.775C5.264 12.814 6.522 13.333 8 13.333Z'
347
- })
348
- }))]
349
- }));
1474
+ for (var i = 1; i < args.length; i++) {
1475
+ styles += handleInterpolation(mergedProps, registered, args[i]);
1476
+ if (stringMode) {
1477
+ var templateStringsArr = strings;
1478
+ styles += templateStringsArr[i];
1479
+ }
1480
+ } // using a global regex with .exec is stateful so lastIndex has to be reset each time
1481
+
1482
+ labelPattern.lastIndex = 0;
1483
+ var identifierName = '';
1484
+ var match; // https://esbench.com/bench/5b809c2cf2949800a0f61fb5
1485
+
1486
+ while ((match = labelPattern.exec(styles)) !== null) {
1487
+ identifierName += '-' + match[1];
350
1488
  }
351
- var DownChevron = function (_a) {
352
- var _b = _a.color,
353
- color = _b === void 0 ? '#1A1A1A' : _b,
354
- rest = __rest(_a, ["color"]);
355
- return jsxRuntime.jsx("svg", __assign({
356
- xmlns: 'http://www.w3.org/2000/svg',
357
- width: '12',
358
- height: '12',
359
- fill: 'none',
360
- viewBox: '0 0 12 12'
361
- }, rest, {
362
- children: jsxRuntime.jsx("path", {
363
- stroke: color,
364
- strokeLinecap: 'round',
365
- strokeLinejoin: 'round',
366
- strokeWidth: '2',
367
- d: 'M2 4l4 4 4-4'
368
- })
369
- }));
1489
+ var name = murmur2(styles) + identifierName;
1490
+ return {
1491
+ name: name,
1492
+ styles: styles,
1493
+ next: cursor
370
1494
  };
1495
+ }
371
1496
 
372
- var PhoneFieldPrefix = react.forwardRef(function (_a, forwardedRef) {
373
- var countryCode = _a.countryCode, _b = _a.disabled, disabled = _b === void 0 ? false : _b, flagIcon = _a.flagIcon, onDropdownClick = _a.onDropdownClick, showDropdownIcon = _a.showDropdownIcon;
374
- var theme = ctDesignTheme.useTheme();
375
- var onClick = function () {
376
- if (disabled)
377
- return;
378
- onDropdownClick === null || onDropdownClick === void 0 ? void 0 : onDropdownClick();
379
- };
380
- return (jsxRuntime.jsxs(ctDesignBox.Box, __assign({ boxSize: 'micro', horizontal: true, css: {
381
- alignItems: 'center',
382
- justifyContent: 'center',
383
- cursor: disabled ? 'not-allowed' : 'pointer',
384
- paddingLeft: '16px',
385
- }, onClick: onClick, ref: forwardedRef }, { children: [flagIcon && (jsxRuntime.jsx(ctDesignContainer.Container, __assign({ display: 'flex', alignItems: 'center', justifyContent: 'center', height: theme.size[6], width: theme.size[6] }, { children: flagIcon }))), jsxRuntime.jsx(ctDesignTypography.Typography, __assign({ css: { minWidth: 'fit-content' }, variant: 'B1', color: disabled ? 'disabled' : 'primary', isClickable: true }, { children: countryCode })), showDropdownIcon && jsxRuntime.jsx(DownChevron, { color: disabled ? theme.color.text.disabled : theme.color.text.primary }), jsxRuntime.jsx(ctDesignDivider.Divider, { width: '1px', height: '24px', css: { borderBottom: "24px ".concat(theme.color.background.disabledDark, " solid") } })] })));
1497
+ var isBrowser = typeof document !== 'undefined';
1498
+ function getRegisteredStyles(registered, registeredStyles, classNames) {
1499
+ var rawClassName = '';
1500
+ classNames.split(' ').forEach(function (className) {
1501
+ if (registered[className] !== undefined) {
1502
+ registeredStyles.push(registered[className] + ";");
1503
+ } else if (className) {
1504
+ rawClassName += className + " ";
1505
+ }
386
1506
  });
1507
+ return rawClassName;
1508
+ }
1509
+ var registerStyles = function registerStyles(cache, serialized, isStringTag) {
1510
+ var className = cache.key + "-" + serialized.name;
1511
+ if (
1512
+ // we only need to add the styles to the registered cache if the
1513
+ // class name could be used further down
1514
+ // the tree but if it's a string tag, we know it won't
1515
+ // so we don't have to add it to registered cache.
1516
+ // this improves memory usage since we can avoid storing the whole style string
1517
+ (isStringTag === false ||
1518
+ // we need to always store it if we're in compat mode and
1519
+ // in node since emotion-server relies on whether a style is in
1520
+ // the registered cache to know whether a style is global or not
1521
+ // also, note that this check will be dead code eliminated in the browser
1522
+ isBrowser === false && cache.compat !== undefined) && cache.registered[className] === undefined) {
1523
+ cache.registered[className] = serialized.styles;
1524
+ }
1525
+ };
1526
+ var insertStyles = function insertStyles(cache, serialized, isStringTag) {
1527
+ registerStyles(cache, serialized, isStringTag);
1528
+ var className = cache.key + "-" + serialized.name;
1529
+ if (cache.inserted[serialized.name] === undefined) {
1530
+ var stylesForSSR = '';
1531
+ var current = serialized;
1532
+ do {
1533
+ var maybeStyles = cache.insert(serialized === current ? "." + className : '', current, cache.sheet, true);
1534
+ if (!isBrowser && maybeStyles !== undefined) {
1535
+ stylesForSSR += maybeStyles;
1536
+ }
1537
+ current = current.next;
1538
+ } while (current !== undefined);
1539
+ if (!isBrowser && stylesForSSR.length !== 0) {
1540
+ return stylesForSSR;
1541
+ }
1542
+ }
1543
+ };
387
1544
 
388
- var PhoneField = react.forwardRef(function (_a, forwardedRef) {
389
- var max = _a.max, flagIcon = _a.flagIcon, countryCode = _a.countryCode, showDropdownIcon = _a.showDropdownIcon, onChange = _a.onChange, onDropdownClick = _a.onDropdownClick, disabled = _a.disabled, rest = __rest(_a, ["max", "flagIcon", "countryCode", "showDropdownIcon", "onChange", "onDropdownClick", "disabled"]);
390
- var theme = styled.useTheme();
391
- var _b = react.useState(0), prefixWidth = _b[0], setPrefixWidth = _b[1];
392
- var onFieldChange = function (event) {
393
- var value = event.target.value;
394
- var isValidValue = value ? new RegExp(ctDesignCommonConstants.ONLY_NUMERIC).test(value) : true;
395
- if (value.length <= max && isValidValue) {
396
- onChange(event);
397
- }
398
- };
399
- var calculatePrefixWidth = react.useCallback(function (node) {
400
- var _a;
401
- if (node) {
402
- setPrefixWidth(((_a = node.getBoundingClientRect().width) !== null && _a !== void 0 ? _a : 0) + 16);
1545
+ function insertWithoutScoping(cache, serialized) {
1546
+ if (cache.inserted[serialized.name] === undefined) {
1547
+ return cache.insert('', serialized, cache.sheet, true);
1548
+ }
1549
+ }
1550
+ function merge(registered, css, className) {
1551
+ var registeredStyles = [];
1552
+ var rawClassName = getRegisteredStyles(registered, registeredStyles, className);
1553
+ if (registeredStyles.length < 2) {
1554
+ return className;
1555
+ }
1556
+ return rawClassName + css(registeredStyles);
1557
+ }
1558
+ var createEmotion = function createEmotion(options) {
1559
+ var cache = createCache(options);
1560
+ cache.sheet.speedy = function (value) {
1561
+ this.isSpeedy = value;
1562
+ };
1563
+ cache.compat = true;
1564
+ var css = function css() {
1565
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1566
+ args[_key] = arguments[_key];
1567
+ }
1568
+ var serialized = serializeStyles(args, cache.registered, undefined);
1569
+ insertStyles(cache, serialized, false);
1570
+ return cache.key + "-" + serialized.name;
1571
+ };
1572
+ var keyframes = function keyframes() {
1573
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1574
+ args[_key2] = arguments[_key2];
1575
+ }
1576
+ var serialized = serializeStyles(args, cache.registered);
1577
+ var animation = "animation-" + serialized.name;
1578
+ insertWithoutScoping(cache, {
1579
+ name: serialized.name,
1580
+ styles: "@keyframes " + animation + "{" + serialized.styles + "}"
1581
+ });
1582
+ return animation;
1583
+ };
1584
+ var injectGlobal = function injectGlobal() {
1585
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
1586
+ args[_key3] = arguments[_key3];
1587
+ }
1588
+ var serialized = serializeStyles(args, cache.registered);
1589
+ insertWithoutScoping(cache, serialized);
1590
+ };
1591
+ var cx = function cx() {
1592
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
1593
+ args[_key4] = arguments[_key4];
1594
+ }
1595
+ return merge(cache.registered, css, classnames(args));
1596
+ };
1597
+ return {
1598
+ css: css,
1599
+ cx: cx,
1600
+ injectGlobal: injectGlobal,
1601
+ keyframes: keyframes,
1602
+ hydrate: function hydrate(ids) {
1603
+ ids.forEach(function (key) {
1604
+ cache.inserted[key] = true;
1605
+ });
1606
+ },
1607
+ flush: function flush() {
1608
+ cache.registered = {};
1609
+ cache.inserted = {};
1610
+ cache.sheet.flush();
1611
+ },
1612
+ sheet: cache.sheet,
1613
+ cache: cache,
1614
+ getRegisteredStyles: getRegisteredStyles.bind(null, cache.registered),
1615
+ merge: merge.bind(null, cache.registered, css)
1616
+ };
1617
+ };
1618
+ var classnames = function classnames(args) {
1619
+ var cls = '';
1620
+ for (var i = 0; i < args.length; i++) {
1621
+ var arg = args[i];
1622
+ if (arg == null) continue;
1623
+ var toAdd = void 0;
1624
+ switch (typeof arg) {
1625
+ case 'boolean':
1626
+ break;
1627
+ case 'object':
1628
+ {
1629
+ if (Array.isArray(arg)) {
1630
+ toAdd = classnames(arg);
1631
+ } else {
1632
+ toAdd = '';
1633
+ for (var k in arg) {
1634
+ if (arg[k] && k) {
1635
+ toAdd && (toAdd += ' ');
1636
+ toAdd += k;
1637
+ }
1638
+ }
403
1639
  }
404
- }, [countryCode, flagIcon]);
405
- var customPlaceHolderStyling = {
406
- marginLeft: prefixWidth,
407
- };
408
- return (jsxRuntime.jsx(Field, __assign({}, rest, { type: exports.FieldType.PHONE, ref: forwardedRef, onChange: onFieldChange, disabled: disabled, prefix: jsxRuntime.jsx(PhoneFieldPrefix, { flagIcon: flagIcon, countryCode: countryCode, showDropdownIcon: showDropdownIcon, onDropdownClick: onDropdownClick, disabled: disabled, ref: calculatePrefixWidth }), styleConfig: {
409
- field: {
410
- css: {
411
- paddingTop: 'unset',
412
- paddingBottom: 'unset',
413
- paddingLeft: theme.spacing[4],
414
- },
415
- },
416
- placeholderLabel: {
417
- css: __assign({}, customPlaceHolderStyling),
418
- },
419
- } })));
420
- });
1640
+ break;
1641
+ }
1642
+ default:
1643
+ {
1644
+ toAdd = arg;
1645
+ }
1646
+ }
1647
+ if (toAdd) {
1648
+ cls && (cls += ' ');
1649
+ cls += toAdd;
1650
+ }
1651
+ }
1652
+ return cls;
1653
+ };
421
1654
 
422
- var FieldIcon = function (_a) {
423
- var icon = _a.icon, onClick = _a.onClick, focus = _a.focus, focusedIcon = _a.focusedIcon, css = _a.css;
424
- var theme = ctDesignTheme.useTheme();
425
- var iconPrefix = icon;
426
- if (focus && focusedIcon) {
427
- iconPrefix = focusedIcon;
428
- }
429
- var showIconWithoutPointer = !onClick;
430
- var iconStyles = showIconWithoutPointer ? { pointerEvents: 'none' } : { cursor: 'pointer' };
431
- return (jsxRuntime.jsx(ctDesignContainer.Container, __assign({ height: theme.size[6], width: theme.size[6], display: 'flex', alignItems: 'center', justifyContent: 'center', onClick: onClick, css: __assign(__assign({ position: 'absolute' }, iconStyles), css), marginLeft: theme.spacing[4] }, { children: iconPrefix })));
432
- };
1655
+ var _createEmotion = createEmotion({
1656
+ key: 'css'
1657
+ }),
1658
+ css = _createEmotion.css;
433
1659
 
434
- var FieldAction = function (_a) {
435
- var _b = _a.actionsList, actionsList = _b === void 0 ? [] : _b;
436
- return (jsxRuntime.jsx(ctDesignBox.Box, __assign({ boxSize: 'tiny', horizontal: true, css: { paddingRight: '16px' } }, { children: actionsList.map(function (actionItem) {
437
- var _a = actionItem || {}, label = _a.label, color = _a.color, onClick = _a.onClick, isDisabled = _a.isDisabled, isLoading = _a.isLoading;
438
- if (isLoading) {
439
- return jsxRuntime.jsx(ctDesignDottedLoader.DottedLoader, {});
440
- }
441
- return (jsxRuntime.jsx(ctDesignTypography.Typography, __assign({ variant: 'HM4', color: isDisabled ? ctDesignTypography.TypographyColor.DISABLED : color, onClick: !isDisabled ? onClick : function () { }, isClickable: true, isDisabled: isDisabled }, { children: label })));
442
- }) })));
443
- };
1660
+ exports.FieldVariant = void 0;
1661
+ (function (FieldVariant) {
1662
+ FieldVariant["SM"] = "sm";
1663
+ FieldVariant["MD"] = "md";
1664
+ })(exports.FieldVariant || (exports.FieldVariant = {}));
1665
+ exports.FieldType = void 0;
1666
+ (function (FieldType) {
1667
+ FieldType["TEXT"] = "text";
1668
+ FieldType["NUMBER"] = "number";
1669
+ FieldType["PHONE"] = "phone";
1670
+ })(exports.FieldType || (exports.FieldType = {}));
444
1671
 
445
- var SingleOTPField = react.forwardRef(function (_a, forwardedRef) {
446
- var _b = _a.isLoading, isLoading = _b === void 0 ? false : _b, otpBoxCss = _a.otpBoxCss, rest = __rest(_a, ["isLoading", "otpBoxCss"]);
447
- var theme = ctDesignTheme.useTheme();
448
- var loadingStyles = isLoading
449
- ? {
450
- backgroundColor: 'unset',
451
- }
452
- : {};
453
- var OTP_FIELD_TEXT_STYLING = __assign(__assign({}, ctDesignTypography.getTypographyStyles({ theme: theme, variant: ctDesignTypography.TypographyVariant.HM1 })), { letterSpacing: ' -0.25px', textAlign: 'center', padding: theme.spacing[3] });
454
- return (jsxRuntime.jsx(Field, __assign({ ref: forwardedRef, disabled: isLoading, styleConfig: {
455
- field: {
456
- css: __assign(__assign(__assign({}, otpBoxCss), OTP_FIELD_TEXT_STYLING), loadingStyles),
457
- },
458
- fieldContainer: {
459
- css: __assign({}, loadingStyles),
460
- },
461
- } }, rest)));
462
- });
1672
+ const getFieldContainerBorderStyle = ({ theme, hasError, focus, disabled, }) => {
1673
+ if (hasError) {
1674
+ return { borderStyle: 'solid', borderColor: theme.color.border.warning, borderWidth: theme.border.width.md };
1675
+ }
1676
+ if (focus && !disabled) {
1677
+ return { borderStyle: 'solid', borderColor: theme.color.border.primary, borderWidth: theme.border.width.md };
1678
+ }
1679
+ return { borderStyle: 'solid', borderColor: theme.color.border.disabledDark, borderWidth: theme.border.width.sm };
1680
+ };
1681
+ const getFieldSpacingAndHeight = ({ isLabeledPlaceholder, theme, variant, focus, value, disabledPlaceHolder, customSpacingTop = 4, }) => {
1682
+ const isFieldNotEmpty = focus || value.length > 0;
1683
+ const valueWithPlaceholder = isFieldNotEmpty && !disabledPlaceHolder;
1684
+ const commonStyles = {
1685
+ paddingRight: theme.spacing[4],
1686
+ paddingLeft: theme.spacing[4],
1687
+ };
1688
+ switch (variant) {
1689
+ case exports.FieldVariant.SM: {
1690
+ return Object.assign(Object.assign({}, commonStyles), { height: theme.size[10] });
1691
+ }
1692
+ case exports.FieldVariant.MD: {
1693
+ return Object.assign(Object.assign({}, commonStyles), { height: theme.size[14], paddingTop: (isLabeledPlaceholder && focus) || (isLabeledPlaceholder && value.length > 0)
1694
+ ? 24
1695
+ : valueWithPlaceholder
1696
+ ? theme.spacing[customSpacingTop]
1697
+ : theme.spacing[4], paddingBottom: valueWithPlaceholder ? theme.spacing[2] : theme.spacing[4] });
1698
+ }
1699
+ default: {
1700
+ return Object.assign(Object.assign({}, commonStyles), { height: theme.size[14], paddingTop: valueWithPlaceholder ? theme.spacing[6] : theme.spacing[4], paddingBottom: valueWithPlaceholder ? theme.spacing[2] : theme.spacing[4] });
1701
+ }
1702
+ }
1703
+ };
1704
+ const getFieldContainerStyles = ({ hasError, theme, focus, disabled, variant, value, customSpacingTop, }) => {
1705
+ const fieldContainerBorderStyle = getFieldContainerBorderStyle({
1706
+ theme,
1707
+ hasError,
1708
+ focus,
1709
+ disabled,
1710
+ });
1711
+ const { height } = getFieldSpacingAndHeight({
1712
+ theme,
1713
+ variant,
1714
+ focus,
1715
+ value,
1716
+ customSpacingTop,
1717
+ });
1718
+ return Object.assign(Object.assign({}, fieldContainerBorderStyle), { backgroundColor: disabled ? theme.color.background.disabled : theme.color.background.neutral, height });
1719
+ };
1720
+ const getFieldPlaceholderStyles = ({ isFocused, variant, fieldType, }) => {
1721
+ if (variant === exports.FieldVariant.SM) {
1722
+ return { top: 8 };
1723
+ }
1724
+ if (fieldType === exports.FieldType.PHONE) {
1725
+ return {};
1726
+ }
1727
+ if (isFocused) {
1728
+ return { transform: [{ translateY: -12 }] };
1729
+ }
1730
+ return {};
1731
+ };
1732
+ const getFieldStyles = ({ isLabeledPlaceholder, disabled, theme, variant, focus, value, type, isPrefixComponent = false, disabledPlaceHolder, }) => {
1733
+ const fieldSpacingAndHeight = getFieldSpacingAndHeight({
1734
+ isLabeledPlaceholder,
1735
+ theme,
1736
+ variant,
1737
+ focus,
1738
+ value,
1739
+ type,
1740
+ isPrefixComponent,
1741
+ disabledPlaceHolder,
1742
+ customSpacingTop: 2,
1743
+ });
1744
+ return Object.assign(Object.assign({}, fieldSpacingAndHeight), { backgroundColor: 'transparent', color: disabled ? theme.color.text.disabled : theme.color.text.primary });
1745
+ };
1746
+ const getTypographyVariant = (theme, variant) => {
1747
+ switch (variant) {
1748
+ case ctDesignTypography.TypographyVariant.HD1: {
1749
+ return {
1750
+ fontSize: theme.typography.size[48],
1751
+ fontWeight: theme.typography.weight.semibold,
1752
+ lineHeight: theme.typography.lineHeight[56],
1753
+ };
1754
+ }
1755
+ case ctDesignTypography.TypographyVariant.HD2: {
1756
+ return {
1757
+ fontSize: theme.typography.size[40],
1758
+ fontWeight: theme.typography.weight.semibold,
1759
+ lineHeight: theme.typography.lineHeight[48],
1760
+ };
1761
+ }
1762
+ case ctDesignTypography.TypographyVariant.HD3: {
1763
+ return {
1764
+ fontSize: theme.typography.size[32],
1765
+ fontWeight: theme.typography.weight.semibold,
1766
+ lineHeight: theme.typography.lineHeight[40],
1767
+ };
1768
+ }
1769
+ case ctDesignTypography.TypographyVariant.HM1: {
1770
+ return {
1771
+ fontSize: theme.typography.size[24],
1772
+ fontWeight: theme.typography.weight.semibold,
1773
+ lineHeight: theme.typography.lineHeight[32],
1774
+ };
1775
+ }
1776
+ case ctDesignTypography.TypographyVariant.HM2: {
1777
+ return {
1778
+ fontSize: theme.typography.size[20],
1779
+ fontWeight: theme.typography.weight.semibold,
1780
+ lineHeight: theme.typography.lineHeight[28],
1781
+ };
1782
+ }
1783
+ case ctDesignTypography.TypographyVariant.HM3: {
1784
+ return {
1785
+ fontSize: theme.typography.size[16],
1786
+ fontWeight: theme.typography.weight.semibold,
1787
+ lineHeight: theme.typography.lineHeight[24],
1788
+ };
1789
+ }
1790
+ case ctDesignTypography.TypographyVariant.HM4: {
1791
+ return {
1792
+ fontSize: theme.typography.size[14],
1793
+ fontWeight: theme.typography.weight.semibold,
1794
+ lineHeight: theme.typography.lineHeight[20],
1795
+ };
1796
+ }
1797
+ case ctDesignTypography.TypographyVariant.B1: {
1798
+ return {
1799
+ fontSize: theme.typography.size[16],
1800
+ fontWeight: theme.typography.weight.medium,
1801
+ lineHeight: theme.typography.lineHeight[24],
1802
+ };
1803
+ }
1804
+ case ctDesignTypography.TypographyVariant.B2: {
1805
+ return {
1806
+ fontSize: theme.typography.size[14],
1807
+ fontWeight: theme.typography.weight.medium,
1808
+ lineHeight: theme.typography.lineHeight[20],
1809
+ };
1810
+ }
1811
+ case ctDesignTypography.TypographyVariant.B3: {
1812
+ return {
1813
+ fontSize: theme.typography.size[12],
1814
+ fontWeight: theme.typography.weight.medium,
1815
+ lineHeight: theme.typography.lineHeight[16],
1816
+ };
1817
+ }
1818
+ case ctDesignTypography.TypographyVariant.B3CAPS: {
1819
+ return {
1820
+ fontSize: theme.typography.size[12],
1821
+ fontWeight: theme.typography.weight.semibold,
1822
+ lineHeight: theme.typography.lineHeight[16],
1823
+ letterSpacing: theme.typography.letterSpacing.point4,
1824
+ };
1825
+ }
1826
+ case ctDesignTypography.TypographyVariant.B4: {
1827
+ return {
1828
+ fontSize: theme.typography.size[10],
1829
+ fontWeight: theme.typography.weight.medium,
1830
+ lineHeight: theme.typography.lineHeight[14],
1831
+ };
1832
+ }
1833
+ case ctDesignTypography.TypographyVariant.B4CAPS: {
1834
+ return {
1835
+ fontSize: theme.typography.size[10],
1836
+ fontWeight: theme.typography.weight.semibold,
1837
+ lineHeight: theme.typography.lineHeight[12],
1838
+ letterSpacing: theme.typography.letterSpacing.point4,
1839
+ };
1840
+ }
1841
+ case ctDesignTypography.TypographyVariant.P1: {
1842
+ return {
1843
+ fontSize: theme.typography.size[16],
1844
+ fontWeight: theme.typography.weight.normal,
1845
+ lineHeight: theme.typography.lineHeight[22],
1846
+ };
1847
+ }
1848
+ case ctDesignTypography.TypographyVariant.P2: {
1849
+ return {
1850
+ fontSize: theme.typography.size[14],
1851
+ fontWeight: theme.typography.weight.normal,
1852
+ lineHeight: theme.typography.lineHeight[20],
1853
+ };
1854
+ }
1855
+ case ctDesignTypography.TypographyVariant.P3: {
1856
+ return {
1857
+ fontSize: theme.typography.size[12],
1858
+ fontWeight: theme.typography.weight.normal,
1859
+ lineHeight: theme.typography.lineHeight[16],
1860
+ };
1861
+ }
1862
+ case ctDesignTypography.TypographyVariant.P4: {
1863
+ return {
1864
+ fontSize: theme.typography.size[12],
1865
+ fontWeight: theme.typography.weight.normal,
1866
+ lineHeight: theme.typography.lineHeight[16],
1867
+ };
1868
+ }
1869
+ case ctDesignTypography.TypographyVariant.L1: {
1870
+ return {
1871
+ fontSize: theme.typography.size[16],
1872
+ fontWeight: theme.typography.weight.semibold,
1873
+ lineHeight: theme.typography.lineHeight[24],
1874
+ };
1875
+ }
1876
+ case ctDesignTypography.TypographyVariant.L2: {
1877
+ return {
1878
+ fontSize: theme.typography.size[14],
1879
+ fontWeight: theme.typography.weight.semibold,
1880
+ lineHeight: theme.typography.lineHeight[20],
1881
+ };
1882
+ }
1883
+ case ctDesignTypography.TypographyVariant.L3: {
1884
+ return {
1885
+ fontSize: theme.typography.size[12],
1886
+ fontWeight: theme.typography.weight.semibold,
1887
+ lineHeight: theme.typography.lineHeight[16],
1888
+ };
1889
+ }
1890
+ case ctDesignTypography.TypographyVariant.OVERLINE: {
1891
+ return {
1892
+ fontSize: theme.typography.size[12],
1893
+ fontWeight: theme.typography.weight.semibold,
1894
+ lineHeight: theme.typography.lineHeight[16],
1895
+ };
1896
+ }
1897
+ case ctDesignTypography.TypographyVariant.TAG: {
1898
+ return {
1899
+ fontSize: theme.typography.size[10],
1900
+ fontWeight: theme.typography.weight.semibold,
1901
+ lineHeight: theme.typography.lineHeight[12],
1902
+ letterSpacing: theme.typography.letterSpacing.point5,
1903
+ };
1904
+ }
1905
+ default: {
1906
+ return {
1907
+ fontSize: theme.typography.size[20],
1908
+ fontWeight: theme.typography.weight.semibold,
1909
+ lineHeight: theme.typography.lineHeight[28],
1910
+ };
1911
+ }
1912
+ }
1913
+ };
463
1914
 
464
- exports.BoxCount = void 0;
465
- (function (BoxCount) {
466
- BoxCount[BoxCount["SM"] = 4] = "SM";
467
- BoxCount[BoxCount["MD"] = 6] = "MD";
468
- })(exports.BoxCount || (exports.BoxCount = {}));
469
-
470
- var _a;
471
- var SPACEBAR = ctDesignCommonConstants.KEYBOARD_KEY_CODE.SPACEBAR, LEFT_ARROW = ctDesignCommonConstants.KEYBOARD_KEY_CODE.LEFT_ARROW, RIGHT_ARROW = ctDesignCommonConstants.KEYBOARD_KEY_CODE.RIGHT_ARROW;
472
- var boxStyling = (_a = {},
473
- _a[exports.BoxCount.MD] = { width: '48px' },
474
- _a[exports.BoxCount.SM] = { width: '56px' },
475
- _a);
476
- var OTPField = react.forwardRef(function (_a, forwardedRef) {
477
- var _b = _a.boxCount, boxCount = _b === void 0 ? exports.BoxCount.MD : _b, onChanged = _a.onChanged, onSubmit = _a.onSubmit, onResend = _a.onResend, _c = _a.isLoading, isLoading = _c === void 0 ? false : _c, _d = _a.message, message = _d === void 0 ? '' : _d, _e = _a.hasError, hasError = _e === void 0 ? false : _e, _f = _a.showCountDown, showCountDown = _f === void 0 ? true : _f, _g = _a.initialCountDownTime, initialCountDownTime = _g === void 0 ? 30 : _g;
478
- var theme = ctDesignTheme.useTheme();
479
- var otpInputsArr = Array.from(Array(boxCount), function (_, index) { return index; });
480
- var _h = react.useState(initialCountDownTime), countDown = _h[0], setCountDown = _h[1];
481
- var _j = react.useState(showCountDown), startCounter = _j[0], setStartCounter = _j[1];
482
- var _k = react.useState([]), otpValue = _k[0], setOtpValue = _k[1];
483
- var refs = react.useRef(new Array(boxCount));
484
- var messageIcon = !hasError && message ? jsxRuntime.jsx(CheckCircle, {}) : null;
485
- react.useEffect(function () {
486
- var _a;
487
- (_a = refs.current) === null || _a === void 0 ? void 0 : _a[0].focus();
488
- var timerId;
489
- if (showCountDown && startCounter) {
490
- timerId = setInterval(function () {
491
- setCountDown(function (prev) {
492
- var updatedValue = --prev;
493
- if (updatedValue === 0) {
494
- clearInterval(timerId);
495
- setStartCounter(false);
496
- }
497
- return updatedValue;
498
- });
499
- }, 1000);
500
- }
501
- return function () {
502
- timerId && clearInterval(timerId);
503
- };
504
- }, [startCounter]);
505
- react.useEffect(function () {
506
- var val = otpValue.join('');
507
- if (val.length === boxCount) {
508
- onSubmit(val);
509
- }
510
- }, [otpValue]);
511
- var onFieldChange = function (index) { return function (event) {
512
- var _a, _b, _c, _d;
513
- var value = event.target.value;
514
- if (value.length) {
515
- (_b = (_a = refs.current) === null || _a === void 0 ? void 0 : _a[index + 1]) === null || _b === void 0 ? void 0 : _b.focus();
516
- }
517
- else {
518
- (_d = (_c = refs.current) === null || _c === void 0 ? void 0 : _c[index - 1]) === null || _d === void 0 ? void 0 : _d.focus();
519
- }
520
- var updatedOtp = __spreadArray([], otpValue, true);
521
- updatedOtp[index] = value;
522
- setOtpValue(updatedOtp);
523
- onChanged === null || onChanged === void 0 ? void 0 : onChanged(event, value);
524
- }; };
525
- var onPasteOTP = function (index) { return function (e) {
526
- e.preventDefault();
527
- var paste = e.clipboardData.getData('text').split('').slice(0, otpInputsArr.length);
528
- if (!ctDesignCommonConstants.ONLY_NUMERIC.test(paste.join(''))) {
529
- return;
530
- }
531
- var focusIndex = Math.min(index + paste.length, otpInputsArr.length - 1);
532
- setOtpValue(paste);
533
- refs.current[focusIndex].focus();
534
- }; };
535
- var handleOnKeyDown = function (index) { return function (e) {
536
- var _a, _b;
537
- if (e.keyCode === LEFT_ARROW) {
538
- e.preventDefault();
539
- (_a = refs.current) === null || _a === void 0 ? void 0 : _a[index - 1].focus();
540
- }
541
- else if (e.keyCode === RIGHT_ARROW) {
542
- e.preventDefault();
543
- (_b = refs.current) === null || _b === void 0 ? void 0 : _b[index + 1].focus();
544
- }
545
- else if (e.keyCode === SPACEBAR || e.key === ' ' || e.key === 'Spacebar' || e.key === 'Space') {
546
- e.preventDefault();
547
- }
548
- }; };
549
- var onResendHandler = function () {
550
- onResend === null || onResend === void 0 ? void 0 : onResend();
551
- setStartCounter(true);
552
- setCountDown(initialCountDownTime);
553
- };
554
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(ctDesignContainer.Container, __assign({ ref: forwardedRef, position: 'relative', width: 'fit-content' }, { children: [jsxRuntime.jsx(ctDesignBox.Box, __assign({ boxSize: 'micro', horizontal: true }, { children: otpInputsArr.map(function (otp, i) {
555
- return (jsxRuntime.jsx(SingleOTPField, { type: exports.FieldType.NUMBER, ref: function (el) { return (refs.current[i] = el); }, onChange: onFieldChange(i), onKeyDown: handleOnKeyDown(i), onPaste: onPasteOTP(i), value: otpValue === null || otpValue === void 0 ? void 0 : otpValue[i], prompt: { hasError: hasError }, otpBoxCss: __assign({ height: '56px' }, boxStyling[boxCount]), maxLength: 1, isLoading: isLoading }, 'otp_Input_' + otp));
556
- }) })), isLoading && (jsxRuntime.jsx(ctDesignCard.Card, __assign({ shadowDirection: ctDesignCard.CardBorderDirection.BOTTOM, shadowVariant: ctDesignCard.CardShadowVariant.E3, css: {
557
- position: 'absolute',
558
- height: '34px',
559
- width: '66px',
560
- padding: theme.spacing[3],
561
- borderRadius: theme.spacing[8],
562
- top: '50%',
563
- left: '50%',
564
- transform: 'translate(-50%, -50%)',
565
- } }, { children: jsxRuntime.jsx(ctDesignDottedLoader.DottedLoader, {}) })))] })), (messageIcon || message) && (jsxRuntime.jsxs(ctDesignBox.Box, __assign({ boxSize: 'pico', horizontal: true, css: {
566
- paddingTop: theme.spacing[2],
567
- alignItems: 'center',
568
- } }, { children: [messageIcon && (jsxRuntime.jsx(ctDesignContainer.Container, __assign({ css: {
569
- height: theme.size[4],
570
- width: theme.size[4],
571
- display: 'flex',
572
- justifyContent: 'center',
573
- alignItems: 'center',
574
- } }, { children: messageIcon }))), message && (jsxRuntime.jsx(ctDesignTypography.Typography, __assign({ variant: 'B3', color: hasError ? 'warning' : 'success' }, { children: message })))] }))), showCountDown && (jsxRuntime.jsxs(ctDesignTypography.Typography, __assign({ className: 'mt-3 flex', variant: 'B2' }, { children: ["Haven\u2019t received OTP yet?", jsxRuntime.jsxs(ctDesignTypography.Typography, __assign({ variant: 'B2', className: 'ml-1', color: countDown ? 'disabled' : 'link', onClick: !countDown ? onResendHandler : undefined, isClickable: !countDown }, { children: [' ', "Resend ", !!countDown && "(".concat(countDown, "s)")] }))] })))] }));
575
- });
1915
+ const styles$4 = css `
1916
+ outline: none;
1917
+ &:focus {
1918
+ outline: none;
1919
+ }
1920
+ `;
1921
+ const staticStyles$5 = ctDesignStyleManager.makeStyles((theme) => {
1922
+ return {
1923
+ root: {
1924
+ width: '100%',
1925
+ border: 'none',
1926
+ outline: 'none',
1927
+ fontSize: theme.typography.size[16],
1928
+ fontWeight: theme.typography.weight.medium,
1929
+ lineHeight: theme.typography.lineHeight[24],
1930
+ },
1931
+ };
1932
+ });
1933
+ const InputFieldCore$1 = react.forwardRef(({ value, disabled, styleConfig, onChange, onFocus, onBlur, onKeyDown, onSelect, onPressIn, placeholder, autoFocus, readOnly, type, inputMode, autoCapitalize, fieldTypographyVariant, variant, prefix, focus, placeholderType, id, maxLength, }, forwardedRef) => {
1934
+ const inputRef = react.useRef(null);
1935
+ const { field = [] } = styleConfig !== null && styleConfig !== void 0 ? styleConfig : {};
1936
+ const isPrefixComponent = react.isValidElement(prefix);
1937
+ const disabledPlaceHolder = !(placeholder === null || placeholder === void 0 ? void 0 : placeholder.length);
1938
+ const dynamicStyles = ctDesignStyleManager.useStyles((theme) => ({
1939
+ root: getTypographyVariant(theme, fieldTypographyVariant !== null && fieldTypographyVariant !== void 0 ? fieldTypographyVariant : 'HM2'),
1940
+ }), [fieldTypographyVariant]);
1941
+ const fieldStyles = ctDesignStyleManager.useStyles((theme) => {
1942
+ return {
1943
+ root: getFieldStyles({
1944
+ isLabeledPlaceholder: placeholderType === 'labeled',
1945
+ disabled: disabled !== null && disabled !== void 0 ? disabled : false,
1946
+ theme,
1947
+ variant: variant !== null && variant !== void 0 ? variant : 'md',
1948
+ focus,
1949
+ value,
1950
+ type: type !== null && type !== void 0 ? type : 'text',
1951
+ isPrefixComponent,
1952
+ disabledPlaceHolder,
1953
+ }),
1954
+ };
1955
+ }, [disabled, variant, focus, value, type, isPrefixComponent, disabledPlaceHolder]);
1956
+ const mergedStyles = ctDesignStyleManager.useWebMergeStyles([staticStyles$5.root, dynamicStyles.root, styles$4, fieldStyles.root, ...field], [fieldStyles.root, dynamicStyles.root, field]);
1957
+ react.useImperativeHandle(forwardedRef, () => ({
1958
+ focus: () => {
1959
+ var _a;
1960
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
1961
+ },
1962
+ blur: () => {
1963
+ var _a;
1964
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
1965
+ },
1966
+ setSelection: (start, end) => {
1967
+ var _a;
1968
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange(start, end);
1969
+ },
1970
+ }), []);
1971
+ const handleOnChange = react.useCallback((event) => {
1972
+ const inputValue = event.target.value;
1973
+ onChange === null || onChange === void 0 ? void 0 : onChange({
1974
+ target: { value: inputValue, selectionStart: event.target.selectionStart || 0 },
1975
+ currentTarget: {
1976
+ focus: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
1977
+ blur: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur(); },
1978
+ setSelection: (start, end) => {
1979
+ var _a;
1980
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange(start, end);
1981
+ },
1982
+ },
1983
+ });
1984
+ }, [onChange]);
1985
+ const handleOnFocus = react.useCallback((event) => {
1986
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus({
1987
+ target: { value: event.target.value },
1988
+ currentTarget: {
1989
+ focus: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
1990
+ blur: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur(); },
1991
+ setSelection: (start, end) => {
1992
+ var _a;
1993
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange(start, end);
1994
+ },
1995
+ },
1996
+ preventDefault: () => event.preventDefault(),
1997
+ });
1998
+ }, [onFocus]);
1999
+ const handleOnBlur = react.useCallback((event) => {
2000
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur({
2001
+ target: { value: event.target.value },
2002
+ currentTarget: {
2003
+ focus: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
2004
+ blur: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur(); },
2005
+ setSelection: (start, end) => {
2006
+ var _a;
2007
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange(start, end);
2008
+ },
2009
+ },
2010
+ preventDefault: () => event.preventDefault(),
2011
+ });
2012
+ }, [onBlur]);
2013
+ const handleOnKeyDown = react.useCallback((event) => {
2014
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown({
2015
+ target: { value: event.target.value, key: event.key },
2016
+ currentTarget: {
2017
+ focus: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
2018
+ blur: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur(); },
2019
+ setSelection: (start, end) => {
2020
+ var _a;
2021
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange(start, end);
2022
+ },
2023
+ },
2024
+ preventDefault: () => event.preventDefault(),
2025
+ });
2026
+ }, [onKeyDown]);
2027
+ const handleOnSelect = react.useCallback((event) => {
2028
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect({
2029
+ target: {
2030
+ value: event.target.value,
2031
+ selectionStart: event.target.selectionStart || 0,
2032
+ },
2033
+ currentTarget: {
2034
+ focus: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
2035
+ blur: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur(); },
2036
+ setSelection: (start, end) => {
2037
+ var _a;
2038
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange(start, end);
2039
+ },
2040
+ },
2041
+ preventDefault: () => event.preventDefault(),
2042
+ });
2043
+ }, [onSelect]);
2044
+ const handleOnPressIn = react.useCallback((event) => {
2045
+ var _a;
2046
+ onPressIn === null || onPressIn === void 0 ? void 0 : onPressIn({
2047
+ target: { value: ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.value) || '' },
2048
+ currentTarget: {
2049
+ focus: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
2050
+ blur: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur(); },
2051
+ setSelection: (start, end) => {
2052
+ var _a;
2053
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange(start, end);
2054
+ },
2055
+ },
2056
+ preventDefault: () => event.preventDefault(),
2057
+ });
2058
+ }, [onPressIn]);
2059
+ const webProps = {
2060
+ onChange: handleOnChange,
2061
+ onFocus: handleOnFocus,
2062
+ onBlur: handleOnBlur,
2063
+ onKeyDown: handleOnKeyDown,
2064
+ onSelect: handleOnSelect,
2065
+ onMouseDown: handleOnPressIn,
2066
+ placeholder,
2067
+ autoFocus,
2068
+ readOnly,
2069
+ type,
2070
+ inputMode,
2071
+ autoCapitalize,
2072
+ };
2073
+ return (jsxRuntime.jsx("input", Object.assign({ maxLength: maxLength, id: id, ref: inputRef, value: value, disabled: disabled, className: mergedStyles }, webProps)));
2074
+ });
2075
+ InputFieldCore$1.displayName = 'InputFieldCore';
2076
+
2077
+ const staticStyles$4 = ctDesignStyleManager.makeStyles((theme) => {
2078
+ return {
2079
+ root: {
2080
+ position: 'absolute',
2081
+ paddingLeft: theme.spacing[4],
2082
+ width: '100%',
2083
+ height: '100%',
2084
+ display: 'flex',
2085
+ transform: [{ translateY: 0 }],
2086
+ top: 16,
2087
+ },
2088
+ };
2089
+ });
2090
+ const FieldLabelWrapper = ({ variant, type, value, focus = false, placeholder, placeholderType, disabled = false, styleConfig, prefix, id, }) => {
2091
+ const { placeholder: placeholderStyleConfig } = styleConfig !== null && styleConfig !== void 0 ? styleConfig : {};
2092
+ const { placeholderLabel = [], placeholderTypography = {} } = placeholderStyleConfig !== null && placeholderStyleConfig !== void 0 ? placeholderStyleConfig : {};
2093
+ const shiftPlaceholder = placeholderType === 'floating';
2094
+ const isPrefixComponent = react.isValidElement(prefix);
2095
+ const baseStyles = ctDesignStyleManager.useStyles((theme) => ({
2096
+ root: getFieldPlaceholderStyles({
2097
+ theme,
2098
+ isFocused: focus,
2099
+ disabled,
2100
+ variant: variant !== null && variant !== void 0 ? variant : 'md',
2101
+ fieldType: type !== null && type !== void 0 ? type : 'text',
2102
+ isPrefixComponent,
2103
+ shiftPlaceholder,
2104
+ }),
2105
+ }), [focus, disabled, variant, type, isPrefixComponent, shiftPlaceholder]);
2106
+ const labelStyles = ctDesignStyleManager.useWebMergeStyles([baseStyles.root, staticStyles$4.root, ...placeholderLabel], [baseStyles.root, placeholderLabel]);
2107
+ if (placeholderType === 'default' || !focus) {
2108
+ return null;
2109
+ }
2110
+ if (variant === exports.FieldVariant.SM) {
2111
+ if (value.length)
2112
+ return null;
2113
+ return (jsxRuntime.jsx(ctDesignContainer.Container, { styleConfig: { root: [baseStyles.root, staticStyles$4.root, ...placeholderLabel] }, children: jsxRuntime.jsx(ctDesignTypography.Typography, { variant: 'B2', color: 'tertiary', styleConfig: placeholderTypography, children: placeholder }) }));
2114
+ }
2115
+ if (type === exports.FieldType.PHONE && value.length)
2116
+ return null;
2117
+ const typographyVariant = type === exports.FieldType.PHONE ? 'B1' : focus ? 'B3' : 'B1';
2118
+ return (jsxRuntime.jsx("label", { className: labelStyles, htmlFor: id, children: jsxRuntime.jsx(ctDesignTypography.Typography, { variant: typographyVariant, color: 'tertiary', styleConfig: placeholderTypography, children: placeholder }) }));
2119
+ };
2120
+
2121
+ const styles$3 = css `
2122
+ outline: none;
2123
+ &:focus {
2124
+ outline: none;
2125
+ }
2126
+ `;
2127
+ const staticStyles$3 = ctDesignStyleManager.makeStyles((theme) => {
2128
+ return {
2129
+ root: {
2130
+ width: '100%',
2131
+ border: 'none',
2132
+ outline: 'none',
2133
+ fontSize: theme.typography.size[16],
2134
+ fontWeight: theme.typography.weight.medium,
2135
+ lineHeight: theme.typography.lineHeight[24],
2136
+ },
2137
+ };
2138
+ });
2139
+ const InputFieldCore = react.forwardRef(({ value, disabled, styleConfig, onChange, onFocus, onBlur, onKeyDown, onSelect, onPressIn, placeholder, autoFocus, readOnly, type, inputMode, autoCapitalize, fieldTypographyVariant, variant, prefix, focus, placeholderType, id, maxLength, }, forwardedRef) => {
2140
+ const inputRef = react.useRef(null);
2141
+ const { field = [] } = styleConfig !== null && styleConfig !== void 0 ? styleConfig : {};
2142
+ const isPrefixComponent = react.isValidElement(prefix);
2143
+ const disabledPlaceHolder = !(placeholder === null || placeholder === void 0 ? void 0 : placeholder.length);
2144
+ const dynamicStyles = ctDesignStyleManager.useStyles((theme) => ({
2145
+ root: getTypographyVariant(theme, fieldTypographyVariant !== null && fieldTypographyVariant !== void 0 ? fieldTypographyVariant : 'HM2'),
2146
+ }), [fieldTypographyVariant]);
2147
+ const fieldStyles = ctDesignStyleManager.useStyles((theme) => {
2148
+ return {
2149
+ root: getFieldStyles({
2150
+ isLabeledPlaceholder: placeholderType === 'labeled',
2151
+ disabled: disabled !== null && disabled !== void 0 ? disabled : false,
2152
+ theme,
2153
+ variant: variant !== null && variant !== void 0 ? variant : 'md',
2154
+ focus,
2155
+ value,
2156
+ type: type !== null && type !== void 0 ? type : 'text',
2157
+ isPrefixComponent,
2158
+ disabledPlaceHolder,
2159
+ }),
2160
+ };
2161
+ }, [disabled, variant, focus, value, type, isPrefixComponent, disabledPlaceHolder]);
2162
+ const mergedStyles = ctDesignStyleManager.useWebMergeStyles([staticStyles$3.root, dynamicStyles.root, styles$3, fieldStyles.root, ...field], [fieldStyles.root, dynamicStyles.root, field]);
2163
+ react.useImperativeHandle(forwardedRef, () => ({
2164
+ focus: () => {
2165
+ var _a;
2166
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
2167
+ },
2168
+ blur: () => {
2169
+ var _a;
2170
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
2171
+ },
2172
+ setSelection: (start, end) => {
2173
+ var _a;
2174
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange(start, end);
2175
+ },
2176
+ }), []);
2177
+ const handleOnChange = react.useCallback((event) => {
2178
+ const inputValue = event.target.value;
2179
+ onChange === null || onChange === void 0 ? void 0 : onChange({
2180
+ target: { value: inputValue, selectionStart: event.target.selectionStart || 0 },
2181
+ currentTarget: {
2182
+ focus: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
2183
+ blur: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur(); },
2184
+ setSelection: (start, end) => {
2185
+ var _a;
2186
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange(start, end);
2187
+ },
2188
+ },
2189
+ });
2190
+ }, [onChange]);
2191
+ const handleOnFocus = react.useCallback((event) => {
2192
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus({
2193
+ target: { value: event.target.value },
2194
+ currentTarget: {
2195
+ focus: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
2196
+ blur: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur(); },
2197
+ setSelection: (start, end) => {
2198
+ var _a;
2199
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange(start, end);
2200
+ },
2201
+ },
2202
+ preventDefault: () => event.preventDefault(),
2203
+ });
2204
+ }, [onFocus]);
2205
+ const handleOnBlur = react.useCallback((event) => {
2206
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur({
2207
+ target: { value: event.target.value },
2208
+ currentTarget: {
2209
+ focus: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
2210
+ blur: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur(); },
2211
+ setSelection: (start, end) => {
2212
+ var _a;
2213
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange(start, end);
2214
+ },
2215
+ },
2216
+ preventDefault: () => event.preventDefault(),
2217
+ });
2218
+ }, [onBlur]);
2219
+ const handleOnKeyDown = react.useCallback((event) => {
2220
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown({
2221
+ target: { value: event.target.value, key: event.key },
2222
+ currentTarget: {
2223
+ focus: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
2224
+ blur: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur(); },
2225
+ setSelection: (start, end) => {
2226
+ var _a;
2227
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange(start, end);
2228
+ },
2229
+ },
2230
+ preventDefault: () => event.preventDefault(),
2231
+ });
2232
+ }, [onKeyDown]);
2233
+ const handleOnSelect = react.useCallback((event) => {
2234
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect({
2235
+ target: {
2236
+ value: event.target.value,
2237
+ selectionStart: event.target.selectionStart || 0,
2238
+ },
2239
+ currentTarget: {
2240
+ focus: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
2241
+ blur: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur(); },
2242
+ setSelection: (start, end) => {
2243
+ var _a;
2244
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange(start, end);
2245
+ },
2246
+ },
2247
+ preventDefault: () => event.preventDefault(),
2248
+ });
2249
+ }, [onSelect]);
2250
+ const handleOnPressIn = react.useCallback((event) => {
2251
+ var _a;
2252
+ onPressIn === null || onPressIn === void 0 ? void 0 : onPressIn({
2253
+ target: { value: ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.value) || '' },
2254
+ currentTarget: {
2255
+ focus: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
2256
+ blur: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur(); },
2257
+ setSelection: (start, end) => {
2258
+ var _a;
2259
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange(start, end);
2260
+ },
2261
+ },
2262
+ preventDefault: () => event.preventDefault(),
2263
+ });
2264
+ }, [onPressIn]);
2265
+ const webProps = {
2266
+ onChange: handleOnChange,
2267
+ onFocus: handleOnFocus,
2268
+ onBlur: handleOnBlur,
2269
+ onKeyDown: handleOnKeyDown,
2270
+ onSelect: handleOnSelect,
2271
+ onMouseDown: handleOnPressIn,
2272
+ placeholder,
2273
+ autoFocus,
2274
+ readOnly,
2275
+ type,
2276
+ inputMode,
2277
+ autoCapitalize,
2278
+ };
2279
+ return (jsxRuntime.jsx("textarea", Object.assign({ maxLength: maxLength, id: id, ref: inputRef, value: value, disabled: disabled, className: mergedStyles }, webProps)));
2280
+ });
2281
+ InputFieldCore.displayName = 'TextArea';
2282
+
2283
+ const staticStyles$2 = ctDesignStyleManager.makeStyles((theme) => {
2284
+ return {
2285
+ fieldWrapper: {
2286
+ flex: 1,
2287
+ flexShrink: 1,
2288
+ display: 'flex',
2289
+ alignItems: 'center',
2290
+ justifyContent: 'center',
2291
+ position: 'relative',
2292
+ height: '100%',
2293
+ },
2294
+ promptBox: {
2295
+ paddingLeft: theme.spacing[4],
2296
+ paddingRight: theme.spacing[4],
2297
+ display: 'flex',
2298
+ alignItems: 'center',
2299
+ },
2300
+ promptIcon: {
2301
+ height: theme.size[4],
2302
+ width: theme.size[4],
2303
+ paddingRight: theme.spacing[1],
2304
+ display: 'flex',
2305
+ justifyContent: 'center',
2306
+ alignItems: 'center',
2307
+ },
2308
+ flexNoShrink: {
2309
+ flexShrink: 0,
2310
+ },
2311
+ fieldContainer: {
2312
+ position: 'relative',
2313
+ display: 'flex',
2314
+ alignItems: 'center',
2315
+ justifyContent: 'center',
2316
+ flexDirection: 'row',
2317
+ borderStyle: theme === null || theme === void 0 ? void 0 : theme.border.style.solid,
2318
+ borderRadius: theme === null || theme === void 0 ? void 0 : theme.border.radius[8],
2319
+ boxSizing: 'border-box',
2320
+ },
2321
+ };
2322
+ });
2323
+ const Field = react.forwardRef(({ prefix, onBlur, onFocus, onChange, onKeyDown, onPressIn, onSelect, value, autoCapitalize, autoFocus = false, disabled, inputMode, placeholder, prefixGap: _prefixGap, prompt, readOnly, placeholderType = 'default', suffix, suffixGap: _suffixGap, type, variant, styleConfig = {}, fieldTypographyVariant, id, maxLength, numberOfLines, showSoftInputOnFocus, customSpacingTop, }, ref) => {
2324
+ const [focus, setFocus] = react.useState(autoFocus);
2325
+ const _isFocused = focus || value.length > 0;
2326
+ const { promptStyles } = styleConfig || {};
2327
+ const { Icon: promptIcon, message: promptMessage, hasError = false } = prompt || {};
2328
+ const fieldContainerStyles = ctDesignStyleManager.useStyles((theme) => ({
2329
+ root: getFieldContainerStyles({
2330
+ variant: variant !== null && variant !== void 0 ? variant : 'md',
2331
+ theme,
2332
+ hasError,
2333
+ focus,
2334
+ value,
2335
+ disabled,
2336
+ }),
2337
+ }), [variant, hasError, focus, value, disabled, styleConfig]);
2338
+ const InputField = numberOfLines && numberOfLines > 1 ? InputFieldCore : InputFieldCore$1;
2339
+ return (jsxRuntime.jsxs(ctDesignBox.Box, { boxSize: 'micro', styleConfig: styleConfig, children: [jsxRuntime.jsxs(ctDesignContainer.Container, { styleConfig: {
2340
+ root: [fieldContainerStyles.root, staticStyles$2.fieldContainer, ...(styleConfig.fieldContainer || [])],
2341
+ }, children: [react.isValidElement(prefix) && (jsxRuntime.jsx(ctDesignContainer.Container, { styleConfig: { root: [staticStyles$2.flexNoShrink] }, children: react.cloneElement(prefix, { focus }) })), jsxRuntime.jsxs(ctDesignContainer.Container, { styleConfig: { root: [staticStyles$2.fieldWrapper, ...(styleConfig.field || [])] }, children: [jsxRuntime.jsx(FieldLabelWrapper, { id: id, variant: variant, type: type, value: value, focus: _isFocused, placeholder: placeholder, placeholderType: placeholderType, disabled: disabled, styleConfig: styleConfig, prefix: prefix }), jsxRuntime.jsx(InputField, { id: id, ref: ref, value: value, disabled: disabled, placeholder: placeholder, placeholderType: placeholderType, autoFocus: autoFocus, readOnly: readOnly, type: type, inputMode: inputMode, autoCapitalize: autoCapitalize, fieldTypographyVariant: fieldTypographyVariant, styleConfig: styleConfig, focus: _isFocused, onChange: onChange, onSelect: onSelect, onPressIn: onPressIn, onFocus: (e) => {
2342
+ setFocus(true);
2343
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
2344
+ }, onBlur: (e) => {
2345
+ setFocus(false);
2346
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
2347
+ }, onKeyDown: onKeyDown, maxLength: maxLength, numberOfLines: numberOfLines, showSoftInputOnFocus: showSoftInputOnFocus, customSpacingTop: customSpacingTop })] }), react.isValidElement(suffix) && (jsxRuntime.jsx(ctDesignContainer.Container, { styleConfig: { root: [staticStyles$2.flexNoShrink] }, children: react.cloneElement(suffix, { focus }) }))] }), (promptIcon || promptMessage) && (jsxRuntime.jsxs(ctDesignBox.Box, { boxSize: 'pico', horizontal: true, styleConfig: {
2348
+ root: [staticStyles$2.promptBox, ...((promptStyles === null || promptStyles === void 0 ? void 0 : promptStyles.promptBox) || [])],
2349
+ }, children: [promptIcon && (jsxRuntime.jsx(ctDesignContainer.Container, { styleConfig: { root: [staticStyles$2.promptIcon, ...((promptStyles === null || promptStyles === void 0 ? void 0 : promptStyles.promptIconContainer) || [])] }, children: promptIcon })), promptMessage && (jsxRuntime.jsx(ctDesignTypography.Typography, { variant: 'B3', color: hasError ? 'warning' : 'success', styleConfig: promptStyles === null || promptStyles === void 0 ? void 0 : promptStyles.promptMessageTypography, children: promptMessage }))] }))] }));
2350
+ });
2351
+ Field.displayName = 'Field';
2352
+
2353
+ /******************************************************************************
2354
+ Copyright (c) Microsoft Corporation.
2355
+
2356
+ Permission to use, copy, modify, and/or distribute this software for any
2357
+ purpose with or without fee is hereby granted.
2358
+
2359
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
2360
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2361
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
2362
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
2363
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2364
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2365
+ PERFORMANCE OF THIS SOFTWARE.
2366
+ ***************************************************************************** */
2367
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
2368
+
2369
+ function __rest(s, e) {
2370
+ var t = {};
2371
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
2372
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2373
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
2374
+ }
2375
+ return t;
2376
+ }
2377
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
2378
+ var e = new Error(message);
2379
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
2380
+ };
2381
+
2382
+ const styles$2 = ctDesignStyleManager.makeStyles((theme) => {
2383
+ return {
2384
+ wrapper: {
2385
+ alignItems: 'center',
2386
+ justifyContent: 'center',
2387
+ flexDirection: 'row',
2388
+ paddingLeft: 16,
2389
+ },
2390
+ flagContainer: {
2391
+ display: 'flex',
2392
+ alignItems: 'center',
2393
+ justifyContent: 'center',
2394
+ flexDirection: 'row',
2395
+ height: theme.size[6],
2396
+ width: theme.size[6],
2397
+ },
2398
+ countryCode: {
2399
+ alignSelf: 'flex-start',
2400
+ },
2401
+ divider: {
2402
+ borderRightWidth: 1,
2403
+ height: '100%',
2404
+ borderRightColor: theme.color.background.disabledDark,
2405
+ },
2406
+ disabledColor: {
2407
+ color: theme.color.text.disabled,
2408
+ },
2409
+ enabledColor: {
2410
+ color: theme.color.text.primary,
2411
+ },
2412
+ container: {
2413
+ flexDirection: 'row',
2414
+ alignItems: 'center',
2415
+ gap: theme.spacing[2],
2416
+ },
2417
+ };
2418
+ });
2419
+ const DownChevronV2 = (_a) => {
2420
+ var { color = '#1A1A1A' } = _a, rest = __rest(_a, ["color"]);
2421
+ return (jsxRuntime.jsx("svg", Object.assign({ xmlns: 'http://www.w3.org/2000/svg', width: '12', height: '12', fill: 'none', viewBox: '0 0 12 12' }, rest, { children: jsxRuntime.jsx("path", { stroke: color, strokeLinecap: 'round', strokeLinejoin: 'round', strokeWidth: '2', d: 'M2 4l4 4 4-4' }) })));
2422
+ };
2423
+ const PhoneFieldPrefix = ({ countryCode, disabled = false, flagIcon, onDropdownClick, showDropdownIcon, }) => {
2424
+ const onClick = () => {
2425
+ if (disabled)
2426
+ return;
2427
+ onDropdownClick === null || onDropdownClick === void 0 ? void 0 : onDropdownClick();
2428
+ };
2429
+ return (jsxRuntime.jsxs(ctDesignBox.Box, { boxSize: 'micro', styleConfig: { root: [styles$2.wrapper] }, onClick: onClick, children: [jsxRuntime.jsxs(ctDesignContainer.Container, { styleConfig: {
2430
+ root: [styles$2.container],
2431
+ }, children: [flagIcon && jsxRuntime.jsx(ctDesignContainer.Container, { styleConfig: { root: [styles$2.flagContainer] }, children: flagIcon }), jsxRuntime.jsx(ctDesignTypography.Typography, { variant: 'B1', color: disabled ? 'disabled' : 'primary', styleConfig: { root: [styles$2.countryCode] }, children: countryCode }), showDropdownIcon && (jsxRuntime.jsx(DownChevronV2, { color: disabled ? styles$2.disabledColor.color : styles$2.enabledColor.color }))] }), jsxRuntime.jsx(ctDesignDivider.Divider, { dividerWidth: 1, dividerLength: 0, orientation: 'vertical', styleConfig: { root: [styles$2.divider] } })] }));
2432
+ };
2433
+
2434
+ const styles$1 = ctDesignStyleManager.makeStyles((theme) => {
2435
+ return {
2436
+ fieldConfig: {
2437
+ flex: 1,
2438
+ paddingTop: 0,
2439
+ paddingBottom: 0,
2440
+ paddingVertical: 0,
2441
+ lineHeight: 18,
2442
+ paddingLeft: theme.spacing[4],
2443
+ },
2444
+ };
2445
+ });
2446
+ const PhoneField = react.forwardRef((_a, forwardedRef) => {
2447
+ var _b;
2448
+ var { flagIcon, countryCode, showDropdownIcon, onDropdownClick, disabled, max, onChange, styleConfig } = _a, rest = __rest(_a, ["flagIcon", "countryCode", "showDropdownIcon", "onDropdownClick", "disabled", "max", "onChange", "styleConfig"]);
2449
+ const [prefixWidth, setPrefixWidth] = react.useState(0);
2450
+ const handleChange = (event) => {
2451
+ const value = event.target.value;
2452
+ const isValidValue = value ? new RegExp(ctDesignCommonConstants.ONLY_NUMERIC).test(value) : true;
2453
+ if (value.length <= max && isValidValue) {
2454
+ onChange === null || onChange === void 0 ? void 0 : onChange(event);
2455
+ }
2456
+ };
2457
+ const customPlaceHolderStyling = ctDesignStyleManager.useStyles(() => {
2458
+ return {
2459
+ placeholderStyles: {
2460
+ marginLeft: prefixWidth,
2461
+ },
2462
+ };
2463
+ }, [prefixWidth]);
2464
+ return (jsxRuntime.jsx(Field, Object.assign({}, rest, { type: exports.FieldType.PHONE, ref: forwardedRef, disabled: disabled, onChange: handleChange, prefix: jsxRuntime.jsx("div", { ref: (ref) => { var _a; return setPrefixWidth((_a = ref === null || ref === void 0 ? void 0 : ref.getBoundingClientRect().width) !== null && _a !== void 0 ? _a : 0); }, children: jsxRuntime.jsx(PhoneFieldPrefix, { flagIcon: flagIcon, countryCode: countryCode, showDropdownIcon: showDropdownIcon, onDropdownClick: onDropdownClick, disabled: disabled }) }), inputMode: 'numeric', styleConfig: Object.assign({ field: [styles$1.fieldConfig, ...((styleConfig === null || styleConfig === void 0 ? void 0 : styleConfig.field) || [])], placeholder: {
2465
+ placeholderLabel: [
2466
+ customPlaceHolderStyling.placeholderStyles,
2467
+ ...(((_b = styleConfig === null || styleConfig === void 0 ? void 0 : styleConfig.placeholder) === null || _b === void 0 ? void 0 : _b.placeholderLabel) || []),
2468
+ ],
2469
+ } }, styleConfig) })));
2470
+ });
2471
+ PhoneField.displayName = 'PhoneField';
2472
+
2473
+ const styles = ctDesignStyleManager.makeStyles((theme) => ({
2474
+ rootContainer: {
2475
+ justifyContent: 'center',
2476
+ },
2477
+ otpContainer: {
2478
+ display: 'flex',
2479
+ flexDirection: 'row',
2480
+ gap: theme.spacing[3],
2481
+ },
2482
+ otpBox: {
2483
+ width: theme.size[15],
2484
+ height: theme.size[15],
2485
+ borderRadius: theme === null || theme === void 0 ? void 0 : theme.border.radius[8],
2486
+ justifyContent: 'center',
2487
+ alignItems: 'center',
2488
+ borderStyle: theme.border.style.solid,
2489
+ },
2490
+ otpInput: {
2491
+ width: '100%',
2492
+ height: '100%',
2493
+ fontSize: theme === null || theme === void 0 ? void 0 : theme.typography.size[20],
2494
+ fontWeight: theme === null || theme === void 0 ? void 0 : theme.typography.weight.semibold,
2495
+ color: theme.color.text.primary,
2496
+ textAlign: 'center',
2497
+ },
2498
+ errorText: {
2499
+ marginVertical: theme === null || theme === void 0 ? void 0 : theme.spacing[2],
2500
+ fontSize: theme === null || theme === void 0 ? void 0 : theme.typography.size[14],
2501
+ fontWeight: theme === null || theme === void 0 ? void 0 : theme.typography.weight.semibold,
2502
+ color: theme === null || theme === void 0 ? void 0 : theme.color.text.warning,
2503
+ },
2504
+ }));
2505
+ const OtpBox = ({ value, focus, inputMode, onChange, onFocus, readOnly, onBlur, onPressIn, onKeyDown, onSelect, maxLength, prompt, styleConfig, }) => {
2506
+ const theme = ctDesignTheme.useTheme();
2507
+ const ref = react.useRef(null);
2508
+ const { hasError = false } = prompt || {};
2509
+ const { otpBox = [], otpRootInput = [] } = styleConfig || {};
2510
+ react.useEffect(() => {
2511
+ if (focus && ref.current) {
2512
+ ref.current.focus();
2513
+ }
2514
+ }, [focus]);
2515
+ const dynamicStyles = ctDesignStyleManager.useStyles((theme) => {
2516
+ if (hasError) {
2517
+ return {
2518
+ otpBox: {
2519
+ borderColor: theme.color.border.warning,
2520
+ borderWidth: theme.border.width.lg,
2521
+ },
2522
+ };
2523
+ }
2524
+ return {
2525
+ otpBox: {
2526
+ borderColor: focus ? theme.color.border.primary : theme.color.border.disabledDark,
2527
+ borderWidth: focus ? theme.border.width.lg : theme.border.width.sm,
2528
+ },
2529
+ };
2530
+ }, [hasError, focus]);
2531
+ return (jsxRuntime.jsx(ctDesignContainer.Container, { styleConfig: {
2532
+ root: [styles.otpBox, dynamicStyles.otpBox, ...otpBox],
2533
+ }, children: jsxRuntime.jsx(InputFieldCore$1, { id: `otp-box`, disabled: readOnly, ref: ref, value: value, maxLength: maxLength, inputMode: inputMode, onChange: onChange, onBlur: onBlur, onPressIn: onPressIn, onKeyDown: onKeyDown, onSelect: onSelect, autoCapitalize: 'characters', cursorColor: theme.color.text.grapetini900, onFocus: onFocus, focus: focus, styleConfig: { root: [styles.otpInput, ...otpRootInput] } }) }));
2534
+ };
2535
+ const OtpField = ({ value = '', numberOfBoxes = 4, inputMode = 'numeric', autoFocus = true, refocus = false, onChange, readOnly = false, onComplete, onKeyDown, onSelect, onBlur, onPressIn, onFocus, prompt, styleConfig = {}, }) => {
2536
+ const [focusedIndex, setFocusedIndex] = react.useState(autoFocus ? 0 : -1);
2537
+ const { hasError = false, message: errorMessage } = prompt || {};
2538
+ const { promptStyles, otpRootContainer = [], otpRootInput = [] } = styleConfig || {};
2539
+ const { promptMessageTypography } = promptStyles || {};
2540
+ const otpValues = Array(numberOfBoxes)
2541
+ .fill('')
2542
+ .map((_, index) => {
2543
+ const char = value[index];
2544
+ return char && char !== ' ' ? char : '';
2545
+ });
2546
+ react.useEffect(() => {
2547
+ if (autoFocus && !readOnly) {
2548
+ setFocusedIndex(0);
2549
+ }
2550
+ }, [autoFocus, readOnly]);
2551
+ react.useEffect(() => {
2552
+ if (refocus) {
2553
+ setFocusedIndex(0);
2554
+ }
2555
+ }, [refocus]);
2556
+ const validateInput = react.useCallback((text) => {
2557
+ if (inputMode === 'numeric') {
2558
+ return text.replace(/[^0-9]/g, '');
2559
+ }
2560
+ return text.replace(/[^0-9A-Za-z]/g, '').toUpperCase();
2561
+ }, [inputMode]);
2562
+ const handleInputChange = react.useCallback((e, index) => {
2563
+ const validatedText = validateInput(e.target.value);
2564
+ const otpString = value || '';
2565
+ const currentOtpValues = Array(numberOfBoxes)
2566
+ .fill('')
2567
+ .map((_, idx) => {
2568
+ const char = otpString[idx];
2569
+ return char && char !== ' ' ? char : '';
2570
+ });
2571
+ if (validatedText.length > 1) {
2572
+ const newValues = [...currentOtpValues];
2573
+ for (let i = 0; i < validatedText.length && index + i < numberOfBoxes; i++) {
2574
+ newValues[index + i] = validatedText[i];
2575
+ }
2576
+ const newValue = newValues.join('');
2577
+ onChange === null || onChange === void 0 ? void 0 : onChange({
2578
+ target: { value: newValue, selectionStart: index },
2579
+ currentTarget: e.currentTarget,
2580
+ preventDefault: e.preventDefault,
2581
+ });
2582
+ const nextEmptyIndex = newValues.findIndex((val) => !val);
2583
+ if (nextEmptyIndex !== -1) {
2584
+ setFocusedIndex(nextEmptyIndex);
2585
+ }
2586
+ else {
2587
+ setFocusedIndex(numberOfBoxes - 1);
2588
+ }
2589
+ if (!newValues.includes('')) {
2590
+ onComplete === null || onComplete === void 0 ? void 0 : onComplete(newValue);
2591
+ }
2592
+ return;
2593
+ }
2594
+ if (validatedText) {
2595
+ const newValues = [...currentOtpValues];
2596
+ newValues[index] = validatedText;
2597
+ const newValue = newValues.join('');
2598
+ onChange === null || onChange === void 0 ? void 0 : onChange({
2599
+ target: { value: newValue, selectionStart: index },
2600
+ currentTarget: e.currentTarget,
2601
+ preventDefault: e.preventDefault,
2602
+ });
2603
+ if (index < numberOfBoxes - 1) {
2604
+ setFocusedIndex(index + 1);
2605
+ }
2606
+ if (!newValues.includes('')) {
2607
+ onComplete === null || onComplete === void 0 ? void 0 : onComplete(newValue);
2608
+ }
2609
+ }
2610
+ }, [validateInput, value, numberOfBoxes, onChange, onComplete]);
2611
+ const handleKeyPress = react.useCallback((e, index) => {
2612
+ var _a, _b;
2613
+ const key = e.target.key;
2614
+ if (key === 'Backspace') {
2615
+ const otpString = value || '';
2616
+ const currentOtpValues = Array(numberOfBoxes)
2617
+ .fill('')
2618
+ .map((_, idx) => {
2619
+ const char = otpString[idx];
2620
+ return char && char !== ' ' ? char : '';
2621
+ });
2622
+ if (currentOtpValues[index]) {
2623
+ const newValues = [...currentOtpValues];
2624
+ newValues[index] = ' ';
2625
+ onChange === null || onChange === void 0 ? void 0 : onChange({
2626
+ target: { value: newValues.join(''), selectionStart: index },
2627
+ currentTarget: e.currentTarget,
2628
+ preventDefault: e.preventDefault,
2629
+ });
2630
+ }
2631
+ else if (index > 0) {
2632
+ setFocusedIndex(index - 1);
2633
+ }
2634
+ }
2635
+ else if (key === 'ArrowLeft' && index > 0) {
2636
+ (_a = e.preventDefault) === null || _a === void 0 ? void 0 : _a.call(e);
2637
+ setFocusedIndex(index - 1);
2638
+ }
2639
+ else if (key === 'ArrowRight' && index < numberOfBoxes - 1) {
2640
+ (_b = e.preventDefault) === null || _b === void 0 ? void 0 : _b.call(e);
2641
+ setFocusedIndex(index + 1);
2642
+ }
2643
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown({
2644
+ target: { value, key },
2645
+ currentTarget: e.currentTarget,
2646
+ preventDefault: e.preventDefault,
2647
+ });
2648
+ }, [numberOfBoxes, onKeyDown, value, onChange]);
2649
+ const handleFocus = react.useCallback((e, index) => {
2650
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus({
2651
+ target: { value, index },
2652
+ currentTarget: e.currentTarget,
2653
+ preventDefault: e.preventDefault,
2654
+ });
2655
+ setFocusedIndex(index);
2656
+ }, [onFocus, value]);
2657
+ return (jsxRuntime.jsxs(ctDesignContainer.Container, { styleConfig: { root: [styles.rootContainer, ...otpRootContainer] }, children: [jsxRuntime.jsx(ctDesignContainer.Container, { styleConfig: { root: [styles.otpContainer, ...otpRootInput] }, children: Array(numberOfBoxes)
2658
+ .fill(null)
2659
+ .map((_, index) => (jsxRuntime.jsx(OtpBox, { value: otpValues[index], focus: focusedIndex === index, prompt: { hasError }, inputMode: inputMode, maxLength: ctDesignCommonUtils.isIOS() ? numberOfBoxes : 1, onFocus: (e) => handleFocus(e, index), onChange: (e) => handleInputChange(e, index), readOnly: readOnly, onPressIn: onPressIn, onKeyDown: (e) => handleKeyPress(e, index), onSelect: onSelect, onBlur: onBlur, styleConfig: styleConfig }, index))) }), hasError && !!errorMessage && (jsxRuntime.jsx(ctDesignTypography.Typography, { variant: ctDesignTypography.TypographyVariant.P3, color: ctDesignTypography.TypographyColor.WARNING, styleConfig: Object.assign({ root: [styles.errorText] }, promptMessageTypography), children: errorMessage }))] }));
2660
+ };
2661
+
2662
+ var CURSOR_OPERATION;
2663
+ (function (CURSOR_OPERATION) {
2664
+ CURSOR_OPERATION["NONE"] = "NONE";
2665
+ CURSOR_OPERATION["ADD"] = "ADD";
2666
+ CURSOR_OPERATION["SUBSTRACT"] = "SUBSTRACT";
2667
+ })(CURSOR_OPERATION || (CURSOR_OPERATION = {}));
2668
+ const CardField = react.forwardRef((_a, forwardedRef) => {
2669
+ var { onChange, value } = _a, rest = __rest(_a, ["onChange", "value"]);
2670
+ const ref = react.useRef(null);
2671
+ const mergedRef = useMergeRefs__default.default(forwardedRef, ref);
2672
+ const cursorRef = react.useRef({
2673
+ cursorPos: 0,
2674
+ operation: CURSOR_OPERATION.NONE,
2675
+ });
2676
+ react.useEffect(() => {
2677
+ var _a;
2678
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.setSelection(cursorRef.current.cursorPos, cursorRef.current.cursorPos);
2679
+ cursorRef.current = {
2680
+ cursorPos: cursorRef.current.cursorPos,
2681
+ operation: CURSOR_OPERATION.NONE,
2682
+ };
2683
+ }, [value]);
2684
+ const handleChange = (e) => {
2685
+ onChange === null || onChange === void 0 ? void 0 : onChange(e);
2686
+ let selectionStart = e.target.selectionStart || 0;
2687
+ switch (cursorRef.current.operation) {
2688
+ case CURSOR_OPERATION.SUBSTRACT: {
2689
+ --selectionStart;
2690
+ break;
2691
+ }
2692
+ case CURSOR_OPERATION.ADD: {
2693
+ ++selectionStart;
2694
+ break;
2695
+ }
2696
+ }
2697
+ cursorRef.current = {
2698
+ cursorPos: selectionStart,
2699
+ operation: CURSOR_OPERATION.NONE,
2700
+ };
2701
+ };
2702
+ return (jsxRuntime.jsx(Field, Object.assign({ ref: mergedRef, onChange: handleChange }, rest, { type: exports.FieldType.NUMBER, value: value, inputMode: 'numeric' })));
2703
+ });
2704
+ CardField.displayName = 'CardField';
2705
+
2706
+ const InputField = react.forwardRef((props, forwardedRef) => {
2707
+ if (props.fieldType === 'phone') {
2708
+ return jsxRuntime.jsx(PhoneField, Object.assign({}, props, { ref: forwardedRef }));
2709
+ }
2710
+ if (props.fieldType === 'otp') {
2711
+ return jsxRuntime.jsx(OtpField, Object.assign({}, props));
2712
+ }
2713
+ if (props.fieldType === 'card') {
2714
+ return jsxRuntime.jsx(CardField, Object.assign({}, props, { ref: forwardedRef }));
2715
+ }
2716
+ return jsxRuntime.jsx(Field, Object.assign({}, props, { ref: forwardedRef }));
2717
+ });
2718
+ InputField.displayName = 'InputField';
2719
+
2720
+ const staticStyles$1 = ctDesignStyleManager.makeStyles((theme) => {
2721
+ return {
2722
+ root: {
2723
+ display: 'flex',
2724
+ alignItems: 'center',
2725
+ justifyContent: 'center',
2726
+ marginLeft: theme.spacing[4],
2727
+ width: theme.size[6],
2728
+ height: theme.size[6],
2729
+ },
2730
+ };
2731
+ });
2732
+ const FieldIcon = ({ icon, onClick, focus, focusedIcon, styleConfig }) => {
2733
+ const { root: customRootStyles = [] } = styleConfig || {};
2734
+ if (!react.isValidElement(icon))
2735
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {});
2736
+ let IconPrefix = icon;
2737
+ if (focus && react.isValidElement(focusedIcon)) {
2738
+ IconPrefix = focusedIcon;
2739
+ }
2740
+ const handleClick = () => {
2741
+ onClick === null || onClick === void 0 ? void 0 : onClick();
2742
+ };
2743
+ return (jsxRuntime.jsx(ctDesignContainer.Container, { styleConfig: { root: [staticStyles$1.root, ...customRootStyles] }, onClick: handleClick, children: IconPrefix }));
2744
+ };
2745
+
2746
+ const staticStyles = ctDesignStyleManager.makeStyles((theme) => ({
2747
+ root: {
2748
+ paddingRight: theme.spacing[4],
2749
+ },
2750
+ }));
2751
+ const FieldAction = ({ actionsList = [] }) => {
2752
+ return (jsxRuntime.jsx(ctDesignBox.Box, { boxSize: 'tiny', horizontal: true, styleConfig: { root: [staticStyles.root] }, children: actionsList.map((actionItem) => {
2753
+ const { label, color, onClick, isDisabled, isLoading } = actionItem || {};
2754
+ if (isLoading) {
2755
+ return jsxRuntime.jsx(ctDesignDottedLoader.DottedLoader, {}, 'fieldAction');
2756
+ }
2757
+ return (jsxRuntime.jsx(ctDesignTypography.Typography, { variant: 'HM4', color: isDisabled ? ctDesignTypography.TypographyColor.DISABLED : color, onClick: !isDisabled
2758
+ ? onClick
2759
+ : () => {
2760
+ }, isClickable: true, isDisabled: isDisabled, children: label }, 'fieldAction'));
2761
+ }) }));
2762
+ };
576
2763
 
577
- exports.CardField = CardField;
578
- exports.FieldAction = FieldAction;
579
- exports.FieldIcon = FieldIcon;
580
- exports.FieldV2 = Field;
581
- exports.OTPField = OTPField;
582
- exports.PhoneField = PhoneField;
583
- exports.PhoneFieldPrefix = PhoneFieldPrefix;
2764
+ exports.FieldAction = FieldAction;
2765
+ exports.FieldIcon = FieldIcon;
2766
+ exports.InputField = InputField;
2767
+ exports.TextArea = InputFieldCore;
584
2768
 
585
2769
  }));
586
2770
  //# sourceMappingURL=ct-design-field.umd.js.map