@pnkx-lib/ui 1.9.273 → 1.9.274
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.
|
@@ -163,6 +163,40 @@ const HookFormContext = React__default.createContext(null);
|
|
|
163
163
|
* ```
|
|
164
164
|
*/
|
|
165
165
|
const useFormContext = () => React__default.useContext(HookFormContext);
|
|
166
|
+
/**
|
|
167
|
+
* A provider component that propagates the `useForm` methods to all children components via [React Context](https://reactjs.org/docs/context.html) API. To be used with {@link useFormContext}.
|
|
168
|
+
*
|
|
169
|
+
* @remarks
|
|
170
|
+
* [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
|
|
171
|
+
*
|
|
172
|
+
* @param props - all useForm methods
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```tsx
|
|
176
|
+
* function App() {
|
|
177
|
+
* const methods = useForm();
|
|
178
|
+
* const onSubmit = data => console.log(data);
|
|
179
|
+
*
|
|
180
|
+
* return (
|
|
181
|
+
* <FormProvider {...methods} >
|
|
182
|
+
* <form onSubmit={methods.handleSubmit(onSubmit)}>
|
|
183
|
+
* <NestedInput />
|
|
184
|
+
* <input type="submit" />
|
|
185
|
+
* </form>
|
|
186
|
+
* </FormProvider>
|
|
187
|
+
* );
|
|
188
|
+
* }
|
|
189
|
+
*
|
|
190
|
+
* function NestedInput() {
|
|
191
|
+
* const { register } = useFormContext(); // retrieve all hook methods
|
|
192
|
+
* return <input {...register("test")} />;
|
|
193
|
+
* }
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
const FormProvider = (props) => {
|
|
197
|
+
const { children, ...data } = props;
|
|
198
|
+
return (React__default.createElement(HookFormContext.Provider, { value: data }, children));
|
|
199
|
+
};
|
|
166
200
|
|
|
167
201
|
var getProxyFormState = (formState, control, localProxyFormState, isRoot = true) => {
|
|
168
202
|
const result = {
|
|
@@ -2263,4 +2297,4 @@ function useForm(props = {}) {
|
|
|
2263
2297
|
return _formControl.current;
|
|
2264
2298
|
}
|
|
2265
2299
|
|
|
2266
|
-
export { Controller as C, useForm as u };
|
|
2300
|
+
export { Controller as C, FormProvider as F, useForm as u };
|
package/es/fields/PnkxField.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { C as Controller } from '../chunks/index.esm-
|
|
3
|
+
import { C as Controller } from '../chunks/index.esm-dryjkTpj.js';
|
|
4
4
|
|
|
5
5
|
class PnkxField extends React.PureComponent {
|
|
6
6
|
render() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { u as useForm } from '../chunks/index.esm-
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { u as useForm, F as FormProvider } from '../chunks/index.esm-dryjkTpj.js';
|
|
3
3
|
import { Button } from './Button.js';
|
|
4
4
|
import { I as Icon, _ as _extends } from '../chunks/AntdIcon-ZIq9SabE.js';
|
|
5
5
|
import * as React from 'react';
|
|
@@ -46,10 +46,11 @@ const SearchFiltersForm = ({
|
|
|
46
46
|
hideDefaultSubmit,
|
|
47
47
|
hideResetButton
|
|
48
48
|
}) => {
|
|
49
|
-
const
|
|
49
|
+
const methods = useForm({
|
|
50
50
|
defaultValues: initialValues
|
|
51
51
|
});
|
|
52
|
-
|
|
52
|
+
const { control, handleSubmit, reset, setValue } = methods;
|
|
53
|
+
return /* @__PURE__ */ jsx(FormProvider, { ...methods, children: /* @__PURE__ */ jsxs("form", { className: classNameWrapperForm, onSubmit: handleSubmit(onSubmit), children: [
|
|
53
54
|
/* @__PURE__ */ jsx("div", { className: classNamesContainer, children: renderFilterFields && renderFilterFields({
|
|
54
55
|
control,
|
|
55
56
|
setValue,
|
|
@@ -81,7 +82,7 @@ const SearchFiltersForm = ({
|
|
|
81
82
|
}
|
|
82
83
|
)
|
|
83
84
|
] })
|
|
84
|
-
] });
|
|
85
|
+
] }) });
|
|
85
86
|
};
|
|
86
87
|
|
|
87
88
|
export { SearchFiltersForm };
|
package/es/ui/UploadImage.js
CHANGED
package/es/ui/UploadMultiple.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
import { Spin, Upload, message } from 'antd';
|
|
5
|
-
import { C as Controller } from '../chunks/index.esm-
|
|
5
|
+
import { C as Controller } from '../chunks/index.esm-dryjkTpj.js';
|
|
6
6
|
import { I as Icon, _ as _extends } from '../chunks/AntdIcon-ZIq9SabE.js';
|
|
7
7
|
|
|
8
8
|
// This icon file is generated automatically.
|
package/es/ui/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
6
6
|
import React__default, { useLayoutEffect, useEffect, useRef, useMemo, useCallback, useState, memo, useReducer, createContext, useContext } from 'react';
|
|
7
7
|
import { Select, Input, Pagination, Table as Table$1 } from 'antd';
|
|
8
8
|
import { Modal } from './Modal.js';
|
|
9
|
-
import { u as useForm } from '../chunks/index.esm-
|
|
9
|
+
import { u as useForm } from '../chunks/index.esm-dryjkTpj.js';
|
|
10
10
|
import { PnkxField } from '../fields/PnkxField.js';
|
|
11
11
|
import { Checkbox } from '../fields/Checkbox.js';
|
|
12
12
|
import { unstable_batchedUpdates, createPortal } from 'react-dom';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnkx-lib/ui",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.9.
|
|
4
|
+
"version": "1.9.274",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./es/index.js",
|
|
7
7
|
"module": "./es/index.js",
|
|
@@ -122,6 +122,7 @@
|
|
|
122
122
|
"antd": "^5.24.4",
|
|
123
123
|
"react": "^18.3.1",
|
|
124
124
|
"react-dom": "^18.3.1",
|
|
125
|
+
"react-hook-form": "^7.54.2",
|
|
125
126
|
"react-router": "^7.6.0",
|
|
126
127
|
"tailwindcss": "^4.0.17"
|
|
127
128
|
},
|
|
@@ -145,8 +146,6 @@
|
|
|
145
146
|
"date-fns": "^4.1.0",
|
|
146
147
|
"lodash": "^4.17.21",
|
|
147
148
|
"react-datepicker": "^4.16.0",
|
|
148
|
-
"react-hook-form": "^7.54.2",
|
|
149
|
-
"react-number-format": "^5.4.3",
|
|
150
149
|
"tailwind-merge": "^3.3.0",
|
|
151
150
|
"yup": "^1.6.1",
|
|
152
151
|
"zustand": "^5.0.3"
|