@sckyzo/cosmos-react 0.5.0 → 0.6.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/CHANGELOG.md +65 -0
- package/README.md +2 -2
- package/dist/editor/index.cjs +421 -66
- package/dist/editor/index.cjs.map +1 -1
- package/dist/editor/index.d.cts +38 -12
- package/dist/editor/index.d.ts +38 -12
- package/dist/editor/index.js +423 -69
- package/dist/editor/index.js.map +1 -1
- package/dist/index.cjs +5474 -1602
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1413 -167
- package/dist/index.d.ts +1413 -167
- package/dist/index.js +5452 -1604
- package/dist/index.js.map +1 -1
- package/dist/qr/index.cjs +62 -0
- package/dist/qr/index.cjs.map +1 -0
- package/dist/qr/index.d.cts +43 -0
- package/dist/qr/index.d.ts +43 -0
- package/dist/qr/index.js +60 -0
- package/dist/qr/index.js.map +1 -0
- package/package.json +39 -11
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var clsx = require('clsx');
|
|
5
|
+
var react = require('react');
|
|
6
|
+
var qr = require('qr');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
|
|
9
|
+
// src/qr/QrCode.tsx
|
|
10
|
+
var QUIET_ZONE = 4;
|
|
11
|
+
var qrMatrix = (value, ecc) => {
|
|
12
|
+
try {
|
|
13
|
+
return qr.encodeQR(value, "raw", { ecc, border: QUIET_ZONE });
|
|
14
|
+
} catch (cause) {
|
|
15
|
+
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
16
|
+
throw new Error(`QrCode: cannot encode the value at ecc="${ecc}" (${reason}).`, { cause });
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var matrixPath = (matrix) => {
|
|
20
|
+
let path = "";
|
|
21
|
+
matrix.forEach((row, y) => {
|
|
22
|
+
for (let x = 0; x < row.length; x++) {
|
|
23
|
+
if (!row[x]) continue;
|
|
24
|
+
const start = x;
|
|
25
|
+
while (row[x + 1]) x++;
|
|
26
|
+
const run = x - start + 1;
|
|
27
|
+
path += `M${start} ${y}h${run}v1h-${run}z`;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return path;
|
|
31
|
+
};
|
|
32
|
+
var QrCode = ({
|
|
33
|
+
value,
|
|
34
|
+
label,
|
|
35
|
+
size = 192,
|
|
36
|
+
ecc = "medium",
|
|
37
|
+
className,
|
|
38
|
+
ref
|
|
39
|
+
}) => {
|
|
40
|
+
const { side, path } = react.useMemo(() => {
|
|
41
|
+
const matrix = qrMatrix(value, ecc);
|
|
42
|
+
return { side: matrix.length, path: matrixPath(matrix) };
|
|
43
|
+
}, [value, ecc]);
|
|
44
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
45
|
+
"svg",
|
|
46
|
+
{
|
|
47
|
+
ref,
|
|
48
|
+
role: "img",
|
|
49
|
+
"aria-label": label,
|
|
50
|
+
viewBox: `0 0 ${side} ${side}`,
|
|
51
|
+
width: size,
|
|
52
|
+
height: size,
|
|
53
|
+
shapeRendering: "crispEdges",
|
|
54
|
+
className: clsx.clsx("h-auto max-w-full rounded-sm bg-white text-black", className),
|
|
55
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: path, fill: "currentColor" })
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
exports.QrCode = QrCode;
|
|
61
|
+
//# sourceMappingURL=index.cjs.map
|
|
62
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/qr/qrMatrix.ts","../../src/qr/QrCode.tsx"],"names":["encodeQR","useMemo","jsx","clsx"],"mappings":";;;;;;;;;AAMO,IAAM,UAAA,GAAa,CAAA;AAQnB,IAAM,QAAA,GAAW,CAAC,KAAA,EAAe,GAAA,KAA4B;AAClE,EAAA,IAAI;AACF,I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AA,MAAM,MAAA,GAAS,QAAA,CAAS,KAAA,EAAO,GAAG,CAAA;AAClC,IAAA,OAAO,EAAE,IAAA,EAAM,MAAA,CAAO,QAAQ,IAAA,EAAM,UAAA,CAAW,MAAM,CAAA,EAAE;AAAA,EACzD,CAAA,EAAG,CAAC,KAAA,EAAO,GAAG,CAAC,CAAA;AACf,EAAA,uBACEC,cAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,IAAA,EAAK,KAAA;AAAA,MACL,YAAA,EAAY,KAAA;AAAA,MACZ,OAAA,EAAS,CAAA,IAAA,EAAO,IAAI,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA,MAC5B,KAAA,EAAO,IAAA;AAAA,MACP,MAAA,EAAQ,IAAA;AAAA,MACR,cAAA,EAAe,YAAA;AAAA,MACf,SAAA,EAAWC,SAAA,CAAK,kDAAA,EAAoD,SAAS,CAAA;AAAA,MAE7E,QAAA,kBAAAD,cAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAG,IAAA,EAAM,MAAK,cAAA,EAAe;AAAA;AAAA,GACrC;AAEJ","file":"index.cjs","sourcesContent":["import { encodeQR } from 'qr';\n\n/** How much of the symbol the error correction can lose: 7%, 15%, 25% and 30%. */\nexport type QrEcc = 'low' | 'medium' | 'quartile' | 'high';\n\n/** Light modules around the symbol on every side: the 4 the QR standard (ISO/IEC 18004) asks for. */\nexport const QUIET_ZONE = 4;\n\n/**\n * The modules of the QR code for `value`, the quiet zone included, `true` for a dark one. Only the\n * encoding can fail (a text that does not fit), so only it is wrapped: the library's own message\n * (\"Capacity overflow\") says nothing of the component or of the level that was asked for, and is\n * kept in the new one.\n */\nexport const qrMatrix = (value: string, ecc: QrEcc): boolean[][] => {\n try {\n return encodeQR(value, 'raw', { ecc, border: QUIET_ZONE });\n } catch (cause) {\n const reason = cause instanceof Error ? cause.message : String(cause);\n throw new Error(`QrCode: cannot encode the value at ecc=\"${ecc}\" (${reason}).`, { cause });\n }\n};\n\n/**\n * One SVG path for the dark modules of `matrix`, on a grid of unit squares: a run of dark modules\n * along a row is one rectangle, which keeps the path short.\n */\nexport const matrixPath = (matrix: boolean[][]): string => {\n let path = '';\n matrix.forEach((row, y) => {\n for (let x = 0; x < row.length; x++) {\n if (!row[x]) continue;\n const start = x;\n while (row[x + 1]) x++;\n const run = x - start + 1;\n path += `M${start} ${y}h${run}v1h-${run}z`;\n }\n });\n return path;\n};\n","import { clsx } from 'clsx';\nimport { useMemo, type Ref } from 'react';\nimport { matrixPath, qrMatrix, type QrEcc } from './qrMatrix';\n\nexport type QrCodeProps = {\n /**\n * The text to encode: a link, an `otpauth://` URI, a pairing code. A value too long for the\n * level (about 2.3 KB at `medium`) throws an error that names the level.\n */\n value: string;\n /**\n * Accessible name: what the code is for (\"Authenticator setup code\"). A screen reader cannot\n * read a code, so give the same data as text next to it.\n */\n label: string;\n /** Side of the square in pixels, quiet zone included. It shrinks in a narrower parent. Default `192`. */\n size?: number;\n /**\n * How much of the code can be lost and still scan: `low` 7%, `medium` 15%, `quartile` 25%,\n * `high` 30%. A higher level draws more modules for the same text. Default `medium`.\n */\n ecc?: QrEcc;\n className?: string;\n /** Ref to the `<svg>`. */\n ref?: Ref<SVGSVGElement>;\n};\n\n/**\n * QrCode — a QR code drawn as one SVG path, from the `qr` package (an optional peer dependency of\n * the `/qr` entry).\n *\n * The tile is white and the modules black in every theme, with the four-module quiet zone the\n * standard asks for inside it. A dark theme keeps the light tile instead of flipping the colors:\n * readers handle an inverted code unevenly. No semantic color variable fits (they all turn dark\n * with the theme), so the tile takes the two ends of the palette, `white` and `black`: the sand\n * theme tints the white slightly, and nothing else redefines either. Right to left does not\n * mirror it.\n */\nexport const QrCode = ({\n value,\n label,\n size = 192,\n ecc = 'medium',\n className,\n ref,\n}: QrCodeProps) => {\n const { side, path } = useMemo(() => {\n const matrix = qrMatrix(value, ecc);\n return { side: matrix.length, path: matrixPath(matrix) };\n }, [value, ecc]);\n return (\n <svg\n ref={ref}\n role=\"img\"\n aria-label={label}\n viewBox={`0 0 ${side} ${side}`}\n width={size}\n height={size}\n shapeRendering=\"crispEdges\"\n className={clsx('h-auto max-w-full rounded-sm bg-white text-black', className)}\n >\n <path d={path} fill=\"currentColor\" />\n </svg>\n );\n};\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { Ref } from 'react';
|
|
3
|
+
|
|
4
|
+
/** How much of the symbol the error correction can lose: 7%, 15%, 25% and 30%. */
|
|
5
|
+
type QrEcc = 'low' | 'medium' | 'quartile' | 'high';
|
|
6
|
+
|
|
7
|
+
type QrCodeProps = {
|
|
8
|
+
/**
|
|
9
|
+
* The text to encode: a link, an `otpauth://` URI, a pairing code. A value too long for the
|
|
10
|
+
* level (about 2.3 KB at `medium`) throws an error that names the level.
|
|
11
|
+
*/
|
|
12
|
+
value: string;
|
|
13
|
+
/**
|
|
14
|
+
* Accessible name: what the code is for ("Authenticator setup code"). A screen reader cannot
|
|
15
|
+
* read a code, so give the same data as text next to it.
|
|
16
|
+
*/
|
|
17
|
+
label: string;
|
|
18
|
+
/** Side of the square in pixels, quiet zone included. It shrinks in a narrower parent. Default `192`. */
|
|
19
|
+
size?: number;
|
|
20
|
+
/**
|
|
21
|
+
* How much of the code can be lost and still scan: `low` 7%, `medium` 15%, `quartile` 25%,
|
|
22
|
+
* `high` 30%. A higher level draws more modules for the same text. Default `medium`.
|
|
23
|
+
*/
|
|
24
|
+
ecc?: QrEcc;
|
|
25
|
+
className?: string;
|
|
26
|
+
/** Ref to the `<svg>`. */
|
|
27
|
+
ref?: Ref<SVGSVGElement>;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* QrCode — a QR code drawn as one SVG path, from the `qr` package (an optional peer dependency of
|
|
31
|
+
* the `/qr` entry).
|
|
32
|
+
*
|
|
33
|
+
* The tile is white and the modules black in every theme, with the four-module quiet zone the
|
|
34
|
+
* standard asks for inside it. A dark theme keeps the light tile instead of flipping the colors:
|
|
35
|
+
* readers handle an inverted code unevenly. No semantic color variable fits (they all turn dark
|
|
36
|
+
* with the theme), so the tile takes the two ends of the palette, `white` and `black`: the sand
|
|
37
|
+
* theme tints the white slightly, and nothing else redefines either. Right to left does not
|
|
38
|
+
* mirror it.
|
|
39
|
+
*/
|
|
40
|
+
declare const QrCode: ({ value, label, size, ecc, className, ref, }: QrCodeProps) => react.JSX.Element;
|
|
41
|
+
|
|
42
|
+
export { QrCode };
|
|
43
|
+
export type { QrCodeProps, QrEcc };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { Ref } from 'react';
|
|
3
|
+
|
|
4
|
+
/** How much of the symbol the error correction can lose: 7%, 15%, 25% and 30%. */
|
|
5
|
+
type QrEcc = 'low' | 'medium' | 'quartile' | 'high';
|
|
6
|
+
|
|
7
|
+
type QrCodeProps = {
|
|
8
|
+
/**
|
|
9
|
+
* The text to encode: a link, an `otpauth://` URI, a pairing code. A value too long for the
|
|
10
|
+
* level (about 2.3 KB at `medium`) throws an error that names the level.
|
|
11
|
+
*/
|
|
12
|
+
value: string;
|
|
13
|
+
/**
|
|
14
|
+
* Accessible name: what the code is for ("Authenticator setup code"). A screen reader cannot
|
|
15
|
+
* read a code, so give the same data as text next to it.
|
|
16
|
+
*/
|
|
17
|
+
label: string;
|
|
18
|
+
/** Side of the square in pixels, quiet zone included. It shrinks in a narrower parent. Default `192`. */
|
|
19
|
+
size?: number;
|
|
20
|
+
/**
|
|
21
|
+
* How much of the code can be lost and still scan: `low` 7%, `medium` 15%, `quartile` 25%,
|
|
22
|
+
* `high` 30%. A higher level draws more modules for the same text. Default `medium`.
|
|
23
|
+
*/
|
|
24
|
+
ecc?: QrEcc;
|
|
25
|
+
className?: string;
|
|
26
|
+
/** Ref to the `<svg>`. */
|
|
27
|
+
ref?: Ref<SVGSVGElement>;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* QrCode — a QR code drawn as one SVG path, from the `qr` package (an optional peer dependency of
|
|
31
|
+
* the `/qr` entry).
|
|
32
|
+
*
|
|
33
|
+
* The tile is white and the modules black in every theme, with the four-module quiet zone the
|
|
34
|
+
* standard asks for inside it. A dark theme keeps the light tile instead of flipping the colors:
|
|
35
|
+
* readers handle an inverted code unevenly. No semantic color variable fits (they all turn dark
|
|
36
|
+
* with the theme), so the tile takes the two ends of the palette, `white` and `black`: the sand
|
|
37
|
+
* theme tints the white slightly, and nothing else redefines either. Right to left does not
|
|
38
|
+
* mirror it.
|
|
39
|
+
*/
|
|
40
|
+
declare const QrCode: ({ value, label, size, ecc, className, ref, }: QrCodeProps) => react.JSX.Element;
|
|
41
|
+
|
|
42
|
+
export { QrCode };
|
|
43
|
+
export type { QrCodeProps, QrEcc };
|
package/dist/qr/index.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { encodeQR } from 'qr';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
// src/qr/QrCode.tsx
|
|
8
|
+
var QUIET_ZONE = 4;
|
|
9
|
+
var qrMatrix = (value, ecc) => {
|
|
10
|
+
try {
|
|
11
|
+
return encodeQR(value, "raw", { ecc, border: QUIET_ZONE });
|
|
12
|
+
} catch (cause) {
|
|
13
|
+
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
14
|
+
throw new Error(`QrCode: cannot encode the value at ecc="${ecc}" (${reason}).`, { cause });
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var matrixPath = (matrix) => {
|
|
18
|
+
let path = "";
|
|
19
|
+
matrix.forEach((row, y) => {
|
|
20
|
+
for (let x = 0; x < row.length; x++) {
|
|
21
|
+
if (!row[x]) continue;
|
|
22
|
+
const start = x;
|
|
23
|
+
while (row[x + 1]) x++;
|
|
24
|
+
const run = x - start + 1;
|
|
25
|
+
path += `M${start} ${y}h${run}v1h-${run}z`;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return path;
|
|
29
|
+
};
|
|
30
|
+
var QrCode = ({
|
|
31
|
+
value,
|
|
32
|
+
label,
|
|
33
|
+
size = 192,
|
|
34
|
+
ecc = "medium",
|
|
35
|
+
className,
|
|
36
|
+
ref
|
|
37
|
+
}) => {
|
|
38
|
+
const { side, path } = useMemo(() => {
|
|
39
|
+
const matrix = qrMatrix(value, ecc);
|
|
40
|
+
return { side: matrix.length, path: matrixPath(matrix) };
|
|
41
|
+
}, [value, ecc]);
|
|
42
|
+
return /* @__PURE__ */ jsx(
|
|
43
|
+
"svg",
|
|
44
|
+
{
|
|
45
|
+
ref,
|
|
46
|
+
role: "img",
|
|
47
|
+
"aria-label": label,
|
|
48
|
+
viewBox: `0 0 ${side} ${side}`,
|
|
49
|
+
width: size,
|
|
50
|
+
height: size,
|
|
51
|
+
shapeRendering: "crispEdges",
|
|
52
|
+
className: clsx("h-auto max-w-full rounded-sm bg-white text-black", className),
|
|
53
|
+
children: /* @__PURE__ */ jsx("path", { d: path, fill: "currentColor" })
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export { QrCode };
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/qr/qrMatrix.ts","../../src/qr/QrCode.tsx"],"names":[],"mappings":";;;;;;;AAMO,IAAM,UAAA,GAAa,CAAA;AAQnB,IAAM,QAAA,GAAW,CAAC,KAAA,EAAe,GAAA,KAA4B;AAClE,EAAA,IAAI;AACF,IAAA,OAAO,SAAS,KAAA,EAAO,KAAA,EAAO,EAAE,GAAA,EAAK,MAAA,EAAQ,YAAY,CAAA;AAAA,EAC3D,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,SAAS,KAAA,YAAiB,KAAA,GAAQ,K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AAA,EAAG,CAAC,KAAA,EAAO,GAAG,CAAC,CAAA;AACf,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,IAAA,EAAK,KAAA;AAAA,MACL,YAAA,EAAY,KAAA;AAAA,MACZ,OAAA,EAAS,CAAA,IAAA,EAAO,IAAI,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA,MAC5B,KAAA,EAAO,IAAA;AAAA,MACP,MAAA,EAAQ,IAAA;AAAA,MACR,cAAA,EAAe,YAAA;AAAA,MACf,SAAA,EAAW,IAAA,CAAK,kDAAA,EAAoD,SAAS,CAAA;AAAA,MAE7E,QAAA,kBAAA,GAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAG,IAAA,EAAM,MAAK,cAAA,EAAe;AAAA;AAAA,GACrC;AAEJ","file":"index.js","sourcesContent":["import { encodeQR } from 'qr';\n\n/** How much of the symbol the error correction can lose: 7%, 15%, 25% and 30%. */\nexport type QrEcc = 'low' | 'medium' | 'quartile' | 'high';\n\n/** Light modules around the symbol on every side: the 4 the QR standard (ISO/IEC 18004) asks for. */\nexport const QUIET_ZONE = 4;\n\n/**\n * The modules of the QR code for `value`, the quiet zone included, `true` for a dark one. Only the\n * encoding can fail (a text that does not fit), so only it is wrapped: the library's own message\n * (\"Capacity overflow\") says nothing of the component or of the level that was asked for, and is\n * kept in the new one.\n */\nexport const qrMatrix = (value: string, ecc: QrEcc): boolean[][] => {\n try {\n return encodeQR(value, 'raw', { ecc, border: QUIET_ZONE });\n } catch (cause) {\n const reason = cause instanceof Error ? cause.message : String(cause);\n throw new Error(`QrCode: cannot encode the value at ecc=\"${ecc}\" (${reason}).`, { cause });\n }\n};\n\n/**\n * One SVG path for the dark modules of `matrix`, on a grid of unit squares: a run of dark modules\n * along a row is one rectangle, which keeps the path short.\n */\nexport const matrixPath = (matrix: boolean[][]): string => {\n let path = '';\n matrix.forEach((row, y) => {\n for (let x = 0; x < row.length; x++) {\n if (!row[x]) continue;\n const start = x;\n while (row[x + 1]) x++;\n const run = x - start + 1;\n path += `M${start} ${y}h${run}v1h-${run}z`;\n }\n });\n return path;\n};\n","import { clsx } from 'clsx';\nimport { useMemo, type Ref } from 'react';\nimport { matrixPath, qrMatrix, type QrEcc } from './qrMatrix';\n\nexport type QrCodeProps = {\n /**\n * The text to encode: a link, an `otpauth://` URI, a pairing code. A value too long for the\n * level (about 2.3 KB at `medium`) throws an error that names the level.\n */\n value: string;\n /**\n * Accessible name: what the code is for (\"Authenticator setup code\"). A screen reader cannot\n * read a code, so give the same data as text next to it.\n */\n label: string;\n /** Side of the square in pixels, quiet zone included. It shrinks in a narrower parent. Default `192`. */\n size?: number;\n /**\n * How much of the code can be lost and still scan: `low` 7%, `medium` 15%, `quartile` 25%,\n * `high` 30%. A higher level draws more modules for the same text. Default `medium`.\n */\n ecc?: QrEcc;\n className?: string;\n /** Ref to the `<svg>`. */\n ref?: Ref<SVGSVGElement>;\n};\n\n/**\n * QrCode — a QR code drawn as one SVG path, from the `qr` package (an optional peer dependency of\n * the `/qr` entry).\n *\n * The tile is white and the modules black in every theme, with the four-module quiet zone the\n * standard asks for inside it. A dark theme keeps the light tile instead of flipping the colors:\n * readers handle an inverted code unevenly. No semantic color variable fits (they all turn dark\n * with the theme), so the tile takes the two ends of the palette, `white` and `black`: the sand\n * theme tints the white slightly, and nothing else redefines either. Right to left does not\n * mirror it.\n */\nexport const QrCode = ({\n value,\n label,\n size = 192,\n ecc = 'medium',\n className,\n ref,\n}: QrCodeProps) => {\n const { side, path } = useMemo(() => {\n const matrix = qrMatrix(value, ecc);\n return { side: matrix.length, path: matrixPath(matrix) };\n }, [value, ecc]);\n return (\n <svg\n ref={ref}\n role=\"img\"\n aria-label={label}\n viewBox={`0 0 ${side} ${side}`}\n width={size}\n height={size}\n shapeRendering=\"crispEdges\"\n className={clsx('h-auto max-w-full rounded-sm bg-white text-black', className)}\n >\n <path d={path} fill=\"currentColor\" />\n </svg>\n );\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sckyzo/cosmos-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "React 19 + Tailwind 4 UI component library — 135+ themeable, accessible components (forms, overlays, navigation, tables, data display) with built-in light/dark mode.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "SckyzO",
|
|
@@ -56,6 +56,16 @@
|
|
|
56
56
|
"default": "./dist/map/index.cjs"
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
|
+
"./qr": {
|
|
60
|
+
"import": {
|
|
61
|
+
"types": "./dist/qr/index.d.ts",
|
|
62
|
+
"default": "./dist/qr/index.js"
|
|
63
|
+
},
|
|
64
|
+
"require": {
|
|
65
|
+
"types": "./dist/qr/index.d.cts",
|
|
66
|
+
"default": "./dist/qr/index.cjs"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
59
69
|
"./calendar.css": "./calendar.css",
|
|
60
70
|
"./package.json": "./package.json"
|
|
61
71
|
},
|
|
@@ -69,6 +79,9 @@
|
|
|
69
79
|
],
|
|
70
80
|
"map": [
|
|
71
81
|
"./dist/map/index.d.ts"
|
|
82
|
+
],
|
|
83
|
+
"qr": [
|
|
84
|
+
"./dist/qr/index.d.ts"
|
|
72
85
|
]
|
|
73
86
|
}
|
|
74
87
|
},
|
|
@@ -92,11 +105,14 @@
|
|
|
92
105
|
},
|
|
93
106
|
"peerDependencies": {
|
|
94
107
|
"@tiptap/core": "^3.32.0",
|
|
108
|
+
"@tiptap/extension-image": "^3.32.0",
|
|
109
|
+
"@tiptap/extension-text-align": "^3.32.0",
|
|
95
110
|
"@tiptap/extensions": "^3.32.0",
|
|
96
111
|
"@tiptap/pm": "^3.32.0",
|
|
97
112
|
"@tiptap/react": "^3.32.0",
|
|
98
113
|
"@tiptap/starter-kit": "^3.32.0",
|
|
99
114
|
"maplibre-gl": "^5.24.0 || ^6.4.1",
|
|
115
|
+
"qr": "~0.7.2",
|
|
100
116
|
"react": "^19.0.0",
|
|
101
117
|
"react-dom": "^19.0.0",
|
|
102
118
|
"shiki": "^4.5.0"
|
|
@@ -105,6 +121,12 @@
|
|
|
105
121
|
"@tiptap/core": {
|
|
106
122
|
"optional": true
|
|
107
123
|
},
|
|
124
|
+
"@tiptap/extension-image": {
|
|
125
|
+
"optional": true
|
|
126
|
+
},
|
|
127
|
+
"@tiptap/extension-text-align": {
|
|
128
|
+
"optional": true
|
|
129
|
+
},
|
|
108
130
|
"@tiptap/extensions": {
|
|
109
131
|
"optional": true
|
|
110
132
|
},
|
|
@@ -120,6 +142,9 @@
|
|
|
120
142
|
"maplibre-gl": {
|
|
121
143
|
"optional": true
|
|
122
144
|
},
|
|
145
|
+
"qr": {
|
|
146
|
+
"optional": true
|
|
147
|
+
},
|
|
123
148
|
"shiki": {
|
|
124
149
|
"optional": true
|
|
125
150
|
}
|
|
@@ -131,30 +156,33 @@
|
|
|
131
156
|
"@dnd-kit/react": "0.5.1",
|
|
132
157
|
"@radix-ui/react-accordion": "^1.3.1",
|
|
133
158
|
"@radix-ui/react-slider": "^1.6.1",
|
|
134
|
-
"@sckyzo/cosmos-theme": "^0.
|
|
159
|
+
"@sckyzo/cosmos-theme": "^0.6.0",
|
|
135
160
|
"clsx": "^2.1.1",
|
|
136
161
|
"cmdk": "^1.1.1",
|
|
137
162
|
"embla-carousel-autoplay": "^8.6.0",
|
|
138
163
|
"embla-carousel-react": "^8.6.0",
|
|
139
|
-
"lucide-react": "^1.
|
|
164
|
+
"lucide-react": "^1.64.0",
|
|
140
165
|
"react-day-picker": "^10.0.2",
|
|
141
166
|
"sonner": "^2.0.8"
|
|
142
167
|
},
|
|
143
168
|
"devDependencies": {
|
|
144
|
-
"@storybook/react-vite": "^10.6.
|
|
145
|
-
"@tiptap/core": "3.32.
|
|
146
|
-
"@tiptap/
|
|
147
|
-
"@tiptap/
|
|
148
|
-
"@tiptap/
|
|
149
|
-
"@tiptap/
|
|
169
|
+
"@storybook/react-vite": "^10.6.5",
|
|
170
|
+
"@tiptap/core": "3.32.1",
|
|
171
|
+
"@tiptap/extension-image": "3.32.1",
|
|
172
|
+
"@tiptap/extension-text-align": "3.32.1",
|
|
173
|
+
"@tiptap/extensions": "3.32.1",
|
|
174
|
+
"@tiptap/pm": "3.32.1",
|
|
175
|
+
"@tiptap/react": "3.32.1",
|
|
176
|
+
"@tiptap/starter-kit": "3.32.1",
|
|
150
177
|
"@types/react": "^19.3.0",
|
|
151
178
|
"@types/react-dom": "^19.3.0",
|
|
152
179
|
"hast-util-to-jsx-runtime": "2.3.6",
|
|
153
|
-
"maplibre-gl": "6.
|
|
180
|
+
"maplibre-gl": "6.16.0",
|
|
181
|
+
"qr": "0.7.2",
|
|
154
182
|
"react": "^19.3.1",
|
|
155
183
|
"react-dom": "^19.3.1",
|
|
156
184
|
"shiki": "4.5.0",
|
|
157
|
-
"storybook": "^10.6.
|
|
185
|
+
"storybook": "^10.6.5",
|
|
158
186
|
"tsup": "^9.0.0",
|
|
159
187
|
"typescript": "^6.0.3"
|
|
160
188
|
},
|