@zag-js/pin-input 0.82.1 → 1.0.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/dist/index.d.mts +38 -46
- package/dist/index.d.ts +38 -46
- package/dist/index.js +364 -309
- package/dist/index.mjs +366 -313
- package/package.json +14 -9
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
-
import { RequiredBy, PropTypes, DirectionProperty, CommonProperties, NormalizeProps } from '@zag-js/types';
|
|
3
2
|
import * as _zag_js_core from '@zag-js/core';
|
|
4
|
-
import {
|
|
3
|
+
import { Service, EventObject } from '@zag-js/core';
|
|
4
|
+
import { DirectionProperty, CommonProperties, PropTypes, RequiredBy, NormalizeProps } from '@zag-js/types';
|
|
5
5
|
|
|
6
6
|
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "label" | "input" | "control">;
|
|
7
7
|
|
|
@@ -23,7 +23,7 @@ type ElementIds = Partial<{
|
|
|
23
23
|
control: string;
|
|
24
24
|
input(id: string): string;
|
|
25
25
|
}>;
|
|
26
|
-
interface
|
|
26
|
+
interface PinInputProps extends DirectionProperty, CommonProperties {
|
|
27
27
|
/**
|
|
28
28
|
* The name of the input element. Useful for form submission.
|
|
29
29
|
*/
|
|
@@ -71,9 +71,14 @@ interface PublicContext extends DirectionProperty, CommonProperties {
|
|
|
71
71
|
*/
|
|
72
72
|
otp?: boolean | undefined;
|
|
73
73
|
/**
|
|
74
|
-
* The value of the the pin input.
|
|
74
|
+
* The controlled value of the the pin input.
|
|
75
75
|
*/
|
|
76
|
-
value
|
|
76
|
+
value?: string[] | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* The initial value of the the pin input when rendered.
|
|
79
|
+
* Use when you don't need to control the value of the pin input.
|
|
80
|
+
*/
|
|
81
|
+
defaultValue?: string[] | undefined;
|
|
77
82
|
/**
|
|
78
83
|
* The type of value the pin-input should allow
|
|
79
84
|
* @default "numeric"
|
|
@@ -106,49 +111,33 @@ interface PublicContext extends DirectionProperty, CommonProperties {
|
|
|
106
111
|
/**
|
|
107
112
|
* Specifies the localized strings that identifies the accessibility elements and their states
|
|
108
113
|
*/
|
|
109
|
-
translations
|
|
110
|
-
}
|
|
111
|
-
type UserDefinedContext = RequiredBy<PublicContext, "id">;
|
|
112
|
-
type ComputedContext = Readonly<{
|
|
113
|
-
/**
|
|
114
|
-
* @computed
|
|
115
|
-
* The number of inputs
|
|
116
|
-
*/
|
|
117
|
-
valueLength: number;
|
|
118
|
-
/**
|
|
119
|
-
* @computed
|
|
120
|
-
* The number of inputs that are not empty
|
|
121
|
-
*/
|
|
122
|
-
filledValueLength: number;
|
|
123
|
-
/**
|
|
124
|
-
* @computed
|
|
125
|
-
* Whether all input values are valid
|
|
126
|
-
*/
|
|
127
|
-
isValueComplete: boolean;
|
|
128
|
-
/**
|
|
129
|
-
* @computed
|
|
130
|
-
* The string representation of the input values
|
|
131
|
-
*/
|
|
132
|
-
valueAsString: string;
|
|
133
|
-
/**
|
|
134
|
-
* @computed
|
|
135
|
-
* The value at focused index
|
|
136
|
-
*/
|
|
137
|
-
focusedValue: string;
|
|
138
|
-
}>;
|
|
139
|
-
interface PrivateContext {
|
|
114
|
+
translations?: IntlTranslations | undefined;
|
|
140
115
|
}
|
|
141
|
-
|
|
116
|
+
type PropsWithDefault = "placeholder" | "otp" | "type" | "defaultValue";
|
|
117
|
+
interface PinInputSchema {
|
|
118
|
+
state: "idle" | "focused";
|
|
119
|
+
props: RequiredBy<PinInputProps, PropsWithDefault>;
|
|
120
|
+
context: {
|
|
121
|
+
value: string[];
|
|
122
|
+
focusedIndex: number;
|
|
123
|
+
};
|
|
124
|
+
computed: {
|
|
125
|
+
valueLength: number;
|
|
126
|
+
filledValueLength: number;
|
|
127
|
+
isValueComplete: boolean;
|
|
128
|
+
valueAsString: string;
|
|
129
|
+
focusedValue: string;
|
|
130
|
+
};
|
|
131
|
+
event: EventObject;
|
|
132
|
+
action: string;
|
|
133
|
+
effect: string;
|
|
134
|
+
guard: string;
|
|
142
135
|
}
|
|
143
|
-
|
|
144
|
-
value: "idle" | "focused";
|
|
145
|
-
}
|
|
146
|
-
type State = StateMachine.State<MachineContext, MachineState>;
|
|
147
|
-
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
136
|
+
type PinInputService = Service<PinInputSchema>;
|
|
148
137
|
interface InputProps {
|
|
149
138
|
index: number;
|
|
150
139
|
}
|
|
151
|
-
interface
|
|
140
|
+
interface PinInputApi<T extends PropTypes = PropTypes> {
|
|
152
141
|
/**
|
|
153
142
|
* The value of the input as an array of strings.
|
|
154
143
|
*/
|
|
@@ -184,8 +173,11 @@ interface MachineApi<T extends PropTypes = PropTypes> {
|
|
|
184
173
|
getInputProps(props: InputProps): T["input"];
|
|
185
174
|
}
|
|
186
175
|
|
|
187
|
-
declare function connect<T extends PropTypes>(
|
|
176
|
+
declare function connect<T extends PropTypes>(service: Service<PinInputSchema>, normalize: NormalizeProps<T>): PinInputApi<T>;
|
|
177
|
+
|
|
178
|
+
declare const machine: _zag_js_core.MachineConfig<PinInputSchema>;
|
|
188
179
|
|
|
189
|
-
declare
|
|
180
|
+
declare const props: (keyof PinInputProps)[];
|
|
181
|
+
declare const splitProps: <Props extends Partial<PinInputProps>>(props: Props) => [Partial<PinInputProps>, Omit<Props, keyof PinInputProps>];
|
|
190
182
|
|
|
191
|
-
export { type
|
|
183
|
+
export { type PinInputApi as Api, type ElementIds, type InputProps, type IntlTranslations, type PinInputProps as Props, type PinInputService as Service, type ValueChangeDetails, type ValueInvalidDetails, anatomy, connect, machine, props, splitProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
-
import { RequiredBy, PropTypes, DirectionProperty, CommonProperties, NormalizeProps } from '@zag-js/types';
|
|
3
2
|
import * as _zag_js_core from '@zag-js/core';
|
|
4
|
-
import {
|
|
3
|
+
import { Service, EventObject } from '@zag-js/core';
|
|
4
|
+
import { DirectionProperty, CommonProperties, PropTypes, RequiredBy, NormalizeProps } from '@zag-js/types';
|
|
5
5
|
|
|
6
6
|
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "label" | "input" | "control">;
|
|
7
7
|
|
|
@@ -23,7 +23,7 @@ type ElementIds = Partial<{
|
|
|
23
23
|
control: string;
|
|
24
24
|
input(id: string): string;
|
|
25
25
|
}>;
|
|
26
|
-
interface
|
|
26
|
+
interface PinInputProps extends DirectionProperty, CommonProperties {
|
|
27
27
|
/**
|
|
28
28
|
* The name of the input element. Useful for form submission.
|
|
29
29
|
*/
|
|
@@ -71,9 +71,14 @@ interface PublicContext extends DirectionProperty, CommonProperties {
|
|
|
71
71
|
*/
|
|
72
72
|
otp?: boolean | undefined;
|
|
73
73
|
/**
|
|
74
|
-
* The value of the the pin input.
|
|
74
|
+
* The controlled value of the the pin input.
|
|
75
75
|
*/
|
|
76
|
-
value
|
|
76
|
+
value?: string[] | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* The initial value of the the pin input when rendered.
|
|
79
|
+
* Use when you don't need to control the value of the pin input.
|
|
80
|
+
*/
|
|
81
|
+
defaultValue?: string[] | undefined;
|
|
77
82
|
/**
|
|
78
83
|
* The type of value the pin-input should allow
|
|
79
84
|
* @default "numeric"
|
|
@@ -106,49 +111,33 @@ interface PublicContext extends DirectionProperty, CommonProperties {
|
|
|
106
111
|
/**
|
|
107
112
|
* Specifies the localized strings that identifies the accessibility elements and their states
|
|
108
113
|
*/
|
|
109
|
-
translations
|
|
110
|
-
}
|
|
111
|
-
type UserDefinedContext = RequiredBy<PublicContext, "id">;
|
|
112
|
-
type ComputedContext = Readonly<{
|
|
113
|
-
/**
|
|
114
|
-
* @computed
|
|
115
|
-
* The number of inputs
|
|
116
|
-
*/
|
|
117
|
-
valueLength: number;
|
|
118
|
-
/**
|
|
119
|
-
* @computed
|
|
120
|
-
* The number of inputs that are not empty
|
|
121
|
-
*/
|
|
122
|
-
filledValueLength: number;
|
|
123
|
-
/**
|
|
124
|
-
* @computed
|
|
125
|
-
* Whether all input values are valid
|
|
126
|
-
*/
|
|
127
|
-
isValueComplete: boolean;
|
|
128
|
-
/**
|
|
129
|
-
* @computed
|
|
130
|
-
* The string representation of the input values
|
|
131
|
-
*/
|
|
132
|
-
valueAsString: string;
|
|
133
|
-
/**
|
|
134
|
-
* @computed
|
|
135
|
-
* The value at focused index
|
|
136
|
-
*/
|
|
137
|
-
focusedValue: string;
|
|
138
|
-
}>;
|
|
139
|
-
interface PrivateContext {
|
|
114
|
+
translations?: IntlTranslations | undefined;
|
|
140
115
|
}
|
|
141
|
-
|
|
116
|
+
type PropsWithDefault = "placeholder" | "otp" | "type" | "defaultValue";
|
|
117
|
+
interface PinInputSchema {
|
|
118
|
+
state: "idle" | "focused";
|
|
119
|
+
props: RequiredBy<PinInputProps, PropsWithDefault>;
|
|
120
|
+
context: {
|
|
121
|
+
value: string[];
|
|
122
|
+
focusedIndex: number;
|
|
123
|
+
};
|
|
124
|
+
computed: {
|
|
125
|
+
valueLength: number;
|
|
126
|
+
filledValueLength: number;
|
|
127
|
+
isValueComplete: boolean;
|
|
128
|
+
valueAsString: string;
|
|
129
|
+
focusedValue: string;
|
|
130
|
+
};
|
|
131
|
+
event: EventObject;
|
|
132
|
+
action: string;
|
|
133
|
+
effect: string;
|
|
134
|
+
guard: string;
|
|
142
135
|
}
|
|
143
|
-
|
|
144
|
-
value: "idle" | "focused";
|
|
145
|
-
}
|
|
146
|
-
type State = StateMachine.State<MachineContext, MachineState>;
|
|
147
|
-
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
136
|
+
type PinInputService = Service<PinInputSchema>;
|
|
148
137
|
interface InputProps {
|
|
149
138
|
index: number;
|
|
150
139
|
}
|
|
151
|
-
interface
|
|
140
|
+
interface PinInputApi<T extends PropTypes = PropTypes> {
|
|
152
141
|
/**
|
|
153
142
|
* The value of the input as an array of strings.
|
|
154
143
|
*/
|
|
@@ -184,8 +173,11 @@ interface MachineApi<T extends PropTypes = PropTypes> {
|
|
|
184
173
|
getInputProps(props: InputProps): T["input"];
|
|
185
174
|
}
|
|
186
175
|
|
|
187
|
-
declare function connect<T extends PropTypes>(
|
|
176
|
+
declare function connect<T extends PropTypes>(service: Service<PinInputSchema>, normalize: NormalizeProps<T>): PinInputApi<T>;
|
|
177
|
+
|
|
178
|
+
declare const machine: _zag_js_core.MachineConfig<PinInputSchema>;
|
|
188
179
|
|
|
189
|
-
declare
|
|
180
|
+
declare const props: (keyof PinInputProps)[];
|
|
181
|
+
declare const splitProps: <Props extends Partial<PinInputProps>>(props: Props) => [Partial<PinInputProps>, Omit<Props, keyof PinInputProps>];
|
|
190
182
|
|
|
191
|
-
export { type
|
|
183
|
+
export { type PinInputApi as Api, type ElementIds, type InputProps, type IntlTranslations, type PinInputProps as Props, type PinInputService as Service, type ValueChangeDetails, type ValueInvalidDetails, anatomy, connect, machine, props, splitProps };
|