@fluentui/react-input 9.72.9-experimental.component-base-hooks.20260122-49fc330360.0 → 9.74.3-experimental.esm.20260709-49ee7a20cf.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/CHANGELOG.md +107 -10
- package/dist/index.d.cts +140 -0
- package/dist/index.d.ts +22 -2
- package/lib/Input.js +1 -1
- package/lib/Input.js.map +1 -1
- package/lib/components/Input/Input.js +5 -5
- package/lib/components/Input/Input.js.map +1 -1
- package/lib/components/Input/Input.types.js +3 -1
- package/lib/components/Input/Input.types.js.map +1 -1
- package/lib/components/Input/index.js +4 -4
- package/lib/components/Input/index.js.map +1 -1
- package/lib/components/Input/renderInput.js +1 -1
- package/lib/components/Input/renderInput.js.map +1 -1
- package/lib/components/Input/useInput.js +32 -21
- package/lib/components/Input/useInput.js.map +1 -1
- package/lib/components/Input/useInputStyles.styles.js +6 -4
- package/lib/components/Input/useInputStyles.styles.js.map +1 -1
- package/lib/components/Input/useInputStyles.styles.raw.js +6 -3
- package/lib/components/Input/useInputStyles.styles.raw.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib-commonjs/{Input.js → Input.cjs} +4 -1
- package/lib-commonjs/Input.cjs.map +1 -0
- package/lib-commonjs/components/Input/{Input.js → Input.cjs} +3 -3
- package/lib-commonjs/components/Input/{Input.js.map → Input.cjs.map} +1 -1
- package/lib-commonjs/components/Input/Input.types.cjs +6 -0
- package/lib-commonjs/components/Input/Input.types.cjs.map +1 -0
- package/lib-commonjs/components/Input/{index.js → index.cjs} +7 -4
- package/lib-commonjs/components/Input/index.cjs.map +1 -0
- package/lib-commonjs/components/Input/renderInput.cjs.map +1 -0
- package/lib-commonjs/components/Input/{useInput.js → useInput.cjs} +34 -22
- package/lib-commonjs/components/Input/useInput.cjs.map +1 -0
- package/lib-commonjs/components/Input/{useInputStyles.styles.js → useInputStyles.styles.cjs} +4 -1
- package/lib-commonjs/components/Input/useInputStyles.styles.cjs.map +1 -0
- package/lib-commonjs/components/Input/{useInputStyles.styles.raw.js → useInputStyles.styles.raw.cjs} +4 -1
- package/lib-commonjs/components/Input/useInputStyles.styles.raw.cjs.map +1 -0
- package/lib-commonjs/{index.js → index.cjs} +4 -1
- package/lib-commonjs/index.cjs.map +1 -0
- package/package.json +18 -12
- package/lib-commonjs/Input.js.map +0 -1
- package/lib-commonjs/components/Input/Input.types.js +0 -6
- package/lib-commonjs/components/Input/Input.types.js.map +0 -1
- package/lib-commonjs/components/Input/index.js.map +0 -1
- package/lib-commonjs/components/Input/renderInput.js.map +0 -1
- package/lib-commonjs/components/Input/useInput.js.map +0 -1
- package/lib-commonjs/components/Input/useInputStyles.styles.js.map +0 -1
- package/lib-commonjs/components/Input/useInputStyles.styles.raw.js.map +0 -1
- package/lib-commonjs/index.js.map +0 -1
- /package/lib-commonjs/components/Input/{renderInput.js → renderInput.cjs} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,22 +1,119 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-input
|
|
2
2
|
|
|
3
|
-
This log was last generated on Thu,
|
|
3
|
+
This log was last generated on Thu, 09 Jul 2026 17:34:07 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
-
## [9.
|
|
7
|
+
## [9.74.3-experimental.esm.20260709-49ee7a20cf.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-input_v9.74.3-experimental.esm.20260709-49ee7a20cf.0)
|
|
8
8
|
|
|
9
|
-
Thu,
|
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-input_v9.
|
|
9
|
+
Thu, 09 Jul 2026 17:34:07 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-input_v9.8.4..@fluentui/react-input_v9.74.3-experimental.esm.20260709-49ee7a20cf.0)
|
|
11
11
|
|
|
12
12
|
### Changes
|
|
13
13
|
|
|
14
|
-
- Release 9.
|
|
15
|
-
- Bump @fluentui/react-field to v9.
|
|
16
|
-
- Bump @fluentui/react-jsx-runtime to v9.
|
|
17
|
-
- Bump @fluentui/react-shared-contexts to v9.
|
|
18
|
-
- Bump @fluentui/react-theme to v9.
|
|
19
|
-
- Bump @fluentui/react-utilities to v9.
|
|
14
|
+
- Release 9.74.3-experimental.esm.20260709-49ee7a20cf ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
|
|
15
|
+
- Bump @fluentui/react-field to v9.74.3-experimental.esm.20260709-49ee7a20cf.0 ([commit](https://github.com/microsoft/fluentui/commit/175a26e0c520dd90a54578d1185a3b0b6c446e15) by beachball)
|
|
16
|
+
- Bump @fluentui/react-jsx-runtime to v9.74.3-experimental.esm.20260709-49ee7a20cf.0 ([commit](https://github.com/microsoft/fluentui/commit/175a26e0c520dd90a54578d1185a3b0b6c446e15) by beachball)
|
|
17
|
+
- Bump @fluentui/react-shared-contexts to v9.74.3-experimental.esm.20260709-49ee7a20cf.0 ([commit](https://github.com/microsoft/fluentui/commit/175a26e0c520dd90a54578d1185a3b0b6c446e15) by beachball)
|
|
18
|
+
- Bump @fluentui/react-theme to v9.74.3-experimental.esm.20260709-49ee7a20cf.0 ([commit](https://github.com/microsoft/fluentui/commit/175a26e0c520dd90a54578d1185a3b0b6c446e15) by beachball)
|
|
19
|
+
- Bump @fluentui/react-utilities to v9.74.3-experimental.esm.20260709-49ee7a20cf.0 ([commit](https://github.com/microsoft/fluentui/commit/175a26e0c520dd90a54578d1185a3b0b6c446e15) by beachball)
|
|
20
|
+
|
|
21
|
+
## [9.8.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-input_v9.8.4)
|
|
22
|
+
|
|
23
|
+
Wed, 24 Jun 2026 11:09:45 GMT
|
|
24
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-input_v9.8.3..@fluentui/react-input_v9.8.4)
|
|
25
|
+
|
|
26
|
+
### Patches
|
|
27
|
+
|
|
28
|
+
- fix: move Field control props to base hooks ([PR #36312](https://github.com/microsoft/fluentui/pull/36312) by dmytrokirpa@microsoft.com)
|
|
29
|
+
- fix: remove redundant use no memo directives, and add justification to valid ones ([PR #36224](https://github.com/microsoft/fluentui/pull/36224) by martinhochel@microsoft.com)
|
|
30
|
+
- Bump @fluentui/react-field to v9.5.3 ([commit](https://github.com/microsoft/fluentui/commit/a4b871ca80c1f16f35ab4229def4fe02be7f30ea) by beachball)
|
|
31
|
+
- Bump @fluentui/react-jsx-runtime to v9.4.4 ([commit](https://github.com/microsoft/fluentui/commit/a4b871ca80c1f16f35ab4229def4fe02be7f30ea) by beachball)
|
|
32
|
+
- Bump @fluentui/react-utilities to v9.26.5 ([commit](https://github.com/microsoft/fluentui/commit/a4b871ca80c1f16f35ab4229def4fe02be7f30ea) by beachball)
|
|
33
|
+
|
|
34
|
+
## [9.8.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-input_v9.8.3)
|
|
35
|
+
|
|
36
|
+
Tue, 26 May 2026 09:40:01 GMT
|
|
37
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-input_v9.8.2..@fluentui/react-input_v9.8.3)
|
|
38
|
+
|
|
39
|
+
### Patches
|
|
40
|
+
|
|
41
|
+
- Bump @fluentui/react-field to v9.5.2 ([PR #36246](https://github.com/microsoft/fluentui/pull/36246) by beachball)
|
|
42
|
+
- Bump @fluentui/react-jsx-runtime to v9.4.3 ([PR #36246](https://github.com/microsoft/fluentui/pull/36246) by beachball)
|
|
43
|
+
- Bump @fluentui/react-utilities to v9.26.4 ([PR #36246](https://github.com/microsoft/fluentui/pull/36246) by beachball)
|
|
44
|
+
|
|
45
|
+
## [9.8.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-input_v9.8.2)
|
|
46
|
+
|
|
47
|
+
Thu, 23 Apr 2026 14:21:17 GMT
|
|
48
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-input_v9.8.1..@fluentui/react-input_v9.8.2)
|
|
49
|
+
|
|
50
|
+
### Patches
|
|
51
|
+
|
|
52
|
+
- Bump @fluentui/react-field to v9.5.1 ([PR #36035](https://github.com/microsoft/fluentui/pull/36035) by beachball)
|
|
53
|
+
- Bump @fluentui/react-jsx-runtime to v9.4.2 ([PR #36035](https://github.com/microsoft/fluentui/pull/36035) by beachball)
|
|
54
|
+
- Bump @fluentui/react-utilities to v9.26.3 ([PR #36035](https://github.com/microsoft/fluentui/pull/36035) by beachball)
|
|
55
|
+
|
|
56
|
+
## [9.8.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-input_v9.8.1)
|
|
57
|
+
|
|
58
|
+
Wed, 01 Apr 2026 15:52:43 GMT
|
|
59
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-input_v9.8.0..@fluentui/react-input_v9.8.1)
|
|
60
|
+
|
|
61
|
+
### Patches
|
|
62
|
+
|
|
63
|
+
- Bump @fluentui/react-field to v9.5.0 ([PR #35912](https://github.com/microsoft/fluentui/pull/35912) by beachball)
|
|
64
|
+
|
|
65
|
+
## [9.8.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-input_v9.8.0)
|
|
66
|
+
|
|
67
|
+
Thu, 26 Mar 2026 08:12:50 GMT
|
|
68
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-input_v9.7.16..@fluentui/react-input_v9.8.0)
|
|
69
|
+
|
|
70
|
+
### Minor changes
|
|
71
|
+
|
|
72
|
+
- feat: add base hooks for Input ([PR #35813](https://github.com/microsoft/fluentui/pull/35813) by dmytrokirpa@microsoft.com)
|
|
73
|
+
|
|
74
|
+
## [9.7.16](https://github.com/microsoft/fluentui/tree/@fluentui/react-input_v9.7.16)
|
|
75
|
+
|
|
76
|
+
Wed, 11 Mar 2026 09:22:22 GMT
|
|
77
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-input_v9.7.15..@fluentui/react-input_v9.7.16)
|
|
78
|
+
|
|
79
|
+
### Patches
|
|
80
|
+
|
|
81
|
+
- Bump @fluentui/react-field to v9.4.16 ([PR #35859](https://github.com/microsoft/fluentui/pull/35859) by beachball)
|
|
82
|
+
|
|
83
|
+
## [9.7.15](https://github.com/microsoft/fluentui/tree/@fluentui/react-input_v9.7.15)
|
|
84
|
+
|
|
85
|
+
Wed, 25 Feb 2026 13:32:28 GMT
|
|
86
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-input_v9.7.14..@fluentui/react-input_v9.7.15)
|
|
87
|
+
|
|
88
|
+
### Patches
|
|
89
|
+
|
|
90
|
+
- Bump @fluentui/react-field to v9.4.15 ([PR #35782](https://github.com/microsoft/fluentui/pull/35782) by beachball)
|
|
91
|
+
- Bump @fluentui/react-jsx-runtime to v9.4.1 ([PR #35782](https://github.com/microsoft/fluentui/pull/35782) by beachball)
|
|
92
|
+
- Bump @fluentui/react-shared-contexts to v9.26.2 ([PR #35782](https://github.com/microsoft/fluentui/pull/35782) by beachball)
|
|
93
|
+
- Bump @fluentui/react-utilities to v9.26.2 ([PR #35782](https://github.com/microsoft/fluentui/pull/35782) by beachball)
|
|
94
|
+
|
|
95
|
+
## [9.7.14](https://github.com/microsoft/fluentui/tree/@fluentui/react-input_v9.7.14)
|
|
96
|
+
|
|
97
|
+
Thu, 12 Feb 2026 10:46:15 GMT
|
|
98
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-input_v9.7.13..@fluentui/react-input_v9.7.14)
|
|
99
|
+
|
|
100
|
+
### Patches
|
|
101
|
+
|
|
102
|
+
- Bump @fluentui/react-field to v9.4.14 ([PR #35743](https://github.com/microsoft/fluentui/pull/35743) by beachball)
|
|
103
|
+
- Bump @fluentui/react-jsx-runtime to v9.4.0 ([PR #35743](https://github.com/microsoft/fluentui/pull/35743) by beachball)
|
|
104
|
+
|
|
105
|
+
## [9.7.13](https://github.com/microsoft/fluentui/tree/@fluentui/react-input_v9.7.13)
|
|
106
|
+
|
|
107
|
+
Thu, 22 Jan 2026 17:06:56 GMT
|
|
108
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-input_v9.7.12..@fluentui/react-input_v9.7.13)
|
|
109
|
+
|
|
110
|
+
### Patches
|
|
111
|
+
|
|
112
|
+
- Bump @fluentui/react-field to v9.4.13 ([PR #35574](https://github.com/microsoft/fluentui/pull/35574) by beachball)
|
|
113
|
+
- Bump @fluentui/react-jsx-runtime to v9.3.5 ([PR #35574](https://github.com/microsoft/fluentui/pull/35574) by beachball)
|
|
114
|
+
- Bump @fluentui/react-shared-contexts to v9.26.1 ([PR #35574](https://github.com/microsoft/fluentui/pull/35574) by beachball)
|
|
115
|
+
- Bump @fluentui/react-theme to v9.2.1 ([PR #35574](https://github.com/microsoft/fluentui/pull/35574) by beachball)
|
|
116
|
+
- Bump @fluentui/react-utilities to v9.26.1 ([PR #35574](https://github.com/microsoft/fluentui/pull/35574) by beachball)
|
|
20
117
|
|
|
21
118
|
## [9.7.12](https://github.com/microsoft/fluentui/tree/@fluentui/react-input_v9.7.12)
|
|
22
119
|
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { ComponentProps } from '@fluentui/react-utilities';
|
|
2
|
+
import type { ComponentState } from '@fluentui/react-utilities';
|
|
3
|
+
import type { ForwardRefComponent } from '@fluentui/react-utilities';
|
|
4
|
+
import type { JSXElement } from '@fluentui/react-utilities';
|
|
5
|
+
import type * as React_2 from 'react';
|
|
6
|
+
import type { Slot } from '@fluentui/react-utilities';
|
|
7
|
+
import type { SlotClassNames } from '@fluentui/react-utilities';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The Input component allows people to enter and edit text.
|
|
11
|
+
*/
|
|
12
|
+
export declare const Input: ForwardRefComponent<InputProps>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Input props without design-specific props (appearance, size).
|
|
16
|
+
* Use this when building a base input that is unstyled or uses a custom design system.
|
|
17
|
+
*/
|
|
18
|
+
export declare type InputBaseProps = Omit<InputProps, 'appearance' | 'size'>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Input state without design-specific state (appearance, size).
|
|
22
|
+
*/
|
|
23
|
+
export declare type InputBaseState = Omit<InputState, 'appearance' | 'size'>;
|
|
24
|
+
|
|
25
|
+
export declare const inputClassNames: SlotClassNames<InputSlots>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Data passed to the `onChange` callback when a user changes the input's value.
|
|
29
|
+
*/
|
|
30
|
+
export declare type InputOnChangeData = {
|
|
31
|
+
/** Updated input value from the user */
|
|
32
|
+
value: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export declare type InputProps = Omit<ComponentProps<Partial<InputSlots>, 'input'>, 'children' | 'defaultValue' | 'onChange' | 'size' | 'type' | 'value'> & {
|
|
36
|
+
/** Input can't have children. */
|
|
37
|
+
children?: never;
|
|
38
|
+
/**
|
|
39
|
+
* Size of the input (changes the font size and spacing).
|
|
40
|
+
* @default 'medium'
|
|
41
|
+
*/
|
|
42
|
+
size?: 'small' | 'medium' | 'large';
|
|
43
|
+
/**
|
|
44
|
+
* Controls the colors and borders of the input.
|
|
45
|
+
* @default 'outline'
|
|
46
|
+
*
|
|
47
|
+
* Note: 'filled-darker-shadow' and 'filled-lighter-shadow' are deprecated and will be removed in the future.
|
|
48
|
+
*/
|
|
49
|
+
appearance?: 'outline' | 'underline' | 'filled-darker' | 'filled-lighter' | 'filled-darker-shadow' | 'filled-lighter-shadow';
|
|
50
|
+
/**
|
|
51
|
+
* Default value of the input. Provide this if the input should be an uncontrolled component
|
|
52
|
+
* which tracks its current state internally; otherwise, use `value`.
|
|
53
|
+
*
|
|
54
|
+
* (This prop is mutually exclusive with `value`.)
|
|
55
|
+
*/
|
|
56
|
+
defaultValue?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Current value of the input. Provide this if the input is a controlled component where you
|
|
59
|
+
* are maintaining its current state; otherwise, use `defaultValue`.
|
|
60
|
+
*
|
|
61
|
+
* (This prop is mutually exclusive with `defaultValue`.)
|
|
62
|
+
*/
|
|
63
|
+
value?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Called when the user changes the input's value.
|
|
66
|
+
*/
|
|
67
|
+
onChange?: (ev: React_2.ChangeEvent<HTMLInputElement>, data: InputOnChangeData) => void;
|
|
68
|
+
/**
|
|
69
|
+
* An input can have different text-based [types](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input#input_types)
|
|
70
|
+
* based on the type of value the user will enter.
|
|
71
|
+
*
|
|
72
|
+
* Note that no custom styling is currently applied for alternative types, and some types may
|
|
73
|
+
* activate browser-default styling which does not match the Fluent design language.
|
|
74
|
+
*
|
|
75
|
+
* (For non-text-based types such as `button` or `checkbox`, use the appropriate component or an
|
|
76
|
+
* `<input>` element instead.)
|
|
77
|
+
* @default 'text'
|
|
78
|
+
*/
|
|
79
|
+
type?: 'text' | 'email' | 'password' | 'search' | 'tel' | 'url' | 'date' | 'datetime-local' | 'month' | 'number' | 'time' | 'week';
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export declare type InputSlots = {
|
|
83
|
+
/**
|
|
84
|
+
* Wrapper element which visually appears to be the input and is used for borders, focus styling, etc.
|
|
85
|
+
* (A wrapper is needed to properly position `contentBefore` and `contentAfter` relative to `input`.)
|
|
86
|
+
*
|
|
87
|
+
* The root slot receives the `className` and `style` specified directly on the `<Input>`.
|
|
88
|
+
* All other top-level native props will be applied to the primary slot, `input`.
|
|
89
|
+
*/
|
|
90
|
+
root: NonNullable<Slot<'span'>>;
|
|
91
|
+
/**
|
|
92
|
+
* The actual `<input>` element. `type="text"` will be automatically applied unless overridden.
|
|
93
|
+
*
|
|
94
|
+
* This is the "primary" slot, so native props specified directly on the `<Input>` will go here
|
|
95
|
+
* (except `className` and `style`, which go to the `root` slot). The top-level `ref` will
|
|
96
|
+
* also go here.
|
|
97
|
+
*/
|
|
98
|
+
input: NonNullable<Slot<'input'>>;
|
|
99
|
+
/** Element before the input text, within the input border */
|
|
100
|
+
contentBefore?: Slot<'span'>;
|
|
101
|
+
/** Element after the input text, within the input border */
|
|
102
|
+
contentAfter?: Slot<'span'>;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* State used in rendering Input.
|
|
107
|
+
*/
|
|
108
|
+
export declare type InputState = Required<Pick<InputProps, 'appearance' | 'size'>> & ComponentState<InputSlots>;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Render the final JSX of Input
|
|
112
|
+
*/
|
|
113
|
+
export declare const renderInput_unstable: (state: InputBaseState) => JSXElement;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Create the state required to render Input.
|
|
117
|
+
*
|
|
118
|
+
* The returned state can be modified with hooks such as useInputStyles_unstable,
|
|
119
|
+
* before being passed to renderInput_unstable.
|
|
120
|
+
*
|
|
121
|
+
* @param props - props from this instance of Input
|
|
122
|
+
* @param ref - reference to `<input>` element of Input
|
|
123
|
+
*/
|
|
124
|
+
export declare const useInput_unstable: (props: InputProps, ref: React_2.Ref<HTMLInputElement>) => InputState;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Base hook for Input component, which manages state related to controlled/uncontrolled value,
|
|
128
|
+
* slot structure, and onChange handling. This hook excludes design-specific props (appearance, size).
|
|
129
|
+
*
|
|
130
|
+
* @param props - User provided props to the Input component.
|
|
131
|
+
* @param ref - User provided ref to be passed to the Input component.
|
|
132
|
+
*/
|
|
133
|
+
export declare const useInputBase_unstable: (props: InputBaseProps, ref: React_2.Ref<HTMLInputElement>) => InputBaseState;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Apply styling to the Input slots based on the state
|
|
137
|
+
*/
|
|
138
|
+
export declare const useInputStyles_unstable: (state: InputState) => InputState;
|
|
139
|
+
|
|
140
|
+
export { }
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ComponentProps } from '@fluentui/react-utilities';
|
|
|
2
2
|
import type { ComponentState } from '@fluentui/react-utilities';
|
|
3
3
|
import type { ForwardRefComponent } from '@fluentui/react-utilities';
|
|
4
4
|
import type { JSXElement } from '@fluentui/react-utilities';
|
|
5
|
-
import * as React_2 from 'react';
|
|
5
|
+
import type * as React_2 from 'react';
|
|
6
6
|
import type { Slot } from '@fluentui/react-utilities';
|
|
7
7
|
import type { SlotClassNames } from '@fluentui/react-utilities';
|
|
8
8
|
|
|
@@ -11,6 +11,17 @@ import type { SlotClassNames } from '@fluentui/react-utilities';
|
|
|
11
11
|
*/
|
|
12
12
|
export declare const Input: ForwardRefComponent<InputProps>;
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Input props without design-specific props (appearance, size).
|
|
16
|
+
* Use this when building a base input that is unstyled or uses a custom design system.
|
|
17
|
+
*/
|
|
18
|
+
export declare type InputBaseProps = Omit<InputProps, 'appearance' | 'size'>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Input state without design-specific state (appearance, size).
|
|
22
|
+
*/
|
|
23
|
+
export declare type InputBaseState = Omit<InputState, 'appearance' | 'size'>;
|
|
24
|
+
|
|
14
25
|
export declare const inputClassNames: SlotClassNames<InputSlots>;
|
|
15
26
|
|
|
16
27
|
/**
|
|
@@ -99,7 +110,7 @@ export declare type InputState = Required<Pick<InputProps, 'appearance' | 'size'
|
|
|
99
110
|
/**
|
|
100
111
|
* Render the final JSX of Input
|
|
101
112
|
*/
|
|
102
|
-
export declare const renderInput_unstable: (state:
|
|
113
|
+
export declare const renderInput_unstable: (state: InputBaseState) => JSXElement;
|
|
103
114
|
|
|
104
115
|
/**
|
|
105
116
|
* Create the state required to render Input.
|
|
@@ -112,6 +123,15 @@ export declare const renderInput_unstable: (state: InputState) => JSXElement;
|
|
|
112
123
|
*/
|
|
113
124
|
export declare const useInput_unstable: (props: InputProps, ref: React_2.Ref<HTMLInputElement>) => InputState;
|
|
114
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Base hook for Input component, which manages state related to controlled/uncontrolled value,
|
|
128
|
+
* slot structure, and onChange handling. This hook excludes design-specific props (appearance, size).
|
|
129
|
+
*
|
|
130
|
+
* @param props - User provided props to the Input component.
|
|
131
|
+
* @param ref - User provided ref to be passed to the Input component.
|
|
132
|
+
*/
|
|
133
|
+
export declare const useInputBase_unstable: (props: InputBaseProps, ref: React_2.Ref<HTMLInputElement>) => InputBaseState;
|
|
134
|
+
|
|
115
135
|
/**
|
|
116
136
|
* Apply styling to the Input slots based on the state
|
|
117
137
|
*/
|
package/lib/Input.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Input, inputClassNames, renderInput_unstable, useInputStyles_unstable, useInput_unstable } from
|
|
1
|
+
export { Input, inputClassNames, renderInput_unstable, useInputStyles_unstable, useInput_unstable, useInputBase_unstable } from "./components/Input/index.js";
|
package/lib/Input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Input.ts"],"sourcesContent":["export type {
|
|
1
|
+
{"version":3,"sources":["../src/Input.ts"],"sourcesContent":["export type {\n InputOnChangeData,\n InputProps,\n InputSlots,\n InputState,\n InputBaseProps,\n InputBaseState,\n} from './components/Input/index';\nexport {\n Input,\n inputClassNames,\n renderInput_unstable,\n useInputStyles_unstable,\n useInput_unstable,\n useInputBase_unstable,\n} from './components/Input/index';\n"],"names":["Input","inputClassNames","renderInput_unstable","useInputStyles_unstable","useInput_unstable","useInputBase_unstable"],"mappings":"AAQA,SACEA,KAAK,EACLC,eAAe,EACfC,oBAAoB,EACpBC,uBAAuB,EACvBC,iBAAiB,EACjBC,qBAAqB,QAChB,8BAA2B"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import * as React from
|
|
3
|
-
import { useInput_unstable } from
|
|
4
|
-
import { renderInput_unstable } from
|
|
5
|
-
import { useInputStyles_unstable } from
|
|
6
|
-
import { useCustomStyleHook_unstable } from
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { useInput_unstable } from "./useInput.js";
|
|
4
|
+
import { renderInput_unstable } from "./renderInput.js";
|
|
5
|
+
import { useInputStyles_unstable } from "./useInputStyles.styles.js";
|
|
6
|
+
import { useCustomStyleHook_unstable } from "@fluentui/react-shared-contexts";
|
|
7
7
|
/**
|
|
8
8
|
* The Input component allows people to enter and edit text.
|
|
9
9
|
*/ export const Input = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Input/Input.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useInput_unstable } from './useInput';\nimport { renderInput_unstable } from './renderInput';\nimport { useInputStyles_unstable } from './useInputStyles.styles';\nimport type { InputProps } from './Input.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\n\n/**\n * The Input component allows people to enter and edit text.\n */\nexport const Input: ForwardRefComponent<InputProps> = React.forwardRef((props, ref) => {\n const state = useInput_unstable(props, ref);\n\n useInputStyles_unstable(state);\n\n useCustomStyleHook_unstable('useInputStyles_unstable')(state);\n\n return renderInput_unstable(state);\n});\n\nInput.displayName = 'Input';\n"],"names":["React","useInput_unstable","renderInput_unstable","useInputStyles_unstable","useCustomStyleHook_unstable","Input","forwardRef","props","ref","state","displayName"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,iBAAiB,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../src/components/Input/Input.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useInput_unstable } from './useInput';\nimport { renderInput_unstable } from './renderInput';\nimport { useInputStyles_unstable } from './useInputStyles.styles';\nimport type { InputProps } from './Input.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\n\n/**\n * The Input component allows people to enter and edit text.\n */\nexport const Input: ForwardRefComponent<InputProps> = React.forwardRef((props, ref) => {\n const state = useInput_unstable(props, ref);\n\n useInputStyles_unstable(state);\n\n useCustomStyleHook_unstable('useInputStyles_unstable')(state);\n\n return renderInput_unstable(state);\n});\n\nInput.displayName = 'Input';\n"],"names":["React","useInput_unstable","renderInput_unstable","useInputStyles_unstable","useCustomStyleHook_unstable","Input","forwardRef","props","ref","state","displayName"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,iBAAiB,QAAQ,gBAAa;AAC/C,SAASC,oBAAoB,QAAQ,mBAAgB;AACrD,SAASC,uBAAuB,QAAQ,6BAA0B;AAGlE,SAASC,2BAA2B,QAAQ,kCAAkC;AAE9E;;CAEC,GACD,OAAO,MAAMC,sBAAyCL,MAAMM,UAAU,CAAC,CAACC,OAAOC;IAC7E,MAAMC,QAAQR,kBAAkBM,OAAOC;IAEvCL,wBAAwBM;IAExBL,4BAA4B,2BAA2BK;IAEvD,OAAOP,qBAAqBO;AAC9B,GAAG;AAEHJ,MAAMK,WAAW,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Input/Input.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type InputSlots = {\n /**\n * Wrapper element which visually appears to be the input and is used for borders, focus styling, etc.\n * (A wrapper is needed to properly position `contentBefore` and `contentAfter` relative to `input`.)\n *\n * The root slot receives the `className` and `style` specified directly on the `<Input>`.\n * All other top-level native props will be applied to the primary slot, `input`.\n */\n root: NonNullable<Slot<'span'>>;\n\n /**\n * The actual `<input>` element. `type=\"text\"` will be automatically applied unless overridden.\n *\n * This is the \"primary\" slot, so native props specified directly on the `<Input>` will go here\n * (except `className` and `style`, which go to the `root` slot). The top-level `ref` will\n * also go here.\n */\n input: NonNullable<Slot<'input'>>;\n\n /** Element before the input text, within the input border */\n contentBefore?: Slot<'span'>;\n\n /** Element after the input text, within the input border */\n contentAfter?: Slot<'span'>;\n};\n\nexport type InputProps = Omit<\n ComponentProps<Partial<InputSlots>, 'input'>,\n // `children` is unsupported. The rest of these native props have customized definitions.\n 'children' | 'defaultValue' | 'onChange' | 'size' | 'type' | 'value'\n> & {\n /** Input can't have children. */\n children?: never;\n\n /**\n * Size of the input (changes the font size and spacing).\n * @default 'medium'\n */\n // This name overlaps with the native `size` prop, but that prop isn't very useful in practice\n // (we could add `htmlSize` for the native functionality if someone needs it)\n // https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/size\n size?: 'small' | 'medium' | 'large';\n\n /**\n * Controls the colors and borders of the input.\n * @default 'outline'\n *\n * Note: 'filled-darker-shadow' and 'filled-lighter-shadow' are deprecated and will be removed in the future.\n */\n appearance?:\n | 'outline'\n | 'underline'\n | 'filled-darker'\n | 'filled-lighter'\n | 'filled-darker-shadow'\n | 'filled-lighter-shadow';\n\n /**\n * Default value of the input. Provide this if the input should be an uncontrolled component\n * which tracks its current state internally; otherwise, use `value`.\n *\n * (This prop is mutually exclusive with `value`.)\n */\n defaultValue?: string;\n\n /**\n * Current value of the input. Provide this if the input is a controlled component where you\n * are maintaining its current state; otherwise, use `defaultValue`.\n *\n * (This prop is mutually exclusive with `defaultValue`.)\n */\n value?: string;\n\n /**\n * Called when the user changes the input's value.\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\n onChange?: (ev: React.ChangeEvent<HTMLInputElement>, data: InputOnChangeData) => void;\n\n /**\n * An input can have different text-based [types](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input#input_types)\n * based on the type of value the user will enter.\n *\n * Note that no custom styling is currently applied for alternative types, and some types may\n * activate browser-default styling which does not match the Fluent design language.\n *\n * (For non-text-based types such as `button` or `checkbox`, use the appropriate component or an\n * `<input>` element instead.)\n * @default 'text'\n */\n type?:\n | 'text'\n | 'email'\n | 'password'\n | 'search'\n | 'tel'\n | 'url'\n | 'date'\n | 'datetime-local'\n | 'month'\n | 'number'\n | 'time'\n | 'week';\n};\n\n/**\n * State used in rendering Input.\n */\nexport type InputState = Required<Pick<InputProps, 'appearance' | 'size'>> & ComponentState<InputSlots>;\n\n/**\n * Data passed to the `onChange` callback when a user changes the input's value.\n */\nexport type InputOnChangeData = {\n /** Updated input value from the user */\n value: string;\n};\n"],"names":[
|
|
1
|
+
{"version":3,"sources":["../src/components/Input/Input.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type InputSlots = {\n /**\n * Wrapper element which visually appears to be the input and is used for borders, focus styling, etc.\n * (A wrapper is needed to properly position `contentBefore` and `contentAfter` relative to `input`.)\n *\n * The root slot receives the `className` and `style` specified directly on the `<Input>`.\n * All other top-level native props will be applied to the primary slot, `input`.\n */\n root: NonNullable<Slot<'span'>>;\n\n /**\n * The actual `<input>` element. `type=\"text\"` will be automatically applied unless overridden.\n *\n * This is the \"primary\" slot, so native props specified directly on the `<Input>` will go here\n * (except `className` and `style`, which go to the `root` slot). The top-level `ref` will\n * also go here.\n */\n input: NonNullable<Slot<'input'>>;\n\n /** Element before the input text, within the input border */\n contentBefore?: Slot<'span'>;\n\n /** Element after the input text, within the input border */\n contentAfter?: Slot<'span'>;\n};\n\nexport type InputProps = Omit<\n ComponentProps<Partial<InputSlots>, 'input'>,\n // `children` is unsupported. The rest of these native props have customized definitions.\n 'children' | 'defaultValue' | 'onChange' | 'size' | 'type' | 'value'\n> & {\n /** Input can't have children. */\n children?: never;\n\n /**\n * Size of the input (changes the font size and spacing).\n * @default 'medium'\n */\n // This name overlaps with the native `size` prop, but that prop isn't very useful in practice\n // (we could add `htmlSize` for the native functionality if someone needs it)\n // https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/size\n size?: 'small' | 'medium' | 'large';\n\n /**\n * Controls the colors and borders of the input.\n * @default 'outline'\n *\n * Note: 'filled-darker-shadow' and 'filled-lighter-shadow' are deprecated and will be removed in the future.\n */\n appearance?:\n | 'outline'\n | 'underline'\n | 'filled-darker'\n | 'filled-lighter'\n | 'filled-darker-shadow'\n | 'filled-lighter-shadow';\n\n /**\n * Default value of the input. Provide this if the input should be an uncontrolled component\n * which tracks its current state internally; otherwise, use `value`.\n *\n * (This prop is mutually exclusive with `value`.)\n */\n defaultValue?: string;\n\n /**\n * Current value of the input. Provide this if the input is a controlled component where you\n * are maintaining its current state; otherwise, use `defaultValue`.\n *\n * (This prop is mutually exclusive with `defaultValue`.)\n */\n value?: string;\n\n /**\n * Called when the user changes the input's value.\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\n onChange?: (ev: React.ChangeEvent<HTMLInputElement>, data: InputOnChangeData) => void;\n\n /**\n * An input can have different text-based [types](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input#input_types)\n * based on the type of value the user will enter.\n *\n * Note that no custom styling is currently applied for alternative types, and some types may\n * activate browser-default styling which does not match the Fluent design language.\n *\n * (For non-text-based types such as `button` or `checkbox`, use the appropriate component or an\n * `<input>` element instead.)\n * @default 'text'\n */\n type?:\n | 'text'\n | 'email'\n | 'password'\n | 'search'\n | 'tel'\n | 'url'\n | 'date'\n | 'datetime-local'\n | 'month'\n | 'number'\n | 'time'\n | 'week';\n};\n\n/**\n * Input props without design-specific props (appearance, size).\n * Use this when building a base input that is unstyled or uses a custom design system.\n */\nexport type InputBaseProps = Omit<InputProps, 'appearance' | 'size'>;\n\n/**\n * State used in rendering Input.\n */\nexport type InputState = Required<Pick<InputProps, 'appearance' | 'size'>> & ComponentState<InputSlots>;\n\n/**\n * Input state without design-specific state (appearance, size).\n */\nexport type InputBaseState = Omit<InputState, 'appearance' | 'size'>;\n\n/**\n * Data passed to the `onChange` callback when a user changes the input's value.\n */\nexport type InputOnChangeData = {\n /** Updated input value from the user */\n value: string;\n};\n"],"names":[],"mappings":"AA4HA;;CAEC,GACD,WAGE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Input } from
|
|
2
|
-
export { renderInput_unstable } from
|
|
3
|
-
export { useInput_unstable } from
|
|
4
|
-
export { inputClassNames, useInputStyles_unstable } from
|
|
1
|
+
export { Input } from "./Input.js";
|
|
2
|
+
export { renderInput_unstable } from "./renderInput.js";
|
|
3
|
+
export { useInput_unstable, useInputBase_unstable } from "./useInput.js";
|
|
4
|
+
export { inputClassNames, useInputStyles_unstable } from "./useInputStyles.styles.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Input/index.ts"],"sourcesContent":["export { Input } from './Input';\nexport type {
|
|
1
|
+
{"version":3,"sources":["../src/components/Input/index.ts"],"sourcesContent":["export { Input } from './Input';\nexport type {\n InputBaseProps,\n InputBaseState,\n InputOnChangeData,\n InputProps,\n InputSlots,\n InputState,\n} from './Input.types';\nexport { renderInput_unstable } from './renderInput';\nexport { useInput_unstable, useInputBase_unstable } from './useInput';\nexport { inputClassNames, useInputStyles_unstable } from './useInputStyles.styles';\n"],"names":["Input","renderInput_unstable","useInput_unstable","useInputBase_unstable","inputClassNames","useInputStyles_unstable"],"mappings":"AAAA,SAASA,KAAK,QAAQ,aAAU;AAShC,SAASC,oBAAoB,QAAQ,mBAAgB;AACrD,SAASC,iBAAiB,EAAEC,qBAAqB,QAAQ,gBAAa;AACtE,SAASC,eAAe,EAAEC,uBAAuB,QAAQ,6BAA0B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@fluentui/react-jsx-runtime/jsx-runtime";
|
|
2
|
-
import { assertSlots } from
|
|
2
|
+
import { assertSlots } from "@fluentui/react-utilities";
|
|
3
3
|
/**
|
|
4
4
|
* Render the final JSX of Input
|
|
5
5
|
*/ export const renderInput_unstable = (state)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Input/renderInput.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/components/Input/renderInput.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport type { InputBaseState, InputSlots } from './Input.types';\n\n/**\n * Render the final JSX of Input\n */\nexport const renderInput_unstable = (state: InputBaseState): JSXElement => {\n assertSlots<InputSlots>(state);\n return (\n <state.root>\n {state.contentBefore && <state.contentBefore />}\n <state.input />\n {state.contentAfter && <state.contentAfter />}\n </state.root>\n );\n};\n"],"names":["assertSlots","renderInput_unstable","state","root","contentBefore","input","contentAfter"],"mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,4BAA4B;AAIxD;;CAEC,GACD,OAAO,MAAMC,uBAAuB,CAACC;IACnCF,YAAwBE;IACxB,qBACE,MAACA,MAAMC,IAAI;;YACRD,MAAME,aAAa,kBAAI,KAACF,MAAME,aAAa;0BAC5C,KAACF,MAAMG,KAAK;YACXH,MAAMI,YAAY,kBAAI,KAACJ,MAAMI,YAAY;;;AAGhD,EAAE"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { useOverrides_unstable as useOverrides } from '@fluentui/react-shared-contexts';
|
|
2
|
+
import { useFieldControlProps_unstable } from "@fluentui/react-field";
|
|
3
|
+
import { getPartitionedNativeProps, useControllableState, useEventCallback, slot } from "@fluentui/react-utilities";
|
|
4
|
+
import { useOverrides_unstable as useOverrides } from "@fluentui/react-shared-contexts";
|
|
6
5
|
/**
|
|
7
6
|
* Create the state required to render Input.
|
|
8
7
|
*
|
|
@@ -12,43 +11,54 @@ import { useOverrides_unstable as useOverrides } from '@fluentui/react-shared-co
|
|
|
12
11
|
* @param props - props from this instance of Input
|
|
13
12
|
* @param ref - reference to `<input>` element of Input
|
|
14
13
|
*/ export const useInput_unstable = (props, ref)=>{
|
|
15
|
-
props = useFieldControlProps_unstable(props, {
|
|
16
|
-
supportsLabelFor: true,
|
|
17
|
-
supportsRequired: true,
|
|
18
|
-
supportsSize: true
|
|
19
|
-
});
|
|
20
14
|
const overrides = useOverrides();
|
|
21
15
|
var _overrides_inputDefaultAppearance;
|
|
22
|
-
const { size = 'medium', appearance = (_overrides_inputDefaultAppearance = overrides.inputDefaultAppearance) !== null && _overrides_inputDefaultAppearance !== void 0 ? _overrides_inputDefaultAppearance : 'outline',
|
|
16
|
+
const { size = 'medium', appearance = (_overrides_inputDefaultAppearance = overrides.inputDefaultAppearance) !== null && _overrides_inputDefaultAppearance !== void 0 ? _overrides_inputDefaultAppearance : 'outline', ...baseProps } = props;
|
|
23
17
|
if (process.env.NODE_ENV !== 'production' && (appearance === 'filled-darker-shadow' || appearance === 'filled-lighter-shadow')) {
|
|
24
18
|
// eslint-disable-next-line no-console
|
|
25
19
|
console.error("The 'filled-darker-shadow' and 'filled-lighter-shadow' appearances are deprecated and will be removed in the" + ' future.');
|
|
26
20
|
}
|
|
21
|
+
const state = useInputBase_unstable(baseProps, ref);
|
|
22
|
+
return {
|
|
23
|
+
size,
|
|
24
|
+
appearance,
|
|
25
|
+
...state
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Base hook for Input component, which manages state related to controlled/uncontrolled value,
|
|
30
|
+
* slot structure, and onChange handling. This hook excludes design-specific props (appearance, size).
|
|
31
|
+
*
|
|
32
|
+
* @param props - User provided props to the Input component.
|
|
33
|
+
* @param ref - User provided ref to be passed to the Input component.
|
|
34
|
+
*/ export const useInputBase_unstable = (props, ref)=>{
|
|
35
|
+
const fieldControlProps = useFieldControlProps_unstable(props, {
|
|
36
|
+
supportsLabelFor: true,
|
|
37
|
+
supportsRequired: true,
|
|
38
|
+
supportsSize: true
|
|
39
|
+
});
|
|
27
40
|
const [value, setValue] = useControllableState({
|
|
28
|
-
state:
|
|
29
|
-
defaultState:
|
|
41
|
+
state: fieldControlProps.value,
|
|
42
|
+
defaultState: fieldControlProps.defaultValue,
|
|
30
43
|
initialState: ''
|
|
31
44
|
});
|
|
32
45
|
const nativeProps = getPartitionedNativeProps({
|
|
33
|
-
props,
|
|
46
|
+
props: fieldControlProps,
|
|
34
47
|
primarySlotTagName: 'input',
|
|
35
48
|
excludedPropNames: [
|
|
36
|
-
'size',
|
|
37
49
|
'onChange',
|
|
38
50
|
'value',
|
|
39
51
|
'defaultValue'
|
|
40
52
|
]
|
|
41
53
|
});
|
|
42
54
|
const state = {
|
|
43
|
-
size,
|
|
44
|
-
appearance,
|
|
45
55
|
components: {
|
|
46
56
|
root: 'span',
|
|
47
57
|
input: 'input',
|
|
48
58
|
contentBefore: 'span',
|
|
49
59
|
contentAfter: 'span'
|
|
50
60
|
},
|
|
51
|
-
input: slot.always(
|
|
61
|
+
input: slot.always(fieldControlProps.input, {
|
|
52
62
|
defaultProps: {
|
|
53
63
|
type: 'text',
|
|
54
64
|
ref,
|
|
@@ -56,21 +66,22 @@ import { useOverrides_unstable as useOverrides } from '@fluentui/react-shared-co
|
|
|
56
66
|
},
|
|
57
67
|
elementType: 'input'
|
|
58
68
|
}),
|
|
59
|
-
contentAfter: slot.optional(
|
|
69
|
+
contentAfter: slot.optional(fieldControlProps.contentAfter, {
|
|
60
70
|
elementType: 'span'
|
|
61
71
|
}),
|
|
62
|
-
contentBefore: slot.optional(
|
|
72
|
+
contentBefore: slot.optional(fieldControlProps.contentBefore, {
|
|
63
73
|
elementType: 'span'
|
|
64
74
|
}),
|
|
65
|
-
root: slot.always(
|
|
75
|
+
root: slot.always(fieldControlProps.root, {
|
|
66
76
|
defaultProps: nativeProps.root,
|
|
67
77
|
elementType: 'span'
|
|
68
78
|
})
|
|
69
79
|
};
|
|
70
80
|
state.input.value = value;
|
|
71
81
|
state.input.onChange = useEventCallback((ev)=>{
|
|
82
|
+
var _fieldControlProps_onChange;
|
|
72
83
|
const newValue = ev.target.value;
|
|
73
|
-
onChange === null ||
|
|
84
|
+
(_fieldControlProps_onChange = fieldControlProps.onChange) === null || _fieldControlProps_onChange === void 0 ? void 0 : _fieldControlProps_onChange.call(fieldControlProps, ev, {
|
|
74
85
|
value: newValue
|
|
75
86
|
});
|
|
76
87
|
setValue(newValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Input/useInput.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { getPartitionedNativeProps, useControllableState, useEventCallback, slot } from '@fluentui/react-utilities';\nimport type { InputProps, InputState } from './Input.types';\nimport { useOverrides_unstable as useOverrides } from '@fluentui/react-shared-contexts';\n\n/**\n * Create the state required to render Input.\n *\n * The returned state can be modified with hooks such as useInputStyles_unstable,\n * before being passed to renderInput_unstable.\n *\n * @param props - props from this instance of Input\n * @param ref - reference to `<input>` element of Input\n */\nexport const useInput_unstable = (props: InputProps, ref: React.Ref<HTMLInputElement>): InputState => {\n
|
|
1
|
+
{"version":3,"sources":["../src/components/Input/useInput.ts"],"sourcesContent":["'use client';\n\nimport type * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { getPartitionedNativeProps, useControllableState, useEventCallback, slot } from '@fluentui/react-utilities';\nimport type { InputBaseProps, InputBaseState, InputProps, InputState } from './Input.types';\nimport { useOverrides_unstable as useOverrides } from '@fluentui/react-shared-contexts';\n\n/**\n * Create the state required to render Input.\n *\n * The returned state can be modified with hooks such as useInputStyles_unstable,\n * before being passed to renderInput_unstable.\n *\n * @param props - props from this instance of Input\n * @param ref - reference to `<input>` element of Input\n */\nexport const useInput_unstable = (props: InputProps, ref: React.Ref<HTMLInputElement>): InputState => {\n const overrides = useOverrides();\n\n const { size = 'medium', appearance = overrides.inputDefaultAppearance ?? 'outline', ...baseProps } = props;\n\n if (\n process.env.NODE_ENV !== 'production' &&\n (appearance === 'filled-darker-shadow' || appearance === 'filled-lighter-shadow')\n ) {\n // eslint-disable-next-line no-console\n console.error(\n \"The 'filled-darker-shadow' and 'filled-lighter-shadow' appearances are deprecated and will be removed in the\" +\n ' future.',\n );\n }\n\n const state = useInputBase_unstable(baseProps, ref);\n\n return {\n size,\n appearance,\n ...state,\n };\n};\n\n/**\n * Base hook for Input component, which manages state related to controlled/uncontrolled value,\n * slot structure, and onChange handling. This hook excludes design-specific props (appearance, size).\n *\n * @param props - User provided props to the Input component.\n * @param ref - User provided ref to be passed to the Input component.\n */\nexport const useInputBase_unstable = (props: InputBaseProps, ref: React.Ref<HTMLInputElement>): InputBaseState => {\n const fieldControlProps = useFieldControlProps_unstable(props, {\n supportsLabelFor: true,\n supportsRequired: true,\n supportsSize: true,\n });\n\n const [value, setValue] = useControllableState({\n state: fieldControlProps.value,\n defaultState: fieldControlProps.defaultValue,\n initialState: '',\n });\n\n const nativeProps = getPartitionedNativeProps({\n props: fieldControlProps,\n primarySlotTagName: 'input',\n excludedPropNames: ['onChange', 'value', 'defaultValue'],\n });\n\n const state: InputBaseState = {\n components: {\n root: 'span',\n input: 'input',\n contentBefore: 'span',\n contentAfter: 'span',\n },\n input: slot.always(fieldControlProps.input, {\n defaultProps: {\n type: 'text',\n ref,\n ...nativeProps.primary,\n },\n elementType: 'input',\n }),\n contentAfter: slot.optional(fieldControlProps.contentAfter, { elementType: 'span' }),\n contentBefore: slot.optional(fieldControlProps.contentBefore, { elementType: 'span' }),\n root: slot.always(fieldControlProps.root, {\n defaultProps: nativeProps.root,\n elementType: 'span',\n }),\n };\n\n state.input.value = value;\n state.input.onChange = useEventCallback(ev => {\n const newValue = ev.target.value;\n fieldControlProps.onChange?.(ev, { value: newValue });\n setValue(newValue);\n });\n\n return state;\n};\n"],"names":["useFieldControlProps_unstable","getPartitionedNativeProps","useControllableState","useEventCallback","slot","useOverrides_unstable","useOverrides","useInput_unstable","props","ref","overrides","size","appearance","inputDefaultAppearance","baseProps","process","env","NODE_ENV","console","error","state","useInputBase_unstable","fieldControlProps","supportsLabelFor","supportsRequired","supportsSize","value","setValue","defaultState","defaultValue","initialState","nativeProps","primarySlotTagName","excludedPropNames","components","root","input","contentBefore","contentAfter","always","defaultProps","type","primary","elementType","optional","onChange","ev","newValue","target"],"mappings":"AAAA;AAGA,SAASA,6BAA6B,QAAQ,wBAAwB;AACtE,SAASC,yBAAyB,EAAEC,oBAAoB,EAAEC,gBAAgB,EAAEC,IAAI,QAAQ,4BAA4B;AAEpH,SAASC,yBAAyBC,YAAY,QAAQ,kCAAkC;AAExF;;;;;;;;CAQC,GACD,OAAO,MAAMC,oBAAoB,CAACC,OAAmBC;IACnD,MAAMC,YAAYJ;QAEoBI;IAAtC,MAAM,EAAEC,OAAO,QAAQ,EAAEC,aAAaF,CAAAA,oCAAAA,UAAUG,sBAAsB,cAAhCH,+CAAAA,oCAAoC,SAAS,EAAE,GAAGI,WAAW,GAAGN;IAEtG,IACEO,QAAQC,GAAG,CAACC,QAAQ,KAAK,gBACxBL,CAAAA,eAAe,0BAA0BA,eAAe,uBAAsB,GAC/E;QACA,sCAAsC;QACtCM,QAAQC,KAAK,CACX,iHACE;IAEN;IAEA,MAAMC,QAAQC,sBAAsBP,WAAWL;IAE/C,OAAO;QACLE;QACAC;QACA,GAAGQ,KAAK;IACV;AACF,EAAE;AAEF;;;;;;CAMC,GACD,OAAO,MAAMC,wBAAwB,CAACb,OAAuBC;IAC3D,MAAMa,oBAAoBtB,8BAA8BQ,OAAO;QAC7De,kBAAkB;QAClBC,kBAAkB;QAClBC,cAAc;IAChB;IAEA,MAAM,CAACC,OAAOC,SAAS,GAAGzB,qBAAqB;QAC7CkB,OAAOE,kBAAkBI,KAAK;QAC9BE,cAAcN,kBAAkBO,YAAY;QAC5CC,cAAc;IAChB;IAEA,MAAMC,cAAc9B,0BAA0B;QAC5CO,OAAOc;QACPU,oBAAoB;QACpBC,mBAAmB;YAAC;YAAY;YAAS;SAAe;IAC1D;IAEA,MAAMb,QAAwB;QAC5Bc,YAAY;YACVC,MAAM;YACNC,OAAO;YACPC,eAAe;YACfC,cAAc;QAChB;QACAF,OAAOhC,KAAKmC,MAAM,CAACjB,kBAAkBc,KAAK,EAAE;YAC1CI,cAAc;gBACZC,MAAM;gBACNhC;gBACA,GAAGsB,YAAYW,OAAO;YACxB;YACAC,aAAa;QACf;QACAL,cAAclC,KAAKwC,QAAQ,CAACtB,kBAAkBgB,YAAY,EAAE;YAAEK,aAAa;QAAO;QAClFN,eAAejC,KAAKwC,QAAQ,CAACtB,kBAAkBe,aAAa,EAAE;YAAEM,aAAa;QAAO;QACpFR,MAAM/B,KAAKmC,MAAM,CAACjB,kBAAkBa,IAAI,EAAE;YACxCK,cAAcT,YAAYI,IAAI;YAC9BQ,aAAa;QACf;IACF;IAEAvB,MAAMgB,KAAK,CAACV,KAAK,GAAGA;IACpBN,MAAMgB,KAAK,CAACS,QAAQ,GAAG1C,iBAAiB2C,CAAAA;YAEtCxB;QADA,MAAMyB,WAAWD,GAAGE,MAAM,CAACtB,KAAK;SAChCJ,8BAAAA,kBAAkBuB,QAAQ,cAA1BvB,kDAAAA,iCAAAA,mBAA6BwB,IAAI;YAAEpB,OAAOqB;QAAS;QACnDpB,SAASoB;IACX;IAEA,OAAO3B;AACT,EAAE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { tokens, typographyStyles } from
|
|
4
|
-
import { __resetStyles, __styles, mergeClasses, shorthands } from
|
|
3
|
+
import { tokens, typographyStyles } from "@fluentui/react-theme";
|
|
4
|
+
import { __resetStyles, __styles, mergeClasses, shorthands } from "@griffel/react";
|
|
5
5
|
export const inputClassNames = {
|
|
6
6
|
root: 'fui-Input',
|
|
7
7
|
input: 'fui-Input__input',
|
|
@@ -229,8 +229,6 @@ const useContentStyles = /*#__PURE__*/__styles({
|
|
|
229
229
|
* Apply styling to the Input slots based on the state
|
|
230
230
|
*/
|
|
231
231
|
export const useInputStyles_unstable = state => {
|
|
232
|
-
'use no memo';
|
|
233
|
-
|
|
234
232
|
const {
|
|
235
233
|
size,
|
|
236
234
|
appearance
|
|
@@ -241,13 +239,17 @@ export const useInputStyles_unstable = state => {
|
|
|
241
239
|
const rootStyles = useRootStyles();
|
|
242
240
|
const inputStyles = useInputElementStyles();
|
|
243
241
|
const contentStyles = useContentStyles();
|
|
242
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
244
243
|
state.root.className = mergeClasses(inputClassNames.root, useRootClassName(), rootStyles[size], state.contentBefore && rootStyles[`${size}WithContentBefore`], state.contentAfter && rootStyles[`${size}WithContentAfter`], rootStyles[appearance], !disabled && appearance === 'outline' && rootStyles.outlineInteractive, !disabled && appearance === 'underline' && rootStyles.underlineInteractive, !disabled && filled && rootStyles.filledInteractive, filled && rootStyles.filled, !disabled && invalid && rootStyles.invalid, disabled && rootStyles.disabled, state.root.className);
|
|
244
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
245
245
|
state.input.className = mergeClasses(inputClassNames.input, useInputClassName(), inputStyles[size], state.contentBefore && inputStyles[`${size}WithContentBefore`], state.contentAfter && inputStyles[`${size}WithContentAfter`], disabled && inputStyles.disabled, state.input.className);
|
|
246
246
|
const contentClasses = [useContentClassName(), disabled && contentStyles.disabled, contentStyles[size]];
|
|
247
247
|
if (state.contentBefore) {
|
|
248
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
248
249
|
state.contentBefore.className = mergeClasses(inputClassNames.contentBefore, ...contentClasses, state.contentBefore.className);
|
|
249
250
|
}
|
|
250
251
|
if (state.contentAfter) {
|
|
252
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
251
253
|
state.contentAfter.className = mergeClasses(inputClassNames.contentAfter, ...contentClasses, state.contentAfter.className);
|
|
252
254
|
}
|
|
253
255
|
return state;
|