@kjun-ui/react 0.15.0 → 0.16.0
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 +86 -18
- package/dist/index.js +99 -31
- package/dist/styles.css +25 -2
- package/dist/types/packages/react/src/floating-panel.d.cts +5 -1
- package/dist/types/packages/react/src/floating-panel.d.ts +5 -1
- package/dist/types/packages/react/src/list.d.cts +4 -1
- package/dist/types/packages/react/src/list.d.ts +4 -1
- package/dist/types/packages/react/src/popover.d.cts +12 -3
- package/dist/types/packages/react/src/popover.d.ts +12 -3
- package/dist/types/shared/package-runtime/anchor-rect.d.cts +17 -0
- package/dist/types/shared/package-runtime/anchor-rect.d.ts +17 -0
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -3106,7 +3106,9 @@ function FloatingPanel({
|
|
|
3106
3106
|
flip = true,
|
|
3107
3107
|
nonModal = false,
|
|
3108
3108
|
ownsDismiss = false,
|
|
3109
|
-
returnFocus
|
|
3109
|
+
returnFocus,
|
|
3110
|
+
repositionKey = 0,
|
|
3111
|
+
inside
|
|
3110
3112
|
}) {
|
|
3111
3113
|
const motion = usePresence(open, useReducedMotion(), import_tokens19.tokens.motion.popupExit);
|
|
3112
3114
|
const layer = useLayer(open, motion.present, "popup", () => onOpenChange(false), triggerRef, returnFocus);
|
|
@@ -3141,12 +3143,17 @@ function FloatingPanel({
|
|
|
3141
3143
|
if (next) onOpenChange(next);
|
|
3142
3144
|
} : onOpenChange,
|
|
3143
3145
|
triggerRef,
|
|
3146
|
+
shouldCloseOnInteractOutside: inside ? (element) => {
|
|
3147
|
+
var _a;
|
|
3148
|
+
return !((_a = inside.current) == null ? void 0 : _a.contains(element));
|
|
3149
|
+
} : void 0,
|
|
3144
3150
|
UNSTABLE_portalContainer: container,
|
|
3145
3151
|
placement: placement.replace("-", " "),
|
|
3146
3152
|
shouldFlip: flip,
|
|
3147
3153
|
maxHeight: typeof maxHeight === "number" ? maxHeight : maxHeight == null ? field ? import_tokens19.tokens.extensions.menu.listMaxHeight : import_tokens19.tokens.extensions.floating.maxHeight : void 0,
|
|
3148
3154
|
offset: field ? import_tokens19.tokens.extensions.floating.fieldGap : import_tokens19.tokens.extensions.floating.anchorGap,
|
|
3149
3155
|
containerPadding: import_tokens19.tokens.extensions.floating.viewportInset,
|
|
3156
|
+
crossOffset: repositionKey % 2 ? 1e-3 : 0,
|
|
3150
3157
|
className: "kjun-scope kjun-floating " + className,
|
|
3151
3158
|
"data-motion": "popup",
|
|
3152
3159
|
"data-motion-open": String(motion.active),
|
|
@@ -3161,6 +3168,31 @@ function FloatingPanel({
|
|
|
3161
3168
|
}
|
|
3162
3169
|
var resolveFocusReturn = (target) => target === void 0 ? void 0 : () => typeof target === "function" ? target() : target instanceof HTMLElement ? target : target.current;
|
|
3163
3170
|
|
|
3171
|
+
// shared/package-runtime/anchor-rect.ts
|
|
3172
|
+
function place(element, rect) {
|
|
3173
|
+
var _a, _b;
|
|
3174
|
+
const next = [rect.x, rect.y, (_a = rect.width) != null ? _a : 0, (_b = rect.height) != null ? _b : 0].map((value) => value + "px");
|
|
3175
|
+
const style = element.style;
|
|
3176
|
+
if (style.left === next[0] && style.top === next[1] && style.width === next[2] && style.height === next[3]) return false;
|
|
3177
|
+
[style.left, style.top, style.width, style.height] = next;
|
|
3178
|
+
return true;
|
|
3179
|
+
}
|
|
3180
|
+
function followAnchor(element, source, moved) {
|
|
3181
|
+
let frame = 0, stopped = false;
|
|
3182
|
+
const step = () => {
|
|
3183
|
+
const current = source();
|
|
3184
|
+
const rect = typeof current === "function" ? current() : current;
|
|
3185
|
+
if (rect && place(element, rect)) moved();
|
|
3186
|
+
if (!stopped && typeof current === "function") frame = requestAnimationFrame(step);
|
|
3187
|
+
};
|
|
3188
|
+
step();
|
|
3189
|
+
return () => {
|
|
3190
|
+
stopped = true;
|
|
3191
|
+
cancelAnimationFrame(frame);
|
|
3192
|
+
};
|
|
3193
|
+
}
|
|
3194
|
+
var anchorStyle = { position: "fixed", pointerEvents: "none", visibility: "hidden" };
|
|
3195
|
+
|
|
3164
3196
|
// packages/react/src/popover.tsx
|
|
3165
3197
|
var import_tokens20 = require("@kjun-ui/tokens");
|
|
3166
3198
|
var import_react28 = require("react");
|
|
@@ -3241,6 +3273,7 @@ function KjunPopover({
|
|
|
3241
3273
|
returnFocus,
|
|
3242
3274
|
header,
|
|
3243
3275
|
modal = true,
|
|
3276
|
+
anchorRect,
|
|
3244
3277
|
trigger,
|
|
3245
3278
|
children
|
|
3246
3279
|
}) {
|
|
@@ -3253,6 +3286,17 @@ function KjunPopover({
|
|
|
3253
3286
|
if (node && focusOnMount.current) node.focus();
|
|
3254
3287
|
}, []);
|
|
3255
3288
|
const resolveReturn = resolveFocusReturn(returnFocus);
|
|
3289
|
+
const anchor = (0, import_react28.useRef)(null), anchorSource = (0, import_react28.useRef)(anchorRect), opener = (0, import_react28.useRef)(null);
|
|
3290
|
+
anchorSource.current = anchorRect;
|
|
3291
|
+
const [reposition, setReposition] = (0, import_react28.useState)(0);
|
|
3292
|
+
const anchored = anchorRect !== void 0;
|
|
3293
|
+
const wasOpen = (0, import_react28.useRef)(false);
|
|
3294
|
+
if (open && !wasOpen.current && typeof document !== "undefined") opener.current = document.activeElement;
|
|
3295
|
+
wasOpen.current = open;
|
|
3296
|
+
(0, import_react28.useLayoutEffect)(() => {
|
|
3297
|
+
if (!open || !anchored || !anchor.current) return;
|
|
3298
|
+
return followAnchor(anchor.current, () => anchorSource.current, () => setReposition((n) => n + 1));
|
|
3299
|
+
}, [open, anchored, typeof anchorRect === "function" ? anchorRect : anchorRect && `${anchorRect.x},${anchorRect.y},${anchorRect.width},${anchorRect.height}`]);
|
|
3256
3300
|
const change = (v) => {
|
|
3257
3301
|
setInternal(v);
|
|
3258
3302
|
onOpenChange == null ? void 0 : onOpenChange(v);
|
|
@@ -3275,7 +3319,8 @@ function KjunPopover({
|
|
|
3275
3319
|
});
|
|
3276
3320
|
const content = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "kjun-popover-content", "data-no-padding": noPadding, children: typeof children === "function" ? children(() => change(false)) : children });
|
|
3277
3321
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
3278
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3322
|
+
anchored && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { ref: anchor, "aria-hidden": "true", style: anchorStyle }),
|
|
3323
|
+
(!anchored || trigger != null) && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3279
3324
|
"div",
|
|
3280
3325
|
{
|
|
3281
3326
|
ref,
|
|
@@ -3300,13 +3345,18 @@ function KjunPopover({
|
|
|
3300
3345
|
{
|
|
3301
3346
|
open,
|
|
3302
3347
|
onOpenChange: change,
|
|
3303
|
-
triggerRef: ref,
|
|
3348
|
+
triggerRef: anchored ? anchor : ref,
|
|
3349
|
+
inside: anchored ? ref : void 0,
|
|
3350
|
+
repositionKey: reposition,
|
|
3304
3351
|
className: "kjun-content-popover" + (header != null ? " kjun-popover-has-header" : ""),
|
|
3305
3352
|
placement,
|
|
3306
3353
|
matchTriggerWidth,
|
|
3307
3354
|
maxHeight,
|
|
3308
3355
|
flip,
|
|
3309
|
-
returnFocus: () =>
|
|
3356
|
+
returnFocus: () => {
|
|
3357
|
+
var _a;
|
|
3358
|
+
return skipReturn.current ? false : (_a = resolveReturn == null ? void 0 : resolveReturn()) != null ? _a : anchored && trigger == null ? opener.current : void 0;
|
|
3359
|
+
},
|
|
3310
3360
|
nonModal: !modal,
|
|
3311
3361
|
ownsDismiss: !modal,
|
|
3312
3362
|
children: (() => {
|
|
@@ -3330,6 +3380,9 @@ function KjunPopover({
|
|
|
3330
3380
|
}
|
|
3331
3381
|
function KjunTooltip({
|
|
3332
3382
|
content = "",
|
|
3383
|
+
title,
|
|
3384
|
+
align,
|
|
3385
|
+
width,
|
|
3333
3386
|
placement = "top",
|
|
3334
3387
|
delay = 0,
|
|
3335
3388
|
open: controlled,
|
|
@@ -3343,19 +3396,23 @@ function KjunTooltip({
|
|
|
3343
3396
|
onOpenChange == null ? void 0 : onOpenChange(value);
|
|
3344
3397
|
};
|
|
3345
3398
|
const layer = useLayer(open, open, "tooltip", () => setOpen(false));
|
|
3346
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_react_aria_components5.TooltipTrigger, { isOpen: open && !layer.blocked, onOpenChange: setOpen, delay, closeDelay: 0, isDisabled: !content || !layer.scopeActive, children: [
|
|
3399
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_react_aria_components5.TooltipTrigger, { isOpen: open && !layer.blocked && !!(content || title), onOpenChange: setOpen, delay, closeDelay: 0, isDisabled: !content && !title || !layer.scopeActive, children: [
|
|
3347
3400
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_aria_components5.Focusable, { children }),
|
|
3348
3401
|
container !== null && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
3349
3402
|
import_react_aria_components5.Tooltip,
|
|
3350
3403
|
{
|
|
3351
|
-
style: { zIndex: layer.zIndex },
|
|
3404
|
+
style: { zIndex: layer.zIndex, ...width ? { maxWidth: `var(--_kjun-extension-tooltip-max-widths-${width})` } : {} },
|
|
3405
|
+
"data-align": align,
|
|
3352
3406
|
UNSTABLE_portalContainer: container,
|
|
3353
3407
|
placement,
|
|
3354
3408
|
offset: import_tokens20.tokens.extensions.floating.anchorGap,
|
|
3355
3409
|
className: "kjun-scope kjun-tooltip",
|
|
3356
3410
|
children: [
|
|
3357
3411
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_aria_components5.OverlayArrow, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("svg", { width: import_tokens20.tokens.extensions.tooltip.arrowSize, height: import_tokens20.tokens.extensions.tooltip.arrowSize, viewBox: "0 0 8 8", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("path", { d: "M0 0L4 4L8 0", fill: "currentColor" }) }) }),
|
|
3358
|
-
|
|
3412
|
+
title ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
3413
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "kjun-tooltip-title", children: title }),
|
|
3414
|
+
content && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "kjun-tooltip-body", children: content })
|
|
3415
|
+
] }) : content
|
|
3359
3416
|
]
|
|
3360
3417
|
}
|
|
3361
3418
|
)
|
|
@@ -7510,18 +7567,29 @@ function KjunListRow({ title, description, leading, trailing, actions, href, dis
|
|
|
7510
7567
|
actions && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "kjun-list-actions", "data-disabled": disabled || void 0, inert: disabled || void 0, children: actions })
|
|
7511
7568
|
] });
|
|
7512
7569
|
}
|
|
7513
|
-
function KjunListSection({ title, description, actions, children, ariaLabel, surface = true, divider = true, density = "default" }) {
|
|
7570
|
+
function KjunListSection({ title, description, actions, children, ariaLabel, surface = true, divider = true, density = "default", radius = "none" }) {
|
|
7514
7571
|
const id = "kjun-" + (0, import_react52.useId)();
|
|
7515
|
-
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
7572
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
7573
|
+
"section",
|
|
7574
|
+
{
|
|
7575
|
+
className: "kjun-list-section",
|
|
7576
|
+
"data-surface": surface ? void 0 : "false",
|
|
7577
|
+
"data-radius": radius === "none" ? void 0 : radius,
|
|
7578
|
+
style: radius === "none" ? void 0 : { borderRadius: `var(--_kjun-geometry-card-radii-${radius})` },
|
|
7579
|
+
"aria-labelledby": title ? id : void 0,
|
|
7580
|
+
"aria-label": title ? void 0 : ariaLabel,
|
|
7581
|
+
children: [
|
|
7582
|
+
(title || description || actions) && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "kjun-list-heading", children: [
|
|
7583
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { children: [
|
|
7584
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("h3", { id, children: title }),
|
|
7585
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { children: description })
|
|
7586
|
+
] }),
|
|
7587
|
+
actions
|
|
7588
|
+
] }),
|
|
7589
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("ul", { className: "kjun-list", "aria-label": ariaLabel || title, "data-divider": divider ? void 0 : "false", "data-density": density === "compact" ? "compact" : void 0, children })
|
|
7590
|
+
]
|
|
7591
|
+
}
|
|
7592
|
+
);
|
|
7525
7593
|
}
|
|
7526
7594
|
function KjunListItem({ children }) {
|
|
7527
7595
|
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("li", { className: "kjun-list-item", children });
|
package/dist/index.js
CHANGED
|
@@ -3031,7 +3031,9 @@ function FloatingPanel({
|
|
|
3031
3031
|
flip = true,
|
|
3032
3032
|
nonModal = false,
|
|
3033
3033
|
ownsDismiss = false,
|
|
3034
|
-
returnFocus
|
|
3034
|
+
returnFocus,
|
|
3035
|
+
repositionKey = 0,
|
|
3036
|
+
inside
|
|
3035
3037
|
}) {
|
|
3036
3038
|
const motion = usePresence(open, useReducedMotion(), tokens14.motion.popupExit);
|
|
3037
3039
|
const layer = useLayer(open, motion.present, "popup", () => onOpenChange(false), triggerRef, returnFocus);
|
|
@@ -3066,12 +3068,17 @@ function FloatingPanel({
|
|
|
3066
3068
|
if (next) onOpenChange(next);
|
|
3067
3069
|
} : onOpenChange,
|
|
3068
3070
|
triggerRef,
|
|
3071
|
+
shouldCloseOnInteractOutside: inside ? (element) => {
|
|
3072
|
+
var _a;
|
|
3073
|
+
return !((_a = inside.current) == null ? void 0 : _a.contains(element));
|
|
3074
|
+
} : void 0,
|
|
3069
3075
|
UNSTABLE_portalContainer: container,
|
|
3070
3076
|
placement: placement.replace("-", " "),
|
|
3071
3077
|
shouldFlip: flip,
|
|
3072
3078
|
maxHeight: typeof maxHeight === "number" ? maxHeight : maxHeight == null ? field ? tokens14.extensions.menu.listMaxHeight : tokens14.extensions.floating.maxHeight : void 0,
|
|
3073
3079
|
offset: field ? tokens14.extensions.floating.fieldGap : tokens14.extensions.floating.anchorGap,
|
|
3074
3080
|
containerPadding: tokens14.extensions.floating.viewportInset,
|
|
3081
|
+
crossOffset: repositionKey % 2 ? 1e-3 : 0,
|
|
3075
3082
|
className: "kjun-scope kjun-floating " + className,
|
|
3076
3083
|
"data-motion": "popup",
|
|
3077
3084
|
"data-motion-open": String(motion.active),
|
|
@@ -3086,9 +3093,34 @@ function FloatingPanel({
|
|
|
3086
3093
|
}
|
|
3087
3094
|
var resolveFocusReturn = (target) => target === void 0 ? void 0 : () => typeof target === "function" ? target() : target instanceof HTMLElement ? target : target.current;
|
|
3088
3095
|
|
|
3096
|
+
// shared/package-runtime/anchor-rect.ts
|
|
3097
|
+
function place(element, rect) {
|
|
3098
|
+
var _a, _b;
|
|
3099
|
+
const next = [rect.x, rect.y, (_a = rect.width) != null ? _a : 0, (_b = rect.height) != null ? _b : 0].map((value) => value + "px");
|
|
3100
|
+
const style = element.style;
|
|
3101
|
+
if (style.left === next[0] && style.top === next[1] && style.width === next[2] && style.height === next[3]) return false;
|
|
3102
|
+
[style.left, style.top, style.width, style.height] = next;
|
|
3103
|
+
return true;
|
|
3104
|
+
}
|
|
3105
|
+
function followAnchor(element, source, moved) {
|
|
3106
|
+
let frame = 0, stopped = false;
|
|
3107
|
+
const step = () => {
|
|
3108
|
+
const current = source();
|
|
3109
|
+
const rect = typeof current === "function" ? current() : current;
|
|
3110
|
+
if (rect && place(element, rect)) moved();
|
|
3111
|
+
if (!stopped && typeof current === "function") frame = requestAnimationFrame(step);
|
|
3112
|
+
};
|
|
3113
|
+
step();
|
|
3114
|
+
return () => {
|
|
3115
|
+
stopped = true;
|
|
3116
|
+
cancelAnimationFrame(frame);
|
|
3117
|
+
};
|
|
3118
|
+
}
|
|
3119
|
+
var anchorStyle = { position: "fixed", pointerEvents: "none", visibility: "hidden" };
|
|
3120
|
+
|
|
3089
3121
|
// packages/react/src/popover.tsx
|
|
3090
3122
|
import { tokens as tokens15 } from "@kjun-ui/tokens";
|
|
3091
|
-
import { useCallback as useCallback4, useEffect as useEffect8, useId as useId6, useRef as useRef16, useState as useState10 } from "react";
|
|
3123
|
+
import { useCallback as useCallback4, useEffect as useEffect8, useId as useId6, useLayoutEffect as useLayoutEffect10, useRef as useRef16, useState as useState10 } from "react";
|
|
3092
3124
|
import { Dialog as Dialog2, Focusable, OverlayArrow, Tooltip, TooltipTrigger } from "react-aria-components";
|
|
3093
3125
|
|
|
3094
3126
|
// shared/package-runtime/popover-nonmodal.ts
|
|
@@ -3166,6 +3198,7 @@ function KjunPopover({
|
|
|
3166
3198
|
returnFocus,
|
|
3167
3199
|
header,
|
|
3168
3200
|
modal = true,
|
|
3201
|
+
anchorRect,
|
|
3169
3202
|
trigger,
|
|
3170
3203
|
children
|
|
3171
3204
|
}) {
|
|
@@ -3178,6 +3211,17 @@ function KjunPopover({
|
|
|
3178
3211
|
if (node && focusOnMount.current) node.focus();
|
|
3179
3212
|
}, []);
|
|
3180
3213
|
const resolveReturn = resolveFocusReturn(returnFocus);
|
|
3214
|
+
const anchor = useRef16(null), anchorSource = useRef16(anchorRect), opener = useRef16(null);
|
|
3215
|
+
anchorSource.current = anchorRect;
|
|
3216
|
+
const [reposition, setReposition] = useState10(0);
|
|
3217
|
+
const anchored = anchorRect !== void 0;
|
|
3218
|
+
const wasOpen = useRef16(false);
|
|
3219
|
+
if (open && !wasOpen.current && typeof document !== "undefined") opener.current = document.activeElement;
|
|
3220
|
+
wasOpen.current = open;
|
|
3221
|
+
useLayoutEffect10(() => {
|
|
3222
|
+
if (!open || !anchored || !anchor.current) return;
|
|
3223
|
+
return followAnchor(anchor.current, () => anchorSource.current, () => setReposition((n) => n + 1));
|
|
3224
|
+
}, [open, anchored, typeof anchorRect === "function" ? anchorRect : anchorRect && `${anchorRect.x},${anchorRect.y},${anchorRect.width},${anchorRect.height}`]);
|
|
3181
3225
|
const change = (v) => {
|
|
3182
3226
|
setInternal(v);
|
|
3183
3227
|
onOpenChange == null ? void 0 : onOpenChange(v);
|
|
@@ -3200,7 +3244,8 @@ function KjunPopover({
|
|
|
3200
3244
|
});
|
|
3201
3245
|
const content = /* @__PURE__ */ jsx16("div", { className: "kjun-popover-content", "data-no-padding": noPadding, children: typeof children === "function" ? children(() => change(false)) : children });
|
|
3202
3246
|
return /* @__PURE__ */ jsxs10(Fragment4, { children: [
|
|
3203
|
-
/* @__PURE__ */ jsx16(
|
|
3247
|
+
anchored && /* @__PURE__ */ jsx16("div", { ref: anchor, "aria-hidden": "true", style: anchorStyle }),
|
|
3248
|
+
(!anchored || trigger != null) && /* @__PURE__ */ jsx16(
|
|
3204
3249
|
"div",
|
|
3205
3250
|
{
|
|
3206
3251
|
ref,
|
|
@@ -3225,13 +3270,18 @@ function KjunPopover({
|
|
|
3225
3270
|
{
|
|
3226
3271
|
open,
|
|
3227
3272
|
onOpenChange: change,
|
|
3228
|
-
triggerRef: ref,
|
|
3273
|
+
triggerRef: anchored ? anchor : ref,
|
|
3274
|
+
inside: anchored ? ref : void 0,
|
|
3275
|
+
repositionKey: reposition,
|
|
3229
3276
|
className: "kjun-content-popover" + (header != null ? " kjun-popover-has-header" : ""),
|
|
3230
3277
|
placement,
|
|
3231
3278
|
matchTriggerWidth,
|
|
3232
3279
|
maxHeight,
|
|
3233
3280
|
flip,
|
|
3234
|
-
returnFocus: () =>
|
|
3281
|
+
returnFocus: () => {
|
|
3282
|
+
var _a;
|
|
3283
|
+
return skipReturn.current ? false : (_a = resolveReturn == null ? void 0 : resolveReturn()) != null ? _a : anchored && trigger == null ? opener.current : void 0;
|
|
3284
|
+
},
|
|
3235
3285
|
nonModal: !modal,
|
|
3236
3286
|
ownsDismiss: !modal,
|
|
3237
3287
|
children: (() => {
|
|
@@ -3255,6 +3305,9 @@ function KjunPopover({
|
|
|
3255
3305
|
}
|
|
3256
3306
|
function KjunTooltip({
|
|
3257
3307
|
content = "",
|
|
3308
|
+
title,
|
|
3309
|
+
align,
|
|
3310
|
+
width,
|
|
3258
3311
|
placement = "top",
|
|
3259
3312
|
delay = 0,
|
|
3260
3313
|
open: controlled,
|
|
@@ -3268,19 +3321,23 @@ function KjunTooltip({
|
|
|
3268
3321
|
onOpenChange == null ? void 0 : onOpenChange(value);
|
|
3269
3322
|
};
|
|
3270
3323
|
const layer = useLayer(open, open, "tooltip", () => setOpen(false));
|
|
3271
|
-
return /* @__PURE__ */ jsxs10(TooltipTrigger, { isOpen: open && !layer.blocked, onOpenChange: setOpen, delay, closeDelay: 0, isDisabled: !content || !layer.scopeActive, children: [
|
|
3324
|
+
return /* @__PURE__ */ jsxs10(TooltipTrigger, { isOpen: open && !layer.blocked && !!(content || title), onOpenChange: setOpen, delay, closeDelay: 0, isDisabled: !content && !title || !layer.scopeActive, children: [
|
|
3272
3325
|
/* @__PURE__ */ jsx16(Focusable, { children }),
|
|
3273
3326
|
container !== null && /* @__PURE__ */ jsxs10(
|
|
3274
3327
|
Tooltip,
|
|
3275
3328
|
{
|
|
3276
|
-
style: { zIndex: layer.zIndex },
|
|
3329
|
+
style: { zIndex: layer.zIndex, ...width ? { maxWidth: `var(--_kjun-extension-tooltip-max-widths-${width})` } : {} },
|
|
3330
|
+
"data-align": align,
|
|
3277
3331
|
UNSTABLE_portalContainer: container,
|
|
3278
3332
|
placement,
|
|
3279
3333
|
offset: tokens15.extensions.floating.anchorGap,
|
|
3280
3334
|
className: "kjun-scope kjun-tooltip",
|
|
3281
3335
|
children: [
|
|
3282
3336
|
/* @__PURE__ */ jsx16(OverlayArrow, { children: /* @__PURE__ */ jsx16("svg", { width: tokens15.extensions.tooltip.arrowSize, height: tokens15.extensions.tooltip.arrowSize, viewBox: "0 0 8 8", children: /* @__PURE__ */ jsx16("path", { d: "M0 0L4 4L8 0", fill: "currentColor" }) }) }),
|
|
3283
|
-
|
|
3337
|
+
title ? /* @__PURE__ */ jsxs10(Fragment4, { children: [
|
|
3338
|
+
/* @__PURE__ */ jsx16("span", { className: "kjun-tooltip-title", children: title }),
|
|
3339
|
+
content && /* @__PURE__ */ jsx16("span", { className: "kjun-tooltip-body", children: content })
|
|
3340
|
+
] }) : content
|
|
3284
3341
|
]
|
|
3285
3342
|
}
|
|
3286
3343
|
)
|
|
@@ -4076,7 +4133,7 @@ function KjunDatePicker({
|
|
|
4076
4133
|
import { useState as useState16 } from "react";
|
|
4077
4134
|
|
|
4078
4135
|
// shared/package-runtime/search-input.ts
|
|
4079
|
-
import { useEffect as useEffect12, useLayoutEffect as
|
|
4136
|
+
import { useEffect as useEffect12, useLayoutEffect as useLayoutEffect11, useRef as useRef19, useState as useState15 } from "react";
|
|
4080
4137
|
function useSearchInputModel({
|
|
4081
4138
|
value,
|
|
4082
4139
|
disabled = false,
|
|
@@ -4091,11 +4148,11 @@ function useSearchInputModel({
|
|
|
4091
4148
|
const timer = useRef19(void 0);
|
|
4092
4149
|
const notifyValue = useRef19(onValueChange);
|
|
4093
4150
|
notifyValue.current = onValueChange;
|
|
4094
|
-
|
|
4151
|
+
useLayoutEffect11(() => {
|
|
4095
4152
|
clearTimeout(timer.current);
|
|
4096
4153
|
setQuery(value);
|
|
4097
4154
|
}, [value]);
|
|
4098
|
-
|
|
4155
|
+
useLayoutEffect11(() => {
|
|
4099
4156
|
clearTimeout(timer.current);
|
|
4100
4157
|
return () => clearTimeout(timer.current);
|
|
4101
4158
|
}, [disabled, debounce, !!loadOptions]);
|
|
@@ -4539,7 +4596,7 @@ import { tokens as tokens21 } from "@kjun-ui/tokens";
|
|
|
4539
4596
|
|
|
4540
4597
|
// packages/react/src/collapse.tsx
|
|
4541
4598
|
import { tokens as tokens20 } from "@kjun-ui/tokens";
|
|
4542
|
-
import { useLayoutEffect as
|
|
4599
|
+
import { useLayoutEffect as useLayoutEffect12, useRef as useRef22, useState as useState18 } from "react";
|
|
4543
4600
|
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
4544
4601
|
function Collapse({ open, keepMounted = false, children }) {
|
|
4545
4602
|
const reduced = useReducedMotion();
|
|
@@ -4551,7 +4608,7 @@ function Collapse({ open, keepMounted = false, children }) {
|
|
|
4551
4608
|
const opened = useRef22(open);
|
|
4552
4609
|
if (open) opened.current = true;
|
|
4553
4610
|
const present = open || retained || keepMounted && opened.current;
|
|
4554
|
-
|
|
4611
|
+
useLayoutEffect12(() => {
|
|
4555
4612
|
const el = root.current, inner = body.current;
|
|
4556
4613
|
if (!el || !inner) return;
|
|
4557
4614
|
let disposed = false;
|
|
@@ -4712,7 +4769,7 @@ import {
|
|
|
4712
4769
|
isValidElement as isValidElement3,
|
|
4713
4770
|
useContext as useContext13,
|
|
4714
4771
|
useEffect as useEffect16,
|
|
4715
|
-
useLayoutEffect as
|
|
4772
|
+
useLayoutEffect as useLayoutEffect13,
|
|
4716
4773
|
useId as useId10,
|
|
4717
4774
|
useRef as useRef24,
|
|
4718
4775
|
useState as useState20
|
|
@@ -4739,13 +4796,13 @@ function KjunTabs({
|
|
|
4739
4796
|
isValidElement3
|
|
4740
4797
|
);
|
|
4741
4798
|
const tabs = items.length ? items : panes.filter((child) => child.type === KjunTabPane).map((child) => child.props);
|
|
4742
|
-
|
|
4799
|
+
useLayoutEffect13(() => {
|
|
4743
4800
|
var _a2;
|
|
4744
4801
|
const list = (_a2 = group.current) == null ? void 0 : _a2.querySelector('[role="tablist"]');
|
|
4745
4802
|
if (list) return manageTabList(list, () => {
|
|
4746
4803
|
}, false);
|
|
4747
4804
|
}, [group]);
|
|
4748
|
-
|
|
4805
|
+
useLayoutEffect13(() => {
|
|
4749
4806
|
var _a2;
|
|
4750
4807
|
const panelNames = new Set(panes.filter((child) => child.type === KjunTabPane).map((child) => child.props.name));
|
|
4751
4808
|
for (const tab of ((_a2 = group.current) == null ? void 0 : _a2.querySelectorAll('[role="tab"]')) || []) {
|
|
@@ -4761,7 +4818,7 @@ function KjunTabs({
|
|
|
4761
4818
|
press.current = null;
|
|
4762
4819
|
};
|
|
4763
4820
|
useEffect16(() => clear, []);
|
|
4764
|
-
|
|
4821
|
+
useLayoutEffect13(() => {
|
|
4765
4822
|
if (press.current && !canOpenMenu(press.current.name)) clear();
|
|
4766
4823
|
}, [tabs, onTabMenu]);
|
|
4767
4824
|
const change = (name) => {
|
|
@@ -5655,7 +5712,7 @@ import {
|
|
|
5655
5712
|
import { tokens as tokens28 } from "@kjun-ui/tokens";
|
|
5656
5713
|
|
|
5657
5714
|
// shared/package-runtime/use-number-motion.ts
|
|
5658
|
-
import { useLayoutEffect as
|
|
5715
|
+
import { useLayoutEffect as useLayoutEffect14, useRef as useRef26, useState as useState24 } from "react";
|
|
5659
5716
|
|
|
5660
5717
|
// shared/package-runtime/number-motion.ts
|
|
5661
5718
|
import { tokens as tokens27 } from "@kjun-ui/tokens";
|
|
@@ -5704,11 +5761,11 @@ function useNumberMotion(value, animated, fromPrevious, reduced) {
|
|
|
5704
5761
|
const [display, setDisplay] = useState24(typeof value === "string" || fromPrevious || !animated || reduced ? value : 0);
|
|
5705
5762
|
const motion = useRef26(null);
|
|
5706
5763
|
if (!motion.current) motion.current = createNumberMotion(setDisplay);
|
|
5707
|
-
|
|
5764
|
+
useLayoutEffect14(() => {
|
|
5708
5765
|
if (!motion.current) motion.current = createNumberMotion(setDisplay);
|
|
5709
5766
|
motion.current.update(value, animated, fromPrevious, reduced);
|
|
5710
5767
|
}, [value, animated, fromPrevious, reduced]);
|
|
5711
|
-
|
|
5768
|
+
useLayoutEffect14(() => () => {
|
|
5712
5769
|
var _a;
|
|
5713
5770
|
(_a = motion.current) == null ? void 0 : _a.cancel();
|
|
5714
5771
|
motion.current = null;
|
|
@@ -7470,18 +7527,29 @@ function KjunListRow({ title, description, leading, trailing, actions, href, dis
|
|
|
7470
7527
|
actions && /* @__PURE__ */ jsx43("div", { className: "kjun-list-actions", "data-disabled": disabled || void 0, inert: disabled || void 0, children: actions })
|
|
7471
7528
|
] });
|
|
7472
7529
|
}
|
|
7473
|
-
function KjunListSection({ title, description, actions, children, ariaLabel, surface = true, divider = true, density = "default" }) {
|
|
7530
|
+
function KjunListSection({ title, description, actions, children, ariaLabel, surface = true, divider = true, density = "default", radius = "none" }) {
|
|
7474
7531
|
const id = "kjun-" + useId12();
|
|
7475
|
-
return /* @__PURE__ */ jsxs35(
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7484
|
-
|
|
7532
|
+
return /* @__PURE__ */ jsxs35(
|
|
7533
|
+
"section",
|
|
7534
|
+
{
|
|
7535
|
+
className: "kjun-list-section",
|
|
7536
|
+
"data-surface": surface ? void 0 : "false",
|
|
7537
|
+
"data-radius": radius === "none" ? void 0 : radius,
|
|
7538
|
+
style: radius === "none" ? void 0 : { borderRadius: `var(--_kjun-geometry-card-radii-${radius})` },
|
|
7539
|
+
"aria-labelledby": title ? id : void 0,
|
|
7540
|
+
"aria-label": title ? void 0 : ariaLabel,
|
|
7541
|
+
children: [
|
|
7542
|
+
(title || description || actions) && /* @__PURE__ */ jsxs35("div", { className: "kjun-list-heading", children: [
|
|
7543
|
+
/* @__PURE__ */ jsxs35("div", { children: [
|
|
7544
|
+
title && /* @__PURE__ */ jsx43("h3", { id, children: title }),
|
|
7545
|
+
description && /* @__PURE__ */ jsx43("p", { children: description })
|
|
7546
|
+
] }),
|
|
7547
|
+
actions
|
|
7548
|
+
] }),
|
|
7549
|
+
/* @__PURE__ */ jsx43("ul", { className: "kjun-list", "aria-label": ariaLabel || title, "data-divider": divider ? void 0 : "false", "data-density": density === "compact" ? "compact" : void 0, children })
|
|
7550
|
+
]
|
|
7551
|
+
}
|
|
7552
|
+
);
|
|
7485
7553
|
}
|
|
7486
7554
|
function KjunListItem({ children }) {
|
|
7487
7555
|
return /* @__PURE__ */ jsx43("li", { className: "kjun-list-item", children });
|
package/dist/styles.css
CHANGED
|
@@ -79,6 +79,8 @@
|
|
|
79
79
|
--_kjun-color-selected-bg: var(--kjun-selected-bg, var(--kjun-active));
|
|
80
80
|
--_kjun-color-on-brand: var(--kjun-on-brand, var(--kjun-inverse));
|
|
81
81
|
--_kjun-color-switch-thumb-on: var(--kjun-switch-thumb-on, var(--kjun-on-brand, var(--kjun-inverse)));
|
|
82
|
+
--_kjun-color-filter-selected-bg: var(--kjun-filter-selected-bg, var(--kjun-text));
|
|
83
|
+
--_kjun-color-filter-selected-text: var(--kjun-filter-selected-text, var(--kjun-inverse));
|
|
82
84
|
--_kjun-color-on-danger: var(--kjun-on-danger, var(--kjun-inverse));
|
|
83
85
|
--_kjun-color-on-success: var(--kjun-on-success, var(--kjun-inverse));
|
|
84
86
|
--_kjun-color-on-warning: var(--kjun-on-warning, var(--kjun-inverse));
|
|
@@ -182,6 +184,8 @@
|
|
|
182
184
|
--_kjun-selected-bg: var(--_kjun-color-selected-bg);
|
|
183
185
|
--_kjun-on-brand: var(--_kjun-color-on-brand);
|
|
184
186
|
--_kjun-switch-thumb-on: var(--_kjun-color-switch-thumb-on);
|
|
187
|
+
--_kjun-filter-selected-bg: var(--_kjun-color-filter-selected-bg);
|
|
188
|
+
--_kjun-filter-selected-text: var(--_kjun-color-filter-selected-text);
|
|
185
189
|
--_kjun-on-danger: var(--_kjun-color-on-danger);
|
|
186
190
|
--_kjun-on-success: var(--_kjun-color-on-success);
|
|
187
191
|
--_kjun-on-warning: var(--_kjun-color-on-warning);
|
|
@@ -532,6 +536,9 @@
|
|
|
532
536
|
--_kjun-extension-switch-label-gap: 8px;
|
|
533
537
|
--_kjun-extension-tooltip-padding-x: 8px;
|
|
534
538
|
--_kjun-extension-tooltip-padding-y: 4px;
|
|
539
|
+
--_kjun-extension-tooltip-max-widths-sm: 192px;
|
|
540
|
+
--_kjun-extension-tooltip-max-widths-md: 256px;
|
|
541
|
+
--_kjun-extension-tooltip-max-widths-lg: 320px;
|
|
535
542
|
--_kjun-extension-tooltip-max-width: 256px;
|
|
536
543
|
--_kjun-extension-tooltip-arrow-size: 8px;
|
|
537
544
|
--_kjun-extension-financial-affix-gap: 4px;
|
|
@@ -833,6 +840,7 @@
|
|
|
833
840
|
--_kjun-geometry-card-radii-sm: 8px;
|
|
834
841
|
--_kjun-geometry-card-radii-md: 12px;
|
|
835
842
|
--_kjun-geometry-card-radii-lg: 16px;
|
|
843
|
+
--_kjun-geometry-card-radii-xl: 24px;
|
|
836
844
|
--_kjun-geometry-card-subtitle-gap: 4px;
|
|
837
845
|
--_kjun-geometry-card-title-gap: 8px;
|
|
838
846
|
--_kjun-geometry-card-glass-blur: 10px;
|
|
@@ -882,6 +890,7 @@
|
|
|
882
890
|
--_kjun-geometry-radius-radius9999: 9999px;
|
|
883
891
|
--_kjun-geometry-radius-radius14: 14px;
|
|
884
892
|
--_kjun-geometry-radius-radius20: 20px;
|
|
893
|
+
--_kjun-geometry-radius-radius24: 24px;
|
|
885
894
|
--_kjun-geometry-native-minimum-touch-target: 44px;
|
|
886
895
|
--_kjun-geometry-space-inline-xs: 4px;
|
|
887
896
|
--_kjun-geometry-space-inline-sm: 8px;
|
|
@@ -2421,8 +2430,8 @@
|
|
|
2421
2430
|
white-space: nowrap;
|
|
2422
2431
|
}
|
|
2423
2432
|
.kjun-filter-chip[aria-pressed="true"] > span {
|
|
2424
|
-
background: var(--_kjun-color-
|
|
2425
|
-
color: var(--_kjun-color-
|
|
2433
|
+
background: var(--_kjun-color-filter-selected-bg);
|
|
2434
|
+
color: var(--_kjun-color-filter-selected-text);
|
|
2426
2435
|
font-weight: var(--_kjun-type-control-weight);
|
|
2427
2436
|
}
|
|
2428
2437
|
.kjun-filter-chip:disabled {
|
|
@@ -2520,6 +2529,17 @@
|
|
|
2520
2529
|
font-weight: var(--_kjun-type-caption-weight);
|
|
2521
2530
|
letter-spacing: var(--_kjun-type-caption-tracking);
|
|
2522
2531
|
}
|
|
2532
|
+
/* Title above the body: a bolder small role in the same tooltip text color. */
|
|
2533
|
+
.kjun-tooltip-title {
|
|
2534
|
+
display: block;
|
|
2535
|
+
font-size: var(--_kjun-type-control-small-size);
|
|
2536
|
+
line-height: var(--_kjun-type-control-small-line);
|
|
2537
|
+
font-weight: var(--_kjun-type-control-small-weight);
|
|
2538
|
+
letter-spacing: var(--_kjun-type-control-small-tracking);
|
|
2539
|
+
}
|
|
2540
|
+
.kjun-tooltip-body { display: block; }
|
|
2541
|
+
.kjun-tooltip[data-align="start"] { text-align: start; }
|
|
2542
|
+
.kjun-tooltip[data-align="center"] { text-align: center; }
|
|
2523
2543
|
.kjun-tooltip svg {
|
|
2524
2544
|
display: block;
|
|
2525
2545
|
color: var(--_kjun-color-chart-tooltip-bg);
|
|
@@ -5023,6 +5043,9 @@
|
|
|
5023
5043
|
|
|
5024
5044
|
/* 0.14.0: plain sections, destructive rows, decorative chevrons and non-row list items share the row inset. */
|
|
5025
5045
|
.kjun-list-section[data-surface="false"]{background:transparent}
|
|
5046
|
+
/* A rounded section clips its rows to the corners; row focus rings move inside so the clip does not cut them. */
|
|
5047
|
+
.kjun-list-section[data-radius]{overflow:hidden;overflow:clip}
|
|
5048
|
+
.kjun-list-section[data-radius] .kjun-list-main:focus-visible{outline-offset:var(--_kjun-state-focus-inset-offset)}
|
|
5026
5049
|
.kjun-list-row[data-destructive] .kjun-list-title{color:var(--_kjun-color-danger)}
|
|
5027
5050
|
.kjun-list-chevron{flex-shrink:0;color:var(--_kjun-color-text-tertiary)}
|
|
5028
5051
|
.kjun-list-item{padding:var(--_kjun-extension-list-padding);border-bottom:var(--_kjun-border-default-width) solid var(--_kjun-color-divider);min-width:0}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactNode, type RefObject } from "react";
|
|
2
2
|
export type Placement = "top" | "bottom" | "left" | "right" | "bottom-start" | "bottom-end" | "top-start" | "top-end";
|
|
3
|
-
export declare function FloatingPanel({ open, onOpenChange, triggerRef, children, placement, className, matchTriggerWidth, maxHeight, field, flip, nonModal, ownsDismiss, returnFocus, }: {
|
|
3
|
+
export declare function FloatingPanel({ open, onOpenChange, triggerRef, children, placement, className, matchTriggerWidth, maxHeight, field, flip, nonModal, ownsDismiss, returnFocus, repositionKey, inside, }: {
|
|
4
4
|
open: boolean;
|
|
5
5
|
onOpenChange: (v: boolean) => void;
|
|
6
6
|
triggerRef: RefObject<HTMLElement | null>;
|
|
@@ -15,6 +15,10 @@ export declare function FloatingPanel({ open, onOpenChange, triggerRef, children
|
|
|
15
15
|
/** The consumer closes the panel itself (non-modal Popover); ignore react-aria's own close requests. */
|
|
16
16
|
ownsDismiss?: boolean;
|
|
17
17
|
returnFocus?: () => HTMLElement | null | false | undefined;
|
|
18
|
+
/** Changing it makes react-aria place the panel again (it does not watch its trigger move). */
|
|
19
|
+
repositionKey?: number;
|
|
20
|
+
/** Another element that counts as inside (an anchored Popover's trigger area): pressing it is not an outside press. */
|
|
21
|
+
inside?: RefObject<HTMLElement | null>;
|
|
18
22
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
19
23
|
/** A focus target given as an element, a ref or a function read when the panel closes. */
|
|
20
24
|
export type FocusReturn = HTMLElement | RefObject<HTMLElement | null> | (() => HTMLElement | null);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactNode, type RefObject } from "react";
|
|
2
2
|
export type Placement = "top" | "bottom" | "left" | "right" | "bottom-start" | "bottom-end" | "top-start" | "top-end";
|
|
3
|
-
export declare function FloatingPanel({ open, onOpenChange, triggerRef, children, placement, className, matchTriggerWidth, maxHeight, field, flip, nonModal, ownsDismiss, returnFocus, }: {
|
|
3
|
+
export declare function FloatingPanel({ open, onOpenChange, triggerRef, children, placement, className, matchTriggerWidth, maxHeight, field, flip, nonModal, ownsDismiss, returnFocus, repositionKey, inside, }: {
|
|
4
4
|
open: boolean;
|
|
5
5
|
onOpenChange: (v: boolean) => void;
|
|
6
6
|
triggerRef: RefObject<HTMLElement | null>;
|
|
@@ -15,6 +15,10 @@ export declare function FloatingPanel({ open, onOpenChange, triggerRef, children
|
|
|
15
15
|
/** The consumer closes the panel itself (non-modal Popover); ignore react-aria's own close requests. */
|
|
16
16
|
ownsDismiss?: boolean;
|
|
17
17
|
returnFocus?: () => HTMLElement | null | false | undefined;
|
|
18
|
+
/** Changing it makes react-aria place the panel again (it does not watch its trigger move). */
|
|
19
|
+
repositionKey?: number;
|
|
20
|
+
/** Another element that counts as inside (an anchored Popover's trigger area): pressing it is not an outside press. */
|
|
21
|
+
inside?: RefObject<HTMLElement | null>;
|
|
18
22
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
19
23
|
/** A focus target given as an element, a ref or a function read when the panel closes. */
|
|
20
24
|
export type FocusReturn = HTMLElement | RefObject<HTMLElement | null> | (() => HTMLElement | null);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CardRadius } from "@kjun-ui/tokens";
|
|
1
2
|
import { type MouseEvent, type ReactNode } from "react";
|
|
2
3
|
export interface KjunListRowProps {
|
|
3
4
|
title: string;
|
|
@@ -30,8 +31,10 @@ export interface KjunListSectionProps {
|
|
|
30
31
|
divider?: boolean;
|
|
31
32
|
/** "compact" rows keep the 16px inset but are 44 tall (the touch minimum) instead of 56. */
|
|
32
33
|
density?: "default" | "compact";
|
|
34
|
+
/** Rounds the section on the card radius steps and clips its rows to the corners (default "none"). */
|
|
35
|
+
radius?: CardRadius;
|
|
33
36
|
}
|
|
34
|
-
export declare function KjunListSection({ title, description, actions, children, ariaLabel, surface, divider, density }: KjunListSectionProps): import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
export declare function KjunListSection({ title, description, actions, children, ariaLabel, surface, divider, density, radius }: KjunListSectionProps): import("react/jsx-runtime").JSX.Element;
|
|
35
38
|
export interface KjunListItemProps {
|
|
36
39
|
children: ReactNode;
|
|
37
40
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CardRadius } from "@kjun-ui/tokens";
|
|
1
2
|
import { type MouseEvent, type ReactNode } from "react";
|
|
2
3
|
export interface KjunListRowProps {
|
|
3
4
|
title: string;
|
|
@@ -30,8 +31,10 @@ export interface KjunListSectionProps {
|
|
|
30
31
|
divider?: boolean;
|
|
31
32
|
/** "compact" rows keep the 16px inset but are 44 tall (the touch minimum) instead of 56. */
|
|
32
33
|
density?: "default" | "compact";
|
|
34
|
+
/** Rounds the section on the card radius steps and clips its rows to the corners (default "none"). */
|
|
35
|
+
radius?: CardRadius;
|
|
33
36
|
}
|
|
34
|
-
export declare function KjunListSection({ title, description, actions, children, ariaLabel, surface, divider, density }: KjunListSectionProps): import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
export declare function KjunListSection({ title, description, actions, children, ariaLabel, surface, divider, density, radius }: KjunListSectionProps): import("react/jsx-runtime").JSX.Element;
|
|
35
38
|
export interface KjunListItemProps {
|
|
36
39
|
children: ReactNode;
|
|
37
40
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type AnchorSource } from "../../../shared/package-runtime/anchor-rect.cjs";
|
|
1
2
|
import { type CSSProperties, type ReactNode, type RefObject } from "react";
|
|
2
3
|
export interface KjunPopoverProps {
|
|
3
4
|
noPadding?: boolean;
|
|
@@ -16,12 +17,20 @@ export interface KjunPopoverProps {
|
|
|
16
17
|
header?: ReactNode;
|
|
17
18
|
/** false keeps the page usable: Tab can leave, and an outside press or focus move closes without returning focus. */
|
|
18
19
|
modal?: boolean;
|
|
19
|
-
|
|
20
|
+
/** Attach to this screen rectangle (or a function read every frame while open) instead of the trigger. Web only.
|
|
21
|
+
* The trigger becomes optional; presses inside it still count as inside a non-modal Popover. */
|
|
22
|
+
anchorRect?: AnchorSource;
|
|
23
|
+
trigger?: ReactNode | ((open: boolean) => ReactNode);
|
|
20
24
|
children: ReactNode | ((close: () => void) => ReactNode);
|
|
21
25
|
}
|
|
22
|
-
export declare function KjunPopover({ noPadding, open: controlled, onOpenChange, manualTrigger, matchTriggerWidth, maxHeight, flip, focusOnOpen, ariaLabel, placement, returnFocus, header, modal, trigger, children, }: KjunPopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export declare function KjunPopover({ noPadding, open: controlled, onOpenChange, manualTrigger, matchTriggerWidth, maxHeight, flip, focusOnOpen, ariaLabel, placement, returnFocus, header, modal, anchorRect, trigger, children, }: KjunPopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
23
27
|
export interface KjunTooltipProps {
|
|
24
28
|
content?: string;
|
|
29
|
+
/** A bolder line above content (a file name above its path). Read together with content. */
|
|
30
|
+
title?: string;
|
|
31
|
+
align?: "start" | "center";
|
|
32
|
+
/** Maximum width step (tooltip.maxWidths); default is md, the earlier width. */
|
|
33
|
+
width?: "sm" | "md" | "lg";
|
|
25
34
|
placement?: "top" | "bottom" | "left" | "right";
|
|
26
35
|
delay?: number;
|
|
27
36
|
/** Controlled visibility; omit to let hover and focus drive it. */
|
|
@@ -29,4 +38,4 @@ export interface KjunTooltipProps {
|
|
|
29
38
|
onOpenChange?: (open: boolean) => void;
|
|
30
39
|
children: ReactNode;
|
|
31
40
|
}
|
|
32
|
-
export declare function KjunTooltip({ content, placement, delay, open: controlled, onOpenChange, children, }: KjunTooltipProps): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
export declare function KjunTooltip({ content, title, align, width, placement, delay, open: controlled, onOpenChange, children, }: KjunTooltipProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type AnchorSource } from "../../../shared/package-runtime/anchor-rect.js";
|
|
1
2
|
import { type CSSProperties, type ReactNode, type RefObject } from "react";
|
|
2
3
|
export interface KjunPopoverProps {
|
|
3
4
|
noPadding?: boolean;
|
|
@@ -16,12 +17,20 @@ export interface KjunPopoverProps {
|
|
|
16
17
|
header?: ReactNode;
|
|
17
18
|
/** false keeps the page usable: Tab can leave, and an outside press or focus move closes without returning focus. */
|
|
18
19
|
modal?: boolean;
|
|
19
|
-
|
|
20
|
+
/** Attach to this screen rectangle (or a function read every frame while open) instead of the trigger. Web only.
|
|
21
|
+
* The trigger becomes optional; presses inside it still count as inside a non-modal Popover. */
|
|
22
|
+
anchorRect?: AnchorSource;
|
|
23
|
+
trigger?: ReactNode | ((open: boolean) => ReactNode);
|
|
20
24
|
children: ReactNode | ((close: () => void) => ReactNode);
|
|
21
25
|
}
|
|
22
|
-
export declare function KjunPopover({ noPadding, open: controlled, onOpenChange, manualTrigger, matchTriggerWidth, maxHeight, flip, focusOnOpen, ariaLabel, placement, returnFocus, header, modal, trigger, children, }: KjunPopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export declare function KjunPopover({ noPadding, open: controlled, onOpenChange, manualTrigger, matchTriggerWidth, maxHeight, flip, focusOnOpen, ariaLabel, placement, returnFocus, header, modal, anchorRect, trigger, children, }: KjunPopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
23
27
|
export interface KjunTooltipProps {
|
|
24
28
|
content?: string;
|
|
29
|
+
/** A bolder line above content (a file name above its path). Read together with content. */
|
|
30
|
+
title?: string;
|
|
31
|
+
align?: "start" | "center";
|
|
32
|
+
/** Maximum width step (tooltip.maxWidths); default is md, the earlier width. */
|
|
33
|
+
width?: "sm" | "md" | "lg";
|
|
25
34
|
placement?: "top" | "bottom" | "left" | "right";
|
|
26
35
|
delay?: number;
|
|
27
36
|
/** Controlled visibility; omit to let hover and focus drive it. */
|
|
@@ -29,4 +38,4 @@ export interface KjunTooltipProps {
|
|
|
29
38
|
onOpenChange?: (open: boolean) => void;
|
|
30
39
|
children: ReactNode;
|
|
31
40
|
}
|
|
32
|
-
export declare function KjunTooltip({ content, placement, delay, open: controlled, onOpenChange, children, }: KjunTooltipProps): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
export declare function KjunTooltip({ content, title, align, width, placement, delay, open: controlled, onOpenChange, children, }: KjunTooltipProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** A screen (viewport) rectangle a popover attaches to instead of its trigger; width and height default to 0. */
|
|
2
|
+
export interface AnchorRect {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
}
|
|
8
|
+
export type AnchorSource = AnchorRect | (() => AnchorRect | null);
|
|
9
|
+
/** Keeps the anchor on its source while a popover is open: a value is placed once, a function is read every
|
|
10
|
+
* frame (a text cursor moves without scrolling). A function returning null keeps the last position. */
|
|
11
|
+
export declare function followAnchor(element: HTMLElement, source: () => AnchorSource | undefined, moved: () => void): () => void;
|
|
12
|
+
/** Inline style of the anchor element: fixed, invisible and ignoring the pointer. */
|
|
13
|
+
export declare const anchorStyle: {
|
|
14
|
+
readonly position: "fixed";
|
|
15
|
+
readonly pointerEvents: "none";
|
|
16
|
+
readonly visibility: "hidden";
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** A screen (viewport) rectangle a popover attaches to instead of its trigger; width and height default to 0. */
|
|
2
|
+
export interface AnchorRect {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
}
|
|
8
|
+
export type AnchorSource = AnchorRect | (() => AnchorRect | null);
|
|
9
|
+
/** Keeps the anchor on its source while a popover is open: a value is placed once, a function is read every
|
|
10
|
+
* frame (a text cursor moves without scrolling). A function returning null keeps the last position. */
|
|
11
|
+
export declare function followAnchor(element: HTMLElement, source: () => AnchorSource | undefined, moved: () => void): () => void;
|
|
12
|
+
/** Inline style of the anchor element: fixed, invisible and ignoring the pointer. */
|
|
13
|
+
export declare const anchorStyle: {
|
|
14
|
+
readonly position: "fixed";
|
|
15
|
+
readonly pointerEvents: "none";
|
|
16
|
+
readonly visibility: "hidden";
|
|
17
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kjun-ui/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://ui.kjun.dev",
|
|
6
6
|
"repository": {
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"./package.json": "./package.json"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@kjun-ui/tokens": "0.
|
|
44
|
+
"@kjun-ui/tokens": "0.16.0",
|
|
45
45
|
"react-aria-components": "1.21.1",
|
|
46
|
-
"@kjun-ui/icons": "0.
|
|
46
|
+
"@kjun-ui/icons": "0.16.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"react": "^19.2.3",
|