@splenddev/kreativ-ui 0.3.1 → 0.3.2

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/dist/index.cjs CHANGED
@@ -35,11 +35,11 @@ function _interopNamespace(e) {
35
35
  var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
36
36
  var hooks_star__namespace = /*#__PURE__*/_interopNamespace(hooks_star);
37
37
 
38
- console.log("BANNER TEST");
39
38
  var __defProp = Object.defineProperty;
40
39
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
41
40
  var __getOwnPropNames = Object.getOwnPropertyNames;
42
41
  var __hasOwnProp = Object.prototype.hasOwnProperty;
42
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
43
43
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
44
44
  var __export = (target, all) => {
45
45
  for (var name in all)
@@ -54,16 +54,19 @@ var __copyProps = (to, from, except, desc) => {
54
54
  return to;
55
55
  };
56
56
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget);
57
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
57
58
 
58
59
  // src/index.ts
59
60
  var index_exports = {};
60
61
  __export(index_exports, {
61
62
  Adornment: () => Adornment,
63
+ Box: () => Box,
62
64
  Button: () => Button,
63
65
  ButtonGroup: () => ButtonGroup,
64
66
  ButtonGroupContext: () => ButtonGroupContext,
65
67
  ButtonGroupItemContext: () => ButtonGroupItemContext,
66
68
  Card: () => Card,
69
+ CardOverlay: () => CardOverlay,
67
70
  Checkbox: () => Checkbox,
68
71
  Combobox: () => Combobox,
69
72
  ComboboxContent: () => ComboboxContent,
@@ -88,8 +91,10 @@ __export(index_exports, {
88
91
  MultiSelectContent: () => MultiSelectContent,
89
92
  MultiSelectItem: () => MultiSelectItem,
90
93
  MultiSelectTrigger: () => MultiSelectTrigger,
94
+ PersistMode: () => kreativCore.PersistMode,
91
95
  Radio: () => Radio,
92
96
  RadioGroup: () => RadioGroup,
97
+ ScrollArea: () => ScrollArea,
93
98
  Select: () => Select,
94
99
  SelectContent: () => SelectContent,
95
100
  SelectGroup: () => SelectGroup,
@@ -103,7 +108,6 @@ __export(index_exports, {
103
108
  Textarea: () => Textarea,
104
109
  ThemeContext: () => kreativCore.ThemeContext,
105
110
  ThemeToggler: () => ThemeToggler,
106
- cardSkeleton: () => cardSkeleton,
107
111
  cn: () => cn,
108
112
  defineRecipe: () => kreativCore.defineRecipe,
109
113
  defineSemanticToken: () => kreativCore.defineSemanticToken,
@@ -126,11 +130,13 @@ __export(index_exports, {
126
130
  useButtonGroupContext: () => useButtonGroupContext,
127
131
  useButtonGroupItemContext: () => useButtonGroupItemContext,
128
132
  useClearableField: () => useClearableField,
133
+ useElementScrollProgress: () => useElementScrollProgress,
129
134
  useFloatingSide: () => useFloatingSide,
130
135
  useFormContext: () => useFormContext,
131
136
  useKeyboardShortcuts: () => useKeyboardShortcuts,
132
137
  useOptionalButtonGroupContext: () => useOptionalButtonGroupContext,
133
138
  useOptionalButtonGroupItemContext: () => useOptionalButtonGroupItemContext,
139
+ useScrollProgress: () => useScrollProgress,
134
140
  useStatusTransition: () => useStatusTransition
135
141
  });
136
142
  function cn(...inputs) {
@@ -178,6 +184,46 @@ function isMotionGated(props) {
178
184
  return props["data-kui-motion-gated"] === true || props["data-kui-motion-gated"] === "true";
179
185
  }
180
186
  __name(isMotionGated, "isMotionGated");
187
+
188
+ // src/utils/resolveColor.ts
189
+ var RAW_COLOR = /^(#|rgb|hsl|hwb|lab|lch|oklab|oklch|color\(|var\()/i;
190
+ function isRawColor(value) {
191
+ return RAW_COLOR.test(value) || value === "transparent" || value === "currentColor";
192
+ }
193
+ __name(isRawColor, "isRawColor");
194
+ function resolveColor(value) {
195
+ if (typeof value === "string") {
196
+ return isRawColor(value) ? value : `var(--color-kui-${value})`;
197
+ }
198
+ const token = "color" in value ? value.color : value;
199
+ return typeof token === "string" && isRawColor(token) ? token : `var(--color-kui-${String(token)})`;
200
+ }
201
+ __name(resolveColor, "resolveColor");
202
+
203
+ // src/utils/resolveRadius.ts
204
+ var RAW_LENGTH = /px|rem|em|%|vw|vh|ch|var\(/i;
205
+ function resolveRadius(value) {
206
+ if (typeof value === "number") return `${value}px`;
207
+ if (value === "none" || value === "0") return "0";
208
+ if (value === "full") return "9999px";
209
+ if (RAW_LENGTH.test(value)) return value;
210
+ return `var(--kui-radii-${value})`;
211
+ }
212
+ __name(resolveRadius, "resolveRadius");
213
+
214
+ // src/utils/resolveSpace.ts
215
+ var LENGTH_RE = /^[+-]?[\d.]+(px|rem|em|%|vw|vh|vmin|vmax|ch|ex|dvh|svh|lvh)$/i;
216
+ var FN_RE = /^[a-z-]+\(/i;
217
+ var TOKEN_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/i;
218
+ function resolveSpace(value) {
219
+ if (value == null) return void 0;
220
+ if (typeof value === "number") return `${value}px`;
221
+ const s = String(value).trim();
222
+ if (LENGTH_RE.test(s) || FN_RE.test(s)) return s;
223
+ if (TOKEN_RE.test(s)) return `var(--kui-spacing-${s})`;
224
+ return s;
225
+ }
226
+ __name(resolveSpace, "resolveSpace");
181
227
  var Adornment = React2.forwardRef(
182
228
  ({ children, position, className, ...props }, ref) => {
183
229
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -198,8 +244,6 @@ var Adornment = React2.forwardRef(
198
244
  }
199
245
  );
200
246
  Adornment.displayName = "Adornment";
201
-
202
- // src/theme/recipes/resolveRecipe.ts
203
247
  function matchesConditions(conditions, props) {
204
248
  return Object.entries(conditions).every(
205
249
  ([key, expected]) => props[key] === expected
@@ -214,7 +258,7 @@ function resolveRecipe(recipe, props = {}) {
214
258
  };
215
259
  const classes = [];
216
260
  if (recipe.base) {
217
- classes.push(recipe.base);
261
+ classes.push(kreativCore.resolveStyle(recipe.base));
218
262
  }
219
263
  if (recipe.variants) {
220
264
  for (const [variantName, variantValues] of Object.entries(
@@ -224,14 +268,14 @@ function resolveRecipe(recipe, props = {}) {
224
268
  if (value === void 0) continue;
225
269
  const variantClass = variantValues[String(value)];
226
270
  if (variantClass) {
227
- classes.push(variantClass);
271
+ classes.push(kreativCore.resolveStyle(variantClass));
228
272
  }
229
273
  }
230
274
  }
231
275
  if (recipe.compoundVariants) {
232
276
  for (const compound of recipe.compoundVariants) {
233
277
  if (matchesConditions(compound.conditions, resolvedProps)) {
234
- classes.push(compound.className);
278
+ classes.push(kreativCore.resolveStyle(compound.className));
235
279
  }
236
280
  }
237
281
  }
@@ -437,7 +481,7 @@ var Button = React2.forwardRef(
437
481
  const resolvedClassName = cn(
438
482
  recipeClasses,
439
483
  fullWidth && "w-full",
440
- isLoading && "opacity-90 pointer-events-none",
484
+ isLoading && "opacity-90 pointer-events-none text-xs",
441
485
  className
442
486
  );
443
487
  const resolvedStyle = {
@@ -799,104 +843,121 @@ var getModeIcons = /* @__PURE__ */ __name((allowSystem, labels, icons) => {
799
843
  }
800
844
  return modes;
801
845
  }, "getModeIcons");
802
- function ThemeToggler({
803
- variant = "ghost",
804
- color = "neutral",
805
- activeVariant = "solid",
806
- activeColor = "brand",
807
- size = "sm",
808
- iconOnly = false,
809
- allowSystem = false,
810
- orientation = "horizontal",
811
- rounded = false,
812
- unstyled = false,
813
- labels,
814
- icons,
815
- className,
816
- buttonProps = {},
817
- display = "buttons",
818
- animated = false,
819
- transition = defaultTransition
820
- }) {
821
- const { mode, setMode, resolvedMode, theme } = kreativCore.useTheme();
822
- const resolvedSize = size;
823
- const wrapperRadius = hooks_star.useSizeToken(resolvedSize, "radius");
824
- const indicatorRadius = hooks_star.useSizeToken(resolvedSize, "radius", "4px");
825
- const buttonWidth = hooks_star.useSizeToken(resolvedSize, "width");
826
- const activeMode = allowSystem ? mode : resolvedMode;
827
- const modes = getModeIcons(allowSystem, labels, icons);
828
- const allowedModes = modes.map((item) => item.key);
829
- const currentMode = modes.find(({ key }) => key === activeMode) ?? modes[0];
830
- const indicatorClasses = resolveRecipe(theme.recipes.Button, {
831
- variant: activeVariant,
832
- color: activeColor
833
- });
834
- const effectiveRounded = rounded && !(orientation === "vertical" && !iconOnly && !unstyled);
835
- React2.useEffect(() => {
836
- if (!rounded || effectiveRounded) return;
837
- const reasons = [];
838
- if (orientation === "vertical" && !iconOnly) {
839
- reasons.push("orientation='vertical' with iconOnly={false}");
846
+ var ThemeToggler = kreativCore.createComponent({
847
+ displayName: "ThemeToggler",
848
+ __kui: {
849
+ role: "action",
850
+ skeleton: "preserve",
851
+ video: {
852
+ id: "theme-toggler",
853
+ safe: true,
854
+ acceptsChildren: false,
855
+ interactionStates: ["hover", "pressed"],
856
+ motionGated: true
840
857
  }
841
- if (unstyled) reasons.push("unstyled={true}");
842
- if (reasons.length > 0) {
843
- console.warn(
844
- `[kreativ-ui/ThemeToggler] \`rounded\` is ignored when ${reasons.join(" and ")}.`
858
+ },
859
+ render: /* @__PURE__ */ __name(({
860
+ variant = "ghost",
861
+ color = "neutral",
862
+ activeVariant = "solid",
863
+ activeColor = "brand",
864
+ size = "sm",
865
+ iconOnly = false,
866
+ allowSystem = false,
867
+ orientation = "horizontal",
868
+ rounded = false,
869
+ unstyled = false,
870
+ labels,
871
+ icons,
872
+ className,
873
+ buttonProps = {},
874
+ display = "buttons",
875
+ animated = false,
876
+ transition = defaultTransition,
877
+ ...rest
878
+ }, _ref) => {
879
+ const { mode, setMode, resolvedMode, theme } = kreativCore.useTheme();
880
+ const motionGated = kreativCore.isMotionGated(rest);
881
+ const resolvedSize = size;
882
+ const wrapperRadius = hooks_star.useSizeToken(resolvedSize, "radius");
883
+ const indicatorRadius = hooks_star.useSizeToken(resolvedSize, "radius", "4px");
884
+ const buttonWidth = hooks_star.useSizeToken(resolvedSize, "width");
885
+ const activeMode = allowSystem ? mode : resolvedMode;
886
+ const modes = getModeIcons(allowSystem, labels, icons);
887
+ const allowedModes = modes.map((item) => item.key);
888
+ const currentMode = modes.find(({ key }) => key === activeMode) ?? modes[0];
889
+ const indicatorClasses = resolveRecipe(theme.recipes.Button, {
890
+ variant: activeVariant,
891
+ color: activeColor
892
+ });
893
+ const effectiveRounded = rounded && !(orientation === "vertical" && !iconOnly && !unstyled);
894
+ React2.useEffect(() => {
895
+ if (!rounded || effectiveRounded) return;
896
+ const reasons = [];
897
+ if (orientation === "vertical" && !iconOnly) {
898
+ reasons.push("orientation is vertical with iconOnly false");
899
+ }
900
+ if (unstyled) reasons.push("unstyled is true");
901
+ if (reasons.length > 0) {
902
+ console.warn(
903
+ `[kreativ-ui/ThemeToggler]: rounded is ignored when ${reasons.join(" and ")}.`
904
+ );
905
+ }
906
+ }, [rounded, effectiveRounded, orientation, iconOnly, unstyled]);
907
+ const handleCycle = /* @__PURE__ */ __name(() => {
908
+ const index = allowedModes.indexOf(
909
+ activeMode
910
+ );
911
+ setMode(allowedModes[(index + 1) % allowedModes.length]);
912
+ }, "handleCycle");
913
+ const isActive = /* @__PURE__ */ __name((key) => key === "system" ? mode === "system" : activeMode === key, "isActive");
914
+ const containerStyle = {
915
+ ...!effectiveRounded && {
916
+ "--kui-theme-toggler-radius": wrapperRadius
917
+ }
918
+ };
919
+ const indicatorTransition = animated && !motionGated ? { type: "spring", stiffness: 300, damping: 30, mass: 0.8 } : { duration: 0 };
920
+ if (display === "cycle") {
921
+ return /* @__PURE__ */ jsxRuntime.jsx(
922
+ CycleMode,
923
+ {
924
+ size: resolvedSize,
925
+ variant,
926
+ color,
927
+ iconOnly,
928
+ buttonProps,
929
+ animated: animated && !motionGated,
930
+ transition,
931
+ rounded: effectiveRounded,
932
+ currentMode,
933
+ onCycle: handleCycle
934
+ }
845
935
  );
846
936
  }
847
- }, [rounded, effectiveRounded, orientation, iconOnly, unstyled]);
848
- const handleCycle = /* @__PURE__ */ __name(() => {
849
- const index = allowedModes.indexOf(activeMode);
850
- setMode(allowedModes[(index + 1) % allowedModes.length]);
851
- }, "handleCycle");
852
- const isActive = /* @__PURE__ */ __name((key) => key === "system" ? mode === "system" : activeMode === key, "isActive");
853
- const containerStyle = {
854
- ...!effectiveRounded && {
855
- "--kui-theme-toggler-radius": wrapperRadius
856
- }
857
- };
858
- const indicatorTransition = animated ? { type: "spring", stiffness: 300, damping: 30, mass: 0.8 } : { duration: 0 };
859
- if (display === "cycle") {
860
937
  return /* @__PURE__ */ jsxRuntime.jsx(
861
- CycleMode,
938
+ ButtonsMode,
862
939
  {
863
940
  size: resolvedSize,
864
- variant,
865
941
  color,
866
942
  iconOnly,
867
943
  buttonProps,
868
- animated,
869
- transition,
870
- rounded: effectiveRounded,
871
- currentMode,
872
- onCycle: handleCycle
944
+ rounded,
945
+ unstyled,
946
+ className,
947
+ modes,
948
+ activeMode,
949
+ onSelect: setMode,
950
+ containerStyle,
951
+ isActive,
952
+ orientation,
953
+ indicatorClasses,
954
+ indicatorRadius,
955
+ buttonWidth,
956
+ indicatorTransition
873
957
  }
874
958
  );
875
- }
876
- return /* @__PURE__ */ jsxRuntime.jsx(
877
- ButtonsMode,
878
- {
879
- size: resolvedSize,
880
- color,
881
- iconOnly,
882
- buttonProps,
883
- rounded,
884
- unstyled,
885
- className,
886
- modes,
887
- activeMode,
888
- onSelect: setMode,
889
- containerStyle,
890
- isActive,
891
- orientation,
892
- indicatorClasses,
893
- indicatorRadius,
894
- buttonWidth,
895
- indicatorTransition
896
- }
897
- );
898
- }
899
- __name(ThemeToggler, "ThemeToggler");
959
+ }, "render")
960
+ });
900
961
 
901
962
  // src/components/forms/Input/Input.constants.ts
902
963
  var inputKindDefaults = {
@@ -14431,21 +14492,21 @@ var allProcessors = {
14431
14492
  };
14432
14493
  function toJSONSchema(input, params) {
14433
14494
  if ("_idmap" in input) {
14434
- const registry3 = input;
14495
+ const registry2 = input;
14435
14496
  const ctx2 = initializeContext({ ...params, processors: allProcessors });
14436
14497
  const defs = {};
14437
- for (const entry of registry3._idmap.entries()) {
14498
+ for (const entry of registry2._idmap.entries()) {
14438
14499
  const [_, schema] = entry;
14439
14500
  process2(schema, ctx2);
14440
14501
  }
14441
14502
  const schemas = {};
14442
14503
  const external = {
14443
- registry: registry3,
14504
+ registry: registry2,
14444
14505
  uri: params?.uri,
14445
14506
  defs
14446
14507
  };
14447
14508
  ctx2.external = external;
14448
- for (const entry of registry3._idmap.entries()) {
14509
+ for (const entry of registry2._idmap.entries()) {
14449
14510
  const [key, schema] = entry;
14450
14511
  extractDefs(ctx2, schema);
14451
14512
  schemas[key] = finalize(ctx2, schema);
@@ -17366,7 +17427,7 @@ function SelectLabel({ children, className }) {
17366
17427
  return /* @__PURE__ */ jsxRuntime.jsx("div", { id, className: cn("px-2.5 py-1.5 font-mono text-[11px] text-kui-text-muted", className), children });
17367
17428
  }
17368
17429
  __name(SelectLabel, "SelectLabel");
17369
- function SelectImpl({ options, children, ...rootProps }, ref) {
17430
+ function SelectImpl({ options, children, label, ...rootProps }, ref) {
17370
17431
  const childArray = React2__namespace.Children.toArray(children);
17371
17432
  const compound = childArray.length > 0;
17372
17433
  if (isDev() && compound && options?.length) {
@@ -17375,6 +17436,7 @@ function SelectImpl({ options, children, ...rootProps }, ref) {
17375
17436
  );
17376
17437
  }
17377
17438
  return /* @__PURE__ */ jsxRuntime.jsx(SelectRoot, { ...rootProps, ref, children: compound ? children : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
17439
+ label && /* @__PURE__ */ jsxRuntime.jsx(Select.Label, { children: label }),
17378
17440
  /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, {}) }),
17379
17441
  /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: options?.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
17380
17442
  SelectItem,
@@ -17874,362 +17936,68 @@ var TextareaCore = React2.forwardRef(
17874
17936
  }
17875
17937
  );
17876
17938
  TextareaCore.displayName = "TextareaCore";
17877
-
17878
- // src/components/forms/MarkdownEditor/markdownActions.ts
17879
- function lineBounds(value, index) {
17880
- const start = value.lastIndexOf("\n", index - 1) + 1;
17881
- const nextBreak = value.indexOf("\n", index);
17882
- const end = nextBreak === -1 ? value.length : nextBreak;
17883
- return { start, end };
17884
- }
17885
- __name(lineBounds, "lineBounds");
17886
- function selectedLineRange(value, start, end) {
17887
- const first = lineBounds(value, start);
17888
- const last = lineBounds(value, Math.max(end - 1, start));
17889
- return { from: first.start, to: last.end };
17890
- }
17891
- __name(selectedLineRange, "selectedLineRange");
17892
- function toggleWrap(value, start, end, marker) {
17893
- const before = value.slice(Math.max(0, start - marker.length), start);
17894
- const after = value.slice(end, end + marker.length);
17895
- if (before === marker && after === marker) {
17896
- const next2 = value.slice(0, start - marker.length) + value.slice(start, end) + value.slice(end + marker.length);
17897
- return {
17898
- value: next2,
17899
- selectionStart: start - marker.length,
17900
- selectionEnd: end - marker.length
17901
- };
17902
- }
17903
- const selected = value.slice(start, end);
17904
- const next = value.slice(0, start) + marker + selected + marker + value.slice(end);
17905
- return selected.length === 0 ? {
17906
- value: next,
17907
- selectionStart: start + marker.length,
17908
- selectionEnd: start + marker.length
17909
- } : {
17910
- value: next,
17911
- selectionStart: start,
17912
- selectionEnd: end + marker.length * 2
17913
- };
17914
- }
17915
- __name(toggleWrap, "toggleWrap");
17916
- function toggleLinePrefix(value, start, end, prefix) {
17917
- const { from, to } = selectedLineRange(value, start, end);
17918
- const line = value.slice(from, to);
17919
- const next = line.startsWith(prefix) ? value.slice(0, from) + line.slice(prefix.length) + value.slice(to) : value.slice(0, from) + prefix + line + value.slice(to);
17920
- const delta = (line.startsWith(prefix) ? -1 : 1) * prefix.length;
17921
- return {
17922
- value: next,
17923
- selectionStart: start + delta,
17924
- selectionEnd: end + delta
17925
- };
17926
- }
17927
- __name(toggleLinePrefix, "toggleLinePrefix");
17928
- function toggleListPrefix(value, start, end, makePrefix) {
17929
- const { from, to } = selectedLineRange(value, start, end);
17930
- const block = value.slice(from, to);
17931
- const lines = block.split("\n");
17932
- const alreadyListed = lines.every(
17933
- (l) => l.startsWith(makePrefix(0)) || /^\d+\.\s/.test(l)
17934
- );
17935
- const nextLines = lines.map(
17936
- (l, i) => alreadyListed ? l.replace(/^(\d+\.\s|-\s\[ \]\s|-\s)/, "") : makePrefix(i) + l
17937
- );
17938
- const next = value.slice(0, from) + nextLines.join("\n") + value.slice(to);
17939
- const delta = nextLines.join("\n").length - block.length;
17940
- return { value: next, selectionStart: from, selectionEnd: to + delta };
17941
- }
17942
- __name(toggleListPrefix, "toggleListPrefix");
17943
- function toggleCode(value, start, end) {
17944
- const selected = value.slice(start, end);
17945
- if (selected.includes("\n")) {
17946
- const next = value.slice(0, start) + "```\n" + selected + "\n```" + value.slice(end);
17947
- return { value: next, selectionStart: start + 4, selectionEnd: end + 4 };
17948
- }
17949
- return toggleWrap(value, start, end, "`");
17950
- }
17951
- __name(toggleCode, "toggleCode");
17952
- function insertLink(value, start, end) {
17953
- const selected = value.slice(start, end);
17954
- const label = selected || "text";
17955
- const snippet = `[${label}](url)`;
17956
- const next = value.slice(0, start) + snippet + value.slice(end);
17957
- const urlStart = start + label.length + 3;
17958
- return { value: next, selectionStart: urlStart, selectionEnd: urlStart + 3 };
17959
- }
17960
- __name(insertLink, "insertLink");
17961
- var TOOLBAR = [
17962
- {
17963
- label: "Heading",
17964
- icon: lucideReact.Heading,
17965
- action: /* @__PURE__ */ __name((v, s, e) => toggleLinePrefix(v, s, e, "### "), "action")
17966
- },
17967
- {
17968
- label: "Bold",
17969
- icon: lucideReact.Bold,
17970
- action: /* @__PURE__ */ __name((v, s, e) => toggleWrap(v, s, e, "**"), "action")
17971
- },
17972
- {
17973
- label: "Italic",
17974
- icon: lucideReact.Italic,
17975
- action: /* @__PURE__ */ __name((v, s, e) => toggleWrap(v, s, e, "_"), "action")
17976
- },
17977
- {
17978
- label: "Ordered list",
17979
- icon: lucideReact.ListOrdered,
17980
- action: /* @__PURE__ */ __name((v, s, e) => toggleListPrefix(v, s, e, (i) => `${i + 1}. `), "action")
17939
+ var Textarea = kreativCore.createComponent({
17940
+ displayName: "Textarea",
17941
+ __kui: {
17942
+ role: "formControl",
17943
+ formControl: "single",
17944
+ supports: { disabled: true, invalid: true, required: true },
17945
+ skeleton: "input-shaped",
17946
+ video: {
17947
+ id: "textarea",
17948
+ safe: true,
17949
+ acceptsChildren: false,
17950
+ interactionStates: ["focus"],
17951
+ controlled: ["value", "disabled"],
17952
+ motionGated: true
17953
+ }
17981
17954
  },
17982
- {
17983
- label: "Checklist",
17984
- icon: lucideReact.ClipboardList,
17985
- action: /* @__PURE__ */ __name((v, s, e) => toggleListPrefix(v, s, e, () => "- [ ] "), "action")
17955
+ render: /* @__PURE__ */ __name((props, ref) => {
17956
+ return /* @__PURE__ */ jsxRuntime.jsx(TextareaCore, { ref, ...props });
17957
+ }, "render")
17958
+ });
17959
+ var Checkbox = kreativCore.createComponent({
17960
+ displayName: "Checkbox",
17961
+ __kui: {
17962
+ role: "formControl",
17963
+ formControl: "single",
17964
+ supports: { disabled: true, invalid: true, required: true },
17965
+ skeleton: "input-shaped",
17966
+ video: {
17967
+ id: "checkbox",
17968
+ safe: true,
17969
+ acceptsChildren: false,
17970
+ interactionStates: ["focus"],
17971
+ controlled: ["checked", "disabled", "indeterminate"],
17972
+ motionGated: true
17973
+ }
17986
17974
  },
17987
- { label: "Code", icon: lucideReact.Code, action: toggleCode },
17988
- { label: "Link", icon: lucideReact.Link, action: insertLink }
17989
- ];
17990
- var MarkdownEditor = React2.forwardRef(
17991
- ({
17992
- renderMarkdown,
17993
- tab: tabProp,
17994
- defaultTab = "write",
17995
- onTabChange,
17996
- hint = "Markdown is supported",
17997
- value: valueProp,
17998
- defaultValue,
17999
- onValueChange,
17975
+ render: /* @__PURE__ */ __name(({
18000
17976
  className,
18001
- fullWidth,
18002
- variant = "outline",
18003
- success: success2,
17977
+ checked: checkedProp,
17978
+ defaultChecked,
17979
+ onCheckedChange,
17980
+ indeterminate = false,
17981
+ size = "sm",
18004
17982
  error: error51,
18005
- warning,
17983
+ success: success2,
17984
+ status,
18006
17985
  disabled,
18007
- maxLength,
18008
- ...textareaProps
17986
+ label,
17987
+ description,
17988
+ id: externalId,
17989
+ onChange: onChangeProp,
17990
+ required: required2,
17991
+ ...props
18009
17992
  }, ref) => {
18010
- const baseId = React2.useId();
18011
- const textareaRef = React2.useRef(null);
18012
- const [uncontrolledTab, setUncontrolledTab] = React2.useState(
18013
- defaultTab
18014
- );
18015
- const tab = tabProp ?? uncontrolledTab;
18016
- const { theme } = kreativCore.useTheme();
17993
+ const autoId = React2.useId();
18017
17994
  const field = useOptionalFormField();
18018
- const footerMessage = hint;
18019
- const [draft, setDraft] = React2.useState(() => valueProp ?? defaultValue ?? "");
18020
- const value = valueProp ?? draft;
18021
- const maxLengthReached = typeof maxLength === "number" && value.length >= maxLength;
18022
- const state = error51 || maxLengthReached ? "error" : success2 ? "success" : warning ? "warning" : field?.status ?? "none";
18023
- const editorClasses = cn(
18024
- resolveRecipe(theme.recipes.MarkdownEditor, {
18025
- variant,
18026
- state,
18027
- fullWidth,
18028
- disabled: !!disabled
18029
- }),
18030
- className
18031
- );
18032
- function setTab(next) {
18033
- if (tabProp === void 0) setUncontrolledTab(next);
18034
- onTabChange?.(next);
18035
- }
18036
- __name(setTab, "setTab");
18037
- function commit(next) {
18038
- setDraft(next);
18039
- onValueChange?.(next);
18040
- }
18041
- __name(commit, "commit");
18042
- function runAction(action) {
18043
- if (disabled) return;
18044
- const el = textareaRef.current;
18045
- if (!el) return;
18046
- const { selectionStart, selectionEnd } = el;
18047
- const edit = action(
18048
- value,
18049
- selectionStart ?? value.length,
18050
- selectionEnd ?? value.length
18051
- );
18052
- commit(edit.value);
18053
- el.focus();
18054
- requestAnimationFrame(() => {
18055
- el.setSelectionRange(edit.selectionStart, edit.selectionEnd);
18056
- });
18057
- }
18058
- __name(runAction, "runAction");
18059
- const tablistId = `${baseId}-tablist`;
18060
- const writePanelId = `${baseId}-write-panel`;
18061
- const previewPanelId = `${baseId}-preview-panel`;
18062
- const renderedPreview = React2.useMemo(
18063
- () => renderMarkdown ? renderMarkdown(value) : null,
18064
- [renderMarkdown, value]
18065
- );
18066
- React2.useEffect(() => {
18067
- if (isDev() && !renderMarkdown) {
18068
- console.warn(
18069
- "[kreativ-ui/MarkdownEditor]: no `renderMarkdown` prop was provided, so the Preview tab is just showing plain text with no markdown formatting applied. Pass a `renderMarkdown={(value) => ReactNode}` function \u2014 e.g. using react-markdown \u2014 to enable a real preview:\n\n import ReactMarkdown from 'react-markdown';\n <Textarea allowMarkdown renderMarkdown={(v) => <ReactMarkdown>{v}</ReactMarkdown>} />"
18070
- );
18071
- }
18072
- }, [renderMarkdown]);
18073
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: editorClasses, children: [
18074
- /* @__PURE__ */ jsxRuntime.jsxs(
18075
- "div",
18076
- {
18077
- role: "tablist",
18078
- "aria-label": "Markdown editor mode",
18079
- id: tablistId,
18080
- className: "flex items-center gap-4 border-b border-kui-border px-3",
18081
- children: [
18082
- ["write", "preview"].map((t) => /* @__PURE__ */ jsxRuntime.jsx(
18083
- "button",
18084
- {
18085
- type: "button",
18086
- role: "tab",
18087
- id: `${baseId}-${t}-tab`,
18088
- "aria-selected": tab === t,
18089
- "aria-controls": t === "write" ? writePanelId : previewPanelId,
18090
- onClick: () => setTab(t),
18091
- disabled,
18092
- className: cn(
18093
- "border-b-2 py-2.5 text-sm capitalize transition-colors",
18094
- "disabled:pointer-events-none disabled:cursor-not-allowed",
18095
- tab === t ? "border-kui-brand text-kui-text" : "border-transparent text-kui-text-muted hover:text-kui-text"
18096
- ),
18097
- children: t
18098
- },
18099
- t
18100
- )),
18101
- tab === "write" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto flex items-center gap-1 py-1.5", children: TOOLBAR.map(({ label, icon: Icon, action }) => /* @__PURE__ */ jsxRuntime.jsx(
18102
- "button",
18103
- {
18104
- type: "button",
18105
- "aria-label": label,
18106
- onClick: () => runAction(action),
18107
- disabled,
18108
- className: "rounded-(--kui-radii-sm) p-1.5 text-kui-text-muted transition-colors hover:bg-kui-surface-raised hover:text-kui-text disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
18109
- children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: 15 })
18110
- },
18111
- label
18112
- )) })
18113
- ]
18114
- }
18115
- ),
18116
- /* @__PURE__ */ jsxRuntime.jsx(
18117
- "div",
18118
- {
18119
- id: writePanelId,
18120
- role: "tabpanel",
18121
- "aria-labelledby": `${baseId}-write-tab`,
18122
- hidden: tab !== "write",
18123
- children: /* @__PURE__ */ jsxRuntime.jsx(
18124
- TextareaCore,
18125
- {
18126
- ref: (node) => {
18127
- textareaRef.current = node;
18128
- if (typeof ref === "function") {
18129
- ref(node);
18130
- } else if (ref) {
18131
- ref.current = node;
18132
- }
18133
- },
18134
- value,
18135
- onValueChange: commit,
18136
- embedded: true,
18137
- resize: "vertical",
18138
- disabled,
18139
- maxLength,
18140
- ...textareaProps
18141
- }
18142
- )
18143
- }
18144
- ),
18145
- /* @__PURE__ */ jsxRuntime.jsx(
18146
- "div",
18147
- {
18148
- id: previewPanelId,
18149
- role: "tabpanel",
18150
- "aria-labelledby": `${baseId}-preview-tab`,
18151
- hidden: tab !== "preview",
18152
- className: "min-h-32 p-3 text-sm text-kui-text",
18153
- children: renderMarkdown ? renderedPreview : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-kui-text-muted", children: "No renderMarkdown provided \u2014 showing raw text." })
18154
- }
18155
- ),
18156
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2 border-t border-kui-border px-3 py-2 text-xs z-1", children: footerMessage })
18157
- ] });
18158
- }
18159
- );
18160
- MarkdownEditor.displayName = "MarkdownEditor";
18161
- var Textarea = kreativCore.createComponent({
18162
- displayName: "Textarea",
18163
- __kui: {
18164
- role: "formControl",
18165
- formControl: "single",
18166
- supports: { disabled: true, invalid: true, required: true },
18167
- skeleton: "input-shaped",
18168
- video: {
18169
- id: "textarea",
18170
- safe: true,
18171
- acceptsChildren: false,
18172
- interactionStates: ["focus"],
18173
- controlled: ["value", "disabled"],
18174
- motionGated: true
18175
- }
18176
- },
18177
- render: /* @__PURE__ */ __name(({ allowMarkdown, ...props }, ref) => {
18178
- if (allowMarkdown) {
18179
- return /* @__PURE__ */ jsxRuntime.jsx(
18180
- MarkdownEditor,
18181
- {
18182
- ref,
18183
- ...props,
18184
- embedded: true
18185
- }
18186
- );
18187
- }
18188
- return /* @__PURE__ */ jsxRuntime.jsx(TextareaCore, { ref, ...props });
18189
- }, "render")
18190
- });
18191
- var Checkbox = kreativCore.createComponent({
18192
- displayName: "Checkbox",
18193
- __kui: {
18194
- role: "formControl",
18195
- formControl: "single",
18196
- supports: { disabled: true, invalid: true, required: true },
18197
- skeleton: "input-shaped",
18198
- video: {
18199
- id: "checkbox",
18200
- safe: true,
18201
- acceptsChildren: false,
18202
- interactionStates: ["focus"],
18203
- controlled: ["checked", "disabled", "indeterminate"],
18204
- motionGated: true
18205
- }
18206
- },
18207
- render: /* @__PURE__ */ __name(({
18208
- className,
18209
- checked: checkedProp,
18210
- defaultChecked,
18211
- onCheckedChange,
18212
- indeterminate = false,
18213
- size = "sm",
18214
- error: error51,
18215
- success: success2,
18216
- status,
18217
- disabled,
18218
- label,
18219
- description,
18220
- id: externalId,
18221
- onChange: onChangeProp,
18222
- required: required2,
18223
- ...props
18224
- }, ref) => {
18225
- const autoId = React2.useId();
18226
- const field = useOptionalFormField();
18227
- const { theme } = kreativCore.useTheme();
18228
- const id = field?.id ?? externalId ?? autoId;
18229
- const isDisabled = disabled || Boolean(field?.disabled);
18230
- const inputRef = React2.useRef(null);
18231
- const [internalChecked, setInternalChecked] = React2.useState(
18232
- defaultChecked ?? false
17995
+ const { theme } = kreativCore.useTheme();
17996
+ const id = field?.id ?? externalId ?? autoId;
17997
+ const isDisabled = disabled || Boolean(field?.disabled);
17998
+ const inputRef = React2.useRef(null);
17999
+ const [internalChecked, setInternalChecked] = React2.useState(
18000
+ defaultChecked ?? false
18233
18001
  );
18234
18002
  const isControlled = checkedProp !== void 0;
18235
18003
  const checked = isControlled ? checkedProp : internalChecked;
@@ -20092,75 +19860,413 @@ var FormField = Object.assign(FormFieldForwardRef, {
20092
19860
  Message: FormFieldMessage,
20093
19861
  Control: FormFieldControl
20094
19862
  });
20095
- var RadioGroupContext = React2.createContext(null);
20096
- function useRadioGroupContext() {
20097
- const ctx = React2.useContext(RadioGroupContext);
20098
- if (!ctx) {
20099
- throw new Error("<Radio /> must be rendered inside <RadioGroup>.");
20100
- }
20101
- return ctx;
19863
+
19864
+ // src/components/forms/MarkdownEditor/markdownActions.ts
19865
+ function lineBounds(value, index) {
19866
+ const start = value.lastIndexOf("\n", index - 1) + 1;
19867
+ const nextBreak = value.indexOf("\n", index);
19868
+ const end = nextBreak === -1 ? value.length : nextBreak;
19869
+ return { start, end };
20102
19870
  }
20103
- __name(useRadioGroupContext, "useRadioGroupContext");
20104
- function RadioGroup({
20105
- value: valueProp,
20106
- defaultValue,
20107
- onValueChange,
20108
- name: nameProp,
20109
- disabled = false,
20110
- required: required2 = false,
20111
- orientation = "vertical",
20112
- size = "md",
20113
- error: error51,
20114
- success: success2,
20115
- className,
20116
- children
20117
- }) {
20118
- const autoName = React2.useId();
20119
- const name = nameProp ?? autoName;
20120
- const field = useOptionalFormField();
20121
- const [internalValue, setInternalValue] = React2.useState(defaultValue);
20122
- const value = valueProp !== void 0 ? valueProp : internalValue;
20123
- const handleValueChange = React2.useCallback(
20124
- (next) => {
20125
- if (valueProp === void 0) setInternalValue(next);
20126
- onValueChange?.(next);
20127
- },
20128
- [valueProp, onValueChange]
20129
- );
20130
- const isInvalid = error51 ?? field?.invalid ?? false;
20131
- const isSuccess = success2 ?? false;
20132
- const state = isInvalid ? "error" : isSuccess ? "success" : "none";
20133
- const groupRequired = required2 || !!field?.required;
20134
- return /* @__PURE__ */ jsxRuntime.jsx(
20135
- RadioGroupContext.Provider,
20136
- {
20137
- value: {
20138
- name,
20139
- value,
20140
- onValueChange: handleValueChange,
20141
- disabled,
20142
- size,
20143
- state,
20144
- groupRequired
20145
- },
20146
- children: /* @__PURE__ */ jsxRuntime.jsx(
20147
- "div",
20148
- {
20149
- role: "radiogroup",
20150
- "aria-labelledby": field?.hasExternalLabel ? `${field.id}-label` : void 0,
20151
- "aria-describedby": field?.describedBy,
20152
- "aria-required": groupRequired || void 0,
20153
- "aria-invalid": isInvalid || void 0,
20154
- className: cn(
20155
- "flex gap-3",
20156
- orientation === "horizontal" ? "flex-row flex-wrap" : "flex-col",
20157
- className
20158
- ),
20159
- children
20160
- }
20161
- )
20162
- }
20163
- );
19871
+ __name(lineBounds, "lineBounds");
19872
+ function selectedLineRange(value, start, end) {
19873
+ const first = lineBounds(value, start);
19874
+ const last = lineBounds(value, Math.max(end - 1, start));
19875
+ return { from: first.start, to: last.end };
19876
+ }
19877
+ __name(selectedLineRange, "selectedLineRange");
19878
+ function toggleWrap(value, start, end, marker) {
19879
+ const before = value.slice(Math.max(0, start - marker.length), start);
19880
+ const after = value.slice(end, end + marker.length);
19881
+ if (before === marker && after === marker) {
19882
+ const next2 = value.slice(0, start - marker.length) + value.slice(start, end) + value.slice(end + marker.length);
19883
+ return {
19884
+ value: next2,
19885
+ selectionStart: start - marker.length,
19886
+ selectionEnd: end - marker.length
19887
+ };
19888
+ }
19889
+ const selected = value.slice(start, end);
19890
+ const next = value.slice(0, start) + marker + selected + marker + value.slice(end);
19891
+ return selected.length === 0 ? {
19892
+ value: next,
19893
+ selectionStart: start + marker.length,
19894
+ selectionEnd: start + marker.length
19895
+ } : {
19896
+ value: next,
19897
+ selectionStart: start,
19898
+ selectionEnd: end + marker.length * 2
19899
+ };
19900
+ }
19901
+ __name(toggleWrap, "toggleWrap");
19902
+ function toggleLinePrefix(value, start, end, prefix) {
19903
+ const { from, to } = selectedLineRange(value, start, end);
19904
+ const line = value.slice(from, to);
19905
+ const next = line.startsWith(prefix) ? value.slice(0, from) + line.slice(prefix.length) + value.slice(to) : value.slice(0, from) + prefix + line + value.slice(to);
19906
+ const delta = (line.startsWith(prefix) ? -1 : 1) * prefix.length;
19907
+ return {
19908
+ value: next,
19909
+ selectionStart: start + delta,
19910
+ selectionEnd: end + delta
19911
+ };
19912
+ }
19913
+ __name(toggleLinePrefix, "toggleLinePrefix");
19914
+ function toggleListPrefix(value, start, end, makePrefix) {
19915
+ const { from, to } = selectedLineRange(value, start, end);
19916
+ const block = value.slice(from, to);
19917
+ const lines = block.split("\n");
19918
+ const alreadyListed = lines.every(
19919
+ (l) => l.startsWith(makePrefix(0)) || /^\d+\.\s/.test(l)
19920
+ );
19921
+ const nextLines = lines.map(
19922
+ (l, i) => alreadyListed ? l.replace(/^(\d+\.\s|-\s\[ \]\s|-\s)/, "") : makePrefix(i) + l
19923
+ );
19924
+ const next = value.slice(0, from) + nextLines.join("\n") + value.slice(to);
19925
+ const delta = nextLines.join("\n").length - block.length;
19926
+ return { value: next, selectionStart: from, selectionEnd: to + delta };
19927
+ }
19928
+ __name(toggleListPrefix, "toggleListPrefix");
19929
+ function toggleCode(value, start, end) {
19930
+ const selected = value.slice(start, end);
19931
+ if (selected.includes("\n")) {
19932
+ const next = value.slice(0, start) + "```\n" + selected + "\n```" + value.slice(end);
19933
+ return { value: next, selectionStart: start + 4, selectionEnd: end + 4 };
19934
+ }
19935
+ return toggleWrap(value, start, end, "`");
19936
+ }
19937
+ __name(toggleCode, "toggleCode");
19938
+ function insertLink(value, start, end) {
19939
+ const selected = value.slice(start, end);
19940
+ const label = selected || "text";
19941
+ const snippet = `[${label}](url)`;
19942
+ const next = value.slice(0, start) + snippet + value.slice(end);
19943
+ const urlStart = start + label.length + 3;
19944
+ return { value: next, selectionStart: urlStart, selectionEnd: urlStart + 3 };
19945
+ }
19946
+ __name(insertLink, "insertLink");
19947
+ var TOOLBAR = [
19948
+ {
19949
+ label: "Heading",
19950
+ icon: lucideReact.Heading,
19951
+ action: /* @__PURE__ */ __name((v, s, e) => toggleLinePrefix(v, s, e, "### "), "action")
19952
+ },
19953
+ {
19954
+ label: "Bold",
19955
+ icon: lucideReact.Bold,
19956
+ action: /* @__PURE__ */ __name((v, s, e) => toggleWrap(v, s, e, "**"), "action"),
19957
+ shortcutKey: "b"
19958
+ },
19959
+ {
19960
+ label: "Italic",
19961
+ icon: lucideReact.Italic,
19962
+ action: /* @__PURE__ */ __name((v, s, e) => toggleWrap(v, s, e, "_"), "action"),
19963
+ shortcutKey: "i"
19964
+ },
19965
+ {
19966
+ label: "Strikethrough",
19967
+ icon: lucideReact.Strikethrough,
19968
+ action: /* @__PURE__ */ __name((v, s, e) => toggleWrap(v, s, e, "~~"), "action")
19969
+ },
19970
+ {
19971
+ label: "Quote",
19972
+ icon: lucideReact.Quote,
19973
+ action: /* @__PURE__ */ __name((v, s, e) => toggleLinePrefix(v, s, e, "> "), "action")
19974
+ },
19975
+ {
19976
+ label: "Ordered list",
19977
+ icon: lucideReact.ListOrdered,
19978
+ action: /* @__PURE__ */ __name((v, s, e) => toggleListPrefix(v, s, e, (i) => `${i + 1}. `), "action")
19979
+ },
19980
+ {
19981
+ label: "Checklist",
19982
+ icon: lucideReact.ClipboardList,
19983
+ action: /* @__PURE__ */ __name((v, s, e) => toggleListPrefix(v, s, e, () => "- [ ] "), "action")
19984
+ },
19985
+ { label: "Code", icon: lucideReact.Code, action: toggleCode },
19986
+ { label: "Link", icon: lucideReact.Link, action: insertLink, shortcutKey: "k" }
19987
+ ];
19988
+ var SHORTCUT_MAP = new Map(
19989
+ TOOLBAR.filter((item) => item.shortcutKey).map((item) => [
19990
+ item.shortcutKey,
19991
+ item
19992
+ ])
19993
+ );
19994
+ var isMac = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform);
19995
+ var modLabel = isMac ? "\u2318" : "Ctrl";
19996
+ function shortcutHint(item) {
19997
+ if (!item.shortcutKey) return item.label;
19998
+ return `${item.label} (${modLabel}+${item.shortcutKey.toUpperCase()})`;
19999
+ }
20000
+ __name(shortcutHint, "shortcutHint");
20001
+ var MarkdownEditor = kreativCore.createComponent({
20002
+ displayName: "MarkdownEditor",
20003
+ __kui: {
20004
+ role: "formControl",
20005
+ formControl: "single",
20006
+ supports: { disabled: true, invalid: true, required: true },
20007
+ skeleton: "input-shaped",
20008
+ video: {
20009
+ id: "markdown-editor",
20010
+ safe: true,
20011
+ acceptsChildren: false,
20012
+ interactionStates: ["focus"],
20013
+ controlled: ["value", "disabled"],
20014
+ motionGated: true
20015
+ }
20016
+ },
20017
+ render: /* @__PURE__ */ __name(({
20018
+ renderMarkdown,
20019
+ tab: tabProp,
20020
+ defaultTab = "write",
20021
+ onTabChange,
20022
+ hint = "Markdown is supported",
20023
+ value: valueProp,
20024
+ defaultValue,
20025
+ onValueChange,
20026
+ className,
20027
+ fullWidth,
20028
+ variant = "outline",
20029
+ success: success2,
20030
+ error: error51,
20031
+ warning,
20032
+ disabled,
20033
+ maxLength,
20034
+ ...textareaProps
20035
+ }, ref) => {
20036
+ const baseId = React2.useId();
20037
+ const textareaRef = React2.useRef(null);
20038
+ const { theme } = kreativCore.useTheme();
20039
+ const field = useOptionalFormField();
20040
+ const motionGated = kreativCore.isMotionGated(textareaProps);
20041
+ const isDisabled = disabled || Boolean(field?.disabled);
20042
+ const [uncontrolledTab, setUncontrolledTab] = React2.useState(
20043
+ defaultTab
20044
+ );
20045
+ const tab = tabProp ?? uncontrolledTab;
20046
+ const footerMessage = hint;
20047
+ const [draft, setDraft] = React2.useState(() => valueProp ?? defaultValue ?? "");
20048
+ const value = valueProp ?? draft;
20049
+ const maxLengthReached = typeof maxLength === "number" && value.length >= maxLength;
20050
+ const state = error51 || maxLengthReached ? "error" : success2 ? "success" : warning ? "warning" : field?.status ?? "none";
20051
+ const editorClasses = cn(
20052
+ resolveRecipe(theme.recipes.MarkdownEditor, {
20053
+ variant,
20054
+ state,
20055
+ fullWidth,
20056
+ disabled: isDisabled
20057
+ }),
20058
+ className
20059
+ );
20060
+ function setTab(next) {
20061
+ if (tabProp === void 0) setUncontrolledTab(next);
20062
+ onTabChange?.(next);
20063
+ }
20064
+ __name(setTab, "setTab");
20065
+ function commit(next) {
20066
+ setDraft(next);
20067
+ onValueChange?.(next);
20068
+ }
20069
+ __name(commit, "commit");
20070
+ function runAction(action) {
20071
+ if (isDisabled) return;
20072
+ const el = textareaRef.current;
20073
+ if (!el) return;
20074
+ const { selectionStart, selectionEnd } = el;
20075
+ const edit = action(
20076
+ value,
20077
+ selectionStart ?? value.length,
20078
+ selectionEnd ?? value.length
20079
+ );
20080
+ commit(edit.value);
20081
+ el.focus();
20082
+ const place = /* @__PURE__ */ __name(() => {
20083
+ el.setSelectionRange(edit.selectionStart, edit.selectionEnd);
20084
+ }, "place");
20085
+ if (motionGated) place();
20086
+ else requestAnimationFrame(place);
20087
+ }
20088
+ __name(runAction, "runAction");
20089
+ function handleToolbarKeyDown(event) {
20090
+ if (isDisabled) return;
20091
+ if (event.nativeEvent.isComposing) return;
20092
+ const mod = isMac ? event.metaKey : event.ctrlKey;
20093
+ if (!mod || event.altKey) return;
20094
+ const key = event.key.toLowerCase();
20095
+ const item = SHORTCUT_MAP.get(key);
20096
+ if (!item) return;
20097
+ event.preventDefault();
20098
+ runAction(item.action);
20099
+ }
20100
+ __name(handleToolbarKeyDown, "handleToolbarKeyDown");
20101
+ const writePanelId = `${baseId}-write-panel`;
20102
+ const previewPanelId = `${baseId}-preview-panel`;
20103
+ const renderedPreview = React2.useMemo(
20104
+ () => renderMarkdown ? renderMarkdown(value) : null,
20105
+ [renderMarkdown, value]
20106
+ );
20107
+ React2.useEffect(() => {
20108
+ if (isDev() && !renderMarkdown) {
20109
+ console.warn(
20110
+ "[kreativ-ui/MarkdownEditor]: no renderMarkdown prop was provided, so the Preview tab is showing plain text. Pass renderMarkdown={(value) => ReactNode}."
20111
+ );
20112
+ }
20113
+ }, [renderMarkdown]);
20114
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: editorClasses, children: [
20115
+ /* @__PURE__ */ jsxRuntime.jsxs(
20116
+ "div",
20117
+ {
20118
+ role: "tablist",
20119
+ "aria-label": "Markdown editor mode",
20120
+ id: `${baseId}-tablist`,
20121
+ className: "flex items-center gap-4 border-b border-kui-border px-3",
20122
+ children: [
20123
+ ["write", "preview"].map((t) => /* @__PURE__ */ jsxRuntime.jsx(
20124
+ "button",
20125
+ {
20126
+ type: "button",
20127
+ role: "tab",
20128
+ id: `${baseId}-${t}-tab`,
20129
+ "aria-selected": tab === t,
20130
+ "aria-controls": t === "write" ? writePanelId : previewPanelId,
20131
+ onClick: () => setTab(t),
20132
+ disabled: isDisabled,
20133
+ className: cn(
20134
+ "border-b-2 py-2.5 text-sm capitalize",
20135
+ !motionGated && "transition-colors",
20136
+ "disabled:pointer-events-none disabled:cursor-not-allowed",
20137
+ tab === t ? "border-kui-brand text-kui-text" : "border-transparent text-kui-text-muted hover:text-kui-text"
20138
+ ),
20139
+ children: t
20140
+ },
20141
+ t
20142
+ )),
20143
+ tab === "write" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto flex items-center gap-1 py-1.5 overflow-x-auto kui-scrollbar", children: TOOLBAR.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
20144
+ "button",
20145
+ {
20146
+ type: "button",
20147
+ "aria-label": shortcutHint(item),
20148
+ title: shortcutHint(item),
20149
+ onMouseDown: (event) => event.preventDefault(),
20150
+ onClick: () => runAction(item.action),
20151
+ disabled: isDisabled,
20152
+ className: cn(
20153
+ "rounded-(--kui-radii-sm) p-1.5 text-kui-text-muted hover:bg-kui-surface-raised hover:text-kui-text disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
20154
+ !motionGated && "transition-colors"
20155
+ ),
20156
+ children: /* @__PURE__ */ jsxRuntime.jsx(item.icon, { size: 15 })
20157
+ },
20158
+ item.label
20159
+ )) })
20160
+ ]
20161
+ }
20162
+ ),
20163
+ /* @__PURE__ */ jsxRuntime.jsx(
20164
+ "div",
20165
+ {
20166
+ id: writePanelId,
20167
+ role: "tabpanel",
20168
+ "aria-labelledby": `${baseId}-write-tab`,
20169
+ hidden: tab !== "write",
20170
+ onKeyDown: handleToolbarKeyDown,
20171
+ children: /* @__PURE__ */ jsxRuntime.jsx(
20172
+ TextareaCore,
20173
+ {
20174
+ ref: kreativCore.composeRefs(textareaRef, ref),
20175
+ value,
20176
+ onValueChange: commit,
20177
+ embedded: true,
20178
+ resize: "vertical",
20179
+ disabled: isDisabled,
20180
+ maxLength,
20181
+ ...textareaProps
20182
+ }
20183
+ )
20184
+ }
20185
+ ),
20186
+ /* @__PURE__ */ jsxRuntime.jsx(
20187
+ "div",
20188
+ {
20189
+ id: previewPanelId,
20190
+ role: "tabpanel",
20191
+ "aria-labelledby": `${baseId}-preview-tab`,
20192
+ hidden: tab !== "preview",
20193
+ className: "min-h-32 p-3 text-sm text-kui-text",
20194
+ children: renderMarkdown ? renderedPreview : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-kui-text-muted", children: "No renderMarkdown provided \u2014 showing raw text." })
20195
+ }
20196
+ ),
20197
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2 border-t border-kui-border px-3 py-2 text-xs z-1", children: footerMessage })
20198
+ ] });
20199
+ }, "render")
20200
+ });
20201
+ var RadioGroupContext = React2.createContext(null);
20202
+ function useRadioGroupContext() {
20203
+ const ctx = React2.useContext(RadioGroupContext);
20204
+ if (!ctx) {
20205
+ throw new Error("<Radio /> must be rendered inside <RadioGroup>.");
20206
+ }
20207
+ return ctx;
20208
+ }
20209
+ __name(useRadioGroupContext, "useRadioGroupContext");
20210
+ function RadioGroup({
20211
+ value: valueProp,
20212
+ defaultValue,
20213
+ onValueChange,
20214
+ name: nameProp,
20215
+ disabled = false,
20216
+ required: required2 = false,
20217
+ orientation = "vertical",
20218
+ size = "md",
20219
+ error: error51,
20220
+ success: success2,
20221
+ className,
20222
+ children
20223
+ }) {
20224
+ const autoName = React2.useId();
20225
+ const name = nameProp ?? autoName;
20226
+ const field = useOptionalFormField();
20227
+ const [internalValue, setInternalValue] = React2.useState(defaultValue);
20228
+ const value = valueProp !== void 0 ? valueProp : internalValue;
20229
+ const handleValueChange = React2.useCallback(
20230
+ (next) => {
20231
+ if (valueProp === void 0) setInternalValue(next);
20232
+ onValueChange?.(next);
20233
+ },
20234
+ [valueProp, onValueChange]
20235
+ );
20236
+ const isInvalid = error51 ?? field?.invalid ?? false;
20237
+ const isSuccess = success2 ?? false;
20238
+ const state = isInvalid ? "error" : isSuccess ? "success" : "none";
20239
+ const groupRequired = required2 || !!field?.required;
20240
+ return /* @__PURE__ */ jsxRuntime.jsx(
20241
+ RadioGroupContext.Provider,
20242
+ {
20243
+ value: {
20244
+ name,
20245
+ value,
20246
+ onValueChange: handleValueChange,
20247
+ disabled,
20248
+ size,
20249
+ state,
20250
+ groupRequired
20251
+ },
20252
+ children: /* @__PURE__ */ jsxRuntime.jsx(
20253
+ "div",
20254
+ {
20255
+ role: "radiogroup",
20256
+ "aria-labelledby": field?.hasExternalLabel ? `${field.id}-label` : void 0,
20257
+ "aria-describedby": field?.describedBy,
20258
+ "aria-required": groupRequired || void 0,
20259
+ "aria-invalid": isInvalid || void 0,
20260
+ className: cn(
20261
+ "flex gap-3",
20262
+ orientation === "horizontal" ? "flex-row flex-wrap" : "flex-col",
20263
+ className
20264
+ ),
20265
+ children
20266
+ }
20267
+ )
20268
+ }
20269
+ );
20164
20270
  }
20165
20271
  __name(RadioGroup, "RadioGroup");
20166
20272
  var radioBubbleVariants = classVarianceAuthority.cva(
@@ -21099,6 +21205,10 @@ MultiSelect.Content = MultiSelectContent;
21099
21205
  MultiSelect.Item = MultiSelectItem;
21100
21206
 
21101
21207
  // src/utils/responsive.ts
21208
+ function isResponsiveValue(value) {
21209
+ return typeof value === "object" && value !== null;
21210
+ }
21211
+ __name(isResponsiveValue, "isResponsiveValue");
21102
21212
  function resolveResponsiveValue(value) {
21103
21213
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
21104
21214
  return {
@@ -21148,108 +21258,1312 @@ var Container = React2.forwardRef(
21148
21258
  {
21149
21259
  ref,
21150
21260
  "data-kui-responsive": attribute,
21151
- className: cn(recipeClassName, centered && "mx-auto", className),
21152
- style,
21261
+ className: cn(recipeClassName, centered && "mx-auto", className),
21262
+ style,
21263
+ ...rest,
21264
+ children
21265
+ }
21266
+ )
21267
+ ] });
21268
+ }
21269
+ );
21270
+ Container.displayName = "Container";
21271
+ var Flex = kreativCore.createComponent({
21272
+ displayName: "Flex",
21273
+ __kui: {
21274
+ role: "layout",
21275
+ skeleton: "preserve",
21276
+ video: {
21277
+ id: "flex",
21278
+ safe: true,
21279
+ acceptsChildren: true,
21280
+ interactionStates: []
21281
+ }
21282
+ },
21283
+ render: /* @__PURE__ */ __name(({
21284
+ inline = false,
21285
+ direction = "row",
21286
+ wrap = "nowrap",
21287
+ align,
21288
+ justify,
21289
+ gap,
21290
+ gapX,
21291
+ gapY,
21292
+ grow,
21293
+ shrink,
21294
+ basis,
21295
+ fullWidth,
21296
+ fullHeight,
21297
+ as: Tag = "div",
21298
+ className,
21299
+ style,
21300
+ unstyled,
21301
+ children,
21302
+ ...rest
21303
+ }, ref) => {
21304
+ const { theme } = kreativCore.useTheme();
21305
+ const responsiveStyles = (0, hooks_exports.useMergedResponsiveStyles)([
21306
+ [direction, (v) => ({ flexDirection: v })],
21307
+ [wrap, (v) => ({ flexWrap: v })],
21308
+ [align, (v) => ({ alignItems: v })],
21309
+ [justify, (v) => ({ justifyContent: v })],
21310
+ [gap, (v) => ({ gap: resolveSpace(v) })],
21311
+ [gapX, (v) => ({ columnGap: resolveSpace(v) })],
21312
+ [gapY, (v) => ({ rowGap: resolveSpace(v) })],
21313
+ [grow, (v) => ({ flexGrow: v === true ? 1 : v === false ? 0 : v })],
21314
+ [shrink, (v) => ({ flexShrink: v === true ? 1 : v === false ? 0 : v })],
21315
+ [basis, (v) => ({ flexBasis: v })]
21316
+ ]);
21317
+ const { attribute, style: responsiveCss } = (0, hooks_exports.useResponsiveStyles)(responsiveStyles);
21318
+ const recipeClasses = resolveRecipe(theme.recipes.Flex, {
21319
+ inline,
21320
+ fullWidth: Boolean(fullWidth),
21321
+ fullHeight: Boolean(fullHeight)
21322
+ });
21323
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
21324
+ /* @__PURE__ */ jsxRuntime.jsx(ResponsiveStyle, { css: responsiveCss }),
21325
+ /* @__PURE__ */ jsxRuntime.jsx(
21326
+ Tag,
21327
+ {
21328
+ ref,
21329
+ "data-kui-responsive": attribute,
21330
+ className: cn(!unstyled && recipeClasses, className),
21331
+ style,
21332
+ ...rest,
21333
+ children
21334
+ }
21335
+ )
21336
+ ] });
21337
+ }, "render")
21338
+ });
21339
+ var Stack = React2.forwardRef(
21340
+ ({ orientation = "vertical", divider, children, ...rest }, ref) => {
21341
+ const direction = orientation === "horizontal" ? "row" : "column";
21342
+ if (!divider) {
21343
+ return /* @__PURE__ */ jsxRuntime.jsx(Flex, { ref, direction, ...rest, children });
21344
+ }
21345
+ const items = React2.Children.toArray(children).filter(React2.isValidElement);
21346
+ return /* @__PURE__ */ jsxRuntime.jsx(Flex, { ref, direction, ...rest, children: items.map((child, index) => /* @__PURE__ */ jsxRuntime.jsxs(React2.Fragment, { children: [
21347
+ child,
21348
+ index < items.length - 1 && divider
21349
+ ] }, child.key ?? index)) });
21350
+ }
21351
+ );
21352
+ Stack.displayName = "Stack";
21353
+ function spanValue(value) {
21354
+ return value === "full" ? "1 / -1" : `span ${value}`;
21355
+ }
21356
+ __name(spanValue, "spanValue");
21357
+ var GridItem = kreativCore.createComponent({
21358
+ displayName: "Grid.Item",
21359
+ __kui: {
21360
+ role: "layout",
21361
+ skeleton: "preserve",
21362
+ groupSlot: "Grid",
21363
+ video: {
21364
+ id: "grid-item",
21365
+ safe: true,
21366
+ acceptsChildren: true,
21367
+ interactionStates: []
21368
+ }
21369
+ },
21370
+ render: /* @__PURE__ */ __name(({
21371
+ span,
21372
+ rowSpan,
21373
+ as: Tag = "div",
21374
+ className,
21375
+ style,
21376
+ unstyled,
21377
+ children,
21378
+ ...rest
21379
+ }, ref) => {
21380
+ const responsiveStyles = (0, hooks_exports.useMergedResponsiveStyles)([
21381
+ [span, (v) => ({ gridColumn: spanValue(v) })],
21382
+ [rowSpan, (v) => ({ gridRow: spanValue(v) })]
21383
+ ]);
21384
+ const { attribute, style: responsiveCss } = (0, hooks_exports.useResponsiveStyles)(responsiveStyles);
21385
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
21386
+ /* @__PURE__ */ jsxRuntime.jsx(ResponsiveStyle, { css: responsiveCss }),
21387
+ /* @__PURE__ */ jsxRuntime.jsx(
21388
+ Tag,
21389
+ {
21390
+ ref,
21391
+ "data-kui-responsive": attribute,
21392
+ className: cn(!unstyled && className),
21393
+ style,
21394
+ ...rest,
21395
+ children
21396
+ }
21397
+ )
21398
+ ] });
21399
+ }, "render")
21400
+ });
21401
+ var RAW_LENGTH2 = /px|rem|em|%|vw|vh|ch|var\(/i;
21402
+ function resolveTrackSize(value) {
21403
+ if (typeof value === "number") return `${value}px`;
21404
+ if (RAW_LENGTH2.test(value)) return value;
21405
+ return resolveSpace(value);
21406
+ }
21407
+ __name(resolveTrackSize, "resolveTrackSize");
21408
+ var GridRoot = kreativCore.createComponent({
21409
+ displayName: "Grid",
21410
+ __kui: {
21411
+ role: "layout",
21412
+ skeleton: "preserve",
21413
+ video: {
21414
+ id: "grid",
21415
+ safe: true,
21416
+ acceptsChildren: true,
21417
+ interactionStates: []
21418
+ }
21419
+ },
21420
+ render: /* @__PURE__ */ __name(({
21421
+ columns,
21422
+ minChildWidth,
21423
+ templateColumns,
21424
+ templateRows,
21425
+ templateAreas,
21426
+ autoFlow,
21427
+ gap,
21428
+ gapX,
21429
+ gapY,
21430
+ align,
21431
+ justifyItems,
21432
+ inline = false,
21433
+ as: Tag = "div",
21434
+ className,
21435
+ style,
21436
+ unstyled,
21437
+ children,
21438
+ ...rest
21439
+ }, ref) => {
21440
+ const { theme } = kreativCore.useTheme();
21441
+ if (isDev() && [columns, minChildWidth, templateColumns].filter((v) => v != null).length > 1) {
21442
+ console.warn(
21443
+ "[kreativ-ui/Grid]: columns, minChildWidth, and templateColumns are mutually exclusive. templateColumns wins, then columns, then minChildWidth."
21444
+ );
21445
+ }
21446
+ const responsiveStyles = (0, hooks_exports.useMergedResponsiveStyles)([
21447
+ [
21448
+ columns,
21449
+ (v) => ({ gridTemplateColumns: `repeat(${v}, minmax(0, 1fr))` })
21450
+ ],
21451
+ [
21452
+ minChildWidth,
21453
+ (v) => ({
21454
+ gridTemplateColumns: `repeat(auto-fit, minmax(${resolveTrackSize(v)}, 1fr))`
21455
+ })
21456
+ ],
21457
+ [templateColumns, (v) => ({ gridTemplateColumns: v })],
21458
+ [templateRows, (v) => ({ gridTemplateRows: v })],
21459
+ [autoFlow, (v) => ({ gridAutoFlow: v })],
21460
+ [gap, (v) => ({ gap: resolveSpace(v) })],
21461
+ [gapX, (v) => ({ columnGap: resolveSpace(v) })],
21462
+ [gapY, (v) => ({ rowGap: resolveSpace(v) })],
21463
+ [align, (v) => ({ alignItems: v })],
21464
+ [justifyItems, (v) => ({ justifyItems: v })]
21465
+ ]);
21466
+ const { attribute, style: responsiveCss } = (0, hooks_exports.useResponsiveStyles)(responsiveStyles);
21467
+ const recipeClasses = resolveRecipe(theme.recipes.Grid, { inline });
21468
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
21469
+ /* @__PURE__ */ jsxRuntime.jsx(ResponsiveStyle, { css: responsiveCss }),
21470
+ /* @__PURE__ */ jsxRuntime.jsx(
21471
+ Tag,
21472
+ {
21473
+ ref,
21474
+ "data-kui-responsive": attribute,
21475
+ className: cn(!unstyled && recipeClasses, className),
21476
+ style: { ...style, gridTemplateAreas: templateAreas },
21153
21477
  ...rest,
21154
21478
  children
21155
21479
  }
21156
21480
  )
21157
21481
  ] });
21482
+ }, "render")
21483
+ });
21484
+ var Grid = Object.assign(GridRoot, { Item: GridItem });
21485
+ function withAlpha(color, alpha) {
21486
+ return `color-mix(in srgb, ${color} ${Math.round(alpha * 100)}%, transparent)`;
21487
+ }
21488
+ __name(withAlpha, "withAlpha");
21489
+ function resolveOverlayBackground(color, opacity, gradient) {
21490
+ if (!color && opacity === void 0) return void 0;
21491
+ const resolvedColor = color ?? "currentColor";
21492
+ if (!gradient) {
21493
+ return resolvedColor;
21494
+ }
21495
+ const startOpacity = opacity ?? 1;
21496
+ const startColor = startOpacity === 1 ? resolvedColor : withAlpha(resolvedColor, startOpacity);
21497
+ if (typeof gradient === "object") {
21498
+ const position = gradient.position ?? "center";
21499
+ return `radial-gradient(circle at ${position}, ${startColor} 0%, transparent 100%)`;
21500
+ }
21501
+ const directionMap = {
21502
+ top: "to top",
21503
+ bottom: "to bottom",
21504
+ left: "to left",
21505
+ right: "to right"
21506
+ };
21507
+ return `linear-gradient(${directionMap[gradient]}, ${startColor} 0%, transparent 100%)`;
21508
+ }
21509
+ __name(resolveOverlayBackground, "resolveOverlayBackground");
21510
+ var CardOverlay = kreativCore.createComponent({
21511
+ __kui: {
21512
+ groupSlot: "Card"
21513
+ },
21514
+ displayName: "Card.Overlay",
21515
+ render: /* @__PURE__ */ __name(({ color, opacity, blur, gradient, className, style, children, ...props }, ref) => {
21516
+ const background = resolveOverlayBackground(color, opacity, gradient);
21517
+ const { theme } = kreativCore.useTheme();
21518
+ return /* @__PURE__ */ jsxRuntime.jsx(
21519
+ "div",
21520
+ {
21521
+ ref,
21522
+ className: cn(resolveRecipe(theme.recipes.CardOverlay), className),
21523
+ style: {
21524
+ ...background !== void 0 ? gradient ? { backgroundImage: background } : { backgroundColor: background } : null,
21525
+ ...!gradient && opacity !== void 0 ? { opacity } : null,
21526
+ ...blur !== void 0 ? {
21527
+ backdropFilter: `blur(${typeof blur === "number" ? `${blur}px` : blur})`
21528
+ } : null,
21529
+ ...style
21530
+ },
21531
+ ...props,
21532
+ children
21533
+ }
21534
+ );
21535
+ }, "render")
21536
+ });
21537
+ var CardMedia = kreativCore.createComponent({
21538
+ __kui: {
21539
+ groupSlot: "Card"
21540
+ },
21541
+ displayName: "Card.Media",
21542
+ render: /* @__PURE__ */ __name(({
21543
+ src,
21544
+ alt,
21545
+ fit = "cover",
21546
+ blend = "normal",
21547
+ aspectRatio,
21548
+ className,
21549
+ style,
21550
+ children,
21551
+ ...props
21552
+ }, ref) => {
21553
+ const { theme } = kreativCore.useTheme();
21554
+ return /* @__PURE__ */ jsxRuntime.jsxs(
21555
+ "div",
21556
+ {
21557
+ ref,
21558
+ className: cn(resolveRecipe(theme.recipes.CardMedia), className),
21559
+ style: {
21560
+ ...aspectRatio !== void 0 ? { aspectRatio } : null,
21561
+ ...style
21562
+ },
21563
+ ...props,
21564
+ children: [
21565
+ /* @__PURE__ */ jsxRuntime.jsx(
21566
+ "img",
21567
+ {
21568
+ src,
21569
+ alt,
21570
+ className: resolveRecipe(theme.recipes.CardMediaImage, { fit, blend })
21571
+ }
21572
+ ),
21573
+ children
21574
+ ]
21575
+ }
21576
+ );
21577
+ }, "render")
21578
+ });
21579
+ var CardRoot = kreativCore.createComponent({
21580
+ __kui: {
21581
+ role: "display",
21582
+ skeleton: "preserve"
21583
+ },
21584
+ displayName: "Card",
21585
+ render: /* @__PURE__ */ __name(({
21586
+ variant = "outline",
21587
+ size = "md",
21588
+ fullWidth = false,
21589
+ className,
21590
+ style,
21591
+ children,
21592
+ ...props
21593
+ }, ref) => {
21594
+ kreativCore.useValidateChildren("Card", children);
21595
+ const { theme } = kreativCore.useTheme();
21596
+ return /* @__PURE__ */ jsxRuntime.jsx(
21597
+ "div",
21598
+ {
21599
+ ref,
21600
+ className: cn(
21601
+ resolveRecipe(theme.recipes.Card, { variant, size, fullWidth }),
21602
+ className
21603
+ ),
21604
+ ...props,
21605
+ children
21606
+ }
21607
+ );
21608
+ }, "render")
21609
+ });
21610
+ var CardHeader = kreativCore.createComponent({
21611
+ __kui: {
21612
+ groupSlot: "Card"
21613
+ },
21614
+ displayName: "Card.Header",
21615
+ render: /* @__PURE__ */ __name(({ className, children, noPadding = false, size = "md", ...props }, ref) => {
21616
+ const { theme } = kreativCore.useTheme();
21617
+ return /* @__PURE__ */ jsxRuntime.jsx(
21618
+ "div",
21619
+ {
21620
+ ref,
21621
+ className: cn(
21622
+ resolveRecipe(theme.recipes.CardHeader, { size, noPadding }),
21623
+ className
21624
+ ),
21625
+ ...props,
21626
+ children
21627
+ }
21628
+ );
21629
+ }, "render")
21630
+ });
21631
+ var CardBody = kreativCore.createComponent({
21632
+ __kui: {
21633
+ groupSlot: "Card"
21634
+ },
21635
+ displayName: "Card.Body",
21636
+ render: /* @__PURE__ */ __name(({ size = "md", noPadding = false, className, children, ...props }, ref) => {
21637
+ const { theme } = kreativCore.useTheme();
21638
+ return /* @__PURE__ */ jsxRuntime.jsx(
21639
+ "div",
21640
+ {
21641
+ ref,
21642
+ className: cn(
21643
+ resolveRecipe(theme.recipes.CardBody, { size, noPadding }),
21644
+ className
21645
+ ),
21646
+ ...props,
21647
+ children
21648
+ }
21649
+ );
21650
+ }, "render")
21651
+ });
21652
+ var CardFooter = kreativCore.createComponent({
21653
+ __kui: {
21654
+ groupSlot: "Card"
21655
+ },
21656
+ displayName: "Card.Footer",
21657
+ render: /* @__PURE__ */ __name(({ size = "md", noPadding = false, className, children, ...props }, ref) => {
21658
+ const { theme } = kreativCore.useTheme();
21659
+ return /* @__PURE__ */ jsxRuntime.jsx(
21660
+ "div",
21661
+ {
21662
+ ref,
21663
+ className: cn(
21664
+ resolveRecipe(theme.recipes.CardFooter, { size, noPadding }),
21665
+ className
21666
+ ),
21667
+ ...props,
21668
+ children
21669
+ }
21670
+ );
21671
+ }, "render")
21672
+ });
21673
+ var Card = Object.assign(CardRoot, {
21674
+ Header: CardHeader,
21675
+ Body: CardBody,
21676
+ Footer: CardFooter,
21677
+ Media: CardMedia,
21678
+ Overlay: CardOverlay
21679
+ });
21680
+ var initialState = {
21681
+ hasVerticalOverflow: false,
21682
+ hasHorizontalOverflow: false,
21683
+ atTop: true,
21684
+ atBottom: false,
21685
+ atLeft: true,
21686
+ atRight: false
21687
+ };
21688
+ function statesEqual(a, b) {
21689
+ return a.hasVerticalOverflow === b.hasVerticalOverflow && a.hasHorizontalOverflow === b.hasHorizontalOverflow && a.atTop === b.atTop && a.atBottom === b.atBottom && a.atLeft === b.atLeft && a.atRight === b.atRight;
21690
+ }
21691
+ __name(statesEqual, "statesEqual");
21692
+ function useScrollPosition({ direction, threshold, onScrollEnd, onMeasure }) {
21693
+ const elRef = React2.useRef(null);
21694
+ const [state, setState] = React2.useState(initialState);
21695
+ const stateRef = React2.useRef(state);
21696
+ const onMeasureRef = React2.useRef(onMeasure);
21697
+ onMeasureRef.current = onMeasure;
21698
+ const inZone = React2.useRef({
21699
+ top: false,
21700
+ bottom: false,
21701
+ left: false,
21702
+ right: false
21703
+ });
21704
+ const fireIfEntering = React2.useCallback(
21705
+ (edge, isAtEdge) => {
21706
+ if (isAtEdge && !inZone.current[edge]) {
21707
+ inZone.current[edge] = true;
21708
+ onScrollEnd?.(edge);
21709
+ } else if (!isAtEdge && inZone.current[edge]) {
21710
+ inZone.current[edge] = false;
21711
+ }
21712
+ },
21713
+ [onScrollEnd]
21714
+ );
21715
+ const measure = React2.useCallback(() => {
21716
+ const el = elRef.current;
21717
+ if (!el) return;
21718
+ const hasVerticalOverflow = el.scrollHeight > el.clientHeight;
21719
+ const hasHorizontalOverflow = el.scrollWidth > el.clientWidth;
21720
+ const wantsVertical = direction === "vertical" || direction === "both";
21721
+ const wantsHorizontal = direction === "horizontal" || direction === "both";
21722
+ let atTop = true, atBottom = false, atLeft = true, atRight = false;
21723
+ if (wantsVertical && hasVerticalOverflow) {
21724
+ const distTop = el.scrollTop;
21725
+ const distBottom = el.scrollHeight - el.clientHeight - el.scrollTop;
21726
+ atTop = distTop <= threshold;
21727
+ atBottom = distBottom <= threshold;
21728
+ fireIfEntering("top", atTop);
21729
+ fireIfEntering("bottom", atBottom);
21730
+ }
21731
+ if (wantsHorizontal && hasHorizontalOverflow) {
21732
+ const distLeft = el.scrollLeft;
21733
+ const distRight = el.scrollWidth - el.clientWidth - el.scrollLeft;
21734
+ atLeft = distLeft <= threshold;
21735
+ atRight = distRight <= threshold;
21736
+ fireIfEntering("left", atLeft);
21737
+ fireIfEntering("right", atRight);
21738
+ }
21739
+ const next = {
21740
+ hasVerticalOverflow,
21741
+ hasHorizontalOverflow,
21742
+ atTop: wantsVertical ? atTop : true,
21743
+ atBottom: wantsVertical ? atBottom : false,
21744
+ atLeft: wantsHorizontal ? atLeft : true,
21745
+ atRight: wantsHorizontal ? atRight : false
21746
+ };
21747
+ if (!statesEqual(stateRef.current, next)) {
21748
+ stateRef.current = next;
21749
+ setState(next);
21750
+ }
21751
+ onMeasureRef.current?.();
21752
+ }, [direction, threshold, fireIfEntering]);
21753
+ const handleScroll = React2.useCallback(() => measure(), [measure]);
21754
+ React2.useEffect(() => {
21755
+ const el = elRef.current;
21756
+ if (!el) return;
21757
+ measure();
21758
+ const resizeObserver = new ResizeObserver(() => measure());
21759
+ resizeObserver.observe(el);
21760
+ const mutationObserver = new MutationObserver(() => measure());
21761
+ mutationObserver.observe(el, { childList: true, subtree: true, characterData: true });
21762
+ return () => {
21763
+ resizeObserver.disconnect();
21764
+ mutationObserver.disconnect();
21765
+ };
21766
+ }, [measure]);
21767
+ return { elRef, state, handleScroll, measure };
21768
+ }
21769
+ __name(useScrollPosition, "useScrollPosition");
21770
+ var THRESHOLD = 5;
21771
+ var IGNORE = "input, textarea, select, [contenteditable=''], [contenteditable='true'], [data-no-drag]";
21772
+ function useDragScroll(elRef, { enabled, direction, onRelease }) {
21773
+ const releaseRef = React2.useRef(onRelease);
21774
+ releaseRef.current = onRelease;
21775
+ React2.useEffect(() => {
21776
+ const el = elRef.current;
21777
+ if (!el || !enabled) return;
21778
+ const allowX = direction !== "vertical";
21779
+ const allowY = direction !== "horizontal";
21780
+ let pointerId = null;
21781
+ let startX = 0, startY = 0, startLeft = 0, startTop = 0;
21782
+ let dragging = false;
21783
+ let suppressClick = false;
21784
+ const onDown = /* @__PURE__ */ __name((e) => {
21785
+ if (e.pointerType === "touch" || e.button !== 0) return;
21786
+ if (e.target.closest(IGNORE)) return;
21787
+ pointerId = e.pointerId;
21788
+ startX = e.clientX;
21789
+ startY = e.clientY;
21790
+ startLeft = el.scrollLeft;
21791
+ startTop = el.scrollTop;
21792
+ dragging = false;
21793
+ }, "onDown");
21794
+ const onMove = /* @__PURE__ */ __name((e) => {
21795
+ if (e.pointerId !== pointerId) return;
21796
+ const dx = e.clientX - startX;
21797
+ const dy = e.clientY - startY;
21798
+ if (!dragging) {
21799
+ if (Math.hypot(dx, dy) < THRESHOLD) return;
21800
+ dragging = true;
21801
+ try {
21802
+ el.setPointerCapture(e.pointerId);
21803
+ } catch {
21804
+ }
21805
+ el.setAttribute("data-dragging", "");
21806
+ window.getSelection()?.removeAllRanges();
21807
+ }
21808
+ if (allowX) el.scrollLeft = startLeft - dx;
21809
+ if (allowY) el.scrollTop = startTop - dy;
21810
+ }, "onMove");
21811
+ const onEnd = /* @__PURE__ */ __name((e) => {
21812
+ if (e.pointerId !== pointerId) return;
21813
+ pointerId = null;
21814
+ if (!dragging) return;
21815
+ dragging = false;
21816
+ suppressClick = true;
21817
+ setTimeout(() => {
21818
+ suppressClick = false;
21819
+ }, 0);
21820
+ el.removeAttribute("data-dragging");
21821
+ releaseRef.current?.(el);
21822
+ }, "onEnd");
21823
+ const onClickCapture = /* @__PURE__ */ __name((e) => {
21824
+ if (!suppressClick) return;
21825
+ e.preventDefault();
21826
+ e.stopPropagation();
21827
+ }, "onClickCapture");
21828
+ const onDragStart = /* @__PURE__ */ __name((e) => {
21829
+ if (!e.target.closest?.('[draggable="true"]')) e.preventDefault();
21830
+ }, "onDragStart");
21831
+ el.addEventListener("pointerdown", onDown);
21832
+ el.addEventListener("pointermove", onMove);
21833
+ el.addEventListener("pointerup", onEnd);
21834
+ el.addEventListener("pointercancel", onEnd);
21835
+ el.addEventListener("click", onClickCapture, true);
21836
+ el.addEventListener("dragstart", onDragStart);
21837
+ return () => {
21838
+ el.removeEventListener("pointerdown", onDown);
21839
+ el.removeEventListener("pointermove", onMove);
21840
+ el.removeEventListener("pointerup", onEnd);
21841
+ el.removeEventListener("pointercancel", onEnd);
21842
+ el.removeEventListener("click", onClickCapture, true);
21843
+ el.removeEventListener("dragstart", onDragStart);
21844
+ el.removeAttribute("data-dragging");
21845
+ };
21846
+ }, [elRef, enabled, direction]);
21847
+ }
21848
+ __name(useDragScroll, "useDragScroll");
21849
+
21850
+ // src/components/layout/ScrollArea/scrollProgress.ts
21851
+ var clamp01 = /* @__PURE__ */ __name((n) => Math.min(1, Math.max(0, n)), "clamp01");
21852
+ function containerProgress(el) {
21853
+ const maxY = el.scrollHeight - el.clientHeight;
21854
+ const maxX = el.scrollWidth - el.clientWidth;
21855
+ return {
21856
+ x: maxX > 0 ? clamp01(el.scrollLeft / maxX) : 0,
21857
+ y: maxY > 0 ? clamp01(el.scrollTop / maxY) : 0
21858
+ };
21859
+ }
21860
+ __name(containerProgress, "containerProgress");
21861
+ function sceneProgress(scene, container, axis, range) {
21862
+ const c = container.getBoundingClientRect();
21863
+ const s = scene.getBoundingClientRect();
21864
+ const vertical = axis === "y";
21865
+ const view = vertical ? container.clientHeight : container.clientWidth;
21866
+ const size = vertical ? s.height : s.width;
21867
+ const offset = vertical ? s.top - c.top - container.clientTop : s.left - c.left - container.clientLeft;
21868
+ if (range === "through") {
21869
+ const total = view + size;
21870
+ return total > 0 ? clamp01((view - offset) / total) : 0;
21871
+ }
21872
+ const travel = size - view;
21873
+ return travel > 0 ? clamp01(-offset / travel) : 0;
21874
+ }
21875
+ __name(sceneProgress, "sceneProgress");
21876
+ function createStore(initial, equals = Object.is) {
21877
+ let value = initial;
21878
+ const listeners = /* @__PURE__ */ new Set();
21879
+ return {
21880
+ get: /* @__PURE__ */ __name(() => value, "get"),
21881
+ set(next) {
21882
+ if (equals(value, next)) return false;
21883
+ value = next;
21884
+ listeners.forEach((l) => l(next));
21885
+ return true;
21886
+ },
21887
+ subscribe(fn) {
21888
+ listeners.add(fn);
21889
+ return () => {
21890
+ listeners.delete(fn);
21891
+ };
21892
+ },
21893
+ get size() {
21894
+ return listeners.size;
21895
+ }
21896
+ };
21897
+ }
21898
+ __name(createStore, "createStore");
21899
+
21900
+ // src/components/layout/ScrollArea/ScrollEngine.ts
21901
+ var EPS = 1;
21902
+ var round = /* @__PURE__ */ __name((n) => Math.round(n * 1e4) / 1e4, "round");
21903
+ var progressEqual = /* @__PURE__ */ __name((a, b) => a.x === b.x && a.y === b.y, "progressEqual");
21904
+ var STICKY_EDGES = ["top", "bottom", "left", "right"];
21905
+ var _StickyHandle = class _StickyHandle {
21906
+ constructor() {
21907
+ __publicField(this, "el", null);
21908
+ __publicField(this, "edges", []);
21909
+ __publicField(this, "offsets", {});
21910
+ __publicField(this, "stuck", "");
21911
+ __publicField(this, "dirty", true);
21912
+ __publicField(this, "onStuckChange");
21913
+ }
21914
+ resolve() {
21915
+ if (!this.el) return;
21916
+ const cs = getComputedStyle(this.el);
21917
+ this.offsets = {};
21918
+ for (const edge of this.edges) {
21919
+ const px = parseFloat(cs[edge]);
21920
+ if (!Number.isNaN(px)) this.offsets[edge] = px;
21921
+ }
21922
+ this.dirty = false;
21923
+ }
21924
+ };
21925
+ __name(_StickyHandle, "StickyHandle");
21926
+ var StickyHandle = _StickyHandle;
21927
+ var _SceneHandle = class _SceneHandle {
21928
+ constructor(engine) {
21929
+ __publicField(this, "engine", engine);
21930
+ __publicField(this, "el", null);
21931
+ __publicField(this, "axis", "y");
21932
+ __publicField(this, "range", "through");
21933
+ __publicField(this, "store", createStore(0));
21934
+ __publicField(this, "get", /* @__PURE__ */ __name(() => {
21935
+ const container = this.engine.el;
21936
+ return this.el && container ? round(sceneProgress(this.el, container, this.axis, this.range)) : 0;
21937
+ }, "get"));
21938
+ __publicField(this, "subscribe", /* @__PURE__ */ __name((fn) => {
21939
+ const off = this.store.subscribe(fn);
21940
+ this.engine.schedule();
21941
+ return off;
21942
+ }, "subscribe"));
21943
+ }
21944
+ };
21945
+ __name(_SceneHandle, "SceneHandle");
21946
+ var SceneHandle = _SceneHandle;
21947
+ var _ScrollEngine = class _ScrollEngine {
21948
+ constructor() {
21949
+ __publicField(this, "el", null);
21950
+ __publicField(this, "trackVars", false);
21951
+ __publicField(this, "varsDirty", false);
21952
+ __publicField(this, "offsetsDirty", false);
21953
+ __publicField(this, "frame", 0);
21954
+ __publicField(this, "resizeObserver", null);
21955
+ __publicField(this, "scenes", /* @__PURE__ */ new Set());
21956
+ __publicField(this, "stickies", /* @__PURE__ */ new Set());
21957
+ __publicField(this, "viewport", { w: -1, h: -1 });
21958
+ __publicField(this, "containerStore", createStore(
21959
+ { x: 0, y: 0 },
21960
+ progressEqual
21961
+ ));
21962
+ __publicField(this, "progress", {
21963
+ get: /* @__PURE__ */ __name(() => this.el ? containerProgress(this.el) : { x: 0, y: 0 }, "get"),
21964
+ subscribe: /* @__PURE__ */ __name((fn) => {
21965
+ const off = this.containerStore.subscribe(fn);
21966
+ this.schedule();
21967
+ return off;
21968
+ }, "subscribe")
21969
+ });
21970
+ __publicField(this, "schedule", /* @__PURE__ */ __name(() => {
21971
+ if (this.frame || !this.el || !this.isActive()) return;
21972
+ this.frame = requestAnimationFrame(this.flush);
21973
+ }, "schedule"));
21974
+ __publicField(this, "flush", /* @__PURE__ */ __name(() => {
21975
+ this.frame = 0;
21976
+ const el = this.el;
21977
+ if (!el) return;
21978
+ const c = containerProgress(el);
21979
+ const rounded = { x: round(c.x), y: round(c.y) };
21980
+ const sceneValues = [];
21981
+ this.scenes.forEach((s) => {
21982
+ if (s.el)
21983
+ sceneValues.push([s, round(sceneProgress(s.el, el, s.axis, s.range))]);
21984
+ });
21985
+ const stickyStates = [];
21986
+ if (this.stickies.size > 0) {
21987
+ const cr = el.getBoundingClientRect();
21988
+ const portTop = cr.top + el.clientTop;
21989
+ const portLeft = cr.left + el.clientLeft;
21990
+ const portBottom = portTop + el.clientHeight;
21991
+ const portRight = portLeft + el.clientWidth;
21992
+ const maxY = el.scrollHeight - el.clientHeight;
21993
+ const maxX = el.scrollWidth - el.clientWidth;
21994
+ this.stickies.forEach((s) => {
21995
+ if (!s.el) return;
21996
+ if (s.dirty || this.offsetsDirty) s.resolve();
21997
+ const r = s.el.getBoundingClientRect();
21998
+ const o = s.offsets;
21999
+ const hit = [];
22000
+ if (o.top !== void 0 && Math.abs(r.top - (portTop + o.top)) <= EPS && el.scrollTop > EPS)
22001
+ hit.push("top");
22002
+ if (o.bottom !== void 0 && Math.abs(r.bottom - (portBottom - o.bottom)) <= EPS && el.scrollTop < maxY - EPS)
22003
+ hit.push("bottom");
22004
+ if (o.left !== void 0 && Math.abs(r.left - (portLeft + o.left)) <= EPS && el.scrollLeft > EPS)
22005
+ hit.push("left");
22006
+ if (o.right !== void 0 && Math.abs(r.right - (portRight - o.right)) <= EPS && el.scrollLeft < maxX - EPS)
22007
+ hit.push("right");
22008
+ stickyStates.push([s, hit.join(" ")]);
22009
+ });
22010
+ }
22011
+ this.offsetsDirty = false;
22012
+ const changed = this.containerStore.set(rounded);
22013
+ if (this.trackVars && (changed || this.varsDirty)) {
22014
+ el.style.setProperty("--kui-scroll-x", String(rounded.x));
22015
+ el.style.setProperty("--kui-scroll-y", String(rounded.y));
22016
+ this.varsDirty = false;
22017
+ }
22018
+ for (const [s, v] of sceneValues) {
22019
+ if (s.store.set(v) && s.el)
22020
+ s.el.style.setProperty("--kui-scene-progress", String(v));
22021
+ }
22022
+ for (const [s, stuck] of stickyStates) {
22023
+ if (!s.el || s.stuck === stuck) continue;
22024
+ const was = s.stuck !== "";
22025
+ s.stuck = stuck;
22026
+ if (stuck) s.el.setAttribute("data-stuck", stuck);
22027
+ else s.el.removeAttribute("data-stuck");
22028
+ if (was !== (stuck !== "")) s.onStuckChange?.(stuck !== "");
22029
+ }
22030
+ }, "flush"));
22031
+ }
22032
+ attach(el) {
22033
+ this.el = el;
22034
+ this.resizeObserver = new ResizeObserver(() => {
22035
+ this.offsetsDirty = true;
22036
+ this.syncViewport();
22037
+ this.schedule();
22038
+ });
22039
+ this.resizeObserver.observe(el);
22040
+ this.scenes.forEach((s) => s.el && this.resizeObserver.observe(s.el));
22041
+ this.syncViewport();
22042
+ this.schedule();
22043
+ }
22044
+ detach() {
22045
+ cancelAnimationFrame(this.frame);
22046
+ this.frame = 0;
22047
+ this.resizeObserver?.disconnect();
22048
+ this.resizeObserver = null;
22049
+ this.el = null;
22050
+ this.viewport = { w: -1, h: -1 };
22051
+ }
22052
+ setTrackProgress(on) {
22053
+ if (this.trackVars === on) return;
22054
+ this.trackVars = on;
22055
+ if (on) {
22056
+ this.varsDirty = true;
22057
+ } else {
22058
+ this.el?.style.removeProperty("--kui-scroll-x");
22059
+ this.el?.style.removeProperty("--kui-scroll-y");
22060
+ }
22061
+ this.schedule();
22062
+ }
22063
+ register(scene) {
22064
+ this.scenes.add(scene);
22065
+ if (scene.el) this.resizeObserver?.observe(scene.el);
22066
+ this.schedule();
22067
+ return () => {
22068
+ this.scenes.delete(scene);
22069
+ if (scene.el) this.resizeObserver?.unobserve(scene.el);
22070
+ };
22071
+ }
22072
+ registerSticky(s) {
22073
+ this.stickies.add(s);
22074
+ this.schedule();
22075
+ return () => {
22076
+ this.stickies.delete(s);
22077
+ };
22078
+ }
22079
+ isActive() {
22080
+ return this.trackVars || this.scenes.size > 0 || this.stickies.size > 0 || this.containerStore.size > 0;
22081
+ }
22082
+ syncViewport() {
22083
+ const el = this.el;
22084
+ if (!el) return;
22085
+ const w = el.clientWidth;
22086
+ const h = el.clientHeight;
22087
+ if (w === this.viewport.w && h === this.viewport.h) return;
22088
+ this.viewport = { w, h };
22089
+ el.style.setProperty("--kui-scroll-viewport-width", `${w}px`);
22090
+ el.style.setProperty("--kui-scroll-viewport-height", `${h}px`);
22091
+ }
22092
+ };
22093
+ __name(_ScrollEngine, "ScrollEngine");
22094
+ var ScrollEngine = _ScrollEngine;
22095
+ var ScrollEngineContext = React2.createContext(null);
22096
+ var useIsoLayoutEffect = typeof window !== "undefined" ? React2.useLayoutEffect : React2.useEffect;
22097
+ function useScrollEngine(hookName) {
22098
+ const engine = React2.useContext(ScrollEngineContext);
22099
+ if (!engine) throw new Error(`${hookName} must be used inside <ScrollArea>`);
22100
+ return engine;
22101
+ }
22102
+ __name(useScrollEngine, "useScrollEngine");
22103
+ function useScrollProgress() {
22104
+ return useScrollEngine("useScrollProgress").progress;
22105
+ }
22106
+ __name(useScrollProgress, "useScrollProgress");
22107
+ function useElementScrollProgress(ref, { range = "through", axis = "y" } = {}) {
22108
+ const engine = useScrollEngine("useElementScrollProgress");
22109
+ const [handle] = React2.useState(() => new SceneHandle(engine));
22110
+ useIsoLayoutEffect(() => {
22111
+ handle.el = ref.current;
22112
+ handle.axis = axis;
22113
+ handle.range = range;
22114
+ return engine.register(handle);
22115
+ }, [engine, handle, ref, axis, range]);
22116
+ return handle;
22117
+ }
22118
+ __name(useElementScrollProgress, "useElementScrollProgress");
22119
+
22120
+ // src/components/layout/ScrollArea/scrollTargets.ts
22121
+ var axesFor = /* @__PURE__ */ __name((d) => d === "both" ? ["x", "y"] : d === "horizontal" ? ["x"] : ["y"], "axesFor");
22122
+ var prefersReducedMotion = /* @__PURE__ */ __name(() => typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, "prefersReducedMotion");
22123
+ var resolveBehavior = /* @__PURE__ */ __name((b) => b ?? (prefersReducedMotion() ? "auto" : "smooth"), "resolveBehavior");
22124
+ function childTarget(container, child, axis, align) {
22125
+ const h = axis === "x";
22126
+ const c = container.getBoundingClientRect();
22127
+ const r = child.getBoundingClientRect();
22128
+ const cs = getComputedStyle(container);
22129
+ const view = h ? container.clientWidth : container.clientHeight;
22130
+ const size = h ? r.width : r.height;
22131
+ const rel = h ? r.left - c.left - container.clientLeft : r.top - c.top - container.clientTop;
22132
+ const current = h ? container.scrollLeft : container.scrollTop;
22133
+ const max = h ? container.scrollWidth - view : container.scrollHeight - view;
22134
+ const padStart = parseFloat(h ? cs.scrollPaddingLeft : cs.scrollPaddingTop) || 0;
22135
+ const padEnd = parseFloat(h ? cs.scrollPaddingRight : cs.scrollPaddingBottom) || 0;
22136
+ let offsetInView;
22137
+ if (align === "start") offsetInView = padStart;
22138
+ else if (align === "end") offsetInView = view - padEnd - size;
22139
+ else offsetInView = padStart + (view - padStart - padEnd - size) / 2;
22140
+ return Math.min(Math.max(current + rel - offsetInView, 0), Math.max(max, 0));
22141
+ }
22142
+ __name(childTarget, "childTarget");
22143
+ var snapItems = /* @__PURE__ */ __name((el) => Array.from(el.children).filter(
22144
+ (c) => !getComputedStyle(c).scrollSnapAlign.startsWith("none")
22145
+ ), "snapItems");
22146
+ function snapToNearest(el, direction, align) {
22147
+ const items = snapItems(el);
22148
+ if (!items.length) return;
22149
+ const opts = { behavior: resolveBehavior() };
22150
+ for (const axis of axesFor(direction)) {
22151
+ const cur = axis === "x" ? el.scrollLeft : el.scrollTop;
22152
+ let best = cur;
22153
+ let bestDist = Infinity;
22154
+ for (const item of items) {
22155
+ const t = childTarget(el, item, axis, align);
22156
+ const d = Math.abs(t - cur);
22157
+ if (d < bestDist) {
22158
+ bestDist = d;
22159
+ best = t;
22160
+ }
22161
+ }
22162
+ opts[axis === "x" ? "left" : "top"] = best;
22163
+ }
22164
+ el.scrollTo(opts);
22165
+ }
22166
+ __name(snapToNearest, "snapToNearest");
22167
+ var ScrollAreaScene = kreativCore.createComponent({
22168
+ displayName: "ScrollArea.Scene",
22169
+ __kui: {
22170
+ role: "layout",
22171
+ skeleton: "preserve",
22172
+ groupSlot: "ScrollArea",
22173
+ video: {
22174
+ id: "scroll-area-scene",
22175
+ safe: true,
22176
+ acceptsChildren: true,
22177
+ interactionStates: [],
22178
+ motionGated: true
22179
+ }
22180
+ },
22181
+ render: /* @__PURE__ */ __name(({ range, axis, as: Tag = "div", ...rest }, forwardedRef) => {
22182
+ const ref = React2.useRef(null);
22183
+ void isMotionGated(rest);
22184
+ useElementScrollProgress(ref, { range, axis });
22185
+ return /* @__PURE__ */ jsxRuntime.jsx(Tag, { ref: kreativCore.composeRefs(ref, forwardedRef), "data-kui-scroll-scene": true, ...rest });
22186
+ }, "render")
22187
+ });
22188
+ function warnIfClipped(el, container) {
22189
+ for (let p = el.parentElement; p && p !== container; p = p.parentElement) {
22190
+ if (/hidden|auto|scroll/.test(getComputedStyle(p).overflow)) {
22191
+ console.warn(
22192
+ "[kreativ-ui/ScrollArea.Sticky]: will not stick: an ancestor has overflow other than visible/clip.",
22193
+ p
22194
+ );
22195
+ return;
22196
+ }
21158
22197
  }
21159
- );
21160
- Container.displayName = "Container";
21161
- function spaceVar(value) {
21162
- return `var(--kui-spacing-${value})`;
21163
22198
  }
21164
- __name(spaceVar, "spaceVar");
21165
- var Flex = React2.forwardRef(
21166
- ({
21167
- direction = "row",
21168
- wrap = "nowrap",
21169
- align,
21170
- justify,
21171
- gap,
22199
+ __name(warnIfClipped, "warnIfClipped");
22200
+ var ScrollAreaSticky = kreativCore.createComponent({
22201
+ displayName: "ScrollArea.Sticky",
22202
+ __kui: {
22203
+ role: "layout",
22204
+ skeleton: "preserve",
22205
+ groupSlot: "ScrollArea",
22206
+ video: {
22207
+ id: "scroll-area-sticky",
22208
+ safe: true,
22209
+ acceptsChildren: true,
22210
+ needsParentContext: true,
22211
+ interactionStates: []
22212
+ }
22213
+ },
22214
+ render: /* @__PURE__ */ __name(({
22215
+ top,
22216
+ bottom,
22217
+ left,
22218
+ right,
22219
+ zIndex = 1,
22220
+ onStuckChange,
22221
+ as: Tag = "div",
22222
+ style,
22223
+ ...rest
22224
+ }, forwardedRef) => {
22225
+ const engine = useScrollEngine("ScrollArea.Sticky");
22226
+ const ref = React2.useRef(null);
22227
+ const [handle] = React2.useState(() => new StickyHandle());
22228
+ const none = top === void 0 && bottom === void 0 && left === void 0 && right === void 0;
22229
+ const offsets = {
22230
+ top: none ? 0 : top,
22231
+ bottom,
22232
+ left,
22233
+ right
22234
+ };
22235
+ useIsoLayoutEffect(() => {
22236
+ handle.onStuckChange = onStuckChange;
22237
+ });
22238
+ useIsoLayoutEffect(() => {
22239
+ const el = ref.current;
22240
+ if (!el) return;
22241
+ handle.el = el;
22242
+ handle.edges = STICKY_EDGES.filter((e) => offsets[e] !== void 0);
22243
+ handle.dirty = true;
22244
+ if (process.env.NODE_ENV !== "production") warnIfClipped(el, engine.el);
22245
+ return engine.registerSticky(handle);
22246
+ }, [
22247
+ engine,
22248
+ handle,
22249
+ offsets.top,
22250
+ offsets.bottom,
22251
+ offsets.left,
22252
+ offsets.right
22253
+ ]);
22254
+ return /* @__PURE__ */ jsxRuntime.jsx(
22255
+ Tag,
22256
+ {
22257
+ ref: kreativCore.composeRefs(ref, forwardedRef),
22258
+ "data-kui-scroll-sticky": true,
22259
+ style: {
22260
+ position: "sticky",
22261
+ top: offsets.top,
22262
+ bottom: offsets.bottom,
22263
+ left: offsets.left,
22264
+ right: offsets.right,
22265
+ zIndex,
22266
+ ...style
22267
+ },
22268
+ ...rest
22269
+ }
22270
+ );
22271
+ }, "render")
22272
+ });
22273
+ function shouldFade(fadeEdges, edge) {
22274
+ if (fadeEdges === true) return true;
22275
+ if (!fadeEdges) return false;
22276
+ return !!fadeEdges[edge];
22277
+ }
22278
+ __name(shouldFade, "shouldFade");
22279
+ var ScrollAreaRoot = kreativCore.createComponent({
22280
+ displayName: "ScrollArea",
22281
+ __kui: {
22282
+ role: "layout",
22283
+ formControl: "compound",
22284
+ skeleton: "preserve",
22285
+ video: {
22286
+ id: "scroll-area",
22287
+ safe: true,
22288
+ acceptsChildren: true,
22289
+ interactionStates: [],
22290
+ motionGated: true
22291
+ }
22292
+ },
22293
+ render: /* @__PURE__ */ __name(({
22294
+ maxHeight,
22295
+ maxWidth,
22296
+ direction = "vertical",
22297
+ showScrollbar = "auto",
22298
+ scrollbarVariant = "thin",
22299
+ fadeEdges = false,
22300
+ fadeSize = "24px",
22301
+ overscrollBehavior = "contain",
22302
+ snap = "none",
22303
+ snapAlign = "start",
22304
+ dragToScroll = false,
22305
+ onScroll,
22306
+ onScrollEnd,
22307
+ endThreshold = 0,
22308
+ trackProgress = false,
22309
+ tabIndex,
21172
22310
  as: Tag = "div",
21173
22311
  className,
21174
22312
  style,
21175
- unstyled,
21176
22313
  children,
21177
22314
  ...rest
21178
- }, ref) => {
21179
- const responsiveStyles = (0, hooks_exports.useMergedResponsiveStyles)([
21180
- [direction, (v) => ({ flexDirection: v })],
21181
- [wrap, (v) => ({ flexWrap: v })],
21182
- [align, (v) => ({ alignItems: v })],
21183
- [justify, (v) => ({ justifyContent: v })],
21184
- [gap, (v) => ({ gap: spaceVar(v) })]
21185
- ]);
21186
- const { attribute, style: responsiveCss } = (0, hooks_exports.useResponsiveStyles)(responsiveStyles);
21187
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
22315
+ }, forwardedRef) => {
22316
+ const { theme } = kreativCore.useTheme();
22317
+ const [engine] = React2.useState(() => new ScrollEngine());
22318
+ const motionGated = isMotionGated(rest);
22319
+ const snapActive = motionGated ? "none" : snap;
22320
+ const dragActive = motionGated ? false : dragToScroll;
22321
+ const { elRef, state, handleScroll, measure } = useScrollPosition({
22322
+ direction,
22323
+ threshold: endThreshold,
22324
+ onScrollEnd,
22325
+ onMeasure: engine.schedule
22326
+ });
22327
+ useIsoLayoutEffect(() => {
22328
+ const el = elRef.current;
22329
+ if (!el) return;
22330
+ engine.attach(el);
22331
+ return () => engine.detach();
22332
+ }, [engine, elRef]);
22333
+ useIsoLayoutEffect(() => {
22334
+ engine.setTrackProgress(trackProgress);
22335
+ }, [engine, trackProgress]);
22336
+ useDragScroll(elRef, {
22337
+ enabled: dragActive,
22338
+ direction,
22339
+ onRelease: snapActive === "mandatory" ? (el) => snapToNearest(el, direction, snapAlign) : void 0
22340
+ });
22341
+ React2.useImperativeHandle(forwardedRef, () => {
22342
+ const getEl = /* @__PURE__ */ __name(() => elRef.current, "getEl");
22343
+ const defaultAxis = /* @__PURE__ */ __name(() => direction === "horizontal" ? "x" : "y", "defaultAxis");
22344
+ const stepScroll = /* @__PURE__ */ __name((dir, o) => {
22345
+ const el = getEl();
22346
+ if (!el) return;
22347
+ const axis = o?.axis ?? defaultAxis();
22348
+ const h = axis === "x";
22349
+ const cur = h ? el.scrollLeft : el.scrollTop;
22350
+ let target;
22351
+ if ((o?.step ?? "page") === "page") {
22352
+ target = cur + dir * (h ? el.clientWidth : el.clientHeight);
22353
+ } else {
22354
+ const targets = snapItems(el).map(
22355
+ (c) => childTarget(el, c, axis, snapAlign)
22356
+ );
22357
+ const found = dir === 1 ? targets.find((t) => t > cur + 1) : [...targets].reverse().find((t) => t < cur - 1);
22358
+ if (found === void 0) return;
22359
+ target = found;
22360
+ }
22361
+ el.scrollTo({
22362
+ [h ? "left" : "top"]: target,
22363
+ behavior: resolveBehavior(o?.behavior)
22364
+ });
22365
+ }, "stepScroll");
22366
+ return {
22367
+ getElement: getEl,
22368
+ measure,
22369
+ scrollTo: /* @__PURE__ */ __name((opts) => getEl()?.scrollTo(opts), "scrollTo"),
22370
+ scrollToTop: /* @__PURE__ */ __name((behavior) => getEl()?.scrollTo({ top: 0, behavior: resolveBehavior(behavior) }), "scrollToTop"),
22371
+ scrollToBottom: /* @__PURE__ */ __name((behavior) => {
22372
+ const el = getEl();
22373
+ if (el)
22374
+ el.scrollTo({
22375
+ top: el.scrollHeight,
22376
+ behavior: resolveBehavior(behavior)
22377
+ });
22378
+ }, "scrollToBottom"),
22379
+ scrollToEdge: /* @__PURE__ */ __name((edge, behavior) => {
22380
+ const el = getEl();
22381
+ if (!el) return;
22382
+ const opts = { behavior: resolveBehavior(behavior) };
22383
+ if (edge === "top") opts.top = 0;
22384
+ if (edge === "bottom") opts.top = el.scrollHeight;
22385
+ if (edge === "left") opts.left = 0;
22386
+ if (edge === "right") opts.left = el.scrollWidth;
22387
+ el.scrollTo(opts);
22388
+ }, "scrollToEdge"),
22389
+ scrollNext: /* @__PURE__ */ __name((o) => stepScroll(1, o), "scrollNext"),
22390
+ scrollPrev: /* @__PURE__ */ __name((o) => stepScroll(-1, o), "scrollPrev"),
22391
+ scrollToIndex: /* @__PURE__ */ __name((index, o) => {
22392
+ const el = getEl();
22393
+ const child = el?.children[index];
22394
+ if (!el || !child) return;
22395
+ const axis = o?.axis ?? defaultAxis();
22396
+ el.scrollTo({
22397
+ [axis === "x" ? "left" : "top"]: childTarget(
22398
+ el,
22399
+ child,
22400
+ axis,
22401
+ snapAlign
22402
+ ),
22403
+ behavior: resolveBehavior(o?.behavior)
22404
+ });
22405
+ }, "scrollToIndex")
22406
+ };
22407
+ }, [elRef, measure, direction, snapAlign]);
22408
+ const handleScrollEvent = React2.useCallback(
22409
+ (e) => {
22410
+ onScroll?.(e);
22411
+ handleScroll();
22412
+ },
22413
+ [onScroll, handleScroll]
22414
+ );
22415
+ const responsiveDims = React2.useMemo(() => {
22416
+ const styles = {};
22417
+ const inlineStyle = {};
22418
+ if (isResponsiveValue(maxHeight)) {
22419
+ const { base, responsive } = resolveResponsiveValue(maxHeight);
22420
+ if (base !== void 0) inlineStyle.maxHeight = base;
22421
+ Object.entries(responsive).forEach(([bp, val]) => {
22422
+ styles[bp] = {
22423
+ ...styles[bp] ?? {},
22424
+ maxHeight: val
22425
+ };
22426
+ });
22427
+ } else if (maxHeight !== void 0) {
22428
+ inlineStyle.maxHeight = maxHeight;
22429
+ }
22430
+ if (isResponsiveValue(maxWidth)) {
22431
+ const { base, responsive } = resolveResponsiveValue(maxWidth);
22432
+ if (base !== void 0) inlineStyle.maxWidth = base;
22433
+ Object.entries(responsive).forEach(([bp, val]) => {
22434
+ styles[bp] = {
22435
+ ...styles[bp] ?? {},
22436
+ maxWidth: val
22437
+ };
22438
+ });
22439
+ } else if (maxWidth !== void 0) {
22440
+ inlineStyle.maxWidth = maxWidth;
22441
+ }
22442
+ return { inlineStyle, breakpointStyles: styles };
22443
+ }, [maxHeight, maxWidth]);
22444
+ const { attribute, style: responsiveCss } = (0, hooks_exports.useResponsiveStyles)(
22445
+ responsiveDims.breakpointStyles
22446
+ );
22447
+ const fadeTop = shouldFade(fadeEdges, "top") && state.hasVerticalOverflow && !state.atTop;
22448
+ const fadeBottom = shouldFade(fadeEdges, "bottom") && state.hasVerticalOverflow && !state.atBottom;
22449
+ const fadeLeft = shouldFade(fadeEdges, "left") && state.hasHorizontalOverflow && !state.atLeft;
22450
+ const fadeRight = shouldFade(fadeEdges, "right") && state.hasHorizontalOverflow && !state.atRight;
22451
+ const maskImage = React2.useMemo(() => {
22452
+ if (direction !== "both") return void 0;
22453
+ if (!fadeTop && !fadeBottom && !fadeLeft && !fadeRight) return void 0;
22454
+ const v = `linear-gradient(to bottom, ${fadeTop ? "transparent 0, black var(--kui-scroll-fade-size)" : "black 0"}, ${fadeBottom ? "black calc(100% - var(--kui-scroll-fade-size)), transparent 100%" : "black 100%"})`;
22455
+ const h = `linear-gradient(to right, ${fadeLeft ? "transparent 0, black var(--kui-scroll-fade-size)" : "black 0"}, ${fadeRight ? "black calc(100% - var(--kui-scroll-fade-size)), transparent 100%" : "black 100%"})`;
22456
+ return `${v}, ${h}`;
22457
+ }, [direction, fadeTop, fadeBottom, fadeLeft, fadeRight]);
22458
+ const recipeClasses = resolveRecipe(theme.recipes.ScrollArea, {
22459
+ direction,
22460
+ showScrollbar,
22461
+ scrollbarVariant
22462
+ });
22463
+ const resolvedTabIndex = tabIndex ?? (state.hasVerticalOverflow || state.hasHorizontalOverflow ? 0 : void 0);
22464
+ const snapAxis = direction === "both" ? "both" : direction === "horizontal" ? "x" : "y";
22465
+ const fadeSizeValue = typeof fadeSize === "number" ? `${fadeSize}px` : fadeSize;
22466
+ return /* @__PURE__ */ jsxRuntime.jsxs(ScrollEngineContext.Provider, { value: engine, children: [
21188
22467
  /* @__PURE__ */ jsxRuntime.jsx(ResponsiveStyle, { css: responsiveCss }),
21189
22468
  /* @__PURE__ */ jsxRuntime.jsx(
21190
22469
  Tag,
21191
22470
  {
21192
- ref,
22471
+ ref: elRef,
22472
+ "data-kui-scroll-area": true,
22473
+ "data-direction": direction,
22474
+ "data-fade-top": fadeTop || void 0,
22475
+ "data-fade-bottom": fadeBottom || void 0,
22476
+ "data-fade-left": fadeLeft || void 0,
22477
+ "data-fade-right": fadeRight || void 0,
22478
+ "data-snap-align": snapActive !== "none" ? snapAlign : void 0,
22479
+ "data-drag-scroll": dragActive || void 0,
21193
22480
  "data-kui-responsive": attribute,
21194
- className: cn(!unstyled && "flex", className),
21195
- style,
22481
+ onScroll: handleScrollEvent,
22482
+ tabIndex: resolvedTabIndex,
22483
+ className: cn(recipeClasses, className),
22484
+ style: {
22485
+ ...responsiveDims.inlineStyle,
22486
+ overscrollBehavior,
22487
+ scrollSnapType: snapActive !== "none" ? `${snapAxis} ${snapActive}` : void 0,
22488
+ "--kui-scroll-fade-size": fadeSizeValue,
22489
+ ...maskImage ? {
22490
+ maskImage,
22491
+ WebkitMaskImage: maskImage,
22492
+ maskComposite: "intersect",
22493
+ WebkitMaskComposite: "source-in"
22494
+ } : {},
22495
+ ...style
22496
+ },
21196
22497
  ...rest,
21197
22498
  children
21198
22499
  }
21199
22500
  )
21200
22501
  ] });
21201
- }
21202
- );
21203
- Flex.displayName = "Flex";
21204
- var Stack = React2.forwardRef(
21205
- ({ orientation = "vertical", divider, children, ...rest }, ref) => {
21206
- const direction = orientation === "horizontal" ? "row" : "column";
21207
- if (!divider) {
21208
- return /* @__PURE__ */ jsxRuntime.jsx(Flex, { ref, direction, ...rest, children });
22502
+ }, "render")
22503
+ });
22504
+ var ScrollArea = Object.assign(ScrollAreaRoot, {
22505
+ Scene: ScrollAreaScene,
22506
+ Sticky: ScrollAreaSticky
22507
+ });
22508
+ function resolveSize(value) {
22509
+ if (value === "full") return "100%";
22510
+ if (value === "fit") return "fit-content";
22511
+ if (value === "auto") return "auto";
22512
+ return resolveSpace(value);
22513
+ }
22514
+ __name(resolveSize, "resolveSize");
22515
+ var Box = kreativCore.createComponent({
22516
+ displayName: "Box",
22517
+ __kui: {
22518
+ role: "layout",
22519
+ skeleton: "preserve",
22520
+ video: {
22521
+ id: "box",
22522
+ safe: true,
22523
+ acceptsChildren: true,
22524
+ interactionStates: []
21209
22525
  }
21210
- const items = React2.Children.toArray(children).filter(React2.isValidElement);
21211
- return /* @__PURE__ */ jsxRuntime.jsx(Flex, { ref, direction, ...rest, children: items.map((child, index) => /* @__PURE__ */ jsxRuntime.jsxs(React2.Fragment, { children: [
21212
- child,
21213
- index < items.length - 1 && divider
21214
- ] }, child.key ?? index)) });
21215
- }
21216
- );
21217
- Stack.displayName = "Stack";
21218
- function spaceVar2(value) {
21219
- return `var(--kui-spacing-${value})`;
21220
- }
21221
- __name(spaceVar2, "spaceVar");
21222
- var Grid = React2.forwardRef(
21223
- ({
21224
- columns,
21225
- templateColumns,
21226
- templateRows,
21227
- templateAreas,
21228
- gap,
21229
- columnGap,
21230
- rowGap,
21231
- align,
21232
- justify,
22526
+ },
22527
+ render: /* @__PURE__ */ __name(({
21233
22528
  as: Tag = "div",
22529
+ p,
22530
+ px,
22531
+ py,
22532
+ m,
22533
+ mx,
22534
+ my,
22535
+ bg,
22536
+ color,
22537
+ border = false,
22538
+ rounded,
22539
+ w,
22540
+ h,
21234
22541
  className,
21235
22542
  style,
21236
22543
  unstyled,
21237
22544
  children,
21238
22545
  ...rest
21239
22546
  }, ref) => {
22547
+ const { theme } = kreativCore.useTheme();
22548
+ const borderColor = typeof border === "boolean" ? void 0 : border;
21240
22549
  const responsiveStyles = (0, hooks_exports.useMergedResponsiveStyles)([
21241
- [
21242
- templateColumns ?? columns,
21243
- (v) => typeof v === "number" ? { gridTemplateColumns: `repeat(${v}, minmax(0, 1fr))` } : { gridTemplateColumns: v }
21244
- ],
21245
- [templateRows, (v) => ({ gridTemplateRows: v })],
21246
- [gap, (v) => ({ gap: spaceVar2(v) })],
21247
- [columnGap, (v) => ({ columnGap: spaceVar2(v) })],
21248
- [rowGap, (v) => ({ rowGap: spaceVar2(v) })],
21249
- [align, (v) => ({ alignItems: v })],
21250
- [justify, (v) => ({ justifyContent: v })]
22550
+ [p, (v) => ({ padding: resolveSpace(v) })],
22551
+ [px, (v) => ({ paddingInline: resolveSpace(v) })],
22552
+ [py, (v) => ({ paddingBlock: resolveSpace(v) })],
22553
+ [m, (v) => ({ margin: v === "auto" ? "auto" : resolveSpace(v) })],
22554
+ [mx, (v) => ({ marginInline: v === "auto" ? "auto" : resolveSpace(v) })],
22555
+ [my, (v) => ({ marginBlock: v === "auto" ? "auto" : resolveSpace(v) })],
22556
+ [bg, (v) => ({ background: resolveColor(v) })],
22557
+ [color, (v) => ({ color: resolveColor(v) })],
22558
+ [borderColor, (v) => ({ borderColor: resolveColor(v) })],
22559
+ [rounded, (v) => ({ borderRadius: resolveRadius(v) })],
22560
+ [w, (v) => ({ width: resolveSize(v) })],
22561
+ [h, (v) => ({ height: resolveSize(v) })]
21251
22562
  ]);
21252
22563
  const { attribute, style: responsiveCss } = (0, hooks_exports.useResponsiveStyles)(responsiveStyles);
22564
+ const recipeClasses = resolveRecipe(theme.recipes.Box, {
22565
+ border: Boolean(border)
22566
+ });
21253
22567
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
21254
22568
  /* @__PURE__ */ jsxRuntime.jsx(ResponsiveStyle, { css: responsiveCss }),
21255
22569
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -21257,144 +22571,15 @@ var Grid = React2.forwardRef(
21257
22571
  {
21258
22572
  ref,
21259
22573
  "data-kui-responsive": attribute,
21260
- className: cn(!unstyled && "grid", className),
21261
- style: { ...style, gridTemplateAreas: templateAreas },
22574
+ className: cn(!unstyled && recipeClasses, className),
22575
+ style,
21262
22576
  ...rest,
21263
22577
  children
21264
22578
  }
21265
22579
  )
21266
22580
  ] });
21267
- }
21268
- );
21269
- Grid.displayName = "Grid";
21270
- var cardVariants = {
21271
- solid: "bg-kui-surface",
21272
- outline: "border border-kui-border bg-kui-surface",
21273
- ghost: "bg-transparent",
21274
- elevated: "bg-kui-surface shadow-md",
21275
- compact: "bg-kui-surface"
21276
- };
21277
- var cardSizes = {
21278
- sm: "p-3",
21279
- md: "p-4",
21280
- lg: "p-6"
21281
- };
21282
- var CardRoot = kreativCore.createComponent({
21283
- __kui: {
21284
- role: "display",
21285
- skeleton: "preserve"
21286
- },
21287
- displayName: "Card",
21288
- render: /* @__PURE__ */ __name(({
21289
- variant = "outline",
21290
- size = "md",
21291
- hasImage = false,
21292
- fullWidth = false,
21293
- noPadding = false,
21294
- className,
21295
- children,
21296
- ...props
21297
- }, ref) => {
21298
- const basePadding = variant === "compact" ? "p-3" : hasImage ? "p-0" : cardSizes[size];
21299
- return /* @__PURE__ */ jsxRuntime.jsx(
21300
- "div",
21301
- {
21302
- ref,
21303
- className: cn(
21304
- "overflow-hidden rounded-(--kui-radii-lg)",
21305
- cardVariants[variant],
21306
- fullWidth && "w-full",
21307
- className
21308
- ),
21309
- ...props,
21310
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(!noPadding && basePadding), children })
21311
- }
21312
- );
21313
22581
  }, "render")
21314
22582
  });
21315
- var CardHeader = kreativCore.createComponent({
21316
- __kui: {
21317
- groupSlot: "Card"
21318
- },
21319
- displayName: "Card.Header",
21320
- render: /* @__PURE__ */ __name(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
21321
- "div",
21322
- {
21323
- ref,
21324
- className: cn(
21325
- "flex items-center justify-between gap-(--kui-spacing-md)",
21326
- className
21327
- ),
21328
- ...props,
21329
- children
21330
- }
21331
- ), "render")
21332
- });
21333
- var CardBody = kreativCore.createComponent({
21334
- __kui: {
21335
- groupSlot: "Card"
21336
- },
21337
- displayName: "Card.Body",
21338
- render: /* @__PURE__ */ __name(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("min-w-0", className), ...props, children }), "render")
21339
- });
21340
- var CardFooter = kreativCore.createComponent({
21341
- __kui: {
21342
- groupSlot: "Card"
21343
- },
21344
- displayName: "Card.Footer",
21345
- render: /* @__PURE__ */ __name(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
21346
- "div",
21347
- {
21348
- ref,
21349
- className: cn("flex items-center gap-(--kui-spacing-md)", className),
21350
- ...props,
21351
- children
21352
- }
21353
- ), "render")
21354
- });
21355
- var Card = Object.assign(CardRoot, {
21356
- Header: CardHeader,
21357
- Body: CardBody,
21358
- Footer: CardFooter
21359
- // Media: CardMedia,
21360
- // Overlay: CardOverlay,
21361
- });
21362
-
21363
- // src/components/internal/loader/skeletonRegistry.ts
21364
- var registry2 = /* @__PURE__ */ new WeakMap();
21365
- function registerSkeleton(component, definition) {
21366
- registry2.set(component, definition);
21367
- }
21368
- __name(registerSkeleton, "registerSkeleton");
21369
-
21370
- // src/components/Loader/Loader.types.ts
21371
- var KUI_COMPONENT_METADATA = /* @__PURE__ */ Symbol("kui.component.metadata");
21372
- function tagKuiComponent(component, metadata) {
21373
- component[KUI_COMPONENT_METADATA] = metadata;
21374
- }
21375
- __name(tagKuiComponent, "tagKuiComponent");
21376
-
21377
- // src/components/Loader/defineSkeleton.ts
21378
- function defineSkeleton(resolve, options) {
21379
- return { resolve, defaults: options?.defaults };
21380
- }
21381
- __name(defineSkeleton, "defineSkeleton");
21382
-
21383
- // src/components/layout/Card/Card.skeleton.tsx
21384
- tagKuiComponent(Card, {
21385
- name: "Card",
21386
- usesSizeScale: true,
21387
- slots: ["avatar", "text"]
21388
- });
21389
- var cardSkeleton = defineSkeleton(
21390
- (props) => ({
21391
- avatar: props.hasImage ? { size: "md", shape: "square" } : false,
21392
- rows: props.variant === "compact" ? 1 : 3,
21393
- width: props.fullWidth ? "100%" : props.size === "sm" ? 200 : 320
21394
- }),
21395
- { defaults: { rows: 2, avatar: false, width: 280 } }
21396
- );
21397
- registerSkeleton(Card, cardSkeleton);
21398
22583
  var InputField = React2.forwardRef(
21399
22584
  ({
21400
22585
  id,
@@ -21697,7 +22882,7 @@ var defaultTypography = kreativCore.defineTypography({
21697
22882
  },
21698
22883
  sizeMd: {
21699
22884
  fontFamily: "{fonts.body}",
21700
- fontSize: "{fontSizes.sm}",
22885
+ fontSize: "{fontSizes.md}",
21701
22886
  fontWeight: "{fontWeights.normal}",
21702
22887
  lineHeight: "{lineHeights.normal}"
21703
22888
  },
@@ -21722,8 +22907,7 @@ var defaultSizes = kreativCore.defineSizes({
21722
22907
  fontSize: "{typography.sizeXs}",
21723
22908
  gap: "0.25rem",
21724
22909
  iconSize: "0.75rem",
21725
- radius: "0.65rem",
21726
- separatorSize: "15px"
22910
+ radius: "0.65rem"
21727
22911
  },
21728
22912
  sm: {
21729
22913
  height: "2rem",
@@ -21732,8 +22916,7 @@ var defaultSizes = kreativCore.defineSizes({
21732
22916
  fontSize: "{typography.sizeSm}",
21733
22917
  gap: "0.375rem",
21734
22918
  iconSize: "0.875rem",
21735
- radius: "0.8rem",
21736
- separatorSize: "20px"
22919
+ radius: "0.8rem"
21737
22920
  },
21738
22921
  md: {
21739
22922
  height: "2.5rem",
@@ -21742,8 +22925,7 @@ var defaultSizes = kreativCore.defineSizes({
21742
22925
  fontSize: "{typography.sizeMd}",
21743
22926
  gap: "0.5rem",
21744
22927
  iconSize: "1rem",
21745
- radius: "1rem",
21746
- separatorSize: "25px"
22928
+ radius: "1rem"
21747
22929
  },
21748
22930
  lg: {
21749
22931
  height: "3rem",
@@ -21752,8 +22934,7 @@ var defaultSizes = kreativCore.defineSizes({
21752
22934
  fontSize: "{typography.sizeLg}",
21753
22935
  gap: "0.625rem",
21754
22936
  iconSize: "1.25rem",
21755
- radius: "1.15rem",
21756
- separatorSize: "30px"
22937
+ radius: "1.15rem"
21757
22938
  },
21758
22939
  xl: {
21759
22940
  height: "3.5rem",
@@ -21762,8 +22943,7 @@ var defaultSizes = kreativCore.defineSizes({
21762
22943
  fontSize: "{typography.sizeXl}",
21763
22944
  gap: "0.875rem",
21764
22945
  iconSize: "1.5rem",
21765
- radius: "1.3rem",
21766
- separatorSize: "35px"
22946
+ radius: "1.3rem"
21767
22947
  }
21768
22948
  });
21769
22949
  var buttonBase = "inline-flex items-center justify-center rounded-[var(--kui-button-radius,var(--kui-radius))] font-medium transition-[background-color,border-color,color,transform,opacity] duration-200 will-change-transform focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-kui-brand focus-visible:ring-offset-2 focus-visible:ring-offset-surface disabled:opacity-60 disabled:pointer-events-none disabled:active:scale-100";
@@ -21817,6 +22997,13 @@ var buttonColors = {
21817
22997
  soft: "bg-white/10 text-white hover:bg-white/20",
21818
22998
  link: "text-white"
21819
22999
  },
23000
+ black: {
23001
+ solid: "bg-black text-white hover:bg-neutral-900 active:bg-neutral-950 shadow-sm",
23002
+ outline: "border border-black/80 text-black bg-transparent hover:bg-black hover:text-white active:bg-black/90",
23003
+ ghost: "text-black bg-transparent hover:bg-black/10 active:bg-black/15",
23004
+ soft: "bg-black/10 text-black hover:bg-black/15 active:bg-black/20",
23005
+ link: "text-black underline-offset-4 hover:underline"
23006
+ },
21820
23007
  neutral: {
21821
23008
  solid: "bg-kui-surface-raised text-kui-text hover:bg-kui-surface-sunken",
21822
23009
  outline: "border-kui-border text-kui-text hover:bg-kui-surface-raised",
@@ -21860,7 +23047,11 @@ var buttonRecipe = kreativCore.defineRecipe({
21860
23047
  });
21861
23048
  var formControlBase = "group relative inline-flex items-center rounded-[var(--kui-radii-md)] transition-[border-color,box-shadow] duration-[var(--kui-duration-fast)] focus-within:outline-none ";
21862
23049
  var formControlVariants = {
21863
- outline: "border border-kui-border bg-transparent text-kui-text",
23050
+ outline: {
23051
+ border: "1px solid rgb(var(--kui-border))",
23052
+ backgroundColor: "transparent",
23053
+ color: "rgb(var(--kui-text))"
23054
+ },
21864
23055
  filled: "border border-transparent bg-kui-surface-raised text-kui-text",
21865
23056
  ghost: "border border-transparent bg-transparent text-kui-text"
21866
23057
  };
@@ -22229,7 +23420,7 @@ var switchRecipe = kreativCore.defineRecipe({
22229
23420
  disabled: false
22230
23421
  }
22231
23422
  });
22232
- var containerReccipe = kreativCore.defineRecipe({
23423
+ var containerRecipe = kreativCore.defineRecipe({
22233
23424
  base: "w-full",
22234
23425
  variants: {
22235
23426
  maxWidth: {
@@ -22242,6 +23433,7 @@ var containerReccipe = kreativCore.defineRecipe({
22242
23433
  }
22243
23434
  },
22244
23435
  defaultVariants: {
23436
+ size: "lg",
22245
23437
  maxWidth: "lg"
22246
23438
  }
22247
23439
  });
@@ -22365,18 +23557,179 @@ var numberStepperButtonsRecipe = kreativCore.defineRecipe({
22365
23557
  var numberStepperButtonRecipe = kreativCore.defineRecipe({
22366
23558
  base: "kui-number-stepper__button"
22367
23559
  });
23560
+ var cardRecipe = kreativCore.defineRecipe({
23561
+ base: "overflow-hidden rounded-(--kui-radii-lg)",
23562
+ variants: {
23563
+ variant: {
23564
+ solid: "bg-kui-surface",
23565
+ outline: "border border-kui-border bg-kui-surface",
23566
+ ghost: "bg-transparent",
23567
+ elevated: "bg-kui-surface shadow-md",
23568
+ compact: "bg-kui-surface"
23569
+ },
23570
+ fullWidth: {
23571
+ true: "w-full"
23572
+ }
23573
+ },
23574
+ defaultVariants: {
23575
+ variant: "outline"
23576
+ }
23577
+ });
23578
+ var sectionPaddingVariants = {
23579
+ size: {
23580
+ sm: "p-3",
23581
+ md: "p-4",
23582
+ lg: "p-6"
23583
+ }
23584
+ };
23585
+ var sectionPaddingCompoundVariants = [
23586
+ {
23587
+ conditions: { variant: "compact" },
23588
+ className: "p-3"
23589
+ },
23590
+ {
23591
+ conditions: { noPadding: true },
23592
+ className: "p-0"
23593
+ }
23594
+ ];
23595
+ var cardHeaderRecipe = kreativCore.defineRecipe({
23596
+ base: "relative flex items-center justify-between gap-(--kui-spacing-md)",
23597
+ variants: sectionPaddingVariants,
23598
+ defaultVariants: {
23599
+ size: "md"
23600
+ },
23601
+ compoundVariants: [...sectionPaddingCompoundVariants]
23602
+ });
23603
+ var cardBodyRecipe = kreativCore.defineRecipe({
23604
+ base: "relative min-w-0",
23605
+ variants: sectionPaddingVariants,
23606
+ defaultVariants: {
23607
+ size: "md"
23608
+ },
23609
+ compoundVariants: [...sectionPaddingCompoundVariants]
23610
+ });
23611
+ var cardFooterRecipe = kreativCore.defineRecipe({
23612
+ base: "relative flex items-center gap-(--kui-spacing-md)",
23613
+ variants: sectionPaddingVariants,
23614
+ defaultVariants: {
23615
+ size: "md"
23616
+ },
23617
+ compoundVariants: [...sectionPaddingCompoundVariants]
23618
+ });
23619
+ var cardMediaRecipe = kreativCore.defineRecipe({
23620
+ base: "relative overflow-hidden"
23621
+ });
23622
+ kreativCore.defineRecipe({
23623
+ base: "h-full w-full",
23624
+ variants: {
23625
+ fit: {
23626
+ cover: "object-cover",
23627
+ contain: "object-contain",
23628
+ fill: "object-fill",
23629
+ none: "object-none"
23630
+ },
23631
+ blend: {
23632
+ normal: "mix-blend-normal",
23633
+ multiply: "mix-blend-multiply",
23634
+ screen: "mix-blend-screen",
23635
+ overlay: "mix-blend-overlay",
23636
+ darken: "mix-blend-darken",
23637
+ lighten: "mix-blend-lighten"
23638
+ }
23639
+ },
23640
+ defaultVariants: {
23641
+ fit: "cover",
23642
+ blend: "normal"
23643
+ }
23644
+ });
23645
+ var cardOverlayRecipe = kreativCore.defineRecipe({
23646
+ base: "absolute inset-0"
23647
+ });
23648
+ var scrollAreaRecipe = kreativCore.defineRecipe({
23649
+ base: "kui-scroll-area",
23650
+ variants: {
23651
+ direction: {
23652
+ vertical: "overflow-y-auto overflow-x-hidden",
23653
+ horizontal: "overflow-x-auto overflow-y-hidden",
23654
+ both: "overflow-auto"
23655
+ },
23656
+ showScrollbar: {
23657
+ auto: "",
23658
+ always: "kui-scrollbar",
23659
+ hover: "kui-scrollbar kui-scrollbar-hover-only",
23660
+ never: "kui-scrollbar-hidden"
23661
+ },
23662
+ scrollbarVariant: {
23663
+ thin: "kui-scrollbar",
23664
+ default: "kui-scrollbar-default-width"
23665
+ }
23666
+ },
23667
+ defaultVariants: {
23668
+ direction: "vertical",
23669
+ showScrollbar: "auto",
23670
+ scrollbarVariant: "thin"
23671
+ }
23672
+ });
23673
+ var boxRecipe = kreativCore.defineRecipe({
23674
+ base: "box-border",
23675
+ variants: {
23676
+ border: {
23677
+ true: "border border-solid border-kui-border",
23678
+ false: ""
23679
+ }
23680
+ },
23681
+ defaultVariants: {
23682
+ border: "false"
23683
+ }
23684
+ });
23685
+ var flexRecipe = kreativCore.defineRecipe({
23686
+ base: "",
23687
+ variants: {
23688
+ inline: {
23689
+ true: "inline-flex",
23690
+ false: "flex"
23691
+ },
23692
+ fullWidth: {
23693
+ true: "w-full",
23694
+ false: ""
23695
+ },
23696
+ fullHeight: {
23697
+ true: "h-full",
23698
+ false: ""
23699
+ }
23700
+ },
23701
+ defaultVariants: {
23702
+ inline: "false",
23703
+ fullWidth: "false",
23704
+ fullHeight: "false"
23705
+ }
23706
+ });
23707
+ var gridRecipe = kreativCore.defineRecipe({
23708
+ base: "",
23709
+ variants: {
23710
+ inline: {
23711
+ true: "inline-grid",
23712
+ false: "grid"
23713
+ }
23714
+ },
23715
+ defaultVariants: {
23716
+ inline: "false"
23717
+ }
23718
+ });
22368
23719
 
22369
23720
  // src/theme/defaults/theme.ts
22370
23721
  var defaultRecipes = {
23722
+ Box: boxRecipe,
22371
23723
  Button: buttonRecipe,
23724
+ ButtonGroup: buttonGroupRecipe,
23725
+ Checkbox: checkboxRecipe,
23726
+ Flex: flexRecipe,
22372
23727
  FormControl: formControlRecipe,
22373
23728
  Input: inputRecipe,
22374
23729
  Textarea: textareaRecipe,
22375
23730
  MarkdownEditor: markdownEditorRecipe,
22376
- Checkbox: checkboxRecipe,
22377
- ButtonGroup: buttonGroupRecipe,
22378
23731
  Switch: switchRecipe,
22379
- Container: containerReccipe,
23732
+ Container: containerRecipe,
22380
23733
  Link: linkRecipe,
22381
23734
  RepeaterRemove: repeaterRemoveRecipe,
22382
23735
  RepeaterMoveUp: repeaterMoveUpRecipe,
@@ -22386,7 +23739,15 @@ var defaultRecipes = {
22386
23739
  RepeaterItems: repeaterItemsRecipe,
22387
23740
  NumberStepper: numberStepperRecipe,
22388
23741
  NumberStepperButton: numberStepperButtonRecipe,
22389
- NumberStepperButtons: numberStepperButtonsRecipe
23742
+ NumberStepperButtons: numberStepperButtonsRecipe,
23743
+ CardBody: cardBodyRecipe,
23744
+ CardFooter: cardFooterRecipe,
23745
+ CardHeader: cardHeaderRecipe,
23746
+ CardMedia: cardMediaRecipe,
23747
+ CardOverlay: cardOverlayRecipe,
23748
+ Card: cardRecipe,
23749
+ ScrollArea: scrollAreaRecipe,
23750
+ Grid: gridRecipe
22390
23751
  };
22391
23752
  var defaultTheme = kreativCore.defineTheme({
22392
23753
  tokens: defaultTokens,
@@ -22480,6 +23841,7 @@ __name(extendSizes, "extendSizes");
22480
23841
 
22481
23842
  // src/theme/extendTheme.ts
22482
23843
  function extendTheme(override) {
23844
+ console.log(override?.semanticTokens?.colors);
22483
23845
  if (!override) {
22484
23846
  return defaultTheme;
22485
23847
  }
@@ -22513,7 +23875,9 @@ function KreativUIProvider({
22513
23875
  as = "div",
22514
23876
  fallbackSize = "md",
22515
23877
  textColor,
22516
- background
23878
+ background,
23879
+ style,
23880
+ className
22517
23881
  }) {
22518
23882
  const [mode, setMode] = React2.useState(defaultMode);
22519
23883
  const systemPrefersDark = useSystemPrefersDark();
@@ -22550,11 +23914,12 @@ function KreativUIProvider({
22550
23914
  Tag,
22551
23915
  {
22552
23916
  "data-kreativ-theme": resolvedMode,
22553
- className: resolvedMode === "dark" ? "dark" : void 0,
23917
+ className: [resolvedMode === "dark" ? "dark" : void 0, className].filter(Boolean).join(" "),
22554
23918
  style: {
22555
23919
  ...cssVars,
22556
23920
  ...background && { background },
22557
- ...textColor && { color: textColor }
23921
+ ...textColor && { color: textColor },
23922
+ ...style
22558
23923
  },
22559
23924
  children
22560
23925
  }
@@ -22565,6 +23930,10 @@ __name(KreativUIProvider, "KreativUIProvider");
22565
23930
  // src/index.ts
22566
23931
  __reExport(index_exports, hooks_exports);
22567
23932
 
23933
+ Object.defineProperty(exports, "PersistMode", {
23934
+ enumerable: true,
23935
+ get: function () { return kreativCore.PersistMode; }
23936
+ });
22568
23937
  Object.defineProperty(exports, "ThemeContext", {
22569
23938
  enumerable: true,
22570
23939
  get: function () { return kreativCore.ThemeContext; }
@@ -22602,11 +23971,13 @@ Object.defineProperty(exports, "resolveTypography", {
22602
23971
  get: function () { return kreativCore.resolveTypography; }
22603
23972
  });
22604
23973
  exports.Adornment = Adornment;
23974
+ exports.Box = Box;
22605
23975
  exports.Button = Button;
22606
23976
  exports.ButtonGroup = ButtonGroup;
22607
23977
  exports.ButtonGroupContext = ButtonGroupContext;
22608
23978
  exports.ButtonGroupItemContext = ButtonGroupItemContext;
22609
23979
  exports.Card = Card;
23980
+ exports.CardOverlay = CardOverlay;
22610
23981
  exports.Checkbox = Checkbox;
22611
23982
  exports.Combobox = Combobox;
22612
23983
  exports.ComboboxContent = ComboboxContent;
@@ -22633,6 +24004,7 @@ exports.MultiSelectItem = MultiSelectItem;
22633
24004
  exports.MultiSelectTrigger = MultiSelectTrigger;
22634
24005
  exports.Radio = Radio;
22635
24006
  exports.RadioGroup = RadioGroup;
24007
+ exports.ScrollArea = ScrollArea;
22636
24008
  exports.Select = Select;
22637
24009
  exports.SelectContent = SelectContent;
22638
24010
  exports.SelectGroup = SelectGroup;
@@ -22645,7 +24017,6 @@ exports.Stack = Stack;
22645
24017
  exports.Switch = Switch;
22646
24018
  exports.Textarea = Textarea;
22647
24019
  exports.ThemeToggler = ThemeToggler;
22648
- exports.cardSkeleton = cardSkeleton;
22649
24020
  exports.cn = cn;
22650
24021
  exports.defineUIField = defineUIField;
22651
24022
  exports.extendRecipe = extendRecipe;
@@ -22660,11 +24031,13 @@ exports.rgbToHex = rgbToHex;
22660
24031
  exports.useButtonGroupContext = useButtonGroupContext;
22661
24032
  exports.useButtonGroupItemContext = useButtonGroupItemContext;
22662
24033
  exports.useClearableField = useClearableField;
24034
+ exports.useElementScrollProgress = useElementScrollProgress;
22663
24035
  exports.useFloatingSide = useFloatingSide;
22664
24036
  exports.useFormContext = useFormContext;
22665
24037
  exports.useKeyboardShortcuts = useKeyboardShortcuts;
22666
24038
  exports.useOptionalButtonGroupContext = useOptionalButtonGroupContext;
22667
24039
  exports.useOptionalButtonGroupItemContext = useOptionalButtonGroupItemContext;
24040
+ exports.useScrollProgress = useScrollProgress;
22668
24041
  exports.useStatusTransition = useStatusTransition;
22669
24042
  //# sourceMappingURL=index.cjs.map
22670
24043
  //# sourceMappingURL=index.cjs.map