@twintag/twintag-form 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
+ import type * as React from 'react';
1
2
  import type { VariantProps } from 'tailwind-variants';
2
3
 
3
- import * as React from 'react';
4
4
  import { ChevronLeft, ChevronRight } from 'lucide-react';
5
5
  import { DayPicker } from 'react-day-picker';
6
6
  import { tv } from 'tailwind-variants';
@@ -1,7 +1,7 @@
1
+ import type { FC } from 'react';
1
2
  import type { Props } from '@twintag/twintag-form/types';
2
3
  import type { WithChildren } from 'twintag-types/dom';
3
4
 
4
- import { type FC } from 'react';
5
5
  import { tv } from 'tailwind-variants';
6
6
 
7
7
  import {
@@ -1,6 +1,6 @@
1
+ import type * as React from 'react';
1
2
  import type { Props } from '@twintag/twintag-form/types';
2
3
 
3
- import * as React from 'react';
4
4
  import { format } from 'date-fns';
5
5
  import { AsteriskIcon, Calendar as CalendarIcon } from 'lucide-react';
6
6
  import { useFormContext } from 'react-hook-form';
@@ -137,7 +137,7 @@ export const DatePicker: React.FC<Props<'input'>> = ({
137
137
  mode='single'
138
138
  size={size}
139
139
  selected={
140
- !isNaN(new Date(field.value as Date).getTime())
140
+ !Number.isNaN(new Date(field.value as Date).getTime())
141
141
  ? new Date(field.value as Date)
142
142
  : undefined
143
143
  }
@@ -82,7 +82,7 @@ export const RadioGroup: FC<
82
82
  );
83
83
  }
84
84
 
85
- return <></>;
85
+ return null;
86
86
  })}
87
87
  </CommonRadioGroup>
88
88
  </FormControl>
package/lib/utils/data.ts CHANGED
@@ -6,16 +6,18 @@ type Items = (Props<'input'> & {
6
6
  export const getBindSetFromItems = (items: Items): Set<string> => {
7
7
  const binds = new Set<string>();
8
8
 
9
- items.forEach((item) => {
9
+ for (const item of items) {
10
10
  if (item.bind) {
11
11
  binds.add(item.bind);
12
12
  }
13
13
 
14
14
  if (item.items) {
15
15
  const subBinds = getBindSetFromItems(item.items as unknown as Items);
16
- subBinds.forEach((bind) => binds.add(bind));
16
+ for (const bind of subBinds) {
17
+ binds.add(bind);
18
+ }
17
19
  }
18
- });
20
+ }
19
21
 
20
22
  return binds;
21
23
  };
@@ -1,8 +1,8 @@
1
1
  export const camelize = (str: string) => {
2
2
  return str
3
- .replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
4
- return index === 0 ? word.toLowerCase() : word.toUpperCase();
5
- })
3
+ .replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) =>
4
+ index === 0 ? word.toLowerCase() : word.toUpperCase(),
5
+ )
6
6
  .replace(/\s+/g, '');
7
7
  };
8
8
 
@@ -8,7 +8,6 @@ import config from '../twind.config';
8
8
  const withTwind = install(config);
9
9
 
10
10
  const TwintagFormElement = r2wc(Form, {
11
- // @ts-expect-error: ts limitation
12
11
  props: {
13
12
  config: 'json',
14
13
  options: 'json',
package/package.json CHANGED
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "name": "@twintag/twintag-form",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "author": "Twintag",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
8
- "import": "./dist/twintag-form.react.js",
9
- "types": "./dist/react.d.ts"
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/index.cjs"
10
11
  },
11
12
  "./webcomponent": {
12
- "import": "./dist/twintag-form.webcomponent.js",
13
- "types": "./dist/webcomponent.d.ts"
13
+ "types": "./dist/webcomponent.d.ts",
14
+ "import": "./dist/webcomponent.js",
15
+ "require": "./dist/webcomponent.cjs"
14
16
  }
15
17
  },
16
18
  "dependencies": {
@@ -43,12 +45,10 @@
43
45
  "@twind/with-react": "^1.1.3",
44
46
  "@types/uuid": "^9.0.7",
45
47
  "@vitejs/plugin-react-swc": "^3.6.0",
46
- "tailwindcss": "^3.3.6",
47
48
  "vite": "^5.2.11",
48
49
  "vite-plugin-dts": "^3.9.1",
49
50
  "tsconfig": "0.0.0",
50
- "twintag-types": "0.2.0",
51
- "eslint-config-custom": "1.0.0"
51
+ "twintag-types": "0.4.0"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public"
@@ -56,7 +56,6 @@
56
56
  "scripts": {
57
57
  "dev": "vite",
58
58
  "build": "tsc && vite build",
59
- "lint": "eslint . --ext .ts,.tsx",
60
59
  "format": "prettier --write \"**/*.{ts,md,tsx,cjs,mjs,json,html}\" --ignore-path ../../.gitignore",
61
60
  "format:check": "prettier --check \"**/*.{ts,md,tsx,cjs,mjs,json,html}\" --ignore-path ../../.gitignore"
62
61
  }
@@ -34,8 +34,8 @@ const config = {
34
34
  ring: 'hsl(var(--tf-ring) / <alpha-value>)',
35
35
  },
36
36
  borderRadius: {
37
- lg: `var(--tf-radius)`,
38
- md: `calc(var(--tf-radius) - 2px)`,
37
+ lg: 'var(--tf-radius)',
38
+ md: 'calc(var(--tf-radius) - 2px)',
39
39
  sm: 'calc(var(--tf-radius) - 4px)',
40
40
  },
41
41
  fontFamily: {
package/tsconfig.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "extends": "tsconfig/vite.json",
3
3
  "include": [
4
- ".eslintrc.cjs",
5
4
  "lib",
6
5
  "dev",
7
6
  "scripts",
package/vite.config.ts CHANGED
@@ -3,8 +3,19 @@ import { dirname, resolve } from 'pathe';
3
3
  import { defineConfig } from 'vite';
4
4
  import dts from 'vite-plugin-dts';
5
5
 
6
+ import { dependencies, devDependencies } from './package.json';
7
+
6
8
  export const __dirname = dirname(new URL(import.meta.url).pathname);
7
9
 
10
+ const externalPackages = [
11
+ ...Object.keys(dependencies || {}),
12
+ ...Object.keys(devDependencies || {}),
13
+ ].filter((packageName) => packageName !== 'twintag-types');
14
+
15
+ const regexesOfPackages = externalPackages.map(
16
+ (packageName) => new RegExp(`^${packageName}(/.*)?`),
17
+ );
18
+
8
19
  // https://vitejs.dev/config/
9
20
  export default defineConfig({
10
21
  resolve: {
@@ -16,14 +27,14 @@ export default defineConfig({
16
27
  lib: {
17
28
  // Could also be a dictionary or array of multiple entry points
18
29
  entry: {
19
- react: resolve(__dirname, './lib/index.tsx'),
30
+ index: resolve(__dirname, './lib/index.tsx'),
20
31
  webcomponent: resolve(__dirname, './lib/webcomponent.ts'),
21
32
  },
22
33
  },
23
34
  rollupOptions: {
24
35
  // make sure to externalize deps that shouldn't be bundled
25
36
  // into your library
26
- external: ['react', 'react-dom'],
37
+ external: regexesOfPackages,
27
38
  preserveEntrySignatures: 'strict',
28
39
  output: {
29
40
  preserveModules: false,
package/.eslintrc.cjs DELETED
@@ -1,9 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- extends: ['custom'],
4
- parserOptions: {
5
- project: 'tsconfig.json',
6
- tsconfigRootDir: __dirname,
7
- sourceType: 'module',
8
- },
9
- };