Skip to content

Commit 933d43b

Browse files
create components package
1 parent f028d91 commit 933d43b

File tree

11 files changed

+256
-4
lines changed

11 files changed

+256
-4
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ apps/*/build
44
apps/*/dist
55
packages/*/build
66
packages/*/dist
7+
components/*/build
8+
components/*/dist
79

810
# Turborepo
911
.turbo

components/input/package.json

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
"name": "@method-inc/components/input",
3+
"version": "1.1.1",
4+
"description": "Method input",
5+
"license": "MIT",
6+
"author": "Method",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/method-inc/rnr-method.git"
10+
},
11+
"publishConfig": {
12+
"registry": "https://npm.pkg.github.com"
13+
},
14+
"bugs": {
15+
"url": "https://github.com/method-inc/rnr-method/issues"
16+
},
17+
"homepage": "https://github.com/method-inc/rnr-method#readme",
18+
"main": "dist/index.js",
19+
"module": "dist/index.mjs",
20+
"types": "dist/index.d.ts",
21+
"exports": {
22+
".": {
23+
"import": "./dist/index.mjs",
24+
"require": "./dist/index.js",
25+
"types": "./dist/index.d.ts",
26+
"default": "./dist/index.js"
27+
},
28+
"./dist/input": {
29+
"import": "./dist/input.mjs",
30+
"require": "./dist/input.js",
31+
"types": "./dist/input.d.ts",
32+
"default": "./dist/input.js"
33+
}
34+
},
35+
"files": [
36+
"dist"
37+
],
38+
"scripts": {
39+
"build": "tsup",
40+
"dev": "tsup --watch",
41+
"clean": "rm -rf dist",
42+
"pub:beta": "pnpm publish --no-git-checks --access public --tag beta",
43+
"pub:next": "pnpm publish --no-git-checks --access public --tag next",
44+
"pub:release": "pnpm publish --access public"
45+
},
46+
"dependencies": {
47+
"@radix-ui/react-label": "^2.1.0",
48+
"@method-inc/slot": "workspace:*",
49+
"@method-inc/types": "workspace:*",
50+
"@method-inc/utils": "workspace:*",
51+
"class-variance-authority": "^0.7.0",
52+
"clsx": "^2.0.0",
53+
"lucide-react": "^0.279.0",
54+
"nativewind": "^4.1.23"
55+
},
56+
"devDependencies": {
57+
"@tsconfig/react-native": "^1.0.1",
58+
"@types/react": "~18.3.12",
59+
"@types/react-native-web": "^0.19.0",
60+
"autoprefixer": "10.4.15",
61+
"postcss": "8.4.30",
62+
"react": "18.3.1",
63+
"react-native": "0.76.3",
64+
"tailwindcss": "3.3.3",
65+
"tsup": "^8.1.0"
66+
},
67+
"peerDependencies": {
68+
"react": "*",
69+
"react-native": "*",
70+
"react-native-web": "*"
71+
},
72+
"peerDependenciesMeta": {
73+
"react-native": {
74+
"optional": true
75+
},
76+
"react-native-web": {
77+
"optional": true
78+
}
79+
}
80+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="nativewind/types" />

components/input/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './input';
2+
export * from './types';

components/input/src/input.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import * as React from 'react';
2+
import { TextInput, type TextInputProps } from 'react-native';
3+
import { cn } from '@method-inc/utils';
4+
5+
const Input = React.forwardRef<React.ElementRef<typeof TextInput>, TextInputProps>(
6+
({ className, placeholderClassName, ...props }, ref) => {
7+
return (
8+
<TextInput
9+
ref={ref}
10+
className={cn(
11+
'web:flex h-12 native:h-14 web:w-full rounded-md border border-input bg-background px-3 web:py-2 text-base lg:text-sm native:text-lg native:leading-[1.25] text-foreground placeholder:text-muted-foreground web:ring-offset-background file:border-0 file:bg-transparent file:font-medium web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2',
12+
props.editable === false && 'opacity-50 web:cursor-not-allowed',
13+
className
14+
)}
15+
placeholderClassName={cn('text-muted-foreground', placeholderClassName)}
16+
{...props}
17+
/>
18+
);
19+
}
20+
);
21+
22+
Input.displayName = 'Input';
23+
24+
export { Input };

components/input/src/types.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import type {
2+
PressableRef,
3+
SlottablePressableProps,
4+
SlottableTextProps,
5+
TextRef,
6+
} from '@method-inc/types';
7+
import type { ViewStyle } from 'react-native';
8+
9+
type RootProps = Omit<SlottablePressableProps, 'children' | 'hitSlop' | 'style'> & {
10+
children: React.ReactNode;
11+
style?: ViewStyle;
12+
};
13+
14+
type ExampleComponentProps = SlottableTextProps & {
15+
/**
16+
* Equivalent to `id` so that the same value can be passed as `aria-labelledby` to the input element.
17+
*/
18+
nativeID?: string;
19+
/**
20+
* WEB ONLY
21+
*/
22+
htmlFor?: string;
23+
};
24+
25+
type RootRef = PressableRef;
26+
27+
export type { RootProps, RootRef, ExampleComponentProps, TextRef };

components/input/tsconfig.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"extends": "@tsconfig/react-native/tsconfig.json",
3+
"jsxImportSource": "nativewind",
4+
"jsx": "preserve",
5+
"include": [
6+
"./src/**/*",
7+
"nativewind-env.d.ts"
8+
],
9+
"compilerOptions": {
10+
"lib": [
11+
"dom",
12+
"es2019",
13+
"es2020.bigint",
14+
"es2020.date",
15+
"es2020.number",
16+
"es2020.promise",
17+
"es2020.string",
18+
"es2020.symbol.wellknown",
19+
"es2021.promise",
20+
"es2021.string",
21+
"es2021.weakref",
22+
"es2022.array",
23+
"es2022.object",
24+
"es2022.string"
25+
],
26+
"types": [
27+
"react-native-web"
28+
],
29+
"paths": {
30+
"react-native": [
31+
"react-native-web"
32+
]
33+
}
34+
},
35+
"exclude": [
36+
"dist",
37+
"build",
38+
"node_modules"
39+
]
40+
}

components/input/tsup.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { defineConfig, Options } from 'tsup';
2+
3+
export default defineConfig((options: Options) => ({
4+
entry: ['src/index.ts', 'src/input.tsx'],
5+
banner: {
6+
js: "'use client'",
7+
},
8+
clean: true,
9+
format: ['cjs', 'esm'],
10+
external: ['react', './input'],
11+
dts: true,
12+
...options,
13+
esbuildOptions(options) {
14+
options.jsx = 'preserve';
15+
},
16+
}));

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
"scripts": {
55
"dev": "turbo dev --concurrency=34",
66
"dev:primitives": "turbo dev --filter=./packages/* --concurrency=34",
7+
"dev:components": "turbo dev --filter=./components/* --concurrency=34",
78
"dev:expo-nativewind": "turbo dev --filter=./apps/expo-nativewind",
89
"dev:nextjs-nativewind": "turbo dev --filter=./apps/nextjs-nativewind",
910
"dev:docs": "turbo dev --filter=./apps/docs",
1011
"lint": "turbo lint",
1112
"test": "turbo test",
12-
"build": "turbo build --filter=./packages/*",
13+
"build": "turbo build --filter=./packages/* && turbo build --filter=./components/*",
1314
"build:docs": "turbo build --filter=./apps/docs",
1415
"build:expo-nativewind": "turbo build --filter=\"...{./apps/expo-nativewind}\"",
1516
"publish-all:primitives:next": "turbo pub:next --filter=./packages/* --concurrency=34",

pnpm-lock.yaml

Lines changed: 61 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)