svelte-ag 0.0.2-dev.81 → 0.0.2-dev.83

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 (163) hide show
  1. package/dist/lib/components/animated/animated.svelte +16 -30
  2. package/dist/lib/components/animated/animated.svelte.d.ts +1 -1
  3. package/dist/lib/components/animated/animated.svelte.d.ts.map +1 -1
  4. package/dist/lib/components/carousel/carousel-content.svelte +5 -24
  5. package/dist/lib/components/carousel/carousel-content.svelte.d.ts +6 -1
  6. package/dist/lib/components/carousel/carousel-content.svelte.d.ts.map +1 -1
  7. package/dist/lib/components/carousel/carousel-dots.svelte +1 -3
  8. package/dist/lib/components/carousel/carousel-dots.svelte.d.ts +6 -1
  9. package/dist/lib/components/carousel/carousel-dots.svelte.d.ts.map +1 -1
  10. package/dist/lib/components/carousel/carousel-item.svelte.d.ts +6 -1
  11. package/dist/lib/components/carousel/carousel-item.svelte.d.ts.map +1 -1
  12. package/dist/lib/components/carousel/carousel-next.svelte +21 -9
  13. package/dist/lib/components/carousel/carousel-next.svelte.d.ts +21 -1
  14. package/dist/lib/components/carousel/carousel-next.svelte.d.ts.map +1 -1
  15. package/dist/lib/components/carousel/carousel-previous.svelte +21 -9
  16. package/dist/lib/components/carousel/carousel-previous.svelte.d.ts +21 -1
  17. package/dist/lib/components/carousel/carousel-previous.svelte.d.ts.map +1 -1
  18. package/dist/lib/components/carousel/carousel.svelte +21 -1
  19. package/dist/lib/components/carousel/carousel.svelte.d.ts +2 -1
  20. package/dist/lib/components/carousel/carousel.svelte.d.ts.map +1 -1
  21. package/dist/lib/components/carousel/context.d.ts +1 -0
  22. package/dist/lib/components/carousel/context.d.ts.map +1 -1
  23. package/dist/lib/components/dnd/Droppable.svelte.d.ts +8 -1
  24. package/dist/lib/components/dnd/Droppable.svelte.d.ts.map +1 -1
  25. package/dist/lib/components/dnd/dnd-context.svelte.d.ts +1 -1
  26. package/dist/lib/components/dnd/dnd-drag-overlay.svelte.d.ts +1 -1
  27. package/dist/lib/components/dnd/dnd-drag-placeholder.svelte.d.ts +1 -1
  28. package/dist/lib/components/dnd/dnd-drag-placeholder.svelte.d.ts.map +1 -1
  29. package/dist/lib/components/dnd/dnd-draghandle.svelte.d.ts +1 -1
  30. package/dist/lib/components/dnd/dnd-draghandle.svelte.d.ts.map +1 -1
  31. package/dist/lib/components/dnd/dnd-overlay.svelte.d.ts +11 -3
  32. package/dist/lib/components/dnd/dnd-overlay.svelte.d.ts.map +1 -1
  33. package/dist/lib/components/dnd/dnd-sortable-context.svelte.d.ts +1 -1
  34. package/dist/lib/components/dnd/dnd-sortable-context.svelte.d.ts.map +1 -1
  35. package/dist/lib/components/dnd/dnd-sortable-item.svelte.d.ts +1 -1
  36. package/dist/lib/components/dnd/dnd-sortable-item.svelte.d.ts.map +1 -1
  37. package/dist/lib/components/dnd/example.svelte.d.ts +1 -1
  38. package/dist/lib/components/dnd/example.svelte.d.ts.map +1 -1
  39. package/dist/lib/components/form/form-button.svelte.d.ts +2 -1
  40. package/dist/lib/components/form/form-button.svelte.d.ts.map +1 -1
  41. package/dist/lib/components/form/form-description.svelte.d.ts +2 -1
  42. package/dist/lib/components/form/form-description.svelte.d.ts.map +1 -1
  43. package/dist/lib/components/form/form-element-field.svelte.d.ts +1 -1
  44. package/dist/lib/components/form/form-field-errors.svelte.d.ts +1 -1
  45. package/dist/lib/components/form/form-field-errors.svelte.d.ts.map +1 -1
  46. package/dist/lib/components/form/form-field.svelte.d.ts +1 -1
  47. package/dist/lib/components/form/form-fieldset.svelte.d.ts +1 -1
  48. package/dist/lib/components/form/form-label.svelte.d.ts +2 -1
  49. package/dist/lib/components/form/form-label.svelte.d.ts.map +1 -1
  50. package/dist/lib/components/form/form-legend.svelte.d.ts +2 -1
  51. package/dist/lib/components/form/form-legend.svelte.d.ts.map +1 -1
  52. package/dist/lib/components/form/form.svelte.d.ts +6 -1
  53. package/dist/lib/components/form/form.svelte.d.ts.map +1 -1
  54. package/dist/lib/components/gallery/gallery.svelte +67 -0
  55. package/dist/lib/components/gallery/gallery.svelte.d.ts +35 -0
  56. package/dist/lib/components/gallery/gallery.svelte.d.ts.map +1 -0
  57. package/dist/lib/components/gallery/index.d.ts +3 -0
  58. package/dist/lib/components/gallery/index.d.ts.map +1 -0
  59. package/dist/lib/components/gallery/index.js +2 -0
  60. package/dist/lib/components/gallery/utils.d.ts +17 -0
  61. package/dist/lib/components/gallery/utils.d.ts.map +1 -0
  62. package/dist/lib/components/gallery/utils.js +94 -0
  63. package/dist/lib/components/gradient/Gradient.svelte +45 -51
  64. package/dist/lib/components/gradient/Gradient.svelte.d.ts +10 -1
  65. package/dist/lib/components/gradient/Gradient.svelte.d.ts.map +1 -1
  66. package/dist/lib/components/gradient/gradient.frag +43 -0
  67. package/dist/lib/components/safe/safe.svelte.d.ts +1 -1
  68. package/dist/lib/components/safe/safe.svelte.d.ts.map +1 -1
  69. package/dist/lib/components/search/combinations/searchPopover.svelte.d.ts +11 -1
  70. package/dist/lib/components/search/combinations/searchPopover.svelte.d.ts.map +1 -1
  71. package/dist/lib/components/search/components/search-empty.svelte.d.ts +2 -1
  72. package/dist/lib/components/search/components/search-empty.svelte.d.ts.map +1 -1
  73. package/dist/lib/components/search/components/search-input.svelte.d.ts +2 -1
  74. package/dist/lib/components/search/components/search-input.svelte.d.ts.map +1 -1
  75. package/dist/lib/components/search/components/search-list.svelte.d.ts +2 -1
  76. package/dist/lib/components/search/components/search-list.svelte.d.ts.map +1 -1
  77. package/dist/lib/components/search/components/search-pagnation.svelte.d.ts +6 -1
  78. package/dist/lib/components/search/components/search-pagnation.svelte.d.ts.map +1 -1
  79. package/dist/lib/components/search/components/search.svelte.d.ts +2 -1
  80. package/dist/lib/components/search/components/search.svelte.d.ts.map +1 -1
  81. package/dist/lib/components/sidebar/sidebar-content.svelte.d.ts +3 -1
  82. package/dist/lib/components/sidebar/sidebar-content.svelte.d.ts.map +1 -1
  83. package/dist/lib/components/sidebar/sidebar-footer.svelte.d.ts +3 -1
  84. package/dist/lib/components/sidebar/sidebar-footer.svelte.d.ts.map +1 -1
  85. package/dist/lib/components/sidebar/sidebar-group-action.svelte.d.ts +9 -1
  86. package/dist/lib/components/sidebar/sidebar-group-action.svelte.d.ts.map +1 -1
  87. package/dist/lib/components/sidebar/sidebar-group-content.svelte.d.ts +3 -1
  88. package/dist/lib/components/sidebar/sidebar-group-content.svelte.d.ts.map +1 -1
  89. package/dist/lib/components/sidebar/sidebar-group-label.svelte.d.ts +9 -1
  90. package/dist/lib/components/sidebar/sidebar-group-label.svelte.d.ts.map +1 -1
  91. package/dist/lib/components/sidebar/sidebar-group.svelte.d.ts +3 -1
  92. package/dist/lib/components/sidebar/sidebar-group.svelte.d.ts.map +1 -1
  93. package/dist/lib/components/sidebar/sidebar-header.svelte.d.ts +3 -1
  94. package/dist/lib/components/sidebar/sidebar-header.svelte.d.ts.map +1 -1
  95. package/dist/lib/components/sidebar/sidebar-input.svelte.d.ts +9 -1
  96. package/dist/lib/components/sidebar/sidebar-input.svelte.d.ts.map +1 -1
  97. package/dist/lib/components/sidebar/sidebar-inset.svelte.d.ts +3 -1
  98. package/dist/lib/components/sidebar/sidebar-inset.svelte.d.ts.map +1 -1
  99. package/dist/lib/components/sidebar/sidebar-menu-action.svelte.d.ts +10 -1
  100. package/dist/lib/components/sidebar/sidebar-menu-action.svelte.d.ts.map +1 -1
  101. package/dist/lib/components/sidebar/sidebar-menu-badge.svelte.d.ts +3 -1
  102. package/dist/lib/components/sidebar/sidebar-menu-badge.svelte.d.ts.map +1 -1
  103. package/dist/lib/components/sidebar/sidebar-menu-button.svelte.d.ts +20 -1
  104. package/dist/lib/components/sidebar/sidebar-menu-button.svelte.d.ts.map +1 -1
  105. package/dist/lib/components/sidebar/sidebar-menu-item.svelte.d.ts +3 -1
  106. package/dist/lib/components/sidebar/sidebar-menu-item.svelte.d.ts.map +1 -1
  107. package/dist/lib/components/sidebar/sidebar-menu-skeleton.svelte.d.ts +6 -1
  108. package/dist/lib/components/sidebar/sidebar-menu-skeleton.svelte.d.ts.map +1 -1
  109. package/dist/lib/components/sidebar/sidebar-menu-sub-button.svelte.d.ts +11 -1
  110. package/dist/lib/components/sidebar/sidebar-menu-sub-button.svelte.d.ts.map +1 -1
  111. package/dist/lib/components/sidebar/sidebar-menu-sub-item.svelte.d.ts +3 -1
  112. package/dist/lib/components/sidebar/sidebar-menu-sub-item.svelte.d.ts.map +1 -1
  113. package/dist/lib/components/sidebar/sidebar-menu-sub.svelte.d.ts +3 -1
  114. package/dist/lib/components/sidebar/sidebar-menu-sub.svelte.d.ts.map +1 -1
  115. package/dist/lib/components/sidebar/sidebar-menu.svelte.d.ts +3 -1
  116. package/dist/lib/components/sidebar/sidebar-menu.svelte.d.ts.map +1 -1
  117. package/dist/lib/components/sidebar/sidebar-provider.svelte.d.ts +10 -1
  118. package/dist/lib/components/sidebar/sidebar-provider.svelte.d.ts.map +1 -1
  119. package/dist/lib/components/sidebar/sidebar-rail.svelte.d.ts +6 -1
  120. package/dist/lib/components/sidebar/sidebar-rail.svelte.d.ts.map +1 -1
  121. package/dist/lib/components/sidebar/sidebar-separator.svelte.d.ts +1 -1
  122. package/dist/lib/components/sidebar/sidebar-separator.svelte.d.ts.map +1 -1
  123. package/dist/lib/components/sidebar/sidebar-trigger.svelte.d.ts +7 -1
  124. package/dist/lib/components/sidebar/sidebar-trigger.svelte.d.ts.map +1 -1
  125. package/dist/lib/components/sidebar/sidebar.svelte.d.ts +8 -1
  126. package/dist/lib/components/sidebar/sidebar.svelte.d.ts.map +1 -1
  127. package/dist/lib/components/utilities/arrow/arrow.svelte.d.ts +1 -1
  128. package/dist/lib/components/utilities/arrow/arrow.svelte.d.ts.map +1 -1
  129. package/dist/lib/components/utilities/floating-layer/components/floating-layer-anchor.svelte.d.ts +2 -1
  130. package/dist/lib/components/utilities/floating-layer/components/floating-layer-anchor.svelte.d.ts.map +1 -1
  131. package/dist/lib/components/utilities/floating-layer/components/floating-layer-arrow.svelte.d.ts +1 -1
  132. package/dist/lib/components/utilities/floating-layer/components/floating-layer-arrow.svelte.d.ts.map +1 -1
  133. package/dist/lib/components/utilities/floating-layer/components/floating-layer-content-static.svelte.d.ts +11 -1
  134. package/dist/lib/components/utilities/floating-layer/components/floating-layer-content-static.svelte.d.ts.map +1 -1
  135. package/dist/lib/components/utilities/floating-layer/components/floating-layer-content.svelte.d.ts +2 -1
  136. package/dist/lib/components/utilities/floating-layer/components/floating-layer-content.svelte.d.ts.map +1 -1
  137. package/dist/lib/components/utilities/floating-layer/components/floating-layer.svelte.d.ts +5 -1
  138. package/dist/lib/components/utilities/floating-layer/components/floating-layer.svelte.d.ts.map +1 -1
  139. package/dist/lib/styles/underline.css +10 -0
  140. package/dist/lib/utils/glsl.d.ts +4 -0
  141. package/dist/lib/utils/glsl.d.ts.map +1 -0
  142. package/dist/lib/utils/glsl.js +1 -0
  143. package/dist/lib/utils/index.d.ts +1 -0
  144. package/dist/lib/utils/index.d.ts.map +1 -1
  145. package/dist/lib/utils/index.js +1 -0
  146. package/dist/routes/+layout.svelte.d.ts +11 -3
  147. package/dist/routes/+layout.svelte.d.ts.map +1 -1
  148. package/package.json +3 -2
  149. package/src/lib/components/animated/animated.svelte +16 -30
  150. package/src/lib/components/carousel/carousel-content.svelte +5 -24
  151. package/src/lib/components/carousel/carousel-dots.svelte +1 -3
  152. package/src/lib/components/carousel/carousel-next.svelte +21 -9
  153. package/src/lib/components/carousel/carousel-previous.svelte +21 -9
  154. package/src/lib/components/carousel/carousel.svelte +21 -1
  155. package/src/lib/components/carousel/context.ts +1 -0
  156. package/src/lib/components/gallery/gallery.svelte +67 -0
  157. package/src/lib/components/gallery/index.ts +3 -0
  158. package/src/lib/components/gallery/utils.ts +103 -0
  159. package/src/lib/components/gradient/Gradient.svelte +45 -51
  160. package/src/lib/components/gradient/gradient.frag +43 -0
  161. package/src/lib/styles/underline.css +10 -0
  162. package/src/lib/utils/glsl.ts +3 -0
  163. package/src/lib/utils/index.ts +1 -0
@@ -1,8 +1,16 @@
1
1
  export default Layout;
2
- type Layout = SvelteComponent<Record<string, any>, Record<string, any>, Record<string, any>> & {
2
+ type Layout = SvelteComponent<{
3
+ [x: string]: never;
4
+ }, {
5
+ [evt: string]: CustomEvent<any>;
6
+ }, {}> & {
3
7
  $$bindings?: string | undefined;
4
- } & Record<string, any>;
5
- declare const Layout: $$__sveltets_2_IsomorphicComponent<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, string>;
8
+ };
9
+ declare const Layout: $$__sveltets_2_IsomorphicComponent<{
10
+ [x: string]: never;
11
+ }, {
12
+ [evt: string]: CustomEvent<any>;
13
+ }, {}, {}, string>;
6
14
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
7
15
  new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
8
16
  $$bindings?: Bindings;
@@ -1 +1 @@
1
- {"version":3,"file":"+layout.svelte.d.ts","sourceRoot":"","sources":["../../src/routes/+layout.svelte.js"],"names":[],"mappings":";;;;AAcA,qJAAkH;6CATrE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,OAAO,OAAO,QAAQ;IAC3L,cAAc,OAAO,QAAQ,EAAE,2BAA2B,CAAC,KAAK,CAAC,GAAG,OAAO,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC;IACjK,WAAW,OAAO,SAAS;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAA;KAAC,GAAG,OAAO,GAAG;QAAE,IAAI,CAAC,EAAE,GAAG,CAAC;QAAC,GAAG,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IACtG,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"+layout.svelte.d.ts","sourceRoot":"","sources":["../../src/routes/+layout.svelte.js"],"names":[],"mappings":";;;;;;;;AAcA;;;;mBAAkH;6CATrE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,OAAO,OAAO,QAAQ;IAC3L,cAAc,OAAO,QAAQ,EAAE,2BAA2B,CAAC,KAAK,CAAC,GAAG,OAAO,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC;IACjK,WAAW,OAAO,SAAS;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAA;KAAC,GAAG,OAAO,GAAG;QAAE,IAAI,CAAC,EAAE,GAAG,CAAC;QAAC,GAAG,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IACtG,eAAe,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "svelte-ag",
3
3
  "description": "Useful svelte components",
4
- "version": "0.0.2-dev.81",
4
+ "version": "0.0.2-dev.83",
5
5
  "author": "Alexander Hornung",
6
6
  "bugs": "https://github.com/ageorgeh/cms/issues",
7
7
  "dependencies": {
@@ -16,6 +16,7 @@
16
16
  "@dnd-kit-svelte/utilities": "^0.0.8",
17
17
  "embla-carousel-svelte": "^8.6.0",
18
18
  "svader": "^0.5.4",
19
+ "vite-plugin-glsl": "1.4.2",
19
20
  "runed": "^0.26.0",
20
21
  "bits-ui": "^1.5.3",
21
22
  "@rollup/pluginutils": "^5.1.4",
@@ -23,7 +24,7 @@
23
24
  "formsnap": "2.0.1",
24
25
  "valibot": "1.1.0",
25
26
  "radash": "12.1.0",
26
- "ts-ag": "0.0.1-dev.2"
27
+ "ts-ag": "0.0.1-dev.3"
27
28
  },
28
29
  "peerDependencies": {
29
30
  "svelte": "^5.28.2",
@@ -74,47 +74,30 @@
74
74
  children
75
75
  }: Props = $props();
76
76
 
77
- let animationComplete = $state<boolean>(true);
77
+ let animationComplete = $state<boolean>(disableInitialAnimation);
78
78
  let isInitialRender = $state(true);
79
79
  //svelte-ignore non_reactive_update
80
80
  let growHeightElement: HTMLDivElement | undefined;
81
81
 
82
82
  function handleAnimationEnd(e: AnimationEvent) {
83
- if (!visible) {
84
- animationComplete = true;
85
- } else {
86
- animationComplete = false;
87
- }
88
-
89
- // Mark initial render as complete after animation
90
- isInitialRender = false;
91
-
92
- if (onAnimationComplete) {
93
- onAnimationComplete(visible);
94
- }
83
+ animationComplete = true;
84
+ onAnimationComplete?.(visible);
95
85
  }
96
86
 
97
87
  // Reset animation state when visibility changes
98
88
  watch(
99
89
  () => visible,
100
- (newValue) => {
101
- if (newValue) {
102
- animationComplete = false;
103
- }
90
+ () => {
91
+ isInitialRender = false;
92
+ animationComplete = false;
104
93
  },
105
- { lazy: false }
94
+ // Dont run on mount
95
+ { lazy: true }
106
96
  );
107
97
 
108
- // Set initial render to false when component mounts if disableInitialAnimation is true
109
- $effect(() => {
110
- if (disableInitialAnimation) {
111
- isInitialRender = false;
112
- }
113
- });
114
-
115
98
  const dataState = $derived(visible ? 'visible' : 'hidden');
116
99
  // Skip animation classes on initial render when disableInitialAnimation is true
117
- const shouldApplyAnimationClasses = $derived(!isInitialRender || !disableInitialAnimation);
100
+ const shouldApplyAnimationClasses = $derived(!(isInitialRender && disableInitialAnimation));
118
101
 
119
102
  // Duration in ms for animations
120
103
  const durationMap = {
@@ -210,11 +193,14 @@
210
193
  }
211
194
  }
212
195
 
213
- $effect(() => {
214
- if (animation === 'growHeight') {
215
- animateHeight();
196
+ watch(
197
+ () => visible,
198
+ () => {
199
+ if (animation === 'growHeight') {
200
+ animateHeight();
201
+ }
216
202
  }
217
- });
203
+ );
218
204
  </script>
219
205
 
220
206
  {#if animation === 'growHeight'}
@@ -1,5 +1,4 @@
1
1
  <script lang="ts">
2
- import emblaCarouselSvelte from 'embla-carousel-svelte';
3
2
  import type { WithElementRef } from 'bits-ui';
4
3
  import type { HTMLAttributes } from 'svelte/elements';
5
4
  import { getEmblaContext } from './context.js';
@@ -14,31 +13,13 @@
14
13
  }: WithElementRef<HTMLAttributes<HTMLDivElement>> & { symbol?: symbol } = $props();
15
14
 
16
15
  const emblaCtx = getEmblaContext('<Carousel.Content/>', symbol);
17
-
18
- // console.log(emblaCtx);
19
16
  </script>
20
17
 
21
- <!-- svelte-ignore event_directive_deprecated -->
22
18
  <div
23
- class="overflow-hidden"
24
- use:emblaCarouselSvelte={{
25
- options: {
26
- container: `[data-embla-container="${symbol?.description ?? 'default'}"]`,
27
- loop: true,
28
- slides: `[data-embla-slide="${symbol?.description ?? 'default'}"]`,
29
- ...emblaCtx.options,
30
- axis: emblaCtx.orientation === 'horizontal' ? 'x' : 'y'
31
- },
32
- plugins: emblaCtx.plugins
33
- }}
34
- on:emblaInit={emblaCtx.onInit}
19
+ bind:this={ref}
20
+ class={cn('flex', emblaCtx.orientation === 'horizontal' ? '-ml-4' : `-mt-4 flex-col`, className)}
21
+ data-embla-container={symbol?.description ?? 'default'}
22
+ {...restProps}
35
23
  >
36
- <div
37
- bind:this={ref}
38
- class={cn('flex', emblaCtx.orientation === 'horizontal' ? '-ml-4' : `-mt-4 flex-col`, className)}
39
- data-embla-container={symbol?.description}
40
- {...restProps}
41
- >
42
- {@render children?.()}
43
- </div>
24
+ {@render children?.()}
44
25
  </div>
@@ -7,13 +7,11 @@
7
7
  let {
8
8
  ref = $bindable(null),
9
9
  class: className,
10
- variant = 'outline',
11
- size = 'icon',
12
10
  symbol = undefined,
13
11
  ...restProps
14
12
  }: WithoutChildren<Props> & { symbol?: symbol } = $props();
15
13
 
16
- const emblaCtx = getEmblaContext('<Carousel.Next/>', symbol);
14
+ const emblaCtx = getEmblaContext('<Carousel.Dots/>', symbol);
17
15
  </script>
18
16
 
19
17
  <div class={cn('flex justify-center gap-1.5', className)}>
@@ -4,31 +4,43 @@
4
4
  import { getEmblaContext } from './context.js';
5
5
  import { cn } from '$shadcn/utils.js';
6
6
  import { Button, type Props } from '$shadcn/button/index.js';
7
+ import { tv, type VariantProps } from 'tailwind-variants';
7
8
 
8
9
  let {
9
10
  ref = $bindable(null),
10
11
  class: className,
11
12
  variant = 'outline',
12
13
  size = 'icon',
14
+ position = 'default',
13
15
  symbol = undefined,
16
+ onclick,
14
17
  ...restProps
15
- }: WithoutChildren<Props> & { symbol?: symbol } = $props();
18
+ }: WithoutChildren<Props> & { symbol?: symbol; position: VariantProps<typeof variants>['variant'] } = $props();
16
19
 
17
20
  const emblaCtx = getEmblaContext('<Carousel.Next/>', symbol);
21
+ const variants = tv({
22
+ base: 'size-8 touch-manipulation rounded-full',
23
+ variants: {
24
+ variant: {
25
+ default:
26
+ emblaCtx.orientation === 'horizontal'
27
+ ? 'top-1/2 -right-12 -translate-y-1/2'
28
+ : '-bottom-12 left-1/2 -translate-x-1/2 rotate-90',
29
+ flex: ``
30
+ }
31
+ }
32
+ });
18
33
  </script>
19
34
 
20
35
  <Button
21
36
  {variant}
22
37
  {size}
23
- class={cn(
24
- 'absolute size-8 touch-manipulation rounded-full',
25
- emblaCtx.orientation === 'horizontal'
26
- ? 'top-1/2 -right-12 -translate-y-1/2'
27
- : '-bottom-12 left-1/2 -translate-x-1/2 rotate-90',
28
- className
29
- )}
38
+ class={cn(variants({ variant: position }), className)}
30
39
  disabled={!emblaCtx.canScrollNext}
31
- onclick={emblaCtx.scrollNext}
40
+ onclick={(e) => {
41
+ emblaCtx.scrollNext();
42
+ onclick?.(e);
43
+ }}
32
44
  onkeydown={emblaCtx.handleKeyDown}
33
45
  bind:ref
34
46
  {...restProps}
@@ -4,31 +4,43 @@
4
4
  import { getEmblaContext } from './context.js';
5
5
  import { cn } from '$shadcn/utils.js';
6
6
  import { Button, type Props } from '$shadcn/button/index.js';
7
+ import { type VariantProps, tv } from 'tailwind-variants';
7
8
 
8
9
  let {
9
10
  ref = $bindable(null),
10
11
  class: className,
11
12
  variant = 'outline',
12
13
  size = 'icon',
14
+ position = 'default',
13
15
  symbol = undefined,
16
+ onclick,
14
17
  ...restProps
15
- }: WithoutChildren<Props> & { symbol?: symbol } = $props();
18
+ }: WithoutChildren<Props> & { symbol?: symbol; position: VariantProps<typeof variants>['variant'] } = $props();
16
19
 
17
20
  const emblaCtx = getEmblaContext('<Carousel.Previous/>', symbol);
21
+ const variants = tv({
22
+ base: 'size-8 touch-manipulation rounded-full',
23
+ variants: {
24
+ variant: {
25
+ default:
26
+ emblaCtx.orientation === 'horizontal'
27
+ ? 'top-1/2 -left-12 -translate-y-1/2'
28
+ : '-top-12 left-1/2 -translate-x-1/2 rotate-90',
29
+ flex: ``
30
+ }
31
+ }
32
+ });
18
33
  </script>
19
34
 
20
35
  <Button
21
36
  {variant}
22
37
  {size}
23
- class={cn(
24
- 'absolute size-8 touch-manipulation rounded-full',
25
- emblaCtx.orientation === 'horizontal'
26
- ? 'top-1/2 -left-12 -translate-y-1/2'
27
- : '-top-12 left-1/2 -translate-x-1/2 rotate-90',
28
- className
29
- )}
38
+ class={cn(variants({ variant: position }), className)}
30
39
  disabled={!emblaCtx.canScrollPrev}
31
- onclick={emblaCtx.scrollPrev}
40
+ onclick={(e) => {
41
+ emblaCtx.scrollPrev();
42
+ onclick?.(e);
43
+ }}
32
44
  onkeydown={emblaCtx.handleKeyDown}
33
45
  {...restProps}
34
46
  bind:ref
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { type CarouselAPI, type CarouselProps, type EmblaContext, setEmblaContext } from './context.js';
3
3
  import { cn } from '$shadcn/utils.js';
4
+ import emblaCarouselSvelte from 'embla-carousel-svelte';
4
5
 
5
6
  let {
6
7
  opts = {},
@@ -11,6 +12,7 @@
11
12
  children,
12
13
  pointerdown,
13
14
  pointerup,
15
+ onSelect: a_onSelect,
14
16
  symbol = undefined,
15
17
  ...restProps
16
18
  }: CarouselProps = $props();
@@ -48,6 +50,7 @@
48
50
  carouselState.canScrollPrev = api.canScrollPrev();
49
51
  carouselState.canScrollNext = api.canScrollNext();
50
52
  carouselState.selectedIndex = api.selectedScrollSnap();
53
+ a_onSelect?.(api);
51
54
  }
52
55
 
53
56
  function reinit(api: CarouselAPI) {
@@ -98,6 +101,23 @@
98
101
  });
99
102
  </script>
100
103
 
101
- <div class={cn('relative', className)} role="region" aria-roledescription="carousel" {...restProps}>
104
+ <!-- svelte-ignore event_directive_deprecated -->
105
+ <div
106
+ class={cn('relative', className)}
107
+ role="region"
108
+ aria-roledescription="carousel"
109
+ {...restProps}
110
+ use:emblaCarouselSvelte={{
111
+ options: {
112
+ container: `[data-embla-container="${symbol?.description ?? 'default'}"]`,
113
+ loop: true,
114
+ slides: `[data-embla-slide="${symbol?.description ?? 'default'}"]`,
115
+ ...carouselState.options,
116
+ axis: carouselState.orientation === 'horizontal' ? 'x' : 'y'
117
+ },
118
+ plugins: carouselState.plugins
119
+ }}
120
+ on:emblaInit={carouselState.onInit}
121
+ >
102
122
  {@render children?.()}
103
123
  </div>
@@ -25,6 +25,7 @@ export type CarouselProps = {
25
25
  setApi?: (api: CarouselAPI | undefined) => void;
26
26
  pointerdown?: (api: CarouselAPI) => void;
27
27
  pointerup?: (api: CarouselAPI) => void;
28
+ onSelect?: (api: CarouselAPI) => void;
28
29
  orientation?: 'horizontal' | 'vertical';
29
30
  } & WithElementRef<HTMLAttributes<HTMLDivElement>>;
30
31
 
@@ -0,0 +1,67 @@
1
+ <!-- src/lib/components/pages/GALLERY.svelte -->
2
+ <script lang="ts" generics="Item">
3
+ import { onMount, type Snippet } from 'svelte';
4
+ import { containerSize, cn, type HTMLDivAttributes } from '$utils/index.js';
5
+ import type { Size } from './utils.js';
6
+ import { packGrid, styleForSize } from './utils.js';
7
+ import type { WithElementRef } from 'bits-ui';
8
+
9
+ let {
10
+ images = $bindable(),
11
+ ref = $bindable(),
12
+ class: className,
13
+ child,
14
+ ...restProps
15
+ }: WithElementRef<HTMLDivAttributes> & {
16
+ images: { large: Item[]; medium: Item[]; small: Item[] };
17
+ child: Snippet<[{ props: { style: string }; item: Item; index: number }]>;
18
+ } = $props();
19
+
20
+ type ItemWithSize = Item & { size: Size };
21
+
22
+ let numCols = $state(4);
23
+
24
+ onMount(() => {
25
+ containerSize((size) => {
26
+ let cols = 2;
27
+ if (size.width > 640) {
28
+ cols = 3;
29
+ }
30
+ if (size.width > 768) {
31
+ cols = 4;
32
+ }
33
+ numCols = cols;
34
+ });
35
+ });
36
+
37
+ let large = $derived(images.large.map((img) => ({ ...img, size: 'L' as Size })));
38
+ let medium = $derived(images.medium.map((img) => ({ ...img, size: 'M' as Size })));
39
+ let small = $derived(images.small.map((img) => ({ ...img, size: 'S' as Size })));
40
+
41
+ // $effect.pre(() => {
42
+ // allItems = packGrid($state.snapshot(small), $state.snapshot(medium), $state.snapshot(large), numCols);
43
+ // });
44
+
45
+ let allItems = $derived(
46
+ packGrid($state.snapshot(small), $state.snapshot(medium), $state.snapshot(large), numCols)
47
+ ) as ItemWithSize[];
48
+
49
+ export { allItems };
50
+ </script>
51
+
52
+ <div
53
+ bind:this={ref}
54
+ class={cn(
55
+ `
56
+ @vsm:grid-cols-3
57
+ @vmd:grid-cols-4
58
+ grid grid-cols-2 gap-2
59
+ `,
60
+ className
61
+ )}
62
+ {...restProps}
63
+ >
64
+ {#each allItems as o, i (i)}
65
+ {@render child({ props: { style: styleForSize(o.size) }, item: o, index: i })}
66
+ {/each}
67
+ </div>
@@ -0,0 +1,3 @@
1
+ import Gallery from './gallery.svelte';
2
+
3
+ export { Gallery };
@@ -0,0 +1,103 @@
1
+ export type Size = 'S' | 'M' | 'L';
2
+
3
+ const w = { S: 1, M: 1, L: 2 };
4
+ const h = { S: 1, M: 2, L: 3 };
5
+
6
+ function imageSize(size: Size) {
7
+ return [w[size], h[size]];
8
+ }
9
+
10
+ /**
11
+ * Gets the style statement for a particular size
12
+ */
13
+ export function styleForSize(size: Size) {
14
+ return `grid-column: span ${imageSize(size)[0]}; grid-row: span ${imageSize(size)[1]};`;
15
+ }
16
+
17
+ /**
18
+ * Packs images of different sizes into a grid layout
19
+ * @param small Array of small-sized items to place in grid
20
+ * @param medium Array of medium-sized items to place in grid
21
+ * @param large Array of large-sized items to place in grid
22
+ * @param cols Number of columns in the grid
23
+ * @returns Array of items arranged in optimal grid order
24
+ */
25
+ export function packGrid<Item extends { size: Size }>(small: Item[], medium: Item[], large: Item[], cols = 4): Item[] {
26
+ const result: Item[] = [];
27
+ // Create a 2D grid to track occupied cells (32 rows max, adjustable column width)
28
+ const occ: boolean[][] = Array.from({ length: 32 }, () => Array(cols).fill(false));
29
+
30
+ let r = 0, // Current row
31
+ c = 0, // Current column
32
+ lastSize: Size | null = null; // Track last placed item size for variety
33
+
34
+ // Check if we still have any items to place
35
+ const hasStock = () => small.length || medium.length || large.length;
36
+
37
+ // Organize items by size for easy access
38
+ const pool = { S: small, M: medium, L: large } as const;
39
+
40
+ // Dynamic preference ordering strategy for visual variety
41
+ // After placing one size, prefer different sizes next for better distribution
42
+ const pref = (prev: Size | null): Size[] => {
43
+ if (prev === 'L') return ['S', 'M', 'L']; // After large, prefer small
44
+ if (prev === 'S') return ['L', 'M', 'S']; // After small, prefer large
45
+ if (prev === 'M') return ['S', 'L', 'M']; // After medium, prefer small
46
+ return ['L', 'M', 'S']; // Initial preference (start with large items)
47
+ };
48
+
49
+ while (hasStock()) {
50
+ // Skip already occupied cells
51
+ while (occ[r]?.[c]) {
52
+ // Move to next row if end of column reached
53
+ if (++c === cols) {
54
+ c = 0;
55
+ r++;
56
+ }
57
+ }
58
+
59
+ // Check if item of given size can fit at current position
60
+ const fits = (size: Size) => {
61
+ // Check if item would extend beyond right edge
62
+ if (c + w[size] > cols) return false;
63
+ // Check if all required cells are unoccupied
64
+ for (let y = 0; y < h[size]; y++) for (let x = 0; x < w[size]; x++) if (occ[r + y]?.[c + x]) return false;
65
+ return true;
66
+ };
67
+
68
+ let chosen: Item | undefined;
69
+
70
+ // Try to place items in preferred size order
71
+ for (const sz of pref(lastSize)) {
72
+ if (pool[sz].length && fits(sz)) {
73
+ chosen = pool[sz].shift()!;
74
+ break;
75
+ }
76
+ }
77
+
78
+ if (!chosen) {
79
+ // If no item fits at current position, move to next cell
80
+ if (++c === cols) {
81
+ c = 0;
82
+ r++;
83
+ }
84
+ continue;
85
+ }
86
+
87
+ // Mark grid cells as occupied based on item dimensions
88
+ const sx = w[chosen.size],
89
+ sy = h[chosen.size];
90
+ for (let y = 0; y < sy; y++) for (let x = 0; x < sx; x++) occ[r + y][c + x] = true;
91
+
92
+ result.push(chosen);
93
+ lastSize = chosen.size; // Remember this size for next preference calculation
94
+ c += sx; // Move cursor past the placed item
95
+ // Move to next row if needed
96
+ if (c === cols) {
97
+ c = 0;
98
+ r++;
99
+ }
100
+ }
101
+
102
+ return result;
103
+ }
@@ -1,66 +1,60 @@
1
1
  <script lang="ts">
2
2
  import { WebGlShader } from 'svader';
3
+ import type { Vec2, Vec4 } from '$utils/glsl.js';
4
+ import fragment from './gradient.frag?raw';
5
+ import { cn } from '$utils';
6
+ import type { BitsPrimitiveDivAttributes } from 'bits-ui';
3
7
 
4
8
  let {
9
+ class: className,
5
10
  center,
6
11
  edge,
7
12
  noise,
8
- centerPos = ['0.5', '0.5'],
9
- radius = ['1.0', '1.0']
10
- }: { center: string; edge: string; noise: string; centerPos: [string, string]; radius: [string, string] } = $props();
13
+ centerPos = [0.5, 0.5],
14
+ radius = [1.0, 1.0]
15
+ }: BitsPrimitiveDivAttributes & {
16
+ center: Vec4;
17
+ edge: Vec4;
18
+ noise: number;
19
+ centerPos?: Vec2;
20
+ radius?: Vec2;
21
+ } = $props();
11
22
 
12
- const shaderCode = `#version 300 es
13
-
14
- precision highp float;
15
-
16
- out vec4 fragColor;
17
-
18
- uniform vec2 u_resolution;
19
- uniform vec2 u_offset;
20
-
21
- // Pseudo-random number between 0 and 1 generator
22
- float dither(vec2 pos) {
23
- return fract(sin(dot(pos, vec2(12.9898, 78.233))) * 43758.5453);
23
+ function toRgba(color: Vec4): string {
24
+ const [r, g, b, a] = color.map((c) => Math.round(c * 255));
25
+ return `rgba(${r}, ${g}, ${b}, ${color[3].toFixed(3)})`;
24
26
  }
25
-
26
- void main() {
27
- vec2 fragPos = gl_FragCoord.xy + u_offset;
28
27
 
29
- vec2 centerPx = vec2(${centerPos.join()}) * u_resolution;
30
- vec2 radiusPx = vec2(${radius.join()}) * u_resolution;
28
+ let fallbackBackground = $derived.by(() => {
29
+ // Convert Vec4 colors to rgba() CSS strings
30
+ const centerColorRgba = toRgba(center);
31
+ const edgeColorRgba = toRgba(edge);
31
32
 
32
- // Calculate distance from the center of the canvas
33
- float d = distance(fragPos, u_resolution / 2.0);
33
+ const posX = centerPos[0] * 100;
34
+ const posY = centerPos[1] * 100;
34
35
 
35
- // Calculate max distance from center to corner of the canvas
36
- float maxDist = length(u_resolution / 2.0);
37
- // float t = d / maxDist;
36
+ const sizeX = radius[0] * 100;
37
+ const sizeY = radius[1] * 100;
38
38
 
39
- // compute “stretched” distance
40
- vec2 diff = fragPos - centerPx;
41
- vec2 norm = diff / radiusPx;
42
- float t = length(norm);
43
-
44
- // Dither strength (1/255 ~ 8-bit step size)
45
- float noise = (dither(gl_FragCoord.xy) - 0.5) * ( ${noise} / 255.0);
46
-
47
- vec4 c1 = vec4(${center}); // center
48
- vec4 c2 = vec4(${edge}); // edge
49
-
50
- fragColor = mix(c1, c2, clamp(t + noise, 0.0, 1.0));
51
- }
52
-
53
- `;
39
+ return `radial-gradient(ellipse ${sizeX}% ${sizeY}% at ${posX}% ${posY}%, ${centerColorRgba}, ${edgeColorRgba})`;
40
+ });
54
41
  </script>
55
42
 
56
- <WebGlShader
57
- width="100%"
58
- height="100%"
59
- code={shaderCode}
60
- parameters={[
61
- { name: 'u_resolution', value: 'resolution' },
62
- { name: 'u_offset', value: 'offset' }
63
- ]}
64
- >
65
- <div class="fallback">WebGL not supported in this environment.</div>
66
- </WebGlShader>
43
+ <div class={cn('h-full w-full', className)}>
44
+ <WebGlShader
45
+ width="100%"
46
+ height="100%"
47
+ code={fragment}
48
+ parameters={[
49
+ { name: 'u_resolution', value: 'resolution' },
50
+ { name: 'u_offset', value: 'offset' },
51
+ { name: 'u_centerPos', type: 'vec2', value: centerPos },
52
+ { name: 'u_radius', type: 'vec2', value: radius },
53
+ { name: 'u_noise', type: 'float', value: noise },
54
+ { name: 'u_centerColor', type: 'vec4', value: center },
55
+ { name: 'u_edgeColor', type: 'vec4', value: edge }
56
+ ]}
57
+ >
58
+ <div style="background: {fallbackBackground};" class="fallback size-full"></div>
59
+ </WebGlShader>
60
+ </div>