yummies 5.15.1 → 6.1.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/README.md +10 -4
- package/async.cjs +45 -1
- package/async.cjs.map +1 -1
- package/async.d.ts +7 -6
- package/common.cjs +11 -1
- package/common.cjs.map +1 -1
- package/common.d.ts +8 -5
- package/common.js.map +1 -1
- package/complex.cjs +130 -1
- package/complex.cjs.map +1 -1
- package/complex.d.ts +113 -0
- package/complex.js +43 -1
- package/complex.js.map +1 -1
- package/cookie.cjs +9 -1
- package/cookie.cjs.map +1 -1
- package/cookie.d.ts +5 -3
- package/cookie.js.map +1 -1
- package/css.cjs +45 -1
- package/css.cjs.map +1 -1
- package/css.d.ts +11 -8
- package/css.js.map +1 -1
- package/data.cjs +43 -1
- package/data.cjs.map +1 -1
- package/data.d.ts +5 -4
- package/data.js.map +1 -1
- package/date-time.cjs +395 -1
- package/date-time.cjs.map +1 -1
- package/date-time.d.ts +12 -10
- package/date-time.js.map +1 -1
- package/device.cjs +32 -1
- package/device.cjs.map +1 -1
- package/device.d.ts +9 -8
- package/encodings.cjs +270 -1
- package/encodings.cjs.map +1 -1
- package/encodings.d.ts +3 -2
- package/encodings.js.map +1 -1
- package/errors.cjs +23 -1
- package/errors.cjs.map +1 -1
- package/errors.d.ts +5 -4
- package/errors.js.map +1 -1
- package/file.cjs +28 -1
- package/file.cjs.map +1 -1
- package/file.d.ts +4 -3
- package/format.cjs +75 -1
- package/format.cjs.map +1 -1
- package/format.d.ts +74 -0
- package/format.js.map +1 -1
- package/html.cjs +167 -1
- package/html.cjs.map +1 -1
- package/html.d.ts +19 -17
- package/html.js.map +1 -1
- package/id.cjs +25 -1
- package/id.cjs.map +1 -1
- package/id.d.ts +9 -8
- package/imports.cjs +33 -1
- package/imports.cjs.map +1 -1
- package/imports.d.ts +6 -4
- package/math.cjs +14 -1
- package/math.cjs.map +1 -1
- package/math.d.ts +7 -5
- package/math.js.map +1 -1
- package/media.cjs +105 -1
- package/media.cjs.map +1 -1
- package/media.d.ts +11 -11
- package/mobx.cjs +184 -1
- package/mobx.cjs.map +1 -1
- package/mobx.d.ts +66 -0
- package/mobx.js.map +1 -1
- package/ms.cjs +13 -1
- package/ms.cjs.map +1 -1
- package/ms.d.ts +4 -3
- package/number.cjs +10 -1
- package/number.cjs.map +1 -1
- package/number.d.ts +3 -2
- package/package.json +97 -141
- package/parser.cjs +68 -1
- package/parser.cjs.map +1 -1
- package/parser.d.ts +41 -0
- package/parser.js.map +1 -1
- package/price.cjs +20 -1
- package/price.cjs.map +1 -1
- package/price.d.ts +5 -3
- package/random.cjs +24 -1
- package/random.cjs.map +1 -1
- package/random.d.ts +10 -9
- package/react.cjs +216 -1
- package/react.cjs.map +1 -1
- package/react.d.ts +113 -0
- package/react.js.map +1 -1
- package/sound.cjs +11 -1
- package/sound.cjs.map +1 -1
- package/sound.d.ts +3 -2
- package/text.cjs +37 -1
- package/text.cjs.map +1 -1
- package/text.d.ts +4 -3
- package/type-guard.cjs +75 -1
- package/type-guard.cjs.map +1 -1
- package/type-guard.d.ts +121 -0
- package/type-guard.js.map +1 -1
- package/{utils/types.d.ts → types.d.ts} +54 -53
- package/types.global.cjs +2 -0
- package/types.global.cjs.map +1 -0
- package/{utility-types.d.ts → types.global.d.ts} +1 -1
- package/types.global.js +2 -0
- package/types.global.js.map +1 -0
- package/vibrate.cjs +8 -1
- package/vibrate.cjs.map +1 -1
- package/vibrate.d.ts +3 -2
- package/async.d.ts.map +0 -1
- package/common.d.ts.map +0 -1
- package/complex/counter.d.ts +0 -15
- package/complex/counter.d.ts.map +0 -1
- package/complex/global-config.d.ts +0 -11
- package/complex/global-config.d.ts.map +0 -1
- package/complex/index.d.ts +0 -4
- package/complex/index.d.ts.map +0 -1
- package/complex/modules-factory.d.ts +0 -49
- package/complex/modules-factory.d.ts.map +0 -1
- package/cookie.d.ts.map +0 -1
- package/css.d.ts.map +0 -1
- package/data.d.ts.map +0 -1
- package/date-time.d.ts.map +0 -1
- package/device.d.ts.map +0 -1
- package/encodings.d.ts.map +0 -1
- package/errors.d.ts.map +0 -1
- package/file.d.ts.map +0 -1
- package/format/_exports.d.ts +0 -5
- package/format/_exports.d.ts.map +0 -1
- package/format/constants.d.ts +0 -4
- package/format/constants.d.ts.map +0 -1
- package/format/index.d.ts +0 -3
- package/format/index.d.ts.map +0 -1
- package/format/number.d.ts +0 -36
- package/format/number.d.ts.map +0 -1
- package/format/percent.d.ts +0 -15
- package/format/percent.d.ts.map +0 -1
- package/format/skip-spaces.d.ts +0 -5
- package/format/skip-spaces.d.ts.map +0 -1
- package/html.d.ts.map +0 -1
- package/id.d.ts.map +0 -1
- package/imports.d.ts.map +0 -1
- package/math.d.ts.map +0 -1
- package/media.d.ts.map +0 -1
- package/mobx/apply-observable.d.ts +0 -4
- package/mobx/apply-observable.d.ts.map +0 -1
- package/mobx/create-enhanced-atom.d.ts +0 -11
- package/mobx/create-enhanced-atom.d.ts.map +0 -1
- package/mobx/create-ref.d.ts +0 -28
- package/mobx/create-ref.d.ts.map +0 -1
- package/mobx/deep-observable-struct.d.ts +0 -7
- package/mobx/deep-observable-struct.d.ts.map +0 -1
- package/mobx/get-mobx-administration.d.ts +0 -6
- package/mobx/get-mobx-administration.d.ts.map +0 -1
- package/mobx/index.d.ts +0 -7
- package/mobx/index.d.ts.map +0 -1
- package/mobx/lazy-observe.d.ts +0 -14
- package/mobx/lazy-observe.d.ts.map +0 -1
- package/ms.d.ts.map +0 -1
- package/number.d.ts.map +0 -1
- package/parser/_exports.d.ts +0 -4
- package/parser/_exports.d.ts.map +0 -1
- package/parser/index.d.ts +0 -3
- package/parser/index.d.ts.map +0 -1
- package/parser/number.d.ts +0 -21
- package/parser/number.d.ts.map +0 -1
- package/parser/percent.d.ts +0 -4
- package/parser/percent.d.ts.map +0 -1
- package/parser/string.d.ts +0 -7
- package/parser/string.d.ts.map +0 -1
- package/price.d.ts.map +0 -1
- package/random.d.ts.map +0 -1
- package/react/hooks/index.d.ts +0 -22
- package/react/hooks/index.d.ts.map +0 -1
- package/react/hooks/use-abort-controller.d.ts +0 -2
- package/react/hooks/use-abort-controller.d.ts.map +0 -1
- package/react/hooks/use-abort-signal.d.ts +0 -2
- package/react/hooks/use-abort-signal.d.ts.map +0 -1
- package/react/hooks/use-click-outside.d.ts +0 -9
- package/react/hooks/use-click-outside.d.ts.map +0 -1
- package/react/hooks/use-constant.d.ts +0 -9
- package/react/hooks/use-constant.d.ts.map +0 -1
- package/react/hooks/use-define-ref.d.ts +0 -10
- package/react/hooks/use-define-ref.d.ts.map +0 -1
- package/react/hooks/use-element-ref.d.ts +0 -2
- package/react/hooks/use-element-ref.d.ts.map +0 -1
- package/react/hooks/use-event-listener.d.ts +0 -8
- package/react/hooks/use-event-listener.d.ts.map +0 -1
- package/react/hooks/use-event.d.ts +0 -3
- package/react/hooks/use-event.d.ts.map +0 -1
- package/react/hooks/use-flag.d.ts +0 -8
- package/react/hooks/use-flag.d.ts.map +0 -1
- package/react/hooks/use-force-update.d.ts +0 -2
- package/react/hooks/use-force-update.d.ts.map +0 -1
- package/react/hooks/use-initial-height.d.ts +0 -5
- package/react/hooks/use-initial-height.d.ts.map +0 -1
- package/react/hooks/use-instance.d.ts +0 -27
- package/react/hooks/use-instance.d.ts.map +0 -1
- package/react/hooks/use-intersection-observer.d.ts +0 -2
- package/react/hooks/use-intersection-observer.d.ts.map +0 -1
- package/react/hooks/use-last-defined-value.d.ts +0 -2
- package/react/hooks/use-last-defined-value.d.ts.map +0 -1
- package/react/hooks/use-last-value-ref.d.ts +0 -2
- package/react/hooks/use-last-value-ref.d.ts.map +0 -1
- package/react/hooks/use-life-cycle.d.ts +0 -5
- package/react/hooks/use-life-cycle.d.ts.map +0 -1
- package/react/hooks/use-resize-observer.d.ts +0 -2
- package/react/hooks/use-resize-observer.d.ts.map +0 -1
- package/react/hooks/use-sync-ref.d.ts +0 -2
- package/react/hooks/use-sync-ref.d.ts.map +0 -1
- package/react/hooks/use-toggle.d.ts +0 -2
- package/react/hooks/use-toggle.d.ts.map +0 -1
- package/react/hooks/use-value.d.ts +0 -5
- package/react/hooks/use-value.d.ts.map +0 -1
- package/react/hooks/use-visibility-state.d.ts +0 -2
- package/react/hooks/use-visibility-state.d.ts.map +0 -1
- package/react/index.d.ts +0 -2
- package/react/index.d.ts.map +0 -1
- package/sound.d.ts.map +0 -1
- package/storage.d.ts +0 -39
- package/storage.d.ts.map +0 -1
- package/text.d.ts.map +0 -1
- package/type-guard/_exports.d.ts +0 -86
- package/type-guard/_exports.d.ts.map +0 -1
- package/type-guard/index.d.ts +0 -3
- package/type-guard/index.d.ts.map +0 -1
- package/utility-types.cjs +0 -2
- package/utility-types.cjs.map +0 -1
- package/utility-types.d.ts.map +0 -1
- package/utility-types.js +0 -2
- package/utility-types.js.map +0 -1
- package/utils/types.d.ts.map +0 -1
- package/vibrate.d.ts.map +0 -1
- /package/{utils/types.cjs → types.cjs} +0 -0
- /package/{utils/types.cjs.map → types.cjs.map} +0 -0
- /package/{utils/types.js → types.js} +0 -0
- /package/{utils/types.js.map → types.js.map} +0 -0
package/cookie.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookie.js","sources":["../src/cookie.ts"],"sourcesContent":["import type { AnyObject } from 'yummies/
|
|
1
|
+
{"version":3,"file":"cookie.js","sources":["../src/cookie.ts"],"sourcesContent":["import type { AnyObject } from 'yummies/types';\n\nexport const parseCookie = (cookiesString = document.cookie) => {\n return cookiesString\n .split(';')\n .map((cookieString) => cookieString.trim().split('='))\n .reduce<AnyObject>((acc, current) => {\n acc[current[0]] = current[1];\n return acc;\n }, {});\n};\n"],"names":[],"mappings":"AAEO,MAAM,cAAc,CAAC,gBAAgB,SAAS,WAAW;AAC9D,SAAO,cACJ,MAAM,GAAG,EACT,IAAI,CAAC,iBAAiB,aAAa,KAAA,EAAO,MAAM,GAAG,CAAC,EACpD,OAAkB,CAAC,KAAK,YAAY;AACnC,QAAI,QAAQ,CAAC,CAAC,IAAI,QAAQ,CAAC;AAC3B,WAAO;AAAA,EACT,GAAG,CAAA,CAAE;AACT;"}
|
package/css.cjs
CHANGED
|
@@ -1,2 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const classVarianceAuthority = require("class-variance-authority");
|
|
4
|
+
const clsx = require("clsx");
|
|
5
|
+
const tailwindMerge = require("tailwind-merge");
|
|
6
|
+
const toRem = (px, remValue = 16) => `${px / remValue}rem`;
|
|
7
|
+
const cx = (...args) => tailwindMerge.twMerge(clsx(...args));
|
|
8
|
+
const cva = (...args) => {
|
|
9
|
+
const schema = classVarianceAuthority.cva(...args);
|
|
10
|
+
return (...inputArgs) => tailwindMerge.twMerge(schema(...inputArgs));
|
|
11
|
+
};
|
|
12
|
+
const loadCssFile = (url, attrubutes) => new Promise((resolve, reject) => {
|
|
13
|
+
let link;
|
|
14
|
+
if (attrubutes?.id) {
|
|
15
|
+
link = document.getElementById(attrubutes.id);
|
|
16
|
+
if (link) {
|
|
17
|
+
link.remove();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
link = document.createElement("link");
|
|
21
|
+
const handleLoad = () => {
|
|
22
|
+
resolve(void 0);
|
|
23
|
+
link.removeEventListener("load", handleLoad);
|
|
24
|
+
link.removeEventListener("error", handleError);
|
|
25
|
+
};
|
|
26
|
+
const handleError = () => {
|
|
27
|
+
reject(void 0);
|
|
28
|
+
link.removeEventListener("load", handleLoad);
|
|
29
|
+
link.removeEventListener("error", handleError);
|
|
30
|
+
};
|
|
31
|
+
link.addEventListener("load", handleLoad);
|
|
32
|
+
link.addEventListener("error", handleError);
|
|
33
|
+
link.setAttribute("href", url);
|
|
34
|
+
if (!attrubutes?.rel) {
|
|
35
|
+
link.setAttribute("rel", "stylesheet");
|
|
36
|
+
}
|
|
37
|
+
Object.entries(attrubutes || {}).forEach(([key, value]) => {
|
|
38
|
+
link.setAttribute(key, value);
|
|
39
|
+
});
|
|
40
|
+
document.head.appendChild(link);
|
|
41
|
+
});
|
|
42
|
+
exports.cva = cva;
|
|
43
|
+
exports.cx = cx;
|
|
44
|
+
exports.loadCssFile = loadCssFile;
|
|
45
|
+
exports.toRem = toRem;
|
|
2
46
|
//# sourceMappingURL=css.cjs.map
|
package/css.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css.cjs","sources":["../src/css.ts"],"sourcesContent":["import { cva as cvaLib } from 'class-variance-authority';\nimport clsx, { type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\nimport type { Maybe } from 'yummies/
|
|
1
|
+
{"version":3,"file":"css.cjs","sources":["../src/css.ts"],"sourcesContent":["import { cva as cvaLib } from 'class-variance-authority';\nimport clsx, { type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\nimport type { Maybe } from 'yummies/types';\n\ntype ClassProp = {\n class?: ClassValue;\n className?: ClassValue;\n};\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;\n\n/**\n * Перевод значения в пикселях в rem строковое\n */\nexport const toRem = (px: number, remValue = 16) => `${px / remValue}rem`;\n\n/**\n * classNames/clsx но с примесями tailwind-merge\n */\nexport const cx = (...args: Parameters<typeof clsx>) => twMerge(clsx(...args));\n\ntype ConfigSchema = Record<string, Record<string, ClassValue>>;\ntype ConfigVariants<T extends ConfigSchema> = {\n [Variant in keyof T]?: StringToBoolean<keyof T[Variant]> | null | undefined;\n};\ntype ConfigVariantsMulti<T extends ConfigSchema> = {\n [Variant in keyof T]?:\n | StringToBoolean<keyof T[Variant]>\n | StringToBoolean<keyof T[Variant]>[]\n | undefined;\n};\ntype Config<T> = T extends ConfigSchema\n ? {\n variants?: T;\n defaultVariants?: ConfigVariants<T>;\n compoundVariants?: (T extends ConfigSchema\n ? (ConfigVariants<T> | ConfigVariantsMulti<T>) & ClassProp\n : ClassProp)[];\n }\n : never;\n\ntype Props<T> = T extends ConfigSchema\n ? ConfigVariants<T> & ClassProp\n : ClassProp;\n\n/**\n * Class Variance Authority но с примесями tailwind-merge\n *\n * https://cva.style/docs\n */\nexport const cva = ((...args: any[]) => {\n const schema = cvaLib(...args);\n return (...inputArgs: any[]) => twMerge(schema(...inputArgs));\n}) as any as <T>(\n base?: ClassValue,\n config?: Config<T>,\n) => (props?: Props<T>) => string;\n\nexport type { VariantProps } from 'class-variance-authority';\nexport type { ClassValue } from 'clsx';\n\n/**\n * Load CSS file by providing `url`.\n *\n * **NOTE:** If `id` is provided, it will remove the existing link element with the same `id` before creating a new one.\n */\nexport const loadCssFile = (url: string, attrubutes?: Record<string, any>) =>\n new Promise((resolve, reject) => {\n let link: Maybe<HTMLLinkElement>;\n\n if (attrubutes?.id) {\n link = document.getElementById(attrubutes.id) as HTMLLinkElement | null;\n\n if (link) {\n link.remove();\n }\n }\n\n link = document.createElement('link');\n\n const handleLoad = () => {\n resolve(undefined);\n link!.removeEventListener('load', handleLoad);\n link!.removeEventListener('error', handleError);\n };\n\n const handleError = () => {\n reject(undefined);\n link!.removeEventListener('load', handleLoad);\n link!.removeEventListener('error', handleError);\n };\n\n link.addEventListener('load', handleLoad);\n link.addEventListener('error', handleError);\n\n link.setAttribute('href', url);\n\n if (!attrubutes?.rel) {\n link.setAttribute('rel', 'stylesheet');\n }\n\n Object.entries(attrubutes || {}).forEach(([key, value]) => {\n link.setAttribute(key, value);\n });\n\n document.head.appendChild(link);\n });\n"],"names":["twMerge","cvaLib"],"mappings":";;;;;AAeO,MAAM,QAAQ,CAAC,IAAY,WAAW,OAAO,GAAG,KAAK,QAAQ;AAK7D,MAAM,KAAK,IAAI,SAAkCA,cAAAA,QAAQ,KAAK,GAAG,IAAI,CAAC;AA+BtE,MAAM,MAAO,IAAI,SAAgB;AACtC,QAAM,SAASC,2BAAO,GAAG,IAAI;AAC7B,SAAO,IAAI,cAAqBD,cAAAA,QAAQ,OAAO,GAAG,SAAS,CAAC;AAC9D;AAaO,MAAM,cAAc,CAAC,KAAa,eACvC,IAAI,QAAQ,CAAC,SAAS,WAAW;AAC/B,MAAI;AAEJ,MAAI,YAAY,IAAI;AAClB,WAAO,SAAS,eAAe,WAAW,EAAE;AAE5C,QAAI,MAAM;AACR,WAAK,OAAA;AAAA,IACP;AAAA,EACF;AAEA,SAAO,SAAS,cAAc,MAAM;AAEpC,QAAM,aAAa,MAAM;AACvB,YAAQ,MAAS;AACjB,SAAM,oBAAoB,QAAQ,UAAU;AAC5C,SAAM,oBAAoB,SAAS,WAAW;AAAA,EAChD;AAEA,QAAM,cAAc,MAAM;AACxB,WAAO,MAAS;AAChB,SAAM,oBAAoB,QAAQ,UAAU;AAC5C,SAAM,oBAAoB,SAAS,WAAW;AAAA,EAChD;AAEA,OAAK,iBAAiB,QAAQ,UAAU;AACxC,OAAK,iBAAiB,SAAS,WAAW;AAE1C,OAAK,aAAa,QAAQ,GAAG;AAE7B,MAAI,CAAC,YAAY,KAAK;AACpB,SAAK,aAAa,OAAO,YAAY;AAAA,EACvC;AAEA,SAAO,QAAQ,cAAc,CAAA,CAAE,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AACzD,SAAK,aAAa,KAAK,KAAK;AAAA,EAC9B,CAAC;AAED,WAAS,KAAK,YAAY,IAAI;AAChC,CAAC;;;;;"}
|
package/css.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import clsx, { ClassValue } from 'clsx';
|
|
2
|
+
export { ClassValue } from 'clsx';
|
|
3
|
+
export { VariantProps } from 'class-variance-authority';
|
|
4
|
+
|
|
2
5
|
type ClassProp = {
|
|
3
6
|
class?: ClassValue;
|
|
4
7
|
className?: ClassValue;
|
|
@@ -7,11 +10,11 @@ type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
|
|
|
7
10
|
/**
|
|
8
11
|
* Перевод значения в пикселях в rem строковое
|
|
9
12
|
*/
|
|
10
|
-
|
|
13
|
+
declare const toRem: (px: number, remValue?: number) => string;
|
|
11
14
|
/**
|
|
12
15
|
* classNames/clsx но с примесями tailwind-merge
|
|
13
16
|
*/
|
|
14
|
-
|
|
17
|
+
declare const cx: (...args: Parameters<typeof clsx>) => string;
|
|
15
18
|
type ConfigSchema = Record<string, Record<string, ClassValue>>;
|
|
16
19
|
type ConfigVariants<T extends ConfigSchema> = {
|
|
17
20
|
[Variant in keyof T]?: StringToBoolean<keyof T[Variant]> | null | undefined;
|
|
@@ -30,13 +33,13 @@ type Props<T> = T extends ConfigSchema ? ConfigVariants<T> & ClassProp : ClassPr
|
|
|
30
33
|
*
|
|
31
34
|
* https://cva.style/docs
|
|
32
35
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export type { ClassValue } from 'clsx';
|
|
36
|
+
declare const cva: <T>(base?: ClassValue, config?: Config<T>) => (props?: Props<T>) => string;
|
|
37
|
+
|
|
36
38
|
/**
|
|
37
39
|
* Load CSS file by providing `url`.
|
|
38
40
|
*
|
|
39
41
|
* **NOTE:** If `id` is provided, it will remove the existing link element with the same `id` before creating a new one.
|
|
40
42
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
declare const loadCssFile: (url: string, attrubutes?: Record<string, any>) => Promise<unknown>;
|
|
44
|
+
|
|
45
|
+
export { cva, cx, loadCssFile, toRem };
|
package/css.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css.js","sources":["../src/css.ts"],"sourcesContent":["import { cva as cvaLib } from 'class-variance-authority';\nimport clsx, { type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\nimport type { Maybe } from 'yummies/
|
|
1
|
+
{"version":3,"file":"css.js","sources":["../src/css.ts"],"sourcesContent":["import { cva as cvaLib } from 'class-variance-authority';\nimport clsx, { type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\nimport type { Maybe } from 'yummies/types';\n\ntype ClassProp = {\n class?: ClassValue;\n className?: ClassValue;\n};\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;\n\n/**\n * Перевод значения в пикселях в rem строковое\n */\nexport const toRem = (px: number, remValue = 16) => `${px / remValue}rem`;\n\n/**\n * classNames/clsx но с примесями tailwind-merge\n */\nexport const cx = (...args: Parameters<typeof clsx>) => twMerge(clsx(...args));\n\ntype ConfigSchema = Record<string, Record<string, ClassValue>>;\ntype ConfigVariants<T extends ConfigSchema> = {\n [Variant in keyof T]?: StringToBoolean<keyof T[Variant]> | null | undefined;\n};\ntype ConfigVariantsMulti<T extends ConfigSchema> = {\n [Variant in keyof T]?:\n | StringToBoolean<keyof T[Variant]>\n | StringToBoolean<keyof T[Variant]>[]\n | undefined;\n};\ntype Config<T> = T extends ConfigSchema\n ? {\n variants?: T;\n defaultVariants?: ConfigVariants<T>;\n compoundVariants?: (T extends ConfigSchema\n ? (ConfigVariants<T> | ConfigVariantsMulti<T>) & ClassProp\n : ClassProp)[];\n }\n : never;\n\ntype Props<T> = T extends ConfigSchema\n ? ConfigVariants<T> & ClassProp\n : ClassProp;\n\n/**\n * Class Variance Authority но с примесями tailwind-merge\n *\n * https://cva.style/docs\n */\nexport const cva = ((...args: any[]) => {\n const schema = cvaLib(...args);\n return (...inputArgs: any[]) => twMerge(schema(...inputArgs));\n}) as any as <T>(\n base?: ClassValue,\n config?: Config<T>,\n) => (props?: Props<T>) => string;\n\nexport type { VariantProps } from 'class-variance-authority';\nexport type { ClassValue } from 'clsx';\n\n/**\n * Load CSS file by providing `url`.\n *\n * **NOTE:** If `id` is provided, it will remove the existing link element with the same `id` before creating a new one.\n */\nexport const loadCssFile = (url: string, attrubutes?: Record<string, any>) =>\n new Promise((resolve, reject) => {\n let link: Maybe<HTMLLinkElement>;\n\n if (attrubutes?.id) {\n link = document.getElementById(attrubutes.id) as HTMLLinkElement | null;\n\n if (link) {\n link.remove();\n }\n }\n\n link = document.createElement('link');\n\n const handleLoad = () => {\n resolve(undefined);\n link!.removeEventListener('load', handleLoad);\n link!.removeEventListener('error', handleError);\n };\n\n const handleError = () => {\n reject(undefined);\n link!.removeEventListener('load', handleLoad);\n link!.removeEventListener('error', handleError);\n };\n\n link.addEventListener('load', handleLoad);\n link.addEventListener('error', handleError);\n\n link.setAttribute('href', url);\n\n if (!attrubutes?.rel) {\n link.setAttribute('rel', 'stylesheet');\n }\n\n Object.entries(attrubutes || {}).forEach(([key, value]) => {\n link.setAttribute(key, value);\n });\n\n document.head.appendChild(link);\n });\n"],"names":["cvaLib"],"mappings":";;;AAeO,MAAM,QAAQ,CAAC,IAAY,WAAW,OAAO,GAAG,KAAK,QAAQ;AAK7D,MAAM,KAAK,IAAI,SAAkC,QAAQ,KAAK,GAAG,IAAI,CAAC;AA+BtE,MAAM,MAAO,IAAI,SAAgB;AACtC,QAAM,SAASA,MAAO,GAAG,IAAI;AAC7B,SAAO,IAAI,cAAqB,QAAQ,OAAO,GAAG,SAAS,CAAC;AAC9D;AAaO,MAAM,cAAc,CAAC,KAAa,eACvC,IAAI,QAAQ,CAAC,SAAS,WAAW;AAC/B,MAAI;AAEJ,MAAI,YAAY,IAAI;AAClB,WAAO,SAAS,eAAe,WAAW,EAAE;AAE5C,QAAI,MAAM;AACR,WAAK,OAAA;AAAA,IACP;AAAA,EACF;AAEA,SAAO,SAAS,cAAc,MAAM;AAEpC,QAAM,aAAa,MAAM;AACvB,YAAQ,MAAS;AACjB,SAAM,oBAAoB,QAAQ,UAAU;AAC5C,SAAM,oBAAoB,SAAS,WAAW;AAAA,EAChD;AAEA,QAAM,cAAc,MAAM;AACxB,WAAO,MAAS;AAChB,SAAM,oBAAoB,QAAQ,UAAU;AAC5C,SAAM,oBAAoB,SAAS,WAAW;AAAA,EAChD;AAEA,OAAK,iBAAiB,QAAQ,UAAU;AACxC,OAAK,iBAAiB,SAAS,WAAW;AAE1C,OAAK,aAAa,QAAQ,GAAG;AAE7B,MAAI,CAAC,YAAY,KAAK;AACpB,SAAK,aAAa,OAAO,YAAY;AAAA,EACvC;AAEA,SAAO,QAAQ,cAAc,CAAA,CAAE,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AACzD,SAAK,aAAa,KAAK,KAAK;AAAA,EAC9B,CAAC;AAED,WAAS,KAAK,YAAY,IAAI;AAChC,CAAC;"}
|
package/data.cjs
CHANGED
|
@@ -1,2 +1,44 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const isShallowEqual = (a, b) => {
|
|
4
|
+
if (a === b) return true;
|
|
5
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
if (a.constructor !== b.constructor) return false;
|
|
9
|
+
const isArrayA = Array.isArray(a);
|
|
10
|
+
if (isArrayA !== Array.isArray(b)) return false;
|
|
11
|
+
if (isArrayA) {
|
|
12
|
+
const arrA = a;
|
|
13
|
+
const arrB = b;
|
|
14
|
+
if (arrA.length !== arrB.length) return false;
|
|
15
|
+
for (const [i, element] of arrA.entries()) {
|
|
16
|
+
if (element !== arrB[i]) return false;
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
if (a instanceof Date) return a.getTime() === b.getTime();
|
|
21
|
+
if (a instanceof RegExp) return a.toString() === b.toString();
|
|
22
|
+
const aKeys = Object.keys(a);
|
|
23
|
+
const bKeys = Object.keys(b);
|
|
24
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
25
|
+
const bObj = b;
|
|
26
|
+
for (const key of aKeys) {
|
|
27
|
+
if (!Object.hasOwn(bObj, key) || a[key] !== bObj[key]) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
};
|
|
33
|
+
const flatMapDeep = (arr, fn) => Array.isArray(arr) ? arr.flatMap((c) => flatMapDeep(c, fn)) : [fn(arr, 0, [arr])];
|
|
34
|
+
const safeJsonParse = (json) => {
|
|
35
|
+
try {
|
|
36
|
+
return JSON.parse(json);
|
|
37
|
+
} catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.flatMapDeep = flatMapDeep;
|
|
42
|
+
exports.isShallowEqual = isShallowEqual;
|
|
43
|
+
exports.safeJsonParse = safeJsonParse;
|
|
2
44
|
//# sourceMappingURL=data.cjs.map
|
package/data.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.cjs","sources":["../src/data.ts"],"sourcesContent":["import type { AnyObject } from 'yummies/
|
|
1
|
+
{"version":3,"file":"data.cjs","sources":["../src/data.ts"],"sourcesContent":["import type { AnyObject } from 'yummies/types';\n\nexport const isShallowEqual = (a: unknown, b: unknown): boolean => {\n if (a === b) return true;\n\n if (\n typeof a !== 'object' ||\n typeof b !== 'object' ||\n a === null ||\n b === null\n ) {\n return false;\n }\n\n if (a.constructor !== b.constructor) return false;\n\n const isArrayA = Array.isArray(a);\n\n if (isArrayA !== Array.isArray(b)) return false;\n\n if (isArrayA) {\n const arrA = a as unknown[];\n const arrB = b as unknown[];\n if (arrA.length !== arrB.length) return false;\n\n for (const [i, element] of arrA.entries()) {\n if (element !== arrB[i]) return false;\n }\n return true;\n }\n\n if (a instanceof Date) return a.getTime() === (b as Date).getTime();\n\n if (a instanceof RegExp) return a.toString() === (b as RegExp).toString();\n\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n\n if (aKeys.length !== bKeys.length) return false;\n\n const bObj = b as AnyObject;\n for (const key of aKeys) {\n if (!Object.hasOwn(bObj, key) || (a as AnyObject)[key] !== bObj[key]) {\n return false;\n }\n }\n\n return true;\n};\n\nexport const flatMapDeep = <TSource, TNewValue>(\n arr: TSource | TSource[],\n fn: (value: TSource, i: number, arr: TSource[]) => TNewValue,\n): TNewValue[] =>\n Array.isArray(arr)\n ? arr.flatMap((c: TSource): TNewValue[] => flatMapDeep(c, fn))\n : [fn(arr, 0, [arr])];\n\nexport const safeJsonParse = (json: string) => {\n try {\n return JSON.parse(json);\n } catch {\n return null;\n }\n};\n"],"names":[],"mappings":";;AAEO,MAAM,iBAAiB,CAAC,GAAY,MAAwB;AACjE,MAAI,MAAM,EAAG,QAAO;AAEpB,MACE,OAAO,MAAM,YACb,OAAO,MAAM,YACb,MAAM,QACN,MAAM,MACN;AACA,WAAO;AAAA,EACT;AAEA,MAAI,EAAE,gBAAgB,EAAE,YAAa,QAAO;AAE5C,QAAM,WAAW,MAAM,QAAQ,CAAC;AAEhC,MAAI,aAAa,MAAM,QAAQ,CAAC,EAAG,QAAO;AAE1C,MAAI,UAAU;AACZ,UAAM,OAAO;AACb,UAAM,OAAO;AACb,QAAI,KAAK,WAAW,KAAK,OAAQ,QAAO;AAExC,eAAW,CAAC,GAAG,OAAO,KAAK,KAAK,WAAW;AACzC,UAAI,YAAY,KAAK,CAAC,EAAG,QAAO;AAAA,IAClC;AACA,WAAO;AAAA,EACT;AAEA,MAAI,aAAa,KAAM,QAAO,EAAE,QAAA,MAAe,EAAW,QAAA;AAE1D,MAAI,aAAa,OAAQ,QAAO,EAAE,SAAA,MAAgB,EAAa,SAAA;AAE/D,QAAM,QAAQ,OAAO,KAAK,CAAC;AAC3B,QAAM,QAAQ,OAAO,KAAK,CAAC;AAE3B,MAAI,MAAM,WAAW,MAAM,OAAQ,QAAO;AAE1C,QAAM,OAAO;AACb,aAAW,OAAO,OAAO;AACvB,QAAI,CAAC,OAAO,OAAO,MAAM,GAAG,KAAM,EAAgB,GAAG,MAAM,KAAK,GAAG,GAAG;AACpE,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;AAEO,MAAM,cAAc,CACzB,KACA,OAEA,MAAM,QAAQ,GAAG,IACb,IAAI,QAAQ,CAAC,MAA4B,YAAY,GAAG,EAAE,CAAC,IAC3D,CAAC,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjB,MAAM,gBAAgB,CAAC,SAAiB;AAC7C,MAAI;AACF,WAAO,KAAK,MAAM,IAAI;AAAA,EACxB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;;;;"}
|
package/data.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
declare const isShallowEqual: (a: unknown, b: unknown) => boolean;
|
|
2
|
+
declare const flatMapDeep: <TSource, TNewValue>(arr: TSource | TSource[], fn: (value: TSource, i: number, arr: TSource[]) => TNewValue) => TNewValue[];
|
|
3
|
+
declare const safeJsonParse: (json: string) => any;
|
|
4
|
+
|
|
5
|
+
export { flatMapDeep, isShallowEqual, safeJsonParse };
|
package/data.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.js","sources":["../src/data.ts"],"sourcesContent":["import type { AnyObject } from 'yummies/
|
|
1
|
+
{"version":3,"file":"data.js","sources":["../src/data.ts"],"sourcesContent":["import type { AnyObject } from 'yummies/types';\n\nexport const isShallowEqual = (a: unknown, b: unknown): boolean => {\n if (a === b) return true;\n\n if (\n typeof a !== 'object' ||\n typeof b !== 'object' ||\n a === null ||\n b === null\n ) {\n return false;\n }\n\n if (a.constructor !== b.constructor) return false;\n\n const isArrayA = Array.isArray(a);\n\n if (isArrayA !== Array.isArray(b)) return false;\n\n if (isArrayA) {\n const arrA = a as unknown[];\n const arrB = b as unknown[];\n if (arrA.length !== arrB.length) return false;\n\n for (const [i, element] of arrA.entries()) {\n if (element !== arrB[i]) return false;\n }\n return true;\n }\n\n if (a instanceof Date) return a.getTime() === (b as Date).getTime();\n\n if (a instanceof RegExp) return a.toString() === (b as RegExp).toString();\n\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n\n if (aKeys.length !== bKeys.length) return false;\n\n const bObj = b as AnyObject;\n for (const key of aKeys) {\n if (!Object.hasOwn(bObj, key) || (a as AnyObject)[key] !== bObj[key]) {\n return false;\n }\n }\n\n return true;\n};\n\nexport const flatMapDeep = <TSource, TNewValue>(\n arr: TSource | TSource[],\n fn: (value: TSource, i: number, arr: TSource[]) => TNewValue,\n): TNewValue[] =>\n Array.isArray(arr)\n ? arr.flatMap((c: TSource): TNewValue[] => flatMapDeep(c, fn))\n : [fn(arr, 0, [arr])];\n\nexport const safeJsonParse = (json: string) => {\n try {\n return JSON.parse(json);\n } catch {\n return null;\n }\n};\n"],"names":[],"mappings":"AAEO,MAAM,iBAAiB,CAAC,GAAY,MAAwB;AACjE,MAAI,MAAM,EAAG,QAAO;AAEpB,MACE,OAAO,MAAM,YACb,OAAO,MAAM,YACb,MAAM,QACN,MAAM,MACN;AACA,WAAO;AAAA,EACT;AAEA,MAAI,EAAE,gBAAgB,EAAE,YAAa,QAAO;AAE5C,QAAM,WAAW,MAAM,QAAQ,CAAC;AAEhC,MAAI,aAAa,MAAM,QAAQ,CAAC,EAAG,QAAO;AAE1C,MAAI,UAAU;AACZ,UAAM,OAAO;AACb,UAAM,OAAO;AACb,QAAI,KAAK,WAAW,KAAK,OAAQ,QAAO;AAExC,eAAW,CAAC,GAAG,OAAO,KAAK,KAAK,WAAW;AACzC,UAAI,YAAY,KAAK,CAAC,EAAG,QAAO;AAAA,IAClC;AACA,WAAO;AAAA,EACT;AAEA,MAAI,aAAa,KAAM,QAAO,EAAE,QAAA,MAAe,EAAW,QAAA;AAE1D,MAAI,aAAa,OAAQ,QAAO,EAAE,SAAA,MAAgB,EAAa,SAAA;AAE/D,QAAM,QAAQ,OAAO,KAAK,CAAC;AAC3B,QAAM,QAAQ,OAAO,KAAK,CAAC;AAE3B,MAAI,MAAM,WAAW,MAAM,OAAQ,QAAO;AAE1C,QAAM,OAAO;AACb,aAAW,OAAO,OAAO;AACvB,QAAI,CAAC,OAAO,OAAO,MAAM,GAAG,KAAM,EAAgB,GAAG,MAAM,KAAK,GAAG,GAAG;AACpE,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;AAEO,MAAM,cAAc,CACzB,KACA,OAEA,MAAM,QAAQ,GAAG,IACb,IAAI,QAAQ,CAAC,MAA4B,YAAY,GAAG,EAAE,CAAC,IAC3D,CAAC,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjB,MAAM,gBAAgB,CAAC,SAAiB;AAC7C,MAAI;AACF,WAAO,KAAK,MAAM,IAAI;AAAA,EACxB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;"}
|