Browse Source

Update dependencies

Extract react-utils to separate project, update imports.
master
TheoryOfNekomata 1 month ago
parent
commit
1198ce95a8
24 changed files with 58 additions and 497 deletions
  1. +1
    -1
      categories/web/blob/react/package.json
  2. +1
    -1
      categories/web/choice/react/package.json
  3. +2
    -2
      categories/web/formatted/react/package.json
  4. +1
    -1
      categories/web/freeform/react/package.json
  5. +1
    -1
      categories/web/multichoice/react/package.json
  6. +1
    -1
      categories/web/number/react/package.json
  7. +1
    -1
      categories/web/temporal/react/package.json
  8. +9
    -0
      package.json
  9. +4
    -1
      packages/react-blob-previews/package.json
  10. +0
    -9
      packages/react-utils/.eslintrc
  11. +0
    -107
      packages/react-utils/.gitignore
  12. +0
    -7
      packages/react-utils/LICENSE
  13. +0
    -77
      packages/react-utils/package.json
  14. +0
    -3
      packages/react-utils/pridepack.json
  15. +0
    -37
      packages/react-utils/src/event.ts
  16. +0
    -16
      packages/react-utils/src/hooks/browser.ts
  17. +0
    -18
      packages/react-utils/src/hooks/client-side.ts
  18. +0
    -94
      packages/react-utils/src/hooks/form.ts
  19. +0
    -6
      packages/react-utils/src/hooks/id.ts
  20. +0
    -4
      packages/react-utils/src/index.ts
  21. +0
    -21
      packages/react-utils/tsconfig.eslint.json
  22. +0
    -21
      packages/react-utils/tsconfig.json
  23. +0
    -8
      packages/react-utils/vitest.config.ts
  24. +37
    -60
      pnpm-lock.yaml

+ 1
- 1
categories/web/blob/react/package.json View File

@@ -62,7 +62,7 @@
"access": "public"
},
"dependencies": {
"@modal-sh/react-utils": "workspace:*",
"@modal-sh/react-utils": "0.0.0",
"@tesseract-design/web-base": "workspace:*"
},
"types": "./dist/types/index.d.ts",


+ 1
- 1
categories/web/choice/react/package.json View File

@@ -62,7 +62,7 @@
"access": "public"
},
"dependencies": {
"@modal-sh/react-utils": "workspace:*",
"@modal-sh/react-utils": "0.0.0",
"@tesseract-design/web-base": "workspace:*"
},
"types": "./dist/types/index.d.ts",


+ 2
- 2
categories/web/formatted/react/package.json View File

@@ -62,9 +62,9 @@
"access": "public"
},
"dependencies": {
"@modal-sh/react-utils": "workspace:*",
"@modal-sh/react-utils": "0.0.0",
"@tesseract-design/web-base": "workspace:*",
"react-phone-number-input": "^3.3.0"
"react-phone-number-input": "3.3.0"
},
"types": "./dist/types/index.d.ts",
"main": "./dist/cjs/production/index.js",


+ 1
- 1
categories/web/freeform/react/package.json View File

@@ -62,7 +62,7 @@
"access": "public"
},
"dependencies": {
"@modal-sh/react-utils": "workspace:*",
"@modal-sh/react-utils": "0.0.0",
"@tesseract-design/web-base": "workspace:*"
},
"types": "./dist/types/index.d.ts",


+ 1
- 1
categories/web/multichoice/react/package.json View File

@@ -62,7 +62,7 @@
"access": "public"
},
"dependencies": {
"@modal-sh/react-utils": "workspace:*",
"@modal-sh/react-utils": "0.0.0",
"@tesseract-design/web-base": "workspace:*"
},
"types": "./dist/types/index.d.ts",


+ 1
- 1
categories/web/number/react/package.json View File

@@ -62,7 +62,7 @@
"access": "public"
},
"dependencies": {
"@modal-sh/react-utils": "workspace:*",
"@modal-sh/react-utils": "0.0.0",
"@tesseract-design/web-base": "workspace:*"
},
"types": "./dist/types/index.d.ts",


+ 1
- 1
categories/web/temporal/react/package.json View File

@@ -62,7 +62,7 @@
"access": "public"
},
"dependencies": {
"@modal-sh/react-utils": "workspace:*",
"@modal-sh/react-utils": "0.0.0",
"@tesseract-design/web-base": "workspace:*"
},
"types": "./dist/types/index.d.ts",


+ 9
- 0
package.json View File

@@ -0,0 +1,9 @@
{
"name": "@tesseract-design/web",
"version": "1.0.0",
"pnpm": {
"overrides": {
"@modal-sh/react-utils": "file:../react-utils"
}
}
}

+ 4
- 1
packages/react-blob-previews/package.json View File

@@ -1,5 +1,5 @@
{
"name": "@modal-sh/react-utils",
"name": "@modal-sh/react-blob-previews",
"version": "0.0.0",
"files": [
"dist",
@@ -12,6 +12,9 @@
"keywords": [
"pridepack"
],
"dependencies": {
"@modal-sh/react-utils": "0.0.0"
},
"devDependencies": {
"@storybook/react": "^7.3.2",
"@testing-library/jest-dom": "^5.16.5",


+ 0
- 9
packages/react-utils/.eslintrc View File

@@ -1,9 +0,0 @@
{
"root": true,
"extends": [
"lxsmnsyc/typescript/react"
],
"parserOptions": {
"project": "./tsconfig.eslint.json"
}
}

+ 0
- 107
packages/react-utils/.gitignore View File

@@ -1,107 +0,0 @@
# 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

+ 0
- 7
packages/react-utils/LICENSE View File

@@ -1,7 +0,0 @@
MIT License Copyright (c) 2023 TheoryOfNekomata <allan.crisostomo@outlook.com>

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.

+ 0
- 77
packages/react-utils/package.json View File

@@ -1,77 +0,0 @@
{
"name": "@modal-sh/react-utils",
"version": "0.0.0",
"files": [
"dist",
"src"
],
"engines": {
"node": ">=12"
},
"license": "MIT",
"keywords": [
"pridepack"
],
"devDependencies": {
"@storybook/react": "^7.3.2",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@types/node": "^18.14.1",
"@types/react": "^18.2.18",
"eslint": "^8.35.0",
"eslint-config-lxsmnsyc": "^0.5.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 <allan.crisostomo@outlook.com>",
"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": {
"*": {}
}
}

+ 0
- 3
packages/react-utils/pridepack.json View File

@@ -1,3 +0,0 @@
{
"target": "es2018"
}

+ 0
- 37
packages/react-utils/src/event.ts View File

@@ -1,37 +0,0 @@
export const delegateTriggerEvent = <T extends HTMLElement>(
eventName: string,
target: T,
value?: unknown,
) => {
if (typeof window === 'undefined') {
return;
}

const TAG_NAME_ELEMENT_CONSTRUCTOR = {
'INPUT': window.HTMLInputElement,
'SELECT': window.HTMLSelectElement,
'TEXTAREA': window.HTMLTextAreaElement,
} as const;

const {
[target.tagName as keyof typeof TAG_NAME_ELEMENT_CONSTRUCTOR]: elementCtor,
} = TAG_NAME_ELEMENT_CONSTRUCTOR;

if (!elementCtor) {
return;
}

if (eventName === 'change') {
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(elementCtor.prototype, 'value')?.set;
if (nativeInputValueSetter) {
if (
(target.tagName === 'INPUT' && (target as unknown as HTMLInputElement).type !== 'file')
|| target.tagName !== 'INPUT'
) {
nativeInputValueSetter.call(target, value);
}
const simulatedEvent = new Event(eventName, {bubbles: true});
target.dispatchEvent(simulatedEvent);
}
}
};

+ 0
- 16
packages/react-utils/src/hooks/browser.ts View File

@@ -1,16 +0,0 @@
import * as React from 'react';

export const useBrowser = () => {
const [browser, setBrowser] = React.useState<string>();
React.useEffect(() => {
const isFirefox = typeof (window as unknown as Record<string, unknown>).InstallTrigger !== 'undefined';
if (isFirefox) {
setBrowser('firefox');
} else {
// TODO - detect other browsers
setBrowser('chrome');
}
}, []);

return React.useMemo(() => browser, [browser]);
};

+ 0
- 18
packages/react-utils/src/hooks/client-side.ts View File

@@ -1,18 +0,0 @@
import * as React from 'react';

export interface UseEnhancedOptions {
clientSide: boolean;
initial?: boolean;
}

export const useClientSide = (options: UseEnhancedOptions) => {
const { clientSide: enhancedProp, initial = false } = options;
const [enhanced, setEnhanced] = React.useState(initial);
React.useEffect(() => {
setEnhanced(enhancedProp);
}, [enhancedProp]);

return React.useMemo(() => ({
clientSide: enhanced,
}), [enhanced]);
};

+ 0
- 94
packages/react-utils/src/hooks/form.ts View File

@@ -1,94 +0,0 @@
import * as React from 'react';
import { delegateTriggerEvent } from '../event';

type ValueType = string | number | readonly string[];

interface HTMLElementWithValue extends HTMLElement {
value: ValueType;
}

export interface UseProxyInputOptions<
ForwardedRef extends HTMLElementWithValue,
Value = ValueType,
> {
forwardedRef: React.Ref<ForwardedRef>;
valueSetterFn: (value: Value) => void;
transformChangeHandlerArgs?: (value: Value) => ValueType;
}

export const useProxyInput = <
TheValueType = ValueType,
ForwardedRefType extends HTMLElementWithValue = HTMLElementWithValue,
DefaultRefType extends HTMLElementWithValue = ForwardedRefType,
>(options: UseProxyInputOptions<ForwardedRefType, TheValueType>) => {
const {
forwardedRef,
valueSetterFn,
transformChangeHandlerArgs = (e) => e as ValueType,
} = options;
const defaultRef = React.useRef<DefaultRefType>(null);

React.useEffect(() => {
const { current: currentRaw } = defaultRef;
const current = currentRaw as unknown as ForwardedRefType;
const forwardedRefProxy = new Proxy(current, {
get(target, prop, receiver) {
return Reflect.get(target, prop, receiver) as unknown;
},
set(target, prop, newValue, receiver) {
if (prop === 'value') {
const thisNewValue = newValue as TheValueType;
const actualNewValue = (
Array.isArray(thisNewValue) ? thisNewValue.join('') : thisNewValue?.toString() ?? ''
) as TheValueType;
valueSetterFn(actualNewValue);
current.value = actualNewValue as string;
return true;
}
return Reflect.set(target, prop, newValue, receiver);
},
}) as unknown as ForwardedRefType;

if (typeof forwardedRef === 'function') {
forwardedRef(forwardedRefProxy);
return;
}

if (typeof forwardedRef === 'object' && forwardedRef) {
const mutableForwardedRef = forwardedRef as React.MutableRefObject<ForwardedRefType>;
mutableForwardedRef.current = forwardedRefProxy;
}
});

// todo Handle input event

// do we need to expose this? or is defaultref enough?
// maybe we could attach the event listener to the defaultRef instead of exposing a handler (as
// long as target element exposes a ref)

// why do we have to do all this? because we want to proxy event handlers to fallback elements.
// fallback elements ensure server-side compatibility--with this, we can serialize every value
// that can be inputted in every custom control. (see graceful degradation)
const handleChange = React.useCallback((e: TheValueType) => {
if (!(typeof defaultRef === 'object' && defaultRef)) {
return;
}
const { current: input } = defaultRef;
if (!input) {
return;
}
const transformedValue = transformChangeHandlerArgs(e);
valueSetterFn(e);
setTimeout(() => {
delegateTriggerEvent('change', input, transformedValue);
});
}, [valueSetterFn, transformChangeHandlerArgs, defaultRef]);

return React.useMemo(() => ({
defaultRef,
handleChange,
}), [
defaultRef,
handleChange,
]);
};

+ 0
- 6
packages/react-utils/src/hooks/id.ts View File

@@ -1,6 +0,0 @@
import * as React from 'react';

export const useFallbackId = (id?: string) => {
const defaultId = React.useId();
return id || defaultId;
};

+ 0
- 4
packages/react-utils/src/index.ts View File

@@ -1,4 +0,0 @@
export * from './hooks/browser';
export * from './hooks/client-side';
export * from './hooks/form';
export * from './hooks/id';

+ 0
- 21
packages/react-utils/tsconfig.eslint.json View File

@@ -1,21 +0,0 @@
{
"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"
}
}

+ 0
- 21
packages/react-utils/tsconfig.json View File

@@ -1,21 +0,0 @@
{
"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"
}
}

+ 0
- 8
packages/react-utils/vitest.config.ts View File

@@ -1,8 +0,0 @@
/// <reference types="vitest" />

export default ({
test: {
global: true,
environment: 'jsdom',
},
});

+ 37
- 60
pnpm-lock.yaml View File

@@ -4,8 +4,13 @@ settings:
autoInstallPeers: true
excludeLinksFromLockfile: false

overrides:
'@modal-sh/react-utils': file:../react-utils

importers:

.: {}

base:
dependencies:
clsx:
@@ -107,8 +112,8 @@ importers:
categories/web/blob/react:
dependencies:
'@modal-sh/react-utils':
specifier: workspace:*
version: link:../../../../packages/react-utils
specifier: file:/Users/theoryofnekomata/Projects/react-utils
version: file:../react-utils(react-dom@18.2.0)(react@18.2.0)
'@tesseract-design/web-base':
specifier: workspace:*
version: link:../../../../base
@@ -171,8 +176,8 @@ importers:
categories/web/choice/react:
dependencies:
'@modal-sh/react-utils':
specifier: workspace:*
version: link:../../../../packages/react-utils
specifier: file:/Users/theoryofnekomata/Projects/react-utils
version: file:../react-utils(react-dom@18.2.0)(react@18.2.0)
'@tesseract-design/web-base':
specifier: workspace:*
version: link:../../../../base
@@ -308,13 +313,13 @@ importers:
categories/web/formatted/react:
dependencies:
'@modal-sh/react-utils':
specifier: workspace:*
version: link:../../../../packages/react-utils
specifier: file:/Users/theoryofnekomata/Projects/react-utils
version: file:../react-utils(react-dom@18.2.0)(react@18.2.0)
'@tesseract-design/web-base':
specifier: workspace:*
version: link:../../../../base
react-phone-number-input:
specifier: ^3.3.0
specifier: 3.3.0
version: 3.3.0(react-dom@18.2.0)(react@18.2.0)
devDependencies:
'@storybook/react':
@@ -375,8 +380,8 @@ importers:
categories/web/freeform/react:
dependencies:
'@modal-sh/react-utils':
specifier: workspace:*
version: link:../../../../packages/react-utils
specifier: file:/Users/theoryofnekomata/Projects/react-utils
version: file:../react-utils(react-dom@18.2.0)(react@18.2.0)
'@tesseract-design/web-base':
specifier: workspace:*
version: link:../../../../base
@@ -500,8 +505,8 @@ importers:
categories/web/multichoice/react:
dependencies:
'@modal-sh/react-utils':
specifier: workspace:*
version: link:../../../../packages/react-utils
specifier: file:/Users/theoryofnekomata/Projects/react-utils
version: file:../react-utils(react-dom@18.2.0)(react@18.2.0)
'@tesseract-design/web-base':
specifier: workspace:*
version: link:../../../../base
@@ -625,8 +630,8 @@ importers:
categories/web/number/react:
dependencies:
'@modal-sh/react-utils':
specifier: workspace:*
version: link:../../../../packages/react-utils
specifier: file:/Users/theoryofnekomata/Projects/react-utils
version: file:../react-utils(react-dom@18.2.0)(react@18.2.0)
'@tesseract-design/web-base':
specifier: workspace:*
version: link:../../../../base
@@ -689,8 +694,8 @@ importers:
categories/web/temporal/react:
dependencies:
'@modal-sh/react-utils':
specifier: workspace:*
version: link:../../../../packages/react-utils
specifier: file:/Users/theoryofnekomata/Projects/react-utils
version: file:../react-utils(react-dom@18.2.0)(react@18.2.0)
'@tesseract-design/web-base':
specifier: workspace:*
version: link:../../../../base
@@ -953,6 +958,10 @@ importers:
version: 0.28.1

packages/react-blob-previews:
dependencies:
'@modal-sh/react-utils':
specifier: file:/Users/theoryofnekomata/Projects/react-utils
version: file:../react-utils(react-dom@18.2.0)(react@18.2.0)
devDependencies:
'@storybook/react':
specifier: ^7.3.2
@@ -1058,51 +1067,6 @@ importers:
specifier: ^0.28.1
version: 0.28.1

packages/react-utils:
devDependencies:
'@storybook/react':
specifier: ^7.3.2
version: 7.4.0(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5)
'@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.2.18
version: 18.2.18
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)
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

packages/react-wavesurfer:
dependencies:
'@tesseract-design/web-base':
@@ -9395,3 +9359,16 @@ packages:
resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==}
engines: {node: '>=12.20'}
dev: true

file:../react-utils(react-dom@18.2.0)(react@18.2.0):
resolution: {directory: ../react-utils, type: directory}
id: file:../react-utils
name: '@modal-sh/react-utils'
engines: {node: '>=12'}
peerDependencies:
react: ^16.8 || ^17.0 || ^18.0
react-dom: ^16.8 || ^17.0 || ^18.0
dependencies:
react: 18.2.0
react-dom: 18.2.0(react@18.2.0)
dev: false

Loading…
Cancel
Save