@fluentui/react-field 9.0.0-alpha.15 → 9.0.0-alpha.17
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +67 -1
- package/CHANGELOG.md +26 -2
- package/dist/index.d.ts +60 -86
- package/lib/components/Field/Field.js +11 -0
- package/lib/components/Field/Field.js.map +1 -0
- package/lib/components/Field/Field.types.js.map +1 -1
- package/lib/components/Field/index.js +1 -0
- package/lib/components/Field/index.js.map +1 -1
- package/lib/components/Field/renderField.js +4 -6
- package/lib/components/Field/renderField.js.map +1 -1
- package/lib/components/Field/useField.js +39 -72
- package/lib/components/Field/useField.js.map +1 -1
- package/lib/components/Field/useFieldStyles.js +48 -70
- package/lib/components/Field/useFieldStyles.js.map +1 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/util/makeDeprecatedField.js +71 -0
- package/lib/util/makeDeprecatedField.js.map +1 -0
- package/lib-amd/components/Field/Field.js +12 -0
- package/lib-amd/components/Field/Field.js.map +1 -0
- package/lib-amd/components/Field/Field.types.js.map +1 -1
- package/lib-amd/components/Field/index.js +2 -1
- package/lib-amd/components/Field/index.js.map +1 -1
- package/lib-amd/components/Field/renderField.js +4 -3
- package/lib-amd/components/Field/renderField.js.map +1 -1
- package/lib-amd/components/Field/useField.js +31 -53
- package/lib-amd/components/Field/useField.js.map +1 -1
- package/lib-amd/components/Field/useFieldStyles.js +55 -58
- package/lib-amd/components/Field/useFieldStyles.js.map +1 -1
- package/lib-amd/index.js +6 -3
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/util/makeDeprecatedField.js +38 -0
- package/lib-amd/util/makeDeprecatedField.js.map +1 -0
- package/lib-commonjs/components/Field/Field.js +17 -0
- package/lib-commonjs/components/Field/Field.js.map +1 -0
- package/lib-commonjs/components/Field/index.js +1 -0
- package/lib-commonjs/components/Field/index.js.map +1 -1
- package/lib-commonjs/components/Field/renderField.js +4 -6
- package/lib-commonjs/components/Field/renderField.js.map +1 -1
- package/lib-commonjs/components/Field/useField.js +40 -74
- package/lib-commonjs/components/Field/useField.js.map +1 -1
- package/lib-commonjs/components/Field/useFieldStyles.js +48 -71
- package/lib-commonjs/components/Field/useFieldStyles.js.map +1 -1
- package/lib-commonjs/index.js +23 -3
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/util/makeDeprecatedField.js +79 -0
- package/lib-commonjs/util/makeDeprecatedField.js.map +1 -0
- package/package.json +5 -4
- package/lib/components/Field/SlotComponent.types.js +0 -2
- package/lib/components/Field/SlotComponent.types.js.map +0 -1
- package/lib-amd/components/Field/SlotComponent.types.js +0 -5
- package/lib-amd/components/Field/SlotComponent.types.js.map +0 -1
- package/lib-commonjs/components/Field/SlotComponent.types.js +0 -6
- package/lib-commonjs/components/Field/SlotComponent.types.js.map +0 -1
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.useField_unstable =
|
6
|
+
exports.useField_unstable = void 0;
|
7
7
|
const React = /*#__PURE__*/require("react");
|
8
8
|
const react_icons_1 = /*#__PURE__*/require("@fluentui/react-icons");
|
9
9
|
const react_label_1 = /*#__PURE__*/require("@fluentui/react-label");
|
@@ -13,38 +13,6 @@ const validationMessageIcons = {
|
|
13
13
|
warning: /*#__PURE__*/React.createElement(react_icons_1.Warning12Filled, null),
|
14
14
|
success: /*#__PURE__*/React.createElement(react_icons_1.CheckmarkCircle12Filled, null)
|
15
15
|
};
|
16
|
-
/**
|
17
|
-
* Partition the props used by the Field itself, from the props that are passed to the underlying field component.
|
18
|
-
*/
|
19
|
-
const getPartitionedFieldProps = props => {
|
20
|
-
const {
|
21
|
-
className,
|
22
|
-
control,
|
23
|
-
hint,
|
24
|
-
label,
|
25
|
-
orientation,
|
26
|
-
root,
|
27
|
-
style,
|
28
|
-
validationMessage,
|
29
|
-
validationMessageIcon,
|
30
|
-
validationState,
|
31
|
-
...restOfProps
|
32
|
-
} = props;
|
33
|
-
const fieldProps = {
|
34
|
-
className,
|
35
|
-
control,
|
36
|
-
hint,
|
37
|
-
label,
|
38
|
-
orientation,
|
39
|
-
root,
|
40
|
-
style,
|
41
|
-
validationMessage,
|
42
|
-
validationMessageIcon,
|
43
|
-
validationState
|
44
|
-
};
|
45
|
-
return [fieldProps, restOfProps];
|
46
|
-
};
|
47
|
-
exports.getPartitionedFieldProps = getPartitionedFieldProps;
|
48
16
|
/**
|
49
17
|
* Create the state required to render Field.
|
50
18
|
*
|
@@ -52,53 +20,58 @@ exports.getPartitionedFieldProps = getPartitionedFieldProps;
|
|
52
20
|
* before being passed to renderField_unstable.
|
53
21
|
*
|
54
22
|
* @param props - Props passed to this field
|
55
|
-
* @param ref - Ref to the
|
56
|
-
* @param params - Configuration parameters for this Field
|
23
|
+
* @param ref - Ref to the root
|
57
24
|
*/
|
58
|
-
const useField_unstable = (props, ref
|
59
|
-
var _a, _b, _c;
|
60
|
-
const [fieldProps, controlProps] = exports.getPartitionedFieldProps(props);
|
25
|
+
const useField_unstable = (props, ref) => {
|
26
|
+
var _a, _b, _c, _d;
|
61
27
|
const {
|
28
|
+
children,
|
62
29
|
orientation = 'vertical',
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
ariaInvalidOnError = true
|
68
|
-
} = params;
|
30
|
+
required,
|
31
|
+
validationState,
|
32
|
+
size
|
33
|
+
} = props;
|
69
34
|
const baseId = react_utilities_1.useId('field-');
|
70
|
-
const root = react_utilities_1.
|
71
|
-
|
72
|
-
|
73
|
-
});
|
74
|
-
const label = react_utilities_1.resolveShorthand(
|
35
|
+
const root = react_utilities_1.getNativeElementProps('div', {
|
36
|
+
...props,
|
37
|
+
ref
|
38
|
+
}, /*excludedPropNames:*/['children']);
|
39
|
+
const label = react_utilities_1.resolveShorthand(props.label, {
|
75
40
|
defaultProps: {
|
76
41
|
id: baseId + '__label',
|
77
|
-
required
|
78
|
-
size
|
42
|
+
required,
|
43
|
+
size
|
79
44
|
// htmlFor is handled below
|
80
45
|
}
|
81
46
|
});
|
82
47
|
|
83
|
-
const validationMessage = react_utilities_1.resolveShorthand(
|
48
|
+
const validationMessage = react_utilities_1.resolveShorthand(props.validationMessage, {
|
84
49
|
defaultProps: {
|
85
|
-
id: baseId + '__validationMessage'
|
50
|
+
id: baseId + '__validationMessage',
|
51
|
+
role: validationState === 'error' ? 'alert' : undefined
|
86
52
|
}
|
87
53
|
});
|
88
|
-
const hint = react_utilities_1.resolveShorthand(
|
54
|
+
const hint = react_utilities_1.resolveShorthand(props.hint, {
|
89
55
|
defaultProps: {
|
90
56
|
id: baseId + '__hint'
|
91
57
|
}
|
92
58
|
});
|
93
|
-
const validationMessageIcon = react_utilities_1.resolveShorthand(
|
59
|
+
const validationMessageIcon = react_utilities_1.resolveShorthand(props.validationMessageIcon, {
|
94
60
|
required: !!validationState,
|
95
61
|
defaultProps: {
|
96
62
|
children: validationState ? validationMessageIcons[validationState] : undefined
|
97
63
|
}
|
98
64
|
});
|
99
|
-
|
100
|
-
|
65
|
+
const controlProps = React.isValidElement(children) ? {
|
66
|
+
...children.props
|
67
|
+
} : {};
|
68
|
+
if (label) {
|
101
69
|
(_a = controlProps['aria-labelledby']) !== null && _a !== void 0 ? _a : controlProps['aria-labelledby'] = label.id;
|
70
|
+
if (!label.htmlFor) {
|
71
|
+
// Assign the child a generated ID if doesn't already have an ID
|
72
|
+
(_b = controlProps.id) !== null && _b !== void 0 ? _b : controlProps.id = baseId + '__control';
|
73
|
+
label.htmlFor = controlProps.id;
|
74
|
+
}
|
102
75
|
}
|
103
76
|
if (validationMessage || hint) {
|
104
77
|
// The control is described by the validation message, or hint, or both
|
@@ -106,40 +79,33 @@ const useField_unstable = (props, ref, params) => {
|
|
106
79
|
// For reference: https://github.com/microsoft/fluentui/pull/25580#discussion_r1017259933
|
107
80
|
controlProps['aria-describedby'] = [validationMessage === null || validationMessage === void 0 ? void 0 : validationMessage.id, hint === null || hint === void 0 ? void 0 : hint.id, controlProps['aria-describedby']].filter(Boolean).join(' ');
|
108
81
|
}
|
109
|
-
if (validationState === 'error'
|
110
|
-
(
|
82
|
+
if (validationState === 'error') {
|
83
|
+
(_c = controlProps['aria-invalid']) !== null && _c !== void 0 ? _c : controlProps['aria-invalid'] = true;
|
111
84
|
}
|
112
|
-
|
113
|
-
required: true
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
});
|
120
|
-
if (label && labelConnection === 'htmlFor') {
|
121
|
-
(_c = label.htmlFor) !== null && _c !== void 0 ? _c : label.htmlFor = control.id;
|
85
|
+
if (required) {
|
86
|
+
(_d = controlProps['aria-required']) !== null && _d !== void 0 ? _d : controlProps['aria-required'] = true;
|
87
|
+
}
|
88
|
+
if (React.isValidElement(children)) {
|
89
|
+
root.children = React.cloneElement(children, controlProps);
|
90
|
+
} else if (typeof children === 'function') {
|
91
|
+
root.children = children(controlProps);
|
122
92
|
}
|
123
|
-
|
93
|
+
return {
|
124
94
|
orientation,
|
125
95
|
validationState,
|
126
|
-
classNames: params.classNames,
|
127
96
|
components: {
|
128
97
|
root: 'div',
|
129
|
-
control: params.component,
|
130
98
|
label: react_label_1.Label,
|
131
99
|
validationMessage: 'div',
|
132
100
|
validationMessageIcon: 'span',
|
133
101
|
hint: 'div'
|
134
102
|
},
|
135
103
|
root,
|
136
|
-
control,
|
137
104
|
label,
|
138
105
|
validationMessageIcon,
|
139
106
|
validationMessage,
|
140
107
|
hint
|
141
108
|
};
|
142
|
-
return state;
|
143
109
|
};
|
144
110
|
exports.useField_unstable = useField_unstable;
|
145
111
|
//# sourceMappingURL=useField.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"mappings":";;;;;;AAAA;
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AAEA;AACA;AACA;AAGA,MAAMA,sBAAsB,GAAG;EAC7BC,KAAK,eAAEC,oBAACC,iCAAmB,OAAG;EAC9BC,OAAO,eAAEF,oBAACC,6BAAe,OAAG;EAC5BE,OAAO,eAAEH,oBAACC,qCAAuB;CACzB;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P;IACDP,IAAI;IACJC,KAAK;IACLO,qBAAqB;IACrBJ,iBAAiB;IACjBG;GACD;AACH,CAAC;AAvFYW,yBAAiB","names":["validationMessageIcons","error","React","react_icons_1","warning","success","useField_unstable","props","ref","children","orientation","required","validationState","size","baseId","react_utilities_1","root","label","defaultProps","id","validationMessage","role","undefined","hint","validationMessageIcon","controlProps","isValidElement","htmlFor","filter","Boolean","join","cloneElement","components","react_label_1","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-field/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 { FieldChildProps, FieldProps, FieldState } from './Field.types';\n\nconst validationMessageIcons = {\n error: <ErrorCircle12Filled />,\n warning: <Warning12Filled />,\n success: <CheckmarkCircle12Filled />,\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 { children, orientation = 'vertical', required, validationState, size } = props;\n\n const baseId = useId('field-');\n\n const root = getNativeElementProps('div', { ...props, ref }, /*excludedPropNames:*/ ['children']);\n\n const label = resolveShorthand(props.label, {\n defaultProps: {\n id: baseId + '__label',\n required,\n size,\n // htmlFor is handled below\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 validationMessageIcon = resolveShorthand(props.validationMessageIcon, {\n required: !!validationState,\n defaultProps: {\n children: validationState ? validationMessageIcons[validationState] : undefined,\n },\n });\n\n const controlProps: FieldChildProps = React.isValidElement(children) ? { ...children.props } : {};\n\n if (label) {\n controlProps['aria-labelledby'] ??= label.id;\n\n if (!label.htmlFor) {\n // Assign the child a generated ID if doesn't already have an ID\n controlProps.id ??= baseId + '__control';\n label.htmlFor = controlProps.id;\n }\n }\n\n if (validationMessage || hint) {\n // The control is described by the validation message, or hint, or both\n // We also preserve and append any aria-describedby supplied by the user\n // For reference: https://github.com/microsoft/fluentui/pull/25580#discussion_r1017259933\n controlProps['aria-describedby'] = [validationMessage?.id, hint?.id, controlProps['aria-describedby']]\n .filter(Boolean)\n .join(' ');\n }\n\n if (validationState === 'error') {\n controlProps['aria-invalid'] ??= true;\n }\n\n if (required) {\n controlProps['aria-required'] ??= true;\n }\n\n if (React.isValidElement(children)) {\n root.children = React.cloneElement(children, controlProps);\n } else if (typeof children === 'function') {\n root.children = children(controlProps);\n }\n\n return {\n orientation,\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"]}
|
@@ -3,95 +3,72 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.useFieldStyles_unstable = exports.
|
6
|
+
exports.useFieldStyles_unstable = exports.fieldClassNames = void 0;
|
7
7
|
const react_theme_1 = /*#__PURE__*/require("@fluentui/react-theme");
|
8
8
|
const react_1 = /*#__PURE__*/require("@griffel/react");
|
9
|
-
|
10
|
-
root: `fui
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
9
|
+
exports.fieldClassNames = {
|
10
|
+
root: `fui-Field`,
|
11
|
+
label: `fui-Field__label`,
|
12
|
+
validationMessage: `fui-Field__validationMessage`,
|
13
|
+
validationMessageIcon: `fui-Field__validationMessageIcon`,
|
14
|
+
hint: `fui-Field__hint`
|
15
|
+
};
|
16
|
+
// Size of the icon in the validation message
|
17
|
+
const iconSize = '12px';
|
18
18
|
/**
|
19
19
|
* Styles for the root slot
|
20
20
|
*/
|
21
21
|
const useRootStyles = /*#__PURE__*/react_1.__styles({
|
22
22
|
base: {
|
23
|
-
mc9l5x: "f13qh94s"
|
24
|
-
Bxotwcr: "f14np9u9",
|
25
|
-
Budl1dq: "fjxzuw",
|
26
|
-
zoa1oz: "f6nraym",
|
27
|
-
B7hvi0a: "f1m2n5bn"
|
23
|
+
mc9l5x: "f13qh94s"
|
28
24
|
},
|
29
25
|
horizontal: {
|
30
|
-
Budl1dq: "
|
31
|
-
|
32
|
-
},
|
33
|
-
label: {
|
34
|
-
Br312pm: "f150pcdf",
|
35
|
-
Bw0ie65: "fwm4whi",
|
36
|
-
Ijaq50: "f1tty21m",
|
37
|
-
nk6f5a: "f19648ye"
|
38
|
-
},
|
39
|
-
control: {
|
40
|
-
Br312pm: "f1bfa6ju",
|
41
|
-
Bw0ie65: "fl3lap4"
|
26
|
+
Budl1dq: "f2wwaib",
|
27
|
+
wkccdc: "f1645dqt"
|
42
28
|
},
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
},
|
47
|
-
validationMessage: {
|
48
|
-
Br312pm: "f1n69xcw",
|
49
|
-
Bw0ie65: "f1hw1m5m"
|
50
|
-
},
|
51
|
-
hint: {
|
52
|
-
Br312pm: "fbug73u",
|
53
|
-
Bw0ie65: "fbtgo1w"
|
29
|
+
horizontalNoLabel: {
|
30
|
+
uwmqm3: ["f15jqgz8", "fggqkej"],
|
31
|
+
Budl1dq: "f1c2z91y"
|
54
32
|
}
|
55
33
|
}, {
|
56
|
-
d: [".f13qh94s{display:grid;}", ".
|
34
|
+
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;}"]
|
57
35
|
});
|
58
36
|
const useLabelStyles = /*#__PURE__*/react_1.__styles({
|
59
37
|
base: {
|
60
|
-
|
38
|
+
z8tnut: "fclwglc",
|
39
|
+
Byoj8tv: "fywfov9"
|
40
|
+
},
|
41
|
+
large: {
|
42
|
+
z8tnut: "f1sl3k7w",
|
43
|
+
Byoj8tv: "f1brlhvm"
|
44
|
+
},
|
45
|
+
vertical: {
|
61
46
|
jrapky: "fyacil5"
|
62
47
|
},
|
48
|
+
verticalLarge: {
|
49
|
+
jrapky: "f8l5zjj"
|
50
|
+
},
|
63
51
|
horizontal: {
|
64
52
|
t21cq0: ["fkujibs", "f199hnxi"],
|
65
|
-
|
66
|
-
|
53
|
+
Ijaq50: "f16hsg94",
|
54
|
+
nk6f5a: "f1nzqi2z"
|
67
55
|
}
|
68
56
|
}, {
|
69
|
-
d: [".
|
57
|
+
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;}"]
|
70
58
|
});
|
59
|
+
const useSecondaryTextBaseClassName = /*#__PURE__*/react_1.__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);}"]);
|
71
60
|
const useSecondaryTextStyles = /*#__PURE__*/react_1.__styles({
|
72
|
-
base: {
|
73
|
-
B6of3ja: "fg30ohd",
|
74
|
-
sj55zd: "f11d4kpn",
|
75
|
-
Bahqtrf: "fk6fouc",
|
76
|
-
Be2twd7: "fy9rknc",
|
77
|
-
Bhrd7zp: "figsok6",
|
78
|
-
Bg96gwp: "fwrc4pm"
|
79
|
-
},
|
80
61
|
error: {
|
81
62
|
sj55zd: "f1hcrxcs"
|
63
|
+
},
|
64
|
+
withIcon: {
|
65
|
+
uwmqm3: ["frawy03", "fg4c52"]
|
82
66
|
}
|
83
67
|
}, {
|
84
|
-
d: [".
|
68
|
+
d: [".f1hcrxcs{color:var(--colorPaletteRedForeground1);}", ".frawy03{padding-left:calc(12px + var(--spacingHorizontalXS));}", ".fg4c52{padding-right:calc(12px + var(--spacingHorizontalXS));}"]
|
85
69
|
});
|
70
|
+
const useValidationMessageIconBaseClassName = /*#__PURE__*/react_1.__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;}"]);
|
86
71
|
const useValidationMessageIconStyles = /*#__PURE__*/react_1.__styles({
|
87
|
-
base: {
|
88
|
-
mc9l5x: "ftgm304",
|
89
|
-
qb2dma: "f9h729m",
|
90
|
-
Be2twd7: "f1ugzwwg",
|
91
|
-
Bg96gwp: "fp4gqsa",
|
92
|
-
t21cq0: ["fm0x6gh", "fbyavb5"],
|
93
|
-
B6of3ja: "fww94b8"
|
94
|
-
},
|
95
72
|
error: {
|
96
73
|
sj55zd: "f1hcrxcs"
|
97
74
|
},
|
@@ -102,34 +79,34 @@ const useValidationMessageIconStyles = /*#__PURE__*/react_1.__styles({
|
|
102
79
|
sj55zd: "ffmvakt"
|
103
80
|
}
|
104
81
|
}, {
|
105
|
-
d: [".
|
82
|
+
d: [".f1hcrxcs{color:var(--colorPaletteRedForeground1);}", ".f1k5f75o{color:var(--colorPaletteDarkOrangeForeground1);}", ".ffmvakt{color:var(--colorPaletteGreenForeground1);}"]
|
106
83
|
});
|
107
84
|
/**
|
108
85
|
* Apply styling to the Field slots based on the state
|
109
86
|
*/
|
110
87
|
const useFieldStyles_unstable = state => {
|
111
|
-
const
|
112
|
-
|
88
|
+
const {
|
89
|
+
validationState
|
90
|
+
} = state;
|
113
91
|
const horizontal = state.orientation === 'horizontal';
|
114
92
|
const rootStyles = useRootStyles();
|
115
|
-
state.root.className = react_1.mergeClasses(
|
116
|
-
if (state.control) {
|
117
|
-
state.control.className = react_1.mergeClasses(classNames.control, rootStyles.control, state.control.className);
|
118
|
-
}
|
93
|
+
state.root.className = react_1.mergeClasses(exports.fieldClassNames.root, rootStyles.base, horizontal && rootStyles.horizontal, horizontal && !state.label && rootStyles.horizontalNoLabel, state.root.className);
|
119
94
|
const labelStyles = useLabelStyles();
|
120
95
|
if (state.label) {
|
121
|
-
state.label.className = react_1.mergeClasses(
|
96
|
+
state.label.className = react_1.mergeClasses(exports.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);
|
122
97
|
}
|
98
|
+
const validationMessageIconBaseClassName = useValidationMessageIconBaseClassName();
|
123
99
|
const validationMessageIconStyles = useValidationMessageIconStyles();
|
124
100
|
if (state.validationMessageIcon) {
|
125
|
-
state.validationMessageIcon.className = react_1.mergeClasses(
|
101
|
+
state.validationMessageIcon.className = react_1.mergeClasses(exports.fieldClassNames.validationMessageIcon, validationMessageIconBaseClassName, !!validationState && validationMessageIconStyles[validationState], state.validationMessageIcon.className);
|
126
102
|
}
|
103
|
+
const secondaryTextBaseClassName = useSecondaryTextBaseClassName();
|
127
104
|
const secondaryTextStyles = useSecondaryTextStyles();
|
128
105
|
if (state.validationMessage) {
|
129
|
-
state.validationMessage.className = react_1.mergeClasses(
|
106
|
+
state.validationMessage.className = react_1.mergeClasses(exports.fieldClassNames.validationMessage, secondaryTextBaseClassName, validationState === 'error' && secondaryTextStyles.error, !!state.validationMessageIcon && secondaryTextStyles.withIcon, state.validationMessage.className);
|
130
107
|
}
|
131
108
|
if (state.hint) {
|
132
|
-
state.hint.className = react_1.mergeClasses(
|
109
|
+
state.hint.className = react_1.mergeClasses(exports.fieldClassNames.hint, secondaryTextBaseClassName, state.hint.className);
|
133
110
|
}
|
134
111
|
};
|
135
112
|
exports.useFieldStyles_unstable = useFieldStyles_unstable;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"mappings":";;;;;;AAAA;AAEA;
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AAEA;AAGaA,uBAAe,GAA+B;EACzDC,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE,kBAAkB;EACzBC,iBAAiB,EAAE,8BAA8B;EACjDC,qBAAqB,EAAE,kCAAkC;EACzDC,IAAI,EAAE;CACP;AAED;AACA,MAAMC,QAAQ,GAAG,MAAM;AAEvB;;;AAGA,MAAMC,aAAa,gBAAGC,gBAAU;EAAA;IAAA;EAAA;EAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;EAAA;AAAA;EAAA;AAAA,EAkB9B;AAEF,MAAMC,cAAc,gBAAGD,gBAAU;EAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;EAAA;AAAA;EAAA;AAAA,EAwB/B;AAEF,MAAME,6BAA6B,gBAAGF,qBAAe,wPAInD;AAEF,MAAMG,sBAAsB,gBAAGH,gBAAU;EAAA;IAAA;EAAA;EAAA;IAAA;EAAA;AAAA;EAAA;AAAA,EASvC;AAEF,MAAMI,qCAAqC,gBAAGJ,qBAAe,4XAU3D;AAEF,MAAMK,8BAA8B,gBAAGL,gBAAU;EAAA;IAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;EAAA;AAAA;EAAA;AAAA,EAU/C;AAEF;;;AAGO,MAAM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AAqB,CAACgB,SAAS,CACtC;;EAGH,MAAMU,0BAA0B,GAAGpB,6BAA6B,EAAE;EAClE,MAAMqB,mBAAmB,GAAGpB,sBAAsB,EAAE;EACpD,IAAII,KAAK,CAACZ,iBAAiB,EAAE;IAC3BY,KAAK,CAACZ,iBAAiB,CAACiB,SAAS,GAAGZ,oBAAY,CAC9CR,uBAAe,CAACG,iBAAiB,EACjC2B,0BAA0B,EAC1Bd,eAAe,KAAK,OAAO,IAAIe,mBAAmB,CAACC,KAAK,EACxD,CAAC,CAACjB,KAAK,CAACX,qBAAqB,IAAI2B,mBAAmB,CAACE,QAAQ,EAC7DlB,KAAK,CAACZ,iBAAiB,CAACiB,SAAS,CAClC;;EAGH,IAAIL,KAAK,CAACV,IAAI,EAAE;IACdU,KAAK,CAACV,IAAI,CAACe,SAAS,GAAGZ,oBAAY,CAACR,uBAAe,CAACK,IAAI,EAAEyB,0BAA0B,EAAEf,KAAK,CAACV,IAAI,CAACe,SAAS,CAAC;;AAE/G,CAAC;AApDYpB,+BAAuB","names":["exports","root","label","validationMessage","validationMessageIcon","hint","iconSize","useRootStyles","react_1","useLabelStyles","useSecondaryTextBaseClassName","useSecondaryTextStyles","useValidationMessageIconBaseClassName","useValidationMessageIconStyles","useFieldStyles_unstable","state","validationState","horizontal","orientation","rootStyles","className","base","horizontalNoLabel","labelStyles","vertical","size","large","verticalLarge","validationMessageIconBaseClassName","validationMessageIconStyles","secondaryTextBaseClassName","secondaryTextStyles","error","withIcon"],"sourceRoot":"../src/","sources":["packages/react-components/react-field/src/components/Field/useFieldStyles.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 && 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"]}
|
package/lib-commonjs/index.js
CHANGED
@@ -3,12 +3,18 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.useField_unstable = exports.useFieldStyles_unstable = exports.renderField_unstable = exports.
|
6
|
+
exports.makeDeprecatedField = exports.getDeprecatedFieldClassNames = exports.useField_unstable = exports.useFieldStyles_unstable = exports.renderField_unstable = exports.fieldClassNames = exports.Field = void 0;
|
7
7
|
var Field_1 = /*#__PURE__*/require("./Field");
|
8
|
-
Object.defineProperty(exports, "
|
8
|
+
Object.defineProperty(exports, "Field", {
|
9
9
|
enumerable: true,
|
10
10
|
get: function () {
|
11
|
-
return Field_1.
|
11
|
+
return Field_1.Field;
|
12
|
+
}
|
13
|
+
});
|
14
|
+
Object.defineProperty(exports, "fieldClassNames", {
|
15
|
+
enumerable: true,
|
16
|
+
get: function () {
|
17
|
+
return Field_1.fieldClassNames;
|
12
18
|
}
|
13
19
|
});
|
14
20
|
Object.defineProperty(exports, "renderField_unstable", {
|
@@ -29,4 +35,18 @@ Object.defineProperty(exports, "useField_unstable", {
|
|
29
35
|
return Field_1.useField_unstable;
|
30
36
|
}
|
31
37
|
});
|
38
|
+
// eslint-disable-next-line deprecation/deprecation
|
39
|
+
var makeDeprecatedField_1 = /*#__PURE__*/require("./util/makeDeprecatedField");
|
40
|
+
Object.defineProperty(exports, "getDeprecatedFieldClassNames", {
|
41
|
+
enumerable: true,
|
42
|
+
get: function () {
|
43
|
+
return makeDeprecatedField_1.getDeprecatedFieldClassNames;
|
44
|
+
}
|
45
|
+
});
|
46
|
+
Object.defineProperty(exports, "makeDeprecatedField", {
|
47
|
+
enumerable: true,
|
48
|
+
get: function () {
|
49
|
+
return makeDeprecatedField_1.makeDeprecatedField;
|
50
|
+
}
|
51
|
+
});
|
32
52
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"mappings":";;;;;;AAAA;AAASA;EAAAC;EAAAC;IAAA,
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AAASA;EAAAC;EAAAC;IAAA,oBAAK;EAAA;AAAA;AAAEF;EAAAC;EAAAC;IAAA,8BAAe;EAAA;AAAA;AAAEF;EAAAC;EAAAC;IAAA,mCAAoB;EAAA;AAAA;AAAEF;EAAAC;EAAAC;IAAA,sCAAuB;EAAA;AAAA;AAAEF;EAAAC;EAAAC;IAAA,gCAAiB;EAAA;AAAA;AAGjG;AACA;AAASF;EAAAC;EAAAC;IAAA,yDAA4B;EAAA;AAAA;AAAEF;EAAAC;EAAAC;IAAA,gDAAmB;EAAA;AAAA","names":["Object","enumerable","get"],"sourceRoot":"../src/","sources":["packages/react-components/react-field/src/index.ts"],"sourcesContent":["export { Field, fieldClassNames, renderField_unstable, useFieldStyles_unstable, useField_unstable } from './Field';\nexport type { FieldProps, FieldSlots, FieldState } from './Field';\n\n// eslint-disable-next-line deprecation/deprecation\nexport { getDeprecatedFieldClassNames, makeDeprecatedField } from './util/makeDeprecatedField';\n// eslint-disable-next-line deprecation/deprecation\nexport type { DeprecatedFieldProps } from './util/makeDeprecatedField';\n"]}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.getDeprecatedFieldClassNames = exports.makeDeprecatedField = void 0;
|
7
|
+
/* eslint-disable deprecation/deprecation */
|
8
|
+
const React = /*#__PURE__*/require("react");
|
9
|
+
const Field_1 = /*#__PURE__*/require("../Field");
|
10
|
+
/**
|
11
|
+
* Partition the props used by the Field itself, from the props that are passed to the underlying field component.
|
12
|
+
*/
|
13
|
+
function getPartitionedFieldProps(props) {
|
14
|
+
const {
|
15
|
+
className,
|
16
|
+
control,
|
17
|
+
hint,
|
18
|
+
label,
|
19
|
+
orientation,
|
20
|
+
required,
|
21
|
+
root,
|
22
|
+
size,
|
23
|
+
style,
|
24
|
+
validationMessage,
|
25
|
+
validationMessageIcon,
|
26
|
+
validationState,
|
27
|
+
...restOfProps
|
28
|
+
} = props;
|
29
|
+
return [{
|
30
|
+
className,
|
31
|
+
hint,
|
32
|
+
label,
|
33
|
+
orientation,
|
34
|
+
required,
|
35
|
+
size,
|
36
|
+
style,
|
37
|
+
validationMessage,
|
38
|
+
validationMessageIcon,
|
39
|
+
validationState,
|
40
|
+
...root
|
41
|
+
}, {
|
42
|
+
required,
|
43
|
+
size,
|
44
|
+
...restOfProps,
|
45
|
+
...control
|
46
|
+
}];
|
47
|
+
}
|
48
|
+
/**
|
49
|
+
* @deprecated Only for use to make deprecated [Control]Field shim components.
|
50
|
+
* @internal
|
51
|
+
*/
|
52
|
+
function makeDeprecatedField(Control, options = {}) {
|
53
|
+
const {
|
54
|
+
mapProps = props => props,
|
55
|
+
displayName = `${Control.displayName}Field`
|
56
|
+
} = options;
|
57
|
+
const DeprecatedField = React.forwardRef((props, ref) => {
|
58
|
+
const [fieldProps, controlProps] = getPartitionedFieldProps(mapProps(props));
|
59
|
+
return React.createElement(Field_1.Field, {
|
60
|
+
...fieldProps
|
61
|
+
}, React.createElement(Control, {
|
62
|
+
...controlProps,
|
63
|
+
ref: ref
|
64
|
+
}));
|
65
|
+
});
|
66
|
+
DeprecatedField.displayName = displayName;
|
67
|
+
return DeprecatedField;
|
68
|
+
}
|
69
|
+
exports.makeDeprecatedField = makeDeprecatedField;
|
70
|
+
/**
|
71
|
+
* @deprecated Only for use to make deprecated [Control]Field shim components.
|
72
|
+
* @internal
|
73
|
+
*/
|
74
|
+
const getDeprecatedFieldClassNames = controlRootClassName => ({
|
75
|
+
...Field_1.fieldClassNames,
|
76
|
+
control: controlRootClassName
|
77
|
+
});
|
78
|
+
exports.getDeprecatedFieldClassNames = getDeprecatedFieldClassNames;
|
79
|
+
//# sourceMappingURL=makeDeprecatedField.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AAGA;AAqBA;;;AAGA,SAASA,wBAAwB,CAC/BC,KAAiF;EAEjF,MAAM;IACJC,SAAS;IACTC,OAAO;IACPC,IAAI;IACJC,KAAK;IACLC,WAAW;IACXC,QAAQ;IACRC,IAAI;IACJC,IAAI;IACJC,KAAK;IACLC,iBAAiB;IACjBC,qBAAqB;IACrBC,eAAe;IACf,GAAGC;EAAW,CACf,GAAGb,KAAK;EAET,OAAO,CACL;IACEC,SAAS;IACTE,IAAI;IACJC,KAAK;IACLC,WAAW;IACXC,QAAQ;IACRE,IAAI;IACJC,KAAK;IACLC,iBAAiB;IACjBC,qBAAqB;IACrBC,eAAe;IACf,GAAGL;GACJ,EACD;IACED,QAAQ;IACRE,IAAI;IACJ,GAAGK,WAAW;IACd,GAAGX;GACJ,CACF;AACH;AAEA;;;;AAIA,SAAgBY,mBAAmB,CACjCC,OAA0C,EAC1CC,UAGI,EAAE;EAEN,MAAM;IAAEC,QAAQ,GAAGjB,KAAK,IAAIA,KAAK;IAAEkB,WAAW,GAAG,GAAGH,OAAO,CAACG,WAAW;EAAO,CAAE,GAAGF,OAAO;EAE1F,MAAMG,eAAe,GAAGC,KAAK,CAACC,UAAU,CAAC,CAACrB,KAAK,EAAEsB,GAAG,KAAI;IACtD,MAAM,CAACC,UAAU,EAAEC,YAAY,CAAC,GAAGzB,wBAAwB,CAACkB,QAAQ,CAACjB,KAAK,CAAC,CAAC;IAC5E,OACEoB,oBAACK,aAAK;MAAA,GAAKF;IAAU,GAEnBH,oBAACL,OAAO;MAAA,GAAMS,YAAoB;MAAEF,GAAG,EAAEA;IAAU,EAAI,CACjD;EAEZ,CAAC,CAA4D;EAE7DH,eAAe,CAACD,WAAW,GAAGA,WAAW;EAEzC,OAAOC,eAAe;AACxB;AAtBAO;AAwBA;;;;AAIO,MAAMC,4BAA4B,GAAIC,oBAA4B,KAAM;EAC7E,GAAGH,uBAAe;EAClBvB,OAAO,EAAE0B;CACV,CAAC;AAHWF,oCAA4B","names":["getPartitionedFieldProps","props","className","control","hint","label","orientation","required","root","size","style","validationMessage","validationMessageIcon","validationState","restOfProps","makeDeprecatedField","Control","options","mapProps","displayName","DeprecatedField","React","forwardRef","ref","fieldProps","controlProps","Field_1","exports","getDeprecatedFieldClassNames","controlRootClassName"],"sourceRoot":"../src/","sources":["packages/react-components/react-field/src/util/makeDeprecatedField.tsx"],"sourcesContent":["/* eslint-disable deprecation/deprecation */\nimport * as React from 'react';\nimport { ForwardRefComponent } from '@fluentui/react-utilities';\nimport type { FieldProps } from '../Field';\nimport { Field, fieldClassNames } from '../Field';\n\n/**\n * @deprecated Only for use to make deprecated [Control]Field shim components.\n * @internal\n */\nexport type DeprecatedFieldProps<ControlProps> = ControlProps & {\n root?: FieldProps;\n control?: ControlProps;\n} & Pick<\n FieldProps,\n | 'className'\n | 'hint'\n | 'label'\n | 'orientation'\n | 'style'\n | 'validationMessage'\n | 'validationMessageIcon'\n | 'validationState'\n >;\n\n/**\n * Partition the props used by the Field itself, from the props that are passed to the underlying field component.\n */\nfunction getPartitionedFieldProps<ControlProps>(\n props: DeprecatedFieldProps<ControlProps> & Pick<FieldProps, 'required' | 'size'>,\n) {\n const {\n className,\n control,\n hint,\n label,\n orientation,\n required,\n root,\n size,\n style,\n validationMessage,\n validationMessageIcon,\n validationState,\n ...restOfProps\n } = props;\n\n return [\n {\n className,\n hint,\n label,\n orientation,\n required,\n size,\n style,\n validationMessage,\n validationMessageIcon,\n validationState,\n ...root,\n },\n {\n required,\n size,\n ...restOfProps,\n ...control,\n },\n ];\n}\n\n/**\n * @deprecated Only for use to make deprecated [Control]Field shim components.\n * @internal\n */\nexport function makeDeprecatedField<ControlProps>(\n Control: React.ComponentType<ControlProps>,\n options: {\n mapProps?: (props: DeprecatedFieldProps<ControlProps>) => DeprecatedFieldProps<ControlProps>;\n displayName?: string;\n } = {},\n) {\n const { mapProps = props => props, displayName = `${Control.displayName}Field` } = options;\n\n const DeprecatedField = React.forwardRef((props, ref) => {\n const [fieldProps, controlProps] = getPartitionedFieldProps(mapProps(props));\n return (\n <Field {...fieldProps}>\n {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}\n <Control {...(controlProps as any)} ref={ref as any} />\n </Field>\n );\n }) as ForwardRefComponent<DeprecatedFieldProps<ControlProps>>;\n\n DeprecatedField.displayName = displayName;\n\n return DeprecatedField;\n}\n\n/**\n * @deprecated Only for use to make deprecated [Control]Field shim components.\n * @internal\n */\nexport const getDeprecatedFieldClassNames = (controlRootClassName: string) => ({\n ...fieldClassNames,\n control: controlRootClassName,\n});\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-field",
|
3
|
-
"version": "9.0.0-alpha.
|
3
|
+
"version": "9.0.0-alpha.17",
|
4
4
|
"description": "Fluent UI Field components",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -13,6 +13,7 @@
|
|
13
13
|
"license": "MIT",
|
14
14
|
"scripts": {
|
15
15
|
"build": "just-scripts build",
|
16
|
+
"bundle-size": "bundle-size measure",
|
16
17
|
"clean": "just-scripts clean",
|
17
18
|
"code-style": "just-scripts code-style",
|
18
19
|
"just": "just-scripts",
|
@@ -31,11 +32,11 @@
|
|
31
32
|
"@fluentui/scripts-tasks": "*"
|
32
33
|
},
|
33
34
|
"dependencies": {
|
34
|
-
"@fluentui/react-context-selector": "^9.1.
|
35
|
+
"@fluentui/react-context-selector": "^9.1.6",
|
35
36
|
"@fluentui/react-icons": "^2.0.175",
|
36
|
-
"@fluentui/react-label": "^9.0.
|
37
|
+
"@fluentui/react-label": "^9.0.18",
|
37
38
|
"@fluentui/react-theme": "^9.1.5",
|
38
|
-
"@fluentui/react-utilities": "^9.
|
39
|
+
"@fluentui/react-utilities": "^9.5.0",
|
39
40
|
"@griffel/react": "^1.5.2",
|
40
41
|
"tslib": "^2.1.0"
|
41
42
|
},
|