@destyler/dynamic 0.0.5 → 0.0.7-beta.1
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.cjs +1027 -22
- package/dist/index.d.cts +356 -4
- package/dist/index.d.mts +356 -4
- package/dist/index.d.ts +356 -4
- package/dist/index.mjs +1024 -10
- package/package.json +12 -19
- package/README.md +0 -7
- package/dist/component.cjs +0 -622
- package/dist/component.d.cts +0 -854
- package/dist/component.d.mts +0 -854
- package/dist/component.d.ts +0 -854
- package/dist/component.mjs +0 -608
- package/dist/resolver.cjs +0 -25
- package/dist/resolver.d.cts +0 -6
- package/dist/resolver.d.mts +0 -6
- package/dist/resolver.d.ts +0 -6
- package/dist/resolver.mjs +0 -22
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,356 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
3
|
-
import '@
|
|
4
|
-
import '@
|
|
1
|
+
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
+
import { RequiredBy, PropTypes, DirectionProperty, CommonProperties, NormalizeProps } from '@zag-js/types';
|
|
3
|
+
import * as _zag_js_core from '@zag-js/core';
|
|
4
|
+
import { StateMachine } from '@zag-js/core';
|
|
5
|
+
import { InteractOutsideHandlers } from '@zag-js/interact-outside';
|
|
6
|
+
export { FocusOutsideEvent, InteractOutsideEvent, PointerDownOutsideEvent } from '@zag-js/interact-outside';
|
|
7
|
+
import { LiveRegion } from '@zag-js/live-region';
|
|
8
|
+
|
|
9
|
+
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "label" | "control" | "input" | "clearTrigger" | "item" | "itemPreview" | "itemInput" | "itemText" | "itemDeleteTrigger">;
|
|
10
|
+
|
|
11
|
+
interface ValueChangeDetails {
|
|
12
|
+
value: string[];
|
|
13
|
+
}
|
|
14
|
+
interface InputValueChangeDetails {
|
|
15
|
+
inputValue: string;
|
|
16
|
+
}
|
|
17
|
+
interface HighlightChangeDetails {
|
|
18
|
+
highlightedValue: string | null;
|
|
19
|
+
}
|
|
20
|
+
type ValidityState = 'rangeOverflow' | 'invalidTag';
|
|
21
|
+
interface ValidityChangeDetails {
|
|
22
|
+
reason: ValidityState;
|
|
23
|
+
}
|
|
24
|
+
interface ValidateArgs {
|
|
25
|
+
inputValue: string;
|
|
26
|
+
value: string[];
|
|
27
|
+
}
|
|
28
|
+
interface IntlTranslations {
|
|
29
|
+
clearTriggerLabel: string;
|
|
30
|
+
deleteTagTriggerLabel: (value: string) => string;
|
|
31
|
+
tagSelected: (value: string) => string;
|
|
32
|
+
tagAdded: (value: string) => string;
|
|
33
|
+
tagsPasted: (value: string[]) => string;
|
|
34
|
+
tagEdited: (value: string) => string;
|
|
35
|
+
tagUpdated: (value: string) => string;
|
|
36
|
+
tagDeleted: (value: string) => string;
|
|
37
|
+
noTagsSelected?: string | undefined;
|
|
38
|
+
inputLabel?: (count: number) => string;
|
|
39
|
+
}
|
|
40
|
+
type Log = {
|
|
41
|
+
type: 'add' | 'update' | 'delete' | 'select';
|
|
42
|
+
value: string;
|
|
43
|
+
} | {
|
|
44
|
+
type: 'clear';
|
|
45
|
+
} | {
|
|
46
|
+
type: 'paste';
|
|
47
|
+
values: string[];
|
|
48
|
+
} | {
|
|
49
|
+
type: 'set';
|
|
50
|
+
values: string[];
|
|
51
|
+
};
|
|
52
|
+
type ElementIds = Partial<{
|
|
53
|
+
root: string;
|
|
54
|
+
input: string;
|
|
55
|
+
hiddenInput: string;
|
|
56
|
+
clearBtn: string;
|
|
57
|
+
label: string;
|
|
58
|
+
control: string;
|
|
59
|
+
item: (opts: ItemProps) => string;
|
|
60
|
+
itemDeleteTrigger: (opts: ItemProps) => string;
|
|
61
|
+
itemInput: (opts: ItemProps) => string;
|
|
62
|
+
}>;
|
|
63
|
+
interface PublicContext extends DirectionProperty, CommonProperties, InteractOutsideHandlers {
|
|
64
|
+
/**
|
|
65
|
+
* The ids of the elements in the tags input. Useful for composition.
|
|
66
|
+
*/
|
|
67
|
+
ids?: ElementIds | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Specifies the localized strings that identifies the accessibility elements and their states
|
|
70
|
+
*/
|
|
71
|
+
translations: IntlTranslations;
|
|
72
|
+
/**
|
|
73
|
+
* The max length of the input.
|
|
74
|
+
*/
|
|
75
|
+
maxLength?: number | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* The character that serves has:
|
|
78
|
+
* - event key to trigger the addition of a new tag
|
|
79
|
+
* - character used to split tags when pasting into the input
|
|
80
|
+
*
|
|
81
|
+
* @default ","
|
|
82
|
+
*/
|
|
83
|
+
delimiter?: string | RegExp | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Whether the input should be auto-focused
|
|
86
|
+
*/
|
|
87
|
+
autoFocus?: boolean | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Whether the tags input should be disabled
|
|
90
|
+
*/
|
|
91
|
+
disabled?: boolean | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Whether the tags input should be read-only
|
|
94
|
+
*/
|
|
95
|
+
readOnly?: boolean | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Whether the tags input is invalid
|
|
98
|
+
*/
|
|
99
|
+
invalid?: boolean | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Whether the tags input is required
|
|
102
|
+
*/
|
|
103
|
+
required?: boolean | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Whether a tag can be edited after creation, by pressing `Enter` or double clicking.
|
|
106
|
+
* @default true
|
|
107
|
+
*/
|
|
108
|
+
editable?: boolean | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* The tag input's value
|
|
111
|
+
*/
|
|
112
|
+
inputValue: string;
|
|
113
|
+
/**
|
|
114
|
+
* The tag values
|
|
115
|
+
*/
|
|
116
|
+
value: string[];
|
|
117
|
+
/**
|
|
118
|
+
* Callback fired when the tag values is updated
|
|
119
|
+
*/
|
|
120
|
+
onValueChange?: (details: ValueChangeDetails) => void;
|
|
121
|
+
/**
|
|
122
|
+
* Callback fired when the input value is updated
|
|
123
|
+
*/
|
|
124
|
+
onInputValueChange?: (details: InputValueChangeDetails) => void;
|
|
125
|
+
/**
|
|
126
|
+
* Callback fired when a tag is highlighted by pointer or keyboard navigation
|
|
127
|
+
*/
|
|
128
|
+
onHighlightChange?: (details: HighlightChangeDetails) => void;
|
|
129
|
+
/**
|
|
130
|
+
* Callback fired when the max tag count is reached or the `validateTag` function returns `false`
|
|
131
|
+
*/
|
|
132
|
+
onValueInvalid?: (details: ValidityChangeDetails) => void;
|
|
133
|
+
/**
|
|
134
|
+
* Returns a boolean that determines whether a tag can be added.
|
|
135
|
+
* Useful for preventing duplicates or invalid tag values.
|
|
136
|
+
*/
|
|
137
|
+
validate?: (details: ValidateArgs) => boolean;
|
|
138
|
+
/**
|
|
139
|
+
* The behavior of the tags input when the input is blurred
|
|
140
|
+
* - `"add"`: add the input value as a new tag
|
|
141
|
+
* - `"clear"`: clear the input value
|
|
142
|
+
*/
|
|
143
|
+
blurBehavior?: 'clear' | 'add' | undefined;
|
|
144
|
+
/**
|
|
145
|
+
* Whether to add a tag when you paste values into the tag input
|
|
146
|
+
* @default false
|
|
147
|
+
*/
|
|
148
|
+
addOnPaste?: boolean | undefined;
|
|
149
|
+
/**
|
|
150
|
+
* The max number of tags
|
|
151
|
+
* @default Infinity
|
|
152
|
+
*/
|
|
153
|
+
max: number;
|
|
154
|
+
/**
|
|
155
|
+
* Whether to allow tags to exceed max. In this case,
|
|
156
|
+
* we'll attach `data-invalid` to the root
|
|
157
|
+
*/
|
|
158
|
+
allowOverflow?: boolean | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* The name attribute for the input. Useful for form submissions
|
|
161
|
+
*/
|
|
162
|
+
name?: string | undefined;
|
|
163
|
+
/**
|
|
164
|
+
* The associate form of the underlying input element.
|
|
165
|
+
*/
|
|
166
|
+
form?: string | undefined;
|
|
167
|
+
}
|
|
168
|
+
type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
|
|
169
|
+
type ComputedContext = Readonly<{
|
|
170
|
+
/**
|
|
171
|
+
* @computed
|
|
172
|
+
* The string value of the tags input
|
|
173
|
+
*/
|
|
174
|
+
valueAsString: string;
|
|
175
|
+
/**
|
|
176
|
+
* @computed
|
|
177
|
+
* The trimmed value of the input
|
|
178
|
+
*/
|
|
179
|
+
trimmedInputValue: string;
|
|
180
|
+
/**
|
|
181
|
+
* @computed
|
|
182
|
+
* Whether the tags input is interactive
|
|
183
|
+
*/
|
|
184
|
+
isInteractive: boolean;
|
|
185
|
+
/**
|
|
186
|
+
* @computed
|
|
187
|
+
* Whether the tags input is at the maximum allowed number of tags
|
|
188
|
+
*/
|
|
189
|
+
isAtMax: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* @computed
|
|
192
|
+
* The total number of tags
|
|
193
|
+
*/
|
|
194
|
+
count: number;
|
|
195
|
+
/**
|
|
196
|
+
* @computed
|
|
197
|
+
* Whether the tags input is exceeding the max number of tags
|
|
198
|
+
*/
|
|
199
|
+
isOverflowing: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* @computed
|
|
202
|
+
* Whether the tags input is disabled
|
|
203
|
+
*/
|
|
204
|
+
isDisabled: boolean;
|
|
205
|
+
}>;
|
|
206
|
+
interface PrivateContext {
|
|
207
|
+
/**
|
|
208
|
+
* @internal
|
|
209
|
+
* The output log for the screen reader to speak
|
|
210
|
+
*/
|
|
211
|
+
log: {
|
|
212
|
+
current: Log | null;
|
|
213
|
+
prev: Log | null;
|
|
214
|
+
};
|
|
215
|
+
/**
|
|
216
|
+
* @internal
|
|
217
|
+
* The live region to announce changes to the user
|
|
218
|
+
*/
|
|
219
|
+
liveRegion: LiveRegion | null;
|
|
220
|
+
/**
|
|
221
|
+
* @internal
|
|
222
|
+
* The `id` of the currently highlighted tag
|
|
223
|
+
*/
|
|
224
|
+
highlightedTagId: string | null;
|
|
225
|
+
/**
|
|
226
|
+
* @internal
|
|
227
|
+
* The index of the deleted tag. Used to determine the next tag to focus.
|
|
228
|
+
*/
|
|
229
|
+
idx?: number | undefined;
|
|
230
|
+
/**
|
|
231
|
+
* @internal
|
|
232
|
+
* The `id` of the currently edited tag
|
|
233
|
+
*/
|
|
234
|
+
editedTagId: string | null;
|
|
235
|
+
/**
|
|
236
|
+
* @internal
|
|
237
|
+
* The value of the currently edited tag
|
|
238
|
+
*/
|
|
239
|
+
editedTagValue: string;
|
|
240
|
+
/**
|
|
241
|
+
* @internal
|
|
242
|
+
* Whether the fieldset is disabled
|
|
243
|
+
*/
|
|
244
|
+
fieldsetDisabled: boolean;
|
|
245
|
+
}
|
|
246
|
+
interface MachineContext extends PublicContext, ComputedContext, PrivateContext {
|
|
247
|
+
}
|
|
248
|
+
interface MachineState {
|
|
249
|
+
value: 'idle' | 'navigating:tag' | 'focused:input' | 'editing:tag';
|
|
250
|
+
tags: 'focused' | 'editing';
|
|
251
|
+
}
|
|
252
|
+
type State = StateMachine.State<MachineContext, MachineState>;
|
|
253
|
+
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
254
|
+
interface ItemProps {
|
|
255
|
+
index: string | number;
|
|
256
|
+
value: string;
|
|
257
|
+
disabled?: boolean | undefined;
|
|
258
|
+
}
|
|
259
|
+
interface ItemState {
|
|
260
|
+
/**
|
|
261
|
+
* The underlying id of the item
|
|
262
|
+
*/
|
|
263
|
+
id: string;
|
|
264
|
+
/**
|
|
265
|
+
* Whether the item is being edited
|
|
266
|
+
*/
|
|
267
|
+
editing: boolean;
|
|
268
|
+
/**
|
|
269
|
+
* Whether the item is highlighted
|
|
270
|
+
*/
|
|
271
|
+
highlighted: boolean;
|
|
272
|
+
/**
|
|
273
|
+
* Whether the item is disabled
|
|
274
|
+
*/
|
|
275
|
+
disabled: boolean;
|
|
276
|
+
}
|
|
277
|
+
interface MachineApi<T extends PropTypes = PropTypes> {
|
|
278
|
+
/**
|
|
279
|
+
* Whether the tags are empty
|
|
280
|
+
*/
|
|
281
|
+
empty: boolean;
|
|
282
|
+
/**
|
|
283
|
+
* The value of the tags entry input.
|
|
284
|
+
*/
|
|
285
|
+
inputValue: string;
|
|
286
|
+
/**
|
|
287
|
+
* The value of the tags as an array of strings.
|
|
288
|
+
*/
|
|
289
|
+
value: string[];
|
|
290
|
+
/**
|
|
291
|
+
* The value of the tags as a string.
|
|
292
|
+
*/
|
|
293
|
+
valueAsString: string;
|
|
294
|
+
/**
|
|
295
|
+
* The number of the tags.
|
|
296
|
+
*/
|
|
297
|
+
count: number;
|
|
298
|
+
/**
|
|
299
|
+
* Whether the tags have reached the max limit.
|
|
300
|
+
*/
|
|
301
|
+
atMax: boolean;
|
|
302
|
+
/**
|
|
303
|
+
* Function to set the value of the tags.
|
|
304
|
+
*/
|
|
305
|
+
setValue: (value: string[]) => void;
|
|
306
|
+
/**
|
|
307
|
+
* Function to clear the value of the tags.
|
|
308
|
+
*/
|
|
309
|
+
clearValue: (id?: string) => void;
|
|
310
|
+
/**
|
|
311
|
+
* Function to add a tag to the tags.
|
|
312
|
+
*/
|
|
313
|
+
addValue: (value: string) => void;
|
|
314
|
+
/**
|
|
315
|
+
* Function to set the value of a tag at the given index.
|
|
316
|
+
*/
|
|
317
|
+
setValueAtIndex: (index: number, value: string) => void;
|
|
318
|
+
/**
|
|
319
|
+
* Function to set the value of the tags entry input.
|
|
320
|
+
*/
|
|
321
|
+
setInputValue: (value: string) => void;
|
|
322
|
+
/**
|
|
323
|
+
* Function to clear the value of the tags entry input.
|
|
324
|
+
*/
|
|
325
|
+
clearInputValue: () => void;
|
|
326
|
+
/**
|
|
327
|
+
* Function to focus the tags entry input.
|
|
328
|
+
*/
|
|
329
|
+
focus: () => void;
|
|
330
|
+
/**
|
|
331
|
+
* Returns the state of a tag
|
|
332
|
+
*/
|
|
333
|
+
getItemState: (props: ItemProps) => ItemState;
|
|
334
|
+
getRootProps: () => T['element'];
|
|
335
|
+
getLabelProps: () => T['label'];
|
|
336
|
+
getControlProps: () => T['element'];
|
|
337
|
+
getInputProps: () => T['input'];
|
|
338
|
+
getHiddenInputProps: () => T['input'];
|
|
339
|
+
getClearTriggerProps: () => T['button'];
|
|
340
|
+
getItemProps: (options: ItemProps) => T['element'];
|
|
341
|
+
getItemPreviewProps: (options: ItemProps) => T['element'];
|
|
342
|
+
getItemTextProps: (options: ItemProps) => T['element'];
|
|
343
|
+
getItemInputProps: (options: ItemProps) => T['input'];
|
|
344
|
+
getItemDeleteTriggerProps: (options: ItemProps) => T['button'];
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
|
|
348
|
+
|
|
349
|
+
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
350
|
+
|
|
351
|
+
declare const props: ("ids" | "translations" | "maxLength" | "delimiter" | "autoFocus" | "disabled" | "readOnly" | "invalid" | "required" | "editable" | "inputValue" | "value" | "onValueChange" | "onInputValueChange" | "onHighlightChange" | "onValueInvalid" | "validate" | "blurBehavior" | "addOnPaste" | "max" | "allowOverflow" | "name" | "form" | "dir" | "id" | "getRootNode" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside")[];
|
|
352
|
+
declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "ids" | "translations" | "maxLength" | "delimiter" | "autoFocus" | "disabled" | "readOnly" | "invalid" | "required" | "editable" | "inputValue" | "value" | "onValueChange" | "onInputValueChange" | "onHighlightChange" | "onValueInvalid" | "validate" | "blurBehavior" | "addOnPaste" | "max" | "allowOverflow" | "name" | "form" | "dir" | "id" | "getRootNode" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside">];
|
|
353
|
+
declare const itemProps: (keyof ItemProps)[];
|
|
354
|
+
declare const splitItemProps: <Props extends ItemProps>(props: Props) => [ItemProps, Omit<Props, keyof ItemProps>];
|
|
355
|
+
|
|
356
|
+
export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type HighlightChangeDetails, type InputValueChangeDetails, type IntlTranslations, type ItemProps, type ItemState, type ValidateArgs, type ValidityChangeDetails, type ValueChangeDetails, anatomy, connect, itemProps, machine, props, splitItemProps, splitProps };
|