@camunda/design-system 0.71.0 → 0.73.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/carbon-compat/checkbox.d.ts +6 -1
- package/dist/carbon-compat/checkbox.d.ts.map +1 -1
- package/dist/carbon-compat/checkbox.js +6 -2
- package/dist/carbon-compat/checkbox.js.map +1 -1
- package/dist/carbon-compat/radio-button.d.ts +3 -1
- package/dist/carbon-compat/radio-button.d.ts.map +1 -1
- package/dist/carbon-compat/radio-button.js +6 -2
- package/dist/carbon-compat/radio-button.js.map +1 -1
- package/dist/carbon-compat/toggle.d.ts +5 -3
- package/dist/carbon-compat/toggle.d.ts.map +1 -1
- package/dist/carbon-compat/toggle.js +15 -10
- package/dist/carbon-compat/toggle.js.map +1 -1
- package/dist/src/components/ui/code-block.d.ts.map +1 -1
- package/dist/src/components/ui/code-block.js +11 -76
- package/dist/src/components/ui/code-block.js.map +1 -1
- package/dist/src/components/ui/copy-button.d.ts +21 -0
- package/dist/src/components/ui/copy-button.d.ts.map +1 -0
- package/dist/src/components/ui/copy-button.js +55 -0
- package/dist/src/components/ui/copy-button.js.map +1 -0
- package/dist/src/components/ui/copyable-value.d.ts +13 -0
- package/dist/src/components/ui/copyable-value.d.ts.map +1 -0
- package/dist/src/components/ui/copyable-value.js +13 -0
- package/dist/src/components/ui/copyable-value.js.map +1 -0
- package/dist/src/components/ui/definition-tooltip.d.ts +5 -1
- package/dist/src/components/ui/definition-tooltip.d.ts.map +1 -1
- package/dist/src/components/ui/definition-tooltip.js +149 -6
- package/dist/src/components/ui/definition-tooltip.js.map +1 -1
- package/dist/src/components/ui/empty-state.d.ts.map +1 -1
- package/dist/src/components/ui/empty-state.js +4 -1
- package/dist/src/components/ui/empty-state.js.map +1 -1
- package/dist/src/hooks/use-copy-to-clipboard.d.ts +29 -0
- package/dist/src/hooks/use-copy-to-clipboard.d.ts.map +1 -0
- package/dist/src/hooks/use-copy-to-clipboard.js +126 -0
- package/dist/src/hooks/use-copy-to-clipboard.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/i18n/dictionary.d.ts +7 -0
- package/dist/src/lib/i18n/dictionary.d.ts.map +1 -1
- package/dist/src/lib/i18n/dictionary.js +6 -0
- package/dist/src/lib/i18n/dictionary.js.map +1 -1
- package/dist/styles.css +44 -0
- package/package.json +3 -2
|
@@ -4,6 +4,11 @@ export type CheckboxProps = Omit<CarbonCheckboxProps, "id"> & {
|
|
|
4
4
|
/** Specify a custom `id` for the control. Generated with `React.useId()` when omitted. */
|
|
5
5
|
id?: string;
|
|
6
6
|
};
|
|
7
|
-
declare
|
|
7
|
+
declare const Checkbox: React.ForwardRefExoticComponent<Omit<Omit<CarbonCheckboxProps, "id"> & {
|
|
8
|
+
/** Specify a custom `id` for the control. Generated with `React.useId()` when omitted. */
|
|
9
|
+
id?: string;
|
|
10
|
+
} & {
|
|
11
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
12
|
+
}, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
8
13
|
export { Checkbox };
|
|
9
14
|
//# sourceMappingURL=checkbox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../carbon-compat/checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../carbon-compat/checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,KAAK,EAAE,aAAa,IAAI,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAI1E,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,GAAG;IAC5D,0FAA0F;IAC1F,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAuHF,QAAA,MAAM,QAAQ;IAzHZ,0FAA0F;SACrF,MAAM;;UA0Ha,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC;mDACvC,CAAC;AAEhB,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -2,8 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { Checkbox as ShadcnCheckbox } from "../src/components/ui/checkbox.js";
|
|
4
4
|
import { cn, warnDroppedProps } from "../src/lib/utils.js";
|
|
5
|
+
import { withRef } from "../src/lib/with-ref.js";
|
|
5
6
|
import { fieldMessages } from "./field-messages.js";
|
|
6
|
-
|
|
7
|
+
// The ref reaches the Radix `<button role="checkbox">`, not a native input as
|
|
8
|
+
// in Carbon (see MAPPING.md).
|
|
9
|
+
function CheckboxImpl({ ref, ...props }) {
|
|
7
10
|
const { id, labelText, checked, defaultChecked, indeterminate, onChange, disabled, className, helperText, invalid, invalidText, warn, warnText, readOnly, hideLabel, title, "aria-describedby": ariaDescribedBy, "aria-errormessage": ariaErrorMessage, ...rest } = props;
|
|
8
11
|
warnDroppedProps("Checkbox", { readOnly, hideLabel });
|
|
9
12
|
const generatedId = React.useId();
|
|
@@ -24,7 +27,7 @@ function Checkbox(props) {
|
|
|
24
27
|
const checkedValue = indeterminate
|
|
25
28
|
? "indeterminate"
|
|
26
29
|
: checked;
|
|
27
|
-
const box = (_jsx(ShadcnCheckbox, { id: resolvedId, checked: checkedValue, defaultChecked: defaultChecked, disabled: disabled, onCheckedChange: handleCheckedChange, title: title, ...ariaProps, ...rest }));
|
|
30
|
+
const box = (_jsx(ShadcnCheckbox, { ref: ref, id: resolvedId, checked: checkedValue, defaultChecked: defaultChecked, disabled: disabled, onCheckedChange: handleCheckedChange, title: title, ...ariaProps, ...rest }));
|
|
28
31
|
const control = labelText !== undefined ? (_jsxs("label", { className: cn("flex items-center gap-2", !message && className), children: [box, _jsx("span", { children: labelText })] })) : (React.cloneElement(box, { className: message ? undefined : className }));
|
|
29
32
|
// One root and one child order whatever the props, so the checkbox is never
|
|
30
33
|
// remounted when validation or helper text comes and goes — a remount drops
|
|
@@ -36,5 +39,6 @@ function Checkbox(props) {
|
|
|
36
39
|
// checkbox's accessible name; it's announced via aria-describedby instead.
|
|
37
40
|
return (_jsxs("div", { className: cn(message ? "flex flex-col items-start gap-1" : "contents", message && className), children: [control, message] }));
|
|
38
41
|
}
|
|
42
|
+
const Checkbox = withRef(CheckboxImpl);
|
|
39
43
|
export { Checkbox };
|
|
40
44
|
//# sourceMappingURL=checkbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.js","sourceRoot":"","sources":["../../carbon-compat/checkbox.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,EAAE,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAejD,SAAS,
|
|
1
|
+
{"version":3,"file":"checkbox.js","sourceRoot":"","sources":["../../carbon-compat/checkbox.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,EAAE,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAejD,8EAA8E;AAC9E,8BAA8B;AAC9B,SAAS,YAAY,CAAC,EACpB,GAAG,EACH,GAAG,KAAK,EAC+C;IACvD,MA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,YAAY,EACrB,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,mBAAmB,EACpC,KAAK,EAAE,KAAK,KACR,SAAS,KACR,IAAoD,GACzD,CACH,CAAC;IACF,MAAM,OAAO,GACX,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,CACxB,iBAAO,SAAS,EAAE,EAAE,CAAC,yBAAyB,EAAE,CAAC,OAAO,IAAI,SAAS,CAAC,aACnE,GAAG,EACJ,yBAAO,SAAS,GAAQ,IAClB,CACT,CAAC,CAAC,CAAC,CACF,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CACxE,CAAC;IACJ,4EAA4E;IAC5E,4EAA4E;IAC5E,0EAA0E;IAC1E,8EAA8E;IAC9E,6DAA6D;IAC7D,EAAE;IACF,mEAAmE;IACnE,2EAA2E;IAC3E,OAAO,CACL,eACE,SAAS,EAAE,EAAE,CACX,OAAO,CAAC,CAAC,CAAC,iCAAiC,CAAC,CAAC,CAAC,UAAU,EACxD,OAAO,IAAI,SAAS,CACrB,aAEA,OAAO,EACP,OAAO,IACJ,CACP,CAAC;AACJ,CAAC;AAED,MAAM,QAAQ,GAAG,OAAO,CAGtB,YAAY,CAAC,CAAC;AAEhB,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -3,6 +3,8 @@ import type { RadioButtonGroupProps as CarbonRadioButtonGroupProps, RadioButtonP
|
|
|
3
3
|
export type RadioButtonGroupProps = CarbonRadioButtonGroupProps;
|
|
4
4
|
export type RadioButtonProps = CarbonRadioButtonProps;
|
|
5
5
|
declare function RadioButtonGroup(props: RadioButtonGroupProps): React.JSX.Element;
|
|
6
|
-
declare
|
|
6
|
+
declare const RadioButton: React.ForwardRefExoticComponent<Omit<CarbonRadioButtonProps & {
|
|
7
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
8
|
+
}, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
7
9
|
export { RadioButton, RadioButtonGroup };
|
|
8
10
|
//# sourceMappingURL=radio-button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-button.d.ts","sourceRoot":"","sources":["../../carbon-compat/radio-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"radio-button.d.ts","sourceRoot":"","sources":["../../carbon-compat/radio-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,KAAK,EACV,qBAAqB,IAAI,2BAA2B,EACpD,gBAAgB,IAAI,sBAAsB,EAC3C,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AAChE,MAAM,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;AAEtD,iBAAS,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,qBAkIrD;AA4DD,QAAA,MAAM,WAAW;UAEY,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC;mDACvC,CAAC;AAEnB,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -3,6 +3,7 @@ import * as React from "react";
|
|
|
3
3
|
import { RadioGroup, RadioGroupItem } from "../src/components/ui/radio-group.js";
|
|
4
4
|
import { Text } from "../src/components/ui/typography.js";
|
|
5
5
|
import { cn, warnDroppedProps } from "../src/lib/utils.js";
|
|
6
|
+
import { withRef } from "../src/lib/with-ref.js";
|
|
6
7
|
import { fieldMessages } from "./field-messages.js";
|
|
7
8
|
function RadioButtonGroup(props) {
|
|
8
9
|
const { children, className, defaultSelected, disabled, helperText, invalid, invalidText, legendText, name, onChange, orientation, readOnly, valueSelected, warn, warnText, "aria-describedby": ariaDescribedBy, "aria-errormessage": ariaErrorMessage, ...rest } = props;
|
|
@@ -45,13 +46,16 @@ function RadioButtonGroup(props) {
|
|
|
45
46
|
}
|
|
46
47
|
return field;
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
+
// The ref reaches the Radix `<button role="radio">`, not a native input as in
|
|
50
|
+
// Carbon (see MAPPING.md).
|
|
51
|
+
function RadioButtonImpl({ ref, ...props }) {
|
|
49
52
|
// `onChange` is plucked out and consumed by the parent
|
|
50
53
|
// `<RadioButtonGroup>` via React.Children walk (Carbon API parity);
|
|
51
54
|
// it must NOT be forwarded to the underlying RadioGroupItem.
|
|
52
55
|
const { checked, className, disabled, hideLabel, id, inline, labelText, value, onChange: _onChange, ...rest } = props;
|
|
53
56
|
warnDroppedProps("RadioButton", { checked, inline });
|
|
54
|
-
return (_jsxs("div", { className: cn("flex items-center gap-2", className), children: [_jsx(RadioGroupItem, { ...rest, id: id, value: value, disabled: disabled }), labelText !== undefined && (_jsx("label", { htmlFor: id, className: cn("text-sm font-medium leading-none", hideLabel && "sr-only", disabled && "cursor-not-allowed opacity-70"), children: labelText }))] }));
|
|
57
|
+
return (_jsxs("div", { className: cn("flex items-center gap-2", className), children: [_jsx(RadioGroupItem, { ref: ref, ...rest, id: id, value: value, disabled: disabled }), labelText !== undefined && (_jsx("label", { htmlFor: id, className: cn("text-sm font-medium leading-none", hideLabel && "sr-only", disabled && "cursor-not-allowed opacity-70"), children: labelText }))] }));
|
|
55
58
|
}
|
|
59
|
+
const RadioButton = withRef(RadioButtonImpl);
|
|
56
60
|
export { RadioButton, RadioButtonGroup };
|
|
57
61
|
//# sourceMappingURL=radio-button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-button.js","sourceRoot":"","sources":["../../carbon-compat/radio-button.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,iCAAiC,CAA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,IAAI,+BAA+B,CAC5C,YAEA,SAAS,GACJ,CACT,IACG,CACP,CAAC;AACJ,CAAC;AAED,MAAM,WAAW,GAAG,OAAO,CAGzB,eAAe,CAAC,CAAC;AAEnB,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import type { ToggleProps as CarbonToggleProps } from
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { ToggleProps as CarbonToggleProps } from "@carbon/react";
|
|
3
3
|
export type ToggleProps = CarbonToggleProps;
|
|
4
|
-
declare
|
|
4
|
+
declare const Toggle: React.ForwardRefExoticComponent<Omit<CarbonToggleProps & {
|
|
5
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
6
|
+
}, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
5
7
|
export { Toggle };
|
|
6
8
|
//# sourceMappingURL=toggle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle.d.ts","sourceRoot":"","sources":["../../carbon-compat/toggle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"toggle.d.ts","sourceRoot":"","sources":["../../carbon-compat/toggle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEtE,MAAM,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAiG5C,QAAA,MAAM,MAAM;UAEY,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC;mDACvC,CAAC;AAEd,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import * as React from
|
|
3
|
-
import { Switch } from
|
|
4
|
-
import { cn, warnDroppedProps } from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Switch } from "../src/components/ui/switch.js";
|
|
4
|
+
import { cn, warnDroppedProps } from "../src/lib/utils.js";
|
|
5
|
+
import { withRef } from "../src/lib/with-ref.js";
|
|
6
|
+
// The ref reaches the Radix `<button role="switch">`, as in Carbon.
|
|
7
|
+
function ToggleImpl({ ref, ...props }) {
|
|
8
|
+
const { "aria-labelledby": ariaLabelledby, className, defaultToggled, disabled, hideLabel, id, labelA, labelB, labelText, onClick, onToggle, readOnly, size, toggled, ...rest } = props;
|
|
9
|
+
warnDroppedProps("Toggle", { readOnly });
|
|
8
10
|
// Carbon's `<Toggle size="sm">` maps to DS `<Switch size="sm">` (visually
|
|
9
11
|
// matches `.cds--toggle--small`); Carbon's default `md` maps to DS `md`.
|
|
10
12
|
// Carbon `ToggleProps.size` is typed as `'sm' | 'md'` (Carbon Toggle has
|
|
11
13
|
// no `lg`); any unknown/legacy value falls back to DS `md`.
|
|
12
|
-
const dsSize = size ===
|
|
14
|
+
const dsSize = size === "sm" ? "sm" : "md";
|
|
13
15
|
// Track the switch's checked state internally so the side label ("On"/"Off"
|
|
14
16
|
// via labelA/labelB) reflects toggles when the consumer hasn't wired
|
|
15
17
|
// `toggled` + `onToggle` — same shape Carbon's `Toggle` uses via
|
|
@@ -43,11 +45,14 @@ function Toggle(props) {
|
|
|
43
45
|
// labelA/labelB. This IS a BC deviation from Carbon (which would
|
|
44
46
|
// render labelText as the header and labelA/labelB as the side); it
|
|
45
47
|
// is intentional because carbon-compat can't render both.
|
|
46
|
-
const labelContent = hideLabel
|
|
47
|
-
|
|
48
|
+
const labelContent = hideLabel
|
|
49
|
+
? labelText
|
|
50
|
+
: (labelText ?? (checkedState ? labelB : labelA));
|
|
51
|
+
const switchEl = (_jsx(Switch, { ref: ref, id: id, size: dsSize, "aria-labelledby": ariaLabelledby, disabled: disabled, checked: checkedState, onClick: onClick, onCheckedChange: handleCheckedChange, ...rest }));
|
|
48
52
|
if (!labelContent)
|
|
49
53
|
return React.cloneElement(switchEl, { className });
|
|
50
|
-
return (_jsxs("div", { className: cn(
|
|
54
|
+
return (_jsxs("div", { className: cn("flex items-center gap-2", className), children: [switchEl, _jsx("label", { htmlFor: id, className: cn("text-sm font-medium leading-none", disabled && "cursor-not-allowed opacity-70"), children: labelContent })] }));
|
|
51
55
|
}
|
|
56
|
+
const Toggle = withRef(ToggleImpl);
|
|
52
57
|
export { Toggle };
|
|
53
58
|
//# sourceMappingURL=toggle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle.js","sourceRoot":"","sources":["../../carbon-compat/toggle.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,
|
|
1
|
+
{"version":3,"file":"toggle.js","sourceRoot":"","sources":["../../carbon-compat/toggle.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,EAAE,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAK9C,oEAAoE;AACpE,SAAS,UAAU,CAAC,EAClB,GAAG,EACH,GAAG,KAAK,EAC6C;IACrD,MAAM,EACJ,iBAAiB,EAAE,cAAc,EACjC,SAAS,EACT,cAAc,EACd,QAAQ,EACR,SAAS,EACT,EAAE,EACF,MAAM,EACN,MAAM,EACN,SAAS,EACT,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,GAAG,IAAI,EACR,GAAG,KAAK,CAAC;IACV,gBAAgB,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IACzC,0EAA0E;IAC1E,yEAAyE;IACzE,yEAAyE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,EAClB,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,OAAgE,EACzE,eAAe,EAAE,mBAAmB,KAC/B,IAA4C,GACjD,CACH,CAAC;IACF,IAAI,CAAC,YAAY;QAAE,OAAO,KAAK,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;IACtE,OAAO,CACL,eAAK,SAAS,EAAE,EAAE,CAAC,yBAAyB,EAAE,SAAS,CAAC,aACrD,QAAQ,EACT,gBACE,OAAO,EAAE,EAAE,EACX,SAAS,EAAE,EAAE,CACX,kCAAkC,EAClC,QAAQ,IAAI,+BAA+B,CAC5C,YAEA,YAAY,GACP,IACJ,CACP,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,OAAO,CAGpB,UAAU,CAAC,CAAC;AAEd,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-block.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/code-block.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"code-block.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/code-block.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAUlE,QAAA,MAAM,iBAAiB;;8EAatB,CAAC;AAQF,KAAK,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,GAC/D,YAAY,CAAC,OAAO,iBAAiB,CAAC,GAAG;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sIAAsI;IACtI,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oJAAoJ;IACpJ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oJAAoJ;IACpJ,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACnE,iOAAiO;IACjO,aAAa,CAAC,EAAE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wIAAwI;IACxI,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6IAA6I;IAC7I,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAgMJ,QAAA,MAAM,SAAS,oGAAyD,CAAC;AAEzE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,KAAK,cAAc,EAAE,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { cva } from "class-variance-authority";
|
|
4
4
|
import { Check, ChevronDown, CircleAlert, Copy } from "../../icons/lucide.js";
|
|
5
|
+
import { useCopyToClipboard } from "../../hooks/use-copy-to-clipboard.js";
|
|
5
6
|
import { mergeRefs } from "../../lib/merge-refs.js";
|
|
6
7
|
import { cn } from "../../lib/utils.js";
|
|
7
8
|
import { useC4Dictionary } from "../../lib/i18n/context.js";
|
|
@@ -18,7 +19,6 @@ const codeBlockVariants = cva("relative rounded-lg border border-border bg-neutr
|
|
|
18
19
|
variant: "single",
|
|
19
20
|
},
|
|
20
21
|
});
|
|
21
|
-
const COPIED_RESET_MS = 2000;
|
|
22
22
|
// A cap exactly equal to natural content height is the common case for content
|
|
23
23
|
// that fits in `collapsedRows` by one line's margin — a 1px subpixel rounding
|
|
24
24
|
// error in the measured line-height must not tip that into a dead show-more
|
|
@@ -44,12 +44,10 @@ function CodeBlockImpl({ ref, className, variant = "single", children, copyable
|
|
|
44
44
|
}, [collapsedRows, variant]);
|
|
45
45
|
const codeRef = React.useRef(null);
|
|
46
46
|
const preRef = React.useRef(null);
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const resetTimerRef = React.useRef(undefined);
|
|
52
|
-
const announceFrameRef = React.useRef(undefined);
|
|
47
|
+
const { status, isCopying, announcement, copy } = useCopyToClipboard({
|
|
48
|
+
getText: () => onCopyRequest ? onCopyRequest() : (codeRef.current?.textContent ?? ""),
|
|
49
|
+
onCopy,
|
|
50
|
+
});
|
|
53
51
|
const collapsible = variant === "multi" && collapsedRows !== undefined;
|
|
54
52
|
const [expanded, setExpanded] = React.useState(false);
|
|
55
53
|
const [capPx, setCapPx] = React.useState(null);
|
|
@@ -88,86 +86,23 @@ function CodeBlockImpl({ ref, className, variant = "single", children, copyable
|
|
|
88
86
|
// call a consumer's ref callback with `null` then the node again on every
|
|
89
87
|
// re-render, not just when the ref itself changes.
|
|
90
88
|
const preRefCallback = React.useMemo(() => mergeRefs(ref, preRef), [ref, preRef]);
|
|
91
|
-
React.useEffect(() => () => {
|
|
92
|
-
clearTimeout(resetTimerRef.current);
|
|
93
|
-
if (announceFrameRef.current !== undefined) {
|
|
94
|
-
cancelAnimationFrame(announceFrameRef.current);
|
|
95
|
-
}
|
|
96
|
-
}, []);
|
|
97
|
-
const handleCopy = async () => {
|
|
98
|
-
// Await the resolver and `writeText` in one try so a rejection from either
|
|
99
|
-
// reaches the catch. `text` seeds to "" so the catch can still report it.
|
|
100
|
-
let text = "";
|
|
101
|
-
let success;
|
|
102
|
-
try {
|
|
103
|
-
if (onCopyRequest) {
|
|
104
|
-
setIsCopying(true);
|
|
105
|
-
try {
|
|
106
|
-
text = await onCopyRequest();
|
|
107
|
-
}
|
|
108
|
-
finally {
|
|
109
|
-
setIsCopying(false);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
text = codeRef.current?.textContent ?? "";
|
|
114
|
-
}
|
|
115
|
-
if (!text) {
|
|
116
|
-
// Copying nothing would wipe the clipboard and report success.
|
|
117
|
-
onCopy?.("", false);
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
await navigator.clipboard.writeText(text);
|
|
121
|
-
success = true;
|
|
122
|
-
onCopy?.(text, true);
|
|
123
|
-
}
|
|
124
|
-
catch (caught) {
|
|
125
|
-
success = false;
|
|
126
|
-
// The third argument is only ever passed on failure — there is no real
|
|
127
|
-
// error to report on success, and a synthesized one would just be noise.
|
|
128
|
-
onCopy?.(text, false, caught);
|
|
129
|
-
}
|
|
130
|
-
// Clear unconditionally: a failure arriving inside the previous success's
|
|
131
|
-
// window would otherwise leave the tick and "Copied" standing over a copy
|
|
132
|
-
// that did not happen.
|
|
133
|
-
clearTimeout(resetTimerRef.current);
|
|
134
|
-
setStatus(success ? "copied" : "failed");
|
|
135
|
-
// Only success is transient. A confirmation has done its job once it has been
|
|
136
|
-
// seen, but an error that clears itself can vanish before the user looks up —
|
|
137
|
-
// so a failure stays put until the next attempt replaces it.
|
|
138
|
-
if (success) {
|
|
139
|
-
resetTimerRef.current = setTimeout(() => setStatus("idle"), COPIED_RESET_MS);
|
|
140
|
-
// Emptied and refilled rather than left set: a second copy of the same block
|
|
141
|
-
// leaves the text identical, and a live region only announces on change, so
|
|
142
|
-
// repeat copies would otherwise be silent. The region stays mounted through
|
|
143
|
-
// the swap — remounting one is not reliably announced.
|
|
144
|
-
setAnnouncement("");
|
|
145
|
-
if (announceFrameRef.current !== undefined) {
|
|
146
|
-
cancelAnimationFrame(announceFrameRef.current);
|
|
147
|
-
}
|
|
148
|
-
announceFrameRef.current = requestAnimationFrame(() => setAnnouncement(resolvedCopiedLabel));
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
setAnnouncement("");
|
|
152
|
-
if (announceFrameRef.current !== undefined) {
|
|
153
|
-
cancelAnimationFrame(announceFrameRef.current);
|
|
154
|
-
}
|
|
155
|
-
announceFrameRef.current = requestAnimationFrame(() => setAnnouncement(resolvedCopyFailedLabel));
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
89
|
return (_jsxs("div", { "data-slot": "code-block", "data-variant": variant, className: cn(codeBlockVariants({ variant }), copyable && "pr-10"), children: [_jsx("div", { tabIndex: 0, className: cn("outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset", variant === "single" ? "overflow-x-auto" : "", isCollapsedVisual ? "overflow-hidden" : ""),
|
|
159
90
|
// The row cap is a measured pixel value, not a design token — it depends
|
|
160
91
|
// on `collapsedRows` (a consumer-supplied number) and the block's own
|
|
161
92
|
// computed line-height, so it can't be expressed as a fixed utility class.
|
|
162
93
|
style: isCollapsedVisual && capPx !== null ? { maxHeight: capPx } : undefined, children: _jsx("pre", { ref: preRefCallback, className: cn(variant === "single"
|
|
163
94
|
? "whitespace-pre"
|
|
164
|
-
: "whitespace-pre-wrap break-words", className), ...props, children: _jsx("code", { ref: codeRef, children: children }) }) }), showToggle && (_jsxs(Button, { type: "button", variant: "ghost", size: "xs", onClick: () => setExpanded((prev) => !prev), "aria-expanded": expanded, className: "mt-2", children: [expanded ? resolvedShowLessLabel : resolvedShowMoreLabel, _jsx(ChevronDown, { "aria-hidden": "true", className: cn("transition-transform", expanded && "rotate-180") })] })), copyable && (_jsxs(_Fragment, { children: [_jsx(Button, { type: "button", variant: "ghost", size: "icon-xs", loading: isCopying, onClick:
|
|
95
|
+
: "whitespace-pre-wrap break-words", className), ...props, children: _jsx("code", { ref: codeRef, children: children }) }) }), showToggle && (_jsxs(Button, { type: "button", variant: "ghost", size: "xs", onClick: () => setExpanded((prev) => !prev), "aria-expanded": expanded, className: "mt-2", children: [expanded ? resolvedShowLessLabel : resolvedShowMoreLabel, _jsx(ChevronDown, { "aria-hidden": "true", className: cn("transition-transform", expanded && "rotate-180") })] })), copyable && (_jsxs(_Fragment, { children: [_jsx(Button, { type: "button", variant: "ghost", size: "icon-xs", loading: isCopying, onClick: copy, "aria-label": status === "copied"
|
|
165
96
|
? resolvedCopiedLabel
|
|
166
97
|
: status === "failed"
|
|
167
98
|
? resolvedCopyFailedLabel
|
|
168
99
|
: resolvedCopyLabel,
|
|
169
100
|
// `aria-disabled` here means copy-in-flight, not disabled: keep full opacity.
|
|
170
|
-
className: "absolute top-1.5 right-1.5 aria-disabled:opacity-100", children: status === "copied" ? (_jsx(Check, { className: "text-success-foreground-subtle", "aria-hidden": "true" })) : status === "failed" ? (_jsx(CircleAlert, { className: "text-danger-foreground-subtle", "aria-hidden": "true" })) : (_jsx(Copy, { "aria-hidden": "true" })) }), _jsx("span", { role: "status", "aria-live": "polite", className: "sr-only", children: announcement
|
|
101
|
+
className: "absolute top-1.5 right-1.5 aria-disabled:opacity-100", children: status === "copied" ? (_jsx(Check, { className: "text-success-foreground-subtle", "aria-hidden": "true" })) : status === "failed" ? (_jsx(CircleAlert, { className: "text-danger-foreground-subtle", "aria-hidden": "true" })) : (_jsx(Copy, { "aria-hidden": "true" })) }), _jsx("span", { role: "status", "aria-live": "polite", className: "sr-only", children: announcement === "copied"
|
|
102
|
+
? resolvedCopiedLabel
|
|
103
|
+
: announcement === "failed"
|
|
104
|
+
? resolvedCopyFailedLabel
|
|
105
|
+
: "" })] }))] }));
|
|
171
106
|
}
|
|
172
107
|
const CodeBlock = withRef(CodeBlockImpl);
|
|
173
108
|
export { CodeBlock, codeBlockVariants };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-block.js","sourceRoot":"","sources":["../../../../src/components/ui/code-block.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAErE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,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AK,QAAQ;4BACxB,CAAC,CAAC,mBAAmB;4BACrB,CAAC,CAAC,YAAY,KAAK,QAAQ;gCACzB,CAAC,CAAC,uBAAuB;gCACzB,CAAC,CAAC,EAAE,GACH,IACN,CACJ,IACG,CACP,CAAC;AACJ,CAAC;AAED,MAAM,SAAS,GAAG,OAAO,CAAiC,aAAa,CAAC,CAAC;AAEzE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAuB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type IconButtonProps } from "./icon-button.js";
|
|
3
|
+
type CopyButtonProps = Omit<IconButtonProps, "label" | "icon" | "loading" | "onClick" | "onCopy"> & {
|
|
4
|
+
/** The string copied on activation (unless `onCopyRequest` is given). Also the identity of the thing being copied: changing it resets the copy state. */
|
|
5
|
+
value: string;
|
|
6
|
+
/** Names the thing being copied, interpolated verbatim into the label templates (`Copy {name}`). Pass a lower-case noun phrase, e.g. `"process instance key"`. */
|
|
7
|
+
name?: string;
|
|
8
|
+
/** Accessible name and tooltip in the idle state. Sourced from the i18n dictionary at key `"copyButton.copy"` (or `"copyButton.copyNamed"` when `name` is set) when omitted. */
|
|
9
|
+
copyLabel?: string;
|
|
10
|
+
/** Accessible name/tooltip and announcement after a successful copy. Sourced from `"copyButton.copied"` (or `"copyButton.copiedNamed"`) when omitted. */
|
|
11
|
+
copiedLabel?: string;
|
|
12
|
+
/** Accessible name/tooltip and announcement after a failed copy. Sourced from `"copyButton.copyFailed"` (or `"copyButton.copyFailedNamed"`) when omitted. */
|
|
13
|
+
copyFailedLabel?: string;
|
|
14
|
+
/** `error` carries the original rejection (or the `TypeError` for a missing `navigator.clipboard`) on failure; omitted on success and on the empty-text failure. Not called for attempts invalidated by a `value` change or unmount. */
|
|
15
|
+
onCopy?: (text: string, success: boolean, error?: unknown) => void;
|
|
16
|
+
/** Resolves the text to copy instead of `value`; may be async. A rejection surfaces via `onCopy("", false, error)` and the failed state. */
|
|
17
|
+
onCopyRequest?: () => string | Promise<string>;
|
|
18
|
+
};
|
|
19
|
+
declare const CopyButton: React.ForwardRefExoticComponent<Omit<CopyButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
20
|
+
export { CopyButton, type CopyButtonProps };
|
|
21
|
+
//# sourceMappingURL=copy-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-button.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/copy-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAuBjE,KAAK,eAAe,GAAG,IAAI,CACzB,eAAe,EACf,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CACpD,GAAG;IACF,yJAAyJ;IACzJ,KAAK,EAAE,MAAM,CAAC;IACd,kKAAkK;IAClK,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gLAAgL;IAChL,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yJAAyJ;IACzJ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6JAA6J;IAC7J,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,wOAAwO;IACxO,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACnE,4IAA4I;IAC5I,aAAa,CAAC,EAAE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAChD,CAAC;AAiFF,QAAA,MAAM,UAAU,wGAA8D,CAAC;AAE/E,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Check, CircleAlert, Copy } from "../../icons/lucide.js";
|
|
4
|
+
import { useCopyToClipboard } from "../../hooks/use-copy-to-clipboard.js";
|
|
5
|
+
import { cn } from "../../lib/utils.js";
|
|
6
|
+
import { useC4Dictionary } from "../../lib/i18n/context.js";
|
|
7
|
+
import { withRef } from "../../lib/with-ref.js";
|
|
8
|
+
import { IconButton } from "./icon-button.js";
|
|
9
|
+
// Module-level so each state keeps a stable component identity across renders.
|
|
10
|
+
function CopiedIcon({ className, ...props }) {
|
|
11
|
+
return (_jsx(Check, { className: cn("text-success-foreground-subtle", className), ...props }));
|
|
12
|
+
}
|
|
13
|
+
function CopyFailedIcon({ className, ...props }) {
|
|
14
|
+
return (_jsx(CircleAlert, { className: cn("text-danger-foreground-subtle", className), ...props }));
|
|
15
|
+
}
|
|
16
|
+
function CopyButtonImpl({ ref, value, name, copyLabel, copiedLabel, copyFailedLabel, onCopy, onCopyRequest, variant = "ghost", size = "xs", className, ...props }) {
|
|
17
|
+
const { t } = useC4Dictionary();
|
|
18
|
+
const resolvedCopyLabel = copyLabel ??
|
|
19
|
+
(name === undefined
|
|
20
|
+
? t("copyButton.copy")
|
|
21
|
+
: t("copyButton.copyNamed", { name }));
|
|
22
|
+
const resolvedCopiedLabel = copiedLabel ??
|
|
23
|
+
(name === undefined
|
|
24
|
+
? t("copyButton.copied")
|
|
25
|
+
: t("copyButton.copiedNamed", { name }));
|
|
26
|
+
const resolvedCopyFailedLabel = copyFailedLabel ??
|
|
27
|
+
(name === undefined
|
|
28
|
+
? t("copyButton.copyFailed")
|
|
29
|
+
: t("copyButton.copyFailedNamed", { name }));
|
|
30
|
+
const { status, isCopying, announcement, copy } = useCopyToClipboard({
|
|
31
|
+
resetKey: value,
|
|
32
|
+
getText: () => (onCopyRequest ? onCopyRequest() : value),
|
|
33
|
+
onCopy,
|
|
34
|
+
});
|
|
35
|
+
const label = status === "copied"
|
|
36
|
+
? resolvedCopiedLabel
|
|
37
|
+
: status === "failed"
|
|
38
|
+
? resolvedCopyFailedLabel
|
|
39
|
+
: resolvedCopyLabel;
|
|
40
|
+
const icon = status === "copied"
|
|
41
|
+
? CopiedIcon
|
|
42
|
+
: status === "failed"
|
|
43
|
+
? CopyFailedIcon
|
|
44
|
+
: Copy;
|
|
45
|
+
return (_jsxs(_Fragment, { children: [_jsx(IconButton, { ref: ref, "data-slot": "copy-button", variant: variant, size: size, label: label, icon: icon, loading: isCopying, onClick: copy,
|
|
46
|
+
// `aria-disabled` here means copy-in-flight, not disabled: keep full opacity.
|
|
47
|
+
className: cn("aria-disabled:opacity-100", className), ...props }), _jsx("span", { role: "status", "aria-live": "polite", className: "sr-only", children: announcement === "copied"
|
|
48
|
+
? resolvedCopiedLabel
|
|
49
|
+
: announcement === "failed"
|
|
50
|
+
? resolvedCopyFailedLabel
|
|
51
|
+
: "" })] }));
|
|
52
|
+
}
|
|
53
|
+
const CopyButton = withRef(CopyButtonImpl);
|
|
54
|
+
export { CopyButton };
|
|
55
|
+
//# sourceMappingURL=copy-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-button.js","sourceRoot":"","sources":["../../../../src/components/ui/copy-button.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAwB,MAAM,eAAe,CAAC;AAIjE,+EAA+E;AAC/E,SAAS,UAAU,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAa;IACpD,OAAO,CACL,KAAC,KAA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AAE,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QACxD,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,KAAK,GACT,MAAM,KAAK,QAAQ;QACjB,CAAC,CAAC,mBAAmB;QACrB,CAAC,CAAC,MAAM,KAAK,QAAQ;YACnB,CAAC,CAAC,uBAAuB;YACzB,CAAC,CAAC,iBAAiB,CAAC;IAC1B,MAAM,IAAI,GACR,MAAM,KAAK,QAAQ;QACjB,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,MAAM,KAAK,QAAQ;YACnB,CAAC,CAAC,cAAc;YAChB,CAAC,CAAC,IAAI,CAAC;IAEb,OAAO,CACL,8BACE,KAAC,UAAU,IACT,GAAG,EAAE,GAAG,eACE,aAAa,EACvB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,SAAS,EAClB,OAAO,EAAE,IAAI;gBACb,8EAA8E;gBAC9E,SAAS,EAAE,EAAE,CAAC,2BAA2B,EAAE,SAAS,CAAC,KACjD,KAAK,GACT,EAIF,eAAM,IAAI,EAAC,QAAQ,eAAW,QAAQ,EAAC,SAAS,EAAC,SAAS,YACvD,YAAY,KAAK,QAAQ;oBACxB,CAAC,CAAC,mBAAmB;oBACrB,CAAC,CAAC,YAAY,KAAK,QAAQ;wBACzB,CAAC,CAAC,uBAAuB;wBACzB,CAAC,CAAC,EAAE,GACH,IACN,CACJ,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,GAAG,OAAO,CAAqC,cAAc,CAAC,CAAC;AAE/E,OAAO,EAAE,UAAU,EAAwB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type CopyButtonProps } from "./copy-button.js";
|
|
3
|
+
type CopyableValueProps = Omit<React.ComponentProps<"span">, "onCopy"> & Pick<CopyButtonProps, "onCopy" | "onCopyRequest" | "tooltipSide"> & {
|
|
4
|
+
/** Rendered verbatim and copied in full, also when `truncate` hides part of it. Changing it resets the copy state. */
|
|
5
|
+
value: string;
|
|
6
|
+
/** What the value is, as a lower-case noun phrase (e.g. `"agent instance key"`). Required so every instance has a distinct accessible name (`Copy {name}`). */
|
|
7
|
+
name: string;
|
|
8
|
+
/** Show the value on one line with an ellipsis when it does not fit; the parent must constrain the width. */
|
|
9
|
+
truncate?: boolean;
|
|
10
|
+
};
|
|
11
|
+
declare const CopyableValue: React.ForwardRefExoticComponent<Omit<CopyableValueProps, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
12
|
+
export { CopyableValue, type CopyableValueProps };
|
|
13
|
+
//# sourceMappingURL=copyable-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copyable-value.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/copyable-value.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAEjE,KAAK,kBAAkB,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,GACpE,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,eAAe,GAAG,aAAa,CAAC,GAAG;IAClE,sHAAsH;IACtH,KAAK,EAAE,MAAM,CAAC;IACd,+JAA+J;IAC/J,IAAI,EAAE,MAAM,CAAC;IACb,6GAA6G;IAC7G,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AA8CJ,QAAA,MAAM,aAAa,yGAElB,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
import { withRef } from "../../lib/with-ref.js";
|
|
5
|
+
import { CopyButton } from "./copy-button.js";
|
|
6
|
+
function CopyableValueImpl({ ref, className, value, name, truncate = false, onCopy, onCopyRequest, tooltipSide, ...props }) {
|
|
7
|
+
return (_jsxs("span", { ref: ref, "data-slot": "copyable-value", className: cn("inline-flex items-center gap-1", truncate && "min-w-0 max-w-full", className), ...props, children: [_jsx("code", { className: cn("font-mono text-xs", truncate
|
|
8
|
+
? "min-w-0 overflow-hidden text-ellipsis whitespace-pre"
|
|
9
|
+
: "break-all whitespace-pre-wrap"), children: value }), _jsx(CopyButton, { value: value, name: name, onCopy: onCopy, onCopyRequest: onCopyRequest, tooltipSide: tooltipSide, className: "shrink-0" })] }));
|
|
10
|
+
}
|
|
11
|
+
const CopyableValue = withRef(CopyableValueImpl);
|
|
12
|
+
export { CopyableValue };
|
|
13
|
+
//# sourceMappingURL=copyable-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copyable-value.js","sourceRoot":"","sources":["../../../../src/components/ui/copyable-value.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAwB,MAAM,eAAe,CAAC;AAYjE,SAAS,iBAAiB,CAAC,EACzB,GAAG,EACH,SAAS,EACT,KAAK,EACL,IAAI,EACJ,QAAQ,GAAG,KAAK,EAChB,MAAM,EACN,aAAa,EACb,WAAW,EACX,GAAG,KAAK,EACW;IACnB,OAAO,CACL,gBACE,GAAG,EAAE,GAAG,eACE,gBAAgB,EAC1B,SAAS,EAAE,EAAE,CACX,gCAAgC,EAChC,QAAQ,IAAI,oBAAoB,EAChC,SAAS,CACV,KACG,KAAK,aAET,eACE,SAAS,EAAE,EAAE,CACX,mBAAmB,EACnB,QAAQ;oBACN,CAAC,CAAC,sDAAsD;oBACxD,CAAC,CAAC,+BAA+B,CACpC,YAEA,KAAK,GACD,EACP,KAAC,UAAU,IACT,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,SAAS,EAAC,UAAU,GACpB,IACG,CACR,CAAC;AACJ,CAAC;AAED,MAAM,aAAa,GAAG,OAAO,CAC3B,iBAAiB,CAClB,CAAC;AAEF,OAAO,EAAE,aAAa,EAA2B,CAAC"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
type DefinitionTooltipAlign = "top" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "left-start" | "left-end" | "right" | "right-start" | "right-end";
|
|
3
3
|
type DefinitionTooltipProps = {
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* The definition shown when the term is opened. Short text, optionally
|
|
6
|
+
* ending in one link (e.g. "Learn more about variables") — it stays open while hovered and
|
|
7
|
+
* Tab from the term moves into it.
|
|
8
|
+
*/
|
|
5
9
|
definition: React.ReactNode;
|
|
6
10
|
/** The term to define — rendered inline with a dotted underline as the trigger. */
|
|
7
11
|
children: React.ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition-tooltip.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/definition-tooltip.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"definition-tooltip.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/definition-tooltip.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA2C/B,KAAK,sBAAsB,GACvB,KAAK,GACL,WAAW,GACX,SAAS,GACT,QAAQ,GACR,cAAc,GACd,YAAY,GACZ,MAAM,GACN,YAAY,GACZ,UAAU,GACV,OAAO,GACP,aAAa,GACb,WAAW,CAAC;AA0DhB,KAAK,sBAAsB,GAAG;IAC5B;;;;OAIG;IACH,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B,mFAAmF;IACnF,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,oFAAoF;IACpF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,uFAAuF;IACvF,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,yCAAyC;IACzC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,yFAAyF;IACzF,KAAK,CAAC,EAAE,sBAAsB,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;CACpC,CAAC;AAqOF,QAAA,MAAM,iBAAiB,+GAEtB,CAAC;AAEF,OAAO,EACL,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,GAC5B,CAAC"}
|