@zag-js/number-input 0.2.0 → 0.2.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.d.ts +1 -1
- package/dist/index.js +13 -4
- package/dist/index.mjs +13 -4
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -234,6 +234,6 @@ declare function connect<T extends PropTypes>(state: State, send: Send, normaliz
|
|
|
234
234
|
scrubberProps: T["element"];
|
|
235
235
|
};
|
|
236
236
|
|
|
237
|
-
declare function machine(
|
|
237
|
+
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
238
238
|
|
|
239
239
|
export { UserDefinedContext as Context, connect, machine };
|
package/dist/index.js
CHANGED
|
@@ -633,6 +633,15 @@ var callAll2 = (...fns) => (...a) => {
|
|
|
633
633
|
fn == null ? void 0 : fn(...a);
|
|
634
634
|
});
|
|
635
635
|
};
|
|
636
|
+
var isArray2 = (v) => Array.isArray(v);
|
|
637
|
+
var isObject2 = (v) => !(v == null || typeof v !== "object" || isArray2(v));
|
|
638
|
+
function compact(obj) {
|
|
639
|
+
if (obj === void 0)
|
|
640
|
+
return obj;
|
|
641
|
+
return Object.fromEntries(
|
|
642
|
+
Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject2(value) ? compact(value) : value])
|
|
643
|
+
);
|
|
644
|
+
}
|
|
636
645
|
|
|
637
646
|
// ../../utilities/form-utils/dist/index.mjs
|
|
638
647
|
function getWindow(el) {
|
|
@@ -641,7 +650,7 @@ function getWindow(el) {
|
|
|
641
650
|
}
|
|
642
651
|
function getDescriptor(el, options) {
|
|
643
652
|
var _a;
|
|
644
|
-
const { type, property } = options;
|
|
653
|
+
const { type, property = "value" } = options;
|
|
645
654
|
const proto = getWindow(el)[type].prototype;
|
|
646
655
|
return (_a = Object.getOwnPropertyDescriptor(proto, property)) != null ? _a : {};
|
|
647
656
|
}
|
|
@@ -660,7 +669,8 @@ function dispatchInputValueEvent(el, value) {
|
|
|
660
669
|
|
|
661
670
|
// src/number-input.machine.ts
|
|
662
671
|
var { not, and } = import_core.guards;
|
|
663
|
-
function machine(
|
|
672
|
+
function machine(userContext) {
|
|
673
|
+
const ctx = compact(userContext);
|
|
664
674
|
return (0, import_core.createMachine)(
|
|
665
675
|
{
|
|
666
676
|
id: "number-input",
|
|
@@ -1048,8 +1058,7 @@ function machine(ctx) {
|
|
|
1048
1058
|
dispatchChangeEvent(ctx2) {
|
|
1049
1059
|
dispatchInputValueEvent(dom.getInputEl(ctx2), ctx2.formattedValue);
|
|
1050
1060
|
}
|
|
1051
|
-
}
|
|
1052
|
-
hookSync: true
|
|
1061
|
+
}
|
|
1053
1062
|
}
|
|
1054
1063
|
);
|
|
1055
1064
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -606,6 +606,15 @@ var callAll2 = (...fns) => (...a) => {
|
|
|
606
606
|
fn == null ? void 0 : fn(...a);
|
|
607
607
|
});
|
|
608
608
|
};
|
|
609
|
+
var isArray2 = (v) => Array.isArray(v);
|
|
610
|
+
var isObject2 = (v) => !(v == null || typeof v !== "object" || isArray2(v));
|
|
611
|
+
function compact(obj) {
|
|
612
|
+
if (obj === void 0)
|
|
613
|
+
return obj;
|
|
614
|
+
return Object.fromEntries(
|
|
615
|
+
Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject2(value) ? compact(value) : value])
|
|
616
|
+
);
|
|
617
|
+
}
|
|
609
618
|
|
|
610
619
|
// ../../utilities/form-utils/dist/index.mjs
|
|
611
620
|
function getWindow(el) {
|
|
@@ -614,7 +623,7 @@ function getWindow(el) {
|
|
|
614
623
|
}
|
|
615
624
|
function getDescriptor(el, options) {
|
|
616
625
|
var _a;
|
|
617
|
-
const { type, property } = options;
|
|
626
|
+
const { type, property = "value" } = options;
|
|
618
627
|
const proto = getWindow(el)[type].prototype;
|
|
619
628
|
return (_a = Object.getOwnPropertyDescriptor(proto, property)) != null ? _a : {};
|
|
620
629
|
}
|
|
@@ -633,7 +642,8 @@ function dispatchInputValueEvent(el, value) {
|
|
|
633
642
|
|
|
634
643
|
// src/number-input.machine.ts
|
|
635
644
|
var { not, and } = guards;
|
|
636
|
-
function machine(
|
|
645
|
+
function machine(userContext) {
|
|
646
|
+
const ctx = compact(userContext);
|
|
637
647
|
return createMachine(
|
|
638
648
|
{
|
|
639
649
|
id: "number-input",
|
|
@@ -1021,8 +1031,7 @@ function machine(ctx) {
|
|
|
1021
1031
|
dispatchChangeEvent(ctx2) {
|
|
1022
1032
|
dispatchInputValueEvent(dom.getInputEl(ctx2), ctx2.formattedValue);
|
|
1023
1033
|
}
|
|
1024
|
-
}
|
|
1025
|
-
hookSync: true
|
|
1034
|
+
}
|
|
1026
1035
|
}
|
|
1027
1036
|
);
|
|
1028
1037
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/number-input",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Core logic for the number-input widget implemented as a state machine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@zag-js/core": "0.2.
|
|
33
|
-
"@zag-js/types": "0.3.
|
|
32
|
+
"@zag-js/core": "0.2.2",
|
|
33
|
+
"@zag-js/types": "0.3.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@zag-js/dom-utils": "0.2.
|
|
37
|
-
"@zag-js/form-utils": "0.2.
|
|
36
|
+
"@zag-js/dom-utils": "0.2.1",
|
|
37
|
+
"@zag-js/form-utils": "0.2.1",
|
|
38
38
|
"@zag-js/number-utils": "0.2.0",
|
|
39
|
-
"@zag-js/utils": "0.
|
|
39
|
+
"@zag-js/utils": "0.3.1"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build-fast": "tsup src/index.ts --format=esm,cjs",
|