@iquji-web/web-component 0.0.0-stage → 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 (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +135 -2
  3. package/dist/calendar.d.ts +27 -0
  4. package/dist/color-picker.d.ts +24 -0
  5. package/dist/confirmation.d.ts +12 -0
  6. package/dist/data-table.d.ts +16 -0
  7. package/dist/date-picker.d.ts +37 -0
  8. package/dist/desktop-account.d.ts +45 -0
  9. package/dist/desktop-rail.d.ts +21 -0
  10. package/dist/desktop-shell.d.ts +9 -0
  11. package/dist/desktop-tabs.d.ts +24 -0
  12. package/dist/desktop-titlebar.d.ts +17 -0
  13. package/dist/drawer.d.ts +24 -0
  14. package/dist/emoji-picker.d.ts +21 -0
  15. package/dist/feedback.d.ts +27 -0
  16. package/dist/floating.d.ts +65 -0
  17. package/dist/form-dialog-resize.d.ts +24 -0
  18. package/dist/form-dialog.d.ts +9 -0
  19. package/dist/form-steps.d.ts +18 -0
  20. package/dist/forms.d.ts +77 -0
  21. package/dist/index.d.ts +139 -0
  22. package/dist/index.js +4712 -0
  23. package/dist/layout.d.ts +15 -0
  24. package/dist/multi-select.d.ts +22 -0
  25. package/dist/navigation.d.ts +17 -0
  26. package/dist/notification.d.ts +27 -0
  27. package/dist/overlay-focus.d.ts +8 -0
  28. package/dist/overlay-layer.d.ts +32 -0
  29. package/dist/overlay-presence.d.ts +6 -0
  30. package/dist/overlay-scope.d.ts +8 -0
  31. package/dist/overlays.d.ts +22 -0
  32. package/dist/pagination.d.ts +13 -0
  33. package/dist/progress-bar.d.ts +12 -0
  34. package/dist/scroll-area.d.ts +10 -0
  35. package/dist/search-dialog.d.ts +26 -0
  36. package/dist/settings-layout.d.ts +24 -0
  37. package/dist/settings-nav.d.ts +31 -0
  38. package/dist/settings-rows.d.ts +53 -0
  39. package/dist/styles.css +4131 -0
  40. package/dist/timeline.d.ts +17 -0
  41. package/dist/tooltip.d.ts +12 -0
  42. package/dist/utils.d.ts +1 -0
  43. package/dist/workbench.d.ts +32 -0
  44. package/package.json +43 -4
package/dist/index.js ADDED
@@ -0,0 +1,4712 @@
1
+ // src/index.tsx
2
+ import { forwardRef as forwardRef3 } from "react";
3
+
4
+ // src/calendar.tsx
5
+ import { IqujiIcon } from "@iquji-web/web-icons";
6
+ import { useCallback, useMemo, useState } from "react";
7
+
8
+ // src/utils.ts
9
+ function classNames(...names) {
10
+ return names.filter(Boolean).join(" ");
11
+ }
12
+
13
+ // src/calendar.tsx
14
+ import { jsx, jsxs } from "react/jsx-runtime";
15
+ var pad2 = (n) => n < 10 ? `0${n}` : `${n}`;
16
+ function formatCalendarDate(date) {
17
+ return `${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())}`;
18
+ }
19
+ function parseCalendarDate(str) {
20
+ if (!str)
21
+ return null;
22
+ const match = /^(\d{4})-(\d{1,2})-(\d{1,2})$/u.exec(str.trim());
23
+ if (!match)
24
+ return null;
25
+ const year = Number.parseInt(match[1] ?? "", 10);
26
+ const month = Number.parseInt(match[2] ?? "", 10) - 1;
27
+ const day = Number.parseInt(match[3] ?? "", 10);
28
+ const date = new Date(year, month, day);
29
+ if (date.getFullYear() !== year || date.getMonth() !== month || date.getDate() !== day) {
30
+ return null;
31
+ }
32
+ return date;
33
+ }
34
+ var WEEKDAY_NAMES_ZH = ["日", "一", "二", "三", "四", "五", "六"];
35
+ var WEEKDAY_NAMES_EN = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
36
+ function IqujiCalendar({
37
+ className,
38
+ clearable = true,
39
+ defaultValue,
40
+ disabledDate,
41
+ footer,
42
+ locale = "zh-CN",
43
+ max,
44
+ min,
45
+ onChange,
46
+ onClear,
47
+ showToday = true,
48
+ value
49
+ }) {
50
+ const isZh = locale.startsWith("zh");
51
+ const weekdays = isZh ? WEEKDAY_NAMES_ZH : WEEKDAY_NAMES_EN;
52
+ const initialDate = useMemo(() => {
53
+ return parseCalendarDate(value ?? defaultValue) ?? new Date;
54
+ }, [value, defaultValue]);
55
+ const [viewYear, setViewYear] = useState(initialDate.getFullYear());
56
+ const [viewMonth, setViewMonth] = useState(initialDate.getMonth());
57
+ const todayString = useMemo(() => formatCalendarDate(new Date), []);
58
+ const selectedDateString = useMemo(() => {
59
+ if (value !== undefined) {
60
+ return value;
61
+ }
62
+ return defaultValue ?? null;
63
+ }, [value, defaultValue]);
64
+ const calendarDays = useMemo(() => {
65
+ const days = [];
66
+ const firstDayOfMonth = new Date(viewYear, viewMonth, 1);
67
+ const startingDayOfWeek = firstDayOfMonth.getDay();
68
+ const daysInCurrentMonth = new Date(viewYear, viewMonth + 1, 0).getDate();
69
+ const daysInPrevMonth = new Date(viewYear, viewMonth, 0).getDate();
70
+ for (let i = startingDayOfWeek - 1;i >= 0; i--) {
71
+ const dayNumber = daysInPrevMonth - i;
72
+ const prevDate = new Date(viewYear, viewMonth - 1, dayNumber);
73
+ const dateString = formatCalendarDate(prevDate);
74
+ const isDateDisabled = Boolean(min && dateString < min) || Boolean(max && dateString > max) || Boolean(disabledDate?.(prevDate));
75
+ days.push({
76
+ date: prevDate,
77
+ dateString,
78
+ dayNumber,
79
+ isCurrentMonth: false,
80
+ isToday: dateString === todayString,
81
+ isSelected: dateString === selectedDateString,
82
+ isDisabled: isDateDisabled
83
+ });
84
+ }
85
+ for (let dayNumber = 1;dayNumber <= daysInCurrentMonth; dayNumber++) {
86
+ const currentDate = new Date(viewYear, viewMonth, dayNumber);
87
+ const dateString = formatCalendarDate(currentDate);
88
+ const isDateDisabled = Boolean(min && dateString < min) || Boolean(max && dateString > max) || Boolean(disabledDate?.(currentDate));
89
+ days.push({
90
+ date: currentDate,
91
+ dateString,
92
+ dayNumber,
93
+ isCurrentMonth: true,
94
+ isToday: dateString === todayString,
95
+ isSelected: dateString === selectedDateString,
96
+ isDisabled: isDateDisabled
97
+ });
98
+ }
99
+ const remainingDays = 42 - days.length;
100
+ for (let dayNumber = 1;dayNumber <= remainingDays; dayNumber++) {
101
+ const nextDate = new Date(viewYear, viewMonth + 1, dayNumber);
102
+ const dateString = formatCalendarDate(nextDate);
103
+ const isDateDisabled = Boolean(min && dateString < min) || Boolean(max && dateString > max) || Boolean(disabledDate?.(nextDate));
104
+ days.push({
105
+ date: nextDate,
106
+ dateString,
107
+ dayNumber,
108
+ isCurrentMonth: false,
109
+ isToday: dateString === todayString,
110
+ isSelected: dateString === selectedDateString,
111
+ isDisabled: isDateDisabled
112
+ });
113
+ }
114
+ return days;
115
+ }, [
116
+ viewYear,
117
+ viewMonth,
118
+ min,
119
+ max,
120
+ disabledDate,
121
+ todayString,
122
+ selectedDateString
123
+ ]);
124
+ const handlePrevYear = useCallback(() => {
125
+ setViewYear((prev) => prev - 1);
126
+ }, []);
127
+ const handleNextYear = useCallback(() => {
128
+ setViewYear((prev) => prev + 1);
129
+ }, []);
130
+ const handlePrevMonth = useCallback(() => {
131
+ setViewMonth((prev) => {
132
+ if (prev === 0) {
133
+ setViewYear((y) => y - 1);
134
+ return 11;
135
+ }
136
+ return prev - 1;
137
+ });
138
+ }, []);
139
+ const handleNextMonth = useCallback(() => {
140
+ setViewMonth((prev) => {
141
+ if (prev === 11) {
142
+ setViewYear((y) => y + 1);
143
+ return 0;
144
+ }
145
+ return prev + 1;
146
+ });
147
+ }, []);
148
+ const handleSelectDay = useCallback((day) => {
149
+ if (day.isDisabled)
150
+ return;
151
+ if (!day.isCurrentMonth) {
152
+ setViewYear(day.date.getFullYear());
153
+ setViewMonth(day.date.getMonth());
154
+ }
155
+ onChange?.(day.dateString);
156
+ }, [onChange]);
157
+ const handleToday = useCallback(() => {
158
+ const today = new Date;
159
+ setViewYear(today.getFullYear());
160
+ setViewMonth(today.getMonth());
161
+ onChange?.(formatCalendarDate(today));
162
+ }, [onChange]);
163
+ const handleClear = useCallback(() => {
164
+ onClear?.();
165
+ }, [onClear]);
166
+ const titleText = isZh ? `${viewYear} 年 ${viewMonth + 1} 月` : new Intl.DateTimeFormat(locale, {
167
+ month: "short",
168
+ year: "numeric"
169
+ }).format(new Date(viewYear, viewMonth, 1));
170
+ const calendarWeeks = Array.from({ length: Math.ceil(calendarDays.length / 7) }, (_, index) => calendarDays.slice(index * 7, index * 7 + 7));
171
+ return /* @__PURE__ */ jsxs("section", {
172
+ "aria-label": titleText,
173
+ className: classNames("iquji-calendar", className),
174
+ children: [
175
+ /* @__PURE__ */ jsxs("div", {
176
+ className: "iquji-calendar__header",
177
+ children: [
178
+ /* @__PURE__ */ jsxs("div", {
179
+ className: "iquji-calendar__nav",
180
+ children: [
181
+ /* @__PURE__ */ jsx("button", {
182
+ "aria-label": isZh ? "上一年" : "Previous year",
183
+ className: "iquji-calendar__nav-btn",
184
+ onClick: handlePrevYear,
185
+ type: "button",
186
+ children: /* @__PURE__ */ jsx(IqujiIcon, {
187
+ decorative: true,
188
+ name: "chevrons-left",
189
+ size: 14
190
+ })
191
+ }),
192
+ /* @__PURE__ */ jsx("button", {
193
+ "aria-label": isZh ? "上一月" : "Previous month",
194
+ className: "iquji-calendar__nav-btn",
195
+ onClick: handlePrevMonth,
196
+ type: "button",
197
+ children: /* @__PURE__ */ jsx(IqujiIcon, {
198
+ decorative: true,
199
+ name: "chevron-left",
200
+ size: 14
201
+ })
202
+ })
203
+ ]
204
+ }),
205
+ /* @__PURE__ */ jsx("span", {
206
+ className: "iquji-calendar__title",
207
+ children: titleText
208
+ }),
209
+ /* @__PURE__ */ jsxs("div", {
210
+ className: "iquji-calendar__nav",
211
+ children: [
212
+ /* @__PURE__ */ jsx("button", {
213
+ "aria-label": isZh ? "下一月" : "Next month",
214
+ className: "iquji-calendar__nav-btn",
215
+ onClick: handleNextMonth,
216
+ type: "button",
217
+ children: /* @__PURE__ */ jsx(IqujiIcon, {
218
+ decorative: true,
219
+ name: "chevron-right",
220
+ size: 14
221
+ })
222
+ }),
223
+ /* @__PURE__ */ jsx("button", {
224
+ "aria-label": isZh ? "下一年" : "Next year",
225
+ className: "iquji-calendar__nav-btn",
226
+ onClick: handleNextYear,
227
+ type: "button",
228
+ children: /* @__PURE__ */ jsx(IqujiIcon, {
229
+ decorative: true,
230
+ name: "chevrons-right",
231
+ size: 14
232
+ })
233
+ })
234
+ ]
235
+ })
236
+ ]
237
+ }),
238
+ /* @__PURE__ */ jsxs("table", {
239
+ "aria-label": isZh ? "日期" : "Dates",
240
+ className: "iquji-calendar__table",
241
+ children: [
242
+ /* @__PURE__ */ jsx("thead", {
243
+ children: /* @__PURE__ */ jsx("tr", {
244
+ className: "iquji-calendar__weekdays",
245
+ children: weekdays.map((name) => /* @__PURE__ */ jsx("th", {
246
+ className: "iquji-calendar__weekday",
247
+ scope: "col",
248
+ children: name
249
+ }, name))
250
+ })
251
+ }),
252
+ /* @__PURE__ */ jsx("tbody", {
253
+ className: "iquji-calendar__body",
254
+ children: calendarWeeks.map((week) => /* @__PURE__ */ jsx("tr", {
255
+ className: "iquji-calendar__grid",
256
+ children: week.map((day) => {
257
+ const names = classNames("iquji-calendar__cell", !day.isCurrentMonth ? "iquji-calendar__cell--outside" : undefined, day.isToday ? "iquji-calendar__cell--today" : undefined, day.isSelected ? "iquji-calendar__cell--selected" : undefined, day.isDisabled ? "iquji-calendar__cell--disabled" : undefined);
258
+ return /* @__PURE__ */ jsx("td", {
259
+ className: "iquji-calendar__day",
260
+ children: /* @__PURE__ */ jsx("button", {
261
+ "aria-label": day.dateString,
262
+ "aria-pressed": day.isSelected,
263
+ className: names,
264
+ disabled: day.isDisabled,
265
+ onClick: () => handleSelectDay(day),
266
+ tabIndex: day.isCurrentMonth ? 0 : -1,
267
+ type: "button",
268
+ children: day.dayNumber
269
+ })
270
+ }, day.dateString);
271
+ })
272
+ }, week[0]?.dateString))
273
+ })
274
+ ]
275
+ }),
276
+ (showToday || clearable && selectedDateString || footer) && /* @__PURE__ */ jsxs("div", {
277
+ className: "iquji-calendar__footer",
278
+ children: [
279
+ showToday && /* @__PURE__ */ jsx("button", {
280
+ className: "iquji-calendar__footer-btn",
281
+ onClick: handleToday,
282
+ type: "button",
283
+ children: isZh ? "今天" : "Today"
284
+ }),
285
+ clearable && Boolean(selectedDateString) && /* @__PURE__ */ jsx("button", {
286
+ className: "iquji-calendar__footer-btn iquji-calendar__footer-btn--clear",
287
+ onClick: handleClear,
288
+ type: "button",
289
+ children: isZh ? "清除" : "Clear"
290
+ }),
291
+ footer
292
+ ]
293
+ })
294
+ ]
295
+ });
296
+ }
297
+ // src/color-picker.tsx
298
+ import { useEffect, useRef as useRef2, useState as useState3 } from "react";
299
+
300
+ // src/floating.tsx
301
+ import { Menu as BaseMenu } from "@base-ui/react/menu";
302
+ import { Popover as BasePopover } from "@base-ui/react/popover";
303
+ import { IqujiIcon as IqujiIcon2 } from "@iquji-web/web-icons";
304
+ import {
305
+ useState as useState2
306
+ } from "react";
307
+
308
+ // src/overlay-focus.ts
309
+ import { useCallback as useCallback2, useRef } from "react";
310
+ function resolveIqujiOverlayInitialFocus(ref) {
311
+ if (!ref)
312
+ return;
313
+ return () => {
314
+ const target = ref.current;
315
+ return target?.isConnected && !target.matches(':disabled, [aria-disabled="true"]') && !target.closest("[hidden], [inert]") ? target : true;
316
+ };
317
+ }
318
+ var floatingTriggers = new WeakMap;
319
+ function useIqujiFloatingTriggerRefs() {
320
+ const trigger = useRef(null);
321
+ const popup = useRef(null);
322
+ const triggerRef = useCallback2((element) => {
323
+ trigger.current = element;
324
+ if (element && popup.current)
325
+ floatingTriggers.set(popup.current, element);
326
+ }, []);
327
+ const popupRef = useCallback2((element) => {
328
+ popup.current = element;
329
+ if (element && trigger.current)
330
+ floatingTriggers.set(element, trigger.current);
331
+ }, []);
332
+ return { triggerRef, popupRef };
333
+ }
334
+ var resolveReturnTarget = (element) => {
335
+ const visited = new Set;
336
+ let target = element;
337
+ while (!visited.has(target)) {
338
+ visited.add(target);
339
+ const popup = target.closest(".iquji-menu-popup, .iquji-popover-popup");
340
+ const trigger = popup ? floatingTriggers.get(popup) : undefined;
341
+ if (!trigger)
342
+ break;
343
+ target = trigger;
344
+ }
345
+ return target;
346
+ };
347
+ function restoreIqujiOverlayFocus(resolveTarget) {
348
+ const target = resolveTarget();
349
+ if (target instanceof HTMLElement)
350
+ target.focus({ preventScroll: true });
351
+ }
352
+ function useIqujiOverlayReturnFocus(open) {
353
+ const wasOpen = useRef(false);
354
+ const currentOpen = useRef(open);
355
+ currentOpen.current = open;
356
+ const returnTarget = useRef(null);
357
+ if (open && !wasOpen.current) {
358
+ const activeElement = typeof document === "undefined" ? null : document.activeElement;
359
+ returnTarget.current = typeof HTMLElement !== "undefined" && activeElement instanceof HTMLElement && activeElement !== document.body && activeElement !== document.documentElement ? resolveReturnTarget(activeElement) : null;
360
+ }
361
+ wasOpen.current = Boolean(open);
362
+ return useCallback2(() => {
363
+ if (currentOpen.current)
364
+ return false;
365
+ const target = returnTarget.current;
366
+ const active = typeof document !== "undefined" && document.activeElement instanceof HTMLElement ? document.activeElement : null;
367
+ const focusedPopup = active ? active.closest("[data-iquji-overlay-surface][data-open], .iquji-floating-popup[data-open]") : null;
368
+ if (focusedPopup && !focusedPopup.contains(target))
369
+ return false;
370
+ if (active && active !== target && active.matches('input, textarea, select, [contenteditable="true"]') && !active.closest("[hidden], [inert]") && !active.closest("[data-iquji-overlay-surface]:not([data-open])"))
371
+ return false;
372
+ if (!target)
373
+ return true;
374
+ if (target.hasAttribute("data-iquji-overlay-surface") && active !== target && target.contains(active))
375
+ return false;
376
+ if (!target.isConnected || target.matches(':disabled, [aria-disabled="true"]') || target.closest("[hidden], [inert]"))
377
+ return false;
378
+ return target;
379
+ }, []);
380
+ }
381
+
382
+ // src/overlay-scope.tsx
383
+ import {
384
+ createContext,
385
+ useContext,
386
+ useMemo as useMemo2
387
+ } from "react";
388
+ import { jsx as jsx2 } from "react/jsx-runtime";
389
+ var IqujiOverlayScopeContext = createContext(undefined);
390
+ function IqujiOverlayScopeProvider({
391
+ children,
392
+ container
393
+ }) {
394
+ const value = useMemo2(() => container, [container]);
395
+ return /* @__PURE__ */ jsx2(IqujiOverlayScopeContext.Provider, {
396
+ value,
397
+ children
398
+ });
399
+ }
400
+ function useIqujiOverlayContainer() {
401
+ return useContext(IqujiOverlayScopeContext);
402
+ }
403
+
404
+ // src/floating.tsx
405
+ import { jsx as jsx3, jsxs as jsxs2, Fragment } from "react/jsx-runtime";
406
+ function MenuEntryContent({
407
+ entry,
408
+ chevron = false
409
+ }) {
410
+ return /* @__PURE__ */ jsxs2(Fragment, {
411
+ children: [
412
+ entry.icon ? /* @__PURE__ */ jsx3("span", {
413
+ "aria-hidden": "true",
414
+ className: "iquji-menu-item__icon",
415
+ children: entry.icon
416
+ }) : null,
417
+ /* @__PURE__ */ jsx3("span", {
418
+ className: "iquji-menu-item__label",
419
+ children: entry.label
420
+ }),
421
+ entry.shortcut ? /* @__PURE__ */ jsx3("span", {
422
+ "aria-hidden": "true",
423
+ className: "iquji-menu-item__shortcut",
424
+ children: entry.shortcut
425
+ }) : null,
426
+ chevron ? /* @__PURE__ */ jsx3(IqujiIcon2, {
427
+ className: "iquji-menu-item__chevron",
428
+ decorative: true,
429
+ name: "chevron-right",
430
+ size: 15
431
+ }) : null
432
+ ]
433
+ });
434
+ }
435
+ function DropdownSubmenu({ item }) {
436
+ const [open, setOpen] = useState2(false);
437
+ const portalContainer = useIqujiOverlayContainer();
438
+ const structured = item.kind === "submenu" ? item.items : undefined;
439
+ return /* @__PURE__ */ jsxs2(BaseMenu.SubmenuRoot, {
440
+ open,
441
+ onOpenChange: setOpen,
442
+ children: [
443
+ /* @__PURE__ */ jsx3(BaseMenu.SubmenuTrigger, {
444
+ className: classNames("iquji-menu-item", item.kind === "item" && item.tone === "danger" ? "iquji-menu-item--danger" : undefined),
445
+ disabled: item.disabled,
446
+ onClick: () => {
447
+ if (!item.disabled)
448
+ setOpen(true);
449
+ },
450
+ openOnHover: true,
451
+ children: /* @__PURE__ */ jsx3(MenuEntryContent, {
452
+ chevron: true,
453
+ entry: item
454
+ })
455
+ }),
456
+ /* @__PURE__ */ jsx3(BaseMenu.Portal, {
457
+ container: portalContainer ?? undefined,
458
+ children: /* @__PURE__ */ jsx3(BaseMenu.Positioner, {
459
+ align: "start",
460
+ className: "iquji-floating-positioner",
461
+ side: "right",
462
+ sideOffset: 4,
463
+ style: { zIndex: portalContainer ? undefined : 1002 },
464
+ children: /* @__PURE__ */ jsx3(BaseMenu.Popup, {
465
+ className: "iquji-floating-popup iquji-menu-popup",
466
+ children: open ? structured ? renderMenuEntries(structured) : item.kind === "submenu" ? null : item.submenu : null
467
+ })
468
+ })
469
+ })
470
+ ]
471
+ });
472
+ }
473
+ function renderMenuEntry(entry) {
474
+ if (entry.kind === "separator") {
475
+ return /* @__PURE__ */ jsx3(BaseMenu.Separator, {
476
+ className: "iquji-menu-separator"
477
+ }, entry.key);
478
+ }
479
+ if (entry.kind === "label") {
480
+ return /* @__PURE__ */ jsx3("div", {
481
+ className: "iquji-menu-label",
482
+ role: "presentation",
483
+ children: entry.label
484
+ }, entry.key);
485
+ }
486
+ if (entry.kind === "submenu" || entry.submenu) {
487
+ return /* @__PURE__ */ jsx3(DropdownSubmenu, {
488
+ item: entry
489
+ }, entry.key);
490
+ }
491
+ return /* @__PURE__ */ jsx3(BaseMenu.Item, {
492
+ "aria-keyshortcuts": entry.keyshortcuts,
493
+ className: classNames("iquji-menu-item", entry.tone === "danger" ? "iquji-menu-item--danger" : undefined),
494
+ disabled: entry.disabled,
495
+ onClick: entry.onSelect,
496
+ children: /* @__PURE__ */ jsx3(MenuEntryContent, {
497
+ entry
498
+ })
499
+ }, entry.key);
500
+ }
501
+ function renderMenuEntries(entries) {
502
+ return entries.map(renderMenuEntry);
503
+ }
504
+ var IqujiDropdownMenu = ({
505
+ trigger,
506
+ items,
507
+ open,
508
+ onOpenChange,
509
+ align,
510
+ side,
511
+ sideOffset,
512
+ anchor,
513
+ collisionBoundary,
514
+ finalFocus,
515
+ popupStyle,
516
+ ariaLabel
517
+ }) => {
518
+ const portalContainer = useIqujiOverlayContainer();
519
+ const { triggerRef, popupRef } = useIqujiFloatingTriggerRefs();
520
+ return /* @__PURE__ */ jsxs2(BaseMenu.Root, {
521
+ open,
522
+ onOpenChange,
523
+ children: [
524
+ /* @__PURE__ */ jsx3(BaseMenu.Trigger, {
525
+ ref: triggerRef,
526
+ render: trigger
527
+ }),
528
+ /* @__PURE__ */ jsx3(BaseMenu.Portal, {
529
+ keepMounted: true,
530
+ container: portalContainer ?? undefined,
531
+ children: /* @__PURE__ */ jsx3(BaseMenu.Positioner, {
532
+ align,
533
+ anchor,
534
+ collisionBoundary,
535
+ className: "iquji-floating-positioner",
536
+ side,
537
+ sideOffset,
538
+ style: { zIndex: portalContainer ? undefined : 1002 },
539
+ children: /* @__PURE__ */ jsx3(BaseMenu.Popup, {
540
+ "aria-label": ariaLabel,
541
+ className: "iquji-floating-popup iquji-menu-popup",
542
+ finalFocus,
543
+ ref: popupRef,
544
+ style: popupStyle,
545
+ children: renderMenuEntries(items)
546
+ })
547
+ })
548
+ })
549
+ ]
550
+ });
551
+ };
552
+ function IqujiPopover({
553
+ anchor,
554
+ trigger,
555
+ children,
556
+ open,
557
+ onOpenChange,
558
+ side = "bottom",
559
+ align,
560
+ collisionBoundary,
561
+ collisionPadding,
562
+ collisionAvoidance,
563
+ popupStyle,
564
+ finalFocus
565
+ }) {
566
+ const container = useIqujiOverlayContainer();
567
+ const { triggerRef, popupRef } = useIqujiFloatingTriggerRefs();
568
+ return /* @__PURE__ */ jsxs2(BasePopover.Root, {
569
+ open,
570
+ onOpenChange,
571
+ children: [
572
+ /* @__PURE__ */ jsx3(BasePopover.Trigger, {
573
+ ref: triggerRef,
574
+ render: trigger
575
+ }),
576
+ /* @__PURE__ */ jsx3(BasePopover.Portal, {
577
+ keepMounted: true,
578
+ container: container ?? undefined,
579
+ children: /* @__PURE__ */ jsx3(BasePopover.Positioner, {
580
+ anchor,
581
+ side,
582
+ align,
583
+ sideOffset: 8,
584
+ collisionBoundary,
585
+ collisionPadding,
586
+ collisionAvoidance,
587
+ className: "iquji-floating-positioner",
588
+ style: { zIndex: container ? undefined : 1002 },
589
+ children: /* @__PURE__ */ jsx3(BasePopover.Popup, {
590
+ ref: popupRef,
591
+ finalFocus,
592
+ className: "iquji-floating-popup iquji-popover-popup",
593
+ style: popupStyle,
594
+ children
595
+ })
596
+ })
597
+ })
598
+ ]
599
+ });
600
+ }
601
+
602
+ // src/color-picker.tsx
603
+ import { jsx as jsx4, jsxs as jsxs3, Fragment as Fragment2 } from "react/jsx-runtime";
604
+ var normalizeIqujiColor = (value) => /^#[0-9a-f]{6}$/iu.test(value.trim()) ? value.trim().toLowerCase() : null;
605
+ function IqujiColorPicker({
606
+ value,
607
+ onChange,
608
+ presets,
609
+ label,
610
+ defaultLabel,
611
+ customLabel,
612
+ hexLabel,
613
+ applyLabel,
614
+ cancelLabel,
615
+ disabled = false,
616
+ trigger,
617
+ onOpenChange,
618
+ finalFocus
619
+ }) {
620
+ const currentOnOpenChange = useRef2(onOpenChange);
621
+ currentOnOpenChange.current = onOpenChange;
622
+ const [open, setOpen] = useState3(false);
623
+ const [custom, setCustom] = useState3(false);
624
+ const [draft, setDraft] = useState3(value ?? "#000000");
625
+ const valid = normalizeIqujiColor(draft);
626
+ const changeOpen = (next, reason = "programmatic") => {
627
+ if (next && disabled)
628
+ return;
629
+ setOpen(next);
630
+ if (next) {
631
+ setCustom(false);
632
+ setDraft(value ?? "#000000");
633
+ }
634
+ onOpenChange?.(next, reason);
635
+ };
636
+ useEffect(() => {
637
+ if (disabled && open) {
638
+ setOpen(false);
639
+ currentOnOpenChange.current?.(false, "disabled");
640
+ }
641
+ }, [disabled, open]);
642
+ const choose = (next) => {
643
+ if (disabled)
644
+ return;
645
+ onChange(next);
646
+ changeOpen(false, "selection");
647
+ };
648
+ return /* @__PURE__ */ jsx4(IqujiPopover, {
649
+ open,
650
+ onOpenChange: (next, details) => changeOpen(next, details.reason),
651
+ align: "start",
652
+ collisionPadding: 12,
653
+ collisionAvoidance: { side: "flip", align: "shift", fallbackAxisSide: "start" },
654
+ popupStyle: { maxWidth: "calc(100vw - 32px)" },
655
+ finalFocus,
656
+ trigger: trigger ?? /* @__PURE__ */ jsxs3(IqujiButton, {
657
+ compact: true,
658
+ variant: "ghost",
659
+ disabled,
660
+ "aria-label": label,
661
+ children: [
662
+ /* @__PURE__ */ jsx4("span", {
663
+ className: "iquji-color-swatch",
664
+ style: { backgroundColor: value ?? "transparent" }
665
+ }),
666
+ label
667
+ ]
668
+ }),
669
+ children: /* @__PURE__ */ jsxs3("fieldset", {
670
+ className: "iquji-color-picker",
671
+ "aria-label": label,
672
+ children: [
673
+ /* @__PURE__ */ jsx4(IqujiButton, {
674
+ compact: true,
675
+ variant: "ghost",
676
+ disabled,
677
+ onClick: () => choose(null),
678
+ children: defaultLabel
679
+ }),
680
+ /* @__PURE__ */ jsx4("div", {
681
+ className: "iquji-color-presets",
682
+ children: presets.map((preset) => /* @__PURE__ */ jsxs3(IqujiButton, {
683
+ compact: true,
684
+ variant: "ghost",
685
+ disabled: disabled || !normalizeIqujiColor(preset.value),
686
+ "aria-label": preset.label,
687
+ title: preset.label,
688
+ "aria-pressed": value === preset.value,
689
+ onClick: () => choose(preset.value),
690
+ children: [
691
+ /* @__PURE__ */ jsx4("span", {
692
+ className: "iquji-color-swatch",
693
+ style: { backgroundColor: preset.value }
694
+ }),
695
+ /* @__PURE__ */ jsx4("span", {
696
+ className: "iquji-color-name",
697
+ children: preset.label
698
+ })
699
+ ]
700
+ }, preset.value))
701
+ }),
702
+ !custom ? /* @__PURE__ */ jsx4(IqujiButton, {
703
+ compact: true,
704
+ variant: "ghost",
705
+ disabled,
706
+ onClick: () => setCustom(true),
707
+ children: customLabel
708
+ }) : /* @__PURE__ */ jsxs3(Fragment2, {
709
+ children: [
710
+ /* @__PURE__ */ jsx4("input", {
711
+ className: "iquji-color-spectrum",
712
+ type: "color",
713
+ value: valid ?? "#000000",
714
+ "aria-label": customLabel,
715
+ disabled,
716
+ onChange: (event) => setDraft(event.target.value)
717
+ }),
718
+ /* @__PURE__ */ jsxs3("label", {
719
+ className: "iquji-color-hex",
720
+ children: [
721
+ hexLabel,
722
+ /* @__PURE__ */ jsx4("input", {
723
+ value: draft,
724
+ spellCheck: false,
725
+ maxLength: 7,
726
+ "aria-invalid": !valid,
727
+ disabled,
728
+ onChange: (event) => setDraft(event.target.value)
729
+ })
730
+ ]
731
+ }),
732
+ /* @__PURE__ */ jsxs3("div", {
733
+ className: "iquji-color-actions",
734
+ children: [
735
+ /* @__PURE__ */ jsx4(IqujiButton, {
736
+ compact: true,
737
+ variant: "secondary",
738
+ onClick: () => changeOpen(false, "cancel"),
739
+ children: cancelLabel
740
+ }),
741
+ /* @__PURE__ */ jsx4(IqujiButton, {
742
+ compact: true,
743
+ disabled: disabled || !valid,
744
+ onClick: () => valid && choose(valid),
745
+ children: applyLabel
746
+ })
747
+ ]
748
+ })
749
+ ]
750
+ })
751
+ ]
752
+ })
753
+ });
754
+ }
755
+ // src/confirmation.tsx
756
+ import { useRef as useRef5 } from "react";
757
+
758
+ // src/overlays.tsx
759
+ import { Dialog } from "@base-ui/react/dialog";
760
+ import { IqujiIcon as IqujiIcon3 } from "@iquji-web/web-icons";
761
+ import {
762
+ useId,
763
+ useState as useState6
764
+ } from "react";
765
+
766
+ // src/overlay-layer.tsx
767
+ import {
768
+ createContext as createContext2,
769
+ useCallback as useCallback3,
770
+ useContext as useContext2,
771
+ useEffect as useEffect2,
772
+ useMemo as useMemo3,
773
+ useRef as useRef3,
774
+ useState as useState4
775
+ } from "react";
776
+ import { jsx as jsx5 } from "react/jsx-runtime";
777
+ function useIqujiOverlayModal(open, isTopLayer) {
778
+ const [focused, setFocused] = useState4(false);
779
+ useEffect2(() => {
780
+ if (!open || !isTopLayer)
781
+ setFocused(false);
782
+ }, [open, isTopLayer]);
783
+ return {
784
+ modal: !open || isTopLayer && focused ? "trap-focus" : false,
785
+ onFocusCapture(event) {
786
+ if (open && isTopLayer && event.currentTarget.contains(event.target))
787
+ setFocused(true);
788
+ }
789
+ };
790
+ }
791
+ var Context = createContext2(null);
792
+ var Ancestors = createContext2([]);
793
+ var locks = new WeakMap;
794
+ var nextOrder = 0;
795
+ function orderedLayers(layers) {
796
+ const pending = [...layers].sort((left, right) => left.order - right.order);
797
+ const result = [];
798
+ while (pending.length) {
799
+ const index = pending.findIndex((layer) => !pending.some((other) => layer.ancestors.includes(other.id)));
800
+ result.push(...pending.splice(index, 1));
801
+ }
802
+ return result;
803
+ }
804
+ function IqujiOverlayAncestry({
805
+ id,
806
+ children
807
+ }) {
808
+ const ancestors = useContext2(Ancestors);
809
+ const value = useMemo3(() => [...ancestors, id], [ancestors, id]);
810
+ return /* @__PURE__ */ jsx5(Ancestors.Provider, {
811
+ value,
812
+ children
813
+ });
814
+ }
815
+ function IqujiOverlayProvider({ children }) {
816
+ const [layers, setLayers] = useState4([]);
817
+ const register = useCallback3((layer) => setLayers((current) => orderedLayers([
818
+ ...current.filter((value2) => value2.id !== layer.id),
819
+ layer
820
+ ])), []);
821
+ const unregister = useCallback3((id) => setLayers((current) => orderedLayers(current.filter((layer) => layer.id !== id))), []);
822
+ const locked = layers.length > 0;
823
+ useEffect2(() => {
824
+ if (!locked)
825
+ return;
826
+ const body = document.body;
827
+ const lock = locks.get(body) ?? { count: 0, overflow: body.style.overflow };
828
+ lock.count++;
829
+ locks.set(body, lock);
830
+ body.style.overflow = "hidden";
831
+ return () => {
832
+ if (--lock.count === 0) {
833
+ body.style.overflow = lock.overflow;
834
+ locks.delete(body);
835
+ }
836
+ };
837
+ }, [locked]);
838
+ const value = useMemo3(() => ({ layers, register, unregister }), [layers, register, unregister]);
839
+ return /* @__PURE__ */ jsx5(Context.Provider, {
840
+ value,
841
+ children
842
+ });
843
+ }
844
+ function IqujiOverlayBoundary({ children }) {
845
+ return useContext2(Context) ? children : /* @__PURE__ */ jsx5(IqujiOverlayProvider, {
846
+ children
847
+ });
848
+ }
849
+ function useIqujiOverlayLayer(id, kind, active, open, container) {
850
+ const opening = useRef3({ open: false, order: 0 });
851
+ if (open && !opening.current.open)
852
+ opening.current.order = ++nextOrder;
853
+ opening.current.open = open;
854
+ const order = opening.current.order;
855
+ const ancestors = useContext2(Ancestors);
856
+ const context = useContext2(Context);
857
+ const register = context?.register, unregister = context?.unregister;
858
+ useEffect2(() => {
859
+ if (!active || !register || !unregister)
860
+ return;
861
+ register({ id, kind, order, ancestors, container, open });
862
+ return () => unregister(id);
863
+ }, [
864
+ active,
865
+ id,
866
+ kind,
867
+ order,
868
+ ancestors,
869
+ container,
870
+ open,
871
+ register,
872
+ unregister
873
+ ]);
874
+ const layers = context?.layers ?? [];
875
+ const index = layers.findIndex((layer) => layer.id === id);
876
+ const base = 1000 + Math.max(index, 0) * 20;
877
+ return {
878
+ registered: index !== -1,
879
+ isTopLayer: !layers.length || layers.at(-1)?.id === id,
880
+ backdrop: base,
881
+ surface: base + 1,
882
+ floating: base + 2
883
+ };
884
+ }
885
+ function useIqujiNotificationContainer() {
886
+ const context = useContext2(Context);
887
+ return [...context?.layers ?? []].reverse().find((layer) => layer.open)?.container ?? undefined;
888
+ }
889
+
890
+ // src/overlay-presence.ts
891
+ import { useCallback as useCallback4, useEffect as useEffect3, useRef as useRef4, useState as useState5 } from "react";
892
+ function useIqujiOverlayPresence(open, onCloseComplete) {
893
+ const [present, setPresent] = useState5(open);
894
+ const currentOpen = useRef4(open), completed = useRef4(!open), pending = useRef4(false), completion = useRef4(onCloseComplete);
895
+ currentOpen.current = open;
896
+ completion.current = onCloseComplete;
897
+ if (open) {
898
+ completed.current = false;
899
+ pending.current = false;
900
+ }
901
+ useEffect3(() => {
902
+ if (open)
903
+ setPresent(true);
904
+ }, [open]);
905
+ const complete = useCallback4((nextOpen) => {
906
+ if (nextOpen || currentOpen.current || completed.current)
907
+ return;
908
+ completed.current = true;
909
+ pending.current = true;
910
+ setPresent(false);
911
+ }, []);
912
+ const notify = useCallback4(() => {
913
+ if (currentOpen.current || !pending.current)
914
+ return;
915
+ pending.current = false;
916
+ completion.current?.();
917
+ }, []);
918
+ return { active: open || present, complete, notify };
919
+ }
920
+ function useIqujiOverlayCompletion(presence, registered, finalFocus) {
921
+ const { active, notify } = presence;
922
+ useEffect3(() => {
923
+ if (active || registered)
924
+ return;
925
+ let cancelled = false;
926
+ queueMicrotask(() => {
927
+ if (!cancelled) {
928
+ restoreIqujiOverlayFocus(finalFocus);
929
+ notify();
930
+ }
931
+ });
932
+ return () => {
933
+ cancelled = true;
934
+ };
935
+ }, [active, registered, notify, finalFocus]);
936
+ }
937
+
938
+ // src/overlays.tsx
939
+ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
940
+ var widths = {
941
+ sm: "min(92vw, 420px)",
942
+ md: "min(92vw, 720px)",
943
+ lg: "min(94vw, 960px)"
944
+ };
945
+ function IqujiDialog(props) {
946
+ return /* @__PURE__ */ jsx6(IqujiOverlayBoundary, {
947
+ children: /* @__PURE__ */ jsx6(DialogContent, {
948
+ ...props
949
+ })
950
+ });
951
+ }
952
+ function DialogContent({
953
+ open,
954
+ onOpenChange,
955
+ onCloseComplete,
956
+ title,
957
+ description,
958
+ heading,
959
+ headerActions,
960
+ closeLabel,
961
+ children,
962
+ actions,
963
+ initialFocusRef,
964
+ popupRef,
965
+ mandatory = false,
966
+ destroyOnClose = true,
967
+ size = "md",
968
+ surface = "panel",
969
+ layout = "standard",
970
+ width,
971
+ className,
972
+ style,
973
+ onFocusCapture,
974
+ ...props
975
+ }) {
976
+ const id = useId();
977
+ const [container, setContainer] = useState6(null);
978
+ const presence = useIqujiOverlayPresence(open, onCloseComplete);
979
+ const layer = useIqujiOverlayLayer(id, "dialog", presence.active, open, container);
980
+ const focus = useIqujiOverlayModal(open, layer.isTopLayer);
981
+ const finalFocus = useIqujiOverlayReturnFocus(open);
982
+ useIqujiOverlayCompletion(presence, layer.registered, finalFocus);
983
+ if (!mandatory && !closeLabel)
984
+ throw new Error("可关闭对话框必须提供 closeLabel");
985
+ return /* @__PURE__ */ jsx6(IqujiOverlayAncestry, {
986
+ id,
987
+ children: /* @__PURE__ */ jsx6(Dialog.Root, {
988
+ open,
989
+ modal: focus.modal,
990
+ disablePointerDismissal: mandatory,
991
+ onOpenChange: (next, details) => {
992
+ if (!next && (mandatory || !layer.isTopLayer)) {
993
+ details.cancel();
994
+ return;
995
+ }
996
+ onOpenChange?.(next);
997
+ },
998
+ onOpenChangeComplete: (next) => {
999
+ if (!next)
1000
+ restoreIqujiOverlayFocus(finalFocus);
1001
+ presence.complete(next);
1002
+ },
1003
+ children: /* @__PURE__ */ jsxs4(Dialog.Portal, {
1004
+ keepMounted: !destroyOnClose,
1005
+ container: typeof document === "undefined" ? undefined : document.body,
1006
+ children: [
1007
+ /* @__PURE__ */ jsx6(Dialog.Backdrop, {
1008
+ forceRender: true,
1009
+ className: "iquji-overlay-backdrop iquji-dialog-backdrop",
1010
+ style: { zIndex: layer.backdrop }
1011
+ }),
1012
+ /* @__PURE__ */ jsx6("div", {
1013
+ ref: setContainer,
1014
+ className: "iquji-overlay-floating-layer",
1015
+ "data-iquji-overlay-portal": "",
1016
+ style: { zIndex: layer.floating }
1017
+ }),
1018
+ /* @__PURE__ */ jsx6("div", {
1019
+ className: "iquji-dialog-positioner",
1020
+ style: { zIndex: layer.surface },
1021
+ children: /* @__PURE__ */ jsx6(Dialog.Popup, {
1022
+ ...props,
1023
+ ref: popupRef,
1024
+ onFocusCapture: (event) => {
1025
+ focus.onFocusCapture(event);
1026
+ onFocusCapture?.(event);
1027
+ },
1028
+ initialFocus: !open || layer.isTopLayer ? resolveIqujiOverlayInitialFocus(initialFocusRef) : false,
1029
+ finalFocus,
1030
+ className: classNames("iquji-dialog iquji-floating-popup", surface === "glass" && "iquji-dialog--glass", layout === "compact" && "iquji-dialog--compact", className),
1031
+ "data-iquji-overlay-surface": "",
1032
+ "data-mandatory": mandatory || undefined,
1033
+ style: {
1034
+ width: width ?? widths[size],
1035
+ zIndex: layer.surface,
1036
+ ...style
1037
+ },
1038
+ children: /* @__PURE__ */ jsx6(IqujiOverlayScopeProvider, {
1039
+ container,
1040
+ children: /* @__PURE__ */ jsxs4("div", {
1041
+ className: "iquji-dialog__surface",
1042
+ children: [
1043
+ (title || description || heading || headerActions) && /* @__PURE__ */ jsxs4("header", {
1044
+ className: "iquji-dialog__header",
1045
+ children: [
1046
+ /* @__PURE__ */ jsxs4("div", {
1047
+ className: "iquji-dialog__heading",
1048
+ children: [
1049
+ heading,
1050
+ title && /* @__PURE__ */ jsx6(Dialog.Title, {
1051
+ className: classNames("iquji-dialog__title", Boolean(heading) && "iquji-dialog__title--hidden"),
1052
+ children: title
1053
+ }),
1054
+ description && /* @__PURE__ */ jsx6(Dialog.Description, {
1055
+ className: "iquji-dialog__description",
1056
+ children: description
1057
+ })
1058
+ ]
1059
+ }),
1060
+ /* @__PURE__ */ jsxs4("div", {
1061
+ className: "iquji-dialog__header-actions",
1062
+ children: [
1063
+ headerActions,
1064
+ !mandatory && /* @__PURE__ */ jsx6(Dialog.Close, {
1065
+ render: /* @__PURE__ */ jsx6(IconButton, {
1066
+ label: closeLabel ?? "",
1067
+ icon: /* @__PURE__ */ jsx6(IqujiIcon3, {
1068
+ name: "close"
1069
+ })
1070
+ })
1071
+ })
1072
+ ]
1073
+ })
1074
+ ]
1075
+ }),
1076
+ /* @__PURE__ */ jsx6("div", {
1077
+ className: "iquji-dialog__body",
1078
+ children
1079
+ }),
1080
+ actions && /* @__PURE__ */ jsx6("footer", {
1081
+ className: "iquji-dialog__actions",
1082
+ children: actions
1083
+ })
1084
+ ]
1085
+ })
1086
+ })
1087
+ })
1088
+ })
1089
+ ]
1090
+ })
1091
+ })
1092
+ });
1093
+ }
1094
+
1095
+ // src/confirmation.tsx
1096
+ import { jsx as jsx7, jsxs as jsxs5, Fragment as Fragment3 } from "react/jsx-runtime";
1097
+ function IqujiConfirmDialog({
1098
+ confirmLabel,
1099
+ cancelLabel,
1100
+ confirmLoading = false,
1101
+ confirmDisabled = false,
1102
+ additionalActions,
1103
+ onConfirm,
1104
+ onOpenChange,
1105
+ initialFocusRef,
1106
+ size,
1107
+ width,
1108
+ layout = "compact",
1109
+ ...props
1110
+ }) {
1111
+ const cancel = useRef5(null);
1112
+ return /* @__PURE__ */ jsx7(IqujiDialog, {
1113
+ ...props,
1114
+ initialFocusRef: initialFocusRef ?? cancel,
1115
+ size: size ?? "sm",
1116
+ width: width ?? (size === undefined ? "min(92vw, 420px)" : undefined),
1117
+ layout,
1118
+ mandatory: confirmLoading || props.mandatory,
1119
+ onOpenChange,
1120
+ actions: /* @__PURE__ */ jsxs5(Fragment3, {
1121
+ children: [
1122
+ additionalActions,
1123
+ /* @__PURE__ */ jsx7(IqujiButton, {
1124
+ variant: "secondary",
1125
+ ref: cancel,
1126
+ disabled: confirmLoading,
1127
+ onClick: () => onOpenChange?.(false),
1128
+ children: cancelLabel
1129
+ }),
1130
+ /* @__PURE__ */ jsx7(IqujiButton, {
1131
+ variant: "danger",
1132
+ disabled: confirmDisabled,
1133
+ loading: confirmLoading,
1134
+ onClick: onConfirm,
1135
+ children: confirmLabel
1136
+ })
1137
+ ]
1138
+ })
1139
+ });
1140
+ }
1141
+ // src/data-table.tsx
1142
+ import {
1143
+ flexRender,
1144
+ getCoreRowModel,
1145
+ useReactTable
1146
+ } from "@tanstack/react-table";
1147
+
1148
+ // src/layout.tsx
1149
+ import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
1150
+ function IqujiPageHeader({
1151
+ actions,
1152
+ className,
1153
+ description,
1154
+ eyebrow,
1155
+ title,
1156
+ titleId,
1157
+ ...headerProps
1158
+ }) {
1159
+ return /* @__PURE__ */ jsxs6("header", {
1160
+ className: classNames("iquji-page-header", className),
1161
+ ...headerProps,
1162
+ children: [
1163
+ /* @__PURE__ */ jsxs6("div", {
1164
+ className: "iquji-page-header__copy",
1165
+ children: [
1166
+ eyebrow ? /* @__PURE__ */ jsx8("div", {
1167
+ className: "iquji-page-header__eyebrow",
1168
+ children: eyebrow
1169
+ }) : null,
1170
+ /* @__PURE__ */ jsx8("h1", {
1171
+ id: titleId,
1172
+ tabIndex: -1,
1173
+ children: title
1174
+ }),
1175
+ description ? /* @__PURE__ */ jsx8("div", {
1176
+ className: "iquji-page-header__description",
1177
+ children: description
1178
+ }) : null
1179
+ ]
1180
+ }),
1181
+ actions ? /* @__PURE__ */ jsx8("div", {
1182
+ className: "iquji-page-header__actions",
1183
+ children: actions
1184
+ }) : null
1185
+ ]
1186
+ });
1187
+ }
1188
+ function IqujiTableFrame({
1189
+ busy = false,
1190
+ children,
1191
+ className,
1192
+ label,
1193
+ toolbar,
1194
+ ...divProps
1195
+ }) {
1196
+ return /* @__PURE__ */ jsxs6("div", {
1197
+ "aria-busy": busy,
1198
+ className: classNames("iquji-table-frame", className),
1199
+ ...divProps,
1200
+ children: [
1201
+ toolbar ? /* @__PURE__ */ jsx8("div", {
1202
+ className: "iquji-table-frame__toolbar",
1203
+ children: toolbar
1204
+ }) : null,
1205
+ /* @__PURE__ */ jsx8("section", {
1206
+ "aria-label": label,
1207
+ className: "iquji-table-frame__scroller",
1208
+ tabIndex: 0,
1209
+ children
1210
+ })
1211
+ ]
1212
+ });
1213
+ }
1214
+
1215
+ // src/data-table.tsx
1216
+ import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
1217
+ function IqujiDataTable({
1218
+ busy = false,
1219
+ columns,
1220
+ data,
1221
+ emptyBody = "当前筛选没有结果。",
1222
+ emptyTitle = "暂无数据",
1223
+ label,
1224
+ toolbar,
1225
+ onRowClick,
1226
+ rowKey,
1227
+ className
1228
+ }) {
1229
+ const table = useReactTable({
1230
+ columns,
1231
+ data,
1232
+ getCoreRowModel: getCoreRowModel(),
1233
+ ...rowKey ? { getRowId: (row) => rowKey(row) } : {}
1234
+ });
1235
+ if (data.length === 0) {
1236
+ return /* @__PURE__ */ jsx9(IqujiEmptyState, {
1237
+ body: emptyBody,
1238
+ title: emptyTitle
1239
+ });
1240
+ }
1241
+ return /* @__PURE__ */ jsx9(IqujiTableFrame, {
1242
+ busy,
1243
+ className,
1244
+ label,
1245
+ toolbar,
1246
+ children: /* @__PURE__ */ jsxs7("table", {
1247
+ className: "iquji-data-table",
1248
+ children: [
1249
+ /* @__PURE__ */ jsx9("thead", {
1250
+ children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx9("tr", {
1251
+ children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx9("th", {
1252
+ scope: "col",
1253
+ children: header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())
1254
+ }, header.id))
1255
+ }, headerGroup.id))
1256
+ }),
1257
+ /* @__PURE__ */ jsx9("tbody", {
1258
+ children: table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx9("tr", {
1259
+ "data-clickable": onRowClick ? "true" : undefined,
1260
+ onClick: onRowClick ? () => onRowClick(row.original) : undefined,
1261
+ onKeyDown: onRowClick ? (event) => {
1262
+ if (event.key === "Enter" || event.key === " ") {
1263
+ event.preventDefault();
1264
+ onRowClick(row.original);
1265
+ }
1266
+ } : undefined,
1267
+ tabIndex: onRowClick ? 0 : undefined,
1268
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx9("td", {
1269
+ children: flexRender(cell.column.columnDef.cell, cell.getContext())
1270
+ }, cell.id))
1271
+ }, row.id))
1272
+ })
1273
+ ]
1274
+ })
1275
+ });
1276
+ }
1277
+ // src/date-picker.tsx
1278
+ import { Popover as BasePopover2 } from "@base-ui/react/popover";
1279
+ import { IqujiIcon as IqujiIcon4 } from "@iquji-web/web-icons";
1280
+ import {
1281
+ forwardRef,
1282
+ useCallback as useCallback5,
1283
+ useId as useId2,
1284
+ useState as useState7
1285
+ } from "react";
1286
+ import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
1287
+ var IqujiDatePicker = forwardRef(function IqujiDatePicker2({
1288
+ "aria-invalid": ariaInvalid,
1289
+ allowClear = true,
1290
+ className,
1291
+ compact = false,
1292
+ defaultValue,
1293
+ disabled = false,
1294
+ disabledDate,
1295
+ iconStart,
1296
+ id,
1297
+ invalid = false,
1298
+ locale = "zh-CN",
1299
+ max,
1300
+ min,
1301
+ name,
1302
+ onChange,
1303
+ placeholder = "请选择日期",
1304
+ value,
1305
+ ...triggerProps
1306
+ }, ref) {
1307
+ const generatedId = useId2();
1308
+ const triggerId = id ?? `${generatedId}-datepicker`;
1309
+ const overlayContainer = useIqujiOverlayContainer();
1310
+ const [open, setOpen] = useState7(false);
1311
+ const [internalValue, setInternalValue] = useState7(defaultValue ?? null);
1312
+ const isControlled = value !== undefined;
1313
+ const currentValue = isControlled ? value : internalValue;
1314
+ const actualInvalid = invalid || ariaInvalid === true || ariaInvalid === "true";
1315
+ const handleDateChange = useCallback5((nextDate) => {
1316
+ if (!isControlled) {
1317
+ setInternalValue(nextDate);
1318
+ }
1319
+ onChange?.(nextDate);
1320
+ setOpen(false);
1321
+ }, [isControlled, onChange]);
1322
+ const handleClear = useCallback5((event) => {
1323
+ event?.stopPropagation();
1324
+ event?.preventDefault();
1325
+ if (!isControlled) {
1326
+ setInternalValue(null);
1327
+ }
1328
+ onChange?.(null);
1329
+ setOpen(false);
1330
+ }, [isControlled, onChange]);
1331
+ const names = classNames("iquji-date-picker", compact ? "iquji-date-picker--compact" : undefined, actualInvalid ? "is-invalid" : undefined, currentValue ? "has-value" : "is-empty", allowClear && Boolean(currentValue) && !disabled ? "has-clear" : undefined, className);
1332
+ return /* @__PURE__ */ jsxs8(BasePopover2.Root, {
1333
+ onOpenChange: (nextOpen) => {
1334
+ if (!disabled) {
1335
+ setOpen(nextOpen);
1336
+ }
1337
+ },
1338
+ open: open && !disabled,
1339
+ children: [
1340
+ /* @__PURE__ */ jsxs8("div", {
1341
+ className: classNames("iquji-date-picker__control", compact ? "iquji-date-picker__control--compact" : undefined),
1342
+ children: [
1343
+ /* @__PURE__ */ jsxs8(BasePopover2.Trigger, {
1344
+ ...triggerProps,
1345
+ "aria-haspopup": "dialog",
1346
+ "aria-invalid": actualInvalid || undefined,
1347
+ "aria-label": triggerProps["aria-label"] ?? placeholder,
1348
+ className: names,
1349
+ "data-disabled": disabled || undefined,
1350
+ "data-invalid": actualInvalid || undefined,
1351
+ disabled,
1352
+ id: triggerId,
1353
+ name,
1354
+ ref,
1355
+ type: "button",
1356
+ children: [
1357
+ iconStart ? /* @__PURE__ */ jsx10("span", {
1358
+ "aria-hidden": "true",
1359
+ className: "iquji-date-picker__start-icon",
1360
+ children: iconStart
1361
+ }) : null,
1362
+ /* @__PURE__ */ jsx10("span", {
1363
+ className: classNames("iquji-date-picker__value", !currentValue ? "iquji-date-picker__placeholder" : undefined),
1364
+ children: currentValue || placeholder
1365
+ }),
1366
+ /* @__PURE__ */ jsx10("span", {
1367
+ className: "iquji-date-picker__actions",
1368
+ children: /* @__PURE__ */ jsx10("span", {
1369
+ "aria-hidden": "true",
1370
+ className: "iquji-date-picker__indicator",
1371
+ children: /* @__PURE__ */ jsx10(IqujiIcon4, {
1372
+ decorative: true,
1373
+ name: "calendar",
1374
+ size: 15
1375
+ })
1376
+ })
1377
+ })
1378
+ ]
1379
+ }),
1380
+ allowClear && Boolean(currentValue) && !disabled ? /* @__PURE__ */ jsx10("button", {
1381
+ "aria-label": "清除日期",
1382
+ className: "iquji-date-picker__clear-btn",
1383
+ onClick: handleClear,
1384
+ type: "button",
1385
+ children: /* @__PURE__ */ jsx10(IqujiIcon4, {
1386
+ decorative: true,
1387
+ name: "close",
1388
+ size: 14
1389
+ })
1390
+ }) : null
1391
+ ]
1392
+ }),
1393
+ /* @__PURE__ */ jsx10(BasePopover2.Portal, {
1394
+ container: overlayContainer,
1395
+ children: /* @__PURE__ */ jsx10(BasePopover2.Positioner, {
1396
+ align: "start",
1397
+ className: "iquji-date-picker__positioner",
1398
+ sideOffset: 4,
1399
+ children: /* @__PURE__ */ jsx10(BasePopover2.Popup, {
1400
+ className: "iquji-date-picker__popup",
1401
+ "data-iquji-overlay": "date-picker",
1402
+ children: /* @__PURE__ */ jsx10(IqujiCalendar, {
1403
+ clearable: allowClear,
1404
+ defaultValue,
1405
+ disabledDate,
1406
+ locale,
1407
+ max,
1408
+ min,
1409
+ onChange: handleDateChange,
1410
+ onClear: handleClear,
1411
+ value: currentValue
1412
+ })
1413
+ })
1414
+ })
1415
+ })
1416
+ ]
1417
+ });
1418
+ });
1419
+ IqujiDatePicker.displayName = "IqujiDatePicker";
1420
+ // src/desktop-account.tsx
1421
+ import { IqujiIcon as IqujiIcon5 } from "@iquji-web/web-icons";
1422
+ import { useId as useId3, useState as useState8 } from "react";
1423
+ import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
1424
+ function AccountAvatar({
1425
+ avatar,
1426
+ avatarLabel,
1427
+ avatarTone = "accent",
1428
+ size
1429
+ }) {
1430
+ return /* @__PURE__ */ jsx11("span", {
1431
+ className: size === "sm" ? "iquji-desktop-account__trigger-avatar" : "iquji-desktop-account-card__avatar",
1432
+ "data-tone": avatarTone,
1433
+ children: avatar ?? avatarLabel ?? (size === "sm" ? /* @__PURE__ */ jsx11(IqujiIcon5, {
1434
+ decorative: true,
1435
+ name: "user",
1436
+ size: 16
1437
+ }) : /* @__PURE__ */ jsx11(IqujiIcon5, {
1438
+ decorative: true,
1439
+ name: "user",
1440
+ size: 20
1441
+ }))
1442
+ });
1443
+ }
1444
+ function IqujiDesktopAccountCard({
1445
+ name,
1446
+ secondary,
1447
+ badge,
1448
+ avatar,
1449
+ avatarLabel,
1450
+ avatarTone,
1451
+ usage,
1452
+ sections,
1453
+ footer,
1454
+ onItemSelect,
1455
+ className
1456
+ }) {
1457
+ const usageLabelId = useId3();
1458
+ const usageValue = usage && Number.isFinite(usage.value) ? Math.min(Math.max(usage.value, 0), 100) : 0;
1459
+ return /* @__PURE__ */ jsxs9("div", {
1460
+ className: classNames("iquji-desktop-account-card", className),
1461
+ children: [
1462
+ /* @__PURE__ */ jsxs9("div", {
1463
+ className: "iquji-desktop-account-card__header",
1464
+ children: [
1465
+ /* @__PURE__ */ jsx11(AccountAvatar, {
1466
+ avatar,
1467
+ avatarLabel,
1468
+ avatarTone,
1469
+ size: "md"
1470
+ }),
1471
+ /* @__PURE__ */ jsxs9("div", {
1472
+ className: "iquji-desktop-account-card__identity",
1473
+ children: [
1474
+ /* @__PURE__ */ jsx11("span", {
1475
+ className: "iquji-desktop-account-card__name",
1476
+ children: name
1477
+ }),
1478
+ secondary ? /* @__PURE__ */ jsx11("span", {
1479
+ className: "iquji-desktop-account-card__secondary",
1480
+ children: secondary
1481
+ }) : null,
1482
+ badge ? /* @__PURE__ */ jsx11("span", {
1483
+ className: "iquji-desktop-account-card__badge",
1484
+ children: badge
1485
+ }) : null
1486
+ ]
1487
+ })
1488
+ ]
1489
+ }),
1490
+ usage ? /* @__PURE__ */ jsxs9("div", {
1491
+ className: "iquji-desktop-account-card__usage",
1492
+ children: [
1493
+ /* @__PURE__ */ jsxs9("div", {
1494
+ className: "iquji-desktop-account-card__usage-copy",
1495
+ children: [
1496
+ /* @__PURE__ */ jsx11("span", {
1497
+ id: usageLabelId,
1498
+ children: usage.label
1499
+ }),
1500
+ usage.valueText ? /* @__PURE__ */ jsx11("span", {
1501
+ children: usage.valueText
1502
+ }) : null
1503
+ ]
1504
+ }),
1505
+ /* @__PURE__ */ jsx11("div", {
1506
+ "aria-labelledby": usageLabelId,
1507
+ "aria-valuemax": 100,
1508
+ "aria-valuemin": 0,
1509
+ "aria-valuenow": usageValue,
1510
+ className: "iquji-desktop-account-card__meter",
1511
+ "data-tone": usage.tone ?? "accent",
1512
+ role: "progressbar",
1513
+ children: /* @__PURE__ */ jsx11("span", {
1514
+ className: "iquji-desktop-account-card__meter-fill",
1515
+ style: { width: `${usageValue}%` }
1516
+ })
1517
+ })
1518
+ ]
1519
+ }) : null,
1520
+ /* @__PURE__ */ jsx11("div", {
1521
+ className: "iquji-desktop-account-card__sections",
1522
+ children: sections.map((section) => /* @__PURE__ */ jsx11("div", {
1523
+ className: "iquji-desktop-account-card__section",
1524
+ children: section.items.map((item) => /* @__PURE__ */ jsxs9("button", {
1525
+ "aria-keyshortcuts": item.keyshortcuts,
1526
+ className: "iquji-desktop-account-card__item",
1527
+ "data-tone": item.tone ?? "neutral",
1528
+ disabled: item.disabled,
1529
+ onClick: () => {
1530
+ item.onSelect?.();
1531
+ onItemSelect?.(item);
1532
+ },
1533
+ type: "button",
1534
+ children: [
1535
+ item.icon ? /* @__PURE__ */ jsx11("span", {
1536
+ "aria-hidden": "true",
1537
+ className: "iquji-desktop-account-card__item-icon",
1538
+ children: item.icon
1539
+ }) : null,
1540
+ /* @__PURE__ */ jsx11("span", {
1541
+ className: "iquji-desktop-account-card__item-label",
1542
+ children: item.label
1543
+ }),
1544
+ item.shortcut ? /* @__PURE__ */ jsx11("span", {
1545
+ "aria-hidden": "true",
1546
+ className: "iquji-desktop-account-card__item-shortcut",
1547
+ children: item.shortcut
1548
+ }) : null,
1549
+ item.trailing ? /* @__PURE__ */ jsx11("span", {
1550
+ "aria-hidden": "true",
1551
+ className: "iquji-desktop-account-card__item-trailing",
1552
+ children: item.trailing
1553
+ }) : null
1554
+ ]
1555
+ }, item.key))
1556
+ }, section.key))
1557
+ }),
1558
+ footer ? /* @__PURE__ */ jsx11("div", {
1559
+ className: "iquji-desktop-account-card__footer",
1560
+ children: footer
1561
+ }) : null
1562
+ ]
1563
+ });
1564
+ }
1565
+ function IqujiDesktopAccount({
1566
+ card,
1567
+ trigger,
1568
+ triggerLabel,
1569
+ open,
1570
+ onOpenChange,
1571
+ closeOnSelect = true
1572
+ }) {
1573
+ const [internalOpen, setInternalOpen] = useState8(false);
1574
+ const actualOpen = open ?? internalOpen;
1575
+ const changeOpen = (next) => {
1576
+ if (open === undefined) {
1577
+ setInternalOpen(next);
1578
+ }
1579
+ onOpenChange?.(next);
1580
+ };
1581
+ const triggerElement = trigger ?? /* @__PURE__ */ jsx11("button", {
1582
+ "aria-label": triggerLabel,
1583
+ className: "iquji-desktop-account__trigger",
1584
+ type: "button",
1585
+ children: /* @__PURE__ */ jsx11(AccountAvatar, {
1586
+ avatar: card.avatar,
1587
+ avatarLabel: card.avatarLabel,
1588
+ avatarTone: card.avatarTone,
1589
+ size: "sm"
1590
+ })
1591
+ });
1592
+ return /* @__PURE__ */ jsx11(IqujiPopover, {
1593
+ align: "start",
1594
+ onOpenChange: changeOpen,
1595
+ open: actualOpen,
1596
+ side: "top",
1597
+ trigger: triggerElement,
1598
+ children: /* @__PURE__ */ jsx11(IqujiDesktopAccountCard, {
1599
+ ...card,
1600
+ onItemSelect: (item) => {
1601
+ card.onItemSelect?.(item);
1602
+ if (closeOnSelect) {
1603
+ changeOpen(false);
1604
+ }
1605
+ }
1606
+ })
1607
+ });
1608
+ }
1609
+ // src/tooltip.tsx
1610
+ import { cloneElement, useId as useId4 } from "react";
1611
+ import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
1612
+ function IqujiTooltip({
1613
+ children,
1614
+ className,
1615
+ content,
1616
+ placement = "top"
1617
+ }) {
1618
+ const tooltipId = useId4();
1619
+ const describedBy = [children.props["aria-describedby"], tooltipId].filter(Boolean).join(" ");
1620
+ return /* @__PURE__ */ jsxs10("span", {
1621
+ className: classNames("iquji-tooltip", className),
1622
+ children: [
1623
+ cloneElement(children, { "aria-describedby": describedBy }),
1624
+ /* @__PURE__ */ jsx12("span", {
1625
+ className: "iquji-tooltip__content",
1626
+ "data-placement": placement,
1627
+ id: tooltipId,
1628
+ role: "tooltip",
1629
+ children: content
1630
+ })
1631
+ ]
1632
+ });
1633
+ }
1634
+
1635
+ // src/desktop-rail.tsx
1636
+ import { jsx as jsx13, jsxs as jsxs11, Fragment as Fragment4 } from "react/jsx-runtime";
1637
+ function IqujiDesktopRail({
1638
+ label,
1639
+ items,
1640
+ footer,
1641
+ showDivider = true,
1642
+ className
1643
+ }) {
1644
+ return /* @__PURE__ */ jsxs11("aside", {
1645
+ className: classNames("iquji-desktop-rail", className),
1646
+ "data-show-divider": showDivider ? "true" : "false",
1647
+ children: [
1648
+ /* @__PURE__ */ jsx13("nav", {
1649
+ "aria-label": label,
1650
+ className: "iquji-desktop-rail__nav",
1651
+ children: items.map((item) => {
1652
+ const content = /* @__PURE__ */ jsxs11(Fragment4, {
1653
+ children: [
1654
+ /* @__PURE__ */ jsx13("span", {
1655
+ "aria-hidden": "true",
1656
+ className: "iquji-desktop-rail__icon",
1657
+ children: item.icon
1658
+ }),
1659
+ item.badge ? /* @__PURE__ */ jsx13("span", {
1660
+ className: "iquji-desktop-rail__badge",
1661
+ children: item.badge
1662
+ }) : null
1663
+ ]
1664
+ });
1665
+ const trigger = item.href && !item.disabled ? /* @__PURE__ */ jsx13("a", {
1666
+ "aria-current": item.active ? "page" : undefined,
1667
+ "aria-label": item.label,
1668
+ className: "iquji-desktop-rail__item",
1669
+ "data-active": item.active || undefined,
1670
+ href: item.href,
1671
+ onClick: item.onSelect,
1672
+ onFocus: item.onIntent,
1673
+ onMouseEnter: item.onIntent,
1674
+ children: content
1675
+ }) : /* @__PURE__ */ jsx13("button", {
1676
+ "aria-current": item.active ? "page" : undefined,
1677
+ "aria-label": item.label,
1678
+ className: "iquji-desktop-rail__item",
1679
+ "data-active": item.active || undefined,
1680
+ disabled: item.disabled,
1681
+ onFocus: item.onIntent,
1682
+ onMouseEnter: item.onIntent,
1683
+ onClick: item.disabled ? undefined : item.onSelect,
1684
+ type: "button",
1685
+ children: content
1686
+ });
1687
+ return /* @__PURE__ */ jsx13(IqujiTooltip, {
1688
+ content: item.tooltip ?? item.label,
1689
+ placement: "right",
1690
+ children: trigger
1691
+ }, item.id);
1692
+ })
1693
+ }),
1694
+ footer ? /* @__PURE__ */ jsx13("div", {
1695
+ className: "iquji-desktop-rail__footer",
1696
+ children: footer
1697
+ }) : null
1698
+ ]
1699
+ });
1700
+ }
1701
+ // src/desktop-shell.tsx
1702
+ import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
1703
+ function IqujiDesktopShell({
1704
+ children,
1705
+ className,
1706
+ contentId = "iquji-desktop-content",
1707
+ rail,
1708
+ skipLinkLabel,
1709
+ windowBar,
1710
+ ...divProps
1711
+ }) {
1712
+ return /* @__PURE__ */ jsxs12("div", {
1713
+ ...divProps,
1714
+ className: classNames("iquji-desktop-shell", className),
1715
+ "data-has-window-bar": windowBar ? "true" : "false",
1716
+ children: [
1717
+ skipLinkLabel ? /* @__PURE__ */ jsx14("a", {
1718
+ className: "iquji-skip-link",
1719
+ href: `#${contentId}`,
1720
+ children: skipLinkLabel
1721
+ }) : null,
1722
+ windowBar,
1723
+ /* @__PURE__ */ jsxs12("div", {
1724
+ className: "iquji-desktop-shell__body",
1725
+ "data-has-rail": rail ? "true" : "false",
1726
+ children: [
1727
+ rail,
1728
+ /* @__PURE__ */ jsx14("main", {
1729
+ className: "iquji-desktop-shell__content",
1730
+ id: contentId,
1731
+ tabIndex: -1,
1732
+ children
1733
+ })
1734
+ ]
1735
+ })
1736
+ ]
1737
+ });
1738
+ }
1739
+ // src/desktop-tabs.tsx
1740
+ import { IqujiIcon as IqujiIcon6 } from "@iquji-web/web-icons";
1741
+ import {
1742
+ useRef as useRef6
1743
+ } from "react";
1744
+ import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
1745
+ function closeLabelOf(tab, closeTabLabel) {
1746
+ return tab.closeLabel ?? closeTabLabel?.(tab);
1747
+ }
1748
+ function IqujiDesktopTabStrip({
1749
+ tabs,
1750
+ activeTabId,
1751
+ label,
1752
+ onActiveTabChange,
1753
+ onTabClose,
1754
+ onTabAdd,
1755
+ addTabLabel,
1756
+ closeTabLabel,
1757
+ tabActions,
1758
+ className
1759
+ }) {
1760
+ const tabRefs = useRef6(new Map);
1761
+ const enabledTabs = tabs.filter((tab) => !tab.disabled);
1762
+ const enabledIndexById = new Map(enabledTabs.map((tab, index) => [tab.id, index]));
1763
+ const activeIndex = enabledTabs.findIndex((tab) => tab.id === activeTabId);
1764
+ const rovingIndex = activeIndex >= 0 ? activeIndex : 0;
1765
+ const activate = (id) => {
1766
+ onActiveTabChange?.(id);
1767
+ tabRefs.current.get(id)?.focus();
1768
+ };
1769
+ const moveFocus = (event, direction) => {
1770
+ if (enabledTabs.length === 0)
1771
+ return;
1772
+ const current = Math.max(0, enabledTabs.findIndex((tab) => tab.id === activeTabId));
1773
+ const next = enabledTabs[(current + direction + enabledTabs.length) % enabledTabs.length];
1774
+ if (!next)
1775
+ return;
1776
+ event.preventDefault();
1777
+ activate(next.id);
1778
+ };
1779
+ const handleTabKeyDown = (event) => {
1780
+ if (event.key === "ArrowRight") {
1781
+ moveFocus(event, 1);
1782
+ return;
1783
+ }
1784
+ if (event.key === "ArrowLeft") {
1785
+ moveFocus(event, -1);
1786
+ return;
1787
+ }
1788
+ if (event.key === "Home") {
1789
+ const first = enabledTabs[0];
1790
+ if (first) {
1791
+ event.preventDefault();
1792
+ activate(first.id);
1793
+ }
1794
+ return;
1795
+ }
1796
+ if (event.key === "End") {
1797
+ const last = enabledTabs[enabledTabs.length - 1];
1798
+ if (last) {
1799
+ event.preventDefault();
1800
+ activate(last.id);
1801
+ }
1802
+ return;
1803
+ }
1804
+ if (event.key === "Delete" && activeTabId && onTabClose) {
1805
+ const active = tabs.find((tab) => tab.id === activeTabId);
1806
+ if (active && !active.disabled && closeLabelOf(active, closeTabLabel)) {
1807
+ event.preventDefault();
1808
+ onTabClose(activeTabId);
1809
+ }
1810
+ }
1811
+ };
1812
+ return /* @__PURE__ */ jsxs13("div", {
1813
+ className: classNames("iquji-desktop-tabstrip", className),
1814
+ children: [
1815
+ tabs.length > 0 ? /* @__PURE__ */ jsx15("div", {
1816
+ "aria-label": label,
1817
+ className: "iquji-desktop-tabstrip__list",
1818
+ role: "tablist",
1819
+ children: tabs.map((tab) => {
1820
+ const active = tab.id === activeTabId;
1821
+ const closeLabel = closeLabelOf(tab, closeTabLabel);
1822
+ const canClose = Boolean(onTabClose && tab.closable !== false && closeLabel);
1823
+ return /* @__PURE__ */ jsxs13("div", {
1824
+ className: "iquji-desktop-tab",
1825
+ "data-active": active || undefined,
1826
+ role: "presentation",
1827
+ children: [
1828
+ /* @__PURE__ */ jsxs13("button", {
1829
+ "aria-selected": active,
1830
+ className: "iquji-desktop-tab__select",
1831
+ disabled: tab.disabled,
1832
+ onClick: () => onActiveTabChange?.(tab.id),
1833
+ onKeyDown: handleTabKeyDown,
1834
+ ref: (element) => {
1835
+ if (element) {
1836
+ tabRefs.current.set(tab.id, element);
1837
+ } else {
1838
+ tabRefs.current.delete(tab.id);
1839
+ }
1840
+ },
1841
+ role: "tab",
1842
+ tabIndex: tab.disabled ? -1 : enabledIndexById.get(tab.id) === rovingIndex ? 0 : -1,
1843
+ type: "button",
1844
+ children: [
1845
+ tab.icon ? /* @__PURE__ */ jsx15("span", {
1846
+ "aria-hidden": "true",
1847
+ className: "iquji-desktop-tab__icon",
1848
+ children: tab.icon
1849
+ }) : null,
1850
+ /* @__PURE__ */ jsx15("span", {
1851
+ className: "iquji-desktop-tab__label",
1852
+ children: tab.label
1853
+ }),
1854
+ tab.dirty ? /* @__PURE__ */ jsx15("span", {
1855
+ "aria-hidden": "true",
1856
+ className: "iquji-desktop-tab__dirty"
1857
+ }) : null
1858
+ ]
1859
+ }),
1860
+ canClose ? /* @__PURE__ */ jsx15(IconButton, {
1861
+ className: "iquji-desktop-tab__close",
1862
+ compact: true,
1863
+ icon: /* @__PURE__ */ jsx15(IqujiIcon6, {
1864
+ decorative: true,
1865
+ name: "close",
1866
+ size: 14
1867
+ }),
1868
+ label: closeLabel ?? "",
1869
+ onClick: () => onTabClose?.(tab.id),
1870
+ tabIndex: active ? 0 : -1
1871
+ }) : null
1872
+ ]
1873
+ }, tab.id);
1874
+ })
1875
+ }) : /* @__PURE__ */ jsx15("div", {
1876
+ className: "iquji-desktop-tabstrip__list"
1877
+ }),
1878
+ onTabAdd && addTabLabel ? /* @__PURE__ */ jsx15(IconButton, {
1879
+ className: "iquji-desktop-tabstrip__add",
1880
+ compact: true,
1881
+ icon: /* @__PURE__ */ jsx15(IqujiIcon6, {
1882
+ decorative: true,
1883
+ name: "plus",
1884
+ size: 15
1885
+ }),
1886
+ label: addTabLabel,
1887
+ onClick: onTabAdd
1888
+ }) : null,
1889
+ tabActions ? /* @__PURE__ */ jsx15("div", {
1890
+ className: "iquji-desktop-tabstrip__actions",
1891
+ children: tabActions
1892
+ }) : null
1893
+ ]
1894
+ });
1895
+ }
1896
+ // src/desktop-titlebar.tsx
1897
+ import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
1898
+ function lengthOf(value) {
1899
+ return typeof value === "number" ? `${value}px` : value;
1900
+ }
1901
+ function hasLength(value) {
1902
+ return typeof value === "number" ? value > 0 : value.trim() !== "";
1903
+ }
1904
+ function IqujiDesktopTitleBar({
1905
+ actions,
1906
+ children,
1907
+ className,
1908
+ dragRegion = false,
1909
+ leading,
1910
+ style,
1911
+ windowControls,
1912
+ windowControlsPlacement = "start",
1913
+ windowControlsSpace = 0,
1914
+ ...headerProps
1915
+ }) {
1916
+ const reserveSpace = typeof windowControlsSpace === "number" ? windowControlsSpace > 0 : hasLength(windowControlsSpace);
1917
+ const reservedStyle = reserveSpace ? windowControlsPlacement === "start" ? { paddingLeft: lengthOf(windowControlsSpace) } : { paddingRight: lengthOf(windowControlsSpace) } : undefined;
1918
+ return /* @__PURE__ */ jsxs14("header", {
1919
+ ...headerProps,
1920
+ className: classNames("iquji-desktop-titlebar", className),
1921
+ "data-iquji-drag-region": dragRegion || undefined,
1922
+ style: { ...style, ...reservedStyle },
1923
+ children: [
1924
+ windowControlsPlacement === "start" && windowControls ? /* @__PURE__ */ jsx16("div", {
1925
+ className: "iquji-desktop-titlebar__window-controls",
1926
+ children: windowControls
1927
+ }) : null,
1928
+ leading ? /* @__PURE__ */ jsx16("div", {
1929
+ className: "iquji-desktop-titlebar__leading",
1930
+ children: leading
1931
+ }) : null,
1932
+ /* @__PURE__ */ jsx16("div", {
1933
+ className: "iquji-desktop-titlebar__center",
1934
+ children
1935
+ }),
1936
+ actions ? /* @__PURE__ */ jsx16("div", {
1937
+ className: "iquji-desktop-titlebar__actions",
1938
+ children: actions
1939
+ }) : null,
1940
+ windowControlsPlacement === "end" && windowControls ? /* @__PURE__ */ jsx16("div", {
1941
+ className: "iquji-desktop-titlebar__window-controls",
1942
+ children: windowControls
1943
+ }) : null
1944
+ ]
1945
+ });
1946
+ }
1947
+ // src/drawer.tsx
1948
+ import { Drawer } from "@base-ui/react/drawer";
1949
+ import { IqujiIcon as IqujiIcon7 } from "@iquji-web/web-icons";
1950
+ import {
1951
+ useId as useId5,
1952
+ useState as useState9
1953
+ } from "react";
1954
+ import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
1955
+ var widths2 = {
1956
+ sm: "min(92vw, 420px)",
1957
+ md: "min(92vw, 720px)",
1958
+ lg: "min(94vw, 960px)",
1959
+ xl: "min(96vw, 1180px)"
1960
+ };
1961
+ function widthOf(value) {
1962
+ return typeof value === "number" ? `${value}px` : widths2[value] ?? value;
1963
+ }
1964
+ function IqujiDrawer(props) {
1965
+ return /* @__PURE__ */ jsx17(IqujiOverlayBoundary, {
1966
+ children: /* @__PURE__ */ jsx17(DrawerContent, {
1967
+ ...props
1968
+ })
1969
+ });
1970
+ }
1971
+ function DrawerContent({
1972
+ open,
1973
+ onOpenChange,
1974
+ onCloseComplete,
1975
+ onEscape,
1976
+ initialFocusRef,
1977
+ title,
1978
+ description,
1979
+ closeLabel,
1980
+ headerMeta,
1981
+ headerToolbar,
1982
+ actions,
1983
+ actionBarLayout = "end",
1984
+ children,
1985
+ size = "md",
1986
+ width,
1987
+ surface = "panel",
1988
+ className,
1989
+ bodyClassName,
1990
+ destroyOnClose = false
1991
+ }) {
1992
+ const id = useId5();
1993
+ const [container, setContainer] = useState9(null);
1994
+ const presence = useIqujiOverlayPresence(open, onCloseComplete);
1995
+ const layer = useIqujiOverlayLayer(id, "drawer", presence.active, open, container);
1996
+ const focus = useIqujiOverlayModal(open, layer.isTopLayer);
1997
+ const finalFocus = useIqujiOverlayReturnFocus(open);
1998
+ useIqujiOverlayCompletion(presence, layer.registered, finalFocus);
1999
+ return /* @__PURE__ */ jsx17(IqujiOverlayAncestry, {
2000
+ id,
2001
+ children: /* @__PURE__ */ jsx17(Drawer.Root, {
2002
+ open,
2003
+ modal: focus.modal,
2004
+ swipeDirection: "right",
2005
+ onOpenChange: (next, details) => {
2006
+ if (!next && (!layer.isTopLayer || details.reason === "escape-key" && onEscape?.())) {
2007
+ details.cancel();
2008
+ return;
2009
+ }
2010
+ onOpenChange?.(next);
2011
+ },
2012
+ onOpenChangeComplete: (next) => {
2013
+ if (!next)
2014
+ restoreIqujiOverlayFocus(finalFocus);
2015
+ presence.complete(next);
2016
+ },
2017
+ children: /* @__PURE__ */ jsxs15(Drawer.Portal, {
2018
+ keepMounted: !destroyOnClose,
2019
+ container: typeof document === "undefined" ? undefined : document.body,
2020
+ children: [
2021
+ /* @__PURE__ */ jsx17(Drawer.Backdrop, {
2022
+ forceRender: true,
2023
+ className: "iquji-overlay-backdrop iquji-drawer-backdrop",
2024
+ style: { zIndex: layer.backdrop }
2025
+ }),
2026
+ /* @__PURE__ */ jsx17("div", {
2027
+ ref: setContainer,
2028
+ className: "iquji-overlay-floating-layer",
2029
+ "data-iquji-overlay-portal": "",
2030
+ style: { zIndex: layer.floating }
2031
+ }),
2032
+ /* @__PURE__ */ jsx17(Drawer.Popup, {
2033
+ onFocusCapture: focus.onFocusCapture,
2034
+ initialFocus: !open || layer.isTopLayer ? resolveIqujiOverlayInitialFocus(initialFocusRef) : false,
2035
+ "data-iquji-overlay-surface": "",
2036
+ finalFocus,
2037
+ className: classNames("iquji-drawer", surface === "canvas" && "iquji-drawer--canvas", className),
2038
+ style: { width: widthOf(width ?? size), zIndex: layer.surface },
2039
+ children: /* @__PURE__ */ jsxs15(IqujiOverlayScopeProvider, {
2040
+ container,
2041
+ children: [
2042
+ (title || description || headerMeta) && /* @__PURE__ */ jsxs15("header", {
2043
+ className: "iquji-drawer__header",
2044
+ children: [
2045
+ /* @__PURE__ */ jsxs15("div", {
2046
+ className: "iquji-drawer__heading",
2047
+ children: [
2048
+ title && /* @__PURE__ */ jsx17(Drawer.Title, {
2049
+ className: "iquji-dialog__title",
2050
+ children: title
2051
+ }),
2052
+ description && /* @__PURE__ */ jsx17(Drawer.Description, {
2053
+ className: "iquji-dialog__description",
2054
+ children: description
2055
+ })
2056
+ ]
2057
+ }),
2058
+ headerMeta && /* @__PURE__ */ jsx17("div", {
2059
+ className: "iquji-drawer__meta",
2060
+ children: headerMeta
2061
+ }),
2062
+ /* @__PURE__ */ jsx17(Drawer.Close, {
2063
+ render: /* @__PURE__ */ jsx17(IconButton, {
2064
+ label: closeLabel,
2065
+ icon: /* @__PURE__ */ jsx17(IqujiIcon7, {
2066
+ name: "close"
2067
+ })
2068
+ })
2069
+ })
2070
+ ]
2071
+ }),
2072
+ headerToolbar && /* @__PURE__ */ jsx17("div", {
2073
+ className: "iquji-drawer__toolbar",
2074
+ children: headerToolbar
2075
+ }),
2076
+ /* @__PURE__ */ jsx17("div", {
2077
+ className: classNames("iquji-drawer__body", bodyClassName),
2078
+ children
2079
+ }),
2080
+ actions && /* @__PURE__ */ jsx17("footer", {
2081
+ className: "iquji-drawer__actions",
2082
+ children: /* @__PURE__ */ jsx17("div", {
2083
+ className: classNames("iquji-drawer__action-row", actionBarLayout === "full" && "iquji-drawer__action-row--full"),
2084
+ children: actions
2085
+ })
2086
+ })
2087
+ ]
2088
+ })
2089
+ })
2090
+ ]
2091
+ })
2092
+ })
2093
+ });
2094
+ }
2095
+ // src/feedback.tsx
2096
+ import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
2097
+ function IqujiBadge({
2098
+ className,
2099
+ tone = "neutral",
2100
+ ...spanProps
2101
+ }) {
2102
+ return /* @__PURE__ */ jsx18("span", {
2103
+ className: classNames("iquji-badge", className),
2104
+ "data-tone": tone,
2105
+ ...spanProps
2106
+ });
2107
+ }
2108
+ function IqujiAlert({
2109
+ children,
2110
+ className,
2111
+ role,
2112
+ title,
2113
+ tone = "info",
2114
+ ...divProps
2115
+ }) {
2116
+ return /* @__PURE__ */ jsxs16("div", {
2117
+ className: classNames("iquji-alert", className),
2118
+ "data-tone": tone,
2119
+ role: role ?? (tone === "danger" ? "alert" : "status"),
2120
+ ...divProps,
2121
+ children: [
2122
+ title ? /* @__PURE__ */ jsx18("div", {
2123
+ className: "iquji-alert__title",
2124
+ children: title
2125
+ }) : null,
2126
+ /* @__PURE__ */ jsx18("div", {
2127
+ className: "iquji-alert__body",
2128
+ children
2129
+ })
2130
+ ]
2131
+ });
2132
+ }
2133
+ function IqujiSkeleton({
2134
+ className,
2135
+ height,
2136
+ shape = "line",
2137
+ style,
2138
+ width,
2139
+ ...spanProps
2140
+ }) {
2141
+ return /* @__PURE__ */ jsx18("span", {
2142
+ "aria-hidden": "true",
2143
+ className: classNames("iquji-skeleton", className),
2144
+ "data-shape": shape,
2145
+ style: { ...style, height, width },
2146
+ ...spanProps
2147
+ });
2148
+ }
2149
+ function IqujiAsyncStateFrame({
2150
+ children,
2151
+ className,
2152
+ emptyFallback,
2153
+ errorFallback,
2154
+ loadingFallback,
2155
+ refreshLabel,
2156
+ state,
2157
+ ...divProps
2158
+ }) {
2159
+ const content = state === "loading" ? loadingFallback : state === "empty" ? emptyFallback : state === "error" ? errorFallback : children;
2160
+ return /* @__PURE__ */ jsxs16("div", {
2161
+ "aria-busy": state === "loading" || state === "refreshing",
2162
+ className: classNames("iquji-async-state-frame", className),
2163
+ "data-state": state,
2164
+ ...divProps,
2165
+ children: [
2166
+ content,
2167
+ state === "refreshing" && refreshLabel ? /* @__PURE__ */ jsx18("div", {
2168
+ className: "iquji-async-state-frame__progress",
2169
+ role: "status",
2170
+ children: /* @__PURE__ */ jsx18("span", {
2171
+ className: "iquji-visually-hidden",
2172
+ children: refreshLabel
2173
+ })
2174
+ }) : null,
2175
+ state === "refreshing" && !refreshLabel ? /* @__PURE__ */ jsx18("div", {
2176
+ "aria-hidden": "true",
2177
+ className: "iquji-async-state-frame__progress"
2178
+ }) : null
2179
+ ]
2180
+ });
2181
+ }
2182
+ // src/form-dialog.tsx
2183
+ import { IqujiIcon as IqujiIcon8 } from "@iquji-web/web-icons";
2184
+
2185
+ // src/form-dialog-resize.tsx
2186
+ import { Component, createRef } from "react";
2187
+
2188
+ class FormDialogResize extends Component {
2189
+ popup = createRef();
2190
+ animation = null;
2191
+ motion = null;
2192
+ componentDidMount() {
2193
+ this.motion = window.matchMedia("(prefers-reduced-motion: reduce)");
2194
+ this.motion.addEventListener("change", this.preferenceChanged);
2195
+ window.addEventListener("resize", this.stop);
2196
+ }
2197
+ getSnapshotBeforeUpdate(previous) {
2198
+ if (!previous.open || !this.props.open || previous.expanded === this.props.expanded)
2199
+ return null;
2200
+ const bounds = this.popup.current?.getBoundingClientRect();
2201
+ return bounds ? { width: bounds.width, height: bounds.height } : null;
2202
+ }
2203
+ componentDidUpdate(_previous, _state, before) {
2204
+ if (!this.props.open) {
2205
+ this.stop();
2206
+ return;
2207
+ }
2208
+ if (!before)
2209
+ return;
2210
+ this.stop();
2211
+ const popup = this.popup.current;
2212
+ if (!popup || this.motion?.matches || typeof popup.animate !== "function")
2213
+ return;
2214
+ const after = popup.getBoundingClientRect();
2215
+ if (before.width === after.width && before.height === after.height)
2216
+ return;
2217
+ const style = getComputedStyle(popup);
2218
+ const token = style.getPropertyValue("--iquji-motion-overlay").trim();
2219
+ const duration = Number.parseFloat(token) * (token.endsWith("ms") ? 1 : 1000);
2220
+ if (!Number.isFinite(duration) || duration <= 0)
2221
+ return;
2222
+ const animation = popup.animate([
2223
+ {
2224
+ width: `${before.width}px`,
2225
+ height: `${before.height}px`,
2226
+ maxHeight: `${before.height}px`
2227
+ },
2228
+ {
2229
+ width: `${after.width}px`,
2230
+ height: `${after.height}px`,
2231
+ maxHeight: `${after.height}px`
2232
+ }
2233
+ ], {
2234
+ duration,
2235
+ easing: style.getPropertyValue("--iquji-ease-standard").trim() || "ease"
2236
+ });
2237
+ this.animation = animation;
2238
+ animation.onfinish = () => {
2239
+ if (this.animation === animation)
2240
+ this.animation = null;
2241
+ };
2242
+ }
2243
+ componentWillUnmount() {
2244
+ this.stop();
2245
+ this.motion?.removeEventListener("change", this.preferenceChanged);
2246
+ window.removeEventListener("resize", this.stop);
2247
+ }
2248
+ stop = () => {
2249
+ const animation = this.animation;
2250
+ this.animation = null;
2251
+ animation?.cancel();
2252
+ };
2253
+ preferenceChanged = () => {
2254
+ if (this.motion?.matches)
2255
+ this.stop();
2256
+ };
2257
+ render() {
2258
+ return this.props.children(this.popup);
2259
+ }
2260
+ }
2261
+
2262
+ // src/form-dialog.tsx
2263
+ import { jsx as jsx19, jsxs as jsxs17, Fragment as Fragment5 } from "react/jsx-runtime";
2264
+ function IqujiFormDialog({
2265
+ expanded,
2266
+ onExpandedChange,
2267
+ expandLabel,
2268
+ collapseLabel,
2269
+ className,
2270
+ headerActions,
2271
+ width,
2272
+ ...props
2273
+ }) {
2274
+ return /* @__PURE__ */ jsx19(FormDialogResize, {
2275
+ open: props.open,
2276
+ expanded,
2277
+ children: (popupRef) => /* @__PURE__ */ jsx19(IqujiDialog, {
2278
+ ...props,
2279
+ popupRef,
2280
+ className: classNames("iquji-form-dialog", expanded && "iquji-form-dialog--expanded", className),
2281
+ width: expanded ? "min(calc(100vw - 48px), 1000px)" : width,
2282
+ headerActions: /* @__PURE__ */ jsxs17(Fragment5, {
2283
+ children: [
2284
+ headerActions,
2285
+ /* @__PURE__ */ jsx19(IconButton, {
2286
+ "aria-expanded": expanded,
2287
+ icon: /* @__PURE__ */ jsx19(IqujiIcon8, {
2288
+ decorative: true,
2289
+ name: expanded ? "minimize" : "maximize"
2290
+ }),
2291
+ label: expanded ? collapseLabel : expandLabel,
2292
+ onClick: () => onExpandedChange(!expanded)
2293
+ })
2294
+ ]
2295
+ })
2296
+ })
2297
+ });
2298
+ }
2299
+ // src/form-steps.tsx
2300
+ import { IqujiIcon as IqujiIcon9 } from "@iquji-web/web-icons";
2301
+ import { useId as useId6, useRef as useRef7 } from "react";
2302
+ import { jsx as jsx20, jsxs as jsxs18 } from "react/jsx-runtime";
2303
+ function IqujiFormSteps({
2304
+ label,
2305
+ steps,
2306
+ value,
2307
+ onChange,
2308
+ className,
2309
+ completedLabel
2310
+ }) {
2311
+ const id = useId6();
2312
+ const refs = useRef7(new Map);
2313
+ const enabled = steps.filter((step) => !step.disabled);
2314
+ const selectedEnabled = enabled.some((step) => step.id === value);
2315
+ const moveFocus = (event, current) => {
2316
+ if (event.nativeEvent.isComposing || event.keyCode === 229 || !enabled.length)
2317
+ return;
2318
+ const index = enabled.findIndex((step) => step.id === current);
2319
+ let next;
2320
+ if (event.key === "Home")
2321
+ next = enabled[0];
2322
+ else if (event.key === "End")
2323
+ next = enabled.at(-1);
2324
+ else if (event.key === "ArrowRight" || event.key === "ArrowDown")
2325
+ next = enabled[(index + 1) % enabled.length];
2326
+ else if (event.key === "ArrowLeft" || event.key === "ArrowUp")
2327
+ next = enabled[(index - 1 + enabled.length) % enabled.length];
2328
+ if (next) {
2329
+ event.preventDefault();
2330
+ refs.current.get(next.id)?.focus();
2331
+ }
2332
+ };
2333
+ return /* @__PURE__ */ jsx20("nav", {
2334
+ "aria-label": label,
2335
+ className: classNames("iquji-form-steps", className),
2336
+ children: /* @__PURE__ */ jsx20("ol", {
2337
+ children: steps.map((step, index) => /* @__PURE__ */ jsx20("li", {
2338
+ children: /* @__PURE__ */ jsxs18("button", {
2339
+ "aria-current": step.id === value ? "step" : undefined,
2340
+ "aria-label": typeof step.label === "string" ? step.label : undefined,
2341
+ "aria-describedby": [
2342
+ step.description && `${id}-${step.id}-description`,
2343
+ step.completed && completedLabel && `${id}-${step.id}-completed`
2344
+ ].filter(Boolean).join(" ") || undefined,
2345
+ "aria-labelledby": typeof step.label === "string" ? undefined : `${id}-${step.id}-label`,
2346
+ className: classNames("iquji-form-steps__step", step.completed && "iquji-form-steps__step--completed"),
2347
+ disabled: step.disabled,
2348
+ onClick: () => onChange(step.id),
2349
+ onKeyDown: (event) => moveFocus(event, step.id),
2350
+ ref: (element) => {
2351
+ if (element)
2352
+ refs.current.set(step.id, element);
2353
+ else
2354
+ refs.current.delete(step.id);
2355
+ },
2356
+ tabIndex: !step.disabled && (step.id === value || !selectedEnabled && step === enabled[0]) ? 0 : -1,
2357
+ type: "button",
2358
+ children: [
2359
+ /* @__PURE__ */ jsx20("span", {
2360
+ "aria-hidden": "true",
2361
+ className: "iquji-form-steps__marker",
2362
+ children: step.completed ? /* @__PURE__ */ jsx20(IqujiIcon9, {
2363
+ decorative: true,
2364
+ name: "check"
2365
+ }) : index + 1
2366
+ }),
2367
+ /* @__PURE__ */ jsxs18("span", {
2368
+ className: "iquji-form-steps__text",
2369
+ children: [
2370
+ /* @__PURE__ */ jsx20("span", {
2371
+ id: `${id}-${step.id}-label`,
2372
+ className: "iquji-form-steps__label",
2373
+ children: step.label
2374
+ }),
2375
+ step.description && /* @__PURE__ */ jsx20("span", {
2376
+ id: `${id}-${step.id}-description`,
2377
+ className: "iquji-form-steps__description",
2378
+ children: step.description
2379
+ }),
2380
+ step.completed && completedLabel && /* @__PURE__ */ jsx20("span", {
2381
+ id: `${id}-${step.id}-completed`,
2382
+ className: "iquji-form-steps__status",
2383
+ children: completedLabel
2384
+ })
2385
+ ]
2386
+ })
2387
+ ]
2388
+ })
2389
+ }, step.id))
2390
+ })
2391
+ });
2392
+ }
2393
+ // src/forms.tsx
2394
+ import { Select as BaseSelect } from "@base-ui/react/select";
2395
+ import { IqujiIcon as IqujiIcon10 } from "@iquji-web/web-icons";
2396
+ import {
2397
+ cloneElement as cloneElement2,
2398
+ forwardRef as forwardRef2,
2399
+ useId as useId7
2400
+ } from "react";
2401
+ import { jsx as jsx21, jsxs as jsxs19 } from "react/jsx-runtime";
2402
+ function IqujiField({
2403
+ children,
2404
+ className,
2405
+ description,
2406
+ error,
2407
+ id,
2408
+ label,
2409
+ required = false
2410
+ }) {
2411
+ const generatedId = useId7();
2412
+ const controlId = children.props.id ?? id ?? `${generatedId}-control`;
2413
+ const descriptionId = description ? `${controlId}-description` : undefined;
2414
+ const errorId = error ? `${controlId}-error` : undefined;
2415
+ const actualRequired = required || children.props.required === true;
2416
+ const describedBy = [
2417
+ children.props["aria-describedby"],
2418
+ descriptionId,
2419
+ errorId
2420
+ ].filter(Boolean).join(" ");
2421
+ const controlProps = {
2422
+ id: controlId,
2423
+ required: actualRequired
2424
+ };
2425
+ if (describedBy) {
2426
+ controlProps["aria-describedby"] = describedBy;
2427
+ }
2428
+ if (error) {
2429
+ controlProps["aria-invalid"] = true;
2430
+ }
2431
+ return /* @__PURE__ */ jsxs19("div", {
2432
+ className: classNames("iquji-field", className),
2433
+ children: [
2434
+ /* @__PURE__ */ jsxs19("label", {
2435
+ className: "iquji-field__label",
2436
+ htmlFor: controlId,
2437
+ children: [
2438
+ label,
2439
+ actualRequired ? /* @__PURE__ */ jsx21("span", {
2440
+ "aria-hidden": "true",
2441
+ children: "*"
2442
+ }) : null
2443
+ ]
2444
+ }),
2445
+ cloneElement2(children, controlProps),
2446
+ description ? /* @__PURE__ */ jsx21("div", {
2447
+ className: "iquji-field__description",
2448
+ id: descriptionId,
2449
+ children: description
2450
+ }) : null,
2451
+ error ? /* @__PURE__ */ jsx21("div", {
2452
+ className: "iquji-field__error",
2453
+ id: errorId,
2454
+ role: "alert",
2455
+ children: error
2456
+ }) : null
2457
+ ]
2458
+ });
2459
+ }
2460
+ var IqujiInput = forwardRef2(function IqujiInput2({ className, ...inputProps }, ref) {
2461
+ return /* @__PURE__ */ jsx21("input", {
2462
+ className: classNames("iquji-input", className),
2463
+ ref,
2464
+ ...inputProps
2465
+ });
2466
+ });
2467
+ var IqujiTextarea = forwardRef2(function IqujiTextarea2({ className, ...textareaProps }, ref) {
2468
+ return /* @__PURE__ */ jsx21("textarea", {
2469
+ className: classNames("iquji-textarea", className),
2470
+ ref,
2471
+ ...textareaProps
2472
+ });
2473
+ });
2474
+ function IqujiSelect({
2475
+ "aria-invalid": ariaInvalid,
2476
+ autoComplete,
2477
+ className,
2478
+ compact = false,
2479
+ defaultValue,
2480
+ disabled = false,
2481
+ groups,
2482
+ iconStart,
2483
+ id,
2484
+ invalid = false,
2485
+ name,
2486
+ onValueChange,
2487
+ options,
2488
+ placeholder,
2489
+ ref,
2490
+ required = false,
2491
+ triggerPresentation = "value",
2492
+ value,
2493
+ ...triggerProps
2494
+ }) {
2495
+ const overlayContainer = useIqujiOverlayContainer();
2496
+ const allOptions = groups ? groups.flatMap((group) => group.options) : options;
2497
+ const renderOptions = (entries) => entries.map((option, index) => /* @__PURE__ */ jsxs19(BaseSelect.Item, {
2498
+ className: "iquji-select__item",
2499
+ disabled: option.disabled,
2500
+ value: option.value,
2501
+ children: [
2502
+ /* @__PURE__ */ jsx21(BaseSelect.ItemText, {
2503
+ className: "iquji-select__item-text",
2504
+ children: option.label
2505
+ }),
2506
+ /* @__PURE__ */ jsx21(BaseSelect.ItemIndicator, {
2507
+ className: "iquji-select__item-indicator",
2508
+ children: /* @__PURE__ */ jsx21(IqujiIcon10, {
2509
+ decorative: true,
2510
+ name: "check",
2511
+ size: 16
2512
+ })
2513
+ })
2514
+ ]
2515
+ }, option.key ?? `${index}:${String(option.value)}`));
2516
+ const actualInvalid = invalid || ariaInvalid === true || ariaInvalid === "true";
2517
+ const names = classNames("iquji-select", compact ? "iquji-select--compact" : undefined, triggerPresentation === "icon-only" ? "iquji-select--icon-only" : undefined, className);
2518
+ const triggerTitle = triggerProps.title ?? (triggerPresentation === "icon-only" && typeof triggerProps["aria-label"] === "string" ? triggerProps["aria-label"] : undefined);
2519
+ const triggerAriaLabel = triggerProps["aria-label"] ?? (triggerPresentation === "icon-only" && typeof triggerProps.title === "string" ? triggerProps.title : undefined);
2520
+ return /* @__PURE__ */ jsxs19(BaseSelect.Root, {
2521
+ autoComplete,
2522
+ defaultValue,
2523
+ disabled,
2524
+ id,
2525
+ items: allOptions,
2526
+ name,
2527
+ onOpenChange: (_open, details) => {
2528
+ if (details.reason === "escape-key") {
2529
+ details.event.stopPropagation();
2530
+ }
2531
+ },
2532
+ onValueChange: (nextValue) => onValueChange?.(nextValue),
2533
+ required,
2534
+ value,
2535
+ children: [
2536
+ /* @__PURE__ */ jsxs19(BaseSelect.Trigger, {
2537
+ ...triggerProps,
2538
+ "aria-label": triggerAriaLabel,
2539
+ "aria-invalid": actualInvalid || undefined,
2540
+ className: names,
2541
+ "data-invalid": actualInvalid || undefined,
2542
+ "data-trigger-presentation": triggerPresentation,
2543
+ title: triggerTitle,
2544
+ ref,
2545
+ children: [
2546
+ iconStart ? /* @__PURE__ */ jsx21("span", {
2547
+ "aria-hidden": "true",
2548
+ className: "iquji-select__start-icon",
2549
+ children: iconStart
2550
+ }) : null,
2551
+ /* @__PURE__ */ jsx21(BaseSelect.Value, {
2552
+ "aria-hidden": triggerPresentation === "icon-only" || undefined,
2553
+ className: "iquji-select__value",
2554
+ placeholder
2555
+ }),
2556
+ /* @__PURE__ */ jsx21(BaseSelect.Icon, {
2557
+ "aria-hidden": "true",
2558
+ className: "iquji-select__indicator",
2559
+ children: /* @__PURE__ */ jsx21(IqujiIcon10, {
2560
+ decorative: true,
2561
+ name: "chevron-down",
2562
+ size: 16
2563
+ })
2564
+ })
2565
+ ]
2566
+ }),
2567
+ /* @__PURE__ */ jsx21(BaseSelect.Portal, {
2568
+ className: "iquji-select__portal",
2569
+ container: overlayContainer,
2570
+ children: /* @__PURE__ */ jsx21(BaseSelect.Positioner, {
2571
+ align: triggerPresentation === "icon-only" ? "end" : "start",
2572
+ alignItemWithTrigger: false,
2573
+ className: "iquji-select__positioner",
2574
+ sideOffset: 4,
2575
+ children: /* @__PURE__ */ jsxs19(BaseSelect.Popup, {
2576
+ className: "iquji-select__popup",
2577
+ "data-iquji-overlay": "select",
2578
+ finalFocus: true,
2579
+ children: [
2580
+ /* @__PURE__ */ jsx21(BaseSelect.ScrollUpArrow, {
2581
+ className: "iquji-select__scroll-arrow",
2582
+ children: /* @__PURE__ */ jsx21(IqujiIcon10, {
2583
+ decorative: true,
2584
+ name: "arrow-up",
2585
+ size: 15
2586
+ })
2587
+ }),
2588
+ /* @__PURE__ */ jsx21(BaseSelect.List, {
2589
+ className: "iquji-select__list",
2590
+ children: groups ? groups.map((group) => /* @__PURE__ */ jsxs19(BaseSelect.Group, {
2591
+ className: "iquji-select__group",
2592
+ children: [
2593
+ /* @__PURE__ */ jsx21(BaseSelect.GroupLabel, {
2594
+ className: "iquji-select__group-label",
2595
+ children: group.label
2596
+ }),
2597
+ renderOptions(group.options)
2598
+ ]
2599
+ }, group.key)) : renderOptions(options)
2600
+ }),
2601
+ /* @__PURE__ */ jsx21(BaseSelect.ScrollDownArrow, {
2602
+ className: "iquji-select__scroll-arrow",
2603
+ children: /* @__PURE__ */ jsx21(IqujiIcon10, {
2604
+ decorative: true,
2605
+ name: "arrow-down",
2606
+ size: 15
2607
+ })
2608
+ })
2609
+ ]
2610
+ })
2611
+ })
2612
+ })
2613
+ ]
2614
+ });
2615
+ }
2616
+ function IqujiChoice({
2617
+ "aria-describedby": ariaDescribedBy,
2618
+ className,
2619
+ description,
2620
+ label,
2621
+ type,
2622
+ ...inputProps
2623
+ }) {
2624
+ const descriptionId = useId7();
2625
+ const describedBy = [ariaDescribedBy, description ? descriptionId : undefined].filter(Boolean).join(" ");
2626
+ return /* @__PURE__ */ jsxs19("label", {
2627
+ className: classNames("iquji-choice", className),
2628
+ children: [
2629
+ /* @__PURE__ */ jsx21("input", {
2630
+ "aria-describedby": describedBy || undefined,
2631
+ type,
2632
+ ...inputProps
2633
+ }),
2634
+ /* @__PURE__ */ jsx21("span", {
2635
+ className: "iquji-choice__control",
2636
+ "aria-hidden": "true"
2637
+ }),
2638
+ /* @__PURE__ */ jsxs19("span", {
2639
+ className: "iquji-choice__content",
2640
+ children: [
2641
+ /* @__PURE__ */ jsx21("span", {
2642
+ className: "iquji-choice__label",
2643
+ children: label
2644
+ }),
2645
+ description ? /* @__PURE__ */ jsx21("span", {
2646
+ className: "iquji-choice__description",
2647
+ id: descriptionId,
2648
+ children: description
2649
+ }) : null
2650
+ ]
2651
+ })
2652
+ ]
2653
+ });
2654
+ }
2655
+ function IqujiCheckbox(props) {
2656
+ return /* @__PURE__ */ jsx21(IqujiChoice, {
2657
+ type: "checkbox",
2658
+ ...props
2659
+ });
2660
+ }
2661
+ function IqujiRadio(props) {
2662
+ return /* @__PURE__ */ jsx21(IqujiChoice, {
2663
+ type: "radio",
2664
+ ...props
2665
+ });
2666
+ }
2667
+ function IqujiSwitch({ className, ...props }) {
2668
+ return /* @__PURE__ */ jsx21(IqujiChoice, {
2669
+ className: classNames("iquji-switch", className),
2670
+ role: "switch",
2671
+ type: "checkbox",
2672
+ ...props
2673
+ });
2674
+ }
2675
+ function IqujiSegmentedControl({
2676
+ className,
2677
+ disabled = false,
2678
+ label,
2679
+ onChange,
2680
+ options,
2681
+ value
2682
+ }) {
2683
+ return /* @__PURE__ */ jsxs19("fieldset", {
2684
+ className: classNames("iquji-segmented", className),
2685
+ disabled,
2686
+ children: [
2687
+ /* @__PURE__ */ jsx21("legend", {
2688
+ className: "iquji-visually-hidden",
2689
+ children: label
2690
+ }),
2691
+ options.map((option) => /* @__PURE__ */ jsx21("button", {
2692
+ "aria-pressed": option.value === value,
2693
+ disabled: disabled || option.disabled,
2694
+ onClick: () => onChange(option.value),
2695
+ type: "button",
2696
+ children: option.label
2697
+ }, option.value))
2698
+ ]
2699
+ });
2700
+ }
2701
+ // src/multi-select.tsx
2702
+ import { Fragment as Fragment6, useId as useId8, useMemo as useMemo4, useState as useState10 } from "react";
2703
+ import { jsx as jsx22, jsxs as jsxs20 } from "react/jsx-runtime";
2704
+ function IqujiMultiSelect({
2705
+ className,
2706
+ clearLabel,
2707
+ disabled = false,
2708
+ emptyLabel = "没有匹配项",
2709
+ label,
2710
+ onChange,
2711
+ options,
2712
+ placeholder = "请选择",
2713
+ searchable = false,
2714
+ searchLabel = "搜索选项",
2715
+ selectAllLabel,
2716
+ value
2717
+ }) {
2718
+ const labelId = useId8();
2719
+ const [open, setOpen] = useState10(false);
2720
+ const [query, setQuery] = useState10("");
2721
+ const selected = useMemo4(() => new Set(value), [value]);
2722
+ const visible = useMemo4(() => {
2723
+ const keyword = query.trim().toLowerCase();
2724
+ if (!keyword)
2725
+ return options;
2726
+ return options.filter((option) => `${typeof option.label === "string" ? option.label : ""} ${option.value}`.toLowerCase().includes(keyword));
2727
+ }, [options, query]);
2728
+ const selectedOptions = options.filter((option) => selected.has(option.value));
2729
+ const toggle = (option, checked) => {
2730
+ if (option.disabled || disabled)
2731
+ return;
2732
+ const next = new Set(selected);
2733
+ if (checked)
2734
+ next.add(option.value);
2735
+ else
2736
+ next.delete(option.value);
2737
+ onChange(options.filter((item) => next.has(item.value)).map((item) => item.value));
2738
+ };
2739
+ const selectAll = () => {
2740
+ if (disabled)
2741
+ return;
2742
+ const next = new Set(selected);
2743
+ for (const option of options) {
2744
+ if (!option.disabled)
2745
+ next.add(option.value);
2746
+ }
2747
+ onChange(options.filter((item) => next.has(item.value)).map((item) => item.value));
2748
+ };
2749
+ return /* @__PURE__ */ jsxs20("div", {
2750
+ className: classNames("iquji-multi-select", className),
2751
+ children: [
2752
+ /* @__PURE__ */ jsx22("span", {
2753
+ className: "iquji-multi-select__label",
2754
+ id: labelId,
2755
+ children: label
2756
+ }),
2757
+ /* @__PURE__ */ jsx22(IqujiPopover, {
2758
+ onOpenChange: setOpen,
2759
+ open,
2760
+ trigger: /* @__PURE__ */ jsx22(IqujiButton, {
2761
+ "aria-expanded": open,
2762
+ "aria-haspopup": "listbox",
2763
+ "aria-labelledby": labelId,
2764
+ className: "iquji-multi-select__trigger",
2765
+ disabled,
2766
+ variant: "secondary",
2767
+ children: /* @__PURE__ */ jsx22("span", {
2768
+ className: "iquji-multi-select__value",
2769
+ children: selectedOptions.length ? selectedOptions.map((option, index) => /* @__PURE__ */ jsxs20(Fragment6, {
2770
+ children: [
2771
+ index > 0 ? "、" : null,
2772
+ option.label
2773
+ ]
2774
+ }, option.value)) : placeholder
2775
+ })
2776
+ }),
2777
+ children: /* @__PURE__ */ jsxs20("div", {
2778
+ className: "iquji-multi-select__popup",
2779
+ children: [
2780
+ searchable ? /* @__PURE__ */ jsx22(IqujiInput, {
2781
+ "aria-label": searchLabel,
2782
+ onChange: (event) => setQuery(event.currentTarget.value),
2783
+ placeholder: searchLabel,
2784
+ value: query
2785
+ }) : null,
2786
+ /* @__PURE__ */ jsxs20("div", {
2787
+ "aria-label": label,
2788
+ className: "iquji-multi-select__options",
2789
+ role: "group",
2790
+ children: [
2791
+ visible.map((option) => /* @__PURE__ */ jsx22(IqujiCheckbox, {
2792
+ checked: selected.has(option.value),
2793
+ description: option.description,
2794
+ disabled: disabled || option.disabled,
2795
+ label: option.label,
2796
+ onChange: (event) => toggle(option, event.currentTarget.checked)
2797
+ }, option.value)),
2798
+ visible.length === 0 ? /* @__PURE__ */ jsx22("p", {
2799
+ className: "iquji-multi-select__empty",
2800
+ children: emptyLabel
2801
+ }) : null
2802
+ ]
2803
+ }),
2804
+ /* @__PURE__ */ jsxs20("div", {
2805
+ className: "iquji-multi-select__actions",
2806
+ children: [
2807
+ selectAllLabel ? /* @__PURE__ */ jsx22(IqujiButton, {
2808
+ compact: true,
2809
+ disabled,
2810
+ onClick: selectAll,
2811
+ variant: "ghost",
2812
+ children: selectAllLabel
2813
+ }) : null,
2814
+ clearLabel ? /* @__PURE__ */ jsx22(IqujiButton, {
2815
+ compact: true,
2816
+ disabled: disabled || selected.size === 0,
2817
+ onClick: () => {
2818
+ if (!disabled)
2819
+ onChange([]);
2820
+ },
2821
+ variant: "ghost",
2822
+ children: clearLabel
2823
+ }) : null
2824
+ ]
2825
+ })
2826
+ ]
2827
+ })
2828
+ })
2829
+ ]
2830
+ });
2831
+ }
2832
+ // src/navigation.tsx
2833
+ import { useId as useId9, useRef as useRef8 } from "react";
2834
+ import { jsx as jsx23 } from "react/jsx-runtime";
2835
+ function IqujiTabs({
2836
+ id,
2837
+ className,
2838
+ label,
2839
+ onChange,
2840
+ panelId,
2841
+ tabs,
2842
+ value,
2843
+ variant = "underline"
2844
+ }) {
2845
+ const generatedId = useId9();
2846
+ const tabsId = id ?? generatedId;
2847
+ const refs = useRef8(new Map);
2848
+ const enabled = tabs.filter((tab) => !tab.disabled);
2849
+ const selectedEnabled = enabled.some((tab) => tab.value === value);
2850
+ const moveFocus = (event, current, direction) => {
2851
+ const currentIndex = enabled.findIndex((tab) => tab.value === current);
2852
+ const nextIndex = (currentIndex + direction + enabled.length) % enabled.length;
2853
+ const next = enabled[nextIndex];
2854
+ if (!next) {
2855
+ return;
2856
+ }
2857
+ event.preventDefault();
2858
+ onChange(next.value);
2859
+ refs.current.get(next.value)?.focus();
2860
+ };
2861
+ return /* @__PURE__ */ jsx23("div", {
2862
+ "aria-label": label,
2863
+ className: classNames("iquji-tabs", variant === "segmented" && "iquji-tabs--segmented", className),
2864
+ id: tabsId,
2865
+ role: "tablist",
2866
+ children: tabs.map((tab) => {
2867
+ const selected = tab.value === value;
2868
+ return /* @__PURE__ */ jsx23("button", {
2869
+ "aria-controls": panelId,
2870
+ "aria-selected": selected,
2871
+ disabled: tab.disabled,
2872
+ id: `${tabsId}-${tab.value}`,
2873
+ onClick: () => onChange(tab.value),
2874
+ onKeyDown: (event) => {
2875
+ if (event.nativeEvent.isComposing || event.keyCode === 229)
2876
+ return;
2877
+ if (event.key === "ArrowRight") {
2878
+ moveFocus(event, tab.value, 1);
2879
+ } else if (event.key === "ArrowLeft") {
2880
+ moveFocus(event, tab.value, -1);
2881
+ } else if (event.key === "Home") {
2882
+ const first = tabs.find((item) => !item.disabled);
2883
+ if (first) {
2884
+ event.preventDefault();
2885
+ onChange(first.value);
2886
+ refs.current.get(first.value)?.focus();
2887
+ }
2888
+ } else if (event.key === "End") {
2889
+ const last = [...tabs].reverse().find((item) => !item.disabled);
2890
+ if (last) {
2891
+ event.preventDefault();
2892
+ onChange(last.value);
2893
+ refs.current.get(last.value)?.focus();
2894
+ }
2895
+ }
2896
+ },
2897
+ ref: (element) => {
2898
+ if (element) {
2899
+ refs.current.set(tab.value, element);
2900
+ } else {
2901
+ refs.current.delete(tab.value);
2902
+ }
2903
+ },
2904
+ role: "tab",
2905
+ tabIndex: !tab.disabled && (selected || !selectedEnabled && tab === enabled[0]) ? 0 : -1,
2906
+ type: "button",
2907
+ children: tab.label
2908
+ }, tab.value);
2909
+ })
2910
+ });
2911
+ }
2912
+ // src/notification.tsx
2913
+ import { Toast } from "@base-ui/react/toast";
2914
+ import { IqujiIcon as IqujiIcon11 } from "@iquji-web/web-icons";
2915
+ import {
2916
+ createContext as createContext3,
2917
+ useCallback as useCallback6,
2918
+ useContext as useContext3,
2919
+ useId as useId10,
2920
+ useMemo as useMemo5,
2921
+ useRef as useRef9
2922
+ } from "react";
2923
+ import { jsx as jsx24, jsxs as jsxs21 } from "react/jsx-runtime";
2924
+ var Context2 = createContext3(null);
2925
+ var icons = {
2926
+ info: "circle-info",
2927
+ success: "check-circle",
2928
+ warning: "circle-alert",
2929
+ danger: "x-circle"
2930
+ };
2931
+ function IqujiNotificationProvider({
2932
+ children,
2933
+ closeLabel,
2934
+ label = "通知",
2935
+ placement = "topRight",
2936
+ duration = 4500,
2937
+ maxCount = 3
2938
+ }) {
2939
+ if (!closeLabel.trim())
2940
+ throw new Error("通知必须提供 closeLabel");
2941
+ if (!Number.isFinite(duration) || duration < 0)
2942
+ throw new Error("通知 duration 必须为非负有限数");
2943
+ if (!Number.isInteger(maxCount) || maxCount < 1)
2944
+ throw new Error("通知 maxCount 必须为正整数");
2945
+ return /* @__PURE__ */ jsx24(Toast.Provider, {
2946
+ timeout: duration,
2947
+ limit: maxCount,
2948
+ children: /* @__PURE__ */ jsx24(NotificationContent, {
2949
+ closeLabel,
2950
+ label,
2951
+ placement,
2952
+ duration,
2953
+ maxCount,
2954
+ children
2955
+ })
2956
+ });
2957
+ }
2958
+ function NotificationContent({
2959
+ children,
2960
+ closeLabel,
2961
+ label,
2962
+ placement,
2963
+ duration,
2964
+ maxCount
2965
+ }) {
2966
+ const { add, close, update, toasts } = Toast.useToastManager();
2967
+ const container = useIqujiNotificationContainer();
2968
+ const prefix = useId10();
2969
+ const sequence = useRef9(0);
2970
+ const active = useRef9(new Map);
2971
+ const open = useCallback6((options) => {
2972
+ const timeout = options.duration ?? duration;
2973
+ if (!Number.isFinite(timeout) || timeout < 0)
2974
+ throw new Error("通知 duration 必须为非负有限数");
2975
+ const key = options.key ?? `${prefix}-${++sequence.current}`;
2976
+ const existing = active.current.get(key);
2977
+ const id = existing ?? `${prefix}-notification-${++sequence.current}`;
2978
+ const configuration = {
2979
+ title: options.title,
2980
+ description: options.description,
2981
+ type: options.tone ?? "info",
2982
+ timeout,
2983
+ data: { actions: options.actions },
2984
+ onClose: () => {
2985
+ if (active.current.get(key) === id)
2986
+ active.current.delete(key);
2987
+ options.onClose?.();
2988
+ }
2989
+ };
2990
+ if (existing) {
2991
+ update(existing, configuration);
2992
+ } else {
2993
+ while (active.current.size >= maxCount) {
2994
+ const oldest = active.current.values().next().value;
2995
+ if (!oldest)
2996
+ break;
2997
+ close(oldest);
2998
+ }
2999
+ active.current.set(key, id);
3000
+ add({ ...configuration, id });
3001
+ }
3002
+ return key;
3003
+ }, [add, close, update, duration, maxCount, prefix]);
3004
+ const dismiss = useCallback6((key) => {
3005
+ if (key === undefined)
3006
+ close();
3007
+ else {
3008
+ const id = active.current.get(key);
3009
+ if (id)
3010
+ close(id);
3011
+ }
3012
+ }, [close]);
3013
+ const api = useMemo5(() => ({ open, close: dismiss }), [open, dismiss]);
3014
+ return /* @__PURE__ */ jsxs21(Context2.Provider, {
3015
+ value: api,
3016
+ children: [
3017
+ children,
3018
+ /* @__PURE__ */ jsx24(Toast.Portal, {
3019
+ container,
3020
+ children: /* @__PURE__ */ jsx24(Toast.Viewport, {
3021
+ "aria-label": label,
3022
+ className: "iquji-notification-viewport",
3023
+ "data-placement": placement,
3024
+ children: toasts.map((toast) => {
3025
+ const tone = toast.type ?? "info";
3026
+ return /* @__PURE__ */ jsxs21(Toast.Root, {
3027
+ className: "iquji-notification",
3028
+ "data-tone": tone,
3029
+ role: tone === "danger" ? "alert" : "status",
3030
+ onKeyDown: (event) => {
3031
+ if (event.key === "Escape")
3032
+ event.stopPropagation();
3033
+ },
3034
+ swipeDirection: [],
3035
+ toast,
3036
+ children: [
3037
+ /* @__PURE__ */ jsx24(IqujiIcon11, {
3038
+ className: "iquji-notification__icon",
3039
+ decorative: true,
3040
+ name: icons[tone],
3041
+ size: 21
3042
+ }),
3043
+ /* @__PURE__ */ jsxs21(Toast.Content, {
3044
+ className: "iquji-notification__content",
3045
+ children: [
3046
+ /* @__PURE__ */ jsx24(Toast.Title, {
3047
+ className: "iquji-notification__title"
3048
+ }),
3049
+ toast.description != null && /* @__PURE__ */ jsx24(Toast.Description, {
3050
+ className: "iquji-notification__description"
3051
+ }),
3052
+ toast.data?.actions && /* @__PURE__ */ jsx24("div", {
3053
+ className: "iquji-notification__actions",
3054
+ children: toast.data.actions
3055
+ })
3056
+ ]
3057
+ }),
3058
+ /* @__PURE__ */ jsx24(Toast.Close, {
3059
+ render: /* @__PURE__ */ jsx24(IconButton, {
3060
+ compact: true,
3061
+ className: "iquji-notification__close",
3062
+ icon: /* @__PURE__ */ jsx24(IqujiIcon11, {
3063
+ decorative: true,
3064
+ name: "close",
3065
+ size: 16
3066
+ }),
3067
+ label: closeLabel
3068
+ })
3069
+ })
3070
+ ]
3071
+ }, toast.id);
3072
+ })
3073
+ })
3074
+ })
3075
+ ]
3076
+ });
3077
+ }
3078
+ function useIqujiNotification() {
3079
+ const value = useContext3(Context2);
3080
+ if (!value)
3081
+ throw new Error("useIqujiNotification 必须在 IqujiNotificationProvider 中使用");
3082
+ return value;
3083
+ }
3084
+ // src/pagination.tsx
3085
+ import { jsx as jsx25, jsxs as jsxs22 } from "react/jsx-runtime";
3086
+ function IqujiPagination({
3087
+ page,
3088
+ pageSize,
3089
+ total,
3090
+ label,
3091
+ previousLabel,
3092
+ nextLabel,
3093
+ summary,
3094
+ onPageChange,
3095
+ className
3096
+ }) {
3097
+ if (!Number.isSafeInteger(page) || page < 1 || !Number.isSafeInteger(pageSize) || pageSize < 1 || !Number.isSafeInteger(total) || total < 0) {
3098
+ throw new RangeError("分页必须使用有效页码、正整数页大小和非负总数");
3099
+ }
3100
+ const pageCount = Math.max(1, Math.ceil(total / pageSize));
3101
+ const range = [
3102
+ total === 0 ? 0 : Math.min(total, (page - 1) * pageSize + 1),
3103
+ Math.min(total, page * pageSize)
3104
+ ];
3105
+ return /* @__PURE__ */ jsxs22("nav", {
3106
+ "aria-label": label,
3107
+ className: classNames("iquji-pagination", className),
3108
+ children: [
3109
+ summary ? /* @__PURE__ */ jsx25("span", {
3110
+ children: summary(total, range)
3111
+ }) : null,
3112
+ /* @__PURE__ */ jsx25(IqujiButton, {
3113
+ compact: true,
3114
+ disabled: !onPageChange || page <= 1,
3115
+ onClick: () => onPageChange?.(page - 1, pageSize),
3116
+ variant: "secondary",
3117
+ children: previousLabel
3118
+ }),
3119
+ /* @__PURE__ */ jsxs22("span", {
3120
+ children: [
3121
+ page,
3122
+ " / ",
3123
+ pageCount
3124
+ ]
3125
+ }),
3126
+ /* @__PURE__ */ jsx25(IqujiButton, {
3127
+ compact: true,
3128
+ disabled: !onPageChange || page >= pageCount,
3129
+ onClick: () => onPageChange?.(page + 1, pageSize),
3130
+ variant: "secondary",
3131
+ children: nextLabel
3132
+ })
3133
+ ]
3134
+ });
3135
+ }
3136
+ // src/progress-bar.tsx
3137
+ import { jsx as jsx26, jsxs as jsxs23 } from "react/jsx-runtime";
3138
+ function IqujiProgressBar({
3139
+ className,
3140
+ formatValue,
3141
+ indeterminate = false,
3142
+ label,
3143
+ max = 100,
3144
+ showValue = false,
3145
+ tone = "info",
3146
+ value,
3147
+ ...divProps
3148
+ }) {
3149
+ if (!Number.isFinite(max) || max <= 0) {
3150
+ throw new RangeError("进度条最大值必须是正数");
3151
+ }
3152
+ const determinate = !indeterminate && value !== undefined && Number.isFinite(value);
3153
+ const current = determinate ? Math.min(Math.max(value, 0), max) : 0;
3154
+ const percent = determinate ? current / max * 100 : 0;
3155
+ return /* @__PURE__ */ jsxs23("div", {
3156
+ className: classNames("iquji-progress", className),
3157
+ ...divProps,
3158
+ children: [
3159
+ /* @__PURE__ */ jsxs23("div", {
3160
+ className: "iquji-progress__heading",
3161
+ children: [
3162
+ /* @__PURE__ */ jsx26("span", {
3163
+ className: "iquji-progress__label",
3164
+ children: label
3165
+ }),
3166
+ showValue && determinate ? /* @__PURE__ */ jsx26("span", {
3167
+ className: "iquji-progress__value",
3168
+ children: formatValue ? formatValue(current, max) : `${Math.round(percent)}%`
3169
+ }) : null
3170
+ ]
3171
+ }),
3172
+ /* @__PURE__ */ jsx26("div", {
3173
+ "aria-label": label,
3174
+ "aria-valuemax": determinate ? max : undefined,
3175
+ "aria-valuemin": determinate ? 0 : undefined,
3176
+ "aria-valuenow": determinate ? current : undefined,
3177
+ className: "iquji-progress__track",
3178
+ "data-indeterminate": !determinate || undefined,
3179
+ "data-tone": tone,
3180
+ role: "progressbar",
3181
+ children: /* @__PURE__ */ jsx26("span", {
3182
+ className: "iquji-progress__fill",
3183
+ style: determinate ? { width: `${percent}%` } : undefined
3184
+ })
3185
+ })
3186
+ ]
3187
+ });
3188
+ }
3189
+ // src/scroll-area.tsx
3190
+ import { jsx as jsx27 } from "react/jsx-runtime";
3191
+ function size(value) {
3192
+ if (value === undefined)
3193
+ return;
3194
+ return typeof value === "number" ? `${value}px` : value;
3195
+ }
3196
+ function IqujiScrollArea({
3197
+ children,
3198
+ className,
3199
+ height,
3200
+ label,
3201
+ maxHeight,
3202
+ orientation = "vertical",
3203
+ style,
3204
+ tabIndex = 0,
3205
+ ...divProps
3206
+ }) {
3207
+ const styles = {
3208
+ ...style,
3209
+ height: size(height),
3210
+ maxHeight: size(maxHeight)
3211
+ };
3212
+ return /* @__PURE__ */ jsx27("div", {
3213
+ "aria-label": label,
3214
+ className: classNames("iquji-scroll-area", className),
3215
+ "data-orientation": orientation,
3216
+ role: "region",
3217
+ style: styles,
3218
+ tabIndex,
3219
+ ...divProps,
3220
+ children
3221
+ });
3222
+ }
3223
+ // src/search-dialog.tsx
3224
+ import { IqujiIcon as IqujiIcon12 } from "@iquji-web/web-icons";
3225
+ import {
3226
+ useEffect as useEffect4,
3227
+ useId as useId11,
3228
+ useMemo as useMemo6,
3229
+ useRef as useRef10,
3230
+ useState as useState11
3231
+ } from "react";
3232
+ import { jsx as jsx28, jsxs as jsxs24 } from "react/jsx-runtime";
3233
+ function IqujiSearchDialog({
3234
+ open,
3235
+ onOpenChange,
3236
+ title,
3237
+ placeholder,
3238
+ emptyLabel,
3239
+ closeLabel,
3240
+ groups,
3241
+ onSelect
3242
+ }) {
3243
+ const id = useId11();
3244
+ const input = useRef10(null);
3245
+ const options = useRef10(new Map);
3246
+ const composing = useRef10(false);
3247
+ const [query, setQuery] = useState11("");
3248
+ const [activeId, setActiveId] = useState11(null);
3249
+ const filtered = useMemo6(() => {
3250
+ const term = query.trim().toLocaleLowerCase();
3251
+ return groups.flatMap((group) => {
3252
+ const items = group.items.filter((item) => [item.title, item.description, item.keywords].filter(Boolean).join(" ").toLocaleLowerCase().includes(term));
3253
+ return items.length ? [{ ...group, items }] : [];
3254
+ });
3255
+ }, [groups, query]);
3256
+ const enabled = useMemo6(() => filtered.flatMap((group) => group.items.filter((item) => !item.disabled)), [filtered]);
3257
+ const active = enabled.find((item) => item.id === activeId) ?? enabled[0];
3258
+ const selectedId = active?.id;
3259
+ const optionId = (itemId) => `${id}-option-${encodeURIComponent(itemId)}`;
3260
+ useEffect4(() => {
3261
+ setQuery("");
3262
+ setActiveId(null);
3263
+ composing.current = false;
3264
+ }, [open]);
3265
+ useEffect4(() => {
3266
+ if (activeId && !enabled.some((item) => item.id === activeId))
3267
+ setActiveId(null);
3268
+ }, [activeId, enabled]);
3269
+ useEffect4(() => {
3270
+ if (open && selectedId)
3271
+ options.current.get(selectedId)?.scrollIntoView?.({ block: "nearest" });
3272
+ }, [selectedId, open, query]);
3273
+ const select = (item) => {
3274
+ if (!open || item.disabled)
3275
+ return;
3276
+ onSelect(item.id);
3277
+ };
3278
+ const onKeyDown = (event) => {
3279
+ if (composing.current || event.nativeEvent.isComposing || event.keyCode === 229) {
3280
+ if (event.key === "Escape")
3281
+ event.stopPropagation();
3282
+ return;
3283
+ }
3284
+ if (event.key === "Enter") {
3285
+ event.preventDefault();
3286
+ if (active)
3287
+ select(active);
3288
+ return;
3289
+ }
3290
+ if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key))
3291
+ return;
3292
+ event.preventDefault();
3293
+ if (!enabled.length)
3294
+ return;
3295
+ const index = active ? enabled.findIndex((item) => item.id === active.id) : 0;
3296
+ const next = event.key === "Home" ? 0 : event.key === "End" ? enabled.length - 1 : (index + (event.key === "ArrowDown" ? 1 : -1) + enabled.length) % enabled.length;
3297
+ setActiveId(enabled[next]?.id ?? null);
3298
+ };
3299
+ return /* @__PURE__ */ jsxs24(IqujiDialog, {
3300
+ className: "iquji-search-dialog",
3301
+ open,
3302
+ onOpenChange,
3303
+ title,
3304
+ closeLabel,
3305
+ initialFocusRef: input,
3306
+ width: "min(560px, 92vw)",
3307
+ children: [
3308
+ /* @__PURE__ */ jsxs24("div", {
3309
+ className: "iquji-search-dialog__query",
3310
+ children: [
3311
+ /* @__PURE__ */ jsx28(IqujiIcon12, {
3312
+ decorative: true,
3313
+ name: "search"
3314
+ }),
3315
+ /* @__PURE__ */ jsx28("input", {
3316
+ "aria-activedescendant": open && active ? optionId(active.id) : undefined,
3317
+ "aria-autocomplete": "list",
3318
+ "aria-controls": `${id}-results`,
3319
+ "aria-expanded": open,
3320
+ "aria-label": title,
3321
+ autoComplete: "off",
3322
+ onChange: (event) => {
3323
+ setQuery(event.target.value);
3324
+ setActiveId(null);
3325
+ },
3326
+ onCompositionStart: () => {
3327
+ composing.current = true;
3328
+ },
3329
+ onCompositionEnd: () => {
3330
+ composing.current = false;
3331
+ },
3332
+ onKeyDown,
3333
+ placeholder,
3334
+ ref: input,
3335
+ role: "combobox",
3336
+ spellCheck: false,
3337
+ type: "text",
3338
+ value: query
3339
+ })
3340
+ ]
3341
+ }),
3342
+ /* @__PURE__ */ jsxs24("div", {
3343
+ className: "iquji-search-dialog__results",
3344
+ children: [
3345
+ /* @__PURE__ */ jsx28("div", {
3346
+ "aria-label": title,
3347
+ id: `${id}-results`,
3348
+ role: "listbox",
3349
+ children: filtered.map((group) => {
3350
+ const labelId = `${id}-group-${encodeURIComponent(group.id)}`;
3351
+ return /* @__PURE__ */ jsxs24("div", {
3352
+ "aria-labelledby": labelId,
3353
+ className: "iquji-search-dialog__group",
3354
+ role: "group",
3355
+ children: [
3356
+ /* @__PURE__ */ jsx28("div", {
3357
+ className: "iquji-search-dialog__group-label",
3358
+ id: labelId,
3359
+ children: group.label
3360
+ }),
3361
+ group.items.map((item) => {
3362
+ const itemId = optionId(item.id);
3363
+ const hasMetadata = item.metadata !== undefined && item.metadata !== null;
3364
+ const descriptionIds = [
3365
+ item.description ? `${itemId}-description` : null,
3366
+ hasMetadata ? `${itemId}-metadata` : null
3367
+ ].filter(Boolean).join(" ");
3368
+ return /* @__PURE__ */ jsxs24("button", {
3369
+ "aria-describedby": descriptionIds || undefined,
3370
+ "aria-disabled": item.disabled || undefined,
3371
+ "aria-labelledby": `${itemId}-title`,
3372
+ "aria-selected": active?.id === item.id,
3373
+ className: "iquji-search-dialog__option",
3374
+ disabled: item.disabled,
3375
+ id: itemId,
3376
+ onClick: () => select(item),
3377
+ onMouseDown: (event) => event.preventDefault(),
3378
+ onMouseMove: () => {
3379
+ if (!item.disabled)
3380
+ setActiveId(item.id);
3381
+ },
3382
+ ref: (element) => {
3383
+ if (element)
3384
+ options.current.set(item.id, element);
3385
+ else
3386
+ options.current.delete(item.id);
3387
+ },
3388
+ role: "option",
3389
+ tabIndex: -1,
3390
+ type: "button",
3391
+ children: [
3392
+ item.icon && /* @__PURE__ */ jsx28("span", {
3393
+ "aria-hidden": "true",
3394
+ className: "iquji-search-dialog__icon",
3395
+ children: item.icon
3396
+ }),
3397
+ /* @__PURE__ */ jsxs24("span", {
3398
+ className: "iquji-search-dialog__item-content",
3399
+ children: [
3400
+ /* @__PURE__ */ jsx28("span", {
3401
+ className: "iquji-search-dialog__item-title",
3402
+ id: `${itemId}-title`,
3403
+ children: item.title
3404
+ }),
3405
+ item.description && /* @__PURE__ */ jsx28("span", {
3406
+ className: "iquji-search-dialog__description",
3407
+ id: `${itemId}-description`,
3408
+ children: item.description
3409
+ })
3410
+ ]
3411
+ }),
3412
+ hasMetadata && /* @__PURE__ */ jsx28("span", {
3413
+ className: "iquji-search-dialog__metadata",
3414
+ id: `${itemId}-metadata`,
3415
+ children: item.metadata
3416
+ })
3417
+ ]
3418
+ }, item.id);
3419
+ })
3420
+ ]
3421
+ }, group.id);
3422
+ })
3423
+ }),
3424
+ !filtered.length && /* @__PURE__ */ jsx28("p", {
3425
+ className: "iquji-search-dialog__empty",
3426
+ role: "status",
3427
+ children: emptyLabel
3428
+ })
3429
+ ]
3430
+ })
3431
+ ]
3432
+ });
3433
+ }
3434
+ // src/settings-layout.tsx
3435
+ import {
3436
+ useId as useId12
3437
+ } from "react";
3438
+ import { jsx as jsx29, jsxs as jsxs25 } from "react/jsx-runtime";
3439
+ function IqujiSettingsLayout({
3440
+ navigation,
3441
+ children,
3442
+ className,
3443
+ navigationClassName,
3444
+ contentClassName,
3445
+ ...divProps
3446
+ }) {
3447
+ return /* @__PURE__ */ jsxs25("div", {
3448
+ className: classNames("iquji-settings", className),
3449
+ ...divProps,
3450
+ children: [
3451
+ /* @__PURE__ */ jsx29("div", {
3452
+ className: classNames("iquji-settings__navigation", navigationClassName),
3453
+ children: navigation
3454
+ }),
3455
+ /* @__PURE__ */ jsx29("div", {
3456
+ className: classNames("iquji-settings__content", contentClassName),
3457
+ children
3458
+ })
3459
+ ]
3460
+ });
3461
+ }
3462
+ function IqujiSettingsContent({
3463
+ actions,
3464
+ children,
3465
+ className,
3466
+ description,
3467
+ title,
3468
+ titleId,
3469
+ ...sectionProps
3470
+ }) {
3471
+ const generatedId = useId12();
3472
+ const headingId = titleId ?? `${generatedId}-title`;
3473
+ return /* @__PURE__ */ jsxs25("section", {
3474
+ "aria-labelledby": headingId,
3475
+ className: classNames("iquji-settings-content", className),
3476
+ ...sectionProps,
3477
+ children: [
3478
+ /* @__PURE__ */ jsxs25("header", {
3479
+ className: "iquji-settings-content__header",
3480
+ children: [
3481
+ /* @__PURE__ */ jsxs25("div", {
3482
+ children: [
3483
+ /* @__PURE__ */ jsx29("h1", {
3484
+ id: headingId,
3485
+ tabIndex: -1,
3486
+ children: title
3487
+ }),
3488
+ description ? /* @__PURE__ */ jsx29("p", {
3489
+ className: "iquji-settings-content__description",
3490
+ children: description
3491
+ }) : null
3492
+ ]
3493
+ }),
3494
+ actions ? /* @__PURE__ */ jsx29("div", {
3495
+ className: "iquji-settings-content__actions",
3496
+ children: actions
3497
+ }) : null
3498
+ ]
3499
+ }),
3500
+ /* @__PURE__ */ jsx29("div", {
3501
+ className: "iquji-settings-content__body",
3502
+ children
3503
+ })
3504
+ ]
3505
+ });
3506
+ }
3507
+ function IqujiSettingsSection({
3508
+ actions,
3509
+ children,
3510
+ className,
3511
+ description,
3512
+ title,
3513
+ titleId,
3514
+ ...sectionProps
3515
+ }) {
3516
+ const generatedId = useId12();
3517
+ const headingId = titleId ?? `${generatedId}-title`;
3518
+ return /* @__PURE__ */ jsxs25("section", {
3519
+ "aria-labelledby": headingId,
3520
+ className: classNames("iquji-settings-section", className),
3521
+ ...sectionProps,
3522
+ children: [
3523
+ /* @__PURE__ */ jsxs25("header", {
3524
+ className: "iquji-settings-section__header",
3525
+ children: [
3526
+ /* @__PURE__ */ jsxs25("div", {
3527
+ children: [
3528
+ /* @__PURE__ */ jsx29("h2", {
3529
+ id: headingId,
3530
+ children: title
3531
+ }),
3532
+ description ? /* @__PURE__ */ jsx29("p", {
3533
+ className: "iquji-settings-section__description",
3534
+ children: description
3535
+ }) : null
3536
+ ]
3537
+ }),
3538
+ actions ? /* @__PURE__ */ jsx29("div", {
3539
+ className: "iquji-settings-section__actions",
3540
+ children: actions
3541
+ }) : null
3542
+ ]
3543
+ }),
3544
+ /* @__PURE__ */ jsx29("div", {
3545
+ className: "iquji-settings-section__rows",
3546
+ children
3547
+ })
3548
+ ]
3549
+ });
3550
+ }
3551
+ // src/settings-nav.tsx
3552
+ import { IqujiIcon as IqujiIcon13 } from "@iquji-web/web-icons";
3553
+ import { useId as useId13 } from "react";
3554
+ import { jsx as jsx30, jsxs as jsxs26, Fragment as Fragment7 } from "react/jsx-runtime";
3555
+ function navItemContent(item) {
3556
+ return /* @__PURE__ */ jsxs26(Fragment7, {
3557
+ children: [
3558
+ item.icon ? /* @__PURE__ */ jsx30("span", {
3559
+ "aria-hidden": "true",
3560
+ className: "iquji-settings-nav__item-icon",
3561
+ children: item.icon
3562
+ }) : null,
3563
+ /* @__PURE__ */ jsx30("span", {
3564
+ className: "iquji-settings-nav__item-label",
3565
+ children: item.label
3566
+ }),
3567
+ item.trailing ? /* @__PURE__ */ jsx30("span", {
3568
+ className: "iquji-settings-nav__item-trailing",
3569
+ children: item.trailing
3570
+ }) : null
3571
+ ]
3572
+ });
3573
+ }
3574
+ function IqujiSettingsNav({
3575
+ label,
3576
+ groups,
3577
+ header,
3578
+ search,
3579
+ emptyLabel,
3580
+ className
3581
+ }) {
3582
+ const generatedId = useId13();
3583
+ const searchId = `${generatedId}-search`;
3584
+ return /* @__PURE__ */ jsxs26("div", {
3585
+ className: classNames("iquji-settings-nav", className),
3586
+ children: [
3587
+ header ? /* @__PURE__ */ jsx30("div", {
3588
+ className: "iquji-settings-nav__header",
3589
+ children: header
3590
+ }) : null,
3591
+ search ? /* @__PURE__ */ jsxs26("div", {
3592
+ className: "iquji-settings-nav__search",
3593
+ children: [
3594
+ /* @__PURE__ */ jsx30("label", {
3595
+ className: "iquji-visually-hidden",
3596
+ htmlFor: searchId,
3597
+ children: search.label
3598
+ }),
3599
+ /* @__PURE__ */ jsx30("span", {
3600
+ "aria-hidden": "true",
3601
+ className: "iquji-settings-nav__search-icon",
3602
+ children: /* @__PURE__ */ jsx30(IqujiIcon13, {
3603
+ decorative: true,
3604
+ name: "search",
3605
+ size: 15
3606
+ })
3607
+ }),
3608
+ /* @__PURE__ */ jsx30("input", {
3609
+ autoComplete: "off",
3610
+ className: "iquji-settings-nav__search-input",
3611
+ id: searchId,
3612
+ onChange: (event) => search.onChange(event.target.value),
3613
+ placeholder: search.placeholder,
3614
+ spellCheck: false,
3615
+ type: "search",
3616
+ value: search.value
3617
+ })
3618
+ ]
3619
+ }) : null,
3620
+ /* @__PURE__ */ jsxs26("nav", {
3621
+ "aria-label": label,
3622
+ className: "iquji-settings-nav__nav",
3623
+ children: [
3624
+ groups.length === 0 && emptyLabel ? /* @__PURE__ */ jsx30("p", {
3625
+ className: "iquji-settings-nav__empty",
3626
+ role: "status",
3627
+ children: emptyLabel
3628
+ }) : null,
3629
+ groups.map((group, index) => {
3630
+ const headingId = group.label ? `${generatedId}-group-${index}` : undefined;
3631
+ return /* @__PURE__ */ jsxs26("div", {
3632
+ "aria-labelledby": headingId,
3633
+ className: "iquji-settings-nav__group",
3634
+ role: headingId ? "group" : undefined,
3635
+ children: [
3636
+ group.label ? /* @__PURE__ */ jsx30("h2", {
3637
+ className: "iquji-settings-nav__group-label",
3638
+ id: headingId,
3639
+ children: group.label
3640
+ }) : null,
3641
+ /* @__PURE__ */ jsx30("div", {
3642
+ className: "iquji-settings-nav__items",
3643
+ children: group.items.map((item) => item.href && !item.disabled ? /* @__PURE__ */ jsx30("a", {
3644
+ "aria-current": item.active ? "page" : undefined,
3645
+ className: "iquji-settings-nav__item",
3646
+ "data-active": item.active || undefined,
3647
+ href: item.href,
3648
+ onClick: item.onSelect,
3649
+ children: navItemContent(item)
3650
+ }, item.key) : /* @__PURE__ */ jsx30("button", {
3651
+ "aria-current": item.active ? "page" : undefined,
3652
+ className: "iquji-settings-nav__item",
3653
+ "data-active": item.active || undefined,
3654
+ disabled: item.disabled,
3655
+ onClick: item.onSelect,
3656
+ type: "button",
3657
+ children: navItemContent(item)
3658
+ }, item.key))
3659
+ })
3660
+ ]
3661
+ }, group.key);
3662
+ })
3663
+ ]
3664
+ })
3665
+ ]
3666
+ });
3667
+ }
3668
+ // src/settings-rows.tsx
3669
+ import { useId as useId14 } from "react";
3670
+ import { jsx as jsx31, jsxs as jsxs27, Fragment as Fragment8 } from "react/jsx-runtime";
3671
+ function SettingsRowFrame({
3672
+ label,
3673
+ description,
3674
+ labelId,
3675
+ descriptionId,
3676
+ htmlFor,
3677
+ disabled = false,
3678
+ align = "center",
3679
+ className,
3680
+ labelClassName,
3681
+ controlClassName,
3682
+ control
3683
+ }) {
3684
+ return /* @__PURE__ */ jsxs27("div", {
3685
+ className: classNames("iquji-settings-row", className),
3686
+ "data-align": align,
3687
+ "data-disabled": disabled || undefined,
3688
+ children: [
3689
+ /* @__PURE__ */ jsxs27("div", {
3690
+ className: "iquji-settings-row__copy",
3691
+ children: [
3692
+ htmlFor ? /* @__PURE__ */ jsx31("label", {
3693
+ className: classNames("iquji-settings-row__label", labelClassName),
3694
+ htmlFor,
3695
+ id: labelId,
3696
+ children: label
3697
+ }) : /* @__PURE__ */ jsx31("span", {
3698
+ className: classNames("iquji-settings-row__label", labelClassName),
3699
+ id: labelId,
3700
+ children: label
3701
+ }),
3702
+ description !== undefined && description !== null ? /* @__PURE__ */ jsx31("span", {
3703
+ className: "iquji-settings-row__description",
3704
+ id: descriptionId,
3705
+ children: description
3706
+ }) : null
3707
+ ]
3708
+ }),
3709
+ /* @__PURE__ */ jsx31("div", {
3710
+ className: classNames("iquji-settings-row__control", controlClassName),
3711
+ children: control
3712
+ })
3713
+ ]
3714
+ });
3715
+ }
3716
+ function IqujiSettingsRow({
3717
+ label,
3718
+ description,
3719
+ control,
3720
+ htmlFor,
3721
+ labelId,
3722
+ descriptionId,
3723
+ align,
3724
+ disabled,
3725
+ className,
3726
+ labelClassName,
3727
+ controlClassName
3728
+ }) {
3729
+ const generatedId = useId14();
3730
+ return /* @__PURE__ */ jsx31(SettingsRowFrame, {
3731
+ align,
3732
+ className,
3733
+ control,
3734
+ controlClassName,
3735
+ description,
3736
+ descriptionId: description !== undefined && description !== null ? descriptionId ?? `${generatedId}-description` : undefined,
3737
+ disabled,
3738
+ htmlFor,
3739
+ label,
3740
+ labelClassName,
3741
+ labelId: labelId ?? `${generatedId}-label`
3742
+ });
3743
+ }
3744
+ function IqujiSettingsSwitchRow({
3745
+ className,
3746
+ ...props
3747
+ }) {
3748
+ return /* @__PURE__ */ jsx31(IqujiSwitch, {
3749
+ ...props,
3750
+ className: classNames("iquji-settings-row", "iquji-settings-row--switch", className)
3751
+ });
3752
+ }
3753
+ function IqujiSettingsSelectRow({
3754
+ label,
3755
+ description,
3756
+ options,
3757
+ groups,
3758
+ value,
3759
+ defaultValue,
3760
+ onValueChange,
3761
+ placeholder,
3762
+ disabled = false,
3763
+ invalid = false,
3764
+ required = false,
3765
+ compact = false,
3766
+ name,
3767
+ id,
3768
+ align,
3769
+ className,
3770
+ labelClassName,
3771
+ controlClassName
3772
+ }) {
3773
+ const generatedId = useId14();
3774
+ const labelId = `${generatedId}-label`;
3775
+ const descriptionId = description !== undefined && description !== null ? `${generatedId}-description` : undefined;
3776
+ const selectProps = {
3777
+ "aria-labelledby": labelId,
3778
+ ...descriptionId ? { "aria-describedby": descriptionId } : {},
3779
+ compact,
3780
+ disabled,
3781
+ invalid,
3782
+ options,
3783
+ required,
3784
+ ...groups !== undefined ? { groups } : {},
3785
+ ...value !== undefined ? { value } : {},
3786
+ ...defaultValue !== undefined ? { defaultValue } : {},
3787
+ ...onValueChange ? { onValueChange } : {},
3788
+ ...placeholder !== undefined ? { placeholder } : {},
3789
+ ...name !== undefined ? { name } : {},
3790
+ ...id !== undefined ? { id } : {}
3791
+ };
3792
+ return /* @__PURE__ */ jsx31(SettingsRowFrame, {
3793
+ align,
3794
+ className,
3795
+ control: /* @__PURE__ */ jsx31(IqujiSelect, {
3796
+ ...selectProps
3797
+ }),
3798
+ controlClassName,
3799
+ description,
3800
+ descriptionId,
3801
+ disabled,
3802
+ label,
3803
+ labelClassName,
3804
+ labelId
3805
+ });
3806
+ }
3807
+ function IqujiSettingsActionRow({
3808
+ label,
3809
+ description,
3810
+ value,
3811
+ action,
3812
+ disabled = false,
3813
+ align = "center",
3814
+ className,
3815
+ valueClassName,
3816
+ controlClassName
3817
+ }) {
3818
+ const generatedId = useId14();
3819
+ const labelId = `${generatedId}-label`;
3820
+ const descriptionId = description !== undefined && description !== null ? `${generatedId}-description` : undefined;
3821
+ return /* @__PURE__ */ jsx31(SettingsRowFrame, {
3822
+ align,
3823
+ className,
3824
+ control: /* @__PURE__ */ jsxs27(Fragment8, {
3825
+ children: [
3826
+ value !== undefined && value !== null ? /* @__PURE__ */ jsx31("span", {
3827
+ className: classNames("iquji-settings-row__value", valueClassName),
3828
+ children: value
3829
+ }) : null,
3830
+ action
3831
+ ]
3832
+ }),
3833
+ controlClassName,
3834
+ description,
3835
+ descriptionId,
3836
+ disabled,
3837
+ label,
3838
+ labelId
3839
+ });
3840
+ }
3841
+ // src/timeline.tsx
3842
+ import { jsx as jsx32, jsxs as jsxs28 } from "react/jsx-runtime";
3843
+ function IqujiTimeline({
3844
+ className,
3845
+ emptyLabel = "暂无时间线记录",
3846
+ items,
3847
+ label,
3848
+ ...sectionProps
3849
+ }) {
3850
+ return /* @__PURE__ */ jsx32("section", {
3851
+ "aria-label": label,
3852
+ className: classNames("iquji-timeline", className),
3853
+ ...sectionProps,
3854
+ children: items.length === 0 ? /* @__PURE__ */ jsx32("p", {
3855
+ className: "iquji-timeline__empty",
3856
+ children: emptyLabel
3857
+ }) : /* @__PURE__ */ jsx32("ol", {
3858
+ className: "iquji-timeline__list",
3859
+ children: items.map((item) => /* @__PURE__ */ jsxs28("li", {
3860
+ className: "iquji-timeline__item",
3861
+ "data-tone": item.tone ?? "neutral",
3862
+ children: [
3863
+ /* @__PURE__ */ jsx32("span", {
3864
+ "aria-hidden": "true",
3865
+ className: "iquji-timeline__marker",
3866
+ children: item.icon
3867
+ }),
3868
+ /* @__PURE__ */ jsxs28("div", {
3869
+ className: "iquji-timeline__content",
3870
+ children: [
3871
+ /* @__PURE__ */ jsxs28("div", {
3872
+ className: "iquji-timeline__heading",
3873
+ children: [
3874
+ /* @__PURE__ */ jsx32("span", {
3875
+ className: "iquji-timeline__title",
3876
+ children: item.title
3877
+ }),
3878
+ item.timestamp ? /* @__PURE__ */ jsx32("span", {
3879
+ className: "iquji-timeline__timestamp",
3880
+ children: item.timestamp
3881
+ }) : null
3882
+ ]
3883
+ }),
3884
+ item.description ? /* @__PURE__ */ jsx32("div", {
3885
+ className: "iquji-timeline__description",
3886
+ children: item.description
3887
+ }) : null,
3888
+ item.status ? /* @__PURE__ */ jsx32("div", {
3889
+ className: "iquji-timeline__status",
3890
+ children: item.status
3891
+ }) : null
3892
+ ]
3893
+ })
3894
+ ]
3895
+ }, item.id))
3896
+ })
3897
+ });
3898
+ }
3899
+ // src/workbench.tsx
3900
+ import {
3901
+ useId as useId15,
3902
+ useLayoutEffect,
3903
+ useRef as useRef11,
3904
+ useState as useState12
3905
+ } from "react";
3906
+ import { jsx as jsx33, jsxs as jsxs29 } from "react/jsx-runtime";
3907
+ var DEFAULT_LEFT_WIDTH = 240;
3908
+ var DEFAULT_LEFT_MIN = 180;
3909
+ var DEFAULT_LEFT_MAX = 420;
3910
+ var DEFAULT_RIGHT_WIDTH = 420;
3911
+ var DEFAULT_RIGHT_MIN = 280;
3912
+ var DEFAULT_RIGHT_MAX = 640;
3913
+ var DEFAULT_CENTER_MIN = 480;
3914
+ var RESIZE_STEP = 16;
3915
+ function numberOr(value, fallback) {
3916
+ return value !== undefined && Number.isFinite(value) ? value : fallback;
3917
+ }
3918
+ function widthBounds(minValue, maxValue) {
3919
+ const min = Math.max(0, Math.round(numberOr(minValue, 0)));
3920
+ const max = Math.max(min, Math.round(numberOr(maxValue, min)));
3921
+ return { min, max };
3922
+ }
3923
+ function clampWidth(value, min, max) {
3924
+ const lower = Math.max(0, Math.min(min, max));
3925
+ const upper = Math.max(lower, max);
3926
+ return Math.min(Math.max(value, lower), upper);
3927
+ }
3928
+ function IqujiWorkbenchLayout({
3929
+ left,
3930
+ center,
3931
+ right,
3932
+ leftWidth,
3933
+ defaultLeftWidth,
3934
+ onLeftWidthChange,
3935
+ leftMinWidth,
3936
+ leftMaxWidth,
3937
+ leftCollapsed = false,
3938
+ rightWidth,
3939
+ defaultRightWidth,
3940
+ onRightWidthChange,
3941
+ rightMinWidth,
3942
+ rightMaxWidth,
3943
+ rightCollapsed = false,
3944
+ centerMinWidth,
3945
+ onLayoutChange,
3946
+ leftResizeLabel = "Resize left panel",
3947
+ rightResizeLabel = "Resize right panel",
3948
+ className,
3949
+ leftClassName,
3950
+ centerClassName,
3951
+ rightClassName
3952
+ }) {
3953
+ const generatedId = useId15();
3954
+ const rootRef = useRef11(null);
3955
+ const leftRef = useRef11(null);
3956
+ const centerRef = useRef11(null);
3957
+ const rightRef = useRef11(null);
3958
+ const previousGeometry = useRef11(null);
3959
+ const dragRef = useRef11(null);
3960
+ const [resizing, setResizing] = useState12(null);
3961
+ const leftBounds = widthBounds(leftMinWidth ?? DEFAULT_LEFT_MIN, leftMaxWidth ?? DEFAULT_LEFT_MAX);
3962
+ const rightBounds = widthBounds(rightMinWidth ?? DEFAULT_RIGHT_MIN, rightMaxWidth ?? DEFAULT_RIGHT_MAX);
3963
+ const leftDefault = clampWidth(numberOr(defaultLeftWidth, DEFAULT_LEFT_WIDTH), leftBounds.min, leftBounds.max);
3964
+ const rightDefault = clampWidth(numberOr(defaultRightWidth, DEFAULT_RIGHT_WIDTH), rightBounds.min, rightBounds.max);
3965
+ const [internalLeftWidth, setInternalLeftWidth] = useState12(leftDefault);
3966
+ const [internalRightWidth, setInternalRightWidth] = useState12(rightDefault);
3967
+ const leftValue = clampWidth(numberOr(leftWidth, internalLeftWidth), leftBounds.min, leftBounds.max);
3968
+ const rightValue = clampWidth(numberOr(rightWidth, internalRightWidth), rightBounds.min, rightBounds.max);
3969
+ const centerMin = Math.max(1, Math.round(numberOr(centerMinWidth, DEFAULT_CENTER_MIN)));
3970
+ const hasLeft = left !== undefined && left !== null;
3971
+ const hasRight = right !== undefined && right !== null;
3972
+ const leftVisible = hasLeft && !leftCollapsed;
3973
+ const rightVisible = hasRight && !rightCollapsed;
3974
+ useLayoutEffect(() => {
3975
+ if (!onLayoutChange) {
3976
+ previousGeometry.current = null;
3977
+ return;
3978
+ }
3979
+ let disposed = false;
3980
+ const measure = () => {
3981
+ if (disposed)
3982
+ return;
3983
+ const geometry = {
3984
+ leftWidth: leftVisible ? leftRef.current?.getBoundingClientRect().width ?? 0 : 0,
3985
+ centerWidth: centerRef.current?.getBoundingClientRect().width ?? 0,
3986
+ rightWidth: rightVisible ? rightRef.current?.getBoundingClientRect().width ?? 0 : 0
3987
+ };
3988
+ const previous = previousGeometry.current;
3989
+ if (previous?.leftWidth === geometry.leftWidth && previous.centerWidth === geometry.centerWidth && previous.rightWidth === geometry.rightWidth)
3990
+ return;
3991
+ previousGeometry.current = geometry;
3992
+ onLayoutChange(geometry);
3993
+ };
3994
+ const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
3995
+ for (const pane of [leftRef.current, centerRef.current, rightRef.current]) {
3996
+ if (pane)
3997
+ observer?.observe(pane);
3998
+ }
3999
+ measure();
4000
+ return () => {
4001
+ disposed = true;
4002
+ observer?.disconnect();
4003
+ };
4004
+ }, [hasLeft, hasRight, leftVisible, onLayoutChange, rightVisible]);
4005
+ const limitForSide = (side, requested) => {
4006
+ const bounds = side === "left" ? leftBounds : rightBounds;
4007
+ const otherWidth = side === "left" ? rightVisible ? rightValue : 0 : leftVisible ? leftValue : 0;
4008
+ const measuredWidth = rootRef.current?.getBoundingClientRect().width ?? 0;
4009
+ const available = measuredWidth > 0 ? measuredWidth - centerMin - otherWidth : Number.POSITIVE_INFINITY;
4010
+ return clampWidth(requested, bounds.min, Math.min(bounds.max, available));
4011
+ };
4012
+ const changeLeftWidth = (next) => {
4013
+ const limited = limitForSide("left", next);
4014
+ if (leftWidth === undefined) {
4015
+ setInternalLeftWidth(limited);
4016
+ }
4017
+ onLeftWidthChange?.(limited);
4018
+ };
4019
+ const changeRightWidth = (next) => {
4020
+ const limited = limitForSide("right", next);
4021
+ if (rightWidth === undefined) {
4022
+ setInternalRightWidth(limited);
4023
+ }
4024
+ onRightWidthChange?.(limited);
4025
+ };
4026
+ const changeSideWidth = (side, next) => {
4027
+ if (side === "left") {
4028
+ changeLeftWidth(next);
4029
+ } else {
4030
+ changeRightWidth(next);
4031
+ }
4032
+ };
4033
+ const currentWidth = (side) => side === "left" ? leftValue : rightValue;
4034
+ const startDrag = (side, event) => {
4035
+ if (event.button !== 0)
4036
+ return;
4037
+ event.preventDefault();
4038
+ event.currentTarget.focus();
4039
+ if (typeof event.currentTarget.setPointerCapture === "function") {
4040
+ event.currentTarget.setPointerCapture(event.pointerId);
4041
+ }
4042
+ dragRef.current = {
4043
+ side,
4044
+ pointerId: event.pointerId,
4045
+ startX: event.clientX,
4046
+ startWidth: currentWidth(side)
4047
+ };
4048
+ setResizing(side);
4049
+ };
4050
+ const moveDrag = (side, event) => {
4051
+ const drag = dragRef.current;
4052
+ if (!drag || drag.side !== side || drag.pointerId !== event.pointerId) {
4053
+ return;
4054
+ }
4055
+ const delta = event.clientX - drag.startX;
4056
+ changeSideWidth(side, drag.startWidth + (side === "left" ? delta : -delta));
4057
+ };
4058
+ const finishDrag = (event) => {
4059
+ if (dragRef.current?.pointerId !== event.pointerId)
4060
+ return;
4061
+ dragRef.current = null;
4062
+ setResizing(null);
4063
+ if (typeof event.currentTarget.releasePointerCapture === "function" && event.currentTarget.hasPointerCapture?.(event.pointerId)) {
4064
+ event.currentTarget.releasePointerCapture(event.pointerId);
4065
+ }
4066
+ };
4067
+ const handleKeyDown = (side, event) => {
4068
+ const step = event.shiftKey ? RESIZE_STEP * 4 : RESIZE_STEP;
4069
+ const current = currentWidth(side);
4070
+ let next = null;
4071
+ if (event.key === "ArrowLeft") {
4072
+ next = current + (side === "left" ? -step : step);
4073
+ } else if (event.key === "ArrowRight") {
4074
+ next = current + (side === "left" ? step : -step);
4075
+ } else if (event.key === "Home") {
4076
+ next = side === "left" ? leftBounds.min : rightBounds.min;
4077
+ } else if (event.key === "End") {
4078
+ next = side === "left" ? leftBounds.max : rightBounds.max;
4079
+ }
4080
+ if (next === null)
4081
+ return;
4082
+ event.preventDefault();
4083
+ changeSideWidth(side, next);
4084
+ };
4085
+ const resetWidth = (side, event) => {
4086
+ event.preventDefault();
4087
+ changeSideWidth(side, side === "left" ? leftDefault : rightDefault);
4088
+ };
4089
+ const style = {
4090
+ "--iquji-workbench-left-width": `${leftVisible ? leftValue : 0}px`,
4091
+ "--iquji-workbench-right-width": `${rightVisible ? rightValue : 0}px`,
4092
+ "--iquji-workbench-center-min-width": `${centerMin}px`
4093
+ };
4094
+ const renderResizer = (side) => {
4095
+ const bounds = side === "left" ? leftBounds : rightBounds;
4096
+ const value = currentWidth(side);
4097
+ const paneId = side === "left" ? `${generatedId}-left` : `${generatedId}-right`;
4098
+ return /* @__PURE__ */ jsx33("div", {
4099
+ "aria-controls": paneId,
4100
+ "aria-label": side === "left" ? leftResizeLabel : rightResizeLabel,
4101
+ "aria-orientation": "vertical",
4102
+ "aria-valuemax": bounds.max,
4103
+ "aria-valuemin": bounds.min,
4104
+ "aria-valuenow": value,
4105
+ className: classNames("iquji-workbench__resizer", `iquji-workbench__resizer--${side}`),
4106
+ onDoubleClick: (event) => resetWidth(side, event),
4107
+ onKeyDown: (event) => handleKeyDown(side, event),
4108
+ onPointerCancel: finishDrag,
4109
+ onPointerDown: (event) => startDrag(side, event),
4110
+ onPointerMove: (event) => moveDrag(side, event),
4111
+ onPointerUp: finishDrag,
4112
+ role: "separator",
4113
+ tabIndex: 0
4114
+ });
4115
+ };
4116
+ return /* @__PURE__ */ jsxs29("div", {
4117
+ className: classNames("iquji-workbench", leftCollapsed && "iquji-workbench--left-collapsed", rightCollapsed && "iquji-workbench--right-collapsed", className),
4118
+ "data-resizing": resizing ?? undefined,
4119
+ ref: rootRef,
4120
+ style,
4121
+ children: [
4122
+ hasLeft ? /* @__PURE__ */ jsxs29("div", {
4123
+ "aria-hidden": leftCollapsed || undefined,
4124
+ className: classNames("iquji-workbench__pane", "iquji-workbench__pane--left", leftClassName),
4125
+ id: `${generatedId}-left`,
4126
+ inert: leftCollapsed || undefined,
4127
+ ref: leftRef,
4128
+ children: [
4129
+ left,
4130
+ leftVisible ? renderResizer("left") : null
4131
+ ]
4132
+ }) : null,
4133
+ /* @__PURE__ */ jsx33("div", {
4134
+ className: classNames("iquji-workbench__pane", "iquji-workbench__pane--center", centerClassName),
4135
+ id: `${generatedId}-center`,
4136
+ ref: centerRef,
4137
+ children: center
4138
+ }),
4139
+ hasRight ? /* @__PURE__ */ jsxs29("div", {
4140
+ "aria-hidden": rightCollapsed || undefined,
4141
+ className: classNames("iquji-workbench__pane", "iquji-workbench__pane--right", rightClassName),
4142
+ id: `${generatedId}-right`,
4143
+ inert: rightCollapsed || undefined,
4144
+ ref: rightRef,
4145
+ children: [
4146
+ rightVisible ? renderResizer("right") : null,
4147
+ right
4148
+ ]
4149
+ }) : null
4150
+ ]
4151
+ });
4152
+ }
4153
+ // src/emoji-picker.tsx
4154
+ import { useId as useId16, useMemo as useMemo7, useRef as useRef12, useState as useState13 } from "react";
4155
+ import { jsx as jsx34, jsxs as jsxs30 } from "react/jsx-runtime";
4156
+ function IqujiEmojiPicker({ value, options, onChange, label, searchLabel, emptyLabel, clearLabel, allLabel, disabled, variant = "primary" }) {
4157
+ const [open, setOpen] = useState13(false), [search, setSearch] = useState13("");
4158
+ const [category, setCategory] = useState13(null), [active, setActive] = useState13(0);
4159
+ const id = useId16(), buttons = useRef12(new Map);
4160
+ const categories = useMemo7(() => [...new Set(options.flatMap((option) => option.category ? [option.category] : []))], [options]);
4161
+ const filtered = useMemo7(() => options.filter((option) => (!category || option.category === category) && `${option.label} ${option.keywords ?? ""} ${option.value}`.toLocaleLowerCase().includes(search.trim().toLocaleLowerCase())), [options, search, category]);
4162
+ const navigate = (event) => {
4163
+ const offset = { ArrowRight: 1, ArrowLeft: -1, ArrowDown: 6, ArrowUp: -6 }[event.key];
4164
+ if (offset === undefined && event.key !== "Home" && event.key !== "End")
4165
+ return;
4166
+ event.preventDefault();
4167
+ const next = event.key === "Home" ? 0 : event.key === "End" ? filtered.length - 1 : Math.max(0, Math.min(filtered.length - 1, active + (offset ?? 0)));
4168
+ setActive(next);
4169
+ buttons.current.get(next)?.focus();
4170
+ };
4171
+ return /* @__PURE__ */ jsx34(IqujiPopover, {
4172
+ open,
4173
+ onOpenChange: (next) => {
4174
+ setOpen(next);
4175
+ if (!next) {
4176
+ setSearch("");
4177
+ setCategory(null);
4178
+ setActive(0);
4179
+ }
4180
+ },
4181
+ trigger: /* @__PURE__ */ jsx34(IqujiButton, {
4182
+ variant,
4183
+ disabled,
4184
+ "aria-label": label,
4185
+ children: value ?? label
4186
+ }),
4187
+ children: /* @__PURE__ */ jsxs30("section", {
4188
+ className: "iquji-emoji-picker",
4189
+ "aria-label": label,
4190
+ children: [
4191
+ /* @__PURE__ */ jsx34("label", {
4192
+ htmlFor: id,
4193
+ children: searchLabel
4194
+ }),
4195
+ /* @__PURE__ */ jsx34(IqujiInput, {
4196
+ id,
4197
+ value: search,
4198
+ onChange: (event) => {
4199
+ setSearch(event.target.value);
4200
+ setActive(0);
4201
+ },
4202
+ onKeyDown: (event) => {
4203
+ if (event.key === "ArrowDown" && filtered.length) {
4204
+ event.preventDefault();
4205
+ buttons.current.get(0)?.focus();
4206
+ }
4207
+ }
4208
+ }),
4209
+ categories.length > 0 && /* @__PURE__ */ jsxs30("div", {
4210
+ className: "iquji-emoji-picker__categories",
4211
+ role: "group",
4212
+ "aria-label": label,
4213
+ children: [
4214
+ /* @__PURE__ */ jsx34(IqujiButton, {
4215
+ compact: true,
4216
+ variant: "ghost",
4217
+ "aria-pressed": category === null,
4218
+ onClick: () => {
4219
+ setCategory(null);
4220
+ setActive(0);
4221
+ },
4222
+ children: allLabel ?? searchLabel
4223
+ }),
4224
+ categories.map((item) => /* @__PURE__ */ jsx34(IqujiButton, {
4225
+ compact: true,
4226
+ variant: "ghost",
4227
+ "aria-pressed": category === item,
4228
+ onClick: () => {
4229
+ setCategory(item);
4230
+ setActive(0);
4231
+ },
4232
+ children: item
4233
+ }, item))
4234
+ ]
4235
+ }),
4236
+ /* @__PURE__ */ jsx34("div", {
4237
+ className: "iquji-emoji-picker__grid",
4238
+ role: "group",
4239
+ "aria-label": label,
4240
+ onKeyDown: navigate,
4241
+ children: filtered.map((option, index) => /* @__PURE__ */ jsx34(IqujiButton, {
4242
+ ref: (element) => {
4243
+ if (element)
4244
+ buttons.current.set(index, element);
4245
+ else
4246
+ buttons.current.delete(index);
4247
+ },
4248
+ tabIndex: index === Math.min(active, filtered.length - 1) ? 0 : -1,
4249
+ variant: "ghost",
4250
+ "aria-label": option.label,
4251
+ "aria-pressed": value === option.value,
4252
+ title: option.label,
4253
+ onFocus: () => setActive(index),
4254
+ onClick: () => {
4255
+ onChange(option.value);
4256
+ setOpen(false);
4257
+ setSearch("");
4258
+ setCategory(null);
4259
+ setActive(0);
4260
+ },
4261
+ children: option.value
4262
+ }, option.value))
4263
+ }),
4264
+ !filtered.length && /* @__PURE__ */ jsx34("p", {
4265
+ role: "status",
4266
+ children: emptyLabel
4267
+ }),
4268
+ /* @__PURE__ */ jsx34(IqujiButton, {
4269
+ variant: "ghost",
4270
+ onClick: () => {
4271
+ onChange(null);
4272
+ setOpen(false);
4273
+ },
4274
+ children: clearLabel
4275
+ })
4276
+ ]
4277
+ })
4278
+ });
4279
+ }
4280
+
4281
+ // src/index.tsx
4282
+ import { jsx as jsx35, jsxs as jsxs31, Fragment as Fragment9 } from "react/jsx-runtime";
4283
+ var renderNavigationItem = (item) => {
4284
+ const content = /* @__PURE__ */ jsxs31(Fragment9, {
4285
+ children: [
4286
+ item.icon,
4287
+ /* @__PURE__ */ jsx35("span", {
4288
+ children: item.label
4289
+ })
4290
+ ]
4291
+ });
4292
+ return item.disabled || !item.href ? /* @__PURE__ */ jsx35("button", {
4293
+ "aria-label": item.label,
4294
+ className: "iquji-app-shell__navigation-item",
4295
+ "data-disabled": "true",
4296
+ disabled: true,
4297
+ type: "button",
4298
+ children: content
4299
+ }, item.id) : /* @__PURE__ */ jsx35("a", {
4300
+ "aria-label": item.label,
4301
+ "aria-current": item.active ? "page" : undefined,
4302
+ className: "iquji-app-shell__navigation-item",
4303
+ "data-active": item.active || undefined,
4304
+ href: item.href,
4305
+ onClick: item.onNavigate,
4306
+ onFocus: item.onIntent,
4307
+ onMouseEnter: item.onIntent,
4308
+ children: content
4309
+ }, item.id);
4310
+ };
4311
+ function AppShell({
4312
+ brand,
4313
+ navigationLabel,
4314
+ navigation: navigation2,
4315
+ navigationGroups,
4316
+ header,
4317
+ children,
4318
+ mainId = "iquji-main-content",
4319
+ skipLinkLabel
4320
+ }) {
4321
+ return /* @__PURE__ */ jsxs31("div", {
4322
+ className: "iquji-app-shell",
4323
+ children: [
4324
+ skipLinkLabel ? /* @__PURE__ */ jsx35("a", {
4325
+ className: "iquji-skip-link",
4326
+ href: `#${mainId}`,
4327
+ children: skipLinkLabel
4328
+ }) : null,
4329
+ /* @__PURE__ */ jsxs31("aside", {
4330
+ className: "iquji-app-shell__sidebar",
4331
+ children: [
4332
+ /* @__PURE__ */ jsx35("div", {
4333
+ className: "iquji-app-shell__brand",
4334
+ children: brand
4335
+ }),
4336
+ /* @__PURE__ */ jsx35("nav", {
4337
+ "aria-label": navigationLabel,
4338
+ className: "iquji-app-shell__navigation",
4339
+ children: navigationGroups?.length ? navigationGroups.map((group) => /* @__PURE__ */ jsxs31("section", {
4340
+ "aria-labelledby": `${group.id}-navigation-heading`,
4341
+ className: "iquji-app-shell__navigation-group",
4342
+ children: [
4343
+ /* @__PURE__ */ jsx35("h2", {
4344
+ className: "iquji-app-shell__navigation-heading",
4345
+ id: `${group.id}-navigation-heading`,
4346
+ children: group.label
4347
+ }),
4348
+ group.items.map(renderNavigationItem)
4349
+ ]
4350
+ }, group.id)) : navigation2.map(renderNavigationItem)
4351
+ })
4352
+ ]
4353
+ }),
4354
+ /* @__PURE__ */ jsxs31("div", {
4355
+ className: "iquji-app-shell__workspace",
4356
+ children: [
4357
+ /* @__PURE__ */ jsx35("header", {
4358
+ className: "iquji-app-shell__header",
4359
+ children: header
4360
+ }),
4361
+ /* @__PURE__ */ jsx35("main", {
4362
+ className: "iquji-app-shell__main",
4363
+ id: mainId,
4364
+ tabIndex: -1,
4365
+ children
4366
+ })
4367
+ ]
4368
+ })
4369
+ ]
4370
+ });
4371
+ }
4372
+ var IconButton = forwardRef3(function IconButton2({
4373
+ className,
4374
+ compact = false,
4375
+ disabled,
4376
+ icon,
4377
+ label,
4378
+ loading = false,
4379
+ type = "button",
4380
+ variant = "ghost",
4381
+ ...buttonProps
4382
+ }, ref) {
4383
+ const names = [
4384
+ "iquji-icon-button",
4385
+ `iquji-icon-button--${variant}`,
4386
+ compact ? "iquji-icon-button--compact" : null,
4387
+ className
4388
+ ].filter(Boolean).join(" ");
4389
+ return /* @__PURE__ */ jsx35("button", {
4390
+ ...buttonProps,
4391
+ "aria-busy": loading || undefined,
4392
+ "aria-label": label,
4393
+ className: names,
4394
+ disabled: disabled || loading,
4395
+ ref,
4396
+ title: label,
4397
+ type,
4398
+ children: loading ? /* @__PURE__ */ jsx35("span", {
4399
+ "aria-hidden": "true",
4400
+ className: "iquji-button__spinner"
4401
+ }) : /* @__PURE__ */ jsx35("span", {
4402
+ "aria-hidden": "true",
4403
+ className: "iquji-icon-button__icon",
4404
+ children: icon
4405
+ })
4406
+ });
4407
+ });
4408
+ function StatusBadge({
4409
+ tone = "neutral",
4410
+ className,
4411
+ ...props
4412
+ }) {
4413
+ const names = ["iquji-status-badge", className].filter(Boolean).join(" ");
4414
+ return /* @__PURE__ */ jsx35("span", {
4415
+ className: names,
4416
+ "data-tone": tone,
4417
+ ...props
4418
+ });
4419
+ }
4420
+ var IqujiButton = forwardRef3(function IqujiButton2({
4421
+ allowLabelWrap = false,
4422
+ block = false,
4423
+ children,
4424
+ className,
4425
+ compact = false,
4426
+ disabled,
4427
+ iconEnd,
4428
+ iconStart,
4429
+ loading = false,
4430
+ type = "button",
4431
+ variant = "primary",
4432
+ ...buttonProps
4433
+ }, ref) {
4434
+ const names = [
4435
+ "iquji-button",
4436
+ `iquji-button--${variant}`,
4437
+ compact ? "iquji-button--compact" : null,
4438
+ block ? "iquji-button--block" : null,
4439
+ allowLabelWrap ? "iquji-button--allow-label-wrap" : null,
4440
+ className
4441
+ ].filter(Boolean).join(" ");
4442
+ const content = typeof children === "string" || typeof children === "number" ? /* @__PURE__ */ jsx35("span", {
4443
+ className: "iquji-button__label",
4444
+ children
4445
+ }) : children;
4446
+ return /* @__PURE__ */ jsxs31("button", {
4447
+ ...buttonProps,
4448
+ "aria-busy": loading || undefined,
4449
+ className: names,
4450
+ disabled: disabled || loading,
4451
+ ref,
4452
+ type,
4453
+ children: [
4454
+ loading ? /* @__PURE__ */ jsx35("span", {
4455
+ className: "iquji-button__spinner",
4456
+ "aria-hidden": "true"
4457
+ }) : iconStart ? /* @__PURE__ */ jsx35("span", {
4458
+ className: "iquji-button__icon",
4459
+ "aria-hidden": "true",
4460
+ children: iconStart
4461
+ }) : null,
4462
+ content,
4463
+ !loading && iconEnd ? /* @__PURE__ */ jsx35("span", {
4464
+ className: "iquji-button__icon",
4465
+ "aria-hidden": "true",
4466
+ children: iconEnd
4467
+ }) : null
4468
+ ]
4469
+ });
4470
+ });
4471
+ function IqujiButtonLink({
4472
+ "aria-disabled": ariaDisabled,
4473
+ allowLabelWrap = false,
4474
+ block = false,
4475
+ children,
4476
+ className,
4477
+ compact = false,
4478
+ disabled = false,
4479
+ href,
4480
+ iconEnd,
4481
+ iconStart,
4482
+ loading = false,
4483
+ onClick,
4484
+ tabIndex,
4485
+ variant = "primary",
4486
+ ...anchorProps
4487
+ }) {
4488
+ const blocked = disabled || loading || ariaDisabled === true || ariaDisabled === "true";
4489
+ const names = [
4490
+ "iquji-button-link",
4491
+ `iquji-button-link--${variant}`,
4492
+ compact ? "iquji-button-link--compact" : null,
4493
+ block ? "iquji-button-link--block" : null,
4494
+ allowLabelWrap ? "iquji-button-link--allow-label-wrap" : null,
4495
+ className
4496
+ ].filter(Boolean).join(" ");
4497
+ const content = typeof children === "string" || typeof children === "number" ? /* @__PURE__ */ jsx35("span", {
4498
+ className: "iquji-button__label",
4499
+ children
4500
+ }) : children;
4501
+ return /* @__PURE__ */ jsxs31("a", {
4502
+ ...anchorProps,
4503
+ "aria-busy": loading || undefined,
4504
+ "aria-disabled": blocked || undefined,
4505
+ className: names,
4506
+ "data-loading": loading || undefined,
4507
+ href: blocked ? undefined : href,
4508
+ role: anchorProps.role ?? (blocked ? "link" : undefined),
4509
+ onClick: (event) => {
4510
+ if (blocked) {
4511
+ event.preventDefault();
4512
+ event.stopPropagation();
4513
+ return;
4514
+ }
4515
+ onClick?.(event);
4516
+ },
4517
+ tabIndex: blocked ? -1 : tabIndex,
4518
+ children: [
4519
+ loading ? /* @__PURE__ */ jsx35("span", {
4520
+ className: "iquji-button__spinner",
4521
+ "aria-hidden": "true"
4522
+ }) : iconStart ? /* @__PURE__ */ jsx35("span", {
4523
+ className: "iquji-button__icon",
4524
+ "aria-hidden": "true",
4525
+ children: iconStart
4526
+ }) : null,
4527
+ content,
4528
+ !loading && iconEnd ? /* @__PURE__ */ jsx35("span", {
4529
+ className: "iquji-button__icon",
4530
+ "aria-hidden": "true",
4531
+ children: iconEnd
4532
+ }) : null
4533
+ ]
4534
+ });
4535
+ }
4536
+ function IqujiPanel({
4537
+ className,
4538
+ header,
4539
+ children,
4540
+ ...sectionProps
4541
+ }) {
4542
+ const names = ["iquji-panel", className].filter(Boolean).join(" ");
4543
+ return /* @__PURE__ */ jsxs31("section", {
4544
+ className: names,
4545
+ ...sectionProps,
4546
+ children: [
4547
+ header ? /* @__PURE__ */ jsx35("header", {
4548
+ className: "iquji-panel__header",
4549
+ children: header
4550
+ }) : null,
4551
+ children
4552
+ ]
4553
+ });
4554
+ }
4555
+ function IqujiPageHeading({
4556
+ aside,
4557
+ className,
4558
+ kicker,
4559
+ summary,
4560
+ title,
4561
+ titleId
4562
+ }) {
4563
+ const names = ["iquji-page-heading", className].filter(Boolean).join(" ");
4564
+ return /* @__PURE__ */ jsxs31("div", {
4565
+ className: names,
4566
+ children: [
4567
+ /* @__PURE__ */ jsxs31("div", {
4568
+ children: [
4569
+ kicker ? /* @__PURE__ */ jsx35("p", {
4570
+ className: "iquji-page-heading__kicker",
4571
+ children: kicker
4572
+ }) : null,
4573
+ /* @__PURE__ */ jsx35("h1", {
4574
+ id: titleId,
4575
+ children: title
4576
+ }),
4577
+ summary ? /* @__PURE__ */ jsx35("p", {
4578
+ className: "iquji-page-heading__summary",
4579
+ children: summary
4580
+ }) : null
4581
+ ]
4582
+ }),
4583
+ aside
4584
+ ]
4585
+ });
4586
+ }
4587
+ function IqujiEmptyState({
4588
+ action,
4589
+ body,
4590
+ className,
4591
+ icon,
4592
+ title,
4593
+ titleId,
4594
+ children,
4595
+ ...sectionProps
4596
+ }) {
4597
+ const names = ["iquji-empty-state", className].filter(Boolean).join(" ");
4598
+ return /* @__PURE__ */ jsxs31("section", {
4599
+ className: names,
4600
+ ...sectionProps,
4601
+ children: [
4602
+ icon ? /* @__PURE__ */ jsx35("span", {
4603
+ className: "iquji-empty-state__icon",
4604
+ "aria-hidden": "true",
4605
+ children: icon
4606
+ }) : null,
4607
+ title ? /* @__PURE__ */ jsx35("h2", {
4608
+ id: titleId,
4609
+ children: title
4610
+ }) : null,
4611
+ body ? /* @__PURE__ */ jsx35("p", {
4612
+ children: body
4613
+ }) : null,
4614
+ children,
4615
+ action ? /* @__PURE__ */ jsx35("div", {
4616
+ className: "iquji-empty-state__action",
4617
+ children: action
4618
+ }) : null
4619
+ ]
4620
+ });
4621
+ }
4622
+ function IqujiLoadingState({
4623
+ className,
4624
+ label,
4625
+ ...divProps
4626
+ }) {
4627
+ const names = ["iquji-loading-state", className].filter(Boolean).join(" ");
4628
+ return /* @__PURE__ */ jsxs31("div", {
4629
+ "aria-busy": "true",
4630
+ "aria-live": "polite",
4631
+ className: names,
4632
+ role: "status",
4633
+ ...divProps,
4634
+ children: [
4635
+ /* @__PURE__ */ jsx35("span", {
4636
+ className: "iquji-loading-state__spinner",
4637
+ "aria-hidden": "true"
4638
+ }),
4639
+ /* @__PURE__ */ jsx35("span", {
4640
+ children: label
4641
+ })
4642
+ ]
4643
+ });
4644
+ }
4645
+ export {
4646
+ useIqujiOverlayContainer,
4647
+ useIqujiNotification,
4648
+ parseCalendarDate,
4649
+ normalizeIqujiColor,
4650
+ formatCalendarDate,
4651
+ StatusBadge,
4652
+ IqujiWorkbenchLayout,
4653
+ IqujiTooltip,
4654
+ IqujiTimeline,
4655
+ IqujiTextarea,
4656
+ IqujiTabs,
4657
+ IqujiTableFrame,
4658
+ IqujiSwitch,
4659
+ IqujiSkeleton,
4660
+ IqujiSettingsSwitchRow,
4661
+ IqujiSettingsSelectRow,
4662
+ IqujiSettingsSection,
4663
+ IqujiSettingsRow,
4664
+ IqujiSettingsNav,
4665
+ IqujiSettingsLayout,
4666
+ IqujiSettingsContent,
4667
+ IqujiSettingsActionRow,
4668
+ IqujiSelect,
4669
+ IqujiSegmentedControl,
4670
+ IqujiSearchDialog,
4671
+ IqujiScrollArea,
4672
+ IqujiRadio,
4673
+ IqujiProgressBar,
4674
+ IqujiPopover,
4675
+ IqujiPanel,
4676
+ IqujiPagination,
4677
+ IqujiPageHeading,
4678
+ IqujiPageHeader,
4679
+ IqujiOverlayScopeProvider,
4680
+ IqujiOverlayProvider,
4681
+ IqujiNotificationProvider,
4682
+ IqujiMultiSelect,
4683
+ IqujiLoadingState,
4684
+ IqujiInput,
4685
+ IqujiFormSteps,
4686
+ IqujiFormDialog,
4687
+ IqujiField,
4688
+ IqujiEmptyState,
4689
+ IqujiEmojiPicker,
4690
+ IqujiDropdownMenu,
4691
+ IqujiDrawer,
4692
+ IqujiDialog,
4693
+ IqujiDesktopTitleBar,
4694
+ IqujiDesktopTabStrip,
4695
+ IqujiDesktopShell,
4696
+ IqujiDesktopRail,
4697
+ IqujiDesktopAccountCard,
4698
+ IqujiDesktopAccount,
4699
+ IqujiDatePicker,
4700
+ IqujiDataTable,
4701
+ IqujiConfirmDialog,
4702
+ IqujiColorPicker,
4703
+ IqujiCheckbox,
4704
+ IqujiCalendar,
4705
+ IqujiButtonLink,
4706
+ IqujiButton,
4707
+ IqujiBadge,
4708
+ IqujiAsyncStateFrame,
4709
+ IqujiAlert,
4710
+ IconButton,
4711
+ AppShell
4712
+ };