@fluentui/react-field 0.0.0-nightly-20230501-0418.1 → 0.0.0-nightly-20230503-0419.1
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.json +15 -15
- package/CHANGELOG.md +10 -10
- package/dist/index.d.ts +209 -0
- package/lib/Field.js +2 -0
- package/lib/Field.js.map +1 -0
- package/lib/components/Field/Field.js +13 -0
- package/lib/components/Field/Field.js.map +1 -0
- package/lib/components/Field/Field.types.js +2 -0
- package/lib/components/Field/Field.types.js.map +1 -0
- package/lib/components/Field/index.js +6 -0
- package/lib/components/Field/index.js.map +1 -0
- package/lib/components/Field/renderField.js +22 -0
- package/lib/components/Field/renderField.js.map +1 -0
- package/lib/components/Field/useField.js +81 -0
- package/lib/components/Field/useField.js.map +1 -0
- package/lib/components/Field/useFieldStyles.styles.js +106 -0
- package/lib/components/Field/useFieldStyles.styles.js.map +1 -0
- package/lib/contexts/FieldContext.js +5 -0
- package/lib/contexts/FieldContext.js.map +1 -0
- package/lib/contexts/index.js +4 -0
- package/lib/contexts/index.js.map +1 -0
- package/lib/contexts/useFieldContextValues.js +33 -0
- package/lib/contexts/useFieldContextValues.js.map +1 -0
- package/lib/contexts/useFieldControlProps.js +65 -0
- package/lib/contexts/useFieldControlProps.js.map +1 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -0
- package/package.json +7 -7
package/CHANGELOG.json
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
"name": "@fluentui/react-field",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
6
|
-
"tag": "@fluentui/react-field_v0.0.0-nightly-
|
7
|
-
"version": "0.0.0-nightly-
|
5
|
+
"date": "Wed, 03 May 2023 04:25:36 GMT",
|
6
|
+
"tag": "@fluentui/react-field_v0.0.0-nightly-20230503-0419.1",
|
7
|
+
"version": "0.0.0-nightly-20230503-0419.1",
|
8
8
|
"comments": {
|
9
9
|
"prerelease": [
|
10
10
|
{
|
@@ -16,38 +16,38 @@
|
|
16
16
|
{
|
17
17
|
"author": "beachball",
|
18
18
|
"package": "@fluentui/react-field",
|
19
|
-
"comment": "Bump @fluentui/react-context-selector to v0.0.0-nightly-
|
20
|
-
"commit": "
|
19
|
+
"comment": "Bump @fluentui/react-context-selector to v0.0.0-nightly-20230503-0419.1",
|
20
|
+
"commit": "a9a6cef152f4c3885a3697ddf9ded12bfce5a2be"
|
21
21
|
},
|
22
22
|
{
|
23
23
|
"author": "beachball",
|
24
24
|
"package": "@fluentui/react-field",
|
25
|
-
"comment": "Bump @fluentui/react-jsx-runtime to v0.0.0-nightly-
|
26
|
-
"commit": "
|
25
|
+
"comment": "Bump @fluentui/react-jsx-runtime to v0.0.0-nightly-20230503-0419.1",
|
26
|
+
"commit": "a9a6cef152f4c3885a3697ddf9ded12bfce5a2be"
|
27
27
|
},
|
28
28
|
{
|
29
29
|
"author": "beachball",
|
30
30
|
"package": "@fluentui/react-field",
|
31
|
-
"comment": "Bump @fluentui/react-label to v0.0.0-nightly-
|
32
|
-
"commit": "
|
31
|
+
"comment": "Bump @fluentui/react-label to v0.0.0-nightly-20230503-0419.1",
|
32
|
+
"commit": "a9a6cef152f4c3885a3697ddf9ded12bfce5a2be"
|
33
33
|
},
|
34
34
|
{
|
35
35
|
"author": "beachball",
|
36
36
|
"package": "@fluentui/react-field",
|
37
|
-
"comment": "Bump @fluentui/react-theme to v0.0.0-nightly-
|
38
|
-
"commit": "
|
37
|
+
"comment": "Bump @fluentui/react-theme to v0.0.0-nightly-20230503-0419.1",
|
38
|
+
"commit": "a9a6cef152f4c3885a3697ddf9ded12bfce5a2be"
|
39
39
|
},
|
40
40
|
{
|
41
41
|
"author": "beachball",
|
42
42
|
"package": "@fluentui/react-field",
|
43
|
-
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-
|
44
|
-
"commit": "
|
43
|
+
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-20230503-0419.1",
|
44
|
+
"commit": "a9a6cef152f4c3885a3697ddf9ded12bfce5a2be"
|
45
45
|
},
|
46
46
|
{
|
47
47
|
"author": "beachball",
|
48
48
|
"package": "@fluentui/react-field",
|
49
|
-
"comment": "Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-
|
50
|
-
"commit": "
|
49
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20230503-0419.1",
|
50
|
+
"commit": "a9a6cef152f4c3885a3697ddf9ded12bfce5a2be"
|
51
51
|
}
|
52
52
|
]
|
53
53
|
}
|
package/CHANGELOG.md
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
# Change Log - @fluentui/react-field
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Wed, 03 May 2023 04:25:36 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
-
## [0.0.0-nightly-
|
7
|
+
## [0.0.0-nightly-20230503-0419.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v0.0.0-nightly-20230503-0419.1)
|
8
8
|
|
9
|
-
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.1.1..@fluentui/react-field_v0.0.0-nightly-
|
9
|
+
Wed, 03 May 2023 04:25:36 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.1.1..@fluentui/react-field_v0.0.0-nightly-20230503-0419.1)
|
11
11
|
|
12
12
|
### Changes
|
13
13
|
|
14
14
|
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
|
15
|
-
- Bump @fluentui/react-context-selector to v0.0.0-nightly-
|
16
|
-
- Bump @fluentui/react-jsx-runtime to v0.0.0-nightly-
|
17
|
-
- Bump @fluentui/react-label to v0.0.0-nightly-
|
18
|
-
- Bump @fluentui/react-theme to v0.0.0-nightly-
|
19
|
-
- Bump @fluentui/react-utilities to v0.0.0-nightly-
|
20
|
-
- Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-
|
15
|
+
- Bump @fluentui/react-context-selector to v0.0.0-nightly-20230503-0419.1 ([commit](https://github.com/microsoft/fluentui/commit/a9a6cef152f4c3885a3697ddf9ded12bfce5a2be) by beachball)
|
16
|
+
- Bump @fluentui/react-jsx-runtime to v0.0.0-nightly-20230503-0419.1 ([commit](https://github.com/microsoft/fluentui/commit/a9a6cef152f4c3885a3697ddf9ded12bfce5a2be) by beachball)
|
17
|
+
- Bump @fluentui/react-label to v0.0.0-nightly-20230503-0419.1 ([commit](https://github.com/microsoft/fluentui/commit/a9a6cef152f4c3885a3697ddf9ded12bfce5a2be) by beachball)
|
18
|
+
- Bump @fluentui/react-theme to v0.0.0-nightly-20230503-0419.1 ([commit](https://github.com/microsoft/fluentui/commit/a9a6cef152f4c3885a3697ddf9ded12bfce5a2be) by beachball)
|
19
|
+
- Bump @fluentui/react-utilities to v0.0.0-nightly-20230503-0419.1 ([commit](https://github.com/microsoft/fluentui/commit/a9a6cef152f4c3885a3697ddf9ded12bfce5a2be) by beachball)
|
20
|
+
- Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20230503-0419.1 ([commit](https://github.com/microsoft/fluentui/commit/a9a6cef152f4c3885a3697ddf9ded12bfce5a2be) by beachball)
|
21
21
|
|
22
22
|
## [9.1.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.1.1)
|
23
23
|
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
|
3
|
+
import type { ComponentProps } from '@fluentui/react-utilities';
|
4
|
+
import type { ComponentState } from '@fluentui/react-utilities';
|
5
|
+
import type { ForwardRefComponent } from '@fluentui/react-utilities';
|
6
|
+
import { Label } from '@fluentui/react-label';
|
7
|
+
import * as React_2 from 'react';
|
8
|
+
import type { Slot } from '@fluentui/react-utilities';
|
9
|
+
import type { SlotClassNames } from '@fluentui/react-utilities';
|
10
|
+
|
11
|
+
export declare const Field: ForwardRefComponent<FieldProps>;
|
12
|
+
|
13
|
+
export declare const fieldClassNames: SlotClassNames<FieldSlots>;
|
14
|
+
|
15
|
+
export declare const FieldContextProvider: React_2.Provider<Readonly<Pick<FieldState, "orientation" | "required" | "size" | "validationState" | "generatedControlId"> & {
|
16
|
+
labelFor?: string | undefined;
|
17
|
+
labelId?: string | undefined;
|
18
|
+
validationMessageId?: string | undefined;
|
19
|
+
hintId?: string | undefined;
|
20
|
+
}> | undefined>;
|
21
|
+
|
22
|
+
export declare type FieldContextValue = Readonly<Pick<FieldState, 'generatedControlId' | 'orientation' | 'required' | 'size' | 'validationState'> & {
|
23
|
+
/** The label's for prop. Undefined if there is no label. */
|
24
|
+
labelFor?: string;
|
25
|
+
/** The label's id prop. Undefined if there is no label. */
|
26
|
+
labelId?: string;
|
27
|
+
/** The validationMessage's id prop. Undefined if there is no validationMessage. */
|
28
|
+
validationMessageId?: string;
|
29
|
+
/** The hint's id prop. Undefined if there is no hint. */
|
30
|
+
hintId?: string;
|
31
|
+
}>;
|
32
|
+
|
33
|
+
export declare type FieldContextValues = {
|
34
|
+
field: FieldContextValue;
|
35
|
+
};
|
36
|
+
|
37
|
+
/**
|
38
|
+
* The props added to the control inside the Field.
|
39
|
+
*/
|
40
|
+
export declare type FieldControlProps = Pick<React_2.HTMLAttributes<HTMLElement>, 'id' | 'aria-labelledby' | 'aria-describedby' | 'aria-invalid' | 'aria-required'>;
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Options for `useFieldControlProps_unstable`.
|
44
|
+
*/
|
45
|
+
export declare type FieldControlPropsOptions = {
|
46
|
+
/**
|
47
|
+
* Skips setting `aria-labelledby` on the control if the `label.htmlFor` refers to the control.
|
48
|
+
*
|
49
|
+
* This should be used with controls that can be the target of a label's `for` prop:
|
50
|
+
* `<button>`, `<input>`, `<progress>`, `<select>`, `<textarea>`.
|
51
|
+
*/
|
52
|
+
supportsLabelFor?: boolean;
|
53
|
+
/**
|
54
|
+
* Sets `required` instead of `aria-required` when the Field is marked required.
|
55
|
+
*
|
56
|
+
* This should be used with controls that support the `required` prop:
|
57
|
+
* `<input>` (except `range` or `color`), `<select>`, `<textarea>`.
|
58
|
+
*/
|
59
|
+
supportsRequired?: boolean;
|
60
|
+
/**
|
61
|
+
* Sets the size prop on the control to match the Field's size: `'small' | 'medium' | 'large'`.
|
62
|
+
*
|
63
|
+
* This should be used with controls that have a custom size prop that matches the Field's size prop.
|
64
|
+
*/
|
65
|
+
supportsSize?: boolean;
|
66
|
+
};
|
67
|
+
|
68
|
+
/**
|
69
|
+
* Field Props
|
70
|
+
*/
|
71
|
+
export declare type FieldProps = Omit<ComponentProps<FieldSlots>, 'children'> & {
|
72
|
+
/**
|
73
|
+
* The Field's child can be a single form control, or a render function that takes the props that should be spread on
|
74
|
+
* a form control.
|
75
|
+
*
|
76
|
+
* All form controls in this library can be used directly as children (such as `<Input>` or `<RadioGroup>`).
|
77
|
+
*
|
78
|
+
* For other controls, there are two options:
|
79
|
+
* 1. The child of Field can be a render function that is given the props that should be spread on the control.
|
80
|
+
* `<Field>{(props) => <MyInput {...props} />}</Field>`
|
81
|
+
* 2. The control itself can merge props from field with useFieldControlProps_unstable().
|
82
|
+
* `props = useFieldControlProps_unstable(props);`
|
83
|
+
*/
|
84
|
+
children?: React_2.ReactNode | ((props: FieldControlProps) => React_2.ReactNode);
|
85
|
+
/**
|
86
|
+
* The orientation of the label relative to the field component.
|
87
|
+
* This only affects the label, and not the validationMessage or hint (which always appear below the field component).
|
88
|
+
*
|
89
|
+
* @default vertical
|
90
|
+
*/
|
91
|
+
orientation?: 'vertical' | 'horizontal';
|
92
|
+
/**
|
93
|
+
* The `validationState` affects the display of the `validationMessage` and `validationMessageIcon`.
|
94
|
+
*
|
95
|
+
* * error: (default) The validation message has a red error icon and red text, with `role="alert"` so it is
|
96
|
+
* announced by screen readers. Additionally, the control inside the field has `aria-invalid` set, which adds a
|
97
|
+
* red border to some field components (such as `Input`).
|
98
|
+
* * success: The validation message has a green checkmark icon and gray text.
|
99
|
+
* * warning: The validation message has a yellow exclamation icon and gray text.
|
100
|
+
* * none: The validation message has no icon and gray text.
|
101
|
+
*
|
102
|
+
* @default error when validationMessage is set; none otherwise.
|
103
|
+
*/
|
104
|
+
validationState?: 'error' | 'warning' | 'success' | 'none';
|
105
|
+
/**
|
106
|
+
* Marks the Field as required. If `true`, an asterisk will be appended to the label, and `aria-required` will be set
|
107
|
+
* on the Field's child.
|
108
|
+
*/
|
109
|
+
required?: boolean;
|
110
|
+
/**
|
111
|
+
* The size of the Field's label.
|
112
|
+
*
|
113
|
+
* @default medium
|
114
|
+
*/
|
115
|
+
size?: 'small' | 'medium' | 'large';
|
116
|
+
};
|
117
|
+
|
118
|
+
/**
|
119
|
+
* Slots of the Field component
|
120
|
+
*/
|
121
|
+
export declare type FieldSlots = {
|
122
|
+
root: NonNullable<Slot<'div'>>;
|
123
|
+
/**
|
124
|
+
* The label associated with the field.
|
125
|
+
*/
|
126
|
+
label?: Slot<typeof Label>;
|
127
|
+
/**
|
128
|
+
* A message about the validation state. By default, this is an error message, but it can be a success, warning,
|
129
|
+
* or custom message by setting `validationState`.
|
130
|
+
*/
|
131
|
+
validationMessage?: Slot<'div'>;
|
132
|
+
/**
|
133
|
+
* The icon associated with the `validationMessage`. This will only be displayed if `validationMessage` is set.
|
134
|
+
*
|
135
|
+
* The default depends on `validationState`:
|
136
|
+
* * error: `<ErrorCircle12Filled />`
|
137
|
+
* * warning: `<Warning12Filled />`
|
138
|
+
* * success: `<CheckmarkCircle12Filled />`
|
139
|
+
* * none: `null`
|
140
|
+
*/
|
141
|
+
validationMessageIcon?: Slot<'span'>;
|
142
|
+
/**
|
143
|
+
* Additional hint text below the field.
|
144
|
+
*/
|
145
|
+
hint?: Slot<'div'>;
|
146
|
+
};
|
147
|
+
|
148
|
+
/**
|
149
|
+
* State used in rendering Field
|
150
|
+
*/
|
151
|
+
export declare type FieldState = ComponentState<Required<FieldSlots>> & Required<Pick<FieldProps, 'orientation' | 'required' | 'size' | 'validationState'>> & Pick<FieldProps, 'children'> & {
|
152
|
+
/**
|
153
|
+
* The ID generated for the control inside the field, and the default value of label.htmlFor prop.
|
154
|
+
*/
|
155
|
+
generatedControlId: string;
|
156
|
+
};
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Render the final JSX of Field
|
160
|
+
*/
|
161
|
+
export declare const renderField_unstable: (state: FieldState, contextValues: FieldContextValues) => JSX.Element;
|
162
|
+
|
163
|
+
/**
|
164
|
+
* Create the state required to render Field.
|
165
|
+
*
|
166
|
+
* The returned state can be modified with hooks such as useFieldStyles_unstable,
|
167
|
+
* before being passed to renderField_unstable.
|
168
|
+
*
|
169
|
+
* @param props - Props passed to this field
|
170
|
+
* @param ref - Ref to the root
|
171
|
+
*/
|
172
|
+
export declare const useField_unstable: (props: FieldProps, ref: React_2.Ref<HTMLDivElement>) => FieldState;
|
173
|
+
|
174
|
+
export declare const useFieldContext_unstable: () => Readonly<Pick<FieldState, "orientation" | "required" | "size" | "validationState" | "generatedControlId"> & {
|
175
|
+
labelFor?: string | undefined;
|
176
|
+
labelId?: string | undefined;
|
177
|
+
validationMessageId?: string | undefined;
|
178
|
+
hintId?: string | undefined;
|
179
|
+
}> | undefined;
|
180
|
+
|
181
|
+
/**
|
182
|
+
* Get the context values used when rendering Field.
|
183
|
+
*/
|
184
|
+
export declare const useFieldContextValues_unstable: (state: FieldState) => FieldContextValues;
|
185
|
+
|
186
|
+
/**
|
187
|
+
* Gets the control props from the field context, if this inside a `<Field>`.
|
188
|
+
*
|
189
|
+
* When called with no arguments, returns the FieldControlProps that should be applied to the control.
|
190
|
+
*
|
191
|
+
* @returns A FieldControlProps object if inside a `<Field>`, otherwise undefined.
|
192
|
+
*/
|
193
|
+
export declare function useFieldControlProps_unstable(): FieldControlProps | undefined;
|
194
|
+
|
195
|
+
/**
|
196
|
+
* Copies and merges the FieldControlProps with the given props, if this inside a `<Field>`.
|
197
|
+
*
|
198
|
+
* @param props - The existing props for the control. These will be merged with the control props from the field context.
|
199
|
+
* @param options - Option to include the size prop.
|
200
|
+
* @returns Merged props if inside a `<Field>`, otherwise the original props, or undefined if no props given.
|
201
|
+
*/
|
202
|
+
export declare function useFieldControlProps_unstable<Props extends FieldControlProps>(props: Props, options?: FieldControlPropsOptions): Props;
|
203
|
+
|
204
|
+
/**
|
205
|
+
* Apply styling to the Field slots based on the state
|
206
|
+
*/
|
207
|
+
export declare const useFieldStyles_unstable: (state: FieldState) => void;
|
208
|
+
|
209
|
+
export { }
|
package/lib/Field.js
ADDED
package/lib/Field.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sources":["../src/Field.ts"],"sourcesContent":["export * from './components/Field/index';\n"],"mappings":"AAAA,cAAc"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { renderField_unstable } from './renderField';
|
3
|
+
import { useField_unstable } from './useField';
|
4
|
+
import { useFieldStyles_unstable } from './useFieldStyles.styles';
|
5
|
+
import { useFieldContextValues_unstable } from '../../contexts/index';
|
6
|
+
export const Field = /*#__PURE__*/React.forwardRef((props, ref) => {
|
7
|
+
const state = useField_unstable(props, ref);
|
8
|
+
useFieldStyles_unstable(state);
|
9
|
+
const context = useFieldContextValues_unstable(state);
|
10
|
+
return renderField_unstable(state, context);
|
11
|
+
});
|
12
|
+
Field.displayName = 'Field';
|
13
|
+
//# sourceMappingURL=Field.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["React","renderField_unstable","useField_unstable","useFieldStyles_unstable","useFieldContextValues_unstable","Field","forwardRef","props","ref","state","context","displayName"],"sources":["../../../src/components/Field/Field.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport type { FieldProps } from './Field.types';\nimport { renderField_unstable } from './renderField';\nimport { useField_unstable } from './useField';\nimport { useFieldStyles_unstable } from './useFieldStyles.styles';\nimport { useFieldContextValues_unstable } from '../../contexts/index';\n\nexport const Field: ForwardRefComponent<FieldProps> = React.forwardRef((props, ref) => {\n const state = useField_unstable(props, ref);\n useFieldStyles_unstable(state);\n const context = useFieldContextValues_unstable(state);\n return renderField_unstable(state, context);\n});\n\nField.displayName = 'Field';\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAGvB,SAASC,oBAAoB,QAAQ;AACrC,SAASC,iBAAiB,QAAQ;AAClC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,8BAA8B,QAAQ;AAE/C,OAAO,MAAMC,KAAA,gBAAyCL,KAAA,CAAMM,UAAU,CAAC,CAACC,KAAA,EAAOC,GAAA,KAAQ;EACrF,MAAMC,KAAA,GAAQP,iBAAA,CAAkBK,KAAA,EAAOC,GAAA;EACvCL,uBAAA,CAAwBM,KAAA;EACxB,MAAMC,OAAA,GAAUN,8BAAA,CAA+BK,KAAA;EAC/C,OAAOR,oBAAA,CAAqBQ,KAAA,EAAOC,OAAA;AACrC;AAEAL,KAAA,CAAMM,WAAW,GAAG"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["React"],"sources":["../../../src/components/Field/Field.types.ts"],"sourcesContent":["import * as React from 'react';\nimport { Label } from '@fluentui/react-label';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\n/**\n * The props added to the control inside the Field.\n */\nexport type FieldControlProps = Pick<\n React.HTMLAttributes<HTMLElement>,\n 'id' | 'aria-labelledby' | 'aria-describedby' | 'aria-invalid' | 'aria-required'\n>;\n\n/**\n * Slots of the Field component\n */\nexport type FieldSlots = {\n root: NonNullable<Slot<'div'>>;\n\n /**\n * The label associated with the field.\n */\n label?: Slot<typeof Label>;\n\n /**\n * A message about the validation state. By default, this is an error message, but it can be a success, warning,\n * or custom message by setting `validationState`.\n */\n validationMessage?: Slot<'div'>;\n\n /**\n * The icon associated with the `validationMessage`. This will only be displayed if `validationMessage` is set.\n *\n * The default depends on `validationState`:\n * * error: `<ErrorCircle12Filled />`\n * * warning: `<Warning12Filled />`\n * * success: `<CheckmarkCircle12Filled />`\n * * none: `null`\n */\n validationMessageIcon?: Slot<'span'>;\n\n /**\n * Additional hint text below the field.\n */\n hint?: Slot<'div'>;\n};\n\n/**\n * Field Props\n */\nexport type FieldProps = Omit<ComponentProps<FieldSlots>, 'children'> & {\n /**\n * The Field's child can be a single form control, or a render function that takes the props that should be spread on\n * a form control.\n *\n * All form controls in this library can be used directly as children (such as `<Input>` or `<RadioGroup>`).\n *\n * For other controls, there are two options:\n * 1. The child of Field can be a render function that is given the props that should be spread on the control.\n * `<Field>{(props) => <MyInput {...props} />}</Field>`\n * 2. The control itself can merge props from field with useFieldControlProps_unstable().\n * `props = useFieldControlProps_unstable(props);`\n */\n children?: React.ReactNode | ((props: FieldControlProps) => React.ReactNode);\n\n /**\n * The orientation of the label relative to the field component.\n * This only affects the label, and not the validationMessage or hint (which always appear below the field component).\n *\n * @default vertical\n */\n orientation?: 'vertical' | 'horizontal';\n\n /**\n * The `validationState` affects the display of the `validationMessage` and `validationMessageIcon`.\n *\n * * error: (default) The validation message has a red error icon and red text, with `role=\"alert\"` so it is\n * announced by screen readers. Additionally, the control inside the field has `aria-invalid` set, which adds a\n * red border to some field components (such as `Input`).\n * * success: The validation message has a green checkmark icon and gray text.\n * * warning: The validation message has a yellow exclamation icon and gray text.\n * * none: The validation message has no icon and gray text.\n *\n * @default error when validationMessage is set; none otherwise.\n */\n validationState?: 'error' | 'warning' | 'success' | 'none';\n\n /**\n * Marks the Field as required. If `true`, an asterisk will be appended to the label, and `aria-required` will be set\n * on the Field's child.\n */\n required?: boolean;\n\n /**\n * The size of the Field's label.\n *\n * @default medium\n */\n size?: 'small' | 'medium' | 'large';\n};\n\n/**\n * State used in rendering Field\n */\nexport type FieldState = ComponentState<Required<FieldSlots>> &\n Required<Pick<FieldProps, 'orientation' | 'required' | 'size' | 'validationState'>> &\n Pick<FieldProps, 'children'> & {\n /**\n * The ID generated for the control inside the field, and the default value of label.htmlFor prop.\n */\n generatedControlId: string;\n };\n\nexport type FieldContextValue = Readonly<\n Pick<FieldState, 'generatedControlId' | 'orientation' | 'required' | 'size' | 'validationState'> & {\n /** The label's for prop. Undefined if there is no label. */\n labelFor?: string;\n /** The label's id prop. Undefined if there is no label. */\n labelId?: string;\n /** The validationMessage's id prop. Undefined if there is no validationMessage. */\n validationMessageId?: string;\n /** The hint's id prop. Undefined if there is no hint. */\n hintId?: string;\n }\n>;\n\nexport type FieldContextValues = {\n field: FieldContextValue;\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/components/Field/index.ts"],"sourcesContent":["export * from './Field.types';\nexport * from './Field';\nexport * from './renderField';\nexport * from './useField';\nexport * from './useFieldStyles.styles';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/** @jsxRuntime classic */ /** @jsx createElement */import { createElement } from '@fluentui/react-jsx-runtime';
|
2
|
+
import { getSlotsNext } from '@fluentui/react-utilities';
|
3
|
+
import { FieldContextProvider, getFieldControlProps } from '../../contexts/index';
|
4
|
+
/**
|
5
|
+
* Render the final JSX of Field
|
6
|
+
*/
|
7
|
+
export const renderField_unstable = (state, contextValues) => {
|
8
|
+
const {
|
9
|
+
slots,
|
10
|
+
slotProps
|
11
|
+
} = getSlotsNext(state);
|
12
|
+
let {
|
13
|
+
children
|
14
|
+
} = state;
|
15
|
+
if (typeof children === 'function') {
|
16
|
+
children = children(getFieldControlProps(contextValues.field) || {});
|
17
|
+
}
|
18
|
+
return /*#__PURE__*/createElement(FieldContextProvider, {
|
19
|
+
value: contextValues === null || contextValues === void 0 ? void 0 : contextValues.field
|
20
|
+
}, /*#__PURE__*/createElement(slots.root, slotProps.root, slots.label && /*#__PURE__*/createElement(slots.label, slotProps.label), children, slots.validationMessage && /*#__PURE__*/createElement(slots.validationMessage, slotProps.validationMessage, slots.validationMessageIcon && /*#__PURE__*/createElement(slots.validationMessageIcon, slotProps.validationMessageIcon), slotProps.validationMessage.children), slots.hint && /*#__PURE__*/createElement(slots.hint, slotProps.hint)));
|
21
|
+
};
|
22
|
+
//# sourceMappingURL=renderField.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["createElement","getSlotsNext","FieldContextProvider","getFieldControlProps","renderField_unstable","state","contextValues","slots","slotProps","children","field","value","root","label","validationMessage","validationMessageIcon","hint"],"sources":["../../../src/components/Field/renderField.tsx"],"sourcesContent":["/** @jsxRuntime classic */\n/** @jsx createElement */\n\nimport { createElement } from '@fluentui/react-jsx-runtime';\n\nimport { getSlotsNext } from '@fluentui/react-utilities';\nimport { FieldContextProvider, getFieldControlProps } from '../../contexts/index';\nimport type { FieldContextValues, FieldSlots, FieldState } from './Field.types';\n\n/**\n * Render the final JSX of Field\n */\nexport const renderField_unstable = (state: FieldState, contextValues: FieldContextValues) => {\n const { slots, slotProps } = getSlotsNext<FieldSlots>(state);\n\n let { children } = state;\n if (typeof children === 'function') {\n children = children(getFieldControlProps(contextValues.field) || {});\n }\n\n return (\n <FieldContextProvider value={contextValues?.field}>\n <slots.root {...slotProps.root}>\n {slots.label && <slots.label {...slotProps.label} />}\n {children}\n {slots.validationMessage && (\n <slots.validationMessage {...slotProps.validationMessage}>\n {slots.validationMessageIcon && <slots.validationMessageIcon {...slotProps.validationMessageIcon} />}\n {slotProps.validationMessage.children}\n </slots.validationMessage>\n )}\n {slots.hint && <slots.hint {...slotProps.hint} />}\n </slots.root>\n </FieldContextProvider>\n );\n};\n"],"mappings":"AAAA,2BACA,yBAEA,SAASA,aAAa,QAAQ;AAE9B,SAASC,YAAY,QAAQ;AAC7B,SAASC,oBAAoB,EAAEC,oBAAoB,QAAQ;AAG3D;;;AAGA,OAAO,MAAMC,oBAAA,GAAuBA,CAACC,KAAA,EAAmBC,aAAA,KAAsC;EAC5F,MAAM;IAAEC,KAAA;IAAOC;EAAS,CAAE,GAAGP,YAAA,CAAyBI,KAAA;EAEtD,IAAI;IAAEI;EAAQ,CAAE,GAAGJ,KAAA;EACnB,IAAI,OAAOI,QAAA,KAAa,YAAY;IAClCA,QAAA,GAAWA,QAAA,CAASN,oBAAA,CAAqBG,aAAA,CAAcI,KAAK,KAAK,CAAC;EACpE;EAEA,oBACEV,aApBJ,CAoBKE,oBAAA;IAAqBS,KAAA,EAAOL,aAAA,aAAAA,aAAA,uBAAAA,aAAA,CAAeI;kBAC1CV,aArBN,CAqBOO,KAAA,CAAMK,IAAI,EAAKJ,SAAA,CAAUI,IAAI,EAC3BL,KAAA,CAAMM,KAAK,iBAAIb,aAtBxB,CAsByBO,KAAA,CAAMM,KAAK,EAAKL,SAAA,CAAUK,KAAK,GAC/CJ,QAAA,EACAF,KAAA,CAAMO,iBAAiB,iBACtBd,aAzBV,CAyBWO,KAAA,CAAMO,iBAAiB,EAAKN,SAAA,CAAUM,iBAAiB,EACrDP,KAAA,CAAMQ,qBAAqB,iBAAIf,aA1B5C,CA0B6CO,KAAA,CAAMQ,qBAAqB,EAAKP,SAAA,CAAUO,qBAAqB,GAC/FP,SAAA,CAAUM,iBAAiB,CAACL,QAAQ,GAGxCF,KAAA,CAAMS,IAAI,iBAAIhB,aA9BvB,CA8BwBO,KAAA,CAAMS,IAAI,EAAKR,SAAA,CAAUQ,IAAI;AAIrD"}
|
@@ -0,0 +1,81 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { CheckmarkCircle12Filled, ErrorCircle12Filled, Warning12Filled } from '@fluentui/react-icons';
|
3
|
+
import { Label } from '@fluentui/react-label';
|
4
|
+
import { getNativeElementProps, resolveShorthand, useId } from '@fluentui/react-utilities';
|
5
|
+
const validationMessageIcons = {
|
6
|
+
error: /*#__PURE__*/React.createElement(ErrorCircle12Filled, null),
|
7
|
+
warning: /*#__PURE__*/React.createElement(Warning12Filled, null),
|
8
|
+
success: /*#__PURE__*/React.createElement(CheckmarkCircle12Filled, null),
|
9
|
+
none: undefined
|
10
|
+
};
|
11
|
+
/**
|
12
|
+
* Create the state required to render Field.
|
13
|
+
*
|
14
|
+
* The returned state can be modified with hooks such as useFieldStyles_unstable,
|
15
|
+
* before being passed to renderField_unstable.
|
16
|
+
*
|
17
|
+
* @param props - Props passed to this field
|
18
|
+
* @param ref - Ref to the root
|
19
|
+
*/
|
20
|
+
export const useField_unstable = (props, ref) => {
|
21
|
+
const {
|
22
|
+
children,
|
23
|
+
orientation = 'vertical',
|
24
|
+
required = false,
|
25
|
+
validationState = props.validationMessage ? 'error' : 'none',
|
26
|
+
size = 'medium'
|
27
|
+
} = props;
|
28
|
+
const baseId = useId('field-');
|
29
|
+
const generatedControlId = baseId + '__control';
|
30
|
+
const root = getNativeElementProps('div', {
|
31
|
+
...props,
|
32
|
+
ref
|
33
|
+
}, /*excludedPropNames:*/['children']);
|
34
|
+
const label = resolveShorthand(props.label, {
|
35
|
+
defaultProps: {
|
36
|
+
htmlFor: generatedControlId,
|
37
|
+
id: baseId + '__label',
|
38
|
+
required,
|
39
|
+
size
|
40
|
+
}
|
41
|
+
});
|
42
|
+
const validationMessage = resolveShorthand(props.validationMessage, {
|
43
|
+
defaultProps: {
|
44
|
+
id: baseId + '__validationMessage',
|
45
|
+
role: validationState === 'error' ? 'alert' : undefined
|
46
|
+
}
|
47
|
+
});
|
48
|
+
const hint = resolveShorthand(props.hint, {
|
49
|
+
defaultProps: {
|
50
|
+
id: baseId + '__hint'
|
51
|
+
}
|
52
|
+
});
|
53
|
+
const defaultIcon = validationMessageIcons[validationState];
|
54
|
+
const validationMessageIcon = resolveShorthand(props.validationMessageIcon, {
|
55
|
+
required: !!defaultIcon,
|
56
|
+
defaultProps: {
|
57
|
+
children: defaultIcon
|
58
|
+
}
|
59
|
+
});
|
60
|
+
return {
|
61
|
+
children,
|
62
|
+
generatedControlId,
|
63
|
+
orientation,
|
64
|
+
required,
|
65
|
+
size,
|
66
|
+
validationState,
|
67
|
+
components: {
|
68
|
+
root: 'div',
|
69
|
+
label: Label,
|
70
|
+
validationMessage: 'div',
|
71
|
+
validationMessageIcon: 'span',
|
72
|
+
hint: 'div'
|
73
|
+
},
|
74
|
+
root,
|
75
|
+
label,
|
76
|
+
validationMessageIcon,
|
77
|
+
validationMessage,
|
78
|
+
hint
|
79
|
+
};
|
80
|
+
};
|
81
|
+
//# sourceMappingURL=useField.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["React","CheckmarkCircle12Filled","ErrorCircle12Filled","Warning12Filled","Label","getNativeElementProps","resolveShorthand","useId","validationMessageIcons","error","createElement","warning","success","none","undefined","useField_unstable","props","ref","children","orientation","required","validationState","validationMessage","size","baseId","generatedControlId","root","label","defaultProps","htmlFor","id","role","hint","defaultIcon","validationMessageIcon","components"],"sources":["../../../src/components/Field/useField.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { CheckmarkCircle12Filled, ErrorCircle12Filled, Warning12Filled } from '@fluentui/react-icons';\nimport { Label } from '@fluentui/react-label';\nimport { getNativeElementProps, resolveShorthand, useId } from '@fluentui/react-utilities';\nimport type { FieldProps, FieldState } from './Field.types';\n\nconst validationMessageIcons = {\n error: <ErrorCircle12Filled />,\n warning: <Warning12Filled />,\n success: <CheckmarkCircle12Filled />,\n none: undefined,\n} as const;\n\n/**\n * Create the state required to render Field.\n *\n * The returned state can be modified with hooks such as useFieldStyles_unstable,\n * before being passed to renderField_unstable.\n *\n * @param props - Props passed to this field\n * @param ref - Ref to the root\n */\nexport const useField_unstable = (props: FieldProps, ref: React.Ref<HTMLDivElement>): FieldState => {\n const {\n children,\n orientation = 'vertical',\n required = false,\n validationState = props.validationMessage ? 'error' : 'none',\n size = 'medium',\n } = props;\n\n const baseId = useId('field-');\n const generatedControlId = baseId + '__control';\n\n const root = getNativeElementProps('div', { ...props, ref }, /*excludedPropNames:*/ ['children']);\n\n const label = resolveShorthand(props.label, {\n defaultProps: {\n htmlFor: generatedControlId,\n id: baseId + '__label',\n required,\n size,\n },\n });\n\n const validationMessage = resolveShorthand(props.validationMessage, {\n defaultProps: {\n id: baseId + '__validationMessage',\n role: validationState === 'error' ? 'alert' : undefined,\n },\n });\n\n const hint = resolveShorthand(props.hint, {\n defaultProps: {\n id: baseId + '__hint',\n },\n });\n\n const defaultIcon = validationMessageIcons[validationState];\n const validationMessageIcon = resolveShorthand(props.validationMessageIcon, {\n required: !!defaultIcon,\n defaultProps: {\n children: defaultIcon,\n },\n });\n\n return {\n children,\n generatedControlId,\n orientation,\n required,\n size,\n validationState,\n components: {\n root: 'div',\n label: Label,\n validationMessage: 'div',\n validationMessageIcon: 'span',\n hint: 'div',\n },\n root,\n label,\n validationMessageIcon,\n validationMessage,\n hint,\n };\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAEvB,SAASC,uBAAuB,EAAEC,mBAAmB,EAAEC,eAAe,QAAQ;AAC9E,SAASC,KAAK,QAAQ;AACtB,SAASC,qBAAqB,EAAEC,gBAAgB,EAAEC,KAAK,QAAQ;AAG/D,MAAMC,sBAAA,GAAyB;EAC7BC,KAAA,eAAOT,KAAA,CAAAU,aAAA,CAACR,mBAAA;EACRS,OAAA,eAASX,KAAA,CAAAU,aAAA,CAACP,eAAA;EACVS,OAAA,eAASZ,KAAA,CAAAU,aAAA,CAACT,uBAAA;EACVY,IAAA,EAAMC;AACR;AAEA;;;;;;;;;AASA,OAAO,MAAMC,iBAAA,GAAoBA,CAACC,KAAA,EAAmBC,GAAA,KAA+C;EAClG,MAAM;IACJC,QAAA;IACAC,WAAA,GAAc;IACdC,QAAA,GAAW,KAAK;IAChBC,eAAA,GAAkBL,KAAA,CAAMM,iBAAiB,GAAG,UAAU,MAAM;IAC5DC,IAAA,GAAO;EAAQ,CAChB,GAAGP,KAAA;EAEJ,MAAMQ,MAAA,GAASjB,KAAA,CAAM;EACrB,MAAMkB,kBAAA,GAAqBD,MAAA,GAAS;EAEpC,MAAME,IAAA,GAAOrB,qBAAA,CAAsB,OAAO;IAAE,GAAGW,KAAK;IAAEC;EAAI,GAAG,sBAAuB,CAAC,WAAW;EAEhG,MAAMU,KAAA,GAAQrB,gBAAA,CAAiBU,KAAA,CAAMW,KAAK,EAAE;IAC1CC,YAAA,EAAc;MACZC,OAAA,EAASJ,kBAAA;MACTK,EAAA,EAAIN,MAAA,GAAS;MACbJ,QAAA;MACAG;IACF;EACF;EAEA,MAAMD,iBAAA,GAAoBhB,gBAAA,CAAiBU,KAAA,CAAMM,iBAAiB,EAAE;IAClEM,YAAA,EAAc;MACZE,EAAA,EAAIN,MAAA,GAAS;MACbO,IAAA,EAAMV,eAAA,KAAoB,UAAU,UAAUP;IAChD;EACF;EAEA,MAAMkB,IAAA,GAAO1B,gBAAA,CAAiBU,KAAA,CAAMgB,IAAI,EAAE;IACxCJ,YAAA,EAAc;MACZE,EAAA,EAAIN,MAAA,GAAS;IACf;EACF;EAEA,MAAMS,WAAA,GAAczB,sBAAsB,CAACa,eAAA,CAAgB;EAC3D,MAAMa,qBAAA,GAAwB5B,gBAAA,CAAiBU,KAAA,CAAMkB,qBAAqB,EAAE;IAC1Ed,QAAA,EAAU,CAAC,CAACa,WAAA;IACZL,YAAA,EAAc;MACZV,QAAA,EAAUe;IACZ;EACF;EAEA,OAAO;IACLf,QAAA;IACAO,kBAAA;IACAN,WAAA;IACAC,QAAA;IACAG,IAAA;IACAF,eAAA;IACAc,UAAA,EAAY;MACVT,IAAA,EAAM;MACNC,KAAA,EAAOvB,KAAA;MACPkB,iBAAA,EAAmB;MACnBY,qBAAA,EAAuB;MACvBF,IAAA,EAAM;IACR;IACAN,IAAA;IACAC,KAAA;IACAO,qBAAA;IACAZ,iBAAA;IACAU;EACF;AACF"}
|
@@ -0,0 +1,106 @@
|
|
1
|
+
import { tokens, typographyStyles } from '@fluentui/react-theme';
|
2
|
+
import { __resetStyles, __styles, mergeClasses } from '@griffel/react';
|
3
|
+
export const fieldClassNames = {
|
4
|
+
root: `fui-Field`,
|
5
|
+
label: `fui-Field__label`,
|
6
|
+
validationMessage: `fui-Field__validationMessage`,
|
7
|
+
validationMessageIcon: `fui-Field__validationMessageIcon`,
|
8
|
+
hint: `fui-Field__hint`
|
9
|
+
};
|
10
|
+
// Size of the icon in the validation message
|
11
|
+
const iconSize = '12px';
|
12
|
+
/**
|
13
|
+
* Styles for the root slot
|
14
|
+
*/
|
15
|
+
const useRootStyles = /*#__PURE__*/__styles({
|
16
|
+
base: {
|
17
|
+
mc9l5x: "f13qh94s"
|
18
|
+
},
|
19
|
+
horizontal: {
|
20
|
+
Budl1dq: "f2wwaib",
|
21
|
+
wkccdc: "f1645dqt"
|
22
|
+
},
|
23
|
+
horizontalNoLabel: {
|
24
|
+
uwmqm3: ["f15jqgz8", "fggqkej"],
|
25
|
+
Budl1dq: "f1c2z91y"
|
26
|
+
}
|
27
|
+
}, {
|
28
|
+
d: [".f13qh94s{display:grid;}", ".f2wwaib{grid-template-columns:33% 1fr;}", ".f1645dqt{grid-template-rows:auto auto auto 1fr;}", ".f15jqgz8{padding-left:33%;}", ".fggqkej{padding-right:33%;}", ".f1c2z91y{grid-template-columns:1fr;}"]
|
29
|
+
});
|
30
|
+
const useLabelStyles = /*#__PURE__*/__styles({
|
31
|
+
base: {
|
32
|
+
z8tnut: "fclwglc",
|
33
|
+
Byoj8tv: "fywfov9"
|
34
|
+
},
|
35
|
+
large: {
|
36
|
+
z8tnut: "f1sl3k7w",
|
37
|
+
Byoj8tv: "f1brlhvm"
|
38
|
+
},
|
39
|
+
vertical: {
|
40
|
+
jrapky: "fyacil5"
|
41
|
+
},
|
42
|
+
verticalLarge: {
|
43
|
+
jrapky: "f8l5zjj"
|
44
|
+
},
|
45
|
+
horizontal: {
|
46
|
+
t21cq0: ["fkujibs", "f199hnxi"],
|
47
|
+
Ijaq50: "f16hsg94",
|
48
|
+
nk6f5a: "f1nzqi2z"
|
49
|
+
}
|
50
|
+
}, {
|
51
|
+
d: [".fclwglc{padding-top:var(--spacingVerticalXXS);}", ".fywfov9{padding-bottom:var(--spacingVerticalXXS);}", ".f1sl3k7w{padding-top:1px;}", ".f1brlhvm{padding-bottom:1px;}", ".fyacil5{margin-bottom:var(--spacingVerticalXXS);}", ".f8l5zjj{margin-bottom:var(--spacingVerticalXS);}", ".fkujibs{margin-right:var(--spacingHorizontalM);}", ".f199hnxi{margin-left:var(--spacingHorizontalM);}", ".f16hsg94{grid-row-start:1;}", ".f1nzqi2z{grid-row-end:-1;}"]
|
52
|
+
});
|
53
|
+
const useSecondaryTextBaseClassName = /*#__PURE__*/__resetStyles("r5c4z9l", null, [".r5c4z9l{margin-top:var(--spacingVerticalXXS);color:var(--colorNeutralForeground3);font-family:var(--fontFamilyBase);font-size:var(--fontSizeBase200);font-weight:var(--fontWeightRegular);line-height:var(--lineHeightBase200);}"]);
|
54
|
+
const useSecondaryTextStyles = /*#__PURE__*/__styles({
|
55
|
+
error: {
|
56
|
+
sj55zd: "f1hcrxcs"
|
57
|
+
},
|
58
|
+
withIcon: {
|
59
|
+
uwmqm3: ["frawy03", "fg4c52"]
|
60
|
+
}
|
61
|
+
}, {
|
62
|
+
d: [".f1hcrxcs{color:var(--colorPaletteRedForeground1);}", ".frawy03{padding-left:calc(12px + var(--spacingHorizontalXS));}", ".fg4c52{padding-right:calc(12px + var(--spacingHorizontalXS));}"]
|
63
|
+
});
|
64
|
+
const useValidationMessageIconBaseClassName = /*#__PURE__*/__resetStyles("ra7h1uk", "r1rh6bd7", [".ra7h1uk{display:inline-block;font-size:12px;margin-left:calc(-12px - var(--spacingHorizontalXS));margin-right:var(--spacingHorizontalXS);line-height:0;vertical-align:-1px;}", ".r1rh6bd7{display:inline-block;font-size:12px;margin-right:calc(-12px - var(--spacingHorizontalXS));margin-left:var(--spacingHorizontalXS);line-height:0;vertical-align:-1px;}"]);
|
65
|
+
const useValidationMessageIconStyles = /*#__PURE__*/__styles({
|
66
|
+
error: {
|
67
|
+
sj55zd: "f1hcrxcs"
|
68
|
+
},
|
69
|
+
warning: {
|
70
|
+
sj55zd: "f1k5f75o"
|
71
|
+
},
|
72
|
+
success: {
|
73
|
+
sj55zd: "ffmvakt"
|
74
|
+
}
|
75
|
+
}, {
|
76
|
+
d: [".f1hcrxcs{color:var(--colorPaletteRedForeground1);}", ".f1k5f75o{color:var(--colorPaletteDarkOrangeForeground1);}", ".ffmvakt{color:var(--colorPaletteGreenForeground1);}"]
|
77
|
+
});
|
78
|
+
/**
|
79
|
+
* Apply styling to the Field slots based on the state
|
80
|
+
*/
|
81
|
+
export const useFieldStyles_unstable = state => {
|
82
|
+
const {
|
83
|
+
validationState
|
84
|
+
} = state;
|
85
|
+
const horizontal = state.orientation === 'horizontal';
|
86
|
+
const rootStyles = useRootStyles();
|
87
|
+
state.root.className = mergeClasses(fieldClassNames.root, rootStyles.base, horizontal && rootStyles.horizontal, horizontal && !state.label && rootStyles.horizontalNoLabel, state.root.className);
|
88
|
+
const labelStyles = useLabelStyles();
|
89
|
+
if (state.label) {
|
90
|
+
state.label.className = mergeClasses(fieldClassNames.label, labelStyles.base, horizontal && labelStyles.horizontal, !horizontal && labelStyles.vertical, state.label.size === 'large' && labelStyles.large, !horizontal && state.label.size === 'large' && labelStyles.verticalLarge, state.label.className);
|
91
|
+
}
|
92
|
+
const validationMessageIconBaseClassName = useValidationMessageIconBaseClassName();
|
93
|
+
const validationMessageIconStyles = useValidationMessageIconStyles();
|
94
|
+
if (state.validationMessageIcon) {
|
95
|
+
state.validationMessageIcon.className = mergeClasses(fieldClassNames.validationMessageIcon, validationMessageIconBaseClassName, validationState !== 'none' && validationMessageIconStyles[validationState], state.validationMessageIcon.className);
|
96
|
+
}
|
97
|
+
const secondaryTextBaseClassName = useSecondaryTextBaseClassName();
|
98
|
+
const secondaryTextStyles = useSecondaryTextStyles();
|
99
|
+
if (state.validationMessage) {
|
100
|
+
state.validationMessage.className = mergeClasses(fieldClassNames.validationMessage, secondaryTextBaseClassName, validationState === 'error' && secondaryTextStyles.error, !!state.validationMessageIcon && secondaryTextStyles.withIcon, state.validationMessage.className);
|
101
|
+
}
|
102
|
+
if (state.hint) {
|
103
|
+
state.hint.className = mergeClasses(fieldClassNames.hint, secondaryTextBaseClassName, state.hint.className);
|
104
|
+
}
|
105
|
+
};
|
106
|
+
//# sourceMappingURL=useFieldStyles.styles.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["tokens","typographyStyles","__resetStyles","__styles","mergeClasses","fieldClassNames","root","label","validationMessage","validationMessageIcon","hint","iconSize","useRootStyles","base","mc9l5x","horizontal","Budl1dq","wkccdc","horizontalNoLabel","uwmqm3","d","useLabelStyles","z8tnut","Byoj8tv","large","vertical","jrapky","verticalLarge","t21cq0","Ijaq50","nk6f5a","useSecondaryTextBaseClassName","useSecondaryTextStyles","error","sj55zd","withIcon","useValidationMessageIconBaseClassName","useValidationMessageIconStyles","warning","success","useFieldStyles_unstable","state","validationState","orientation","rootStyles","className","labelStyles","size","validationMessageIconBaseClassName","validationMessageIconStyles","secondaryTextBaseClassName","secondaryTextStyles"],"sources":["../../../src/components/Field/useFieldStyles.styles.ts"],"sourcesContent":["import { tokens, typographyStyles } from '@fluentui/react-theme';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { makeResetStyles, makeStyles, mergeClasses } from '@griffel/react';\nimport type { FieldSlots, FieldState } from './Field.types';\n\nexport const fieldClassNames: SlotClassNames<FieldSlots> = {\n root: `fui-Field`,\n label: `fui-Field__label`,\n validationMessage: `fui-Field__validationMessage`,\n validationMessageIcon: `fui-Field__validationMessageIcon`,\n hint: `fui-Field__hint`,\n};\n\n// Size of the icon in the validation message\nconst iconSize = '12px';\n\n/**\n * Styles for the root slot\n */\nconst useRootStyles = makeStyles({\n base: {\n display: 'grid',\n },\n\n // In horizontal layout, the field is a grid with the label taking up the entire first column.\n // The last row is slack space in case the label is taller than the rest of the content.\n horizontal: {\n gridTemplateColumns: '33% 1fr',\n gridTemplateRows: 'auto auto auto 1fr',\n },\n\n // In horizontal layout without a label, replace the label's column with padding.\n // This lets grid auto-flow properly place the other children, and keeps fields with and without labels aligned.\n horizontalNoLabel: {\n paddingLeft: '33%',\n gridTemplateColumns: '1fr',\n },\n});\n\nconst useLabelStyles = makeStyles({\n base: {\n paddingTop: tokens.spacingVerticalXXS,\n paddingBottom: tokens.spacingVerticalXXS,\n },\n\n large: {\n paddingTop: '1px',\n paddingBottom: '1px',\n },\n\n vertical: {\n marginBottom: tokens.spacingVerticalXXS,\n },\n\n verticalLarge: {\n marginBottom: tokens.spacingVerticalXS,\n },\n\n horizontal: {\n marginRight: tokens.spacingHorizontalM,\n gridRowStart: '1',\n gridRowEnd: '-1',\n },\n});\n\nconst useSecondaryTextBaseClassName = makeResetStyles({\n marginTop: tokens.spacingVerticalXXS,\n color: tokens.colorNeutralForeground3,\n ...typographyStyles.caption1,\n});\n\nconst useSecondaryTextStyles = makeStyles({\n error: {\n color: tokens.colorPaletteRedForeground1,\n },\n\n withIcon: {\n // Add a gutter for the icon, to allow multiple lines of text to line up to the right of the icon.\n paddingLeft: `calc(${iconSize} + ${tokens.spacingHorizontalXS})`,\n },\n});\n\nconst useValidationMessageIconBaseClassName = makeResetStyles({\n display: 'inline-block',\n fontSize: iconSize,\n // Negative left margin puts the icon in the gutter of the validation message div's withIcon style.\n marginLeft: `calc(-${iconSize} - ${tokens.spacingHorizontalXS})`,\n marginRight: tokens.spacingHorizontalXS,\n // Line height of 0 prevents the verticalAlign from affecting the line height of the text.\n lineHeight: '0',\n // Negative verticalAlign shifts the inline icon down to align with the text (effectively top padding).\n verticalAlign: '-1px',\n});\n\nconst useValidationMessageIconStyles = makeStyles({\n error: {\n color: tokens.colorPaletteRedForeground1,\n },\n warning: {\n color: tokens.colorPaletteDarkOrangeForeground1,\n },\n success: {\n color: tokens.colorPaletteGreenForeground1,\n },\n});\n\n/**\n * Apply styling to the Field slots based on the state\n */\nexport const useFieldStyles_unstable = (state: FieldState) => {\n const { validationState } = state;\n const horizontal = state.orientation === 'horizontal';\n\n const rootStyles = useRootStyles();\n state.root.className = mergeClasses(\n fieldClassNames.root,\n rootStyles.base,\n horizontal && rootStyles.horizontal,\n horizontal && !state.label && rootStyles.horizontalNoLabel,\n state.root.className,\n );\n\n const labelStyles = useLabelStyles();\n if (state.label) {\n state.label.className = mergeClasses(\n fieldClassNames.label,\n labelStyles.base,\n horizontal && labelStyles.horizontal,\n !horizontal && labelStyles.vertical,\n state.label.size === 'large' && labelStyles.large,\n !horizontal && state.label.size === 'large' && labelStyles.verticalLarge,\n state.label.className,\n );\n }\n\n const validationMessageIconBaseClassName = useValidationMessageIconBaseClassName();\n const validationMessageIconStyles = useValidationMessageIconStyles();\n if (state.validationMessageIcon) {\n state.validationMessageIcon.className = mergeClasses(\n fieldClassNames.validationMessageIcon,\n validationMessageIconBaseClassName,\n validationState !== 'none' && validationMessageIconStyles[validationState],\n state.validationMessageIcon.className,\n );\n }\n\n const secondaryTextBaseClassName = useSecondaryTextBaseClassName();\n const secondaryTextStyles = useSecondaryTextStyles();\n if (state.validationMessage) {\n state.validationMessage.className = mergeClasses(\n fieldClassNames.validationMessage,\n secondaryTextBaseClassName,\n validationState === 'error' && secondaryTextStyles.error,\n !!state.validationMessageIcon && secondaryTextStyles.withIcon,\n state.validationMessage.className,\n );\n }\n\n if (state.hint) {\n state.hint.className = mergeClasses(fieldClassNames.hint, secondaryTextBaseClassName, state.hint.className);\n }\n};\n"],"mappings":"AAAA,SAASA,MAAM,EAAEC,gBAAgB,QAAQ;AAEzC,SAAAC,aAAA,EAAAC,QAAA,EAAsCC,YAAY,QAAQ;AAG1D,OAAO,MAAMC,eAAA,GAA8C;EACzDC,IAAA,EAAO,WAAU;EACjBC,KAAA,EAAQ,kBAAiB;EACzBC,iBAAA,EAAoB,8BAA6B;EACjDC,qBAAA,EAAwB,kCAAiC;EACzDC,IAAA,EAAO;AACT;AAEA;AACA,MAAMC,QAAA,GAAW;AAEjB;;;AAGA,MAAMC,aAAA,gBAAgBT,QAAA;EAAAU,IAAA;IAAAC,MAAA;EAAA;EAAAC,UAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;EAAAC,iBAAA;IAAAC,MAAA;IAAAH,OAAA;EAAA;AAAA;EAAAI,CAAA;AAAA,EAkBtB;AAEA,MAAMC,cAAA,gBAAiBlB,QAAA;EAAAU,IAAA;IAAAS,MAAA;IAAAC,OAAA;EAAA;EAAAC,KAAA;IAAAF,MAAA;IAAAC,OAAA;EAAA;EAAAE,QAAA;IAAAC,MAAA;EAAA;EAAAC,aAAA;IAAAD,MAAA;EAAA;EAAAX,UAAA;IAAAa,MAAA;IAAAC,MAAA;IAAAC,MAAA;EAAA;AAAA;EAAAV,CAAA;AAAA,EAwBvB;AAEA,MAAMW,6BAAA,gBAAgC7B,aAAA,wPAItC;AAEA,MAAM8B,sBAAA,gBAAyB7B,QAAA;EAAA8B,KAAA;IAAAC,MAAA;EAAA;EAAAC,QAAA;IAAAhB,MAAA;EAAA;AAAA;EAAAC,CAAA;AAAA,EAS/B;AAEA,MAAMgB,qCAAA,gBAAwClC,aAAA,4XAU9C;AAEA,MAAMmC,8BAAA,gBAAiClC,QAAA;EAAA8B,KAAA;IAAAC,MAAA;EAAA;EAAAI,OAAA;IAAAJ,MAAA;EAAA;EAAAK,OAAA;IAAAL,MAAA;EAAA;AAAA;EAAAd,CAAA;AAAA,EAUvC;AAEA;;;AAGA,OAAO,MAAMoB,uBAAA,GAA2BC,KAAA,IAAsB;EAC5D,MAAM;IAAEC;EAAe,CAAE,GAAGD,KAAA;EAC5B,MAAM1B,UAAA,GAAa0B,KAAA,CAAME,WAAW,KAAK;EAEzC,MAAMC,UAAA,GAAahC,aAAA;EACnB6B,KAAA,CAAMnC,IAAI,CAACuC,SAAS,GAAGzC,YAAA,CACrBC,eAAA,CAAgBC,IAAI,EACpBsC,UAAA,CAAW/B,IAAI,EACfE,UAAA,IAAc6B,UAAA,CAAW7B,UAAU,EACnCA,UAAA,IAAc,CAAC0B,KAAA,CAAMlC,KAAK,IAAIqC,UAAA,CAAW1B,iBAAiB,EAC1DuB,KAAA,CAAMnC,IAAI,CAACuC,SAAS;EAGtB,MAAMC,WAAA,GAAczB,cAAA;EACpB,IAAIoB,KAAA,CAAMlC,KAAK,EAAE;IACfkC,KAAA,CAAMlC,KAAK,CAACsC,SAAS,GAAGzC,YAAA,CACtBC,eAAA,CAAgBE,KAAK,EACrBuC,WAAA,CAAYjC,IAAI,EAChBE,UAAA,IAAc+B,WAAA,CAAY/B,UAAU,EACpC,CAACA,UAAA,IAAc+B,WAAA,CAAYrB,QAAQ,EACnCgB,KAAA,CAAMlC,KAAK,CAACwC,IAAI,KAAK,WAAWD,WAAA,CAAYtB,KAAK,EACjD,CAACT,UAAA,IAAc0B,KAAA,CAAMlC,KAAK,CAACwC,IAAI,KAAK,WAAWD,WAAA,CAAYnB,aAAa,EACxEc,KAAA,CAAMlC,KAAK,CAACsC,SAAS;EAEzB;EAEA,MAAMG,kCAAA,GAAqCZ,qCAAA;EAC3C,MAAMa,2BAAA,GAA8BZ,8BAAA;EACpC,IAAII,KAAA,CAAMhC,qBAAqB,EAAE;IAC/BgC,KAAA,CAAMhC,qBAAqB,CAACoC,SAAS,GAAGzC,YAAA,CACtCC,eAAA,CAAgBI,qBAAqB,EACrCuC,kCAAA,EACAN,eAAA,KAAoB,UAAUO,2BAA2B,CAACP,eAAA,CAAgB,EAC1ED,KAAA,CAAMhC,qBAAqB,CAACoC,SAAS;EAEzC;EAEA,MAAMK,0BAAA,GAA6BnB,6BAAA;EACnC,MAAMoB,mBAAA,GAAsBnB,sBAAA;EAC5B,IAAIS,KAAA,CAAMjC,iBAAiB,EAAE;IAC3BiC,KAAA,CAAMjC,iBAAiB,CAACqC,SAAS,GAAGzC,YAAA,CAClCC,eAAA,CAAgBG,iBAAiB,EACjC0C,0BAAA,EACAR,eAAA,KAAoB,WAAWS,mBAAA,CAAoBlB,KAAK,EACxD,CAAC,CAACQ,KAAA,CAAMhC,qBAAqB,IAAI0C,mBAAA,CAAoBhB,QAAQ,EAC7DM,KAAA,CAAMjC,iBAAiB,CAACqC,SAAS;EAErC;EAEA,IAAIJ,KAAA,CAAM/B,IAAI,EAAE;IACd+B,KAAA,CAAM/B,IAAI,CAACmC,SAAS,GAAGzC,YAAA,CAAaC,eAAA,CAAgBK,IAAI,EAAEwC,0BAAA,EAA4BT,KAAA,CAAM/B,IAAI,CAACmC,SAAS;EAC5G;AACF"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
const FieldContext = /*#__PURE__*/React.createContext(undefined);
|
3
|
+
export const FieldContextProvider = FieldContext.Provider;
|
4
|
+
export const useFieldContext_unstable = () => React.useContext(FieldContext);
|
5
|
+
//# sourceMappingURL=FieldContext.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["React","FieldContext","createContext","undefined","FieldContextProvider","Provider","useFieldContext_unstable","useContext"],"sources":["../../src/contexts/FieldContext.ts"],"sourcesContent":["import * as React from 'react';\n\nimport type { FieldContextValue } from '../Field';\n\nconst FieldContext = React.createContext<FieldContextValue | undefined>(undefined);\n\nexport const FieldContextProvider = FieldContext.Provider;\n\nexport const useFieldContext_unstable = () => React.useContext(FieldContext);\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAIvB,MAAMC,YAAA,gBAAeD,KAAA,CAAME,aAAa,CAAgCC,SAAA;AAExE,OAAO,MAAMC,oBAAA,GAAuBH,YAAA,CAAaI,QAAQ;AAEzD,OAAO,MAAMC,wBAAA,GAA2BA,CAAA,KAAMN,KAAA,CAAMO,UAAU,CAACN,YAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/contexts/index.ts"],"sourcesContent":["export * from './FieldContext';\nexport * from './useFieldContextValues';\nexport * from './useFieldControlProps';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc"}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
/**
|
3
|
+
* Get the context values used when rendering Field.
|
4
|
+
*/
|
5
|
+
export const useFieldContextValues_unstable = state => {
|
6
|
+
var _state_label, _state_label1, _state_validationMessage, _state_hint;
|
7
|
+
const {
|
8
|
+
generatedControlId,
|
9
|
+
orientation,
|
10
|
+
required,
|
11
|
+
size,
|
12
|
+
validationState
|
13
|
+
} = state;
|
14
|
+
const labelFor = (_state_label = state.label) === null || _state_label === void 0 ? void 0 : _state_label.htmlFor;
|
15
|
+
const labelId = (_state_label1 = state.label) === null || _state_label1 === void 0 ? void 0 : _state_label1.id;
|
16
|
+
const validationMessageId = (_state_validationMessage = state.validationMessage) === null || _state_validationMessage === void 0 ? void 0 : _state_validationMessage.id;
|
17
|
+
const hintId = (_state_hint = state.hint) === null || _state_hint === void 0 ? void 0 : _state_hint.id;
|
18
|
+
const field = React.useMemo(() => ({
|
19
|
+
generatedControlId,
|
20
|
+
hintId,
|
21
|
+
labelFor,
|
22
|
+
labelId,
|
23
|
+
orientation,
|
24
|
+
required,
|
25
|
+
size,
|
26
|
+
validationMessageId,
|
27
|
+
validationState
|
28
|
+
}), [generatedControlId, hintId, labelFor, labelId, orientation, required, size, validationMessageId, validationState]);
|
29
|
+
return {
|
30
|
+
field
|
31
|
+
};
|
32
|
+
};
|
33
|
+
//# sourceMappingURL=useFieldContextValues.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["React","useFieldContextValues_unstable","state","_state_label","_state_label1","_state_validationMessage","_state_hint","generatedControlId","orientation","required","size","validationState","labelFor","label","htmlFor","labelId","id","validationMessageId","validationMessage","hintId","hint","field","useMemo"],"sources":["../../src/contexts/useFieldContextValues.ts"],"sourcesContent":["import * as React from 'react';\n\nimport type { FieldContextValue, FieldContextValues, FieldState } from '../Field';\n\n/**\n * Get the context values used when rendering Field.\n */\nexport const useFieldContextValues_unstable = (state: FieldState): FieldContextValues => {\n const { generatedControlId, orientation, required, size, validationState } = state;\n const labelFor = state.label?.htmlFor;\n const labelId = state.label?.id;\n const validationMessageId = state.validationMessage?.id;\n const hintId = state.hint?.id;\n\n const field: FieldContextValue = React.useMemo(\n () => ({\n generatedControlId,\n hintId,\n labelFor,\n labelId,\n orientation,\n required,\n size,\n validationMessageId,\n validationState,\n }),\n [generatedControlId, hintId, labelFor, labelId, orientation, required, size, validationMessageId, validationState],\n );\n\n return { field };\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAIvB;;;AAGA,OAAO,MAAMC,8BAAA,GAAkCC,KAAA,IAA0C;MAEtEC,YAAA,EACDC,aAAA,EACYC,wBAAA,EACbC,WAAA;EAJf,MAAM;IAAEC,kBAAA;IAAoBC,WAAA;IAAaC,QAAA;IAAUC,IAAA;IAAMC;EAAe,CAAE,GAAGT,KAAA;EAC7E,MAAMU,QAAA,GAAW,CAAAT,YAAA,GAAAD,KAAA,CAAMW,KAAK,cAAXV,YAAA,uBAAAA,YAAA,CAAaW,OAAO;EACrC,MAAMC,OAAA,GAAU,CAAAX,aAAA,GAAAF,KAAA,CAAMW,KAAK,cAAXT,aAAA,uBAAAA,aAAA,CAAaY,EAAE;EAC/B,MAAMC,mBAAA,GAAsB,CAAAZ,wBAAA,GAAAH,KAAA,CAAMgB,iBAAiB,cAAvBb,wBAAA,uBAAAA,wBAAA,CAAyBW,EAAE;EACvD,MAAMG,MAAA,GAAS,CAAAb,WAAA,GAAAJ,KAAA,CAAMkB,IAAI,cAAVd,WAAA,uBAAAA,WAAA,CAAYU,EAAE;EAE7B,MAAMK,KAAA,GAA2BrB,KAAA,CAAMsB,OAAO,CAC5C,OAAO;IACLf,kBAAA;IACAY,MAAA;IACAP,QAAA;IACAG,OAAA;IACAP,WAAA;IACAC,QAAA;IACAC,IAAA;IACAO,mBAAA;IACAN;EACF,IACA,CAACJ,kBAAA,EAAoBY,MAAA,EAAQP,QAAA,EAAUG,OAAA,EAASP,WAAA,EAAaC,QAAA,EAAUC,IAAA,EAAMO,mBAAA,EAAqBN,eAAA,CAAgB;EAGpH,OAAO;IAAEU;EAAM;AACjB"}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
var _props, _props1, _arialabelledby, _props2, _ariainvalid, _props3, _props4, _ariarequired, _props5;
|
2
|
+
import { useFieldContext_unstable } from './FieldContext';
|
3
|
+
export function useFieldControlProps_unstable(props, options) {
|
4
|
+
return getFieldControlProps(useFieldContext_unstable(), props, options);
|
5
|
+
}
|
6
|
+
/**
|
7
|
+
* @internal
|
8
|
+
* Implementation of useFieldControlProps_unstable.
|
9
|
+
* Split out so it can be used directly in renderField_unstable.
|
10
|
+
*/
|
11
|
+
export function getFieldControlProps(context, props, options) {
|
12
|
+
if (!context) {
|
13
|
+
return props;
|
14
|
+
}
|
15
|
+
// Create a copy of props so we don't modify the original
|
16
|
+
props = {
|
17
|
+
...props
|
18
|
+
};
|
19
|
+
const {
|
20
|
+
generatedControlId,
|
21
|
+
hintId,
|
22
|
+
labelFor,
|
23
|
+
labelId,
|
24
|
+
required,
|
25
|
+
validationMessageId,
|
26
|
+
validationState
|
27
|
+
} = context;
|
28
|
+
if (generatedControlId) {
|
29
|
+
var _id;
|
30
|
+
(_id = (_props = props).id) !== null && _id !== void 0 ? _id : _props.id = generatedControlId;
|
31
|
+
}
|
32
|
+
// Set aria-labelledby if the control doesn't support label.htmlFor, or if the label's htmlFor doesn't refer
|
33
|
+
// to this control (i.e. the user set this control's id prop without also setting the Field's label.htmlFor).
|
34
|
+
if (labelId && (!(options === null || options === void 0 ? void 0 : options.supportsLabelFor) || labelFor !== props.id)) {
|
35
|
+
var _;
|
36
|
+
(_ = (_props1 = props)[_arialabelledby = 'aria-labelledby']) !== null && _ !== void 0 ? _ : _props1[_arialabelledby] = labelId;
|
37
|
+
}
|
38
|
+
// The control is described by the validation message, or hint, or both.
|
39
|
+
// We also preserve and append any aria-describedby from props.
|
40
|
+
// For reference: https://github.com/microsoft/fluentui/pull/25580#discussion_r1017259933
|
41
|
+
if (validationMessageId || hintId) {
|
42
|
+
// NOTE: Not using ??= since we're merging and overriding the user-provided value.
|
43
|
+
props['aria-describedby'] = [validationMessageId, hintId, props === null || props === void 0 ? void 0 : props['aria-describedby']].filter(Boolean).join(' ');
|
44
|
+
}
|
45
|
+
if (validationState === 'error') {
|
46
|
+
var _1;
|
47
|
+
(_1 = (_props2 = props)[_ariainvalid = 'aria-invalid']) !== null && _1 !== void 0 ? _1 : _props2[_ariainvalid] = true;
|
48
|
+
}
|
49
|
+
if (required) {
|
50
|
+
if (options === null || options === void 0 ? void 0 : options.supportsRequired) {
|
51
|
+
var _required;
|
52
|
+
(_required = (_props3 = props).required) !== null && _required !== void 0 ? _required : _props3.required = true;
|
53
|
+
} else {
|
54
|
+
var _2;
|
55
|
+
(_2 = (_props4 = props)[_ariarequired = 'aria-required']) !== null && _2 !== void 0 ? _2 : _props4[_ariarequired] = true;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
// Include the size prop if this control supports it
|
59
|
+
if (options === null || options === void 0 ? void 0 : options.supportsSize) {
|
60
|
+
var _size;
|
61
|
+
(_size = (_props5 = props).size) !== null && _size !== void 0 ? _size : _props5.size = context.size;
|
62
|
+
}
|
63
|
+
return props;
|
64
|
+
}
|
65
|
+
//# sourceMappingURL=useFieldControlProps.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_props","_props1","_arialabelledby","_props2","_ariainvalid","_props3","_props4","_ariarequired","_props5","useFieldContext_unstable","useFieldControlProps_unstable","props","options","getFieldControlProps","context","generatedControlId","hintId","labelFor","labelId","required","validationMessageId","validationState","_id","id","supportsLabelFor","_","filter","Boolean","join","_1","supportsRequired","_required","_2","supportsSize","_size","size"],"sources":["../../src/contexts/useFieldControlProps.ts"],"sourcesContent":["import type { FieldContextValue, FieldControlProps } from '../Field';\nimport { useFieldContext_unstable } from './FieldContext';\n\n/**\n * Options for `useFieldControlProps_unstable`.\n */\nexport type FieldControlPropsOptions = {\n /**\n * Skips setting `aria-labelledby` on the control if the `label.htmlFor` refers to the control.\n *\n * This should be used with controls that can be the target of a label's `for` prop:\n * `<button>`, `<input>`, `<progress>`, `<select>`, `<textarea>`.\n */\n supportsLabelFor?: boolean;\n\n /**\n * Sets `required` instead of `aria-required` when the Field is marked required.\n *\n * This should be used with controls that support the `required` prop:\n * `<input>` (except `range` or `color`), `<select>`, `<textarea>`.\n */\n supportsRequired?: boolean;\n\n /**\n * Sets the size prop on the control to match the Field's size: `'small' | 'medium' | 'large'`.\n *\n * This should be used with controls that have a custom size prop that matches the Field's size prop.\n */\n supportsSize?: boolean;\n};\n\n/**\n * Gets the control props from the field context, if this inside a `<Field>`.\n *\n * When called with no arguments, returns the FieldControlProps that should be applied to the control.\n *\n * @returns A FieldControlProps object if inside a `<Field>`, otherwise undefined.\n */\nexport function useFieldControlProps_unstable(): FieldControlProps | undefined;\n\n/**\n * Copies and merges the FieldControlProps with the given props, if this inside a `<Field>`.\n *\n * @param props - The existing props for the control. These will be merged with the control props from the field context.\n * @param options - Option to include the size prop.\n * @returns Merged props if inside a `<Field>`, otherwise the original props, or undefined if no props given.\n */\nexport function useFieldControlProps_unstable<Props extends FieldControlProps>(\n props: Props,\n options?: FieldControlPropsOptions,\n): Props;\nexport function useFieldControlProps_unstable<Props extends FieldControlProps>(\n props?: Props,\n options?: FieldControlPropsOptions,\n): Props | undefined {\n return getFieldControlProps(useFieldContext_unstable(), props, options);\n}\n\n/**\n * @internal\n * Implementation of useFieldControlProps_unstable.\n * Split out so it can be used directly in renderField_unstable.\n */\nexport function getFieldControlProps<Props extends FieldControlProps>(\n context: FieldContextValue | undefined,\n props?: Props,\n options?: FieldControlPropsOptions,\n): Props | undefined {\n if (!context) {\n return props;\n }\n\n // Create a copy of props so we don't modify the original\n props = { ...props } as Props;\n\n const { generatedControlId, hintId, labelFor, labelId, required, validationMessageId, validationState } = context;\n\n if (generatedControlId) {\n props.id ??= generatedControlId;\n }\n\n // Set aria-labelledby if the control doesn't support label.htmlFor, or if the label's htmlFor doesn't refer\n // to this control (i.e. the user set this control's id prop without also setting the Field's label.htmlFor).\n if (labelId && (!options?.supportsLabelFor || labelFor !== props.id)) {\n props['aria-labelledby'] ??= labelId;\n }\n\n // The control is described by the validation message, or hint, or both.\n // We also preserve and append any aria-describedby from props.\n // For reference: https://github.com/microsoft/fluentui/pull/25580#discussion_r1017259933\n if (validationMessageId || hintId) {\n // NOTE: Not using ??= since we're merging and overriding the user-provided value.\n props['aria-describedby'] = [validationMessageId, hintId, props?.['aria-describedby']].filter(Boolean).join(' ');\n }\n\n if (validationState === 'error') {\n props['aria-invalid'] ??= true;\n }\n\n if (required) {\n if (options?.supportsRequired) {\n (props as { required?: boolean }).required ??= true;\n } else {\n props['aria-required'] ??= true;\n }\n }\n\n // Include the size prop if this control supports it\n if (options?.supportsSize) {\n (props as { size?: FieldContextValue['size'] }).size ??= context.size;\n }\n\n return props;\n}\n"],"mappings":"IA8EIA,MAAA,EAMAC,OAAA,EAAMC,eAAA,EAYNC,OAAA,EAAMC,YAAA,EAKHC,OAAA,EAEDC,OAAA,EAAMC,aAAA,EAMPC,OAAA;AA5GL,SAASC,wBAAwB,QAAQ;AAkDzC,OAAO,SAASC,8BACdC,KAAa,EACbC,OAAkC,EACf;EACnB,OAAOC,oBAAA,CAAqBJ,wBAAA,IAA4BE,KAAA,EAAOC,OAAA;AACjE;AAEA;;;;;AAKA,OAAO,SAASC,qBACdC,OAAsC,EACtCH,KAAa,EACbC,OAAkC,EACf;EACnB,IAAI,CAACE,OAAA,EAAS;IACZ,OAAOH,KAAA;EACT;EAEA;EACAA,KAAA,GAAQ;IAAE,GAAGA;EAAM;EAEnB,MAAM;IAAEI,kBAAA;IAAoBC,MAAA;IAAQC,QAAA;IAAUC,OAAA;IAASC,QAAA;IAAUC,mBAAA;IAAqBC;EAAe,CAAE,GAAGP,OAAA;EAE1G,IAAIC,kBAAA,EAAoB;;IACtB,CAAAO,GAAA,IAAAtB,MAAA,GAAAW,KAAA,EAAMY,EAAA,cAAAD,GAAA,cAAAA,GAAA,GAANtB,MAAA,CAAMuB,EAAA,GAAOR,kBAAkB;EACjC;EAEA;EACA;EACA,IAAIG,OAAA,KAAY,EAACN,OAAA,aAAAA,OAAA,uBAAAA,OAAA,CAASY,gBAAgB,CAAD,IAAKP,QAAA,KAAaN,KAAA,CAAMY,EAAE,CAAD,EAAI;;IACpE,CAAAE,CAAA,IAAAxB,OAAA,GAAAU,KAAA,EAAMT,eAAA,qBAAkB,cAAAuB,CAAA,cAAAA,CAAA,GAAxBxB,OAAK,CAACC,eAAA,CAAkB,GAAKgB,OAAO;EACtC;EAEA;EACA;EACA;EACA,IAAIE,mBAAA,IAAuBJ,MAAA,EAAQ;IACjC;IACAL,KAAK,CAAC,mBAAmB,GAAG,CAACS,mBAAA,EAAqBJ,MAAA,EAAQL,KAAA,aAAAA,KAAA,uBAAAA,KAAO,CAAC,mBAAmB,CAAC,CAACe,MAAM,CAACC,OAAA,EAASC,IAAI,CAAC;EAC9G;EAEA,IAAIP,eAAA,KAAoB,SAAS;;IAC/B,CAAAQ,EAAA,IAAA1B,OAAA,GAAAQ,KAAA,EAAMP,YAAA,kBAAe,cAAAyB,EAAA,cAAAA,EAAA,GAArB1B,OAAK,CAACC,YAAA,CAAe,GAAK,IAAI;EAChC;EAEA,IAAIe,QAAA,EAAU;IACZ,IAAIP,OAAA,aAAAA,OAAA,uBAAAA,OAAA,CAASkB,gBAAgB,EAAE;;MAC7B,CAAAC,SAAA,IAAC1B,OAAA,GAAAM,KAAA,EAAiCQ,QAAA,cAAAY,SAAA,cAAAA,SAAA,GAAjC1B,OAAA,CAAiCc,QAAA,GAAa,IAAI;IACrD,OAAO;;MACL,CAAAa,EAAA,IAAA1B,OAAA,GAAAK,KAAA,EAAMJ,aAAA,mBAAgB,cAAAyB,EAAA,cAAAA,EAAA,GAAtB1B,OAAK,CAACC,aAAA,CAAgB,GAAK,IAAI;IACjC;EACF;EAEA;EACA,IAAIK,OAAA,aAAAA,OAAA,uBAAAA,OAAA,CAASqB,YAAY,EAAE;;IACzB,CAAAC,KAAA,IAAC1B,OAAA,GAAAG,KAAA,EAA+CwB,IAAA,cAAAD,KAAA,cAAAA,KAAA,GAA/C1B,OAAA,CAA+C2B,IAAA,GAASrB,OAAA,CAAQqB,IAAI;EACvE;EAEA,OAAOxB,KAAA;AACT"}
|
package/lib/index.js
ADDED
@@ -0,0 +1,3 @@
|
|
1
|
+
export { Field, fieldClassNames, renderField_unstable, useFieldStyles_unstable, useField_unstable } from './Field';
|
2
|
+
export { FieldContextProvider, useFieldContext_unstable, useFieldContextValues_unstable, useFieldControlProps_unstable } from './contexts/index';
|
3
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["Field","fieldClassNames","renderField_unstable","useFieldStyles_unstable","useField_unstable","FieldContextProvider","useFieldContext_unstable","useFieldContextValues_unstable","useFieldControlProps_unstable"],"sources":["../src/index.ts"],"sourcesContent":["export { Field, fieldClassNames, renderField_unstable, useFieldStyles_unstable, useField_unstable } from './Field';\nexport type {\n FieldContextValue,\n FieldContextValues,\n FieldControlProps,\n FieldProps,\n FieldSlots,\n FieldState,\n} from './Field';\nexport {\n FieldContextProvider,\n useFieldContext_unstable,\n useFieldContextValues_unstable,\n useFieldControlProps_unstable,\n} from './contexts/index';\nexport type { FieldControlPropsOptions } from './contexts/index';\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,eAAe,EAAEC,oBAAoB,EAAEC,uBAAuB,EAAEC,iBAAiB,QAAQ;AASzG,SACEC,oBAAoB,EACpBC,wBAAwB,EACxBC,8BAA8B,EAC9BC,6BAA6B,QACxB"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-field",
|
3
|
-
"version": "0.0.0-nightly-
|
3
|
+
"version": "0.0.0-nightly-20230503-0419.1",
|
4
4
|
"description": "Fluent UI Field components",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -27,17 +27,17 @@
|
|
27
27
|
"devDependencies": {
|
28
28
|
"@fluentui/eslint-plugin": "*",
|
29
29
|
"@fluentui/react-conformance": "*",
|
30
|
-
"@fluentui/react-conformance-griffel": "0.0.0-nightly-
|
30
|
+
"@fluentui/react-conformance-griffel": "0.0.0-nightly-20230503-0419.1",
|
31
31
|
"@fluentui/scripts-api-extractor": "*",
|
32
32
|
"@fluentui/scripts-tasks": "*"
|
33
33
|
},
|
34
34
|
"dependencies": {
|
35
|
-
"@fluentui/react-context-selector": "0.0.0-nightly-
|
35
|
+
"@fluentui/react-context-selector": "0.0.0-nightly-20230503-0419.1",
|
36
36
|
"@fluentui/react-icons": "^2.0.196",
|
37
|
-
"@fluentui/react-jsx-runtime": "0.0.0-nightly-
|
38
|
-
"@fluentui/react-label": "0.0.0-nightly-
|
39
|
-
"@fluentui/react-theme": "0.0.0-nightly-
|
40
|
-
"@fluentui/react-utilities": "0.0.0-nightly-
|
37
|
+
"@fluentui/react-jsx-runtime": "0.0.0-nightly-20230503-0419.1",
|
38
|
+
"@fluentui/react-label": "0.0.0-nightly-20230503-0419.1",
|
39
|
+
"@fluentui/react-theme": "0.0.0-nightly-20230503-0419.1",
|
40
|
+
"@fluentui/react-utilities": "0.0.0-nightly-20230503-0419.1",
|
41
41
|
"@griffel/react": "^1.5.2",
|
42
42
|
"@swc/helpers": "^0.4.14"
|
43
43
|
},
|