svelte-ag 0.0.2-dev.80 → 0.0.2-dev.82

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 (53) hide show
  1. package/dist/lib/components/carousel/carousel-content.svelte +5 -24
  2. package/dist/lib/components/carousel/carousel-content.svelte.d.ts.map +1 -1
  3. package/dist/lib/components/carousel/carousel-dots.svelte +1 -3
  4. package/dist/lib/components/carousel/carousel-dots.svelte.d.ts.map +1 -1
  5. package/dist/lib/components/carousel/carousel-next.svelte +21 -9
  6. package/dist/lib/components/carousel/carousel-next.svelte.d.ts +19 -4
  7. package/dist/lib/components/carousel/carousel-next.svelte.d.ts.map +1 -1
  8. package/dist/lib/components/carousel/carousel-previous.svelte +21 -9
  9. package/dist/lib/components/carousel/carousel-previous.svelte.d.ts +19 -4
  10. package/dist/lib/components/carousel/carousel-previous.svelte.d.ts.map +1 -1
  11. package/dist/lib/components/carousel/carousel.svelte +21 -1
  12. package/dist/lib/components/carousel/carousel.svelte.d.ts.map +1 -1
  13. package/dist/lib/components/carousel/context.d.ts +1 -0
  14. package/dist/lib/components/carousel/context.d.ts.map +1 -1
  15. package/dist/lib/components/gallery/gallery.svelte +67 -0
  16. package/dist/lib/components/gallery/gallery.svelte.d.ts +35 -0
  17. package/dist/lib/components/gallery/gallery.svelte.d.ts.map +1 -0
  18. package/dist/lib/components/gallery/index.d.ts +3 -0
  19. package/dist/lib/components/gallery/index.d.ts.map +1 -0
  20. package/dist/lib/components/gallery/index.js +2 -0
  21. package/dist/lib/components/gallery/utils.d.ts +17 -0
  22. package/dist/lib/components/gallery/utils.d.ts.map +1 -0
  23. package/dist/lib/components/gallery/utils.js +94 -0
  24. package/dist/lib/components/gradient/Gradient.svelte +45 -51
  25. package/dist/lib/components/gradient/Gradient.svelte.d.ts +8 -6
  26. package/dist/lib/components/gradient/Gradient.svelte.d.ts.map +1 -1
  27. package/dist/lib/components/gradient/gradient.frag +43 -0
  28. package/dist/lib/styles/underline.css +10 -0
  29. package/dist/lib/utils/glsl.d.ts +4 -0
  30. package/dist/lib/utils/glsl.d.ts.map +1 -0
  31. package/dist/lib/utils/glsl.js +1 -0
  32. package/dist/lib/utils/index.d.ts +1 -0
  33. package/dist/lib/utils/index.d.ts.map +1 -1
  34. package/dist/lib/utils/index.js +1 -0
  35. package/dist/lib/vite/vite-plugin-component-source-collector.d.ts +1 -0
  36. package/dist/lib/vite/vite-plugin-component-source-collector.d.ts.map +1 -1
  37. package/dist/lib/vite/vite-plugin-component-source-collector.js +16 -6
  38. package/package.json +3 -2
  39. package/src/lib/components/carousel/carousel-content.svelte +5 -24
  40. package/src/lib/components/carousel/carousel-dots.svelte +1 -3
  41. package/src/lib/components/carousel/carousel-next.svelte +21 -9
  42. package/src/lib/components/carousel/carousel-previous.svelte +21 -9
  43. package/src/lib/components/carousel/carousel.svelte +21 -1
  44. package/src/lib/components/carousel/context.ts +1 -0
  45. package/src/lib/components/gallery/gallery.svelte +67 -0
  46. package/src/lib/components/gallery/index.ts +3 -0
  47. package/src/lib/components/gallery/utils.ts +103 -0
  48. package/src/lib/components/gradient/Gradient.svelte +45 -51
  49. package/src/lib/components/gradient/gradient.frag +43 -0
  50. package/src/lib/styles/underline.css +10 -0
  51. package/src/lib/utils/glsl.ts +3 -0
  52. package/src/lib/utils/index.ts +1 -0
  53. package/src/lib/vite/vite-plugin-component-source-collector.ts +18 -5
@@ -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>
@@ -1 +1 @@
1
- {"version":3,"file":"carousel-content.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/carousel/carousel-content.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIrD,KAAK,gBAAgB,GAAI,cAAc,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAuC/F,QAAA,MAAM,eAAe,yDAAwC,CAAC;AAC9D,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAC1D,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"carousel-content.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/carousel/carousel-content.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIrD,KAAK,gBAAgB,GAAI,cAAc,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAwB/F,QAAA,MAAM,eAAe,yDAAwC,CAAC;AAC9D,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAC1D,eAAe,eAAe,CAAC"}
@@ -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)}>
@@ -1 +1 @@
1
- {"version":3,"file":"carousel-dots.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/carousel/carousel-dots.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C,OAAO,EAAU,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAE5D,KAAK,gBAAgB,GAAI,eAAe,CAAC,KAAK,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AA8BvE,QAAA,MAAM,YAAY,yDAAwC,CAAC;AAC3D,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"carousel-dots.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/carousel/carousel-dots.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C,OAAO,EAAU,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAE5D,KAAK,gBAAgB,GAAI,eAAe,CAAC,KAAK,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AA4BvE,QAAA,MAAM,YAAY,yDAAwC,CAAC;AAC3D,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,eAAe,YAAY,CAAC"}
@@ -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}
@@ -1,9 +1,24 @@
1
- import type { WithoutChildren } from 'bits-ui';
2
1
  import { type Props } from '$shadcn/button/index.js';
3
- type $$ComponentProps = WithoutChildren<Props> & {
2
+ import { type VariantProps } from 'tailwind-variants';
3
+ declare const CarouselNext: import("svelte").Component<Omit<Props, "children"> & {
4
4
  symbol?: symbol;
5
- };
6
- declare const CarouselNext: import("svelte").Component<$$ComponentProps, {}, "ref">;
5
+ position: VariantProps<import("tailwind-variants").TVReturnType<{
6
+ variant: {
7
+ default: string;
8
+ flex: string;
9
+ };
10
+ }, undefined, "size-8 touch-manipulation rounded-full", {
11
+ variant: {
12
+ default: string;
13
+ flex: string;
14
+ };
15
+ }, undefined, import("tailwind-variants").TVReturnType<{
16
+ variant: {
17
+ default: string;
18
+ flex: string;
19
+ };
20
+ }, undefined, "size-8 touch-manipulation rounded-full", unknown, unknown, undefined>>>["variant"];
21
+ }, {}, "ref">;
7
22
  type CarouselNext = ReturnType<typeof CarouselNext>;
8
23
  export default CarouselNext;
9
24
  //# sourceMappingURL=carousel-next.svelte.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"carousel-next.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/carousel/carousel-next.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C,OAAO,EAAU,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAE5D,KAAK,gBAAgB,GAAI,eAAe,CAAC,KAAK,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAiCvE,QAAA,MAAM,YAAY,yDAAwC,CAAC;AAC3D,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"carousel-next.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/carousel/carousel-next.svelte.ts"],"names":[],"mappings":"AAOA,OAAO,EAAU,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAM,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA8C1D,QAAA,MAAM,YAAY;aAtC8C,MAAM;cAAY,YAAY;;;;;;;;;;;;;;;0FAAiB,CAAC,SAAS,CAAC;aAsChE,CAAC;AAC3D,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,eAAe,YAAY,CAAC"}
@@ -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,9 +1,24 @@
1
- import type { WithoutChildren } from 'bits-ui';
2
1
  import { type Props } from '$shadcn/button/index.js';
3
- type $$ComponentProps = WithoutChildren<Props> & {
2
+ import { type VariantProps } from 'tailwind-variants';
3
+ declare const CarouselPrevious: import("svelte").Component<Omit<Props, "children"> & {
4
4
  symbol?: symbol;
5
- };
6
- declare const CarouselPrevious: import("svelte").Component<$$ComponentProps, {}, "ref">;
5
+ position: VariantProps<import("tailwind-variants").TVReturnType<{
6
+ variant: {
7
+ default: string;
8
+ flex: string;
9
+ };
10
+ }, undefined, "size-8 touch-manipulation rounded-full", {
11
+ variant: {
12
+ default: string;
13
+ flex: string;
14
+ };
15
+ }, undefined, import("tailwind-variants").TVReturnType<{
16
+ variant: {
17
+ default: string;
18
+ flex: string;
19
+ };
20
+ }, undefined, "size-8 touch-manipulation rounded-full", unknown, unknown, undefined>>>["variant"];
21
+ }, {}, "ref">;
7
22
  type CarouselPrevious = ReturnType<typeof CarouselPrevious>;
8
23
  export default CarouselPrevious;
9
24
  //# sourceMappingURL=carousel-previous.svelte.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"carousel-previous.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/carousel/carousel-previous.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C,OAAO,EAAU,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAE5D,KAAK,gBAAgB,GAAI,eAAe,CAAC,KAAK,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAiCvE,QAAA,MAAM,gBAAgB,yDAAwC,CAAC;AAC/D,KAAK,gBAAgB,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC5D,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"carousel-previous.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/carousel/carousel-previous.svelte.ts"],"names":[],"mappings":"AAOA,OAAO,EAAU,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,KAAK,YAAY,EAAM,MAAM,mBAAmB,CAAC;AA8C1D,QAAA,MAAM,gBAAgB;aAtC0C,MAAM;cAAY,YAAY;;;;;;;;;;;;;;;0FAAiB,CAAC,SAAS,CAAC;aAsC5D,CAAC;AAC/D,KAAK,gBAAgB,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC5D,eAAe,gBAAgB,CAAC"}
@@ -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>
@@ -1 +1 @@
1
- {"version":3,"file":"carousel.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/carousel/carousel.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,EAAoB,KAAK,aAAa,EAAsC,MAAM,cAAc,CAAC;AA6GxG,QAAA,MAAM,QAAQ,mDAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"carousel.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/carousel/carousel.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,EAAoB,KAAK,aAAa,EAAsC,MAAM,cAAc,CAAC;AA2HxG,QAAA,MAAM,QAAQ,mDAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
@@ -13,6 +13,7 @@ export type CarouselProps = {
13
13
  setApi?: (api: CarouselAPI | undefined) => void;
14
14
  pointerdown?: (api: CarouselAPI) => void;
15
15
  pointerup?: (api: CarouselAPI) => void;
16
+ onSelect?: (api: CarouselAPI) => void;
16
17
  orientation?: 'horizontal' | 'vertical';
17
18
  } & WithElementRef<HTMLAttributes<HTMLDivElement>>;
18
19
  export type EmblaContext = {
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"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AAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAIF,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,GAAE,MAA+B,GAAG,YAAY,CAG3G;AAED,wBAAgB,eAAe,CAAC,IAAI,SAAmB,EAAE,MAAM,GAAE,MAA+B,GAAG,YAAY,CAK9G"}
@@ -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,35 @@
1
+ import { type Snippet } from 'svelte';
2
+ import { type HTMLDivAttributes } from '../../utils/index.js';
3
+ declare class __sveltets_Render<Item> {
4
+ props(): HTMLDivAttributes & {
5
+ ref?: HTMLElement | null | undefined;
6
+ } & {
7
+ images: {
8
+ large: Item[];
9
+ medium: Item[];
10
+ small: Item[];
11
+ };
12
+ child: Snippet<[{
13
+ props: {
14
+ style: string;
15
+ };
16
+ item: Item;
17
+ index: number;
18
+ }]>;
19
+ };
20
+ events(): {};
21
+ slots(): {};
22
+ bindings(): "ref" | "images";
23
+ exports(): {};
24
+ }
25
+ interface $$IsomorphicComponent {
26
+ new <Item>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<Item>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<Item>['props']>, ReturnType<__sveltets_Render<Item>['events']>, ReturnType<__sveltets_Render<Item>['slots']>> & {
27
+ $$bindings?: ReturnType<__sveltets_Render<Item>['bindings']>;
28
+ } & ReturnType<__sveltets_Render<Item>['exports']>;
29
+ <Item>(internal: unknown, props: ReturnType<__sveltets_Render<Item>['props']> & {}): ReturnType<__sveltets_Render<Item>['exports']>;
30
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
31
+ }
32
+ declare const Gallery: $$IsomorphicComponent;
33
+ type Gallery<Item> = InstanceType<typeof Gallery<Item>>;
34
+ export default Gallery;
35
+ //# sourceMappingURL=gallery.svelte.d.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CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;CACjE;AACD,QAAA,MAAM,OAAO,EAAE,qBAAmC,CAAC;AACjC,KAAK,OAAO,CAAC,IAAI,IAAI,YAAY,CAAC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AAC1D,eAAe,OAAO,CAAC"}
@@ -0,0 +1,3 @@
1
+ import Gallery from './gallery.svelte';
2
+ export { Gallery };
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/gallery/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAEvC,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ import Gallery from './gallery.svelte';
2
+ export { Gallery };
@@ -0,0 +1,17 @@
1
+ export type Size = 'S' | 'M' | 'L';
2
+ /**
3
+ * Gets the style statement for a particular size
4
+ */
5
+ export declare function styleForSize(size: Size): string;
6
+ /**
7
+ * Packs images of different sizes into a grid layout
8
+ * @param small Array of small-sized items to place in grid
9
+ * @param medium Array of medium-sized items to place in grid
10
+ * @param large Array of large-sized items to place in grid
11
+ * @param cols Number of columns in the grid
12
+ * @returns Array of items arranged in optimal grid order
13
+ */
14
+ export declare function packGrid<Item extends {
15
+ size: Size;
16
+ }>(small: Item[], medium: Item[], large: Item[], cols?: number): Item[];
17
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/gallery/utils.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AASnC;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,UAEtC;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,SAAS;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,IAAI,SAAI,GAAG,IAAI,EAAE,CA8EpH"}
@@ -0,0 +1,94 @@
1
+ const w = { S: 1, M: 1, L: 2 };
2
+ const h = { S: 1, M: 2, L: 3 };
3
+ function imageSize(size) {
4
+ return [w[size], h[size]];
5
+ }
6
+ /**
7
+ * Gets the style statement for a particular size
8
+ */
9
+ export function styleForSize(size) {
10
+ return `grid-column: span ${imageSize(size)[0]}; grid-row: span ${imageSize(size)[1]};`;
11
+ }
12
+ /**
13
+ * Packs images of different sizes into a grid layout
14
+ * @param small Array of small-sized items to place in grid
15
+ * @param medium Array of medium-sized items to place in grid
16
+ * @param large Array of large-sized items to place in grid
17
+ * @param cols Number of columns in the grid
18
+ * @returns Array of items arranged in optimal grid order
19
+ */
20
+ export function packGrid(small, medium, large, cols = 4) {
21
+ const result = [];
22
+ // Create a 2D grid to track occupied cells (32 rows max, adjustable column width)
23
+ const occ = Array.from({ length: 32 }, () => Array(cols).fill(false));
24
+ let r = 0, // Current row
25
+ c = 0, // Current column
26
+ lastSize = null; // Track last placed item size for variety
27
+ // Check if we still have any items to place
28
+ const hasStock = () => small.length || medium.length || large.length;
29
+ // Organize items by size for easy access
30
+ const pool = { S: small, M: medium, L: large };
31
+ // Dynamic preference ordering strategy for visual variety
32
+ // After placing one size, prefer different sizes next for better distribution
33
+ const pref = (prev) => {
34
+ if (prev === 'L')
35
+ return ['S', 'M', 'L']; // After large, prefer small
36
+ if (prev === 'S')
37
+ return ['L', 'M', 'S']; // After small, prefer large
38
+ if (prev === 'M')
39
+ return ['S', 'L', 'M']; // After medium, prefer small
40
+ return ['L', 'M', 'S']; // Initial preference (start with large items)
41
+ };
42
+ while (hasStock()) {
43
+ // Skip already occupied cells
44
+ while (occ[r]?.[c]) {
45
+ // Move to next row if end of column reached
46
+ if (++c === cols) {
47
+ c = 0;
48
+ r++;
49
+ }
50
+ }
51
+ // Check if item of given size can fit at current position
52
+ const fits = (size) => {
53
+ // Check if item would extend beyond right edge
54
+ if (c + w[size] > cols)
55
+ return false;
56
+ // Check if all required cells are unoccupied
57
+ for (let y = 0; y < h[size]; y++)
58
+ for (let x = 0; x < w[size]; x++)
59
+ if (occ[r + y]?.[c + x])
60
+ return false;
61
+ return true;
62
+ };
63
+ let chosen;
64
+ // Try to place items in preferred size order
65
+ for (const sz of pref(lastSize)) {
66
+ if (pool[sz].length && fits(sz)) {
67
+ chosen = pool[sz].shift();
68
+ break;
69
+ }
70
+ }
71
+ if (!chosen) {
72
+ // If no item fits at current position, move to next cell
73
+ if (++c === cols) {
74
+ c = 0;
75
+ r++;
76
+ }
77
+ continue;
78
+ }
79
+ // Mark grid cells as occupied based on item dimensions
80
+ const sx = w[chosen.size], sy = h[chosen.size];
81
+ for (let y = 0; y < sy; y++)
82
+ for (let x = 0; x < sx; x++)
83
+ occ[r + y][c + x] = true;
84
+ result.push(chosen);
85
+ lastSize = chosen.size; // Remember this size for next preference calculation
86
+ c += sx; // Move cursor past the placed item
87
+ // Move to next row if needed
88
+ if (c === cols) {
89
+ c = 0;
90
+ r++;
91
+ }
92
+ }
93
+ return result;
94
+ }