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.
@@ -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;
@@ -1 +1 @@
1
- export { type Field } from "soda-tanstack-form";
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, Time, ZonedDateTime, fromAbsolute, getLocalTimeZone } from "@internationalized/date";
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.24",
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.23.6",
40
- "soda-type": "6.7.1",
41
- "soda-tanstack-form": "0.3.2",
42
- "deepsea-tools": "5.43.1",
43
- "soda-hooks": "6.16.0"
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.3",
49
- "prettier": "^3.6.2",
48
+ "glob": "^11.1.0",
49
+ "prettier": "^3.7.4",
50
50
  "prettier-plugin-organize-imports": "^4.3.0",
51
- "typescript": "^5.9.3"
51
+ "typescript": ">=5.8.3"
52
52
  },
53
53
  "peerDependencies": {
54
- "@types/node": ">=20",
55
54
  "@heroui/react": ">=2",
56
- "@types/react": ">=19.2.4",
57
- "react": ">=19.2.0"
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
- import { Button, PressEvent, addToast } from "@heroui/react"
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 { ValueOf, getEnumOptions, intParser, isNonNullable } from "deepsea-tools"
6
+ import { getEnumOptions, intParser, isNonNullable, ValueOf } from "deepsea-tools"
6
7
  import { useInputState } from "soda-hooks"
7
8
 
8
- import { EmptyValue, FormContext, GetEmptyValue, getEmptyValue } from "./FormProvider"
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
- ComponentProps<typeof Select<EnumOption<Options>>>,
38
- "items" | "selectionMode" | "disallowEmptySelection" | "children" | "selectedKeys" | "onSelectionChange" | "value" | "onValueChange"
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,6 +1,7 @@
1
1
  "use client"
2
2
 
3
3
  import { ComponentProps, FC } from "react"
4
+
4
5
  import { isNonNullable } from "deepsea-tools"
5
6
 
6
7
  export interface ErrorMessageItem {
@@ -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<FieldValue extends string | null | undefined = string | null | undefined, RenderItem extends object = object>
10
- extends FieldComponentProps<typeof Autocomplete<RenderItem>, FieldValue> {
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 { TimeValueMode, TimeValueModeMap, getFieldValue, getOnChange } from "@/utils/time"
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 { ComponentPropsWithoutRef, ReactNode } from "react"
4
+
4
5
  import { As, Checkbox, CheckboxProps, MergeWithAs } from "@heroui/react"
5
6
  import { Field } from "soda-tanstack-form"
6
7
 
@@ -1,6 +1,7 @@
1
1
  "use client"
2
2
 
3
3
  import { ComponentPropsWithoutRef, ReactNode } from "react"
4
+
4
5
  import { As, CheckboxGroup, CheckboxGroupProps, MergeWithAs } from "@heroui/react"
5
6
  import { Field } from "soda-tanstack-form"
6
7
 
@@ -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 { TimeValueMode, TimeValueModeMap, getFieldValue, getOnChange } from "@/utils/time"
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 { TimeValueMode, TimeValueModeMap, getFieldValue, getOnChange } from "@/utils/time"
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 { RangeDefaultTime, getFieldRangeValue, getOnRangeChange } from "@/utils/range"
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 { ComponentPropsWithoutRef, ReactNode } from "react"
4
+
4
5
  import { As, Input, InputProps, MergeWithAs } from "@heroui/react"
5
6
  import { Field } from "soda-tanstack-form"
6
7
 
@@ -1,6 +1,7 @@
1
1
  "use client"
2
2
 
3
3
  import { ComponentPropsWithoutRef, ReactNode } from "react"
4
+
4
5
  import { As, InputOtp, InputOtpProps, MergeWithAs } from "@heroui/react"
5
6
  import { Field } from "soda-tanstack-form"
6
7
 
@@ -1,6 +1,7 @@
1
1
  "use client"
2
2
 
3
3
  import { ComponentPropsWithoutRef, ReactNode } from "react"
4
+
4
5
  import { As, MergeWithAs, NumberInput, NumberInputProps } from "@heroui/react"
5
6
  import { Field } from "soda-tanstack-form"
6
7
 
@@ -1,6 +1,7 @@
1
1
  "use client"
2
2
 
3
3
  import { ComponentPropsWithoutRef, ReactNode } from "react"
4
+
4
5
  import { As, MergeWithAs, Pagination, PaginationProps } from "@heroui/react"
5
6
  import { Field } from "soda-tanstack-form"
6
7
 
@@ -1,6 +1,7 @@
1
1
  "use client"
2
2
 
3
- import { FC, ReactNode, createContext, useContext } from "react"
3
+ import { createContext, FC, ReactNode, useContext } from "react"
4
+
4
5
  import { assign } from "deepsea-tools"
5
6
 
6
7
  export type EmptyValue = "null" | "undefined"
@@ -1,6 +1,7 @@
1
1
  "use client"
2
2
 
3
3
  import { ComponentPropsWithoutRef, ReactNode } from "react"
4
+
4
5
  import { As, MergeWithAs, RadioGroup, RadioGroupProps } from "@heroui/react"
5
6
  import { Field } from "soda-tanstack-form"
6
7
 
@@ -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 { RangeDefaultTime, getFieldRangeValue, getOnRangeChange } from "@/utils/range"
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,6 +1,7 @@
1
1
  "use client"
2
2
 
3
3
  import { ComponentPropsWithoutRef, ReactNode } from "react"
4
+
4
5
  import { As, MergeWithAs, Switch, SwitchProps } from "@heroui/react"
5
6
  import { Field } from "soda-tanstack-form"
6
7
 
@@ -1,7 +1,8 @@
1
1
  "use client"
2
2
 
3
3
  import { ComponentPropsWithoutRef, ReactNode } from "react"
4
- import { As, MergeWithAs, TextAreaProps, Textarea } from "@heroui/react"
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 { TimeValueMode, TimeValueModeMap, getFieldValue, getOnChange } from "@/utils/time"
15
+ import { getFieldValue, getOnChange, TimeValueMode, TimeValueModeMap } from "@/utils/time"
15
16
 
16
17
  export interface FormTimeInputProps<
17
18
  ValueMode extends TimeValueMode = "date",
@@ -1 +1 @@
1
- export { type Field } from "soda-tanstack-form"
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
 
@@ -1,4 +1,5 @@
1
1
  import { JSX } from "react"
2
+
2
3
  import { Field, isFieldInvalid } from "soda-tanstack-form"
3
4
 
4
5
  import { ErrorMessage } from "@/components/ErrorMessage"
@@ -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()
@@ -1,6 +1,6 @@
1
- import { CalendarDate, CalendarDateTime, Time, ZonedDateTime, fromAbsolute, getLocalTimeZone } from "@internationalized/date"
1
+ import { CalendarDate, CalendarDateTime, fromAbsolute, getLocalTimeZone, Time, ZonedDateTime } from "@internationalized/date"
2
2
 
3
- export { CalendarDate, CalendarDateTime, Time, ZonedDateTime, fromAbsolute, getLocalTimeZone } from "@internationalized/date"
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
 
@@ -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
 
package/src/utils/time.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { SetStateAction } from "react"
2
+
2
3
  import { CalendarDate, CalendarDateTime, Time, ZonedDateTime } from "@internationalized/date"
3
4
  import { isNonNullable } from "deepsea-tools"
4
5
  import { Field } from "soda-tanstack-form"