@expcat/tigercat-react 0.0.67 → 0.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 (196) hide show
  1. package/dist/chunk-2DOPHSZP.js +32 -0
  2. package/dist/chunk-2TS6X5RA.js +73 -0
  3. package/dist/chunk-2Y327ZU4.js +493 -0
  4. package/dist/chunk-3OF7XPIQ.js +90 -0
  5. package/dist/chunk-3WPKVV4N.js +140 -0
  6. package/dist/chunk-5FRENLDC.js +194 -0
  7. package/dist/chunk-5QKMQRCW.js +89 -0
  8. package/dist/chunk-5ZVSFIZD.js +50 -0
  9. package/dist/chunk-6MGEGOYJ.js +108 -0
  10. package/dist/chunk-6PUSRC6S.js +68 -0
  11. package/dist/chunk-72ZRDBXN.js +25 -0
  12. package/dist/chunk-77D7VQMG.js +43 -0
  13. package/dist/chunk-7P6PHSFM.js +548 -0
  14. package/dist/chunk-AG6GVQ5O.js +271 -0
  15. package/dist/chunk-AQ6DHCP6.js +53 -0
  16. package/dist/chunk-AQQRWISY.js +184 -0
  17. package/dist/chunk-C5EFBJBR.js +540 -0
  18. package/dist/chunk-D3I2SY7X.js +301 -0
  19. package/dist/chunk-DZJUFU55.js +300 -0
  20. package/dist/chunk-EI2GHMQS.js +37 -0
  21. package/dist/chunk-ENR3RIMM.js +205 -0
  22. package/dist/chunk-EQWQXURG.js +18 -0
  23. package/dist/chunk-EUHWE7MN.js +267 -0
  24. package/dist/chunk-FAKTU64M.js +67 -0
  25. package/dist/chunk-FQ6UHRAO.js +499 -0
  26. package/dist/chunk-GX74TC62.js +54 -0
  27. package/dist/chunk-HDDBBZQH.js +321 -0
  28. package/dist/chunk-IFY46RWU.js +25 -0
  29. package/dist/chunk-IQINYCU6.js +99 -0
  30. package/dist/chunk-IY4LEJYF.js +78 -0
  31. package/dist/chunk-JW64IJP2.js +210 -0
  32. package/dist/chunk-KUCFT2OA.js +43 -0
  33. package/dist/chunk-LNKI6HQ3.js +152 -0
  34. package/dist/chunk-LXA2YBAO.js +38 -0
  35. package/dist/chunk-MKWXJZ3T.js +74 -0
  36. package/dist/chunk-NEULKOYJ.js +48 -0
  37. package/dist/chunk-NI2WNZRT.js +38 -0
  38. package/dist/chunk-OFCKGWTS.js +12 -0
  39. package/dist/chunk-OTRGVENC.js +305 -0
  40. package/dist/chunk-P273E6XE.js +219 -0
  41. package/dist/chunk-Q3DPJHNM.js +407 -0
  42. package/dist/chunk-QFVE7GKD.js +109 -0
  43. package/dist/chunk-QL6OBKEN.js +84 -0
  44. package/dist/chunk-QL6UEG3U.js +27 -0
  45. package/dist/chunk-QORSSZX4.js +144 -0
  46. package/dist/chunk-R4JSBXGG.js +12 -0
  47. package/dist/chunk-R5BQHZWB.js +698 -0
  48. package/dist/chunk-R7MS42PL.js +90 -0
  49. package/dist/chunk-TB2UHDOZ.js +19 -0
  50. package/dist/chunk-TBIEWDY5.js +175 -0
  51. package/dist/chunk-TJFS44SH.js +48 -0
  52. package/dist/chunk-TZ26HQAW.js +85 -0
  53. package/dist/chunk-U4ZVEPYD.js +71 -0
  54. package/dist/chunk-UFAXJVMD.js +120 -0
  55. package/dist/chunk-VJJ76I7U.js +19 -0
  56. package/dist/chunk-VO4WDK4K.js +37 -0
  57. package/dist/chunk-VSF4DF7N.js +84 -0
  58. package/dist/chunk-VVO4V4IK.js +56 -0
  59. package/dist/chunk-WK5HN4OH.js +113 -0
  60. package/dist/chunk-XZDJ5FRB.js +333 -0
  61. package/dist/chunk-YE2M2HNM.js +168 -0
  62. package/dist/chunk-YYGTJKP5.js +39 -0
  63. package/dist/chunk-ZREFCRX3.js +52 -0
  64. package/dist/components/Alert.d.ts +24 -0
  65. package/dist/components/Alert.js +10 -0
  66. package/dist/components/Avatar.d.ts +12 -0
  67. package/dist/components/Avatar.js +10 -0
  68. package/dist/components/Badge.d.ts +12 -0
  69. package/dist/components/Badge.js +10 -0
  70. package/dist/components/Breadcrumb.d.ts +13 -0
  71. package/dist/components/Breadcrumb.js +14 -0
  72. package/dist/components/BreadcrumbItem.d.ts +21 -0
  73. package/dist/components/BreadcrumbItem.js +11 -0
  74. package/dist/components/Button.d.ts +8 -0
  75. package/dist/components/Button.js +10 -0
  76. package/dist/components/Card.d.ts +33 -0
  77. package/dist/components/Card.js +10 -0
  78. package/dist/components/Checkbox.d.ts +48 -0
  79. package/dist/components/Checkbox.js +11 -0
  80. package/dist/components/CheckboxGroup.d.ts +39 -0
  81. package/dist/components/CheckboxGroup.js +14 -0
  82. package/dist/components/Code.d.ts +9 -0
  83. package/dist/components/Code.js +16 -0
  84. package/dist/components/Col.d.ts +7 -0
  85. package/dist/components/Col.js +11 -0
  86. package/dist/components/ConfigProvider.d.ts +14 -0
  87. package/dist/components/ConfigProvider.js +14 -0
  88. package/dist/components/Container.d.ts +13 -0
  89. package/dist/components/Container.js +10 -0
  90. package/dist/components/Content.d.ts +9 -0
  91. package/dist/components/Content.js +10 -0
  92. package/dist/components/DatePicker.d.ts +24 -0
  93. package/dist/components/DatePicker.js +10 -0
  94. package/dist/components/Descriptions.d.ts +53 -0
  95. package/dist/components/Descriptions.js +16 -0
  96. package/dist/components/Divider.d.ts +12 -0
  97. package/dist/components/Divider.js +10 -0
  98. package/dist/components/Drawer.d.ts +19 -0
  99. package/dist/components/Drawer.js +11 -0
  100. package/dist/components/Dropdown.d.ts +22 -0
  101. package/dist/components/Dropdown.js +16 -0
  102. package/dist/components/DropdownItem.d.ts +17 -0
  103. package/dist/components/DropdownItem.js +13 -0
  104. package/dist/components/DropdownMenu.d.ts +13 -0
  105. package/dist/components/DropdownMenu.js +10 -0
  106. package/dist/components/Footer.d.ts +9 -0
  107. package/dist/components/Footer.js +10 -0
  108. package/dist/components/Form.d.ts +56 -0
  109. package/dist/components/Form.js +14 -0
  110. package/dist/components/FormItem.d.ts +16 -0
  111. package/dist/components/FormItem.js +11 -0
  112. package/dist/components/Header.d.ts +9 -0
  113. package/dist/components/Header.js +10 -0
  114. package/dist/components/Icon.d.ts +9 -0
  115. package/dist/components/Icon.js +10 -0
  116. package/dist/components/Input.d.ts +28 -0
  117. package/dist/components/Input.js +10 -0
  118. package/dist/components/Layout.d.ts +9 -0
  119. package/dist/components/Layout.js +10 -0
  120. package/dist/components/Link.d.ts +10 -0
  121. package/dist/components/Link.js +10 -0
  122. package/dist/components/List.d.ts +94 -0
  123. package/dist/components/List.js +12 -0
  124. package/dist/components/Loading.d.ts +8 -0
  125. package/dist/components/Loading.js +10 -0
  126. package/dist/components/Menu.d.ts +35 -0
  127. package/dist/components/Menu.js +14 -0
  128. package/dist/components/MenuItem.d.ts +20 -0
  129. package/dist/components/MenuItem.js +11 -0
  130. package/dist/components/MenuItemGroup.d.ts +16 -0
  131. package/dist/components/MenuItemGroup.js +12 -0
  132. package/dist/components/Message.d.ts +44 -0
  133. package/dist/components/Message.js +20 -0
  134. package/dist/components/Modal.d.ts +41 -0
  135. package/dist/components/Modal.js +11 -0
  136. package/dist/components/Notification.d.ts +40 -0
  137. package/dist/components/Notification.js +20 -0
  138. package/dist/components/Pagination.d.ts +11 -0
  139. package/dist/components/Pagination.js +16 -0
  140. package/dist/components/Popconfirm.d.ts +34 -0
  141. package/dist/components/Popconfirm.js +10 -0
  142. package/dist/components/Popover.d.ts +14 -0
  143. package/dist/components/Popover.js +10 -0
  144. package/dist/components/Progress.d.ts +8 -0
  145. package/dist/components/Progress.js +10 -0
  146. package/dist/components/Radio.d.ts +20 -0
  147. package/dist/components/Radio.js +11 -0
  148. package/dist/components/RadioGroup.d.ts +28 -0
  149. package/dist/components/RadioGroup.js +14 -0
  150. package/dist/components/Row.d.ts +11 -0
  151. package/dist/components/Row.js +14 -0
  152. package/dist/components/Select.d.ts +23 -0
  153. package/dist/components/Select.js +10 -0
  154. package/dist/components/Sidebar.d.ts +9 -0
  155. package/dist/components/Sidebar.js +10 -0
  156. package/dist/components/Skeleton.d.ts +7 -0
  157. package/dist/components/Skeleton.js +10 -0
  158. package/dist/components/Slider.d.ts +12 -0
  159. package/dist/components/Slider.js +10 -0
  160. package/dist/components/Space.d.ts +11 -0
  161. package/dist/components/Space.js +10 -0
  162. package/dist/components/Steps.d.ts +31 -0
  163. package/dist/components/Steps.js +14 -0
  164. package/dist/components/StepsItem.d.ts +36 -0
  165. package/dist/components/StepsItem.js +10 -0
  166. package/dist/components/SubMenu.d.ts +20 -0
  167. package/dist/components/SubMenu.js +13 -0
  168. package/dist/components/Switch.d.ts +12 -0
  169. package/dist/components/Switch.js +10 -0
  170. package/dist/components/TabPane.d.ts +42 -0
  171. package/dist/components/TabPane.js +10 -0
  172. package/dist/components/Table.d.ts +46 -0
  173. package/dist/components/Table.js +10 -0
  174. package/dist/components/Tabs.d.ts +43 -0
  175. package/dist/components/Tabs.js +14 -0
  176. package/dist/components/Tag.d.ts +16 -0
  177. package/dist/components/Tag.js +10 -0
  178. package/dist/components/Text.d.ts +9 -0
  179. package/dist/components/Text.js +10 -0
  180. package/dist/components/Textarea.d.ts +13 -0
  181. package/dist/components/Textarea.js +10 -0
  182. package/dist/components/TimePicker.d.ts +28 -0
  183. package/dist/components/TimePicker.js +10 -0
  184. package/dist/components/Timeline.d.ts +47 -0
  185. package/dist/components/Timeline.js +10 -0
  186. package/dist/components/Tooltip.d.ts +15 -0
  187. package/dist/components/Tooltip.js +10 -0
  188. package/dist/components/Tree.d.ts +154 -0
  189. package/dist/components/Tree.js +16 -0
  190. package/dist/components/Upload.d.ts +16 -0
  191. package/dist/components/Upload.js +11 -0
  192. package/dist/index.d.ts +77 -0
  193. package/dist/index.js +364 -0
  194. package/package.json +3 -6
  195. package/dist/styles/index.css +0 -4
  196. package/dist/styles/index.d.mts +0 -2
@@ -0,0 +1,499 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var tigercatCore = require('@expcat/tigercat-core');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+
7
+ // src/components/Select.tsx
8
+ var flattenSelectOptions = (options) => {
9
+ const all = [];
10
+ for (const item of options) {
11
+ if (tigercatCore.isOptionGroup(item)) {
12
+ all.push(...item.options);
13
+ } else {
14
+ all.push(item);
15
+ }
16
+ }
17
+ return all;
18
+ };
19
+ var isMultipleSelect = (props) => props.multiple === true;
20
+ var Select = (props) => {
21
+ const {
22
+ options = [],
23
+ size = "md",
24
+ disabled = false,
25
+ placeholder = "Select an option",
26
+ searchable = false,
27
+ clearable = true,
28
+ noOptionsText = "No options found",
29
+ noDataText = "No options available",
30
+ onSearch,
31
+ className
32
+ } = props;
33
+ const divProps = (({ value: _value, onChange: _onChange, multiple: _multiple, ...rest }) => rest)(
34
+ props
35
+ );
36
+ const instanceId = react.useId();
37
+ const listboxId = `tiger-select-listbox-${instanceId}`;
38
+ const [isOpen, setIsOpen] = react.useState(false);
39
+ const [searchQuery, setSearchQuery] = react.useState("");
40
+ const [activeIndex, setActiveIndex] = react.useState(-1);
41
+ const dropdownRef = react.useRef(null);
42
+ const triggerRef = react.useRef(null);
43
+ const searchInputRef = react.useRef(null);
44
+ const filteredOptions = react.useMemo(
45
+ () => searchable && searchQuery ? tigercatCore.filterOptions(options, searchQuery) : options,
46
+ [options, searchable, searchQuery]
47
+ );
48
+ const flatFilteredOptions = react.useMemo(
49
+ () => flattenSelectOptions(filteredOptions),
50
+ [filteredOptions]
51
+ );
52
+ const allOptions = react.useMemo(() => flattenSelectOptions(options), [options]);
53
+ const displayText = (() => {
54
+ if (isMultipleSelect(props)) {
55
+ const value2 = props.value ?? [];
56
+ if (value2.length === 0) {
57
+ return placeholder;
58
+ }
59
+ const selectedOptions = allOptions.filter((opt) => value2.includes(opt.value));
60
+ return selectedOptions.map((opt) => opt.label).join(", ");
61
+ }
62
+ const value = props.value;
63
+ if (value === void 0 || value === null || value === "") {
64
+ return placeholder;
65
+ }
66
+ return allOptions.find((opt) => opt.value === value)?.label ?? placeholder;
67
+ })();
68
+ const showClearButton = clearable && !disabled && props.value !== void 0 && props.value !== null && props.value !== "" && (!Array.isArray(props.value) || props.value.length > 0);
69
+ const isSelected = (option) => {
70
+ if (isMultipleSelect(props)) {
71
+ return (props.value ?? []).includes(option.value);
72
+ }
73
+ return props.value === option.value;
74
+ };
75
+ const getOptionId = (index) => `tiger-select-option-${instanceId}-${index}`;
76
+ const findFirstEnabledIndex = () => flatFilteredOptions.findIndex((opt) => !opt.disabled);
77
+ const findLastEnabledIndex = () => {
78
+ for (let i = flatFilteredOptions.length - 1; i >= 0; i--) {
79
+ if (!flatFilteredOptions[i]?.disabled) {
80
+ return i;
81
+ }
82
+ }
83
+ return -1;
84
+ };
85
+ const findNextEnabledIndex = (current, direction) => {
86
+ if (flatFilteredOptions.length === 0) {
87
+ return -1;
88
+ }
89
+ const start = current < 0 ? direction === 1 ? 0 : flatFilteredOptions.length - 1 : current + direction;
90
+ for (let i = start; i >= 0 && i < flatFilteredOptions.length; i += direction) {
91
+ if (!flatFilteredOptions[i]?.disabled) {
92
+ return i;
93
+ }
94
+ }
95
+ return current;
96
+ };
97
+ const focusOptionAt = (index) => {
98
+ if (index < 0) {
99
+ return;
100
+ }
101
+ requestAnimationFrame(() => {
102
+ const el = dropdownRef.current?.querySelector(`[data-option-index="${index}"]`);
103
+ el?.focus();
104
+ el?.scrollIntoView({ block: "nearest" });
105
+ });
106
+ };
107
+ const setActiveAndFocus = (index) => {
108
+ setActiveIndex(index);
109
+ focusOptionAt(index);
110
+ };
111
+ const closeDropdown = () => {
112
+ setIsOpen(false);
113
+ setSearchQuery("");
114
+ setActiveIndex(-1);
115
+ };
116
+ const toggleDropdown = () => {
117
+ if (!disabled) {
118
+ setIsOpen((prev) => !prev);
119
+ }
120
+ };
121
+ const getActiveOption = () => {
122
+ if (activeIndex < 0) {
123
+ return void 0;
124
+ }
125
+ return flatFilteredOptions[activeIndex];
126
+ };
127
+ const selectActiveOption = () => {
128
+ const option = getActiveOption();
129
+ if (!option || option.disabled) {
130
+ return;
131
+ }
132
+ selectOption(option);
133
+ };
134
+ const selectOption = (option) => {
135
+ if (option.disabled) {
136
+ return;
137
+ }
138
+ if (isMultipleSelect(props)) {
139
+ const currentValue = props.value ?? [];
140
+ const nextValue = currentValue.includes(option.value) ? currentValue.filter((v) => v !== option.value) : [...currentValue, option.value];
141
+ props.onChange?.(nextValue);
142
+ return;
143
+ }
144
+ props.onChange?.(option.value);
145
+ closeDropdown();
146
+ requestAnimationFrame(() => {
147
+ triggerRef.current?.focus();
148
+ });
149
+ };
150
+ const clearSelection = (event) => {
151
+ event.stopPropagation();
152
+ if (isMultipleSelect(props)) {
153
+ props.onChange?.([]);
154
+ return;
155
+ }
156
+ props.onChange?.(void 0);
157
+ };
158
+ const handleSearchInput = (event) => {
159
+ const query = event.target.value;
160
+ setSearchQuery(query);
161
+ onSearch?.(query);
162
+ };
163
+ const handleTriggerKeyDown = (event) => {
164
+ if (disabled) {
165
+ return;
166
+ }
167
+ switch (event.key) {
168
+ case "ArrowDown": {
169
+ event.preventDefault();
170
+ if (!isOpen) {
171
+ setIsOpen(true);
172
+ return;
173
+ }
174
+ const next = findNextEnabledIndex(activeIndex, 1);
175
+ setActiveAndFocus(next);
176
+ return;
177
+ }
178
+ case "ArrowUp": {
179
+ event.preventDefault();
180
+ if (!isOpen) {
181
+ setIsOpen(true);
182
+ return;
183
+ }
184
+ const next = findNextEnabledIndex(activeIndex, -1);
185
+ setActiveAndFocus(next);
186
+ return;
187
+ }
188
+ case "Enter":
189
+ case " ": {
190
+ event.preventDefault();
191
+ if (!isOpen) {
192
+ setIsOpen(true);
193
+ return;
194
+ }
195
+ selectActiveOption();
196
+ return;
197
+ }
198
+ case "Escape": {
199
+ if (isOpen) {
200
+ event.preventDefault();
201
+ closeDropdown();
202
+ }
203
+ return;
204
+ }
205
+ default:
206
+ return;
207
+ }
208
+ };
209
+ const handleDropdownKeyDown = (event) => {
210
+ switch (event.key) {
211
+ case "ArrowDown": {
212
+ event.preventDefault();
213
+ const next = findNextEnabledIndex(activeIndex, 1);
214
+ setActiveAndFocus(next);
215
+ return;
216
+ }
217
+ case "ArrowUp": {
218
+ event.preventDefault();
219
+ const next = findNextEnabledIndex(activeIndex, -1);
220
+ setActiveAndFocus(next);
221
+ return;
222
+ }
223
+ case "Home": {
224
+ event.preventDefault();
225
+ const next = findFirstEnabledIndex();
226
+ setActiveAndFocus(next);
227
+ return;
228
+ }
229
+ case "End": {
230
+ event.preventDefault();
231
+ const next = findLastEnabledIndex();
232
+ setActiveAndFocus(next);
233
+ return;
234
+ }
235
+ case "Enter":
236
+ case " ": {
237
+ event.preventDefault();
238
+ selectActiveOption();
239
+ return;
240
+ }
241
+ case "Escape": {
242
+ event.preventDefault();
243
+ closeDropdown();
244
+ triggerRef.current?.focus();
245
+ return;
246
+ }
247
+ case "Tab": {
248
+ closeDropdown();
249
+ return;
250
+ }
251
+ default:
252
+ return;
253
+ }
254
+ };
255
+ const handleSearchKeyDown = (event) => {
256
+ switch (event.key) {
257
+ case " ": {
258
+ event.stopPropagation();
259
+ return;
260
+ }
261
+ case "ArrowDown": {
262
+ event.preventDefault();
263
+ event.stopPropagation();
264
+ const next = activeIndex >= 0 ? activeIndex : findFirstEnabledIndex();
265
+ setActiveAndFocus(next);
266
+ return;
267
+ }
268
+ case "ArrowUp": {
269
+ event.preventDefault();
270
+ event.stopPropagation();
271
+ const next = activeIndex >= 0 ? activeIndex : findLastEnabledIndex();
272
+ setActiveAndFocus(next);
273
+ return;
274
+ }
275
+ case "Enter": {
276
+ if (activeIndex >= 0) {
277
+ event.preventDefault();
278
+ event.stopPropagation();
279
+ selectActiveOption();
280
+ }
281
+ return;
282
+ }
283
+ case "Escape": {
284
+ event.preventDefault();
285
+ event.stopPropagation();
286
+ closeDropdown();
287
+ triggerRef.current?.focus();
288
+ return;
289
+ }
290
+ default:
291
+ return;
292
+ }
293
+ };
294
+ react.useEffect(() => {
295
+ if (isOpen && searchable) {
296
+ searchInputRef.current?.focus();
297
+ }
298
+ }, [isOpen, searchable]);
299
+ react.useEffect(() => {
300
+ if (!isOpen) {
301
+ return;
302
+ }
303
+ if (flatFilteredOptions.length === 0) {
304
+ setActiveIndex(-1);
305
+ return;
306
+ }
307
+ const selectedIndex = (() => {
308
+ if (isMultipleSelect(props)) {
309
+ const value2 = props.value ?? [];
310
+ if (value2.length === 0) {
311
+ return -1;
312
+ }
313
+ return flatFilteredOptions.findIndex((opt) => value2.includes(opt.value) && !opt.disabled);
314
+ }
315
+ const value = props.value;
316
+ if (value === void 0 || value === null || value === "") {
317
+ return -1;
318
+ }
319
+ return flatFilteredOptions.findIndex((opt) => opt.value === value && !opt.disabled);
320
+ })();
321
+ const nextActive = selectedIndex >= 0 ? selectedIndex : findFirstEnabledIndex();
322
+ setActiveIndex(nextActive);
323
+ if (!searchable) {
324
+ focusOptionAt(nextActive);
325
+ }
326
+ }, [isOpen, searchable, flatFilteredOptions, props.multiple, props.value]);
327
+ react.useEffect(() => {
328
+ if (!isOpen) {
329
+ return;
330
+ }
331
+ const handleClickOutside = (event) => {
332
+ const target = event.target;
333
+ if (dropdownRef.current && triggerRef.current && !dropdownRef.current.contains(target) && !triggerRef.current.contains(target)) {
334
+ closeDropdown();
335
+ }
336
+ };
337
+ document.addEventListener("click", handleClickOutside);
338
+ return () => {
339
+ document.removeEventListener("click", handleClickOutside);
340
+ };
341
+ }, [isOpen]);
342
+ const triggerClasses = tigercatCore.getSelectTriggerClasses(size, disabled, isOpen);
343
+ const renderOption = (option, index) => {
344
+ const optionSelected = isSelected(option);
345
+ const optionActive = index === activeIndex;
346
+ return /* @__PURE__ */ jsxRuntime.jsx(
347
+ "div",
348
+ {
349
+ id: getOptionId(index),
350
+ "data-option-index": index,
351
+ role: "option",
352
+ "aria-selected": optionSelected,
353
+ "aria-disabled": option.disabled ? true : void 0,
354
+ tabIndex: optionActive ? 0 : -1,
355
+ className: tigercatCore.getSelectOptionClasses(optionSelected, !!option.disabled, size),
356
+ onMouseEnter: () => {
357
+ if (!option.disabled) {
358
+ setActiveIndex(index);
359
+ }
360
+ },
361
+ onClick: () => selectOption(option),
362
+ children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center justify-between w-full", children: [
363
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: option.label }),
364
+ optionSelected && /* @__PURE__ */ jsxRuntime.jsx(
365
+ "svg",
366
+ {
367
+ className: "w-5 h-5 text-[var(--tiger-select-check-icon,var(--tiger-primary,#2563eb))]",
368
+ xmlns: "http://www.w3.org/2000/svg",
369
+ viewBox: "0 0 20 20",
370
+ fill: "currentColor",
371
+ children: /* @__PURE__ */ jsxRuntime.jsx(
372
+ "path",
373
+ {
374
+ fillRule: "evenodd",
375
+ d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",
376
+ clipRule: "evenodd"
377
+ }
378
+ )
379
+ }
380
+ )
381
+ ] })
382
+ },
383
+ option.value
384
+ );
385
+ };
386
+ const hasOptions = filteredOptions.length > 0;
387
+ const renderOptions = () => {
388
+ if (!hasOptions) {
389
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: tigercatCore.selectEmptyStateClasses, children: options.length === 0 ? noDataText : noOptionsText });
390
+ }
391
+ let optionIndex = -1;
392
+ return filteredOptions.map((item) => {
393
+ if (tigercatCore.isOptionGroup(item)) {
394
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
395
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: tigercatCore.selectGroupLabelClasses, children: item.label }),
396
+ item.options.map((option) => {
397
+ optionIndex += 1;
398
+ return renderOption(option, optionIndex);
399
+ })
400
+ ] }, item.label);
401
+ }
402
+ optionIndex += 1;
403
+ return renderOption(item, optionIndex);
404
+ });
405
+ };
406
+ const containerClasses = tigercatCore.classNames(tigercatCore.selectBaseClasses, className);
407
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: containerClasses, ...divProps, children: [
408
+ /* @__PURE__ */ jsxRuntime.jsxs(
409
+ "button",
410
+ {
411
+ ref: triggerRef,
412
+ type: "button",
413
+ className: triggerClasses,
414
+ disabled,
415
+ onClick: toggleDropdown,
416
+ onKeyDown: handleTriggerKeyDown,
417
+ "aria-haspopup": "listbox",
418
+ "aria-expanded": isOpen,
419
+ "aria-controls": listboxId,
420
+ children: [
421
+ /* @__PURE__ */ jsxRuntime.jsx(
422
+ "span",
423
+ {
424
+ className: tigercatCore.classNames(
425
+ "flex-1 text-left truncate",
426
+ displayText === placeholder && "text-[var(--tiger-select-placeholder,var(--tiger-text-muted,#9ca3af))]"
427
+ ),
428
+ children: displayText
429
+ }
430
+ ),
431
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-1", children: [
432
+ showClearButton && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex", "data-tiger-select-clear": true, onClick: clearSelection, children: /* @__PURE__ */ jsxRuntime.jsx(
433
+ "svg",
434
+ {
435
+ className: "w-4 h-4 text-[var(--tiger-select-icon,var(--tiger-text-muted,#9ca3af))] hover:text-[var(--tiger-select-icon-hover,var(--tiger-text-muted,#6b7280))]",
436
+ xmlns: "http://www.w3.org/2000/svg",
437
+ viewBox: "0 0 20 20",
438
+ fill: "currentColor",
439
+ children: /* @__PURE__ */ jsxRuntime.jsx(
440
+ "path",
441
+ {
442
+ fillRule: "evenodd",
443
+ d: "M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",
444
+ clipRule: "evenodd"
445
+ }
446
+ )
447
+ }
448
+ ) }),
449
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: tigercatCore.classNames("inline-flex", isOpen && "rotate-180"), children: /* @__PURE__ */ jsxRuntime.jsx(
450
+ "svg",
451
+ {
452
+ className: "w-5 h-5 text-[var(--tiger-select-icon,var(--tiger-text-muted,#9ca3af))] transition-transform",
453
+ xmlns: "http://www.w3.org/2000/svg",
454
+ viewBox: "0 0 20 20",
455
+ fill: "currentColor",
456
+ children: /* @__PURE__ */ jsxRuntime.jsx(
457
+ "path",
458
+ {
459
+ fillRule: "evenodd",
460
+ d: "M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",
461
+ clipRule: "evenodd"
462
+ }
463
+ )
464
+ }
465
+ ) })
466
+ ] })
467
+ ]
468
+ }
469
+ ),
470
+ isOpen && /* @__PURE__ */ jsxRuntime.jsxs(
471
+ "div",
472
+ {
473
+ ref: dropdownRef,
474
+ className: tigercatCore.selectDropdownBaseClasses,
475
+ role: "listbox",
476
+ id: listboxId,
477
+ "aria-multiselectable": isMultipleSelect(props) ? true : void 0,
478
+ onKeyDown: handleDropdownKeyDown,
479
+ children: [
480
+ searchable && /* @__PURE__ */ jsxRuntime.jsx(
481
+ "input",
482
+ {
483
+ ref: searchInputRef,
484
+ type: "text",
485
+ className: tigercatCore.selectSearchInputClasses,
486
+ placeholder: "Search...",
487
+ value: searchQuery,
488
+ onChange: handleSearchInput,
489
+ onKeyDown: handleSearchKeyDown
490
+ }
491
+ ),
492
+ renderOptions()
493
+ ]
494
+ }
495
+ )
496
+ ] });
497
+ };
498
+
499
+ exports.Select = Select;
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var tigercatCore = require('@expcat/tigercat-core');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+
7
+ // src/components/Code.tsx
8
+ var Code = ({
9
+ code,
10
+ copyable = true,
11
+ copyLabel = "\u590D\u5236",
12
+ copiedLabel = "\u5DF2\u590D\u5236",
13
+ onCopy,
14
+ className,
15
+ ...props
16
+ }) => {
17
+ const [isCopied, setIsCopied] = react.useState(false);
18
+ react.useEffect(() => {
19
+ if (!isCopied) return;
20
+ const timer = window.setTimeout(() => {
21
+ setIsCopied(false);
22
+ }, 1500);
23
+ return () => window.clearTimeout(timer);
24
+ }, [isCopied]);
25
+ const handleCopy = async () => {
26
+ if (!copyable) return;
27
+ const ok = await tigercatCore.copyTextToClipboard(code);
28
+ if (!ok) return;
29
+ setIsCopied(true);
30
+ onCopy?.(code);
31
+ };
32
+ const containerClasses = tigercatCore.classNames(tigercatCore.codeBlockContainerClasses, className);
33
+ const copyButtonClasses = tigercatCore.classNames(
34
+ tigercatCore.codeBlockCopyButtonBaseClasses,
35
+ isCopied && tigercatCore.codeBlockCopyButtonCopiedClasses
36
+ );
37
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: containerClasses, ...props, children: [
38
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { className: tigercatCore.codeBlockPreClasses, children: /* @__PURE__ */ jsxRuntime.jsx("code", { className: "block", children: code }) }),
39
+ copyable && /* @__PURE__ */ jsxRuntime.jsx(
40
+ "button",
41
+ {
42
+ type: "button",
43
+ className: copyButtonClasses,
44
+ onClick: handleCopy,
45
+ "aria-label": isCopied ? copiedLabel : copyLabel,
46
+ children: isCopied ? copiedLabel : copyLabel
47
+ }
48
+ )
49
+ ] });
50
+ };
51
+ var Code_default = Code;
52
+
53
+ exports.Code = Code;
54
+ exports.Code_default = Code_default;