@aiszlab/relax 1.5.3 → 1.5.4

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.
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var stringify = require('./stringify.cjs');
4
+ var normalize = require('./normalize.cjs');
5
+
6
+
7
+
8
+ exports.stringify = stringify.stringify;
9
+ exports.normalize = normalize.normalize;
@@ -0,0 +1,2 @@
1
+ export { stringify } from "./stringify";
2
+ export { normalize } from "./normalize";
@@ -0,0 +1,2 @@
1
+ export { stringify } from './stringify.mjs';
2
+ export { normalize } from './normalize.mjs';
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
4
+ var _createForOfIteratorHelper = require('@babel/runtime/helpers/createForOfIteratorHelper');
5
+ var isString = require('../is/is-string.cjs');
6
+
7
+ function normalize() {
8
+ var values = new Set();
9
+ for (var _len = arguments.length, classNames = new Array(_len), _key = 0; _key < _len; _key++) {
10
+ classNames[_key] = arguments[_key];
11
+ }
12
+ for (var _i = 0, _classNames2 = classNames; _i < _classNames2.length; _i++) {
13
+ var _classNames = _classNames2[_i];
14
+ if (!isString.isString(_classNames)) return;
15
+ var _iterator = _createForOfIteratorHelper(_classNames.matchAll(/\S+/g)),
16
+ _step;
17
+ try {
18
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
19
+ var _step$value = _slicedToArray(_step.value, 1),
20
+ className = _step$value[0];
21
+ values.add(className);
22
+ }
23
+ } catch (err) {
24
+ _iterator.e(err);
25
+ } finally {
26
+ _iterator.f();
27
+ }
28
+ }
29
+ return Array.from(values);
30
+ }
31
+
32
+ exports.normalize = normalize;
@@ -0,0 +1,2 @@
1
+ declare function normalize(...classNames: string[]): string[] | undefined;
2
+ export { normalize };
@@ -0,0 +1,30 @@
1
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
+ import _createForOfIteratorHelper from '@babel/runtime/helpers/createForOfIteratorHelper';
3
+ import { isString } from '../is/is-string.mjs';
4
+
5
+ function normalize() {
6
+ var values = new Set();
7
+ for (var _len = arguments.length, classNames = new Array(_len), _key = 0; _key < _len; _key++) {
8
+ classNames[_key] = arguments[_key];
9
+ }
10
+ for (var _i = 0, _classNames2 = classNames; _i < _classNames2.length; _i++) {
11
+ var _classNames = _classNames2[_i];
12
+ if (!isString(_classNames)) return;
13
+ var _iterator = _createForOfIteratorHelper(_classNames.matchAll(/\S+/g)),
14
+ _step;
15
+ try {
16
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
17
+ var _step$value = _slicedToArray(_step.value, 1),
18
+ className = _step$value[0];
19
+ values.add(className);
20
+ }
21
+ } catch (err) {
22
+ _iterator.e(err);
23
+ } finally {
24
+ _iterator.f();
25
+ }
26
+ }
27
+ return Array.from(values);
28
+ }
29
+
30
+ export { normalize };
@@ -8,28 +8,28 @@ var isString = require('../is/is-string.cjs');
8
8
  var isVoid = require('../is/is-void.cjs');
9
9
 
10
10
  var _toClassNames = function toClassNames(_classNames) {
11
- if (isVoid.isVoid(_classNames) || isBoolean.isBoolean(_classNames)) return [];
12
- if (isString.isString(_classNames) || isNumber.isNumber(_classNames)) return [_classNames.toString()];
11
+ if (isVoid.isVoid(_classNames) || isBoolean.isBoolean(_classNames)) return new Set();
12
+ if (isString.isString(_classNames) || isNumber.isNumber(_classNames)) return new Set([_classNames.toString()]);
13
13
  if (isArray.isArray(_classNames)) {
14
14
  return _classNames.reduce(function (classNames, item) {
15
- return classNames.concat(_toClassNames(item));
16
- }, []);
15
+ return classNames.union(_toClassNames(item));
16
+ }, new Set());
17
17
  }
18
18
  return Object.entries(_classNames).reduce(function (classNames, _ref) {
19
19
  var _ref2 = _slicedToArray(_ref, 2),
20
20
  className = _ref2[0],
21
21
  isValid = _ref2[1];
22
22
  if (isValid) {
23
- classNames.push(className);
23
+ classNames.add(className);
24
24
  }
25
25
  return classNames;
26
- }, []);
26
+ }, new Set());
27
27
  };
28
- var clsx = function clsx() {
28
+ var stringify = function stringify() {
29
29
  for (var _len = arguments.length, _classNames = new Array(_len), _key = 0; _key < _len; _key++) {
30
30
  _classNames[_key] = arguments[_key];
31
31
  }
32
- return _toClassNames(_classNames).join(" ");
32
+ return Array.from(_toClassNames(_classNames)).join(" ");
33
33
  };
34
34
 
35
- exports.clsx = clsx;
35
+ exports.stringify = stringify;
@@ -1,3 +1,3 @@
1
1
  type ClassNames = string | number | Record<string, boolean> | ClassNames[] | null | undefined | boolean;
2
- export declare const clsx: (..._classNames: ClassNames[]) => string;
2
+ export declare const stringify: (..._classNames: ClassNames[]) => string;
3
3
  export {};
@@ -6,28 +6,28 @@ import { isString } from '../is/is-string.mjs';
6
6
  import { isVoid } from '../is/is-void.mjs';
7
7
 
8
8
  var _toClassNames = function toClassNames(_classNames) {
9
- if (isVoid(_classNames) || isBoolean(_classNames)) return [];
10
- if (isString(_classNames) || isNumber(_classNames)) return [_classNames.toString()];
9
+ if (isVoid(_classNames) || isBoolean(_classNames)) return new Set();
10
+ if (isString(_classNames) || isNumber(_classNames)) return new Set([_classNames.toString()]);
11
11
  if (isArray(_classNames)) {
12
12
  return _classNames.reduce(function (classNames, item) {
13
- return classNames.concat(_toClassNames(item));
14
- }, []);
13
+ return classNames.union(_toClassNames(item));
14
+ }, new Set());
15
15
  }
16
16
  return Object.entries(_classNames).reduce(function (classNames, _ref) {
17
17
  var _ref2 = _slicedToArray(_ref, 2),
18
18
  className = _ref2[0],
19
19
  isValid = _ref2[1];
20
20
  if (isValid) {
21
- classNames.push(className);
21
+ classNames.add(className);
22
22
  }
23
23
  return classNames;
24
- }, []);
24
+ }, new Set());
25
25
  };
26
- var clsx = function clsx() {
26
+ var stringify = function stringify() {
27
27
  for (var _len = arguments.length, _classNames = new Array(_len), _key = 0; _key < _len; _key++) {
28
28
  _classNames[_key] = arguments[_key];
29
29
  }
30
- return _toClassNames(_classNames).join(" ");
30
+ return Array.from(_toClassNames(_classNames)).join(" ");
31
31
  };
32
32
 
33
- export { clsx };
33
+ export { stringify };
package/dist/index.cjs CHANGED
@@ -68,7 +68,6 @@ var clone = require('./utils/clone.cjs');
68
68
  var toggle = require('./utils/toggle.cjs');
69
69
  var taggedTemplateLiterals = require('./utils/tagged-template-literals.cjs');
70
70
  var replace = require('./utils/replace.cjs');
71
- var clsx = require('./utils/clsx.cjs');
72
71
  var first = require('./utils/first.cjs');
73
72
  var last = require('./utils/last.cjs');
74
73
  var merge = require('./utils/merge.cjs');
@@ -146,7 +145,6 @@ exports.clone = clone.clone;
146
145
  exports.toggle = toggle.toggle;
147
146
  exports.taggedTemplateLiterals = taggedTemplateLiterals.taggedTemplateLiterals;
148
147
  exports.replace = replace.replace;
149
- exports.clsx = clsx.clsx;
150
148
  exports.first = first.first;
151
149
  exports.last = last.last;
152
150
  exports.merge = merge.merge;
package/dist/index.d.ts CHANGED
@@ -78,7 +78,6 @@ export { clone } from "./utils/clone";
78
78
  export { toggle } from "./utils/toggle";
79
79
  export { taggedTemplateLiterals } from "./utils/tagged-template-literals";
80
80
  export { replace } from "./utils/replace";
81
- export { clsx } from "./utils/clsx";
82
81
  export { first } from "./utils/first";
83
82
  export { last } from "./utils/last";
84
83
  export { merge } from "./utils/merge";
package/dist/index.mjs CHANGED
@@ -66,7 +66,6 @@ export { clone } from './utils/clone.mjs';
66
66
  export { toggle } from './utils/toggle.mjs';
67
67
  export { taggedTemplateLiterals } from './utils/tagged-template-literals.mjs';
68
68
  export { replace } from './utils/replace.mjs';
69
- export { clsx } from './utils/clsx.mjs';
70
69
  export { first } from './utils/first.mjs';
71
70
  export { last } from './utils/last.mjs';
72
71
  export { merge } from './utils/merge.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiszlab/relax",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "description": "react utils collection",
5
5
  "exports": {
6
6
  ".": {
@@ -10,19 +10,12 @@
10
10
  "import": "./dist/index.mjs",
11
11
  "default": "./dist/index.mjs"
12
12
  },
13
- "./dom": {
14
- "types": "./dist/dom/index.d.ts",
15
- "node": "./dist/dom/index.cjs",
16
- "require": "./dist/dom/index.cjs",
17
- "import": "./dist/dom/index.mjs",
18
- "default": "./dist/dom/index.mjs"
19
- },
20
- "./react": {
21
- "types": "./dist/react/index.d.ts",
22
- "node": "./dist/react/index.cjs",
23
- "require": "./dist/react/index.cjs",
24
- "import": "./dist/react/index.mjs",
25
- "default": "./dist/react/index.mjs"
13
+ "./*": {
14
+ "types": "./dist/*/index.d.ts",
15
+ "node": "./dist/*/index.cjs",
16
+ "require": "./dist/*/index.cjs",
17
+ "import": "./dist/*/index.mjs",
18
+ "default": "./dist/*/index.mjs"
26
19
  },
27
20
  "./types": "./dist/types/index.d.ts"
28
21
  },
@@ -59,7 +52,7 @@
59
52
  "jest-environment-jsdom": "^29.7.0",
60
53
  "react": "^18.3.1",
61
54
  "react-dom": "^18.3.1",
62
- "rollup": "^4.24.1",
55
+ "rollup": "^4.24.2",
63
56
  "typescript": "5.6.2"
64
57
  },
65
58
  "peerDependencies": {