@lykomi/web-primitives 0.50.0 → 0.52.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/field.d.ts +3 -1
- package/dist/field.js +2 -2
- package/dist/read-only-field.d.ts +2 -1
- package/dist/read-only-field.js +4 -3
- package/package.json +1 -1
package/dist/field.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ComponentPropsWithoutRef, type ReactNode } from "react";
|
|
2
|
-
export declare function Field({ label, hint, error, htmlFor, action, className, children, }: {
|
|
2
|
+
export declare function Field({ label, hint, error, htmlFor, action, className, children, agentContext, }: {
|
|
3
3
|
label?: ReactNode;
|
|
4
4
|
hint?: ReactNode;
|
|
5
5
|
error?: ReactNode;
|
|
@@ -7,5 +7,7 @@ export declare function Field({ label, hint, error, htmlFor, action, className,
|
|
|
7
7
|
action?: ReactNode;
|
|
8
8
|
className?: string;
|
|
9
9
|
children: ReactNode;
|
|
10
|
+
/** Disable automatic agent context for private fields. */
|
|
11
|
+
agentContext?: boolean;
|
|
10
12
|
}): import("react/jsx-runtime").JSX.Element;
|
|
11
13
|
export declare function FieldSet({ className, ...props }: ComponentPropsWithoutRef<"div">): import("react/jsx-runtime").JSX.Element;
|
package/dist/field.js
CHANGED
|
@@ -12,7 +12,7 @@ function unwrapSingleChild(children) {
|
|
|
12
12
|
: child;
|
|
13
13
|
}
|
|
14
14
|
// A named control with associated help/error; actions stay outside its label.
|
|
15
|
-
export function Field({ label, hint, error, htmlFor, action, className, children, }) {
|
|
15
|
+
export function Field({ label, hint, error, htmlFor, action, className, children, agentContext = true, }) {
|
|
16
16
|
const id = useId();
|
|
17
17
|
const singleChild = unwrapSingleChild(children);
|
|
18
18
|
const child = isValidElement(singleChild)
|
|
@@ -36,7 +36,7 @@ export function Field({ label, hint, error, htmlFor, action, className, children
|
|
|
36
36
|
"aria-invalid": error ? true : child.props["aria-invalid"],
|
|
37
37
|
})
|
|
38
38
|
: children;
|
|
39
|
-
return (_jsxs("div", { className: cn("grid gap-1.5", className), children: [singleControl || htmlFor ? (_jsxs(_Fragment, { children: [(label || action) && (_jsxs("div", { className: "flex items-center justify-between gap-3", children: [label ? (_jsx("label", { htmlFor: controlId, className: labelClass, children: labelContent })) : (_jsx("span", {})), action] })), control] })) : (_jsxs(_Fragment, { children: [action && _jsx("div", { className: "flex justify-end", children: action }), _jsxs("label", { className: "grid gap-1.5", children: [label && _jsx("span", { className: labelClass, children: labelContent }), control] })] })), hint && (_jsx("span", { id: `${id}-hint`, className: "block text-xs text-muted-foreground", children: hint })), error && (_jsx("span", { id: `${id}-error`, className: "block text-xs text-destructive", children: error }))] }));
|
|
39
|
+
return (_jsxs("div", { "data-agent-field": id, "data-agent-context": agentContext ? undefined : "off", className: cn("grid gap-1.5", className), children: [singleControl || htmlFor ? (_jsxs(_Fragment, { children: [(label || action) && (_jsxs("div", { className: "flex items-center justify-between gap-3", children: [label ? (_jsx("label", { "data-agent-field-label": true, htmlFor: controlId, className: labelClass, children: labelContent })) : (_jsx("span", {})), action] })), control] })) : (_jsxs(_Fragment, { children: [action && _jsx("div", { className: "flex justify-end", children: action }), _jsxs("label", { className: "grid gap-1.5", children: [label && (_jsx("span", { "data-agent-field-label": true, className: labelClass, children: labelContent })), control] })] })), hint && (_jsx("span", { id: `${id}-hint`, className: "block text-xs text-muted-foreground", children: hint })), error && (_jsx("span", { id: `${id}-error`, className: "block text-xs text-destructive", children: error }))] }));
|
|
40
40
|
}
|
|
41
41
|
export function FieldSet({ className, ...props }) {
|
|
42
42
|
return _jsx("div", { className: cn("grid gap-4", className), ...props });
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type ComponentPropsWithoutRef, type ReactNode } from "react";
|
|
2
2
|
/** Readable label/value pair; keeps the Field rhythm without a disabled input. */
|
|
3
|
-
export declare function ReadOnlyField({ label, hint, emptyLabel, children, multiline, valueAppearance, className, ...props }: ComponentPropsWithoutRef<"dl"> & {
|
|
3
|
+
export declare function ReadOnlyField({ label, hint, emptyLabel, children, multiline, valueAppearance, className, agentContext, ...props }: ComponentPropsWithoutRef<"dl"> & {
|
|
4
4
|
label: ReactNode;
|
|
5
|
+
agentContext?: boolean;
|
|
5
6
|
multiline?: boolean;
|
|
6
7
|
/** Field preserves an editable slot; content presents fixed information without input chrome. */
|
|
7
8
|
valueAppearance?: "field" | "content";
|
package/dist/read-only-field.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { cloneElement, Fragment, isValidElement, } from "react";
|
|
2
|
+
import { cloneElement, useId, Fragment, isValidElement, } from "react";
|
|
3
3
|
import { cn } from "./utils.js";
|
|
4
4
|
function isEmptyValue(value) {
|
|
5
5
|
if (isValidElement(value) &&
|
|
@@ -21,9 +21,10 @@ function displayValue(value) {
|
|
|
21
21
|
return value;
|
|
22
22
|
}
|
|
23
23
|
/** Readable label/value pair; keeps the Field rhythm without a disabled input. */
|
|
24
|
-
export function ReadOnlyField({ label, hint, emptyLabel = "Not set", children, multiline = false, valueAppearance = "field", className, ...props }) {
|
|
24
|
+
export function ReadOnlyField({ label, hint, emptyLabel = "Not set", children, multiline = false, valueAppearance = "field", className, agentContext = true, ...props }) {
|
|
25
|
+
const id = useId();
|
|
25
26
|
const empty = isEmptyValue(children);
|
|
26
|
-
return (_jsxs("dl", { ...props, className: cn("grid min-w-0 gap-1.5", className), children: [_jsx("dt", { className: "text-xs font-medium text-muted-foreground", children: label }), _jsx("dd", { "data-value-appearance": valueAppearance, className: cn("m-0 min-w-0 break-words whitespace-pre-wrap text-sm text-foreground", valueAppearance === "field"
|
|
27
|
+
return (_jsxs("dl", { ...props, "data-agent-field": id, "data-agent-context": agentContext ? undefined : "off", className: cn("grid min-w-0 gap-1.5", className), children: [_jsx("dt", { "data-agent-field-label": true, className: "text-xs font-medium text-muted-foreground", children: label }), _jsx("dd", { "data-agent-field-value": true, "data-value-appearance": valueAppearance, className: cn("m-0 min-w-0 break-words whitespace-pre-wrap text-sm text-foreground", valueAppearance === "field"
|
|
27
28
|
? "min-h-10 rounded-xl border border-border bg-background px-3 py-2 leading-5"
|
|
28
29
|
: "leading-6", multiline && valueAppearance === "field" && "min-h-24 leading-6"), children: empty ? (_jsx("span", { className: "text-muted-foreground", children: emptyLabel })) : (displayValue(children)) }), hint && _jsx("dd", { className: "m-0 text-xs text-muted-foreground", children: hint })] }));
|
|
29
30
|
}
|