@heyform-inc/utils 1.2.1 → 1.3.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.d.mts CHANGED
@@ -1,12 +1,13 @@
1
1
  export * from 'deep-object-diff';
2
2
  import { IParseOptions, IStringifyOptions } from 'qs';
3
3
  export { default as qs } from 'qs';
4
- import dayjs, { QUnitType, OpUnitType } from 'dayjs';
5
- import _isUUID from 'validator/lib/isUUID';
4
+ import { ClassValue } from 'clsx';
5
+ import _dayjs, { OpUnitType, QUnitType } from 'dayjs';
6
+ import { IsEmailOptions } from 'validator/lib/isEmail';
6
7
  import _isFQDN from 'validator/lib/isFQDN';
7
8
  import { IsNumericOptions } from 'validator/lib/isNumeric';
8
- import { IsEmailOptions } from 'validator/lib/isEmail';
9
9
  import { IsURLOptions } from 'validator/lib/isURL';
10
+ import _isUUID from 'validator/lib/isUUID';
10
11
  export { v4 as uuidv4, v5 as uuidv5 } from 'uuid';
11
12
  export { deepEqual } from 'fast-equals';
12
13
 
@@ -16,6 +17,8 @@ declare function formatBytes(value: string | number): string;
16
17
 
17
18
  declare function clone<T>(obj: T): T;
18
19
 
20
+ declare function clsx(...inputs: ClassValue[]): string;
21
+
19
22
  declare function isHexColor(color: string): boolean;
20
23
  declare function isRgba(color: string): boolean;
21
24
  declare function isRgb(color: string): boolean;
@@ -53,8 +56,9 @@ declare function toURLQuery(value: Record<string | number, any>, baseUri?: strin
53
56
  declare function htmlToText(html: string, limit?: number): string;
54
57
 
55
58
  declare function timestamp(): number;
56
- declare function date(str?: string, format?: string): dayjs.Dayjs;
57
- declare function unixDate(t: number): dayjs.Dayjs;
59
+ declare const dayjs: typeof _dayjs;
60
+ declare const date: typeof _dayjs;
61
+ declare function unixDate(t: number): _dayjs.Dayjs;
58
62
  declare function isDateExpired(start: number, end: number, expire: string): boolean;
59
63
  declare function unixDiff(start: number, end: number, unit?: QUnitType | OpUnitType): number;
60
64
  declare function datePeriod(start: number, value?: number, unit?: OpUnitType): number;
@@ -168,4 +172,4 @@ declare function slugify(text: string, options?: SlugifyOptions): string;
168
172
 
169
173
  declare function type(obj: any): string;
170
174
 
171
- export { FILE_MIME_TYPES, IMAGE_MIME_TYPES, RandomType, type SlugifyOptions, alpha, alphaHexToRgb, bytes, clone, colorBrightness, commonFileMimeTypes, commonImageMimeTypes, copyObjectValues, darken, date, datePeriod, excludeObject, formatBytes, _default as helper, hexToRgb, hs, htmlToText, invert, isDarkColor, isDateExpired, isHexColor, isLightColor, isRgb, isRgba, lighten, mime, ms, nanoid, nanoidCustomAlphabet, parseBool, parseBytes, parseJson, parseNumber, pickObject, pickValidValues, random, removeObjectNil, rgbToHex, slugify, timestamp, toBool, toDuration, toFixed, toFloat, toInt, toInteger, toIntlNumber, toJSON, toMillisecond, toSecond, toURLParams, toURLQuery, type, unixDate, unixDiff };
175
+ export { FILE_MIME_TYPES, IMAGE_MIME_TYPES, RandomType, type SlugifyOptions, alpha, alphaHexToRgb, bytes, clone, clsx, colorBrightness, commonFileMimeTypes, commonImageMimeTypes, copyObjectValues, darken, date, datePeriod, dayjs, excludeObject, formatBytes, _default as helper, hexToRgb, hs, htmlToText, invert, isDarkColor, isDateExpired, isHexColor, isLightColor, isRgb, isRgba, lighten, mime, ms, nanoid, nanoidCustomAlphabet, parseBool, parseBytes, parseJson, parseNumber, pickObject, pickValidValues, random, removeObjectNil, rgbToHex, slugify, timestamp, toBool, toDuration, toFixed, toFloat, toInt, toInteger, toIntlNumber, toJSON, toMillisecond, toSecond, toURLParams, toURLQuery, type, unixDate, unixDiff };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  export * from 'deep-object-diff';
2
2
  import { IParseOptions, IStringifyOptions } from 'qs';
3
3
  export { default as qs } from 'qs';
4
- import dayjs, { QUnitType, OpUnitType } from 'dayjs';
5
- import _isUUID from 'validator/lib/isUUID';
4
+ import { ClassValue } from 'clsx';
5
+ import _dayjs, { OpUnitType, QUnitType } from 'dayjs';
6
+ import { IsEmailOptions } from 'validator/lib/isEmail';
6
7
  import _isFQDN from 'validator/lib/isFQDN';
7
8
  import { IsNumericOptions } from 'validator/lib/isNumeric';
8
- import { IsEmailOptions } from 'validator/lib/isEmail';
9
9
  import { IsURLOptions } from 'validator/lib/isURL';
10
+ import _isUUID from 'validator/lib/isUUID';
10
11
  export { v4 as uuidv4, v5 as uuidv5 } from 'uuid';
11
12
  export { deepEqual } from 'fast-equals';
12
13
 
@@ -16,6 +17,8 @@ declare function formatBytes(value: string | number): string;
16
17
 
17
18
  declare function clone<T>(obj: T): T;
18
19
 
20
+ declare function clsx(...inputs: ClassValue[]): string;
21
+
19
22
  declare function isHexColor(color: string): boolean;
20
23
  declare function isRgba(color: string): boolean;
21
24
  declare function isRgb(color: string): boolean;
@@ -53,8 +56,9 @@ declare function toURLQuery(value: Record<string | number, any>, baseUri?: strin
53
56
  declare function htmlToText(html: string, limit?: number): string;
54
57
 
55
58
  declare function timestamp(): number;
56
- declare function date(str?: string, format?: string): dayjs.Dayjs;
57
- declare function unixDate(t: number): dayjs.Dayjs;
59
+ declare const dayjs: typeof _dayjs;
60
+ declare const date: typeof _dayjs;
61
+ declare function unixDate(t: number): _dayjs.Dayjs;
58
62
  declare function isDateExpired(start: number, end: number, expire: string): boolean;
59
63
  declare function unixDiff(start: number, end: number, unit?: QUnitType | OpUnitType): number;
60
64
  declare function datePeriod(start: number, value?: number, unit?: OpUnitType): number;
@@ -168,4 +172,4 @@ declare function slugify(text: string, options?: SlugifyOptions): string;
168
172
 
169
173
  declare function type(obj: any): string;
170
174
 
171
- export { FILE_MIME_TYPES, IMAGE_MIME_TYPES, RandomType, type SlugifyOptions, alpha, alphaHexToRgb, bytes, clone, colorBrightness, commonFileMimeTypes, commonImageMimeTypes, copyObjectValues, darken, date, datePeriod, excludeObject, formatBytes, _default as helper, hexToRgb, hs, htmlToText, invert, isDarkColor, isDateExpired, isHexColor, isLightColor, isRgb, isRgba, lighten, mime, ms, nanoid, nanoidCustomAlphabet, parseBool, parseBytes, parseJson, parseNumber, pickObject, pickValidValues, random, removeObjectNil, rgbToHex, slugify, timestamp, toBool, toDuration, toFixed, toFloat, toInt, toInteger, toIntlNumber, toJSON, toMillisecond, toSecond, toURLParams, toURLQuery, type, unixDate, unixDiff };
175
+ export { FILE_MIME_TYPES, IMAGE_MIME_TYPES, RandomType, type SlugifyOptions, alpha, alphaHexToRgb, bytes, clone, clsx, colorBrightness, commonFileMimeTypes, commonImageMimeTypes, copyObjectValues, darken, date, datePeriod, dayjs, excludeObject, formatBytes, _default as helper, hexToRgb, hs, htmlToText, invert, isDarkColor, isDateExpired, isHexColor, isLightColor, isRgb, isRgba, lighten, mime, ms, nanoid, nanoidCustomAlphabet, parseBool, parseBytes, parseJson, parseNumber, pickObject, pickValidValues, random, removeObjectNil, rgbToHex, slugify, timestamp, toBool, toDuration, toFixed, toFloat, toInt, toInteger, toIntlNumber, toJSON, toMillisecond, toSecond, toURLParams, toURLQuery, type, unixDate, unixDiff };
package/dist/index.js CHANGED
@@ -2,15 +2,17 @@
2
2
 
3
3
  var deepObjectDiff = require('deep-object-diff');
4
4
  var qs = require('qs');
5
- var _isUUID = require('validator/lib/isUUID');
5
+ var _isEmail = require('validator/lib/isEmail');
6
6
  var _isFQDN = require('validator/lib/isFQDN');
7
7
  var _isNumeric = require('validator/lib/isNumeric');
8
- var _isEmail = require('validator/lib/isEmail');
9
8
  var _isURL = require('validator/lib/isURL');
9
+ var _isUUID = require('validator/lib/isUUID');
10
10
  var _clone = require('clone');
11
+ var clsx$1 = require('clsx');
12
+ var tailwindMerge = require('tailwind-merge');
11
13
  var htmlToText$1 = require('html-to-text');
14
+ var _dayjs = require('dayjs');
12
15
  var _ms = require('ms');
13
- var dayjs = require('dayjs');
14
16
  var nanoid$1 = require('nanoid');
15
17
  var objectPath = require('object-path');
16
18
  var fastEquals = require('fast-equals');
@@ -38,14 +40,14 @@ function _interopNamespace(e) {
38
40
  }
39
41
 
40
42
  var qs__default = /*#__PURE__*/_interopDefault(qs);
41
- var _isUUID__default = /*#__PURE__*/_interopDefault(_isUUID);
43
+ var _isEmail__default = /*#__PURE__*/_interopDefault(_isEmail);
42
44
  var _isFQDN__default = /*#__PURE__*/_interopDefault(_isFQDN);
43
45
  var _isNumeric__default = /*#__PURE__*/_interopDefault(_isNumeric);
44
- var _isEmail__default = /*#__PURE__*/_interopDefault(_isEmail);
45
46
  var _isURL__default = /*#__PURE__*/_interopDefault(_isURL);
47
+ var _isUUID__default = /*#__PURE__*/_interopDefault(_isUUID);
46
48
  var _clone__default = /*#__PURE__*/_interopDefault(_clone);
49
+ var _dayjs__default = /*#__PURE__*/_interopDefault(_dayjs);
47
50
  var _ms__default = /*#__PURE__*/_interopDefault(_ms);
48
- var dayjs__default = /*#__PURE__*/_interopDefault(dayjs);
49
51
  var objectPath__namespace = /*#__PURE__*/_interopNamespace(objectPath);
50
52
  var slug__default = /*#__PURE__*/_interopDefault(slug);
51
53
 
@@ -303,6 +305,9 @@ function formatBytes(value) {
303
305
  function clone(obj) {
304
306
  return _clone__default.default(obj);
305
307
  }
308
+ function clsx(...inputs) {
309
+ return tailwindMerge.twMerge(clsx$1.clsx(inputs));
310
+ }
306
311
 
307
312
  // src/color.ts
308
313
  var HEX_REGEX = /^#?([0-9A-F]{3}|[0-9A-F]{4}|[0-9A-F]{6}|[0-9A-F]{8})$/i;
@@ -382,9 +387,7 @@ function alphaHexToRgb(hex, alpha2, backgroundHex) {
382
387
  const backgroundRgb = hexToRgb(backgroundHex);
383
388
  return hexRgb.map((color, index) => {
384
389
  return colorRange(
385
- Math.floor(
386
- colorRange(color) * alpha2 + colorRange(backgroundRgb[index]) * (1 - alpha2)
387
- )
390
+ Math.floor(colorRange(color) * alpha2 + colorRange(backgroundRgb[index]) * (1 - alpha2))
388
391
  );
389
392
  });
390
393
  }
@@ -548,14 +551,15 @@ function ms(arg) {
548
551
  }
549
552
  var toSecond = hs;
550
553
  var toMillisecond = ms;
554
+
555
+ // src/date.ts
551
556
  function timestamp() {
552
557
  return Math.floor(Date.now() / 1e3);
553
558
  }
554
- function date(str, format) {
555
- return dayjs__default.default(str, format);
556
- }
559
+ var dayjs = _dayjs__default.default;
560
+ var date = dayjs;
557
561
  function unixDate(t) {
558
- return dayjs__default.default.unix(t);
562
+ return dayjs.unix(t);
559
563
  }
560
564
  function isDateExpired(start, end, expire) {
561
565
  return end - start > hs(expire);
@@ -1979,6 +1983,7 @@ exports.alpha = alpha;
1979
1983
  exports.alphaHexToRgb = alphaHexToRgb;
1980
1984
  exports.bytes = bytes;
1981
1985
  exports.clone = clone;
1986
+ exports.clsx = clsx;
1982
1987
  exports.colorBrightness = colorBrightness;
1983
1988
  exports.commonFileMimeTypes = commonFileMimeTypes;
1984
1989
  exports.commonImageMimeTypes = commonImageMimeTypes;
@@ -1986,6 +1991,7 @@ exports.copyObjectValues = copyObjectValues;
1986
1991
  exports.darken = darken;
1987
1992
  exports.date = date;
1988
1993
  exports.datePeriod = datePeriod;
1994
+ exports.dayjs = dayjs;
1989
1995
  exports.excludeObject = excludeObject;
1990
1996
  exports.formatBytes = formatBytes;
1991
1997
  exports.helper = helper_default;
@@ -2036,5 +2042,5 @@ Object.keys(deepObjectDiff).forEach(function (k) {
2036
2042
  get: function () { return deepObjectDiff[k]; }
2037
2043
  });
2038
2044
  });
2039
- //# sourceMappingURL=out.js.map
2045
+ //# sourceMappingURL=index.js.map
2040
2046
  //# sourceMappingURL=index.js.map