Skip to content

Commit

Permalink
Fix stocked package build
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtiomTr committed Oct 29, 2024
1 parent 86a0ea6 commit eb734f0
Show file tree
Hide file tree
Showing 9 changed files with 280 additions and 202 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@types/jest": "26.0.24",
"@types/lodash": "4.14.161",
"@types/node": "^18.11.18",
"@types/react": "18.0.23",
"@types/react": "18.3.12",
"aqu": "0.4.3",
"eslint": "^9.13.0",
"jest": "29.2.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/components/Field.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from 'react';
import React, { Fragment, ReactNode } from 'react';

import { FieldConfig, useField } from '../hooks/useField';
import { FieldContext } from '../typings/FieldContext';

export type FieldProps<V> = FieldConfig<V> & {
children: (ctx: FieldContext<V>) => React.ReactNode;
children: (ctx: FieldContext<V>) => ReactNode;
};

export const Field = <V,>({ children, ...config }: FieldProps<V>) => {
const bag = useField(config);

return <React.Fragment>{children(bag)}</React.Fragment>;
return <Fragment>{children(bag)}</Fragment>;
};
4 changes: 2 additions & 2 deletions packages/core/src/hooks/useFieldValidator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useRef } from 'react';
import merge from 'lodash/merge';
import { Pxth } from 'pxth';
import type { Schema } from 'yup';
import type { BaseSchema } from 'yup';

import { useFormContext } from './useFormContext';
import { FieldValidator } from '../typings/FieldValidator';
Expand All @@ -12,7 +12,7 @@ export type UseFieldValidatorConfig<V> = FieldValidationProps<V> & { name: Pxth<

export type FieldValidationProps<V> = {
validator?: FieldValidator<V>;
schema?: Schema<Partial<V> | V | undefined>;
schema?: BaseSchema<Partial<V> | V | undefined>;
};

export const useFieldValidator = <V>({ name, validator: validatorFn, schema }: UseFieldValidatorConfig<V>) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/hooks/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import mergeWith from 'lodash/mergeWith';
import { createPxth, deepGet, deepSet, Pxth } from 'pxth';
import { BatchUpdate } from 'stocked';
import invariant from 'tiny-invariant';
import type { Schema } from 'yup';
import type { BaseSchema } from 'yup';

import { useFormControl } from './useFormControl';
import { usePluginBagDecorators, usePluginConfigDecorators } from './usePlugins';
Expand Down Expand Up @@ -34,7 +34,7 @@ export type InitialFormStateConfig<Values extends object> = {
};

export interface ExtendableFormConfig<Values extends object> {
schema?: Schema<Partial<Values> | undefined>;
schema?: BaseSchema<Partial<Values> | undefined>;
onSubmit?: SubmitAction<Values>;
validateForm?: FieldValidator<Values>;
onValidationFailed?: (errors: FieldError<Values>) => void;
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/utils/runYupSchema.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { Schema, ValidateOptions } from 'yup';
import type { BaseSchema } from 'yup';
import { ValidateOptions } from 'yup/lib/types';

import { isYupError } from './isYupError';
import { yupToFormErrors } from './yupToFormErrors';
import { FieldError } from '../typings/FieldError';

export const runYupSchema = async <V>(
schema: Schema<Partial<V> | undefined>,
schema: BaseSchema<Partial<V> | undefined>,
value: V,
options?: ValidateOptions,
): Promise<FieldError<V> | undefined> => {
Expand Down
11 changes: 0 additions & 11 deletions packages/stocked/aqu.config.json

This file was deleted.

31 changes: 22 additions & 9 deletions packages/stocked/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,20 @@
"name": "stocked",
"description": "Tiny state management library for react.",
"version": "1.0.0-beta.33",
"main": "dist/index.js",
"module": "dist/stocked.esm.js",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
"import": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"require": "./dist/index.cjs"
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/fracht/reactive-forms.git",
Expand All @@ -13,13 +25,13 @@
"license": "MIT",
"scripts": {
"analyze": "size-limit --why",
"build": "aqu build",
"build": "tsup",
"build:docs": "vitepress build new-docs",
"dev:docs": "vitepress dev new-docs",
"format": "syncpack format && prettier --write \"**/*.{ts,tsx,cjs,mjs,js,jsx,json,yml,yaml,clean-publish}\"",
"lint": "eslint .",
"lint:config": "pnpm lint --write-file",
"prepublishOnly": "aqu build",
"lint": "eslint . && attw --pack .",
"lint:fix": "eslint . --fix",
"prepublishOnly": "tsup",
"serve:docs": "vitepress serve new-docs",
"size": "size-limit",
"start": "aqu watch",
Expand All @@ -37,12 +49,14 @@
"@types/lodash": "^4.17.12",
"@types/react": "18.3.12",
"@types/react-dom": "18.3.1",
"aqu": "^0.4.3",
"configs": "github:fracht/configs",
"jsdom": "^25.0.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"tslib": "2.3.1",
"@microsoft/api-extractor": "^7.47.11",
"@arethetypeswrong/cli": "^0.16.4",
"tsup": "^8.3.5",
"typescript": "^5.6.3",
"vitepress": "^1.4.1",
"vitest": "^2.1.3"
Expand All @@ -55,6 +69,5 @@
},
"files": [
"dist"
],
"typings": "dist/stocked.d.ts"
]
}
13 changes: 13 additions & 0 deletions packages/stocked/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineConfig } from 'tsup';

export default defineConfig({
entry: ['./src/index.ts'],
experimentalDts: true,
bundle: true,
format: ['cjs', 'esm'],
treeshake: 'smallest',
tsconfig: './tsconfig.json',
define: {
'import.meta.vitest': 'undefined',
},
});
Loading

0 comments on commit eb734f0

Please sign in to comment.