From 231b0382dfda6633046fe1d93d47eeb4f9453846 Mon Sep 17 00:00:00 2001 From: TheoryOfNekomata Date: Fri, 7 Jul 2023 12:57:00 +0800 Subject: [PATCH] Extract all categories outside kitchen sink Define all categories presently implemented. --- .../src/components/ActionButton/index.tsx | 6 +- categories/blob/react/.eslintrc | 9 + categories/blob/react/.gitignore | 107 ++++++++++ categories/blob/react/LICENSE | 7 + categories/blob/react/package.json | 81 ++++++++ categories/blob/react/pridepack.json | 3 + .../src}/components/FileSelectBox/index.tsx | 88 ++++----- categories/blob/react/src/index.ts | 1 + categories/blob/react/tsconfig.eslint.json | 21 ++ categories/blob/react/tsconfig.json | 21 ++ categories/blob/react/vitest.config.ts | 8 + categories/choice/react/package.json | 4 +- .../src/components/TagInput/TagInput.css | 8 +- .../react/src/components/LinkButton/index.tsx | 6 +- categories/number/react/package.json | 4 +- packages/blob-utils/.eslintrc | 9 + packages/blob-utils/.gitignore | 107 ++++++++++ packages/blob-utils/LICENSE | 7 + packages/blob-utils/package.json | 70 +++++++ packages/blob-utils/pridepack.json | 3 + packages/blob-utils/src/content-type.ts | 49 +++++ packages/blob-utils/src/description.ts | 59 ++++++ packages/blob-utils/src/index.ts | 2 + packages/blob-utils/tsconfig.eslint.json | 21 ++ packages/blob-utils/tsconfig.json | 21 ++ packages/react-blob-previews/.eslintrc | 9 + packages/react-blob-previews/.gitignore | 107 ++++++++++ packages/react-blob-previews/LICENSE | 7 + packages/react-blob-previews/package.json | 77 ++++++++ packages/react-blob-previews/pridepack.json | 3 + .../components/AudioFilePreview/index.tsx | 18 +- .../components/AudioMiniFilePreview/index.tsx | 10 +- .../components/BinaryFilePreview/index.tsx | 14 +- .../components/ImageFilePreview/index.tsx | 14 +- .../src}/components/TextFilePreview/index.tsx | 14 +- .../components/VideoFilePreview/index.tsx | 14 +- .../src}/hooks/blob/index.ts | 0 .../src}/hooks/blob/metadata.ts | 2 +- .../src}/hooks/interactive/image.ts | 0 .../src}/hooks/interactive/index.ts | 0 .../src}/hooks/interactive/media.ts | 0 .../src}/index.ts | 1 - .../react-blob-previews/tsconfig.eslint.json | 21 ++ packages/react-blob-previews/tsconfig.json | 21 ++ packages/react-blob-previews/vitest.config.ts | 8 + .../src/categories/blob/react/common.ts | 10 - .../src/pages/categories/blob/index.tsx | 187 ------------------ pnpm-lock.yaml | 145 +++++++++++++- pnpm-workspace.yaml | 1 + .../web-kitchensink-reactnext/.eslintrc.json | 0 .../web-kitchensink-reactnext/.gitignore | 0 .../web-kitchensink-reactnext/README.md | 0 .../web-kitchensink-reactnext/colorthief.d.ts | 0 .../web-kitchensink-reactnext/next.config.js | 0 .../web-kitchensink-reactnext/package.json | 1 + .../web-kitchensink-reactnext/pnpm-lock.yaml | 0 .../postcss.config.js | 0 .../public/audio.wav | Bin .../public/binary.bin | Bin .../web-kitchensink-reactnext/public/code.py | 0 .../public/favicon.ico | Bin .../public/image.png | Bin .../web-kitchensink-reactnext/public/next.svg | 0 .../public/plaintext.txt | 0 .../public/vercel.svg | 0 .../public/video.mp4 | Bin .../react-refractor.d.ts | 0 .../src/components/DefaultLayout/index.tsx | 0 .../src/components/Section/index.tsx | 0 .../src/packages/react-refractor/index.tsx | 0 .../packages/react-refractor/style.module.css | 0 .../SpectrogramCanvas/index.tsx | 0 .../react-wavesurfer/WaveformCanvas/index.tsx | 0 .../src/packages/react-wavesurfer/index.ts | 0 .../src/pages/_app.tsx | 0 .../src/pages/_document.tsx | 0 .../src/pages/api/hello.ts | 0 .../src/pages/categories/action/index.tsx | 0 .../src/pages/categories/code/index.tsx | 0 .../src/pages/categories/freeform/index.tsx | 0 .../src/pages/categories/navigation/index.tsx | 0 .../src/pages/categories/number/index.tsx | 0 .../src/pages/categories/option/index.tsx | 0 .../pages/categories/presentation/index.tsx | 0 .../src/pages/examples/blog-post/index.tsx | 0 .../examples/registration-form/index.tsx | 2 +- .../src/pages/index.tsx | 0 .../src/styles/globals.css | 0 .../src/styles/kitchen-sink.css | 0 .../src/styles/theme.ts | 0 .../src/utils/blob.ts | 109 ---------- .../src/utils/numeral.ts | 0 .../tailwind.config.js | 0 .../web-kitchensink-reactnext/tsconfig.json | 0 94 files changed, 1094 insertions(+), 423 deletions(-) create mode 100644 categories/blob/react/.eslintrc create mode 100644 categories/blob/react/.gitignore create mode 100644 categories/blob/react/LICENSE create mode 100644 categories/blob/react/package.json create mode 100644 categories/blob/react/pridepack.json rename {packages/web-kitchensink-reactnext/src/categories/blob/react => categories/blob/react/src}/components/FileSelectBox/index.tsx (74%) create mode 100644 categories/blob/react/src/index.ts create mode 100644 categories/blob/react/tsconfig.eslint.json create mode 100644 categories/blob/react/tsconfig.json create mode 100644 categories/blob/react/vitest.config.ts create mode 100644 packages/blob-utils/.eslintrc create mode 100644 packages/blob-utils/.gitignore create mode 100644 packages/blob-utils/LICENSE create mode 100644 packages/blob-utils/package.json create mode 100644 packages/blob-utils/pridepack.json create mode 100644 packages/blob-utils/src/content-type.ts create mode 100644 packages/blob-utils/src/description.ts create mode 100644 packages/blob-utils/src/index.ts create mode 100644 packages/blob-utils/tsconfig.eslint.json create mode 100644 packages/blob-utils/tsconfig.json create mode 100644 packages/react-blob-previews/.eslintrc create mode 100644 packages/react-blob-previews/.gitignore create mode 100644 packages/react-blob-previews/LICENSE create mode 100644 packages/react-blob-previews/package.json create mode 100644 packages/react-blob-previews/pridepack.json rename packages/{web-kitchensink-reactnext/src/categories/blob/react => react-blob-previews/src}/components/AudioFilePreview/index.tsx (96%) rename packages/{web-kitchensink-reactnext/src/categories/blob/react => react-blob-previews/src}/components/AudioMiniFilePreview/index.tsx (95%) rename packages/{web-kitchensink-reactnext/src/categories/blob/react => react-blob-previews/src}/components/BinaryFilePreview/index.tsx (90%) rename packages/{web-kitchensink-reactnext/src/categories/blob/react => react-blob-previews/src}/components/ImageFilePreview/index.tsx (92%) rename packages/{web-kitchensink-reactnext/src/categories/blob/react => react-blob-previews/src}/components/TextFilePreview/index.tsx (89%) rename packages/{web-kitchensink-reactnext/src/categories/blob/react => react-blob-previews/src}/components/VideoFilePreview/index.tsx (95%) rename packages/{web-kitchensink-reactnext/src/categories/blob/react => react-blob-previews/src}/hooks/blob/index.ts (100%) rename packages/{web-kitchensink-reactnext/src/categories/blob/react => react-blob-previews/src}/hooks/blob/metadata.ts (95%) rename packages/{web-kitchensink-reactnext/src/categories/blob/react => react-blob-previews/src}/hooks/interactive/image.ts (100%) rename packages/{web-kitchensink-reactnext/src/categories/blob/react => react-blob-previews/src}/hooks/interactive/index.ts (100%) rename packages/{web-kitchensink-reactnext/src/categories/blob/react => react-blob-previews/src}/hooks/interactive/media.ts (100%) rename packages/{web-kitchensink-reactnext/src/categories/blob/react => react-blob-previews/src}/index.ts (88%) create mode 100644 packages/react-blob-previews/tsconfig.eslint.json create mode 100644 packages/react-blob-previews/tsconfig.json create mode 100644 packages/react-blob-previews/vitest.config.ts delete mode 100644 packages/web-kitchensink-reactnext/src/categories/blob/react/common.ts delete mode 100644 packages/web-kitchensink-reactnext/src/pages/categories/blob/index.tsx rename {packages => showcases}/web-kitchensink-reactnext/.eslintrc.json (100%) rename {packages => showcases}/web-kitchensink-reactnext/.gitignore (100%) rename {packages => showcases}/web-kitchensink-reactnext/README.md (100%) rename {packages => showcases}/web-kitchensink-reactnext/colorthief.d.ts (100%) rename {packages => showcases}/web-kitchensink-reactnext/next.config.js (100%) rename {packages => showcases}/web-kitchensink-reactnext/package.json (97%) rename {packages => showcases}/web-kitchensink-reactnext/pnpm-lock.yaml (100%) rename {packages => showcases}/web-kitchensink-reactnext/postcss.config.js (100%) rename {packages => showcases}/web-kitchensink-reactnext/public/audio.wav (100%) rename {packages => showcases}/web-kitchensink-reactnext/public/binary.bin (100%) rename {packages => showcases}/web-kitchensink-reactnext/public/code.py (100%) rename {packages => showcases}/web-kitchensink-reactnext/public/favicon.ico (100%) rename {packages => showcases}/web-kitchensink-reactnext/public/image.png (100%) rename {packages => showcases}/web-kitchensink-reactnext/public/next.svg (100%) rename {packages => showcases}/web-kitchensink-reactnext/public/plaintext.txt (100%) rename {packages => showcases}/web-kitchensink-reactnext/public/vercel.svg (100%) rename {packages => showcases}/web-kitchensink-reactnext/public/video.mp4 (100%) rename {packages => showcases}/web-kitchensink-reactnext/react-refractor.d.ts (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/components/DefaultLayout/index.tsx (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/components/Section/index.tsx (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/packages/react-refractor/index.tsx (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/packages/react-refractor/style.module.css (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/packages/react-wavesurfer/SpectrogramCanvas/index.tsx (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/packages/react-wavesurfer/WaveformCanvas/index.tsx (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/packages/react-wavesurfer/index.ts (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/pages/_app.tsx (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/pages/_document.tsx (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/pages/api/hello.ts (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/pages/categories/action/index.tsx (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/pages/categories/code/index.tsx (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/pages/categories/freeform/index.tsx (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/pages/categories/navigation/index.tsx (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/pages/categories/number/index.tsx (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/pages/categories/option/index.tsx (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/pages/categories/presentation/index.tsx (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/pages/examples/blog-post/index.tsx (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/pages/examples/registration-form/index.tsx (97%) rename {packages => showcases}/web-kitchensink-reactnext/src/pages/index.tsx (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/styles/globals.css (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/styles/kitchen-sink.css (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/styles/theme.ts (100%) rename {packages => showcases}/web-kitchensink-reactnext/src/utils/blob.ts (54%) rename {packages => showcases}/web-kitchensink-reactnext/src/utils/numeral.ts (100%) rename {packages => showcases}/web-kitchensink-reactnext/tailwind.config.js (100%) rename {packages => showcases}/web-kitchensink-reactnext/tsconfig.json (100%) diff --git a/categories/action/react/src/components/ActionButton/index.tsx b/categories/action/react/src/components/ActionButton/index.tsx index 9285d36..113fb8e 100644 --- a/categories/action/react/src/components/ActionButton/index.tsx +++ b/categories/action/react/src/components/ActionButton/index.tsx @@ -33,7 +33,7 @@ export const ActionButton = React.forwardRef + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/categories/blob/react/package.json b/categories/blob/react/package.json new file mode 100644 index 0000000..92190a2 --- /dev/null +++ b/categories/blob/react/package.json @@ -0,0 +1,81 @@ +{ + "name": "@tesseract-design/web-blob-react", + "version": "0.0.0", + "files": [ + "dist", + "src" + ], + "engines": { + "node": ">=12" + }, + "license": "MIT", + "keywords": [ + "pridepack" + ], + "devDependencies": { + "@testing-library/jest-dom": "^5.16.5", + "@testing-library/react": "^13.4.0", + "@types/node": "^18.14.1", + "@types/react": "^18.0.27", + "eslint": "^8.35.0", + "eslint-config-lxsmnsyc": "^0.5.0", + "jsdom": "^21.1.0", + "pridepack": "2.4.4", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-test-renderer": "^18.2.0", + "tslib": "^2.5.0", + "typescript": "^4.9.5", + "vitest": "^0.28.1" + }, + "peerDependencies": { + "react": "^16.8 || ^17.0 || ^18.0", + "react-dom": "^16.8 || ^17.0 || ^18.0" + }, + "scripts": { + "prepublishOnly": "pridepack clean && pridepack build", + "build": "pridepack build", + "type-check": "pridepack check", + "lint": "pridepack lint", + "clean": "pridepack clean", + "watch": "pridepack watch", + "start": "pridepack start", + "dev": "pridepack dev", + "test": "vitest" + }, + "private": false, + "description": "Tesseract components for displaying data.", + "repository": { + "url": "", + "type": "git" + }, + "homepage": "", + "bugs": { + "url": "" + }, + "author": "TheoryOfNekomata ", + "publishConfig": { + "access": "public" + }, + "dependencies": { + "clsx": "^1.2.1", + "@modal-sh/react-utils": "workspace:*" + }, + "types": "./dist/types/index.d.ts", + "main": "./dist/cjs/production/index.js", + "module": "./dist/esm/production/index.js", + "exports": { + ".": { + "development": { + "require": "./dist/cjs/development/index.js", + "import": "./dist/esm/development/index.js" + }, + "require": "./dist/cjs/production/index.js", + "import": "./dist/esm/production/index.js", + "types": "./dist/types/index.d.ts" + } + }, + "typesVersions": { + "*": {} + } +} diff --git a/categories/blob/react/pridepack.json b/categories/blob/react/pridepack.json new file mode 100644 index 0000000..841fb58 --- /dev/null +++ b/categories/blob/react/pridepack.json @@ -0,0 +1,3 @@ +{ + "target": "es2018" +} \ No newline at end of file diff --git a/packages/web-kitchensink-reactnext/src/categories/blob/react/components/FileSelectBox/index.tsx b/categories/blob/react/src/components/FileSelectBox/index.tsx similarity index 74% rename from packages/web-kitchensink-reactnext/src/categories/blob/react/components/FileSelectBox/index.tsx rename to categories/blob/react/src/components/FileSelectBox/index.tsx index d26c77b..5f62277 100644 --- a/packages/web-kitchensink-reactnext/src/categories/blob/react/components/FileSelectBox/index.tsx +++ b/categories/blob/react/src/components/FileSelectBox/index.tsx @@ -1,27 +1,20 @@ import * as React from 'react'; -import {ContentType, FileWithResolvedContentType, getContentType, getMimeTypeDescription} from '@/utils/blob'; -import {formatFileSize} from '@/utils/numeral'; -import {AudioFilePreview} from '../AudioFilePreview'; -import {BinaryFilePreview} from '../BinaryFilePreview'; -import {ImageFilePreview} from '../ImageFilePreview'; -import {VideoFilePreview} from '../VideoFilePreview'; -import {TextFilePreview} from '../TextFilePreview'; -import {AudioMiniFilePreview} from '../AudioMiniFilePreview'; -import {delegateTriggerEvent, useClientSide} from '@modal-sh/react-utils'; +import { delegateTriggerEvent, useClientSide } from '@modal-sh/react-utils'; import clsx from 'clsx'; -import {FilePreviewComponent} from '@/categories/blob/react/common'; -const FILE_PREVIEW_COMPONENTS: Record = { - [ContentType.IMAGE]: ImageFilePreview, - [ContentType.AUDIO]: AudioFilePreview, - [ContentType.VIDEO]: VideoFilePreview, - [ContentType.BINARY]: BinaryFilePreview, - [ContentType.TEXT]: TextFilePreview, -}; +export interface CommonPreviewProps = Partial> { + file?: F; + disabled?: boolean; + enhanced?: boolean; + mini?: boolean; +} export type FileSelectBoxDerivedElement = HTMLInputElement; -export interface FileSelectBoxProps extends Omit, 'size' | 'type' | 'style' | 'label' | 'list'> { +export interface FileSelectBoxProps< + F extends Partial = Partial, + P extends CommonPreviewProps = CommonPreviewProps +> extends Omit, 'size' | 'type' | 'style' | 'label' | 'list'> { /** * Should the component display a border? */ @@ -43,6 +36,7 @@ export interface FileSelectBoxProps extends Omit, } export const FileSelectBox = React.forwardRef( @@ -59,6 +53,7 @@ export const FileSelectBox = React.forwardRef { e.stopPropagation(); e.preventDefault(); - } + }; const handleDropZone: React.DragEventHandler = async (e) => { cancelEvent(e); @@ -122,7 +117,7 @@ export const FileSelectBox = React.forwardRef { delegateTriggerEvent('change', current); }); - } + }; const filesCount = fileList?.length ?? 0; @@ -131,6 +126,8 @@ export const FileSelectBox = React.forwardRef
- {Array.from(fileList ?? []).map((file: File) => { - const f = file as unknown as FileWithResolvedContentType; - const fileContentType = getContentType(file.type, file.name); + {Array.from(fileList ?? []).map((file, i) => { return (
- { - fileContentType === ContentType.IMAGE - && typeof f?.url === 'string' - && ( - {f.name} - ) - } - { - fileContentType === ContentType.AUDIO - && ( - - ) - } +
); })} @@ -244,25 +226,25 @@ export const FileSelectBox = React.forwardRef { - const f = file as unknown as FileWithResolvedContentType; - const fileContentType = getContentType(file.type, file.name); - const { [fileContentType]: FilePreviewComponent = BinaryFilePreview } = FILE_PREVIEW_COMPONENTS; + && Array.from(fileList ?? []).map((file, i) => { return (
- + > + +
) diff --git a/categories/blob/react/src/index.ts b/categories/blob/react/src/index.ts new file mode 100644 index 0000000..8c9ec95 --- /dev/null +++ b/categories/blob/react/src/index.ts @@ -0,0 +1 @@ +export * from './components/FileSelectBox'; diff --git a/categories/blob/react/tsconfig.eslint.json b/categories/blob/react/tsconfig.eslint.json new file mode 100644 index 0000000..16f2e87 --- /dev/null +++ b/categories/blob/react/tsconfig.eslint.json @@ -0,0 +1,21 @@ +{ + "exclude": ["node_modules"], + "include": ["src", "types", "test"], + "compilerOptions": { + "module": "ESNext", + "lib": ["DOM", "ESNext"], + "importHelpers": true, + "declaration": true, + "sourceMap": true, + "rootDir": "./", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "moduleResolution": "node", + "jsx": "react", + "esModuleInterop": true, + "target": "es2018" + } +} diff --git a/categories/blob/react/tsconfig.json b/categories/blob/react/tsconfig.json new file mode 100644 index 0000000..0ed68f4 --- /dev/null +++ b/categories/blob/react/tsconfig.json @@ -0,0 +1,21 @@ +{ + "exclude": ["node_modules"], + "include": ["src", "types"], + "compilerOptions": { + "module": "ESNext", + "lib": ["DOM", "ESNext"], + "importHelpers": true, + "declaration": true, + "sourceMap": true, + "rootDir": "./src", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "moduleResolution": "node", + "jsx": "react", + "esModuleInterop": true, + "target": "es2018" + } +} diff --git a/categories/blob/react/vitest.config.ts b/categories/blob/react/vitest.config.ts new file mode 100644 index 0000000..a104d21 --- /dev/null +++ b/categories/blob/react/vitest.config.ts @@ -0,0 +1,8 @@ +/// + +export default ({ + test: { + global: true, + environment: 'jsdom', + }, +}); diff --git a/categories/choice/react/package.json b/categories/choice/react/package.json index a0bbecc..d415f08 100644 --- a/categories/choice/react/package.json +++ b/categories/choice/react/package.json @@ -74,7 +74,9 @@ "require": "./dist/cjs/production/index.js", "import": "./dist/esm/production/index.js", "types": "./dist/types/index.d.ts" - } + }, + "./dist/RadioButton.css": "./dist/RadioButton.css", + "./dist/RadioTickBox.css": "./dist/RadioTickBox.css" }, "typesVersions": { "*": {} diff --git a/categories/multichoice/react/src/components/TagInput/TagInput.css b/categories/multichoice/react/src/components/TagInput/TagInput.css index 16d68da..2f63dff 100644 --- a/categories/multichoice/react/src/components/TagInput/TagInput.css +++ b/categories/multichoice/react/src/components/TagInput/TagInput.css @@ -73,24 +73,24 @@ padding-right: 4rem; } -.tesseract-design-tag-input.tag-input textarea + div > span { +.tesseract-design-tag-input textarea + div > span { padding: 0.125rem; border-radius: 0.25rem; line-height: 1; background-color: rgb(var(--color-positive) / 25%); } -.tesseract-design-tag-input.tag-input textarea + div > span span { +.tesseract-design-tag-input textarea + div > span span { pointer-events: none; } -.tesseract-design-tag-input.tag-input textarea + div > span button { +.tesseract-design-tag-input textarea + div > span button { color: rgb(var(--color-primary)); padding: 0; width: 1rem; margin-left: 0.25rem; } -.tesseract-design-tag-input.tag-input textarea + div > span button:hover { +.tesseract-design-tag-input textarea + div > span button:hover { color: rgb(var(--color-primary)); } diff --git a/categories/navigation/react/src/components/LinkButton/index.tsx b/categories/navigation/react/src/components/LinkButton/index.tsx index c750104..aa2b2b0 100644 --- a/categories/navigation/react/src/components/LinkButton/index.tsx +++ b/categories/navigation/react/src/components/LinkButton/index.tsx @@ -32,7 +32,7 @@ export const LinkButton = React.forwardRef + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/packages/blob-utils/package.json b/packages/blob-utils/package.json new file mode 100644 index 0000000..cb02918 --- /dev/null +++ b/packages/blob-utils/package.json @@ -0,0 +1,70 @@ +{ + "name": "@modal-sh/blob-utils", + "version": "0.0.0", + "files": [ + "dist", + "src" + ], + "engines": { + "node": ">=12" + }, + "license": "MIT", + "keywords": [ + "pridepack" + ], + "devDependencies": { + "@types/mime-types": "^2.1.1", + "@types/node": "^18.14.1", + "eslint": "^8.35.0", + "eslint-config-lxsmnsyc": "^0.5.0", + "pridepack": "2.4.4", + "tslib": "^2.5.0", + "typescript": "^4.9.5", + "vitest": "^0.28.1" + }, + "scripts": { + "prepublishOnly": "pridepack clean && pridepack build", + "build": "pridepack build", + "type-check": "pridepack check", + "lint": "pridepack lint", + "clean": "pridepack clean", + "watch": "pridepack watch", + "start": "pridepack start", + "dev": "pridepack dev", + "test": "vitest" + }, + "private": false, + "description": "Utilities for binary data.", + "repository": { + "url": "", + "type": "git" + }, + "homepage": "", + "bugs": { + "url": "" + }, + "author": "TheoryOfNekomata ", + "publishConfig": { + "access": "public" + }, + "types": "./dist/types/index.d.ts", + "main": "./dist/cjs/production/index.js", + "module": "./dist/esm/production/index.js", + "exports": { + ".": { + "development": { + "require": "./dist/cjs/development/index.js", + "import": "./dist/esm/development/index.js" + }, + "require": "./dist/cjs/production/index.js", + "import": "./dist/esm/production/index.js", + "types": "./dist/types/index.d.ts" + } + }, + "typesVersions": { + "*": {} + }, + "dependencies": { + "mime-types": "^2.1.35" + } +} diff --git a/packages/blob-utils/pridepack.json b/packages/blob-utils/pridepack.json new file mode 100644 index 0000000..841fb58 --- /dev/null +++ b/packages/blob-utils/pridepack.json @@ -0,0 +1,3 @@ +{ + "target": "es2018" +} \ No newline at end of file diff --git a/packages/blob-utils/src/content-type.ts b/packages/blob-utils/src/content-type.ts new file mode 100644 index 0000000..b021e61 --- /dev/null +++ b/packages/blob-utils/src/content-type.ts @@ -0,0 +1,49 @@ +import * as mimeTypes from 'mime-types'; + +export enum ContentType { + TEXT = 'text', + AUDIO = 'audio', + VIDEO = 'video', + IMAGE = 'image', + BINARY = 'binary', +} + +export const getContentType = (mimeType?: string, filename?: string) => { + let effectiveMimeType: string; + if (typeof mimeType !== 'string') { + if (typeof filename !== 'string') { + return ContentType.BINARY; + } + const lookupMimeType = mimeTypes.lookup(filename); + + if (typeof lookupMimeType !== 'string') { + return ContentType.BINARY; + } + + effectiveMimeType = lookupMimeType; + } else { + effectiveMimeType = mimeType; + } + + if ( + effectiveMimeType === 'application/json' + || effectiveMimeType === 'application/xml' + || effectiveMimeType.startsWith('text/') + ) { + return ContentType.TEXT; + } + + if (effectiveMimeType.startsWith('video/')) { + return ContentType.VIDEO; + } + + if (effectiveMimeType.startsWith('audio/')) { + return ContentType.AUDIO; + } + + if (effectiveMimeType.startsWith('image/')) { + return ContentType.IMAGE; + } + + return ContentType.BINARY; +}; diff --git a/packages/blob-utils/src/description.ts b/packages/blob-utils/src/description.ts new file mode 100644 index 0000000..406479f --- /dev/null +++ b/packages/blob-utils/src/description.ts @@ -0,0 +1,59 @@ +const MIME_TYPE_DESCRIPTIONS = { + 'image/gif': 'GIF Image', + 'image/jpeg': 'JPEG Image', + 'image/png': 'PNG Image', + 'image/tiff': 'TIFF Image', + 'image/svg+xml': 'SVG Image', + 'image/webp': 'WEBP Image', + 'audio/wav': 'WAVE Audio', + 'audio/ogg': 'OGG Audio', + 'audio/mpeg': 'MPEG Audio', + 'audio/mid': 'MIDI Track', + 'application/json': 'JSON Data', + 'application/xml': 'XML Data', + 'application/x-bittorrent': 'Torrent File', + 'application/x-zip-compressed': 'Compressed ZIP Archive', + 'application/x-x509-ca-cert': 'Certificate File', + 'application/x-tar': 'Compressed TAR Archive', + 'application/x-rar': 'Compressed RAR Archive', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'Workbook', + 'application/vnd.openxmlformats-officedocument.presentationml.presentation': 'Slideshow Presentation', + 'application/msword': 'Microsoft Word Document', + 'application/pdf': 'PDF Document', + 'application/postscript': 'PostScript Document', + 'application/epub+zip': 'EPUB Document', + 'message/rfc822': 'Email Message', + 'video/mp4': 'MP4 Video', +} as const; + +const EXTENSION_DESCRIPTIONS = { + rar: 'Compressed RAR Archive', + '7z': 'Compressed 7-Zip Archive', + psd: 'Adobe Photoshop Document', + dmg: 'Disk Image', + 'fb2k-component': 'foobar2000 Component', +} as const; + +export const getFileDescription = (type?: string, filename?: string) => { + if (typeof (type as unknown) !== 'string') { + return ''; + } + + if (type === 'application/octet-stream' || type === '') { + if (typeof filename === 'string' && filename.includes('.')) { + const extension = filename.slice(filename.lastIndexOf('.') + '.'.length).toLowerCase(); + const { + [extension as keyof typeof EXTENSION_DESCRIPTIONS]: extensionDescription = `${extension.toUpperCase()} File`, + } = EXTENSION_DESCRIPTIONS; + + return extensionDescription; + } + return `${type} File`; + } + + const { + [type as keyof typeof MIME_TYPE_DESCRIPTIONS]: description = type, + } = MIME_TYPE_DESCRIPTIONS; + + return description; +}; diff --git a/packages/blob-utils/src/index.ts b/packages/blob-utils/src/index.ts new file mode 100644 index 0000000..92c77b2 --- /dev/null +++ b/packages/blob-utils/src/index.ts @@ -0,0 +1,2 @@ +export * from './content-type'; +export * from './description'; diff --git a/packages/blob-utils/tsconfig.eslint.json b/packages/blob-utils/tsconfig.eslint.json new file mode 100644 index 0000000..459f2a1 --- /dev/null +++ b/packages/blob-utils/tsconfig.eslint.json @@ -0,0 +1,21 @@ +{ + "exclude": ["node_modules"], + "include": ["src", "types", "test"], + "compilerOptions": { + "module": "ESNext", + "lib": ["ESNext"], + "importHelpers": true, + "declaration": true, + "sourceMap": true, + "rootDir": "./", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "moduleResolution": "node", + "jsx": "react", + "esModuleInterop": true, + "target": "es2018" + } +} diff --git a/packages/blob-utils/tsconfig.json b/packages/blob-utils/tsconfig.json new file mode 100644 index 0000000..e210542 --- /dev/null +++ b/packages/blob-utils/tsconfig.json @@ -0,0 +1,21 @@ +{ + "exclude": ["node_modules"], + "include": ["src", "types"], + "compilerOptions": { + "module": "ESNext", + "lib": ["ESNext"], + "importHelpers": true, + "declaration": true, + "sourceMap": true, + "rootDir": "./src", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "moduleResolution": "node", + "jsx": "react", + "esModuleInterop": true, + "target": "es2018" + } +} diff --git a/packages/react-blob-previews/.eslintrc b/packages/react-blob-previews/.eslintrc new file mode 100644 index 0000000..7d22244 --- /dev/null +++ b/packages/react-blob-previews/.eslintrc @@ -0,0 +1,9 @@ +{ + "root": true, + "extends": [ + "lxsmnsyc/typescript/react" + ], + "parserOptions": { + "project": "./tsconfig.eslint.json" + } +} diff --git a/packages/react-blob-previews/.gitignore b/packages/react-blob-previews/.gitignore new file mode 100644 index 0000000..53992de --- /dev/null +++ b/packages/react-blob-previews/.gitignore @@ -0,0 +1,107 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.production +.env.development + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# Next.js build output +.next + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and *not* Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +.npmrc diff --git a/packages/react-blob-previews/LICENSE b/packages/react-blob-previews/LICENSE new file mode 100644 index 0000000..f24dd21 --- /dev/null +++ b/packages/react-blob-previews/LICENSE @@ -0,0 +1,7 @@ +MIT License Copyright (c) 2023 TheoryOfNekomata + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/packages/react-blob-previews/package.json b/packages/react-blob-previews/package.json new file mode 100644 index 0000000..151bf9f --- /dev/null +++ b/packages/react-blob-previews/package.json @@ -0,0 +1,77 @@ +{ + "name": "@modal-sh/react-utils", + "version": "0.0.0", + "files": [ + "dist", + "src" + ], + "engines": { + "node": ">=12" + }, + "license": "MIT", + "keywords": [ + "pridepack" + ], + "devDependencies": { + "@testing-library/jest-dom": "^5.16.5", + "@testing-library/react": "^13.4.0", + "@types/node": "^18.14.1", + "@types/react": "^18.0.27", + "eslint": "^8.35.0", + "eslint-config-lxsmnsyc": "^0.5.0", + "jsdom": "^21.1.0", + "pridepack": "2.4.4", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-test-renderer": "^18.2.0", + "tslib": "^2.5.0", + "typescript": "^4.9.5", + "vitest": "^0.28.1" + }, + "peerDependencies": { + "react": "^16.8 || ^17.0 || ^18.0", + "react-dom": "^16.8 || ^17.0 || ^18.0" + }, + "scripts": { + "prepublishOnly": "pridepack clean && pridepack build", + "build": "pridepack build", + "type-check": "pridepack check", + "lint": "pridepack lint", + "clean": "pridepack clean", + "watch": "pridepack watch", + "start": "pridepack start", + "dev": "pridepack dev", + "test": "vitest" + }, + "private": false, + "description": "Utilities for React.", + "repository": { + "url": "", + "type": "git" + }, + "homepage": "", + "bugs": { + "url": "" + }, + "author": "TheoryOfNekomata ", + "publishConfig": { + "access": "public" + }, + "types": "./dist/types/index.d.ts", + "main": "./dist/cjs/production/index.js", + "module": "./dist/esm/production/index.js", + "exports": { + ".": { + "development": { + "require": "./dist/cjs/development/index.js", + "import": "./dist/esm/development/index.js" + }, + "require": "./dist/cjs/production/index.js", + "import": "./dist/esm/production/index.js", + "types": "./dist/types/index.d.ts" + } + }, + "typesVersions": { + "*": {} + } +} diff --git a/packages/react-blob-previews/pridepack.json b/packages/react-blob-previews/pridepack.json new file mode 100644 index 0000000..841fb58 --- /dev/null +++ b/packages/react-blob-previews/pridepack.json @@ -0,0 +1,3 @@ +{ + "target": "es2018" +} \ No newline at end of file diff --git a/packages/web-kitchensink-reactnext/src/categories/blob/react/components/AudioFilePreview/index.tsx b/packages/react-blob-previews/src/components/AudioFilePreview/index.tsx similarity index 96% rename from packages/web-kitchensink-reactnext/src/categories/blob/react/components/AudioFilePreview/index.tsx rename to packages/react-blob-previews/src/components/AudioFilePreview/index.tsx index 1f41b06..823362b 100644 --- a/packages/web-kitchensink-reactnext/src/categories/blob/react/components/AudioFilePreview/index.tsx +++ b/packages/react-blob-previews/src/components/AudioFilePreview/index.tsx @@ -1,21 +1,21 @@ import * as React from 'react'; -import {augmentAudioFile, getMimeTypeDescription} from '@/utils/blob'; +import {augmentAudioFile, getMimeTypeDescription} from 'packages/web-kitchensink-reactnext/src/utils/blob'; import { formatFileSize, formatNumeral, formatSecondsDurationConcise, formatSecondsDurationPrecise, -} from '@/utils/numeral'; -import theme from '@/styles/theme'; +} from 'packages/web-kitchensink-reactnext/src/utils/numeral'; +import theme from 'packages/web-kitchensink-reactnext/src/styles/theme'; import {useMediaControls} from '../../hooks/interactive'; -import {useFileMetadata, useFileUrl} from '@/categories/blob/react'; +import {useFileMetadata, useFileUrl} from 'src/index'; import clsx from 'clsx'; -import {SpectrogramCanvas, WaveformCanvas} from '@modal-sh/react-wavesurfer'; -import {Slider} from '@tesseract-design/web-number-react'; -import {KeyValueTable} from '@tesseract-design/web-information-react'; -import {useClientSide} from '@modal-sh/react-utils'; -import {CommonPreviewProps} from '@/categories/blob/react/common'; +import {SpectrogramCanvas, WaveformCanvas} from 'packages/web-kitchensink-reactnext/src/packages/react-wavesurfer'; +import {Slider} from 'categories/number/react'; +import {KeyValueTable} from 'categories/information/react'; +import {useClientSide} from 'packages/react-utils'; +import type {CommonPreviewProps} from '../../../../../categories/blob/react/src/components/FileSelectBox'; export type AudioFilePreviewDerivedElement = HTMLAudioElement; diff --git a/packages/web-kitchensink-reactnext/src/categories/blob/react/components/AudioMiniFilePreview/index.tsx b/packages/react-blob-previews/src/components/AudioMiniFilePreview/index.tsx similarity index 95% rename from packages/web-kitchensink-reactnext/src/categories/blob/react/components/AudioMiniFilePreview/index.tsx rename to packages/react-blob-previews/src/components/AudioMiniFilePreview/index.tsx index dfbb636..6ae5530 100644 --- a/packages/web-kitchensink-reactnext/src/categories/blob/react/components/AudioMiniFilePreview/index.tsx +++ b/packages/react-blob-previews/src/components/AudioMiniFilePreview/index.tsx @@ -1,11 +1,11 @@ import * as React from 'react'; -import {augmentAudioFile} from '@/utils/blob'; -import theme from '@/styles/theme'; +import {augmentAudioFile} from 'packages/web-kitchensink-reactnext/src/utils/blob'; +import theme from 'packages/web-kitchensink-reactnext/src/styles/theme'; import {useMediaControls} from '../../hooks/interactive'; -import {useFileMetadata, useFileUrl} from '@/categories/blob/react'; +import {useFileMetadata, useFileUrl} from 'src/index'; import clsx from 'clsx'; -import {SpectrogramCanvas, WaveformCanvas} from '@modal-sh/react-wavesurfer'; -import {useClientSide} from '@modal-sh/react-utils'; +import {SpectrogramCanvas, WaveformCanvas} from 'packages/web-kitchensink-reactnext/src/packages/react-wavesurfer'; +import {useClientSide} from 'packages/react-utils'; export type AudioMiniFilePreviewDerivedElement = HTMLAudioElement; diff --git a/packages/web-kitchensink-reactnext/src/categories/blob/react/components/BinaryFilePreview/index.tsx b/packages/react-blob-previews/src/components/BinaryFilePreview/index.tsx similarity index 90% rename from packages/web-kitchensink-reactnext/src/categories/blob/react/components/BinaryFilePreview/index.tsx rename to packages/react-blob-previews/src/components/BinaryFilePreview/index.tsx index 64abcdd..e6df3c6 100644 --- a/packages/web-kitchensink-reactnext/src/categories/blob/react/components/BinaryFilePreview/index.tsx +++ b/packages/react-blob-previews/src/components/BinaryFilePreview/index.tsx @@ -1,12 +1,12 @@ import * as React from 'react'; -import {augmentBinaryFile, getMimeTypeDescription} from '@/utils/blob'; -import {formatFileSize, formatNumeral} from '@/utils/numeral'; -import {useFileMetadata, useFileUrl} from '@/categories/blob/react'; +import {augmentBinaryFile, getMimeTypeDescription} from 'packages/web-kitchensink-reactnext/src/utils/blob'; +import {formatFileSize, formatNumeral} from 'packages/web-kitchensink-reactnext/src/utils/numeral'; +import {useFileMetadata, useFileUrl} from 'src/index'; import clsx from 'clsx'; -import {KeyValueTable} from '@tesseract-design/web-information-react'; -import {BinaryDataCanvas} from '@modal-sh/react-binary-data-canvas'; -import {useClientSide} from '@modal-sh/react-utils'; -import {CommonPreviewProps} from '@/categories/blob/react/common'; +import {KeyValueTable} from 'categories/information/react'; +import {BinaryDataCanvas} from 'packages/react-binary-data-canvas'; +import {useClientSide} from 'packages/react-utils'; +import type {CommonPreviewProps} from '../../../../../categories/blob/react/src/components/FileSelectBox'; export type BinaryFilePreviewDerivedElement = HTMLDivElement; diff --git a/packages/web-kitchensink-reactnext/src/categories/blob/react/components/ImageFilePreview/index.tsx b/packages/react-blob-previews/src/components/ImageFilePreview/index.tsx similarity index 92% rename from packages/web-kitchensink-reactnext/src/categories/blob/react/components/ImageFilePreview/index.tsx rename to packages/react-blob-previews/src/components/ImageFilePreview/index.tsx index f401c4c..726501a 100644 --- a/packages/web-kitchensink-reactnext/src/categories/blob/react/components/ImageFilePreview/index.tsx +++ b/packages/react-blob-previews/src/components/ImageFilePreview/index.tsx @@ -1,12 +1,12 @@ import * as React from 'react'; -import {augmentImageFile, getMimeTypeDescription} from '@/utils/blob'; -import {formatFileSize, formatNumeral} from '@/utils/numeral'; +import {augmentImageFile, getMimeTypeDescription} from 'packages/web-kitchensink-reactnext/src/utils/blob'; +import {formatFileSize, formatNumeral} from 'packages/web-kitchensink-reactnext/src/utils/numeral'; import clsx from 'clsx'; -import {useFileMetadata, useFileUrl, useImageControls} from '@/categories/blob/react'; -import {KeyValueTable} from '@tesseract-design/web-information-react'; -import {useClientSide} from '@modal-sh/react-utils'; -import {CommonPreviewProps} from '@/categories/blob/react/common'; -import {Swatch} from '@tesseract-design/web-color-react'; +import {useFileMetadata, useFileUrl, useImageControls} from 'src/index'; +import {KeyValueTable} from 'categories/information/react'; +import {useClientSide} from 'packages/react-utils'; +import type {CommonPreviewProps} from '../../../../../categories/blob/react/src/components/FileSelectBox'; +import {Swatch} from 'categories/color/react'; export type ImageFilePreviewDerivedElement = HTMLImageElement; diff --git a/packages/web-kitchensink-reactnext/src/categories/blob/react/components/TextFilePreview/index.tsx b/packages/react-blob-previews/src/components/TextFilePreview/index.tsx similarity index 89% rename from packages/web-kitchensink-reactnext/src/categories/blob/react/components/TextFilePreview/index.tsx rename to packages/react-blob-previews/src/components/TextFilePreview/index.tsx index 700d93a..2146b54 100644 --- a/packages/web-kitchensink-reactnext/src/categories/blob/react/components/TextFilePreview/index.tsx +++ b/packages/react-blob-previews/src/components/TextFilePreview/index.tsx @@ -1,12 +1,12 @@ import * as React from 'react'; -import {formatFileSize, formatNumeral} from '@/utils/numeral'; -import {useFileMetadata, useFileUrl} from '@/categories/blob/react'; -import {augmentTextFile, getMimeTypeDescription} from '@/utils/blob'; +import {formatFileSize, formatNumeral} from 'packages/web-kitchensink-reactnext/src/utils/numeral'; +import {useFileMetadata, useFileUrl} from 'src/index'; +import {augmentTextFile, getMimeTypeDescription} from 'packages/web-kitchensink-reactnext/src/utils/blob'; import clsx from 'clsx'; -import {KeyValueTable} from '@tesseract-design/web-information-react'; -import {Refractor} from '@modal-sh/react-refractor'; -import {useClientSide} from '@modal-sh/react-utils'; -import {CommonPreviewProps} from '@/categories/blob/react/common'; +import {KeyValueTable} from 'categories/information/react'; +import {Refractor} from 'packages/web-kitchensink-reactnext/src/packages/react-refractor'; +import {useClientSide} from 'packages/react-utils'; +import type {CommonPreviewProps} from '../../../../../categories/blob/react/src/components/FileSelectBox'; type TextFilePreviewDerivedComponent = HTMLDivElement; diff --git a/packages/web-kitchensink-reactnext/src/categories/blob/react/components/VideoFilePreview/index.tsx b/packages/react-blob-previews/src/components/VideoFilePreview/index.tsx similarity index 95% rename from packages/web-kitchensink-reactnext/src/categories/blob/react/components/VideoFilePreview/index.tsx rename to packages/react-blob-previews/src/components/VideoFilePreview/index.tsx index 586dab3..aa661bf 100644 --- a/packages/web-kitchensink-reactnext/src/categories/blob/react/components/VideoFilePreview/index.tsx +++ b/packages/react-blob-previews/src/components/VideoFilePreview/index.tsx @@ -1,12 +1,12 @@ import * as React from 'react'; -import {augmentVideoFile, getMimeTypeDescription} from '@/utils/blob'; -import {formatFileSize, formatNumeral, formatSecondsDurationConcise} from '@/utils/numeral'; -import {useFileMetadata, useFileUrl, useMediaControls} from '@tesseract-design/web-blob-react'; +import {augmentVideoFile, getMimeTypeDescription} from 'packages/web-kitchensink-reactnext/src/utils/blob'; +import {formatFileSize, formatNumeral, formatSecondsDurationConcise} from 'packages/web-kitchensink-reactnext/src/utils/numeral'; +import {useFileMetadata, useFileUrl, useMediaControls} from 'src/index'; import clsx from 'clsx'; -import {Slider} from '@tesseract-design/web-number-react'; -import {KeyValueTable} from '@tesseract-design/web-information-react'; -import {useClientSide} from '@modal-sh/react-utils'; -import {CommonPreviewProps} from '@/categories/blob/react/common'; +import {Slider} from 'categories/number/react'; +import {KeyValueTable} from 'categories/information/react'; +import {useClientSide} from 'packages/react-utils'; +import type {CommonPreviewProps} from '../../../../../categories/blob/react/src/components/FileSelectBox'; export type VideoFilePreviewDerivedComponent = HTMLVideoElement; diff --git a/packages/web-kitchensink-reactnext/src/categories/blob/react/hooks/blob/index.ts b/packages/react-blob-previews/src/hooks/blob/index.ts similarity index 100% rename from packages/web-kitchensink-reactnext/src/categories/blob/react/hooks/blob/index.ts rename to packages/react-blob-previews/src/hooks/blob/index.ts diff --git a/packages/web-kitchensink-reactnext/src/categories/blob/react/hooks/blob/metadata.ts b/packages/react-blob-previews/src/hooks/blob/metadata.ts similarity index 95% rename from packages/web-kitchensink-reactnext/src/categories/blob/react/hooks/blob/metadata.ts rename to packages/react-blob-previews/src/hooks/blob/metadata.ts index 5b64bb5..2860c6a 100644 --- a/packages/web-kitchensink-reactnext/src/categories/blob/react/hooks/blob/metadata.ts +++ b/packages/react-blob-previews/src/hooks/blob/metadata.ts @@ -1,5 +1,5 @@ import * as React from 'react'; -import {addDataUrl, FileWithDataUrl} from '@/utils/blob'; +import {addDataUrl, FileWithDataUrl} from 'packages/web-kitchensink-reactnext/src/utils/blob'; export interface UseFileUrlOptions { file?: Partial; diff --git a/packages/web-kitchensink-reactnext/src/categories/blob/react/hooks/interactive/image.ts b/packages/react-blob-previews/src/hooks/interactive/image.ts similarity index 100% rename from packages/web-kitchensink-reactnext/src/categories/blob/react/hooks/interactive/image.ts rename to packages/react-blob-previews/src/hooks/interactive/image.ts diff --git a/packages/web-kitchensink-reactnext/src/categories/blob/react/hooks/interactive/index.ts b/packages/react-blob-previews/src/hooks/interactive/index.ts similarity index 100% rename from packages/web-kitchensink-reactnext/src/categories/blob/react/hooks/interactive/index.ts rename to packages/react-blob-previews/src/hooks/interactive/index.ts diff --git a/packages/web-kitchensink-reactnext/src/categories/blob/react/hooks/interactive/media.ts b/packages/react-blob-previews/src/hooks/interactive/media.ts similarity index 100% rename from packages/web-kitchensink-reactnext/src/categories/blob/react/hooks/interactive/media.ts rename to packages/react-blob-previews/src/hooks/interactive/media.ts diff --git a/packages/web-kitchensink-reactnext/src/categories/blob/react/index.ts b/packages/react-blob-previews/src/index.ts similarity index 88% rename from packages/web-kitchensink-reactnext/src/categories/blob/react/index.ts rename to packages/react-blob-previews/src/index.ts index ace370a..35ef75f 100644 --- a/packages/web-kitchensink-reactnext/src/categories/blob/react/index.ts +++ b/packages/react-blob-previews/src/index.ts @@ -1,7 +1,6 @@ export * from './components/AudioFilePreview'; export * from './components/AudioMiniFilePreview'; export * from './components/BinaryFilePreview'; -export * from './components/FileSelectBox'; export * from './components/ImageFilePreview'; export * from './components/TextFilePreview'; export * from './components/VideoFilePreview'; diff --git a/packages/react-blob-previews/tsconfig.eslint.json b/packages/react-blob-previews/tsconfig.eslint.json new file mode 100644 index 0000000..16f2e87 --- /dev/null +++ b/packages/react-blob-previews/tsconfig.eslint.json @@ -0,0 +1,21 @@ +{ + "exclude": ["node_modules"], + "include": ["src", "types", "test"], + "compilerOptions": { + "module": "ESNext", + "lib": ["DOM", "ESNext"], + "importHelpers": true, + "declaration": true, + "sourceMap": true, + "rootDir": "./", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "moduleResolution": "node", + "jsx": "react", + "esModuleInterop": true, + "target": "es2018" + } +} diff --git a/packages/react-blob-previews/tsconfig.json b/packages/react-blob-previews/tsconfig.json new file mode 100644 index 0000000..0ed68f4 --- /dev/null +++ b/packages/react-blob-previews/tsconfig.json @@ -0,0 +1,21 @@ +{ + "exclude": ["node_modules"], + "include": ["src", "types"], + "compilerOptions": { + "module": "ESNext", + "lib": ["DOM", "ESNext"], + "importHelpers": true, + "declaration": true, + "sourceMap": true, + "rootDir": "./src", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "moduleResolution": "node", + "jsx": "react", + "esModuleInterop": true, + "target": "es2018" + } +} diff --git a/packages/react-blob-previews/vitest.config.ts b/packages/react-blob-previews/vitest.config.ts new file mode 100644 index 0000000..a104d21 --- /dev/null +++ b/packages/react-blob-previews/vitest.config.ts @@ -0,0 +1,8 @@ +/// + +export default ({ + test: { + global: true, + environment: 'jsdom', + }, +}); diff --git a/packages/web-kitchensink-reactnext/src/categories/blob/react/common.ts b/packages/web-kitchensink-reactnext/src/categories/blob/react/common.ts deleted file mode 100644 index 75612f0..0000000 --- a/packages/web-kitchensink-reactnext/src/categories/blob/react/common.ts +++ /dev/null @@ -1,10 +0,0 @@ -import * as React from 'react'; - -export interface CommonPreviewProps = Partial> { - file?: F; - disabled?: boolean; - enhanced?: boolean; - mini?: boolean; -} - -export type FilePreviewComponent = (props: T) => React.ReactNode; diff --git a/packages/web-kitchensink-reactnext/src/pages/categories/blob/index.tsx b/packages/web-kitchensink-reactnext/src/pages/categories/blob/index.tsx deleted file mode 100644 index 50d2ac9..0000000 --- a/packages/web-kitchensink-reactnext/src/pages/categories/blob/index.tsx +++ /dev/null @@ -1,187 +0,0 @@ -import {NextPage} from 'next'; -import * as React from 'react'; -import * as BlobReact from '@tesseract-design/web-blob-react'; -import {DefaultLayout} from '@/components/DefaultLayout'; -import {Section, Subsection} from '@/components/Section'; -import {addDataUrl} from '@/utils/blob'; - -const BlobPage: NextPage = () => { - const [imageFile, setImageFile] = React.useState>(); - React.useEffect(() => { - fetch('/image.png').then((response) => { - response.blob().then(async (blob) => { - const imageFile = new File([blob], 'image.png', { - type: 'image/png', - }); - const theFile = await addDataUrl(imageFile); - setImageFile(theFile); - }); - }); - }, []); - - const [videoFile, setVideoFile] = React.useState(); - React.useEffect(() => { - fetch('/video.mp4').then((response) => { - response.blob().then((blob) => { - setVideoFile(new File([blob], 'video.mp4', { - type: 'video/mp4', - })); - }); - }); - }, []); - - const [audioFile, setAudioFile] = React.useState(); - React.useEffect(() => { - fetch('/audio.wav').then((response) => { - response.blob().then((blob) => { - setAudioFile(new File([blob], 'audio.wav', { - type: 'audio/wav', - })); - }); - }); - }, []); - - const [binaryFile, setBinaryFile] = React.useState(); - React.useEffect(() => { - fetch('/binary.bin').then((response) => { - response.blob().then((blob) => { - setBinaryFile(new File([blob], 'binary.bin', { - type: 'application/octet-stream', - })); - }); - }); - }, []); - - const [plaintextFile, setPlaintextFile] = React.useState(); - React.useEffect(() => { - fetch('/plaintext.txt').then((response) => { - response.blob().then((blob) => { - setPlaintextFile(new File([blob], 'plaintext.txt', { - type: 'text/plain', - })); - }); - }); - }, []); - - const [codeFile, setCodeFile] = React.useState(); - React.useEffect(() => { - fetch('/code.py').then((response) => { - response.blob().then((blob) => { - setCodeFile(new File([blob], 'code.py', { - type: 'text/x-python', - })); - }); - }); - }, []); - - return ( - -
- - - } - className="sm:h-64" - /> - -
-
- - - } - className="sm:h-64" - enhanced - /> - -
-
- - - } - className="sm:h-64" - enhanced - /> - -
-
- - - } - className="sm:h-64" - /> - -
-
- - - } - className="sm:h-64" - /> - - - - } - className="sm:h-64" - /> - -
-
- - console.log(e.currentTarget.files)} - /> - -
-
- ) -} - -export default BlobPage; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8625934..2003292 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -82,6 +82,58 @@ importers: specifier: ^0.28.1 version: 0.28.1(jsdom@21.1.0) + categories/blob/react: + dependencies: + '@modal-sh/react-utils': + specifier: workspace:* + version: link:../../../packages/react-utils + clsx: + specifier: ^1.2.1 + version: 1.2.1 + devDependencies: + '@testing-library/jest-dom': + specifier: ^5.16.5 + version: 5.16.5 + '@testing-library/react': + specifier: ^13.4.0 + version: 13.4.0(react-dom@18.2.0)(react@18.2.0) + '@types/node': + specifier: ^18.14.1 + version: 18.14.1 + '@types/react': + specifier: ^18.0.27 + version: 18.2.14 + eslint: + specifier: ^8.35.0 + version: 8.43.0 + eslint-config-lxsmnsyc: + specifier: ^0.5.0 + version: 0.5.0(eslint@8.43.0)(typescript@4.9.5) + jsdom: + specifier: ^21.1.0 + version: 21.1.0 + pridepack: + specifier: 2.4.4 + version: 2.4.4(eslint@8.43.0)(tslib@2.6.0)(typescript@4.9.5) + react: + specifier: ^18.2.0 + version: 18.2.0 + react-dom: + specifier: ^18.2.0 + version: 18.2.0(react@18.2.0) + react-test-renderer: + specifier: ^18.2.0 + version: 18.2.0(react@18.2.0) + tslib: + specifier: ^2.5.0 + version: 2.6.0 + typescript: + specifier: ^4.9.5 + version: 4.9.5 + vitest: + specifier: ^0.28.1 + version: 0.28.1(jsdom@21.1.0) + categories/choice/react: dependencies: '@tesseract-design/web-base': @@ -535,6 +587,37 @@ importers: specifier: ^0.28.1 version: 0.28.1(jsdom@21.1.0) + packages/blob-utils: + dependencies: + mime-types: + specifier: ^2.1.35 + version: 2.1.35 + devDependencies: + '@types/mime-types': + specifier: ^2.1.1 + version: 2.1.1 + '@types/node': + specifier: ^18.14.1 + version: 18.14.1 + eslint: + specifier: ^8.35.0 + version: 8.43.0 + eslint-config-lxsmnsyc: + specifier: ^0.5.0 + version: 0.5.0(eslint@8.43.0)(typescript@4.9.5) + pridepack: + specifier: 2.4.4 + version: 2.4.4(eslint@8.43.0)(tslib@2.6.0)(typescript@4.9.5) + tslib: + specifier: ^2.5.0 + version: 2.6.0 + typescript: + specifier: ^4.9.5 + version: 4.9.5 + vitest: + specifier: ^0.28.1 + version: 0.28.1(jsdom@21.1.0) + packages/image-utils: dependencies: colorthief: @@ -617,6 +700,51 @@ importers: specifier: ^0.28.1 version: 0.28.1(jsdom@21.1.0) + packages/react-blob-previews: + devDependencies: + '@testing-library/jest-dom': + specifier: ^5.16.5 + version: 5.16.5 + '@testing-library/react': + specifier: ^13.4.0 + version: 13.4.0(react-dom@18.2.0)(react@18.2.0) + '@types/node': + specifier: ^18.14.1 + version: 18.14.1 + '@types/react': + specifier: ^18.0.27 + version: 18.2.14 + eslint: + specifier: ^8.35.0 + version: 8.43.0 + eslint-config-lxsmnsyc: + specifier: ^0.5.0 + version: 0.5.0(eslint@8.43.0)(typescript@4.9.5) + jsdom: + specifier: ^21.1.0 + version: 21.1.0 + pridepack: + specifier: 2.4.4 + version: 2.4.4(eslint@8.43.0)(tslib@2.6.0)(typescript@4.9.5) + react: + specifier: ^18.2.0 + version: 18.2.0 + react-dom: + specifier: ^18.2.0 + version: 18.2.0(react@18.2.0) + react-test-renderer: + specifier: ^18.2.0 + version: 18.2.0(react@18.2.0) + tslib: + specifier: ^2.5.0 + version: 2.6.0 + typescript: + specifier: ^4.9.5 + version: 4.9.5 + vitest: + specifier: ^0.28.1 + version: 0.28.1(jsdom@21.1.0) + packages/react-utils: devDependencies: '@testing-library/jest-dom': @@ -720,32 +848,35 @@ importers: specifier: ^0.28.1 version: 0.28.1(jsdom@21.1.0) - packages/web-kitchensink-reactnext: + showcases/web-kitchensink-reactnext: dependencies: '@modal-sh/audio-utils': specifier: workspace:* - version: link:../audio-utils + version: link:../../packages/audio-utils '@modal-sh/image-utils': specifier: workspace:* - version: link:../image-utils + version: link:../../packages/image-utils '@modal-sh/react-binary-data-canvas': specifier: workspace:* - version: link:../react-binary-data-canvas + version: link:../../packages/react-binary-data-canvas '@modal-sh/react-utils': specifier: workspace:* - version: link:../react-utils + version: link:../../packages/react-utils '@modal-sh/text-utils': specifier: workspace:* - version: link:../text-utils + version: link:../../packages/text-utils '@modal-sh/video-utils': specifier: workspace:* - version: link:../video-utils + version: link:../../packages/video-utils '@tesseract-design/web-action-react': specifier: workspace:* version: link:../../categories/action/react '@tesseract-design/web-base': specifier: workspace:* version: link:../../base + '@tesseract-design/web-blob-react': + specifier: workspace:* + version: link:../../categories/blob/react '@tesseract-design/web-choice-react': specifier: workspace:* version: link:../../categories/choice/react diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 53ad6de..dabfbeb 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -2,3 +2,4 @@ packages: - 'base' - 'packages/*' - 'categories/**' + - 'showcases/**' diff --git a/packages/web-kitchensink-reactnext/.eslintrc.json b/showcases/web-kitchensink-reactnext/.eslintrc.json similarity index 100% rename from packages/web-kitchensink-reactnext/.eslintrc.json rename to showcases/web-kitchensink-reactnext/.eslintrc.json diff --git a/packages/web-kitchensink-reactnext/.gitignore b/showcases/web-kitchensink-reactnext/.gitignore similarity index 100% rename from packages/web-kitchensink-reactnext/.gitignore rename to showcases/web-kitchensink-reactnext/.gitignore diff --git a/packages/web-kitchensink-reactnext/README.md b/showcases/web-kitchensink-reactnext/README.md similarity index 100% rename from packages/web-kitchensink-reactnext/README.md rename to showcases/web-kitchensink-reactnext/README.md diff --git a/packages/web-kitchensink-reactnext/colorthief.d.ts b/showcases/web-kitchensink-reactnext/colorthief.d.ts similarity index 100% rename from packages/web-kitchensink-reactnext/colorthief.d.ts rename to showcases/web-kitchensink-reactnext/colorthief.d.ts diff --git a/packages/web-kitchensink-reactnext/next.config.js b/showcases/web-kitchensink-reactnext/next.config.js similarity index 100% rename from packages/web-kitchensink-reactnext/next.config.js rename to showcases/web-kitchensink-reactnext/next.config.js diff --git a/packages/web-kitchensink-reactnext/package.json b/showcases/web-kitchensink-reactnext/package.json similarity index 97% rename from packages/web-kitchensink-reactnext/package.json rename to showcases/web-kitchensink-reactnext/package.json index 325b3b7..d0c9532 100644 --- a/packages/web-kitchensink-reactnext/package.json +++ b/showcases/web-kitchensink-reactnext/package.json @@ -38,6 +38,7 @@ "@modal-sh/react-binary-data-canvas": "workspace:*", "@tesseract-design/web-base": "workspace:*", "@tesseract-design/web-action-react": "workspace:*", + "@tesseract-design/web-blob-react": "workspace:*", "@tesseract-design/web-color-react": "workspace:*", "@tesseract-design/web-choice-react": "workspace:*", "@tesseract-design/web-formatted-react": "workspace:*", diff --git a/packages/web-kitchensink-reactnext/pnpm-lock.yaml b/showcases/web-kitchensink-reactnext/pnpm-lock.yaml similarity index 100% rename from packages/web-kitchensink-reactnext/pnpm-lock.yaml rename to showcases/web-kitchensink-reactnext/pnpm-lock.yaml diff --git a/packages/web-kitchensink-reactnext/postcss.config.js b/showcases/web-kitchensink-reactnext/postcss.config.js similarity index 100% rename from packages/web-kitchensink-reactnext/postcss.config.js rename to showcases/web-kitchensink-reactnext/postcss.config.js diff --git a/packages/web-kitchensink-reactnext/public/audio.wav b/showcases/web-kitchensink-reactnext/public/audio.wav similarity index 100% rename from packages/web-kitchensink-reactnext/public/audio.wav rename to showcases/web-kitchensink-reactnext/public/audio.wav diff --git a/packages/web-kitchensink-reactnext/public/binary.bin b/showcases/web-kitchensink-reactnext/public/binary.bin similarity index 100% rename from packages/web-kitchensink-reactnext/public/binary.bin rename to showcases/web-kitchensink-reactnext/public/binary.bin diff --git a/packages/web-kitchensink-reactnext/public/code.py b/showcases/web-kitchensink-reactnext/public/code.py similarity index 100% rename from packages/web-kitchensink-reactnext/public/code.py rename to showcases/web-kitchensink-reactnext/public/code.py diff --git a/packages/web-kitchensink-reactnext/public/favicon.ico b/showcases/web-kitchensink-reactnext/public/favicon.ico similarity index 100% rename from packages/web-kitchensink-reactnext/public/favicon.ico rename to showcases/web-kitchensink-reactnext/public/favicon.ico diff --git a/packages/web-kitchensink-reactnext/public/image.png b/showcases/web-kitchensink-reactnext/public/image.png similarity index 100% rename from packages/web-kitchensink-reactnext/public/image.png rename to showcases/web-kitchensink-reactnext/public/image.png diff --git a/packages/web-kitchensink-reactnext/public/next.svg b/showcases/web-kitchensink-reactnext/public/next.svg similarity index 100% rename from packages/web-kitchensink-reactnext/public/next.svg rename to showcases/web-kitchensink-reactnext/public/next.svg diff --git a/packages/web-kitchensink-reactnext/public/plaintext.txt b/showcases/web-kitchensink-reactnext/public/plaintext.txt similarity index 100% rename from packages/web-kitchensink-reactnext/public/plaintext.txt rename to showcases/web-kitchensink-reactnext/public/plaintext.txt diff --git a/packages/web-kitchensink-reactnext/public/vercel.svg b/showcases/web-kitchensink-reactnext/public/vercel.svg similarity index 100% rename from packages/web-kitchensink-reactnext/public/vercel.svg rename to showcases/web-kitchensink-reactnext/public/vercel.svg diff --git a/packages/web-kitchensink-reactnext/public/video.mp4 b/showcases/web-kitchensink-reactnext/public/video.mp4 similarity index 100% rename from packages/web-kitchensink-reactnext/public/video.mp4 rename to showcases/web-kitchensink-reactnext/public/video.mp4 diff --git a/packages/web-kitchensink-reactnext/react-refractor.d.ts b/showcases/web-kitchensink-reactnext/react-refractor.d.ts similarity index 100% rename from packages/web-kitchensink-reactnext/react-refractor.d.ts rename to showcases/web-kitchensink-reactnext/react-refractor.d.ts diff --git a/packages/web-kitchensink-reactnext/src/components/DefaultLayout/index.tsx b/showcases/web-kitchensink-reactnext/src/components/DefaultLayout/index.tsx similarity index 100% rename from packages/web-kitchensink-reactnext/src/components/DefaultLayout/index.tsx rename to showcases/web-kitchensink-reactnext/src/components/DefaultLayout/index.tsx diff --git a/packages/web-kitchensink-reactnext/src/components/Section/index.tsx b/showcases/web-kitchensink-reactnext/src/components/Section/index.tsx similarity index 100% rename from packages/web-kitchensink-reactnext/src/components/Section/index.tsx rename to showcases/web-kitchensink-reactnext/src/components/Section/index.tsx diff --git a/packages/web-kitchensink-reactnext/src/packages/react-refractor/index.tsx b/showcases/web-kitchensink-reactnext/src/packages/react-refractor/index.tsx similarity index 100% rename from packages/web-kitchensink-reactnext/src/packages/react-refractor/index.tsx rename to showcases/web-kitchensink-reactnext/src/packages/react-refractor/index.tsx diff --git a/packages/web-kitchensink-reactnext/src/packages/react-refractor/style.module.css b/showcases/web-kitchensink-reactnext/src/packages/react-refractor/style.module.css similarity index 100% rename from packages/web-kitchensink-reactnext/src/packages/react-refractor/style.module.css rename to showcases/web-kitchensink-reactnext/src/packages/react-refractor/style.module.css diff --git a/packages/web-kitchensink-reactnext/src/packages/react-wavesurfer/SpectrogramCanvas/index.tsx b/showcases/web-kitchensink-reactnext/src/packages/react-wavesurfer/SpectrogramCanvas/index.tsx similarity index 100% rename from packages/web-kitchensink-reactnext/src/packages/react-wavesurfer/SpectrogramCanvas/index.tsx rename to showcases/web-kitchensink-reactnext/src/packages/react-wavesurfer/SpectrogramCanvas/index.tsx diff --git a/packages/web-kitchensink-reactnext/src/packages/react-wavesurfer/WaveformCanvas/index.tsx b/showcases/web-kitchensink-reactnext/src/packages/react-wavesurfer/WaveformCanvas/index.tsx similarity index 100% rename from packages/web-kitchensink-reactnext/src/packages/react-wavesurfer/WaveformCanvas/index.tsx rename to showcases/web-kitchensink-reactnext/src/packages/react-wavesurfer/WaveformCanvas/index.tsx diff --git a/packages/web-kitchensink-reactnext/src/packages/react-wavesurfer/index.ts b/showcases/web-kitchensink-reactnext/src/packages/react-wavesurfer/index.ts similarity index 100% rename from packages/web-kitchensink-reactnext/src/packages/react-wavesurfer/index.ts rename to showcases/web-kitchensink-reactnext/src/packages/react-wavesurfer/index.ts diff --git a/packages/web-kitchensink-reactnext/src/pages/_app.tsx b/showcases/web-kitchensink-reactnext/src/pages/_app.tsx similarity index 100% rename from packages/web-kitchensink-reactnext/src/pages/_app.tsx rename to showcases/web-kitchensink-reactnext/src/pages/_app.tsx diff --git a/packages/web-kitchensink-reactnext/src/pages/_document.tsx b/showcases/web-kitchensink-reactnext/src/pages/_document.tsx similarity index 100% rename from packages/web-kitchensink-reactnext/src/pages/_document.tsx rename to showcases/web-kitchensink-reactnext/src/pages/_document.tsx diff --git a/packages/web-kitchensink-reactnext/src/pages/api/hello.ts b/showcases/web-kitchensink-reactnext/src/pages/api/hello.ts similarity index 100% rename from packages/web-kitchensink-reactnext/src/pages/api/hello.ts rename to showcases/web-kitchensink-reactnext/src/pages/api/hello.ts diff --git a/packages/web-kitchensink-reactnext/src/pages/categories/action/index.tsx b/showcases/web-kitchensink-reactnext/src/pages/categories/action/index.tsx similarity index 100% rename from packages/web-kitchensink-reactnext/src/pages/categories/action/index.tsx rename to showcases/web-kitchensink-reactnext/src/pages/categories/action/index.tsx diff --git a/packages/web-kitchensink-reactnext/src/pages/categories/code/index.tsx b/showcases/web-kitchensink-reactnext/src/pages/categories/code/index.tsx similarity index 100% rename from packages/web-kitchensink-reactnext/src/pages/categories/code/index.tsx rename to showcases/web-kitchensink-reactnext/src/pages/categories/code/index.tsx diff --git a/packages/web-kitchensink-reactnext/src/pages/categories/freeform/index.tsx b/showcases/web-kitchensink-reactnext/src/pages/categories/freeform/index.tsx similarity index 100% rename from packages/web-kitchensink-reactnext/src/pages/categories/freeform/index.tsx rename to showcases/web-kitchensink-reactnext/src/pages/categories/freeform/index.tsx diff --git a/packages/web-kitchensink-reactnext/src/pages/categories/navigation/index.tsx b/showcases/web-kitchensink-reactnext/src/pages/categories/navigation/index.tsx similarity index 100% rename from packages/web-kitchensink-reactnext/src/pages/categories/navigation/index.tsx rename to showcases/web-kitchensink-reactnext/src/pages/categories/navigation/index.tsx diff --git a/packages/web-kitchensink-reactnext/src/pages/categories/number/index.tsx b/showcases/web-kitchensink-reactnext/src/pages/categories/number/index.tsx similarity index 100% rename from packages/web-kitchensink-reactnext/src/pages/categories/number/index.tsx rename to showcases/web-kitchensink-reactnext/src/pages/categories/number/index.tsx diff --git a/packages/web-kitchensink-reactnext/src/pages/categories/option/index.tsx b/showcases/web-kitchensink-reactnext/src/pages/categories/option/index.tsx similarity index 100% rename from packages/web-kitchensink-reactnext/src/pages/categories/option/index.tsx rename to showcases/web-kitchensink-reactnext/src/pages/categories/option/index.tsx diff --git a/packages/web-kitchensink-reactnext/src/pages/categories/presentation/index.tsx b/showcases/web-kitchensink-reactnext/src/pages/categories/presentation/index.tsx similarity index 100% rename from packages/web-kitchensink-reactnext/src/pages/categories/presentation/index.tsx rename to showcases/web-kitchensink-reactnext/src/pages/categories/presentation/index.tsx diff --git a/packages/web-kitchensink-reactnext/src/pages/examples/blog-post/index.tsx b/showcases/web-kitchensink-reactnext/src/pages/examples/blog-post/index.tsx similarity index 100% rename from packages/web-kitchensink-reactnext/src/pages/examples/blog-post/index.tsx rename to showcases/web-kitchensink-reactnext/src/pages/examples/blog-post/index.tsx diff --git a/packages/web-kitchensink-reactnext/src/pages/examples/registration-form/index.tsx b/showcases/web-kitchensink-reactnext/src/pages/examples/registration-form/index.tsx similarity index 97% rename from packages/web-kitchensink-reactnext/src/pages/examples/registration-form/index.tsx rename to showcases/web-kitchensink-reactnext/src/pages/examples/registration-form/index.tsx index 4494b56..0437806 100644 --- a/packages/web-kitchensink-reactnext/src/pages/examples/registration-form/index.tsx +++ b/showcases/web-kitchensink-reactnext/src/pages/examples/registration-form/index.tsx @@ -1,5 +1,5 @@ import { NextPage } from 'next'; -import * as Freeform from '../../../../../../categories/freeform/react/src'; +import * as Freeform from '@tesseract-design/web-freeform-react'; import * as Action from '@tesseract-design/web-action-react'; const RegistrationFormPage: NextPage = () => { diff --git a/packages/web-kitchensink-reactnext/src/pages/index.tsx b/showcases/web-kitchensink-reactnext/src/pages/index.tsx similarity index 100% rename from packages/web-kitchensink-reactnext/src/pages/index.tsx rename to showcases/web-kitchensink-reactnext/src/pages/index.tsx diff --git a/packages/web-kitchensink-reactnext/src/styles/globals.css b/showcases/web-kitchensink-reactnext/src/styles/globals.css similarity index 100% rename from packages/web-kitchensink-reactnext/src/styles/globals.css rename to showcases/web-kitchensink-reactnext/src/styles/globals.css diff --git a/packages/web-kitchensink-reactnext/src/styles/kitchen-sink.css b/showcases/web-kitchensink-reactnext/src/styles/kitchen-sink.css similarity index 100% rename from packages/web-kitchensink-reactnext/src/styles/kitchen-sink.css rename to showcases/web-kitchensink-reactnext/src/styles/kitchen-sink.css diff --git a/packages/web-kitchensink-reactnext/src/styles/theme.ts b/showcases/web-kitchensink-reactnext/src/styles/theme.ts similarity index 100% rename from packages/web-kitchensink-reactnext/src/styles/theme.ts rename to showcases/web-kitchensink-reactnext/src/styles/theme.ts diff --git a/packages/web-kitchensink-reactnext/src/utils/blob.ts b/showcases/web-kitchensink-reactnext/src/utils/blob.ts similarity index 54% rename from packages/web-kitchensink-reactnext/src/utils/blob.ts rename to showcases/web-kitchensink-reactnext/src/utils/blob.ts index 3880ac6..2a66b7e 100644 --- a/packages/web-kitchensink-reactnext/src/utils/blob.ts +++ b/showcases/web-kitchensink-reactnext/src/utils/blob.ts @@ -1,117 +1,8 @@ -import * as mimeTypes from 'mime-types'; import {getTextMetadata, TextMetadata} from '@modal-sh/text-utils'; import {getMetadataFromUrl as getImageMetadataFromUrl, ImageMetadata} from '@modal-sh/image-utils'; import {getMetadataFromUrl as getAudioMetadataFromUrl, AudioMetadata} from '@modal-sh/audio-utils'; import {getMetadataFromUrl as getVideoMetadataFromUrl, VideoMetadata} from '@modal-sh/video-utils'; -const MIME_TYPE_DESCRIPTIONS = { - 'image/gif': 'GIF Image', - 'image/jpeg': 'JPEG Image', - 'image/png': 'PNG Image', - 'image/tiff': 'TIFF Image', - 'image/svg+xml': 'SVG Image', - 'image/webp': 'WEBP Image', - 'audio/wav': 'WAVE Audio', - 'audio/ogg': 'OGG Audio', - 'audio/mpeg': 'MPEG Audio', - 'audio/mid': 'MIDI Track', - 'application/json': 'JSON Data', - 'application/xml': 'XML Data', - 'application/x-bittorrent': 'Torrent File', - 'application/x-zip-compressed': 'Compressed ZIP Archive', - 'application/x-x509-ca-cert': 'Certificate File', - 'application/x-tar': 'Compressed TAR Archive', - 'application/x-rar': 'Compressed RAR Archive', - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'Workbook', - 'application/vnd.openxmlformats-officedocument.presentationml.presentation': 'Slideshow Presentation', - 'application/msword': 'Microsoft Word Document', - 'application/pdf': 'PDF Document', - 'application/postscript': 'PostScript Document', - 'application/epub+zip': 'EPUB Document', - 'message/rfc822': 'Email Message', - 'video/mp4': 'MP4 Video', -} as const; - -const EXTENSION_DESCRIPTIONS = { - 'rar': 'Compressed RAR Archive', - '7z': 'Compressed 7-Zip Archive', - 'psd': 'Adobe Photoshop Document', - 'dmg': 'Disk Image', - 'fb2k-component': 'foobar2000 Component', -} as const; - -export const getMimeTypeDescription = (type?: string, filename?: string) => { - if (typeof (type as unknown) !== 'string') { - return ''; - } - - if (type === 'application/octet-stream' || type === '') { - if (typeof filename === 'string' && filename.includes('.')) { - const extension = filename.slice(filename.lastIndexOf('.') + '.'.length).toLowerCase(); - const { - [extension as keyof typeof EXTENSION_DESCRIPTIONS]: extensionDescription = `${extension.toUpperCase()} File`, - } = EXTENSION_DESCRIPTIONS; - - return extensionDescription; - } - return `${type} File`; - } - - const { - [type as keyof typeof MIME_TYPE_DESCRIPTIONS]: description = type, - } = MIME_TYPE_DESCRIPTIONS; - - return description; -} - -export enum ContentType { - TEXT = 'text', - AUDIO = 'audio', - VIDEO = 'video', - IMAGE = 'image', - BINARY = 'binary', -} - -export const getContentType = (mimeType?: string, filename?: string) => { - let effectiveMimeType: string; - if (typeof mimeType !== 'string') { - if (typeof filename !== 'string') { - return ContentType.BINARY; - } - const lookupMimeType = mimeTypes.lookup(filename); - - if (typeof lookupMimeType !== 'string') { - return ContentType.BINARY; - } - - effectiveMimeType = lookupMimeType; - } else { - effectiveMimeType = mimeType; - } - - if ( - effectiveMimeType === 'application/json' - || effectiveMimeType === 'application/xml' - || effectiveMimeType.startsWith('text/') - ) { - return ContentType.TEXT; - } - - if (effectiveMimeType.startsWith('video/')) { - return ContentType.VIDEO; - } - - if (effectiveMimeType.startsWith('audio/')) { - return ContentType.AUDIO; - } - - if (effectiveMimeType.startsWith('image/')) { - return ContentType.IMAGE; - } - - return ContentType.BINARY; -} - export const readAsDataURL = (blob: Partial) => new Promise((resolve, reject) => { // TODO when to revoke these URLs // return URL.createObjectURL(blob as Blob); diff --git a/packages/web-kitchensink-reactnext/src/utils/numeral.ts b/showcases/web-kitchensink-reactnext/src/utils/numeral.ts similarity index 100% rename from packages/web-kitchensink-reactnext/src/utils/numeral.ts rename to showcases/web-kitchensink-reactnext/src/utils/numeral.ts diff --git a/packages/web-kitchensink-reactnext/tailwind.config.js b/showcases/web-kitchensink-reactnext/tailwind.config.js similarity index 100% rename from packages/web-kitchensink-reactnext/tailwind.config.js rename to showcases/web-kitchensink-reactnext/tailwind.config.js diff --git a/packages/web-kitchensink-reactnext/tsconfig.json b/showcases/web-kitchensink-reactnext/tsconfig.json similarity index 100% rename from packages/web-kitchensink-reactnext/tsconfig.json rename to showcases/web-kitchensink-reactnext/tsconfig.json