@zag-js/utils 0.0.0-dev-20220919135419 → 0.0.0-dev-20220919164136

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
@@ -1,58 +1,3 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- add: () => add,
24
- callAll: () => callAll,
25
- cast: () => cast,
26
- chunk: () => chunk,
27
- clear: () => clear,
28
- first: () => first,
29
- fromLength: () => fromLength,
30
- has: () => has,
31
- hasProp: () => hasProp,
32
- invariant: () => invariant,
33
- isArray: () => isArray,
34
- isBoolean: () => isBoolean,
35
- isDev: () => isDev,
36
- isEmpty: () => isEmpty,
37
- isFunction: () => isFunction,
38
- isNumber: () => isNumber,
39
- isObject: () => isObject,
40
- isString: () => isString,
41
- last: () => last,
42
- next: () => next,
43
- nextIndex: () => nextIndex,
44
- noop: () => noop,
45
- prev: () => prev,
46
- prevIndex: () => prevIndex,
47
- remove: () => remove,
48
- removeAt: () => removeAt,
49
- runIfFn: () => runIfFn,
50
- toArray: () => toArray,
51
- uuid: () => uuid,
52
- warn: () => warn
53
- });
54
- module.exports = __toCommonJS(src_exports);
55
-
56
1
  // src/array.ts
57
2
  function toArray(v) {
58
3
  if (!v)
@@ -157,8 +102,7 @@ function invariant(...a) {
157
102
  throw new Error(m);
158
103
  }
159
104
  }
160
- // Annotate the CommonJS export names for ESM import in node:
161
- 0 && (module.exports = {
105
+ export {
162
106
  add,
163
107
  callAll,
164
108
  cast,
@@ -189,4 +133,4 @@ function invariant(...a) {
189
133
  toArray,
190
134
  uuid,
191
135
  warn
192
- });
136
+ };
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
+ "type": "module",
2
3
  "name": "@zag-js/utils",
3
- "version": "0.0.0-dev-20220919135419",
4
+ "version": "0.0.0-dev-20220919164136",
4
5
  "description": "",
5
6
  "keywords": [
6
7
  "js",
@@ -11,7 +12,6 @@
11
12
  "homepage": "https://github.com/chakra-ui/zag#readme",
12
13
  "license": "MIT",
13
14
  "main": "dist/index.js",
14
- "module": "dist/index.mjs",
15
15
  "types": "dist/index.d.ts",
16
16
  "repository": "https://github.com/chakra-ui/zag/tree/main/packages/utilities/core",
17
17
  "sideEffects": false,
@@ -25,9 +25,9 @@
25
25
  "url": "https://github.com/chakra-ui/zag/issues"
26
26
  },
27
27
  "scripts": {
28
- "build-fast": "tsup src/index.ts --format=esm,cjs",
28
+ "build-fast": "tsup src/index.ts --format=esm",
29
29
  "start": "pnpm build --watch",
30
- "build": "tsup src/index.ts --format=esm,cjs --dts",
30
+ "build": "tsup src/index.ts --format=esm --dts",
31
31
  "test": "jest --config ../../../jest.config.js --rootDir . --passWithNoTests",
32
32
  "lint": "eslint src --ext .ts,.tsx",
33
33
  "test-ci": "pnpm test --ci --runInBand",
package/dist/index.mjs DELETED
@@ -1,136 +0,0 @@
1
- // src/array.ts
2
- function toArray(v) {
3
- if (!v)
4
- return [];
5
- return Array.isArray(v) ? v : [v];
6
- }
7
- var fromLength = (length) => Array.from(Array(length).keys());
8
- var first = (v) => v[0];
9
- var last = (v) => v[v.length - 1];
10
- var isEmpty = (v) => v.length === 0;
11
- var has = (v, t) => v.indexOf(t) !== -1;
12
- var add = (v, ...items) => v.concat(items);
13
- var remove = (v, item) => removeAt(v, v.indexOf(item));
14
- var removeAt = (v, i) => {
15
- if (i > -1)
16
- v.splice(i, 1);
17
- return v;
18
- };
19
- function clear(v) {
20
- while (v.length > 0)
21
- v.pop();
22
- return v;
23
- }
24
- function nextIndex(v, idx, opts = {}) {
25
- const { step = 1, loop = true } = opts;
26
- const next2 = idx + step;
27
- const len = v.length;
28
- const last2 = len - 1;
29
- if (idx === -1)
30
- return step > 0 ? 0 : last2;
31
- if (next2 < 0)
32
- return loop ? last2 : 0;
33
- if (next2 >= len)
34
- return loop ? 0 : idx > len ? len : idx;
35
- return next2;
36
- }
37
- function next(v, idx, opts = {}) {
38
- return v[nextIndex(v, idx, opts)];
39
- }
40
- function prevIndex(v, idx, opts = {}) {
41
- const { step = 1, loop = true } = opts;
42
- return nextIndex(v, idx, { step: -step, loop });
43
- }
44
- function prev(v, index, opts = {}) {
45
- return v[prevIndex(v, index, opts)];
46
- }
47
- var chunk = (v, size) => {
48
- const res = [];
49
- return v.reduce((rows, value, index) => {
50
- var _a;
51
- if (index % size === 0)
52
- rows.push([value]);
53
- else
54
- (_a = last(rows)) == null ? void 0 : _a.push(value);
55
- return rows;
56
- }, res);
57
- };
58
-
59
- // src/functions.ts
60
- var runIfFn = (v, ...a) => {
61
- const res = typeof v === "function" ? v(...a) : v;
62
- return res ?? void 0;
63
- };
64
- var cast = (v) => v;
65
- var noop = () => {
66
- };
67
- var callAll = (...fns) => (...a) => {
68
- fns.forEach(function(fn) {
69
- fn == null ? void 0 : fn(...a);
70
- });
71
- };
72
- var uuid = /* @__PURE__ */ (() => {
73
- let id = 0;
74
- return () => {
75
- id++;
76
- return id.toString(36);
77
- };
78
- })();
79
-
80
- // src/guard.ts
81
- var isDev = () => process.env.NODE_ENV !== "production";
82
- var isArray = (v) => Array.isArray(v);
83
- var isBoolean = (v) => v === true || v === false;
84
- var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
85
- var isNumber = (v) => typeof v === "number" && !Number.isNaN(v);
86
- var isString = (v) => typeof v === "string";
87
- var isFunction = (v) => typeof v === "function";
88
- var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
89
-
90
- // src/warning.ts
91
- function warn(...a) {
92
- const m = a.length === 1 ? a[0] : a[1];
93
- const c = a.length === 2 ? a[0] : true;
94
- if (c && process.env.NODE_ENV !== "production") {
95
- console.warn(m);
96
- }
97
- }
98
- function invariant(...a) {
99
- const m = a.length === 1 ? a[0] : a[1];
100
- const c = a.length === 2 ? a[0] : true;
101
- if (c && process.env.NODE_ENV !== "production") {
102
- throw new Error(m);
103
- }
104
- }
105
- export {
106
- add,
107
- callAll,
108
- cast,
109
- chunk,
110
- clear,
111
- first,
112
- fromLength,
113
- has,
114
- hasProp,
115
- invariant,
116
- isArray,
117
- isBoolean,
118
- isDev,
119
- isEmpty,
120
- isFunction,
121
- isNumber,
122
- isObject,
123
- isString,
124
- last,
125
- next,
126
- nextIndex,
127
- noop,
128
- prev,
129
- prevIndex,
130
- remove,
131
- removeAt,
132
- runIfFn,
133
- toArray,
134
- uuid,
135
- warn
136
- };