@gamecrafters/base-ui 0.0.39 → 0.0.41

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.
@@ -59,6 +59,7 @@ export * from "./highlight";
59
59
  export * from "./hover-card";
60
60
  export * from "./icon-button";
61
61
  export * from "./image";
62
+ export * from "./inline-edit";
62
63
  export * from "./inline-message";
63
64
  export * from "./json-tree-view";
64
65
  export * from "./keybinding-hint";
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ declare const _default: (props: Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof import("./InlineEdit.types").UseInlineEditProps> & import("./InlineEdit.types").UseInlineEditProps & {
3
+ size?: import("..").TextInputSize;
4
+ block?: boolean;
5
+ contrast?: boolean;
6
+ className?: string;
7
+ } & React.RefAttributes<any>) => React.ReactNode;
8
+ export default _default;
@@ -0,0 +1,116 @@
1
+ import type * as React from "react";
2
+ import type { PolymorphicProps } from "../../utilities/polymorphic";
3
+ import type { ButtonSize, ButtonVariant, ButtonVisual } from "../button";
4
+ import type { TextInputSize } from "../text-input/TextInput.types";
5
+ export type InlineEditActivationMode = "focus" | "click" | "dblclick" | "none";
6
+ export type InlineEditSubmitMode = "enter" | "blur" | "both" | "none";
7
+ export type InlineEditPlaceholder = string | {
8
+ edit: string;
9
+ preview: string;
10
+ };
11
+ export type InlineEditInputElement = "input" | "textarea";
12
+ export type InlineEditIds = {
13
+ root?: string;
14
+ label?: string;
15
+ area?: string;
16
+ input?: string;
17
+ preview?: string;
18
+ control?: string;
19
+ editTrigger?: string;
20
+ submitTrigger?: string;
21
+ cancelTrigger?: string;
22
+ };
23
+ export type UseInlineEditProps = {
24
+ value?: string;
25
+ defaultValue?: string;
26
+ edit?: boolean;
27
+ defaultEdit?: boolean;
28
+ activationMode?: InlineEditActivationMode;
29
+ submitMode?: InlineEditSubmitMode;
30
+ selectOnFocus?: boolean;
31
+ placeholder?: InlineEditPlaceholder;
32
+ maxLength?: number;
33
+ autoResize?: boolean;
34
+ disabled?: boolean;
35
+ readOnly?: boolean;
36
+ required?: boolean;
37
+ invalid?: boolean;
38
+ name?: string;
39
+ form?: string;
40
+ id?: string;
41
+ ids?: InlineEditIds;
42
+ returnFocusRef?: React.RefObject<HTMLElement | null>;
43
+ onValueChange?: (value: string) => void;
44
+ onValueCommit?: (value: string) => void;
45
+ onValueRevert?: (value: string) => void;
46
+ onEditChange?: (edit: boolean) => void;
47
+ };
48
+ export type UseInlineEditReturn = {
49
+ editing: boolean;
50
+ empty: boolean;
51
+ value: string;
52
+ valueText: string;
53
+ placeholder?: string;
54
+ activationMode: InlineEditActivationMode;
55
+ autoResize: boolean;
56
+ maxLength?: number;
57
+ disabled: boolean;
58
+ readOnly: boolean;
59
+ required: boolean;
60
+ invalid: boolean;
61
+ name?: string;
62
+ form?: string;
63
+ ids: Required<InlineEditIds>;
64
+ describedBy?: string;
65
+ setValue: (value: string) => void;
66
+ clearValue: () => void;
67
+ edit: () => void;
68
+ submit: () => void;
69
+ cancel: () => void;
70
+ focus: () => void;
71
+ rootRef: React.RefObject<HTMLDivElement | null>;
72
+ handleInputChange: (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
73
+ handleInputKeyDown: (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
74
+ handlePreviewFocus: () => void;
75
+ handlePreviewClick: () => void;
76
+ handlePreviewDoubleClick: () => void;
77
+ handlePreviewKeyDown: (event: React.KeyboardEvent<HTMLElement>) => void;
78
+ };
79
+ type InlineEditFieldProps = {
80
+ size?: TextInputSize;
81
+ block?: boolean;
82
+ contrast?: boolean;
83
+ className?: string;
84
+ };
85
+ export type InlineEditProps = Omit<React.ComponentPropsWithoutRef<"div">, keyof UseInlineEditProps> & UseInlineEditProps & InlineEditFieldProps;
86
+ export type InlineEditRootProviderProps = Omit<React.ComponentPropsWithoutRef<"div">, "defaultValue"> & InlineEditFieldProps & {
87
+ value: UseInlineEditReturn;
88
+ };
89
+ export type InlineEditLabelProps = React.ComponentPropsWithoutRef<"label"> & {
90
+ visuallyHidden?: boolean;
91
+ className?: string;
92
+ };
93
+ export type InlineEditAreaProps = React.ComponentPropsWithoutRef<"div"> & {
94
+ className?: string;
95
+ };
96
+ export type InlineEditInputProps<As extends InlineEditInputElement = "input"> = Omit<PolymorphicProps<As, "input", {
97
+ className?: string;
98
+ }>, "value" | "defaultValue">;
99
+ export type InlineEditPreviewProps<As extends React.ElementType = "span"> = PolymorphicProps<As, "span", {
100
+ className?: string;
101
+ }>;
102
+ export type InlineEditControlProps = React.ComponentPropsWithoutRef<"div"> & {
103
+ className?: string;
104
+ };
105
+ type InlineEditTriggerProps = Omit<React.ComponentPropsWithoutRef<"button">, "type" | "aria-label" | "aria-labelledby"> & {
106
+ variant?: ButtonVariant;
107
+ size?: ButtonSize;
108
+ icon?: ButtonVisual;
109
+ label?: string;
110
+ className?: string;
111
+ };
112
+ export type InlineEditEditTriggerProps = InlineEditTriggerProps;
113
+ export type InlineEditSubmitTriggerProps = InlineEditTriggerProps;
114
+ export type InlineEditCancelTriggerProps = InlineEditTriggerProps;
115
+ export type InlineEditContextValue = Partial<UseInlineEditReturn> & Omit<InlineEditFieldProps, "className">;
116
+ export {};
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ declare const _default: (props: Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
3
+ className?: string;
4
+ } & React.RefAttributes<any>) => React.ReactNode;
5
+ export default _default;
@@ -0,0 +1,9 @@
1
+ import * as React from "react";
2
+ declare const _default: (props: Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "type" | "aria-label" | "aria-labelledby"> & {
3
+ variant?: import("..").ButtonVariant;
4
+ size?: import("..").ButtonSize;
5
+ icon?: import("..").ButtonVisual;
6
+ label?: string;
7
+ className?: string;
8
+ } & React.RefAttributes<any>) => React.ReactNode;
9
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import type { InlineEditContextValue } from "./InlineEdit.types";
2
+ export declare const InlineEditContext: import("react").Context<InlineEditContextValue>;
3
+ export declare const useInlineEditContext: () => InlineEditContextValue;
4
+ export declare const getStateAttributes: ({ editing, disabled, readOnly, required, invalid, }: InlineEditContextValue) => {
5
+ "data-editing": true | undefined;
6
+ "data-disabled": true | undefined;
7
+ "data-readonly": true | undefined;
8
+ "data-required": true | undefined;
9
+ "data-invalid": true | undefined;
10
+ };
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ declare const _default: (props: Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
3
+ className?: string;
4
+ } & React.RefAttributes<any>) => React.ReactNode;
5
+ export default _default;
@@ -0,0 +1,9 @@
1
+ import * as React from "react";
2
+ declare const _default: (props: Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "type" | "aria-label" | "aria-labelledby"> & {
3
+ variant?: import("..").ButtonVariant;
4
+ size?: import("..").ButtonSize;
5
+ icon?: import("..").ButtonVisual;
6
+ label?: string;
7
+ className?: string;
8
+ } & React.RefAttributes<any>) => React.ReactNode;
9
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import * as React from "react";
2
+ import type { InlineEditInputElement, InlineEditInputProps } from "./InlineEdit.types";
3
+ declare const _default: <As extends InlineEditInputElement = "input">(props: InlineEditInputProps<As> & React.RefAttributes<any>) => React.ReactNode;
4
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ declare const _default: (props: Omit<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref"> & {
3
+ visuallyHidden?: boolean;
4
+ className?: string;
5
+ } & React.RefAttributes<any>) => React.ReactNode;
6
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ declare const _default: <As extends React.ElementType = "span">(props: import("../../utilities/polymorphic").DistributiveOmit<React.ComponentPropsWithRef<React.ElementType extends As ? "span" : As> & {
3
+ className?: string;
4
+ }, "as"> & {
5
+ as?: As | undefined;
6
+ } & React.RefAttributes<any>) => React.ReactNode;
7
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ declare const _default: (props: Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "defaultValue"> & {
3
+ size?: import("..").TextInputSize;
4
+ block?: boolean;
5
+ contrast?: boolean;
6
+ className?: string;
7
+ } & {
8
+ value: import("./InlineEdit.types").UseInlineEditReturn;
9
+ } & React.RefAttributes<any>) => React.ReactNode;
10
+ export default _default;
@@ -0,0 +1,9 @@
1
+ import * as React from "react";
2
+ declare const _default: (props: Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "type" | "aria-label" | "aria-labelledby"> & {
3
+ variant?: import("..").ButtonVariant;
4
+ size?: import("..").ButtonSize;
5
+ icon?: import("..").ButtonVisual;
6
+ label?: string;
7
+ className?: string;
8
+ } & React.RefAttributes<any>) => React.ReactNode;
9
+ export default _default;
@@ -0,0 +1,71 @@
1
+ import InlineEditArea from "./InlineEditArea";
2
+ import InlineEditCancelTrigger from "./InlineEditCancelTrigger";
3
+ import InlineEditControl from "./InlineEditControl";
4
+ import InlineEditEditTrigger from "./InlineEditEditTrigger";
5
+ import InlineEditInput from "./InlineEditInput";
6
+ import InlineEditLabel from "./InlineEditLabel";
7
+ import InlineEditPreview from "./InlineEditPreview";
8
+ import InlineEditRootProvider from "./InlineEditRootProvider";
9
+ import InlineEditSubmitTrigger from "./InlineEditSubmitTrigger";
10
+ export declare const InlineEdit: ((props: Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof import("./InlineEdit.types").UseInlineEditProps> & import("./InlineEdit.types").UseInlineEditProps & {
11
+ size?: import("..").TextInputSize;
12
+ block?: boolean;
13
+ contrast?: boolean;
14
+ className?: string;
15
+ } & import("react").RefAttributes<any>) => React.ReactNode) & {
16
+ Root: (props: Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof import("./InlineEdit.types").UseInlineEditProps> & import("./InlineEdit.types").UseInlineEditProps & {
17
+ size?: import("..").TextInputSize;
18
+ block?: boolean;
19
+ contrast?: boolean;
20
+ className?: string;
21
+ } & import("react").RefAttributes<any>) => React.ReactNode;
22
+ RootProvider: (props: Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "defaultValue"> & {
23
+ size?: import("..").TextInputSize;
24
+ block?: boolean;
25
+ contrast?: boolean;
26
+ className?: string;
27
+ } & {
28
+ value: import("./InlineEdit.types").UseInlineEditReturn;
29
+ } & import("react").RefAttributes<any>) => React.ReactNode;
30
+ Label: (props: Omit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref"> & {
31
+ visuallyHidden?: boolean;
32
+ className?: string;
33
+ } & import("react").RefAttributes<any>) => React.ReactNode;
34
+ Area: (props: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
35
+ className?: string;
36
+ } & import("react").RefAttributes<any>) => React.ReactNode;
37
+ Input: <As extends import("./InlineEdit.types").InlineEditInputElement = "input">(props: import("./InlineEdit.types").InlineEditInputProps<As> & import("react").RefAttributes<any>) => React.ReactNode;
38
+ Preview: <As extends React.ElementType = "span">(props: import("../../utilities/polymorphic").DistributiveOmit<import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "span" : As> & {
39
+ className?: string;
40
+ }, "as"> & {
41
+ as?: As | undefined;
42
+ } & import("react").RefAttributes<any>) => React.ReactNode;
43
+ Control: (props: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
44
+ className?: string;
45
+ } & import("react").RefAttributes<any>) => React.ReactNode;
46
+ EditTrigger: (props: Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "type" | "aria-label" | "aria-labelledby"> & {
47
+ variant?: import("..").ButtonVariant;
48
+ size?: import("..").ButtonSize;
49
+ icon?: import("..").ButtonVisual;
50
+ label?: string;
51
+ className?: string;
52
+ } & import("react").RefAttributes<any>) => React.ReactNode;
53
+ SubmitTrigger: (props: Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "type" | "aria-label" | "aria-labelledby"> & {
54
+ variant?: import("..").ButtonVariant;
55
+ size?: import("..").ButtonSize;
56
+ icon?: import("..").ButtonVisual;
57
+ label?: string;
58
+ className?: string;
59
+ } & import("react").RefAttributes<any>) => React.ReactNode;
60
+ CancelTrigger: (props: Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "type" | "aria-label" | "aria-labelledby"> & {
61
+ variant?: import("..").ButtonVariant;
62
+ size?: import("..").ButtonSize;
63
+ icon?: import("..").ButtonVisual;
64
+ label?: string;
65
+ className?: string;
66
+ } & import("react").RefAttributes<any>) => React.ReactNode;
67
+ };
68
+ export { InlineEditRootProvider, InlineEditLabel, InlineEditArea, InlineEditInput, InlineEditPreview, InlineEditControl, InlineEditEditTrigger, InlineEditSubmitTrigger, InlineEditCancelTrigger, };
69
+ export { InlineEditContext, useInlineEditContext } from "./InlineEditContext";
70
+ export { useInlineEdit } from "./useInlineEdit";
71
+ export * from "./InlineEdit.types";
@@ -0,0 +1,2 @@
1
+ import type { UseInlineEditProps, UseInlineEditReturn } from "./InlineEdit.types";
2
+ export declare const useInlineEdit: (props?: UseInlineEditProps) => UseInlineEditReturn;