@yamada-ui/editable 0.2.4 → 0.2.6

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.
@@ -0,0 +1,101 @@
1
+ import * as _yamada_ui_core from '@yamada-ui/core';
2
+ import { HTMLUIProps, ThemeProps, CSSUIProps } from '@yamada-ui/core';
3
+ import { FormControlOptions } from '@yamada-ui/form-control';
4
+ import { PropGetter } from '@yamada-ui/utils';
5
+ import { ReactNode } from 'react';
6
+
7
+ type UseEditableProps = FormControlOptions & {
8
+ /**
9
+ * The placeholder text when the value is empty.
10
+ */
11
+ placeholder?: string;
12
+ /**
13
+ * The value of the Editable in both edit & preview mode.
14
+ */
15
+ value?: string;
16
+ /**
17
+ * The initial value of the Editable in both edit & preview mode.
18
+ */
19
+ defaultValue?: string;
20
+ /**
21
+ * If `true`, the Editable will start with edit mode by default.
22
+ */
23
+ startWithEditView?: boolean;
24
+ /**
25
+ * If `true`, the read only view, has a `tabIndex` set to `0`
26
+ * so it can receive focus via the keyboard or click.
27
+ *
28
+ * @default true
29
+ */
30
+ isPreviewFocusable?: boolean;
31
+ /**
32
+ * If `true`, it'll update the value onBlur and turn off the edit mode.
33
+ *
34
+ * @default true
35
+ */
36
+ submitOnBlur?: boolean;
37
+ /**
38
+ * If `true`, the input's text will be highlighted on focus.
39
+ *
40
+ * @default true
41
+ */
42
+ selectAllOnFocus?: boolean;
43
+ /**
44
+ * A callback invoked when user changes input.
45
+ */
46
+ onChange?: (value: string) => void;
47
+ /**
48
+ * Callback invoked when user cancels input with the `Esc` key.
49
+ * It provides the last confirmed value as argument.
50
+ */
51
+ onCancel?: (preValue: string) => void;
52
+ /**
53
+ * A callback invoked when user confirms value with `enter` key or by blurring input.
54
+ */
55
+ onSubmit?: (value: string) => void;
56
+ /**
57
+ * A callback invoked once the user enters edit mode.
58
+ */
59
+ onEdit?: () => void;
60
+ };
61
+ declare const useEditable: (props: UseEditableProps) => {
62
+ isEditing: boolean;
63
+ value: string;
64
+ onEdit: () => void;
65
+ onCancel: () => void;
66
+ onSubmit: () => void;
67
+ getPreviewProps: PropGetter;
68
+ getInputProps: PropGetter;
69
+ getTextareaProps: PropGetter;
70
+ getEditProps: PropGetter;
71
+ getSubmitProps: PropGetter;
72
+ getCancelProps: PropGetter;
73
+ };
74
+ type UseEditableReturn = ReturnType<typeof useEditable>;
75
+ declare const useEditableControl: () => {
76
+ isEditing: boolean;
77
+ getEditProps: PropGetter;
78
+ getCancelProps: PropGetter;
79
+ getSubmitProps: PropGetter;
80
+ };
81
+ type EditableOptions = {
82
+ /**
83
+ * The border color when the input is focused.
84
+ */
85
+ focusBorderColor?: CSSUIProps<'unresponsive'>['borderColor'];
86
+ /**
87
+ * The border color when the input is invalid.
88
+ */
89
+ errorBorderColor?: CSSUIProps<'unresponsive'>['borderColor'];
90
+ children?: ReactNode | ((props: Pick<UseEditableReturn, 'isEditing' | 'onSubmit' | 'onCancel' | 'onEdit'>) => ReactNode);
91
+ };
92
+ type EditableProps = Omit<HTMLUIProps<'div'>, 'onChange' | 'value' | 'defaultValue' | 'onSubmit' | 'children'> & ThemeProps<'Editable'> & UseEditableProps & EditableOptions;
93
+ declare const Editable: _yamada_ui_core.Component<"div", EditableProps>;
94
+ type EditablePreviewProps = HTMLUIProps<'span'>;
95
+ declare const EditablePreview: _yamada_ui_core.Component<"span", EditablePreviewProps>;
96
+ type EditableInputProps = HTMLUIProps<'input'>;
97
+ declare const EditableInput: _yamada_ui_core.Component<"input", EditableInputProps>;
98
+ type EditableTextareaProps = HTMLUIProps<'textarea'>;
99
+ declare const EditableTextarea: _yamada_ui_core.Component<"textarea", EditableTextareaProps>;
100
+
101
+ export { Editable, EditableInput, EditableInputProps, EditablePreview, EditablePreviewProps, EditableProps, EditableTextarea, EditableTextareaProps, UseEditableProps, UseEditableReturn, useEditable, useEditableControl };
@@ -0,0 +1,5 @@
1
+ export { Editable, EditableInput, EditableInputProps, EditablePreview, EditablePreviewProps, EditableProps, EditableTextarea, EditableTextareaProps, UseEditableProps, UseEditableReturn, useEditable, useEditableControl } from './editable.mjs';
2
+ import '@yamada-ui/core';
3
+ import '@yamada-ui/form-control';
4
+ import '@yamada-ui/utils';
5
+ import 'react';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yamada-ui/editable",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "Yamada UI editable component",
5
5
  "keywords": [
6
6
  "yamada",
@@ -35,11 +35,11 @@
35
35
  "url": "https://github.com/hirotomoyamada/yamada-ui/issues"
36
36
  },
37
37
  "dependencies": {
38
- "@yamada-ui/utils": "0.1.2",
39
- "@yamada-ui/core": "0.4.3",
40
- "@yamada-ui/form-control": "0.2.4",
41
- "@yamada-ui/use-controllable-state": "0.1.3",
42
- "@yamada-ui/use-focus": "0.1.2"
38
+ "@yamada-ui/core": "0.5.1",
39
+ "@yamada-ui/utils": "0.1.3",
40
+ "@yamada-ui/form-control": "0.2.6",
41
+ "@yamada-ui/use-controllable-state": "0.1.4",
42
+ "@yamada-ui/use-focus": "0.1.3"
43
43
  },
44
44
  "devDependencies": {
45
45
  "react": "^18.0.0",