@destyler/edit 0.0.7-beta.5 → 0.0.7-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts DELETED
@@ -1,231 +0,0 @@
1
- import * as _zag_js_anatomy from '@zag-js/anatomy';
2
- import { DirectionProperty, CommonProperties, PropTypes, RequiredBy, NormalizeProps } from '@zag-js/types';
3
- import * as _zag_js_core from '@zag-js/core';
4
- import { StateMachine, Machine } from '@zag-js/core';
5
- import { InteractOutsideHandlers } from '@zag-js/interact-outside';
6
- export { FocusOutsideEvent, InteractOutsideEvent, PointerDownOutsideEvent } from '@zag-js/interact-outside';
7
-
8
- declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "area" | "label" | "preview" | "input" | "editTrigger" | "submitTrigger" | "cancelTrigger" | "control">;
9
-
10
- interface ValueChangeDetails {
11
- value: string;
12
- }
13
- interface EditChangeDetails {
14
- edit: boolean;
15
- }
16
- type ActivationMode = 'focus' | 'dblclick' | 'click';
17
- type SubmitMode = 'enter' | 'blur' | 'both' | 'none';
18
- interface IntlTranslations {
19
- edit: string;
20
- submit: string;
21
- cancel: string;
22
- input: string;
23
- }
24
- type ElementIds = Partial<{
25
- root: string;
26
- area: string;
27
- label: string;
28
- preview: string;
29
- input: string;
30
- control: string;
31
- submitTrigger: string;
32
- cancelTrigger: string;
33
- editTrigger: string;
34
- }>;
35
- interface PublicContext extends DirectionProperty, CommonProperties, InteractOutsideHandlers {
36
- /**
37
- * The ids of the elements in the editable. Useful for composition.
38
- */
39
- 'ids'?: ElementIds | undefined;
40
- /**
41
- * Whether the input's value is invalid.
42
- */
43
- 'invalid'?: boolean | undefined;
44
- /**
45
- * The name attribute of the editable component. Used for form submission.
46
- */
47
- 'name'?: string | undefined;
48
- /**
49
- * The associate form of the underlying input.
50
- */
51
- 'form'?: string | undefined;
52
- /**
53
- * Whether the editable should auto-resize to fit the content.
54
- */
55
- 'autoResize'?: boolean | undefined;
56
- /**
57
- * The activation mode for the preview element.
58
- *
59
- * - "focus" - Enter edit mode when the preview is focused
60
- * - "dblclick" - Enter edit mode when the preview is double-clicked
61
- * - "click" - Enter edit mode when the preview is clicked
62
- *
63
- * @default "focus"
64
- */
65
- 'activationMode': ActivationMode;
66
- /**
67
- * The action that triggers submit in the edit mode:
68
- *
69
- * - "enter" - Trigger submit when the enter key is pressed
70
- * - "blur" - Trigger submit when the editable is blurred
71
- * - "none" - No action will trigger submit. You need to use the submit button
72
- * - "both" - Pressing `Enter` and blurring the input will trigger submit
73
- *
74
- * @default "both"
75
- */
76
- 'submitMode': SubmitMode;
77
- /**
78
- * Whether the editable is in edit mode.
79
- */
80
- 'edit'?: boolean | undefined;
81
- /**
82
- * Whether the editable is controlled
83
- */
84
- 'edit.controlled'?: boolean | undefined;
85
- /**
86
- * Whether to select the text in the input when it is focused.
87
- * @default true
88
- */
89
- 'selectOnFocus'?: boolean | undefined;
90
- /**
91
- * The value of the editable in both edit and preview mode
92
- */
93
- 'value': string;
94
- /**
95
- * The maximum number of characters allowed in the editable
96
- */
97
- 'maxLength'?: number | undefined;
98
- /**
99
- * Whether the editable is disabled
100
- */
101
- 'disabled'?: boolean | undefined;
102
- /**
103
- * Whether the editable is readonly
104
- */
105
- 'readOnly'?: boolean | undefined;
106
- /**
107
- * Whether the editable is required
108
- */
109
- 'required'?: boolean | undefined;
110
- /**
111
- * The callback that is called when the editable's value is changed
112
- */
113
- 'onValueChange'?: ((details: ValueChangeDetails) => void) | undefined;
114
- /**
115
- * The callback that is called when the esc key is pressed or the cancel button is clicked
116
- */
117
- 'onValueRevert'?: ((details: ValueChangeDetails) => void) | undefined;
118
- /**
119
- * The callback that is called when the editable's value is submitted.
120
- */
121
- 'onValueCommit'?: ((details: ValueChangeDetails) => void) | undefined;
122
- /**
123
- * The callback that is called when the edit mode is changed
124
- */
125
- 'onEditChange'?: ((details: EditChangeDetails) => void) | undefined;
126
- /**
127
- * The placeholder value to show when the `value` is empty
128
- */
129
- 'placeholder'?: string | {
130
- edit: string;
131
- preview: string;
132
- } | undefined;
133
- /**
134
- * Specifies the localized strings that identifies the accessibility elements and their states
135
- */
136
- 'translations': IntlTranslations;
137
- /**
138
- * The element that should receive focus when the editable is closed.
139
- * By default, it will focus on the trigger element.
140
- */
141
- 'finalFocusEl'?: (() => HTMLElement | null) | undefined;
142
- }
143
- type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
144
- type ComputedContext = Readonly<{
145
- /**
146
- * @computed
147
- * Whether the editable can be interacted with
148
- */
149
- isInteractive: boolean;
150
- /**
151
- * @computed
152
- * Whether to submit on enter press
153
- */
154
- submitOnEnter: boolean;
155
- /**
156
- * @computed
157
- * Whether to submit on blur
158
- */
159
- submitOnBlur: boolean;
160
- }>;
161
- interface PrivateContext {
162
- /**
163
- * @internal
164
- * The previous value of the editable. Used to revert in case of cancel/escape
165
- */
166
- previousValue: string;
167
- }
168
- interface MachineContext extends PublicContext, PrivateContext, ComputedContext {
169
- }
170
- interface MachineState {
171
- value: 'preview' | 'edit';
172
- }
173
- type State = StateMachine.State<MachineContext, MachineState>;
174
- type Send = StateMachine.Send<StateMachine.AnyEventObject>;
175
- type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
176
- interface MachineApi<T extends PropTypes = PropTypes> {
177
- /**
178
- * Whether the editable is in edit mode
179
- */
180
- editing: boolean;
181
- /**
182
- * Whether the editable value is empty
183
- */
184
- empty: boolean;
185
- /**
186
- * The current value of the editable
187
- */
188
- value: string;
189
- /**
190
- * The current value of the editable, or the placeholder if the value is empty
191
- */
192
- valueText: string;
193
- /**
194
- * Function to set the value of the editable
195
- */
196
- setValue: (value: string) => void;
197
- /**
198
- * Function to clear the value of the editable
199
- */
200
- clearValue: () => void;
201
- /**
202
- * Function to enter edit mode
203
- */
204
- edit: () => void;
205
- /**
206
- * Function to exit edit mode, and discard any changes
207
- */
208
- cancel: () => void;
209
- /**
210
- * Function to exit edit mode, and submit any changes
211
- */
212
- submit: () => void;
213
- getRootProps: () => T['element'];
214
- getAreaProps: () => T['element'];
215
- getLabelProps: () => T['label'];
216
- getInputProps: () => T['input'];
217
- getPreviewProps: () => T['element'];
218
- getEditTriggerProps: () => T['button'];
219
- getControlProps: () => T['element'];
220
- getSubmitTriggerProps: () => T['button'];
221
- getCancelTriggerProps: () => T['button'];
222
- }
223
-
224
- declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
225
-
226
- declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
227
-
228
- declare const props: ("edit" | "ids" | "invalid" | "name" | "form" | "autoResize" | "activationMode" | "submitMode" | "edit.controlled" | "selectOnFocus" | "value" | "maxLength" | "disabled" | "readOnly" | "required" | "onValueChange" | "onValueRevert" | "onValueCommit" | "onEditChange" | "placeholder" | "translations" | "finalFocusEl" | "dir" | "id" | "getRootNode" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside")[];
229
- declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "edit" | "ids" | "invalid" | "name" | "form" | "autoResize" | "activationMode" | "submitMode" | "edit.controlled" | "selectOnFocus" | "value" | "maxLength" | "disabled" | "readOnly" | "required" | "onValueChange" | "onValueRevert" | "onValueCommit" | "onEditChange" | "placeholder" | "translations" | "finalFocusEl" | "dir" | "id" | "getRootNode" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside">];
230
-
231
- export { type ActivationMode, type MachineApi as Api, type UserDefinedContext as Context, type EditChangeDetails, type ElementIds, type IntlTranslations, type Service, type SubmitMode, type ValueChangeDetails, anatomy, connect, machine, props, splitProps };
package/dist/index.d.mts DELETED
@@ -1,231 +0,0 @@
1
- import * as _zag_js_anatomy from '@zag-js/anatomy';
2
- import { DirectionProperty, CommonProperties, PropTypes, RequiredBy, NormalizeProps } from '@zag-js/types';
3
- import * as _zag_js_core from '@zag-js/core';
4
- import { StateMachine, Machine } from '@zag-js/core';
5
- import { InteractOutsideHandlers } from '@zag-js/interact-outside';
6
- export { FocusOutsideEvent, InteractOutsideEvent, PointerDownOutsideEvent } from '@zag-js/interact-outside';
7
-
8
- declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "area" | "label" | "preview" | "input" | "editTrigger" | "submitTrigger" | "cancelTrigger" | "control">;
9
-
10
- interface ValueChangeDetails {
11
- value: string;
12
- }
13
- interface EditChangeDetails {
14
- edit: boolean;
15
- }
16
- type ActivationMode = 'focus' | 'dblclick' | 'click';
17
- type SubmitMode = 'enter' | 'blur' | 'both' | 'none';
18
- interface IntlTranslations {
19
- edit: string;
20
- submit: string;
21
- cancel: string;
22
- input: string;
23
- }
24
- type ElementIds = Partial<{
25
- root: string;
26
- area: string;
27
- label: string;
28
- preview: string;
29
- input: string;
30
- control: string;
31
- submitTrigger: string;
32
- cancelTrigger: string;
33
- editTrigger: string;
34
- }>;
35
- interface PublicContext extends DirectionProperty, CommonProperties, InteractOutsideHandlers {
36
- /**
37
- * The ids of the elements in the editable. Useful for composition.
38
- */
39
- 'ids'?: ElementIds | undefined;
40
- /**
41
- * Whether the input's value is invalid.
42
- */
43
- 'invalid'?: boolean | undefined;
44
- /**
45
- * The name attribute of the editable component. Used for form submission.
46
- */
47
- 'name'?: string | undefined;
48
- /**
49
- * The associate form of the underlying input.
50
- */
51
- 'form'?: string | undefined;
52
- /**
53
- * Whether the editable should auto-resize to fit the content.
54
- */
55
- 'autoResize'?: boolean | undefined;
56
- /**
57
- * The activation mode for the preview element.
58
- *
59
- * - "focus" - Enter edit mode when the preview is focused
60
- * - "dblclick" - Enter edit mode when the preview is double-clicked
61
- * - "click" - Enter edit mode when the preview is clicked
62
- *
63
- * @default "focus"
64
- */
65
- 'activationMode': ActivationMode;
66
- /**
67
- * The action that triggers submit in the edit mode:
68
- *
69
- * - "enter" - Trigger submit when the enter key is pressed
70
- * - "blur" - Trigger submit when the editable is blurred
71
- * - "none" - No action will trigger submit. You need to use the submit button
72
- * - "both" - Pressing `Enter` and blurring the input will trigger submit
73
- *
74
- * @default "both"
75
- */
76
- 'submitMode': SubmitMode;
77
- /**
78
- * Whether the editable is in edit mode.
79
- */
80
- 'edit'?: boolean | undefined;
81
- /**
82
- * Whether the editable is controlled
83
- */
84
- 'edit.controlled'?: boolean | undefined;
85
- /**
86
- * Whether to select the text in the input when it is focused.
87
- * @default true
88
- */
89
- 'selectOnFocus'?: boolean | undefined;
90
- /**
91
- * The value of the editable in both edit and preview mode
92
- */
93
- 'value': string;
94
- /**
95
- * The maximum number of characters allowed in the editable
96
- */
97
- 'maxLength'?: number | undefined;
98
- /**
99
- * Whether the editable is disabled
100
- */
101
- 'disabled'?: boolean | undefined;
102
- /**
103
- * Whether the editable is readonly
104
- */
105
- 'readOnly'?: boolean | undefined;
106
- /**
107
- * Whether the editable is required
108
- */
109
- 'required'?: boolean | undefined;
110
- /**
111
- * The callback that is called when the editable's value is changed
112
- */
113
- 'onValueChange'?: ((details: ValueChangeDetails) => void) | undefined;
114
- /**
115
- * The callback that is called when the esc key is pressed or the cancel button is clicked
116
- */
117
- 'onValueRevert'?: ((details: ValueChangeDetails) => void) | undefined;
118
- /**
119
- * The callback that is called when the editable's value is submitted.
120
- */
121
- 'onValueCommit'?: ((details: ValueChangeDetails) => void) | undefined;
122
- /**
123
- * The callback that is called when the edit mode is changed
124
- */
125
- 'onEditChange'?: ((details: EditChangeDetails) => void) | undefined;
126
- /**
127
- * The placeholder value to show when the `value` is empty
128
- */
129
- 'placeholder'?: string | {
130
- edit: string;
131
- preview: string;
132
- } | undefined;
133
- /**
134
- * Specifies the localized strings that identifies the accessibility elements and their states
135
- */
136
- 'translations': IntlTranslations;
137
- /**
138
- * The element that should receive focus when the editable is closed.
139
- * By default, it will focus on the trigger element.
140
- */
141
- 'finalFocusEl'?: (() => HTMLElement | null) | undefined;
142
- }
143
- type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
144
- type ComputedContext = Readonly<{
145
- /**
146
- * @computed
147
- * Whether the editable can be interacted with
148
- */
149
- isInteractive: boolean;
150
- /**
151
- * @computed
152
- * Whether to submit on enter press
153
- */
154
- submitOnEnter: boolean;
155
- /**
156
- * @computed
157
- * Whether to submit on blur
158
- */
159
- submitOnBlur: boolean;
160
- }>;
161
- interface PrivateContext {
162
- /**
163
- * @internal
164
- * The previous value of the editable. Used to revert in case of cancel/escape
165
- */
166
- previousValue: string;
167
- }
168
- interface MachineContext extends PublicContext, PrivateContext, ComputedContext {
169
- }
170
- interface MachineState {
171
- value: 'preview' | 'edit';
172
- }
173
- type State = StateMachine.State<MachineContext, MachineState>;
174
- type Send = StateMachine.Send<StateMachine.AnyEventObject>;
175
- type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
176
- interface MachineApi<T extends PropTypes = PropTypes> {
177
- /**
178
- * Whether the editable is in edit mode
179
- */
180
- editing: boolean;
181
- /**
182
- * Whether the editable value is empty
183
- */
184
- empty: boolean;
185
- /**
186
- * The current value of the editable
187
- */
188
- value: string;
189
- /**
190
- * The current value of the editable, or the placeholder if the value is empty
191
- */
192
- valueText: string;
193
- /**
194
- * Function to set the value of the editable
195
- */
196
- setValue: (value: string) => void;
197
- /**
198
- * Function to clear the value of the editable
199
- */
200
- clearValue: () => void;
201
- /**
202
- * Function to enter edit mode
203
- */
204
- edit: () => void;
205
- /**
206
- * Function to exit edit mode, and discard any changes
207
- */
208
- cancel: () => void;
209
- /**
210
- * Function to exit edit mode, and submit any changes
211
- */
212
- submit: () => void;
213
- getRootProps: () => T['element'];
214
- getAreaProps: () => T['element'];
215
- getLabelProps: () => T['label'];
216
- getInputProps: () => T['input'];
217
- getPreviewProps: () => T['element'];
218
- getEditTriggerProps: () => T['button'];
219
- getControlProps: () => T['element'];
220
- getSubmitTriggerProps: () => T['button'];
221
- getCancelTriggerProps: () => T['button'];
222
- }
223
-
224
- declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
225
-
226
- declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
227
-
228
- declare const props: ("edit" | "ids" | "invalid" | "name" | "form" | "autoResize" | "activationMode" | "submitMode" | "edit.controlled" | "selectOnFocus" | "value" | "maxLength" | "disabled" | "readOnly" | "required" | "onValueChange" | "onValueRevert" | "onValueCommit" | "onEditChange" | "placeholder" | "translations" | "finalFocusEl" | "dir" | "id" | "getRootNode" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside")[];
229
- declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "edit" | "ids" | "invalid" | "name" | "form" | "autoResize" | "activationMode" | "submitMode" | "edit.controlled" | "selectOnFocus" | "value" | "maxLength" | "disabled" | "readOnly" | "required" | "onValueChange" | "onValueRevert" | "onValueCommit" | "onEditChange" | "placeholder" | "translations" | "finalFocusEl" | "dir" | "id" | "getRootNode" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside">];
230
-
231
- export { type ActivationMode, type MachineApi as Api, type UserDefinedContext as Context, type EditChangeDetails, type ElementIds, type IntlTranslations, type Service, type SubmitMode, type ValueChangeDetails, anatomy, connect, machine, props, splitProps };