@danxbot/ui 11.0.0 → 11.1.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.js +28839 -28642
- package/dist/index.js.map +1 -1
- package/dist/types/components/EditGutter.d.ts +20 -0
- package/dist/types/components/InlineEdit.d.ts +23 -15
- package/dist/types/components/InlineMarkdownEdit.d.ts +37 -0
- package/dist/types/components/MarkdownEditor.d.ts +7 -1
- package/dist/types/components/code-editor/recipe.d.ts +3 -3
- package/dist/types/components/edit/outcome.d.ts +30 -0
- package/dist/types/index.d.ts +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
/** The controlled activation pair every pencil-activated field takes. */
|
|
3
|
+
export interface EditActivation {
|
|
4
|
+
editing: boolean;
|
|
5
|
+
onEditingChange: (editing: boolean) => void;
|
|
6
|
+
}
|
|
7
|
+
export interface EditGutterProps {
|
|
8
|
+
/**
|
|
9
|
+
* The pencil's accessible name — say WHAT it edits ("Edit title"), because
|
|
10
|
+
* a screen reader lists it among every other pencil on the page.
|
|
11
|
+
*/
|
|
12
|
+
label: string;
|
|
13
|
+
/**
|
|
14
|
+
* Render the field, spreading the activation onto it:
|
|
15
|
+
* `{(edit) => <InlineEdit {...edit} … />}`.
|
|
16
|
+
*/
|
|
17
|
+
children: (activation: EditActivation) => ReactNode;
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function EditGutter({ label, children, className }: EditGutterProps): import("react").JSX.Element;
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { type Ref } from "react";
|
|
2
2
|
import { useRender } from "@base-ui/react/use-render";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Unchanged from 5.2.1 — see `InlineEditOutcome`.
|
|
6
|
-
*/
|
|
7
|
-
export interface InlineEditRefusal {
|
|
8
|
-
refusal: string;
|
|
9
|
-
}
|
|
10
|
-
/** What `onCommit` may report. Returning nothing accepts the value. */
|
|
11
|
-
export type InlineEditOutcome = void | InlineEditRefusal;
|
|
3
|
+
import { type InlineEditCommit } from "./edit/outcome";
|
|
4
|
+
export type { InlineEditCommit, InlineEditOutcome, InlineEditRefusal } from "./edit/outcome";
|
|
12
5
|
export interface InlineEditProps {
|
|
13
6
|
/**
|
|
14
7
|
* The committed value. Controlled — this component never holds the truth,
|
|
@@ -30,7 +23,7 @@ export interface InlineEditProps {
|
|
|
30
23
|
* it settles. Resolve/return `{ refusal }` to reject the value with a
|
|
31
24
|
* reason; throw or reject to report that the save itself failed.
|
|
32
25
|
*/
|
|
33
|
-
onCommit:
|
|
26
|
+
onCommit: InlineEditCommit;
|
|
34
27
|
/**
|
|
35
28
|
* The refusals that are knowable WITHOUT a request. Return the reason, or
|
|
36
29
|
* `null` to accept. Runs after the unchanged check and before `onCommit`.
|
|
@@ -115,10 +108,25 @@ export interface InlineEditProps {
|
|
|
115
108
|
/** The rejected error, handed on so it can be logged or reported. */
|
|
116
109
|
onError?: (error: unknown) => void;
|
|
117
110
|
/**
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
111
|
+
* CONTROLLED ACTIVATION (DX-3372). Pass it and the control never opens
|
|
112
|
+
* ITSELF — no click, Enter or F2 — because something else (the pencil of an
|
|
113
|
+
* `EditGutter`, a menu item, a shortcut) is the way in. Setting it `true`
|
|
114
|
+
* opens the field, focused, caret at the end; the control asks to close
|
|
115
|
+
* through `onEditingChange(false)` once a commit lands or Escape cancels.
|
|
116
|
+
* Setting it `false` yourself while it is open abandons the draft exactly as
|
|
117
|
+
* Escape would — nothing is written. At rest the element leaves the tab
|
|
118
|
+
* order and drops its hover affordance, so the trigger is the one stop.
|
|
119
|
+
*
|
|
120
|
+
* Omit it for the self-opening control (click, Enter or F2).
|
|
121
|
+
*/
|
|
122
|
+
editing?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Fires exactly when the control itself starts or ends editing — never while
|
|
125
|
+
* a read-only control merely declines to open, and never for a change the
|
|
126
|
+
* caller made through `editing`. Use it to suspend any re-render-from-server
|
|
127
|
+
* logic of your own for as long as someone is actually looking at the
|
|
128
|
+
* field; see the module comment. With `editing` controlled, this is how the
|
|
129
|
+
* control hands the closed state back.
|
|
122
130
|
*/
|
|
123
131
|
onEditingChange?: (editing: boolean) => void;
|
|
124
132
|
/** Render as a different element — see `Button`'s own `render` for the shape. */
|
|
@@ -135,4 +143,4 @@ export interface InlineEditProps {
|
|
|
135
143
|
messageClassName?: string;
|
|
136
144
|
ref?: Ref<HTMLElement>;
|
|
137
145
|
}
|
|
138
|
-
export declare function InlineEdit({ value, onCommit, validate, liveValidate, label, placeholder, size, multiline, autosaveMs, readOnly, failureMessage, onError, onEditingChange, render, className, messageClassName, inputMode, ref, }: InlineEditProps): import("react").JSX.Element;
|
|
146
|
+
export declare function InlineEdit({ value, onCommit, validate, liveValidate, label, placeholder, size, multiline, autosaveMs, readOnly, failureMessage, onError, editing: editingProp, onEditingChange, render, className, messageClassName, inputMode, ref, }: InlineEditProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { ImageUploader } from "../lib/markdown/image-pipeline";
|
|
3
|
+
import { type InlineEditCommit } from "./edit/outcome";
|
|
4
|
+
export interface InlineMarkdownEditProps {
|
|
5
|
+
/** The committed markdown. Controlled — the field only ever holds a draft. */
|
|
6
|
+
value: string;
|
|
7
|
+
/**
|
|
8
|
+
* Commit a new value — the same contract as `InlineEdit.onCommit`: called
|
|
9
|
+
* only when the draft differs from `value`, with `base` = the value editing
|
|
10
|
+
* began from; return/resolve `{ refusal }` to refuse with a reason, throw or
|
|
11
|
+
* reject to report a failed save.
|
|
12
|
+
*/
|
|
13
|
+
onCommit: InlineEditCommit;
|
|
14
|
+
/** Whether the editor is open. REQUIRED — see the module comment. */
|
|
15
|
+
editing: boolean;
|
|
16
|
+
/** The field asks to close through this, once a commit lands or Escape cancels. */
|
|
17
|
+
onEditingChange: (editing: boolean) => void;
|
|
18
|
+
/** The accessible name of the field and of its editor. */
|
|
19
|
+
label: string;
|
|
20
|
+
/** Shown at rest and in the editor when the value is empty. @default "Empty" */
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
/** Collapse the rendered view to this many lines behind a `ReadMore`. */
|
|
23
|
+
collapsedLines?: number;
|
|
24
|
+
/** Extra toolbar content for the editor, after its built-in groups. */
|
|
25
|
+
toolbar?: ReactNode;
|
|
26
|
+
/** Stores a pasted/dropped/picked image — see `MarkdownEditorProps.uploadImage`. */
|
|
27
|
+
uploadImage?: ImageUploader;
|
|
28
|
+
/**
|
|
29
|
+
* What is shown when the commit REJECTS (never a `{ refusal }`, which
|
|
30
|
+
* renders its own text).
|
|
31
|
+
*/
|
|
32
|
+
failureMessage?: string;
|
|
33
|
+
/** The rejected error, handed on so it can be logged or reported. */
|
|
34
|
+
onError?: (error: unknown) => void;
|
|
35
|
+
className?: string;
|
|
36
|
+
}
|
|
37
|
+
export declare function InlineMarkdownEdit({ value, onCommit, editing, onEditingChange, label, placeholder, collapsedLines, toolbar, uploadImage, failureMessage, onError, className, }: InlineMarkdownEditProps): import("react").JSX.Element;
|
|
@@ -10,7 +10,13 @@ import { type ImageUploadState, type ImageUploader } from "../lib/markdown/image
|
|
|
10
10
|
* contenteditable host, never a proxy element.
|
|
11
11
|
*/
|
|
12
12
|
export interface MarkdownEditorHandle {
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Focus the surface. `caret` places the caret at the document's `"start"` or
|
|
15
|
+
* `"end"` (snapped to a real caret stop); omit it to leave the caret wherever
|
|
16
|
+
* the browser puts it. DX-3372: `InlineMarkdownEdit` opens with the caret at
|
|
17
|
+
* the end, the same place `InlineEdit` puts it.
|
|
18
|
+
*/
|
|
19
|
+
focus: (caret?: "start" | "end") => void;
|
|
14
20
|
}
|
|
15
21
|
export interface MarkdownEditorProps {
|
|
16
22
|
/** The markdown. Controlled when `onChange` is given. */
|
|
@@ -9,11 +9,11 @@ export declare const code: import("tailwind-variants").TVReturnType<{
|
|
|
9
9
|
footer?: import("tailwind-variants").ClassValue;
|
|
10
10
|
hint?: import("tailwind-variants").ClassValue;
|
|
11
11
|
root?: import("tailwind-variants").ClassValue;
|
|
12
|
-
control?: import("tailwind-variants").ClassValue;
|
|
13
12
|
rendered?: import("tailwind-variants").ClassValue;
|
|
14
13
|
layers?: import("tailwind-variants").ClassValue;
|
|
15
14
|
gutter?: import("tailwind-variants").ClassValue;
|
|
16
15
|
fade?: import("tailwind-variants").ClassValue;
|
|
16
|
+
control?: import("tailwind-variants").ClassValue;
|
|
17
17
|
scroller?: import("tailwind-variants").ClassValue;
|
|
18
18
|
expand?: import("tailwind-variants").ClassValue;
|
|
19
19
|
};
|
|
@@ -29,11 +29,11 @@ export declare const code: import("tailwind-variants").TVReturnType<{
|
|
|
29
29
|
footer?: import("tailwind-variants").ClassValue;
|
|
30
30
|
hint?: import("tailwind-variants").ClassValue;
|
|
31
31
|
root?: import("tailwind-variants").ClassValue;
|
|
32
|
-
control?: import("tailwind-variants").ClassValue;
|
|
33
32
|
rendered?: import("tailwind-variants").ClassValue;
|
|
34
33
|
layers?: import("tailwind-variants").ClassValue;
|
|
35
34
|
gutter?: import("tailwind-variants").ClassValue;
|
|
36
35
|
fade?: import("tailwind-variants").ClassValue;
|
|
36
|
+
control?: import("tailwind-variants").ClassValue;
|
|
37
37
|
scroller?: import("tailwind-variants").ClassValue;
|
|
38
38
|
expand?: import("tailwind-variants").ClassValue;
|
|
39
39
|
};
|
|
@@ -65,11 +65,11 @@ export declare const code: import("tailwind-variants").TVReturnType<{
|
|
|
65
65
|
footer?: import("tailwind-variants").ClassValue;
|
|
66
66
|
hint?: import("tailwind-variants").ClassValue;
|
|
67
67
|
root?: import("tailwind-variants").ClassValue;
|
|
68
|
-
control?: import("tailwind-variants").ClassValue;
|
|
69
68
|
rendered?: import("tailwind-variants").ClassValue;
|
|
70
69
|
layers?: import("tailwind-variants").ClassValue;
|
|
71
70
|
gutter?: import("tailwind-variants").ClassValue;
|
|
72
71
|
fade?: import("tailwind-variants").ClassValue;
|
|
72
|
+
control?: import("tailwind-variants").ClassValue;
|
|
73
73
|
scroller?: import("tailwind-variants").ClassValue;
|
|
74
74
|
expand?: import("tailwind-variants").ClassValue;
|
|
75
75
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The caller's refusal of a value, with the reason that will be shown.
|
|
3
|
+
*/
|
|
4
|
+
export interface InlineEditRefusal {
|
|
5
|
+
refusal: string;
|
|
6
|
+
}
|
|
7
|
+
/** What `onCommit` may report. Returning nothing accepts the value. */
|
|
8
|
+
export type InlineEditOutcome = void | InlineEditRefusal;
|
|
9
|
+
/** Every in-place editor's `onCommit`: the new value and the value editing began from. */
|
|
10
|
+
export type InlineEditCommit = (value: string, base: string) => InlineEditOutcome | Promise<InlineEditOutcome>;
|
|
11
|
+
export declare function isRefusal(outcome: InlineEditOutcome): outcome is InlineEditRefusal;
|
|
12
|
+
export declare function isPromise(outcome: InlineEditOutcome | Promise<InlineEditOutcome>): outcome is Promise<InlineEditOutcome>;
|
|
13
|
+
export declare const DEFAULT_FAILURE = "Could not save. Your text is still here \u2014 press Enter to try again.";
|
|
14
|
+
/**
|
|
15
|
+
* A refusal nobody can read leaves the field open with nothing beside it — the
|
|
16
|
+
* exact silent failure the outcome contract exists to rule out — so an empty
|
|
17
|
+
* reason is a programming error, thrown rather than rendered.
|
|
18
|
+
*/
|
|
19
|
+
export declare function assertReadableRefusal(component: string, reason: string, source: "validate" | "onCommit"): void;
|
|
20
|
+
/**
|
|
21
|
+
* THE MESSAGE IS AN OVERLAY, for the reason `InlineEdit` measured: in normal
|
|
22
|
+
* flow a refusal grows the control's own wrapper, which inside a fixed-height
|
|
23
|
+
* row shoves everything beside it. Absolutely positioned, it cannot contribute
|
|
24
|
+
* height. The parent must be `relative`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function OutcomeMessage({ id, children, className, }: {
|
|
27
|
+
id?: string;
|
|
28
|
+
children: string;
|
|
29
|
+
className?: string;
|
|
30
|
+
}): import("react").JSX.Element;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -21,7 +21,9 @@ export { Skeleton, SkeletonText, LoadingOverlay, type SkeletonProps, type Skelet
|
|
|
21
21
|
export { ErrorBoundary, type ErrorBoundaryProps } from "./components/ErrorBoundary";
|
|
22
22
|
export { Field, FieldSet, type FieldProps, type FieldSetProps } from "./components/Field";
|
|
23
23
|
export { Input, Textarea, type InputProps, type TextareaProps } from "./components/Input";
|
|
24
|
-
export { InlineEdit, type InlineEditProps, type InlineEditRefusal, type InlineEditOutcome, } from "./components/InlineEdit";
|
|
24
|
+
export { InlineEdit, type InlineEditProps, type InlineEditRefusal, type InlineEditOutcome, type InlineEditCommit, } from "./components/InlineEdit";
|
|
25
|
+
export { EditGutter, type EditGutterProps, type EditActivation } from "./components/EditGutter";
|
|
26
|
+
export { InlineMarkdownEdit, type InlineMarkdownEditProps } from "./components/InlineMarkdownEdit";
|
|
25
27
|
export { SecretField, type SecretFieldProps, type SecretValue } from "./components/SecretField";
|
|
26
28
|
export { SettingRow, SettingGroup, type SettingRowProps, type SettingGroupProps, type SettingRowControlRenderProps, } from "./components/SettingRow";
|
|
27
29
|
export { DescriptionList, DescriptionListItem, type DescriptionListProps, type DescriptionListItemProps, type DescriptionListEntry, } from "./components/DescriptionList";
|