soda-heroui 0.11.24 → 0.11.25
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/FormSelect.cjs +1 -1
- package/dist/components/FormSelect.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/parseTime.d.ts +1 -1
- package/package.json +15 -12
- package/src/components/AutoRefresh.tsx +3 -3
- package/src/components/EnumSelect.tsx +6 -5
- package/src/components/ErrorMessage.tsx +1 -0
- package/src/components/FormAutocomplete.tsx +5 -2
- package/src/components/FormCalendar.tsx +2 -1
- package/src/components/FormCheckbox.tsx +1 -0
- package/src/components/FormCheckboxGroup.tsx +1 -0
- package/src/components/FormDateInput.tsx +2 -1
- package/src/components/FormDatePicker.tsx +2 -1
- package/src/components/FormDateRangePicker.tsx +2 -1
- package/src/components/FormInput.tsx +1 -0
- package/src/components/FormInputOtp.tsx +1 -0
- package/src/components/FormNumberInput.tsx +1 -0
- package/src/components/FormPagination.tsx +1 -0
- package/src/components/FormProvider.tsx +2 -1
- package/src/components/FormRadioGroup.tsx +1 -0
- package/src/components/FormRangeCalendar.tsx +2 -1
- package/src/components/FormSelect.tsx +3 -1
- package/src/components/FormSwitch.tsx +1 -0
- package/src/components/FormTextarea.tsx +2 -1
- package/src/components/FormTimeInput.tsx +2 -1
- package/src/types/index.ts +1 -1
- package/src/utils/addBetterToast.ts +1 -0
- package/src/utils/getFieldProps.tsx +1 -0
- package/src/utils/getTimeValue.ts +1 -0
- package/src/utils/parseTime.ts +2 -2
- package/src/utils/range.ts +3 -0
- package/src/utils/time.ts +1 -0
|
@@ -31,8 +31,8 @@ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
|
31
31
|
const external_react_namespaceObject = require("react");
|
|
32
32
|
const react_namespaceObject = require("@heroui/react");
|
|
33
33
|
const external_deepsea_tools_namespaceObject = require("deepsea-tools");
|
|
34
|
-
const getFieldProps_cjs_namespaceObject = require("../utils/getFieldProps.cjs");
|
|
35
34
|
const external_FormProvider_cjs_namespaceObject = require("./FormProvider.cjs");
|
|
35
|
+
const getFieldProps_cjs_namespaceObject = require("../utils/getFieldProps.cjs");
|
|
36
36
|
function FormSelect({ field, emptyValue, component: Select2 = react_namespaceObject.Select, selectionMode, labelPlacement, classNames: { base, label, ...restClassNames } = {}, ...rest }) {
|
|
37
37
|
const context = (0, external_react_namespaceObject.useContext)(external_FormProvider_cjs_namespaceObject.FormContext);
|
|
38
38
|
emptyValue ??= context.emptyValue;
|
|
@@ -3,8 +3,8 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { useContext } from "react";
|
|
4
4
|
import { Select } from "@heroui/react";
|
|
5
5
|
import { clsx, isNonNullable } from "deepsea-tools";
|
|
6
|
-
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
7
6
|
import { FormContext, getEmptyValue } from "./FormProvider.js";
|
|
7
|
+
import { getFieldProps } from "../utils/getFieldProps.js";
|
|
8
8
|
function FormSelect({ field, emptyValue, component: Select2 = Select, selectionMode, labelPlacement, classNames: { base, label, ...restClassNames } = {}, ...rest }) {
|
|
9
9
|
const context = useContext(FormContext);
|
|
10
10
|
emptyValue ??= context.emptyValue;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export type { Field } from "soda-tanstack-form";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CalendarDate, CalendarDateTime, Time, ZonedDateTime } from "@internationalized/date";
|
|
2
|
-
export { CalendarDate, CalendarDateTime,
|
|
2
|
+
export { CalendarDate, CalendarDateTime, fromAbsolute, getLocalTimeZone, Time, ZonedDateTime } from "@internationalized/date";
|
|
3
3
|
export type ParseMode = typeof ZonedDateTime | typeof CalendarDate | typeof CalendarDateTime | typeof Time;
|
|
4
4
|
export type TimeMode = Exclude<ParseMode, typeof CalendarDate>;
|
|
5
5
|
export type DateMode = Exclude<ParseMode, typeof Time>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "soda-heroui",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.25",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -36,25 +36,28 @@
|
|
|
36
36
|
"homepage": "https://github.com/1adybug/deepsea/tree/main/packages/soda-heroui",
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@internationalized/date": "^3.10.0",
|
|
39
|
-
"@tanstack/react-form": "^1.
|
|
40
|
-
"
|
|
41
|
-
"soda-
|
|
42
|
-
"
|
|
43
|
-
"soda-
|
|
39
|
+
"@tanstack/react-form": "^1.27.1",
|
|
40
|
+
"deepsea-tools": "5.43.2",
|
|
41
|
+
"soda-hooks": "6.16.1",
|
|
42
|
+
"soda-type": "6.7.2",
|
|
43
|
+
"soda-tanstack-form": "0.3.3"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@ianvs/prettier-plugin-sort-imports": "^4.7.0",
|
|
47
47
|
"@react-types/shared": "^3.32.1",
|
|
48
|
-
"glob": "^11.0
|
|
49
|
-
"prettier": "^3.
|
|
48
|
+
"glob": "^11.1.0",
|
|
49
|
+
"prettier": "^3.7.4",
|
|
50
50
|
"prettier-plugin-organize-imports": "^4.3.0",
|
|
51
|
-
"typescript": "
|
|
51
|
+
"typescript": ">=5.8.3"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@types/node": ">=20",
|
|
55
54
|
"@heroui/react": ">=2",
|
|
56
|
-
"@types/
|
|
57
|
-
"react": "
|
|
55
|
+
"@types/node": "^24.10.1",
|
|
56
|
+
"@types/react": "^19.2.7",
|
|
57
|
+
"react": ">=19.2.1"
|
|
58
|
+
},
|
|
59
|
+
"overrides": {
|
|
60
|
+
"@internationalized/date": "catalog:"
|
|
58
61
|
},
|
|
59
62
|
"scripts": {
|
|
60
63
|
"dev": "rslib build --watch",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FC, ReactNode } from "react"
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { addToast, Button, PressEvent } from "@heroui/react"
|
|
3
4
|
import { useAutoRefresh } from "soda-hooks"
|
|
4
5
|
import { FirstParameter } from "soda-type"
|
|
5
6
|
|
|
@@ -29,8 +30,7 @@ export const AutoRefresh: FC<AutoRefreshProps> = ({ children, onRefresh, ...rest
|
|
|
29
30
|
</Button>
|
|
30
31
|
),
|
|
31
32
|
...rest,
|
|
32
|
-
})
|
|
33
|
-
)
|
|
33
|
+
}))
|
|
34
34
|
|
|
35
35
|
return children
|
|
36
36
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import { ComponentProps, ReactNode, useCallback, useContext, useMemo } from "react"
|
|
4
|
+
|
|
4
5
|
import { Select, SelectItem, SharedSelection } from "@heroui/react"
|
|
5
|
-
import {
|
|
6
|
+
import { getEnumOptions, intParser, isNonNullable, ValueOf } from "deepsea-tools"
|
|
6
7
|
import { useInputState } from "soda-hooks"
|
|
7
8
|
|
|
8
|
-
import { EmptyValue, FormContext,
|
|
9
|
+
import { EmptyValue, FormContext, getEmptyValue, GetEmptyValue } from "./FormProvider"
|
|
9
10
|
import { SelectionMode } from "./FormSelect"
|
|
10
11
|
|
|
11
12
|
/** enumObject 的类型 */
|
|
@@ -34,9 +35,9 @@ export interface EnumSelectPropsBase<
|
|
|
34
35
|
Empty extends EmptyValue = "null",
|
|
35
36
|
Value = SelectValue<Options, Mode, DisallowEmptySelection, Empty>,
|
|
36
37
|
> extends Omit<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
ComponentProps<typeof Select<EnumOption<Options>>>,
|
|
39
|
+
"items" | "selectionMode" | "disallowEmptySelection" | "children" | "selectedKeys" | "onSelectionChange" | "value" | "onValueChange"
|
|
40
|
+
> {
|
|
40
41
|
enumObject?: Options
|
|
41
42
|
selectionMode?: Mode
|
|
42
43
|
disallowEmptySelection?: DisallowEmptySelection
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import { Key, ReactNode } from "react"
|
|
4
|
+
|
|
4
5
|
import { Autocomplete, AutocompleteProps } from "@heroui/react"
|
|
5
6
|
import { FieldComponentProps } from "soda-tanstack-form"
|
|
6
7
|
|
|
7
8
|
import { getFieldProps } from "../utils/getFieldProps"
|
|
8
9
|
|
|
9
|
-
export interface FormAutocompleteProps<
|
|
10
|
-
extends
|
|
10
|
+
export interface FormAutocompleteProps<
|
|
11
|
+
FieldValue extends string | null | undefined = string | null | undefined,
|
|
12
|
+
RenderItem extends object = object,
|
|
13
|
+
> extends FieldComponentProps<typeof Autocomplete<RenderItem>, FieldValue> {
|
|
11
14
|
component?: <T extends object>(props: AutocompleteProps<T>) => ReactNode
|
|
12
15
|
}
|
|
13
16
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import { ReactNode, useContext } from "react"
|
|
4
|
+
|
|
4
5
|
import { Calendar, CalendarProps, DateValue } from "@heroui/react"
|
|
5
6
|
import { FieldComponentProps } from "soda-tanstack-form"
|
|
6
7
|
import { StrictOmit } from "soda-type"
|
|
@@ -10,7 +11,7 @@ import { EmptyValue, FormContext } from "@/components/FormProvider"
|
|
|
10
11
|
import { getFieldProps } from "@/utils/getFieldProps"
|
|
11
12
|
import { DefaultTime } from "@/utils/getTimeValue"
|
|
12
13
|
import { DateMode } from "@/utils/parseTime"
|
|
13
|
-
import {
|
|
14
|
+
import { getFieldValue, getOnChange, TimeValueMode, TimeValueModeMap } from "@/utils/time"
|
|
14
15
|
|
|
15
16
|
export interface FormCalendarProps<
|
|
16
17
|
ValueMode extends TimeValueMode = "date",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import { ReactNode, useContext } from "react"
|
|
4
|
+
|
|
4
5
|
import { DateInput, DateInputProps, DateValue } from "@heroui/react"
|
|
5
6
|
import { FieldComponentProps } from "soda-tanstack-form"
|
|
6
7
|
import { StrictOmit } from "soda-type"
|
|
@@ -10,7 +11,7 @@ import { EmptyValue, FormContext } from "@/components/FormProvider"
|
|
|
10
11
|
import { getFieldProps } from "@/utils/getFieldProps"
|
|
11
12
|
import { DefaultTime } from "@/utils/getTimeValue"
|
|
12
13
|
import { DateMode } from "@/utils/parseTime"
|
|
13
|
-
import {
|
|
14
|
+
import { getFieldValue, getOnChange, TimeValueMode, TimeValueModeMap } from "@/utils/time"
|
|
14
15
|
|
|
15
16
|
export interface FormDateInputProps<
|
|
16
17
|
ValueMode extends TimeValueMode = "date",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import { ReactNode, useContext } from "react"
|
|
4
|
+
|
|
4
5
|
import { DatePicker, DatePickerProps, DateValue } from "@heroui/react"
|
|
5
6
|
import { FieldComponentProps } from "soda-tanstack-form"
|
|
6
7
|
import { StrictOmit } from "soda-type"
|
|
@@ -10,7 +11,7 @@ import { EmptyValue, FormContext } from "@/components/FormProvider"
|
|
|
10
11
|
import { getFieldProps } from "@/utils/getFieldProps"
|
|
11
12
|
import { DefaultTime } from "@/utils/getTimeValue"
|
|
12
13
|
import { DateMode } from "@/utils/parseTime"
|
|
13
|
-
import {
|
|
14
|
+
import { getFieldValue, getOnChange, TimeValueMode, TimeValueModeMap } from "@/utils/time"
|
|
14
15
|
|
|
15
16
|
export interface FormDatePickerProps<
|
|
16
17
|
ValueMode extends TimeValueMode = "date",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import { ReactNode, useContext } from "react"
|
|
4
|
+
|
|
4
5
|
import { DateRangePicker, DateRangePickerProps, DateValue } from "@heroui/react"
|
|
5
6
|
import { Field, FieldComponentProps } from "soda-tanstack-form"
|
|
6
7
|
import { StrictOmit } from "soda-type"
|
|
@@ -9,7 +10,7 @@ import { EmptyValue, FormContext } from "@/components/FormProvider"
|
|
|
9
10
|
|
|
10
11
|
import { getFieldProps } from "@/utils/getFieldProps"
|
|
11
12
|
import { DateMode } from "@/utils/parseTime"
|
|
12
|
-
import {
|
|
13
|
+
import { getFieldRangeValue, getOnRangeChange, RangeDefaultTime } from "@/utils/range"
|
|
13
14
|
import { TimeValueMode, TimeValueModeMap } from "@/utils/time"
|
|
14
15
|
|
|
15
16
|
export interface FormDateRangePickerProps<
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import { ReactNode, useContext } from "react"
|
|
4
|
+
|
|
4
5
|
import { DateValue, RangeCalendar, RangeCalendarProps } from "@heroui/react"
|
|
5
6
|
import { Field, FieldComponentProps } from "soda-tanstack-form"
|
|
6
7
|
import { StrictOmit } from "soda-type"
|
|
@@ -9,7 +10,7 @@ import { EmptyValue, FormContext } from "@/components/FormProvider"
|
|
|
9
10
|
|
|
10
11
|
import { getFieldProps } from "@/utils/getFieldProps"
|
|
11
12
|
import { DateMode } from "@/utils/parseTime"
|
|
12
|
-
import {
|
|
13
|
+
import { getFieldRangeValue, getOnRangeChange, RangeDefaultTime } from "@/utils/range"
|
|
13
14
|
import { TimeValueMode, TimeValueModeMap } from "@/utils/time"
|
|
14
15
|
|
|
15
16
|
export interface FormRangeCalendarProps<
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import { ReactNode, useContext } from "react"
|
|
4
|
+
|
|
4
5
|
import { Select, SelectProps } from "@heroui/react"
|
|
5
6
|
import { Key } from "@react-types/shared"
|
|
6
7
|
import { clsx, isNonNullable } from "deepsea-tools"
|
|
7
8
|
import { FieldComponentProps } from "soda-tanstack-form"
|
|
8
9
|
import { StrictOmit } from "soda-type"
|
|
9
10
|
|
|
10
|
-
import { getFieldProps } from "../utils/getFieldProps"
|
|
11
11
|
import { EmptyValue, FormContext, getEmptyValue } from "./FormProvider"
|
|
12
12
|
|
|
13
|
+
import { getFieldProps } from "../utils/getFieldProps"
|
|
14
|
+
|
|
13
15
|
export type SelectionMode = "single" | "multiple"
|
|
14
16
|
|
|
15
17
|
export type SelectLabelPlacement = "inside" | "outside" | "outside-left" | "outside-top"
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import { ComponentPropsWithoutRef, ReactNode } from "react"
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
import { As, MergeWithAs, Textarea, TextAreaProps } from "@heroui/react"
|
|
5
6
|
import { Field } from "soda-tanstack-form"
|
|
6
7
|
|
|
7
8
|
import { getFieldProps } from "../utils/getFieldProps"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import { ReactNode, useContext } from "react"
|
|
4
|
+
|
|
4
5
|
import { TimeInput, TimeInputProps } from "@heroui/react"
|
|
5
6
|
import { CalendarDateTime, Time, ZonedDateTime } from "@internationalized/date"
|
|
6
7
|
import { FieldComponentProps } from "soda-tanstack-form"
|
|
@@ -11,7 +12,7 @@ import { EmptyValue, FormContext } from "@/components/FormProvider"
|
|
|
11
12
|
import { getFieldProps } from "@/utils/getFieldProps"
|
|
12
13
|
import { DefaultTime } from "@/utils/getTimeValue"
|
|
13
14
|
import { TimeMode } from "@/utils/parseTime"
|
|
14
|
-
import {
|
|
15
|
+
import { getFieldValue, getOnChange, TimeValueMode, TimeValueModeMap } from "@/utils/time"
|
|
15
16
|
|
|
16
17
|
export interface FormTimeInputProps<
|
|
17
18
|
ValueMode extends TimeValueMode = "date",
|
package/src/types/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export type { Field } from "soda-tanstack-form"
|
|
@@ -18,6 +18,7 @@ export function addBetterToast({ key, loading, onClose, classNames, ...rest }: A
|
|
|
18
18
|
key ??= nanoid()
|
|
19
19
|
classNames = { ...classNames }
|
|
20
20
|
classNames.closeButton = clsx(classNames.closeButton, `toast-${key}-close-button`)
|
|
21
|
+
|
|
21
22
|
if (loading) {
|
|
22
23
|
const { promise, resolve } = Promise.withResolvers<void>()
|
|
23
24
|
|
|
@@ -15,6 +15,7 @@ export function getTimeValue<T extends CalendarDateTime | ZonedDateTime | Time |
|
|
|
15
15
|
defaultTime?: DefaultTime | (() => DefaultTime),
|
|
16
16
|
): T extends null | undefined ? undefined : number {
|
|
17
17
|
type ReturnValue = T extends null | undefined ? undefined : number
|
|
18
|
+
|
|
18
19
|
if (time === undefined || time === null) return undefined as ReturnValue
|
|
19
20
|
const newTime = time as CalendarDateTime
|
|
20
21
|
const now = new Date()
|
package/src/utils/parseTime.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CalendarDate, CalendarDateTime,
|
|
1
|
+
import { CalendarDate, CalendarDateTime, fromAbsolute, getLocalTimeZone, Time, ZonedDateTime } from "@internationalized/date"
|
|
2
2
|
|
|
3
|
-
export { CalendarDate, CalendarDateTime,
|
|
3
|
+
export { CalendarDate, CalendarDateTime, fromAbsolute, getLocalTimeZone, Time, ZonedDateTime } from "@internationalized/date"
|
|
4
4
|
|
|
5
5
|
export type ParseMode = typeof ZonedDateTime | typeof CalendarDate | typeof CalendarDateTime | typeof Time
|
|
6
6
|
|
package/src/utils/range.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SetStateAction } from "react"
|
|
2
|
+
|
|
2
3
|
import { DateValue, RangeValue } from "@heroui/react"
|
|
3
4
|
import { isNonNullable } from "deepsea-tools"
|
|
4
5
|
import { Field } from "soda-tanstack-form"
|
|
@@ -50,6 +51,7 @@ export function getRangeUpdater({
|
|
|
50
51
|
defaultTime = typeof defaultTime === "function" ? defaultTime() : defaultTime
|
|
51
52
|
const { start, end } = isNonNullable(defaultTime) && isRangeDefaultTime(defaultTime) ? defaultTime : { start: defaultTime, end: defaultTime }
|
|
52
53
|
if (valueMode === "timestamp") return [getTimeValue(value.start, start), getTimeValue(value.end, end)]
|
|
54
|
+
|
|
53
55
|
function updater(prev: [Date, Date] | [number, number] | null | undefined): [Date, Date] | [number, number] | null | undefined {
|
|
54
56
|
return prev?.[0] instanceof Date &&
|
|
55
57
|
prev?.[1] instanceof Date &&
|
|
@@ -58,6 +60,7 @@ export function getRangeUpdater({
|
|
|
58
60
|
? prev
|
|
59
61
|
: [new Date(getTimeValue(value!.start, start)!), new Date(getTimeValue(value!.end, end)!)]
|
|
60
62
|
}
|
|
63
|
+
|
|
61
64
|
return updater
|
|
62
65
|
}
|
|
63
66
|
|