@splenddev/kreativ-ui 0.3.18 → 0.3.19

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 (40) hide show
  1. package/dist/{chunk-3SX7MFC4.js → chunk-3QVHDUG2.js} +158 -37
  2. package/dist/chunk-3QVHDUG2.js.map +1 -0
  3. package/dist/{chunk-4KNQFZZT.cjs → chunk-5GGCRNXA.cjs} +2 -10
  4. package/dist/chunk-5GGCRNXA.cjs.map +1 -0
  5. package/dist/chunk-6MO73J54.js +12 -0
  6. package/dist/chunk-6MO73J54.js.map +1 -0
  7. package/dist/{chunk-HHSP6YJA.cjs → chunk-C2JEK4T5.cjs} +29 -7
  8. package/dist/{chunk-HHSP6YJA.cjs.map → chunk-C2JEK4T5.cjs.map} +1 -1
  9. package/dist/{chunk-TGYV2M2L.js → chunk-C4PCJAAL.js} +3 -10
  10. package/dist/chunk-C4PCJAAL.js.map +1 -0
  11. package/dist/{chunk-L3YGJX72.cjs → chunk-KJ2CWKTU.cjs} +274 -153
  12. package/dist/chunk-KJ2CWKTU.cjs.map +1 -0
  13. package/dist/chunk-POSRGA6G.cjs +14 -0
  14. package/dist/chunk-POSRGA6G.cjs.map +1 -0
  15. package/dist/{chunk-6GN2Y3X4.js → chunk-X7373GJO.js} +29 -7
  16. package/dist/{chunk-6GN2Y3X4.js.map → chunk-X7373GJO.js.map} +1 -1
  17. package/dist/cn-Cbsgs0XP.d.cts +5 -0
  18. package/dist/cn-Cbsgs0XP.d.ts +5 -0
  19. package/dist/components.cjs +91 -90
  20. package/dist/components.d.cts +10 -2
  21. package/dist/components.d.ts +10 -2
  22. package/dist/components.js +3 -2
  23. package/dist/core.cjs +22 -17
  24. package/dist/core.d.cts +2 -0
  25. package/dist/core.d.ts +2 -0
  26. package/dist/core.js +2 -1
  27. package/dist/index.cjs +9 -8
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.js +4 -3
  30. package/dist/index.js.map +1 -1
  31. package/dist/styles/index.css +1 -1
  32. package/dist/utils.cjs +40 -39
  33. package/dist/utils.d.cts +3 -4
  34. package/dist/utils.d.ts +3 -4
  35. package/dist/utils.js +2 -1
  36. package/package.json +1 -1
  37. package/dist/chunk-3SX7MFC4.js.map +0 -1
  38. package/dist/chunk-4KNQFZZT.cjs.map +0 -1
  39. package/dist/chunk-L3YGJX72.cjs.map +0 -1
  40. package/dist/chunk-TGYV2M2L.js.map +0 -1
@@ -1,5 +1,6 @@
1
1
  import { useControllableState, useResponsiveStyles, useMergedResponsiveStyles, useStatusTransition, useClearableField, useKeyboardShortcuts, useFloatingSide } from './chunk-EZIFSNRD.js';
2
- import { cn, resolveResponsiveValue, resolveSpace, isMotionGated, isResponsiveValue, resolveColor, resolveRadius, composeRefs as composeRefs$1 } from './chunk-TGYV2M2L.js';
2
+ import { resolveResponsiveValue, resolveSpace, isMotionGated, isResponsiveValue, resolveColor, resolveRadius, composeRefs as composeRefs$1 } from './chunk-C4PCJAAL.js';
3
+ import { cn } from './chunk-6MO73J54.js';
3
4
  import { __name, __export, __publicField } from './chunk-CXR2HHQQ.js';
4
5
  import * as React10 from 'react';
5
6
  import { createContext, useState, useEffect, useMemo, useId, useRef, forwardRef, Children, isValidElement, Fragment as Fragment$1, useImperativeHandle, useCallback, useLayoutEffect, useSyncExternalStore, useContext, useReducer } from 'react';
@@ -2020,13 +2021,62 @@ var Menu = {
2020
2021
  SubTrigger: MenuSubTrigger,
2021
2022
  SubContent: MenuSubContent
2022
2023
  };
2023
- var CarouselContext = React10.createContext(null);
2024
+ var CarouselContext = React10.createContext(
2025
+ null
2026
+ );
2024
2027
  function useCarouselContext(part) {
2025
2028
  const ctx = React10.useContext(CarouselContext);
2026
2029
  if (!ctx) throw new Error(`${part} must be rendered inside <Carousel.Root>`);
2027
2030
  return ctx;
2028
2031
  }
2029
2032
  __name(useCarouselContext, "useCarouselContext");
2033
+ var MIN_VISIBLE = 0.05;
2034
+ var EPS = 1e-6;
2035
+ function resolveWindow(visibility, slidesPerViewProp) {
2036
+ if (visibility && visibility.length > 0) {
2037
+ const v = visibility.map(
2038
+ (x) => Number.isFinite(x) ? Math.min(Math.max(x, MIN_VISIBLE), 1) : 1
2039
+ );
2040
+ const n = v.length;
2041
+ const lead = n > 1 && v[0] < 1 - EPS ? v[0] : 0;
2042
+ const trail = n > 1 && v[n - 1] < 1 - EPS ? v[n - 1] : 0;
2043
+ const interior = v.slice(lead > 0 ? 1 : 0, n - (trail > 0 ? 1 : 0));
2044
+ if (process.env.NODE_ENV !== "production" && interior.some((x) => x < 1 - EPS)) {
2045
+ console.warn(
2046
+ "<Carousel.Root slideVisibility>: only the first and last entries may be below 1. Interior entries are treated as 1."
2047
+ );
2048
+ }
2049
+ if (interior.length >= 1) {
2050
+ return {
2051
+ slidesPerView: interior.length,
2052
+ window: {
2053
+ span: interior.length + lead + trail,
2054
+ gapCount: n - 1,
2055
+ lead,
2056
+ trail,
2057
+ padded: true
2058
+ }
2059
+ };
2060
+ }
2061
+ if (process.env.NODE_ENV !== "production") {
2062
+ console.warn(
2063
+ "<Carousel.Root slideVisibility> needs at least one whole slide (a 1). Falling back to slidesPerView."
2064
+ );
2065
+ }
2066
+ }
2067
+ const spv = Number.isFinite(slidesPerViewProp) ? Math.max(1, slidesPerViewProp) : 1;
2068
+ return {
2069
+ slidesPerView: spv,
2070
+ window: {
2071
+ span: spv,
2072
+ gapCount: Math.ceil(spv) - 1,
2073
+ lead: 0,
2074
+ trail: 0,
2075
+ padded: false
2076
+ }
2077
+ };
2078
+ }
2079
+ __name(resolveWindow, "resolveWindow");
2030
2080
  function usePrefersReducedMotion() {
2031
2081
  const query = "(prefers-reduced-motion: reduce)";
2032
2082
  const [reduced, setReduced] = React10.useState(
@@ -2074,13 +2124,18 @@ var CarouselRoot = createComponent$1({
2074
2124
  onBlur,
2075
2125
  onKeyDown,
2076
2126
  recipeProps,
2127
+ slideVisibility,
2077
2128
  ...rest
2078
2129
  } = props;
2079
2130
  const id = React10.useId();
2080
2131
  const { theme } = useTheme();
2081
- const slidesPerView = Math.max(1, Math.floor(spvProp));
2132
+ const visibilityKey = slideVisibility?.join(",");
2133
+ const { slidesPerView, window: slideWindow } = React10.useMemo(
2134
+ () => resolveWindow(slideVisibility, spvProp),
2135
+ [visibilityKey, spvProp]
2136
+ );
2082
2137
  const [count, setCount] = React10.useState(0);
2083
- const maxIndex = Math.max(count - slidesPerView, 0);
2138
+ const maxIndex = slideWindow.padded ? Math.max(count - slidesPerView, 0) : Math.max(Math.ceil(count - slidesPerView - 1e-6), 0);
2084
2139
  const [rawIndex, setIndex] = useControllableState({
2085
2140
  value: indexProp,
2086
2141
  defaultValue: defaultIndex,
@@ -2167,7 +2222,8 @@ var CarouselRoot = createComponent$1({
2167
2222
  canNext,
2168
2223
  canPrevious,
2169
2224
  indexRef,
2170
- maxIndexRef
2225
+ maxIndexRef,
2226
+ window: slideWindow
2171
2227
  }),
2172
2228
  [
2173
2229
  id,
@@ -2187,7 +2243,8 @@ var CarouselRoot = createComponent$1({
2187
2243
  next,
2188
2244
  previous,
2189
2245
  canNext,
2190
- canPrevious
2246
+ canPrevious,
2247
+ slideWindow
2191
2248
  ]
2192
2249
  );
2193
2250
  return /* @__PURE__ */ jsx(CarouselContext.Provider, { value, children: /* @__PURE__ */ jsx(
@@ -2921,7 +2978,7 @@ function createStore(initial, equals = Object.is) {
2921
2978
  __name(createStore, "createStore");
2922
2979
 
2923
2980
  // src/components/layout/ScrollArea/ScrollEngine.ts
2924
- var EPS = 1;
2981
+ var EPS2 = 1;
2925
2982
  var round = /* @__PURE__ */ __name((n) => Math.round(n * 1e4) / 1e4, "round");
2926
2983
  var progressEqual = /* @__PURE__ */ __name((a, b) => a.x === b.x && a.y === b.y, "progressEqual");
2927
2984
  var STICKY_EDGES = ["top", "bottom", "left", "right"];
@@ -3020,13 +3077,13 @@ var _ScrollEngine = class _ScrollEngine {
3020
3077
  const r = s.el.getBoundingClientRect();
3021
3078
  const o = s.offsets;
3022
3079
  const hit = [];
3023
- if (o.top !== void 0 && Math.abs(r.top - (portTop + o.top)) <= EPS && el.scrollTop > EPS)
3080
+ if (o.top !== void 0 && Math.abs(r.top - (portTop + o.top)) <= EPS2 && el.scrollTop > EPS2)
3024
3081
  hit.push("top");
3025
- if (o.bottom !== void 0 && Math.abs(r.bottom - (portBottom - o.bottom)) <= EPS && el.scrollTop < maxY - EPS)
3082
+ if (o.bottom !== void 0 && Math.abs(r.bottom - (portBottom - o.bottom)) <= EPS2 && el.scrollTop < maxY - EPS2)
3026
3083
  hit.push("bottom");
3027
- if (o.left !== void 0 && Math.abs(r.left - (portLeft + o.left)) <= EPS && el.scrollLeft > EPS)
3084
+ if (o.left !== void 0 && Math.abs(r.left - (portLeft + o.left)) <= EPS2 && el.scrollLeft > EPS2)
3028
3085
  hit.push("left");
3029
- if (o.right !== void 0 && Math.abs(r.right - (portRight - o.right)) <= EPS && el.scrollLeft < maxX - EPS)
3086
+ if (o.right !== void 0 && Math.abs(r.right - (portRight - o.right)) <= EPS2 && el.scrollLeft < maxX - EPS2)
3030
3087
  hit.push("right");
3031
3088
  stickyStates.push([s, hit.join(" ")]);
3032
3089
  });
@@ -3613,6 +3670,17 @@ function slideOffset(viewport, i) {
3613
3670
  return slide.getBoundingClientRect().left - viewport.getBoundingClientRect().left + viewport.scrollLeft;
3614
3671
  }
3615
3672
  __name(slideOffset, "slideOffset");
3673
+ function slideTarget(viewport, i, padded) {
3674
+ const off = slideOffset(viewport, i);
3675
+ if (off == null) return null;
3676
+ const base = padded ? slideOffset(viewport, 0) : 0;
3677
+ if (base == null) return null;
3678
+ return Math.max(
3679
+ 0,
3680
+ Math.min(off - base, viewport.scrollWidth - viewport.clientWidth)
3681
+ );
3682
+ }
3683
+ __name(slideTarget, "slideTarget");
3616
3684
  var CarouselSlide = createComponent$1({
3617
3685
  displayName: "Carousel.Slide",
3618
3686
  __kui: { role: "layout", groupSlot: "Carousel", skeleton: "preserve" },
@@ -3625,7 +3693,11 @@ var CarouselSlide = createComponent$1({
3625
3693
  );
3626
3694
  const { slideStyle } = useCarouselSnap();
3627
3695
  const { theme } = useTheme();
3628
- const active = index >= ctx.index && index < ctx.index + ctx.slidesPerView;
3696
+ const { lead, trail, padded } = ctx.window;
3697
+ const EPS3 = 1e-6;
3698
+ const startU = padded ? ctx.index - lead : Math.max(Math.min(ctx.index, ctx.count - ctx.slidesPerView), 0);
3699
+ const endU = padded ? ctx.index + ctx.slidesPerView + trail : startU + ctx.slidesPerView;
3700
+ const active = index + 1 > startU + EPS3 && index < endU - EPS3;
3629
3701
  return /* @__PURE__ */ jsx(
3630
3702
  "div",
3631
3703
  {
@@ -3640,7 +3712,7 @@ var CarouselSlide = createComponent$1({
3640
3712
  "aria-hidden": !active ? true : void 0,
3641
3713
  className: resolveRecipe(theme.recipes.CarouselSlide, {}, className),
3642
3714
  style: {
3643
- flexBasis: "calc((100% - (var(--kui-carousel-per-view) - 1) * var(--kui-carousel-gap)) / var(--kui-carousel-per-view))",
3715
+ flexBasis: "calc((100% - var(--kui-carousel-gaps) * var(--kui-carousel-gap)) / var(--kui-carousel-per-view))",
3644
3716
  ...slideStyle,
3645
3717
  ...style
3646
3718
  },
@@ -3682,7 +3754,7 @@ var CarouselViewport = createComponent$1({
3682
3754
  React10.useLayoutEffect(() => {
3683
3755
  const vp = getScroller();
3684
3756
  if (!vp || count === 0 || ctx.count !== count) return;
3685
- const left = slideOffset(vp, ctx.index);
3757
+ const left = slideTarget(vp, ctx.index, ctx.window.padded);
3686
3758
  if (left == null) return;
3687
3759
  const first = !mounted.current;
3688
3760
  mounted.current = true;
@@ -3696,6 +3768,7 @@ var CarouselViewport = createComponent$1({
3696
3768
  ctx.count,
3697
3769
  count,
3698
3770
  ctx.slidesPerView,
3771
+ ctx.window,
3699
3772
  ctx.gap,
3700
3773
  ctx.prefersReducedMotion,
3701
3774
  getScroller
@@ -3712,10 +3785,10 @@ var CarouselViewport = createComponent$1({
3712
3785
  let best = 0;
3713
3786
  let bestDist = Infinity;
3714
3787
  for (let i = 0; i <= ctx.maxIndexRef.current; i++) {
3715
- const off = slideOffset(vp, i);
3788
+ const off = slideTarget(vp, i, ctx.window.padded);
3716
3789
  if (off == null) continue;
3717
3790
  const d = Math.abs(off - vp.scrollLeft);
3718
- if (d < bestDist) {
3791
+ if (d <= bestDist) {
3719
3792
  bestDist = d;
3720
3793
  best = i;
3721
3794
  }
@@ -3723,30 +3796,69 @@ var CarouselViewport = createComponent$1({
3723
3796
  if (best !== ctx.indexRef.current) ctx.goTo(best);
3724
3797
  }, 100);
3725
3798
  }, [ctx, getScroller]);
3799
+ const SLIDE_W = "(100% - var(--kui-carousel-gaps) * var(--kui-carousel-gap)) / var(--kui-carousel-per-view)";
3800
+ const { lead, trail, span, gapCount, padded } = ctx.window;
3801
+ const g = toCss(ctx.gap);
3802
+ const snapPad = padded && lead > 0 ? {
3803
+ scrollPaddingLeft: `calc(${lead} * (100% - ${gapCount} * ${g}) / ${span} + ${g})`
3804
+ } : null;
3726
3805
  return /* @__PURE__ */ jsx(
3727
3806
  ScrollArea,
3728
3807
  {
3729
3808
  ref: handleRef,
3730
3809
  direction: "horizontal",
3731
- overscrollBehavior: "contain",
3810
+ overscrollBehavior: "auto",
3732
3811
  showScrollbar: "never",
3733
3812
  onScroll,
3734
3813
  id: ctx.viewportId,
3735
3814
  "aria-live": ctx.autoplayRunning ? "off" : "polite",
3736
3815
  className,
3737
- style: { ...viewportStyle, ...style },
3816
+ style: {
3817
+ ...viewportStyle,
3818
+ ...snapPad,
3819
+ overscrollBehaviorX: "contain",
3820
+ overscrollBehaviorY: "auto",
3821
+ ...style
3822
+ },
3738
3823
  ...rest,
3739
- children: /* @__PURE__ */ jsx(
3824
+ children: /* @__PURE__ */ jsxs(
3740
3825
  "div",
3741
3826
  {
3742
3827
  "data-part": "track",
3743
- className: resolveRecipe(theme.recipes.CarouselTrack, {}, className),
3828
+ className: resolveRecipe(theme.recipes.CarouselTrack, {}),
3744
3829
  style: {
3745
- gap: toCss(ctx.gap),
3746
- "--kui-carousel-gap": toCss(ctx.gap),
3747
- "--kui-carousel-per-view": ctx.slidesPerView
3830
+ gap: g,
3831
+ "--kui-carousel-gap": g,
3832
+ "--kui-carousel-per-view": span,
3833
+ "--kui-carousel-gaps": gapCount,
3834
+ "--kui-carousel-lead": lead,
3835
+ "--kui-carousel-trail": trail
3748
3836
  },
3749
- children: slides
3837
+ children: [
3838
+ lead > 0 && /* @__PURE__ */ jsx(
3839
+ "div",
3840
+ {
3841
+ "aria-hidden": "true",
3842
+ "data-part": "spacer",
3843
+ className: "shrink-0 grow-0",
3844
+ style: {
3845
+ flexBasis: `calc(var(--kui-carousel-lead) * (${SLIDE_W}))`
3846
+ }
3847
+ }
3848
+ ),
3849
+ slides,
3850
+ trail > 0 && /* @__PURE__ */ jsx(
3851
+ "div",
3852
+ {
3853
+ "aria-hidden": "true",
3854
+ "data-part": "spacer",
3855
+ className: "shrink-0 grow-0",
3856
+ style: {
3857
+ flexBasis: `calc(var(--kui-carousel-trail) * (${SLIDE_W}))`
3858
+ }
3859
+ }
3860
+ )
3861
+ ]
3750
3862
  }
3751
3863
  )
3752
3864
  }
@@ -3843,23 +3955,39 @@ var CarouselNext = makeNavButton("Next", 1);
3843
3955
  var CarouselIndicators = createComponent$1({
3844
3956
  displayName: "Carousel.Indicators",
3845
3957
  __kui: { role: "navigation", groupSlot: "Carousel", skeleton: "rect" },
3846
- render: /* @__PURE__ */ __name(({ children, placement, recipeProps, className, ...rest }, ref) => {
3958
+ render: /* @__PURE__ */ __name(({ children, variant, placement, recipeProps, className, ...rest }, ref) => {
3847
3959
  const ctx = useCarouselContext("Carousel.Indicators");
3848
3960
  const { theme } = useTheme();
3849
3961
  const positions = ctx.maxIndex + 1;
3850
3962
  if (positions <= 1) return null;
3963
+ const wrapperClass = resolveRecipe(
3964
+ theme.recipes.CarouselIndicators,
3965
+ { variant, placement },
3966
+ className,
3967
+ recipeProps
3968
+ );
3969
+ if (variant === "fraction" && typeof children !== "function" && children == null) {
3970
+ return /* @__PURE__ */ jsx("div", { ref, className: wrapperClass, ...rest, children: /* @__PURE__ */ jsxs("span", { "aria-hidden": "true", "data-part": "indicator-fraction", children: [
3971
+ ctx.index + 1,
3972
+ " / ",
3973
+ positions
3974
+ ] }) });
3975
+ }
3851
3976
  const info = { index: ctx.index, count: positions, goTo: ctx.goTo };
3852
3977
  const body = typeof children === "function" ? children(info) : children ?? Array.from({ length: positions }, (_, i) => /* @__PURE__ */ jsx(
3853
3978
  "button",
3854
3979
  {
3855
3980
  type: "button",
3856
- className: resolveRecipe(theme.recipes.CarouselIndicator, {}),
3981
+ className: resolveRecipe(theme.recipes.CarouselIndicator, {
3982
+ variant
3983
+ }),
3857
3984
  "data-part": "indicator",
3858
3985
  "data-state": i === ctx.index ? "active" : "inactive",
3859
3986
  "aria-label": `Go to slide ${i + 1}`,
3860
3987
  "aria-current": i === ctx.index ? "true" : void 0,
3861
3988
  "aria-controls": ctx.viewportId,
3862
- onClick: () => ctx.goTo(i)
3989
+ onClick: () => ctx.goTo(i),
3990
+ children: variant === "numbers" ? i + 1 : null
3863
3991
  },
3864
3992
  i
3865
3993
  ));
@@ -3868,15 +3996,8 @@ var CarouselIndicators = createComponent$1({
3868
3996
  {
3869
3997
  ref,
3870
3998
  role: "group",
3871
- className: resolveRecipe(
3872
- theme.recipes.CarouselIndicators,
3873
- {
3874
- placement,
3875
- ...recipeProps
3876
- },
3877
- className
3878
- ),
3879
3999
  "aria-label": "Choose slide",
4000
+ className: wrapperClass,
3880
4001
  ...rest,
3881
4002
  children: body
3882
4003
  }
@@ -30343,5 +30464,5 @@ var Heading = forwardRef(
30343
30464
  Heading.displayName = "Heading";
30344
30465
 
30345
30466
  export { ActionGuard, Box, Button, ButtonGroup, ButtonGroupContext, ButtonGroupItemContext, Card, CardOverlay, Carousel, Checkbox, Combobox, ComboboxContent, ComboboxInput, ComboboxItem, ConfirmConflictError, ConfirmDialog, ConfirmHost, ConfirmRequestManager, Container, DialogProvider, DialogStack, Flex, Form, FormField, FormFieldControl, FormFieldDescription, FormFieldLabel, FormFieldMessage, FormResetButton, FormSubmitButton, Grid, Heading, Input, MarkdownEditor, Menu, MultiSelect, MultiSelectContent, MultiSelectItem, MultiSelectTrigger, NumberStepper, OverlayPortal, OverlayRootContext, Radio, RadioGroup, Repeater, ScrollArea, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectRoot, SelectTrigger, SelectValue, Stack, Switch, Textarea, ThemeToggler, Toast, ToastAction, ToastClose, ToastContent, ToastDescription, ToastIcon, ToastProvider, ToastRoot, ToastTitle, ToastViewport, Tooltip, TooltipProvider, confirmAction, createConfirmAction, createConfirmRequestManager, defaultConfirmManager, defineUIField, isDev, toast, useButtonGroupContext, useButtonGroupItemContext, useCarouselSnap, useConfirmAction, useDialogStack, useDialogState, useElementScrollProgress, useFormContext, useOptionalButtonGroupContext, useOptionalButtonGroupItemContext, useOverlayRoot, useScrollProgress, useToasts };
30346
- //# sourceMappingURL=chunk-3SX7MFC4.js.map
30347
- //# sourceMappingURL=chunk-3SX7MFC4.js.map
30467
+ //# sourceMappingURL=chunk-3QVHDUG2.js.map
30468
+ //# sourceMappingURL=chunk-3QVHDUG2.js.map