soda-heroui 0.10.6 → 0.11.1
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.
- package/dist/components/AutoRefresh.js +5 -5
- package/dist/components/EnumSelect.cjs +60 -0
- package/dist/components/EnumSelect.d.ts +9 -0
- package/dist/components/EnumSelect.js +23 -0
- package/dist/components/ErrorMessage.js +5 -5
- package/dist/components/FormAutocomplete.js +6 -6
- package/dist/components/FormCalendar.js +12 -12
- package/dist/components/FormCheckbox.js +6 -6
- package/dist/components/FormCheckboxGroup.js +6 -6
- package/dist/components/FormDateInput.js +12 -12
- package/dist/components/FormDatePicker.js +12 -12
- package/dist/components/FormDateRangePicker.js +12 -12
- package/dist/components/FormInput.js +6 -6
- package/dist/components/FormInputOtp.js +6 -6
- package/dist/components/FormNumberInput.js +6 -6
- package/dist/components/FormPagination.js +6 -6
- package/dist/components/FormProvider.cjs +2 -2
- package/dist/components/FormProvider.js +7 -7
- package/dist/components/FormRadioGroup.js +6 -6
- package/dist/components/FormRangeCalendar.js +12 -12
- package/dist/components/FormSelect.d.ts +4 -3
- package/dist/components/FormSelect.js +12 -12
- package/dist/components/FormSwitch.js +6 -6
- package/dist/components/FormTextarea.js +6 -6
- package/dist/components/FormTimeInput.js +12 -12
- package/dist/index.cjs +87 -78
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/utils/addBetterToast.cjs +2 -2
- package/dist/utils/addBetterToast.js +6 -6
- package/dist/utils/getFieldProps.js +6 -6
- package/dist/utils/parseTime.cjs +3 -3
- package/dist/utils/parseTime.js +6 -12
- package/dist/utils/range.cjs +2 -2
- package/dist/utils/range.js +13 -13
- package/dist/utils/time.cjs +3 -3
- package/dist/utils/time.js +7 -7
- package/package.json +9 -9
- package/src/components/EnumSelect.tsx +46 -0
- package/src/components/FormSelect.tsx +9 -7
- package/src/index.ts +1 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button, addToast } from "@heroui/react";
|
|
3
|
+
import { useAutoRefresh } from "soda-hooks";
|
|
4
4
|
const AutoRefresh = ({ children, onRefresh, ...rest })=>{
|
|
5
5
|
if ("development" === process.env.NODE_ENV) return children;
|
|
6
6
|
function onPress(e) {
|
|
@@ -8,12 +8,12 @@ const AutoRefresh = ({ children, onRefresh, ...rest })=>{
|
|
|
8
8
|
closeButton?.click();
|
|
9
9
|
onRefresh?.();
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
useAutoRefresh(()=>addToast({
|
|
12
12
|
title: "\u68C0\u6D4B\u5230\u9875\u9762\u66F4\u65B0",
|
|
13
13
|
description: "\u4E3A\u4E86\u6700\u4F73\u7684\u4F53\u9A8C\uFF0C\u8BF7\u5237\u65B0\u9875\u9762",
|
|
14
14
|
color: "warning",
|
|
15
15
|
timeout: 1 / 0,
|
|
16
|
-
endContent: /*#__PURE__*/
|
|
16
|
+
endContent: /*#__PURE__*/ jsx(Button, {
|
|
17
17
|
color: "warning",
|
|
18
18
|
size: "sm",
|
|
19
19
|
variant: "flat",
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
"use strict";
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
6
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: definition[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.r = (exports1)=>{
|
|
17
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
18
|
+
value: 'Module'
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
21
|
+
value: true
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
})();
|
|
25
|
+
var __webpack_exports__ = {};
|
|
26
|
+
__webpack_require__.r(__webpack_exports__);
|
|
27
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
28
|
+
EnumSelect: ()=>EnumSelect,
|
|
29
|
+
createEnumSelect: ()=>createEnumSelect
|
|
30
|
+
});
|
|
31
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
32
|
+
const react_namespaceObject = require("@heroui/react");
|
|
33
|
+
const external_deepsea_tools_namespaceObject = require("deepsea-tools");
|
|
34
|
+
const external_FormSelect_cjs_namespaceObject = require("./FormSelect.cjs");
|
|
35
|
+
function EnumSelect({ enumObject, ...rest }) {
|
|
36
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_FormSelect_cjs_namespaceObject.FormSelect, {
|
|
37
|
+
items: (0, external_deepsea_tools_namespaceObject.getEnumOptions)(enumObject),
|
|
38
|
+
...rest,
|
|
39
|
+
children: ({ label, value })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.SelectItem, {
|
|
40
|
+
children: label
|
|
41
|
+
}, value)
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function createEnumSelect(enumObject) {
|
|
45
|
+
return function(props) {
|
|
46
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(EnumSelect, {
|
|
47
|
+
enumObject: enumObject,
|
|
48
|
+
...props
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
exports.EnumSelect = __webpack_exports__.EnumSelect;
|
|
53
|
+
exports.createEnumSelect = __webpack_exports__.createEnumSelect;
|
|
54
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
55
|
+
"EnumSelect",
|
|
56
|
+
"createEnumSelect"
|
|
57
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
58
|
+
Object.defineProperty(exports, '__esModule', {
|
|
59
|
+
value: true
|
|
60
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { EnumOption } from "deepsea-tools";
|
|
3
|
+
import { StrictOmit, ValueOf } from "soda-type";
|
|
4
|
+
import { FormSelectProps, SelectionMode } from "./FormSelect";
|
|
5
|
+
export interface EnumSelectProps<T extends Record<string, string>, Mode extends SelectionMode = "single", FieldValue extends (Mode extends "multiple" ? ValueOf<T>[] : ValueOf<T>) | null | undefined = (Mode extends "multiple" ? ValueOf<T>[] : ValueOf<T>) | null | undefined> extends StrictOmit<FormSelectProps<Mode, FieldValue, EnumOption<T>>, "children" | "items"> {
|
|
6
|
+
enumObject: T;
|
|
7
|
+
}
|
|
8
|
+
export declare function EnumSelect<T extends Record<string, string>, Mode extends SelectionMode = "single", FieldValue extends (Mode extends "multiple" ? ValueOf<T>[] : ValueOf<T>) | null | undefined = (Mode extends "multiple" ? ValueOf<T>[] : ValueOf<T>) | null | undefined>({ enumObject, ...rest }: EnumSelectProps<T, Mode, FieldValue>): ReactNode;
|
|
9
|
+
export declare function createEnumSelect<T extends Record<string, string>>(enumObject: T): <Mode extends SelectionMode = "single", FieldValue extends (Mode extends "multiple" ? ValueOf<T>[] : ValueOf<T>) | null | undefined = (Mode extends "multiple" ? ValueOf<T>[] : ValueOf<T>) | null | undefined>(props: StrictOmit<EnumSelectProps<T, Mode, FieldValue>, "enumObject">) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { SelectItem } from "@heroui/react";
|
|
4
|
+
import { getEnumOptions } from "deepsea-tools";
|
|
5
|
+
import { FormSelect as external_FormSelect_js_FormSelect } from "./FormSelect.js";
|
|
6
|
+
function EnumSelect({ enumObject, ...rest }) {
|
|
7
|
+
return /*#__PURE__*/ jsx(external_FormSelect_js_FormSelect, {
|
|
8
|
+
items: getEnumOptions(enumObject),
|
|
9
|
+
...rest,
|
|
10
|
+
children: ({ label, value })=>/*#__PURE__*/ jsx(SelectItem, {
|
|
11
|
+
children: label
|
|
12
|
+
}, value)
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function createEnumSelect(enumObject) {
|
|
16
|
+
return function(props) {
|
|
17
|
+
return /*#__PURE__*/ jsx(EnumSelect, {
|
|
18
|
+
enumObject: enumObject,
|
|
19
|
+
...props
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export { EnumSelect, createEnumSelect };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { isNonNullable } from "deepsea-tools";
|
|
4
4
|
function getErrorMessage(error) {
|
|
5
|
-
if (!
|
|
5
|
+
if (!isNonNullable(error)) return [];
|
|
6
6
|
if ("string" == typeof error) return [
|
|
7
7
|
error
|
|
8
8
|
];
|
|
@@ -14,9 +14,9 @@ function getErrorMessage(error) {
|
|
|
14
14
|
const ErrorMessage = (props)=>{
|
|
15
15
|
const { data, ...rest } = props;
|
|
16
16
|
const errors = data.flatMap(getErrorMessage).filter((item, index, array)=>array.indexOf(item) === index);
|
|
17
|
-
return errors.length > 0 && /*#__PURE__*/
|
|
17
|
+
return errors.length > 0 && /*#__PURE__*/ jsx("div", {
|
|
18
18
|
...rest,
|
|
19
|
-
children: errors.map((item, index)=>/*#__PURE__*/
|
|
19
|
+
children: errors.map((item, index)=>/*#__PURE__*/ jsx("div", {
|
|
20
20
|
children: item
|
|
21
21
|
}, index))
|
|
22
22
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
function FormAutocomplete({ field, component: Autocomplete2 =
|
|
6
|
-
return /*#__PURE__*/
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Autocomplete } from "@heroui/react";
|
|
4
|
+
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
5
|
+
function FormAutocomplete({ field, component: Autocomplete2 = Autocomplete, ...rest }) {
|
|
6
|
+
return /*#__PURE__*/ jsx(Autocomplete2, {
|
|
7
7
|
selectedKey: field.state.value ?? "",
|
|
8
8
|
onSelectionChange: field.handleChange,
|
|
9
|
-
...
|
|
9
|
+
...getFieldProps(field),
|
|
10
10
|
...rest
|
|
11
11
|
});
|
|
12
12
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
function FormCalendar({ field, valueMode, emptyValue, dateMode, defaultTime, component: Calendar2 =
|
|
9
|
-
const context =
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useContext } from "react";
|
|
4
|
+
import { Calendar } from "@heroui/react";
|
|
5
|
+
import { FormContext } from "./FormProvider.js";
|
|
6
|
+
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
7
|
+
import { getFieldValue, getOnChange } from "../utils/time.js";
|
|
8
|
+
function FormCalendar({ field, valueMode, emptyValue, dateMode, defaultTime, component: Calendar2 = Calendar, ...rest }) {
|
|
9
|
+
const context = useContext(FormContext);
|
|
10
10
|
emptyValue ??= context.emptyValue;
|
|
11
|
-
return /*#__PURE__*/
|
|
12
|
-
focusedValue:
|
|
13
|
-
onFocusChange:
|
|
11
|
+
return /*#__PURE__*/ jsx(Calendar2, {
|
|
12
|
+
focusedValue: getFieldValue(field, dateMode),
|
|
13
|
+
onFocusChange: getOnChange({
|
|
14
14
|
field,
|
|
15
15
|
valueMode,
|
|
16
16
|
emptyValue,
|
|
17
17
|
defaultTime
|
|
18
18
|
}),
|
|
19
|
-
...
|
|
19
|
+
...getFieldProps(field),
|
|
20
20
|
...rest
|
|
21
21
|
});
|
|
22
22
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
function FormCheckbox({ field, component: Checkbox2 =
|
|
6
|
-
return /*#__PURE__*/
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Checkbox } from "@heroui/react";
|
|
4
|
+
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
5
|
+
function FormCheckbox({ field, component: Checkbox2 = Checkbox, ...rest }) {
|
|
6
|
+
return /*#__PURE__*/ jsx(Checkbox2, {
|
|
7
7
|
isSelected: field.state.value ?? false,
|
|
8
8
|
onValueChange: field.handleChange,
|
|
9
|
-
...
|
|
9
|
+
...getFieldProps(field, true),
|
|
10
10
|
...rest
|
|
11
11
|
});
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
function FormCheckboxGroup({ field, component: CheckboxGroup2 =
|
|
6
|
-
return /*#__PURE__*/
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { CheckboxGroup } from "@heroui/react";
|
|
4
|
+
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
5
|
+
function FormCheckboxGroup({ field, component: CheckboxGroup2 = CheckboxGroup, ...rest }) {
|
|
6
|
+
return /*#__PURE__*/ jsx(CheckboxGroup2, {
|
|
7
7
|
value: field.state.value ?? [],
|
|
8
8
|
onValueChange: field.handleChange,
|
|
9
|
-
...
|
|
9
|
+
...getFieldProps(field),
|
|
10
10
|
...rest
|
|
11
11
|
});
|
|
12
12
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
function FormDateInput({ field, valueMode, emptyValue, dateMode, defaultTime, component: DateInput2 =
|
|
9
|
-
const context =
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useContext } from "react";
|
|
4
|
+
import { DateInput } from "@heroui/react";
|
|
5
|
+
import { FormContext } from "./FormProvider.js";
|
|
6
|
+
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
7
|
+
import { getFieldValue, getOnChange } from "../utils/time.js";
|
|
8
|
+
function FormDateInput({ field, valueMode, emptyValue, dateMode, defaultTime, component: DateInput2 = DateInput, ...rest }) {
|
|
9
|
+
const context = useContext(FormContext);
|
|
10
10
|
emptyValue ??= context.emptyValue;
|
|
11
|
-
return /*#__PURE__*/
|
|
12
|
-
value:
|
|
13
|
-
onChange:
|
|
11
|
+
return /*#__PURE__*/ jsx(DateInput2, {
|
|
12
|
+
value: getFieldValue(field, dateMode),
|
|
13
|
+
onChange: getOnChange({
|
|
14
14
|
field,
|
|
15
15
|
valueMode,
|
|
16
16
|
emptyValue,
|
|
17
17
|
defaultTime
|
|
18
18
|
}),
|
|
19
|
-
...
|
|
19
|
+
...getFieldProps(field),
|
|
20
20
|
...rest
|
|
21
21
|
});
|
|
22
22
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
function FormDatePicker({ field, valueMode, emptyValue, dateMode, defaultTime, component: DatePicker2 =
|
|
9
|
-
const context =
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useContext } from "react";
|
|
4
|
+
import { DatePicker } from "@heroui/react";
|
|
5
|
+
import { FormContext } from "./FormProvider.js";
|
|
6
|
+
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
7
|
+
import { getFieldValue, getOnChange } from "../utils/time.js";
|
|
8
|
+
function FormDatePicker({ field, valueMode, emptyValue, dateMode, defaultTime, component: DatePicker2 = DatePicker, ...rest }) {
|
|
9
|
+
const context = useContext(FormContext);
|
|
10
10
|
emptyValue ??= context.emptyValue;
|
|
11
|
-
return /*#__PURE__*/
|
|
12
|
-
value:
|
|
13
|
-
onChange:
|
|
11
|
+
return /*#__PURE__*/ jsx(DatePicker2, {
|
|
12
|
+
value: getFieldValue(field, dateMode),
|
|
13
|
+
onChange: getOnChange({
|
|
14
14
|
field,
|
|
15
15
|
valueMode,
|
|
16
16
|
emptyValue,
|
|
17
17
|
defaultTime
|
|
18
18
|
}),
|
|
19
|
-
...
|
|
19
|
+
...getFieldProps(field),
|
|
20
20
|
...rest
|
|
21
21
|
});
|
|
22
22
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
function FormDateRangePicker({ field: _field, valueMode, emptyValue, dateMode, defaultTime, component: DateRangePicker2 =
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useContext } from "react";
|
|
4
|
+
import { DateRangePicker } from "@heroui/react";
|
|
5
|
+
import { FormContext } from "./FormProvider.js";
|
|
6
|
+
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
7
|
+
import { getFieldRangeValue, getOnRangeChange } from "../utils/range.js";
|
|
8
|
+
function FormDateRangePicker({ field: _field, valueMode, emptyValue, dateMode, defaultTime, component: DateRangePicker2 = DateRangePicker, ...rest }) {
|
|
9
9
|
const field = _field;
|
|
10
|
-
const context =
|
|
10
|
+
const context = useContext(FormContext);
|
|
11
11
|
emptyValue ??= context.emptyValue;
|
|
12
|
-
return /*#__PURE__*/
|
|
13
|
-
value:
|
|
14
|
-
onChange:
|
|
12
|
+
return /*#__PURE__*/ jsx(DateRangePicker2, {
|
|
13
|
+
value: getFieldRangeValue(field, dateMode),
|
|
14
|
+
onChange: getOnRangeChange({
|
|
15
15
|
field,
|
|
16
16
|
valueMode,
|
|
17
17
|
emptyValue,
|
|
18
18
|
defaultTime
|
|
19
19
|
}),
|
|
20
|
-
...
|
|
20
|
+
...getFieldProps(field),
|
|
21
21
|
...rest
|
|
22
22
|
});
|
|
23
23
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
function FormInput({ field, component: Input2 =
|
|
6
|
-
return /*#__PURE__*/
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Input } from "@heroui/react";
|
|
4
|
+
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
5
|
+
function FormInput({ field, component: Input2 = Input, ...rest }) {
|
|
6
|
+
return /*#__PURE__*/ jsx(Input2, {
|
|
7
7
|
value: field.state.value ?? "",
|
|
8
8
|
onValueChange: field.handleChange,
|
|
9
|
-
...
|
|
9
|
+
...getFieldProps(field),
|
|
10
10
|
...rest
|
|
11
11
|
});
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
function FormInputOtp({ field, component: InputOtp2 =
|
|
6
|
-
return /*#__PURE__*/
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { InputOtp } from "@heroui/react";
|
|
4
|
+
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
5
|
+
function FormInputOtp({ field, component: InputOtp2 = InputOtp, ...rest }) {
|
|
6
|
+
return /*#__PURE__*/ jsx(InputOtp2, {
|
|
7
7
|
value: field.state.value ?? "",
|
|
8
8
|
onValueChange: field.handleChange,
|
|
9
|
-
...
|
|
9
|
+
...getFieldProps(field),
|
|
10
10
|
...rest
|
|
11
11
|
});
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
function FormNumberInput({ field, component: NumberInput2 =
|
|
6
|
-
return /*#__PURE__*/
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { NumberInput } from "@heroui/react";
|
|
4
|
+
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
5
|
+
function FormNumberInput({ field, component: NumberInput2 = NumberInput, ...rest }) {
|
|
6
|
+
return /*#__PURE__*/ jsx(NumberInput2, {
|
|
7
7
|
value: field.state.value ?? 0,
|
|
8
8
|
onValueChange: field.handleChange,
|
|
9
|
-
...
|
|
9
|
+
...getFieldProps(field),
|
|
10
10
|
...rest
|
|
11
11
|
});
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
function FormPagination({ field, component: Pagination2 =
|
|
6
|
-
return /*#__PURE__*/
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Pagination } from "@heroui/react";
|
|
4
|
+
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
5
|
+
function FormPagination({ field, component: Pagination2 = Pagination, ...rest }) {
|
|
6
|
+
return /*#__PURE__*/ jsx(Pagination2, {
|
|
7
7
|
page: field.state.value ?? 1,
|
|
8
8
|
onPageChange: field.handleChange,
|
|
9
|
-
...
|
|
9
|
+
...getFieldProps(field, true),
|
|
10
10
|
...rest
|
|
11
11
|
});
|
|
12
12
|
}
|
|
@@ -25,9 +25,9 @@ var __webpack_require__ = {};
|
|
|
25
25
|
var __webpack_exports__ = {};
|
|
26
26
|
__webpack_require__.r(__webpack_exports__);
|
|
27
27
|
__webpack_require__.d(__webpack_exports__, {
|
|
28
|
+
FormContext: ()=>FormContext,
|
|
28
29
|
FormProvider: ()=>FormProvider,
|
|
29
|
-
getEmptyValue: ()=>getEmptyValue
|
|
30
|
-
FormContext: ()=>FormContext
|
|
30
|
+
getEmptyValue: ()=>getEmptyValue
|
|
31
31
|
});
|
|
32
32
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
33
33
|
const external_react_namespaceObject = require("react");
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext } from "react";
|
|
4
|
+
import { assign as external_deepsea_tools_assign } from "deepsea-tools";
|
|
5
5
|
function getEmptyValue(value) {
|
|
6
6
|
return "undefined" === value ? void 0 : null;
|
|
7
7
|
}
|
|
8
|
-
const FormContext = /*#__PURE__*/
|
|
8
|
+
const FormContext = /*#__PURE__*/ createContext({
|
|
9
9
|
emptyValue: "null"
|
|
10
10
|
});
|
|
11
11
|
const FormProvider = ({ children, emptyValue })=>{
|
|
12
|
-
const config =
|
|
13
|
-
const newConfig = (
|
|
12
|
+
const config = useContext(FormContext);
|
|
13
|
+
const newConfig = external_deepsea_tools_assign(config, {
|
|
14
14
|
emptyValue
|
|
15
15
|
});
|
|
16
|
-
return /*#__PURE__*/
|
|
16
|
+
return /*#__PURE__*/ jsx(FormContext, {
|
|
17
17
|
value: newConfig,
|
|
18
18
|
children: children
|
|
19
19
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
function FormRadioGroup({ field, component: RadioGroup2 =
|
|
6
|
-
return /*#__PURE__*/
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { RadioGroup } from "@heroui/react";
|
|
4
|
+
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
5
|
+
function FormRadioGroup({ field, component: RadioGroup2 = RadioGroup, ...rest }) {
|
|
6
|
+
return /*#__PURE__*/ jsx(RadioGroup2, {
|
|
7
7
|
value: field.state.value ?? "",
|
|
8
8
|
onValueChange: field.handleChange,
|
|
9
|
-
...
|
|
9
|
+
...getFieldProps(field),
|
|
10
10
|
...rest
|
|
11
11
|
});
|
|
12
12
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
function FormRangeCalendar({ field: _field, valueMode, emptyValue, dateMode, defaultTime, component: RangeCalendar2 =
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useContext } from "react";
|
|
4
|
+
import { RangeCalendar } from "@heroui/react";
|
|
5
|
+
import { FormContext } from "./FormProvider.js";
|
|
6
|
+
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
7
|
+
import { getFieldRangeValue, getOnRangeChange } from "../utils/range.js";
|
|
8
|
+
function FormRangeCalendar({ field: _field, valueMode, emptyValue, dateMode, defaultTime, component: RangeCalendar2 = RangeCalendar, ...rest }) {
|
|
9
9
|
const field = _field;
|
|
10
|
-
const context =
|
|
10
|
+
const context = useContext(FormContext);
|
|
11
11
|
emptyValue ??= context.emptyValue;
|
|
12
|
-
return /*#__PURE__*/
|
|
13
|
-
value:
|
|
14
|
-
onChange:
|
|
12
|
+
return /*#__PURE__*/ jsx(RangeCalendar2, {
|
|
13
|
+
value: getFieldRangeValue(field, dateMode),
|
|
14
|
+
onChange: getOnRangeChange({
|
|
15
15
|
field,
|
|
16
16
|
valueMode,
|
|
17
17
|
emptyValue,
|
|
18
18
|
defaultTime
|
|
19
19
|
}),
|
|
20
|
-
...
|
|
20
|
+
...getFieldProps(field),
|
|
21
21
|
...rest
|
|
22
22
|
});
|
|
23
23
|
}
|
|
@@ -4,9 +4,10 @@ import { Key } from "@react-types/shared";
|
|
|
4
4
|
import { FieldComponentProps } from "soda-tanstack-form";
|
|
5
5
|
import { StrictOmit } from "soda-type";
|
|
6
6
|
import { EmptyValue } from "./FormProvider";
|
|
7
|
-
export
|
|
8
|
-
|
|
7
|
+
export type SelectionMode = "single" | "multiple";
|
|
8
|
+
export interface FormSelectProps<Mode extends SelectionMode = "single", Value extends (Mode extends "multiple" ? Key[] : Key) | null | undefined = (Mode extends "multiple" ? Key[] : Key) | null | undefined, RenderItem extends object = object> extends StrictOmit<FieldComponentProps<typeof Select<RenderItem>, Value>, "selectionMode"> {
|
|
9
|
+
selectionMode?: Mode;
|
|
9
10
|
emptyValue?: EmptyValue;
|
|
10
11
|
component?: <RenderItem extends object>(props: SelectProps<RenderItem>) => ReactNode;
|
|
11
12
|
}
|
|
12
|
-
export declare function FormSelect<
|
|
13
|
+
export declare function FormSelect<Mode extends SelectionMode = "single", Value extends (Mode extends "multiple" ? Key[] : Key) | null | undefined = (Mode extends "multiple" ? Key[] : Key) | null | undefined, RenderItem extends object = object>({ field, multiple, emptyValue, component: Select2, ...rest }: FormSelectProps<Mode, Value, RenderItem>): ReactNode;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
function FormSelect({ field, multiple, emptyValue, component: Select2 =
|
|
9
|
-
const context =
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useContext } from "react";
|
|
4
|
+
import { Select } from "@heroui/react";
|
|
5
|
+
import { isNonNullable } from "deepsea-tools";
|
|
6
|
+
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
7
|
+
import { FormContext, getEmptyValue } from "./FormProvider.js";
|
|
8
|
+
function FormSelect({ field, multiple, emptyValue, component: Select2 = Select, ...rest }) {
|
|
9
|
+
const context = useContext(FormContext);
|
|
10
10
|
emptyValue ??= context.emptyValue;
|
|
11
|
-
return /*#__PURE__*/
|
|
12
|
-
selectedKeys:
|
|
11
|
+
return /*#__PURE__*/ jsx(Select2, {
|
|
12
|
+
selectedKeys: isNonNullable(field.state.value) ? multiple ? field.state.value : [
|
|
13
13
|
field.state.value
|
|
14
14
|
] : [],
|
|
15
15
|
onSelectionChange: (keys)=>{
|
|
16
16
|
const value = Array.from(keys);
|
|
17
|
-
field.handleChange(multiple ? value : value.at(0) ??
|
|
17
|
+
field.handleChange(multiple ? value : value.at(0) ?? getEmptyValue(emptyValue));
|
|
18
18
|
},
|
|
19
|
-
...
|
|
19
|
+
...getFieldProps(field),
|
|
20
20
|
...rest
|
|
21
21
|
});
|
|
22
22
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
function FormSwitch({ field, component: Switch2 =
|
|
6
|
-
return /*#__PURE__*/
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Switch } from "@heroui/react";
|
|
4
|
+
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
5
|
+
function FormSwitch({ field, component: Switch2 = Switch, ...rest }) {
|
|
6
|
+
return /*#__PURE__*/ jsx(Switch2, {
|
|
7
7
|
isSelected: field.state.value ?? false,
|
|
8
8
|
onValueChange: field.handleChange,
|
|
9
|
-
...
|
|
9
|
+
...getFieldProps(field, true),
|
|
10
10
|
...rest
|
|
11
11
|
});
|
|
12
12
|
}
|