@yamada-ui/editable 1.0.45-dev-20241005224505 → 1.0.45-dev-20241006032009
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{chunk-IZRLAY3V.mjs → chunk-PCLA7CWV.mjs} +79 -79
- package/dist/chunk-PCLA7CWV.mjs.map +1 -0
- package/dist/editable.d.mts +35 -35
- package/dist/editable.d.ts +35 -35
- package/dist/editable.js +70 -70
- package/dist/editable.js.map +1 -1
- package/dist/editable.mjs +1 -1
- package/dist/index.js +70 -70
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +6 -6
- package/dist/chunk-IZRLAY3V.mjs.map +0 -1
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
// src/editable.tsx
|
4
4
|
import {
|
5
|
-
ui,
|
6
5
|
forwardRef,
|
7
|
-
|
8
|
-
|
6
|
+
omitThemeProps,
|
7
|
+
ui,
|
8
|
+
useComponentMultiStyle
|
9
9
|
} from "@yamada-ui/core";
|
10
10
|
import {
|
11
11
|
formControlProperties,
|
@@ -16,35 +16,35 @@ import { useFocusOnPointerDown } from "@yamada-ui/use-focus";
|
|
16
16
|
import {
|
17
17
|
createContext,
|
18
18
|
cx,
|
19
|
+
handlerAll,
|
20
|
+
isContains,
|
21
|
+
mergeRefs,
|
22
|
+
pickObject,
|
19
23
|
runIfFunc,
|
20
24
|
useCallbackRef,
|
21
25
|
useSafeLayoutEffect,
|
22
|
-
useUpdateEffect
|
23
|
-
isContains,
|
24
|
-
handlerAll,
|
25
|
-
mergeRefs,
|
26
|
-
pickObject
|
26
|
+
useUpdateEffect
|
27
27
|
} from "@yamada-ui/utils";
|
28
28
|
import { useCallback, useEffect, useRef, useState } from "react";
|
29
29
|
import { jsx } from "react/jsx-runtime";
|
30
30
|
var useEditable = (props) => {
|
31
31
|
const {
|
32
32
|
id,
|
33
|
+
defaultValue,
|
34
|
+
isPreviewFocusable = true,
|
33
35
|
placeholder,
|
36
|
+
selectAllOnFocus = true,
|
37
|
+
startWithEditView,
|
38
|
+
submitOnBlur = true,
|
34
39
|
value: valueProp,
|
35
|
-
onChange: onChangeProp,
|
36
40
|
onCancel: onCancelProp,
|
37
|
-
|
41
|
+
onChange: onChangeProp,
|
38
42
|
onEdit: onEditProp,
|
39
|
-
|
40
|
-
startWithEditView,
|
41
|
-
isPreviewFocusable = true,
|
42
|
-
submitOnBlur = true,
|
43
|
-
selectAllOnFocus = true,
|
43
|
+
onSubmit: onSubmitProp,
|
44
44
|
...rest
|
45
45
|
} = useFormControlProps(props);
|
46
46
|
const onEditRef = useCallbackRef(onEditProp);
|
47
|
-
const {
|
47
|
+
const { disabled, readOnly, required, ...formControlProps } = pickObject(
|
48
48
|
rest,
|
49
49
|
formControlProperties
|
50
50
|
);
|
@@ -66,8 +66,8 @@ var useEditable = (props) => {
|
|
66
66
|
const submitRef = useRef(null);
|
67
67
|
useFocusOnPointerDown({
|
68
68
|
ref: inputRef,
|
69
|
-
|
70
|
-
|
69
|
+
elements: [cancelRef, submitRef],
|
70
|
+
enabled: isEditing
|
71
71
|
});
|
72
72
|
useSafeLayoutEffect(() => {
|
73
73
|
var _a, _b;
|
@@ -116,7 +116,7 @@ var useEditable = (props) => {
|
|
116
116
|
if (ev.key === "Escape") {
|
117
117
|
onCancel();
|
118
118
|
} else {
|
119
|
-
const {
|
119
|
+
const { metaKey, shiftKey } = ev;
|
120
120
|
if (!shiftKey && !metaKey) onSubmit();
|
121
121
|
}
|
122
122
|
},
|
@@ -152,9 +152,9 @@ var useEditable = (props) => {
|
|
152
152
|
(props2 = {}, ref = null) => ({
|
153
153
|
...props2,
|
154
154
|
ref: mergeRefs(ref, previewRef),
|
155
|
+
children: isValueEmpty ? placeholder : value,
|
155
156
|
hidden: isEditing,
|
156
157
|
tabIndex: isInteractive && isPreviewFocusable ? 0 : void 0,
|
157
|
-
children: isValueEmpty ? placeholder : value,
|
158
158
|
onFocus: handlerAll(props2.onFocus, onEdit, onUpdatePrevValue)
|
159
159
|
}),
|
160
160
|
[
|
@@ -172,18 +172,18 @@ var useEditable = (props) => {
|
|
172
172
|
(props2 = {}, ref = null) => ({
|
173
173
|
...formControlProps,
|
174
174
|
...props2,
|
175
|
-
ref: mergeRefs(ref, inputRef),
|
176
175
|
id,
|
177
|
-
|
178
|
-
hidden: !isEditing,
|
179
|
-
value,
|
180
|
-
required,
|
176
|
+
ref: mergeRefs(ref, inputRef),
|
181
177
|
disabled,
|
178
|
+
hidden: !isEditing,
|
179
|
+
placeholder,
|
182
180
|
readOnly,
|
181
|
+
required,
|
182
|
+
value,
|
183
183
|
onBlur: handlerAll(props2.onBlur, onBlur),
|
184
184
|
onChange: handlerAll(props2.onChange, onChange),
|
185
|
-
|
186
|
-
|
185
|
+
onFocus: handlerAll(props2.onFocus, onUpdatePrevValue),
|
186
|
+
onKeyDown: handlerAll(props2.onKeyDown, onKeyDown)
|
187
187
|
}),
|
188
188
|
[
|
189
189
|
disabled,
|
@@ -204,18 +204,18 @@ var useEditable = (props) => {
|
|
204
204
|
(props2 = {}, ref = null) => ({
|
205
205
|
...formControlProps,
|
206
206
|
...props2,
|
207
|
-
ref: mergeRefs(ref, inputRef),
|
208
207
|
id,
|
209
|
-
|
210
|
-
hidden: !isEditing,
|
211
|
-
value,
|
212
|
-
required,
|
208
|
+
ref: mergeRefs(ref, inputRef),
|
213
209
|
disabled,
|
210
|
+
hidden: !isEditing,
|
211
|
+
placeholder,
|
214
212
|
readOnly,
|
213
|
+
required,
|
214
|
+
value,
|
215
215
|
onBlur: handlerAll(props2.onBlur, onBlur),
|
216
216
|
onChange: handlerAll(props2.onChange, onChange),
|
217
|
-
|
218
|
-
|
217
|
+
onFocus: handlerAll(props2.onFocus, onUpdatePrevValue),
|
218
|
+
onKeyDown: handlerAll(props2.onKeyDown, onKeyDownWithoutSubmit)
|
219
219
|
}),
|
220
220
|
[
|
221
221
|
disabled,
|
@@ -271,85 +271,85 @@ var useEditable = (props) => {
|
|
271
271
|
return {
|
272
272
|
isEditing,
|
273
273
|
value,
|
274
|
-
|
275
|
-
onCancel,
|
276
|
-
onSubmit,
|
277
|
-
getPreviewProps,
|
278
|
-
getInputProps,
|
279
|
-
getTextareaProps,
|
274
|
+
getCancelProps,
|
280
275
|
getEditProps,
|
276
|
+
getInputProps,
|
277
|
+
getPreviewProps,
|
281
278
|
getSubmitProps,
|
282
|
-
|
279
|
+
getTextareaProps,
|
280
|
+
onCancel,
|
281
|
+
onEdit,
|
282
|
+
onSubmit
|
283
283
|
};
|
284
284
|
};
|
285
285
|
var useEditableControl = () => {
|
286
|
-
const { isEditing,
|
287
|
-
return { isEditing,
|
286
|
+
const { isEditing, getCancelProps, getEditProps, getSubmitProps } = useEditableContext();
|
287
|
+
return { isEditing, getCancelProps, getEditProps, getSubmitProps };
|
288
288
|
};
|
289
289
|
var [EditableProvider, useEditableContext] = createContext({
|
290
290
|
name: "EditableContext",
|
291
291
|
errorMessage: "useEditableContext: context is undefined. Seems you forgot to wrap the editable components in `<Editable />`"
|
292
292
|
});
|
293
293
|
var Editable = forwardRef(
|
294
|
-
({
|
294
|
+
({ errorBorderColor, focusBorderColor, ...props }, ref) => {
|
295
295
|
const [styles, mergedProps] = useComponentMultiStyle("Editable", {
|
296
|
-
focusBorderColor,
|
297
296
|
errorBorderColor,
|
297
|
+
focusBorderColor,
|
298
298
|
...props
|
299
299
|
});
|
300
300
|
const {
|
301
301
|
className,
|
302
302
|
children,
|
303
|
+
defaultValue,
|
304
|
+
isDisabled,
|
303
305
|
isInvalid,
|
306
|
+
isPreviewFocusable,
|
304
307
|
isReadOnly,
|
305
308
|
isRequired,
|
306
|
-
isDisabled,
|
307
309
|
placeholder,
|
308
|
-
|
309
|
-
defaultValue,
|
310
|
+
selectAllOnFocus,
|
310
311
|
startWithEditView,
|
311
|
-
isPreviewFocusable,
|
312
312
|
submitOnBlur,
|
313
|
-
|
314
|
-
onChange,
|
313
|
+
value,
|
315
314
|
onCancel: onCancelProp,
|
316
|
-
|
315
|
+
onChange,
|
317
316
|
onEdit: onEditProp,
|
317
|
+
onSubmit: onSubmitProp,
|
318
318
|
...rest
|
319
319
|
} = omitThemeProps(mergedProps);
|
320
320
|
const {
|
321
321
|
isEditing,
|
322
|
-
getPreviewProps,
|
323
|
-
getInputProps,
|
324
|
-
getTextareaProps,
|
325
|
-
getEditProps,
|
326
322
|
getCancelProps,
|
323
|
+
getEditProps,
|
324
|
+
getInputProps,
|
325
|
+
getPreviewProps,
|
327
326
|
getSubmitProps,
|
328
|
-
|
327
|
+
getTextareaProps,
|
329
328
|
onCancel,
|
330
|
-
onEdit
|
329
|
+
onEdit,
|
330
|
+
onSubmit
|
331
331
|
} = useEditable({
|
332
|
+
defaultValue,
|
333
|
+
isDisabled,
|
332
334
|
isInvalid,
|
335
|
+
isPreviewFocusable,
|
333
336
|
isReadOnly,
|
334
337
|
isRequired,
|
335
|
-
isDisabled,
|
336
338
|
placeholder,
|
337
|
-
|
338
|
-
defaultValue,
|
339
|
+
selectAllOnFocus,
|
339
340
|
startWithEditView,
|
340
|
-
isPreviewFocusable,
|
341
341
|
submitOnBlur,
|
342
|
-
|
343
|
-
onChange,
|
342
|
+
value,
|
344
343
|
onCancel: onCancelProp,
|
345
|
-
|
346
|
-
onEdit: onEditProp
|
344
|
+
onChange,
|
345
|
+
onEdit: onEditProp,
|
346
|
+
onSubmit: onSubmitProp
|
347
347
|
});
|
348
348
|
const cloneChildren = runIfFunc(children, {
|
349
349
|
isEditing,
|
350
|
-
onSubmit,
|
351
350
|
onCancel,
|
352
|
-
onEdit
|
351
|
+
onEdit,
|
352
|
+
onSubmit
|
353
353
|
});
|
354
354
|
const css = { ...styles.container };
|
355
355
|
return /* @__PURE__ */ jsx(
|
@@ -357,13 +357,13 @@ var Editable = forwardRef(
|
|
357
357
|
{
|
358
358
|
value: {
|
359
359
|
isEditing,
|
360
|
-
|
361
|
-
getInputProps,
|
362
|
-
getTextareaProps,
|
363
|
-
getEditProps,
|
360
|
+
styles,
|
364
361
|
getCancelProps,
|
362
|
+
getEditProps,
|
363
|
+
getInputProps,
|
364
|
+
getPreviewProps,
|
365
365
|
getSubmitProps,
|
366
|
-
|
366
|
+
getTextareaProps
|
367
367
|
},
|
368
368
|
children: /* @__PURE__ */ jsx(
|
369
369
|
ui.div,
|
@@ -385,12 +385,12 @@ var EditablePreview = forwardRef(
|
|
385
385
|
({ className, ...rest }, ref) => {
|
386
386
|
const { styles, getPreviewProps } = useEditableContext();
|
387
387
|
const css = {
|
388
|
+
bg: "transparent",
|
388
389
|
cursor: "text",
|
389
390
|
display: "inline-block",
|
390
391
|
fontSize: "inherit",
|
391
392
|
fontWeight: "inherit",
|
392
393
|
textAlign: "inherit",
|
393
|
-
bg: "transparent",
|
394
394
|
...styles.preview
|
395
395
|
};
|
396
396
|
return /* @__PURE__ */ jsx(
|
@@ -409,11 +409,11 @@ var EditableInput = forwardRef(
|
|
409
409
|
({ className, ...rest }, ref) => {
|
410
410
|
const { styles, getInputProps } = useEditableContext();
|
411
411
|
const css = {
|
412
|
-
|
412
|
+
bg: "transparent",
|
413
413
|
fontSize: "inherit",
|
414
414
|
fontWeight: "inherit",
|
415
|
+
outline: 0,
|
415
416
|
textAlign: "inherit",
|
416
|
-
bg: "transparent",
|
417
417
|
...styles.input
|
418
418
|
};
|
419
419
|
return /* @__PURE__ */ jsx(
|
@@ -432,11 +432,11 @@ var EditableTextarea = forwardRef(
|
|
432
432
|
({ className, ...rest }, ref) => {
|
433
433
|
const { styles, getTextareaProps } = useEditableContext();
|
434
434
|
const css = {
|
435
|
-
|
435
|
+
bg: "transparent",
|
436
436
|
fontSize: "inherit",
|
437
437
|
fontWeight: "inherit",
|
438
|
+
outline: 0,
|
438
439
|
textAlign: "inherit",
|
439
|
-
bg: "transparent",
|
440
440
|
...styles.textarea
|
441
441
|
};
|
442
442
|
return /* @__PURE__ */ jsx(
|
@@ -460,4 +460,4 @@ export {
|
|
460
460
|
EditableInput,
|
461
461
|
EditableTextarea
|
462
462
|
};
|
463
|
-
//# sourceMappingURL=chunk-
|
463
|
+
//# sourceMappingURL=chunk-PCLA7CWV.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/editable.tsx"],"sourcesContent":["import type {\n ColorModeToken,\n CSS,\n CSSUIObject,\n HTMLUIProps,\n PropGetter,\n ThemeProps,\n} from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport type { ChangeEvent, FocusEvent, KeyboardEvent, ReactNode } from \"react\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentMultiStyle,\n} from \"@yamada-ui/core\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useFocusOnPointerDown } from \"@yamada-ui/use-focus\"\nimport {\n createContext,\n cx,\n handlerAll,\n isContains,\n mergeRefs,\n pickObject,\n runIfFunc,\n useCallbackRef,\n useSafeLayoutEffect,\n useUpdateEffect,\n} from \"@yamada-ui/utils\"\nimport { useCallback, useEffect, useRef, useState } from \"react\"\n\nexport interface UseEditableProps extends FormControlOptions {\n /**\n * The initial value of the Editable in both edit & preview mode.\n */\n defaultValue?: string\n /**\n * If `true`, the read only view, has a `tabIndex` set to `0`\n * so it can receive focus via the keyboard or click.\n *\n * @default true\n */\n isPreviewFocusable?: boolean\n /**\n * The placeholder text when the value is empty.\n */\n placeholder?: string\n /**\n * If `true`, the input's text will be highlighted on focus.\n *\n * @default true\n */\n selectAllOnFocus?: boolean\n /**\n * If `true`, the Editable will start with edit mode by default.\n */\n startWithEditView?: boolean\n /**\n * If `true`, it'll update the value onBlur and turn off the edit mode.\n *\n * @default true\n */\n submitOnBlur?: boolean\n /**\n * The value of the Editable in both edit & preview mode.\n */\n value?: string\n /**\n * Callback invoked when user cancels input with the `Esc` key.\n * It provides the last confirmed value as argument.\n */\n onCancel?: (preValue: string) => void\n /**\n * A callback invoked when user changes input.\n */\n onChange?: (value: string) => void\n /**\n * A callback invoked once the user enters edit mode.\n */\n onEdit?: () => void\n /**\n * A callback invoked when user confirms value with `enter` key or by blurring input.\n */\n onSubmit?: (value: string) => void\n}\n\nexport const useEditable = (props: UseEditableProps) => {\n const {\n id,\n defaultValue,\n isPreviewFocusable = true,\n placeholder,\n selectAllOnFocus = true,\n startWithEditView,\n submitOnBlur = true,\n value: valueProp,\n onCancel: onCancelProp,\n onChange: onChangeProp,\n onEdit: onEditProp,\n onSubmit: onSubmitProp,\n ...rest\n } = useFormControlProps(props)\n const onEditRef = useCallbackRef(onEditProp)\n const { disabled, readOnly, required, ...formControlProps } = pickObject(\n rest,\n formControlProperties,\n )\n\n const [isEditing, setIsEditing] = useState<boolean>(\n !!startWithEditView && !disabled,\n )\n\n const [value, setValue] = useControllableState({\n defaultValue: defaultValue || \"\",\n value: valueProp,\n onChange: onChangeProp,\n })\n\n const isInteractive = !isEditing && !disabled\n const isValueEmpty = value.length === 0\n\n const [prevValue, setPrevValue] = useState(value)\n\n const inputRef = useRef<HTMLInputElement | HTMLTextAreaElement>(null)\n const previewRef = useRef<HTMLElement>(null)\n const editRef = useRef<HTMLButtonElement>(null)\n const cancelRef = useRef<HTMLButtonElement>(null)\n const submitRef = useRef<HTMLButtonElement>(null)\n\n useFocusOnPointerDown({\n ref: inputRef,\n elements: [cancelRef, submitRef],\n enabled: isEditing,\n })\n\n useSafeLayoutEffect(() => {\n if (!isEditing) return\n\n inputRef.current?.focus()\n\n if (selectAllOnFocus) inputRef.current?.select()\n }, [])\n\n useUpdateEffect(() => {\n if (!isEditing) {\n editRef.current?.focus()\n\n return\n }\n\n inputRef.current?.focus()\n\n if (selectAllOnFocus) inputRef.current?.select()\n\n onEditRef()\n }, [isEditing, onEditRef, selectAllOnFocus])\n\n useEffect(() => {\n if (isEditing) return\n\n const el = inputRef.current\n const activeEl = el?.ownerDocument.activeElement\n\n if (activeEl === el) el?.blur()\n }, [isEditing])\n\n const onChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) =>\n setValue(ev.currentTarget.value),\n [setValue],\n )\n\n const onUpdatePrevValue = useCallback(() => setPrevValue(value), [value])\n\n const onEdit = useCallback(() => {\n if (isInteractive) setIsEditing(true)\n }, [isInteractive])\n\n const onCancel = useCallback(() => {\n setIsEditing(false)\n setValue(prevValue)\n onCancelProp?.(prevValue)\n }, [prevValue, onCancelProp, setValue])\n\n const onSubmit = useCallback(() => {\n setIsEditing(false)\n setPrevValue(value)\n onSubmitProp?.(value)\n }, [onSubmitProp, value])\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent) => {\n if (ev.key !== \"Escape\" && ev.key !== \"Enter\") return\n\n ev.preventDefault()\n\n if (ev.key === \"Escape\") {\n onCancel()\n } else {\n const { metaKey, shiftKey } = ev\n\n if (!shiftKey && !metaKey) onSubmit()\n }\n },\n [onCancel, onSubmit],\n )\n\n const onKeyDownWithoutSubmit = useCallback(\n (ev: KeyboardEvent) => {\n if (ev.key !== \"Escape\") return\n\n ev.preventDefault()\n onCancel()\n },\n [onCancel],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent) => {\n if (!isEditing) return\n\n const ownerDocument = ev.currentTarget.ownerDocument\n const relatedTarget = (ev.relatedTarget ??\n ownerDocument.activeElement) as HTMLElement\n const targetIsCancel = isContains(cancelRef.current, relatedTarget)\n const targetIsSubmit = isContains(submitRef.current, relatedTarget)\n const isValidBlur = !targetIsCancel && !targetIsSubmit\n\n if (!isValidBlur) return\n\n if (submitOnBlur) {\n onSubmit()\n } else {\n onCancel()\n }\n },\n [isEditing, submitOnBlur, onSubmit, onCancel],\n )\n\n const getPreviewProps: PropGetter<\"span\"> = useCallback(\n (props = {}, ref = null) => ({\n ...props,\n ref: mergeRefs(ref, previewRef),\n children: isValueEmpty ? placeholder : value,\n hidden: isEditing,\n tabIndex: isInteractive && isPreviewFocusable ? 0 : undefined,\n onFocus: handlerAll(props.onFocus, onEdit, onUpdatePrevValue),\n }),\n [\n isEditing,\n isInteractive,\n isPreviewFocusable,\n isValueEmpty,\n onEdit,\n onUpdatePrevValue,\n placeholder,\n value,\n ],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...formControlProps,\n ...props,\n id,\n ref: mergeRefs(ref, inputRef),\n disabled,\n hidden: !isEditing,\n placeholder,\n readOnly,\n required,\n value,\n onBlur: handlerAll(props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onChange),\n onFocus: handlerAll(props.onFocus, onUpdatePrevValue),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }),\n [\n disabled,\n id,\n isEditing,\n onBlur,\n onChange,\n onKeyDown,\n onUpdatePrevValue,\n placeholder,\n readOnly,\n required,\n formControlProps,\n value,\n ],\n )\n\n const getTextareaProps: PropGetter<\"textarea\"> = useCallback(\n (props = {}, ref = null) => ({\n ...formControlProps,\n ...props,\n id,\n ref: mergeRefs(ref, inputRef),\n disabled,\n hidden: !isEditing,\n placeholder,\n readOnly,\n required,\n value,\n onBlur: handlerAll(props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onChange),\n onFocus: handlerAll(props.onFocus, onUpdatePrevValue),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDownWithoutSubmit),\n }),\n [\n disabled,\n id,\n isEditing,\n onBlur,\n onChange,\n onKeyDownWithoutSubmit,\n onUpdatePrevValue,\n placeholder,\n readOnly,\n required,\n formControlProps,\n value,\n ],\n )\n\n const getEditProps: PropGetter<\"button\"> = useCallback(\n (props = {}, ref = null) => ({\n ...formControlProps,\n ...props,\n ref: mergeRefs(ref, editRef),\n type: \"button\",\n disabled,\n readOnly,\n onClick: handlerAll(props.onClick, onEdit),\n }),\n [disabled, onEdit, readOnly, formControlProps],\n )\n\n const getSubmitProps: PropGetter<\"button\"> = useCallback(\n (props = {}, ref = null) => ({\n ...formControlProps,\n ...props,\n ref: mergeRefs(submitRef, ref),\n type: \"button\",\n disabled,\n readOnly,\n onClick: handlerAll(props.onClick, onSubmit),\n }),\n [disabled, onSubmit, readOnly, formControlProps],\n )\n\n const getCancelProps: PropGetter<\"button\"> = useCallback(\n (props = {}, ref = null) => ({\n ...formControlProps,\n ...props,\n ref: mergeRefs(cancelRef, ref),\n type: \"button\",\n disabled,\n readOnly,\n onClick: handlerAll(props.onClick, onCancel),\n }),\n [disabled, onCancel, readOnly, formControlProps],\n )\n\n return {\n isEditing,\n value,\n getCancelProps,\n getEditProps,\n getInputProps,\n getPreviewProps,\n getSubmitProps,\n getTextareaProps,\n onCancel,\n onEdit,\n onSubmit,\n }\n}\n\nexport type UseEditableReturn = ReturnType<typeof useEditable>\n\nexport const useEditableControl = () => {\n const { isEditing, getCancelProps, getEditProps, getSubmitProps } =\n useEditableContext()\n\n return { isEditing, getCancelProps, getEditProps, getSubmitProps }\n}\n\ninterface EditableContext {\n isEditing: boolean\n styles: { [key: string]: CSSUIObject | undefined }\n getCancelProps: PropGetter<\"button\">\n getEditProps: PropGetter<\"button\">\n getInputProps: PropGetter<\"input\">\n getPreviewProps: PropGetter<\"span\">\n getSubmitProps: PropGetter<\"button\">\n getTextareaProps: PropGetter<\"textarea\">\n}\n\nconst [EditableProvider, useEditableContext] = createContext<EditableContext>({\n name: \"EditableContext\",\n errorMessage:\n \"useEditableContext: context is undefined. Seems you forgot to wrap the editable components in `<Editable />`\",\n})\n\ninterface EditableElementProps\n extends Pick<\n UseEditableReturn,\n \"isEditing\" | \"onCancel\" | \"onEdit\" | \"onSubmit\"\n > {}\n\ntype EditableElement = (props: EditableElementProps) => ReactNode\n\ninterface EditableOptions {\n children?: EditableElement | ReactNode\n /**\n * The border color when the input is invalid.\n */\n errorBorderColor?: ColorModeToken<CSS.Property.BorderColor, \"colors\">\n /**\n * The border color when the input is focused.\n */\n focusBorderColor?: ColorModeToken<CSS.Property.BorderColor, \"colors\">\n}\n\nexport interface EditableProps\n extends Omit<\n HTMLUIProps,\n \"children\" | \"defaultValue\" | \"onChange\" | \"onSubmit\" | \"value\"\n >,\n ThemeProps<\"Editable\">,\n UseEditableProps,\n EditableOptions {}\n\n/**\n * `Editable` is a component used to obtain inline editable text input.\n *\n * @see Docs https://yamada-ui.com/components/forms/editable\n */\nexport const Editable = forwardRef<EditableProps, \"div\">(\n ({ errorBorderColor, focusBorderColor, ...props }, ref) => {\n const [styles, mergedProps] = useComponentMultiStyle(\"Editable\", {\n errorBorderColor,\n focusBorderColor,\n ...props,\n })\n const {\n className,\n children,\n defaultValue,\n isDisabled,\n isInvalid,\n isPreviewFocusable,\n isReadOnly,\n isRequired,\n placeholder,\n selectAllOnFocus,\n startWithEditView,\n submitOnBlur,\n value,\n onCancel: onCancelProp,\n onChange,\n onEdit: onEditProp,\n onSubmit: onSubmitProp,\n ...rest\n } = omitThemeProps(mergedProps)\n const {\n isEditing,\n getCancelProps,\n getEditProps,\n getInputProps,\n getPreviewProps,\n getSubmitProps,\n getTextareaProps,\n onCancel,\n onEdit,\n onSubmit,\n } = useEditable({\n defaultValue,\n isDisabled,\n isInvalid,\n isPreviewFocusable,\n isReadOnly,\n isRequired,\n placeholder,\n selectAllOnFocus,\n startWithEditView,\n submitOnBlur,\n value,\n onCancel: onCancelProp,\n onChange,\n onEdit: onEditProp,\n onSubmit: onSubmitProp,\n })\n\n const cloneChildren = runIfFunc(children, {\n isEditing,\n onCancel,\n onEdit,\n onSubmit,\n })\n\n const css: CSSUIObject = { ...styles.container }\n\n return (\n <EditableProvider\n value={{\n isEditing,\n styles,\n getCancelProps,\n getEditProps,\n getInputProps,\n getPreviewProps,\n getSubmitProps,\n getTextareaProps,\n }}\n >\n <ui.div\n ref={ref}\n className={cx(\"ui-editable\", className)}\n {...rest}\n __css={css}\n >\n {cloneChildren}\n </ui.div>\n </EditableProvider>\n )\n },\n)\n\nEditable.displayName = \"Editable\"\nEditable.__ui__ = \"Editable\"\n\nexport interface EditablePreviewProps extends HTMLUIProps<\"span\"> {}\n\nexport const EditablePreview = forwardRef<EditablePreviewProps, \"span\">(\n ({ className, ...rest }, ref) => {\n const { styles, getPreviewProps } = useEditableContext()\n\n const css: CSSUIObject = {\n bg: \"transparent\",\n cursor: \"text\",\n display: \"inline-block\",\n fontSize: \"inherit\",\n fontWeight: \"inherit\",\n textAlign: \"inherit\",\n ...styles.preview,\n }\n\n return (\n <ui.span\n className={cx(\"ui-editable__preview\", className)}\n {...getPreviewProps(rest, ref)}\n __css={css}\n />\n )\n },\n)\n\nEditablePreview.displayName = \"EditablePreview\"\nEditablePreview.__ui__ = \"EditablePreview\"\n\nexport interface EditableInputProps extends HTMLUIProps<\"input\"> {}\n\nexport const EditableInput = forwardRef<EditableInputProps, \"input\">(\n ({ className, ...rest }, ref) => {\n const { styles, getInputProps } = useEditableContext()\n\n const css: CSSUIObject = {\n bg: \"transparent\",\n fontSize: \"inherit\",\n fontWeight: \"inherit\",\n outline: 0,\n textAlign: \"inherit\",\n ...styles.input,\n }\n\n return (\n <ui.input\n className={cx(\"ui-editable__input\", className)}\n {...getInputProps(rest, ref)}\n __css={css}\n />\n )\n },\n)\n\nEditableInput.displayName = \"EditableInput\"\nEditableInput.__ui__ = \"EditableInput\"\n\nexport interface EditableTextareaProps extends HTMLUIProps<\"textarea\"> {}\n\nexport const EditableTextarea = forwardRef<EditableTextareaProps, \"textarea\">(\n ({ className, ...rest }, ref) => {\n const { styles, getTextareaProps } = useEditableContext()\n\n const css: CSSUIObject = {\n bg: \"transparent\",\n fontSize: \"inherit\",\n fontWeight: \"inherit\",\n outline: 0,\n textAlign: \"inherit\",\n ...styles.textarea,\n }\n\n return (\n <ui.textarea\n className={cx(\"ui-editable__textarea\", className)}\n {...getTextareaProps(rest, ref)}\n __css={css}\n />\n )\n },\n)\n\nEditableTextarea.displayName = \"EditableTextarea\"\nEditableTextarea.__ui__ = \"EditableTextarea\"\n"],"mappings":";;;AAUA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B;AACrC,SAAS,6BAA6B;AACtC;AAAA,EACE;AAAA,EACA;AAAA,EACA;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AM,GAAG;AAAA,QAC9B,OAAO;AAAA;AAAA,IACT;AAAA,EAEJ;AACF;AAEA,iBAAiB,cAAc;AAC/B,iBAAiB,SAAS;","names":["props"]}
|
package/dist/editable.d.mts
CHANGED
@@ -4,22 +4,10 @@ import { FormControlOptions } from '@yamada-ui/form-control';
|
|
4
4
|
import { ReactNode } from 'react';
|
5
5
|
|
6
6
|
interface UseEditableProps extends FormControlOptions {
|
7
|
-
/**
|
8
|
-
* The placeholder text when the value is empty.
|
9
|
-
*/
|
10
|
-
placeholder?: string;
|
11
|
-
/**
|
12
|
-
* The value of the Editable in both edit & preview mode.
|
13
|
-
*/
|
14
|
-
value?: string;
|
15
7
|
/**
|
16
8
|
* The initial value of the Editable in both edit & preview mode.
|
17
9
|
*/
|
18
10
|
defaultValue?: string;
|
19
|
-
/**
|
20
|
-
* If `true`, the Editable will start with edit mode by default.
|
21
|
-
*/
|
22
|
-
startWithEditView?: boolean;
|
23
11
|
/**
|
24
12
|
* If `true`, the read only view, has a `tabIndex` set to `0`
|
25
13
|
* so it can receive focus via the keyboard or click.
|
@@ -28,11 +16,9 @@ interface UseEditableProps extends FormControlOptions {
|
|
28
16
|
*/
|
29
17
|
isPreviewFocusable?: boolean;
|
30
18
|
/**
|
31
|
-
*
|
32
|
-
*
|
33
|
-
* @default true
|
19
|
+
* The placeholder text when the value is empty.
|
34
20
|
*/
|
35
|
-
|
21
|
+
placeholder?: string;
|
36
22
|
/**
|
37
23
|
* If `true`, the input's text will be highlighted on focus.
|
38
24
|
*
|
@@ -40,58 +26,72 @@ interface UseEditableProps extends FormControlOptions {
|
|
40
26
|
*/
|
41
27
|
selectAllOnFocus?: boolean;
|
42
28
|
/**
|
43
|
-
*
|
29
|
+
* If `true`, the Editable will start with edit mode by default.
|
44
30
|
*/
|
45
|
-
|
31
|
+
startWithEditView?: boolean;
|
32
|
+
/**
|
33
|
+
* If `true`, it'll update the value onBlur and turn off the edit mode.
|
34
|
+
*
|
35
|
+
* @default true
|
36
|
+
*/
|
37
|
+
submitOnBlur?: boolean;
|
38
|
+
/**
|
39
|
+
* The value of the Editable in both edit & preview mode.
|
40
|
+
*/
|
41
|
+
value?: string;
|
46
42
|
/**
|
47
43
|
* Callback invoked when user cancels input with the `Esc` key.
|
48
44
|
* It provides the last confirmed value as argument.
|
49
45
|
*/
|
50
46
|
onCancel?: (preValue: string) => void;
|
51
47
|
/**
|
52
|
-
* A callback invoked when user
|
48
|
+
* A callback invoked when user changes input.
|
53
49
|
*/
|
54
|
-
|
50
|
+
onChange?: (value: string) => void;
|
55
51
|
/**
|
56
52
|
* A callback invoked once the user enters edit mode.
|
57
53
|
*/
|
58
54
|
onEdit?: () => void;
|
55
|
+
/**
|
56
|
+
* A callback invoked when user confirms value with `enter` key or by blurring input.
|
57
|
+
*/
|
58
|
+
onSubmit?: (value: string) => void;
|
59
59
|
}
|
60
60
|
declare const useEditable: (props: UseEditableProps) => {
|
61
61
|
isEditing: boolean;
|
62
62
|
value: string;
|
63
|
-
|
64
|
-
onCancel: () => void;
|
65
|
-
onSubmit: () => void;
|
66
|
-
getPreviewProps: PropGetter<"span", undefined>;
|
67
|
-
getInputProps: PropGetter<"input", undefined>;
|
68
|
-
getTextareaProps: PropGetter<"textarea", undefined>;
|
63
|
+
getCancelProps: PropGetter<"button", undefined>;
|
69
64
|
getEditProps: PropGetter<"button", undefined>;
|
65
|
+
getInputProps: PropGetter<"input", undefined>;
|
66
|
+
getPreviewProps: PropGetter<"span", undefined>;
|
70
67
|
getSubmitProps: PropGetter<"button", undefined>;
|
71
|
-
|
68
|
+
getTextareaProps: PropGetter<"textarea", undefined>;
|
69
|
+
onCancel: () => void;
|
70
|
+
onEdit: () => void;
|
71
|
+
onSubmit: () => void;
|
72
72
|
};
|
73
73
|
type UseEditableReturn = ReturnType<typeof useEditable>;
|
74
74
|
declare const useEditableControl: () => {
|
75
75
|
isEditing: boolean;
|
76
|
-
getEditProps: PropGetter<"button", undefined>;
|
77
76
|
getCancelProps: PropGetter<"button", undefined>;
|
77
|
+
getEditProps: PropGetter<"button", undefined>;
|
78
78
|
getSubmitProps: PropGetter<"button", undefined>;
|
79
79
|
};
|
80
|
-
interface EditableElementProps extends Pick<UseEditableReturn, "isEditing" | "
|
80
|
+
interface EditableElementProps extends Pick<UseEditableReturn, "isEditing" | "onCancel" | "onEdit" | "onSubmit"> {
|
81
81
|
}
|
82
82
|
type EditableElement = (props: EditableElementProps) => ReactNode;
|
83
83
|
interface EditableOptions {
|
84
|
-
|
85
|
-
* The border color when the input is focused.
|
86
|
-
*/
|
87
|
-
focusBorderColor?: ColorModeToken<CSS.Property.BorderColor, "colors">;
|
84
|
+
children?: EditableElement | ReactNode;
|
88
85
|
/**
|
89
86
|
* The border color when the input is invalid.
|
90
87
|
*/
|
91
88
|
errorBorderColor?: ColorModeToken<CSS.Property.BorderColor, "colors">;
|
92
|
-
|
89
|
+
/**
|
90
|
+
* The border color when the input is focused.
|
91
|
+
*/
|
92
|
+
focusBorderColor?: ColorModeToken<CSS.Property.BorderColor, "colors">;
|
93
93
|
}
|
94
|
-
interface EditableProps extends Omit<HTMLUIProps, "
|
94
|
+
interface EditableProps extends Omit<HTMLUIProps, "children" | "defaultValue" | "onChange" | "onSubmit" | "value">, ThemeProps<"Editable">, UseEditableProps, EditableOptions {
|
95
95
|
}
|
96
96
|
/**
|
97
97
|
* `Editable` is a component used to obtain inline editable text input.
|
package/dist/editable.d.ts
CHANGED
@@ -4,22 +4,10 @@ import { FormControlOptions } from '@yamada-ui/form-control';
|
|
4
4
|
import { ReactNode } from 'react';
|
5
5
|
|
6
6
|
interface UseEditableProps extends FormControlOptions {
|
7
|
-
/**
|
8
|
-
* The placeholder text when the value is empty.
|
9
|
-
*/
|
10
|
-
placeholder?: string;
|
11
|
-
/**
|
12
|
-
* The value of the Editable in both edit & preview mode.
|
13
|
-
*/
|
14
|
-
value?: string;
|
15
7
|
/**
|
16
8
|
* The initial value of the Editable in both edit & preview mode.
|
17
9
|
*/
|
18
10
|
defaultValue?: string;
|
19
|
-
/**
|
20
|
-
* If `true`, the Editable will start with edit mode by default.
|
21
|
-
*/
|
22
|
-
startWithEditView?: boolean;
|
23
11
|
/**
|
24
12
|
* If `true`, the read only view, has a `tabIndex` set to `0`
|
25
13
|
* so it can receive focus via the keyboard or click.
|
@@ -28,11 +16,9 @@ interface UseEditableProps extends FormControlOptions {
|
|
28
16
|
*/
|
29
17
|
isPreviewFocusable?: boolean;
|
30
18
|
/**
|
31
|
-
*
|
32
|
-
*
|
33
|
-
* @default true
|
19
|
+
* The placeholder text when the value is empty.
|
34
20
|
*/
|
35
|
-
|
21
|
+
placeholder?: string;
|
36
22
|
/**
|
37
23
|
* If `true`, the input's text will be highlighted on focus.
|
38
24
|
*
|
@@ -40,58 +26,72 @@ interface UseEditableProps extends FormControlOptions {
|
|
40
26
|
*/
|
41
27
|
selectAllOnFocus?: boolean;
|
42
28
|
/**
|
43
|
-
*
|
29
|
+
* If `true`, the Editable will start with edit mode by default.
|
44
30
|
*/
|
45
|
-
|
31
|
+
startWithEditView?: boolean;
|
32
|
+
/**
|
33
|
+
* If `true`, it'll update the value onBlur and turn off the edit mode.
|
34
|
+
*
|
35
|
+
* @default true
|
36
|
+
*/
|
37
|
+
submitOnBlur?: boolean;
|
38
|
+
/**
|
39
|
+
* The value of the Editable in both edit & preview mode.
|
40
|
+
*/
|
41
|
+
value?: string;
|
46
42
|
/**
|
47
43
|
* Callback invoked when user cancels input with the `Esc` key.
|
48
44
|
* It provides the last confirmed value as argument.
|
49
45
|
*/
|
50
46
|
onCancel?: (preValue: string) => void;
|
51
47
|
/**
|
52
|
-
* A callback invoked when user
|
48
|
+
* A callback invoked when user changes input.
|
53
49
|
*/
|
54
|
-
|
50
|
+
onChange?: (value: string) => void;
|
55
51
|
/**
|
56
52
|
* A callback invoked once the user enters edit mode.
|
57
53
|
*/
|
58
54
|
onEdit?: () => void;
|
55
|
+
/**
|
56
|
+
* A callback invoked when user confirms value with `enter` key or by blurring input.
|
57
|
+
*/
|
58
|
+
onSubmit?: (value: string) => void;
|
59
59
|
}
|
60
60
|
declare const useEditable: (props: UseEditableProps) => {
|
61
61
|
isEditing: boolean;
|
62
62
|
value: string;
|
63
|
-
|
64
|
-
onCancel: () => void;
|
65
|
-
onSubmit: () => void;
|
66
|
-
getPreviewProps: PropGetter<"span", undefined>;
|
67
|
-
getInputProps: PropGetter<"input", undefined>;
|
68
|
-
getTextareaProps: PropGetter<"textarea", undefined>;
|
63
|
+
getCancelProps: PropGetter<"button", undefined>;
|
69
64
|
getEditProps: PropGetter<"button", undefined>;
|
65
|
+
getInputProps: PropGetter<"input", undefined>;
|
66
|
+
getPreviewProps: PropGetter<"span", undefined>;
|
70
67
|
getSubmitProps: PropGetter<"button", undefined>;
|
71
|
-
|
68
|
+
getTextareaProps: PropGetter<"textarea", undefined>;
|
69
|
+
onCancel: () => void;
|
70
|
+
onEdit: () => void;
|
71
|
+
onSubmit: () => void;
|
72
72
|
};
|
73
73
|
type UseEditableReturn = ReturnType<typeof useEditable>;
|
74
74
|
declare const useEditableControl: () => {
|
75
75
|
isEditing: boolean;
|
76
|
-
getEditProps: PropGetter<"button", undefined>;
|
77
76
|
getCancelProps: PropGetter<"button", undefined>;
|
77
|
+
getEditProps: PropGetter<"button", undefined>;
|
78
78
|
getSubmitProps: PropGetter<"button", undefined>;
|
79
79
|
};
|
80
|
-
interface EditableElementProps extends Pick<UseEditableReturn, "isEditing" | "
|
80
|
+
interface EditableElementProps extends Pick<UseEditableReturn, "isEditing" | "onCancel" | "onEdit" | "onSubmit"> {
|
81
81
|
}
|
82
82
|
type EditableElement = (props: EditableElementProps) => ReactNode;
|
83
83
|
interface EditableOptions {
|
84
|
-
|
85
|
-
* The border color when the input is focused.
|
86
|
-
*/
|
87
|
-
focusBorderColor?: ColorModeToken<CSS.Property.BorderColor, "colors">;
|
84
|
+
children?: EditableElement | ReactNode;
|
88
85
|
/**
|
89
86
|
* The border color when the input is invalid.
|
90
87
|
*/
|
91
88
|
errorBorderColor?: ColorModeToken<CSS.Property.BorderColor, "colors">;
|
92
|
-
|
89
|
+
/**
|
90
|
+
* The border color when the input is focused.
|
91
|
+
*/
|
92
|
+
focusBorderColor?: ColorModeToken<CSS.Property.BorderColor, "colors">;
|
93
93
|
}
|
94
|
-
interface EditableProps extends Omit<HTMLUIProps, "
|
94
|
+
interface EditableProps extends Omit<HTMLUIProps, "children" | "defaultValue" | "onChange" | "onSubmit" | "value">, ThemeProps<"Editable">, UseEditableProps, EditableOptions {
|
95
95
|
}
|
96
96
|
/**
|
97
97
|
* `Editable` is a component used to obtain inline editable text input.
|