@gridui/inline-editor 2.0.0 → 2.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/README.md +3 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +69 -7
- package/dist/index.js.map +4 -4
- package/dist/inline-editor-textarea/inline-editor-textarea.d.ts +12 -0
- package/dist/shared/editor-context.d.ts +1 -1
- package/docs/catalog.json +20 -3
- package/docs/inline-editor.md +9 -0
- package/docs/reference/README.md +9 -0
- package/docs/reference/inline-editor-actions.md +29 -0
- package/docs/reference/inline-editor-display.md +57 -0
- package/docs/reference/inline-editor-field.md +65 -0
- package/docs/reference/inline-editor-textarea.md +77 -0
- package/docs/reference/inline-editor-trigger.md +89 -0
- package/docs/reference/inline-editor.md +99 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @gridui/inline-editor
|
|
2
2
|
|
|
3
|
-
Core family. Public API: `InlineEditor`, `InlineEditorDisplay`, `InlineEditorTrigger`, `InlineEditorField`, and `InlineEditorActions`.
|
|
3
|
+
Core family. Public API: `InlineEditor`, `InlineEditorDisplay`, `InlineEditorTrigger`, `InlineEditorField`, `InlineEditorTextarea`, and `InlineEditorActions`.
|
|
4
4
|
|
|
5
5
|
Import components from `@gridui/inline-editor` and load `@gridui/inline-editor/styles.css` after Theme.
|
|
6
6
|
Load styles for any composed dependency used by this family. Applications own routes, labels, state persistence, and branding.
|
|
@@ -13,3 +13,5 @@ See [InlineEditor](docs/inline-editor.md) for editing state and submission owner
|
|
|
13
13
|
and [Textarea](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/input/docs/textarea.md#optional-automatic-height) for optional automatic height.
|
|
14
14
|
|
|
15
15
|
See [common inputs](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/input/docs/common-inputs.md) for multiple selection, numeric values, sliders, and editable tags.
|
|
16
|
+
|
|
17
|
+
[Component reference](docs/reference/README.md) contains focused API pages for each public component.
|
package/dist/index.d.ts
CHANGED
|
@@ -12,5 +12,7 @@ export type { InlineEditorDisplayProps } from "./inline-editor-display/inline-ed
|
|
|
12
12
|
export { InlineEditorDisplay } from "./inline-editor-display/inline-editor-display";
|
|
13
13
|
export type { InlineEditorFieldProps } from "./inline-editor-field/inline-editor-field";
|
|
14
14
|
export { InlineEditorField } from "./inline-editor-field/inline-editor-field";
|
|
15
|
+
export type { InlineEditorTextareaProps } from "./inline-editor-textarea/inline-editor-textarea";
|
|
16
|
+
export { InlineEditorTextarea } from "./inline-editor-textarea/inline-editor-textarea";
|
|
15
17
|
export type { InlineEditorTriggerProps } from "./inline-editor-trigger/inline-editor-trigger";
|
|
16
18
|
export { InlineEditorTrigger } from "./inline-editor-trigger/inline-editor-trigger";
|
package/dist/index.js
CHANGED
|
@@ -156,15 +156,16 @@ var InlineEditorDisplay = (props) => {
|
|
|
156
156
|
// src/inline-editor-field/inline-editor-field.tsx
|
|
157
157
|
import { Input } from "@gridui/input";
|
|
158
158
|
import { isComposingKeyEvent } from "@gridui/interaction";
|
|
159
|
-
import { useId, useImperativeHandle } from "react";
|
|
159
|
+
import { useId, useImperativeHandle, useRef as useRef2 } from "react";
|
|
160
160
|
import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
161
161
|
var InlineEditorField = (props) => {
|
|
162
162
|
const { id, label, onKeyDown, ref, ...restProps } = props;
|
|
163
163
|
const { busy, cancel, disabled, editing, input, onValueChange, submit, value } = useEditor();
|
|
164
164
|
const generatedId = useId();
|
|
165
165
|
const inputId = id ?? generatedId;
|
|
166
|
+
const native = useRef2(null);
|
|
166
167
|
useImperativeHandle(ref, () => {
|
|
167
|
-
return
|
|
168
|
+
return native.current;
|
|
168
169
|
});
|
|
169
170
|
if (!editing) {
|
|
170
171
|
return null;
|
|
@@ -182,7 +183,10 @@ var InlineEditorField = (props) => {
|
|
|
182
183
|
{
|
|
183
184
|
...restProps,
|
|
184
185
|
id: inputId,
|
|
185
|
-
ref:
|
|
186
|
+
ref: (element) => {
|
|
187
|
+
input.current = element;
|
|
188
|
+
native.current = element;
|
|
189
|
+
},
|
|
186
190
|
value,
|
|
187
191
|
onValueChange,
|
|
188
192
|
disabled: disabled || busy,
|
|
@@ -205,10 +209,67 @@ var InlineEditorField = (props) => {
|
|
|
205
209
|
] });
|
|
206
210
|
};
|
|
207
211
|
|
|
212
|
+
// src/inline-editor-textarea/inline-editor-textarea.tsx
|
|
213
|
+
import { Textarea } from "@gridui/input";
|
|
214
|
+
import { isComposingKeyEvent as isComposingKeyEvent2 } from "@gridui/interaction";
|
|
215
|
+
import { useId as useId2, useImperativeHandle as useImperativeHandle2, useRef as useRef3 } from "react";
|
|
216
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
217
|
+
var InlineEditorTextarea = (props) => {
|
|
218
|
+
const { id, label, onKeyDown, ref, ...restProps } = props;
|
|
219
|
+
const editor = useEditor();
|
|
220
|
+
const generatedId = useId2();
|
|
221
|
+
const inputId = id ?? generatedId;
|
|
222
|
+
const native = useRef3(null);
|
|
223
|
+
useImperativeHandle2(ref, () => {
|
|
224
|
+
return native.current;
|
|
225
|
+
});
|
|
226
|
+
if (!editor.editing) {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
return /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
230
|
+
/* @__PURE__ */ jsx5(
|
|
231
|
+
"label",
|
|
232
|
+
{
|
|
233
|
+
htmlFor: inputId,
|
|
234
|
+
children: label
|
|
235
|
+
}
|
|
236
|
+
),
|
|
237
|
+
/* @__PURE__ */ jsx5(
|
|
238
|
+
Textarea,
|
|
239
|
+
{
|
|
240
|
+
autoSize: true,
|
|
241
|
+
...restProps,
|
|
242
|
+
id: inputId,
|
|
243
|
+
ref: (element) => {
|
|
244
|
+
native.current = element;
|
|
245
|
+
editor.input.current = element;
|
|
246
|
+
},
|
|
247
|
+
value: editor.value,
|
|
248
|
+
onValueChange: editor.onValueChange,
|
|
249
|
+
disabled: editor.disabled || editor.busy,
|
|
250
|
+
onKeyDown: (event) => {
|
|
251
|
+
onKeyDown?.(event);
|
|
252
|
+
if (event.defaultPrevented || isComposingKeyEvent2(event.nativeEvent) || editor.busy || editor.disabled) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
if (event.key === "Escape") {
|
|
256
|
+
event.preventDefault();
|
|
257
|
+
event.stopPropagation();
|
|
258
|
+
editor.cancel();
|
|
259
|
+
} else if (event.key === "Enter" && (event.ctrlKey || event.metaKey)) {
|
|
260
|
+
event.preventDefault();
|
|
261
|
+
editor.submit();
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
)
|
|
266
|
+
] });
|
|
267
|
+
};
|
|
268
|
+
|
|
208
269
|
// src/inline-editor-trigger/inline-editor-trigger.tsx
|
|
209
270
|
import { Button as Button2 } from "@gridui/button";
|
|
210
|
-
import { useImperativeHandle as
|
|
211
|
-
import { jsx as
|
|
271
|
+
import { useImperativeHandle as useImperativeHandle3 } from "react";
|
|
272
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
212
273
|
var InlineEditorTrigger = (props) => {
|
|
213
274
|
const appearance = props.variant === void 0 || props.variant === null ? {
|
|
214
275
|
...props,
|
|
@@ -216,13 +277,13 @@ var InlineEditorTrigger = (props) => {
|
|
|
216
277
|
} : props;
|
|
217
278
|
const { ref, size, ...restProps } = appearance;
|
|
218
279
|
const { busy, disabled, editing, start, trigger } = useEditor();
|
|
219
|
-
|
|
280
|
+
useImperativeHandle3(ref, () => {
|
|
220
281
|
return trigger.current;
|
|
221
282
|
});
|
|
222
283
|
if (editing) {
|
|
223
284
|
return null;
|
|
224
285
|
}
|
|
225
|
-
return /* @__PURE__ */
|
|
286
|
+
return /* @__PURE__ */ jsx6(
|
|
226
287
|
Button2,
|
|
227
288
|
{
|
|
228
289
|
...restProps,
|
|
@@ -239,6 +300,7 @@ export {
|
|
|
239
300
|
InlineEditorActions,
|
|
240
301
|
InlineEditorDisplay,
|
|
241
302
|
InlineEditorField,
|
|
303
|
+
InlineEditorTextarea,
|
|
242
304
|
InlineEditorTrigger
|
|
243
305
|
};
|
|
244
306
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/shared/editor-context.ts", "../src/inline-editor/inline-editor.tsx", "../src/inline-editor-actions/inline-editor-actions.tsx", "../src/inline-editor-display/inline-editor-display.tsx", "../src/inline-editor-field/inline-editor-field.tsx", "../src/inline-editor-trigger/inline-editor-trigger.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * @author WMXPY\n * @package Inline Editor\n * @namespace Shared\n * @description Editor Context\n */\n\nimport { createContext, type RefObject, useContext } from \"react\";\n\nexport type EditorContext = {\n readonly editing: boolean;\n readonly busy: boolean;\n readonly disabled: boolean;\n readonly submitDisabled: boolean;\n readonly value: string;\n readonly input: RefObject<HTMLInputElement | null>;\n readonly trigger: RefObject<HTMLButtonElement | null>;\n readonly onValueChange: (value: string) => void;\n readonly start: () => void;\n readonly cancel: () => void;\n readonly submit: () => void;\n};\n\nexport const editorContext = createContext<EditorContext | null>(null);\n\nexport const useEditor = (): EditorContext => {\n const editor = useContext(editorContext);\n if (!editor) {\n throw new Error(\"InlineEditor parts require an InlineEditor.\");\n }\n return editor;\n};\n", "/**\n * @author WMXPY\n * @package Inline Editor\n * @namespace InlineEditor\n * @description Inline Editor\n */\n\nimport { editorContext } from \"../shared/editor-context\";\nimport { cn } from \"@gridui/style-utils\";\nimport { type ComponentPropsWithRef, type FC, useLayoutEffect, useRef } from \"react\";\n\nexport type InlineEditorProps = Omit<ComponentPropsWithRef<\"div\">, \"onSubmit\" | \"onChange\"> & {\n readonly editing: boolean;\n readonly onEditingChange: (editing: boolean) => void;\n readonly value: string;\n readonly onValueChange: (value: string) => void;\n readonly onSubmit: (value: string) => void;\n readonly onCancel?: () => void;\n readonly busy?: boolean;\n readonly disabled?: boolean;\n readonly submitDisabled?: boolean;\n};\n\nexport const InlineEditor: FC<InlineEditorProps> = (props: InlineEditorProps) => {\n const { editing, onEditingChange, value, onValueChange, onSubmit, onCancel,\n busy = false, disabled = false, submitDisabled = false, children, className, ...restProps } = props;\n const input = useRef<HTMLInputElement>(null);\n const trigger = useRef<HTMLButtonElement>(null);\n const previousEditing = useRef(false);\n const restoreFocus = useRef(false);\n useLayoutEffect(() => {\n if (editing && !previousEditing.current) {\n restoreFocus.current = false;\n input.current?.focus();\n } else if (!editing && previousEditing.current) {\n restoreFocus.current = true;\n }\n if (!editing && restoreFocus.current && !busy && !disabled) {\n trigger.current?.focus();\n restoreFocus.current = false;\n }\n previousEditing.current = editing;\n }, [\n editing,\n busy,\n disabled,\n ]);\n const cancel = () => {\n onCancel?.();\n onEditingChange(false);\n };\n const submit = () => {\n const element = input.current;\n if (busy || disabled || submitDisabled || !element || element.matches(\":disabled\")) {\n return;\n }\n if (!element.reportValidity()) {\n return;\n }\n onSubmit(value);\n };\n\n return (<editorContext.Provider\n value={{\n editing,\n busy,\n disabled,\n submitDisabled,\n value,\n input,\n trigger,\n onValueChange,\n cancel,\n submit,\n start: () => {\n onEditingChange(true);\n },\n }}\n >\n <div\n {...restProps}\n className={cn(\"gridui-inline-editor\", className)}\n aria-busy={busy || undefined}\n >\n {children}\n </div>\n </editorContext.Provider>);\n};\n", "/**\n * @author WMXPY\n * @package Inline Editor\n * @namespace InlineEditorActions\n * @description Inline Editor Actions\n */\n\nimport { useEditor } from \"../shared/editor-context\";\nimport { Button } from \"@gridui/button\";\nimport type { FC, ReactNode } from \"react\";\n\nexport type InlineEditorActionsProps = {\n readonly saveLabel: ReactNode;\n readonly cancelLabel: ReactNode;\n};\n\nexport const InlineEditorActions: FC<InlineEditorActionsProps> = (props: InlineEditorActionsProps) => {\n const { busy, cancel, disabled, editing, submit, submitDisabled } = useEditor();\n if (!editing) {\n return null;\n }\n return (<div\n className=\"gridui-inline-editor-actions\"\n >\n <Button\n type=\"button\"\n size=\"small\"\n disabled={disabled || busy || submitDisabled}\n loading={busy}\n onClick={submit}\n >\n {props.saveLabel}\n </Button>\n <Button\n type=\"button\"\n size=\"small\"\n variant=\"quiet\"\n disabled={busy}\n onClick={cancel}\n >\n {props.cancelLabel}\n </Button>\n </div>);\n};\n", "/**\n * @author WMXPY\n * @package Inline Editor\n * @namespace InlineEditorDisplay\n * @description Inline Editor Display\n */\n\nimport { useEditor } from \"../shared/editor-context\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type InlineEditorDisplayProps = ComponentPropsWithRef<\"div\">;\n\nexport const InlineEditorDisplay: FC<InlineEditorDisplayProps> = (props: InlineEditorDisplayProps) => {\n const { editing } = useEditor();\n const { children, className, ...restProps } = props;\n if (editing || children === undefined || children === null) {\n return null;\n }\n return (<div\n {...restProps}\n className={cn(\"gridui-inline-editor-display\", className)}\n >\n {children}\n </div>);\n};\n", "/**\n * @author WMXPY\n * @package Inline Editor\n * @namespace InlineEditorField\n * @description Inline Editor Field\n */\n\nimport { useEditor } from \"../shared/editor-context\";\nimport { Input, type InputProps } from \"@gridui/input\";\nimport { isComposingKeyEvent } from \"@gridui/interaction\";\nimport { type FC, useId, useImperativeHandle } from \"react\";\n\nexport type InlineEditorFieldProps = Omit<InputProps, \"value\" | \"defaultValue\" | \"onValueChange\" | \"disabled\"> & {\n readonly label: string;\n};\n\nexport const InlineEditorField: FC<InlineEditorFieldProps> = (props: InlineEditorFieldProps) => {\n const { id, label, onKeyDown, ref, ...restProps } = props;\n const { busy, cancel, disabled, editing, input, onValueChange, submit, value } = useEditor();\n const generatedId = useId();\n const inputId = id ?? generatedId;\n useImperativeHandle(ref, () => {\n return input.current!;\n });\n if (!editing) {\n return null;\n }\n return (<>\n <label\n htmlFor={inputId}\n >\n {label}\n </label>\n <Input\n {...restProps}\n id={inputId}\n ref={input}\n value={value}\n onValueChange={onValueChange}\n disabled={disabled || busy}\n onKeyDown={event => {\n onKeyDown?.(event);\n if (event.defaultPrevented || isComposingKeyEvent(event.nativeEvent) || busy || disabled) {\n return;\n }\n if (event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n cancel();\n } else if (event.key === \"Enter\") {\n event.preventDefault();\n submit();\n }\n }}\n />\n </>);\n};\n", "/**\n * @author WMXPY\n * @package Inline Editor\n * @namespace InlineEditorTrigger\n * @description Inline Editor Trigger\n */\n\nimport { useEditor } from \"../shared/editor-context\";\nimport { Button, type ButtonProps, type ButtonVariants } from \"@gridui/button\";\nimport { type FC, useImperativeHandle } from \"react\";\n\nexport type InlineEditorTriggerProps = Omit<ButtonProps, \"disabled\" | \"loading\" | \"onClick\" | \"type\"> & ButtonVariants;\n\nexport const InlineEditorTrigger: FC<InlineEditorTriggerProps> = (props: InlineEditorTriggerProps) => {\n const appearance = props.variant === undefined || props.variant === null ? {\n ...props,\n variant: \"quiet\" as const,\n } : props;\n const { ref, size, ...restProps } = appearance;\n const { busy, disabled, editing, start, trigger } = useEditor();\n useImperativeHandle(ref, () => {\n return trigger.current!;\n });\n if (editing) {\n return null;\n }\n return (<Button\n {...restProps}\n size={size ?? \"small\"}\n ref={trigger}\n type=\"button\"\n disabled={disabled || busy}\n onClick={start}\n />);\n};\n"],
|
|
5
|
-
"mappings": ";AAOA,SAAS,eAA+B,kBAAkB;AAgBnD,IAAM,gBAAgB,cAAoC,IAAI;AAE9D,IAAM,YAAY,MAAqB;AAC1C,QAAM,SAAS,WAAW,aAAa;AACvC,MAAI,CAAC,QAAQ;AACT,UAAM,IAAI,MAAM,6CAA6C;AAAA,EACjE;AACA,SAAO;AACX;;;ACvBA,SAAS,UAAU;AACnB,SAA8C,iBAAiB,cAAc;AAsErE;AAxDD,IAAM,eAAsC,CAAC,UAA6B;AAC7E,QAAM;AAAA,IAAE;AAAA,IAAS;AAAA,IAAiB;AAAA,IAAO;AAAA,IAAe;AAAA,IAAU;AAAA,IAC9D,OAAO;AAAA,IAAO,WAAW;AAAA,IAAO,iBAAiB;AAAA,IAAO;AAAA,IAAU;AAAA,IAAW,GAAG;AAAA,EAAU,IAAI;AAClG,QAAM,QAAQ,
|
|
6
|
-
"names": ["jsx", "cn", "jsx", "jsx", "jsxs", "Button", "useImperativeHandle", "jsx"]
|
|
3
|
+
"sources": ["../src/shared/editor-context.ts", "../src/inline-editor/inline-editor.tsx", "../src/inline-editor-actions/inline-editor-actions.tsx", "../src/inline-editor-display/inline-editor-display.tsx", "../src/inline-editor-field/inline-editor-field.tsx", "../src/inline-editor-textarea/inline-editor-textarea.tsx", "../src/inline-editor-trigger/inline-editor-trigger.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * @author WMXPY\n * @package Inline Editor\n * @namespace Shared\n * @description Editor Context\n */\n\nimport { createContext, type RefObject, useContext } from \"react\";\n\nexport type EditorContext = {\n readonly editing: boolean;\n readonly busy: boolean;\n readonly disabled: boolean;\n readonly submitDisabled: boolean;\n readonly value: string;\n readonly input: RefObject<HTMLInputElement | HTMLTextAreaElement | null>;\n readonly trigger: RefObject<HTMLButtonElement | null>;\n readonly onValueChange: (value: string) => void;\n readonly start: () => void;\n readonly cancel: () => void;\n readonly submit: () => void;\n};\n\nexport const editorContext = createContext<EditorContext | null>(null);\n\nexport const useEditor = (): EditorContext => {\n const editor = useContext(editorContext);\n if (!editor) {\n throw new Error(\"InlineEditor parts require an InlineEditor.\");\n }\n return editor;\n};\n", "/**\n * @author WMXPY\n * @package Inline Editor\n * @namespace InlineEditor\n * @description Inline Editor\n */\n\nimport { editorContext } from \"../shared/editor-context\";\nimport { cn } from \"@gridui/style-utils\";\nimport { type ComponentPropsWithRef, type FC, useLayoutEffect, useRef } from \"react\";\n\nexport type InlineEditorProps = Omit<ComponentPropsWithRef<\"div\">, \"onSubmit\" | \"onChange\"> & {\n readonly editing: boolean;\n readonly onEditingChange: (editing: boolean) => void;\n readonly value: string;\n readonly onValueChange: (value: string) => void;\n readonly onSubmit: (value: string) => void;\n readonly onCancel?: () => void;\n readonly busy?: boolean;\n readonly disabled?: boolean;\n readonly submitDisabled?: boolean;\n};\n\nexport const InlineEditor: FC<InlineEditorProps> = (props: InlineEditorProps) => {\n const { editing, onEditingChange, value, onValueChange, onSubmit, onCancel,\n busy = false, disabled = false, submitDisabled = false, children, className, ...restProps } = props;\n const input = useRef<HTMLInputElement | HTMLTextAreaElement>(null);\n const trigger = useRef<HTMLButtonElement>(null);\n const previousEditing = useRef(false);\n const restoreFocus = useRef(false);\n useLayoutEffect(() => {\n if (editing && !previousEditing.current) {\n restoreFocus.current = false;\n input.current?.focus();\n } else if (!editing && previousEditing.current) {\n restoreFocus.current = true;\n }\n if (!editing && restoreFocus.current && !busy && !disabled) {\n trigger.current?.focus();\n restoreFocus.current = false;\n }\n previousEditing.current = editing;\n }, [\n editing,\n busy,\n disabled,\n ]);\n const cancel = () => {\n onCancel?.();\n onEditingChange(false);\n };\n const submit = () => {\n const element = input.current;\n if (busy || disabled || submitDisabled || !element || element.matches(\":disabled\")) {\n return;\n }\n if (!element.reportValidity()) {\n return;\n }\n onSubmit(value);\n };\n\n return (<editorContext.Provider\n value={{\n editing,\n busy,\n disabled,\n submitDisabled,\n value,\n input,\n trigger,\n onValueChange,\n cancel,\n submit,\n start: () => {\n onEditingChange(true);\n },\n }}\n >\n <div\n {...restProps}\n className={cn(\"gridui-inline-editor\", className)}\n aria-busy={busy || undefined}\n >\n {children}\n </div>\n </editorContext.Provider>);\n};\n", "/**\n * @author WMXPY\n * @package Inline Editor\n * @namespace InlineEditorActions\n * @description Inline Editor Actions\n */\n\nimport { useEditor } from \"../shared/editor-context\";\nimport { Button } from \"@gridui/button\";\nimport type { FC, ReactNode } from \"react\";\n\nexport type InlineEditorActionsProps = {\n readonly saveLabel: ReactNode;\n readonly cancelLabel: ReactNode;\n};\n\nexport const InlineEditorActions: FC<InlineEditorActionsProps> = (props: InlineEditorActionsProps) => {\n const { busy, cancel, disabled, editing, submit, submitDisabled } = useEditor();\n if (!editing) {\n return null;\n }\n return (<div\n className=\"gridui-inline-editor-actions\"\n >\n <Button\n type=\"button\"\n size=\"small\"\n disabled={disabled || busy || submitDisabled}\n loading={busy}\n onClick={submit}\n >\n {props.saveLabel}\n </Button>\n <Button\n type=\"button\"\n size=\"small\"\n variant=\"quiet\"\n disabled={busy}\n onClick={cancel}\n >\n {props.cancelLabel}\n </Button>\n </div>);\n};\n", "/**\n * @author WMXPY\n * @package Inline Editor\n * @namespace InlineEditorDisplay\n * @description Inline Editor Display\n */\n\nimport { useEditor } from \"../shared/editor-context\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type InlineEditorDisplayProps = ComponentPropsWithRef<\"div\">;\n\nexport const InlineEditorDisplay: FC<InlineEditorDisplayProps> = (props: InlineEditorDisplayProps) => {\n const { editing } = useEditor();\n const { children, className, ...restProps } = props;\n if (editing || children === undefined || children === null) {\n return null;\n }\n return (<div\n {...restProps}\n className={cn(\"gridui-inline-editor-display\", className)}\n >\n {children}\n </div>);\n};\n", "/**\n * @author WMXPY\n * @package Inline Editor\n * @namespace InlineEditorField\n * @description Inline Editor Field\n */\n\nimport { useEditor } from \"../shared/editor-context\";\nimport { Input, type InputProps } from \"@gridui/input\";\nimport { isComposingKeyEvent } from \"@gridui/interaction\";\nimport { type FC, useId, useImperativeHandle, useRef } from \"react\";\n\nexport type InlineEditorFieldProps = Omit<InputProps, \"value\" | \"defaultValue\" | \"onValueChange\" | \"disabled\"> & {\n readonly label: string;\n};\n\nexport const InlineEditorField: FC<InlineEditorFieldProps> = (props: InlineEditorFieldProps) => {\n const { id, label, onKeyDown, ref, ...restProps } = props;\n const { busy, cancel, disabled, editing, input, onValueChange, submit, value } = useEditor();\n const generatedId = useId();\n const inputId = id ?? generatedId;\n const native = useRef<HTMLInputElement>(null);\n useImperativeHandle(ref, () => {\n return native.current!;\n });\n if (!editing) {\n return null;\n }\n return (<>\n <label\n htmlFor={inputId}\n >\n {label}\n </label>\n <Input\n {...restProps}\n id={inputId}\n ref={(element) => {\n input.current = element; native.current = element;\n }}\n value={value}\n onValueChange={onValueChange}\n disabled={disabled || busy}\n onKeyDown={event => {\n onKeyDown?.(event);\n if (event.defaultPrevented || isComposingKeyEvent(event.nativeEvent) || busy || disabled) {\n return;\n }\n if (event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n cancel();\n } else if (event.key === \"Enter\") {\n event.preventDefault();\n submit();\n }\n }}\n />\n </>);\n};\n", "/**\n * @author WMXPY\n * @package Inline Editor\n * @namespace InlineEditorTextarea\n * @description Inline Editor Textarea\n */\n\nimport { useEditor } from \"../shared/editor-context\";\nimport { Textarea, type TextareaProps } from \"@gridui/input\";\nimport { isComposingKeyEvent } from \"@gridui/interaction\";\nimport { type FC, useId, useImperativeHandle, useRef } from \"react\";\n\nexport type InlineEditorTextareaProps = Omit<TextareaProps, \"value\" | \"defaultValue\" | \"onValueChange\" | \"disabled\"> & {\n readonly label: string;\n};\nexport const InlineEditorTextarea: FC<InlineEditorTextareaProps> = (props: InlineEditorTextareaProps) => {\n const { id, label, onKeyDown, ref, ...restProps } = props;\n const editor = useEditor();\n const generatedId = useId();\n const inputId = id ?? generatedId;\n const native = useRef<HTMLTextAreaElement>(null);\n useImperativeHandle(ref, () => {\n return native.current!;\n });\n if (!editor.editing) {\n return null;\n }\n return (<>\n <label\n htmlFor={inputId}\n >\n {label}\n </label>\n <Textarea\n autoSize\n {...restProps}\n id={inputId}\n ref={(element) => {\n native.current = element; editor.input.current = element;\n }}\n value={editor.value}\n onValueChange={editor.onValueChange}\n disabled={editor.disabled || editor.busy}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.defaultPrevented || isComposingKeyEvent(event.nativeEvent) || editor.busy || editor.disabled) {\n return;\n }\n if (event.key === \"Escape\") {\n event.preventDefault(); event.stopPropagation(); editor.cancel();\n } else if (event.key === \"Enter\" && (event.ctrlKey || event.metaKey)) {\n event.preventDefault(); editor.submit();\n }\n }}\n />\n </>);\n};\n", "/**\n * @author WMXPY\n * @package Inline Editor\n * @namespace InlineEditorTrigger\n * @description Inline Editor Trigger\n */\n\nimport { useEditor } from \"../shared/editor-context\";\nimport { Button, type ButtonProps, type ButtonVariants } from \"@gridui/button\";\nimport { type FC, useImperativeHandle } from \"react\";\n\nexport type InlineEditorTriggerProps = Omit<ButtonProps, \"disabled\" | \"loading\" | \"onClick\" | \"type\"> & ButtonVariants;\n\nexport const InlineEditorTrigger: FC<InlineEditorTriggerProps> = (props: InlineEditorTriggerProps) => {\n const appearance = props.variant === undefined || props.variant === null ? {\n ...props,\n variant: \"quiet\" as const,\n } : props;\n const { ref, size, ...restProps } = appearance;\n const { busy, disabled, editing, start, trigger } = useEditor();\n useImperativeHandle(ref, () => {\n return trigger.current!;\n });\n if (editing) {\n return null;\n }\n return (<Button\n {...restProps}\n size={size ?? \"small\"}\n ref={trigger}\n type=\"button\"\n disabled={disabled || busy}\n onClick={start}\n />);\n};\n"],
|
|
5
|
+
"mappings": ";AAOA,SAAS,eAA+B,kBAAkB;AAgBnD,IAAM,gBAAgB,cAAoC,IAAI;AAE9D,IAAM,YAAY,MAAqB;AAC1C,QAAM,SAAS,WAAW,aAAa;AACvC,MAAI,CAAC,QAAQ;AACT,UAAM,IAAI,MAAM,6CAA6C;AAAA,EACjE;AACA,SAAO;AACX;;;ACvBA,SAAS,UAAU;AACnB,SAA8C,iBAAiB,cAAc;AAsErE;AAxDD,IAAM,eAAsC,CAAC,UAA6B;AAC7E,QAAM;AAAA,IAAE;AAAA,IAAS;AAAA,IAAiB;AAAA,IAAO;AAAA,IAAe;AAAA,IAAU;AAAA,IAC9D,OAAO;AAAA,IAAO,WAAW;AAAA,IAAO,iBAAiB;AAAA,IAAO;AAAA,IAAU;AAAA,IAAW,GAAG;AAAA,EAAU,IAAI;AAClG,QAAM,QAAQ,OAA+C,IAAI;AACjE,QAAM,UAAU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;AACD,MAAI,SAAS;AACT,WAAO;AAAA,EACX;AACA,SAAQ,gBAAAC;AAAA,IAACF;AAAA,IAAA;AAAA,MACJ,GAAG;AAAA,MACJ,MAAM,QAAQ;AAAA,MACd,KAAK;AAAA,MACL,MAAK;AAAA,MACL,UAAU,YAAY;AAAA,MACtB,SAAS;AAAA;AAAA,EACb;AACJ;",
|
|
6
|
+
"names": ["jsx", "cn", "jsx", "useRef", "jsx", "jsxs", "isComposingKeyEvent", "useId", "useImperativeHandle", "useRef", "Fragment", "jsx", "jsxs", "Button", "useImperativeHandle", "jsx"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @package Inline Editor
|
|
4
|
+
* @namespace InlineEditorTextarea
|
|
5
|
+
* @description Inline Editor Textarea
|
|
6
|
+
*/
|
|
7
|
+
import { type TextareaProps } from "@gridui/input";
|
|
8
|
+
import { type FC } from "react";
|
|
9
|
+
export type InlineEditorTextareaProps = Omit<TextareaProps, "value" | "defaultValue" | "onValueChange" | "disabled"> & {
|
|
10
|
+
readonly label: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const InlineEditorTextarea: FC<InlineEditorTextareaProps>;
|
|
@@ -11,7 +11,7 @@ export type EditorContext = {
|
|
|
11
11
|
readonly disabled: boolean;
|
|
12
12
|
readonly submitDisabled: boolean;
|
|
13
13
|
readonly value: string;
|
|
14
|
-
readonly input: RefObject<HTMLInputElement | null>;
|
|
14
|
+
readonly input: RefObject<HTMLInputElement | HTMLTextAreaElement | null>;
|
|
15
15
|
readonly trigger: RefObject<HTMLButtonElement | null>;
|
|
16
16
|
readonly onValueChange: (value: string) => void;
|
|
17
17
|
readonly start: () => void;
|
package/docs/catalog.json
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"name": "@gridui/inline-editor",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"category": "core",
|
|
6
6
|
"description": "GridUI React inline editor",
|
|
7
|
-
"usage": "
|
|
7
|
+
"usage": "Component reference contains focused API pages for each public component.",
|
|
8
8
|
"documentation": [
|
|
9
9
|
"README.md",
|
|
10
|
-
"docs/inline-editor.md"
|
|
10
|
+
"docs/inline-editor.md",
|
|
11
|
+
"docs/reference/README.md",
|
|
12
|
+
"docs/reference/inline-editor-actions.md",
|
|
13
|
+
"docs/reference/inline-editor-display.md",
|
|
14
|
+
"docs/reference/inline-editor-field.md",
|
|
15
|
+
"docs/reference/inline-editor-textarea.md",
|
|
16
|
+
"docs/reference/inline-editor-trigger.md",
|
|
17
|
+
"docs/reference/inline-editor.md"
|
|
11
18
|
],
|
|
12
19
|
"exports": [
|
|
13
20
|
{
|
|
@@ -50,6 +57,16 @@
|
|
|
50
57
|
"kind": "type",
|
|
51
58
|
"importPath": "@gridui/inline-editor"
|
|
52
59
|
},
|
|
60
|
+
{
|
|
61
|
+
"name": "InlineEditorTextarea",
|
|
62
|
+
"kind": "component",
|
|
63
|
+
"importPath": "@gridui/inline-editor"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "InlineEditorTextareaProps",
|
|
67
|
+
"kind": "type",
|
|
68
|
+
"importPath": "@gridui/inline-editor"
|
|
69
|
+
},
|
|
53
70
|
{
|
|
54
71
|
"name": "InlineEditorTrigger",
|
|
55
72
|
"kind": "component",
|
package/docs/inline-editor.md
CHANGED
|
@@ -45,3 +45,12 @@ key handler can prevent the default editor shortcut. Native div props and the
|
|
|
45
45
|
outer ref go to the root. The editor uses non-submit buttons and can sit inside
|
|
46
46
|
a larger form. Applications own validation and authorization before accepting a
|
|
47
47
|
submit request.
|
|
48
|
+
|
|
49
|
+
## Multiline editing
|
|
50
|
+
|
|
51
|
+
Use InlineEditorTextarea in place of InlineEditorField for descriptions or notes.
|
|
52
|
+
It accepts native Textarea props, requires label, defaults to automatic height,
|
|
53
|
+
and forwards a native textarea ref. Enter inserts a newline; Ctrl+Enter or
|
|
54
|
+
Command+Enter requests the same validated save as the action button. Escape
|
|
55
|
+
cancels outside IME composition. Failed saves retain the draft under caller
|
|
56
|
+
ownership. Use exactly one field (single-line or multiline) per editor.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<!-- Generated by pnpm docs:storybook. -->
|
|
2
|
+
# Component reference
|
|
3
|
+
|
|
4
|
+
- [InlineEditor](inline-editor.md)
|
|
5
|
+
- [InlineEditorActions](inline-editor-actions.md)
|
|
6
|
+
- [InlineEditorDisplay](inline-editor-display.md)
|
|
7
|
+
- [InlineEditorField](inline-editor-field.md)
|
|
8
|
+
- [InlineEditorTextarea](inline-editor-textarea.md)
|
|
9
|
+
- [InlineEditorTrigger](inline-editor-trigger.md)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
|
|
2
|
+
# InlineEditorActions
|
|
3
|
+
|
|
4
|
+
Compose InlineEditorActions with InlineEditor inside the same @gridui/inline-editor component family.
|
|
5
|
+
|
|
6
|
+
Import from ``@gridui/inline-editor`` and load Theme before this family's stylesheet.
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
import { InlineEditorActions } from "@gridui/inline-editor";
|
|
10
|
+
import "@gridui/theme/styles.css";
|
|
11
|
+
import "@gridui/inline-editor/styles.css";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/inline-editor/README.md) for shared behavior and stylesheet dependencies.
|
|
15
|
+
|
|
16
|
+
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/inline-editor/stories/inline-editor.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
|
|
20
|
+
The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
|
|
21
|
+
|
|
22
|
+
### saveLabel
|
|
23
|
+
|
|
24
|
+
``ReactNode`` · Required
|
|
25
|
+
|
|
26
|
+
### cancelLabel
|
|
27
|
+
|
|
28
|
+
``ReactNode`` · Required
|
|
29
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
|
|
2
|
+
# InlineEditorDisplay
|
|
3
|
+
|
|
4
|
+
Compose InlineEditorDisplay with InlineEditor inside the same @gridui/inline-editor component family.
|
|
5
|
+
|
|
6
|
+
Import from ``@gridui/inline-editor`` and load Theme before this family's stylesheet.
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
import { InlineEditorDisplay } from "@gridui/inline-editor";
|
|
10
|
+
import "@gridui/theme/styles.css";
|
|
11
|
+
import "@gridui/inline-editor/styles.css";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/inline-editor/README.md) for shared behavior and stylesheet dependencies.
|
|
15
|
+
|
|
16
|
+
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/inline-editor/stories/inline-editor.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
|
|
20
|
+
The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
|
|
21
|
+
|
|
22
|
+
### children
|
|
23
|
+
|
|
24
|
+
``ReactNode`` · Optional
|
|
25
|
+
|
|
26
|
+
Content rendered inside the component.
|
|
27
|
+
|
|
28
|
+
### onFocus
|
|
29
|
+
|
|
30
|
+
``(event: FocusEvent<HTMLDivElement, Element>): void`` · Optional
|
|
31
|
+
|
|
32
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
33
|
+
|
|
34
|
+
### onBlur
|
|
35
|
+
|
|
36
|
+
``(event: FocusEvent<HTMLDivElement, Element>): void`` · Optional
|
|
37
|
+
|
|
38
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
39
|
+
|
|
40
|
+
### onChange
|
|
41
|
+
|
|
42
|
+
``(event: ChangeEvent<HTMLDivElement, Element>): void`` · Optional
|
|
43
|
+
|
|
44
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
45
|
+
|
|
46
|
+
### onSubmit
|
|
47
|
+
|
|
48
|
+
``(event: SubmitEvent<HTMLDivElement>): void`` · Optional
|
|
49
|
+
|
|
50
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
51
|
+
|
|
52
|
+
### onClick
|
|
53
|
+
|
|
54
|
+
``(event: MouseEvent<HTMLDivElement, MouseEvent>): void`` · Optional
|
|
55
|
+
|
|
56
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
57
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
|
|
2
|
+
# InlineEditorField
|
|
3
|
+
|
|
4
|
+
Compose InlineEditorField with InlineEditor inside the same @gridui/inline-editor component family.
|
|
5
|
+
|
|
6
|
+
Import from ``@gridui/inline-editor`` and load Theme before this family's stylesheet.
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
import { InlineEditorField } from "@gridui/inline-editor";
|
|
10
|
+
import "@gridui/theme/styles.css";
|
|
11
|
+
import "@gridui/inline-editor/styles.css";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/inline-editor/README.md) for shared behavior and stylesheet dependencies.
|
|
15
|
+
|
|
16
|
+
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/inline-editor/stories/inline-editor.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
|
|
20
|
+
The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
|
|
21
|
+
|
|
22
|
+
### children
|
|
23
|
+
|
|
24
|
+
``ReactNode`` · Optional
|
|
25
|
+
|
|
26
|
+
Content rendered inside the component.
|
|
27
|
+
|
|
28
|
+
### onFocus
|
|
29
|
+
|
|
30
|
+
``(event: FocusEvent<HTMLInputElement, Element>): void`` · Optional
|
|
31
|
+
|
|
32
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
33
|
+
|
|
34
|
+
### onBlur
|
|
35
|
+
|
|
36
|
+
``(event: FocusEvent<HTMLInputElement, Element>): void`` · Optional
|
|
37
|
+
|
|
38
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
39
|
+
|
|
40
|
+
### onChange
|
|
41
|
+
|
|
42
|
+
``(event: ChangeEvent<HTMLInputElement, HTMLInputElement>): void`` · Optional
|
|
43
|
+
|
|
44
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
45
|
+
|
|
46
|
+
### onSubmit
|
|
47
|
+
|
|
48
|
+
``(event: SubmitEvent<HTMLInputElement>): void`` · Optional
|
|
49
|
+
|
|
50
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
51
|
+
|
|
52
|
+
### onClick
|
|
53
|
+
|
|
54
|
+
``(event: MouseEvent<HTMLInputElement, MouseEvent>): void`` · Optional
|
|
55
|
+
|
|
56
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
57
|
+
|
|
58
|
+
### controlSize
|
|
59
|
+
|
|
60
|
+
``"small" | "standard" | undefined`` · Optional
|
|
61
|
+
|
|
62
|
+
### label
|
|
63
|
+
|
|
64
|
+
``string`` · Required
|
|
65
|
+
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
|
|
2
|
+
# InlineEditorTextarea
|
|
3
|
+
|
|
4
|
+
Compose InlineEditorTextarea with InlineEditor inside the same @gridui/inline-editor component family.
|
|
5
|
+
|
|
6
|
+
Import from ``@gridui/inline-editor`` and load Theme before this family's stylesheet.
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
import { InlineEditorTextarea } from "@gridui/inline-editor";
|
|
10
|
+
import "@gridui/theme/styles.css";
|
|
11
|
+
import "@gridui/inline-editor/styles.css";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/inline-editor/README.md) for shared behavior and stylesheet dependencies.
|
|
15
|
+
|
|
16
|
+
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/inline-editor/stories/inline-editor.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
|
|
20
|
+
The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
|
|
21
|
+
|
|
22
|
+
### children
|
|
23
|
+
|
|
24
|
+
``ReactNode`` · Optional
|
|
25
|
+
|
|
26
|
+
Content rendered inside the component.
|
|
27
|
+
|
|
28
|
+
### onFocus
|
|
29
|
+
|
|
30
|
+
``(event: FocusEvent<HTMLTextAreaElement, Element>): void`` · Optional
|
|
31
|
+
|
|
32
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
33
|
+
|
|
34
|
+
### onBlur
|
|
35
|
+
|
|
36
|
+
``(event: FocusEvent<HTMLTextAreaElement, Element>): void`` · Optional
|
|
37
|
+
|
|
38
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
39
|
+
|
|
40
|
+
### onChange
|
|
41
|
+
|
|
42
|
+
``(event: ChangeEvent<HTMLTextAreaElement, HTMLTextAreaElement>): void`` · Optional
|
|
43
|
+
|
|
44
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
45
|
+
|
|
46
|
+
### onSubmit
|
|
47
|
+
|
|
48
|
+
``(event: SubmitEvent<HTMLTextAreaElement>): void`` · Optional
|
|
49
|
+
|
|
50
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
51
|
+
|
|
52
|
+
### onClick
|
|
53
|
+
|
|
54
|
+
``(event: MouseEvent<HTMLTextAreaElement, MouseEvent>): void`` · Optional
|
|
55
|
+
|
|
56
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
57
|
+
|
|
58
|
+
### controlSize
|
|
59
|
+
|
|
60
|
+
``"small" | "standard" | undefined`` · Optional
|
|
61
|
+
|
|
62
|
+
### autoSize
|
|
63
|
+
|
|
64
|
+
``boolean | undefined`` · Optional
|
|
65
|
+
|
|
66
|
+
### maxHeight
|
|
67
|
+
|
|
68
|
+
``number | undefined`` · Optional
|
|
69
|
+
|
|
70
|
+
### maxRows
|
|
71
|
+
|
|
72
|
+
``number | undefined`` · Optional
|
|
73
|
+
|
|
74
|
+
### label
|
|
75
|
+
|
|
76
|
+
``string`` · Required
|
|
77
|
+
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
|
|
2
|
+
# InlineEditorTrigger
|
|
3
|
+
|
|
4
|
+
Compose InlineEditorTrigger with InlineEditor inside the same @gridui/inline-editor component family.
|
|
5
|
+
|
|
6
|
+
Import from ``@gridui/inline-editor`` and load Theme before this family's stylesheet.
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
import { InlineEditorTrigger } from "@gridui/inline-editor";
|
|
10
|
+
import "@gridui/theme/styles.css";
|
|
11
|
+
import "@gridui/inline-editor/styles.css";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/inline-editor/README.md) for shared behavior and stylesheet dependencies.
|
|
15
|
+
|
|
16
|
+
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/inline-editor/stories/inline-editor.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
|
|
20
|
+
The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
|
|
21
|
+
|
|
22
|
+
### children
|
|
23
|
+
|
|
24
|
+
``ReactNode`` · Optional
|
|
25
|
+
|
|
26
|
+
Content rendered inside the component.
|
|
27
|
+
|
|
28
|
+
### variant
|
|
29
|
+
|
|
30
|
+
``"text" | "primary" | "secondary" | "quiet" | "highlight" | "underlined" | null | undefined`` · Optional
|
|
31
|
+
|
|
32
|
+
Visual variant.
|
|
33
|
+
|
|
34
|
+
### size
|
|
35
|
+
|
|
36
|
+
``"small" | "standard" | "large" | "extra-large" | null | undefined`` · Optional
|
|
37
|
+
|
|
38
|
+
Component size preset.
|
|
39
|
+
|
|
40
|
+
### layout
|
|
41
|
+
|
|
42
|
+
``"cell" | "standard" | "icon" | "entry" | "rail" | "divided" | null | undefined`` · Optional
|
|
43
|
+
|
|
44
|
+
Layout within the containing region.
|
|
45
|
+
|
|
46
|
+
### iconMotion
|
|
47
|
+
|
|
48
|
+
``"none" | "outward" | null | undefined`` · Optional
|
|
49
|
+
|
|
50
|
+
### onFocus
|
|
51
|
+
|
|
52
|
+
``(event: FocusEvent<HTMLButtonElement, Element>): void`` · Optional
|
|
53
|
+
|
|
54
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
55
|
+
|
|
56
|
+
### onBlur
|
|
57
|
+
|
|
58
|
+
``(event: FocusEvent<HTMLButtonElement, Element>): void`` · Optional
|
|
59
|
+
|
|
60
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
61
|
+
|
|
62
|
+
### onChange
|
|
63
|
+
|
|
64
|
+
``(event: ChangeEvent<HTMLButtonElement, Element>): void`` · Optional
|
|
65
|
+
|
|
66
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
67
|
+
|
|
68
|
+
### onSubmit
|
|
69
|
+
|
|
70
|
+
``(event: SubmitEvent<HTMLButtonElement>): void`` · Optional
|
|
71
|
+
|
|
72
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
73
|
+
|
|
74
|
+
### startIcon
|
|
75
|
+
|
|
76
|
+
``ReactNode`` · Optional
|
|
77
|
+
|
|
78
|
+
### startIconLayout
|
|
79
|
+
|
|
80
|
+
``"divided" | "inline" | undefined`` · Optional
|
|
81
|
+
|
|
82
|
+
### startIconSize
|
|
83
|
+
|
|
84
|
+
``"standard" | "large" | "extra-large" | undefined`` · Optional
|
|
85
|
+
|
|
86
|
+
### endIcon
|
|
87
|
+
|
|
88
|
+
``ReactNode`` · Optional
|
|
89
|
+
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
|
|
2
|
+
# InlineEditor
|
|
3
|
+
|
|
4
|
+
Switches a displayed value into an editable field with save and cancel actions. Use it for small edits within an existing view.
|
|
5
|
+
|
|
6
|
+
Import from ``@gridui/inline-editor`` and load Theme before this family's stylesheet.
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
import { InlineEditor } from "@gridui/inline-editor";
|
|
10
|
+
import "@gridui/theme/styles.css";
|
|
11
|
+
import "@gridui/inline-editor/styles.css";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/inline-editor/README.md) for shared behavior and stylesheet dependencies.
|
|
15
|
+
|
|
16
|
+
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/inline-editor/stories/inline-editor.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
|
|
20
|
+
The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
|
|
21
|
+
|
|
22
|
+
### children
|
|
23
|
+
|
|
24
|
+
``ReactNode`` · Optional
|
|
25
|
+
|
|
26
|
+
Content rendered inside the component.
|
|
27
|
+
|
|
28
|
+
### onFocus
|
|
29
|
+
|
|
30
|
+
``(event: FocusEvent<HTMLDivElement, Element>): void`` · Optional
|
|
31
|
+
|
|
32
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
33
|
+
|
|
34
|
+
### onBlur
|
|
35
|
+
|
|
36
|
+
``(event: FocusEvent<HTMLDivElement, Element>): void`` · Optional
|
|
37
|
+
|
|
38
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
39
|
+
|
|
40
|
+
### onClick
|
|
41
|
+
|
|
42
|
+
``(event: MouseEvent<HTMLDivElement, MouseEvent>): void`` · Optional
|
|
43
|
+
|
|
44
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
45
|
+
|
|
46
|
+
### editing
|
|
47
|
+
|
|
48
|
+
``boolean`` · Required
|
|
49
|
+
|
|
50
|
+
### onEditingChange
|
|
51
|
+
|
|
52
|
+
``(editing: boolean): void`` · Required
|
|
53
|
+
|
|
54
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
55
|
+
|
|
56
|
+
### value
|
|
57
|
+
|
|
58
|
+
``string`` · Required
|
|
59
|
+
|
|
60
|
+
Controlled value. Pair with the corresponding change callback.
|
|
61
|
+
|
|
62
|
+
### onValueChange
|
|
63
|
+
|
|
64
|
+
``(value: string): void`` · Required
|
|
65
|
+
|
|
66
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
67
|
+
|
|
68
|
+
### onSubmit
|
|
69
|
+
|
|
70
|
+
``(value: string): void`` · Required
|
|
71
|
+
|
|
72
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
73
|
+
|
|
74
|
+
### onCancel
|
|
75
|
+
|
|
76
|
+
``(): void`` · Optional
|
|
77
|
+
|
|
78
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
79
|
+
|
|
80
|
+
### busy
|
|
81
|
+
|
|
82
|
+
``boolean | undefined`` · Optional
|
|
83
|
+
|
|
84
|
+
Default: ``false``
|
|
85
|
+
|
|
86
|
+
### disabled
|
|
87
|
+
|
|
88
|
+
``boolean | undefined`` · Optional
|
|
89
|
+
|
|
90
|
+
Default: ``false``
|
|
91
|
+
|
|
92
|
+
Prevents interaction when enabled.
|
|
93
|
+
|
|
94
|
+
### submitDisabled
|
|
95
|
+
|
|
96
|
+
``boolean | undefined`` · Optional
|
|
97
|
+
|
|
98
|
+
Default: ``false``
|
|
99
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gridui/inline-editor",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "GridUI React inline editor",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"react-dom": "^19.2.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@gridui/button": "^
|
|
31
|
-
"@gridui/input": "^
|
|
30
|
+
"@gridui/button": "^4.0.0",
|
|
31
|
+
"@gridui/input": "^3.0.0",
|
|
32
32
|
"@gridui/interaction": "^1.2.1",
|
|
33
|
-
"@gridui/style-utils": "^
|
|
33
|
+
"@gridui/style-utils": "^3.0.0",
|
|
34
34
|
"@gridui/theme": "^2.5.3"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|