@adam-milo/ui 1.0.22 → 1.0.24

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 (154) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.js +18 -9
  3. package/dist/index10.cjs +1 -1
  4. package/dist/index10.js +53 -59
  5. package/dist/index11.cjs +1 -1
  6. package/dist/index11.js +50 -104
  7. package/dist/index12.cjs +1 -1
  8. package/dist/index12.js +108 -76
  9. package/dist/index13.cjs +1 -1
  10. package/dist/index13.js +77 -26
  11. package/dist/index14.cjs +1 -1
  12. package/dist/index14.js +22 -462
  13. package/dist/index15.cjs +1 -1
  14. package/dist/index15.js +466 -109
  15. package/dist/index16.cjs +1 -1
  16. package/dist/index16.js +111 -30
  17. package/dist/index17.cjs +1 -1
  18. package/dist/index17.js +42 -12
  19. package/dist/index18.cjs +1 -0
  20. package/dist/index18.js +14 -0
  21. package/dist/index2.cjs +1 -1
  22. package/dist/index2.js +1 -1
  23. package/dist/index20.cjs +1 -1
  24. package/dist/index20.js +20 -299
  25. package/dist/index21.cjs +1 -1
  26. package/dist/index21.js +298 -13
  27. package/dist/index22.cjs +1 -0
  28. package/dist/index22.js +16 -0
  29. package/dist/index25.cjs +1 -0
  30. package/dist/index25.js +1193 -0
  31. package/dist/index3.cjs +1 -1
  32. package/dist/index3.js +2 -2
  33. package/dist/index33.cjs +1 -1
  34. package/dist/index33.js +7 -19
  35. package/dist/index36.cjs +1 -0
  36. package/dist/index36.js +21 -0
  37. package/dist/index38.cjs +1 -0
  38. package/dist/index38.js +6 -0
  39. package/dist/index39.cjs +1 -0
  40. package/dist/index39.js +11 -0
  41. package/dist/index4.cjs +1 -1
  42. package/dist/index4.js +1 -1
  43. package/dist/index40.cjs +1 -0
  44. package/dist/index40.js +70 -0
  45. package/dist/index41.cjs +1 -0
  46. package/dist/index41.js +39 -0
  47. package/dist/index42.cjs +1 -0
  48. package/dist/index42.js +64 -0
  49. package/dist/index43.cjs +1 -0
  50. package/dist/index43.js +10 -0
  51. package/dist/index44.cjs +1 -0
  52. package/dist/index44.js +212 -0
  53. package/dist/index45.cjs +1 -0
  54. package/dist/index45.js +29 -0
  55. package/dist/index46.cjs +1 -0
  56. package/dist/index46.js +208 -0
  57. package/dist/index47.cjs +1 -0
  58. package/dist/index47.js +14 -0
  59. package/dist/index48.cjs +1 -0
  60. package/dist/index48.js +293 -0
  61. package/dist/index49.cjs +1 -0
  62. package/dist/index49.js +18 -0
  63. package/dist/index5.cjs +1 -1
  64. package/dist/index5.js +1 -1
  65. package/dist/index50.cjs +1 -0
  66. package/dist/index50.js +43 -0
  67. package/dist/index51.cjs +1 -0
  68. package/dist/index51.js +89 -0
  69. package/dist/index52.cjs +1 -0
  70. package/dist/index52.js +14 -0
  71. package/dist/index53.cjs +1 -0
  72. package/dist/index53.js +71 -0
  73. package/dist/index54.cjs +1 -0
  74. package/dist/index54.js +6 -0
  75. package/dist/index55.cjs +1 -0
  76. package/dist/index55.js +14 -0
  77. package/dist/index56.cjs +1 -0
  78. package/dist/index56.js +34 -0
  79. package/dist/index57.cjs +1 -0
  80. package/dist/index57.js +122 -0
  81. package/dist/index58.cjs +1 -0
  82. package/dist/index58.js +11 -0
  83. package/dist/index59.cjs +1 -0
  84. package/dist/index59.js +17 -0
  85. package/dist/index6.cjs +1 -1
  86. package/dist/index6.js +2 -2
  87. package/dist/index60.cjs +1 -0
  88. package/dist/index60.js +297 -0
  89. package/dist/index61.cjs +1 -0
  90. package/dist/index61.js +25 -0
  91. package/dist/index62.cjs +1 -0
  92. package/dist/index62.js +39 -0
  93. package/dist/index63.cjs +1 -0
  94. package/dist/index63.js +625 -0
  95. package/dist/index64.cjs +1 -0
  96. package/dist/index64.js +39 -0
  97. package/dist/index65.cjs +1 -0
  98. package/dist/index65.js +38 -0
  99. package/dist/index66.cjs +1 -0
  100. package/dist/index66.js +7 -0
  101. package/dist/index67.cjs +1 -0
  102. package/dist/index67.js +10 -0
  103. package/dist/index68.cjs +1 -0
  104. package/dist/index68.js +5 -0
  105. package/dist/index69.cjs +1 -0
  106. package/dist/index69.js +35 -0
  107. package/dist/index7.cjs +1 -1
  108. package/dist/index7.js +1 -1
  109. package/dist/index70.cjs +1 -0
  110. package/dist/index70.js +180 -0
  111. package/dist/index71.cjs +1 -0
  112. package/dist/index71.js +21 -0
  113. package/dist/index72.cjs +1 -0
  114. package/dist/index72.js +721 -0
  115. package/dist/index73.cjs +1 -0
  116. package/dist/index73.js +154 -0
  117. package/dist/index74.cjs +1 -0
  118. package/dist/index74.js +173 -0
  119. package/dist/index75.cjs +1 -0
  120. package/dist/index75.js +88 -0
  121. package/dist/index76.cjs +1 -0
  122. package/dist/index76.js +47 -0
  123. package/dist/index77.cjs +1 -0
  124. package/dist/index77.js +13 -0
  125. package/dist/index78.cjs +1 -0
  126. package/dist/index78.js +19 -0
  127. package/dist/index79.cjs +1 -0
  128. package/dist/index79.js +102 -0
  129. package/dist/index8.cjs +1 -1
  130. package/dist/index8.js +1 -1
  131. package/dist/index80.cjs +1 -0
  132. package/dist/index80.js +11 -0
  133. package/dist/index81.cjs +1 -0
  134. package/dist/index81.js +29 -0
  135. package/dist/index82.cjs +1 -0
  136. package/dist/index82.js +16 -0
  137. package/dist/index83.cjs +1 -0
  138. package/dist/index83.js +48 -0
  139. package/dist/index84.cjs +1 -0
  140. package/dist/index84.js +9 -0
  141. package/dist/index85.cjs +1 -0
  142. package/dist/index85.js +37 -0
  143. package/dist/index9.cjs +1 -1
  144. package/dist/index9.js +224 -35
  145. package/dist/src/components/forms/select/Select.component.d.ts +100 -0
  146. package/dist/src/components/forms/select/Select.component.d.ts.map +1 -0
  147. package/dist/src/index.d.ts +2 -0
  148. package/dist/src/index.d.ts.map +1 -1
  149. package/dist/style.css +1 -1
  150. package/package.json +2 -1
  151. package/dist/index19.cjs +0 -1
  152. package/dist/index19.js +0 -22
  153. package/dist/index30.cjs +0 -1
  154. package/dist/index30.js +0 -9
package/dist/index21.js CHANGED
@@ -1,16 +1,301 @@
1
- import { useCallback } from "react";
2
- function useMergedRef(...refs) {
3
- return useCallback((element) => {
4
- refs.forEach((ref) => {
5
- if (!ref) return;
6
- if (typeof ref === "function") {
7
- ref(element);
8
- } else {
9
- ref.current = element;
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useState, useRef, useId, useMemo, useEffect } from "react";
3
+ import { cn } from "./index18.js";
4
+ /* empty css */
5
+ import { useMergedRef } from "./index22.js";
6
+ import { debounce } from "./index36.js";
7
+ const Input = forwardRef(
8
+ ({
9
+ type = "text",
10
+ label,
11
+ error: externalError,
12
+ helperText,
13
+ fullWidth = false,
14
+ showPasswordToggle = true,
15
+ showLastChar = true,
16
+ lastCharDelay = 500,
17
+ validate,
18
+ onValidationChange,
19
+ className,
20
+ id: providedId,
21
+ onChange,
22
+ onBlur,
23
+ required,
24
+ value: controlledValue,
25
+ "data-cy": dataCy,
26
+ "data-testid": dataTestId,
27
+ ...props
28
+ }, ref) => {
29
+ const [isPasswordVisible, setIsPasswordVisible] = useState(false);
30
+ const [internalError, setInternalError] = useState();
31
+ const [isFocused, setIsFocused] = useState(false);
32
+ const [isHovered, setIsHovered] = useState(false);
33
+ const touchedRef = useRef(false);
34
+ const [displayPassword, setDisplayPassword] = useState("");
35
+ const actualPasswordRef = useRef("");
36
+ const timeoutRef = useRef(null);
37
+ const inputRef = useRef(null);
38
+ const mergedRef = useMergedRef(ref, inputRef);
39
+ const generatedId = useId();
40
+ const id = providedId || generatedId;
41
+ const errorId = `${id}-error`;
42
+ const helperId = `${id}-helper`;
43
+ const finalDataCy = dataCy || "input";
44
+ const finalTestId = dataTestId || "input";
45
+ const isPasswordType = type === "password";
46
+ const showToggle = isPasswordType && showPasswordToggle;
47
+ const shouldEnableLastCharPreview = isPasswordType && showLastChar && !isPasswordVisible;
48
+ const inputType = isPasswordType && (isPasswordVisible || shouldEnableLastCharPreview && actualPasswordRef.current.length > 0) ? "text" : type;
49
+ const displayLabel = label && required && !label.includes("*") ? `${label} *` : label;
50
+ const togglePasswordVisibility = () => {
51
+ setIsPasswordVisible((prev) => !prev);
52
+ setTimeout(() => {
53
+ var _a;
54
+ return (_a = inputRef.current) == null ? void 0 : _a.focus();
55
+ }, 0);
56
+ };
57
+ const debouncedValidate = useMemo(
58
+ () => debounce((value) => {
59
+ if (validate && touchedRef.current) {
60
+ const validationError = validate(value);
61
+ setInternalError(validationError);
62
+ onValidationChange == null ? void 0 : onValidationChange(!validationError);
63
+ }
64
+ }, 300),
65
+ [validate, onValidationChange]
66
+ );
67
+ const debouncedValidateRef = useRef(debouncedValidate);
68
+ useEffect(() => {
69
+ debouncedValidateRef.current = debouncedValidate;
70
+ }, [debouncedValidate]);
71
+ useEffect(() => {
72
+ if (process.env.NODE_ENV === "development") {
73
+ if (isPasswordType && showLastChar && controlledValue !== void 0) {
74
+ console.warn(
75
+ "[Input] Password last character preview (showLastChar) only works in uncontrolled mode. Remove the value prop to use this feature, or set showLastChar={false}."
76
+ );
77
+ }
10
78
  }
11
- });
12
- }, refs);
13
- }
79
+ }, [isPasswordType, showLastChar, controlledValue]);
80
+ useEffect(() => {
81
+ return () => {
82
+ if (timeoutRef.current) {
83
+ clearTimeout(timeoutRef.current);
84
+ }
85
+ debouncedValidateRef.current.cancel();
86
+ };
87
+ }, []);
88
+ const inputValue = shouldEnableLastCharPreview && controlledValue === void 0 ? displayPassword : isPasswordVisible && isPasswordType && controlledValue === void 0 ? actualPasswordRef.current || "" : controlledValue;
89
+ const handleChange = (e) => {
90
+ onChange == null ? void 0 : onChange(e);
91
+ let value = e.target.value;
92
+ if (shouldEnableLastCharPreview) {
93
+ const input = e.target;
94
+ const newValue = input.value;
95
+ actualPasswordRef.current = newValue;
96
+ const masked = newValue ? "•".repeat(newValue.length - 1) + newValue.slice(-1) : "";
97
+ setDisplayPassword(masked);
98
+ input.value = masked;
99
+ value = newValue;
100
+ if (timeoutRef.current) {
101
+ clearTimeout(timeoutRef.current);
102
+ }
103
+ timeoutRef.current = setTimeout(() => {
104
+ setDisplayPassword("•".repeat(newValue.length));
105
+ }, lastCharDelay);
106
+ }
107
+ if (touchedRef.current) {
108
+ debouncedValidate(value);
109
+ }
110
+ };
111
+ const handleFocus = (e) => {
112
+ var _a;
113
+ setIsFocused(true);
114
+ (_a = props.onFocus) == null ? void 0 : _a.call(props, e);
115
+ };
116
+ const handleBlur = (e) => {
117
+ setIsFocused(false);
118
+ touchedRef.current = true;
119
+ if (validate) {
120
+ const valueToValidate = shouldEnableLastCharPreview ? actualPasswordRef.current : e.target.value;
121
+ const validationError = validate(valueToValidate);
122
+ setInternalError(validationError);
123
+ onValidationChange == null ? void 0 : onValidationChange(!validationError);
124
+ }
125
+ onBlur == null ? void 0 : onBlur(e);
126
+ };
127
+ const handleMouseEnter = () => {
128
+ setIsHovered(true);
129
+ };
130
+ const handleMouseLeave = () => {
131
+ setIsHovered(false);
132
+ };
133
+ const displayError = externalError || internalError;
134
+ const inputState = props.disabled ? "disabled" : displayError ? "error" : isFocused ? "focus" : isHovered ? "hover" : "idle";
135
+ return /* @__PURE__ */ jsxs(
136
+ "div",
137
+ {
138
+ className: cn("input-wrapper", fullWidth && "input-wrapper--full-width"),
139
+ "data-cy": `${finalDataCy}-wrapper`,
140
+ "data-testid": `${finalTestId}-wrapper`,
141
+ children: [
142
+ label && /* @__PURE__ */ jsx(
143
+ "label",
144
+ {
145
+ htmlFor: id,
146
+ className: "input__label",
147
+ "data-cy": `${finalDataCy}-label`,
148
+ "data-testid": `${finalTestId}-label`,
149
+ children: displayLabel
150
+ }
151
+ ),
152
+ /* @__PURE__ */ jsxs("div", { className: "input__field-container", children: [
153
+ /* @__PURE__ */ jsx(
154
+ "input",
155
+ {
156
+ ref: mergedRef,
157
+ id,
158
+ type: inputType,
159
+ value: inputValue,
160
+ className: cn(
161
+ "input",
162
+ displayError && "input--error",
163
+ fullWidth && "input--full-width",
164
+ showToggle && "input--with-toggle",
165
+ className
166
+ ),
167
+ "aria-invalid": displayError ? "true" : "false",
168
+ "aria-required": required ? "true" : void 0,
169
+ "aria-describedby": displayError ? errorId : helperText ? helperId : void 0,
170
+ "data-cy": finalDataCy,
171
+ "data-testid": finalTestId,
172
+ "data-state": inputState,
173
+ onChange: handleChange,
174
+ onFocus: handleFocus,
175
+ onBlur: handleBlur,
176
+ onMouseEnter: handleMouseEnter,
177
+ onMouseLeave: handleMouseLeave,
178
+ required,
179
+ ...props
180
+ }
181
+ ),
182
+ showToggle && /* @__PURE__ */ jsx(
183
+ "button",
184
+ {
185
+ type: "button",
186
+ className: "input__toggle",
187
+ onClick: togglePasswordVisibility,
188
+ "aria-label": isPasswordVisible ? "Hide password" : "Show password",
189
+ "data-cy": `${finalDataCy}-toggle`,
190
+ "data-testid": `${finalTestId}-toggle`,
191
+ children: isPasswordVisible ? /* @__PURE__ */ jsxs(
192
+ "svg",
193
+ {
194
+ width: "20",
195
+ height: "20",
196
+ viewBox: "0 0 20 20",
197
+ fill: "none",
198
+ xmlns: "http://www.w3.org/2000/svg",
199
+ "aria-hidden": "true",
200
+ children: [
201
+ /* @__PURE__ */ jsx(
202
+ "path",
203
+ {
204
+ d: "M10 4C5.5 4 2 10 2 10s3.5 6 8 6 8-6 8-6-3.5-6-8-6z",
205
+ stroke: "currentColor",
206
+ strokeWidth: "1.5",
207
+ strokeLinecap: "round",
208
+ strokeLinejoin: "round",
209
+ fill: "none"
210
+ }
211
+ ),
212
+ /* @__PURE__ */ jsx(
213
+ "circle",
214
+ {
215
+ cx: "10",
216
+ cy: "10",
217
+ r: "2.5",
218
+ stroke: "currentColor",
219
+ strokeWidth: "1.5",
220
+ fill: "none"
221
+ }
222
+ )
223
+ ]
224
+ }
225
+ ) : /* @__PURE__ */ jsxs(
226
+ "svg",
227
+ {
228
+ width: "20",
229
+ height: "20",
230
+ viewBox: "0 0 20 20",
231
+ fill: "none",
232
+ xmlns: "http://www.w3.org/2000/svg",
233
+ "aria-hidden": "true",
234
+ children: [
235
+ /* @__PURE__ */ jsx(
236
+ "path",
237
+ {
238
+ d: "M10 4C5.5 4 2 10 2 10s3.5 6 8 6 8-6 8-6-3.5-6-8-6z",
239
+ stroke: "currentColor",
240
+ strokeWidth: "1.5",
241
+ strokeLinecap: "round",
242
+ strokeLinejoin: "round",
243
+ fill: "none"
244
+ }
245
+ ),
246
+ /* @__PURE__ */ jsx(
247
+ "circle",
248
+ {
249
+ cx: "10",
250
+ cy: "10",
251
+ r: "2.5",
252
+ stroke: "currentColor",
253
+ strokeWidth: "1.5",
254
+ fill: "none"
255
+ }
256
+ ),
257
+ /* @__PURE__ */ jsx(
258
+ "path",
259
+ {
260
+ d: "M3 3l14 14",
261
+ stroke: "currentColor",
262
+ strokeWidth: "1.5",
263
+ strokeLinecap: "round"
264
+ }
265
+ )
266
+ ]
267
+ }
268
+ )
269
+ }
270
+ )
271
+ ] }),
272
+ displayError && /* @__PURE__ */ jsx(
273
+ "span",
274
+ {
275
+ id: errorId,
276
+ className: "input__error",
277
+ role: "alert",
278
+ "data-cy": `${finalDataCy}-error`,
279
+ "data-testid": `${finalTestId}-error`,
280
+ children: displayError
281
+ }
282
+ ),
283
+ helperText && !displayError && /* @__PURE__ */ jsx(
284
+ "span",
285
+ {
286
+ id: helperId,
287
+ className: "input__helper",
288
+ "data-cy": `${finalDataCy}-helper`,
289
+ "data-testid": `${finalTestId}-helper`,
290
+ children: helperText
291
+ }
292
+ )
293
+ ]
294
+ }
295
+ );
296
+ }
297
+ );
298
+ Input.displayName = "Input";
14
299
  export {
15
- useMergedRef
300
+ Input
16
301
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react");exports.useMergedRef=function(...r){return e.useCallback(e=>{r.forEach(r=>{r&&("function"==typeof r?r(e):r.current=e)})},r)};
@@ -0,0 +1,16 @@
1
+ import { useCallback } from "react";
2
+ function useMergedRef(...refs) {
3
+ return useCallback((element) => {
4
+ refs.forEach((ref) => {
5
+ if (!ref) return;
6
+ if (typeof ref === "function") {
7
+ ref(element);
8
+ } else {
9
+ ref.current = element;
10
+ }
11
+ });
12
+ }, refs);
13
+ }
14
+ export {
15
+ useMergedRef
16
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("react-dom"),o=require("./index38.cjs"),r=require("./index39.cjs"),n=require("./index40.cjs"),l=require("./index41.cjs"),s=require("./index42.cjs"),i=require("./index43.cjs"),a=require("./index44.cjs"),c=require("./index45.cjs"),d=require("./index46.cjs"),u=require("./index47.cjs"),p=require("./index48.cjs"),f=require("./index49.cjs"),v=require("./index50.cjs"),m=require("./index51.cjs"),h=require("./index52.cjs"),x=require("./index53.cjs"),g=require("./index54.cjs"),w=require("./index55.cjs"),S=require("./index56.cjs"),y=require("./index57.cjs"),b=require("./index58.cjs"),C=require("react/jsx-runtime");function j(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const o in e)if("default"!==o){const r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:()=>e[o]})}return t.default=e,Object.freeze(t)}const P=j(e),E=j(t);var R=[" ","Enter","ArrowUp","ArrowDown"],I=[" ","Enter"],T="Select",[_,D,k]=n.createCollection(T),[H]=s.createContextScope(T,[k,p.createPopperScope]),L=p.createPopperScope(),[N,O]=H(T),[q,M]=H(T),A=e=>{const{__scopeSelect:t,children:o,open:r,defaultOpen:n,onOpenChange:l,value:s,defaultValue:a,onValueChange:c,dir:d,name:f,autoComplete:v,disabled:m,required:h,form:g}=e,w=L(t),[S,y]=P.useState(null),[b,j]=P.useState(null),[E,R]=P.useState(!1),I=i.useDirection(d),[D,k]=x.useControllableState({prop:r,defaultProp:n??!1,onChange:l,caller:T}),[H,O]=x.useControllableState({prop:s,defaultProp:a,onChange:c,caller:T}),M=P.useRef(null),A=!S||(g||!!S.closest("form")),[V,B]=P.useState(new Set),F=Array.from(V).map(e=>e.props.value).join(";");return C.jsx(p.Root,{...w,children:C.jsxs(N,{required:h,scope:t,trigger:S,onTriggerChange:y,valueNode:b,onValueNodeChange:j,valueNodeHasChildren:E,onValueNodeHasChildrenChange:R,contentId:u.useId(),value:H,onValueChange:O,open:D,onOpenChange:k,dir:I,triggerPointerDownPosRef:M,disabled:m,children:[C.jsx(_.Provider,{scope:t,children:C.jsx(q,{scope:e.__scopeSelect,onNativeOptionAdd:P.useCallback(e=>{B(t=>new Set(t).add(e))},[]),onNativeOptionRemove:P.useCallback(e=>{B(t=>{const o=new Set(t);return o.delete(e),o})},[]),children:o})}),A?C.jsxs(Re,{"aria-hidden":!0,required:h,tabIndex:-1,name:f,autoComplete:v,value:H,onChange:e=>O(e.target.value),disabled:m,form:g,children:[void 0===H?C.jsx("option",{value:""}):null,Array.from(V)]},F):null]})})};A.displayName=T;var V="SelectTrigger",B=P.forwardRef((e,t)=>{const{__scopeSelect:o,disabled:n=!1,...s}=e,i=L(o),a=O(V,o),c=a.disabled||n,d=l.useComposedRefs(t,a.onTriggerChange),u=D(o),f=P.useRef("touch"),[m,h,x]=Te(e=>{const t=u().filter(e=>!e.disabled),o=t.find(e=>e.value===a.value),r=_e(t,e,o);void 0!==r&&a.onValueChange(r.value)}),g=e=>{c||(a.onOpenChange(!0),x()),e&&(a.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return C.jsx(p.Anchor,{asChild:!0,...i,children:C.jsx(v.Primitive.button,{type:"button",role:"combobox","aria-controls":a.contentId,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":Ie(a.value)?"":void 0,...s,ref:d,onClick:r.composeEventHandlers(s.onClick,e=>{e.currentTarget.focus(),"mouse"!==f.current&&g(e)}),onPointerDown:r.composeEventHandlers(s.onPointerDown,e=>{f.current=e.pointerType;const t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(g(e),e.preventDefault())}),onKeyDown:r.composeEventHandlers(s.onKeyDown,e=>{const t=""!==m.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||h(e.key),t&&" "===e.key||R.includes(e.key)&&(g(),e.preventDefault())})})})});B.displayName=V;var F="SelectValue",K=P.forwardRef((e,t)=>{const{__scopeSelect:o,className:r,style:n,children:s,placeholder:i="",...a}=e,c=O(F,o),{onValueNodeHasChildrenChange:d}=c,u=void 0!==s,p=l.useComposedRefs(t,c.onValueNodeChange);return g.useLayoutEffect(()=>{d(u)},[d,u]),C.jsx(v.Primitive.span,{...a,ref:p,style:{pointerEvents:"none"},children:Ie(c.value)?C.jsx(C.Fragment,{children:i}):s})});K.displayName=F;var W=P.forwardRef((e,t)=>{const{__scopeSelect:o,children:r,...n}=e;return C.jsx(v.Primitive.span,{"aria-hidden":!0,...n,ref:t,children:r||"▼"})});W.displayName="SelectIcon";var U=e=>C.jsx(f.Portal,{asChild:!0,...e});U.displayName="SelectPortal";var z="SelectContent",G=P.forwardRef((e,t)=>{const o=O(z,e.__scopeSelect),[r,n]=P.useState();if(g.useLayoutEffect(()=>{n(new DocumentFragment)},[]),!o.open){const t=r;return t?E.createPortal(C.jsx(X,{scope:e.__scopeSelect,children:C.jsx(_.Slot,{scope:e.__scopeSelect,children:C.jsx("div",{children:e.children})})}),t):null}return C.jsx(J,{...e,ref:t})});G.displayName=z;var Y=10,[X,Z]=H(z),$=m.createSlot("SelectContent.RemoveScroll"),J=P.forwardRef((e,t)=>{const{__scopeSelect:o,position:n="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:i,onPointerDownOutside:u,side:p,sideOffset:f,align:v,alignOffset:m,arrowPadding:h,collisionBoundary:x,collisionPadding:g,sticky:w,hideWhenDetached:S,avoidCollisions:j,...E}=e,R=O(z,o),[I,T]=P.useState(null),[_,k]=P.useState(null),H=l.useComposedRefs(t,e=>T(e)),[L,N]=P.useState(null),[q,M]=P.useState(null),A=D(o),[V,B]=P.useState(!1),F=P.useRef(!1);P.useEffect(()=>{if(I)return y.hideOthers(I)},[I]),c.useFocusGuards();const K=P.useCallback(e=>{const[t,...o]=A().map(e=>e.ref.current),[r]=o.slice(-1),n=document.activeElement;for(const l of e){if(l===n)return;if(null==l||l.scrollIntoView({block:"nearest"}),l===t&&_&&(_.scrollTop=0),l===r&&_&&(_.scrollTop=_.scrollHeight),null==l||l.focus(),document.activeElement!==n)return}},[A,_]),W=P.useCallback(()=>K([L,I]),[K,L,I]);P.useEffect(()=>{V&&W()},[V,W]);const{onOpenChange:U,triggerPointerDownPosRef:G}=R;P.useEffect(()=>{if(I){let e={x:0,y:0};const t=t=>{var o,r;e={x:Math.abs(Math.round(t.pageX)-((null==(o=G.current)?void 0:o.x)??0)),y:Math.abs(Math.round(t.pageY)-((null==(r=G.current)?void 0:r.y)??0))}},o=o=>{e.x<=10&&e.y<=10?o.preventDefault():I.contains(o.target)||U(!1),document.removeEventListener("pointermove",t),G.current=null};return null!==G.current&&(document.addEventListener("pointermove",t),document.addEventListener("pointerup",o,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",o,{capture:!0})}}},[I,U,G]),P.useEffect(()=>{const e=()=>U(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[U]);const[Y,Z]=Te(e=>{const t=A().filter(e=>!e.disabled),o=t.find(e=>e.ref.current===document.activeElement),r=_e(t,e,o);r&&setTimeout(()=>r.ref.current.focus())}),J=P.useCallback((e,t,o)=>{const r=!F.current&&!o;(void 0!==R.value&&R.value===t||r)&&(N(e),r&&(F.current=!0))},[R.value]),te=P.useCallback(()=>null==I?void 0:I.focus(),[I]),oe=P.useCallback((e,t,o)=>{const r=!F.current&&!o;(void 0!==R.value&&R.value===t||r)&&M(e)},[R.value]),re="popper"===n?ee:Q,ne=re===ee?{side:p,sideOffset:f,align:v,alignOffset:m,arrowPadding:h,collisionBoundary:x,collisionPadding:g,sticky:w,hideWhenDetached:S,avoidCollisions:j}:{};return C.jsx(X,{scope:o,content:I,viewport:_,onViewportChange:k,itemRefCallback:J,selectedItem:L,onItemLeave:te,itemTextRefCallback:oe,focusSelectedItem:W,selectedItemText:q,position:n,isPositioned:V,searchRef:Y,children:C.jsx(b,{as:$,allowPinchZoom:!0,children:C.jsx(d.FocusScope,{asChild:!0,trapped:R.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:r.composeEventHandlers(s,e=>{var t;null==(t=R.trigger)||t.focus({preventScroll:!0}),e.preventDefault()}),children:C.jsx(a.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:u,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>R.onOpenChange(!1),children:C.jsx(re,{role:"listbox",id:R.contentId,"data-state":R.open?"open":"closed",dir:R.dir,onContextMenu:e=>e.preventDefault(),...E,...ne,onPlaced:()=>B(!0),ref:H,style:{display:"flex",flexDirection:"column",outline:"none",...E.style},onKeyDown:r.composeEventHandlers(E.onKeyDown,e=>{const t=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),t||1!==e.key.length||Z(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let t=A().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(t=t.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){const o=e.target,r=t.indexOf(o);t=t.slice(r+1)}setTimeout(()=>K(t)),e.preventDefault()}})})})})})})});J.displayName="SelectContentImpl";var Q=P.forwardRef((e,t)=>{const{__scopeSelect:r,onPlaced:n,...s}=e,i=O(z,r),a=Z(z,r),[c,d]=P.useState(null),[u,p]=P.useState(null),f=l.useComposedRefs(t,e=>p(e)),m=D(r),h=P.useRef(!1),x=P.useRef(!0),{viewport:w,selectedItem:S,selectedItemText:y,focusSelectedItem:b}=a,j=P.useCallback(()=>{if(i.trigger&&i.valueNode&&c&&u&&w&&S&&y){const e=i.trigger.getBoundingClientRect(),t=u.getBoundingClientRect(),r=i.valueNode.getBoundingClientRect(),l=y.getBoundingClientRect();if("rtl"!==i.dir){const n=l.left-t.left,s=r.left-n,i=e.left-s,a=e.width+i,d=Math.max(a,t.width),u=window.innerWidth-Y,p=o.clamp(s,[Y,Math.max(Y,u-d)]);c.style.minWidth=a+"px",c.style.left=p+"px"}else{const n=t.right-l.right,s=window.innerWidth-r.right-n,i=window.innerWidth-e.right-s,a=e.width+i,d=Math.max(a,t.width),u=window.innerWidth-Y,p=o.clamp(s,[Y,Math.max(Y,u-d)]);c.style.minWidth=a+"px",c.style.right=p+"px"}const s=m(),a=window.innerHeight-2*Y,d=w.scrollHeight,p=window.getComputedStyle(u),f=parseInt(p.borderTopWidth,10),v=parseInt(p.paddingTop,10),x=parseInt(p.borderBottomWidth,10),g=f+v+d+parseInt(p.paddingBottom,10)+x,b=Math.min(5*S.offsetHeight,g),C=window.getComputedStyle(w),j=parseInt(C.paddingTop,10),P=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Y,R=a-E,I=S.offsetHeight/2,T=f+v+(S.offsetTop+I),_=g-T;if(T<=E){const e=s.length>0&&S===s[s.length-1].ref.current;c.style.bottom="0px";const t=u.clientHeight-w.offsetTop-w.offsetHeight,o=T+Math.max(R,I+(e?P:0)+t+x);c.style.height=o+"px"}else{const e=s.length>0&&S===s[0].ref.current;c.style.top="0px";const t=Math.max(E,f+w.offsetTop+(e?j:0)+I)+_;c.style.height=t+"px",w.scrollTop=T-E+w.offsetTop}c.style.margin=`${Y}px 0`,c.style.minHeight=b+"px",c.style.maxHeight=a+"px",null==n||n(),requestAnimationFrame(()=>h.current=!0)}},[m,i.trigger,i.valueNode,c,u,w,S,y,i.dir,n]);g.useLayoutEffect(()=>j(),[j]);const[E,R]=P.useState();g.useLayoutEffect(()=>{u&&R(window.getComputedStyle(u).zIndex)},[u]);const I=P.useCallback(e=>{e&&!0===x.current&&(j(),null==b||b(),x.current=!1)},[j,b]);return C.jsx(te,{scope:r,contentWrapper:c,shouldExpandOnScrollRef:h,onScrollButtonChange:I,children:C.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:C.jsx(v.Primitive.div,{...s,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})});Q.displayName="SelectItemAlignedPosition";var ee=P.forwardRef((e,t)=>{const{__scopeSelect:o,align:r="start",collisionPadding:n=Y,...l}=e,s=L(o);return C.jsx(p.Content,{...s,...l,ref:t,align:r,collisionPadding:n,style:{boxSizing:"border-box",...l.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});ee.displayName="SelectPopperPosition";var[te,oe]=H(z,{}),re="SelectViewport",ne=P.forwardRef((e,t)=>{const{__scopeSelect:o,nonce:n,...s}=e,i=Z(re,o),a=oe(re,o),c=l.useComposedRefs(t,i.onViewportChange),d=P.useRef(0);return C.jsxs(C.Fragment,{children:[C.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),C.jsx(_.Slot,{scope:o,children:C.jsx(v.Primitive.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:r.composeEventHandlers(s.onScroll,e=>{const t=e.currentTarget,{contentWrapper:o,shouldExpandOnScrollRef:r}=a;if((null==r?void 0:r.current)&&o){const e=Math.abs(d.current-t.scrollTop);if(e>0){const r=window.innerHeight-2*Y,n=parseFloat(o.style.minHeight),l=parseFloat(o.style.height),s=Math.max(n,l);if(s<r){const n=s+e,l=Math.min(r,n),i=n-l;o.style.height=l+"px","0px"===o.style.bottom&&(t.scrollTop=i>0?i:0,o.style.justifyContent="flex-end")}}}d.current=t.scrollTop})})})]})});ne.displayName=re;var le="SelectGroup",[se,ie]=H(le),ae=P.forwardRef((e,t)=>{const{__scopeSelect:o,...r}=e,n=u.useId();return C.jsx(se,{scope:o,id:n,children:C.jsx(v.Primitive.div,{role:"group","aria-labelledby":n,...r,ref:t})})});ae.displayName=le;var ce="SelectLabel",de=P.forwardRef((e,t)=>{const{__scopeSelect:o,...r}=e,n=ie(ce,o);return C.jsx(v.Primitive.div,{id:n.id,...r,ref:t})});de.displayName=ce;var ue="SelectItem",[pe,fe]=H(ue),ve=P.forwardRef((e,t)=>{const{__scopeSelect:o,value:n,disabled:s=!1,textValue:i,...a}=e,c=O(ue,o),d=Z(ue,o),p=c.value===n,[f,m]=P.useState(i??""),[h,x]=P.useState(!1),g=l.useComposedRefs(t,e=>{var t;return null==(t=d.itemRefCallback)?void 0:t.call(d,e,n,s)}),w=u.useId(),S=P.useRef("touch"),y=()=>{s||(c.onValueChange(n),c.onOpenChange(!1))};if(""===n)throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return C.jsx(pe,{scope:o,value:n,disabled:s,textId:w,isSelected:p,onItemTextChange:P.useCallback(e=>{m(t=>t||((null==e?void 0:e.textContent)??"").trim())},[]),children:C.jsx(_.ItemSlot,{scope:o,value:n,disabled:s,textValue:f,children:C.jsx(v.Primitive.div,{role:"option","aria-labelledby":w,"data-highlighted":h?"":void 0,"aria-selected":p&&h,"data-state":p?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...a,ref:g,onFocus:r.composeEventHandlers(a.onFocus,()=>x(!0)),onBlur:r.composeEventHandlers(a.onBlur,()=>x(!1)),onClick:r.composeEventHandlers(a.onClick,()=>{"mouse"!==S.current&&y()}),onPointerUp:r.composeEventHandlers(a.onPointerUp,()=>{"mouse"===S.current&&y()}),onPointerDown:r.composeEventHandlers(a.onPointerDown,e=>{S.current=e.pointerType}),onPointerMove:r.composeEventHandlers(a.onPointerMove,e=>{var t;S.current=e.pointerType,s?null==(t=d.onItemLeave)||t.call(d):"mouse"===S.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:r.composeEventHandlers(a.onPointerLeave,e=>{var t;e.currentTarget===document.activeElement&&(null==(t=d.onItemLeave)||t.call(d))}),onKeyDown:r.composeEventHandlers(a.onKeyDown,e=>{var t;""!==(null==(t=d.searchRef)?void 0:t.current)&&" "===e.key||(I.includes(e.key)&&y()," "===e.key&&e.preventDefault())})})})})});ve.displayName=ue;var me="SelectItemText",he=P.forwardRef((e,t)=>{const{__scopeSelect:o,className:r,style:n,...s}=e,i=O(me,o),a=Z(me,o),c=fe(me,o),d=M(me,o),[u,p]=P.useState(null),f=l.useComposedRefs(t,e=>p(e),c.onItemTextChange,e=>{var t;return null==(t=a.itemTextRefCallback)?void 0:t.call(a,e,c.value,c.disabled)}),m=null==u?void 0:u.textContent,h=P.useMemo(()=>C.jsx("option",{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:x,onNativeOptionRemove:w}=d;return g.useLayoutEffect(()=>(x(h),()=>w(h)),[x,w,h]),C.jsxs(C.Fragment,{children:[C.jsx(v.Primitive.span,{id:c.textId,...s,ref:f}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?E.createPortal(s.children,i.valueNode):null]})});he.displayName=me;var xe="SelectItemIndicator",ge=P.forwardRef((e,t)=>{const{__scopeSelect:o,...r}=e;return fe(xe,o).isSelected?C.jsx(v.Primitive.span,{"aria-hidden":!0,...r,ref:t}):null});ge.displayName=xe;var we="SelectScrollUpButton",Se=P.forwardRef((e,t)=>{const o=Z(we,e.__scopeSelect),r=oe(we,e.__scopeSelect),[n,s]=P.useState(!1),i=l.useComposedRefs(t,r.onScrollButtonChange);return g.useLayoutEffect(()=>{if(o.viewport&&o.isPositioned){let e=function(){const e=t.scrollTop>0;s(e)};const t=o.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[o.viewport,o.isPositioned]),n?C.jsx(Ce,{...e,ref:i,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=o;e&&t&&(e.scrollTop=e.scrollTop-t.offsetHeight)}}):null});Se.displayName=we;var ye="SelectScrollDownButton",be=P.forwardRef((e,t)=>{const o=Z(ye,e.__scopeSelect),r=oe(ye,e.__scopeSelect),[n,s]=P.useState(!1),i=l.useComposedRefs(t,r.onScrollButtonChange);return g.useLayoutEffect(()=>{if(o.viewport&&o.isPositioned){let e=function(){const e=t.scrollHeight-t.clientHeight,o=Math.ceil(t.scrollTop)<e;s(o)};const t=o.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[o.viewport,o.isPositioned]),n?C.jsx(Ce,{...e,ref:i,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=o;e&&t&&(e.scrollTop=e.scrollTop+t.offsetHeight)}}):null});be.displayName=ye;var Ce=P.forwardRef((e,t)=>{const{__scopeSelect:o,onAutoScroll:n,...l}=e,s=Z("SelectScrollButton",o),i=P.useRef(null),a=D(o),c=P.useCallback(()=>{null!==i.current&&(window.clearInterval(i.current),i.current=null)},[]);return P.useEffect(()=>()=>c(),[c]),g.useLayoutEffect(()=>{var e;const t=a().find(e=>e.ref.current===document.activeElement);null==(e=null==t?void 0:t.ref.current)||e.scrollIntoView({block:"nearest"})},[a]),C.jsx(v.Primitive.div,{"aria-hidden":!0,...l,ref:t,style:{flexShrink:0,...l.style},onPointerDown:r.composeEventHandlers(l.onPointerDown,()=>{null===i.current&&(i.current=window.setInterval(n,50))}),onPointerMove:r.composeEventHandlers(l.onPointerMove,()=>{var e;null==(e=s.onItemLeave)||e.call(s),null===i.current&&(i.current=window.setInterval(n,50))}),onPointerLeave:r.composeEventHandlers(l.onPointerLeave,()=>{c()})})}),je=P.forwardRef((e,t)=>{const{__scopeSelect:o,...r}=e;return C.jsx(v.Primitive.div,{"aria-hidden":!0,...r,ref:t})});je.displayName="SelectSeparator";var Pe="SelectArrow",Ee=P.forwardRef((e,t)=>{const{__scopeSelect:o,...r}=e,n=L(o),l=O(Pe,o),s=Z(Pe,o);return l.open&&"popper"===s.position?C.jsx(p.Arrow,{...n,...r,ref:t}):null});Ee.displayName=Pe;var Re=P.forwardRef(({__scopeSelect:e,value:t,...o},r)=>{const n=P.useRef(null),s=l.useComposedRefs(r,n),i=w.usePrevious(t);return P.useEffect(()=>{const e=n.current;if(!e)return;const o=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(o,"value").set;if(i!==t&&r){const o=new Event("change",{bubbles:!0});r.call(e,t),e.dispatchEvent(o)}},[i,t]),C.jsx(v.Primitive.select,{...o,style:{...S.VISUALLY_HIDDEN_STYLES,...o.style},ref:s,defaultValue:t})});function Ie(e){return""===e||void 0===e}function Te(e){const t=h.useCallbackRef(e),o=P.useRef(""),r=P.useRef(0),n=P.useCallback(e=>{const n=o.current+e;t(n),function e(t){o.current=t,window.clearTimeout(r.current),""!==t&&(r.current=window.setTimeout(()=>e(""),1e3))}(n)},[t]),l=P.useCallback(()=>{o.current="",window.clearTimeout(r.current)},[]);return P.useEffect(()=>()=>window.clearTimeout(r.current),[]),[o,n,l]}function _e(e,t,o){const r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,n=o?e.indexOf(o):-1;let l=(s=e,i=Math.max(n,0),s.map((e,t)=>s[(i+t)%s.length]));var s,i;1===r.length&&(l=l.filter(e=>e!==o));const a=l.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return a!==o?a:void 0}Re.displayName="SelectBubbleInput";var De=A,ke=B,He=K,Le=W,Ne=U,Oe=G,qe=ne,Me=ae,Ae=de,Ve=ve,Be=he,Fe=je;exports.Content=Oe,exports.Group=Me,exports.Icon=Le,exports.Item=Ve,exports.ItemText=Be,exports.Label=Ae,exports.Portal=Ne,exports.Root=De,exports.Select=A,exports.SelectArrow=Ee,exports.SelectContent=G,exports.SelectGroup=ae,exports.SelectIcon=W,exports.SelectItem=ve,exports.SelectItemIndicator=ge,exports.SelectItemText=he,exports.SelectLabel=de,exports.SelectPortal=U,exports.SelectScrollDownButton=be,exports.SelectScrollUpButton=Se,exports.SelectSeparator=je,exports.SelectTrigger=B,exports.SelectValue=K,exports.SelectViewport=ne,exports.Separator=Fe,exports.Trigger=ke,exports.Value=He,exports.Viewport=qe;