svelte-ag 0.0.2-dev.72

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 (313) hide show
  1. package/README.md +6 -0
  2. package/dist/app.css +209 -0
  3. package/dist/app.d.ts +13 -0
  4. package/dist/app.html +12 -0
  5. package/dist/icons.css +6 -0
  6. package/dist/lib/bits/internal/arrays.d.ts +95 -0
  7. package/dist/lib/bits/internal/arrays.js +250 -0
  8. package/dist/lib/bits/internal/arrays.test.d.ts +1 -0
  9. package/dist/lib/bits/internal/arrays.test.js +366 -0
  10. package/dist/lib/bits/internal/attrs.d.ts +22 -0
  11. package/dist/lib/bits/internal/attrs.js +69 -0
  12. package/dist/lib/bits/internal/box-auto-reset.svelte.d.ts +8 -0
  13. package/dist/lib/bits/internal/box-auto-reset.svelte.js +31 -0
  14. package/dist/lib/bits/internal/box.svelte.d.ts +21 -0
  15. package/dist/lib/bits/internal/box.svelte.js +26 -0
  16. package/dist/lib/bits/internal/clamp.d.ts +4 -0
  17. package/dist/lib/bits/internal/clamp.js +6 -0
  18. package/dist/lib/bits/internal/clamp.test.d.ts +1 -0
  19. package/dist/lib/bits/internal/clamp.test.js +31 -0
  20. package/dist/lib/bits/internal/create-event-hook.svelte.d.ts +18 -0
  21. package/dist/lib/bits/internal/create-event-hook.svelte.js +29 -0
  22. package/dist/lib/bits/internal/create-shared-hook.svelte.d.ts +2 -0
  23. package/dist/lib/bits/internal/create-shared-hook.svelte.js +27 -0
  24. package/dist/lib/bits/internal/date-time/announcer.d.ts +7 -0
  25. package/dist/lib/bits/internal/date-time/announcer.js +82 -0
  26. package/dist/lib/bits/internal/date-time/calendar-helpers.svelte.d.ts +201 -0
  27. package/dist/lib/bits/internal/date-time/calendar-helpers.svelte.js +510 -0
  28. package/dist/lib/bits/internal/date-time/field/helpers.d.ts +76 -0
  29. package/dist/lib/bits/internal/date-time/field/helpers.js +378 -0
  30. package/dist/lib/bits/internal/date-time/field/parts.d.ts +6 -0
  31. package/dist/lib/bits/internal/date-time/field/parts.js +9 -0
  32. package/dist/lib/bits/internal/date-time/field/segments.d.ts +51 -0
  33. package/dist/lib/bits/internal/date-time/field/segments.js +128 -0
  34. package/dist/lib/bits/internal/date-time/field/types.d.ts +25 -0
  35. package/dist/lib/bits/internal/date-time/field/types.js +1 -0
  36. package/dist/lib/bits/internal/date-time/formatter.d.ts +24 -0
  37. package/dist/lib/bits/internal/date-time/formatter.js +97 -0
  38. package/dist/lib/bits/internal/date-time/placeholders.d.ts +8 -0
  39. package/dist/lib/bits/internal/date-time/placeholders.js +129 -0
  40. package/dist/lib/bits/internal/date-time/utils.d.ts +69 -0
  41. package/dist/lib/bits/internal/date-time/utils.js +212 -0
  42. package/dist/lib/bits/internal/debounce.d.ts +4 -0
  43. package/dist/lib/bits/internal/debounce.js +19 -0
  44. package/dist/lib/bits/internal/debounce.test.d.ts +1 -0
  45. package/dist/lib/bits/internal/debounce.test.js +50 -0
  46. package/dist/lib/bits/internal/dom.d.ts +10 -0
  47. package/dist/lib/bits/internal/dom.js +38 -0
  48. package/dist/lib/bits/internal/elements.d.ts +2 -0
  49. package/dist/lib/bits/internal/elements.js +6 -0
  50. package/dist/lib/bits/internal/events.d.ts +21 -0
  51. package/dist/lib/bits/internal/events.js +49 -0
  52. package/dist/lib/bits/internal/floating-svelte/floating-utils.svelte.d.ts +7 -0
  53. package/dist/lib/bits/internal/floating-svelte/floating-utils.svelte.js +24 -0
  54. package/dist/lib/bits/internal/floating-svelte/types.d.ts +85 -0
  55. package/dist/lib/bits/internal/floating-svelte/types.js +1 -0
  56. package/dist/lib/bits/internal/floating-svelte/use-floating.svelte.d.ts +2 -0
  57. package/dist/lib/bits/internal/floating-svelte/use-floating.svelte.js +112 -0
  58. package/dist/lib/bits/internal/focus.d.ts +46 -0
  59. package/dist/lib/bits/internal/focus.js +109 -0
  60. package/dist/lib/bits/internal/get-directional-keys.d.ts +21 -0
  61. package/dist/lib/bits/internal/get-directional-keys.js +37 -0
  62. package/dist/lib/bits/internal/get-directional-keys.test.d.ts +1 -0
  63. package/dist/lib/bits/internal/get-directional-keys.test.js +46 -0
  64. package/dist/lib/bits/internal/is.d.ts +25 -0
  65. package/dist/lib/bits/internal/is.js +62 -0
  66. package/dist/lib/bits/internal/is.test.d.ts +1 -0
  67. package/dist/lib/bits/internal/is.test.js +34 -0
  68. package/dist/lib/bits/internal/kbd-constants.d.ts +40 -0
  69. package/dist/lib/bits/internal/kbd-constants.js +40 -0
  70. package/dist/lib/bits/internal/kbd.d.ts +1 -0
  71. package/dist/lib/bits/internal/kbd.js +1 -0
  72. package/dist/lib/bits/internal/locale.d.ts +6 -0
  73. package/dist/lib/bits/internal/locale.js +9 -0
  74. package/dist/lib/bits/internal/math.d.ts +5 -0
  75. package/dist/lib/bits/internal/math.js +43 -0
  76. package/dist/lib/bits/internal/math.test.d.ts +1 -0
  77. package/dist/lib/bits/internal/math.test.js +71 -0
  78. package/dist/lib/bits/internal/noop.d.ts +4 -0
  79. package/dist/lib/bits/internal/noop.js +4 -0
  80. package/dist/lib/bits/internal/should-trap-focus.d.ts +6 -0
  81. package/dist/lib/bits/internal/should-trap-focus.js +6 -0
  82. package/dist/lib/bits/internal/sleep.d.ts +1 -0
  83. package/dist/lib/bits/internal/sleep.js +3 -0
  84. package/dist/lib/bits/internal/tabbable.d.ts +10 -0
  85. package/dist/lib/bits/internal/tabbable.js +66 -0
  86. package/dist/lib/bits/internal/types.d.ts +92 -0
  87. package/dist/lib/bits/internal/types.js +1 -0
  88. package/dist/lib/bits/internal/use-after-animations.svelte.d.ts +5 -0
  89. package/dist/lib/bits/internal/use-after-animations.svelte.js +27 -0
  90. package/dist/lib/bits/internal/use-arrow-navigation.d.ts +62 -0
  91. package/dist/lib/bits/internal/use-arrow-navigation.js +76 -0
  92. package/dist/lib/bits/internal/use-body-scroll-lock.svelte.d.ts +6 -0
  93. package/dist/lib/bits/internal/use-body-scroll-lock.svelte.js +106 -0
  94. package/dist/lib/bits/internal/use-data-typeahead.svelte.d.ts +14 -0
  95. package/dist/lib/bits/internal/use-data-typeahead.svelte.js +31 -0
  96. package/dist/lib/bits/internal/use-dom-typeahead.svelte.d.ts +11 -0
  97. package/dist/lib/bits/internal/use-dom-typeahead.svelte.js +30 -0
  98. package/dist/lib/bits/internal/use-form-control.svelte.d.ts +4 -0
  99. package/dist/lib/bits/internal/use-form-control.svelte.js +16 -0
  100. package/dist/lib/bits/internal/use-grace-area.svelte.d.ts +12 -0
  101. package/dist/lib/bits/internal/use-grace-area.svelte.js +197 -0
  102. package/dist/lib/bits/internal/use-id.d.ts +4 -0
  103. package/dist/lib/bits/internal/use-id.js +8 -0
  104. package/dist/lib/bits/internal/use-resize-observer.svelte.d.ts +2 -0
  105. package/dist/lib/bits/internal/use-resize-observer.svelte.js +17 -0
  106. package/dist/lib/bits/internal/use-roving-focus.svelte.d.ts +38 -0
  107. package/dist/lib/bits/internal/use-roving-focus.svelte.js +91 -0
  108. package/dist/lib/bits/internal/use-size.svelte.d.ts +7 -0
  109. package/dist/lib/bits/internal/use-size.svelte.js +54 -0
  110. package/dist/lib/bits/internal/use-state-machine.svelte.d.ts +24 -0
  111. package/dist/lib/bits/internal/use-state-machine.svelte.js +28 -0
  112. package/dist/lib/bits/internal/use-timeout-fn.svelte.d.ts +25 -0
  113. package/dist/lib/bits/internal/use-timeout-fn.svelte.js +39 -0
  114. package/dist/lib/components/Typeahead.svelte.d.ts +47 -0
  115. package/dist/lib/components/Typeahead.svelte.js +150 -0
  116. package/dist/lib/components/animated/animated.svelte +244 -0
  117. package/dist/lib/components/animated/animated.svelte.d.ts +61 -0
  118. package/dist/lib/components/animated/index.d.ts +2 -0
  119. package/dist/lib/components/animated/index.js +2 -0
  120. package/dist/lib/components/combo/combo.svelte +186 -0
  121. package/dist/lib/components/combo/combo.svelte.d.ts +21 -0
  122. package/dist/lib/components/combo/index.d.ts +2 -0
  123. package/dist/lib/components/combo/index.js +2 -0
  124. package/dist/lib/components/dnd/Droppable.svelte +25 -0
  125. package/dist/lib/components/dnd/Droppable.svelte.d.ts +10 -0
  126. package/dist/lib/components/dnd/context.svelte.d.ts +22 -0
  127. package/dist/lib/components/dnd/context.svelte.js +25 -0
  128. package/dist/lib/components/dnd/dnd-context.svelte +45 -0
  129. package/dist/lib/components/dnd/dnd-context.svelte.d.ts +30 -0
  130. package/dist/lib/components/dnd/dnd-drag-overlay.svelte +44 -0
  131. package/dist/lib/components/dnd/dnd-drag-overlay.svelte.d.ts +27 -0
  132. package/dist/lib/components/dnd/dnd-drag-placeholder.svelte +24 -0
  133. package/dist/lib/components/dnd/dnd-drag-placeholder.svelte.d.ts +9 -0
  134. package/dist/lib/components/dnd/dnd-draghandle.svelte +30 -0
  135. package/dist/lib/components/dnd/dnd-draghandle.svelte.d.ts +6 -0
  136. package/dist/lib/components/dnd/dnd-overlay.svelte +0 -0
  137. package/dist/lib/components/dnd/dnd-overlay.svelte.d.ts +26 -0
  138. package/dist/lib/components/dnd/dnd-sortable-context.svelte +18 -0
  139. package/dist/lib/components/dnd/dnd-sortable-context.svelte.d.ts +8 -0
  140. package/dist/lib/components/dnd/dnd-sortable-item.svelte +68 -0
  141. package/dist/lib/components/dnd/dnd-sortable-item.svelte.d.ts +23 -0
  142. package/dist/lib/components/dnd/example.svelte +109 -0
  143. package/dist/lib/components/dnd/example.svelte.d.ts +3 -0
  144. package/dist/lib/components/dnd/exports.d.ts +9 -0
  145. package/dist/lib/components/dnd/exports.js +9 -0
  146. package/dist/lib/components/dnd/index.d.ts +1 -0
  147. package/dist/lib/components/dnd/index.js +1 -0
  148. package/dist/lib/components/dnd/sortable.svelte.d.ts +13 -0
  149. package/dist/lib/components/dnd/sortable.svelte.js +70 -0
  150. package/dist/lib/components/dnd/utils.svelte.d.ts +20 -0
  151. package/dist/lib/components/dnd/utils.svelte.js +20 -0
  152. package/dist/lib/components/search/combinations/searchPopover.svelte +68 -0
  153. package/dist/lib/components/search/combinations/searchPopover.svelte.d.ts +22 -0
  154. package/dist/lib/components/search/components/search-empty.svelte +28 -0
  155. package/dist/lib/components/search/components/search-empty.svelte.d.ts +4 -0
  156. package/dist/lib/components/search/components/search-input.svelte +53 -0
  157. package/dist/lib/components/search/components/search-input.svelte.d.ts +4 -0
  158. package/dist/lib/components/search/components/search-list.svelte +46 -0
  159. package/dist/lib/components/search/components/search-list.svelte.d.ts +4 -0
  160. package/dist/lib/components/search/components/search-pagnation.svelte +68 -0
  161. package/dist/lib/components/search/components/search-pagnation.svelte.d.ts +8 -0
  162. package/dist/lib/components/search/components/search.svelte +47 -0
  163. package/dist/lib/components/search/components/search.svelte.d.ts +4 -0
  164. package/dist/lib/components/search/exports.d.ts +6 -0
  165. package/dist/lib/components/search/exports.js +5 -0
  166. package/dist/lib/components/search/index.d.ts +2 -0
  167. package/dist/lib/components/search/index.js +2 -0
  168. package/dist/lib/components/search/search.svelte.d.ts +102 -0
  169. package/dist/lib/components/search/search.svelte.js +202 -0
  170. package/dist/lib/components/search/types.d.ts +28 -0
  171. package/dist/lib/components/search/types.js +1 -0
  172. package/dist/lib/components/utilities/arrow/arrow.svelte +23 -0
  173. package/dist/lib/components/utilities/arrow/arrow.svelte.d.ts +3 -0
  174. package/dist/lib/components/utilities/arrow/index.d.ts +2 -0
  175. package/dist/lib/components/utilities/arrow/index.js +1 -0
  176. package/dist/lib/components/utilities/arrow/types.d.ts +17 -0
  177. package/dist/lib/components/utilities/arrow/types.js +1 -0
  178. package/dist/lib/components/utilities/floating-layer/components/floating-layer-anchor.svelte +15 -0
  179. package/dist/lib/components/utilities/floating-layer/components/floating-layer-anchor.svelte.d.ts +4 -0
  180. package/dist/lib/components/utilities/floating-layer/components/floating-layer-arrow.svelte +20 -0
  181. package/dist/lib/components/utilities/floating-layer/components/floating-layer-arrow.svelte.d.ts +3 -0
  182. package/dist/lib/components/utilities/floating-layer/components/floating-layer-content-static.svelte +19 -0
  183. package/dist/lib/components/utilities/floating-layer/components/floating-layer-content-static.svelte.d.ts +13 -0
  184. package/dist/lib/components/utilities/floating-layer/components/floating-layer-content.svelte +61 -0
  185. package/dist/lib/components/utilities/floating-layer/components/floating-layer-content.svelte.d.ts +4 -0
  186. package/dist/lib/components/utilities/floating-layer/components/floating-layer.svelte +10 -0
  187. package/dist/lib/components/utilities/floating-layer/components/floating-layer.svelte.d.ts +7 -0
  188. package/dist/lib/components/utilities/floating-layer/components/index.d.ts +6 -0
  189. package/dist/lib/components/utilities/floating-layer/components/index.js +5 -0
  190. package/dist/lib/components/utilities/floating-layer/index.d.ts +1 -0
  191. package/dist/lib/components/utilities/floating-layer/index.js +1 -0
  192. package/dist/lib/components/utilities/floating-layer/types.d.ts +115 -0
  193. package/dist/lib/components/utilities/floating-layer/types.js +1 -0
  194. package/dist/lib/components/utilities/floating-layer/use-floating-layer.svelte.d.ts +118 -0
  195. package/dist/lib/components/utilities/floating-layer/use-floating-layer.svelte.js +311 -0
  196. package/dist/lib/index.d.ts +1 -0
  197. package/dist/lib/index.js +1 -0
  198. package/dist/lib/utils/asyncDerived.svelte.d.ts +12 -0
  199. package/dist/lib/utils/asyncDerived.svelte.js +26 -0
  200. package/dist/lib/utils/bits.d.ts +39 -0
  201. package/dist/lib/utils/bits.js +69 -0
  202. package/dist/lib/utils/index.d.ts +3 -0
  203. package/dist/lib/utils/index.js +3 -0
  204. package/dist/lib/utils/utils.d.ts +21 -0
  205. package/dist/lib/utils/utils.js +72 -0
  206. package/dist/routes/+layout.svelte +0 -0
  207. package/dist/routes/+layout.svelte.d.ts +26 -0
  208. package/package.json +79 -0
  209. package/src/app.css +209 -0
  210. package/src/app.d.ts +13 -0
  211. package/src/app.html +12 -0
  212. package/src/icons.css +6 -0
  213. package/src/lib/bits/internal/arrays.test.ts +460 -0
  214. package/src/lib/bits/internal/arrays.ts +301 -0
  215. package/src/lib/bits/internal/attrs.ts +97 -0
  216. package/src/lib/bits/internal/box-auto-reset.svelte.ts +40 -0
  217. package/src/lib/bits/internal/box.svelte.ts +60 -0
  218. package/src/lib/bits/internal/clamp.test.ts +37 -0
  219. package/src/lib/bits/internal/clamp.ts +6 -0
  220. package/src/lib/bits/internal/create-event-hook.svelte.ts +64 -0
  221. package/src/lib/bits/internal/create-shared-hook.svelte.ts +33 -0
  222. package/src/lib/bits/internal/date-time/announcer.ts +88 -0
  223. package/src/lib/bits/internal/date-time/calendar-helpers.svelte.ts +815 -0
  224. package/src/lib/bits/internal/date-time/field/helpers.ts +441 -0
  225. package/src/lib/bits/internal/date-time/field/parts.ts +9 -0
  226. package/src/lib/bits/internal/date-time/field/segments.ts +126 -0
  227. package/src/lib/bits/internal/date-time/field/types.ts +35 -0
  228. package/src/lib/bits/internal/date-time/formatter.ts +116 -0
  229. package/src/lib/bits/internal/date-time/placeholders.ts +143 -0
  230. package/src/lib/bits/internal/date-time/utils.ts +261 -0
  231. package/src/lib/bits/internal/debounce.test.ts +67 -0
  232. package/src/lib/bits/internal/debounce.ts +22 -0
  233. package/src/lib/bits/internal/dom.ts +47 -0
  234. package/src/lib/bits/internal/elements.ts +7 -0
  235. package/src/lib/bits/internal/events.ts +89 -0
  236. package/src/lib/bits/internal/floating-svelte/floating-utils.svelte.ts +28 -0
  237. package/src/lib/bits/internal/floating-svelte/types.ts +108 -0
  238. package/src/lib/bits/internal/floating-svelte/use-floating.svelte.ts +133 -0
  239. package/src/lib/bits/internal/focus.ts +111 -0
  240. package/src/lib/bits/internal/get-directional-keys.test.ts +51 -0
  241. package/src/lib/bits/internal/get-directional-keys.ts +43 -0
  242. package/src/lib/bits/internal/is.test.ts +40 -0
  243. package/src/lib/bits/internal/is.ts +78 -0
  244. package/src/lib/bits/internal/kbd-constants.ts +40 -0
  245. package/src/lib/bits/internal/kbd.ts +1 -0
  246. package/src/lib/bits/internal/locale.ts +13 -0
  247. package/src/lib/bits/internal/math.test.ts +88 -0
  248. package/src/lib/bits/internal/math.ts +50 -0
  249. package/src/lib/bits/internal/noop.ts +4 -0
  250. package/src/lib/bits/internal/should-trap-focus.ts +16 -0
  251. package/src/lib/bits/internal/sleep.ts +3 -0
  252. package/src/lib/bits/internal/tabbable.ts +76 -0
  253. package/src/lib/bits/internal/types.ts +91 -0
  254. package/src/lib/bits/internal/use-after-animations.svelte.ts +30 -0
  255. package/src/lib/bits/internal/use-arrow-navigation.ts +168 -0
  256. package/src/lib/bits/internal/use-body-scroll-lock.svelte.ts +138 -0
  257. package/src/lib/bits/internal/use-data-typeahead.svelte.ts +44 -0
  258. package/src/lib/bits/internal/use-dom-typeahead.svelte.ts +44 -0
  259. package/src/lib/bits/internal/use-form-control.svelte.ts +17 -0
  260. package/src/lib/bits/internal/use-grace-area.svelte.ts +229 -0
  261. package/src/lib/bits/internal/use-id.ts +9 -0
  262. package/src/lib/bits/internal/use-resize-observer.svelte.ts +19 -0
  263. package/src/lib/bits/internal/use-roving-focus.svelte.ts +141 -0
  264. package/src/lib/bits/internal/use-size.svelte.ts +60 -0
  265. package/src/lib/bits/internal/use-state-machine.svelte.ts +46 -0
  266. package/src/lib/bits/internal/use-timeout-fn.svelte.ts +80 -0
  267. package/src/lib/components/Typeahead.svelte.ts +200 -0
  268. package/src/lib/components/animated/animated.svelte +244 -0
  269. package/src/lib/components/animated/index.ts +3 -0
  270. package/src/lib/components/combo/combo.svelte +186 -0
  271. package/src/lib/components/combo/index.ts +3 -0
  272. package/src/lib/components/dnd/Droppable.svelte +25 -0
  273. package/src/lib/components/dnd/context.svelte.ts +30 -0
  274. package/src/lib/components/dnd/dnd-context.svelte +45 -0
  275. package/src/lib/components/dnd/dnd-drag-overlay.svelte +44 -0
  276. package/src/lib/components/dnd/dnd-drag-placeholder.svelte +24 -0
  277. package/src/lib/components/dnd/dnd-draghandle.svelte +30 -0
  278. package/src/lib/components/dnd/dnd-overlay.svelte +0 -0
  279. package/src/lib/components/dnd/dnd-sortable-context.svelte +18 -0
  280. package/src/lib/components/dnd/dnd-sortable-item.svelte +68 -0
  281. package/src/lib/components/dnd/example.svelte +109 -0
  282. package/src/lib/components/dnd/exports.ts +12 -0
  283. package/src/lib/components/dnd/index.ts +1 -0
  284. package/src/lib/components/dnd/sortable.svelte.ts +82 -0
  285. package/src/lib/components/dnd/utils.svelte.ts +29 -0
  286. package/src/lib/components/search/combinations/searchPopover.svelte +68 -0
  287. package/src/lib/components/search/components/search-empty.svelte +28 -0
  288. package/src/lib/components/search/components/search-input.svelte +53 -0
  289. package/src/lib/components/search/components/search-list.svelte +46 -0
  290. package/src/lib/components/search/components/search-pagnation.svelte +68 -0
  291. package/src/lib/components/search/components/search.svelte +47 -0
  292. package/src/lib/components/search/exports.ts +13 -0
  293. package/src/lib/components/search/index.ts +2 -0
  294. package/src/lib/components/search/search.svelte.ts +286 -0
  295. package/src/lib/components/search/types.ts +48 -0
  296. package/src/lib/components/utilities/arrow/arrow.svelte +23 -0
  297. package/src/lib/components/utilities/arrow/index.ts +2 -0
  298. package/src/lib/components/utilities/arrow/types.ts +20 -0
  299. package/src/lib/components/utilities/floating-layer/components/floating-layer-anchor.svelte +15 -0
  300. package/src/lib/components/utilities/floating-layer/components/floating-layer-arrow.svelte +20 -0
  301. package/src/lib/components/utilities/floating-layer/components/floating-layer-content-static.svelte +19 -0
  302. package/src/lib/components/utilities/floating-layer/components/floating-layer-content.svelte +61 -0
  303. package/src/lib/components/utilities/floating-layer/components/floating-layer.svelte +10 -0
  304. package/src/lib/components/utilities/floating-layer/components/index.ts +11 -0
  305. package/src/lib/components/utilities/floating-layer/index.ts +1 -0
  306. package/src/lib/components/utilities/floating-layer/types.ts +133 -0
  307. package/src/lib/components/utilities/floating-layer/use-floating-layer.svelte.ts +406 -0
  308. package/src/lib/index.ts +1 -0
  309. package/src/lib/utils/asyncDerived.svelte.ts +38 -0
  310. package/src/lib/utils/bits.ts +93 -0
  311. package/src/lib/utils/index.ts +3 -0
  312. package/src/lib/utils/utils.ts +97 -0
  313. package/src/routes/+layout.svelte +0 -0
@@ -0,0 +1,286 @@
1
+ import { useRefById, type ReadableBoxedValues, type WithRefProps, type WritableBoxedValues } from 'svelte-toolbelt';
2
+ import { Context, watch } from 'runed';
3
+ import { computeCommandScore } from 'bits-ui';
4
+ import type { Item } from './types';
5
+ import { dequal } from 'dequal';
6
+
7
+ const SEARCH_ROOT_ATTR = 'data-search-root';
8
+ const SEARCH_INPUT_ATTR = 'data-search-input';
9
+ const SEARCH_LIST_ATTR = 'data-search-list';
10
+ const SEARCH_ITEM_ATTR = 'data-search-item';
11
+ const SEARCH_EMPTY_ATTR = 'data-search-empty';
12
+
13
+ // -------------------- Search Root --------------------
14
+ export type SearchRootStateProps = WithRefProps<
15
+ ReadableBoxedValues<{
16
+ items: Item[];
17
+ searchWith?: string;
18
+ search?: (term: string) => Promise<Item[]>;
19
+ }> &
20
+ WritableBoxedValues<{
21
+ value: Item;
22
+ }>
23
+ >;
24
+
25
+ export class SearchRootState {
26
+ // State
27
+ searchState = $state({
28
+ value: '',
29
+ sortedList: [] as (Item & { score?: number })[],
30
+ showSuggestions: false
31
+ });
32
+ numPerPage = $state(0);
33
+ start = $state(0);
34
+ end = $state(0);
35
+
36
+ loading = $state(false);
37
+ inputRef = $state<HTMLInputElement | null>(null);
38
+ debounceTimer: number | null = $state(null);
39
+
40
+ constructor(readonly opts: SearchRootStateProps) {
41
+ useRefById(opts);
42
+
43
+ if (opts.items !== null) {
44
+ // Watch for changes in items and update the sorted list
45
+ watch(
46
+ () => this.opts.items.current,
47
+ (newItems, oldItems) => {
48
+ if (dequal(newItems, oldItems)) return;
49
+ this.search();
50
+ }
51
+ );
52
+ }
53
+
54
+ watch(
55
+ () => this.searchState.sortedList,
56
+ () => {
57
+ this.start = 0;
58
+ }
59
+ );
60
+
61
+ watch([() => this.searchState.sortedList, () => this.numPerPage, () => this.start], () => {
62
+ const filteredList = this.getFilteredList();
63
+ this.end = this.numPerPage === 0 ? 0 : Math.min(filteredList.length, this.start + this.numPerPage);
64
+ });
65
+
66
+ this.search();
67
+ this.searchState.value = this.opts.value.current.value;
68
+ }
69
+
70
+ /**
71
+ * This function needs to update the sorted list of items based on the search term.
72
+ */
73
+ async search() {
74
+ if (this.opts.search !== undefined) {
75
+ const func = this.opts.search.current;
76
+ if (func) {
77
+ this.searchState.sortedList = await func(this.searchState.value);
78
+ return;
79
+ }
80
+ }
81
+
82
+ const searchTerm = this.opts.searchWith?.current ?? this.searchState.value;
83
+ const scoredItems = this.opts.items.current.map((item) => ({
84
+ ...item,
85
+ score: searchTerm ? computeCommandScore(item.label, searchTerm, []) : 1
86
+ }));
87
+
88
+ // Sort items by score (highest first) then alphabetically
89
+ const newSortedList = scoredItems.sort((a, b) => {
90
+ if (a.score !== b.score) return b.score - a.score;
91
+ return a.label.localeCompare(b.label);
92
+ });
93
+
94
+ if (dequal(this.searchState.sortedList, newSortedList)) return;
95
+ this.searchState.sortedList = newSortedList;
96
+ }
97
+
98
+ getFilteredList() {
99
+ return this.searchState.sortedList.filter((item) => item.score === undefined || item.score > 0);
100
+ }
101
+
102
+ props = $derived.by(
103
+ () =>
104
+ ({
105
+ id: this.opts.id.current,
106
+ [SEARCH_ROOT_ATTR]: ''
107
+ }) as const
108
+ );
109
+ }
110
+
111
+ const SearchRootContext = new Context<SearchRootState>('Search.Root');
112
+
113
+ // -------------------- Search Input --------------------
114
+ export type SearchInputStateProps = WithRefProps<
115
+ WritableBoxedValues<{
116
+ value: string;
117
+ }>
118
+ >;
119
+ export class SearchInputState {
120
+ constructor(
121
+ readonly opts: SearchInputStateProps,
122
+ readonly root: SearchRootState
123
+ ) {
124
+ useRefById({
125
+ ...opts,
126
+ onRefChange: (node) => {
127
+ if (node instanceof HTMLInputElement) {
128
+ this.root.inputRef = node;
129
+ }
130
+ }
131
+ });
132
+
133
+ /**
134
+ * This is essentially our oninput handler
135
+ */
136
+ watch(
137
+ () => this.opts.value.current,
138
+ () => {
139
+ this.root.searchState.value = this.opts.value.current;
140
+ this.root.search();
141
+ this.root.searchState.showSuggestions = true;
142
+ }
143
+ );
144
+ }
145
+
146
+ onFocus = () => {
147
+ this.root.search();
148
+ };
149
+
150
+ props = $derived.by(
151
+ () =>
152
+ ({
153
+ id: this.opts.id.current,
154
+ onfocus: this.onFocus,
155
+ [SEARCH_INPUT_ATTR]: ''
156
+ }) as const
157
+ );
158
+ }
159
+
160
+ // -------------------- Search List --------------------
161
+ export type SearchListStateProps = WithRefProps;
162
+ export class SearchListState {
163
+ constructor(
164
+ readonly opts: SearchListStateProps,
165
+ readonly root: SearchRootState
166
+ ) {
167
+ useRefById(opts);
168
+ }
169
+
170
+ props = $derived.by(
171
+ () =>
172
+ ({
173
+ id: this.opts.id.current,
174
+ [SEARCH_LIST_ATTR]: ''
175
+ }) as const
176
+ );
177
+
178
+ get suggestions() {
179
+ return this.root.searchState.sortedList;
180
+ }
181
+
182
+ visible(item: Item & { score?: number }) {
183
+ // Check if item has a score of 0
184
+ if (item.score === 0) return false;
185
+
186
+ return this.root
187
+ .getFilteredList()
188
+ .slice(this.root.start, this.root.end)
189
+ .some((i) => dequal({ label: i.label, value: i.value }, { label: item.label, value: item.value }));
190
+ }
191
+
192
+ selected(item: Item) {
193
+ return this.root.opts.value.current.value === item.value;
194
+ }
195
+ select(item: Item) {
196
+ this.root.opts.value.current = item;
197
+ this.root.searchState.showSuggestions = false;
198
+ this.root.inputRef?.focus();
199
+ }
200
+ }
201
+
202
+ // -------------------- Search Item --------------------
203
+ export type SearchPagnationStateProps = WithRefProps<
204
+ WritableBoxedValues<{
205
+ page: number;
206
+ perPage: number;
207
+ }>
208
+ >;
209
+ export class SearchPagnationState {
210
+ constructor(
211
+ readonly opts: SearchPagnationStateProps,
212
+ readonly root: SearchRootState
213
+ ) {
214
+ useRefById(opts);
215
+ this.root.numPerPage = this.opts.perPage.current;
216
+
217
+ watch(
218
+ () => this.opts.perPage.current,
219
+ (perPage) => {
220
+ this.root.numPerPage = perPage;
221
+ }
222
+ );
223
+
224
+ watch(
225
+ () => this.opts.page.current,
226
+ (page) => {
227
+ this.root.start = (page - 1) * this.root.numPerPage;
228
+ }
229
+ );
230
+ }
231
+
232
+ props = $derived.by(
233
+ () =>
234
+ ({
235
+ id: this.opts.id.current,
236
+ [SEARCH_ITEM_ATTR]: ''
237
+ }) as const
238
+ );
239
+
240
+ get length() {
241
+ return this.root.getFilteredList().length;
242
+ }
243
+
244
+ get perPage() {
245
+ return this.opts.perPage.current;
246
+ }
247
+
248
+ get activeItems() {
249
+ return this.root.getFilteredList().slice(this.root.start, this.root.end);
250
+ }
251
+ }
252
+
253
+ // -------------------- Search Empty --------------------
254
+ export type SearchEmptyStateProps = WithRefProps;
255
+ export class SearchEmptyState {
256
+ constructor(
257
+ readonly opts: SearchEmptyStateProps,
258
+ readonly root: SearchRootState
259
+ ) {
260
+ useRefById(opts);
261
+ }
262
+ props = $derived.by(
263
+ () =>
264
+ ({
265
+ id: this.opts.id.current,
266
+ [SEARCH_EMPTY_ATTR]: ''
267
+ }) as const
268
+ );
269
+ }
270
+
271
+ // -------------------- Search Hooks --------------------
272
+ export function useSearchRoot(props: SearchRootStateProps) {
273
+ return SearchRootContext.set(new SearchRootState(props));
274
+ }
275
+ export function useSearchInput(props: SearchInputStateProps) {
276
+ return new SearchInputState(props, SearchRootContext.get());
277
+ }
278
+ export function useSearchList(props: SearchListStateProps) {
279
+ return new SearchListState(props, SearchRootContext.get());
280
+ }
281
+ export function useSearchPagnation(props: SearchPagnationStateProps) {
282
+ return new SearchPagnationState(props, SearchRootContext.get());
283
+ }
284
+ export function useSearchEmpty(props: SearchEmptyStateProps) {
285
+ return new SearchEmptyState(props, SearchRootContext.get());
286
+ }
@@ -0,0 +1,48 @@
1
+ import type { BitsPrimitiveDivAttributes, WithChild, Without, BitsPrimitiveInputAttributes } from 'bits-ui';
2
+ import type { Snippet } from 'svelte';
3
+
4
+ export type Item = {
5
+ label: string;
6
+ value: string;
7
+ };
8
+
9
+ // -------------------- Search Root --------------------
10
+ export type SearchRootPropsWithoutHTML = WithChild<{
11
+ items?: Item[];
12
+ searchWith?: string;
13
+ value: Item;
14
+ search?: (term: string) => Promise<Item[]>;
15
+ }>;
16
+
17
+ export type SearchProps = SearchRootPropsWithoutHTML & Without<BitsPrimitiveDivAttributes, SearchRootPropsWithoutHTML>;
18
+
19
+ // -------------------- Search Input --------------------
20
+ export type SearchInputPropsWithoutHTML = WithChild<{
21
+ value?: string;
22
+ }>;
23
+
24
+ export type SearchInputProps = SearchInputPropsWithoutHTML &
25
+ Without<BitsPrimitiveInputAttributes, SearchInputPropsWithoutHTML>;
26
+
27
+ // -------------------- Search List --------------------
28
+ export type SearchListPropsWithoutHTML = WithChild<{
29
+ item: Snippet<[Item]>;
30
+ }>;
31
+
32
+ export type SearchListProps = SearchListPropsWithoutHTML &
33
+ Without<BitsPrimitiveDivAttributes, SearchListPropsWithoutHTML>;
34
+
35
+ // -------------------- Search Item --------------------
36
+ export type SearchPagnationPropsWithoutHTML = WithChild<{
37
+ page?: number;
38
+ perPage?: number;
39
+ }>;
40
+
41
+ export type SearchPagnationProps = SearchPagnationPropsWithoutHTML &
42
+ Without<BitsPrimitiveDivAttributes, SearchPagnationPropsWithoutHTML>;
43
+
44
+ // -------------------- Search Empty --------------------
45
+ export type SearchEmptyPropsWithoutHTML = WithChild;
46
+
47
+ export type SearchEmptyProps = SearchEmptyPropsWithoutHTML &
48
+ Without<BitsPrimitiveDivAttributes, SearchEmptyPropsWithoutHTML>;
@@ -0,0 +1,23 @@
1
+ <script lang="ts">
2
+ import { mergeProps } from 'svelte-toolbelt';
3
+ import type { ArrowProps } from './types.js';
4
+ import { useId } from '$bits/internal/use-id.js';
5
+
6
+ let { id = useId(), children, child, width = 10, height = 5, ...restProps }: ArrowProps = $props();
7
+
8
+ const mergedProps = $derived(mergeProps(restProps, { id }));
9
+ </script>
10
+
11
+ {#if child}
12
+ {@render child({ props: mergedProps })}
13
+ {:else}
14
+ <span {...mergedProps}>
15
+ {#if children}
16
+ {@render children?.()}
17
+ {:else}
18
+ <svg {width} {height} viewBox="0 0 30 10" preserveAspectRatio="none" data-arrow="">
19
+ <polygon points="0,0 30,0 15,10" fill="currentColor" />
20
+ </svg>
21
+ {/if}
22
+ </span>
23
+ {/if}
@@ -0,0 +1,2 @@
1
+ export { default as Arrow } from "./arrow.svelte";
2
+ export type { ArrowProps } from "./types.js";
@@ -0,0 +1,20 @@
1
+ import type { WithChild } from "$lib/internal/types.js";
2
+ import type { BitsPrimitiveSpanAttributes } from "$lib/shared/attributes.js";
3
+
4
+ export type ArrowPropsWithoutHTML = WithChild<{
5
+ /**
6
+ * The width of the arrow in pixels.
7
+ *
8
+ * @defaultValue 10
9
+ */
10
+ width?: number;
11
+
12
+ /**
13
+ * The height of the arrow in pixels.
14
+ *
15
+ * @defaultValue 5
16
+ */
17
+ height?: number;
18
+ }>;
19
+
20
+ export type ArrowProps = ArrowPropsWithoutHTML & BitsPrimitiveSpanAttributes;
@@ -0,0 +1,15 @@
1
+ <script lang="ts">
2
+ import { box } from 'svelte-toolbelt';
3
+ import { useFloatingAnchorState } from '../use-floating-layer.svelte.js';
4
+ import type { AnchorProps } from './index.js';
5
+ import type { Measurable } from '$bits/internal/floating-svelte/types.js';
6
+
7
+ let { id, children, virtualEl }: AnchorProps = $props();
8
+
9
+ useFloatingAnchorState({
10
+ id: box.with(() => id),
11
+ virtualEl: box.with(() => virtualEl as unknown as Measurable | null)
12
+ });
13
+ </script>
14
+
15
+ {@render children?.()}
@@ -0,0 +1,20 @@
1
+ <script lang="ts">
2
+ import { box, mergeProps } from 'svelte-toolbelt';
3
+ import { useFloatingArrowState } from '../use-floating-layer.svelte.js';
4
+ import { Arrow, type ArrowProps } from '$components/utilities/arrow/index.js';
5
+ import { useId } from 'bits-ui';
6
+
7
+ let { id = useId(), ref = $bindable(null), ...restProps }: ArrowProps = $props();
8
+
9
+ const arrowState = useFloatingArrowState({
10
+ id: box.with(() => id),
11
+ ref: box.with(
12
+ () => ref,
13
+ (v) => (ref = v)
14
+ )
15
+ });
16
+
17
+ const mergedProps = $derived(mergeProps(restProps, arrowState.props));
18
+ </script>
19
+
20
+ <Arrow {...mergedProps} />
@@ -0,0 +1,19 @@
1
+ <script lang="ts">
2
+ import { type Snippet, onMount } from "svelte";
3
+
4
+ let {
5
+ content,
6
+ onPlaced,
7
+ }: {
8
+ content?: Snippet<
9
+ [{ props: Record<string, unknown>; wrapperProps: Record<string, unknown> }]
10
+ >;
11
+ onPlaced?: () => void;
12
+ } = $props();
13
+
14
+ onMount(() => {
15
+ onPlaced?.();
16
+ });
17
+ </script>
18
+
19
+ {@render content?.({ props: {}, wrapperProps: {} })}
@@ -0,0 +1,61 @@
1
+ <script lang="ts">
2
+ import { box, mergeProps } from 'svelte-toolbelt';
3
+ import { useFloatingContentState } from '../use-floating-layer.svelte.js';
4
+ import type { ContentImplProps } from './index.js';
5
+ import { useId } from 'bits-ui';
6
+
7
+ let {
8
+ content,
9
+ side = 'bottom',
10
+ sideOffset = 0,
11
+ align = 'center',
12
+ alignOffset = 0,
13
+ id,
14
+ arrowPadding = 0,
15
+ avoidCollisions = true,
16
+ collisionBoundary = [],
17
+ collisionPadding = 0,
18
+ hideWhenDetached = false,
19
+ onPlaced = () => {},
20
+ sticky = 'partial',
21
+ updatePositionStrategy = 'optimized',
22
+ strategy = 'fixed',
23
+ dir = 'ltr',
24
+ style = {},
25
+ wrapperId = useId(),
26
+ customAnchor = null,
27
+ enabled
28
+ }: ContentImplProps = $props();
29
+
30
+ const contentState = useFloatingContentState({
31
+ side: box.with(() => side),
32
+ sideOffset: box.with(() => sideOffset),
33
+ align: box.with(() => align),
34
+ alignOffset: box.with(() => alignOffset),
35
+ id: box.with(() => id),
36
+ arrowPadding: box.with(() => arrowPadding),
37
+ avoidCollisions: box.with(() => avoidCollisions),
38
+ collisionBoundary: box.with(() => collisionBoundary),
39
+ collisionPadding: box.with(() => collisionPadding),
40
+ hideWhenDetached: box.with(() => hideWhenDetached),
41
+ onPlaced: box.with(() => onPlaced),
42
+ sticky: box.with(() => sticky),
43
+ updatePositionStrategy: box.with(() => updatePositionStrategy),
44
+ strategy: box.with(() => strategy),
45
+ dir: box.with(() => dir),
46
+ style: box.with(() => style),
47
+ enabled: box.with(() => enabled),
48
+ wrapperId: box.with(() => wrapperId),
49
+ customAnchor: box.with(() => customAnchor)
50
+ });
51
+
52
+ const mergedProps = $derived(
53
+ mergeProps(contentState.wrapperProps, {
54
+ style: {
55
+ pointerEvents: 'auto'
56
+ }
57
+ })
58
+ );
59
+ </script>
60
+
61
+ {@render content?.({ props: contentState.props, wrapperProps: mergedProps })}
@@ -0,0 +1,10 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from "svelte";
3
+ import { useFloatingRootState } from "../use-floating-layer.svelte.js";
4
+
5
+ let { children }: { children?: Snippet } = $props();
6
+
7
+ useFloatingRootState();
8
+ </script>
9
+
10
+ {@render children?.()}
@@ -0,0 +1,11 @@
1
+ export { default as Anchor } from "./floating-layer-anchor.svelte";
2
+ export { default as Arrow } from "./floating-layer-arrow.svelte";
3
+ export { default as Content } from "./floating-layer-content.svelte";
4
+ export { default as ContentStatic } from "./floating-layer-content-static.svelte";
5
+ export { default as Root } from "./floating-layer.svelte";
6
+
7
+ export type {
8
+ FloatingLayerContentImplProps as ContentImplProps,
9
+ FloatingLayerContentProps as ContentProps,
10
+ FloatingLayerAnchorProps as AnchorProps,
11
+ } from "../types.js";
@@ -0,0 +1 @@
1
+ export * as FloatingLayer from "./components/index.js";
@@ -0,0 +1,133 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { ReadableBox } from 'svelte-toolbelt';
3
+ import type { Align, Boundary, Side } from './use-floating-layer.svelte.js';
4
+ import type { Arrayable } from '$bits/internal/types.js';
5
+ import type { Direction, StyleProperties } from 'bits-ui';
6
+ import type { Measurable } from '$bits/internal/floating-svelte/types.js';
7
+
8
+ export type FloatingLayerContentProps = {
9
+ /**
10
+ * The preferred side of the anchor to render against when open.
11
+ * Will be reversed when collisions occur.
12
+ *
13
+ * @see https://floating-ui.com/docs/computePosition#placement
14
+ */
15
+ side?: Side;
16
+
17
+ /**
18
+ * The distance in pixels from the anchor to the floating element.
19
+ * @see https://floating-ui.com/docs/offset#options
20
+ */
21
+ sideOffset?: number;
22
+
23
+ /**
24
+ * The preferred alignment of the anchor to render against when open.
25
+ * This may change when collisions occur.
26
+ *
27
+ * @see https://floating-ui.com/docs/computePosition#placement
28
+ */
29
+ align?: Align;
30
+
31
+ /**
32
+ * An offset in pixels from the "start" or "end" alignment options.
33
+ * @see https://floating-ui.com/docs/offset#options
34
+ */
35
+ alignOffset?: number | undefined;
36
+
37
+ /**
38
+ * This describes the padding between the arrow and the edges of the floating element.
39
+ * If your floating element has border-radius, this will prevent it from overflowing
40
+ * the corners.
41
+ */
42
+ arrowPadding?: number;
43
+
44
+ /**
45
+ * When `true`, overrides the `side` and `align` options to prevent collisions
46
+ * with the boundary edges.
47
+ *
48
+ * @default true
49
+ * @see https://floating-ui.com/docs/flip
50
+ */
51
+ avoidCollisions?: boolean | undefined;
52
+
53
+ /**
54
+ * A boundary element or array of elements to check for collisions against.
55
+ *
56
+ * @see https://floating-ui.com/docs/detectoverflow#boundary
57
+ */
58
+ collisionBoundary?: Arrayable<Boundary>;
59
+
60
+ /**
61
+ * The amount in pixels of virtual padding around the viewport edges to check
62
+ * for overflow which will cause a collision.
63
+ *
64
+ * @default 8
65
+ * @see https://floating-ui.com/docs/detectOverflow#padding
66
+ */
67
+ collisionPadding?: number | Partial<Record<Side, number>>;
68
+
69
+ sticky?: 'partial' | 'always';
70
+
71
+ hideWhenDetached?: boolean;
72
+
73
+ /**
74
+ * "optimized" will only update the position when necessary, while "always"
75
+ * will update the position on each animation frame, which is useful if the floating
76
+ * content is following something like a mouse cursor.
77
+ *
78
+ * @defaultValue "optimized"
79
+ */
80
+ updatePositionStrategy?: 'optimized' | 'always';
81
+
82
+ content?: Snippet<[{ props: Record<string, unknown>; wrapperProps: Record<string, unknown> }]>;
83
+
84
+ /**
85
+ * The positioning strategy to use for the floating element.
86
+ * @see https://floating-ui.com/docs/computeposition#strategy
87
+ */
88
+ strategy?: 'absolute' | 'fixed' | undefined;
89
+
90
+ /**
91
+ * The text direction of the content.
92
+ */
93
+ dir?: Direction;
94
+
95
+ /**
96
+ * Whether to prevent scrolling the body when the content is open.
97
+ */
98
+ preventScroll?: boolean;
99
+
100
+ /**
101
+ * Use an element other than the trigger to anchor the content to. If provided,
102
+ * the content will be anchored to the provided element instead of the trigger.
103
+ *
104
+ * You can pass a selector string or an HTMLElement.
105
+ */
106
+ customAnchor?: string | HTMLElement | Measurable | null;
107
+ };
108
+
109
+ export type FloatingLayerContentImplProps = {
110
+ id: string;
111
+
112
+ /**
113
+ * The ID of the content wrapper element.
114
+ */
115
+ wrapperId?: string;
116
+
117
+ /**
118
+ * The style properties to apply to the content.
119
+ */
120
+ style?: StyleProperties | string | null;
121
+
122
+ /**
123
+ * Callback that is called when the floating element is placed.
124
+ */
125
+ onPlaced?: () => void;
126
+ enabled: boolean;
127
+ } & FloatingLayerContentProps;
128
+
129
+ export type FloatingLayerAnchorProps = {
130
+ id: string;
131
+ children?: Snippet;
132
+ virtualEl?: ReadableBox<Measurable | null>;
133
+ };