@stll/ui 0.79.0 → 0.80.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/components/button.d.ts +7 -3
- package/dist/components/button.js +58 -9
- package/dist/components/destructive-confirm-dialog.js +1 -0
- package/dist/components/file-input.d.ts +2 -1
- package/dist/components/file-input.js +2 -1
- package/dist/components/search-field.d.ts +2 -1
- package/dist/components/search-field.js +2 -1
- package/dist/components/secret-input.d.ts +2 -1
- package/dist/components/secret-input.js +2 -1
- package/dist/components/split-button.d.ts +1 -1
- package/dist/components/split-button.js +6 -2
- package/dist/components/tooltip-trigger-helper.d.ts +3 -1
- package/dist/components/tooltip-trigger-helper.js +10 -3
- package/dist/components/tooltip.d.ts +3 -1
- package/dist/components/tooltip.js +25 -20
- package/dist/review/review-decision-actions.d.ts +9 -4
- package/dist/review/review-decision-actions.js +24 -23
- package/dist/review/review-out-of-date-notice.d.ts +2 -4
- package/dist/review/review-out-of-date-notice.js +3 -3
- package/package.json +1 -1
|
@@ -92,7 +92,7 @@ type ButtonProps = Omit<ButtonContract, "children" | "disabled"> & {
|
|
|
92
92
|
shape?: ButtonPlainShape | undefined;
|
|
93
93
|
"data-accessible-disabled"?: "";
|
|
94
94
|
} & useRender.ComponentProps<"button">;
|
|
95
|
-
declare
|
|
95
|
+
declare const Button: (buttonProps: ButtonProps) => import("react").JSX.Element;
|
|
96
96
|
/**
|
|
97
97
|
* How a run shows it can be pressed: underlined like a link, or `plain`, by
|
|
98
98
|
* what it holds (a claim's text mark, which draws its own line), as a plain
|
|
@@ -112,7 +112,11 @@ type ButtonTextRunProps = Omit<ButtonProps, "children" | "className" | "focusRin
|
|
|
112
112
|
className?: string | undefined;
|
|
113
113
|
/** `link` unless the run holds a text mark that draws its own line. */
|
|
114
114
|
variant?: ButtonTextRunVariant | undefined;
|
|
115
|
-
}
|
|
115
|
+
} & ({
|
|
116
|
+
disabled?: false | undefined;
|
|
117
|
+
} | {
|
|
118
|
+
disabledReason: NonNullable<ReactNode>;
|
|
119
|
+
});
|
|
116
120
|
/**
|
|
117
121
|
* A long run of prose that acts as one button: a citation or a
|
|
118
122
|
* cross-reference in reader text. A <button> is an atomic box even at
|
|
@@ -122,5 +126,5 @@ type ButtonTextRunProps = Omit<ButtonProps, "children" | "className" | "focusRin
|
|
|
122
126
|
* <button> it holds, which takes its accessible name from the label. Use
|
|
123
127
|
* `Button size="inline"` for a short action.
|
|
124
128
|
*/
|
|
125
|
-
declare const ButtonTextRun: ({ children, className,
|
|
129
|
+
declare const ButtonTextRun: ({ children, className, variant, ...props }: ButtonTextRunProps) => import("react").JSX.Element;
|
|
126
130
|
export { BUTTON_CONTENT, BUTTON_SIZE_CONTENT, Button, type ButtonFocusRing, type ButtonPlainShape, type ButtonProps, type ButtonSize, ButtonTextRun, type ButtonVariant, buttonAccessibleDisabledClass, buttonVariants };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { BUTTON_DISPOSITION, blockDisabledActivation, blockDisabledKeyActivation, resolveButtonDisposition } from "../lib/button-disposition.js";
|
|
3
3
|
import { rendersNothing } from "../lib/renders-nothing.js";
|
|
4
|
+
import { hasTooltipContent } from "../lib/tooltip-content.js";
|
|
4
5
|
import { cn } from "../lib/utils.js";
|
|
5
6
|
import { BUTTON_BASE_CLASS, BUTTON_DEFAULT_SIZE, BUTTON_LAYOUT_CLASS_NAMES, BUTTON_SIZE_CLASS_NAMES, BUTTON_VARIANT_CLASS_NAMES } from "./button-classes.js";
|
|
6
7
|
import { BUTTON_PLAIN_VARIANT } from "./button.shared.js";
|
|
@@ -8,7 +9,7 @@ import { Loader } from "./loader.js";
|
|
|
8
9
|
import { renderTooltipTrigger } from "./tooltip-trigger-helper.js";
|
|
9
10
|
import { TruncatedText } from "./truncated-text.js";
|
|
10
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { Fragment as Fragment$1, isValidElement } from "react";
|
|
12
|
+
import { Fragment as Fragment$1, isValidElement, useCallback, useId } from "react";
|
|
12
13
|
import { mergeProps } from "@base-ui/react/merge-props";
|
|
13
14
|
import { useRender } from "@base-ui/react/use-render";
|
|
14
15
|
import { panic } from "better-result";
|
|
@@ -174,10 +175,47 @@ const implicitTooltip = (size, accessibleName) => {
|
|
|
174
175
|
default: return panic(`Unhandled button content: ${String(content)}`);
|
|
175
176
|
}
|
|
176
177
|
};
|
|
177
|
-
|
|
178
|
+
const useButtonDescription = ({ disabled, disabledReason, describedBy, render }) => {
|
|
179
|
+
const id = useId();
|
|
180
|
+
const hasReason = disabled === true && hasTooltipContent(disabledReason);
|
|
181
|
+
const plainReason = typeof disabledReason === "string" || typeof disabledReason === "number";
|
|
182
|
+
const ref = useCallback((button) => {
|
|
183
|
+
if (!button || !hasReason || render === void 0) return;
|
|
184
|
+
const previous = button.getAttribute("aria-describedby");
|
|
185
|
+
const merged = [...new Set(`${describedBy ?? ""} ${previous ?? ""} ${id}`.trim().split(/\s+/u))].join(" ");
|
|
186
|
+
button.setAttribute("aria-describedby", merged);
|
|
187
|
+
return () => {
|
|
188
|
+
if (button.getAttribute("aria-describedby") !== merged) return;
|
|
189
|
+
if (previous === null) button.removeAttribute("aria-describedby");
|
|
190
|
+
else button.setAttribute("aria-describedby", previous);
|
|
191
|
+
};
|
|
192
|
+
}, [
|
|
193
|
+
describedBy,
|
|
194
|
+
hasReason,
|
|
195
|
+
id,
|
|
196
|
+
render
|
|
197
|
+
]);
|
|
198
|
+
return {
|
|
199
|
+
ref: hasReason && render !== void 0 ? ref : null,
|
|
200
|
+
describedBy: hasReason && render === void 0 ? [describedBy, id].filter(Boolean).join(" ") : describedBy,
|
|
201
|
+
popupId: hasReason && !plainReason ? id : void 0,
|
|
202
|
+
text: hasReason && plainReason ? {
|
|
203
|
+
id,
|
|
204
|
+
value: disabledReason
|
|
205
|
+
} : void 0
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
const Button = (buttonProps) => {
|
|
209
|
+
const { className, variant: variantProp, size, render, layout, loading, icon, children, disabled, disabledReason, tooltip, selected, focusRing = "outside", shape = "box", "data-accessible-disabled": accessibleDisabled, ...props } = buttonProps;
|
|
178
210
|
const variant = variantProp ?? (size === "inline" ? "link" : void 0);
|
|
179
211
|
const typeValue = render ? void 0 : "button";
|
|
180
212
|
const tooltipContent = disabled === true && disabledReason !== void 0 ? disabledReason : tooltip ?? implicitTooltip(size, props["aria-label"] ?? props.title);
|
|
213
|
+
const description = useButtonDescription({
|
|
214
|
+
disabled,
|
|
215
|
+
disabledReason,
|
|
216
|
+
describedBy: props["aria-describedby"],
|
|
217
|
+
render
|
|
218
|
+
});
|
|
181
219
|
const disposition = resolveButtonDisposition({
|
|
182
220
|
disabled,
|
|
183
221
|
loading,
|
|
@@ -185,6 +223,10 @@ function Button({ className, variant: variantProp, size, render, layout, loading
|
|
|
185
223
|
});
|
|
186
224
|
const isAccessibleDisabled = disposition === BUTTON_DISPOSITION.accessibleDisabled;
|
|
187
225
|
const isActivationPreservingDisabled = accessibleDisabled !== void 0;
|
|
226
|
+
const buttonPropsWithDescription = {
|
|
227
|
+
...props,
|
|
228
|
+
"aria-describedby": description.describedBy
|
|
229
|
+
};
|
|
188
230
|
const defaultProps = {
|
|
189
231
|
children: buttonContent({
|
|
190
232
|
icon,
|
|
@@ -214,20 +256,28 @@ function Button({ className, variant: variantProp, size, render, layout, loading
|
|
|
214
256
|
};
|
|
215
257
|
const button = useRender({
|
|
216
258
|
defaultTagName: "button",
|
|
217
|
-
|
|
259
|
+
ref: description.ref,
|
|
260
|
+
props: isAccessibleDisabled ? mergeProps(defaultProps, buttonPropsWithDescription, {
|
|
218
261
|
onClick: blockDisabledActivation,
|
|
219
262
|
onKeyDown: blockDisabledKeyActivation,
|
|
220
263
|
onKeyUp: blockDisabledKeyActivation,
|
|
221
264
|
onMouseDown: blockDisabledActivation,
|
|
222
265
|
onPointerDown: blockDisabledActivation
|
|
223
|
-
}) : mergeProps(defaultProps,
|
|
266
|
+
}) : mergeProps(defaultProps, buttonPropsWithDescription),
|
|
224
267
|
render
|
|
225
268
|
});
|
|
226
|
-
|
|
269
|
+
const trigger = renderTooltipTrigger({
|
|
227
270
|
tooltip: tooltipContent,
|
|
228
|
-
trigger: button
|
|
271
|
+
trigger: button,
|
|
272
|
+
keepTriggerMounted: Object.hasOwn(buttonProps, "disabledReason"),
|
|
273
|
+
popupDescriptionId: description.popupId
|
|
229
274
|
});
|
|
230
|
-
|
|
275
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [trigger, description.text && /* @__PURE__ */ jsx("span", {
|
|
276
|
+
hidden: true,
|
|
277
|
+
id: description.text.id,
|
|
278
|
+
children: description.text.value
|
|
279
|
+
})] });
|
|
280
|
+
};
|
|
231
281
|
/**
|
|
232
282
|
* What the button shows. Loading never changes its width: with an `icon`,
|
|
233
283
|
* the loader takes the icon's place; without one, the label (already cut to
|
|
@@ -276,13 +326,12 @@ const BUTTON_TEXT_RUN_TARGET_CLASS = "absolute size-px overflow-hidden whitespac
|
|
|
276
326
|
* <button> it holds, which takes its accessible name from the label. Use
|
|
277
327
|
* `Button size="inline"` for a short action.
|
|
278
328
|
*/
|
|
279
|
-
const ButtonTextRun = ({ children, className,
|
|
329
|
+
const ButtonTextRun = ({ children, className, variant = "link", ...props }) => /* @__PURE__ */ jsxs("label", {
|
|
280
330
|
className: cn(BUTTON_TEXT_RUN_CLASS, BUTTON_TEXT_RUN_VARIANT_CLASS[variant], className),
|
|
281
331
|
"data-slot": "button-text-run",
|
|
282
332
|
children: [/* @__PURE__ */ jsx(Button, {
|
|
283
333
|
...props,
|
|
284
334
|
className: BUTTON_TEXT_RUN_TARGET_CLASS,
|
|
285
|
-
disabled,
|
|
286
335
|
focusRing: "outside",
|
|
287
336
|
icon: void 0,
|
|
288
337
|
loading: false,
|
|
@@ -36,6 +36,7 @@ const DestructiveConfirmDialog = ({ cancelLabel, confirmLabel, confirmation, des
|
|
|
36
36
|
children: cancelLabel
|
|
37
37
|
}), /* @__PURE__ */ jsx(Button, {
|
|
38
38
|
disabled: !typedConfirmation.confirmed,
|
|
39
|
+
disabledReason: inputLabel,
|
|
39
40
|
loading,
|
|
40
41
|
onClick: handleConfirmClick,
|
|
41
42
|
variant: "destructive",
|
|
@@ -3,10 +3,11 @@ type FileInputProps = {
|
|
|
3
3
|
"aria-labelledby"?: string | undefined;
|
|
4
4
|
className?: string | undefined;
|
|
5
5
|
disabled?: boolean | undefined;
|
|
6
|
+
disabledReason?: string | undefined;
|
|
6
7
|
file: File | null;
|
|
7
8
|
onFileChange: (file: File) => void;
|
|
8
9
|
chooseLabel: string;
|
|
9
10
|
emptyLabel: string;
|
|
10
11
|
};
|
|
11
|
-
declare const FileInput: ({ accept, "aria-labelledby": labelledBy, className, disabled, file, onFileChange, chooseLabel, emptyLabel }: FileInputProps) => import("react").JSX.Element;
|
|
12
|
+
declare const FileInput: ({ accept, "aria-labelledby": labelledBy, className, disabled, disabledReason, file, onFileChange, chooseLabel, emptyLabel }: FileInputProps) => import("react").JSX.Element;
|
|
12
13
|
export { FileInput, type FileInputProps };
|
|
@@ -7,7 +7,7 @@ import { TruncatedText } from "./truncated-text.js";
|
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { useId } from "react";
|
|
9
9
|
// src/components/file-input.tsx
|
|
10
|
-
const FileInput = ({ accept, "aria-labelledby": labelledBy, className, disabled, file, onFileChange, chooseLabel, emptyLabel }) => {
|
|
10
|
+
const FileInput = ({ accept, "aria-labelledby": labelledBy, className, disabled, disabledReason, file, onFileChange, chooseLabel, emptyLabel }) => {
|
|
11
11
|
const triggerId = useId();
|
|
12
12
|
return /* @__PURE__ */ jsxs("span", {
|
|
13
13
|
className: cn("flex min-w-0 items-center gap-3", className),
|
|
@@ -16,6 +16,7 @@ const FileInput = ({ accept, "aria-labelledby": labelledBy, className, disabled,
|
|
|
16
16
|
"aria-labelledby": labelledBy ? `${labelledBy} ${triggerId}` : void 0,
|
|
17
17
|
"data-slot": "file-input-trigger",
|
|
18
18
|
disabled,
|
|
19
|
+
disabledReason,
|
|
19
20
|
id: triggerId,
|
|
20
21
|
onClick: () => openFilePicker({
|
|
21
22
|
accept,
|
|
@@ -5,6 +5,7 @@ type SearchFieldProps = Omit<React.ComponentProps<typeof InputGroupInput>, "onCh
|
|
|
5
5
|
onValueChange: (value: string) => void;
|
|
6
6
|
/** Accessible name of the clear button; the package ships no copy. */
|
|
7
7
|
clearLabel: string;
|
|
8
|
+
disabledReason?: string | undefined;
|
|
8
9
|
/** Class for the outer group (width, margins). */
|
|
9
10
|
groupClassName?: string;
|
|
10
11
|
};
|
|
@@ -14,5 +15,5 @@ type SearchFieldProps = Omit<React.ComponentProps<typeof InputGroupInput>, "onCh
|
|
|
14
15
|
* and the matching; keep matching local and instant for lists under a few
|
|
15
16
|
* hundred rows.
|
|
16
17
|
*/
|
|
17
|
-
declare const SearchField: ({ value, onValueChange, clearLabel, groupClassName, className, onKeyDown, ...props }: SearchFieldProps) => React.JSX.Element;
|
|
18
|
+
declare const SearchField: ({ value, onValueChange, clearLabel, disabledReason, groupClassName, className, onKeyDown, ...props }: SearchFieldProps) => React.JSX.Element;
|
|
18
19
|
export { SearchField, type SearchFieldProps };
|
|
@@ -11,7 +11,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
* and the matching; keep matching local and instant for lists under a few
|
|
12
12
|
* hundred rows.
|
|
13
13
|
*/
|
|
14
|
-
const SearchField = ({ value, onValueChange, clearLabel, groupClassName, className, onKeyDown, ...props }) => /* @__PURE__ */ jsxs(InputGroup, {
|
|
14
|
+
const SearchField = ({ value, onValueChange, clearLabel, disabledReason, groupClassName, className, onKeyDown, ...props }) => /* @__PURE__ */ jsxs(InputGroup, {
|
|
15
15
|
className: cn("min-h-11 sm:min-h-0", groupClassName),
|
|
16
16
|
children: [/* @__PURE__ */ jsx(InputGroupInput, {
|
|
17
17
|
autoComplete: "off",
|
|
@@ -36,6 +36,7 @@ const SearchField = ({ value, onValueChange, clearLabel, groupClassName, classNa
|
|
|
36
36
|
children: /* @__PURE__ */ jsx(Button, {
|
|
37
37
|
"aria-label": clearLabel,
|
|
38
38
|
disabled: props.disabled,
|
|
39
|
+
disabledReason,
|
|
39
40
|
onClick: () => {
|
|
40
41
|
onValueChange("");
|
|
41
42
|
},
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { InputProps } from "./input.js";
|
|
2
2
|
type SecretInputProps = Omit<InputProps, "type"> & {
|
|
3
3
|
hideValueLabel: string;
|
|
4
|
+
disabledReason?: string | undefined;
|
|
4
5
|
showValueLabel: string;
|
|
5
6
|
};
|
|
6
|
-
declare const SecretInput: ({ className, dir, disabled, hideValueLabel, showValueLabel, ...props }: SecretInputProps) => import("react").JSX.Element;
|
|
7
|
+
declare const SecretInput: ({ className, dir, disabled, hideValueLabel, disabledReason, showValueLabel, ...props }: SecretInputProps) => import("react").JSX.Element;
|
|
7
8
|
export { SecretInput, type SecretInputProps };
|
|
@@ -6,7 +6,7 @@ import { Input } from "./input.js";
|
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { useState } from "react";
|
|
8
8
|
// src/components/secret-input.tsx
|
|
9
|
-
const SecretInput = ({ className, dir, disabled, hideValueLabel, showValueLabel, ...props }) => {
|
|
9
|
+
const SecretInput = ({ className, dir, disabled, hideValueLabel, disabledReason, showValueLabel, ...props }) => {
|
|
10
10
|
const [visibility, setVisibility] = useState("concealed");
|
|
11
11
|
const isRevealed = visibility === "revealed";
|
|
12
12
|
const label = isRevealed ? hideValueLabel : showValueLabel;
|
|
@@ -26,6 +26,7 @@ const SecretInput = ({ className, dir, disabled, hideValueLabel, showValueLabel,
|
|
|
26
26
|
className: "text-muted-foreground hover:text-foreground absolute end-1 top-1/2 z-1 -translate-y-1/2",
|
|
27
27
|
"data-slot": "secret-input-visibility-toggle",
|
|
28
28
|
disabled,
|
|
29
|
+
disabledReason,
|
|
29
30
|
onClick: () => setVisibility(isRevealed ? "concealed" : "revealed"),
|
|
30
31
|
size: "icon-xs",
|
|
31
32
|
type: "button",
|
|
@@ -9,7 +9,7 @@ type SplitButtonSharedProps = {
|
|
|
9
9
|
menuDescriptionId?: string;
|
|
10
10
|
onPrimaryClick: NonNullable<ComponentProps<typeof Button>["onClick"]>;
|
|
11
11
|
menu: ReactNode;
|
|
12
|
-
|
|
12
|
+
primaryDisabledReason?: string | undefined;
|
|
13
13
|
menuDisabled?: boolean;
|
|
14
14
|
size?: SplitButtonSize;
|
|
15
15
|
className?: string;
|
|
@@ -13,7 +13,11 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
* never reads as disabled beside its neighbours.
|
|
14
14
|
*/
|
|
15
15
|
const SplitButton = (props) => {
|
|
16
|
-
const { primaryLabel, menuLabel, primaryDescriptionId, menuDescriptionId, onPrimaryClick, children, menu,
|
|
16
|
+
const { primaryLabel, menuLabel, primaryDescriptionId, menuDescriptionId, onPrimaryClick, children, menu, primaryDisabledReason, menuDisabled, size = "md", className } = props;
|
|
17
|
+
const primaryState = Object.hasOwn(props, "primaryDisabledReason") ? {
|
|
18
|
+
disabled: primaryDisabledReason !== void 0,
|
|
19
|
+
disabledReason: primaryDisabledReason
|
|
20
|
+
} : {};
|
|
17
21
|
const triggerButton = /* @__PURE__ */ jsx(Button, {
|
|
18
22
|
className: SPLIT_BUTTON_TRIGGER_CLASS[size],
|
|
19
23
|
size: "sm",
|
|
@@ -28,7 +32,7 @@ const SplitButton = (props) => {
|
|
|
28
32
|
"aria-describedby": primaryDescriptionId,
|
|
29
33
|
"aria-label": primaryLabel,
|
|
30
34
|
className: SPLIT_BUTTON_PRIMARY_CLASS[size],
|
|
31
|
-
|
|
35
|
+
...primaryState,
|
|
32
36
|
onClick: onPrimaryClick,
|
|
33
37
|
size: "sm",
|
|
34
38
|
tooltip: props.primaryContent === BUTTON_CONTENT.icon ? primaryLabel : void 0,
|
|
@@ -2,11 +2,13 @@ import * as React from "react";
|
|
|
2
2
|
type TooltipTriggerOptions = {
|
|
3
3
|
trigger: React.ReactElement;
|
|
4
4
|
tooltip: React.ReactNode;
|
|
5
|
+
keepTriggerMounted?: boolean;
|
|
6
|
+
popupDescriptionId?: string | undefined;
|
|
5
7
|
};
|
|
6
8
|
/**
|
|
7
9
|
* Overlay triggers pass only an explicit `tooltip`. They cannot tell whether
|
|
8
10
|
* their content is a label or a glyph; a trigger rendered as `Button` hands its
|
|
9
11
|
* `aria-label` to that Button, whose size decides (see `BUTTON_SIZE_CONTENT`).
|
|
10
12
|
*/
|
|
11
|
-
declare const renderTooltipTrigger: ({ trigger, tooltip }: TooltipTriggerOptions) => React.JSX.Element;
|
|
13
|
+
declare const renderTooltipTrigger: ({ trigger, tooltip, keepTriggerMounted, popupDescriptionId }: TooltipTriggerOptions) => React.JSX.Element;
|
|
12
14
|
export { renderTooltipTrigger };
|
|
@@ -8,8 +8,15 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
8
8
|
* their content is a label or a glyph; a trigger rendered as `Button` hands its
|
|
9
9
|
* `aria-label` to that Button, whose size decides (see `BUTTON_SIZE_CONTENT`).
|
|
10
10
|
*/
|
|
11
|
-
const renderTooltipTrigger = ({ trigger, tooltip }) => {
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const renderTooltipTrigger = ({ trigger, tooltip, keepTriggerMounted = false, popupDescriptionId }) => {
|
|
12
|
+
const hasContent = hasTooltipContent(tooltip);
|
|
13
|
+
if (!hasContent && !keepTriggerMounted) return trigger;
|
|
14
|
+
return /* @__PURE__ */ jsxs(Tooltip, {
|
|
15
|
+
disabled: !hasContent,
|
|
16
|
+
children: [/* @__PURE__ */ jsx(TooltipTrigger, { render: trigger }), hasContent && /* @__PURE__ */ jsx(TooltipPopup, {
|
|
17
|
+
descriptionId: popupDescriptionId,
|
|
18
|
+
children: tooltip
|
|
19
|
+
})]
|
|
20
|
+
});
|
|
14
21
|
};
|
|
15
22
|
export { renderTooltipTrigger };
|
|
@@ -27,12 +27,14 @@ declare const TooltipTrigger: (props: Tooltip$1.Trigger.Props) => import("react"
|
|
|
27
27
|
declare const TooltipFactTrigger: ({ children }: {
|
|
28
28
|
children: ReactNode;
|
|
29
29
|
}) => import("react").JSX.Element;
|
|
30
|
-
declare const TooltipPopup: ({ anchor, className, align, sideOffset, side, children, shortcut, ...props }: Tooltip$1.Popup.Props & {
|
|
30
|
+
declare const TooltipPopup: ({ anchor, className, align, sideOffset, side, children, shortcut, descriptionId, ...props }: Tooltip$1.Popup.Props & {
|
|
31
31
|
/**
|
|
32
32
|
* The keys that do the same as the trigger, shown after the label and
|
|
33
33
|
* spelled for the reader's platform (`["mod", "K"]`).
|
|
34
34
|
*/
|
|
35
35
|
shortcut?: KbdKeys | undefined;
|
|
36
|
+
/** Keep the popup as a single accessible description target when closed. */
|
|
37
|
+
descriptionId?: string | undefined;
|
|
36
38
|
/**
|
|
37
39
|
* The element the popup sits beside, when that is a part of the trigger
|
|
38
40
|
* rather than all of it (a wide row whose tooltip explains one detail).
|
|
@@ -41,27 +41,32 @@ const TooltipFactTrigger = ({ children }) => /* @__PURE__ */ jsx(Tooltip$1.Trigg
|
|
|
41
41
|
type: "button",
|
|
42
42
|
children
|
|
43
43
|
});
|
|
44
|
-
const TooltipPopup = ({ anchor, className, align = "center", sideOffset = 4, side = "top", children, shortcut, ...props }) => /* @__PURE__ */ jsx(Tooltip$1.Portal, {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"data-
|
|
62
|
-
|
|
44
|
+
const TooltipPopup = ({ anchor, className, align = "center", sideOffset = 4, side = "top", children, shortcut, descriptionId, ...props }) => /* @__PURE__ */ jsx(Tooltip$1.Portal, {
|
|
45
|
+
keepMounted: descriptionId !== void 0,
|
|
46
|
+
children: /* @__PURE__ */ jsx(Tooltip$1.Positioner, {
|
|
47
|
+
id: descriptionId,
|
|
48
|
+
...anchor === void 0 ? {} : { anchor },
|
|
49
|
+
align,
|
|
50
|
+
className: cn(CONTENT_SIZED_POSITIONER_CLASS_NAME, "transition-[top,left,right,bottom,transform] data-instant:transition-none", OVERLAY_LAYER_CLASS_NAMES.popup),
|
|
51
|
+
collisionPadding: 8,
|
|
52
|
+
"data-slot": "tooltip-positioner",
|
|
53
|
+
side,
|
|
54
|
+
sideOffset,
|
|
55
|
+
children: /* @__PURE__ */ jsx(Tooltip$1.Popup, {
|
|
56
|
+
className: cn(IN_FLOW_POPUP_CLASS_NAME, "bg-popover text-popover-foreground flex h-(--popup-height,auto) w-(--popup-width,auto) origin-(--transform-origin) rounded-md border text-xs text-balance shadow-md/5 transition-[width,height,scale,opacity] not-dark:bg-clip-padding before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-md)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-ending-style:scale-98 data-ending-style:opacity-0 data-instant:duration-0 data-starting-style:scale-98 data-starting-style:opacity-0 dark:before:shadow-[0_-1px_--theme(--color-white/6%)]", className),
|
|
57
|
+
"data-slot": "tooltip-popup",
|
|
58
|
+
role: descriptionId === void 0 ? void 0 : "tooltip",
|
|
59
|
+
...props,
|
|
60
|
+
children: /* @__PURE__ */ jsx(Tooltip$1.Viewport, {
|
|
61
|
+
className: "relative size-full overflow-clip px-(--viewport-inline-padding) py-1 [--viewport-inline-padding:--spacing(2)] **:data-current:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-current:opacity-100 **:data-current:transition-opacity **:data-current:data-ending-style:opacity-0 data-instant:transition-none **:data-previous:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-previous:truncate **:data-previous:opacity-100 **:data-previous:transition-opacity **:data-previous:data-ending-style:opacity-0 **:data-current:data-starting-style:opacity-0 **:data-previous:data-starting-style:opacity-0",
|
|
62
|
+
"data-slot": "tooltip-viewport",
|
|
63
|
+
children: shortcut === void 0 ? children : /* @__PURE__ */ jsxs("span", {
|
|
64
|
+
className: "flex flex-wrap items-center gap-x-2 gap-y-1",
|
|
65
|
+
"data-slot": "tooltip-shortcut-row",
|
|
66
|
+
children: [children, /* @__PURE__ */ jsx(Kbd, { keys: shortcut })]
|
|
67
|
+
})
|
|
63
68
|
})
|
|
64
69
|
})
|
|
65
70
|
})
|
|
66
|
-
})
|
|
71
|
+
});
|
|
67
72
|
export { TOOLTIP_OPEN_DELAY_MS, Tooltip, TooltipPopup as TooltipContent, TooltipPopup, TooltipCreateHandle, TooltipFactTrigger, TooltipProvider, TooltipTrigger };
|
|
@@ -14,7 +14,6 @@ export type ReviewDecisionSize = "xs" | "sm";
|
|
|
14
14
|
*/
|
|
15
15
|
export type ReviewDecisionEmphasis = "primary" | "quiet";
|
|
16
16
|
type ReviewDecisionActionsProps = {
|
|
17
|
-
state: ReviewDecisionState;
|
|
18
17
|
onAccept?: (() => void) | undefined;
|
|
19
18
|
onReject?: (() => void) | undefined;
|
|
20
19
|
onRevert?: (() => void) | undefined;
|
|
@@ -29,9 +28,15 @@ type ReviewDecisionActionsProps = {
|
|
|
29
28
|
reopenLabel?: string | undefined;
|
|
30
29
|
acceptTooltip?: ReactNode;
|
|
31
30
|
rejectTooltip?: ReactNode;
|
|
32
|
-
|
|
31
|
+
disabledReason?: string | undefined;
|
|
33
32
|
className?: string;
|
|
34
|
-
}
|
|
33
|
+
} & ({
|
|
34
|
+
state: Exclude<ReviewDecisionState, "applying">;
|
|
35
|
+
applyingReason?: never;
|
|
36
|
+
} | {
|
|
37
|
+
state: ReviewDecisionState;
|
|
38
|
+
applyingReason: string;
|
|
39
|
+
});
|
|
35
40
|
/** Accept / reject / revert / reopen, in one shape, for every review surface. */
|
|
36
|
-
export declare const ReviewDecisionActions: ({ state, onAccept, onReject, onRevert, onReopen, size, emphasis, acceptLabel, rejectLabel, revertLabel, reopenLabel, acceptTooltip, rejectTooltip,
|
|
41
|
+
export declare const ReviewDecisionActions: ({ state, onAccept, onReject, onRevert, onReopen, size, emphasis, acceptLabel, rejectLabel, revertLabel, reopenLabel, acceptTooltip, rejectTooltip, disabledReason, applyingReason, className }: ReviewDecisionActionsProps) => import("react").JSX.Element | null;
|
|
37
42
|
export {};
|
|
@@ -13,11 +13,11 @@ const REJECT_VARIANT = {
|
|
|
13
13
|
quiet: "ghost"
|
|
14
14
|
};
|
|
15
15
|
/** Accept / reject / revert / reopen, in one shape, for every review surface. */
|
|
16
|
-
const ReviewDecisionActions = ({ state, onAccept, onReject, onRevert, onReopen, size = "sm", emphasis = "primary", acceptLabel, rejectLabel, revertLabel, reopenLabel, acceptTooltip, rejectTooltip,
|
|
16
|
+
const ReviewDecisionActions = ({ state, onAccept, onReject, onRevert, onReopen, size = "sm", emphasis = "primary", acceptLabel, rejectLabel, revertLabel, reopenLabel, acceptTooltip, rejectTooltip, disabledReason, applyingReason, className }) => {
|
|
17
17
|
const controls = renderControls({
|
|
18
18
|
acceptLabel,
|
|
19
19
|
acceptTooltip,
|
|
20
|
-
|
|
20
|
+
disabledReason: state === "applying" ? applyingReason : disabledReason,
|
|
21
21
|
emphasis,
|
|
22
22
|
onAccept,
|
|
23
23
|
onReject,
|
|
@@ -37,40 +37,41 @@ const ReviewDecisionActions = ({ state, onAccept, onReject, onRevert, onReopen,
|
|
|
37
37
|
children: controls
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
|
-
const renderControls = ({ acceptLabel, acceptTooltip,
|
|
40
|
+
const renderControls = ({ acceptLabel, acceptTooltip, disabledReason, emphasis, onAccept, onReject, onReopen, onRevert, rejectLabel, rejectTooltip, reopenLabel, revertLabel, size, state }) => {
|
|
41
41
|
switch (state) {
|
|
42
42
|
case "pending":
|
|
43
|
-
case "applying": {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
43
|
+
case "applying": return /* @__PURE__ */ jsxs(Fragment, { children: [onAccept === void 0 ? null : /* @__PURE__ */ jsxs(Button, {
|
|
44
|
+
disabled: disabledReason !== void 0,
|
|
45
|
+
disabledReason,
|
|
46
|
+
onClick: onAccept,
|
|
47
|
+
size,
|
|
48
|
+
tooltip: acceptTooltip,
|
|
49
|
+
variant: ACCEPT_VARIANT[emphasis],
|
|
50
|
+
children: [/* @__PURE__ */ jsx(CheckIcon, {}), acceptLabel]
|
|
51
|
+
}), onReject === void 0 ? null : /* @__PURE__ */ jsxs(Button, {
|
|
52
|
+
disabled: disabledReason !== void 0,
|
|
53
|
+
disabledReason,
|
|
54
|
+
onClick: onReject,
|
|
55
|
+
size,
|
|
56
|
+
tooltip: rejectTooltip,
|
|
57
|
+
variant: REJECT_VARIANT[emphasis],
|
|
58
|
+
children: [/* @__PURE__ */ jsx(XIcon, {}), rejectLabel]
|
|
59
|
+
})] });
|
|
61
60
|
case "accepted":
|
|
62
61
|
case "rejected":
|
|
63
62
|
case "dismissed":
|
|
64
63
|
if (onRevert === void 0 && onReopen === void 0) return null;
|
|
65
64
|
return /* @__PURE__ */ jsxs(Fragment, { children: [onRevert === void 0 ? null : /* @__PURE__ */ jsx(Button, {
|
|
66
|
-
disabled,
|
|
65
|
+
disabled: disabledReason !== void 0,
|
|
66
|
+
disabledReason,
|
|
67
67
|
onClick: onRevert,
|
|
68
68
|
size,
|
|
69
69
|
variant: "muted",
|
|
70
70
|
children: revertLabel
|
|
71
71
|
}), onReopen === void 0 ? null : /* @__PURE__ */ jsx(Button, {
|
|
72
72
|
"aria-label": reopenLabel,
|
|
73
|
-
disabled,
|
|
73
|
+
disabled: disabledReason !== void 0,
|
|
74
|
+
disabledReason,
|
|
74
75
|
onClick: onReopen,
|
|
75
76
|
size: size === "xs" ? "icon-xs" : "icon-sm",
|
|
76
77
|
variant: "ghost",
|
|
@@ -16,10 +16,8 @@ type ReviewOutOfDateNoticeProps = {
|
|
|
16
16
|
onAction?: (() => void) | undefined;
|
|
17
17
|
/** The action is running: its button shows it and takes no second press. */
|
|
18
18
|
actionPending?: boolean;
|
|
19
|
-
/** The action is not available now. */
|
|
20
|
-
actionDisabled?: boolean;
|
|
21
19
|
/** Why the action is not available now, shown on hover over it. */
|
|
22
|
-
actionDisabledReason?:
|
|
20
|
+
actionDisabledReason?: string | undefined;
|
|
23
21
|
tone?: ReviewOutOfDateTone;
|
|
24
22
|
className?: string;
|
|
25
23
|
};
|
|
@@ -28,5 +26,5 @@ type ReviewOutOfDateNoticeProps = {
|
|
|
28
26
|
* together: they are different reasons to run again, and a reviewer working
|
|
29
27
|
* through findings should see each one rather than the first.
|
|
30
28
|
*/
|
|
31
|
-
export declare const ReviewOutOfDateNotice: ({ reasons, actionLabel, onAction, actionPending,
|
|
29
|
+
export declare const ReviewOutOfDateNotice: ({ reasons, actionLabel, onAction, actionPending, actionDisabledReason, tone, className }: ReviewOutOfDateNoticeProps) => import("react").JSX.Element | null;
|
|
32
30
|
export {};
|
|
@@ -7,7 +7,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
7
7
|
* together: they are different reasons to run again, and a reviewer working
|
|
8
8
|
* through findings should see each one rather than the first.
|
|
9
9
|
*/
|
|
10
|
-
const ReviewOutOfDateNotice = ({ reasons, actionLabel, onAction, actionPending = false,
|
|
10
|
+
const ReviewOutOfDateNotice = ({ reasons, actionLabel, onAction, actionPending = false, actionDisabledReason, tone = "warning", className }) => {
|
|
11
11
|
if (reasons.length === 0) return null;
|
|
12
12
|
return /* @__PURE__ */ jsxs("div", {
|
|
13
13
|
className: cn("mb-2 rounded-lg border px-3 py-2", TONE_CLASS[tone], className),
|
|
@@ -17,11 +17,11 @@ const ReviewOutOfDateNotice = ({ reasons, actionLabel, onAction, actionPending =
|
|
|
17
17
|
children: reasons.map((reason) => /* @__PURE__ */ jsx("li", { children: reason.label }, reason.id))
|
|
18
18
|
}), onAction === void 0 ? null : /* @__PURE__ */ jsx(Button, {
|
|
19
19
|
className: "mt-2",
|
|
20
|
-
disabled:
|
|
20
|
+
disabled: actionDisabledReason !== void 0,
|
|
21
|
+
disabledReason: actionDisabledReason,
|
|
21
22
|
loading: actionPending,
|
|
22
23
|
onClick: onAction,
|
|
23
24
|
size: "xs",
|
|
24
|
-
tooltip: actionDisabled ? actionDisabledReason : void 0,
|
|
25
25
|
variant: "outline",
|
|
26
26
|
children: actionLabel
|
|
27
27
|
})]
|
package/package.json
CHANGED