@glob-ui/utils 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +18 -2
- package/dist/index.d.mts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +33 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +62 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kevin Martínez E
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @glob-ui/utils
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Joins class names and merges Tailwind classes, so the last conflicting class wins. It knows the GlobUI radius and shadow scales.
|
|
4
|
+
|
|
5
|
+
> **Internal API.** This package is used by the other GlobUI packages. Its exports can change in any release, so depend on the component packages instead.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @glob-ui/utils
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Documentation
|
|
14
|
+
|
|
15
|
+
Full docs, examples and the accessibility table: [cn()](https://github.com/kevin-martineze/GlobUI/tree/main/apps/docs/content/docs/utilities/cn.mdx).
|
|
16
|
+
|
|
17
|
+
## License
|
|
18
|
+
|
|
19
|
+
MIT. See [LICENSE](./LICENSE).
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ClassValue } from 'clsx';
|
|
2
|
+
|
|
3
|
+
/** Lowercase, without accents or diacritics, trimmed, with runs of spaces collapsed. */
|
|
4
|
+
declare function normalizeText(text: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* True when every word of the query appears in the texts (in any order, ignoring case and accents).
|
|
7
|
+
* An empty query matches everything.
|
|
8
|
+
*/
|
|
9
|
+
declare function matchesSearch(query: string, ...texts: string[]): boolean;
|
|
10
|
+
|
|
11
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
12
|
+
|
|
13
|
+
export { cn, matchesSearch, normalizeText };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ClassValue } from 'clsx';
|
|
2
|
+
|
|
3
|
+
/** Lowercase, without accents or diacritics, trimmed, with runs of spaces collapsed. */
|
|
4
|
+
declare function normalizeText(text: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* True when every word of the query appears in the texts (in any order, ignoring case and accents).
|
|
7
|
+
* An empty query matches everything.
|
|
8
|
+
*/
|
|
9
|
+
declare function matchesSearch(query: string, ...texts: string[]): boolean;
|
|
10
|
+
|
|
11
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
12
|
+
|
|
13
|
+
export { cn, matchesSearch, normalizeText };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
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 index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
cn: () => cn,
|
|
24
|
+
matchesSearch: () => matchesSearch,
|
|
25
|
+
normalizeText: () => normalizeText
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
var import_clsx = require("clsx");
|
|
29
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
30
|
+
|
|
31
|
+
// src/text.ts
|
|
32
|
+
function normalizeText(text) {
|
|
33
|
+
return text.normalize("NFD").replace(new RegExp("\\p{Diacritic}", "gu"), "").toLowerCase().trim().replace(/\s+/g, " ");
|
|
34
|
+
}
|
|
35
|
+
function matchesSearch(query, ...texts) {
|
|
36
|
+
const words = normalizeText(query).split(" ").filter(Boolean);
|
|
37
|
+
if (words.length === 0) return true;
|
|
38
|
+
const haystack = normalizeText(texts.join(" "));
|
|
39
|
+
return words.every((word) => haystack.includes(word));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// src/index.ts
|
|
43
|
+
var twMerge = (0, import_tailwind_merge.extendTailwindMerge)({
|
|
44
|
+
extend: {
|
|
45
|
+
theme: {
|
|
46
|
+
radius: ["glob-sm", "glob-md", "glob-lg"],
|
|
47
|
+
shadow: ["glob-sm", "glob-md"]
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
function cn(...inputs) {
|
|
52
|
+
return twMerge((0, import_clsx.clsx)(inputs));
|
|
53
|
+
}
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
cn,
|
|
57
|
+
matchesSearch,
|
|
58
|
+
normalizeText
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/text.ts"],"sourcesContent":["import { clsx, type ClassValue } from \"clsx\"\nimport { extendTailwindMerge } from \"tailwind-merge\"\n\n// tailwind-merge only knows the default radius/shadow scales. Without this, \"rounded-glob-md\"\n// and a consumer's \"rounded-full\" both survive and the token class can win.\nconst twMerge = extendTailwindMerge({\n extend: {\n theme: {\n radius: [\"glob-sm\", \"glob-md\", \"glob-lg\"],\n shadow: [\"glob-sm\", \"glob-md\"],\n },\n },\n})\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\nexport { normalizeText, matchesSearch } from \"./text\"\n","/** Lowercase, without accents or diacritics, trimmed, with runs of spaces collapsed. */\nexport function normalizeText(text: string) {\n return text\n .normalize(\"NFD\")\n .replace(/\\p{Diacritic}/gu, \"\")\n .toLowerCase()\n .trim()\n .replace(/\\s+/g, \" \")\n}\n\n/**\n * True when every word of the query appears in the texts (in any order, ignoring case and accents).\n * An empty query matches everything.\n */\nexport function matchesSearch(query: string, ...texts: string[]) {\n const words = normalizeText(query).split(\" \").filter(Boolean)\n if (words.length === 0) return true\n const haystack = normalizeText(texts.join(\" \"))\n return words.every((word) => haystack.includes(word))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAsC;AACtC,4BAAoC;;;ACA7B,SAAS,cAAc,MAAc;AAC1C,SAAO,KACJ,UAAU,KAAK,EACf,QAAQ,WAAC,kBAAc,IAAE,GAAE,EAAE,EAC7B,YAAY,EACZ,KAAK,EACL,QAAQ,QAAQ,GAAG;AACxB;AAMO,SAAS,cAAc,UAAkB,OAAiB;AAC/D,QAAM,QAAQ,cAAc,KAAK,EAAE,MAAM,GAAG,EAAE,OAAO,OAAO;AAC5D,MAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,QAAM,WAAW,cAAc,MAAM,KAAK,GAAG,CAAC;AAC9C,SAAO,MAAM,MAAM,CAAC,SAAS,SAAS,SAAS,IAAI,CAAC;AACtD;;;ADdA,IAAM,cAAU,2CAAoB;AAAA,EAClC,QAAQ;AAAA,IACN,OAAO;AAAA,MACL,QAAQ,CAAC,WAAW,WAAW,SAAS;AAAA,MACxC,QAAQ,CAAC,WAAW,SAAS;AAAA,IAC/B;AAAA,EACF;AACF,CAAC;AAEM,SAAS,MAAM,QAAsB;AAC1C,SAAO,YAAQ,kBAAK,MAAM,CAAC;AAC7B;","names":[]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
|
+
import { extendTailwindMerge } from "tailwind-merge";
|
|
4
|
+
|
|
5
|
+
// src/text.ts
|
|
6
|
+
function normalizeText(text) {
|
|
7
|
+
return text.normalize("NFD").replace(new RegExp("\\p{Diacritic}", "gu"), "").toLowerCase().trim().replace(/\s+/g, " ");
|
|
8
|
+
}
|
|
9
|
+
function matchesSearch(query, ...texts) {
|
|
10
|
+
const words = normalizeText(query).split(" ").filter(Boolean);
|
|
11
|
+
if (words.length === 0) return true;
|
|
12
|
+
const haystack = normalizeText(texts.join(" "));
|
|
13
|
+
return words.every((word) => haystack.includes(word));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// src/index.ts
|
|
17
|
+
var twMerge = extendTailwindMerge({
|
|
18
|
+
extend: {
|
|
19
|
+
theme: {
|
|
20
|
+
radius: ["glob-sm", "glob-md", "glob-lg"],
|
|
21
|
+
shadow: ["glob-sm", "glob-md"]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
function cn(...inputs) {
|
|
26
|
+
return twMerge(clsx(inputs));
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
cn,
|
|
30
|
+
matchesSearch,
|
|
31
|
+
normalizeText
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/text.ts"],"sourcesContent":["import { clsx, type ClassValue } from \"clsx\"\nimport { extendTailwindMerge } from \"tailwind-merge\"\n\n// tailwind-merge only knows the default radius/shadow scales. Without this, \"rounded-glob-md\"\n// and a consumer's \"rounded-full\" both survive and the token class can win.\nconst twMerge = extendTailwindMerge({\n extend: {\n theme: {\n radius: [\"glob-sm\", \"glob-md\", \"glob-lg\"],\n shadow: [\"glob-sm\", \"glob-md\"],\n },\n },\n})\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\nexport { normalizeText, matchesSearch } from \"./text\"\n","/** Lowercase, without accents or diacritics, trimmed, with runs of spaces collapsed. */\nexport function normalizeText(text: string) {\n return text\n .normalize(\"NFD\")\n .replace(/\\p{Diacritic}/gu, \"\")\n .toLowerCase()\n .trim()\n .replace(/\\s+/g, \" \")\n}\n\n/**\n * True when every word of the query appears in the texts (in any order, ignoring case and accents).\n * An empty query matches everything.\n */\nexport function matchesSearch(query: string, ...texts: string[]) {\n const words = normalizeText(query).split(\" \").filter(Boolean)\n if (words.length === 0) return true\n const haystack = normalizeText(texts.join(\" \"))\n return words.every((word) => haystack.includes(word))\n}\n"],"mappings":";AAAA,SAAS,YAA6B;AACtC,SAAS,2BAA2B;;;ACA7B,SAAS,cAAc,MAAc;AAC1C,SAAO,KACJ,UAAU,KAAK,EACf,QAAQ,WAAC,kBAAc,IAAE,GAAE,EAAE,EAC7B,YAAY,EACZ,KAAK,EACL,QAAQ,QAAQ,GAAG;AACxB;AAMO,SAAS,cAAc,UAAkB,OAAiB;AAC/D,QAAM,QAAQ,cAAc,KAAK,EAAE,MAAM,GAAG,EAAE,OAAO,OAAO;AAC5D,MAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,QAAM,WAAW,cAAc,MAAM,KAAK,GAAG,CAAC;AAC9C,SAAO,MAAM,MAAM,CAAC,SAAS,SAAS,SAAS,IAAI,CAAC;AACtD;;;ADdA,IAAM,UAAU,oBAAoB;AAAA,EAClC,QAAQ;AAAA,IACN,OAAO;AAAA,MACL,QAAQ,CAAC,WAAW,WAAW,SAAS;AAAA,MACxC,QAAQ,CAAC,WAAW,SAAS;AAAA,IAC/B;AAAA,EACF;AACF,CAAC;AAEM,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glob-ui/utils",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"module": "./dist/index.mjs",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": {
|
|
10
|
+
"types": "./dist/index.d.mts",
|
|
11
|
+
"default": "./dist/index.mjs"
|
|
12
|
+
},
|
|
13
|
+
"require": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist/",
|
|
22
|
+
"LICENSE",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"clsx": "^2.1.1",
|
|
27
|
+
"tailwind-merge": "^3.6.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"tsup": "^8.5.1"
|
|
31
|
+
},
|
|
32
|
+
"description": "Joins class names and merges Tailwind classes, so the last conflicting class wins. It knows the GlobUI radius and shadow scales.",
|
|
33
|
+
"keywords": [
|
|
34
|
+
"react",
|
|
35
|
+
"glob-ui",
|
|
36
|
+
"components",
|
|
37
|
+
"accessible",
|
|
38
|
+
"tailwind",
|
|
39
|
+
"utils"
|
|
40
|
+
],
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"author": "Kevin Martínez E",
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "git+https://github.com/kevin-martineze/GlobUI.git",
|
|
46
|
+
"directory": "packages/utils"
|
|
47
|
+
},
|
|
48
|
+
"homepage": "https://github.com/kevin-martineze/GlobUI#readme",
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/kevin-martineze/GlobUI/issues"
|
|
51
|
+
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public",
|
|
54
|
+
"provenance": true
|
|
55
|
+
},
|
|
56
|
+
"sideEffects": false,
|
|
57
|
+
"type": "commonjs",
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=18.18"
|
|
60
|
+
},
|
|
61
|
+
"scripts": {
|
|
62
|
+
"build": "tsup",
|
|
63
|
+
"dev": "tsup --watch --no-clean"
|
|
64
|
+
}
|
|
6
65
|
}
|