@hairy/react-lib 1.6.2 → 1.7.0

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.cjs CHANGED
@@ -374,14 +374,14 @@ function useWhenever(source, cb, options) {
374
374
  var hasOwn = {}.hasOwnProperty;
375
375
  function cls(...args) {
376
376
  let classes = "";
377
- for (let i = 0; i < arguments.length; i++) {
378
- const arg = arguments[i];
377
+ for (let i = 0; i < args.length; i++) {
378
+ const arg = args[i];
379
379
  if (arg)
380
- classes = appendClass(classes, parseValue(arg));
380
+ classes = cls.append(classes, cls.parse(arg));
381
381
  }
382
382
  return classes;
383
383
  }
384
- function parseValue(arg) {
384
+ cls.parse = function(arg) {
385
385
  if (typeof arg === "string")
386
386
  return arg;
387
387
  if (typeof arg !== "object")
@@ -393,15 +393,15 @@ function parseValue(arg) {
393
393
  let classes = "";
394
394
  for (const key in arg) {
395
395
  if (hasOwn.call(arg, key) && arg[key])
396
- classes = appendClass(classes, key);
396
+ classes = cls.append(classes, key);
397
397
  }
398
398
  return classes;
399
- }
400
- function appendClass(value, newClass) {
399
+ };
400
+ cls.append = function(value, newClass) {
401
401
  if (!newClass)
402
402
  return value;
403
403
  return value ? `${value} ${newClass}` : newClass;
404
- }
404
+ };
405
405
  // Annotate the CommonJS export names for ESM import in node:
406
406
  0 && (module.exports = {
407
407
  Case,
package/dist/index.d.ts CHANGED
@@ -132,5 +132,9 @@ type Argument = Value | Mapping | ArgumentArray | ReadonlyArgumentArray;
132
132
  * A simple JavaScript utility for conditionally joining classNames together.
133
133
  */
134
134
  declare function cls(...args: ArgumentArray): string;
135
+ declare namespace cls {
136
+ var parse: (arg: any) => string;
137
+ var append: (value: any, newClass: any) => any;
138
+ }
135
139
 
136
140
  export { type Argument, type ArgumentArray, Case, type CaseProps, Default, Else, type EventBusListener, type FetchRequestInterceptCallback, type FetchResponseInterceptCallback, If, type IfProps, type InjectComponent, Injector, type InjectorProps, type Mapping, type PropWithHtmlProps, type ReadonlyArgumentArray, type StateFromFunctionReturningPromise, Switch, type SwitchProps, Then, Trans, type TransProps, Unless, type UnlessProps, type UseAsyncStateOptions, type Value, type WatchCallback, type WatchOptions, cls, useAsyncCallback, useAsyncState, useDebounce, useEventBus, useFetchRequestIntercept, useFetchResponseIntercept, useMounted, useWatch, useWhenever };
@@ -494,14 +494,14 @@ var LibReact = (() => {
494
494
  var hasOwn = {}.hasOwnProperty;
495
495
  function cls(...args) {
496
496
  let classes = "";
497
- for (let i2 = 0; i2 < arguments.length; i2++) {
498
- const arg = arguments[i2];
497
+ for (let i2 = 0; i2 < args.length; i2++) {
498
+ const arg = args[i2];
499
499
  if (arg)
500
- classes = appendClass(classes, parseValue(arg));
500
+ classes = cls.append(classes, cls.parse(arg));
501
501
  }
502
502
  return classes;
503
503
  }
504
- function parseValue(arg) {
504
+ cls.parse = function(arg) {
505
505
  if (typeof arg === "string")
506
506
  return arg;
507
507
  if (typeof arg !== "object")
@@ -513,14 +513,14 @@ var LibReact = (() => {
513
513
  let classes = "";
514
514
  for (const key in arg) {
515
515
  if (hasOwn.call(arg, key) && arg[key])
516
- classes = appendClass(classes, key);
516
+ classes = cls.append(classes, key);
517
517
  }
518
518
  return classes;
519
- }
520
- function appendClass(value, newClass) {
519
+ };
520
+ cls.append = function(value, newClass) {
521
521
  if (!newClass)
522
522
  return value;
523
523
  return value ? `${value} ${newClass}` : newClass;
524
- }
524
+ };
525
525
  return __toCommonJS(index_exports);
526
526
  })();
package/dist/index.js CHANGED
@@ -322,14 +322,14 @@ function useWhenever(source, cb, options) {
322
322
  var hasOwn = {}.hasOwnProperty;
323
323
  function cls(...args) {
324
324
  let classes = "";
325
- for (let i = 0; i < arguments.length; i++) {
326
- const arg = arguments[i];
325
+ for (let i = 0; i < args.length; i++) {
326
+ const arg = args[i];
327
327
  if (arg)
328
- classes = appendClass(classes, parseValue(arg));
328
+ classes = cls.append(classes, cls.parse(arg));
329
329
  }
330
330
  return classes;
331
331
  }
332
- function parseValue(arg) {
332
+ cls.parse = function(arg) {
333
333
  if (typeof arg === "string")
334
334
  return arg;
335
335
  if (typeof arg !== "object")
@@ -341,15 +341,15 @@ function parseValue(arg) {
341
341
  let classes = "";
342
342
  for (const key in arg) {
343
343
  if (hasOwn.call(arg, key) && arg[key])
344
- classes = appendClass(classes, key);
344
+ classes = cls.append(classes, key);
345
345
  }
346
346
  return classes;
347
- }
348
- function appendClass(value, newClass) {
347
+ };
348
+ cls.append = function(value, newClass) {
349
349
  if (!newClass)
350
350
  return value;
351
351
  return value ? `${value} ${newClass}` : newClass;
352
- }
352
+ };
353
353
  export {
354
354
  Case,
355
355
  Default,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hairy/react-lib",
3
3
  "type": "module",
4
- "version": "1.6.2",
4
+ "version": "1.7.0",
5
5
  "description": "Library for react",
6
6
  "author": "Hairyf <wwu710632@gmail.com>",
7
7
  "license": "MIT",
@@ -28,17 +28,17 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "html-parse-stringify": "^3.0.1",
31
- "mitt": "^3.0.1"
31
+ "mitt": "^3.0.1",
32
+ "valtio": "^2"
32
33
  },
33
34
  "devDependencies": {
34
- "@types/node": "^20.11.7",
35
35
  "@types/react": "^18.2.43",
36
36
  "@types/react-dom": "^18.2.17",
37
37
  "react": "^18.2.0",
38
38
  "react-dom": "^18.2.0",
39
39
  "react-i18next": "^14.1.2",
40
40
  "react-use": "^17.6.0",
41
- "@hairy/utils": "1.6.2"
41
+ "@hairy/utils": "1.7.0"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "tsup",