@chai-ui/react 0.6.0 → 0.7.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/DESIGN.md +19 -3
- package/dist/ChaiProvider.d.ts +3 -42
- package/dist/ChaiProvider.d.ts.map +1 -1
- package/dist/ChaiProvider.js +5 -43
- package/dist/ChaiProvider.js.map +1 -1
- package/dist/Composer.d.ts +4 -59
- package/dist/Composer.d.ts.map +1 -1
- package/dist/Composer.js +50 -169
- package/dist/Composer.js.map +1 -1
- package/dist/EditCard.d.ts +2 -16
- package/dist/EditCard.d.ts.map +1 -1
- package/dist/EditCard.js +16 -115
- package/dist/EditCard.js.map +1 -1
- package/dist/MediaAnalyzer.d.ts +3 -49
- package/dist/MediaAnalyzer.d.ts.map +1 -1
- package/dist/MediaAnalyzer.js +13 -141
- package/dist/MediaAnalyzer.js.map +1 -1
- package/dist/ResultCard.d.ts +13 -0
- package/dist/ResultCard.d.ts.map +1 -1
- package/dist/ResultCard.js +2 -48
- package/dist/ResultCard.js.map +1 -1
- package/dist/useComposer.d.ts +11 -86
- package/dist/useComposer.d.ts.map +1 -1
- package/dist/useComposer.js +26 -291
- package/dist/useComposer.js.map +1 -1
- package/dist/useMediaAnalyzer.d.ts +8 -28
- package/dist/useMediaAnalyzer.d.ts.map +1 -1
- package/dist/useMediaAnalyzer.js +9 -106
- package/dist/useMediaAnalyzer.js.map +1 -1
- package/package.json +3 -3
- package/src/ChaiProvider.tsx +12 -70
- package/src/Composer.tsx +73 -258
- package/src/EditCard.tsx +46 -139
- package/src/MediaAnalyzer.tsx +31 -176
- package/src/ResultCard.tsx +13 -38
- package/src/useComposer.ts +33 -411
- package/src/useMediaAnalyzer.ts +15 -146
- package/dist/media-actions.d.ts +0 -18
- package/dist/media-actions.d.ts.map +0 -1
- package/dist/media-actions.js +0 -56
- package/dist/media-actions.js.map +0 -1
- package/dist/regions.d.ts +0 -3
- package/dist/regions.d.ts.map +0 -1
- package/dist/regions.js +0 -7
- package/dist/regions.js.map +0 -1
- package/src/media-actions.ts +0 -54
- package/src/regions.ts +0 -7
package/dist/media-actions.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Download and share for a piece of generated media, shared by the cards.
|
|
3
|
-
*
|
|
4
|
-
* A plain `<a download href={remoteUrl}>` only forces a download for a
|
|
5
|
-
* same-origin or `blob:`/`data:` URL; for a cross-origin CDN URL (what a
|
|
6
|
-
* generated result usually is) browsers ignore `download` and open it
|
|
7
|
-
* instead. Fetching it into a blob first works wherever the source allows
|
|
8
|
-
* cross-origin fetches. When it doesn't, opening the media is the fallback.
|
|
9
|
-
*/
|
|
10
|
-
export async function downloadMedia(src, filename) {
|
|
11
|
-
try {
|
|
12
|
-
const response = await fetch(src);
|
|
13
|
-
const blob = await response.blob();
|
|
14
|
-
const blobUrl = URL.createObjectURL(blob);
|
|
15
|
-
const a = document.createElement("a");
|
|
16
|
-
a.href = blobUrl;
|
|
17
|
-
a.download = filename;
|
|
18
|
-
document.body.appendChild(a);
|
|
19
|
-
a.click();
|
|
20
|
-
a.remove();
|
|
21
|
-
URL.revokeObjectURL(blobUrl);
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
window.open(src, "_blank", "noopener");
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* The native share sheet where there is one, otherwise the media's URL
|
|
29
|
-
* copied to the clipboard. Says which, so the button can confirm a copy.
|
|
30
|
-
*/
|
|
31
|
-
export async function shareMedia(src) {
|
|
32
|
-
if (navigator.share) {
|
|
33
|
-
try {
|
|
34
|
-
await navigator.share({ url: src });
|
|
35
|
-
return "shared";
|
|
36
|
-
}
|
|
37
|
-
catch {
|
|
38
|
-
// Dismissed, or not shareable: same as closing a native share sheet.
|
|
39
|
-
return "none";
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
try {
|
|
43
|
-
await navigator.clipboard.writeText(src);
|
|
44
|
-
return "copied";
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
return "none";
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/** A file name for a download: the URL's own extension when it has one, otherwise a guess by kind. */
|
|
51
|
-
export function downloadFilename(id, kind, src) {
|
|
52
|
-
const match = /\.([a-zA-Z0-9]{2,5})(?:[?#]|$)/.exec(src);
|
|
53
|
-
const ext = match?.[1] ?? (kind === "video" ? "mp4" : kind === "audio" ? "mp3" : kind === "text" ? "txt" : "png");
|
|
54
|
-
return `${kind}-${id}.${ext}`;
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=media-actions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"media-actions.js","sourceRoot":"","sources":["../src/media-actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,GAAW,EAAE,QAAgB;IAC/D,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAClC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAC1C,MAAM,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QACtC,CAAC,CAAC,IAAI,GAAG,OAAO,CAAC;QACjB,CAAC,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACtB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QAC7B,CAAC,CAAC,KAAK,EAAE,CAAC;QACV,CAAC,CAAC,MAAM,EAAE,CAAC;QACX,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;IACzC,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAW;IAC1C,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC;YACH,MAAM,SAAS,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;YACpC,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,MAAM,CAAC;YACP,qEAAqE;YACrE,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;IACD,IAAI,CAAC;QACH,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACzC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC;IAChB,CAAC;AACH,CAAC;AAED,sGAAsG;AACtG,MAAM,UAAU,gBAAgB,CAAC,EAAU,EAAE,IAAY,EAAE,GAAW;IACpE,MAAM,KAAK,GAAG,gCAAgC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzD,MAAM,GAAG,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAClH,OAAO,GAAG,IAAI,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC;AAChC,CAAC"}
|
package/dist/regions.d.ts
DELETED
package/dist/regions.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"regions.d.ts","sourceRoot":"","sources":["../src/regions.ts"],"names":[],"mappings":"AAGA,gGAAgG;AAChG,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAElD"}
|
package/dist/regions.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/** How many region colors the tokens define (`--chai-color-semantic-region-1` to `-6`). */
|
|
2
|
-
const REGION_COLOR_COUNT = 6;
|
|
3
|
-
/** The color token for a region number. Numbers past the last color start over at the first. */
|
|
4
|
-
export function regionColor(number) {
|
|
5
|
-
return `var(--chai-color-semantic-region-${((Math.max(1, number) - 1) % REGION_COLOR_COUNT) + 1})`;
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=regions.js.map
|
package/dist/regions.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"regions.js","sourceRoot":"","sources":["../src/regions.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAE7B,gGAAgG;AAChG,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,OAAO,oCAAoC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC;AACrG,CAAC"}
|
package/src/media-actions.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Download and share for a piece of generated media, shared by the cards.
|
|
3
|
-
*
|
|
4
|
-
* A plain `<a download href={remoteUrl}>` only forces a download for a
|
|
5
|
-
* same-origin or `blob:`/`data:` URL; for a cross-origin CDN URL (what a
|
|
6
|
-
* generated result usually is) browsers ignore `download` and open it
|
|
7
|
-
* instead. Fetching it into a blob first works wherever the source allows
|
|
8
|
-
* cross-origin fetches. When it doesn't, opening the media is the fallback.
|
|
9
|
-
*/
|
|
10
|
-
export async function downloadMedia(src: string, filename: string): Promise<void> {
|
|
11
|
-
try {
|
|
12
|
-
const response = await fetch(src);
|
|
13
|
-
const blob = await response.blob();
|
|
14
|
-
const blobUrl = URL.createObjectURL(blob);
|
|
15
|
-
const a = document.createElement("a");
|
|
16
|
-
a.href = blobUrl;
|
|
17
|
-
a.download = filename;
|
|
18
|
-
document.body.appendChild(a);
|
|
19
|
-
a.click();
|
|
20
|
-
a.remove();
|
|
21
|
-
URL.revokeObjectURL(blobUrl);
|
|
22
|
-
} catch {
|
|
23
|
-
window.open(src, "_blank", "noopener");
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* The native share sheet where there is one, otherwise the media's URL
|
|
29
|
-
* copied to the clipboard. Says which, so the button can confirm a copy.
|
|
30
|
-
*/
|
|
31
|
-
export async function shareMedia(src: string): Promise<"shared" | "copied" | "none"> {
|
|
32
|
-
if (navigator.share) {
|
|
33
|
-
try {
|
|
34
|
-
await navigator.share({ url: src });
|
|
35
|
-
return "shared";
|
|
36
|
-
} catch {
|
|
37
|
-
// Dismissed, or not shareable: same as closing a native share sheet.
|
|
38
|
-
return "none";
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
try {
|
|
42
|
-
await navigator.clipboard.writeText(src);
|
|
43
|
-
return "copied";
|
|
44
|
-
} catch {
|
|
45
|
-
return "none";
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** A file name for a download: the URL's own extension when it has one, otherwise a guess by kind. */
|
|
50
|
-
export function downloadFilename(id: string, kind: string, src: string): string {
|
|
51
|
-
const match = /\.([a-zA-Z0-9]{2,5})(?:[?#]|$)/.exec(src);
|
|
52
|
-
const ext = match?.[1] ?? (kind === "video" ? "mp4" : kind === "audio" ? "mp3" : kind === "text" ? "txt" : "png");
|
|
53
|
-
return `${kind}-${id}.${ext}`;
|
|
54
|
-
}
|
package/src/regions.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/** How many region colors the tokens define (`--chai-color-semantic-region-1` to `-6`). */
|
|
2
|
-
const REGION_COLOR_COUNT = 6;
|
|
3
|
-
|
|
4
|
-
/** The color token for a region number. Numbers past the last color start over at the first. */
|
|
5
|
-
export function regionColor(number: number): string {
|
|
6
|
-
return `var(--chai-color-semantic-region-${((Math.max(1, number) - 1) % REGION_COLOR_COUNT) + 1})`;
|
|
7
|
-
}
|