@zag-js/pin-input 1.3.0 → 1.3.2

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.js CHANGED
@@ -133,6 +133,7 @@ function connect(service, normalize) {
133
133
  "data-disabled": domQuery.dataAttr(prop("disabled")),
134
134
  "data-complete": domQuery.dataAttr(complete),
135
135
  id: getInputId(scope, index.toString()),
136
+ "data-index": index,
136
137
  "data-ownedby": getRootId(scope),
137
138
  "aria-label": translations?.inputLabel?.(index, computed("valueLength")),
138
139
  inputMode: prop("otp") || prop("type") === "numeric" ? "numeric" : "text",
@@ -396,11 +397,13 @@ var machine = createMachine({
396
397
  const value = fill(event.value, context.get("count"));
397
398
  context.set("value", value);
398
399
  },
399
- setFocusedValue({ context, event, computed }) {
400
+ setFocusedValue({ context, event, computed, flush }) {
400
401
  const focusedValue = computed("focusedValue");
401
402
  const focusedIndex = context.get("focusedIndex");
402
403
  const value = getNextValue(focusedValue, event.value);
403
- context.set("value", utils.setValueAtIndex(computed("_value"), focusedIndex, value));
404
+ flush(() => {
405
+ context.set("value", utils.setValueAtIndex(computed("_value"), focusedIndex, value));
406
+ });
404
407
  },
405
408
  revertInputValue({ context, computed, scope }) {
406
409
  const inputEl = getInputElAtIndex(scope, context.get("focusedIndex"));
package/dist/index.mjs CHANGED
@@ -131,6 +131,7 @@ function connect(service, normalize) {
131
131
  "data-disabled": dataAttr(prop("disabled")),
132
132
  "data-complete": dataAttr(complete),
133
133
  id: getInputId(scope, index.toString()),
134
+ "data-index": index,
134
135
  "data-ownedby": getRootId(scope),
135
136
  "aria-label": translations?.inputLabel?.(index, computed("valueLength")),
136
137
  inputMode: prop("otp") || prop("type") === "numeric" ? "numeric" : "text",
@@ -394,11 +395,13 @@ var machine = createMachine({
394
395
  const value = fill(event.value, context.get("count"));
395
396
  context.set("value", value);
396
397
  },
397
- setFocusedValue({ context, event, computed }) {
398
+ setFocusedValue({ context, event, computed, flush }) {
398
399
  const focusedValue = computed("focusedValue");
399
400
  const focusedIndex = context.get("focusedIndex");
400
401
  const value = getNextValue(focusedValue, event.value);
401
- context.set("value", setValueAtIndex(computed("_value"), focusedIndex, value));
402
+ flush(() => {
403
+ context.set("value", setValueAtIndex(computed("_value"), focusedIndex, value));
404
+ });
402
405
  },
403
406
  revertInputValue({ context, computed, scope }) {
404
407
  const inputEl = getInputElAtIndex(scope, context.get("focusedIndex"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/pin-input",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Core logic for the pin-input widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -26,11 +26,11 @@
26
26
  "url": "https://github.com/chakra-ui/zag/issues"
27
27
  },
28
28
  "dependencies": {
29
- "@zag-js/anatomy": "1.3.0",
30
- "@zag-js/dom-query": "1.3.0",
31
- "@zag-js/utils": "1.3.0",
32
- "@zag-js/core": "1.3.0",
33
- "@zag-js/types": "1.3.0"
29
+ "@zag-js/anatomy": "1.3.2",
30
+ "@zag-js/dom-query": "1.3.2",
31
+ "@zag-js/utils": "1.3.2",
32
+ "@zag-js/core": "1.3.2",
33
+ "@zag-js/types": "1.3.2"
34
34
  },
35
35
  "devDependencies": {
36
36
  "clean-package": "2.2.0"