@splenddev/kreativ-ui 0.3.1 → 0.3.3
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 +2110 -740
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +531 -92
- package/dist/index.d.ts +531 -92
- package/dist/index.js +2137 -775
- package/dist/index.js.map +1 -1
- package/dist/styles/index.css +1 -1
- package/package.json +2 -2
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
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
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
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
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
|
-
|
|
938
|
+
ButtonsMode,
|
|
862
939
|
{
|
|
863
940
|
size: resolvedSize,
|
|
864
|
-
variant,
|
|
865
941
|
color,
|
|
866
942
|
iconOnly,
|
|
867
943
|
buttonProps,
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
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
|
-
|
|
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 = {
|
|
@@ -1778,7 +1839,6 @@ var FormSubmitButton = React2__namespace.forwardRef(/* @__PURE__ */ __name(funct
|
|
|
1778
1839
|
"[kreativ-ui/Form.SubmitButton]: must be rendered inside <Form>."
|
|
1779
1840
|
);
|
|
1780
1841
|
}
|
|
1781
|
-
console.log(form.errors);
|
|
1782
1842
|
if (!React2__namespace.isValidElement(children)) {
|
|
1783
1843
|
throw new Error(
|
|
1784
1844
|
"[kreativ-ui/Form.SubmitButton]: requires exactly one React element child."
|
|
@@ -14431,21 +14491,21 @@ var allProcessors = {
|
|
|
14431
14491
|
};
|
|
14432
14492
|
function toJSONSchema(input, params) {
|
|
14433
14493
|
if ("_idmap" in input) {
|
|
14434
|
-
const
|
|
14494
|
+
const registry2 = input;
|
|
14435
14495
|
const ctx2 = initializeContext({ ...params, processors: allProcessors });
|
|
14436
14496
|
const defs = {};
|
|
14437
|
-
for (const entry of
|
|
14497
|
+
for (const entry of registry2._idmap.entries()) {
|
|
14438
14498
|
const [_, schema] = entry;
|
|
14439
14499
|
process2(schema, ctx2);
|
|
14440
14500
|
}
|
|
14441
14501
|
const schemas = {};
|
|
14442
14502
|
const external = {
|
|
14443
|
-
registry:
|
|
14503
|
+
registry: registry2,
|
|
14444
14504
|
uri: params?.uri,
|
|
14445
14505
|
defs
|
|
14446
14506
|
};
|
|
14447
14507
|
ctx2.external = external;
|
|
14448
|
-
for (const entry of
|
|
14508
|
+
for (const entry of registry2._idmap.entries()) {
|
|
14449
14509
|
const [key, schema] = entry;
|
|
14450
14510
|
extractDefs(ctx2, schema);
|
|
14451
14511
|
schemas[key] = finalize(ctx2, schema);
|
|
@@ -17366,7 +17426,7 @@ function SelectLabel({ children, className }) {
|
|
|
17366
17426
|
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
17427
|
}
|
|
17368
17428
|
__name(SelectLabel, "SelectLabel");
|
|
17369
|
-
function SelectImpl({ options, children, ...rootProps }, ref) {
|
|
17429
|
+
function SelectImpl({ options, children, label, ...rootProps }, ref) {
|
|
17370
17430
|
const childArray = React2__namespace.Children.toArray(children);
|
|
17371
17431
|
const compound = childArray.length > 0;
|
|
17372
17432
|
if (isDev() && compound && options?.length) {
|
|
@@ -17375,6 +17435,7 @@ function SelectImpl({ options, children, ...rootProps }, ref) {
|
|
|
17375
17435
|
);
|
|
17376
17436
|
}
|
|
17377
17437
|
return /* @__PURE__ */ jsxRuntime.jsx(SelectRoot, { ...rootProps, ref, children: compound ? children : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
17438
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(Select.Label, { children: label }),
|
|
17378
17439
|
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, {}) }),
|
|
17379
17440
|
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: options?.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
17380
17441
|
SelectItem,
|
|
@@ -17874,362 +17935,68 @@ var TextareaCore = React2.forwardRef(
|
|
|
17874
17935
|
}
|
|
17875
17936
|
);
|
|
17876
17937
|
TextareaCore.displayName = "TextareaCore";
|
|
17877
|
-
|
|
17878
|
-
|
|
17879
|
-
|
|
17880
|
-
|
|
17881
|
-
|
|
17882
|
-
|
|
17883
|
-
|
|
17884
|
-
|
|
17885
|
-
|
|
17886
|
-
|
|
17887
|
-
|
|
17888
|
-
|
|
17889
|
-
|
|
17890
|
-
|
|
17891
|
-
|
|
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")
|
|
17938
|
+
var Textarea = kreativCore.createComponent({
|
|
17939
|
+
displayName: "Textarea",
|
|
17940
|
+
__kui: {
|
|
17941
|
+
role: "formControl",
|
|
17942
|
+
formControl: "single",
|
|
17943
|
+
supports: { disabled: true, invalid: true, required: true },
|
|
17944
|
+
skeleton: "input-shaped",
|
|
17945
|
+
video: {
|
|
17946
|
+
id: "textarea",
|
|
17947
|
+
safe: true,
|
|
17948
|
+
acceptsChildren: false,
|
|
17949
|
+
interactionStates: ["focus"],
|
|
17950
|
+
controlled: ["value", "disabled"],
|
|
17951
|
+
motionGated: true
|
|
17952
|
+
}
|
|
17981
17953
|
},
|
|
17982
|
-
{
|
|
17983
|
-
|
|
17984
|
-
|
|
17985
|
-
|
|
17954
|
+
render: /* @__PURE__ */ __name((props, ref) => {
|
|
17955
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TextareaCore, { ref, ...props });
|
|
17956
|
+
}, "render")
|
|
17957
|
+
});
|
|
17958
|
+
var Checkbox = kreativCore.createComponent({
|
|
17959
|
+
displayName: "Checkbox",
|
|
17960
|
+
__kui: {
|
|
17961
|
+
role: "formControl",
|
|
17962
|
+
formControl: "single",
|
|
17963
|
+
supports: { disabled: true, invalid: true, required: true },
|
|
17964
|
+
skeleton: "input-shaped",
|
|
17965
|
+
video: {
|
|
17966
|
+
id: "checkbox",
|
|
17967
|
+
safe: true,
|
|
17968
|
+
acceptsChildren: false,
|
|
17969
|
+
interactionStates: ["focus"],
|
|
17970
|
+
controlled: ["checked", "disabled", "indeterminate"],
|
|
17971
|
+
motionGated: true
|
|
17972
|
+
}
|
|
17986
17973
|
},
|
|
17987
|
-
|
|
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,
|
|
17974
|
+
render: /* @__PURE__ */ __name(({
|
|
18000
17975
|
className,
|
|
18001
|
-
|
|
18002
|
-
|
|
18003
|
-
|
|
17976
|
+
checked: checkedProp,
|
|
17977
|
+
defaultChecked,
|
|
17978
|
+
onCheckedChange,
|
|
17979
|
+
indeterminate = false,
|
|
17980
|
+
size = "sm",
|
|
18004
17981
|
error: error51,
|
|
18005
|
-
|
|
17982
|
+
success: success2,
|
|
17983
|
+
status,
|
|
18006
17984
|
disabled,
|
|
18007
|
-
|
|
18008
|
-
|
|
17985
|
+
label,
|
|
17986
|
+
description,
|
|
17987
|
+
id: externalId,
|
|
17988
|
+
onChange: onChangeProp,
|
|
17989
|
+
required: required2,
|
|
17990
|
+
...props
|
|
18009
17991
|
}, ref) => {
|
|
18010
|
-
const
|
|
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();
|
|
17992
|
+
const autoId = React2.useId();
|
|
18017
17993
|
const field = useOptionalFormField();
|
|
18018
|
-
const
|
|
18019
|
-
const
|
|
18020
|
-
const
|
|
18021
|
-
const
|
|
18022
|
-
const
|
|
18023
|
-
|
|
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
|
|
17994
|
+
const { theme } = kreativCore.useTheme();
|
|
17995
|
+
const id = field?.id ?? externalId ?? autoId;
|
|
17996
|
+
const isDisabled = disabled || Boolean(field?.disabled);
|
|
17997
|
+
const inputRef = React2.useRef(null);
|
|
17998
|
+
const [internalChecked, setInternalChecked] = React2.useState(
|
|
17999
|
+
defaultChecked ?? false
|
|
18233
18000
|
);
|
|
18234
18001
|
const isControlled = checkedProp !== void 0;
|
|
18235
18002
|
const checked = isControlled ? checkedProp : internalChecked;
|
|
@@ -18486,7 +18253,6 @@ var NumberStepper = kreativCore.createComponent({
|
|
|
18486
18253
|
precision,
|
|
18487
18254
|
required: isRequired
|
|
18488
18255
|
});
|
|
18489
|
-
console.log("validate", { raw, min, max, step, precision, result });
|
|
18490
18256
|
onValidate?.(result);
|
|
18491
18257
|
reportToFormField(result);
|
|
18492
18258
|
return result;
|
|
@@ -20092,75 +19858,413 @@ var FormField = Object.assign(FormFieldForwardRef, {
|
|
|
20092
19858
|
Message: FormFieldMessage,
|
|
20093
19859
|
Control: FormFieldControl
|
|
20094
19860
|
});
|
|
20095
|
-
|
|
20096
|
-
|
|
20097
|
-
|
|
20098
|
-
|
|
20099
|
-
|
|
20100
|
-
|
|
20101
|
-
return
|
|
19861
|
+
|
|
19862
|
+
// src/components/forms/MarkdownEditor/markdownActions.ts
|
|
19863
|
+
function lineBounds(value, index) {
|
|
19864
|
+
const start = value.lastIndexOf("\n", index - 1) + 1;
|
|
19865
|
+
const nextBreak = value.indexOf("\n", index);
|
|
19866
|
+
const end = nextBreak === -1 ? value.length : nextBreak;
|
|
19867
|
+
return { start, end };
|
|
20102
19868
|
}
|
|
20103
|
-
__name(
|
|
20104
|
-
function
|
|
20105
|
-
value
|
|
20106
|
-
|
|
20107
|
-
|
|
20108
|
-
|
|
20109
|
-
|
|
20110
|
-
|
|
20111
|
-
|
|
20112
|
-
|
|
20113
|
-
|
|
20114
|
-
|
|
20115
|
-
|
|
20116
|
-
|
|
20117
|
-
|
|
20118
|
-
|
|
20119
|
-
|
|
20120
|
-
|
|
20121
|
-
const
|
|
20122
|
-
const
|
|
20123
|
-
|
|
20124
|
-
|
|
20125
|
-
|
|
20126
|
-
|
|
20127
|
-
|
|
20128
|
-
|
|
20129
|
-
|
|
20130
|
-
|
|
20131
|
-
|
|
20132
|
-
|
|
20133
|
-
|
|
20134
|
-
|
|
20135
|
-
|
|
20136
|
-
|
|
20137
|
-
|
|
20138
|
-
|
|
20139
|
-
|
|
20140
|
-
|
|
20141
|
-
|
|
20142
|
-
|
|
20143
|
-
|
|
20144
|
-
|
|
20145
|
-
|
|
20146
|
-
|
|
20147
|
-
|
|
20148
|
-
|
|
20149
|
-
|
|
20150
|
-
|
|
20151
|
-
|
|
20152
|
-
|
|
20153
|
-
|
|
20154
|
-
|
|
20155
|
-
|
|
20156
|
-
|
|
20157
|
-
|
|
20158
|
-
|
|
20159
|
-
|
|
20160
|
-
|
|
20161
|
-
|
|
20162
|
-
|
|
20163
|
-
)
|
|
19869
|
+
__name(lineBounds, "lineBounds");
|
|
19870
|
+
function selectedLineRange(value, start, end) {
|
|
19871
|
+
const first = lineBounds(value, start);
|
|
19872
|
+
const last = lineBounds(value, Math.max(end - 1, start));
|
|
19873
|
+
return { from: first.start, to: last.end };
|
|
19874
|
+
}
|
|
19875
|
+
__name(selectedLineRange, "selectedLineRange");
|
|
19876
|
+
function toggleWrap(value, start, end, marker) {
|
|
19877
|
+
const before = value.slice(Math.max(0, start - marker.length), start);
|
|
19878
|
+
const after = value.slice(end, end + marker.length);
|
|
19879
|
+
if (before === marker && after === marker) {
|
|
19880
|
+
const next2 = value.slice(0, start - marker.length) + value.slice(start, end) + value.slice(end + marker.length);
|
|
19881
|
+
return {
|
|
19882
|
+
value: next2,
|
|
19883
|
+
selectionStart: start - marker.length,
|
|
19884
|
+
selectionEnd: end - marker.length
|
|
19885
|
+
};
|
|
19886
|
+
}
|
|
19887
|
+
const selected = value.slice(start, end);
|
|
19888
|
+
const next = value.slice(0, start) + marker + selected + marker + value.slice(end);
|
|
19889
|
+
return selected.length === 0 ? {
|
|
19890
|
+
value: next,
|
|
19891
|
+
selectionStart: start + marker.length,
|
|
19892
|
+
selectionEnd: start + marker.length
|
|
19893
|
+
} : {
|
|
19894
|
+
value: next,
|
|
19895
|
+
selectionStart: start,
|
|
19896
|
+
selectionEnd: end + marker.length * 2
|
|
19897
|
+
};
|
|
19898
|
+
}
|
|
19899
|
+
__name(toggleWrap, "toggleWrap");
|
|
19900
|
+
function toggleLinePrefix(value, start, end, prefix) {
|
|
19901
|
+
const { from, to } = selectedLineRange(value, start, end);
|
|
19902
|
+
const line = value.slice(from, to);
|
|
19903
|
+
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);
|
|
19904
|
+
const delta = (line.startsWith(prefix) ? -1 : 1) * prefix.length;
|
|
19905
|
+
return {
|
|
19906
|
+
value: next,
|
|
19907
|
+
selectionStart: start + delta,
|
|
19908
|
+
selectionEnd: end + delta
|
|
19909
|
+
};
|
|
19910
|
+
}
|
|
19911
|
+
__name(toggleLinePrefix, "toggleLinePrefix");
|
|
19912
|
+
function toggleListPrefix(value, start, end, makePrefix) {
|
|
19913
|
+
const { from, to } = selectedLineRange(value, start, end);
|
|
19914
|
+
const block = value.slice(from, to);
|
|
19915
|
+
const lines = block.split("\n");
|
|
19916
|
+
const alreadyListed = lines.every(
|
|
19917
|
+
(l) => l.startsWith(makePrefix(0)) || /^\d+\.\s/.test(l)
|
|
19918
|
+
);
|
|
19919
|
+
const nextLines = lines.map(
|
|
19920
|
+
(l, i) => alreadyListed ? l.replace(/^(\d+\.\s|-\s\[ \]\s|-\s)/, "") : makePrefix(i) + l
|
|
19921
|
+
);
|
|
19922
|
+
const next = value.slice(0, from) + nextLines.join("\n") + value.slice(to);
|
|
19923
|
+
const delta = nextLines.join("\n").length - block.length;
|
|
19924
|
+
return { value: next, selectionStart: from, selectionEnd: to + delta };
|
|
19925
|
+
}
|
|
19926
|
+
__name(toggleListPrefix, "toggleListPrefix");
|
|
19927
|
+
function toggleCode(value, start, end) {
|
|
19928
|
+
const selected = value.slice(start, end);
|
|
19929
|
+
if (selected.includes("\n")) {
|
|
19930
|
+
const next = value.slice(0, start) + "```\n" + selected + "\n```" + value.slice(end);
|
|
19931
|
+
return { value: next, selectionStart: start + 4, selectionEnd: end + 4 };
|
|
19932
|
+
}
|
|
19933
|
+
return toggleWrap(value, start, end, "`");
|
|
19934
|
+
}
|
|
19935
|
+
__name(toggleCode, "toggleCode");
|
|
19936
|
+
function insertLink(value, start, end) {
|
|
19937
|
+
const selected = value.slice(start, end);
|
|
19938
|
+
const label = selected || "text";
|
|
19939
|
+
const snippet = `[${label}](url)`;
|
|
19940
|
+
const next = value.slice(0, start) + snippet + value.slice(end);
|
|
19941
|
+
const urlStart = start + label.length + 3;
|
|
19942
|
+
return { value: next, selectionStart: urlStart, selectionEnd: urlStart + 3 };
|
|
19943
|
+
}
|
|
19944
|
+
__name(insertLink, "insertLink");
|
|
19945
|
+
var TOOLBAR = [
|
|
19946
|
+
{
|
|
19947
|
+
label: "Heading",
|
|
19948
|
+
icon: lucideReact.Heading,
|
|
19949
|
+
action: /* @__PURE__ */ __name((v, s, e) => toggleLinePrefix(v, s, e, "### "), "action")
|
|
19950
|
+
},
|
|
19951
|
+
{
|
|
19952
|
+
label: "Bold",
|
|
19953
|
+
icon: lucideReact.Bold,
|
|
19954
|
+
action: /* @__PURE__ */ __name((v, s, e) => toggleWrap(v, s, e, "**"), "action"),
|
|
19955
|
+
shortcutKey: "b"
|
|
19956
|
+
},
|
|
19957
|
+
{
|
|
19958
|
+
label: "Italic",
|
|
19959
|
+
icon: lucideReact.Italic,
|
|
19960
|
+
action: /* @__PURE__ */ __name((v, s, e) => toggleWrap(v, s, e, "_"), "action"),
|
|
19961
|
+
shortcutKey: "i"
|
|
19962
|
+
},
|
|
19963
|
+
{
|
|
19964
|
+
label: "Strikethrough",
|
|
19965
|
+
icon: lucideReact.Strikethrough,
|
|
19966
|
+
action: /* @__PURE__ */ __name((v, s, e) => toggleWrap(v, s, e, "~~"), "action")
|
|
19967
|
+
},
|
|
19968
|
+
{
|
|
19969
|
+
label: "Quote",
|
|
19970
|
+
icon: lucideReact.Quote,
|
|
19971
|
+
action: /* @__PURE__ */ __name((v, s, e) => toggleLinePrefix(v, s, e, "> "), "action")
|
|
19972
|
+
},
|
|
19973
|
+
{
|
|
19974
|
+
label: "Ordered list",
|
|
19975
|
+
icon: lucideReact.ListOrdered,
|
|
19976
|
+
action: /* @__PURE__ */ __name((v, s, e) => toggleListPrefix(v, s, e, (i) => `${i + 1}. `), "action")
|
|
19977
|
+
},
|
|
19978
|
+
{
|
|
19979
|
+
label: "Checklist",
|
|
19980
|
+
icon: lucideReact.ClipboardList,
|
|
19981
|
+
action: /* @__PURE__ */ __name((v, s, e) => toggleListPrefix(v, s, e, () => "- [ ] "), "action")
|
|
19982
|
+
},
|
|
19983
|
+
{ label: "Code", icon: lucideReact.Code, action: toggleCode },
|
|
19984
|
+
{ label: "Link", icon: lucideReact.Link, action: insertLink, shortcutKey: "k" }
|
|
19985
|
+
];
|
|
19986
|
+
var SHORTCUT_MAP = new Map(
|
|
19987
|
+
TOOLBAR.filter((item) => item.shortcutKey).map((item) => [
|
|
19988
|
+
item.shortcutKey,
|
|
19989
|
+
item
|
|
19990
|
+
])
|
|
19991
|
+
);
|
|
19992
|
+
var isMac = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform);
|
|
19993
|
+
var modLabel = isMac ? "\u2318" : "Ctrl";
|
|
19994
|
+
function shortcutHint(item) {
|
|
19995
|
+
if (!item.shortcutKey) return item.label;
|
|
19996
|
+
return `${item.label} (${modLabel}+${item.shortcutKey.toUpperCase()})`;
|
|
19997
|
+
}
|
|
19998
|
+
__name(shortcutHint, "shortcutHint");
|
|
19999
|
+
var MarkdownEditor = kreativCore.createComponent({
|
|
20000
|
+
displayName: "MarkdownEditor",
|
|
20001
|
+
__kui: {
|
|
20002
|
+
role: "formControl",
|
|
20003
|
+
formControl: "single",
|
|
20004
|
+
supports: { disabled: true, invalid: true, required: true },
|
|
20005
|
+
skeleton: "input-shaped",
|
|
20006
|
+
video: {
|
|
20007
|
+
id: "markdown-editor",
|
|
20008
|
+
safe: true,
|
|
20009
|
+
acceptsChildren: false,
|
|
20010
|
+
interactionStates: ["focus"],
|
|
20011
|
+
controlled: ["value", "disabled"],
|
|
20012
|
+
motionGated: true
|
|
20013
|
+
}
|
|
20014
|
+
},
|
|
20015
|
+
render: /* @__PURE__ */ __name(({
|
|
20016
|
+
renderMarkdown,
|
|
20017
|
+
tab: tabProp,
|
|
20018
|
+
defaultTab = "write",
|
|
20019
|
+
onTabChange,
|
|
20020
|
+
hint = "Markdown is supported",
|
|
20021
|
+
value: valueProp,
|
|
20022
|
+
defaultValue,
|
|
20023
|
+
onValueChange,
|
|
20024
|
+
className,
|
|
20025
|
+
fullWidth,
|
|
20026
|
+
variant = "outline",
|
|
20027
|
+
success: success2,
|
|
20028
|
+
error: error51,
|
|
20029
|
+
warning,
|
|
20030
|
+
disabled,
|
|
20031
|
+
maxLength,
|
|
20032
|
+
...textareaProps
|
|
20033
|
+
}, ref) => {
|
|
20034
|
+
const baseId = React2.useId();
|
|
20035
|
+
const textareaRef = React2.useRef(null);
|
|
20036
|
+
const { theme } = kreativCore.useTheme();
|
|
20037
|
+
const field = useOptionalFormField();
|
|
20038
|
+
const motionGated = kreativCore.isMotionGated(textareaProps);
|
|
20039
|
+
const isDisabled = disabled || Boolean(field?.disabled);
|
|
20040
|
+
const [uncontrolledTab, setUncontrolledTab] = React2.useState(
|
|
20041
|
+
defaultTab
|
|
20042
|
+
);
|
|
20043
|
+
const tab = tabProp ?? uncontrolledTab;
|
|
20044
|
+
const footerMessage = hint;
|
|
20045
|
+
const [draft, setDraft] = React2.useState(() => valueProp ?? defaultValue ?? "");
|
|
20046
|
+
const value = valueProp ?? draft;
|
|
20047
|
+
const maxLengthReached = typeof maxLength === "number" && value.length >= maxLength;
|
|
20048
|
+
const state = error51 || maxLengthReached ? "error" : success2 ? "success" : warning ? "warning" : field?.status ?? "none";
|
|
20049
|
+
const editorClasses = cn(
|
|
20050
|
+
resolveRecipe(theme.recipes.MarkdownEditor, {
|
|
20051
|
+
variant,
|
|
20052
|
+
state,
|
|
20053
|
+
fullWidth,
|
|
20054
|
+
disabled: isDisabled
|
|
20055
|
+
}),
|
|
20056
|
+
className
|
|
20057
|
+
);
|
|
20058
|
+
function setTab(next) {
|
|
20059
|
+
if (tabProp === void 0) setUncontrolledTab(next);
|
|
20060
|
+
onTabChange?.(next);
|
|
20061
|
+
}
|
|
20062
|
+
__name(setTab, "setTab");
|
|
20063
|
+
function commit(next) {
|
|
20064
|
+
setDraft(next);
|
|
20065
|
+
onValueChange?.(next);
|
|
20066
|
+
}
|
|
20067
|
+
__name(commit, "commit");
|
|
20068
|
+
function runAction(action) {
|
|
20069
|
+
if (isDisabled) return;
|
|
20070
|
+
const el = textareaRef.current;
|
|
20071
|
+
if (!el) return;
|
|
20072
|
+
const { selectionStart, selectionEnd } = el;
|
|
20073
|
+
const edit = action(
|
|
20074
|
+
value,
|
|
20075
|
+
selectionStart ?? value.length,
|
|
20076
|
+
selectionEnd ?? value.length
|
|
20077
|
+
);
|
|
20078
|
+
commit(edit.value);
|
|
20079
|
+
el.focus();
|
|
20080
|
+
const place = /* @__PURE__ */ __name(() => {
|
|
20081
|
+
el.setSelectionRange(edit.selectionStart, edit.selectionEnd);
|
|
20082
|
+
}, "place");
|
|
20083
|
+
if (motionGated) place();
|
|
20084
|
+
else requestAnimationFrame(place);
|
|
20085
|
+
}
|
|
20086
|
+
__name(runAction, "runAction");
|
|
20087
|
+
function handleToolbarKeyDown(event) {
|
|
20088
|
+
if (isDisabled) return;
|
|
20089
|
+
if (event.nativeEvent.isComposing) return;
|
|
20090
|
+
const mod = isMac ? event.metaKey : event.ctrlKey;
|
|
20091
|
+
if (!mod || event.altKey) return;
|
|
20092
|
+
const key = event.key.toLowerCase();
|
|
20093
|
+
const item = SHORTCUT_MAP.get(key);
|
|
20094
|
+
if (!item) return;
|
|
20095
|
+
event.preventDefault();
|
|
20096
|
+
runAction(item.action);
|
|
20097
|
+
}
|
|
20098
|
+
__name(handleToolbarKeyDown, "handleToolbarKeyDown");
|
|
20099
|
+
const writePanelId = `${baseId}-write-panel`;
|
|
20100
|
+
const previewPanelId = `${baseId}-preview-panel`;
|
|
20101
|
+
const renderedPreview = React2.useMemo(
|
|
20102
|
+
() => renderMarkdown ? renderMarkdown(value) : null,
|
|
20103
|
+
[renderMarkdown, value]
|
|
20104
|
+
);
|
|
20105
|
+
React2.useEffect(() => {
|
|
20106
|
+
if (isDev() && !renderMarkdown) {
|
|
20107
|
+
console.warn(
|
|
20108
|
+
"[kreativ-ui/MarkdownEditor]: no renderMarkdown prop was provided, so the Preview tab is showing plain text. Pass renderMarkdown={(value) => ReactNode}."
|
|
20109
|
+
);
|
|
20110
|
+
}
|
|
20111
|
+
}, [renderMarkdown]);
|
|
20112
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: editorClasses, children: [
|
|
20113
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
20114
|
+
"div",
|
|
20115
|
+
{
|
|
20116
|
+
role: "tablist",
|
|
20117
|
+
"aria-label": "Markdown editor mode",
|
|
20118
|
+
id: `${baseId}-tablist`,
|
|
20119
|
+
className: "flex items-center gap-4 border-b border-kui-border px-3",
|
|
20120
|
+
children: [
|
|
20121
|
+
["write", "preview"].map((t) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
20122
|
+
"button",
|
|
20123
|
+
{
|
|
20124
|
+
type: "button",
|
|
20125
|
+
role: "tab",
|
|
20126
|
+
id: `${baseId}-${t}-tab`,
|
|
20127
|
+
"aria-selected": tab === t,
|
|
20128
|
+
"aria-controls": t === "write" ? writePanelId : previewPanelId,
|
|
20129
|
+
onClick: () => setTab(t),
|
|
20130
|
+
disabled: isDisabled,
|
|
20131
|
+
className: cn(
|
|
20132
|
+
"border-b-2 py-2.5 text-sm capitalize",
|
|
20133
|
+
!motionGated && "transition-colors",
|
|
20134
|
+
"disabled:pointer-events-none disabled:cursor-not-allowed",
|
|
20135
|
+
tab === t ? "border-kui-brand text-kui-text" : "border-transparent text-kui-text-muted hover:text-kui-text"
|
|
20136
|
+
),
|
|
20137
|
+
children: t
|
|
20138
|
+
},
|
|
20139
|
+
t
|
|
20140
|
+
)),
|
|
20141
|
+
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(
|
|
20142
|
+
"button",
|
|
20143
|
+
{
|
|
20144
|
+
type: "button",
|
|
20145
|
+
"aria-label": shortcutHint(item),
|
|
20146
|
+
title: shortcutHint(item),
|
|
20147
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
20148
|
+
onClick: () => runAction(item.action),
|
|
20149
|
+
disabled: isDisabled,
|
|
20150
|
+
className: cn(
|
|
20151
|
+
"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",
|
|
20152
|
+
!motionGated && "transition-colors"
|
|
20153
|
+
),
|
|
20154
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(item.icon, { size: 15 })
|
|
20155
|
+
},
|
|
20156
|
+
item.label
|
|
20157
|
+
)) })
|
|
20158
|
+
]
|
|
20159
|
+
}
|
|
20160
|
+
),
|
|
20161
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
20162
|
+
"div",
|
|
20163
|
+
{
|
|
20164
|
+
id: writePanelId,
|
|
20165
|
+
role: "tabpanel",
|
|
20166
|
+
"aria-labelledby": `${baseId}-write-tab`,
|
|
20167
|
+
hidden: tab !== "write",
|
|
20168
|
+
onKeyDown: handleToolbarKeyDown,
|
|
20169
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
20170
|
+
TextareaCore,
|
|
20171
|
+
{
|
|
20172
|
+
ref: kreativCore.composeRefs(textareaRef, ref),
|
|
20173
|
+
value,
|
|
20174
|
+
onValueChange: commit,
|
|
20175
|
+
embedded: true,
|
|
20176
|
+
resize: "vertical",
|
|
20177
|
+
disabled: isDisabled,
|
|
20178
|
+
maxLength,
|
|
20179
|
+
...textareaProps
|
|
20180
|
+
}
|
|
20181
|
+
)
|
|
20182
|
+
}
|
|
20183
|
+
),
|
|
20184
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
20185
|
+
"div",
|
|
20186
|
+
{
|
|
20187
|
+
id: previewPanelId,
|
|
20188
|
+
role: "tabpanel",
|
|
20189
|
+
"aria-labelledby": `${baseId}-preview-tab`,
|
|
20190
|
+
hidden: tab !== "preview",
|
|
20191
|
+
className: "min-h-32 p-3 text-sm text-kui-text",
|
|
20192
|
+
children: renderMarkdown ? renderedPreview : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-kui-text-muted", children: "No renderMarkdown provided \u2014 showing raw text." })
|
|
20193
|
+
}
|
|
20194
|
+
),
|
|
20195
|
+
/* @__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 })
|
|
20196
|
+
] });
|
|
20197
|
+
}, "render")
|
|
20198
|
+
});
|
|
20199
|
+
var RadioGroupContext = React2.createContext(null);
|
|
20200
|
+
function useRadioGroupContext() {
|
|
20201
|
+
const ctx = React2.useContext(RadioGroupContext);
|
|
20202
|
+
if (!ctx) {
|
|
20203
|
+
throw new Error("<Radio /> must be rendered inside <RadioGroup>.");
|
|
20204
|
+
}
|
|
20205
|
+
return ctx;
|
|
20206
|
+
}
|
|
20207
|
+
__name(useRadioGroupContext, "useRadioGroupContext");
|
|
20208
|
+
function RadioGroup({
|
|
20209
|
+
value: valueProp,
|
|
20210
|
+
defaultValue,
|
|
20211
|
+
onValueChange,
|
|
20212
|
+
name: nameProp,
|
|
20213
|
+
disabled = false,
|
|
20214
|
+
required: required2 = false,
|
|
20215
|
+
orientation = "vertical",
|
|
20216
|
+
size = "md",
|
|
20217
|
+
error: error51,
|
|
20218
|
+
success: success2,
|
|
20219
|
+
className,
|
|
20220
|
+
children
|
|
20221
|
+
}) {
|
|
20222
|
+
const autoName = React2.useId();
|
|
20223
|
+
const name = nameProp ?? autoName;
|
|
20224
|
+
const field = useOptionalFormField();
|
|
20225
|
+
const [internalValue, setInternalValue] = React2.useState(defaultValue);
|
|
20226
|
+
const value = valueProp !== void 0 ? valueProp : internalValue;
|
|
20227
|
+
const handleValueChange = React2.useCallback(
|
|
20228
|
+
(next) => {
|
|
20229
|
+
if (valueProp === void 0) setInternalValue(next);
|
|
20230
|
+
onValueChange?.(next);
|
|
20231
|
+
},
|
|
20232
|
+
[valueProp, onValueChange]
|
|
20233
|
+
);
|
|
20234
|
+
const isInvalid = error51 ?? field?.invalid ?? false;
|
|
20235
|
+
const isSuccess = success2 ?? false;
|
|
20236
|
+
const state = isInvalid ? "error" : isSuccess ? "success" : "none";
|
|
20237
|
+
const groupRequired = required2 || !!field?.required;
|
|
20238
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
20239
|
+
RadioGroupContext.Provider,
|
|
20240
|
+
{
|
|
20241
|
+
value: {
|
|
20242
|
+
name,
|
|
20243
|
+
value,
|
|
20244
|
+
onValueChange: handleValueChange,
|
|
20245
|
+
disabled,
|
|
20246
|
+
size,
|
|
20247
|
+
state,
|
|
20248
|
+
groupRequired
|
|
20249
|
+
},
|
|
20250
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
20251
|
+
"div",
|
|
20252
|
+
{
|
|
20253
|
+
role: "radiogroup",
|
|
20254
|
+
"aria-labelledby": field?.hasExternalLabel ? `${field.id}-label` : void 0,
|
|
20255
|
+
"aria-describedby": field?.describedBy,
|
|
20256
|
+
"aria-required": groupRequired || void 0,
|
|
20257
|
+
"aria-invalid": isInvalid || void 0,
|
|
20258
|
+
className: cn(
|
|
20259
|
+
"flex gap-3",
|
|
20260
|
+
orientation === "horizontal" ? "flex-row flex-wrap" : "flex-col",
|
|
20261
|
+
className
|
|
20262
|
+
),
|
|
20263
|
+
children
|
|
20264
|
+
}
|
|
20265
|
+
)
|
|
20266
|
+
}
|
|
20267
|
+
);
|
|
20164
20268
|
}
|
|
20165
20269
|
__name(RadioGroup, "RadioGroup");
|
|
20166
20270
|
var radioBubbleVariants = classVarianceAuthority.cva(
|
|
@@ -21099,6 +21203,10 @@ MultiSelect.Content = MultiSelectContent;
|
|
|
21099
21203
|
MultiSelect.Item = MultiSelectItem;
|
|
21100
21204
|
|
|
21101
21205
|
// src/utils/responsive.ts
|
|
21206
|
+
function isResponsiveValue(value) {
|
|
21207
|
+
return typeof value === "object" && value !== null;
|
|
21208
|
+
}
|
|
21209
|
+
__name(isResponsiveValue, "isResponsiveValue");
|
|
21102
21210
|
function resolveResponsiveValue(value) {
|
|
21103
21211
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
21104
21212
|
return {
|
|
@@ -21148,108 +21256,1312 @@ var Container = React2.forwardRef(
|
|
|
21148
21256
|
{
|
|
21149
21257
|
ref,
|
|
21150
21258
|
"data-kui-responsive": attribute,
|
|
21151
|
-
className: cn(recipeClassName, centered && "mx-auto", className),
|
|
21152
|
-
style,
|
|
21259
|
+
className: cn(recipeClassName, centered && "mx-auto", className),
|
|
21260
|
+
style,
|
|
21261
|
+
...rest,
|
|
21262
|
+
children
|
|
21263
|
+
}
|
|
21264
|
+
)
|
|
21265
|
+
] });
|
|
21266
|
+
}
|
|
21267
|
+
);
|
|
21268
|
+
Container.displayName = "Container";
|
|
21269
|
+
var Flex = kreativCore.createComponent({
|
|
21270
|
+
displayName: "Flex",
|
|
21271
|
+
__kui: {
|
|
21272
|
+
role: "layout",
|
|
21273
|
+
skeleton: "preserve",
|
|
21274
|
+
video: {
|
|
21275
|
+
id: "flex",
|
|
21276
|
+
safe: true,
|
|
21277
|
+
acceptsChildren: true,
|
|
21278
|
+
interactionStates: []
|
|
21279
|
+
}
|
|
21280
|
+
},
|
|
21281
|
+
render: /* @__PURE__ */ __name(({
|
|
21282
|
+
inline = false,
|
|
21283
|
+
direction = "row",
|
|
21284
|
+
wrap = "nowrap",
|
|
21285
|
+
align,
|
|
21286
|
+
justify,
|
|
21287
|
+
gap,
|
|
21288
|
+
gapX,
|
|
21289
|
+
gapY,
|
|
21290
|
+
grow,
|
|
21291
|
+
shrink,
|
|
21292
|
+
basis,
|
|
21293
|
+
fullWidth,
|
|
21294
|
+
fullHeight,
|
|
21295
|
+
as: Tag = "div",
|
|
21296
|
+
className,
|
|
21297
|
+
style,
|
|
21298
|
+
unstyled,
|
|
21299
|
+
children,
|
|
21300
|
+
...rest
|
|
21301
|
+
}, ref) => {
|
|
21302
|
+
const { theme } = kreativCore.useTheme();
|
|
21303
|
+
const responsiveStyles = (0, hooks_exports.useMergedResponsiveStyles)([
|
|
21304
|
+
[direction, (v) => ({ flexDirection: v })],
|
|
21305
|
+
[wrap, (v) => ({ flexWrap: v })],
|
|
21306
|
+
[align, (v) => ({ alignItems: v })],
|
|
21307
|
+
[justify, (v) => ({ justifyContent: v })],
|
|
21308
|
+
[gap, (v) => ({ gap: resolveSpace(v) })],
|
|
21309
|
+
[gapX, (v) => ({ columnGap: resolveSpace(v) })],
|
|
21310
|
+
[gapY, (v) => ({ rowGap: resolveSpace(v) })],
|
|
21311
|
+
[grow, (v) => ({ flexGrow: v === true ? 1 : v === false ? 0 : v })],
|
|
21312
|
+
[shrink, (v) => ({ flexShrink: v === true ? 1 : v === false ? 0 : v })],
|
|
21313
|
+
[basis, (v) => ({ flexBasis: v })]
|
|
21314
|
+
]);
|
|
21315
|
+
const { attribute, style: responsiveCss } = (0, hooks_exports.useResponsiveStyles)(responsiveStyles);
|
|
21316
|
+
const recipeClasses = resolveRecipe(theme.recipes.Flex, {
|
|
21317
|
+
inline,
|
|
21318
|
+
fullWidth: Boolean(fullWidth),
|
|
21319
|
+
fullHeight: Boolean(fullHeight)
|
|
21320
|
+
});
|
|
21321
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
21322
|
+
/* @__PURE__ */ jsxRuntime.jsx(ResponsiveStyle, { css: responsiveCss }),
|
|
21323
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21324
|
+
Tag,
|
|
21325
|
+
{
|
|
21326
|
+
ref,
|
|
21327
|
+
"data-kui-responsive": attribute,
|
|
21328
|
+
className: cn(!unstyled && recipeClasses, className),
|
|
21329
|
+
style,
|
|
21330
|
+
...rest,
|
|
21331
|
+
children
|
|
21332
|
+
}
|
|
21333
|
+
)
|
|
21334
|
+
] });
|
|
21335
|
+
}, "render")
|
|
21336
|
+
});
|
|
21337
|
+
var Stack = React2.forwardRef(
|
|
21338
|
+
({ orientation = "vertical", divider, children, ...rest }, ref) => {
|
|
21339
|
+
const direction = orientation === "horizontal" ? "row" : "column";
|
|
21340
|
+
if (!divider) {
|
|
21341
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Flex, { ref, direction, ...rest, children });
|
|
21342
|
+
}
|
|
21343
|
+
const items = React2.Children.toArray(children).filter(React2.isValidElement);
|
|
21344
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Flex, { ref, direction, ...rest, children: items.map((child, index) => /* @__PURE__ */ jsxRuntime.jsxs(React2.Fragment, { children: [
|
|
21345
|
+
child,
|
|
21346
|
+
index < items.length - 1 && divider
|
|
21347
|
+
] }, child.key ?? index)) });
|
|
21348
|
+
}
|
|
21349
|
+
);
|
|
21350
|
+
Stack.displayName = "Stack";
|
|
21351
|
+
function spanValue(value) {
|
|
21352
|
+
return value === "full" ? "1 / -1" : `span ${value}`;
|
|
21353
|
+
}
|
|
21354
|
+
__name(spanValue, "spanValue");
|
|
21355
|
+
var GridItem = kreativCore.createComponent({
|
|
21356
|
+
displayName: "Grid.Item",
|
|
21357
|
+
__kui: {
|
|
21358
|
+
role: "layout",
|
|
21359
|
+
skeleton: "preserve",
|
|
21360
|
+
groupSlot: "Grid",
|
|
21361
|
+
video: {
|
|
21362
|
+
id: "grid-item",
|
|
21363
|
+
safe: true,
|
|
21364
|
+
acceptsChildren: true,
|
|
21365
|
+
interactionStates: []
|
|
21366
|
+
}
|
|
21367
|
+
},
|
|
21368
|
+
render: /* @__PURE__ */ __name(({
|
|
21369
|
+
span,
|
|
21370
|
+
rowSpan,
|
|
21371
|
+
as: Tag = "div",
|
|
21372
|
+
className,
|
|
21373
|
+
style,
|
|
21374
|
+
unstyled,
|
|
21375
|
+
children,
|
|
21376
|
+
...rest
|
|
21377
|
+
}, ref) => {
|
|
21378
|
+
const responsiveStyles = (0, hooks_exports.useMergedResponsiveStyles)([
|
|
21379
|
+
[span, (v) => ({ gridColumn: spanValue(v) })],
|
|
21380
|
+
[rowSpan, (v) => ({ gridRow: spanValue(v) })]
|
|
21381
|
+
]);
|
|
21382
|
+
const { attribute, style: responsiveCss } = (0, hooks_exports.useResponsiveStyles)(responsiveStyles);
|
|
21383
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
21384
|
+
/* @__PURE__ */ jsxRuntime.jsx(ResponsiveStyle, { css: responsiveCss }),
|
|
21385
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21386
|
+
Tag,
|
|
21387
|
+
{
|
|
21388
|
+
ref,
|
|
21389
|
+
"data-kui-responsive": attribute,
|
|
21390
|
+
className: cn(!unstyled && className),
|
|
21391
|
+
style,
|
|
21392
|
+
...rest,
|
|
21393
|
+
children
|
|
21394
|
+
}
|
|
21395
|
+
)
|
|
21396
|
+
] });
|
|
21397
|
+
}, "render")
|
|
21398
|
+
});
|
|
21399
|
+
var RAW_LENGTH2 = /px|rem|em|%|vw|vh|ch|var\(/i;
|
|
21400
|
+
function resolveTrackSize(value) {
|
|
21401
|
+
if (typeof value === "number") return `${value}px`;
|
|
21402
|
+
if (RAW_LENGTH2.test(value)) return value;
|
|
21403
|
+
return resolveSpace(value);
|
|
21404
|
+
}
|
|
21405
|
+
__name(resolveTrackSize, "resolveTrackSize");
|
|
21406
|
+
var GridRoot = kreativCore.createComponent({
|
|
21407
|
+
displayName: "Grid",
|
|
21408
|
+
__kui: {
|
|
21409
|
+
role: "layout",
|
|
21410
|
+
skeleton: "preserve",
|
|
21411
|
+
video: {
|
|
21412
|
+
id: "grid",
|
|
21413
|
+
safe: true,
|
|
21414
|
+
acceptsChildren: true,
|
|
21415
|
+
interactionStates: []
|
|
21416
|
+
}
|
|
21417
|
+
},
|
|
21418
|
+
render: /* @__PURE__ */ __name(({
|
|
21419
|
+
columns,
|
|
21420
|
+
minChildWidth,
|
|
21421
|
+
templateColumns,
|
|
21422
|
+
templateRows,
|
|
21423
|
+
templateAreas,
|
|
21424
|
+
autoFlow,
|
|
21425
|
+
gap,
|
|
21426
|
+
gapX,
|
|
21427
|
+
gapY,
|
|
21428
|
+
align,
|
|
21429
|
+
justifyItems,
|
|
21430
|
+
inline = false,
|
|
21431
|
+
as: Tag = "div",
|
|
21432
|
+
className,
|
|
21433
|
+
style,
|
|
21434
|
+
unstyled,
|
|
21435
|
+
children,
|
|
21436
|
+
...rest
|
|
21437
|
+
}, ref) => {
|
|
21438
|
+
const { theme } = kreativCore.useTheme();
|
|
21439
|
+
if (isDev() && [columns, minChildWidth, templateColumns].filter((v) => v != null).length > 1) {
|
|
21440
|
+
console.warn(
|
|
21441
|
+
"[kreativ-ui/Grid]: columns, minChildWidth, and templateColumns are mutually exclusive. templateColumns wins, then columns, then minChildWidth."
|
|
21442
|
+
);
|
|
21443
|
+
}
|
|
21444
|
+
const responsiveStyles = (0, hooks_exports.useMergedResponsiveStyles)([
|
|
21445
|
+
[
|
|
21446
|
+
columns,
|
|
21447
|
+
(v) => ({ gridTemplateColumns: `repeat(${v}, minmax(0, 1fr))` })
|
|
21448
|
+
],
|
|
21449
|
+
[
|
|
21450
|
+
minChildWidth,
|
|
21451
|
+
(v) => ({
|
|
21452
|
+
gridTemplateColumns: `repeat(auto-fit, minmax(${resolveTrackSize(v)}, 1fr))`
|
|
21453
|
+
})
|
|
21454
|
+
],
|
|
21455
|
+
[templateColumns, (v) => ({ gridTemplateColumns: v })],
|
|
21456
|
+
[templateRows, (v) => ({ gridTemplateRows: v })],
|
|
21457
|
+
[autoFlow, (v) => ({ gridAutoFlow: v })],
|
|
21458
|
+
[gap, (v) => ({ gap: resolveSpace(v) })],
|
|
21459
|
+
[gapX, (v) => ({ columnGap: resolveSpace(v) })],
|
|
21460
|
+
[gapY, (v) => ({ rowGap: resolveSpace(v) })],
|
|
21461
|
+
[align, (v) => ({ alignItems: v })],
|
|
21462
|
+
[justifyItems, (v) => ({ justifyItems: v })]
|
|
21463
|
+
]);
|
|
21464
|
+
const { attribute, style: responsiveCss } = (0, hooks_exports.useResponsiveStyles)(responsiveStyles);
|
|
21465
|
+
const recipeClasses = resolveRecipe(theme.recipes.Grid, { inline });
|
|
21466
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
21467
|
+
/* @__PURE__ */ jsxRuntime.jsx(ResponsiveStyle, { css: responsiveCss }),
|
|
21468
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21469
|
+
Tag,
|
|
21470
|
+
{
|
|
21471
|
+
ref,
|
|
21472
|
+
"data-kui-responsive": attribute,
|
|
21473
|
+
className: cn(!unstyled && recipeClasses, className),
|
|
21474
|
+
style: { ...style, gridTemplateAreas: templateAreas },
|
|
21153
21475
|
...rest,
|
|
21154
21476
|
children
|
|
21155
21477
|
}
|
|
21156
21478
|
)
|
|
21157
21479
|
] });
|
|
21480
|
+
}, "render")
|
|
21481
|
+
});
|
|
21482
|
+
var Grid = Object.assign(GridRoot, { Item: GridItem });
|
|
21483
|
+
function withAlpha(color, alpha) {
|
|
21484
|
+
return `color-mix(in srgb, ${color} ${Math.round(alpha * 100)}%, transparent)`;
|
|
21485
|
+
}
|
|
21486
|
+
__name(withAlpha, "withAlpha");
|
|
21487
|
+
function resolveOverlayBackground(color, opacity, gradient) {
|
|
21488
|
+
if (!color && opacity === void 0) return void 0;
|
|
21489
|
+
const resolvedColor = color ?? "currentColor";
|
|
21490
|
+
if (!gradient) {
|
|
21491
|
+
return resolvedColor;
|
|
21492
|
+
}
|
|
21493
|
+
const startOpacity = opacity ?? 1;
|
|
21494
|
+
const startColor = startOpacity === 1 ? resolvedColor : withAlpha(resolvedColor, startOpacity);
|
|
21495
|
+
if (typeof gradient === "object") {
|
|
21496
|
+
const position = gradient.position ?? "center";
|
|
21497
|
+
return `radial-gradient(circle at ${position}, ${startColor} 0%, transparent 100%)`;
|
|
21498
|
+
}
|
|
21499
|
+
const directionMap = {
|
|
21500
|
+
top: "to top",
|
|
21501
|
+
bottom: "to bottom",
|
|
21502
|
+
left: "to left",
|
|
21503
|
+
right: "to right"
|
|
21504
|
+
};
|
|
21505
|
+
return `linear-gradient(${directionMap[gradient]}, ${startColor} 0%, transparent 100%)`;
|
|
21506
|
+
}
|
|
21507
|
+
__name(resolveOverlayBackground, "resolveOverlayBackground");
|
|
21508
|
+
var CardOverlay = kreativCore.createComponent({
|
|
21509
|
+
__kui: {
|
|
21510
|
+
groupSlot: "Card"
|
|
21511
|
+
},
|
|
21512
|
+
displayName: "Card.Overlay",
|
|
21513
|
+
render: /* @__PURE__ */ __name(({ color, opacity, blur, gradient, className, style, children, ...props }, ref) => {
|
|
21514
|
+
const background = resolveOverlayBackground(color, opacity, gradient);
|
|
21515
|
+
const { theme } = kreativCore.useTheme();
|
|
21516
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21517
|
+
"div",
|
|
21518
|
+
{
|
|
21519
|
+
ref,
|
|
21520
|
+
className: cn(resolveRecipe(theme.recipes.CardOverlay), className),
|
|
21521
|
+
style: {
|
|
21522
|
+
...background !== void 0 ? gradient ? { backgroundImage: background } : { backgroundColor: background } : null,
|
|
21523
|
+
...!gradient && opacity !== void 0 ? { opacity } : null,
|
|
21524
|
+
...blur !== void 0 ? {
|
|
21525
|
+
backdropFilter: `blur(${typeof blur === "number" ? `${blur}px` : blur})`
|
|
21526
|
+
} : null,
|
|
21527
|
+
...style
|
|
21528
|
+
},
|
|
21529
|
+
...props,
|
|
21530
|
+
children
|
|
21531
|
+
}
|
|
21532
|
+
);
|
|
21533
|
+
}, "render")
|
|
21534
|
+
});
|
|
21535
|
+
var CardMedia = kreativCore.createComponent({
|
|
21536
|
+
__kui: {
|
|
21537
|
+
groupSlot: "Card"
|
|
21538
|
+
},
|
|
21539
|
+
displayName: "Card.Media",
|
|
21540
|
+
render: /* @__PURE__ */ __name(({
|
|
21541
|
+
src,
|
|
21542
|
+
alt,
|
|
21543
|
+
fit = "cover",
|
|
21544
|
+
blend = "normal",
|
|
21545
|
+
aspectRatio,
|
|
21546
|
+
className,
|
|
21547
|
+
style,
|
|
21548
|
+
children,
|
|
21549
|
+
...props
|
|
21550
|
+
}, ref) => {
|
|
21551
|
+
const { theme } = kreativCore.useTheme();
|
|
21552
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
21553
|
+
"div",
|
|
21554
|
+
{
|
|
21555
|
+
ref,
|
|
21556
|
+
className: cn(resolveRecipe(theme.recipes.CardMedia), className),
|
|
21557
|
+
style: {
|
|
21558
|
+
...aspectRatio !== void 0 ? { aspectRatio } : null,
|
|
21559
|
+
...style
|
|
21560
|
+
},
|
|
21561
|
+
...props,
|
|
21562
|
+
children: [
|
|
21563
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21564
|
+
"img",
|
|
21565
|
+
{
|
|
21566
|
+
src,
|
|
21567
|
+
alt,
|
|
21568
|
+
className: resolveRecipe(theme.recipes.CardMediaImage, { fit, blend })
|
|
21569
|
+
}
|
|
21570
|
+
),
|
|
21571
|
+
children
|
|
21572
|
+
]
|
|
21573
|
+
}
|
|
21574
|
+
);
|
|
21575
|
+
}, "render")
|
|
21576
|
+
});
|
|
21577
|
+
var CardRoot = kreativCore.createComponent({
|
|
21578
|
+
__kui: {
|
|
21579
|
+
role: "display",
|
|
21580
|
+
skeleton: "preserve"
|
|
21581
|
+
},
|
|
21582
|
+
displayName: "Card",
|
|
21583
|
+
render: /* @__PURE__ */ __name(({
|
|
21584
|
+
variant = "outline",
|
|
21585
|
+
size = "md",
|
|
21586
|
+
fullWidth = false,
|
|
21587
|
+
className,
|
|
21588
|
+
style,
|
|
21589
|
+
children,
|
|
21590
|
+
...props
|
|
21591
|
+
}, ref) => {
|
|
21592
|
+
kreativCore.useValidateChildren("Card", children);
|
|
21593
|
+
const { theme } = kreativCore.useTheme();
|
|
21594
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21595
|
+
"div",
|
|
21596
|
+
{
|
|
21597
|
+
ref,
|
|
21598
|
+
className: cn(
|
|
21599
|
+
resolveRecipe(theme.recipes.Card, { variant, size, fullWidth }),
|
|
21600
|
+
className
|
|
21601
|
+
),
|
|
21602
|
+
...props,
|
|
21603
|
+
children
|
|
21604
|
+
}
|
|
21605
|
+
);
|
|
21606
|
+
}, "render")
|
|
21607
|
+
});
|
|
21608
|
+
var CardHeader = kreativCore.createComponent({
|
|
21609
|
+
__kui: {
|
|
21610
|
+
groupSlot: "Card"
|
|
21611
|
+
},
|
|
21612
|
+
displayName: "Card.Header",
|
|
21613
|
+
render: /* @__PURE__ */ __name(({ className, children, noPadding = false, size = "md", ...props }, ref) => {
|
|
21614
|
+
const { theme } = kreativCore.useTheme();
|
|
21615
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21616
|
+
"div",
|
|
21617
|
+
{
|
|
21618
|
+
ref,
|
|
21619
|
+
className: cn(
|
|
21620
|
+
resolveRecipe(theme.recipes.CardHeader, { size, noPadding }),
|
|
21621
|
+
className
|
|
21622
|
+
),
|
|
21623
|
+
...props,
|
|
21624
|
+
children
|
|
21625
|
+
}
|
|
21626
|
+
);
|
|
21627
|
+
}, "render")
|
|
21628
|
+
});
|
|
21629
|
+
var CardBody = kreativCore.createComponent({
|
|
21630
|
+
__kui: {
|
|
21631
|
+
groupSlot: "Card"
|
|
21632
|
+
},
|
|
21633
|
+
displayName: "Card.Body",
|
|
21634
|
+
render: /* @__PURE__ */ __name(({ size = "md", noPadding = false, className, children, ...props }, ref) => {
|
|
21635
|
+
const { theme } = kreativCore.useTheme();
|
|
21636
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21637
|
+
"div",
|
|
21638
|
+
{
|
|
21639
|
+
ref,
|
|
21640
|
+
className: cn(
|
|
21641
|
+
resolveRecipe(theme.recipes.CardBody, { size, noPadding }),
|
|
21642
|
+
className
|
|
21643
|
+
),
|
|
21644
|
+
...props,
|
|
21645
|
+
children
|
|
21646
|
+
}
|
|
21647
|
+
);
|
|
21648
|
+
}, "render")
|
|
21649
|
+
});
|
|
21650
|
+
var CardFooter = kreativCore.createComponent({
|
|
21651
|
+
__kui: {
|
|
21652
|
+
groupSlot: "Card"
|
|
21653
|
+
},
|
|
21654
|
+
displayName: "Card.Footer",
|
|
21655
|
+
render: /* @__PURE__ */ __name(({ size = "md", noPadding = false, className, children, ...props }, ref) => {
|
|
21656
|
+
const { theme } = kreativCore.useTheme();
|
|
21657
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21658
|
+
"div",
|
|
21659
|
+
{
|
|
21660
|
+
ref,
|
|
21661
|
+
className: cn(
|
|
21662
|
+
resolveRecipe(theme.recipes.CardFooter, { size, noPadding }),
|
|
21663
|
+
className
|
|
21664
|
+
),
|
|
21665
|
+
...props,
|
|
21666
|
+
children
|
|
21667
|
+
}
|
|
21668
|
+
);
|
|
21669
|
+
}, "render")
|
|
21670
|
+
});
|
|
21671
|
+
var Card = Object.assign(CardRoot, {
|
|
21672
|
+
Header: CardHeader,
|
|
21673
|
+
Body: CardBody,
|
|
21674
|
+
Footer: CardFooter,
|
|
21675
|
+
Media: CardMedia,
|
|
21676
|
+
Overlay: CardOverlay
|
|
21677
|
+
});
|
|
21678
|
+
var initialState = {
|
|
21679
|
+
hasVerticalOverflow: false,
|
|
21680
|
+
hasHorizontalOverflow: false,
|
|
21681
|
+
atTop: true,
|
|
21682
|
+
atBottom: false,
|
|
21683
|
+
atLeft: true,
|
|
21684
|
+
atRight: false
|
|
21685
|
+
};
|
|
21686
|
+
function statesEqual(a, b) {
|
|
21687
|
+
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;
|
|
21688
|
+
}
|
|
21689
|
+
__name(statesEqual, "statesEqual");
|
|
21690
|
+
function useScrollPosition({ direction, threshold, onScrollEnd, onMeasure }) {
|
|
21691
|
+
const elRef = React2.useRef(null);
|
|
21692
|
+
const [state, setState] = React2.useState(initialState);
|
|
21693
|
+
const stateRef = React2.useRef(state);
|
|
21694
|
+
const onMeasureRef = React2.useRef(onMeasure);
|
|
21695
|
+
onMeasureRef.current = onMeasure;
|
|
21696
|
+
const inZone = React2.useRef({
|
|
21697
|
+
top: false,
|
|
21698
|
+
bottom: false,
|
|
21699
|
+
left: false,
|
|
21700
|
+
right: false
|
|
21701
|
+
});
|
|
21702
|
+
const fireIfEntering = React2.useCallback(
|
|
21703
|
+
(edge, isAtEdge) => {
|
|
21704
|
+
if (isAtEdge && !inZone.current[edge]) {
|
|
21705
|
+
inZone.current[edge] = true;
|
|
21706
|
+
onScrollEnd?.(edge);
|
|
21707
|
+
} else if (!isAtEdge && inZone.current[edge]) {
|
|
21708
|
+
inZone.current[edge] = false;
|
|
21709
|
+
}
|
|
21710
|
+
},
|
|
21711
|
+
[onScrollEnd]
|
|
21712
|
+
);
|
|
21713
|
+
const measure = React2.useCallback(() => {
|
|
21714
|
+
const el = elRef.current;
|
|
21715
|
+
if (!el) return;
|
|
21716
|
+
const hasVerticalOverflow = el.scrollHeight > el.clientHeight;
|
|
21717
|
+
const hasHorizontalOverflow = el.scrollWidth > el.clientWidth;
|
|
21718
|
+
const wantsVertical = direction === "vertical" || direction === "both";
|
|
21719
|
+
const wantsHorizontal = direction === "horizontal" || direction === "both";
|
|
21720
|
+
let atTop = true, atBottom = false, atLeft = true, atRight = false;
|
|
21721
|
+
if (wantsVertical && hasVerticalOverflow) {
|
|
21722
|
+
const distTop = el.scrollTop;
|
|
21723
|
+
const distBottom = el.scrollHeight - el.clientHeight - el.scrollTop;
|
|
21724
|
+
atTop = distTop <= threshold;
|
|
21725
|
+
atBottom = distBottom <= threshold;
|
|
21726
|
+
fireIfEntering("top", atTop);
|
|
21727
|
+
fireIfEntering("bottom", atBottom);
|
|
21728
|
+
}
|
|
21729
|
+
if (wantsHorizontal && hasHorizontalOverflow) {
|
|
21730
|
+
const distLeft = el.scrollLeft;
|
|
21731
|
+
const distRight = el.scrollWidth - el.clientWidth - el.scrollLeft;
|
|
21732
|
+
atLeft = distLeft <= threshold;
|
|
21733
|
+
atRight = distRight <= threshold;
|
|
21734
|
+
fireIfEntering("left", atLeft);
|
|
21735
|
+
fireIfEntering("right", atRight);
|
|
21736
|
+
}
|
|
21737
|
+
const next = {
|
|
21738
|
+
hasVerticalOverflow,
|
|
21739
|
+
hasHorizontalOverflow,
|
|
21740
|
+
atTop: wantsVertical ? atTop : true,
|
|
21741
|
+
atBottom: wantsVertical ? atBottom : false,
|
|
21742
|
+
atLeft: wantsHorizontal ? atLeft : true,
|
|
21743
|
+
atRight: wantsHorizontal ? atRight : false
|
|
21744
|
+
};
|
|
21745
|
+
if (!statesEqual(stateRef.current, next)) {
|
|
21746
|
+
stateRef.current = next;
|
|
21747
|
+
setState(next);
|
|
21748
|
+
}
|
|
21749
|
+
onMeasureRef.current?.();
|
|
21750
|
+
}, [direction, threshold, fireIfEntering]);
|
|
21751
|
+
const handleScroll = React2.useCallback(() => measure(), [measure]);
|
|
21752
|
+
React2.useEffect(() => {
|
|
21753
|
+
const el = elRef.current;
|
|
21754
|
+
if (!el) return;
|
|
21755
|
+
measure();
|
|
21756
|
+
const resizeObserver = new ResizeObserver(() => measure());
|
|
21757
|
+
resizeObserver.observe(el);
|
|
21758
|
+
const mutationObserver = new MutationObserver(() => measure());
|
|
21759
|
+
mutationObserver.observe(el, { childList: true, subtree: true, characterData: true });
|
|
21760
|
+
return () => {
|
|
21761
|
+
resizeObserver.disconnect();
|
|
21762
|
+
mutationObserver.disconnect();
|
|
21763
|
+
};
|
|
21764
|
+
}, [measure]);
|
|
21765
|
+
return { elRef, state, handleScroll, measure };
|
|
21766
|
+
}
|
|
21767
|
+
__name(useScrollPosition, "useScrollPosition");
|
|
21768
|
+
var THRESHOLD = 5;
|
|
21769
|
+
var IGNORE = "input, textarea, select, [contenteditable=''], [contenteditable='true'], [data-no-drag]";
|
|
21770
|
+
function useDragScroll(elRef, { enabled, direction, onRelease }) {
|
|
21771
|
+
const releaseRef = React2.useRef(onRelease);
|
|
21772
|
+
releaseRef.current = onRelease;
|
|
21773
|
+
React2.useEffect(() => {
|
|
21774
|
+
const el = elRef.current;
|
|
21775
|
+
if (!el || !enabled) return;
|
|
21776
|
+
const allowX = direction !== "vertical";
|
|
21777
|
+
const allowY = direction !== "horizontal";
|
|
21778
|
+
let pointerId = null;
|
|
21779
|
+
let startX = 0, startY = 0, startLeft = 0, startTop = 0;
|
|
21780
|
+
let dragging = false;
|
|
21781
|
+
let suppressClick = false;
|
|
21782
|
+
const onDown = /* @__PURE__ */ __name((e) => {
|
|
21783
|
+
if (e.pointerType === "touch" || e.button !== 0) return;
|
|
21784
|
+
if (e.target.closest(IGNORE)) return;
|
|
21785
|
+
pointerId = e.pointerId;
|
|
21786
|
+
startX = e.clientX;
|
|
21787
|
+
startY = e.clientY;
|
|
21788
|
+
startLeft = el.scrollLeft;
|
|
21789
|
+
startTop = el.scrollTop;
|
|
21790
|
+
dragging = false;
|
|
21791
|
+
}, "onDown");
|
|
21792
|
+
const onMove = /* @__PURE__ */ __name((e) => {
|
|
21793
|
+
if (e.pointerId !== pointerId) return;
|
|
21794
|
+
const dx = e.clientX - startX;
|
|
21795
|
+
const dy = e.clientY - startY;
|
|
21796
|
+
if (!dragging) {
|
|
21797
|
+
if (Math.hypot(dx, dy) < THRESHOLD) return;
|
|
21798
|
+
dragging = true;
|
|
21799
|
+
try {
|
|
21800
|
+
el.setPointerCapture(e.pointerId);
|
|
21801
|
+
} catch {
|
|
21802
|
+
}
|
|
21803
|
+
el.setAttribute("data-dragging", "");
|
|
21804
|
+
window.getSelection()?.removeAllRanges();
|
|
21805
|
+
}
|
|
21806
|
+
if (allowX) el.scrollLeft = startLeft - dx;
|
|
21807
|
+
if (allowY) el.scrollTop = startTop - dy;
|
|
21808
|
+
}, "onMove");
|
|
21809
|
+
const onEnd = /* @__PURE__ */ __name((e) => {
|
|
21810
|
+
if (e.pointerId !== pointerId) return;
|
|
21811
|
+
pointerId = null;
|
|
21812
|
+
if (!dragging) return;
|
|
21813
|
+
dragging = false;
|
|
21814
|
+
suppressClick = true;
|
|
21815
|
+
setTimeout(() => {
|
|
21816
|
+
suppressClick = false;
|
|
21817
|
+
}, 0);
|
|
21818
|
+
el.removeAttribute("data-dragging");
|
|
21819
|
+
releaseRef.current?.(el);
|
|
21820
|
+
}, "onEnd");
|
|
21821
|
+
const onClickCapture = /* @__PURE__ */ __name((e) => {
|
|
21822
|
+
if (!suppressClick) return;
|
|
21823
|
+
e.preventDefault();
|
|
21824
|
+
e.stopPropagation();
|
|
21825
|
+
}, "onClickCapture");
|
|
21826
|
+
const onDragStart = /* @__PURE__ */ __name((e) => {
|
|
21827
|
+
if (!e.target.closest?.('[draggable="true"]')) e.preventDefault();
|
|
21828
|
+
}, "onDragStart");
|
|
21829
|
+
el.addEventListener("pointerdown", onDown);
|
|
21830
|
+
el.addEventListener("pointermove", onMove);
|
|
21831
|
+
el.addEventListener("pointerup", onEnd);
|
|
21832
|
+
el.addEventListener("pointercancel", onEnd);
|
|
21833
|
+
el.addEventListener("click", onClickCapture, true);
|
|
21834
|
+
el.addEventListener("dragstart", onDragStart);
|
|
21835
|
+
return () => {
|
|
21836
|
+
el.removeEventListener("pointerdown", onDown);
|
|
21837
|
+
el.removeEventListener("pointermove", onMove);
|
|
21838
|
+
el.removeEventListener("pointerup", onEnd);
|
|
21839
|
+
el.removeEventListener("pointercancel", onEnd);
|
|
21840
|
+
el.removeEventListener("click", onClickCapture, true);
|
|
21841
|
+
el.removeEventListener("dragstart", onDragStart);
|
|
21842
|
+
el.removeAttribute("data-dragging");
|
|
21843
|
+
};
|
|
21844
|
+
}, [elRef, enabled, direction]);
|
|
21845
|
+
}
|
|
21846
|
+
__name(useDragScroll, "useDragScroll");
|
|
21847
|
+
|
|
21848
|
+
// src/components/layout/ScrollArea/scrollProgress.ts
|
|
21849
|
+
var clamp01 = /* @__PURE__ */ __name((n) => Math.min(1, Math.max(0, n)), "clamp01");
|
|
21850
|
+
function containerProgress(el) {
|
|
21851
|
+
const maxY = el.scrollHeight - el.clientHeight;
|
|
21852
|
+
const maxX = el.scrollWidth - el.clientWidth;
|
|
21853
|
+
return {
|
|
21854
|
+
x: maxX > 0 ? clamp01(el.scrollLeft / maxX) : 0,
|
|
21855
|
+
y: maxY > 0 ? clamp01(el.scrollTop / maxY) : 0
|
|
21856
|
+
};
|
|
21857
|
+
}
|
|
21858
|
+
__name(containerProgress, "containerProgress");
|
|
21859
|
+
function sceneProgress(scene, container, axis, range) {
|
|
21860
|
+
const c = container.getBoundingClientRect();
|
|
21861
|
+
const s = scene.getBoundingClientRect();
|
|
21862
|
+
const vertical = axis === "y";
|
|
21863
|
+
const view = vertical ? container.clientHeight : container.clientWidth;
|
|
21864
|
+
const size = vertical ? s.height : s.width;
|
|
21865
|
+
const offset = vertical ? s.top - c.top - container.clientTop : s.left - c.left - container.clientLeft;
|
|
21866
|
+
if (range === "through") {
|
|
21867
|
+
const total = view + size;
|
|
21868
|
+
return total > 0 ? clamp01((view - offset) / total) : 0;
|
|
21869
|
+
}
|
|
21870
|
+
const travel = size - view;
|
|
21871
|
+
return travel > 0 ? clamp01(-offset / travel) : 0;
|
|
21872
|
+
}
|
|
21873
|
+
__name(sceneProgress, "sceneProgress");
|
|
21874
|
+
function createStore(initial, equals = Object.is) {
|
|
21875
|
+
let value = initial;
|
|
21876
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
21877
|
+
return {
|
|
21878
|
+
get: /* @__PURE__ */ __name(() => value, "get"),
|
|
21879
|
+
set(next) {
|
|
21880
|
+
if (equals(value, next)) return false;
|
|
21881
|
+
value = next;
|
|
21882
|
+
listeners.forEach((l) => l(next));
|
|
21883
|
+
return true;
|
|
21884
|
+
},
|
|
21885
|
+
subscribe(fn) {
|
|
21886
|
+
listeners.add(fn);
|
|
21887
|
+
return () => {
|
|
21888
|
+
listeners.delete(fn);
|
|
21889
|
+
};
|
|
21890
|
+
},
|
|
21891
|
+
get size() {
|
|
21892
|
+
return listeners.size;
|
|
21893
|
+
}
|
|
21894
|
+
};
|
|
21895
|
+
}
|
|
21896
|
+
__name(createStore, "createStore");
|
|
21897
|
+
|
|
21898
|
+
// src/components/layout/ScrollArea/ScrollEngine.ts
|
|
21899
|
+
var EPS = 1;
|
|
21900
|
+
var round = /* @__PURE__ */ __name((n) => Math.round(n * 1e4) / 1e4, "round");
|
|
21901
|
+
var progressEqual = /* @__PURE__ */ __name((a, b) => a.x === b.x && a.y === b.y, "progressEqual");
|
|
21902
|
+
var STICKY_EDGES = ["top", "bottom", "left", "right"];
|
|
21903
|
+
var _StickyHandle = class _StickyHandle {
|
|
21904
|
+
constructor() {
|
|
21905
|
+
__publicField(this, "el", null);
|
|
21906
|
+
__publicField(this, "edges", []);
|
|
21907
|
+
__publicField(this, "offsets", {});
|
|
21908
|
+
__publicField(this, "stuck", "");
|
|
21909
|
+
__publicField(this, "dirty", true);
|
|
21910
|
+
__publicField(this, "onStuckChange");
|
|
21911
|
+
}
|
|
21912
|
+
resolve() {
|
|
21913
|
+
if (!this.el) return;
|
|
21914
|
+
const cs = getComputedStyle(this.el);
|
|
21915
|
+
this.offsets = {};
|
|
21916
|
+
for (const edge of this.edges) {
|
|
21917
|
+
const px = parseFloat(cs[edge]);
|
|
21918
|
+
if (!Number.isNaN(px)) this.offsets[edge] = px;
|
|
21919
|
+
}
|
|
21920
|
+
this.dirty = false;
|
|
21921
|
+
}
|
|
21922
|
+
};
|
|
21923
|
+
__name(_StickyHandle, "StickyHandle");
|
|
21924
|
+
var StickyHandle = _StickyHandle;
|
|
21925
|
+
var _SceneHandle = class _SceneHandle {
|
|
21926
|
+
constructor(engine) {
|
|
21927
|
+
__publicField(this, "engine", engine);
|
|
21928
|
+
__publicField(this, "el", null);
|
|
21929
|
+
__publicField(this, "axis", "y");
|
|
21930
|
+
__publicField(this, "range", "through");
|
|
21931
|
+
__publicField(this, "store", createStore(0));
|
|
21932
|
+
__publicField(this, "get", /* @__PURE__ */ __name(() => {
|
|
21933
|
+
const container = this.engine.el;
|
|
21934
|
+
return this.el && container ? round(sceneProgress(this.el, container, this.axis, this.range)) : 0;
|
|
21935
|
+
}, "get"));
|
|
21936
|
+
__publicField(this, "subscribe", /* @__PURE__ */ __name((fn) => {
|
|
21937
|
+
const off = this.store.subscribe(fn);
|
|
21938
|
+
this.engine.schedule();
|
|
21939
|
+
return off;
|
|
21940
|
+
}, "subscribe"));
|
|
21941
|
+
}
|
|
21942
|
+
};
|
|
21943
|
+
__name(_SceneHandle, "SceneHandle");
|
|
21944
|
+
var SceneHandle = _SceneHandle;
|
|
21945
|
+
var _ScrollEngine = class _ScrollEngine {
|
|
21946
|
+
constructor() {
|
|
21947
|
+
__publicField(this, "el", null);
|
|
21948
|
+
__publicField(this, "trackVars", false);
|
|
21949
|
+
__publicField(this, "varsDirty", false);
|
|
21950
|
+
__publicField(this, "offsetsDirty", false);
|
|
21951
|
+
__publicField(this, "frame", 0);
|
|
21952
|
+
__publicField(this, "resizeObserver", null);
|
|
21953
|
+
__publicField(this, "scenes", /* @__PURE__ */ new Set());
|
|
21954
|
+
__publicField(this, "stickies", /* @__PURE__ */ new Set());
|
|
21955
|
+
__publicField(this, "viewport", { w: -1, h: -1 });
|
|
21956
|
+
__publicField(this, "containerStore", createStore(
|
|
21957
|
+
{ x: 0, y: 0 },
|
|
21958
|
+
progressEqual
|
|
21959
|
+
));
|
|
21960
|
+
__publicField(this, "progress", {
|
|
21961
|
+
get: /* @__PURE__ */ __name(() => this.el ? containerProgress(this.el) : { x: 0, y: 0 }, "get"),
|
|
21962
|
+
subscribe: /* @__PURE__ */ __name((fn) => {
|
|
21963
|
+
const off = this.containerStore.subscribe(fn);
|
|
21964
|
+
this.schedule();
|
|
21965
|
+
return off;
|
|
21966
|
+
}, "subscribe")
|
|
21967
|
+
});
|
|
21968
|
+
__publicField(this, "schedule", /* @__PURE__ */ __name(() => {
|
|
21969
|
+
if (this.frame || !this.el || !this.isActive()) return;
|
|
21970
|
+
this.frame = requestAnimationFrame(this.flush);
|
|
21971
|
+
}, "schedule"));
|
|
21972
|
+
__publicField(this, "flush", /* @__PURE__ */ __name(() => {
|
|
21973
|
+
this.frame = 0;
|
|
21974
|
+
const el = this.el;
|
|
21975
|
+
if (!el) return;
|
|
21976
|
+
const c = containerProgress(el);
|
|
21977
|
+
const rounded = { x: round(c.x), y: round(c.y) };
|
|
21978
|
+
const sceneValues = [];
|
|
21979
|
+
this.scenes.forEach((s) => {
|
|
21980
|
+
if (s.el)
|
|
21981
|
+
sceneValues.push([s, round(sceneProgress(s.el, el, s.axis, s.range))]);
|
|
21982
|
+
});
|
|
21983
|
+
const stickyStates = [];
|
|
21984
|
+
if (this.stickies.size > 0) {
|
|
21985
|
+
const cr = el.getBoundingClientRect();
|
|
21986
|
+
const portTop = cr.top + el.clientTop;
|
|
21987
|
+
const portLeft = cr.left + el.clientLeft;
|
|
21988
|
+
const portBottom = portTop + el.clientHeight;
|
|
21989
|
+
const portRight = portLeft + el.clientWidth;
|
|
21990
|
+
const maxY = el.scrollHeight - el.clientHeight;
|
|
21991
|
+
const maxX = el.scrollWidth - el.clientWidth;
|
|
21992
|
+
this.stickies.forEach((s) => {
|
|
21993
|
+
if (!s.el) return;
|
|
21994
|
+
if (s.dirty || this.offsetsDirty) s.resolve();
|
|
21995
|
+
const r = s.el.getBoundingClientRect();
|
|
21996
|
+
const o = s.offsets;
|
|
21997
|
+
const hit = [];
|
|
21998
|
+
if (o.top !== void 0 && Math.abs(r.top - (portTop + o.top)) <= EPS && el.scrollTop > EPS)
|
|
21999
|
+
hit.push("top");
|
|
22000
|
+
if (o.bottom !== void 0 && Math.abs(r.bottom - (portBottom - o.bottom)) <= EPS && el.scrollTop < maxY - EPS)
|
|
22001
|
+
hit.push("bottom");
|
|
22002
|
+
if (o.left !== void 0 && Math.abs(r.left - (portLeft + o.left)) <= EPS && el.scrollLeft > EPS)
|
|
22003
|
+
hit.push("left");
|
|
22004
|
+
if (o.right !== void 0 && Math.abs(r.right - (portRight - o.right)) <= EPS && el.scrollLeft < maxX - EPS)
|
|
22005
|
+
hit.push("right");
|
|
22006
|
+
stickyStates.push([s, hit.join(" ")]);
|
|
22007
|
+
});
|
|
22008
|
+
}
|
|
22009
|
+
this.offsetsDirty = false;
|
|
22010
|
+
const changed = this.containerStore.set(rounded);
|
|
22011
|
+
if (this.trackVars && (changed || this.varsDirty)) {
|
|
22012
|
+
el.style.setProperty("--kui-scroll-x", String(rounded.x));
|
|
22013
|
+
el.style.setProperty("--kui-scroll-y", String(rounded.y));
|
|
22014
|
+
this.varsDirty = false;
|
|
22015
|
+
}
|
|
22016
|
+
for (const [s, v] of sceneValues) {
|
|
22017
|
+
if (s.store.set(v) && s.el)
|
|
22018
|
+
s.el.style.setProperty("--kui-scene-progress", String(v));
|
|
22019
|
+
}
|
|
22020
|
+
for (const [s, stuck] of stickyStates) {
|
|
22021
|
+
if (!s.el || s.stuck === stuck) continue;
|
|
22022
|
+
const was = s.stuck !== "";
|
|
22023
|
+
s.stuck = stuck;
|
|
22024
|
+
if (stuck) s.el.setAttribute("data-stuck", stuck);
|
|
22025
|
+
else s.el.removeAttribute("data-stuck");
|
|
22026
|
+
if (was !== (stuck !== "")) s.onStuckChange?.(stuck !== "");
|
|
22027
|
+
}
|
|
22028
|
+
}, "flush"));
|
|
22029
|
+
}
|
|
22030
|
+
attach(el) {
|
|
22031
|
+
this.el = el;
|
|
22032
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
22033
|
+
this.offsetsDirty = true;
|
|
22034
|
+
this.syncViewport();
|
|
22035
|
+
this.schedule();
|
|
22036
|
+
});
|
|
22037
|
+
this.resizeObserver.observe(el);
|
|
22038
|
+
this.scenes.forEach((s) => s.el && this.resizeObserver.observe(s.el));
|
|
22039
|
+
this.syncViewport();
|
|
22040
|
+
this.schedule();
|
|
22041
|
+
}
|
|
22042
|
+
detach() {
|
|
22043
|
+
cancelAnimationFrame(this.frame);
|
|
22044
|
+
this.frame = 0;
|
|
22045
|
+
this.resizeObserver?.disconnect();
|
|
22046
|
+
this.resizeObserver = null;
|
|
22047
|
+
this.el = null;
|
|
22048
|
+
this.viewport = { w: -1, h: -1 };
|
|
22049
|
+
}
|
|
22050
|
+
setTrackProgress(on) {
|
|
22051
|
+
if (this.trackVars === on) return;
|
|
22052
|
+
this.trackVars = on;
|
|
22053
|
+
if (on) {
|
|
22054
|
+
this.varsDirty = true;
|
|
22055
|
+
} else {
|
|
22056
|
+
this.el?.style.removeProperty("--kui-scroll-x");
|
|
22057
|
+
this.el?.style.removeProperty("--kui-scroll-y");
|
|
22058
|
+
}
|
|
22059
|
+
this.schedule();
|
|
22060
|
+
}
|
|
22061
|
+
register(scene) {
|
|
22062
|
+
this.scenes.add(scene);
|
|
22063
|
+
if (scene.el) this.resizeObserver?.observe(scene.el);
|
|
22064
|
+
this.schedule();
|
|
22065
|
+
return () => {
|
|
22066
|
+
this.scenes.delete(scene);
|
|
22067
|
+
if (scene.el) this.resizeObserver?.unobserve(scene.el);
|
|
22068
|
+
};
|
|
22069
|
+
}
|
|
22070
|
+
registerSticky(s) {
|
|
22071
|
+
this.stickies.add(s);
|
|
22072
|
+
this.schedule();
|
|
22073
|
+
return () => {
|
|
22074
|
+
this.stickies.delete(s);
|
|
22075
|
+
};
|
|
22076
|
+
}
|
|
22077
|
+
isActive() {
|
|
22078
|
+
return this.trackVars || this.scenes.size > 0 || this.stickies.size > 0 || this.containerStore.size > 0;
|
|
22079
|
+
}
|
|
22080
|
+
syncViewport() {
|
|
22081
|
+
const el = this.el;
|
|
22082
|
+
if (!el) return;
|
|
22083
|
+
const w = el.clientWidth;
|
|
22084
|
+
const h = el.clientHeight;
|
|
22085
|
+
if (w === this.viewport.w && h === this.viewport.h) return;
|
|
22086
|
+
this.viewport = { w, h };
|
|
22087
|
+
el.style.setProperty("--kui-scroll-viewport-width", `${w}px`);
|
|
22088
|
+
el.style.setProperty("--kui-scroll-viewport-height", `${h}px`);
|
|
22089
|
+
}
|
|
22090
|
+
};
|
|
22091
|
+
__name(_ScrollEngine, "ScrollEngine");
|
|
22092
|
+
var ScrollEngine = _ScrollEngine;
|
|
22093
|
+
var ScrollEngineContext = React2.createContext(null);
|
|
22094
|
+
var useIsoLayoutEffect = typeof window !== "undefined" ? React2.useLayoutEffect : React2.useEffect;
|
|
22095
|
+
function useScrollEngine(hookName) {
|
|
22096
|
+
const engine = React2.useContext(ScrollEngineContext);
|
|
22097
|
+
if (!engine) throw new Error(`${hookName} must be used inside <ScrollArea>`);
|
|
22098
|
+
return engine;
|
|
22099
|
+
}
|
|
22100
|
+
__name(useScrollEngine, "useScrollEngine");
|
|
22101
|
+
function useScrollProgress() {
|
|
22102
|
+
return useScrollEngine("useScrollProgress").progress;
|
|
22103
|
+
}
|
|
22104
|
+
__name(useScrollProgress, "useScrollProgress");
|
|
22105
|
+
function useElementScrollProgress(ref, { range = "through", axis = "y" } = {}) {
|
|
22106
|
+
const engine = useScrollEngine("useElementScrollProgress");
|
|
22107
|
+
const [handle] = React2.useState(() => new SceneHandle(engine));
|
|
22108
|
+
useIsoLayoutEffect(() => {
|
|
22109
|
+
handle.el = ref.current;
|
|
22110
|
+
handle.axis = axis;
|
|
22111
|
+
handle.range = range;
|
|
22112
|
+
return engine.register(handle);
|
|
22113
|
+
}, [engine, handle, ref, axis, range]);
|
|
22114
|
+
return handle;
|
|
22115
|
+
}
|
|
22116
|
+
__name(useElementScrollProgress, "useElementScrollProgress");
|
|
22117
|
+
|
|
22118
|
+
// src/components/layout/ScrollArea/scrollTargets.ts
|
|
22119
|
+
var axesFor = /* @__PURE__ */ __name((d) => d === "both" ? ["x", "y"] : d === "horizontal" ? ["x"] : ["y"], "axesFor");
|
|
22120
|
+
var prefersReducedMotion = /* @__PURE__ */ __name(() => typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, "prefersReducedMotion");
|
|
22121
|
+
var resolveBehavior = /* @__PURE__ */ __name((b) => b ?? (prefersReducedMotion() ? "auto" : "smooth"), "resolveBehavior");
|
|
22122
|
+
function childTarget(container, child, axis, align) {
|
|
22123
|
+
const h = axis === "x";
|
|
22124
|
+
const c = container.getBoundingClientRect();
|
|
22125
|
+
const r = child.getBoundingClientRect();
|
|
22126
|
+
const cs = getComputedStyle(container);
|
|
22127
|
+
const view = h ? container.clientWidth : container.clientHeight;
|
|
22128
|
+
const size = h ? r.width : r.height;
|
|
22129
|
+
const rel = h ? r.left - c.left - container.clientLeft : r.top - c.top - container.clientTop;
|
|
22130
|
+
const current = h ? container.scrollLeft : container.scrollTop;
|
|
22131
|
+
const max = h ? container.scrollWidth - view : container.scrollHeight - view;
|
|
22132
|
+
const padStart = parseFloat(h ? cs.scrollPaddingLeft : cs.scrollPaddingTop) || 0;
|
|
22133
|
+
const padEnd = parseFloat(h ? cs.scrollPaddingRight : cs.scrollPaddingBottom) || 0;
|
|
22134
|
+
let offsetInView;
|
|
22135
|
+
if (align === "start") offsetInView = padStart;
|
|
22136
|
+
else if (align === "end") offsetInView = view - padEnd - size;
|
|
22137
|
+
else offsetInView = padStart + (view - padStart - padEnd - size) / 2;
|
|
22138
|
+
return Math.min(Math.max(current + rel - offsetInView, 0), Math.max(max, 0));
|
|
22139
|
+
}
|
|
22140
|
+
__name(childTarget, "childTarget");
|
|
22141
|
+
var snapItems = /* @__PURE__ */ __name((el) => Array.from(el.children).filter(
|
|
22142
|
+
(c) => !getComputedStyle(c).scrollSnapAlign.startsWith("none")
|
|
22143
|
+
), "snapItems");
|
|
22144
|
+
function snapToNearest(el, direction, align) {
|
|
22145
|
+
const items = snapItems(el);
|
|
22146
|
+
if (!items.length) return;
|
|
22147
|
+
const opts = { behavior: resolveBehavior() };
|
|
22148
|
+
for (const axis of axesFor(direction)) {
|
|
22149
|
+
const cur = axis === "x" ? el.scrollLeft : el.scrollTop;
|
|
22150
|
+
let best = cur;
|
|
22151
|
+
let bestDist = Infinity;
|
|
22152
|
+
for (const item of items) {
|
|
22153
|
+
const t = childTarget(el, item, axis, align);
|
|
22154
|
+
const d = Math.abs(t - cur);
|
|
22155
|
+
if (d < bestDist) {
|
|
22156
|
+
bestDist = d;
|
|
22157
|
+
best = t;
|
|
22158
|
+
}
|
|
22159
|
+
}
|
|
22160
|
+
opts[axis === "x" ? "left" : "top"] = best;
|
|
22161
|
+
}
|
|
22162
|
+
el.scrollTo(opts);
|
|
22163
|
+
}
|
|
22164
|
+
__name(snapToNearest, "snapToNearest");
|
|
22165
|
+
var ScrollAreaScene = kreativCore.createComponent({
|
|
22166
|
+
displayName: "ScrollArea.Scene",
|
|
22167
|
+
__kui: {
|
|
22168
|
+
role: "layout",
|
|
22169
|
+
skeleton: "preserve",
|
|
22170
|
+
groupSlot: "ScrollArea",
|
|
22171
|
+
video: {
|
|
22172
|
+
id: "scroll-area-scene",
|
|
22173
|
+
safe: true,
|
|
22174
|
+
acceptsChildren: true,
|
|
22175
|
+
interactionStates: [],
|
|
22176
|
+
motionGated: true
|
|
22177
|
+
}
|
|
22178
|
+
},
|
|
22179
|
+
render: /* @__PURE__ */ __name(({ range, axis, as: Tag = "div", ...rest }, forwardedRef) => {
|
|
22180
|
+
const ref = React2.useRef(null);
|
|
22181
|
+
void isMotionGated(rest);
|
|
22182
|
+
useElementScrollProgress(ref, { range, axis });
|
|
22183
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Tag, { ref: kreativCore.composeRefs(ref, forwardedRef), "data-kui-scroll-scene": true, ...rest });
|
|
22184
|
+
}, "render")
|
|
22185
|
+
});
|
|
22186
|
+
function warnIfClipped(el, container) {
|
|
22187
|
+
for (let p = el.parentElement; p && p !== container; p = p.parentElement) {
|
|
22188
|
+
if (/hidden|auto|scroll/.test(getComputedStyle(p).overflow)) {
|
|
22189
|
+
console.warn(
|
|
22190
|
+
"[kreativ-ui/ScrollArea.Sticky]: will not stick: an ancestor has overflow other than visible/clip.",
|
|
22191
|
+
p
|
|
22192
|
+
);
|
|
22193
|
+
return;
|
|
22194
|
+
}
|
|
21158
22195
|
}
|
|
21159
|
-
);
|
|
21160
|
-
Container.displayName = "Container";
|
|
21161
|
-
function spaceVar(value) {
|
|
21162
|
-
return `var(--kui-spacing-${value})`;
|
|
21163
22196
|
}
|
|
21164
|
-
__name(
|
|
21165
|
-
var
|
|
21166
|
-
|
|
21167
|
-
|
|
21168
|
-
|
|
21169
|
-
|
|
21170
|
-
|
|
21171
|
-
|
|
22197
|
+
__name(warnIfClipped, "warnIfClipped");
|
|
22198
|
+
var ScrollAreaSticky = kreativCore.createComponent({
|
|
22199
|
+
displayName: "ScrollArea.Sticky",
|
|
22200
|
+
__kui: {
|
|
22201
|
+
role: "layout",
|
|
22202
|
+
skeleton: "preserve",
|
|
22203
|
+
groupSlot: "ScrollArea",
|
|
22204
|
+
video: {
|
|
22205
|
+
id: "scroll-area-sticky",
|
|
22206
|
+
safe: true,
|
|
22207
|
+
acceptsChildren: true,
|
|
22208
|
+
needsParentContext: true,
|
|
22209
|
+
interactionStates: []
|
|
22210
|
+
}
|
|
22211
|
+
},
|
|
22212
|
+
render: /* @__PURE__ */ __name(({
|
|
22213
|
+
top,
|
|
22214
|
+
bottom,
|
|
22215
|
+
left,
|
|
22216
|
+
right,
|
|
22217
|
+
zIndex = 1,
|
|
22218
|
+
onStuckChange,
|
|
22219
|
+
as: Tag = "div",
|
|
22220
|
+
style,
|
|
22221
|
+
...rest
|
|
22222
|
+
}, forwardedRef) => {
|
|
22223
|
+
const engine = useScrollEngine("ScrollArea.Sticky");
|
|
22224
|
+
const ref = React2.useRef(null);
|
|
22225
|
+
const [handle] = React2.useState(() => new StickyHandle());
|
|
22226
|
+
const none = top === void 0 && bottom === void 0 && left === void 0 && right === void 0;
|
|
22227
|
+
const offsets = {
|
|
22228
|
+
top: none ? 0 : top,
|
|
22229
|
+
bottom,
|
|
22230
|
+
left,
|
|
22231
|
+
right
|
|
22232
|
+
};
|
|
22233
|
+
useIsoLayoutEffect(() => {
|
|
22234
|
+
handle.onStuckChange = onStuckChange;
|
|
22235
|
+
});
|
|
22236
|
+
useIsoLayoutEffect(() => {
|
|
22237
|
+
const el = ref.current;
|
|
22238
|
+
if (!el) return;
|
|
22239
|
+
handle.el = el;
|
|
22240
|
+
handle.edges = STICKY_EDGES.filter((e) => offsets[e] !== void 0);
|
|
22241
|
+
handle.dirty = true;
|
|
22242
|
+
if (process.env.NODE_ENV !== "production") warnIfClipped(el, engine.el);
|
|
22243
|
+
return engine.registerSticky(handle);
|
|
22244
|
+
}, [
|
|
22245
|
+
engine,
|
|
22246
|
+
handle,
|
|
22247
|
+
offsets.top,
|
|
22248
|
+
offsets.bottom,
|
|
22249
|
+
offsets.left,
|
|
22250
|
+
offsets.right
|
|
22251
|
+
]);
|
|
22252
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
22253
|
+
Tag,
|
|
22254
|
+
{
|
|
22255
|
+
ref: kreativCore.composeRefs(ref, forwardedRef),
|
|
22256
|
+
"data-kui-scroll-sticky": true,
|
|
22257
|
+
style: {
|
|
22258
|
+
position: "sticky",
|
|
22259
|
+
top: offsets.top,
|
|
22260
|
+
bottom: offsets.bottom,
|
|
22261
|
+
left: offsets.left,
|
|
22262
|
+
right: offsets.right,
|
|
22263
|
+
zIndex,
|
|
22264
|
+
...style
|
|
22265
|
+
},
|
|
22266
|
+
...rest
|
|
22267
|
+
}
|
|
22268
|
+
);
|
|
22269
|
+
}, "render")
|
|
22270
|
+
});
|
|
22271
|
+
function shouldFade(fadeEdges, edge) {
|
|
22272
|
+
if (fadeEdges === true) return true;
|
|
22273
|
+
if (!fadeEdges) return false;
|
|
22274
|
+
return !!fadeEdges[edge];
|
|
22275
|
+
}
|
|
22276
|
+
__name(shouldFade, "shouldFade");
|
|
22277
|
+
var ScrollAreaRoot = kreativCore.createComponent({
|
|
22278
|
+
displayName: "ScrollArea",
|
|
22279
|
+
__kui: {
|
|
22280
|
+
role: "layout",
|
|
22281
|
+
formControl: "compound",
|
|
22282
|
+
skeleton: "preserve",
|
|
22283
|
+
video: {
|
|
22284
|
+
id: "scroll-area",
|
|
22285
|
+
safe: true,
|
|
22286
|
+
acceptsChildren: true,
|
|
22287
|
+
interactionStates: [],
|
|
22288
|
+
motionGated: true
|
|
22289
|
+
}
|
|
22290
|
+
},
|
|
22291
|
+
render: /* @__PURE__ */ __name(({
|
|
22292
|
+
maxHeight,
|
|
22293
|
+
maxWidth,
|
|
22294
|
+
direction = "vertical",
|
|
22295
|
+
showScrollbar = "auto",
|
|
22296
|
+
scrollbarVariant = "thin",
|
|
22297
|
+
fadeEdges = false,
|
|
22298
|
+
fadeSize = "24px",
|
|
22299
|
+
overscrollBehavior = "contain",
|
|
22300
|
+
snap = "none",
|
|
22301
|
+
snapAlign = "start",
|
|
22302
|
+
dragToScroll = false,
|
|
22303
|
+
onScroll,
|
|
22304
|
+
onScrollEnd,
|
|
22305
|
+
endThreshold = 0,
|
|
22306
|
+
trackProgress = false,
|
|
22307
|
+
tabIndex,
|
|
21172
22308
|
as: Tag = "div",
|
|
21173
22309
|
className,
|
|
21174
22310
|
style,
|
|
21175
|
-
unstyled,
|
|
21176
22311
|
children,
|
|
21177
22312
|
...rest
|
|
21178
|
-
},
|
|
21179
|
-
const
|
|
21180
|
-
|
|
21181
|
-
|
|
21182
|
-
|
|
21183
|
-
|
|
21184
|
-
|
|
21185
|
-
|
|
21186
|
-
|
|
21187
|
-
|
|
22313
|
+
}, forwardedRef) => {
|
|
22314
|
+
const { theme } = kreativCore.useTheme();
|
|
22315
|
+
const [engine] = React2.useState(() => new ScrollEngine());
|
|
22316
|
+
const motionGated = isMotionGated(rest);
|
|
22317
|
+
const snapActive = motionGated ? "none" : snap;
|
|
22318
|
+
const dragActive = motionGated ? false : dragToScroll;
|
|
22319
|
+
const { elRef, state, handleScroll, measure } = useScrollPosition({
|
|
22320
|
+
direction,
|
|
22321
|
+
threshold: endThreshold,
|
|
22322
|
+
onScrollEnd,
|
|
22323
|
+
onMeasure: engine.schedule
|
|
22324
|
+
});
|
|
22325
|
+
useIsoLayoutEffect(() => {
|
|
22326
|
+
const el = elRef.current;
|
|
22327
|
+
if (!el) return;
|
|
22328
|
+
engine.attach(el);
|
|
22329
|
+
return () => engine.detach();
|
|
22330
|
+
}, [engine, elRef]);
|
|
22331
|
+
useIsoLayoutEffect(() => {
|
|
22332
|
+
engine.setTrackProgress(trackProgress);
|
|
22333
|
+
}, [engine, trackProgress]);
|
|
22334
|
+
useDragScroll(elRef, {
|
|
22335
|
+
enabled: dragActive,
|
|
22336
|
+
direction,
|
|
22337
|
+
onRelease: snapActive === "mandatory" ? (el) => snapToNearest(el, direction, snapAlign) : void 0
|
|
22338
|
+
});
|
|
22339
|
+
React2.useImperativeHandle(forwardedRef, () => {
|
|
22340
|
+
const getEl = /* @__PURE__ */ __name(() => elRef.current, "getEl");
|
|
22341
|
+
const defaultAxis = /* @__PURE__ */ __name(() => direction === "horizontal" ? "x" : "y", "defaultAxis");
|
|
22342
|
+
const stepScroll = /* @__PURE__ */ __name((dir, o) => {
|
|
22343
|
+
const el = getEl();
|
|
22344
|
+
if (!el) return;
|
|
22345
|
+
const axis = o?.axis ?? defaultAxis();
|
|
22346
|
+
const h = axis === "x";
|
|
22347
|
+
const cur = h ? el.scrollLeft : el.scrollTop;
|
|
22348
|
+
let target;
|
|
22349
|
+
if ((o?.step ?? "page") === "page") {
|
|
22350
|
+
target = cur + dir * (h ? el.clientWidth : el.clientHeight);
|
|
22351
|
+
} else {
|
|
22352
|
+
const targets = snapItems(el).map(
|
|
22353
|
+
(c) => childTarget(el, c, axis, snapAlign)
|
|
22354
|
+
);
|
|
22355
|
+
const found = dir === 1 ? targets.find((t) => t > cur + 1) : [...targets].reverse().find((t) => t < cur - 1);
|
|
22356
|
+
if (found === void 0) return;
|
|
22357
|
+
target = found;
|
|
22358
|
+
}
|
|
22359
|
+
el.scrollTo({
|
|
22360
|
+
[h ? "left" : "top"]: target,
|
|
22361
|
+
behavior: resolveBehavior(o?.behavior)
|
|
22362
|
+
});
|
|
22363
|
+
}, "stepScroll");
|
|
22364
|
+
return {
|
|
22365
|
+
getElement: getEl,
|
|
22366
|
+
measure,
|
|
22367
|
+
scrollTo: /* @__PURE__ */ __name((opts) => getEl()?.scrollTo(opts), "scrollTo"),
|
|
22368
|
+
scrollToTop: /* @__PURE__ */ __name((behavior) => getEl()?.scrollTo({ top: 0, behavior: resolveBehavior(behavior) }), "scrollToTop"),
|
|
22369
|
+
scrollToBottom: /* @__PURE__ */ __name((behavior) => {
|
|
22370
|
+
const el = getEl();
|
|
22371
|
+
if (el)
|
|
22372
|
+
el.scrollTo({
|
|
22373
|
+
top: el.scrollHeight,
|
|
22374
|
+
behavior: resolveBehavior(behavior)
|
|
22375
|
+
});
|
|
22376
|
+
}, "scrollToBottom"),
|
|
22377
|
+
scrollToEdge: /* @__PURE__ */ __name((edge, behavior) => {
|
|
22378
|
+
const el = getEl();
|
|
22379
|
+
if (!el) return;
|
|
22380
|
+
const opts = { behavior: resolveBehavior(behavior) };
|
|
22381
|
+
if (edge === "top") opts.top = 0;
|
|
22382
|
+
if (edge === "bottom") opts.top = el.scrollHeight;
|
|
22383
|
+
if (edge === "left") opts.left = 0;
|
|
22384
|
+
if (edge === "right") opts.left = el.scrollWidth;
|
|
22385
|
+
el.scrollTo(opts);
|
|
22386
|
+
}, "scrollToEdge"),
|
|
22387
|
+
scrollNext: /* @__PURE__ */ __name((o) => stepScroll(1, o), "scrollNext"),
|
|
22388
|
+
scrollPrev: /* @__PURE__ */ __name((o) => stepScroll(-1, o), "scrollPrev"),
|
|
22389
|
+
scrollToIndex: /* @__PURE__ */ __name((index, o) => {
|
|
22390
|
+
const el = getEl();
|
|
22391
|
+
const child = el?.children[index];
|
|
22392
|
+
if (!el || !child) return;
|
|
22393
|
+
const axis = o?.axis ?? defaultAxis();
|
|
22394
|
+
el.scrollTo({
|
|
22395
|
+
[axis === "x" ? "left" : "top"]: childTarget(
|
|
22396
|
+
el,
|
|
22397
|
+
child,
|
|
22398
|
+
axis,
|
|
22399
|
+
snapAlign
|
|
22400
|
+
),
|
|
22401
|
+
behavior: resolveBehavior(o?.behavior)
|
|
22402
|
+
});
|
|
22403
|
+
}, "scrollToIndex")
|
|
22404
|
+
};
|
|
22405
|
+
}, [elRef, measure, direction, snapAlign]);
|
|
22406
|
+
const handleScrollEvent = React2.useCallback(
|
|
22407
|
+
(e) => {
|
|
22408
|
+
onScroll?.(e);
|
|
22409
|
+
handleScroll();
|
|
22410
|
+
},
|
|
22411
|
+
[onScroll, handleScroll]
|
|
22412
|
+
);
|
|
22413
|
+
const responsiveDims = React2.useMemo(() => {
|
|
22414
|
+
const styles = {};
|
|
22415
|
+
const inlineStyle = {};
|
|
22416
|
+
if (isResponsiveValue(maxHeight)) {
|
|
22417
|
+
const { base, responsive } = resolveResponsiveValue(maxHeight);
|
|
22418
|
+
if (base !== void 0) inlineStyle.maxHeight = base;
|
|
22419
|
+
Object.entries(responsive).forEach(([bp, val]) => {
|
|
22420
|
+
styles[bp] = {
|
|
22421
|
+
...styles[bp] ?? {},
|
|
22422
|
+
maxHeight: val
|
|
22423
|
+
};
|
|
22424
|
+
});
|
|
22425
|
+
} else if (maxHeight !== void 0) {
|
|
22426
|
+
inlineStyle.maxHeight = maxHeight;
|
|
22427
|
+
}
|
|
22428
|
+
if (isResponsiveValue(maxWidth)) {
|
|
22429
|
+
const { base, responsive } = resolveResponsiveValue(maxWidth);
|
|
22430
|
+
if (base !== void 0) inlineStyle.maxWidth = base;
|
|
22431
|
+
Object.entries(responsive).forEach(([bp, val]) => {
|
|
22432
|
+
styles[bp] = {
|
|
22433
|
+
...styles[bp] ?? {},
|
|
22434
|
+
maxWidth: val
|
|
22435
|
+
};
|
|
22436
|
+
});
|
|
22437
|
+
} else if (maxWidth !== void 0) {
|
|
22438
|
+
inlineStyle.maxWidth = maxWidth;
|
|
22439
|
+
}
|
|
22440
|
+
return { inlineStyle, breakpointStyles: styles };
|
|
22441
|
+
}, [maxHeight, maxWidth]);
|
|
22442
|
+
const { attribute, style: responsiveCss } = (0, hooks_exports.useResponsiveStyles)(
|
|
22443
|
+
responsiveDims.breakpointStyles
|
|
22444
|
+
);
|
|
22445
|
+
const fadeTop = shouldFade(fadeEdges, "top") && state.hasVerticalOverflow && !state.atTop;
|
|
22446
|
+
const fadeBottom = shouldFade(fadeEdges, "bottom") && state.hasVerticalOverflow && !state.atBottom;
|
|
22447
|
+
const fadeLeft = shouldFade(fadeEdges, "left") && state.hasHorizontalOverflow && !state.atLeft;
|
|
22448
|
+
const fadeRight = shouldFade(fadeEdges, "right") && state.hasHorizontalOverflow && !state.atRight;
|
|
22449
|
+
const maskImage = React2.useMemo(() => {
|
|
22450
|
+
if (direction !== "both") return void 0;
|
|
22451
|
+
if (!fadeTop && !fadeBottom && !fadeLeft && !fadeRight) return void 0;
|
|
22452
|
+
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%"})`;
|
|
22453
|
+
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%"})`;
|
|
22454
|
+
return `${v}, ${h}`;
|
|
22455
|
+
}, [direction, fadeTop, fadeBottom, fadeLeft, fadeRight]);
|
|
22456
|
+
const recipeClasses = resolveRecipe(theme.recipes.ScrollArea, {
|
|
22457
|
+
direction,
|
|
22458
|
+
showScrollbar,
|
|
22459
|
+
scrollbarVariant
|
|
22460
|
+
});
|
|
22461
|
+
const resolvedTabIndex = tabIndex ?? (state.hasVerticalOverflow || state.hasHorizontalOverflow ? 0 : void 0);
|
|
22462
|
+
const snapAxis = direction === "both" ? "both" : direction === "horizontal" ? "x" : "y";
|
|
22463
|
+
const fadeSizeValue = typeof fadeSize === "number" ? `${fadeSize}px` : fadeSize;
|
|
22464
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ScrollEngineContext.Provider, { value: engine, children: [
|
|
21188
22465
|
/* @__PURE__ */ jsxRuntime.jsx(ResponsiveStyle, { css: responsiveCss }),
|
|
21189
22466
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21190
22467
|
Tag,
|
|
21191
22468
|
{
|
|
21192
|
-
ref,
|
|
22469
|
+
ref: elRef,
|
|
22470
|
+
"data-kui-scroll-area": true,
|
|
22471
|
+
"data-direction": direction,
|
|
22472
|
+
"data-fade-top": fadeTop || void 0,
|
|
22473
|
+
"data-fade-bottom": fadeBottom || void 0,
|
|
22474
|
+
"data-fade-left": fadeLeft || void 0,
|
|
22475
|
+
"data-fade-right": fadeRight || void 0,
|
|
22476
|
+
"data-snap-align": snapActive !== "none" ? snapAlign : void 0,
|
|
22477
|
+
"data-drag-scroll": dragActive || void 0,
|
|
21193
22478
|
"data-kui-responsive": attribute,
|
|
21194
|
-
|
|
21195
|
-
|
|
22479
|
+
onScroll: handleScrollEvent,
|
|
22480
|
+
tabIndex: resolvedTabIndex,
|
|
22481
|
+
className: cn(recipeClasses, className),
|
|
22482
|
+
style: {
|
|
22483
|
+
...responsiveDims.inlineStyle,
|
|
22484
|
+
overscrollBehavior,
|
|
22485
|
+
scrollSnapType: snapActive !== "none" ? `${snapAxis} ${snapActive}` : void 0,
|
|
22486
|
+
"--kui-scroll-fade-size": fadeSizeValue,
|
|
22487
|
+
...maskImage ? {
|
|
22488
|
+
maskImage,
|
|
22489
|
+
WebkitMaskImage: maskImage,
|
|
22490
|
+
maskComposite: "intersect",
|
|
22491
|
+
WebkitMaskComposite: "source-in"
|
|
22492
|
+
} : {},
|
|
22493
|
+
...style
|
|
22494
|
+
},
|
|
21196
22495
|
...rest,
|
|
21197
22496
|
children
|
|
21198
22497
|
}
|
|
21199
22498
|
)
|
|
21200
22499
|
] });
|
|
21201
|
-
}
|
|
21202
|
-
);
|
|
21203
|
-
|
|
21204
|
-
|
|
21205
|
-
|
|
21206
|
-
|
|
21207
|
-
|
|
21208
|
-
|
|
22500
|
+
}, "render")
|
|
22501
|
+
});
|
|
22502
|
+
var ScrollArea = Object.assign(ScrollAreaRoot, {
|
|
22503
|
+
Scene: ScrollAreaScene,
|
|
22504
|
+
Sticky: ScrollAreaSticky
|
|
22505
|
+
});
|
|
22506
|
+
function resolveSize(value) {
|
|
22507
|
+
if (value === "full") return "100%";
|
|
22508
|
+
if (value === "fit") return "fit-content";
|
|
22509
|
+
if (value === "auto") return "auto";
|
|
22510
|
+
return resolveSpace(value);
|
|
22511
|
+
}
|
|
22512
|
+
__name(resolveSize, "resolveSize");
|
|
22513
|
+
var Box = kreativCore.createComponent({
|
|
22514
|
+
displayName: "Box",
|
|
22515
|
+
__kui: {
|
|
22516
|
+
role: "layout",
|
|
22517
|
+
skeleton: "preserve",
|
|
22518
|
+
video: {
|
|
22519
|
+
id: "box",
|
|
22520
|
+
safe: true,
|
|
22521
|
+
acceptsChildren: true,
|
|
22522
|
+
interactionStates: []
|
|
21209
22523
|
}
|
|
21210
|
-
|
|
21211
|
-
|
|
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,
|
|
22524
|
+
},
|
|
22525
|
+
render: /* @__PURE__ */ __name(({
|
|
21233
22526
|
as: Tag = "div",
|
|
22527
|
+
p,
|
|
22528
|
+
px,
|
|
22529
|
+
py,
|
|
22530
|
+
m,
|
|
22531
|
+
mx,
|
|
22532
|
+
my,
|
|
22533
|
+
bg,
|
|
22534
|
+
color,
|
|
22535
|
+
border = false,
|
|
22536
|
+
rounded,
|
|
22537
|
+
w,
|
|
22538
|
+
h,
|
|
21234
22539
|
className,
|
|
21235
22540
|
style,
|
|
21236
22541
|
unstyled,
|
|
21237
22542
|
children,
|
|
21238
22543
|
...rest
|
|
21239
22544
|
}, ref) => {
|
|
22545
|
+
const { theme } = kreativCore.useTheme();
|
|
22546
|
+
const borderColor = typeof border === "boolean" ? void 0 : border;
|
|
21240
22547
|
const responsiveStyles = (0, hooks_exports.useMergedResponsiveStyles)([
|
|
21241
|
-
[
|
|
21242
|
-
|
|
21243
|
-
|
|
21244
|
-
],
|
|
21245
|
-
[
|
|
21246
|
-
[
|
|
21247
|
-
[
|
|
21248
|
-
[
|
|
21249
|
-
[
|
|
21250
|
-
[
|
|
22548
|
+
[p, (v) => ({ padding: resolveSpace(v) })],
|
|
22549
|
+
[px, (v) => ({ paddingInline: resolveSpace(v) })],
|
|
22550
|
+
[py, (v) => ({ paddingBlock: resolveSpace(v) })],
|
|
22551
|
+
[m, (v) => ({ margin: v === "auto" ? "auto" : resolveSpace(v) })],
|
|
22552
|
+
[mx, (v) => ({ marginInline: v === "auto" ? "auto" : resolveSpace(v) })],
|
|
22553
|
+
[my, (v) => ({ marginBlock: v === "auto" ? "auto" : resolveSpace(v) })],
|
|
22554
|
+
[bg, (v) => ({ background: resolveColor(v) })],
|
|
22555
|
+
[color, (v) => ({ color: resolveColor(v) })],
|
|
22556
|
+
[borderColor, (v) => ({ borderColor: resolveColor(v) })],
|
|
22557
|
+
[rounded, (v) => ({ borderRadius: resolveRadius(v) })],
|
|
22558
|
+
[w, (v) => ({ width: resolveSize(v) })],
|
|
22559
|
+
[h, (v) => ({ height: resolveSize(v) })]
|
|
21251
22560
|
]);
|
|
21252
22561
|
const { attribute, style: responsiveCss } = (0, hooks_exports.useResponsiveStyles)(responsiveStyles);
|
|
22562
|
+
const recipeClasses = resolveRecipe(theme.recipes.Box, {
|
|
22563
|
+
border: Boolean(border)
|
|
22564
|
+
});
|
|
21253
22565
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
21254
22566
|
/* @__PURE__ */ jsxRuntime.jsx(ResponsiveStyle, { css: responsiveCss }),
|
|
21255
22567
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -21257,144 +22569,15 @@ var Grid = React2.forwardRef(
|
|
|
21257
22569
|
{
|
|
21258
22570
|
ref,
|
|
21259
22571
|
"data-kui-responsive": attribute,
|
|
21260
|
-
className: cn(!unstyled &&
|
|
21261
|
-
style
|
|
22572
|
+
className: cn(!unstyled && recipeClasses, className),
|
|
22573
|
+
style,
|
|
21262
22574
|
...rest,
|
|
21263
22575
|
children
|
|
21264
22576
|
}
|
|
21265
22577
|
)
|
|
21266
22578
|
] });
|
|
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
22579
|
}, "render")
|
|
21314
22580
|
});
|
|
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
22581
|
var InputField = React2.forwardRef(
|
|
21399
22582
|
({
|
|
21400
22583
|
id,
|
|
@@ -21697,7 +22880,7 @@ var defaultTypography = kreativCore.defineTypography({
|
|
|
21697
22880
|
},
|
|
21698
22881
|
sizeMd: {
|
|
21699
22882
|
fontFamily: "{fonts.body}",
|
|
21700
|
-
fontSize: "{fontSizes.
|
|
22883
|
+
fontSize: "{fontSizes.md}",
|
|
21701
22884
|
fontWeight: "{fontWeights.normal}",
|
|
21702
22885
|
lineHeight: "{lineHeights.normal}"
|
|
21703
22886
|
},
|
|
@@ -21722,8 +22905,7 @@ var defaultSizes = kreativCore.defineSizes({
|
|
|
21722
22905
|
fontSize: "{typography.sizeXs}",
|
|
21723
22906
|
gap: "0.25rem",
|
|
21724
22907
|
iconSize: "0.75rem",
|
|
21725
|
-
radius: "0.65rem"
|
|
21726
|
-
separatorSize: "15px"
|
|
22908
|
+
radius: "0.65rem"
|
|
21727
22909
|
},
|
|
21728
22910
|
sm: {
|
|
21729
22911
|
height: "2rem",
|
|
@@ -21732,8 +22914,7 @@ var defaultSizes = kreativCore.defineSizes({
|
|
|
21732
22914
|
fontSize: "{typography.sizeSm}",
|
|
21733
22915
|
gap: "0.375rem",
|
|
21734
22916
|
iconSize: "0.875rem",
|
|
21735
|
-
radius: "0.8rem"
|
|
21736
|
-
separatorSize: "20px"
|
|
22917
|
+
radius: "0.8rem"
|
|
21737
22918
|
},
|
|
21738
22919
|
md: {
|
|
21739
22920
|
height: "2.5rem",
|
|
@@ -21742,8 +22923,7 @@ var defaultSizes = kreativCore.defineSizes({
|
|
|
21742
22923
|
fontSize: "{typography.sizeMd}",
|
|
21743
22924
|
gap: "0.5rem",
|
|
21744
22925
|
iconSize: "1rem",
|
|
21745
|
-
radius: "1rem"
|
|
21746
|
-
separatorSize: "25px"
|
|
22926
|
+
radius: "1rem"
|
|
21747
22927
|
},
|
|
21748
22928
|
lg: {
|
|
21749
22929
|
height: "3rem",
|
|
@@ -21752,8 +22932,7 @@ var defaultSizes = kreativCore.defineSizes({
|
|
|
21752
22932
|
fontSize: "{typography.sizeLg}",
|
|
21753
22933
|
gap: "0.625rem",
|
|
21754
22934
|
iconSize: "1.25rem",
|
|
21755
|
-
radius: "1.15rem"
|
|
21756
|
-
separatorSize: "30px"
|
|
22935
|
+
radius: "1.15rem"
|
|
21757
22936
|
},
|
|
21758
22937
|
xl: {
|
|
21759
22938
|
height: "3.5rem",
|
|
@@ -21762,8 +22941,7 @@ var defaultSizes = kreativCore.defineSizes({
|
|
|
21762
22941
|
fontSize: "{typography.sizeXl}",
|
|
21763
22942
|
gap: "0.875rem",
|
|
21764
22943
|
iconSize: "1.5rem",
|
|
21765
|
-
radius: "1.3rem"
|
|
21766
|
-
separatorSize: "35px"
|
|
22944
|
+
radius: "1.3rem"
|
|
21767
22945
|
}
|
|
21768
22946
|
});
|
|
21769
22947
|
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 +22995,13 @@ var buttonColors = {
|
|
|
21817
22995
|
soft: "bg-white/10 text-white hover:bg-white/20",
|
|
21818
22996
|
link: "text-white"
|
|
21819
22997
|
},
|
|
22998
|
+
black: {
|
|
22999
|
+
solid: "bg-black text-white hover:bg-neutral-900 active:bg-neutral-950 shadow-sm",
|
|
23000
|
+
outline: "border border-black/80 text-black bg-transparent hover:bg-black hover:text-white active:bg-black/90",
|
|
23001
|
+
ghost: "text-black bg-transparent hover:bg-black/10 active:bg-black/15",
|
|
23002
|
+
soft: "bg-black/10 text-black hover:bg-black/15 active:bg-black/20",
|
|
23003
|
+
link: "text-black underline-offset-4 hover:underline"
|
|
23004
|
+
},
|
|
21820
23005
|
neutral: {
|
|
21821
23006
|
solid: "bg-kui-surface-raised text-kui-text hover:bg-kui-surface-sunken",
|
|
21822
23007
|
outline: "border-kui-border text-kui-text hover:bg-kui-surface-raised",
|
|
@@ -21860,7 +23045,11 @@ var buttonRecipe = kreativCore.defineRecipe({
|
|
|
21860
23045
|
});
|
|
21861
23046
|
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
23047
|
var formControlVariants = {
|
|
21863
|
-
outline:
|
|
23048
|
+
outline: {
|
|
23049
|
+
border: "1px solid rgb(var(--kui-border))",
|
|
23050
|
+
backgroundColor: "transparent",
|
|
23051
|
+
color: "rgb(var(--kui-text))"
|
|
23052
|
+
},
|
|
21864
23053
|
filled: "border border-transparent bg-kui-surface-raised text-kui-text",
|
|
21865
23054
|
ghost: "border border-transparent bg-transparent text-kui-text"
|
|
21866
23055
|
};
|
|
@@ -22229,7 +23418,7 @@ var switchRecipe = kreativCore.defineRecipe({
|
|
|
22229
23418
|
disabled: false
|
|
22230
23419
|
}
|
|
22231
23420
|
});
|
|
22232
|
-
var
|
|
23421
|
+
var containerRecipe = kreativCore.defineRecipe({
|
|
22233
23422
|
base: "w-full",
|
|
22234
23423
|
variants: {
|
|
22235
23424
|
maxWidth: {
|
|
@@ -22242,6 +23431,7 @@ var containerReccipe = kreativCore.defineRecipe({
|
|
|
22242
23431
|
}
|
|
22243
23432
|
},
|
|
22244
23433
|
defaultVariants: {
|
|
23434
|
+
size: "lg",
|
|
22245
23435
|
maxWidth: "lg"
|
|
22246
23436
|
}
|
|
22247
23437
|
});
|
|
@@ -22365,18 +23555,179 @@ var numberStepperButtonsRecipe = kreativCore.defineRecipe({
|
|
|
22365
23555
|
var numberStepperButtonRecipe = kreativCore.defineRecipe({
|
|
22366
23556
|
base: "kui-number-stepper__button"
|
|
22367
23557
|
});
|
|
23558
|
+
var cardRecipe = kreativCore.defineRecipe({
|
|
23559
|
+
base: "overflow-hidden rounded-(--kui-radii-lg)",
|
|
23560
|
+
variants: {
|
|
23561
|
+
variant: {
|
|
23562
|
+
solid: "bg-kui-surface",
|
|
23563
|
+
outline: "border border-kui-border bg-kui-surface",
|
|
23564
|
+
ghost: "bg-transparent",
|
|
23565
|
+
elevated: "bg-kui-surface shadow-md",
|
|
23566
|
+
compact: "bg-kui-surface"
|
|
23567
|
+
},
|
|
23568
|
+
fullWidth: {
|
|
23569
|
+
true: "w-full"
|
|
23570
|
+
}
|
|
23571
|
+
},
|
|
23572
|
+
defaultVariants: {
|
|
23573
|
+
variant: "outline"
|
|
23574
|
+
}
|
|
23575
|
+
});
|
|
23576
|
+
var sectionPaddingVariants = {
|
|
23577
|
+
size: {
|
|
23578
|
+
sm: "p-3",
|
|
23579
|
+
md: "p-4",
|
|
23580
|
+
lg: "p-6"
|
|
23581
|
+
}
|
|
23582
|
+
};
|
|
23583
|
+
var sectionPaddingCompoundVariants = [
|
|
23584
|
+
{
|
|
23585
|
+
conditions: { variant: "compact" },
|
|
23586
|
+
className: "p-3"
|
|
23587
|
+
},
|
|
23588
|
+
{
|
|
23589
|
+
conditions: { noPadding: true },
|
|
23590
|
+
className: "p-0"
|
|
23591
|
+
}
|
|
23592
|
+
];
|
|
23593
|
+
var cardHeaderRecipe = kreativCore.defineRecipe({
|
|
23594
|
+
base: "relative flex items-center justify-between gap-(--kui-spacing-md)",
|
|
23595
|
+
variants: sectionPaddingVariants,
|
|
23596
|
+
defaultVariants: {
|
|
23597
|
+
size: "md"
|
|
23598
|
+
},
|
|
23599
|
+
compoundVariants: [...sectionPaddingCompoundVariants]
|
|
23600
|
+
});
|
|
23601
|
+
var cardBodyRecipe = kreativCore.defineRecipe({
|
|
23602
|
+
base: "relative min-w-0",
|
|
23603
|
+
variants: sectionPaddingVariants,
|
|
23604
|
+
defaultVariants: {
|
|
23605
|
+
size: "md"
|
|
23606
|
+
},
|
|
23607
|
+
compoundVariants: [...sectionPaddingCompoundVariants]
|
|
23608
|
+
});
|
|
23609
|
+
var cardFooterRecipe = kreativCore.defineRecipe({
|
|
23610
|
+
base: "relative flex items-center gap-(--kui-spacing-md)",
|
|
23611
|
+
variants: sectionPaddingVariants,
|
|
23612
|
+
defaultVariants: {
|
|
23613
|
+
size: "md"
|
|
23614
|
+
},
|
|
23615
|
+
compoundVariants: [...sectionPaddingCompoundVariants]
|
|
23616
|
+
});
|
|
23617
|
+
var cardMediaRecipe = kreativCore.defineRecipe({
|
|
23618
|
+
base: "relative overflow-hidden"
|
|
23619
|
+
});
|
|
23620
|
+
kreativCore.defineRecipe({
|
|
23621
|
+
base: "h-full w-full",
|
|
23622
|
+
variants: {
|
|
23623
|
+
fit: {
|
|
23624
|
+
cover: "object-cover",
|
|
23625
|
+
contain: "object-contain",
|
|
23626
|
+
fill: "object-fill",
|
|
23627
|
+
none: "object-none"
|
|
23628
|
+
},
|
|
23629
|
+
blend: {
|
|
23630
|
+
normal: "mix-blend-normal",
|
|
23631
|
+
multiply: "mix-blend-multiply",
|
|
23632
|
+
screen: "mix-blend-screen",
|
|
23633
|
+
overlay: "mix-blend-overlay",
|
|
23634
|
+
darken: "mix-blend-darken",
|
|
23635
|
+
lighten: "mix-blend-lighten"
|
|
23636
|
+
}
|
|
23637
|
+
},
|
|
23638
|
+
defaultVariants: {
|
|
23639
|
+
fit: "cover",
|
|
23640
|
+
blend: "normal"
|
|
23641
|
+
}
|
|
23642
|
+
});
|
|
23643
|
+
var cardOverlayRecipe = kreativCore.defineRecipe({
|
|
23644
|
+
base: "absolute inset-0"
|
|
23645
|
+
});
|
|
23646
|
+
var scrollAreaRecipe = kreativCore.defineRecipe({
|
|
23647
|
+
base: "kui-scroll-area",
|
|
23648
|
+
variants: {
|
|
23649
|
+
direction: {
|
|
23650
|
+
vertical: "overflow-y-auto overflow-x-hidden",
|
|
23651
|
+
horizontal: "overflow-x-auto overflow-y-hidden",
|
|
23652
|
+
both: "overflow-auto"
|
|
23653
|
+
},
|
|
23654
|
+
showScrollbar: {
|
|
23655
|
+
auto: "",
|
|
23656
|
+
always: "kui-scrollbar",
|
|
23657
|
+
hover: "kui-scrollbar kui-scrollbar-hover-only",
|
|
23658
|
+
never: "kui-scrollbar-hidden"
|
|
23659
|
+
},
|
|
23660
|
+
scrollbarVariant: {
|
|
23661
|
+
thin: "kui-scrollbar",
|
|
23662
|
+
default: "kui-scrollbar-default-width"
|
|
23663
|
+
}
|
|
23664
|
+
},
|
|
23665
|
+
defaultVariants: {
|
|
23666
|
+
direction: "vertical",
|
|
23667
|
+
showScrollbar: "auto",
|
|
23668
|
+
scrollbarVariant: "thin"
|
|
23669
|
+
}
|
|
23670
|
+
});
|
|
23671
|
+
var boxRecipe = kreativCore.defineRecipe({
|
|
23672
|
+
base: "box-border",
|
|
23673
|
+
variants: {
|
|
23674
|
+
border: {
|
|
23675
|
+
true: "border border-solid border-kui-border",
|
|
23676
|
+
false: ""
|
|
23677
|
+
}
|
|
23678
|
+
},
|
|
23679
|
+
defaultVariants: {
|
|
23680
|
+
border: "false"
|
|
23681
|
+
}
|
|
23682
|
+
});
|
|
23683
|
+
var flexRecipe = kreativCore.defineRecipe({
|
|
23684
|
+
base: "",
|
|
23685
|
+
variants: {
|
|
23686
|
+
inline: {
|
|
23687
|
+
true: "inline-flex",
|
|
23688
|
+
false: "flex"
|
|
23689
|
+
},
|
|
23690
|
+
fullWidth: {
|
|
23691
|
+
true: "w-full",
|
|
23692
|
+
false: ""
|
|
23693
|
+
},
|
|
23694
|
+
fullHeight: {
|
|
23695
|
+
true: "h-full",
|
|
23696
|
+
false: ""
|
|
23697
|
+
}
|
|
23698
|
+
},
|
|
23699
|
+
defaultVariants: {
|
|
23700
|
+
inline: "false",
|
|
23701
|
+
fullWidth: "false",
|
|
23702
|
+
fullHeight: "false"
|
|
23703
|
+
}
|
|
23704
|
+
});
|
|
23705
|
+
var gridRecipe = kreativCore.defineRecipe({
|
|
23706
|
+
base: "",
|
|
23707
|
+
variants: {
|
|
23708
|
+
inline: {
|
|
23709
|
+
true: "inline-grid",
|
|
23710
|
+
false: "grid"
|
|
23711
|
+
}
|
|
23712
|
+
},
|
|
23713
|
+
defaultVariants: {
|
|
23714
|
+
inline: "false"
|
|
23715
|
+
}
|
|
23716
|
+
});
|
|
22368
23717
|
|
|
22369
23718
|
// src/theme/defaults/theme.ts
|
|
22370
23719
|
var defaultRecipes = {
|
|
23720
|
+
Box: boxRecipe,
|
|
22371
23721
|
Button: buttonRecipe,
|
|
23722
|
+
ButtonGroup: buttonGroupRecipe,
|
|
23723
|
+
Checkbox: checkboxRecipe,
|
|
23724
|
+
Flex: flexRecipe,
|
|
22372
23725
|
FormControl: formControlRecipe,
|
|
22373
23726
|
Input: inputRecipe,
|
|
22374
23727
|
Textarea: textareaRecipe,
|
|
22375
23728
|
MarkdownEditor: markdownEditorRecipe,
|
|
22376
|
-
Checkbox: checkboxRecipe,
|
|
22377
|
-
ButtonGroup: buttonGroupRecipe,
|
|
22378
23729
|
Switch: switchRecipe,
|
|
22379
|
-
Container:
|
|
23730
|
+
Container: containerRecipe,
|
|
22380
23731
|
Link: linkRecipe,
|
|
22381
23732
|
RepeaterRemove: repeaterRemoveRecipe,
|
|
22382
23733
|
RepeaterMoveUp: repeaterMoveUpRecipe,
|
|
@@ -22386,7 +23737,15 @@ var defaultRecipes = {
|
|
|
22386
23737
|
RepeaterItems: repeaterItemsRecipe,
|
|
22387
23738
|
NumberStepper: numberStepperRecipe,
|
|
22388
23739
|
NumberStepperButton: numberStepperButtonRecipe,
|
|
22389
|
-
NumberStepperButtons: numberStepperButtonsRecipe
|
|
23740
|
+
NumberStepperButtons: numberStepperButtonsRecipe,
|
|
23741
|
+
CardBody: cardBodyRecipe,
|
|
23742
|
+
CardFooter: cardFooterRecipe,
|
|
23743
|
+
CardHeader: cardHeaderRecipe,
|
|
23744
|
+
CardMedia: cardMediaRecipe,
|
|
23745
|
+
CardOverlay: cardOverlayRecipe,
|
|
23746
|
+
Card: cardRecipe,
|
|
23747
|
+
ScrollArea: scrollAreaRecipe,
|
|
23748
|
+
Grid: gridRecipe
|
|
22390
23749
|
};
|
|
22391
23750
|
var defaultTheme = kreativCore.defineTheme({
|
|
22392
23751
|
tokens: defaultTokens,
|
|
@@ -22513,7 +23872,9 @@ function KreativUIProvider({
|
|
|
22513
23872
|
as = "div",
|
|
22514
23873
|
fallbackSize = "md",
|
|
22515
23874
|
textColor,
|
|
22516
|
-
background
|
|
23875
|
+
background,
|
|
23876
|
+
style,
|
|
23877
|
+
className
|
|
22517
23878
|
}) {
|
|
22518
23879
|
const [mode, setMode] = React2.useState(defaultMode);
|
|
22519
23880
|
const systemPrefersDark = useSystemPrefersDark();
|
|
@@ -22550,11 +23911,12 @@ function KreativUIProvider({
|
|
|
22550
23911
|
Tag,
|
|
22551
23912
|
{
|
|
22552
23913
|
"data-kreativ-theme": resolvedMode,
|
|
22553
|
-
className: resolvedMode === "dark" ? "dark" : void 0,
|
|
23914
|
+
className: [resolvedMode === "dark" ? "dark" : void 0, className].filter(Boolean).join(" "),
|
|
22554
23915
|
style: {
|
|
22555
23916
|
...cssVars,
|
|
22556
23917
|
...background && { background },
|
|
22557
|
-
...textColor && { color: textColor }
|
|
23918
|
+
...textColor && { color: textColor },
|
|
23919
|
+
...style
|
|
22558
23920
|
},
|
|
22559
23921
|
children
|
|
22560
23922
|
}
|
|
@@ -22565,6 +23927,10 @@ __name(KreativUIProvider, "KreativUIProvider");
|
|
|
22565
23927
|
// src/index.ts
|
|
22566
23928
|
__reExport(index_exports, hooks_exports);
|
|
22567
23929
|
|
|
23930
|
+
Object.defineProperty(exports, "PersistMode", {
|
|
23931
|
+
enumerable: true,
|
|
23932
|
+
get: function () { return kreativCore.PersistMode; }
|
|
23933
|
+
});
|
|
22568
23934
|
Object.defineProperty(exports, "ThemeContext", {
|
|
22569
23935
|
enumerable: true,
|
|
22570
23936
|
get: function () { return kreativCore.ThemeContext; }
|
|
@@ -22602,11 +23968,13 @@ Object.defineProperty(exports, "resolveTypography", {
|
|
|
22602
23968
|
get: function () { return kreativCore.resolveTypography; }
|
|
22603
23969
|
});
|
|
22604
23970
|
exports.Adornment = Adornment;
|
|
23971
|
+
exports.Box = Box;
|
|
22605
23972
|
exports.Button = Button;
|
|
22606
23973
|
exports.ButtonGroup = ButtonGroup;
|
|
22607
23974
|
exports.ButtonGroupContext = ButtonGroupContext;
|
|
22608
23975
|
exports.ButtonGroupItemContext = ButtonGroupItemContext;
|
|
22609
23976
|
exports.Card = Card;
|
|
23977
|
+
exports.CardOverlay = CardOverlay;
|
|
22610
23978
|
exports.Checkbox = Checkbox;
|
|
22611
23979
|
exports.Combobox = Combobox;
|
|
22612
23980
|
exports.ComboboxContent = ComboboxContent;
|
|
@@ -22633,6 +24001,7 @@ exports.MultiSelectItem = MultiSelectItem;
|
|
|
22633
24001
|
exports.MultiSelectTrigger = MultiSelectTrigger;
|
|
22634
24002
|
exports.Radio = Radio;
|
|
22635
24003
|
exports.RadioGroup = RadioGroup;
|
|
24004
|
+
exports.ScrollArea = ScrollArea;
|
|
22636
24005
|
exports.Select = Select;
|
|
22637
24006
|
exports.SelectContent = SelectContent;
|
|
22638
24007
|
exports.SelectGroup = SelectGroup;
|
|
@@ -22645,7 +24014,6 @@ exports.Stack = Stack;
|
|
|
22645
24014
|
exports.Switch = Switch;
|
|
22646
24015
|
exports.Textarea = Textarea;
|
|
22647
24016
|
exports.ThemeToggler = ThemeToggler;
|
|
22648
|
-
exports.cardSkeleton = cardSkeleton;
|
|
22649
24017
|
exports.cn = cn;
|
|
22650
24018
|
exports.defineUIField = defineUIField;
|
|
22651
24019
|
exports.extendRecipe = extendRecipe;
|
|
@@ -22660,11 +24028,13 @@ exports.rgbToHex = rgbToHex;
|
|
|
22660
24028
|
exports.useButtonGroupContext = useButtonGroupContext;
|
|
22661
24029
|
exports.useButtonGroupItemContext = useButtonGroupItemContext;
|
|
22662
24030
|
exports.useClearableField = useClearableField;
|
|
24031
|
+
exports.useElementScrollProgress = useElementScrollProgress;
|
|
22663
24032
|
exports.useFloatingSide = useFloatingSide;
|
|
22664
24033
|
exports.useFormContext = useFormContext;
|
|
22665
24034
|
exports.useKeyboardShortcuts = useKeyboardShortcuts;
|
|
22666
24035
|
exports.useOptionalButtonGroupContext = useOptionalButtonGroupContext;
|
|
22667
24036
|
exports.useOptionalButtonGroupItemContext = useOptionalButtonGroupItemContext;
|
|
24037
|
+
exports.useScrollProgress = useScrollProgress;
|
|
22668
24038
|
exports.useStatusTransition = useStatusTransition;
|
|
22669
24039
|
//# sourceMappingURL=index.cjs.map
|
|
22670
24040
|
//# sourceMappingURL=index.cjs.map
|