@pixel-point/toolcraft 0.0.2

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 (257) hide show
  1. package/LICENSE.md +98 -0
  2. package/README.md +41 -0
  3. package/bin/create-toolcraft-app.mjs +8 -0
  4. package/bin/toolcraft.mjs +8 -0
  5. package/package.json +24 -0
  6. package/scripts/prepare-pack.mjs +29 -0
  7. package/src/cli.mjs +392 -0
  8. package/src/cli.test.mjs +284 -0
  9. package/src/copy-recursive.mjs +86 -0
  10. package/src/generate.mjs +212 -0
  11. package/src/generate.test.mjs +322 -0
  12. package/src/import-map.mjs +14 -0
  13. package/src/package-json.mjs +80 -0
  14. package/src/package-json.test.mjs +67 -0
  15. package/src/rewrite-imports.mjs +85 -0
  16. package/src/rewrite-imports.test.mjs +58 -0
  17. package/templates/runtime/contracts/component-contracts.test.ts +1165 -0
  18. package/templates/runtime/contracts/component-contracts.ts +1340 -0
  19. package/templates/runtime/contracts/decision-contracts.test.ts +206 -0
  20. package/templates/runtime/contracts/decision-contracts.ts +283 -0
  21. package/templates/runtime/contracts/index.test.ts +14 -0
  22. package/templates/runtime/contracts/index.ts +3 -0
  23. package/templates/runtime/contracts/types.ts +56 -0
  24. package/templates/runtime/export/export.test.ts +203 -0
  25. package/templates/runtime/export/export.ts +132 -0
  26. package/templates/runtime/export/index.ts +1 -0
  27. package/templates/runtime/index.ts +14 -0
  28. package/templates/runtime/react/canvas-shell.test.tsx +424 -0
  29. package/templates/runtime/react/canvas-shell.tsx +408 -0
  30. package/templates/runtime/react/control-renderers.ts +31 -0
  31. package/templates/runtime/react/controls-panel.test.tsx +3736 -0
  32. package/templates/runtime/react/controls-panel.tsx +2327 -0
  33. package/templates/runtime/react/curve-geometry.test.ts +70 -0
  34. package/templates/runtime/react/index.ts +15 -0
  35. package/templates/runtime/react/layer-tree.ts +96 -0
  36. package/templates/runtime/react/layers-panel.test.tsx +487 -0
  37. package/templates/runtime/react/layers-panel.tsx +1348 -0
  38. package/templates/runtime/react/media-file.ts +82 -0
  39. package/templates/runtime/react/panel-host-config.ts +80 -0
  40. package/templates/runtime/react/panel-host-geometry.test.ts +66 -0
  41. package/templates/runtime/react/panel-host-geometry.ts +109 -0
  42. package/templates/runtime/react/panel-host-types.ts +74 -0
  43. package/templates/runtime/react/panel-host.test.tsx +102 -0
  44. package/templates/runtime/react/panel-host.tsx +353 -0
  45. package/templates/runtime/react/runtime-public-api.test.tsx +132 -0
  46. package/templates/runtime/react/settings-transfer.test.ts +150 -0
  47. package/templates/runtime/react/settings-transfer.ts +279 -0
  48. package/templates/runtime/react/storage-key-migration.ts +48 -0
  49. package/templates/runtime/react/theme-runtime.tsx +177 -0
  50. package/templates/runtime/react/timeline-panel.test.tsx +668 -0
  51. package/templates/runtime/react/timeline-panel.tsx +2953 -0
  52. package/templates/runtime/react/toolbar-panel.test.tsx +212 -0
  53. package/templates/runtime/react/toolbar-panel.tsx +205 -0
  54. package/templates/runtime/react/toolcraft-app.integration.test.tsx +350 -0
  55. package/templates/runtime/react/toolcraft-app.test.tsx +339 -0
  56. package/templates/runtime/react/toolcraft-app.tsx +81 -0
  57. package/templates/runtime/react/toolcraft-root.test.tsx +347 -0
  58. package/templates/runtime/react/toolcraft-root.tsx +203 -0
  59. package/templates/runtime/react/use-toolcraft.ts +41 -0
  60. package/templates/runtime/schema/define-toolcraft.test.ts +1524 -0
  61. package/templates/runtime/schema/define-toolcraft.ts +1442 -0
  62. package/templates/runtime/schema/keyframe-capability.test.ts +90 -0
  63. package/templates/runtime/schema/keyframe-capability.ts +51 -0
  64. package/templates/runtime/schema/runtime-targets.ts +40 -0
  65. package/templates/runtime/schema/types.ts +370 -0
  66. package/templates/runtime/state/canvas-zoom.ts +8 -0
  67. package/templates/runtime/state/create-template-state.test.ts +242 -0
  68. package/templates/runtime/state/create-template-state.ts +95 -0
  69. package/templates/runtime/state/keyframe-evaluation.test.ts +141 -0
  70. package/templates/runtime/state/keyframe-evaluation.ts +203 -0
  71. package/templates/runtime/state/persistence.test.ts +217 -0
  72. package/templates/runtime/state/persistence.ts +511 -0
  73. package/templates/runtime/state/reducer.test.ts +937 -0
  74. package/templates/runtime/state/reducer.ts +1212 -0
  75. package/templates/runtime/state/timeline-readiness.ts +43 -0
  76. package/templates/runtime/state/types.ts +242 -0
  77. package/templates/runtime/styles.css +125 -0
  78. package/templates/runtime/testing/performance.test.ts +1058 -0
  79. package/templates/runtime/testing/performance.ts +1078 -0
  80. package/templates/starter/AGENTS.md +186 -0
  81. package/templates/starter/LICENSE.md +98 -0
  82. package/templates/starter/NOTICE.md +8 -0
  83. package/templates/starter/docs/toolcraft/README.md +41 -0
  84. package/templates/starter/docs/toolcraft/acceptance-testing.md +205 -0
  85. package/templates/starter/docs/toolcraft/agent-worklog.md +81 -0
  86. package/templates/starter/docs/toolcraft/assembly-workflow.md +206 -0
  87. package/templates/starter/docs/toolcraft/component-rules.md +299 -0
  88. package/templates/starter/docs/toolcraft/custom-controls.md +71 -0
  89. package/templates/starter/docs/toolcraft/decision-contract.md +71 -0
  90. package/templates/starter/docs/toolcraft/performance.md +112 -0
  91. package/templates/starter/docs/toolcraft/renderer-technique.md +48 -0
  92. package/templates/starter/docs/toolcraft/schema-reference.md +265 -0
  93. package/templates/starter/docs/toolcraft/workflow.md +87 -0
  94. package/templates/starter/e2e/app-browser-acceptance.spec.ts +785 -0
  95. package/templates/starter/e2e/app-controls.spec.ts +41 -0
  96. package/templates/starter/e2e/app-performance.spec.ts +326 -0
  97. package/templates/starter/e2e/canvas-handle-helpers.ts +244 -0
  98. package/templates/starter/e2e/performance-helpers.ts +612 -0
  99. package/templates/starter/e2e/product-observable-helpers.ts +170 -0
  100. package/templates/starter/index.html +12 -0
  101. package/templates/starter/package.json +52 -0
  102. package/templates/starter/playwright.config.ts +43 -0
  103. package/templates/starter/scripts/check-ai-skills.mjs +95 -0
  104. package/templates/starter/scripts/check-toolcraft-docs.mjs +159 -0
  105. package/templates/starter/scripts/check-toolcraft-integrity.mjs +232 -0
  106. package/templates/starter/scripts/run-vite-on-free-port.mjs +48 -0
  107. package/templates/starter/scripts/toolcraft-port.mjs +54 -0
  108. package/templates/starter/scripts/toolcraft-port.test.mjs +73 -0
  109. package/templates/starter/src/app/starter-acceptance.test.ts +5959 -0
  110. package/templates/starter/src/app/starter-acceptance.ts +2646 -0
  111. package/templates/starter/src/app/starter-performance.test.ts +1390 -0
  112. package/templates/starter/src/app/starter-performance.ts +12 -0
  113. package/templates/starter/src/app/starter-schema.test.ts +70 -0
  114. package/templates/starter/src/app/starter-schema.ts +15 -0
  115. package/templates/starter/src/main.tsx +18 -0
  116. package/templates/starter/src/router.tsx +16 -0
  117. package/templates/starter/src/routes/index.tsx +7 -0
  118. package/templates/starter/src/routes/root.tsx +19 -0
  119. package/templates/starter/src/styles.css +120 -0
  120. package/templates/starter/tsconfig.json +11 -0
  121. package/templates/starter/vite.config.ts +13 -0
  122. package/templates/ui/components/composites/accordion.tsx +73 -0
  123. package/templates/ui/components/composites/alert-dialog.tsx +190 -0
  124. package/templates/ui/components/composites/alert.tsx +74 -0
  125. package/templates/ui/components/composites/aspect-ratio.tsx +22 -0
  126. package/templates/ui/components/composites/avatar.tsx +98 -0
  127. package/templates/ui/components/composites/badge.tsx +69 -0
  128. package/templates/ui/components/composites/breadcrumb.tsx +106 -0
  129. package/templates/ui/components/composites/card.tsx +91 -0
  130. package/templates/ui/components/composites/combobox.tsx +486 -0
  131. package/templates/ui/components/composites/command.tsx +296 -0
  132. package/templates/ui/components/composites/context-menu.tsx +247 -0
  133. package/templates/ui/components/composites/dialog.tsx +282 -0
  134. package/templates/ui/components/composites/dropdown-menu.tsx +299 -0
  135. package/templates/ui/components/composites/empty.tsx +110 -0
  136. package/templates/ui/components/composites/hover-card.tsx +44 -0
  137. package/templates/ui/components/composites/index.ts +30 -0
  138. package/templates/ui/components/composites/menubar.tsx +214 -0
  139. package/templates/ui/components/composites/navigation-menu.tsx +167 -0
  140. package/templates/ui/components/composites/pagination.tsx +131 -0
  141. package/templates/ui/components/composites/progress.tsx +72 -0
  142. package/templates/ui/components/composites/radio-group.tsx +84 -0
  143. package/templates/ui/components/composites/resizable.tsx +42 -0
  144. package/templates/ui/components/composites/sheet.tsx +153 -0
  145. package/templates/ui/components/composites/sidebar-structural.tsx +310 -0
  146. package/templates/ui/components/composites/sidebar.tsx +431 -0
  147. package/templates/ui/components/composites/sonner.tsx +35 -0
  148. package/templates/ui/components/composites/spinner.tsx +43 -0
  149. package/templates/ui/components/composites/table.tsx +108 -0
  150. package/templates/ui/components/composites/tabs.tsx +83 -0
  151. package/templates/ui/components/control-layout/index.tsx +437 -0
  152. package/templates/ui/components/controls/actions/actions-control.tsx +139 -0
  153. package/templates/ui/components/controls/actions/index.ts +9 -0
  154. package/templates/ui/components/controls/anchor-grid/anchor-grid-control.tsx +107 -0
  155. package/templates/ui/components/controls/anchor-grid/index.ts +4 -0
  156. package/templates/ui/components/controls/boolean/boolean-controls.tsx +79 -0
  157. package/templates/ui/components/controls/boolean/index.ts +4 -0
  158. package/templates/ui/components/controls/channel-mixer/channel-mixer-control.tsx +95 -0
  159. package/templates/ui/components/controls/channel-mixer/index.ts +4 -0
  160. package/templates/ui/components/controls/channel-tabs/channel-tabs.tsx +42 -0
  161. package/templates/ui/components/controls/channel-tabs/index.ts +6 -0
  162. package/templates/ui/components/controls/code-textarea/code-textarea-control.tsx +90 -0
  163. package/templates/ui/components/controls/code-textarea/index.ts +4 -0
  164. package/templates/ui/components/controls/color/color-control.tsx +571 -0
  165. package/templates/ui/components/controls/color/color-picker-popover.tsx +104 -0
  166. package/templates/ui/components/controls/color/index.ts +41 -0
  167. package/templates/ui/components/controls/color/palette-control-data.ts +436 -0
  168. package/templates/ui/components/controls/color/palette-control.tsx +535 -0
  169. package/templates/ui/components/controls/color/style-guide-color-picker-channel-utils.ts +162 -0
  170. package/templates/ui/components/controls/color/style-guide-color-picker-interactions.ts +190 -0
  171. package/templates/ui/components/controls/color/style-guide-color-picker-logic.ts +485 -0
  172. package/templates/ui/components/controls/color/style-guide-color-picker-parts.tsx +710 -0
  173. package/templates/ui/components/controls/color/style-guide-color-picker.tsx +503 -0
  174. package/templates/ui/components/controls/control-types.ts +43 -0
  175. package/templates/ui/components/controls/curves/curve-geometry.ts +355 -0
  176. package/templates/ui/components/controls/curves/curve-graph.tsx +390 -0
  177. package/templates/ui/components/controls/curves/curves-control.tsx +445 -0
  178. package/templates/ui/components/controls/curves/index.ts +6 -0
  179. package/templates/ui/components/controls/file-drop/file-drop-control.tsx +191 -0
  180. package/templates/ui/components/controls/file-drop/index.ts +5 -0
  181. package/templates/ui/components/controls/font-picker/font-catalog.json +15360 -0
  182. package/templates/ui/components/controls/font-picker/font-catalog.ts +116 -0
  183. package/templates/ui/components/controls/font-picker/font-picker-control.tsx +1202 -0
  184. package/templates/ui/components/controls/font-picker/font-preview-loader.ts +336 -0
  185. package/templates/ui/components/controls/font-picker/index.ts +24 -0
  186. package/templates/ui/components/controls/font-picker/use-hover-intent.ts +46 -0
  187. package/templates/ui/components/controls/gradient/gradient-control-utils.ts +190 -0
  188. package/templates/ui/components/controls/gradient/gradient-control.tsx +612 -0
  189. package/templates/ui/components/controls/gradient/gradient-stop-list.tsx +400 -0
  190. package/templates/ui/components/controls/gradient/gradient-toolbar.tsx +152 -0
  191. package/templates/ui/components/controls/gradient/index.ts +4 -0
  192. package/templates/ui/components/controls/image-picker/image-picker-control.tsx +139 -0
  193. package/templates/ui/components/controls/image-picker/index.ts +7 -0
  194. package/templates/ui/components/controls/index.ts +192 -0
  195. package/templates/ui/components/controls/range-input/index.ts +4 -0
  196. package/templates/ui/components/controls/range-input/range-input-control.tsx +173 -0
  197. package/templates/ui/components/controls/range-slider/index.ts +4 -0
  198. package/templates/ui/components/controls/range-slider/range-slider-control.tsx +122 -0
  199. package/templates/ui/components/controls/range-slider/range-slider-value.ts +61 -0
  200. package/templates/ui/components/controls/segmented/index.ts +8 -0
  201. package/templates/ui/components/controls/segmented/segmented-control.tsx +94 -0
  202. package/templates/ui/components/controls/select/index.ts +4 -0
  203. package/templates/ui/components/controls/select/select-control.tsx +223 -0
  204. package/templates/ui/components/controls/slider/index.ts +4 -0
  205. package/templates/ui/components/controls/slider/slider-control.tsx +150 -0
  206. package/templates/ui/components/controls/slider/slider-value.ts +56 -0
  207. package/templates/ui/components/controls/text-input/index.ts +4 -0
  208. package/templates/ui/components/controls/text-input/text-input-control.tsx +158 -0
  209. package/templates/ui/components/controls/use-measured-element-width.ts +42 -0
  210. package/templates/ui/components/controls/vector/index.ts +8 -0
  211. package/templates/ui/components/controls/vector/vector-control.tsx +401 -0
  212. package/templates/ui/components/panel/index.ts +19 -0
  213. package/templates/ui/components/panel/panel-actions.tsx +165 -0
  214. package/templates/ui/components/panel/panel-header.tsx +61 -0
  215. package/templates/ui/components/panel/panel-icon-button.tsx +96 -0
  216. package/templates/ui/components/panel/panel-section.tsx +168 -0
  217. package/templates/ui/components/panel/panel-surface.tsx +206 -0
  218. package/templates/ui/components/panel/panel.tsx +210 -0
  219. package/templates/ui/components/primitives/animated-loader.tsx +61 -0
  220. package/templates/ui/components/primitives/button-group.tsx +134 -0
  221. package/templates/ui/components/primitives/button.tsx +429 -0
  222. package/templates/ui/components/primitives/checkbox.tsx +62 -0
  223. package/templates/ui/components/primitives/editable-slider-value-label.tsx +337 -0
  224. package/templates/ui/components/primitives/field.tsx +225 -0
  225. package/templates/ui/components/primitives/index.ts +82 -0
  226. package/templates/ui/components/primitives/input-group.tsx +298 -0
  227. package/templates/ui/components/primitives/input.tsx +61 -0
  228. package/templates/ui/components/primitives/internal/button-loading.tsx +178 -0
  229. package/templates/ui/components/primitives/label.tsx +16 -0
  230. package/templates/ui/components/primitives/popover.tsx +126 -0
  231. package/templates/ui/components/primitives/portal-layer-context.tsx +33 -0
  232. package/templates/ui/components/primitives/primitive-arrow-icon.tsx +38 -0
  233. package/templates/ui/components/primitives/scroll-fade-logic.ts +441 -0
  234. package/templates/ui/components/primitives/scroll-fade-render.tsx +75 -0
  235. package/templates/ui/components/primitives/scroll-fade-types.ts +41 -0
  236. package/templates/ui/components/primitives/scroll-fade.tsx +72 -0
  237. package/templates/ui/components/primitives/select.tsx +408 -0
  238. package/templates/ui/components/primitives/selection-state.ts +31 -0
  239. package/templates/ui/components/primitives/separator.tsx +21 -0
  240. package/templates/ui/components/primitives/slider/index.ts +4 -0
  241. package/templates/ui/components/primitives/slider/slider-interaction.tsx +96 -0
  242. package/templates/ui/components/primitives/slider/slider-parts.tsx +303 -0
  243. package/templates/ui/components/primitives/slider/slider-reset.ts +152 -0
  244. package/templates/ui/components/primitives/slider/slider-value.ts +114 -0
  245. package/templates/ui/components/primitives/slider/slider.tsx +511 -0
  246. package/templates/ui/components/primitives/switch.tsx +35 -0
  247. package/templates/ui/components/primitives/textarea.tsx +49 -0
  248. package/templates/ui/components/primitives/toggle-group.tsx +114 -0
  249. package/templates/ui/components/primitives/toggle.tsx +46 -0
  250. package/templates/ui/components/primitives/tooltip.tsx +100 -0
  251. package/templates/ui/hooks/use-mobile.ts +21 -0
  252. package/templates/ui/index.ts +31 -0
  253. package/templates/ui/lib/control-outline.ts +3 -0
  254. package/templates/ui/lib/input-control-style.ts +131 -0
  255. package/templates/ui/lib/style-guide-color-utils.ts +111 -0
  256. package/templates/ui/lib/utils.ts +6 -0
  257. package/templates/ui/styles.css +291 -0
@@ -0,0 +1,486 @@
1
+ import * as React from "react";
2
+ import { Combobox as ComboboxPrimitive } from "@base-ui/react";
3
+ import { cva } from "class-variance-authority";
4
+ import { outlineControlSurfaceClassName } from "../../lib/control-outline";
5
+ import { cn } from "../../lib/utils";
6
+ import { Button } from "../primitives";
7
+ import { PrimitiveArrowIcon } from "../primitives";
8
+ import {
9
+ InputGroup,
10
+ InputGroupAddon,
11
+ InputGroupInput,
12
+ } from "../primitives";
13
+ import { ScrollFade } from "../primitives";
14
+ import { XIcon, CheckIcon, MagnifyingGlassIcon } from "@phosphor-icons/react";
15
+ const Combobox = ComboboxPrimitive.Root;
16
+ type ComboboxFieldSize = "sm" | "default" | "lg" | "xl";
17
+ const comboboxHoverBorderClassName =
18
+ "[&:not(:focus-within):hover]:!border-[color:color-mix(in_oklab,var(--border)_20%,transparent)]";
19
+ const comboboxButtonNoHoverBackgroundClassName =
20
+ "hover:bg-transparent active:bg-transparent data-pressed:bg-transparent";
21
+ const comboboxActiveInputBorderClassName = [
22
+ comboboxHoverBorderClassName,
23
+ "has-[[data-slot=input-group-button][aria-expanded=true]]:border-[color:color-mix(in_oklab,var(--border)_30%,transparent)]",
24
+ "has-[[data-slot=input-group-button][data-state=open]]:border-[color:color-mix(in_oklab,var(--border)_30%,transparent)]",
25
+ "has-[[data-slot=input-group-button][data-popup-open]]:border-[color:color-mix(in_oklab,var(--border)_30%,transparent)]",
26
+ "has-[[data-slot=input-group-button][data-open]]:border-[color:color-mix(in_oklab,var(--border)_30%,transparent)]",
27
+ "has-[[data-slot=combobox-trigger][aria-expanded=true]]:border-[color:color-mix(in_oklab,var(--border)_30%,transparent)]",
28
+ "has-[[data-slot=combobox-trigger][data-state=open]]:border-[color:color-mix(in_oklab,var(--border)_30%,transparent)]",
29
+ "has-[[data-slot=combobox-trigger][data-popup-open]]:border-[color:color-mix(in_oklab,var(--border)_30%,transparent)]",
30
+ "has-[[data-slot=combobox-trigger][data-open]]:border-[color:color-mix(in_oklab,var(--border)_30%,transparent)]",
31
+ ].join(" ");
32
+ const comboboxPopupSurfaceBaseClassName =
33
+ "floating-popup-surface group/combobox-content relative overflow-hidden rounded-lg border p-1 popup-text-xs-plus text-[color:var(--popover-foreground)] [&>[data-slot=combobox-search]]:-mx-1 [&>[data-slot=combobox-search]]:-mt-1 [&>[data-slot=combobox-search]]:mb-0 [&>[data-slot=combobox-search]]:border-b [&>[data-slot=combobox-search]]:border-[color:color-mix(in_oklab,var(--border)_5%,transparent)] [&>[data-slot=combobox-search]]:pr-1 [&>[data-slot=combobox-search]]:pl-0 [&>[data-slot=combobox-search]]:pt-1 [&>[data-slot=combobox-search]]:pb-1 [&>[data-slot=combobox-search]>[data-slot=input-group]]:m-0 [&>[data-slot=combobox-search]>[data-slot=input-group]]:rounded-none [&>[data-slot=combobox-search]>[data-slot=input-group]]:border-none [&>[data-slot=combobox-search]>[data-slot=input-group]]:bg-transparent [&>[data-slot=combobox-search]>[data-slot=input-group]]:shadow-none";
34
+ const comboboxPopupSurfaceClassName = cn(
35
+ comboboxPopupSurfaceBaseClassName,
36
+ "max-h-(--available-height) w-[min(var(--anchor-width),calc(var(--spacing)*64))] max-w-[min(var(--available-width),calc(var(--spacing)*64))] min-w-[min(calc(var(--anchor-width)+calc(var(--spacing)*7)),calc(var(--spacing)*64))] origin-(--transform-origin) duration-100 data-[chips=true]:min-w-[min(var(--anchor-width),calc(var(--spacing)*64))] data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
37
+ );
38
+ const ComboboxChipsSizeContext =
39
+ React.createContext<ComboboxFieldSize>("default");
40
+ const useComboboxChipsSize = (): ComboboxFieldSize =>
41
+ React.useContext(ComboboxChipsSizeContext);
42
+ const getComboboxInputButtonSize = (
43
+ size: ComboboxFieldSize,
44
+ ): "icon-xxs" | "icon-xs" =>
45
+ size === "sm" || size === "default" ? "icon-xxs" : "icon-xs";
46
+ const getComboboxPopupTypographyClassName = (
47
+ size: ComboboxFieldSize,
48
+ ): string =>
49
+ size === "default"
50
+ ? "text-[13px] leading-[1.125rem]"
51
+ : size === "lg" || size === "xl"
52
+ ? "text-sm/relaxed"
53
+ : "text-xs/relaxed";
54
+
55
+ const ComboboxValue = (props: ComboboxPrimitive.Value.Props) => (
56
+ <ComboboxPrimitive.Value data-slot="combobox-value" {...props} />
57
+ );
58
+
59
+ function ComboboxTrigger({
60
+ className,
61
+ children,
62
+ size = "default",
63
+ ...props
64
+ }: ComboboxPrimitive.Trigger.Props & {
65
+ size?: ComboboxFieldSize;
66
+ }) {
67
+ const isLargeFieldSize = size === "lg" || size === "xl";
68
+
69
+ return (
70
+ <ComboboxPrimitive.Trigger
71
+ data-slot="combobox-trigger"
72
+ className={cn(
73
+ "group/combobox-trigger cursor-pointer",
74
+ isLargeFieldSize ? "[&_svg:not([class*='size-'])]:size-4" : undefined,
75
+ className,
76
+ )}
77
+ {...props}
78
+ >
79
+ {children}
80
+ <PrimitiveArrowIcon
81
+ data-slot="combobox-trigger-caret"
82
+ openClassName="group-aria-expanded/button:rotate-180 group-data-popup-open/button:rotate-180 group-data-open/button:rotate-180 group-aria-expanded/combobox-trigger:rotate-180 group-data-popup-open/combobox-trigger:rotate-180 group-data-open/combobox-trigger:rotate-180"
83
+ />
84
+ </ComboboxPrimitive.Trigger>
85
+ );
86
+ }
87
+
88
+ function ComboboxClear({
89
+ className,
90
+ size = "default",
91
+ ...props
92
+ }: ComboboxPrimitive.Clear.Props & {
93
+ size?: ComboboxFieldSize;
94
+ }) {
95
+ const buttonSize = getComboboxInputButtonSize(size);
96
+
97
+ return (
98
+ <ComboboxPrimitive.Clear
99
+ data-slot="combobox-clear"
100
+ render={
101
+ <Button
102
+ data-slot="input-group-button"
103
+ className={cn(
104
+ "shadow-none",
105
+ comboboxButtonNoHoverBackgroundClassName,
106
+ )}
107
+ size={buttonSize}
108
+ variant="ghost-static"
109
+ />
110
+ }
111
+ className={cn(className)}
112
+ {...props}
113
+ >
114
+ <XIcon className="pointer-events-none" />
115
+ </ComboboxPrimitive.Clear>
116
+ );
117
+ }
118
+
119
+ function ComboboxInput({
120
+ className,
121
+ children,
122
+ disabled = false,
123
+ size = "default",
124
+ showTrigger = true,
125
+ showClear = false,
126
+ ...props
127
+ }: Omit<ComboboxPrimitive.Input.Props, "size"> & {
128
+ size?: ComboboxFieldSize;
129
+ showTrigger?: boolean;
130
+ showClear?: boolean;
131
+ }) {
132
+ const shouldRenderTrigger = showTrigger && !showClear;
133
+ const isPopupSearch = !showTrigger && !showClear;
134
+ const isLargeFieldSize = size === "lg" || size === "xl";
135
+ const buttonSize = getComboboxInputButtonSize(size);
136
+ const typographyClassName = getComboboxPopupTypographyClassName(size);
137
+ const inputGroup = (
138
+ <InputGroup
139
+ className={cn("w-full", comboboxActiveInputBorderClassName, className)}
140
+ focusStyle={isPopupSearch ? "none" : undefined}
141
+ size={size}
142
+ surfaceStyle={isPopupSearch ? "transparent" : undefined}
143
+ >
144
+ {isPopupSearch && (
145
+ <InputGroupAddon align="inline-start">
146
+ <MagnifyingGlassIcon
147
+ className={cn(isLargeFieldSize ? "size-4" : "size-3.5")}
148
+ />
149
+ </InputGroupAddon>
150
+ )}
151
+ <ComboboxPrimitive.Input
152
+ render={
153
+ <InputGroupInput
154
+ className={cn("leading-normal tracking-tight", typographyClassName)}
155
+ disabled={disabled}
156
+ typographyStyle={isPopupSearch ? "popup" : undefined}
157
+ />
158
+ }
159
+ {...props}
160
+ />
161
+ <InputGroupAddon align="inline-end">
162
+ {shouldRenderTrigger && (
163
+ <Button
164
+ data-slot="input-group-button"
165
+ variant="ghost-static"
166
+ render={<ComboboxTrigger size={size} />}
167
+ size={buttonSize}
168
+ className={cn(
169
+ "group-has-data-[slot=combobox-clear]/input-group:hidden",
170
+ comboboxButtonNoHoverBackgroundClassName,
171
+ )}
172
+ disabled={disabled}
173
+ />
174
+ )}
175
+ {showClear && <ComboboxClear disabled={disabled} size={size} />}
176
+ </InputGroupAddon>
177
+ {children}
178
+ </InputGroup>
179
+ );
180
+
181
+ if (isPopupSearch) {
182
+ return <div data-slot="combobox-search">{inputGroup}</div>;
183
+ }
184
+
185
+ return inputGroup;
186
+ }
187
+
188
+ function ComboboxContent({
189
+ className,
190
+ side = "bottom",
191
+ sideOffset = 6,
192
+ align = "start",
193
+ alignOffset = 0,
194
+ anchor,
195
+ ...props
196
+ }: ComboboxPrimitive.Popup.Props &
197
+ Pick<
198
+ ComboboxPrimitive.Positioner.Props,
199
+ "side" | "align" | "sideOffset" | "alignOffset" | "anchor"
200
+ >) {
201
+ return (
202
+ <ComboboxPrimitive.Portal>
203
+ <ComboboxPrimitive.Positioner
204
+ side={side}
205
+ sideOffset={sideOffset}
206
+ align={align}
207
+ alignOffset={alignOffset}
208
+ anchor={anchor}
209
+ className="isolate z-50"
210
+ >
211
+ <ComboboxPrimitive.Popup
212
+ data-slot="combobox-content"
213
+ data-chips={!!anchor}
214
+ className={cn(comboboxPopupSurfaceClassName, className)}
215
+ {...props}
216
+ />
217
+ </ComboboxPrimitive.Positioner>
218
+ </ComboboxPrimitive.Portal>
219
+ );
220
+ }
221
+
222
+ function ComboboxList({ className, ...props }: ComboboxPrimitive.List.Props) {
223
+ return (
224
+ <ComboboxPrimitive.List
225
+ data-slot="combobox-list"
226
+ render={(listProps) => {
227
+ const {
228
+ children,
229
+ className: renderedClassName,
230
+ ...renderedListProps
231
+ } = listProps as React.ComponentProps<"div">;
232
+
233
+ return (
234
+ <div {...renderedListProps} className="min-h-0 w-full">
235
+ <ScrollFade
236
+ className={cn(
237
+ "no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] w-full scroll-py-1 overscroll-contain",
238
+ renderedClassName,
239
+ className,
240
+ )}
241
+ containerClassName="min-h-0 w-full"
242
+ preset="compact"
243
+ side="bottom"
244
+ >
245
+ {children}
246
+ </ScrollFade>
247
+ </div>
248
+ );
249
+ }}
250
+ {...props}
251
+ />
252
+ );
253
+ }
254
+
255
+ function ComboboxItem({
256
+ className,
257
+ children,
258
+ ...props
259
+ }: ComboboxPrimitive.Item.Props) {
260
+ const itemContent =
261
+ typeof children === "string" || typeof children === "number" ? (
262
+ <ScrollFade
263
+ className="no-scrollbar min-w-0"
264
+ containerClassName="min-w-0 flex-1"
265
+ preset="compact"
266
+ side="right"
267
+ watch={[children]}
268
+ >
269
+ <span className="inline-block whitespace-nowrap pr-2">{children}</span>
270
+ </ScrollFade>
271
+ ) : (
272
+ children
273
+ );
274
+
275
+ return (
276
+ <ComboboxPrimitive.Item
277
+ data-slot="combobox-item"
278
+ className={cn(
279
+ "relative flex min-h-7 w-full min-w-0 cursor-pointer items-center gap-2 rounded-md py-1.5 pr-8 pl-2 popup-text-xs-plus leading-normal tracking-tight font-medium outline-hidden select-none data-highlighted:bg-[color:color-mix(in_oklab,var(--foreground)_5%,transparent)] data-highlighted:text-[color:var(--accent-foreground)] not-data-[variant=destructive]:data-highlighted:**:text-[color:var(--accent-foreground)] data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",
280
+ className,
281
+ )}
282
+ {...props}
283
+ >
284
+ {itemContent}
285
+ <ComboboxPrimitive.ItemIndicator
286
+ render={
287
+ <span className="pointer-events-none absolute right-2 flex items-center justify-center" />
288
+ }
289
+ >
290
+ <CheckIcon className="pointer-events-none" />
291
+ </ComboboxPrimitive.ItemIndicator>
292
+ </ComboboxPrimitive.Item>
293
+ );
294
+ }
295
+
296
+ const ComboboxGroup = ({
297
+ className,
298
+ ...props
299
+ }: ComboboxPrimitive.Group.Props) => (
300
+ <ComboboxPrimitive.Group
301
+ data-slot="combobox-group"
302
+ className={cn(className)}
303
+ {...props}
304
+ />
305
+ );
306
+
307
+ function ComboboxLabel({
308
+ className,
309
+ ...props
310
+ }: ComboboxPrimitive.GroupLabel.Props) {
311
+ return (
312
+ <ComboboxPrimitive.GroupLabel
313
+ data-slot="combobox-label"
314
+ className={cn(
315
+ "px-2 py-1.5 popup-text-xs-plus text-[color:color-mix(in_oklab,var(--foreground)_60%,transparent)]",
316
+ className,
317
+ )}
318
+ {...props}
319
+ />
320
+ );
321
+ }
322
+
323
+ const ComboboxCollection = (props: ComboboxPrimitive.Collection.Props) => (
324
+ <ComboboxPrimitive.Collection data-slot="combobox-collection" {...props} />
325
+ );
326
+
327
+ function ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props) {
328
+ return (
329
+ <ComboboxPrimitive.Empty
330
+ data-slot="combobox-empty"
331
+ className={cn(
332
+ "hidden w-full justify-center py-2 text-center popup-text-xs-plus leading-normal tracking-tight text-[color:color-mix(in_oklab,var(--foreground)_60%,transparent)] group-data-empty/combobox-content:flex",
333
+ className,
334
+ )}
335
+ {...props}
336
+ />
337
+ );
338
+ }
339
+
340
+ function ComboboxSeparator({
341
+ className,
342
+ ...props
343
+ }: ComboboxPrimitive.Separator.Props) {
344
+ return (
345
+ <ComboboxPrimitive.Separator
346
+ data-slot="combobox-separator"
347
+ className={cn("floating-popup-separator -mx-1 my-1 h-px", className)}
348
+ {...props}
349
+ />
350
+ );
351
+ }
352
+
353
+ function ComboboxChips({
354
+ className,
355
+ size = "default",
356
+ ...props
357
+ }: Omit<React.ComponentPropsWithRef<typeof ComboboxPrimitive.Chips>, "size"> & {
358
+ size?: ComboboxFieldSize;
359
+ }) {
360
+ return (
361
+ <ComboboxChipsSizeContext.Provider value={size}>
362
+ <ComboboxPrimitive.Chips
363
+ data-size={size}
364
+ data-slot="combobox-chips"
365
+ className={cn(comboboxChipsVariants({ size }), className)}
366
+ {...props}
367
+ />
368
+ </ComboboxChipsSizeContext.Provider>
369
+ );
370
+ }
371
+
372
+ const comboboxChipsVariants = cva(
373
+ cn(
374
+ "flex flex-wrap items-center gap-1 rounded-md border border-[color:color-mix(in_oklab,var(--border)_12%,transparent)] transition-colors focus-within:border-[color:color-mix(in_oklab,var(--border)_30%,transparent)] has-aria-invalid:border-[color:var(--destructive)] dark:has-aria-invalid:border-[color:color-mix(in_oklab,var(--destructive)_50%,transparent)]",
375
+ comboboxHoverBorderClassName,
376
+ outlineControlSurfaceClassName,
377
+ ),
378
+ {
379
+ variants: {
380
+ size: {
381
+ sm: "min-h-6 pl-2 pr-0 text-xs/relaxed has-data-[slot=combobox-chip]:px-1",
382
+ default:
383
+ "min-h-7 py-0.5 pl-2 pr-0 text-[13px] leading-[1.125rem] has-data-[slot=combobox-chip]:px-1",
384
+ lg: "min-h-8 gap-1.5 py-1 pl-2.5 pr-0 text-sm/relaxed has-data-[slot=combobox-chip]:px-1",
385
+ xl: "min-h-10 gap-2 py-1 pl-1 pr-0 text-sm/relaxed",
386
+ },
387
+ },
388
+ defaultVariants: {
389
+ size: "default",
390
+ },
391
+ },
392
+ );
393
+
394
+ function ComboboxChip({
395
+ className,
396
+ children,
397
+ showRemove = true,
398
+ ...props
399
+ }: ComboboxPrimitive.Chip.Props & {
400
+ showRemove?: boolean;
401
+ }) {
402
+ const size = useComboboxChipsSize();
403
+ const removeButtonSize =
404
+ size === "xl"
405
+ ? "icon-lg"
406
+ : size === "lg"
407
+ ? "icon-sm"
408
+ : size === "sm"
409
+ ? "icon-xxs"
410
+ : "icon-xs";
411
+
412
+ return (
413
+ <ComboboxPrimitive.Chip
414
+ data-slot="combobox-chip"
415
+ className={cn(comboboxChipVariants({ size }), className)}
416
+ {...props}
417
+ >
418
+ {children}
419
+ {showRemove && (
420
+ <ComboboxPrimitive.ChipRemove
421
+ render={
422
+ <Button
423
+ className={comboboxButtonNoHoverBackgroundClassName}
424
+ size={removeButtonSize}
425
+ variant="ghost-static"
426
+ />
427
+ }
428
+ className="-ml-1 opacity-50 hover:opacity-100"
429
+ data-slot="combobox-chip-remove"
430
+ >
431
+ <XIcon className="pointer-events-none" />
432
+ </ComboboxPrimitive.ChipRemove>
433
+ )}
434
+ </ComboboxPrimitive.Chip>
435
+ );
436
+ }
437
+
438
+ const comboboxChipVariants = cva(
439
+ "flex w-fit items-center justify-center gap-1 rounded-[calc(var(--radius-md)-2px)] bg-[color:color-mix(in_oklab,var(--muted-foreground)_10%,transparent)] font-medium whitespace-nowrap text-[color:var(--foreground)] has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0",
440
+ {
441
+ variants: {
442
+ size: {
443
+ sm: "-ml-px h-4 px-1.5 text-xs/relaxed",
444
+ default: "h-5 px-1.5 text-[13px] leading-[1.125rem]",
445
+ lg: "h-6 px-2 text-sm/relaxed",
446
+ xl: "h-8 px-2.5 text-sm/relaxed",
447
+ },
448
+ },
449
+ defaultVariants: {
450
+ size: "default",
451
+ },
452
+ },
453
+ );
454
+
455
+ const ComboboxChipsInput = ({
456
+ className,
457
+ ...props
458
+ }: ComboboxPrimitive.Input.Props) => (
459
+ <ComboboxPrimitive.Input
460
+ data-slot="combobox-chip-input"
461
+ className={cn("min-w-16 flex-1 outline-none", className)}
462
+ {...props}
463
+ />
464
+ );
465
+
466
+ const useComboboxAnchor = () => React.useRef<HTMLDivElement | null>(null);
467
+
468
+ export {
469
+ Combobox,
470
+ ComboboxInput,
471
+ ComboboxContent,
472
+ ComboboxList,
473
+ ComboboxItem,
474
+ ComboboxGroup,
475
+ ComboboxLabel,
476
+ ComboboxCollection,
477
+ ComboboxEmpty,
478
+ ComboboxSeparator,
479
+ ComboboxChips,
480
+ ComboboxChip,
481
+ ComboboxChipsInput,
482
+ ComboboxTrigger,
483
+ ComboboxValue,
484
+ comboboxPopupSurfaceClassName,
485
+ useComboboxAnchor,
486
+ };