@scalar/use-hooks 0.3.5 → 0.3.7
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/CHANGELOG.md +12 -0
- package/dist/useBindCx/cva.d.ts +1 -1
- package/dist/useBindCx/cva.js.map +1 -1
- package/dist/useClipboard/useClipboard.d.ts +1 -1
- package/dist/useClipboard/useClipboard.d.ts.map +1 -1
- package/dist/useClipboard/useClipboard.js +11 -1
- package/dist/useClipboard/useClipboard.js.map +2 -2
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @scalar/use-hooks
|
|
2
2
|
|
|
3
|
+
## 0.3.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#7977](https://github.com/scalar/scalar/pull/7977): chore(use-hooks): update tailwind merge to v3.4.0
|
|
8
|
+
|
|
9
|
+
## 0.3.6
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#7678](https://github.com/scalar/scalar/pull/7678): feat: added object stringification to useClipboard
|
|
14
|
+
|
|
3
15
|
## 0.3.5
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/useBindCx/cva.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* this is because it does not load in the tailwind config at runtime (perf reasons)
|
|
6
6
|
* we must specify any custom classes if they are getting overwritten
|
|
7
7
|
*
|
|
8
|
-
* https://github.com/dcastil/tailwind-merge/blob/
|
|
8
|
+
* https://github.com/dcastil/tailwind-merge/blob/v3.4.0/docs/configuration.md#class-groups
|
|
9
9
|
*/
|
|
10
10
|
declare const tw: (...classLists: import("tailwind-merge").ClassNameValue[]) => string;
|
|
11
11
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useBindCx/cva.ts"],
|
|
4
|
-
"sourcesContent": ["import { defineConfig } from 'cva'\nimport { extendTailwindMerge } from 'tailwind-merge'\n\n/**\n * Tailwind Merge Config\n *\n * By default tailwind merge only knows about the default tailwind classes\n * this is because it does not load in the tailwind config at runtime (perf reasons)\n * we must specify any custom classes if they are getting overwritten\n *\n * https://github.com/dcastil/tailwind-merge/blob/
|
|
4
|
+
"sourcesContent": ["import { defineConfig } from 'cva'\nimport { extendTailwindMerge } from 'tailwind-merge'\n\n/**\n * Tailwind Merge Config\n *\n * By default tailwind merge only knows about the default tailwind classes\n * this is because it does not load in the tailwind config at runtime (perf reasons)\n * we must specify any custom classes if they are getting overwritten\n *\n * https://github.com/dcastil/tailwind-merge/blob/v3.4.0/docs/configuration.md#class-groups\n */\nconst tw = extendTailwindMerge({\n extend: {\n classGroups: {\n 'font-size': ['text-3xs', 'text-xxs'],\n 'font-weight': ['font-sidebar', 'font-sidebar-active'],\n },\n },\n})\n\n/**\n * CVA Config\n *\n * https://beta.cva.style/api-reference/#defineconfig\n */\nconst { cva, cx, compose } = defineConfig({\n hooks: {\n onComplete: (className) => tw(className),\n },\n})\n\nexport { cva, cx, compose, tw }\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B;AAWpC,MAAM,KAAK,oBAAoB;AAAA,EAC7B,QAAQ;AAAA,IACN,aAAa;AAAA,MACX,aAAa,CAAC,YAAY,UAAU;AAAA,MACpC,eAAe,CAAC,gBAAgB,qBAAqB;AAAA,IACvD;AAAA,EACF;AACF,CAAC;AAOD,MAAM,EAAE,KAAK,IAAI,QAAQ,IAAI,aAAa;AAAA,EACxC,OAAO;AAAA,IACL,YAAY,CAAC,cAAc,GAAG,SAAS;AAAA,EACzC;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,6 +3,6 @@ import type { UseClipboardOptions } from './types.js';
|
|
|
3
3
|
* A hook for interacting with the clipboard
|
|
4
4
|
*/
|
|
5
5
|
export declare function useClipboard(opts?: UseClipboardOptions): {
|
|
6
|
-
copyToClipboard: (value:
|
|
6
|
+
copyToClipboard: (value: unknown) => Promise<void>;
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=useClipboard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useClipboard.d.ts","sourceRoot":"","sources":["../../src/useClipboard/useClipboard.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"useClipboard.d.ts","sourceRoot":"","sources":["../../src/useClipboard/useClipboard.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAalD;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,mBAAwB;6BAInB,OAAO;EAa9C"}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { useToasts } from "@scalar/use-toasts";
|
|
2
|
+
const serializeValue = (value) => {
|
|
3
|
+
if (value === void 0) {
|
|
4
|
+
return "undefined";
|
|
5
|
+
}
|
|
6
|
+
if (typeof value === "string") {
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
return JSON.stringify(value);
|
|
10
|
+
};
|
|
2
11
|
function useClipboard(opts = {}) {
|
|
3
12
|
const { notify = (m) => toast(m, "info") } = opts;
|
|
4
13
|
const { toast } = useToasts();
|
|
5
14
|
async function copyToClipboard(value) {
|
|
6
15
|
try {
|
|
7
|
-
|
|
16
|
+
const serialized = serializeValue(value);
|
|
17
|
+
await navigator.clipboard.writeText(serialized);
|
|
8
18
|
notify("Copied to the clipboard");
|
|
9
19
|
} catch (e) {
|
|
10
20
|
const error = e;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useClipboard/useClipboard.ts"],
|
|
4
|
-
"sourcesContent": ["import { useToasts } from '@scalar/use-toasts'\n\nimport type { UseClipboardOptions } from './types'\n\n/**\n * A hook for interacting with the clipboard\n */\nexport function useClipboard(opts: UseClipboardOptions = {}) {\n const { notify = (m) => toast(m, 'info') } = opts\n const { toast } = useToasts()\n\n async function copyToClipboard(value:
|
|
5
|
-
"mappings": "AAAA,SAAS,iBAAiB;
|
|
4
|
+
"sourcesContent": ["import { useToasts } from '@scalar/use-toasts'\n\nimport type { UseClipboardOptions } from './types'\n\n/** Safely serialize a value to a string */\nconst serializeValue = (value: unknown) => {\n if (value === undefined) {\n return 'undefined'\n }\n if (typeof value === 'string') {\n return value\n }\n return JSON.stringify(value)\n}\n\n/**\n * A hook for interacting with the clipboard\n */\nexport function useClipboard(opts: UseClipboardOptions = {}) {\n const { notify = (m) => toast(m, 'info') } = opts\n const { toast } = useToasts()\n\n async function copyToClipboard(value: unknown) {\n try {\n const serialized = serializeValue(value)\n await navigator.clipboard.writeText(serialized)\n notify('Copied to the clipboard')\n } catch (e) {\n const error = e as Error\n console.error(error.message)\n notify('Failed to copy to clipboard')\n }\n }\n\n return { copyToClipboard }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAK1B,MAAM,iBAAiB,CAAC,UAAmB;AACzC,MAAI,UAAU,QAAW;AACvB,WAAO;AAAA,EACT;AACA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,SAAO,KAAK,UAAU,KAAK;AAC7B;AAKO,SAAS,aAAa,OAA4B,CAAC,GAAG;AAC3D,QAAM,EAAE,SAAS,CAAC,MAAM,MAAM,GAAG,MAAM,EAAE,IAAI;AAC7C,QAAM,EAAE,MAAM,IAAI,UAAU;AAE5B,iBAAe,gBAAgB,OAAgB;AAC7C,QAAI;AACF,YAAM,aAAa,eAAe,KAAK;AACvC,YAAM,UAAU,UAAU,UAAU,UAAU;AAC9C,aAAO,yBAAyB;AAAA,IAClC,SAAS,GAAG;AACV,YAAM,QAAQ;AACd,cAAQ,MAAM,MAAM,OAAO;AAC3B,aAAO,6BAA6B;AAAA,IACtC;AAAA,EACF;AAEA,SAAO,EAAE,gBAAgB;AAC3B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"url": "git+https://github.com/scalar/scalar.git",
|
|
11
11
|
"directory": "packages/use-hooks"
|
|
12
12
|
},
|
|
13
|
-
"version": "0.3.
|
|
13
|
+
"version": "0.3.7",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=20"
|
|
16
16
|
},
|
|
@@ -44,15 +44,15 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@vueuse/core": "13.9.0",
|
|
46
46
|
"cva": "1.0.0-beta.2",
|
|
47
|
-
"tailwind-merge": "
|
|
48
|
-
"vue": "^3.5.
|
|
49
|
-
"zod": "^4.
|
|
47
|
+
"tailwind-merge": "3.4.0",
|
|
48
|
+
"vue": "^3.5.26",
|
|
49
|
+
"zod": "^4.3.5",
|
|
50
50
|
"@scalar/use-toasts": "0.9.1"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@vue/test-utils": "2.4.6",
|
|
54
|
-
"jsdom": "
|
|
55
|
-
"vite": "7.1
|
|
54
|
+
"jsdom": "27.4.0",
|
|
55
|
+
"vite": "^7.3.1",
|
|
56
56
|
"@scalar/build-tooling": "0.4.1"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|