ant-float-label 1.2.1 → 2.1.0
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/LICENSE +21 -21
- package/README.md +162 -51
- package/dist/LICENSE +21 -21
- package/dist/README.md +162 -51
- package/dist/component/FloatAutoComplete/FloatAutoComplete.stories.d.ts +11 -0
- package/dist/component/FloatAutoComplete/index.d.ts +3 -3
- package/dist/component/FloatCascader/FloatCascader.stories.d.ts +10 -0
- package/dist/component/FloatCascader/index.d.ts +3 -3
- package/dist/component/FloatDatePicker/FloatDatePicker.stories.d.ts +13 -0
- package/dist/component/FloatDatePicker/index.d.ts +3 -3
- package/dist/component/FloatFormItem/FloatFormItem.stories.d.ts +9 -0
- package/dist/component/FloatFormItem/index.d.ts +2 -2
- package/dist/component/FloatInput/FloatInput.stories.d.ts +15 -0
- package/dist/component/FloatInput/index.d.ts +3 -3
- package/dist/component/FloatInputNumber/FloatInputNumber.stories.d.ts +13 -0
- package/dist/component/FloatInputNumber/index.d.ts +3 -3
- package/dist/component/FloatItemList/index.d.ts +3 -2
- package/dist/component/FloatPassword/FloatPassword.stories.d.ts +11 -0
- package/dist/component/FloatPassword/index.d.ts +3 -3
- package/dist/component/FloatRangePicker/FloatRangePicker.stories.d.ts +10 -0
- package/dist/component/FloatRangePicker/index.d.ts +3 -3
- package/dist/component/FloatSelect/FloatSelect.stories.d.ts +13 -0
- package/dist/component/FloatSelect/index.d.ts +3 -3
- package/dist/component/FloatTimePicker/FloatTimePicker.stories.d.ts +11 -0
- package/dist/component/FloatTimePicker/index.d.ts +3 -3
- package/dist/component/FloatTreeSelect/FloatTreeSelect.stories.d.ts +12 -0
- package/dist/component/FloatTreeSelect/index.d.ts +3 -3
- package/dist/component/FloatingLabelBox/index.d.ts +17 -0
- package/dist/hook/useValueHandle.d.ts +3 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +70 -71
- package/dist/index.js.map +1 -1
- package/dist/package.json +56 -33
- package/package.json +56 -38
- package/dist/component/FloattingLabelBox/index.d.ts +0 -18
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { InputNumberProps } from "antd";
|
|
2
2
|
import "./index.css";
|
|
3
|
-
import {
|
|
3
|
+
import { FloatingLabelBoxProps } from "../FloatingLabelBox";
|
|
4
4
|
export interface FloatInputNumberProps extends InputNumberProps {
|
|
5
5
|
required?: boolean;
|
|
6
|
-
labelBoxProps?:
|
|
6
|
+
labelBoxProps?: FloatingLabelBoxProps;
|
|
7
7
|
}
|
|
8
|
-
export declare function FloatInputNumber({ placeholder, onFocus, onBlur, value, defaultValue, style, onChange, required, labelBoxProps, variant, ...restProps }: FloatInputNumberProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function FloatInputNumber({ placeholder, onFocus, onBlur, value, defaultValue, style, onChange, required, labelBoxProps, variant, status, ...restProps }: FloatInputNumberProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
import { Form } from "antd";
|
|
3
|
+
export declare function FloatItemList({ children, name, ...reset }: ComponentProps<typeof Form.List>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { FloatPassword } from "./index";
|
|
3
|
+
declare const meta: Meta<typeof FloatPassword>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof FloatPassword>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Required: Story;
|
|
8
|
+
export declare const WithDefaultValue: Story;
|
|
9
|
+
export declare const Disabled: Story;
|
|
10
|
+
export declare const ErrorStatus: Story;
|
|
11
|
+
export declare const Underlined: Story;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FloatingLabelBoxProps } from "../FloatingLabelBox";
|
|
2
2
|
import { PasswordProps } from "antd/es/input";
|
|
3
3
|
import "./index.css";
|
|
4
4
|
export interface FloatPasswordProps extends PasswordProps {
|
|
5
5
|
required?: boolean;
|
|
6
|
-
labelBoxProps?:
|
|
6
|
+
labelBoxProps?: FloatingLabelBoxProps;
|
|
7
7
|
}
|
|
8
|
-
export declare function FloatPassword({ placeholder, onFocus, onBlur, value, defaultValue, style, onChange, required, labelBoxProps, variant, ...restProps }: FloatPasswordProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function FloatPassword({ placeholder, onFocus, onBlur, value, defaultValue, style, onChange, required, labelBoxProps, variant, status, ...restProps }: FloatPasswordProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { FloatRangePicker } from "./index";
|
|
3
|
+
declare const meta: Meta<typeof FloatRangePicker>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof FloatRangePicker>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Required: Story;
|
|
8
|
+
export declare const Disabled: Story;
|
|
9
|
+
export declare const ErrorStatus: Story;
|
|
10
|
+
export declare const Underlined: Story;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "./index.css";
|
|
2
2
|
import { RangePickerProps } from "antd/es/date-picker";
|
|
3
|
-
import {
|
|
3
|
+
import { FloatingLabelBoxProps } from "../FloatingLabelBox";
|
|
4
4
|
export interface FloatRangePickerProps extends RangePickerProps {
|
|
5
5
|
required?: boolean;
|
|
6
|
-
labelBoxProps?:
|
|
6
|
+
labelBoxProps?: FloatingLabelBoxProps;
|
|
7
7
|
}
|
|
8
|
-
export declare function FloatRangePicker({ placeholder, onFocus, onBlur, value, defaultValue, style, onChange, required, labelBoxProps, variant, ...restProps }: FloatRangePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function FloatRangePicker({ placeholder, onFocus, onBlur, value, defaultValue, style, onChange, required, labelBoxProps, variant, status, ...restProps }: FloatRangePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { FloatSelect } from "./index";
|
|
3
|
+
declare const meta: Meta<typeof FloatSelect>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof FloatSelect>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Required: Story;
|
|
8
|
+
export declare const WithDefaultValue: Story;
|
|
9
|
+
export declare const Multiple: Story;
|
|
10
|
+
export declare const Tags: Story;
|
|
11
|
+
export declare const Disabled: Story;
|
|
12
|
+
export declare const ErrorStatus: Story;
|
|
13
|
+
export declare const Underlined: Story;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SelectProps } from "antd";
|
|
2
2
|
import "./index.css";
|
|
3
|
-
import {
|
|
3
|
+
import { FloatingLabelBoxProps } from "../FloatingLabelBox";
|
|
4
4
|
export interface FloatSelectProps extends SelectProps {
|
|
5
5
|
required?: boolean;
|
|
6
|
-
labelBoxProps?:
|
|
6
|
+
labelBoxProps?: FloatingLabelBoxProps;
|
|
7
7
|
}
|
|
8
|
-
export declare function FloatSelect({ placeholder, onFocus, onBlur, value, defaultValue, style, size, mode, onChange, required, labelBoxProps, variant, ...restProps }: FloatSelectProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function FloatSelect({ placeholder, onFocus, onBlur, value, defaultValue, style, size, mode, onChange, required, labelBoxProps, variant, status, ...restProps }: FloatSelectProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { FloatTimePicker } from "./index";
|
|
3
|
+
declare const meta: Meta<typeof FloatTimePicker>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof FloatTimePicker>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Required: Story;
|
|
8
|
+
export declare const Disabled: Story;
|
|
9
|
+
export declare const ErrorStatus: Story;
|
|
10
|
+
export declare const CustomFormat: Story;
|
|
11
|
+
export declare const Underlined: Story;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TimePickerProps } from "antd";
|
|
2
|
-
import {
|
|
2
|
+
import { FloatingLabelBoxProps } from "../FloatingLabelBox";
|
|
3
3
|
export interface FloatTimePickerProps extends TimePickerProps {
|
|
4
4
|
required?: boolean;
|
|
5
|
-
labelBoxProps?:
|
|
5
|
+
labelBoxProps?: FloatingLabelBoxProps;
|
|
6
6
|
}
|
|
7
|
-
export declare function FloatTimePicker({ placeholder, onFocus, onBlur, value, defaultValue, style, size, mode, onChange, required, labelBoxProps, variant, ...restProps }: FloatTimePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function FloatTimePicker({ placeholder, onFocus, onBlur, value, defaultValue, style, size, mode, onChange, required, labelBoxProps, variant, status, ...restProps }: FloatTimePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { FloatTreeSelect } from "./index";
|
|
3
|
+
declare const meta: Meta<typeof FloatTreeSelect>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof FloatTreeSelect>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Required: Story;
|
|
8
|
+
export declare const Multiple: Story;
|
|
9
|
+
export declare const Checkable: Story;
|
|
10
|
+
export declare const Disabled: Story;
|
|
11
|
+
export declare const ErrorStatus: Story;
|
|
12
|
+
export declare const Underlined: Story;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TreeSelectProps } from "antd";
|
|
2
|
-
import {
|
|
2
|
+
import { FloatingLabelBoxProps } from "../FloatingLabelBox";
|
|
3
3
|
export interface FloatTreeSelectProps extends TreeSelectProps {
|
|
4
4
|
required?: boolean;
|
|
5
|
-
labelBoxProps
|
|
5
|
+
labelBoxProps?: FloatingLabelBoxProps;
|
|
6
6
|
}
|
|
7
|
-
export declare function FloatTreeSelect({ placeholder, onFocus, onBlur, value, defaultValue, style, size, onChange, required, variant, labelBoxProps, ...restProps }: FloatTreeSelectProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function FloatTreeSelect({ placeholder, onFocus, onBlur, value, defaultValue, style, size, onChange, required, variant, labelBoxProps, status, ...restProps }: FloatTreeSelectProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { InputProps } from "antd";
|
|
3
|
+
import "./index.css";
|
|
4
|
+
export interface FloatingLabelBoxProps {
|
|
5
|
+
focused?: boolean;
|
|
6
|
+
hasValue?: boolean;
|
|
7
|
+
label?: React.ReactNode;
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
width?: string | number;
|
|
10
|
+
height?: string | number;
|
|
11
|
+
status?: InputProps['status'];
|
|
12
|
+
required?: boolean;
|
|
13
|
+
fieldsetStyle?: React.CSSProperties;
|
|
14
|
+
labelStyle?: React.CSSProperties;
|
|
15
|
+
variant?: InputProps['variant'];
|
|
16
|
+
}
|
|
17
|
+
export declare function FloatingLabelBox({ focused, hasValue, label, children, width, height, status, required, fieldsetStyle, labelStyle, variant, }: FloatingLabelBoxProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare function useValueHandle({ defaultValue, value,
|
|
2
|
+
export declare function useValueHandle({ defaultValue, value, onFocus, onBlur, status: statusProp, }: {
|
|
3
3
|
defaultValue?: any;
|
|
4
4
|
value?: any;
|
|
5
5
|
id?: string;
|
|
6
6
|
onFocus?: (...args: any) => void;
|
|
7
7
|
onBlur?: (...args: any) => void;
|
|
8
|
+
status?: string;
|
|
8
9
|
}): {
|
|
9
10
|
hasValue: boolean;
|
|
10
11
|
handleChange: import("react").Dispatch<any>;
|
|
11
12
|
handleFocus: (...args: any) => void;
|
|
12
13
|
handleBlur: (...args: any) => void;
|
|
13
14
|
isFocus: boolean;
|
|
15
|
+
formItemStatus: string | undefined;
|
|
14
16
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export * from "./component/FloatInputNumber";
|
|
|
6
6
|
export * from "./component/FloatRangePicker";
|
|
7
7
|
export * from "./component/FloatSelect";
|
|
8
8
|
export * from "./component/FloatTimePicker";
|
|
9
|
-
export * from "./component/
|
|
9
|
+
export * from "./component/FloatingLabelBox";
|
|
10
10
|
export * from "./component/FloatTreeSelect";
|
|
11
11
|
export * from "./component/FloatPassword";
|
|
12
12
|
export * from "./component/FloatFormItem";
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import "./index.css"
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { theme, Form, AutoComplete, Cascader, DatePicker, Input, InputNumber, Select, TimePicker, TreeSelect } from 'antd';
|
|
4
|
-
import React, { useMemo,
|
|
5
|
-
import { FormContext, FormItemInputContext } from 'antd/es/form/context';
|
|
4
|
+
import React, { useMemo, useState, useCallback } from 'react';
|
|
6
5
|
|
|
7
6
|
const { useToken } = theme;
|
|
8
|
-
function
|
|
7
|
+
function FloatingLabelBox({ focused, hasValue, label, children, width, height, status, required, fieldsetStyle, labelStyle, variant = "outlined", }) {
|
|
9
8
|
const { token } = useToken();
|
|
10
9
|
const statusColor = useMemo(() => {
|
|
11
10
|
const colors = {
|
|
@@ -76,26 +75,15 @@ function FloattingLabelBox({ focused, hasValue, label, children, width, height,
|
|
|
76
75
|
}, children: label }) })] }));
|
|
77
76
|
}
|
|
78
77
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const nameMemo = useMemo(() => ({ name }), [name]);
|
|
82
|
-
return (jsx(FloatItemListContext.Provider, { value: nameMemo, children: children }));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function useValueHandle({ defaultValue, value, id, onFocus, onBlur }) {
|
|
86
|
-
const initFlag = useRef(false);
|
|
78
|
+
function useValueHandle({ defaultValue, value, onFocus, onBlur, status: statusProp, }) {
|
|
79
|
+
const [inputValue, setInputValue] = useState(defaultValue);
|
|
87
80
|
const [isFocus, setIsFocus] = useState(false);
|
|
88
|
-
|
|
89
|
-
const {
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return [formListName, ...name];
|
|
95
|
-
}
|
|
96
|
-
return name;
|
|
97
|
-
}, [name, formListName]);
|
|
98
|
-
const changeValue = Form.useWatch(nameMemo, form);
|
|
81
|
+
// Get status from Form.Item context (antd 6 standard approach)
|
|
82
|
+
const { status: formItemStatus } = Form.Item.useStatus();
|
|
83
|
+
// Derived state: Use 'value' prop if present (controlled), otherwise local state (uncontrolled)
|
|
84
|
+
const mergedValue = value !== undefined ? value : inputValue;
|
|
85
|
+
// Merge status: explicit prop > form item context status
|
|
86
|
+
const mergedStatus = statusProp || formItemStatus;
|
|
99
87
|
const handleFocus = useCallback((...args) => {
|
|
100
88
|
setIsFocus(true);
|
|
101
89
|
if (typeof onFocus === "function") {
|
|
@@ -105,36 +93,29 @@ function useValueHandle({ defaultValue, value, id, onFocus, onBlur }) {
|
|
|
105
93
|
const handleBlur = useCallback((...args) => {
|
|
106
94
|
setIsFocus(false);
|
|
107
95
|
if (typeof onBlur === "function") {
|
|
108
|
-
onBlur(args);
|
|
96
|
+
onBlur(...args);
|
|
109
97
|
}
|
|
110
98
|
}, [onBlur]);
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
if (initFlag.current) {
|
|
113
|
-
setInputValue(value);
|
|
114
|
-
}
|
|
115
|
-
initFlag.current = true;
|
|
116
|
-
}, [value]);
|
|
117
|
-
useEffect(() => {
|
|
118
|
-
if (form && id) {
|
|
119
|
-
setInputValue(changeValue);
|
|
120
|
-
}
|
|
121
|
-
}, [changeValue, form]);
|
|
122
99
|
return {
|
|
123
|
-
hasValue: Array.isArray(
|
|
100
|
+
hasValue: Array.isArray(mergedValue)
|
|
101
|
+
? mergedValue.length > 0
|
|
102
|
+
: (mergedValue !== undefined && mergedValue !== null && mergedValue !== ''),
|
|
124
103
|
handleChange: setInputValue,
|
|
125
104
|
handleFocus,
|
|
126
105
|
handleBlur,
|
|
127
|
-
isFocus
|
|
106
|
+
isFocus,
|
|
107
|
+
formItemStatus: mergedStatus,
|
|
128
108
|
};
|
|
129
109
|
}
|
|
130
110
|
|
|
131
|
-
function FloatAutoComplete({ placeholder, onFocus, onBlur, value, defaultValue, style, onChange, required, labelBoxProps, variant, ...restProps }) {
|
|
132
|
-
const { hasValue, handleChange, handleBlur, handleFocus, isFocus } = useValueHandle({
|
|
111
|
+
function FloatAutoComplete({ placeholder, onFocus, onBlur, value, defaultValue, style, onChange, required, labelBoxProps, variant, status, ...restProps }) {
|
|
112
|
+
const { hasValue, handleChange, handleBlur, handleFocus, isFocus, formItemStatus } = useValueHandle({
|
|
133
113
|
id: restProps.id,
|
|
134
114
|
defaultValue,
|
|
135
115
|
value,
|
|
136
116
|
onFocus,
|
|
137
117
|
onBlur,
|
|
118
|
+
status,
|
|
138
119
|
});
|
|
139
120
|
const changeHandler = useCallback((value, option) => {
|
|
140
121
|
handleChange(value);
|
|
@@ -142,20 +123,21 @@ function FloatAutoComplete({ placeholder, onFocus, onBlur, value, defaultValue,
|
|
|
142
123
|
onChange(value, option);
|
|
143
124
|
}
|
|
144
125
|
}, [onChange]);
|
|
145
|
-
return (jsx(
|
|
126
|
+
return (jsx(FloatingLabelBox, { label: placeholder, required: required, focused: isFocus, hasValue: hasValue, width: style?.width, height: style?.height, status: formItemStatus, variant: variant, ...labelBoxProps, children: jsx(AutoComplete, { style: {
|
|
146
127
|
width: "100%",
|
|
147
128
|
...style,
|
|
148
129
|
border: "none",
|
|
149
130
|
}, ...restProps, variant: "borderless", onFocus: handleFocus, onBlur: handleBlur, value: value, defaultValue: defaultValue, onChange: changeHandler, rootClassName: "ant-float-label-form-auto-complete" }) }));
|
|
150
131
|
}
|
|
151
132
|
|
|
152
|
-
function FloatCascader({ placeholder, onFocus, onBlur, value, defaultValue, style, required, onChange, labelBoxProps, variant, ...restProps }) {
|
|
153
|
-
const { hasValue, handleChange, handleBlur, handleFocus, isFocus } = useValueHandle({
|
|
133
|
+
function FloatCascader({ placeholder, onFocus, onBlur, value, defaultValue, style, required, onChange, labelBoxProps, variant, status, ...restProps }) {
|
|
134
|
+
const { hasValue, handleChange, handleBlur, handleFocus, isFocus, formItemStatus } = useValueHandle({
|
|
154
135
|
id: restProps.id,
|
|
155
136
|
defaultValue,
|
|
156
137
|
value,
|
|
157
138
|
onFocus,
|
|
158
139
|
onBlur,
|
|
140
|
+
status,
|
|
159
141
|
});
|
|
160
142
|
const changehandler = useCallback((value, selectedOptions) => {
|
|
161
143
|
handleChange(value);
|
|
@@ -163,16 +145,17 @@ function FloatCascader({ placeholder, onFocus, onBlur, value, defaultValue, styl
|
|
|
163
145
|
onChange(value, selectedOptions);
|
|
164
146
|
}
|
|
165
147
|
}, [onChange]);
|
|
166
|
-
return (jsx(
|
|
148
|
+
return (jsx(FloatingLabelBox, { label: placeholder, focused: isFocus, hasValue: hasValue, width: style?.width, height: style?.height, required: required, status: formItemStatus, variant: variant, ...labelBoxProps, children: jsx(Cascader, { style: { ...style, width: "100%", border: "none" }, variant: "borderless", ...restProps, onFocus: handleFocus, onBlur: handleBlur, value: value, defaultValue: defaultValue, onChange: changehandler, rootClassName: "ant-float-label-form-select" }) }));
|
|
167
149
|
}
|
|
168
150
|
|
|
169
|
-
function FloatDatePicker({ placeholder, onFocus, onBlur, value, defaultValue, style, required, onChange, labelBoxProps, variant, ...restProps }) {
|
|
170
|
-
const { hasValue, handleChange, handleBlur, handleFocus, isFocus } = useValueHandle({
|
|
151
|
+
function FloatDatePicker({ placeholder, onFocus, onBlur, value, defaultValue, style, required, onChange, labelBoxProps, variant, status, ...restProps }) {
|
|
152
|
+
const { hasValue, handleChange, handleBlur, handleFocus, isFocus, formItemStatus } = useValueHandle({
|
|
171
153
|
id: restProps.id,
|
|
172
154
|
defaultValue,
|
|
173
155
|
value,
|
|
174
156
|
onFocus,
|
|
175
157
|
onBlur,
|
|
158
|
+
status,
|
|
176
159
|
});
|
|
177
160
|
const changeHandler = useCallback((value, dateString) => {
|
|
178
161
|
handleChange(value);
|
|
@@ -180,16 +163,17 @@ function FloatDatePicker({ placeholder, onFocus, onBlur, value, defaultValue, st
|
|
|
180
163
|
onChange(value, dateString);
|
|
181
164
|
}
|
|
182
165
|
}, [onChange]);
|
|
183
|
-
return (jsx(
|
|
166
|
+
return (jsx(FloatingLabelBox, { label: placeholder, focused: isFocus, hasValue: hasValue, width: style?.width, height: style?.height, status: formItemStatus, required: required, variant: variant, ...labelBoxProps, children: jsx(DatePicker, { style: { ...style, width: "100%", border: "none" }, ...restProps, variant: "borderless", onFocus: handleFocus, onBlur: handleBlur, value: value, defaultValue: defaultValue, onChange: changeHandler, rootClassName: "ant-float-label-form-picker", placeholder: "" }) }));
|
|
184
167
|
}
|
|
185
168
|
|
|
186
|
-
function FloatInput({ placeholder, onFocus, onBlur, onChange, value, defaultValue, style, size, required, labelBoxProps, variant, ...restProps }) {
|
|
187
|
-
const { hasValue, handleChange, handleBlur, handleFocus, isFocus } = useValueHandle({
|
|
169
|
+
function FloatInput({ placeholder, onFocus, onBlur, onChange, value, defaultValue, style, size, required, labelBoxProps, variant, status, ...restProps }) {
|
|
170
|
+
const { hasValue, handleChange, handleBlur, handleFocus, isFocus, formItemStatus } = useValueHandle({
|
|
188
171
|
id: restProps.id,
|
|
189
172
|
defaultValue,
|
|
190
173
|
value,
|
|
191
174
|
onFocus,
|
|
192
175
|
onBlur,
|
|
176
|
+
status,
|
|
193
177
|
});
|
|
194
178
|
const changeHandler = useCallback((e) => {
|
|
195
179
|
handleChange(e.target.value);
|
|
@@ -197,16 +181,17 @@ function FloatInput({ placeholder, onFocus, onBlur, onChange, value, defaultValu
|
|
|
197
181
|
onChange(e);
|
|
198
182
|
}
|
|
199
183
|
}, [onChange]);
|
|
200
|
-
return (jsx(
|
|
184
|
+
return (jsx(FloatingLabelBox, { label: placeholder, focused: isFocus, hasValue: hasValue, width: style?.width, height: style?.height, required: required, status: formItemStatus, variant: variant, ...labelBoxProps, children: jsx(Input, { style: { ...style, width: "100%", border: "none" }, ...restProps, variant: "borderless", onFocus: handleFocus, onBlur: handleBlur, value: value, defaultValue: defaultValue, onChange: changeHandler, size: size }) }));
|
|
201
185
|
}
|
|
202
186
|
|
|
203
|
-
function FloatInputNumber({ placeholder, onFocus, onBlur, value, defaultValue, style, onChange, required, labelBoxProps, variant, ...restProps }) {
|
|
204
|
-
const { hasValue, handleChange, handleBlur, handleFocus, isFocus } = useValueHandle({
|
|
187
|
+
function FloatInputNumber({ placeholder, onFocus, onBlur, value, defaultValue, style, onChange, required, labelBoxProps, variant, status, ...restProps }) {
|
|
188
|
+
const { hasValue, handleChange, handleBlur, handleFocus, isFocus, formItemStatus } = useValueHandle({
|
|
205
189
|
id: restProps.id,
|
|
206
190
|
defaultValue,
|
|
207
191
|
value,
|
|
208
192
|
onFocus,
|
|
209
193
|
onBlur,
|
|
194
|
+
status,
|
|
210
195
|
});
|
|
211
196
|
const changeHanlder = useCallback((value) => {
|
|
212
197
|
handleChange(value);
|
|
@@ -214,17 +199,18 @@ function FloatInputNumber({ placeholder, onFocus, onBlur, value, defaultValue, s
|
|
|
214
199
|
onChange(value);
|
|
215
200
|
}
|
|
216
201
|
}, [onChange]);
|
|
217
|
-
return (jsx(
|
|
202
|
+
return (jsx(FloatingLabelBox, { label: placeholder, focused: isFocus, hasValue: hasValue, width: style?.width, height: style?.height, required: required, status: formItemStatus, variant: variant, ...labelBoxProps, children: jsx(InputNumber, { style: { ...style, width: "100%", border: "none" }, ...restProps, variant: "borderless", onFocus: handleFocus, onBlur: handleBlur, value: value, defaultValue: defaultValue, onChange: changeHanlder, rootClassName: "ant-float-label-form-input-number" }) }));
|
|
218
203
|
}
|
|
219
204
|
|
|
220
205
|
const { RangePicker } = DatePicker;
|
|
221
|
-
function FloatRangePicker({ placeholder, onFocus, onBlur, value, defaultValue, style, onChange, required, labelBoxProps, variant, ...restProps }) {
|
|
222
|
-
const { hasValue, handleChange, handleBlur, handleFocus, isFocus } = useValueHandle({
|
|
206
|
+
function FloatRangePicker({ placeholder, onFocus, onBlur, value, defaultValue, style, onChange, required, labelBoxProps, variant, status, ...restProps }) {
|
|
207
|
+
const { hasValue, handleChange, handleBlur, handleFocus, isFocus, formItemStatus } = useValueHandle({
|
|
223
208
|
id: restProps.id?.toString(),
|
|
224
209
|
defaultValue,
|
|
225
210
|
value,
|
|
226
211
|
onFocus,
|
|
227
212
|
onBlur,
|
|
213
|
+
status,
|
|
228
214
|
});
|
|
229
215
|
const changeHandler = useCallback((value, dateString) => {
|
|
230
216
|
handleChange(value);
|
|
@@ -235,16 +221,17 @@ function FloatRangePicker({ placeholder, onFocus, onBlur, value, defaultValue, s
|
|
|
235
221
|
const hasValueFlag = useMemo(() => {
|
|
236
222
|
return isFocus || hasValue;
|
|
237
223
|
}, [hasValue, isFocus]);
|
|
238
|
-
return (jsx(
|
|
224
|
+
return (jsx(FloatingLabelBox, { label: hasValueFlag && placeholder ? placeholder.join(" - ") : "", focused: isFocus, hasValue: hasValueFlag, width: style?.width, height: style?.height, required: required, status: formItemStatus, variant: variant, ...labelBoxProps, children: jsx(RangePicker, { style: { ...style, width: "100%", border: "none" }, ...restProps, variant: "borderless", onFocus: handleFocus, onBlur: handleBlur, value: value, defaultValue: defaultValue, onChange: changeHandler, rootClassName: "ant-float-label-form-picker", placeholder: hasValue ? ["", ""] : placeholder }) }));
|
|
239
225
|
}
|
|
240
226
|
|
|
241
|
-
function FloatSelect({ placeholder, onFocus, onBlur, value, defaultValue, style, size, mode, onChange, required, labelBoxProps, variant, ...restProps }) {
|
|
242
|
-
const { hasValue, handleChange, handleBlur, handleFocus, isFocus } = useValueHandle({
|
|
227
|
+
function FloatSelect({ placeholder, onFocus, onBlur, value, defaultValue, style, size, mode, onChange, required, labelBoxProps, variant, status, ...restProps }) {
|
|
228
|
+
const { hasValue, handleChange, handleBlur, handleFocus, isFocus, formItemStatus } = useValueHandle({
|
|
243
229
|
id: restProps.id?.toString(),
|
|
244
230
|
defaultValue,
|
|
245
231
|
value,
|
|
246
232
|
onFocus,
|
|
247
233
|
onBlur,
|
|
234
|
+
status,
|
|
248
235
|
});
|
|
249
236
|
const changeHandler = useCallback((value, option) => {
|
|
250
237
|
handleChange(value);
|
|
@@ -252,16 +239,17 @@ function FloatSelect({ placeholder, onFocus, onBlur, value, defaultValue, style,
|
|
|
252
239
|
onChange(value, option);
|
|
253
240
|
}
|
|
254
241
|
}, [onChange]);
|
|
255
|
-
return (jsx(
|
|
242
|
+
return (jsx(FloatingLabelBox, { label: placeholder, focused: isFocus, hasValue: hasValue, width: style?.width, height: style?.height, required: required, status: formItemStatus, variant: variant, ...labelBoxProps, children: jsx(Select, { style: { ...style, width: "100%", border: "none" }, ...restProps, variant: "borderless", onFocus: handleFocus, onBlur: handleBlur, value: value, defaultValue: defaultValue, size: size, onChange: changeHandler, mode: mode, rootClassName: "ant-float-label-form-select" }) }));
|
|
256
243
|
}
|
|
257
244
|
|
|
258
|
-
function FloatTimePicker({ placeholder, onFocus, onBlur, value, defaultValue, style, size, mode, onChange, required, labelBoxProps, variant, ...restProps }) {
|
|
259
|
-
const { hasValue, handleChange, handleBlur, handleFocus, isFocus } = useValueHandle({
|
|
245
|
+
function FloatTimePicker({ placeholder, onFocus, onBlur, value, defaultValue, style, size, mode, onChange, required, labelBoxProps, variant, status, ...restProps }) {
|
|
246
|
+
const { hasValue, handleChange, handleBlur, handleFocus, isFocus, formItemStatus } = useValueHandle({
|
|
260
247
|
id: restProps.id?.toString(),
|
|
261
248
|
defaultValue,
|
|
262
249
|
value,
|
|
263
250
|
onFocus,
|
|
264
251
|
onBlur,
|
|
252
|
+
status,
|
|
265
253
|
});
|
|
266
254
|
const changeHandler = useCallback((value, option) => {
|
|
267
255
|
handleChange(value);
|
|
@@ -269,20 +257,21 @@ function FloatTimePicker({ placeholder, onFocus, onBlur, value, defaultValue, st
|
|
|
269
257
|
onChange(value, option);
|
|
270
258
|
}
|
|
271
259
|
}, [onChange]);
|
|
272
|
-
return (jsx(
|
|
260
|
+
return (jsx(FloatingLabelBox, { label: placeholder, focused: isFocus, hasValue: hasValue, width: style?.width, height: style?.height, required: required, status: formItemStatus, variant: variant, ...labelBoxProps, children: jsx(TimePicker, { style: {
|
|
273
261
|
...style,
|
|
274
262
|
width: "100%",
|
|
275
263
|
border: "none",
|
|
276
264
|
}, ...restProps, variant: "borderless", onFocus: handleFocus, onBlur: handleBlur, value: value, defaultValue: defaultValue, size: size, onChange: changeHandler, mode: mode, rootClassName: "ant-float-label-form-select", placeholder: "" }) }));
|
|
277
265
|
}
|
|
278
266
|
|
|
279
|
-
function FloatTreeSelect({ placeholder, onFocus, onBlur, value, defaultValue, style, size, onChange, required, variant, labelBoxProps, ...restProps }) {
|
|
280
|
-
const { hasValue, handleChange, handleBlur, handleFocus, isFocus } = useValueHandle({
|
|
267
|
+
function FloatTreeSelect({ placeholder, onFocus, onBlur, value, defaultValue, style, size, onChange, required, variant, labelBoxProps, status, ...restProps }) {
|
|
268
|
+
const { hasValue, handleChange, handleBlur, handleFocus, isFocus, formItemStatus } = useValueHandle({
|
|
281
269
|
id: restProps.id?.toString(),
|
|
282
270
|
defaultValue,
|
|
283
271
|
value,
|
|
284
272
|
onFocus,
|
|
285
273
|
onBlur,
|
|
274
|
+
status,
|
|
286
275
|
});
|
|
287
276
|
const changeHandler = useCallback((value, labelList, extra) => {
|
|
288
277
|
handleChange(value);
|
|
@@ -290,7 +279,7 @@ function FloatTreeSelect({ placeholder, onFocus, onBlur, value, defaultValue, st
|
|
|
290
279
|
onChange(value, labelList, extra);
|
|
291
280
|
}
|
|
292
281
|
}, [onChange]);
|
|
293
|
-
return (jsx(
|
|
282
|
+
return (jsx(FloatingLabelBox, { label: placeholder, focused: isFocus, hasValue: hasValue, width: style?.width, height: style?.height, required: required, status: formItemStatus, variant: variant, ...labelBoxProps, children: jsx(TreeSelect, { style: {
|
|
294
283
|
...style,
|
|
295
284
|
width: "100%",
|
|
296
285
|
border: "none",
|
|
@@ -298,21 +287,22 @@ function FloatTreeSelect({ placeholder, onFocus, onBlur, value, defaultValue, st
|
|
|
298
287
|
}
|
|
299
288
|
|
|
300
289
|
const { Password } = Input;
|
|
301
|
-
function FloatPassword({ placeholder, onFocus, onBlur, value, defaultValue, style, onChange, required, labelBoxProps, variant, ...restProps }) {
|
|
302
|
-
const { hasValue, handleChange, handleBlur, handleFocus, isFocus } = useValueHandle({
|
|
290
|
+
function FloatPassword({ placeholder, onFocus, onBlur, value, defaultValue, style, onChange, required, labelBoxProps, variant, status, ...restProps }) {
|
|
291
|
+
const { hasValue, handleChange, handleBlur, handleFocus, isFocus, formItemStatus } = useValueHandle({
|
|
303
292
|
id: restProps.id,
|
|
304
293
|
defaultValue,
|
|
305
294
|
value,
|
|
306
295
|
onFocus,
|
|
307
296
|
onBlur,
|
|
297
|
+
status,
|
|
308
298
|
});
|
|
309
|
-
const changeHanlder = useCallback((
|
|
310
|
-
handleChange(value);
|
|
299
|
+
const changeHanlder = useCallback((e) => {
|
|
300
|
+
handleChange(e.target.value);
|
|
311
301
|
if (onChange) {
|
|
312
|
-
onChange(
|
|
302
|
+
onChange(e);
|
|
313
303
|
}
|
|
314
304
|
}, [onChange]);
|
|
315
|
-
return (jsx(
|
|
305
|
+
return (jsx(FloatingLabelBox, { label: placeholder, focused: isFocus, hasValue: hasValue, width: style?.width, height: style?.height, required: required, status: formItemStatus, variant: variant, ...labelBoxProps, children: jsx(Password, { style: { ...style, width: "100%", border: "none" }, ...restProps, variant: "borderless", onFocus: handleFocus, onBlur: handleBlur, value: value, defaultValue: defaultValue, onChange: changeHanlder, rootClassName: "ant-float-label-form-input-password" }) }));
|
|
316
306
|
}
|
|
317
307
|
|
|
318
308
|
function FloatFormItem({ children, label = "", rules, required, ...restProps }) {
|
|
@@ -321,7 +311,10 @@ function FloatFormItem({ children, label = "", rules, required, ...restProps })
|
|
|
321
311
|
return required;
|
|
322
312
|
return rules?.some((value) => value.required !== undefined && value.required !== false);
|
|
323
313
|
}, [required, rules]);
|
|
324
|
-
return (
|
|
314
|
+
return (
|
|
315
|
+
// noStyle + label hidden: Form.Item handles validation state via context (Form.Item.useStatus)
|
|
316
|
+
// The float components read status from Form.Item.useStatus() hook automatically
|
|
317
|
+
jsx(Form.Item, { required: required, rules: rules, ...restProps, label: "", children: children
|
|
325
318
|
? React.cloneElement(children, {
|
|
326
319
|
placeholder: label,
|
|
327
320
|
required: isRequired,
|
|
@@ -329,9 +322,15 @@ function FloatFormItem({ children, label = "", rules, required, ...restProps })
|
|
|
329
322
|
: children }));
|
|
330
323
|
}
|
|
331
324
|
|
|
325
|
+
const FloatItemListContext = React.createContext({});
|
|
326
|
+
function FloatItemListProvider({ children, name }) {
|
|
327
|
+
const nameMemo = useMemo(() => ({ name }), [name]);
|
|
328
|
+
return (jsx(FloatItemListContext.Provider, { value: nameMemo, children: children }));
|
|
329
|
+
}
|
|
330
|
+
|
|
332
331
|
function FloatItemList({ children, name, ...reset }) {
|
|
333
332
|
return jsx(FloatItemListProvider, { name: name, children: jsx(Form.List, { name: name, ...reset, children: children }) });
|
|
334
333
|
}
|
|
335
334
|
|
|
336
|
-
export { FloatAutoComplete, FloatCascader, FloatDatePicker, FloatFormItem, FloatInput, FloatInputNumber, FloatItemList, FloatPassword, FloatRangePicker, FloatSelect, FloatTimePicker, FloatTreeSelect,
|
|
335
|
+
export { FloatAutoComplete, FloatCascader, FloatDatePicker, FloatFormItem, FloatInput, FloatInputNumber, FloatItemList, FloatPassword, FloatRangePicker, FloatSelect, FloatTimePicker, FloatTreeSelect, FloatingLabelBox };
|
|
337
336
|
//# sourceMappingURL=index.js.map
|