@zag-js/pin-input 0.1.9 → 0.1.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/pin-input",
3
- "version": "0.1.9",
3
+ "version": "0.1.12",
4
4
  "description": "Core logic for the pin-input widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -29,18 +29,22 @@
29
29
  "url": "https://github.com/chakra-ui/zag/issues"
30
30
  },
31
31
  "dependencies": {
32
- "@zag-js/core": "0.1.7",
33
- "@zag-js/dom-utils": "0.1.6",
34
- "@zag-js/types": "0.2.1",
35
- "@zag-js/utils": "0.1.2"
32
+ "@zag-js/core": "0.1.9",
33
+ "@zag-js/types": "0.2.3"
34
+ },
35
+ "devDependencies": {
36
+ "@zag-js/dom-utils": "0.1.9",
37
+ "@zag-js/form-utils": "0.1.0",
38
+ "@zag-js/utils": "0.1.3"
36
39
  },
37
40
  "scripts": {
38
- "build:fast": "zag build",
39
- "start": "zag build --watch",
40
- "build": "zag build --prod",
41
+ "build-fast": "tsup src/index.ts --format=esm,cjs",
42
+ "start": "pnpm build --watch",
43
+ "build": "tsup src/index.ts --format=esm,cjs --dts",
41
44
  "test": "jest --config ../../../jest.config.js --rootDir . --passWithNoTests",
42
45
  "lint": "eslint src --ext .ts,.tsx",
43
- "test:ci": "yarn test --ci --runInBand",
44
- "test:watch": "yarn test --watch --updateSnapshot"
46
+ "test-ci": "pnpm test --ci --runInBand",
47
+ "test-watch": "pnpm test --watch -u",
48
+ "typecheck": "tsc --noEmit"
45
49
  }
46
- }
50
+ }
@@ -1,15 +0,0 @@
1
- import type { NormalizeProps, PropTypes } from "@zag-js/types";
2
- import type { Send, State } from "./pin-input.types";
3
- export declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
4
- value: string[];
5
- valueAsString: string;
6
- isValueComplete: boolean;
7
- setValue(value: string[]): void;
8
- clearValue(): void;
9
- setValueAtIndex(index: number, value: string): void;
10
- focus(): void;
11
- rootProps: T["element"];
12
- getInputProps({ index }: {
13
- index: number;
14
- }): T["input"];
15
- };
@@ -1,11 +0,0 @@
1
- import type { MachineContext as Ctx } from "./pin-input.types";
2
- export declare const dom: {
3
- getDoc: (ctx: Ctx) => Document;
4
- getRootNode: (ctx: Ctx) => Document | ShadowRoot;
5
- getRootId: (ctx: Ctx) => string;
6
- getInputId: (ctx: Ctx, id: string) => string;
7
- getRootEl: (ctx: Ctx) => HTMLElement;
8
- getElements: (ctx: Ctx) => HTMLInputElement[];
9
- getFocusedEl: (ctx: Ctx) => HTMLInputElement;
10
- getFirstInputEl: (ctx: Ctx) => HTMLInputElement;
11
- };
@@ -1,2 +0,0 @@
1
- import type { MachineContext, MachineState, UserDefinedContext } from "./pin-input.types";
2
- export declare function machine(ctx?: UserDefinedContext): import("@zag-js/core").Machine<MachineContext, MachineState, import("@zag-js/core").StateMachine.AnyEventObject>;
@@ -1,113 +0,0 @@
1
- import type { StateMachine as S } from "@zag-js/core";
2
- import type { Context, DirectionProperty } from "@zag-js/types";
3
- declare type IntlMessages = {
4
- inputLabel: (index: number, length: number) => string;
5
- };
6
- declare type ElementIds = Partial<{
7
- root: string;
8
- input(id: string): string;
9
- }>;
10
- declare type PublicContext = DirectionProperty & {
11
- /**
12
- * The ids of the elements in the pin input. Useful for composition.
13
- */
14
- ids?: ElementIds;
15
- /**
16
- * Whether the inputs are disabled
17
- */
18
- disabled?: boolean;
19
- /**
20
- * The placeholder text for the input
21
- */
22
- placeholder?: string;
23
- /**
24
- * Whether to auto-focus the first input.
25
- */
26
- autoFocus?: boolean;
27
- /**
28
- * Whether the pin input is in the invalid state
29
- */
30
- invalid?: boolean;
31
- /**
32
- * If `true`, the pin input component signals to its fields that they should
33
- * use `autocomplete="one-time-code"`.
34
- */
35
- otp?: boolean;
36
- /**
37
- * The value of the the pin input.
38
- */
39
- value: string[];
40
- /**
41
- * The type of value the pin-input should allow
42
- */
43
- type?: "alphanumeric" | "numeric" | "alphabetic";
44
- /**
45
- * Function called when all inputs have valid values
46
- */
47
- onComplete?: (details: {
48
- value: string[];
49
- valueAsString: string;
50
- }) => void;
51
- /**
52
- * Function called on input change
53
- */
54
- onChange?: (details: {
55
- value: string[];
56
- }) => void;
57
- /**
58
- * Function called when an invalid value is entered
59
- */
60
- onInvalid?: (details: {
61
- value: string;
62
- index: number;
63
- }) => void;
64
- /**
65
- * If `true`, the input's value will be masked just like `type=password`
66
- */
67
- mask?: boolean;
68
- /**
69
- * Whether to blur the input when the value is complete
70
- */
71
- blurOnComplete?: boolean;
72
- /**
73
- * Specifies the localized strings that identifies the accessibility elements and their states
74
- */
75
- messages: IntlMessages;
76
- };
77
- export declare type UserDefinedContext = Partial<PublicContext>;
78
- declare type ComputedContext = Readonly<{
79
- /**
80
- * @computed
81
- * The number of inputs
82
- */
83
- valueLength: number;
84
- /**
85
- * @computed
86
- * The number of inputs that are not empty
87
- */
88
- filledValueLength: number;
89
- /**
90
- * @computed
91
- * Whether all input values are valid
92
- */
93
- isValueComplete: boolean;
94
- /**
95
- * @computed
96
- * The string representation of the input values
97
- */
98
- valueAsString: string;
99
- }>;
100
- declare type PrivateContext = Context<{
101
- /**
102
- * @internal
103
- * The index of the input field that has focus
104
- */
105
- focusedIndex: number;
106
- }>;
107
- export declare type MachineContext = PublicContext & PrivateContext & ComputedContext;
108
- export declare type MachineState = {
109
- value: "unknown" | "idle" | "focused";
110
- };
111
- export declare type State = S.State<MachineContext, MachineState>;
112
- export declare type Send = S.Send<S.AnyEventObject>;
113
- export {};