@easypost/easy-ui 1.0.0-alpha.4 → 1.0.0-alpha.6

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 (133) hide show
  1. package/Badge/index.js +32 -26
  2. package/Badge/index.mjs +32 -26
  3. package/Banner/index.js +15 -16
  4. package/Banner/index.mjs +15 -16
  5. package/Button/Button.d.ts +61 -0
  6. package/Button/Button.d.ts.map +1 -1
  7. package/Button/index.js +34 -69
  8. package/Button/index.mjs +33 -68
  9. package/CHANGELOG.md +21 -0
  10. package/Card/index.js +84 -5
  11. package/Card/index.mjs +84 -5
  12. package/Checkbox/index.js +84 -72
  13. package/Checkbox/index.mjs +84 -72
  14. package/CodeBlock/index.js +43 -49
  15. package/CodeBlock/index.mjs +43 -49
  16. package/DropdownButton/DropdownButton.d.ts +48 -0
  17. package/DropdownButton/DropdownButton.d.ts.map +1 -1
  18. package/DropdownButton/index.js +29 -101
  19. package/DropdownButton/index.mjs +29 -85
  20. package/HorizontalGrid/index.js +11 -31
  21. package/HorizontalGrid/index.mjs +11 -31
  22. package/HorizontalStack/index.js +48 -4
  23. package/HorizontalStack/index.mjs +48 -4
  24. package/Icon/Icon.d.ts +51 -0
  25. package/Icon/Icon.d.ts.map +1 -1
  26. package/Icon/index.js +38 -4
  27. package/Icon/index.mjs +38 -4
  28. package/IconButton/IconButton.d.ts +62 -0
  29. package/IconButton/IconButton.d.ts.map +1 -1
  30. package/IconButton/index.js +26 -43
  31. package/IconButton/index.mjs +25 -42
  32. package/InputField/Label.d.ts +2 -2
  33. package/InputField/index.js +282 -10
  34. package/InputField/index.mjs +266 -10
  35. package/InputField/utilities.d.ts +1 -1
  36. package/InputField/utilities.d.ts.map +1 -1
  37. package/Menu/MenuOverlay.d.ts.map +1 -1
  38. package/Menu/index.js +178 -1958
  39. package/Menu/index.mjs +168 -1948
  40. package/Menu/utilities.d.ts +11 -0
  41. package/Menu/utilities.d.ts.map +1 -0
  42. package/Notification/index.js +1534 -14
  43. package/Notification/index.mjs +1518 -14
  44. package/Provider/index.js +15 -15
  45. package/Provider/index.mjs +15 -15
  46. package/RadioGroup/index.js +63 -63
  47. package/RadioGroup/index.mjs +63 -63
  48. package/Select/Select.d.ts +88 -0
  49. package/Select/Select.d.ts.map +1 -0
  50. package/Select/Select.stories.d.ts +17 -0
  51. package/Select/Select.stories.d.ts.map +1 -0
  52. package/Select/Select.test.d.ts +2 -0
  53. package/Select/Select.test.d.ts.map +1 -0
  54. package/Select/SelectContext.d.ts +14 -0
  55. package/Select/SelectContext.d.ts.map +1 -0
  56. package/Select/SelectField.d.ts +62 -0
  57. package/Select/SelectField.d.ts.map +1 -0
  58. package/Select/SelectOption.d.ts +23 -0
  59. package/Select/SelectOption.d.ts.map +1 -0
  60. package/Select/SelectOverlay.d.ts +3 -0
  61. package/Select/SelectOverlay.d.ts.map +1 -0
  62. package/Select/SelectSection.d.ts +22 -0
  63. package/Select/SelectSection.d.ts.map +1 -0
  64. package/Select/SelectTrigger.d.ts +30 -0
  65. package/Select/SelectTrigger.d.ts.map +1 -0
  66. package/Select/index.d.ts +2 -0
  67. package/Select/index.d.ts.map +1 -0
  68. package/Select/index.js +816 -0
  69. package/Select/index.mjs +816 -0
  70. package/SelectorErrorTooltip/index.js +102 -11
  71. package/SelectorErrorTooltip/index.mjs +86 -11
  72. package/Text/index.js +85 -4
  73. package/Text/index.mjs +85 -4
  74. package/TextField/index.js +19 -38
  75. package/TextField/index.mjs +19 -38
  76. package/Textarea/index.js +20 -37
  77. package/Textarea/index.mjs +20 -37
  78. package/Theme/index.js +145 -9
  79. package/Theme/index.mjs +145 -9
  80. package/Toggle/index.js +51 -50
  81. package/Toggle/index.mjs +51 -50
  82. package/Tooltip/index.js +299 -10
  83. package/Tooltip/index.mjs +299 -10
  84. package/UnstyledButton/index.js +4 -4
  85. package/UnstyledButton/index.mjs +3 -3
  86. package/VerticalStack/index.js +13 -47
  87. package/VerticalStack/index.mjs +13 -47
  88. package/__chunks__/ExpandMore400-7c5263a4.mjs +49 -0
  89. package/__chunks__/ExpandMore400-92646971.js +65 -0
  90. package/__chunks__/InputIcon-2317befd.mjs +148 -0
  91. package/__chunks__/InputIcon-d3963cf8.js +147 -0
  92. package/__chunks__/{import-e7f45c7e.mjs → import-0561e1ba.mjs} +3 -3
  93. package/__chunks__/{import-b7971a11.mjs → import-19bc38ac.mjs} +72 -34
  94. package/__chunks__/{import-01299af6.js → import-24a482e1.js} +3 -2
  95. package/__chunks__/{import-baa3cd0c.mjs → import-29af6941.mjs} +4 -3
  96. package/__chunks__/{import-0d1b4d93.js → import-2b302763.js} +193 -141
  97. package/__chunks__/{import-ab878fb6.mjs → import-3d962a94.mjs} +205 -153
  98. package/__chunks__/{import-86330a7c.mjs → import-6a831ca1.mjs} +16 -15
  99. package/__chunks__/{import-7545401a.js → import-8b6c0bc7.js} +3 -3
  100. package/__chunks__/{import-63bf0645.js → import-a1e0f814.js} +47 -9
  101. package/__chunks__/{import-3ab42f86.js → import-a2023d8f.js} +35 -22
  102. package/__chunks__/{import-76076ca6.js → import-dea5a24d.js} +15 -14
  103. package/__chunks__/{import-856e0385.mjs → import-f1f4792a.mjs} +36 -23
  104. package/__chunks__/{UnstyledButton-883f0c6c.mjs → index-29d7bca9.mjs} +17 -42
  105. package/__chunks__/{UnstyledButton-96172ec0.js → index-3985350a.js} +17 -42
  106. package/__chunks__/{overlayscrollbars-react.es-c8369a03.mjs → overlayscrollbars-react.es-7f332a3b.mjs} +4 -4
  107. package/__chunks__/{overlayscrollbars-react.es-20563393.js → overlayscrollbars-react.es-f2a0bcff.js} +4 -4
  108. package/__chunks__/{real-module-e4cd2301.mjs → real-module-515df21d.mjs} +1 -1
  109. package/__chunks__/{real-module-ae2a4342.js → real-module-e36b1436.js} +1 -1
  110. package/__chunks__/useTriggerWidth-156b038a.js +2030 -0
  111. package/__chunks__/useTriggerWidth-addcd1d6.mjs +2031 -0
  112. package/package.json +11 -11
  113. package/style.css +1423 -1196
  114. package/utilities/css.js +14 -58
  115. package/utilities/css.mjs +14 -58
  116. package/__chunks__/Card-7bbd41e0.mjs +0 -110
  117. package/__chunks__/Card-dac53c75.js +0 -109
  118. package/__chunks__/HorizontalStack-a441c63f.mjs +0 -80
  119. package/__chunks__/HorizontalStack-a862839b.js +0 -79
  120. package/__chunks__/Icon-3d00481a.js +0 -44
  121. package/__chunks__/Icon-a75b5201.mjs +0 -45
  122. package/__chunks__/InputField-4fbaae06.js +0 -487
  123. package/__chunks__/InputField-a272f602.mjs +0 -472
  124. package/__chunks__/Notification-b8eafec6.mjs +0 -1456
  125. package/__chunks__/Notification-c5b34eb3.js +0 -1471
  126. package/__chunks__/SelectorErrorTooltip-43c5e29e.js +0 -84
  127. package/__chunks__/SelectorErrorTooltip-b6204987.mjs +0 -69
  128. package/__chunks__/Text-1ae70c19.js +0 -102
  129. package/__chunks__/Text-4ae50d5c.mjs +0 -103
  130. package/__chunks__/Theme-4e498252.mjs +0 -132
  131. package/__chunks__/Theme-751e5575.js +0 -131
  132. package/__chunks__/Tooltip-bd55165e.js +0 -317
  133. package/__chunks__/Tooltip-f7e67b21.mjs +0 -318
@@ -1,472 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
- import * as React from "react";
33
- import React__default, { useState } from "react";
34
- import { classNames, variationName } from "../utilities/css.mjs";
35
- import { T as Text } from "./Text-4ae50d5c.mjs";
36
- import { I as Icon } from "./Icon-a75b5201.mjs";
37
- import { U as UnstyledButton } from "./UnstyledButton-883f0c6c.mjs";
38
- import { a as $65484d02dcb7eb3e$export$457c3d6518dd4c6f, $ as $3ef42575df84b30b$export$9d1611c77c2fe928 } from "./import-b7971a11.mjs";
39
- import { $ as $2baaea4c71418dea$export$294aa081a6c6f55d } from "./import-baa3cd0c.mjs";
40
- import { c as $e6afbd83fe6ebbd2$export$4c014de7c8940b4c, a as $6179b936705e76d3$export$ae780daf29e6d456 } from "./import-ab878fb6.mjs";
41
- function $2d73ec29415bd339$export$712718f7aec83d5(props, ref) {
42
- let { inputElementType = "input", isDisabled = false, isRequired = false, isReadOnly = false, validationState, type = "text", onChange = () => {
43
- } } = props;
44
- let { focusableProps } = $e6afbd83fe6ebbd2$export$4c014de7c8940b4c(props, ref);
45
- let { labelProps, fieldProps, descriptionProps, errorMessageProps } = $2baaea4c71418dea$export$294aa081a6c6f55d(props);
46
- let domProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
47
- labelable: true
48
- });
49
- const inputOnlyProps = {
50
- type,
51
- pattern: props.pattern
52
- };
53
- return {
54
- labelProps,
55
- inputProps: $3ef42575df84b30b$export$9d1611c77c2fe928(domProps, inputElementType === "input" && inputOnlyProps, __spreadValues(__spreadValues({
56
- disabled: isDisabled,
57
- readOnly: isReadOnly,
58
- "aria-required": isRequired || void 0,
59
- "aria-invalid": validationState === "invalid" || void 0,
60
- "aria-errormessage": props["aria-errormessage"],
61
- "aria-activedescendant": props["aria-activedescendant"],
62
- "aria-autocomplete": props["aria-autocomplete"],
63
- "aria-haspopup": props["aria-haspopup"],
64
- value: props.value,
65
- defaultValue: props.value ? void 0 : props.defaultValue,
66
- onChange: (e) => onChange(e.target.value),
67
- autoComplete: props.autoComplete,
68
- maxLength: props.maxLength,
69
- minLength: props.minLength,
70
- name: props.name,
71
- placeholder: props.placeholder,
72
- inputMode: props.inputMode,
73
- // Clipboard events
74
- onCopy: props.onCopy,
75
- onCut: props.onCut,
76
- onPaste: props.onPaste,
77
- // Composition events
78
- onCompositionEnd: props.onCompositionEnd,
79
- onCompositionStart: props.onCompositionStart,
80
- onCompositionUpdate: props.onCompositionUpdate,
81
- // Selection events
82
- onSelect: props.onSelect,
83
- // Input events
84
- onBeforeInput: props.onBeforeInput,
85
- onInput: props.onInput
86
- }, focusableProps), fieldProps)),
87
- descriptionProps,
88
- errorMessageProps
89
- };
90
- }
91
- const root = "_root_1rp7g_5";
92
- const inputIconContainer = "_inputIconContainer_1rp7g_25";
93
- const label = "_label_1rp7g_31";
94
- const labelHidden = "_labelHidden_1rp7g_35";
95
- const input = "_input_1rp7g_25";
96
- const errorInput = "_errorInput_1rp7g_73";
97
- const inputSizeSm = "_inputSizeSm_1rp7g_81";
98
- const inputSizeLg = "_inputSizeLg_1rp7g_95";
99
- const passwordInput = "_passwordInput_1rp7g_103";
100
- const passwordBtn = "_passwordBtn_1rp7g_113";
101
- const hovered = "_hovered_1rp7g_144";
102
- const textArea = "_textArea_1rp7g_153";
103
- const passwordBtnError = "_passwordBtnError_1rp7g_158";
104
- const passwordBtnSm = "_passwordBtnSm_1rp7g_164";
105
- const passwordBtnLg = "_passwordBtnLg_1rp7g_173";
106
- const icon = "_icon_1rp7g_182";
107
- const iconDisabled = "_iconDisabled_1rp7g_192";
108
- const iconStart = "_iconStart_1rp7g_196";
109
- const iconEnd = "_iconEnd_1rp7g_200";
110
- const iconStartInput = "_iconStartInput_1rp7g_204";
111
- const iconEndInput = "_iconEndInput_1rp7g_208";
112
- const inputIconPlacementSm = "_inputIconPlacementSm_1rp7g_212";
113
- const inputIconPlacementLg = "_inputIconPlacementLg_1rp7g_216";
114
- const caption = "_caption_1rp7g_220";
115
- const styles = {
116
- root,
117
- inputIconContainer,
118
- label,
119
- labelHidden,
120
- input,
121
- errorInput,
122
- inputSizeSm,
123
- inputSizeLg,
124
- passwordInput,
125
- passwordBtn,
126
- hovered,
127
- textArea,
128
- passwordBtnError,
129
- passwordBtnSm,
130
- passwordBtnLg,
131
- icon,
132
- iconDisabled,
133
- iconStart,
134
- iconEnd,
135
- iconStartInput,
136
- iconEndInput,
137
- inputIconPlacementSm,
138
- inputIconPlacementLg,
139
- caption
140
- };
141
- function Label(props) {
142
- const _a = props, {
143
- isLabelVisuallyHidden = false,
144
- isLabelEmphasized = false,
145
- inputSize = "md",
146
- hasError = false,
147
- children
148
- } = _a, labelProps = __objRest(_a, [
149
- "isLabelVisuallyHidden",
150
- "isLabelEmphasized",
151
- "inputSize",
152
- "hasError",
153
- "children"
154
- ]);
155
- const textVariant = isLabelEmphasized ? "subtitle1" : inputSize === "sm" ? "body2" : "body1";
156
- const as = isLabelEmphasized ? "strong" : "span";
157
- const color = hasError ? "danger" : void 0;
158
- return /* @__PURE__ */ React__default.createElement(
159
- "label",
160
- __spreadProps(__spreadValues({}, labelProps), {
161
- className: classNames(
162
- styles.label,
163
- isLabelVisuallyHidden && styles.labelHidden
164
- )
165
- }),
166
- /* @__PURE__ */ React__default.createElement(
167
- Text,
168
- {
169
- variant: textVariant,
170
- as,
171
- color,
172
- visuallyHidden: isLabelVisuallyHidden
173
- },
174
- children
175
- )
176
- );
177
- }
178
- function InputCaption(props) {
179
- const _a = props, { variant, children } = _a, captionTextProps = __objRest(_a, ["variant", "children"]);
180
- return /* @__PURE__ */ React__default.createElement("div", __spreadProps(__spreadValues({}, captionTextProps), { className: styles.caption }), /* @__PURE__ */ React__default.createElement(
181
- Text,
182
- {
183
- variant: "caption",
184
- color: variant === "helper" ? "subdued" : "danger"
185
- },
186
- children
187
- ));
188
- }
189
- var __defProp$1 = Object.defineProperty;
190
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
191
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
192
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
193
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
194
- var __spreadValues$1 = (a, b) => {
195
- for (var prop in b || (b = {}))
196
- if (__hasOwnProp$1.call(b, prop))
197
- __defNormalProp$1(a, prop, b[prop]);
198
- if (__getOwnPropSymbols$1)
199
- for (var prop of __getOwnPropSymbols$1(b)) {
200
- if (__propIsEnum$1.call(b, prop))
201
- __defNormalProp$1(a, prop, b[prop]);
202
- }
203
- return a;
204
- };
205
- var __objRest$1 = (source, exclude) => {
206
- var target = {};
207
- for (var prop in source)
208
- if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
209
- target[prop] = source[prop];
210
- if (source != null && __getOwnPropSymbols$1)
211
- for (var prop of __getOwnPropSymbols$1(source)) {
212
- if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
213
- target[prop] = source[prop];
214
- }
215
- return target;
216
- };
217
- const Visibility = (_a) => {
218
- var _b = _a, {
219
- title,
220
- titleId
221
- } = _b, props = __objRest$1(_b, [
222
- "title",
223
- "titleId"
224
- ]);
225
- return /* @__PURE__ */ React.createElement("svg", __spreadValues$1({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 -960 960 960", "aria-labelledby": titleId }, props), title ? /* @__PURE__ */ React.createElement("title", { id: titleId }, title) : null, /* @__PURE__ */ React.createElement("path", { d: "M480.208-344.232q64.638 0 110.099-45.669 45.461-45.67 45.461-110.307 0-64.638-45.669-110.099-45.67-45.461-110.307-45.461-64.638 0-110.099 45.669-45.461 45.67-45.461 110.307 0 64.638 45.669 110.099 45.67 45.461 110.307 45.461Zm-.511-44.922q-46.312 0-78.428-32.418-32.115-32.419-32.115-78.731t32.418-78.428q32.419-32.115 78.731-32.115t78.428 32.418q32.115 32.419 32.115 78.731t-32.418 78.428q-32.419 32.115-78.731 32.115Zm.358 169.153q-137.593 0-249.823-77.038Q118.001-374.078 61.54-500q56.461-125.922 168.637-202.961 112.175-77.038 249.768-77.038 137.593 0 249.823 77.038Q841.999-625.922 898.46-500q-56.461 125.922-168.637 202.961-112.175 77.038-249.768 77.038ZM480-500Zm-.169 234.615q119.246 0 218.823-63.769Q798.23-392.923 850.461-500 798.23-607.077 698.822-670.846q-99.408-63.769-218.653-63.769-119.246 0-218.823 63.769Q161.77-607.077 108.924-500q52.846 107.077 152.254 170.846 99.408 63.769 218.653 63.769Z" }));
226
- };
227
- var __defProp2 = Object.defineProperty;
228
- var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
229
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
230
- var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
231
- var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
232
- var __spreadValues2 = (a, b) => {
233
- for (var prop in b || (b = {}))
234
- if (__hasOwnProp2.call(b, prop))
235
- __defNormalProp2(a, prop, b[prop]);
236
- if (__getOwnPropSymbols2)
237
- for (var prop of __getOwnPropSymbols2(b)) {
238
- if (__propIsEnum2.call(b, prop))
239
- __defNormalProp2(a, prop, b[prop]);
240
- }
241
- return a;
242
- };
243
- var __objRest2 = (source, exclude) => {
244
- var target = {};
245
- for (var prop in source)
246
- if (__hasOwnProp2.call(source, prop) && exclude.indexOf(prop) < 0)
247
- target[prop] = source[prop];
248
- if (source != null && __getOwnPropSymbols2)
249
- for (var prop of __getOwnPropSymbols2(source)) {
250
- if (exclude.indexOf(prop) < 0 && __propIsEnum2.call(source, prop))
251
- target[prop] = source[prop];
252
- }
253
- return target;
254
- };
255
- const VisibilityOff = (_a) => {
256
- var _b = _a, {
257
- title,
258
- titleId
259
- } = _b, props = __objRest2(_b, [
260
- "title",
261
- "titleId"
262
- ]);
263
- return /* @__PURE__ */ React.createElement("svg", __spreadValues2({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 -960 960 960", "aria-labelledby": titleId }, props), title ? /* @__PURE__ */ React.createElement("title", { id: titleId }, title) : null, /* @__PURE__ */ React.createElement("path", { d: "m620.153-434.386-34.768-34.768q21.384-67.539-28.539-111.461-49.923-43.923-107.692-24.77l-34.768-34.768q13.538-7.923 30.307-11.769T480-655.768q65.23 0 110.499 45.269Q635.768-565.23 635.768-500q0 18.538-4.154 35.999-4.153 17.462-11.461 29.615Zm127.846 126.692-31.153-29.999q45.923-34.077 80.692-75.884 34.769-41.808 52.923-86.423-50-108.307-148.461-171.461-98.462-63.154-214.693-63.154-38.538 0-78.114 7.038-39.577 7.039-65.346 16.885l-34.846-35.461q33.462-14.461 81.423-24.153 47.961-9.693 93.422-9.693 134.538 0 248.038 76.115Q845.383-627.769 898.46-500q-24.461 57.461-62.192 105.653-37.731 48.192-88.269 86.653Zm59.923 216.769-161.845-160q-30.769 13.616-74.384 22.27-43.616 8.654-91.693 8.654-137.538 0-250.768-76.115Q116.001-372.231 61.54-500q21.539-52.385 59.154-101.115 37.616-48.731 87.077-89.115L85.233-812.384l31.999-32.615L837.691-124.54l-29.769 33.615ZM238.77-658.231q-37.384 26.231-74.961 71-37.578 44.769-54.885 87.231 50.615 108.307 150.807 171.461 100.192 63.154 225.961 63.154 37.231 0 73.655-5.731 36.423-5.731 52.423-14.115l-70.924-70.924q-10.615 5.385-28.346 8.654t-32.5 3.269q-64.615 0-110.192-44.961Q324.232-434.154 324.232-500q0-15 3.269-31.923t8.654-28.923l-97.385-97.385ZM531.462-517Zm-105.999 53.384Z" }));
264
- };
265
- function mapIconSize(size) {
266
- if (size === "sm") {
267
- return "xs";
268
- } else if (size === "lg") {
269
- return "md";
270
- }
271
- return size;
272
- }
273
- function logWarningsForInvalidPropConfiguration(bothIconPropsDefined, smallSizeTextarea, definedIconsWithTextarea) {
274
- if (bothIconPropsDefined) {
275
- console.warn("Cannot simultaneously define `iconAtEnd` and `iconAtStart`");
276
- }
277
- if (smallSizeTextarea) {
278
- console.warn("`textarea` cannot be defined with size `sm`");
279
- }
280
- if (definedIconsWithTextarea) {
281
- console.warn("Cannot define `textarea` with `iconAtEnd` or `iconAtStart`");
282
- }
283
- }
284
- function getElementType(isMultiline) {
285
- return isMultiline ? "textarea" : "input";
286
- }
287
- function PasswordButton(props) {
288
- const {
289
- hasError = false,
290
- inputSize = "md",
291
- isDisabled = false,
292
- isPasswordVisible = false,
293
- toggleVisibility,
294
- isInputHovered = false
295
- } = props;
296
- return /* @__PURE__ */ React__default.createElement(
297
- UnstyledButton,
298
- {
299
- className: classNames(
300
- styles.passwordBtn,
301
- isInputHovered && styles.hovered,
302
- hasError && styles.passwordBtnError,
303
- styles[variationName("passwordBtn", inputSize)]
304
- ),
305
- onPress: toggleVisibility,
306
- isDisabled
307
- },
308
- /* @__PURE__ */ React__default.createElement(Text, { visuallyHidden: true }, "password visibility"),
309
- /* @__PURE__ */ React__default.createElement(
310
- Icon,
311
- {
312
- symbol: isPasswordVisible ? Visibility : VisibilityOff,
313
- size: mapIconSize(inputSize)
314
- }
315
- )
316
- );
317
- }
318
- function InputIcon(props) {
319
- const { alignment = "start", size = "md", isDisabled = false, icon: icon2 } = props;
320
- return /* @__PURE__ */ React__default.createElement(
321
- "div",
322
- {
323
- className: classNames(
324
- styles.icon,
325
- alignment === "start" ? styles.iconStart : styles.iconEnd,
326
- isDisabled && styles.iconDisabled,
327
- styles[variationName("inputIconPlacement", size)]
328
- )
329
- },
330
- /* @__PURE__ */ React__default.createElement(Icon, { symbol: icon2, size: mapIconSize(size) })
331
- );
332
- }
333
- function useInputField(props, ref) {
334
- const { isMultiline = false } = props;
335
- const {
336
- labelProps,
337
- inputProps,
338
- descriptionProps: helperTextProps,
339
- errorMessageProps: errorTextProps
340
- } = $2d73ec29415bd339$export$712718f7aec83d5(
341
- __spreadProps(__spreadValues({}, props), { inputElementType: getElementType(isMultiline) }),
342
- ref
343
- );
344
- let elementProps = {};
345
- if (isMultiline) {
346
- elementProps = inputProps;
347
- } else {
348
- elementProps = inputProps;
349
- }
350
- return {
351
- labelProps,
352
- elementProps,
353
- helperTextProps,
354
- errorTextProps
355
- };
356
- }
357
- function InputField(props) {
358
- const {
359
- isMultiline = false,
360
- type = "text",
361
- size = "md",
362
- isLabelVisuallyHidden = false,
363
- isDisabled = false,
364
- isRequired = false,
365
- validationState = "valid",
366
- isLabelEmphasized = false,
367
- autoFocus = false,
368
- label: label2,
369
- errorText,
370
- helperText,
371
- placeholder,
372
- value,
373
- defaultValue,
374
- iconAtStart,
375
- iconAtEnd,
376
- rows
377
- } = props;
378
- const [isPasswordVisible, setIsPasswordVisible] = useState(false);
379
- const ref = React__default.useRef(null);
380
- const { labelProps, elementProps, helperTextProps, errorTextProps } = useInputField(props, ref);
381
- const { isHovered: isInputHovered, hoverProps } = $6179b936705e76d3$export$ae780daf29e6d456(props);
382
- const Component = getElementType(isMultiline);
383
- const bothIconPropsDefined = !!iconAtEnd && !!iconAtStart;
384
- const smallSizeTextarea = size === "sm" && Component === "textarea";
385
- const definedIconsWithTextarea = (!!iconAtEnd || !!iconAtStart) && Component === "textarea";
386
- logWarningsForInvalidPropConfiguration(
387
- bothIconPropsDefined,
388
- smallSizeTextarea,
389
- definedIconsWithTextarea
390
- );
391
- const isPassword = type === "password";
392
- const hasError = validationState === "invalid";
393
- const showErrorText = hasError && errorText;
394
- const showHelperText = !showErrorText && helperText;
395
- const canUseIcon = !bothIconPropsDefined && !isPassword && !definedIconsWithTextarea;
396
- const hasStartIcon = canUseIcon && iconAtStart;
397
- const hasEndIcon = canUseIcon && iconAtEnd;
398
- const isTypeAdjustedForPasswordVisibility = isPassword && isPasswordVisible;
399
- const captionProps = showHelperText ? helperTextProps : errorTextProps;
400
- const captionText = showHelperText ? helperText : errorText;
401
- const adjustedSize = smallSizeTextarea ? "md" : size;
402
- const className = classNames(
403
- styles.input,
404
- isInputHovered && styles.hovered,
405
- Component === "textarea" && styles.textArea,
406
- isPassword && styles.passwordInput,
407
- hasError && styles.errorInput,
408
- hasStartIcon && styles.iconStartInput,
409
- hasEndIcon && styles.iconEndInput,
410
- styles[variationName("inputSize", adjustedSize)]
411
- );
412
- const inputType = Component === "textarea" ? void 0 : isTypeAdjustedForPasswordVisibility ? "text" : type;
413
- return /* @__PURE__ */ React__default.createElement("div", { className: classNames(styles.root) }, /* @__PURE__ */ React__default.createElement(
414
- Label,
415
- __spreadValues({
416
- isLabelVisuallyHidden,
417
- inputSize: adjustedSize,
418
- hasError,
419
- isLabelEmphasized
420
- }, labelProps),
421
- label2
422
- ), /* @__PURE__ */ React__default.createElement("div", { className: styles.inputIconContainer }, hasStartIcon && /* @__PURE__ */ React__default.createElement(
423
- InputIcon,
424
- {
425
- alignment: "start",
426
- size: adjustedSize,
427
- isDisabled,
428
- icon: iconAtStart
429
- }
430
- ), /* @__PURE__ */ React__default.createElement(
431
- Component,
432
- __spreadProps(__spreadValues(__spreadValues({}, elementProps), hoverProps), {
433
- className,
434
- ref,
435
- type: inputType,
436
- value,
437
- required: isRequired,
438
- disabled: isDisabled,
439
- placeholder,
440
- autoFocus,
441
- defaultValue,
442
- rows: Component === "textarea" ? rows : void 0
443
- })
444
- ), isPassword ? /* @__PURE__ */ React__default.createElement(
445
- PasswordButton,
446
- {
447
- isInputHovered,
448
- hasError,
449
- inputSize: adjustedSize,
450
- isDisabled,
451
- isPasswordVisible,
452
- toggleVisibility: () => setIsPasswordVisible((prevVisibility) => !prevVisibility)
453
- }
454
- ) : hasEndIcon && /* @__PURE__ */ React__default.createElement(
455
- InputIcon,
456
- {
457
- alignment: "end",
458
- size: adjustedSize,
459
- isDisabled,
460
- icon: iconAtEnd
461
- }
462
- )), (showErrorText || showHelperText) && /* @__PURE__ */ React__default.createElement(
463
- InputCaption,
464
- __spreadValues({
465
- variant: showHelperText ? "helper" : "error"
466
- }, captionProps),
467
- captionText
468
- ));
469
- }
470
- export {
471
- InputField as I
472
- };