@devalok/shilp-sutra 0.33.2 → 0.34.1

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 (175) hide show
  1. package/dist/_chunks/badge-group.js +306 -246
  2. package/dist/_chunks/chat.js +513 -0
  3. package/dist/_chunks/date-picker.js +748 -0
  4. package/dist/_chunks/document-preview.js +109 -90
  5. package/dist/_chunks/file-preview.js +492 -504
  6. package/dist/_chunks/framer.js +5564 -5613
  7. package/dist/_chunks/image-preview.js +127 -88
  8. package/dist/_chunks/keybinding.js +12 -14
  9. package/dist/_chunks/link-context.js +19 -16
  10. package/dist/_chunks/mention-suggestion.js +353 -350
  11. package/dist/_chunks/motion-provider.js +26 -20
  12. package/dist/_chunks/popover.js +127 -0
  13. package/dist/_chunks/primitives.js +7584 -6425
  14. package/dist/_chunks/rich-chat-input.js +2070 -0
  15. package/dist/_chunks/rolldown-runtime.js +21 -0
  16. package/dist/_chunks/shared.js +126 -0
  17. package/dist/_chunks/sonner.js +605 -734
  18. package/dist/_chunks/stat-row.js +418 -440
  19. package/dist/_chunks/tiptap.js +15850 -19964
  20. package/dist/_chunks/tree-view.js +231 -290
  21. package/dist/_chunks/use-calendar.js +161 -208
  22. package/dist/_chunks/vendor-client.js +314 -2199
  23. package/dist/_chunks/vendor-utils.js +1721 -2978
  24. package/dist/ai/ai-command-provider.js +23 -17
  25. package/dist/ai/block-renderer.js +68 -51
  26. package/dist/ai/blocks/index.js +2 -12
  27. package/dist/ai/command-bar.js +470 -519
  28. package/dist/ai/conversation.js +241 -227
  29. package/dist/ai/index.js +181 -167
  30. package/dist/ai/types.js +0 -1
  31. package/dist/composed/activity-feed.js +232 -202
  32. package/dist/composed/avatar-group.js +164 -222
  33. package/dist/composed/bulk-action-bar.js +174 -165
  34. package/dist/composed/command-palette.js +290 -308
  35. package/dist/composed/confirm-dialog.js +28 -48
  36. package/dist/composed/content-card.js +69 -108
  37. package/dist/composed/date-picker/index.js +3 -13
  38. package/dist/composed/deadline-indicator.js +68 -74
  39. package/dist/composed/emoji-picker.js +83 -110
  40. package/dist/composed/empty-state.js +64 -103
  41. package/dist/composed/error-boundary.js +129 -127
  42. package/dist/composed/file-preview.js +2 -12
  43. package/dist/composed/filter-bar.js +98 -130
  44. package/dist/composed/form-section.js +61 -45
  45. package/dist/composed/global-loading.js +34 -47
  46. package/dist/composed/index.js +34 -92
  47. package/dist/composed/inline-edit.js +92 -107
  48. package/dist/composed/lib/string-utils.js +8 -8
  49. package/dist/composed/loading-skeleton.js +103 -171
  50. package/dist/composed/markdown-viewer.js +187 -139
  51. package/dist/composed/master-detail.js +147 -156
  52. package/dist/composed/member-picker.js +46 -49
  53. package/dist/composed/multi-select-popover.js +181 -179
  54. package/dist/composed/page-header.js +54 -76
  55. package/dist/composed/page-skeletons.js +143 -127
  56. package/dist/composed/priority-indicator.js +105 -111
  57. package/dist/composed/responsive-overlay.js +36 -41
  58. package/dist/composed/rich-chat-input.js +2 -1860
  59. package/dist/composed/rich-text-editor.js +561 -424
  60. package/dist/composed/schedule-view.js +134 -185
  61. package/dist/composed/simple-tooltip.js +21 -21
  62. package/dist/composed/status-badge.js +133 -137
  63. package/dist/hooks/index.js +7 -12
  64. package/dist/hooks/use-color-mode.js +28 -25
  65. package/dist/hooks/use-mobile.js +13 -13
  66. package/dist/hooks/use-toast.js +2 -4
  67. package/dist/hooks/use-touch-device.js +9 -11
  68. package/dist/hooks/use-viewport-height.js +14 -14
  69. package/dist/motion/index.js +3 -11
  70. package/dist/motion/primitives-index.js +226 -186
  71. package/dist/shell/app-command-palette.js +203 -234
  72. package/dist/shell/bottom-navbar.js +150 -190
  73. package/dist/shell/command-registry.js +13 -14
  74. package/dist/shell/index.js +10 -20
  75. package/dist/shell/link-context.js +2 -5
  76. package/dist/shell/notification-center.js +238 -259
  77. package/dist/shell/notification-preferences.js +241 -184
  78. package/dist/shell/sidebar.js +251 -281
  79. package/dist/shell/top-bar.js +203 -237
  80. package/dist/tailwind/index.cjs +426 -451
  81. package/dist/tailwind/index.js +2 -4
  82. package/dist/tailwind/preset.d.ts.map +1 -1
  83. package/dist/tailwind/preset.js +443 -468
  84. package/dist/ui/accordion.js +52 -60
  85. package/dist/ui/alert-dialog.js +111 -156
  86. package/dist/ui/alert.js +177 -99
  87. package/dist/ui/aspect-ratio.js +13 -16
  88. package/dist/ui/autocomplete.js +112 -148
  89. package/dist/ui/avatar.js +196 -169
  90. package/dist/ui/badge-group.js +2 -7
  91. package/dist/ui/badge-indicator.js +42 -51
  92. package/dist/ui/badge.js +2 -15
  93. package/dist/ui/banner.js +76 -68
  94. package/dist/ui/breadcrumb.js +65 -84
  95. package/dist/ui/button-group.js +109 -102
  96. package/dist/ui/button-processing.js +69 -73
  97. package/dist/ui/button.js +393 -279
  98. package/dist/ui/card.js +151 -157
  99. package/dist/ui/charts/index.js +1002 -1319
  100. package/dist/ui/chat/index.js +2 -11
  101. package/dist/ui/checkbox.js +77 -100
  102. package/dist/ui/code.js +18 -32
  103. package/dist/ui/collapsible.js +21 -29
  104. package/dist/ui/color-input.js +453 -372
  105. package/dist/ui/color-swatch.js +60 -90
  106. package/dist/ui/combobox.js +244 -293
  107. package/dist/ui/container.js +18 -24
  108. package/dist/ui/context-menu.js +154 -203
  109. package/dist/ui/data-table-body.js +116 -213
  110. package/dist/ui/data-table-bulk-actions.js +43 -59
  111. package/dist/ui/data-table-card.js +84 -71
  112. package/dist/ui/data-table-context.js +39 -42
  113. package/dist/ui/data-table-header.js +98 -139
  114. package/dist/ui/data-table-pagination.js +69 -82
  115. package/dist/ui/data-table-toolbar.js +104 -130
  116. package/dist/ui/data-table.js +278 -354
  117. package/dist/ui/devalok-grain.js +77 -66
  118. package/dist/ui/dialog.js +122 -151
  119. package/dist/ui/dropdown-menu.js +152 -203
  120. package/dist/ui/file-upload.js +242 -266
  121. package/dist/ui/form.js +60 -56
  122. package/dist/ui/hover-card.js +54 -54
  123. package/dist/ui/icon-button.js +21 -26
  124. package/dist/ui/icon-context.js +17 -17
  125. package/dist/ui/icon-group.js +22 -29
  126. package/dist/ui/icon.js +201 -121
  127. package/dist/ui/index.js +74 -350
  128. package/dist/ui/input-otp.d.ts.map +1 -1
  129. package/dist/ui/input-otp.js +44 -48
  130. package/dist/ui/input.js +92 -169
  131. package/dist/ui/label.js +17 -22
  132. package/dist/ui/lib/date-utils.js +14 -11
  133. package/dist/ui/lib/motion.js +77 -36
  134. package/dist/ui/lib/utils.js +39 -16
  135. package/dist/ui/link.js +13 -24
  136. package/dist/ui/menubar.js +132 -210
  137. package/dist/ui/navigation-menu.js +164 -194
  138. package/dist/ui/number-input.js +72 -95
  139. package/dist/ui/pagination.js +122 -159
  140. package/dist/ui/popover.js +2 -131
  141. package/dist/ui/progress-ring.js +133 -143
  142. package/dist/ui/progress.js +51 -95
  143. package/dist/ui/radio.js +41 -50
  144. package/dist/ui/search-input.js +51 -53
  145. package/dist/ui/segmented-control.js +93 -114
  146. package/dist/ui/select.js +131 -157
  147. package/dist/ui/separator.js +15 -25
  148. package/dist/ui/sheet.js +135 -163
  149. package/dist/ui/sidebar.js +357 -600
  150. package/dist/ui/skeleton.js +179 -231
  151. package/dist/ui/slider.js +24 -34
  152. package/dist/ui/spinner.js +226 -205
  153. package/dist/ui/split-button.js +227 -276
  154. package/dist/ui/stack.js +56 -70
  155. package/dist/ui/stat-card.js +259 -251
  156. package/dist/ui/status-dot.js +67 -63
  157. package/dist/ui/stepper.js +119 -168
  158. package/dist/ui/switch.js +51 -54
  159. package/dist/ui/table.js +57 -90
  160. package/dist/ui/tabs.js +139 -156
  161. package/dist/ui/text.js +52 -59
  162. package/dist/ui/textarea.js +40 -57
  163. package/dist/ui/toast-types.js +0 -1
  164. package/dist/ui/toast.js +554 -536
  165. package/dist/ui/toaster.js +23 -33
  166. package/dist/ui/toggle-group.js +37 -41
  167. package/dist/ui/toggle.js +36 -40
  168. package/dist/ui/tooltip.js +80 -65
  169. package/dist/ui/tree-view/index.js +2 -6
  170. package/dist/ui/visually-hidden.js +12 -10
  171. package/llms-full.txt +1 -1
  172. package/llms.txt +12 -0
  173. package/package.json +3 -3
  174. package/dist/_chunks/date-time-picker.js +0 -851
  175. package/dist/_chunks/typing-indicator.js +0 -565
package/dist/ui/alert.js CHANGED
@@ -1,101 +1,179 @@
1
1
  "use client";
2
- import { jsx as r, jsxs as c } from "react/jsx-runtime";
3
- import { IconInfoCircle as i, IconAlertCircle as y, IconAlertTriangle as C, IconCircleCheck as A, IconX as k } from "@tabler/icons-react";
2
+ import { a as e, c as t } from "../_chunks/framer.js";
3
+ import { motionProps as n, springs as r } from "./lib/motion.js";
4
+ import { t as i } from "../_chunks/vendor-utils.js";
5
+ import { cn as a } from "./lib/utils.js";
6
+ import { Icon as o } from "./icon.js";
4
7
  import * as s from "react";
5
- import { a as V } from "../_chunks/vendor-utils.js";
6
- import { cn as t } from "./lib/utils.js";
7
- import { springs as S, motionProps as j } from "./lib/motion.js";
8
- import { Icon as l } from "./icon.js";
9
- import { A as R, m as E } from "../_chunks/framer.js";
10
- const P = V(
11
- "relative flex rounded-ds-lg border",
12
- {
13
- variants: {
14
- variant: {
15
- subtle: "",
16
- filled: "",
17
- outline: ""
18
- },
19
- color: {
20
- info: "",
21
- success: "",
22
- warning: "",
23
- error: "",
24
- neutral: ""
25
- },
26
- size: {
27
- sm: "gap-ds-03 p-ds-03",
28
- md: "gap-ds-04 p-ds-05",
29
- lg: "gap-ds-05 p-ds-07"
30
- }
31
- },
32
- compoundVariants: [
33
- // subtle (surface bg) — default, matches previous behavior
34
- { variant: "subtle", color: "info", className: "bg-info-3 border-info-7 text-info-11" },
35
- { variant: "subtle", color: "success", className: "bg-success-3 border-success-7 text-success-11" },
36
- { variant: "subtle", color: "warning", className: "bg-warning-3 border-warning-7 text-warning-11" },
37
- { variant: "subtle", color: "error", className: "bg-error-3 border-error-7 text-error-11" },
38
- { variant: "subtle", color: "neutral", className: "bg-surface-raised border-surface-border-strong text-surface-fg [&>svg]:text-surface-fg-muted" },
39
- // filled (solid bg, white text)
40
- { variant: "filled", color: "info", className: "bg-info-9 text-accent-fg border-transparent [&>svg]:text-accent-fg" },
41
- { variant: "filled", color: "success", className: "bg-success-9 text-accent-fg border-transparent [&>svg]:text-accent-fg" },
42
- { variant: "filled", color: "warning", className: "bg-warning-9 text-accent-fg border-transparent [&>svg]:text-accent-fg" },
43
- { variant: "filled", color: "error", className: "bg-error-9 text-accent-fg border-transparent [&>svg]:text-accent-fg" },
44
- { variant: "filled", color: "neutral", className: "bg-surface-raised-hover text-surface-fg border-transparent [&>svg]:text-surface-fg-muted" },
45
- // outline (transparent bg, colored border)
46
- { variant: "outline", color: "info", className: "bg-transparent border-info-7 text-info-11" },
47
- { variant: "outline", color: "success", className: "bg-transparent border-success-7 text-success-11" },
48
- { variant: "outline", color: "warning", className: "bg-transparent border-warning-7 text-warning-11" },
49
- { variant: "outline", color: "error", className: "bg-transparent border-error-7 text-error-11" },
50
- { variant: "outline", color: "neutral", className: "bg-transparent border-surface-border-strong text-surface-fg [&>svg]:text-surface-fg-muted" }
51
- ],
52
- defaultVariants: { variant: "subtle", color: "info", size: "md" }
53
- }
54
- ), T = {
55
- info: i,
56
- success: A,
57
- warning: C,
58
- error: y,
59
- neutral: i
60
- }, D = s.forwardRef(
61
- ({ className: d, variant: m = "subtle", color: a = "info", size: e = "md", title: n, onDismiss: o, children: f, ...g }, u) => {
62
- const b = T[a ?? "info"], [x, v] = s.useState(!0), p = s.useCallback(() => {
63
- v(!1);
64
- }, []), N = e === "sm" ? "sm" : e === "lg" ? "lg" : "md", h = e === "sm" ? "xs" : "sm", w = e === "sm" ? "text-ds-xs" : "text-ds-md", I = e === "sm" ? "text-ds-sm" : e === "lg" ? "text-ds-lg" : "text-ds-md";
65
- return /* @__PURE__ */ r(R, { onExitComplete: o, children: x && /* @__PURE__ */ c(
66
- E.div,
67
- {
68
- ref: u,
69
- initial: { opacity: 1, y: 0 },
70
- animate: { opacity: 1, y: 0 },
71
- exit: { opacity: 0, y: -8 },
72
- transition: S.snappy,
73
- className: t(P({ variant: m, color: a, size: e }), d),
74
- role: "alert",
75
- ...j(g),
76
- children: [
77
- /* @__PURE__ */ r(l, { icon: b, size: N, className: "mt-ds-01 shrink-0" }),
78
- /* @__PURE__ */ c("div", { className: "flex-1 min-w-0", children: [
79
- n && /* @__PURE__ */ r("p", { className: t(I, "font-semibold mb-ds-01"), children: n }),
80
- /* @__PURE__ */ r("div", { className: t(w, "text-surface-fg-muted"), children: f })
81
- ] }),
82
- o && /* @__PURE__ */ r(
83
- "button",
84
- {
85
- type: "button",
86
- onClick: p,
87
- className: "shrink-0 min-h-ds-xs min-w-ds-xs flex items-center justify-center rounded-ds-sm text-surface-fg-subtle transition-colors duration-fast-01 ease-productive-standard hover:text-surface-fg-muted hover:bg-surface-raised-hover active:scale-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-9",
88
- "aria-label": "Dismiss",
89
- children: /* @__PURE__ */ r(l, { icon: k, size: h })
90
- }
91
- )
92
- ]
93
- }
94
- ) });
95
- }
96
- );
97
- D.displayName = "Alert";
98
- export {
99
- D as Alert,
100
- P as alertVariants
101
- };
8
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
9
+ import { IconAlertCircle as u, IconAlertTriangle as d, IconCircleCheck as f, IconInfoCircle as p, IconX as m } from "@tabler/icons-react";
10
+ //#region src/ui/alert.tsx
11
+ var h = i("relative flex rounded-ds-lg border", {
12
+ variants: {
13
+ variant: {
14
+ subtle: "",
15
+ filled: "",
16
+ outline: ""
17
+ },
18
+ color: {
19
+ info: "",
20
+ success: "",
21
+ warning: "",
22
+ error: "",
23
+ neutral: ""
24
+ },
25
+ size: {
26
+ sm: "gap-ds-03 p-ds-03",
27
+ md: "gap-ds-04 p-ds-05",
28
+ lg: "gap-ds-05 p-ds-07"
29
+ }
30
+ },
31
+ compoundVariants: [
32
+ {
33
+ variant: "subtle",
34
+ color: "info",
35
+ className: "bg-info-3 border-info-7 text-info-11"
36
+ },
37
+ {
38
+ variant: "subtle",
39
+ color: "success",
40
+ className: "bg-success-3 border-success-7 text-success-11"
41
+ },
42
+ {
43
+ variant: "subtle",
44
+ color: "warning",
45
+ className: "bg-warning-3 border-warning-7 text-warning-11"
46
+ },
47
+ {
48
+ variant: "subtle",
49
+ color: "error",
50
+ className: "bg-error-3 border-error-7 text-error-11"
51
+ },
52
+ {
53
+ variant: "subtle",
54
+ color: "neutral",
55
+ className: "bg-surface-raised border-surface-border-strong text-surface-fg [&>svg]:text-surface-fg-muted"
56
+ },
57
+ {
58
+ variant: "filled",
59
+ color: "info",
60
+ className: "bg-info-9 text-accent-fg border-transparent [&>svg]:text-accent-fg"
61
+ },
62
+ {
63
+ variant: "filled",
64
+ color: "success",
65
+ className: "bg-success-9 text-accent-fg border-transparent [&>svg]:text-accent-fg"
66
+ },
67
+ {
68
+ variant: "filled",
69
+ color: "warning",
70
+ className: "bg-warning-9 text-accent-fg border-transparent [&>svg]:text-accent-fg"
71
+ },
72
+ {
73
+ variant: "filled",
74
+ color: "error",
75
+ className: "bg-error-9 text-accent-fg border-transparent [&>svg]:text-accent-fg"
76
+ },
77
+ {
78
+ variant: "filled",
79
+ color: "neutral",
80
+ className: "bg-surface-raised-hover text-surface-fg border-transparent [&>svg]:text-surface-fg-muted"
81
+ },
82
+ {
83
+ variant: "outline",
84
+ color: "info",
85
+ className: "bg-transparent border-info-7 text-info-11"
86
+ },
87
+ {
88
+ variant: "outline",
89
+ color: "success",
90
+ className: "bg-transparent border-success-7 text-success-11"
91
+ },
92
+ {
93
+ variant: "outline",
94
+ color: "warning",
95
+ className: "bg-transparent border-warning-7 text-warning-11"
96
+ },
97
+ {
98
+ variant: "outline",
99
+ color: "error",
100
+ className: "bg-transparent border-error-7 text-error-11"
101
+ },
102
+ {
103
+ variant: "outline",
104
+ color: "neutral",
105
+ className: "bg-transparent border-surface-border-strong text-surface-fg [&>svg]:text-surface-fg-muted"
106
+ }
107
+ ],
108
+ defaultVariants: {
109
+ variant: "subtle",
110
+ color: "info",
111
+ size: "md"
112
+ }
113
+ }), g = {
114
+ info: p,
115
+ success: f,
116
+ warning: d,
117
+ error: u,
118
+ neutral: p
119
+ }, _ = s.forwardRef(({ className: i, variant: u = "subtle", color: d = "info", size: f = "md", title: p, onDismiss: _, children: v, ...y }, b) => {
120
+ let x = g[d ?? "info"], [S, C] = s.useState(!0), w = s.useCallback(() => {
121
+ C(!1);
122
+ }, []), T = f === "sm" ? "sm" : f === "lg" ? "lg" : "md", E = f === "sm" ? "xs" : "sm", D = f === "sm" ? "text-ds-xs" : "text-ds-md", O = f === "sm" ? "text-ds-sm" : f === "lg" ? "text-ds-lg" : "text-ds-md";
123
+ return /* @__PURE__ */ c(t, {
124
+ onExitComplete: _,
125
+ children: S && /* @__PURE__ */ l(e.div, {
126
+ ref: b,
127
+ initial: {
128
+ opacity: 1,
129
+ y: 0
130
+ },
131
+ animate: {
132
+ opacity: 1,
133
+ y: 0
134
+ },
135
+ exit: {
136
+ opacity: 0,
137
+ y: -8
138
+ },
139
+ transition: r.snappy,
140
+ className: a(h({
141
+ variant: u,
142
+ color: d,
143
+ size: f
144
+ }), i),
145
+ role: "alert",
146
+ ...n(y),
147
+ children: [
148
+ /* @__PURE__ */ c(o, {
149
+ icon: x,
150
+ size: T,
151
+ className: "mt-ds-01 shrink-0"
152
+ }),
153
+ /* @__PURE__ */ l("div", {
154
+ className: "flex-1 min-w-0",
155
+ children: [p && /* @__PURE__ */ c("p", {
156
+ className: a(O, "font-semibold mb-ds-01"),
157
+ children: p
158
+ }), /* @__PURE__ */ c("div", {
159
+ className: a(D, "text-surface-fg-muted"),
160
+ children: v
161
+ })]
162
+ }),
163
+ _ && /* @__PURE__ */ c("button", {
164
+ type: "button",
165
+ onClick: w,
166
+ className: "shrink-0 min-h-ds-xs min-w-ds-xs flex items-center justify-center rounded-ds-sm text-surface-fg-subtle transition-colors duration-fast-01 ease-productive-standard hover:text-surface-fg-muted hover:bg-surface-raised-hover active:scale-95 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-accent-9",
167
+ "aria-label": "Dismiss",
168
+ children: /* @__PURE__ */ c(o, {
169
+ icon: m,
170
+ size: E
171
+ })
172
+ })
173
+ ]
174
+ })
175
+ });
176
+ });
177
+ _.displayName = "Alert";
178
+ //#endregion
179
+ export { _ as Alert, h as alertVariants };
@@ -1,17 +1,14 @@
1
1
  "use client";
2
- import { jsx as a } from "react/jsx-runtime";
3
- import * as m from "react";
4
- import { f as s } from "../_chunks/primitives.js";
5
- import { cn as p } from "./lib/utils.js";
6
- const e = m.forwardRef(({ className: o, ...t }, r) => /* @__PURE__ */ a(
7
- s,
8
- {
9
- ref: r,
10
- className: p(o),
11
- ...t
12
- }
13
- ));
14
- e.displayName = "AspectRatio";
15
- export {
16
- e as AspectRatio
17
- };
2
+ import { dn as e } from "../_chunks/primitives.js";
3
+ import { cn as t } from "./lib/utils.js";
4
+ import * as n from "react";
5
+ import { jsx as r } from "react/jsx-runtime";
6
+ //#region src/ui/aspect-ratio.tsx
7
+ var i = n.forwardRef(({ className: n, ...i }, a) => /* @__PURE__ */ r(e, {
8
+ ref: a,
9
+ className: t(n),
10
+ ...i
11
+ }));
12
+ i.displayName = "AspectRatio";
13
+ //#endregion
14
+ export { i as AspectRatio };
@@ -1,149 +1,113 @@
1
1
  "use client";
2
- import { jsxs as j, jsx as d } from "react/jsx-runtime";
3
- import * as t from "react";
4
- import { cn as p } from "./lib/utils.js";
5
- import { tweens as L, springs as P } from "./lib/motion.js";
6
- import { A as q, m as v } from "../_chunks/framer.js";
7
- const z = {
8
- hidden: {},
9
- visible: { transition: { staggerChildren: 0.03 } }
10
- }, B = {
11
- hidden: { opacity: 0, y: 4 },
12
- visible: { opacity: 1, y: 0, transition: P.snappy }
13
- }, F = t.forwardRef(
14
- ({
15
- options: b,
16
- value: u,
17
- onValueChange: g,
18
- placeholder: I,
19
- emptyText: R = "No options",
20
- disabled: y,
21
- className: A,
22
- id: C,
23
- ...E
24
- }, i) => {
25
- const N = t.useId(), x = C || N, w = `${x}-listbox`, k = `${x}-option`, [f, h] = t.useState(u?.label ?? ""), [l, r] = t.useState(!1), [s, o] = t.useState(-1), $ = t.useRef(null), M = t.useRef(null), D = t.useRef(null), S = t.useCallback(
26
- (e) => {
27
- $.current = e, typeof i == "function" ? i(e) : i && (i.current = e);
28
- },
29
- [i]
30
- );
31
- t.useEffect(() => {
32
- h(u?.label ?? "");
33
- }, [u]), t.useEffect(() => () => {
34
- }, []);
35
- const n = t.useMemo(
36
- () => f ? b.filter((e) => e.label.toLowerCase().includes(f.toLowerCase())) : b,
37
- [b, f]
38
- ), m = t.useCallback(
39
- (e) => {
40
- h(e.label), r(!1), o(-1), g?.(e);
41
- },
42
- [g]
43
- ), K = t.useCallback(
44
- (e) => {
45
- if (!l) {
46
- (e.key === "ArrowDown" || e.key === "Enter") && r(!0);
47
- return;
48
- }
49
- switch (e.key) {
50
- case "ArrowDown":
51
- e.preventDefault(), o((a) => Math.min(a + 1, n.length - 1));
52
- break;
53
- case "ArrowUp":
54
- e.preventDefault(), o((a) => Math.max(a - 1, 0));
55
- break;
56
- case "Enter":
57
- e.preventDefault(), s >= 0 && n[s] && m(n[s]);
58
- break;
59
- case "Escape":
60
- r(!1), o(-1);
61
- break;
62
- }
63
- },
64
- [l, n, s, m]
65
- ), O = s >= 0 ? `${k}-${s}` : void 0;
66
- return /* @__PURE__ */ j("div", { ref: D, className: p("relative", A), ...E, children: [
67
- /* @__PURE__ */ d(
68
- "input",
69
- {
70
- ref: S,
71
- type: "text",
72
- role: "combobox",
73
- "aria-expanded": l,
74
- "aria-autocomplete": "list",
75
- "aria-controls": l ? w : void 0,
76
- "aria-activedescendant": O,
77
- value: f,
78
- placeholder: I,
79
- disabled: y,
80
- className: p(
81
- "flex h-ds-md w-full rounded-ds-md border border-surface-border-strong bg-surface-raised-hover px-ds-04 py-ds-03 font-sans text-ds-md text-surface-fg placeholder:text-surface-fg-subtle",
82
- "outline-none focus-visible:ring-2 focus-visible:ring-accent-9 focus-visible:ring-offset-[var(--border-focus-offset)]",
83
- "transition-colors duration-fast-01",
84
- y && "opacity-action-disabled cursor-not-allowed"
85
- ),
86
- onChange: (e) => {
87
- h(e.target.value), r(!0), o(-1);
88
- },
89
- onFocus: () => r(!0),
90
- onBlur: (e) => {
91
- D.current?.contains(e.relatedTarget) || r(!1);
92
- },
93
- onKeyDown: K
94
- }
95
- ),
96
- /* @__PURE__ */ d(q, { children: l && /* @__PURE__ */ d(
97
- v.ul,
98
- {
99
- id: w,
100
- ref: M,
101
- role: "listbox",
102
- initial: "hidden",
103
- animate: "visible",
104
- exit: "hidden",
105
- variants: z,
106
- className: p(
107
- "absolute z-popover mt-ds-02 w-full overflow-auto rounded-ds-md border border-surface-border-strong bg-surface-overlay shadow-raised-hover",
108
- "max-h-60"
109
- ),
110
- children: n.length === 0 ? /* @__PURE__ */ d(
111
- v.li,
112
- {
113
- initial: { opacity: 0 },
114
- animate: { opacity: 1 },
115
- transition: L.fade,
116
- className: "px-ds-04 py-ds-03 text-ds-md text-surface-fg-muted",
117
- children: R
118
- }
119
- ) : n.map((e, a) => /* @__PURE__ */ d(
120
- v.li,
121
- {
122
- id: `${k}-${a}`,
123
- role: "option",
124
- "aria-selected": s === a,
125
- variants: B,
126
- className: p(
127
- "cursor-pointer px-ds-04 py-ds-03 text-ds-md text-surface-fg transition-colors duration-fast-01",
128
- s === a && "bg-accent-3",
129
- u?.value === e.value && "font-semibold"
130
- ),
131
- onMouseDown: (c) => c.preventDefault(),
132
- onClick: () => m(e),
133
- onKeyDown: (c) => {
134
- (c.key === "Enter" || c.key === " ") && (c.preventDefault(), m(e));
135
- },
136
- onMouseEnter: () => o(a),
137
- children: e.label
138
- },
139
- e.value
140
- ))
141
- }
142
- ) })
143
- ] });
144
- }
145
- );
146
- F.displayName = "Autocomplete";
147
- export {
148
- F as Autocomplete
149
- };
2
+ import { a as e, c as t } from "../_chunks/framer.js";
3
+ import { springs as n, tweens as r } from "./lib/motion.js";
4
+ import { cn as i } from "./lib/utils.js";
5
+ import * as a from "react";
6
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
7
+ //#region src/ui/autocomplete.tsx
8
+ var c = {
9
+ hidden: {},
10
+ visible: { transition: { staggerChildren: .03 } }
11
+ }, l = {
12
+ hidden: {
13
+ opacity: 0,
14
+ y: 4
15
+ },
16
+ visible: {
17
+ opacity: 1,
18
+ y: 0,
19
+ transition: n.snappy
20
+ }
21
+ }, u = a.forwardRef(({ options: n, value: u, onValueChange: d, placeholder: f, emptyText: p = "No options", disabled: m, className: h, id: g, ..._ }, v) => {
22
+ let y = a.useId(), b = g || y, x = `${b}-listbox`, S = `${b}-option`, [C, w] = a.useState(u?.label ?? ""), [T, E] = a.useState(!1), [D, O] = a.useState(-1), k = a.useRef(null), A = a.useRef(null), j = a.useRef(null), M = a.useCallback((e) => {
23
+ k.current = e, typeof v == "function" ? v(e) : v && (v.current = e);
24
+ }, [v]);
25
+ a.useEffect(() => {
26
+ w(u?.label ?? "");
27
+ }, [u]), a.useEffect(() => () => {}, []);
28
+ let N = a.useMemo(() => C ? n.filter((e) => e.label.toLowerCase().includes(C.toLowerCase())) : n, [n, C]), P = a.useCallback((e) => {
29
+ w(e.label), E(!1), O(-1), d?.(e);
30
+ }, [d]), F = a.useCallback((e) => {
31
+ if (!T) {
32
+ (e.key === "ArrowDown" || e.key === "Enter") && E(!0);
33
+ return;
34
+ }
35
+ switch (e.key) {
36
+ case "ArrowDown":
37
+ e.preventDefault(), O((e) => Math.min(e + 1, N.length - 1));
38
+ break;
39
+ case "ArrowUp":
40
+ e.preventDefault(), O((e) => Math.max(e - 1, 0));
41
+ break;
42
+ case "Enter":
43
+ e.preventDefault(), D >= 0 && N[D] && P(N[D]);
44
+ break;
45
+ case "Escape":
46
+ E(!1), O(-1);
47
+ break;
48
+ }
49
+ }, [
50
+ T,
51
+ N,
52
+ D,
53
+ P
54
+ ]), I = D >= 0 ? `${S}-${D}` : void 0;
55
+ return /* @__PURE__ */ s("div", {
56
+ ref: j,
57
+ className: i("relative", h),
58
+ ..._,
59
+ children: [/* @__PURE__ */ o("input", {
60
+ ref: M,
61
+ type: "text",
62
+ role: "combobox",
63
+ "aria-expanded": T,
64
+ "aria-autocomplete": "list",
65
+ "aria-controls": T ? x : void 0,
66
+ "aria-activedescendant": I,
67
+ value: C,
68
+ placeholder: f,
69
+ disabled: m,
70
+ className: i("flex h-ds-md w-full rounded-ds-md border border-surface-border-strong bg-surface-raised-hover px-ds-04 py-ds-03 font-sans text-ds-md text-surface-fg placeholder:text-surface-fg-subtle", "outline-hidden focus-visible:ring-2 focus-visible:ring-accent-9 focus-visible:ring-offset-[var(--border-focus-offset)]", "transition-colors duration-fast-01", m && "opacity-action-disabled cursor-not-allowed"),
71
+ onChange: (e) => {
72
+ w(e.target.value), E(!0), O(-1);
73
+ },
74
+ onFocus: () => E(!0),
75
+ onBlur: (e) => {
76
+ j.current?.contains(e.relatedTarget) || E(!1);
77
+ },
78
+ onKeyDown: F
79
+ }), /* @__PURE__ */ o(t, { children: T && /* @__PURE__ */ o(e.ul, {
80
+ id: x,
81
+ ref: A,
82
+ role: "listbox",
83
+ initial: "hidden",
84
+ animate: "visible",
85
+ exit: "hidden",
86
+ variants: c,
87
+ className: i("absolute z-popover mt-ds-02 w-full overflow-auto rounded-ds-md border border-surface-border-strong bg-surface-overlay shadow-raised-hover", "max-h-60"),
88
+ children: N.length === 0 ? /* @__PURE__ */ o(e.li, {
89
+ initial: { opacity: 0 },
90
+ animate: { opacity: 1 },
91
+ transition: r.fade,
92
+ className: "px-ds-04 py-ds-03 text-ds-md text-surface-fg-muted",
93
+ children: p
94
+ }) : N.map((t, n) => /* @__PURE__ */ o(e.li, {
95
+ id: `${S}-${n}`,
96
+ role: "option",
97
+ "aria-selected": D === n,
98
+ variants: l,
99
+ className: i("cursor-pointer px-ds-04 py-ds-03 text-ds-md text-surface-fg transition-colors duration-fast-01", D === n && "bg-accent-3", u?.value === t.value && "font-semibold"),
100
+ onMouseDown: (e) => e.preventDefault(),
101
+ onClick: () => P(t),
102
+ onKeyDown: (e) => {
103
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), P(t));
104
+ },
105
+ onMouseEnter: () => O(n),
106
+ children: t.label
107
+ }, t.value))
108
+ }) })]
109
+ });
110
+ });
111
+ u.displayName = "Autocomplete";
112
+ //#endregion
113
+ export { u as Autocomplete };