Skip to content

Commit

Permalink
feat: tool dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1230 committed Apr 19, 2024
1 parent 52d2cfb commit 08500bd
Show file tree
Hide file tree
Showing 22 changed files with 1,008 additions and 499 deletions.
Binary file modified client/bun.lockb
Binary file not shown.
259 changes: 130 additions & 129 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -1,131 +1,132 @@
{
"name": "mychat",
"main": "expo-router/entry",
"version": "1.0.0",
"scripts": {
"start": "APP_VARIANT=development expo start",
"start:clean": "APP_VARIANT=development expo start -c",
"android": "expo run:android",
"ios": "expo run:ios",
"web": "expo start --web",
"test": "jest --watchAll",
"export": "expo export -p web",
"build": "expo run:ios --no-build-cache",
"build:dev": "APP_VARIANT=development expo run:ios --device --no-build-cache",
"build:prev": "APP_VARIANT=preview expo run:ios --device",
"build:sign": "APP_VARIANT=preview eas build -e preview -p ios",
"analyze:web": "source-map-explorer 'dist/_expo/static/js/web/*.js' 'dist/_expo/static/js/web/*.js.map'",
"analyze:ios": "source-map-explorer 'dist/_expo/static/js/ios/*.js' 'dist/_expo/static/js/ios/*.js.map'",
"postinstall": "patch-package",
"tsc": "tsc",
"lint": "eslint ."
},
"jest": {
"preset": "jest-expo",
"extends": [
"react-app",
"react-app/jest"
]
},
"dependencies": {
"@expo/metro-runtime": "^3.1.3",
"@expo/vector-icons": "^14.0.0",
"@hookform/resolvers": "^3.3.4",
"@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-switch": "^1.0.3",
"@react-native-async-storage/async-storage": "1.23.1",
"@react-native-community/netinfo": "^11.3.1",
"@react-navigation/drawer": "^6.6.15",
"@react-navigation/elements": "^1.3.30",
"@react-navigation/native": "^6.1.17",
"@react-navigation/native-stack": "^6.9.26",
"@shopify/flash-list": "^1.6.4",
"@tanstack/query-async-storage-persister": "^5.29.1",
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-persist-client": "^5.29.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"cmdk": "^1.0.0",
"expo": "~50.0.17",
"expo-clipboard": "~5.0.1",
"expo-dev-client": "~3.3.11",
"expo-document-picker": "^11.10.1",
"expo-font": "~11.10.3",
"expo-haptics": "~12.8.1",
"expo-image": "~1.10.6",
"expo-linking": "~6.2.2",
"expo-network": "^5.8.0",
"expo-router": "~3.4.8",
"expo-splash-screen": "~0.26.4",
"expo-status-bar": "~1.11.1",
"expo-system-ui": "~2.9.4",
"expo-updates": "^0.24.12",
"expo-web-browser": "~12.8.2",
"gpt4-tokenizer": "^1.3.0",
"nativewind": "^4.0.1",
"openai": "^4.38.1",
"patch-package": "^8.0.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hook-form": "^7.51.3",
"react-native": "0.73.7",
"react-native-animation-library": "^0.0.8",
"react-native-drawer-layout": "^3.3.0",
"react-native-fetch-api": "^3.0.0",
"react-native-gesture-handler": "~2.16.0",
"react-native-ios-context-menu": "^2.5.1",
"react-native-ios-utilities": "^4.4.5",
"react-native-markdown-display": "^7.0.2",
"react-native-react-query-devtools": "^1.1.0",
"react-native-reanimated": "~3.8.1",
"react-native-root-siblings": "^5.0.1",
"react-native-safe-area-context": "4.9.0",
"react-native-screens": "~3.30.1",
"react-native-svg": "^15.1.0",
"react-native-toast-message": "^2.2.0",
"react-native-url-polyfill": "^2.0.0",
"react-native-vector-icons": "^10.0.3",
"react-native-web": "~0.19.10",
"react-syntax-highlighter": "^15.5.0",
"react-textarea-autosize": "^8.5.3",
"tailwind-merge": "^2.3.0",
"tailwindcss": "^3.4.3",
"tailwindcss-animate": "^1.0.7",
"text-encoding": "^0.7.0",
"web-streams-polyfill": "^4.0.0",
"zod": "^3.22.5",
"zustand": "^4.5.2"
},
"devDependencies": {
"@babel/core": "^7.24.4",
"@tanstack/eslint-plugin-query": "^5.28.11",
"@types/bun": "^1.1.0",
"@types/react": "~18.2.79",
"@types/react-dom": "^18.2.25",
"@types/react-syntax-highlighter": "^15.5.11",
"@types/text-encoding": "^0.0.39",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/parser": "^7.7.0",
"ajv": "^8.12.0",
"eslint": "8.57.0",
"eslint-config-react-app": "^7.0.1",
"jest": "^29.7.0",
"jest-expo": "~50.0.4",
"react-test-renderer": "18.2.0",
"source-map-explorer": "^2.5.3",
"typescript": "next"
},
"resolutions": {
"@typescript-eslint/eslint-plugin": "^7.7.0",
"react": "^18.2",
"react-native": "^0.73",
"react-native-svg": "^15.1.0",
"typescript": "next"
},
"private": true
"name": "mychat",
"main": "expo-router/entry",
"version": "1.0.0",
"scripts": {
"start": "APP_VARIANT=development expo start",
"start:clean": "APP_VARIANT=development expo start -c",
"android": "expo run:android",
"ios": "expo run:ios",
"web": "expo start --web",
"test": "jest --watchAll",
"export": "expo export -p web",
"build": "expo run:ios --no-build-cache",
"build:dev": "APP_VARIANT=development expo run:ios --device --no-build-cache",
"build:prev": "APP_VARIANT=preview expo run:ios --device",
"build:sign": "APP_VARIANT=preview eas build -e preview -p ios",
"analyze:web": "source-map-explorer 'dist/_expo/static/js/web/*.js' 'dist/_expo/static/js/web/*.js.map'",
"analyze:ios": "source-map-explorer 'dist/_expo/static/js/ios/*.js' 'dist/_expo/static/js/ios/*.js.map'",
"postinstall": "patch-package",
"tsc": "tsc",
"lint": "eslint ."
},
"jest": {
"preset": "jest-expo",
"extends": [
"react-app",
"react-app/jest"
]
},
"dependencies": {
"@expo/metro-runtime": "^3.1.3",
"@expo/vector-icons": "^14.0.0",
"@hookform/resolvers": "^3.3.4",
"@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-switch": "^1.0.3",
"@react-native-async-storage/async-storage": "1.23.1",
"@react-native-community/netinfo": "^11.3.1",
"@react-navigation/drawer": "^6.6.15",
"@react-navigation/elements": "^1.3.30",
"@react-navigation/native": "^6.1.17",
"@react-navigation/native-stack": "^6.9.26",
"@shopify/flash-list": "^1.6.4",
"@tanstack/query-async-storage-persister": "^5.29.1",
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-persist-client": "^5.29.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"cmdk": "^1.0.0",
"expo": "~50.0.17",
"expo-clipboard": "~5.0.1",
"expo-dev-client": "~3.3.11",
"expo-document-picker": "^11.10.1",
"expo-font": "~11.10.3",
"expo-haptics": "~12.8.1",
"expo-image": "~1.10.6",
"expo-linking": "~6.2.2",
"expo-network": "^5.8.0",
"expo-router": "~3.4.8",
"expo-splash-screen": "~0.26.4",
"expo-status-bar": "~1.11.1",
"expo-system-ui": "~2.9.4",
"expo-updates": "^0.24.12",
"expo-web-browser": "~12.8.2",
"gpt4-tokenizer": "^1.3.0",
"nativewind": "^4.0.1",
"openai": "^4.38.1",
"patch-package": "^8.0.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hook-form": "^7.51.3",
"react-native": "0.73.7",
"react-native-animation-library": "^0.0.8",
"react-native-drawer-layout": "^3.3.0",
"react-native-fetch-api": "^3.0.0",
"react-native-gesture-handler": "~2.16.0",
"react-native-ios-context-menu": "^2.5.1",
"react-native-ios-utilities": "^4.4.5",
"react-native-markdown-display": "^7.0.2",
"react-native-react-query-devtools": "^1.1.0",
"react-native-reanimated": "~3.8.1",
"react-native-root-siblings": "^5.0.1",
"react-native-safe-area-context": "4.9.0",
"react-native-screens": "~3.30.1",
"react-native-svg": "^15.1.0",
"react-native-toast-message": "^2.2.0",
"react-native-url-polyfill": "^2.0.0",
"react-native-vector-icons": "^10.0.3",
"react-native-web": "~0.19.10",
"react-syntax-highlighter": "^15.5.0",
"react-textarea-autosize": "^8.5.3",
"tailwind-merge": "^2.3.0",
"tailwindcss": "^3.4.3",
"tailwindcss-animate": "^1.0.7",
"text-encoding": "^0.7.0",
"web-streams-polyfill": "^4.0.0",
"zod": "^3.22.5",
"zustand": "^4.5.2"
},
"devDependencies": {
"@babel/core": "^7.24.4",
"@tanstack/eslint-plugin-query": "^5.28.11",
"@types/bun": "^1.1.0",
"@types/react": "~18.2.79",
"@types/react-dom": "^18.2.25",
"@types/react-syntax-highlighter": "^15.5.11",
"@types/text-encoding": "^0.0.39",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/parser": "^7.7.0",
"ajv": "^8.12.0",
"eslint": "8.57.0",
"eslint-config-react-app": "^7.0.1",
"jest": "^29.7.0",
"jest-expo": "~50.0.4",
"react-test-renderer": "18.2.0",
"source-map-explorer": "^2.5.3",
"typescript": "next"
},
"resolutions": {
"@typescript-eslint/eslint-plugin": "^7.7.0",
"react": "^18.2",
"react-native": "^0.73",
"react-native-svg": "^15.1.0",
"typescript": "next"
},
"private": true
}
109 changes: 109 additions & 0 deletions client/src/components/primitives/checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/* eslint-disable jsx-a11y/role-supports-aria-props */
import * as React from "react";
import { GestureResponderEvent, Pressable, View } from "react-native";
import * as Slot from "@/components/primitives/slot";
import type {
ComponentPropsWithAsChild,
PressableRef,
SlottablePressableProps,
} from "@/components/primitives/types";
import type { CheckboxIndicator, CheckboxRootProps } from "./types";

interface RootContext extends CheckboxRootProps {
nativeID?: string;
}

const CheckboxContext = React.createContext<RootContext | null>(null);

const Root = React.forwardRef<PressableRef, SlottablePressableProps & CheckboxRootProps>(
(
{ asChild, disabled = false, checked, onCheckedChange, nativeID, ...props },
ref
) => {
return (
<CheckboxContext.Provider
value={{
disabled,
checked,
onCheckedChange,
nativeID,
}}
>
<Trigger ref={ref} {...props} />
</CheckboxContext.Provider>
);
}
);

Root.displayName = "RootNativeCheckbox";

function useCheckboxContext() {
const context = React.useContext(CheckboxContext);
if (!context) {
throw new Error(
"Checkbox compound components cannot be rendered outside the Checkbox component"
);
}
return context;
}

const Trigger = React.forwardRef<PressableRef, SlottablePressableProps>(
({ asChild, onPress: onPressProp, ...props }, ref) => {
const { disabled, checked, onCheckedChange, nativeID } = useCheckboxContext();

function onPress(ev: GestureResponderEvent) {
if (disabled) return;
const newValue = !checked;
onCheckedChange(newValue);
onPressProp?.(ev);
}

const Component = asChild ? Slot.Pressable : Pressable;
return (
<Component
ref={ref}
nativeID={nativeID}
aria-disabled={disabled}
role="checkbox"
aria-checked={checked}
onPress={onPress}
accessibilityState={{
checked,
disabled,
}}
disabled={disabled}
{...props}
/>
);
}
);

Trigger.displayName = "TriggerNativeCheckbox";

const Indicator = React.forwardRef<
React.ElementRef<typeof View>,
ComponentPropsWithAsChild<typeof View> & CheckboxIndicator
>(({ asChild, forceMount, ...props }, ref) => {
const { checked, disabled } = useCheckboxContext();

if (!forceMount) {
if (!checked) {
return null;
}
}

const Component = asChild ? Slot.View : View;
return (
<Component
ref={ref}
aria-disabled={disabled}
aria-hidden={!(forceMount || checked)}
role={"presentation"}
{...props}
/>
);
});

Indicator.displayName = "IndicatorNativeCheckbox";

export { Indicator, Root };
Loading

0 comments on commit 08500bd

Please sign in to comment.