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.
- package/README.md +6 -0
- package/dist/app.css +209 -0
- package/dist/app.d.ts +13 -0
- package/dist/app.html +12 -0
- package/dist/icons.css +6 -0
- package/dist/lib/bits/internal/arrays.d.ts +95 -0
- package/dist/lib/bits/internal/arrays.js +250 -0
- package/dist/lib/bits/internal/arrays.test.d.ts +1 -0
- package/dist/lib/bits/internal/arrays.test.js +366 -0
- package/dist/lib/bits/internal/attrs.d.ts +22 -0
- package/dist/lib/bits/internal/attrs.js +69 -0
- package/dist/lib/bits/internal/box-auto-reset.svelte.d.ts +8 -0
- package/dist/lib/bits/internal/box-auto-reset.svelte.js +31 -0
- package/dist/lib/bits/internal/box.svelte.d.ts +21 -0
- package/dist/lib/bits/internal/box.svelte.js +26 -0
- package/dist/lib/bits/internal/clamp.d.ts +4 -0
- package/dist/lib/bits/internal/clamp.js +6 -0
- package/dist/lib/bits/internal/clamp.test.d.ts +1 -0
- package/dist/lib/bits/internal/clamp.test.js +31 -0
- package/dist/lib/bits/internal/create-event-hook.svelte.d.ts +18 -0
- package/dist/lib/bits/internal/create-event-hook.svelte.js +29 -0
- package/dist/lib/bits/internal/create-shared-hook.svelte.d.ts +2 -0
- package/dist/lib/bits/internal/create-shared-hook.svelte.js +27 -0
- package/dist/lib/bits/internal/date-time/announcer.d.ts +7 -0
- package/dist/lib/bits/internal/date-time/announcer.js +82 -0
- package/dist/lib/bits/internal/date-time/calendar-helpers.svelte.d.ts +201 -0
- package/dist/lib/bits/internal/date-time/calendar-helpers.svelte.js +510 -0
- package/dist/lib/bits/internal/date-time/field/helpers.d.ts +76 -0
- package/dist/lib/bits/internal/date-time/field/helpers.js +378 -0
- package/dist/lib/bits/internal/date-time/field/parts.d.ts +6 -0
- package/dist/lib/bits/internal/date-time/field/parts.js +9 -0
- package/dist/lib/bits/internal/date-time/field/segments.d.ts +51 -0
- package/dist/lib/bits/internal/date-time/field/segments.js +128 -0
- package/dist/lib/bits/internal/date-time/field/types.d.ts +25 -0
- package/dist/lib/bits/internal/date-time/field/types.js +1 -0
- package/dist/lib/bits/internal/date-time/formatter.d.ts +24 -0
- package/dist/lib/bits/internal/date-time/formatter.js +97 -0
- package/dist/lib/bits/internal/date-time/placeholders.d.ts +8 -0
- package/dist/lib/bits/internal/date-time/placeholders.js +129 -0
- package/dist/lib/bits/internal/date-time/utils.d.ts +69 -0
- package/dist/lib/bits/internal/date-time/utils.js +212 -0
- package/dist/lib/bits/internal/debounce.d.ts +4 -0
- package/dist/lib/bits/internal/debounce.js +19 -0
- package/dist/lib/bits/internal/debounce.test.d.ts +1 -0
- package/dist/lib/bits/internal/debounce.test.js +50 -0
- package/dist/lib/bits/internal/dom.d.ts +10 -0
- package/dist/lib/bits/internal/dom.js +38 -0
- package/dist/lib/bits/internal/elements.d.ts +2 -0
- package/dist/lib/bits/internal/elements.js +6 -0
- package/dist/lib/bits/internal/events.d.ts +21 -0
- package/dist/lib/bits/internal/events.js +49 -0
- package/dist/lib/bits/internal/floating-svelte/floating-utils.svelte.d.ts +7 -0
- package/dist/lib/bits/internal/floating-svelte/floating-utils.svelte.js +24 -0
- package/dist/lib/bits/internal/floating-svelte/types.d.ts +85 -0
- package/dist/lib/bits/internal/floating-svelte/types.js +1 -0
- package/dist/lib/bits/internal/floating-svelte/use-floating.svelte.d.ts +2 -0
- package/dist/lib/bits/internal/floating-svelte/use-floating.svelte.js +112 -0
- package/dist/lib/bits/internal/focus.d.ts +46 -0
- package/dist/lib/bits/internal/focus.js +109 -0
- package/dist/lib/bits/internal/get-directional-keys.d.ts +21 -0
- package/dist/lib/bits/internal/get-directional-keys.js +37 -0
- package/dist/lib/bits/internal/get-directional-keys.test.d.ts +1 -0
- package/dist/lib/bits/internal/get-directional-keys.test.js +46 -0
- package/dist/lib/bits/internal/is.d.ts +25 -0
- package/dist/lib/bits/internal/is.js +62 -0
- package/dist/lib/bits/internal/is.test.d.ts +1 -0
- package/dist/lib/bits/internal/is.test.js +34 -0
- package/dist/lib/bits/internal/kbd-constants.d.ts +40 -0
- package/dist/lib/bits/internal/kbd-constants.js +40 -0
- package/dist/lib/bits/internal/kbd.d.ts +1 -0
- package/dist/lib/bits/internal/kbd.js +1 -0
- package/dist/lib/bits/internal/locale.d.ts +6 -0
- package/dist/lib/bits/internal/locale.js +9 -0
- package/dist/lib/bits/internal/math.d.ts +5 -0
- package/dist/lib/bits/internal/math.js +43 -0
- package/dist/lib/bits/internal/math.test.d.ts +1 -0
- package/dist/lib/bits/internal/math.test.js +71 -0
- package/dist/lib/bits/internal/noop.d.ts +4 -0
- package/dist/lib/bits/internal/noop.js +4 -0
- package/dist/lib/bits/internal/should-trap-focus.d.ts +6 -0
- package/dist/lib/bits/internal/should-trap-focus.js +6 -0
- package/dist/lib/bits/internal/sleep.d.ts +1 -0
- package/dist/lib/bits/internal/sleep.js +3 -0
- package/dist/lib/bits/internal/tabbable.d.ts +10 -0
- package/dist/lib/bits/internal/tabbable.js +66 -0
- package/dist/lib/bits/internal/types.d.ts +92 -0
- package/dist/lib/bits/internal/types.js +1 -0
- package/dist/lib/bits/internal/use-after-animations.svelte.d.ts +5 -0
- package/dist/lib/bits/internal/use-after-animations.svelte.js +27 -0
- package/dist/lib/bits/internal/use-arrow-navigation.d.ts +62 -0
- package/dist/lib/bits/internal/use-arrow-navigation.js +76 -0
- package/dist/lib/bits/internal/use-body-scroll-lock.svelte.d.ts +6 -0
- package/dist/lib/bits/internal/use-body-scroll-lock.svelte.js +106 -0
- package/dist/lib/bits/internal/use-data-typeahead.svelte.d.ts +14 -0
- package/dist/lib/bits/internal/use-data-typeahead.svelte.js +31 -0
- package/dist/lib/bits/internal/use-dom-typeahead.svelte.d.ts +11 -0
- package/dist/lib/bits/internal/use-dom-typeahead.svelte.js +30 -0
- package/dist/lib/bits/internal/use-form-control.svelte.d.ts +4 -0
- package/dist/lib/bits/internal/use-form-control.svelte.js +16 -0
- package/dist/lib/bits/internal/use-grace-area.svelte.d.ts +12 -0
- package/dist/lib/bits/internal/use-grace-area.svelte.js +197 -0
- package/dist/lib/bits/internal/use-id.d.ts +4 -0
- package/dist/lib/bits/internal/use-id.js +8 -0
- package/dist/lib/bits/internal/use-resize-observer.svelte.d.ts +2 -0
- package/dist/lib/bits/internal/use-resize-observer.svelte.js +17 -0
- package/dist/lib/bits/internal/use-roving-focus.svelte.d.ts +38 -0
- package/dist/lib/bits/internal/use-roving-focus.svelte.js +91 -0
- package/dist/lib/bits/internal/use-size.svelte.d.ts +7 -0
- package/dist/lib/bits/internal/use-size.svelte.js +54 -0
- package/dist/lib/bits/internal/use-state-machine.svelte.d.ts +24 -0
- package/dist/lib/bits/internal/use-state-machine.svelte.js +28 -0
- package/dist/lib/bits/internal/use-timeout-fn.svelte.d.ts +25 -0
- package/dist/lib/bits/internal/use-timeout-fn.svelte.js +39 -0
- package/dist/lib/components/Typeahead.svelte.d.ts +47 -0
- package/dist/lib/components/Typeahead.svelte.js +150 -0
- package/dist/lib/components/animated/animated.svelte +244 -0
- package/dist/lib/components/animated/animated.svelte.d.ts +61 -0
- package/dist/lib/components/animated/index.d.ts +2 -0
- package/dist/lib/components/animated/index.js +2 -0
- package/dist/lib/components/combo/combo.svelte +186 -0
- package/dist/lib/components/combo/combo.svelte.d.ts +21 -0
- package/dist/lib/components/combo/index.d.ts +2 -0
- package/dist/lib/components/combo/index.js +2 -0
- package/dist/lib/components/dnd/Droppable.svelte +25 -0
- package/dist/lib/components/dnd/Droppable.svelte.d.ts +10 -0
- package/dist/lib/components/dnd/context.svelte.d.ts +22 -0
- package/dist/lib/components/dnd/context.svelte.js +25 -0
- package/dist/lib/components/dnd/dnd-context.svelte +45 -0
- package/dist/lib/components/dnd/dnd-context.svelte.d.ts +30 -0
- package/dist/lib/components/dnd/dnd-drag-overlay.svelte +44 -0
- package/dist/lib/components/dnd/dnd-drag-overlay.svelte.d.ts +27 -0
- package/dist/lib/components/dnd/dnd-drag-placeholder.svelte +24 -0
- package/dist/lib/components/dnd/dnd-drag-placeholder.svelte.d.ts +9 -0
- package/dist/lib/components/dnd/dnd-draghandle.svelte +30 -0
- package/dist/lib/components/dnd/dnd-draghandle.svelte.d.ts +6 -0
- package/dist/lib/components/dnd/dnd-overlay.svelte +0 -0
- package/dist/lib/components/dnd/dnd-overlay.svelte.d.ts +26 -0
- package/dist/lib/components/dnd/dnd-sortable-context.svelte +18 -0
- package/dist/lib/components/dnd/dnd-sortable-context.svelte.d.ts +8 -0
- package/dist/lib/components/dnd/dnd-sortable-item.svelte +68 -0
- package/dist/lib/components/dnd/dnd-sortable-item.svelte.d.ts +23 -0
- package/dist/lib/components/dnd/example.svelte +109 -0
- package/dist/lib/components/dnd/example.svelte.d.ts +3 -0
- package/dist/lib/components/dnd/exports.d.ts +9 -0
- package/dist/lib/components/dnd/exports.js +9 -0
- package/dist/lib/components/dnd/index.d.ts +1 -0
- package/dist/lib/components/dnd/index.js +1 -0
- package/dist/lib/components/dnd/sortable.svelte.d.ts +13 -0
- package/dist/lib/components/dnd/sortable.svelte.js +70 -0
- package/dist/lib/components/dnd/utils.svelte.d.ts +20 -0
- package/dist/lib/components/dnd/utils.svelte.js +20 -0
- package/dist/lib/components/search/combinations/searchPopover.svelte +68 -0
- package/dist/lib/components/search/combinations/searchPopover.svelte.d.ts +22 -0
- package/dist/lib/components/search/components/search-empty.svelte +28 -0
- package/dist/lib/components/search/components/search-empty.svelte.d.ts +4 -0
- package/dist/lib/components/search/components/search-input.svelte +53 -0
- package/dist/lib/components/search/components/search-input.svelte.d.ts +4 -0
- package/dist/lib/components/search/components/search-list.svelte +46 -0
- package/dist/lib/components/search/components/search-list.svelte.d.ts +4 -0
- package/dist/lib/components/search/components/search-pagnation.svelte +68 -0
- package/dist/lib/components/search/components/search-pagnation.svelte.d.ts +8 -0
- package/dist/lib/components/search/components/search.svelte +47 -0
- package/dist/lib/components/search/components/search.svelte.d.ts +4 -0
- package/dist/lib/components/search/exports.d.ts +6 -0
- package/dist/lib/components/search/exports.js +5 -0
- package/dist/lib/components/search/index.d.ts +2 -0
- package/dist/lib/components/search/index.js +2 -0
- package/dist/lib/components/search/search.svelte.d.ts +102 -0
- package/dist/lib/components/search/search.svelte.js +202 -0
- package/dist/lib/components/search/types.d.ts +28 -0
- package/dist/lib/components/search/types.js +1 -0
- package/dist/lib/components/utilities/arrow/arrow.svelte +23 -0
- package/dist/lib/components/utilities/arrow/arrow.svelte.d.ts +3 -0
- package/dist/lib/components/utilities/arrow/index.d.ts +2 -0
- package/dist/lib/components/utilities/arrow/index.js +1 -0
- package/dist/lib/components/utilities/arrow/types.d.ts +17 -0
- package/dist/lib/components/utilities/arrow/types.js +1 -0
- package/dist/lib/components/utilities/floating-layer/components/floating-layer-anchor.svelte +15 -0
- package/dist/lib/components/utilities/floating-layer/components/floating-layer-anchor.svelte.d.ts +4 -0
- package/dist/lib/components/utilities/floating-layer/components/floating-layer-arrow.svelte +20 -0
- package/dist/lib/components/utilities/floating-layer/components/floating-layer-arrow.svelte.d.ts +3 -0
- package/dist/lib/components/utilities/floating-layer/components/floating-layer-content-static.svelte +19 -0
- package/dist/lib/components/utilities/floating-layer/components/floating-layer-content-static.svelte.d.ts +13 -0
- package/dist/lib/components/utilities/floating-layer/components/floating-layer-content.svelte +61 -0
- package/dist/lib/components/utilities/floating-layer/components/floating-layer-content.svelte.d.ts +4 -0
- package/dist/lib/components/utilities/floating-layer/components/floating-layer.svelte +10 -0
- package/dist/lib/components/utilities/floating-layer/components/floating-layer.svelte.d.ts +7 -0
- package/dist/lib/components/utilities/floating-layer/components/index.d.ts +6 -0
- package/dist/lib/components/utilities/floating-layer/components/index.js +5 -0
- package/dist/lib/components/utilities/floating-layer/index.d.ts +1 -0
- package/dist/lib/components/utilities/floating-layer/index.js +1 -0
- package/dist/lib/components/utilities/floating-layer/types.d.ts +115 -0
- package/dist/lib/components/utilities/floating-layer/types.js +1 -0
- package/dist/lib/components/utilities/floating-layer/use-floating-layer.svelte.d.ts +118 -0
- package/dist/lib/components/utilities/floating-layer/use-floating-layer.svelte.js +311 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +1 -0
- package/dist/lib/utils/asyncDerived.svelte.d.ts +12 -0
- package/dist/lib/utils/asyncDerived.svelte.js +26 -0
- package/dist/lib/utils/bits.d.ts +39 -0
- package/dist/lib/utils/bits.js +69 -0
- package/dist/lib/utils/index.d.ts +3 -0
- package/dist/lib/utils/index.js +3 -0
- package/dist/lib/utils/utils.d.ts +21 -0
- package/dist/lib/utils/utils.js +72 -0
- package/dist/routes/+layout.svelte +0 -0
- package/dist/routes/+layout.svelte.d.ts +26 -0
- package/package.json +79 -0
- package/src/app.css +209 -0
- package/src/app.d.ts +13 -0
- package/src/app.html +12 -0
- package/src/icons.css +6 -0
- package/src/lib/bits/internal/arrays.test.ts +460 -0
- package/src/lib/bits/internal/arrays.ts +301 -0
- package/src/lib/bits/internal/attrs.ts +97 -0
- package/src/lib/bits/internal/box-auto-reset.svelte.ts +40 -0
- package/src/lib/bits/internal/box.svelte.ts +60 -0
- package/src/lib/bits/internal/clamp.test.ts +37 -0
- package/src/lib/bits/internal/clamp.ts +6 -0
- package/src/lib/bits/internal/create-event-hook.svelte.ts +64 -0
- package/src/lib/bits/internal/create-shared-hook.svelte.ts +33 -0
- package/src/lib/bits/internal/date-time/announcer.ts +88 -0
- package/src/lib/bits/internal/date-time/calendar-helpers.svelte.ts +815 -0
- package/src/lib/bits/internal/date-time/field/helpers.ts +441 -0
- package/src/lib/bits/internal/date-time/field/parts.ts +9 -0
- package/src/lib/bits/internal/date-time/field/segments.ts +126 -0
- package/src/lib/bits/internal/date-time/field/types.ts +35 -0
- package/src/lib/bits/internal/date-time/formatter.ts +116 -0
- package/src/lib/bits/internal/date-time/placeholders.ts +143 -0
- package/src/lib/bits/internal/date-time/utils.ts +261 -0
- package/src/lib/bits/internal/debounce.test.ts +67 -0
- package/src/lib/bits/internal/debounce.ts +22 -0
- package/src/lib/bits/internal/dom.ts +47 -0
- package/src/lib/bits/internal/elements.ts +7 -0
- package/src/lib/bits/internal/events.ts +89 -0
- package/src/lib/bits/internal/floating-svelte/floating-utils.svelte.ts +28 -0
- package/src/lib/bits/internal/floating-svelte/types.ts +108 -0
- package/src/lib/bits/internal/floating-svelte/use-floating.svelte.ts +133 -0
- package/src/lib/bits/internal/focus.ts +111 -0
- package/src/lib/bits/internal/get-directional-keys.test.ts +51 -0
- package/src/lib/bits/internal/get-directional-keys.ts +43 -0
- package/src/lib/bits/internal/is.test.ts +40 -0
- package/src/lib/bits/internal/is.ts +78 -0
- package/src/lib/bits/internal/kbd-constants.ts +40 -0
- package/src/lib/bits/internal/kbd.ts +1 -0
- package/src/lib/bits/internal/locale.ts +13 -0
- package/src/lib/bits/internal/math.test.ts +88 -0
- package/src/lib/bits/internal/math.ts +50 -0
- package/src/lib/bits/internal/noop.ts +4 -0
- package/src/lib/bits/internal/should-trap-focus.ts +16 -0
- package/src/lib/bits/internal/sleep.ts +3 -0
- package/src/lib/bits/internal/tabbable.ts +76 -0
- package/src/lib/bits/internal/types.ts +91 -0
- package/src/lib/bits/internal/use-after-animations.svelte.ts +30 -0
- package/src/lib/bits/internal/use-arrow-navigation.ts +168 -0
- package/src/lib/bits/internal/use-body-scroll-lock.svelte.ts +138 -0
- package/src/lib/bits/internal/use-data-typeahead.svelte.ts +44 -0
- package/src/lib/bits/internal/use-dom-typeahead.svelte.ts +44 -0
- package/src/lib/bits/internal/use-form-control.svelte.ts +17 -0
- package/src/lib/bits/internal/use-grace-area.svelte.ts +229 -0
- package/src/lib/bits/internal/use-id.ts +9 -0
- package/src/lib/bits/internal/use-resize-observer.svelte.ts +19 -0
- package/src/lib/bits/internal/use-roving-focus.svelte.ts +141 -0
- package/src/lib/bits/internal/use-size.svelte.ts +60 -0
- package/src/lib/bits/internal/use-state-machine.svelte.ts +46 -0
- package/src/lib/bits/internal/use-timeout-fn.svelte.ts +80 -0
- package/src/lib/components/Typeahead.svelte.ts +200 -0
- package/src/lib/components/animated/animated.svelte +244 -0
- package/src/lib/components/animated/index.ts +3 -0
- package/src/lib/components/combo/combo.svelte +186 -0
- package/src/lib/components/combo/index.ts +3 -0
- package/src/lib/components/dnd/Droppable.svelte +25 -0
- package/src/lib/components/dnd/context.svelte.ts +30 -0
- package/src/lib/components/dnd/dnd-context.svelte +45 -0
- package/src/lib/components/dnd/dnd-drag-overlay.svelte +44 -0
- package/src/lib/components/dnd/dnd-drag-placeholder.svelte +24 -0
- package/src/lib/components/dnd/dnd-draghandle.svelte +30 -0
- package/src/lib/components/dnd/dnd-overlay.svelte +0 -0
- package/src/lib/components/dnd/dnd-sortable-context.svelte +18 -0
- package/src/lib/components/dnd/dnd-sortable-item.svelte +68 -0
- package/src/lib/components/dnd/example.svelte +109 -0
- package/src/lib/components/dnd/exports.ts +12 -0
- package/src/lib/components/dnd/index.ts +1 -0
- package/src/lib/components/dnd/sortable.svelte.ts +82 -0
- package/src/lib/components/dnd/utils.svelte.ts +29 -0
- package/src/lib/components/search/combinations/searchPopover.svelte +68 -0
- package/src/lib/components/search/components/search-empty.svelte +28 -0
- package/src/lib/components/search/components/search-input.svelte +53 -0
- package/src/lib/components/search/components/search-list.svelte +46 -0
- package/src/lib/components/search/components/search-pagnation.svelte +68 -0
- package/src/lib/components/search/components/search.svelte +47 -0
- package/src/lib/components/search/exports.ts +13 -0
- package/src/lib/components/search/index.ts +2 -0
- package/src/lib/components/search/search.svelte.ts +286 -0
- package/src/lib/components/search/types.ts +48 -0
- package/src/lib/components/utilities/arrow/arrow.svelte +23 -0
- package/src/lib/components/utilities/arrow/index.ts +2 -0
- package/src/lib/components/utilities/arrow/types.ts +20 -0
- package/src/lib/components/utilities/floating-layer/components/floating-layer-anchor.svelte +15 -0
- package/src/lib/components/utilities/floating-layer/components/floating-layer-arrow.svelte +20 -0
- package/src/lib/components/utilities/floating-layer/components/floating-layer-content-static.svelte +19 -0
- package/src/lib/components/utilities/floating-layer/components/floating-layer-content.svelte +61 -0
- package/src/lib/components/utilities/floating-layer/components/floating-layer.svelte +10 -0
- package/src/lib/components/utilities/floating-layer/components/index.ts +11 -0
- package/src/lib/components/utilities/floating-layer/index.ts +1 -0
- package/src/lib/components/utilities/floating-layer/types.ts +133 -0
- package/src/lib/components/utilities/floating-layer/use-floating-layer.svelte.ts +406 -0
- package/src/lib/index.ts +1 -0
- package/src/lib/utils/asyncDerived.svelte.ts +38 -0
- package/src/lib/utils/bits.ts +93 -0
- package/src/lib/utils/index.ts +3 -0
- package/src/lib/utils/utils.ts +97 -0
- package/src/routes/+layout.svelte +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
### Typescript
|
|
2
|
+
|
|
3
|
+
Although shadcn exists here in the repo it is not shipped. This is simply for tooling and nothing else, as such in the
|
|
4
|
+
`svelte.config.js` the aliases are added just for typescript, so that they are not resolved by the packaging process.
|
|
5
|
+
|
|
6
|
+
This allows consumers to bring their own shadcn components just so long as they resolve `$shadcn`
|
package/dist/app.css
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/* Tailwind */
|
|
2
|
+
@import 'tailwindcss' source(none);
|
|
3
|
+
@import 'tw-animate-css';
|
|
4
|
+
|
|
5
|
+
/* Plugins */
|
|
6
|
+
@plugin '@tailwindcss/typography';
|
|
7
|
+
/* @plugin '@tailwindcss/forms'; */
|
|
8
|
+
@plugin "@iconify/tailwind4";
|
|
9
|
+
@plugin 'tailwind-scrollbar' {
|
|
10
|
+
nocompatible: true;
|
|
11
|
+
preferredstrategy: 'pseudoelements';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* Imports */
|
|
15
|
+
@import './icons.css';
|
|
16
|
+
|
|
17
|
+
/* --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', 'Ubuntu', sans-serif; */
|
|
18
|
+
|
|
19
|
+
html {
|
|
20
|
+
scrollbar-gutter: stable;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* Below is for shadcn */
|
|
24
|
+
|
|
25
|
+
@custom-variant dark (&:where(.dark, .dark *));
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
The default border color has changed to `currentColor` in Tailwind CSS v4,
|
|
29
|
+
so we've added these compatibility styles to make sure everything still
|
|
30
|
+
looks the same as it did with Tailwind CSS v3.
|
|
31
|
+
|
|
32
|
+
If we ever want to remove these styles, we need to add an explicit border
|
|
33
|
+
color utility to any element that depends on these defaults.
|
|
34
|
+
*/
|
|
35
|
+
@layer base {
|
|
36
|
+
*,
|
|
37
|
+
::after,
|
|
38
|
+
::before,
|
|
39
|
+
::backdrop,
|
|
40
|
+
::file-selector-button {
|
|
41
|
+
border-color: var(--color-stone-200, currentColor);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
:root {
|
|
46
|
+
--background: var(--color-amber-50);
|
|
47
|
+
--foreground: var(--color-stone-950);
|
|
48
|
+
--card: var(--color-amber-50);
|
|
49
|
+
--card-foreground: var(--color-stone-950);
|
|
50
|
+
--popover: var(--color-zinc-50);
|
|
51
|
+
--popover-foreground: var(--color-stone-950);
|
|
52
|
+
--primary: var(--color-amber-800);
|
|
53
|
+
--primary-foreground: var(--color-stone-50);
|
|
54
|
+
--secondary: var(--color-stone-100);
|
|
55
|
+
--secondary-foreground: var(--color-stone-900);
|
|
56
|
+
--muted: var(--color-stone-100);
|
|
57
|
+
--muted-foreground: var(--color-stone-500);
|
|
58
|
+
--accent: var(--color-stone-100);
|
|
59
|
+
--accent-foreground: var(--color-stone-900);
|
|
60
|
+
--destructive: var(--color-red-600);
|
|
61
|
+
--destructive-foreground: var(--color-stone-50);
|
|
62
|
+
--border: var(--color-stone-200);
|
|
63
|
+
--input: var(--color-stone-200);
|
|
64
|
+
--ring: var(--color-amber-600);
|
|
65
|
+
--radius: 0.5rem;
|
|
66
|
+
|
|
67
|
+
--sidebar-background: var(--color-zinc-50);
|
|
68
|
+
--sidebar-foreground: var(--color-zinc-700);
|
|
69
|
+
--sidebar-primary: var(--color-zinc-900);
|
|
70
|
+
--sidebar-primary-foreground: var(--color-zinc-50);
|
|
71
|
+
--sidebar-accent: var(--color-zinc-100);
|
|
72
|
+
--sidebar-accent-foreground: var(--color-zinc-900);
|
|
73
|
+
--sidebar-border: var(--color-gray-200);
|
|
74
|
+
--sidebar-ring: var(--color-blue-500);
|
|
75
|
+
}
|
|
76
|
+
.dark {
|
|
77
|
+
--background: var(--color-gray-950);
|
|
78
|
+
--foreground: var(--color-gray-50);
|
|
79
|
+
--card: var(--color-gray-950);
|
|
80
|
+
--card-foreground: var(--color-gray-50);
|
|
81
|
+
--popover: var(--color-gray-950);
|
|
82
|
+
--popover-foreground: var(--color-gray-50);
|
|
83
|
+
--primary: var(--color-amber-700);
|
|
84
|
+
--primary-foreground: var(--color-gray-50);
|
|
85
|
+
--secondary: var(--color-gray-800);
|
|
86
|
+
--secondary-foreground: var(--color-gray-50);
|
|
87
|
+
--muted: var(--color-gray-800);
|
|
88
|
+
--muted-foreground: var(--color-gray-400);
|
|
89
|
+
--accent: var(--color-gray-800);
|
|
90
|
+
--accent-foreground: var(--color-gray-50);
|
|
91
|
+
--destructive: var(--color-red-900);
|
|
92
|
+
--destructive-foreground: var(--color-gray-50);
|
|
93
|
+
--border: var(--color-gray-800);
|
|
94
|
+
--input: var(--color-gray-800);
|
|
95
|
+
--ring: var(--color-amber-700);
|
|
96
|
+
|
|
97
|
+
--sidebar-background: var(--color-gray-900);
|
|
98
|
+
--sidebar-foreground: var(--color-zinc-100);
|
|
99
|
+
--sidebar-primary: var(--color-amber-700);
|
|
100
|
+
--sidebar-primary-foreground: var(--color-zinc-50);
|
|
101
|
+
--sidebar-accent: var(--color-gray-800);
|
|
102
|
+
--sidebar-accent-foreground: var(--color-zinc-100);
|
|
103
|
+
--sidebar-border: var(--color-zinc-800);
|
|
104
|
+
--sidebar-ring: var(--color-amber-500);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@theme inline {
|
|
108
|
+
/* Fonts */
|
|
109
|
+
--font-sans:
|
|
110
|
+
'Inter Variable', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
|
|
111
|
+
'Noto Color Emoji';
|
|
112
|
+
--font-mono:
|
|
113
|
+
'Source Code Pro Variable', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',
|
|
114
|
+
monospace;
|
|
115
|
+
|
|
116
|
+
/* Colors */
|
|
117
|
+
--color-border: var(--border);
|
|
118
|
+
--color-input: var(--input);
|
|
119
|
+
--color-ring: var(--ring);
|
|
120
|
+
--color-background: var(--background);
|
|
121
|
+
--color-foreground: var(--foreground);
|
|
122
|
+
|
|
123
|
+
/* Button */
|
|
124
|
+
--color-primary: var(--primary);
|
|
125
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
126
|
+
|
|
127
|
+
--color-secondary: var(--secondary);
|
|
128
|
+
--color-secondary-foreground: var(--secondary-foreground);
|
|
129
|
+
--color-destructive: var(--destructive);
|
|
130
|
+
--color-destructive-foreground: var(--destructive-foreground);
|
|
131
|
+
--color-caution: var(--color-red-500);
|
|
132
|
+
--color-warning: var(--color-amber-500);
|
|
133
|
+
--color-info: var(--color-sky-500);
|
|
134
|
+
--color-success: var(--color-green-500);
|
|
135
|
+
--color-muted: var(--muted);
|
|
136
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
137
|
+
--color-accent: var(--accent);
|
|
138
|
+
--color-accent-foreground: var(--accent-foreground);
|
|
139
|
+
--color-popover: var(--popover);
|
|
140
|
+
--color-popover-foreground: var(--popover-foreground);
|
|
141
|
+
--color-card: var(--card);
|
|
142
|
+
--color-card-foreground: var(--card-foreground);
|
|
143
|
+
--color-sidebar: var(--sidebar-background);
|
|
144
|
+
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
145
|
+
--color-sidebar-primary: var(--sidebar-primary);
|
|
146
|
+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
147
|
+
--color-sidebar-accent: var(--sidebar-accent);
|
|
148
|
+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
149
|
+
--color-sidebar-border: var(--sidebar-border);
|
|
150
|
+
--color-sidebar-ring: var(--sidebar-ring);
|
|
151
|
+
|
|
152
|
+
/* Border */
|
|
153
|
+
--radius-xl: calc(var(--radius) + 4px);
|
|
154
|
+
--radius-lg: var(--radius);
|
|
155
|
+
--radius-md: calc(var(--radius) - 2px);
|
|
156
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
157
|
+
|
|
158
|
+
/* Animations */
|
|
159
|
+
--animate-accordion-down: 0.2s ease-out accordion-down;
|
|
160
|
+
--animate-accordion-up: 0.2s ease-out accordion-up;
|
|
161
|
+
--animate-caret-blink: 1.25s ease-out infinite caret-blink;
|
|
162
|
+
|
|
163
|
+
/* Keyframes */
|
|
164
|
+
@keyframes accordion-down {
|
|
165
|
+
from {
|
|
166
|
+
height: 0;
|
|
167
|
+
}
|
|
168
|
+
to {
|
|
169
|
+
height: var(--bits-accordion-content-height);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
@keyframes accordion-up {
|
|
173
|
+
from {
|
|
174
|
+
height: var(--bits-accordion-content-height);
|
|
175
|
+
}
|
|
176
|
+
to {
|
|
177
|
+
height: 0;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
@keyframes caret-blink {
|
|
181
|
+
0%,
|
|
182
|
+
70%,
|
|
183
|
+
100% {
|
|
184
|
+
opacity: 1;
|
|
185
|
+
}
|
|
186
|
+
20%,
|
|
187
|
+
50% {
|
|
188
|
+
opacity: 0;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
@layer base {
|
|
194
|
+
* {
|
|
195
|
+
@apply border-border;
|
|
196
|
+
}
|
|
197
|
+
body {
|
|
198
|
+
@apply bg-background text-foreground;
|
|
199
|
+
}
|
|
200
|
+
h1 {
|
|
201
|
+
@apply text-2xl font-bold;
|
|
202
|
+
}
|
|
203
|
+
h2 {
|
|
204
|
+
@apply text-xl font-bold;
|
|
205
|
+
}
|
|
206
|
+
h3 {
|
|
207
|
+
@apply text-lg font-bold;
|
|
208
|
+
}
|
|
209
|
+
}
|
package/dist/app.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// See https://kit.svelte.dev/docs/types#app
|
|
2
|
+
// for information about these interfaces
|
|
3
|
+
declare global {
|
|
4
|
+
namespace App {
|
|
5
|
+
// interface Error {}
|
|
6
|
+
// interface Locals {}
|
|
7
|
+
// interface PageData {}
|
|
8
|
+
// interface PageState {}
|
|
9
|
+
// interface Platform {}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {};
|
package/dist/app.html
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en" data-theme="light">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
%sveltekit.head%
|
|
8
|
+
</head>
|
|
9
|
+
<body data-sveltekit-preload-data="hover">
|
|
10
|
+
<div style="display: contents">%sveltekit.body%</div>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
package/dist/icons.css
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if two arrays are equal by comparing their values.
|
|
3
|
+
*/
|
|
4
|
+
export declare function arraysAreEqual<T extends Array<unknown>>(arr1: T, arr2: T): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Splits an array into chunks of a given size.
|
|
7
|
+
* @param arr The array to split.
|
|
8
|
+
* @param size The size of each chunk.
|
|
9
|
+
* @returns An array of arrays, where each sub-array has `size` elements from the original array.
|
|
10
|
+
* @example ```ts
|
|
11
|
+
* const arr = [1, 2, 3, 4, 5, 6, 7, 8];
|
|
12
|
+
* const chunks = chunk(arr, 3);
|
|
13
|
+
* // chunks = [[1, 2, 3], [4, 5, 6], [7, 8]]
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function chunk<T>(arr: T[], size: number): T[][];
|
|
17
|
+
/**
|
|
18
|
+
* Checks if the given index is valid for the given array.
|
|
19
|
+
*
|
|
20
|
+
* @param index - The index to check
|
|
21
|
+
* @param arr - The array to check
|
|
22
|
+
*/
|
|
23
|
+
export declare function isValidIndex(index: number, arr: unknown[]): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Returns the array element after the given index, or undefined for out-of-bounds or empty arrays.
|
|
26
|
+
* @param array the array.
|
|
27
|
+
* @param index the index of the current element.
|
|
28
|
+
* @param loop loop to the beginning of the array if the next index is out of bounds?
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Returns the array element after the given index, or undefined for out-of-bounds or empty arrays.
|
|
32
|
+
* For single-element arrays, returns the element if the index is 0.
|
|
33
|
+
* @param array the array.
|
|
34
|
+
* @param index the index of the current element.
|
|
35
|
+
* @param loop loop to the beginning of the array if the next index is out of bounds?
|
|
36
|
+
*/
|
|
37
|
+
export declare function next<T>(array: T[], index: number, loop?: boolean): T | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Returns the array element prior to the given index, or undefined for out-of-bounds or empty arrays.
|
|
40
|
+
* For single-element arrays, returns the element if the index is 0.
|
|
41
|
+
* @param array the array.
|
|
42
|
+
* @param index the index of the current element.
|
|
43
|
+
* @param loop loop to the end of the array if the previous index is out of bounds?
|
|
44
|
+
*/
|
|
45
|
+
export declare function prev<T>(array: T[], index: number, loop?: boolean): T | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Returns the element some number after the given index. If the target index is out of bounds:
|
|
48
|
+
* - If looping is disabled, the first or last element will be returned.
|
|
49
|
+
* - If looping is enabled, it will wrap around the array.
|
|
50
|
+
* Returns undefined for empty arrays or out-of-bounds initial indices.
|
|
51
|
+
* @param array the array.
|
|
52
|
+
* @param index the index of the current element.
|
|
53
|
+
* @param increment the number of elements to move forward (can be negative).
|
|
54
|
+
* @param loop loop around the array if the target index is out of bounds?
|
|
55
|
+
*/
|
|
56
|
+
export declare function forward<T>(array: T[], index: number, increment: number, loop?: boolean): T | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Returns the element some number before the given index. If the target index is out of bounds:
|
|
59
|
+
* - If looping is disabled, the first or last element will be returned.
|
|
60
|
+
* - If looping is enabled, it will wrap around the array.
|
|
61
|
+
* Returns undefined for empty arrays or out-of-bounds initial indices.
|
|
62
|
+
* @param array the array.
|
|
63
|
+
* @param index the index of the current element.
|
|
64
|
+
* @param decrement the number of elements to move backward (can be negative).
|
|
65
|
+
* @param loop loop around the array if the target index is out of bounds?
|
|
66
|
+
*/
|
|
67
|
+
export declare function backward<T>(array: T[], index: number, decrement: number, loop?: boolean): T | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Finds the next matching item from a list of values based on a search string.
|
|
70
|
+
*
|
|
71
|
+
* This function handles several special cases in typeahead behavior:
|
|
72
|
+
*
|
|
73
|
+
* 1. Space handling: When a search string ends with a space, it handles it specially:
|
|
74
|
+
* - If there's only one match for the text before the space, it ignores the space
|
|
75
|
+
* - If there are multiple matches and the current match already starts with the search prefix
|
|
76
|
+
* followed by a space, it keeps the current match (doesn't change selection on space)
|
|
77
|
+
* - Only after typing characters beyond the space will it move to a more specific match
|
|
78
|
+
*
|
|
79
|
+
* 2. Repeated character handling: If a search consists of repeated characters (e.g., "aaa"),
|
|
80
|
+
* it treats it as a single character for matching purposes
|
|
81
|
+
*
|
|
82
|
+
* 3. Cycling behavior: The function wraps around the values array starting from the current match
|
|
83
|
+
* to find the next appropriate match, creating a cycling selection behavior
|
|
84
|
+
*
|
|
85
|
+
* @param values - Array of string values to search through (e.g., the text content of menu items)
|
|
86
|
+
* @param search - The current search string typed by the user
|
|
87
|
+
* @param currentMatch - The currently selected/matched item, if any
|
|
88
|
+
* @returns The next matching value that should be selected, or undefined if no match is found
|
|
89
|
+
*/
|
|
90
|
+
export declare function getNextMatch(values: string[], search: string, currentMatch?: string): string | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Wraps an array around itself at a given start index
|
|
93
|
+
* Example: `wrapArray(['a', 'b', 'c', 'd'], 2) === ['c', 'd', 'a', 'b']`
|
|
94
|
+
*/
|
|
95
|
+
export declare function wrapArray<T>(array: T[], startIndex: number): T[];
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if two arrays are equal by comparing their values.
|
|
3
|
+
*/
|
|
4
|
+
export function arraysAreEqual(arr1, arr2) {
|
|
5
|
+
if (arr1.length !== arr2.length) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
return arr1.every((value, index) => isEqual(value, arr2[index]));
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A utility function that compares two values for equality.
|
|
12
|
+
*/
|
|
13
|
+
function isEqual(a, b) {
|
|
14
|
+
if (Number.isNaN(a) && Number.isNaN(b)) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
18
|
+
return arraysAreEqual(a, b);
|
|
19
|
+
}
|
|
20
|
+
if (typeof a === "object" && typeof b === "object") {
|
|
21
|
+
return isDeepEqual(a, b);
|
|
22
|
+
}
|
|
23
|
+
return Object.is(a, b);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A utility function that compares two values for deep equality.
|
|
27
|
+
*/
|
|
28
|
+
function isDeepEqual(a, b) {
|
|
29
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const aKeys = Object.keys(a);
|
|
33
|
+
const bKeys = Object.keys(b);
|
|
34
|
+
if (aKeys.length !== bKeys.length) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
for (const key of aKeys) {
|
|
38
|
+
if (!bKeys.includes(key)) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if (!isEqual(a[key], b[key])) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Splits an array into chunks of a given size.
|
|
49
|
+
* @param arr The array to split.
|
|
50
|
+
* @param size The size of each chunk.
|
|
51
|
+
* @returns An array of arrays, where each sub-array has `size` elements from the original array.
|
|
52
|
+
* @example ```ts
|
|
53
|
+
* const arr = [1, 2, 3, 4, 5, 6, 7, 8];
|
|
54
|
+
* const chunks = chunk(arr, 3);
|
|
55
|
+
* // chunks = [[1, 2, 3], [4, 5, 6], [7, 8]]
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export function chunk(arr, size) {
|
|
59
|
+
if (size <= 0) {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
const result = [];
|
|
63
|
+
for (let i = 0; i < arr.length; i += size) {
|
|
64
|
+
result.push(arr.slice(i, i + size));
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Checks if the given index is valid for the given array.
|
|
70
|
+
*
|
|
71
|
+
* @param index - The index to check
|
|
72
|
+
* @param arr - The array to check
|
|
73
|
+
*/
|
|
74
|
+
export function isValidIndex(index, arr) {
|
|
75
|
+
return index >= 0 && index < arr.length;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Returns the array element after the given index, or undefined for out-of-bounds or empty arrays.
|
|
79
|
+
* @param array the array.
|
|
80
|
+
* @param index the index of the current element.
|
|
81
|
+
* @param loop loop to the beginning of the array if the next index is out of bounds?
|
|
82
|
+
*/
|
|
83
|
+
/**
|
|
84
|
+
* Returns the array element after the given index, or undefined for out-of-bounds or empty arrays.
|
|
85
|
+
* For single-element arrays, returns the element if the index is 0.
|
|
86
|
+
* @param array the array.
|
|
87
|
+
* @param index the index of the current element.
|
|
88
|
+
* @param loop loop to the beginning of the array if the next index is out of bounds?
|
|
89
|
+
*/
|
|
90
|
+
export function next(array, index, loop = true) {
|
|
91
|
+
if (array.length === 0 || index < 0 || index >= array.length) {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
if (array.length === 1 && index === 0) {
|
|
95
|
+
return array[0];
|
|
96
|
+
}
|
|
97
|
+
if (index === array.length - 1) {
|
|
98
|
+
return loop ? array[0] : undefined;
|
|
99
|
+
}
|
|
100
|
+
return array[index + 1];
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Returns the array element prior to the given index, or undefined for out-of-bounds or empty arrays.
|
|
104
|
+
* For single-element arrays, returns the element if the index is 0.
|
|
105
|
+
* @param array the array.
|
|
106
|
+
* @param index the index of the current element.
|
|
107
|
+
* @param loop loop to the end of the array if the previous index is out of bounds?
|
|
108
|
+
*/
|
|
109
|
+
export function prev(array, index, loop = true) {
|
|
110
|
+
if (array.length === 0 || index < 0 || index >= array.length) {
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
if (array.length === 1 && index === 0) {
|
|
114
|
+
return array[0];
|
|
115
|
+
}
|
|
116
|
+
if (index === 0) {
|
|
117
|
+
return loop ? array[array.length - 1] : undefined;
|
|
118
|
+
}
|
|
119
|
+
return array[index - 1];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Returns the element some number after the given index. If the target index is out of bounds:
|
|
123
|
+
* - If looping is disabled, the first or last element will be returned.
|
|
124
|
+
* - If looping is enabled, it will wrap around the array.
|
|
125
|
+
* Returns undefined for empty arrays or out-of-bounds initial indices.
|
|
126
|
+
* @param array the array.
|
|
127
|
+
* @param index the index of the current element.
|
|
128
|
+
* @param increment the number of elements to move forward (can be negative).
|
|
129
|
+
* @param loop loop around the array if the target index is out of bounds?
|
|
130
|
+
*/
|
|
131
|
+
export function forward(array, index, increment, loop = true) {
|
|
132
|
+
if (array.length === 0 || index < 0 || index >= array.length) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
let targetIndex = index + increment;
|
|
136
|
+
if (loop) {
|
|
137
|
+
// Ensure positive modulus
|
|
138
|
+
targetIndex = ((targetIndex % array.length) + array.length) % array.length;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
// Clamp to array bounds when not looping
|
|
142
|
+
targetIndex = Math.max(0, Math.min(targetIndex, array.length - 1));
|
|
143
|
+
}
|
|
144
|
+
return array[targetIndex];
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Returns the element some number before the given index. If the target index is out of bounds:
|
|
148
|
+
* - If looping is disabled, the first or last element will be returned.
|
|
149
|
+
* - If looping is enabled, it will wrap around the array.
|
|
150
|
+
* Returns undefined for empty arrays or out-of-bounds initial indices.
|
|
151
|
+
* @param array the array.
|
|
152
|
+
* @param index the index of the current element.
|
|
153
|
+
* @param decrement the number of elements to move backward (can be negative).
|
|
154
|
+
* @param loop loop around the array if the target index is out of bounds?
|
|
155
|
+
*/
|
|
156
|
+
export function backward(array, index, decrement, loop = true) {
|
|
157
|
+
if (array.length === 0 || index < 0 || index >= array.length) {
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
let targetIndex = index - decrement;
|
|
161
|
+
if (loop) {
|
|
162
|
+
// Ensure positive modulus
|
|
163
|
+
targetIndex = ((targetIndex % array.length) + array.length) % array.length;
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
// Clamp to array bounds when not looping
|
|
167
|
+
targetIndex = Math.max(0, Math.min(targetIndex, array.length - 1));
|
|
168
|
+
}
|
|
169
|
+
return array[targetIndex];
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Finds the next matching item from a list of values based on a search string.
|
|
173
|
+
*
|
|
174
|
+
* This function handles several special cases in typeahead behavior:
|
|
175
|
+
*
|
|
176
|
+
* 1. Space handling: When a search string ends with a space, it handles it specially:
|
|
177
|
+
* - If there's only one match for the text before the space, it ignores the space
|
|
178
|
+
* - If there are multiple matches and the current match already starts with the search prefix
|
|
179
|
+
* followed by a space, it keeps the current match (doesn't change selection on space)
|
|
180
|
+
* - Only after typing characters beyond the space will it move to a more specific match
|
|
181
|
+
*
|
|
182
|
+
* 2. Repeated character handling: If a search consists of repeated characters (e.g., "aaa"),
|
|
183
|
+
* it treats it as a single character for matching purposes
|
|
184
|
+
*
|
|
185
|
+
* 3. Cycling behavior: The function wraps around the values array starting from the current match
|
|
186
|
+
* to find the next appropriate match, creating a cycling selection behavior
|
|
187
|
+
*
|
|
188
|
+
* @param values - Array of string values to search through (e.g., the text content of menu items)
|
|
189
|
+
* @param search - The current search string typed by the user
|
|
190
|
+
* @param currentMatch - The currently selected/matched item, if any
|
|
191
|
+
* @returns The next matching value that should be selected, or undefined if no match is found
|
|
192
|
+
*/
|
|
193
|
+
export function getNextMatch(values, search, currentMatch) {
|
|
194
|
+
const lowerSearch = search.toLowerCase();
|
|
195
|
+
if (lowerSearch.endsWith(" ")) {
|
|
196
|
+
const searchWithoutSpace = lowerSearch.slice(0, -1);
|
|
197
|
+
const matchesWithoutSpace = values.filter((value) => value.toLowerCase().startsWith(searchWithoutSpace));
|
|
198
|
+
/**
|
|
199
|
+
* If there's only one match for the prefix without space, we don't
|
|
200
|
+
* watch to match with space.
|
|
201
|
+
*/
|
|
202
|
+
if (matchesWithoutSpace.length <= 1) {
|
|
203
|
+
return getNextMatch(values, searchWithoutSpace, currentMatch);
|
|
204
|
+
}
|
|
205
|
+
const currentMatchLowercase = currentMatch?.toLowerCase();
|
|
206
|
+
/**
|
|
207
|
+
* If the current match already starts with the search prefix and has a space afterward,
|
|
208
|
+
* and the user has only typed up to that space, keep the current match until they
|
|
209
|
+
* disambiguate.
|
|
210
|
+
*/
|
|
211
|
+
if (currentMatchLowercase &&
|
|
212
|
+
currentMatchLowercase.startsWith(searchWithoutSpace) &&
|
|
213
|
+
currentMatchLowercase.charAt(searchWithoutSpace.length) === " " &&
|
|
214
|
+
search.trim() === searchWithoutSpace) {
|
|
215
|
+
return currentMatch;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* With multiple matches, find items that match the full search string with space
|
|
219
|
+
*/
|
|
220
|
+
const spacedMatches = values.filter((value) => value.toLowerCase().startsWith(lowerSearch));
|
|
221
|
+
/**
|
|
222
|
+
* If we found matches with the space, use the first one that's not the current match
|
|
223
|
+
*/
|
|
224
|
+
if (spacedMatches.length > 0) {
|
|
225
|
+
const currentMatchIndex = currentMatch ? values.indexOf(currentMatch) : -1;
|
|
226
|
+
let wrappedMatches = wrapArray(spacedMatches, Math.max(currentMatchIndex, 0));
|
|
227
|
+
// return the first match that is not the current one.
|
|
228
|
+
const nextMatch = wrappedMatches.find((match) => match !== currentMatch);
|
|
229
|
+
// fallback to current if no other is found.
|
|
230
|
+
return nextMatch || currentMatch;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
|
|
234
|
+
const normalizedSearch = isRepeated ? search[0] : search;
|
|
235
|
+
const normalizedLowerSearch = normalizedSearch.toLowerCase();
|
|
236
|
+
const currentMatchIndex = currentMatch ? values.indexOf(currentMatch) : -1;
|
|
237
|
+
let wrappedValues = wrapArray(values, Math.max(currentMatchIndex, 0));
|
|
238
|
+
const excludeCurrentMatch = normalizedSearch.length === 1;
|
|
239
|
+
if (excludeCurrentMatch)
|
|
240
|
+
wrappedValues = wrappedValues.filter((v) => v !== currentMatch);
|
|
241
|
+
const nextMatch = wrappedValues.find((value) => value?.toLowerCase().startsWith(normalizedLowerSearch));
|
|
242
|
+
return nextMatch !== currentMatch ? nextMatch : undefined;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Wraps an array around itself at a given start index
|
|
246
|
+
* Example: `wrapArray(['a', 'b', 'c', 'd'], 2) === ['c', 'd', 'a', 'b']`
|
|
247
|
+
*/
|
|
248
|
+
export function wrapArray(array, startIndex) {
|
|
249
|
+
return array.map((_, index) => array[(startIndex + index) % array.length]);
|
|
250
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|