ant-float-label 2.0.0 → 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.
Files changed (30) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +162 -162
  3. package/dist/LICENSE +21 -21
  4. package/dist/README.md +162 -162
  5. package/dist/component/FloatAutoComplete/FloatAutoComplete.stories.d.ts +11 -0
  6. package/dist/component/FloatAutoComplete/index.d.ts +1 -1
  7. package/dist/component/FloatCascader/FloatCascader.stories.d.ts +10 -0
  8. package/dist/component/FloatCascader/index.d.ts +1 -1
  9. package/dist/component/FloatDatePicker/FloatDatePicker.stories.d.ts +13 -0
  10. package/dist/component/FloatDatePicker/index.d.ts +1 -1
  11. package/dist/component/FloatFormItem/FloatFormItem.stories.d.ts +9 -0
  12. package/dist/component/FloatInput/FloatInput.stories.d.ts +15 -0
  13. package/dist/component/FloatInput/index.d.ts +1 -1
  14. package/dist/component/FloatInputNumber/FloatInputNumber.stories.d.ts +13 -0
  15. package/dist/component/FloatInputNumber/index.d.ts +1 -1
  16. package/dist/component/FloatPassword/FloatPassword.stories.d.ts +11 -0
  17. package/dist/component/FloatPassword/index.d.ts +1 -1
  18. package/dist/component/FloatRangePicker/FloatRangePicker.stories.d.ts +10 -0
  19. package/dist/component/FloatRangePicker/index.d.ts +1 -1
  20. package/dist/component/FloatSelect/FloatSelect.stories.d.ts +13 -0
  21. package/dist/component/FloatSelect/index.d.ts +1 -1
  22. package/dist/component/FloatTimePicker/FloatTimePicker.stories.d.ts +11 -0
  23. package/dist/component/FloatTimePicker/index.d.ts +1 -1
  24. package/dist/component/FloatTreeSelect/FloatTreeSelect.stories.d.ts +12 -0
  25. package/dist/component/FloatTreeSelect/index.d.ts +1 -1
  26. package/dist/hook/useValueHandle.d.ts +3 -1
  27. package/dist/index.js +56 -38
  28. package/dist/index.js.map +1 -1
  29. package/dist/package.json +56 -46
  30. package/package.json +56 -46
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Tim Ou
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Tim Ou
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,162 +1,162 @@
1
- # Ant Float Label
2
-
3
- A comprehensive wrapper library for Ant Design components that implements the elegant "Floating Label" pattern (similar to Material UI). This library provides a seamless way to modernize your forms while maintaining the full power and theming capabilities of Ant Design.
4
-
5
- [![NPM Version](https://img.shields.io/npm/v/ant-float-label.svg)](https://www.npmjs.com/package/ant-float-label)
6
- [![License](https://img.shields.io/npm/l/ant-float-label.svg)](https://github.com/razr001/ant-float-label/blob/master/LICENSE)
7
-
8
- ## Features
9
-
10
- - **✨ Modern Aesthetics**: Brings the popular floating label design pattern to Ant Design.
11
- - **🎨 Theme Compatible**: Fully integrates with Ant Design 5+ Token System (Design Tokens), supporting light and dark modes automatically.
12
- - **🛠 TypeScript Ready**: Written in TypeScript with full type definitions.
13
- - **🧩 Complete Suite**: Supports a wide range of input components including Input, Select, DatePicker, Cascader, TreeSelect, and more.
14
- - **🚀 Easy Integration**: Works as a drop-in replacement for standard Ant Design components.
15
- - **📱 Responsive**: Adapts perfectly to different screen sizes and form layouts.
16
-
17
- ## Installation
18
-
19
- Install via npm, yarn, or pnpm:
20
-
21
- ```bash
22
- npm install ant-float-label
23
- # or
24
- yarn add ant-float-label
25
- # or
26
- pnpm add ant-float-label
27
- ```
28
-
29
- Ensure you have the peer dependencies installed:
30
-
31
- ```bash
32
- npm install antd react react-dom
33
- ```
34
-
35
- ## Usage
36
-
37
- ### Basic Usage
38
-
39
- You can use the components directly. Passing the `placeholder` prop will automatically act as the floating label content.
40
-
41
- ```tsx
42
- import React, { useState } from 'react';
43
- import { FloatInput, FloatSelect } from 'ant-float-label';
44
-
45
- const App = () => {
46
- const [value, setValue] = useState('');
47
-
48
- return (
49
- <div style={{ padding: 24, display: 'flex', flexDirection: 'column', gap: 16 }}>
50
- {/* The placeholder acts as the floating label */}
51
- <FloatInput
52
- placeholder="Username"
53
- value={value}
54
- onChange={(e) => setValue(e.target.value)}
55
- />
56
-
57
- <FloatSelect
58
- placeholder="Gender"
59
- options={[
60
- { label: 'Male', value: 'male' },
61
- { label: 'Female', value: 'female' },
62
- ]}
63
- />
64
- </div>
65
- );
66
- };
67
- ```
68
-
69
- ### Using with Ant Design Form
70
-
71
- The recommended way to use this library in forms is with `FloatFormItem`. It automatically handles the label state and passes it to the underlying component.
72
-
73
- ```tsx
74
- import React from 'react';
75
- import { Form, Button } from 'antd';
76
- import { FloatFormItem, FloatInput, FloatPassword } from 'ant-float-label';
77
-
78
- const LoginForm = () => {
79
- const [form] = Form.useForm();
80
-
81
- const onFinish = (values) => {
82
- console.log('Success:', values);
83
- };
84
-
85
- return (
86
- <Form
87
- form={form}
88
- name="login"
89
- onFinish={onFinish}
90
- style={{ maxWidth: 400 }}
91
- >
92
- <FloatFormItem
93
- name="username"
94
- label="Username"
95
- rules={[{ required: true, message: 'Please input your username!' }]}
96
- >
97
- <FloatInput />
98
- </FloatFormItem>
99
-
100
- <FloatFormItem
101
- name="password"
102
- label="Password"
103
- rules={[{ required: true, message: 'Please input your password!' }]}
104
- >
105
- <FloatPassword />
106
- </FloatFormItem>
107
-
108
- <Form.Item>
109
- <Button type="primary" htmlType="submit" block>
110
- Log in
111
- </Button>
112
- </Form.Item>
113
- </Form>
114
- );
115
- };
116
- ```
117
-
118
- ## Available Components
119
-
120
- All components inherit props from their Ant Design counterparts.
121
-
122
- | Component | Description |
123
- |-----------|-------------|
124
- | `FloatInput` | Wraps `Input` |
125
- | `FloatPassword` | Wraps `Input.Password` |
126
- | `FloatInputNumber` | Wraps `InputNumber` |
127
- | `FloatSelect` | Wraps `Select` |
128
- | `FloatDatePicker` | Wraps `DatePicker` |
129
- | `FloatRangePicker` | Wraps `DatePicker.RangePicker` |
130
- | `FloatTimePicker` | Wraps `TimePicker` |
131
- | `FloatCascader` | Wraps `Cascader` |
132
- | `FloatTreeSelect` | Wraps `TreeSelect` |
133
- | `FloatAutoComplete` | Wraps `AutoComplete` |
134
- | `FloatFormItem` | Specialized `Form.Item` for automatic label handling |
135
-
136
- ## Props
137
-
138
- ### Common Props
139
- Most components accept all standard Ant Design props for their respective base component (e.g., `FloatInput` accepts all `InputProps`).
140
-
141
- ### Specific Props
142
-
143
- - **label** (string | ReactNode): When used with `FloatFormItem`, the `label` prop of the FormItem is automatically used as the floating label.
144
- - **placeholder** (string): When used standalone, the `placeholder` acts as the floating label text.
145
- - **labelBoxProps** (object): Props passed to the internal wrapper for advanced styling (e.g. `style`, `className` for the box container).
146
-
147
- ## Customization
148
-
149
- You can customize the appearance by overriding CSS variables or providing `labelBoxProps`. The library follows Ant Design's design token system, so changing your global theme config will automatically update these components.
150
-
151
- ```tsx
152
- <FloatInput
153
- placeholder="Custom Style"
154
- labelBoxProps={{
155
- style: { borderColor: 'red' }
156
- }}
157
- />
158
- ```
159
-
160
- ## License
161
-
162
- MIT © [razr001](https://github.com/razr001)
1
+ # Ant Float Label
2
+
3
+ A comprehensive wrapper library for Ant Design components that implements the elegant "Floating Label" pattern (similar to Material UI). This library provides a seamless way to modernize your forms while maintaining the full power and theming capabilities of Ant Design.
4
+
5
+ [![NPM Version](https://img.shields.io/npm/v/ant-float-label.svg)](https://www.npmjs.com/package/ant-float-label)
6
+ [![License](https://img.shields.io/npm/l/ant-float-label.svg)](https://github.com/razr001/ant-float-label/blob/master/LICENSE)
7
+
8
+ ## Features
9
+
10
+ - **✨ Modern Aesthetics**: Brings the popular floating label design pattern to Ant Design.
11
+ - **🎨 Theme Compatible**: Fully integrates with Ant Design 5+ Token System (Design Tokens), supporting light and dark modes automatically.
12
+ - **🛠 TypeScript Ready**: Written in TypeScript with full type definitions.
13
+ - **🧩 Complete Suite**: Supports a wide range of input components including Input, Select, DatePicker, Cascader, TreeSelect, and more.
14
+ - **🚀 Easy Integration**: Works as a drop-in replacement for standard Ant Design components.
15
+ - **📱 Responsive**: Adapts perfectly to different screen sizes and form layouts.
16
+
17
+ ## Installation
18
+
19
+ Install via npm, yarn, or pnpm:
20
+
21
+ ```bash
22
+ npm install ant-float-label
23
+ # or
24
+ yarn add ant-float-label
25
+ # or
26
+ pnpm add ant-float-label
27
+ ```
28
+
29
+ Ensure you have the peer dependencies installed:
30
+
31
+ ```bash
32
+ npm install antd react react-dom
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ ### Basic Usage
38
+
39
+ You can use the components directly. Passing the `placeholder` prop will automatically act as the floating label content.
40
+
41
+ ```tsx
42
+ import React, { useState } from 'react';
43
+ import { FloatInput, FloatSelect } from 'ant-float-label';
44
+
45
+ const App = () => {
46
+ const [value, setValue] = useState('');
47
+
48
+ return (
49
+ <div style={{ padding: 24, display: 'flex', flexDirection: 'column', gap: 16 }}>
50
+ {/* The placeholder acts as the floating label */}
51
+ <FloatInput
52
+ placeholder="Username"
53
+ value={value}
54
+ onChange={(e) => setValue(e.target.value)}
55
+ />
56
+
57
+ <FloatSelect
58
+ placeholder="Gender"
59
+ options={[
60
+ { label: 'Male', value: 'male' },
61
+ { label: 'Female', value: 'female' },
62
+ ]}
63
+ />
64
+ </div>
65
+ );
66
+ };
67
+ ```
68
+
69
+ ### Using with Ant Design Form
70
+
71
+ The recommended way to use this library in forms is with `FloatFormItem`. It automatically handles the label state and passes it to the underlying component.
72
+
73
+ ```tsx
74
+ import React from 'react';
75
+ import { Form, Button } from 'antd';
76
+ import { FloatFormItem, FloatInput, FloatPassword } from 'ant-float-label';
77
+
78
+ const LoginForm = () => {
79
+ const [form] = Form.useForm();
80
+
81
+ const onFinish = (values) => {
82
+ console.log('Success:', values);
83
+ };
84
+
85
+ return (
86
+ <Form
87
+ form={form}
88
+ name="login"
89
+ onFinish={onFinish}
90
+ style={{ maxWidth: 400 }}
91
+ >
92
+ <FloatFormItem
93
+ name="username"
94
+ label="Username"
95
+ rules={[{ required: true, message: 'Please input your username!' }]}
96
+ >
97
+ <FloatInput />
98
+ </FloatFormItem>
99
+
100
+ <FloatFormItem
101
+ name="password"
102
+ label="Password"
103
+ rules={[{ required: true, message: 'Please input your password!' }]}
104
+ >
105
+ <FloatPassword />
106
+ </FloatFormItem>
107
+
108
+ <Form.Item>
109
+ <Button type="primary" htmlType="submit" block>
110
+ Log in
111
+ </Button>
112
+ </Form.Item>
113
+ </Form>
114
+ );
115
+ };
116
+ ```
117
+
118
+ ## Available Components
119
+
120
+ All components inherit props from their Ant Design counterparts.
121
+
122
+ | Component | Description |
123
+ |-----------|-------------|
124
+ | `FloatInput` | Wraps `Input` |
125
+ | `FloatPassword` | Wraps `Input.Password` |
126
+ | `FloatInputNumber` | Wraps `InputNumber` |
127
+ | `FloatSelect` | Wraps `Select` |
128
+ | `FloatDatePicker` | Wraps `DatePicker` |
129
+ | `FloatRangePicker` | Wraps `DatePicker.RangePicker` |
130
+ | `FloatTimePicker` | Wraps `TimePicker` |
131
+ | `FloatCascader` | Wraps `Cascader` |
132
+ | `FloatTreeSelect` | Wraps `TreeSelect` |
133
+ | `FloatAutoComplete` | Wraps `AutoComplete` |
134
+ | `FloatFormItem` | Specialized `Form.Item` for automatic label handling |
135
+
136
+ ## Props
137
+
138
+ ### Common Props
139
+ Most components accept all standard Ant Design props for their respective base component (e.g., `FloatInput` accepts all `InputProps`).
140
+
141
+ ### Specific Props
142
+
143
+ - **label** (string | ReactNode): When used with `FloatFormItem`, the `label` prop of the FormItem is automatically used as the floating label.
144
+ - **placeholder** (string): When used standalone, the `placeholder` acts as the floating label text.
145
+ - **labelBoxProps** (object): Props passed to the internal wrapper for advanced styling (e.g. `style`, `className` for the box container).
146
+
147
+ ## Customization
148
+
149
+ You can customize the appearance by overriding CSS variables or providing `labelBoxProps`. The library follows Ant Design's design token system, so changing your global theme config will automatically update these components.
150
+
151
+ ```tsx
152
+ <FloatInput
153
+ placeholder="Custom Style"
154
+ labelBoxProps={{
155
+ style: { borderColor: 'red' }
156
+ }}
157
+ />
158
+ ```
159
+
160
+ ## License
161
+
162
+ MIT © [razr001](https://github.com/razr001)
package/dist/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Tim Ou
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Tim Ou
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.