@expcat/tigercat-react 0.0.65 → 0.0.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/dist/styles/index.css +4 -0
  2. package/dist/styles/index.d.mts +2 -0
  3. package/package.json +12 -9
  4. package/dist/chunk-2DOPHSZP.js +0 -32
  5. package/dist/chunk-2TS6X5RA.js +0 -73
  6. package/dist/chunk-2Y327ZU4.js +0 -493
  7. package/dist/chunk-3OF7XPIQ.js +0 -90
  8. package/dist/chunk-3WPKVV4N.js +0 -140
  9. package/dist/chunk-5FRENLDC.js +0 -194
  10. package/dist/chunk-5QKMQRCW.js +0 -89
  11. package/dist/chunk-5ZVSFIZD.js +0 -50
  12. package/dist/chunk-6MGEGOYJ.js +0 -108
  13. package/dist/chunk-6PUSRC6S.js +0 -68
  14. package/dist/chunk-72ZRDBXN.js +0 -25
  15. package/dist/chunk-77D7VQMG.js +0 -43
  16. package/dist/chunk-7P6PHSFM.js +0 -548
  17. package/dist/chunk-AG6GVQ5O.js +0 -271
  18. package/dist/chunk-AQ6DHCP6.js +0 -53
  19. package/dist/chunk-AQQRWISY.js +0 -184
  20. package/dist/chunk-C5EFBJBR.js +0 -540
  21. package/dist/chunk-D3I2SY7X.js +0 -301
  22. package/dist/chunk-DZJUFU55.js +0 -300
  23. package/dist/chunk-EI2GHMQS.js +0 -37
  24. package/dist/chunk-ENR3RIMM.js +0 -205
  25. package/dist/chunk-EQWQXURG.js +0 -18
  26. package/dist/chunk-EUHWE7MN.js +0 -267
  27. package/dist/chunk-FAKTU64M.js +0 -67
  28. package/dist/chunk-FQ6UHRAO.js +0 -499
  29. package/dist/chunk-GX74TC62.js +0 -54
  30. package/dist/chunk-HDDBBZQH.js +0 -321
  31. package/dist/chunk-IFY46RWU.js +0 -25
  32. package/dist/chunk-IQINYCU6.js +0 -99
  33. package/dist/chunk-IY4LEJYF.js +0 -78
  34. package/dist/chunk-JW64IJP2.js +0 -210
  35. package/dist/chunk-KUCFT2OA.js +0 -43
  36. package/dist/chunk-LNKI6HQ3.js +0 -152
  37. package/dist/chunk-LXA2YBAO.js +0 -38
  38. package/dist/chunk-MKWXJZ3T.js +0 -74
  39. package/dist/chunk-NEULKOYJ.js +0 -48
  40. package/dist/chunk-NI2WNZRT.js +0 -38
  41. package/dist/chunk-OFCKGWTS.js +0 -12
  42. package/dist/chunk-OTRGVENC.js +0 -305
  43. package/dist/chunk-P273E6XE.js +0 -219
  44. package/dist/chunk-Q3DPJHNM.js +0 -407
  45. package/dist/chunk-QFVE7GKD.js +0 -109
  46. package/dist/chunk-QL6OBKEN.js +0 -84
  47. package/dist/chunk-QL6UEG3U.js +0 -27
  48. package/dist/chunk-QORSSZX4.js +0 -144
  49. package/dist/chunk-R4JSBXGG.js +0 -12
  50. package/dist/chunk-R5BQHZWB.js +0 -698
  51. package/dist/chunk-R7MS42PL.js +0 -90
  52. package/dist/chunk-TB2UHDOZ.js +0 -19
  53. package/dist/chunk-TBIEWDY5.js +0 -175
  54. package/dist/chunk-TJFS44SH.js +0 -48
  55. package/dist/chunk-TZ26HQAW.js +0 -85
  56. package/dist/chunk-U4ZVEPYD.js +0 -71
  57. package/dist/chunk-UFAXJVMD.js +0 -120
  58. package/dist/chunk-VJJ76I7U.js +0 -19
  59. package/dist/chunk-VO4WDK4K.js +0 -37
  60. package/dist/chunk-VSF4DF7N.js +0 -84
  61. package/dist/chunk-VVO4V4IK.js +0 -56
  62. package/dist/chunk-WK5HN4OH.js +0 -113
  63. package/dist/chunk-XZDJ5FRB.js +0 -333
  64. package/dist/chunk-YE2M2HNM.js +0 -168
  65. package/dist/chunk-YYGTJKP5.js +0 -39
  66. package/dist/chunk-ZREFCRX3.js +0 -52
  67. package/dist/components/Alert.d.ts +0 -24
  68. package/dist/components/Alert.js +0 -10
  69. package/dist/components/Avatar.d.ts +0 -12
  70. package/dist/components/Avatar.js +0 -10
  71. package/dist/components/Badge.d.ts +0 -12
  72. package/dist/components/Badge.js +0 -10
  73. package/dist/components/Breadcrumb.d.ts +0 -13
  74. package/dist/components/Breadcrumb.js +0 -14
  75. package/dist/components/BreadcrumbItem.d.ts +0 -21
  76. package/dist/components/BreadcrumbItem.js +0 -11
  77. package/dist/components/Button.d.ts +0 -8
  78. package/dist/components/Button.js +0 -10
  79. package/dist/components/Card.d.ts +0 -33
  80. package/dist/components/Card.js +0 -10
  81. package/dist/components/Checkbox.d.ts +0 -48
  82. package/dist/components/Checkbox.js +0 -11
  83. package/dist/components/CheckboxGroup.d.ts +0 -39
  84. package/dist/components/CheckboxGroup.js +0 -14
  85. package/dist/components/Code.d.ts +0 -9
  86. package/dist/components/Code.js +0 -16
  87. package/dist/components/Col.d.ts +0 -7
  88. package/dist/components/Col.js +0 -11
  89. package/dist/components/ConfigProvider.d.ts +0 -14
  90. package/dist/components/ConfigProvider.js +0 -14
  91. package/dist/components/Container.d.ts +0 -13
  92. package/dist/components/Container.js +0 -10
  93. package/dist/components/Content.d.ts +0 -9
  94. package/dist/components/Content.js +0 -10
  95. package/dist/components/DatePicker.d.ts +0 -24
  96. package/dist/components/DatePicker.js +0 -10
  97. package/dist/components/Descriptions.d.ts +0 -53
  98. package/dist/components/Descriptions.js +0 -16
  99. package/dist/components/Divider.d.ts +0 -12
  100. package/dist/components/Divider.js +0 -10
  101. package/dist/components/Drawer.d.ts +0 -19
  102. package/dist/components/Drawer.js +0 -11
  103. package/dist/components/Dropdown.d.ts +0 -22
  104. package/dist/components/Dropdown.js +0 -16
  105. package/dist/components/DropdownItem.d.ts +0 -17
  106. package/dist/components/DropdownItem.js +0 -13
  107. package/dist/components/DropdownMenu.d.ts +0 -13
  108. package/dist/components/DropdownMenu.js +0 -10
  109. package/dist/components/Footer.d.ts +0 -9
  110. package/dist/components/Footer.js +0 -10
  111. package/dist/components/Form.d.ts +0 -56
  112. package/dist/components/Form.js +0 -14
  113. package/dist/components/FormItem.d.ts +0 -16
  114. package/dist/components/FormItem.js +0 -11
  115. package/dist/components/Header.d.ts +0 -9
  116. package/dist/components/Header.js +0 -10
  117. package/dist/components/Icon.d.ts +0 -9
  118. package/dist/components/Icon.js +0 -10
  119. package/dist/components/Input.d.ts +0 -28
  120. package/dist/components/Input.js +0 -10
  121. package/dist/components/Layout.d.ts +0 -9
  122. package/dist/components/Layout.js +0 -10
  123. package/dist/components/Link.d.ts +0 -10
  124. package/dist/components/Link.js +0 -10
  125. package/dist/components/List.d.ts +0 -94
  126. package/dist/components/List.js +0 -12
  127. package/dist/components/Loading.d.ts +0 -8
  128. package/dist/components/Loading.js +0 -10
  129. package/dist/components/Menu.d.ts +0 -35
  130. package/dist/components/Menu.js +0 -14
  131. package/dist/components/MenuItem.d.ts +0 -20
  132. package/dist/components/MenuItem.js +0 -11
  133. package/dist/components/MenuItemGroup.d.ts +0 -16
  134. package/dist/components/MenuItemGroup.js +0 -12
  135. package/dist/components/Message.d.ts +0 -44
  136. package/dist/components/Message.js +0 -20
  137. package/dist/components/Modal.d.ts +0 -41
  138. package/dist/components/Modal.js +0 -11
  139. package/dist/components/Notification.d.ts +0 -40
  140. package/dist/components/Notification.js +0 -20
  141. package/dist/components/Pagination.d.ts +0 -11
  142. package/dist/components/Pagination.js +0 -16
  143. package/dist/components/Popconfirm.d.ts +0 -34
  144. package/dist/components/Popconfirm.js +0 -10
  145. package/dist/components/Popover.d.ts +0 -14
  146. package/dist/components/Popover.js +0 -10
  147. package/dist/components/Progress.d.ts +0 -8
  148. package/dist/components/Progress.js +0 -10
  149. package/dist/components/Radio.d.ts +0 -20
  150. package/dist/components/Radio.js +0 -11
  151. package/dist/components/RadioGroup.d.ts +0 -28
  152. package/dist/components/RadioGroup.js +0 -14
  153. package/dist/components/Row.d.ts +0 -11
  154. package/dist/components/Row.js +0 -14
  155. package/dist/components/Select.d.ts +0 -23
  156. package/dist/components/Select.js +0 -10
  157. package/dist/components/Sidebar.d.ts +0 -9
  158. package/dist/components/Sidebar.js +0 -10
  159. package/dist/components/Skeleton.d.ts +0 -7
  160. package/dist/components/Skeleton.js +0 -10
  161. package/dist/components/Slider.d.ts +0 -12
  162. package/dist/components/Slider.js +0 -10
  163. package/dist/components/Space.d.ts +0 -11
  164. package/dist/components/Space.js +0 -10
  165. package/dist/components/Steps.d.ts +0 -31
  166. package/dist/components/Steps.js +0 -14
  167. package/dist/components/StepsItem.d.ts +0 -36
  168. package/dist/components/StepsItem.js +0 -10
  169. package/dist/components/SubMenu.d.ts +0 -20
  170. package/dist/components/SubMenu.js +0 -13
  171. package/dist/components/Switch.d.ts +0 -12
  172. package/dist/components/Switch.js +0 -10
  173. package/dist/components/TabPane.d.ts +0 -42
  174. package/dist/components/TabPane.js +0 -10
  175. package/dist/components/Table.d.ts +0 -46
  176. package/dist/components/Table.js +0 -10
  177. package/dist/components/Tabs.d.ts +0 -43
  178. package/dist/components/Tabs.js +0 -14
  179. package/dist/components/Tag.d.ts +0 -16
  180. package/dist/components/Tag.js +0 -10
  181. package/dist/components/Text.d.ts +0 -9
  182. package/dist/components/Text.js +0 -10
  183. package/dist/components/Textarea.d.ts +0 -13
  184. package/dist/components/Textarea.js +0 -10
  185. package/dist/components/TimePicker.d.ts +0 -28
  186. package/dist/components/TimePicker.js +0 -10
  187. package/dist/components/Timeline.d.ts +0 -47
  188. package/dist/components/Timeline.js +0 -10
  189. package/dist/components/Tooltip.d.ts +0 -15
  190. package/dist/components/Tooltip.js +0 -10
  191. package/dist/components/Tree.d.ts +0 -154
  192. package/dist/components/Tree.js +0 -16
  193. package/dist/components/Upload.d.ts +0 -16
  194. package/dist/components/Upload.js +0 -11
  195. package/dist/index.d.ts +0 -77
  196. package/dist/index.js +0 -364
@@ -1,499 +0,0 @@
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;
@@ -1,54 +0,0 @@
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;