@fluentui/react-field 9.0.0-alpha.8 → 9.0.0-beta.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.swcrc +30 -0
- package/CHANGELOG.json +668 -1
- package/CHANGELOG.md +241 -2
- package/README.md +66 -1
- package/dist/index.d.ts +153 -80
- package/lib/Field.js.map +1 -1
- package/lib/components/Field/Field.js +13 -0
- package/lib/components/Field/Field.js.map +1 -0
- package/lib/components/Field/Field.types.js +1 -1
- 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 +11 -9
- package/lib/components/Field/renderField.js.map +1 -1
- package/lib/components/Field/useField.js +32 -98
- package/lib/components/Field/useField.js.map +1 -1
- package/lib/components/Field/useFieldStyles.js +61 -76
- package/lib/components/Field/useFieldStyles.js.map +1 -1
- 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 +4 -1
- package/lib/index.js.map +1 -1
- package/lib/util/makeDeprecatedField.js +68 -0
- package/lib/util/makeDeprecatedField.js.map +1 -0
- package/lib-commonjs/Field.js +4 -5
- package/lib-commonjs/Field.js.map +1 -1
- package/lib-commonjs/components/Field/Field.js +23 -0
- package/lib-commonjs/components/Field/Field.js.map +1 -0
- package/lib-commonjs/components/Field/Field.types.js +5 -2
- package/lib-commonjs/components/Field/Field.types.js.map +1 -1
- package/lib-commonjs/components/Field/index.js +8 -11
- package/lib-commonjs/components/Field/index.js.map +1 -1
- package/lib-commonjs/components/Field/renderField.js +19 -26
- package/lib-commonjs/components/Field/renderField.js.map +1 -1
- package/lib-commonjs/components/Field/useField.js +71 -155
- package/lib-commonjs/components/Field/useField.js.map +1 -1
- package/lib-commonjs/components/Field/useFieldStyles.js +138 -118
- package/lib-commonjs/components/Field/useFieldStyles.js.map +1 -1
- package/lib-commonjs/contexts/FieldContext.js +21 -0
- package/lib-commonjs/contexts/FieldContext.js.map +1 -0
- package/lib-commonjs/contexts/index.js +11 -0
- package/lib-commonjs/contexts/index.js.map +1 -0
- package/lib-commonjs/contexts/useFieldContextValues.js +44 -0
- package/lib-commonjs/contexts/useFieldContextValues.js.map +1 -0
- package/lib-commonjs/contexts/useFieldControlProps.js +71 -0
- package/lib-commonjs/contexts/useFieldControlProps.js.map +1 -0
- package/lib-commonjs/index.js +24 -29
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/util/makeDeprecatedField.js +61 -0
- package/lib-commonjs/util/makeDeprecatedField.js.map +1 -0
- package/package.json +15 -13
- package/Spec.md +0 -354
- package/lib/components/Field/SlotComponent.types.js +0 -2
- package/lib/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
@@ -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
CHANGED
@@ -1,2 +1,5 @@
|
|
1
|
-
export {
|
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
|
+
// eslint-disable-next-line deprecation/deprecation
|
4
|
+
export { getDeprecatedFieldClassNames, makeDeprecatedField } from './util/makeDeprecatedField';
|
2
5
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["Field","fieldClassNames","renderField_unstable","useFieldStyles_unstable","useField_unstable","FieldContextProvider","useFieldContext_unstable","useFieldContextValues_unstable","useFieldControlProps_unstable","getDeprecatedFieldClassNames","makeDeprecatedField"],"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\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"],"mappings":"AAAA,SAASA,KAAK,EAAEC,eAAe,EAAEC,oBAAoB,EAAEC,uBAAuB,EAAEC,iBAAiB,QAAQ;AASzG,SACEC,oBAAoB,EACpBC,wBAAwB,EACxBC,8BAA8B,EAC9BC,6BAA6B,QACxB;AAGP;AACA,SAASC,4BAA4B,EAAEC,mBAAmB,QAAQ"}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
/* eslint-disable deprecation/deprecation */import * as React from 'react';
|
2
|
+
import { Field, fieldClassNames } from '../Field';
|
3
|
+
/**
|
4
|
+
* Partition the props used by the Field itself, from the props that are passed to the underlying field component.
|
5
|
+
*/
|
6
|
+
function getPartitionedFieldProps(props) {
|
7
|
+
const {
|
8
|
+
className,
|
9
|
+
control,
|
10
|
+
hint,
|
11
|
+
label,
|
12
|
+
orientation,
|
13
|
+
required,
|
14
|
+
root,
|
15
|
+
size,
|
16
|
+
style,
|
17
|
+
validationMessage,
|
18
|
+
validationMessageIcon,
|
19
|
+
validationState = 'none',
|
20
|
+
...restOfProps
|
21
|
+
} = props;
|
22
|
+
return [{
|
23
|
+
className,
|
24
|
+
hint,
|
25
|
+
label,
|
26
|
+
orientation,
|
27
|
+
required,
|
28
|
+
size,
|
29
|
+
style,
|
30
|
+
validationMessage,
|
31
|
+
validationMessageIcon,
|
32
|
+
validationState,
|
33
|
+
...root
|
34
|
+
}, {
|
35
|
+
required,
|
36
|
+
size,
|
37
|
+
...restOfProps,
|
38
|
+
...control
|
39
|
+
}];
|
40
|
+
}
|
41
|
+
/**
|
42
|
+
* @deprecated Only for use to make deprecated [Control]Field shim components.
|
43
|
+
* @internal
|
44
|
+
*/
|
45
|
+
export function makeDeprecatedField(Control, options = {}) {
|
46
|
+
const {
|
47
|
+
mapProps = props => props,
|
48
|
+
displayName = `${Control.displayName}Field`
|
49
|
+
} = options;
|
50
|
+
const DeprecatedField = /*#__PURE__*/React.forwardRef((props, ref) => {
|
51
|
+
const [fieldProps, controlProps] = getPartitionedFieldProps(mapProps(props));
|
52
|
+
return /*#__PURE__*/React.createElement(Field, fieldProps, /*#__PURE__*/React.createElement(Control, {
|
53
|
+
...controlProps,
|
54
|
+
ref: ref
|
55
|
+
}));
|
56
|
+
});
|
57
|
+
DeprecatedField.displayName = displayName;
|
58
|
+
return DeprecatedField;
|
59
|
+
}
|
60
|
+
/**
|
61
|
+
* @deprecated Only for use to make deprecated [Control]Field shim components.
|
62
|
+
* @internal
|
63
|
+
*/
|
64
|
+
export const getDeprecatedFieldClassNames = controlRootClassName => ({
|
65
|
+
...fieldClassNames,
|
66
|
+
control: controlRootClassName
|
67
|
+
});
|
68
|
+
//# sourceMappingURL=makeDeprecatedField.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["React","Field","fieldClassNames","getPartitionedFieldProps","props","className","control","hint","label","orientation","required","root","size","style","validationMessage","validationMessageIcon","validationState","restOfProps","makeDeprecatedField","Control","options","mapProps","displayName","DeprecatedField","forwardRef","ref","fieldProps","controlProps","createElement","getDeprecatedFieldClassNames","controlRootClassName"],"sources":["../../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 = 'none',\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"],"mappings":"AAAA,4CACA,YAAYA,KAAA,MAAW;AAGvB,SAASC,KAAK,EAAEC,eAAe,QAAQ;AAqBvC;;;AAGA,SAASC,yBACPC,KAAiF,EACjF;EACA,MAAM;IACJC,SAAA;IACAC,OAAA;IACAC,IAAA;IACAC,KAAA;IACAC,WAAA;IACAC,QAAA;IACAC,IAAA;IACAC,IAAA;IACAC,KAAA;IACAC,iBAAA;IACAC,qBAAA;IACAC,eAAA,GAAkB;IAClB,GAAGC;EAAA,CACJ,GAAGb,KAAA;EAEJ,OAAO,CACL;IACEC,SAAA;IACAE,IAAA;IACAC,KAAA;IACAC,WAAA;IACAC,QAAA;IACAE,IAAA;IACAC,KAAA;IACAC,iBAAA;IACAC,qBAAA;IACAC,eAAA;IACA,GAAGL;EACL,GACA;IACED,QAAA;IACAE,IAAA;IACA,GAAGK,WAAW;IACd,GAAGX;EACL,EACD;AACH;AAEA;;;;AAIA,OAAO,SAASY,oBACdC,OAA0C,EAC1CC,OAAA,GAGI,CAAC,CAAC,EACN;EACA,MAAM;IAAEC,QAAA,GAAWjB,KAAA,IAASA,KAAA;IAAOkB,WAAA,GAAe,GAAEH,OAAA,CAAQG,WAAY;EAAM,CAAE,GAAGF,OAAA;EAEnF,MAAMG,eAAA,gBAAkBvB,KAAA,CAAMwB,UAAU,CAAC,CAACpB,KAAA,EAAOqB,GAAA,KAAQ;IACvD,MAAM,CAACC,UAAA,EAAYC,YAAA,CAAa,GAAGxB,wBAAA,CAAyBkB,QAAA,CAASjB,KAAA;IACrE,oBACEJ,KAAA,CAAA4B,aAAA,CAAC3B,KAAA,EAAUyB,UAAA,eAET1B,KAAA,CAAA4B,aAAA,CAACT,OAAA;MAAS,GAAIQ,YAAY;MAAUF,GAAA,EAAKA;;EAG/C;EAEAF,eAAA,CAAgBD,WAAW,GAAGA,WAAA;EAE9B,OAAOC,eAAA;AACT;AAEA;;;;AAIA,OAAO,MAAMM,4BAAA,GAAgCC,oBAAA,KAAkC;EAC7E,GAAG5B,eAAe;EAClBI,OAAA,EAASwB;AACX"}
|
package/lib-commonjs/Field.js
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
5
4
|
});
|
5
|
+
const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
|
6
|
+
_exportStar(require("./components/Field/index"), exports);
|
7
|
+
//# sourceMappingURL=Field.js.map
|
6
8
|
|
7
|
-
const tslib_1 = /*#__PURE__*/require("tslib");
|
8
|
-
|
9
|
-
tslib_1.__exportStar(require("./components/Field/index"), exports);
|
10
9
|
//# sourceMappingURL=Field.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Field.
|
1
|
+
{"version":3,"sources":["../lib/Field.js"],"sourcesContent":["export * from './components/Field/index';\n//# sourceMappingURL=Field.js.map"],"names":[],"mappings":";;;;;oBAAc;CACd,iCAAiC"}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "Field", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>Field
|
8
|
+
});
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
11
|
+
const _renderField = require("./renderField");
|
12
|
+
const _useField = require("./useField");
|
13
|
+
const _useFieldStyles = require("./useFieldStyles");
|
14
|
+
const _index = require("../../contexts/index");
|
15
|
+
const Field = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
|
16
|
+
const state = (0, _useField.useField_unstable)(props, ref);
|
17
|
+
(0, _useFieldStyles.useFieldStyles_unstable)(state);
|
18
|
+
const context = (0, _index.useFieldContextValues_unstable)(state);
|
19
|
+
return (0, _renderField.renderField_unstable)(state, context);
|
20
|
+
});
|
21
|
+
Field.displayName = 'Field'; //# sourceMappingURL=Field.js.map
|
22
|
+
|
23
|
+
//# sourceMappingURL=Field.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../lib/components/Field/Field.js"],"sourcesContent":["import * as React from 'react';\nimport { renderField_unstable } from './renderField';\nimport { useField_unstable } from './useField';\nimport { useFieldStyles_unstable } from './useFieldStyles';\nimport { useFieldContextValues_unstable } from '../../contexts/index';\nexport const Field = /*#__PURE__*/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});\nField.displayName = 'Field';\n//# sourceMappingURL=Field.js.map"],"names":["Field","React","forwardRef","props","ref","state","useField_unstable","useFieldStyles_unstable","context","useFieldContextValues_unstable","renderField_unstable","displayName"],"mappings":";;;;+BAKaA;;aAAAA;;;6DALU;6BACc;0BACH;gCACM;uBACO;AACxC,MAAMA,QAAQ,WAAW,GAAEC,OAAMC,UAAU,CAAC,CAACC,OAAOC,MAAQ;IACjE,MAAMC,QAAQC,IAAAA,2BAAiB,EAACH,OAAOC;IACvCG,IAAAA,uCAAuB,EAACF;IACxB,MAAMG,UAAUC,IAAAA,qCAA8B,EAACJ;IAC/C,OAAOK,IAAAA,iCAAoB,EAACL,OAAOG;AACrC;AACAR,MAAMW,WAAW,GAAG,SACpB,iCAAiC"}
|
@@ -1,6 +1,9 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
5
4
|
});
|
5
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
6
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
7
|
+
//# sourceMappingURL=Field.types.js.map
|
8
|
+
|
6
9
|
//# sourceMappingURL=Field.types.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":[],"
|
1
|
+
{"version":3,"sources":["../../../lib/components/Field/Field.types.js"],"sourcesContent":["import * as React from 'react';\n//# sourceMappingURL=Field.types.js.map"],"names":[],"mappings":";;;;;6DAAuB;CACvB,uCAAuC"}
|
@@ -1,16 +1,13 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
5
4
|
});
|
5
|
+
const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
|
6
|
+
_exportStar(require("./Field.types"), exports);
|
7
|
+
_exportStar(require("./Field"), exports);
|
8
|
+
_exportStar(require("./renderField"), exports);
|
9
|
+
_exportStar(require("./useField"), exports);
|
10
|
+
_exportStar(require("./useFieldStyles"), exports);
|
11
|
+
//# sourceMappingURL=index.js.map
|
6
12
|
|
7
|
-
const tslib_1 = /*#__PURE__*/require("tslib");
|
8
|
-
|
9
|
-
tslib_1.__exportStar(require("./Field.types"), exports);
|
10
|
-
|
11
|
-
tslib_1.__exportStar(require("./renderField"), exports);
|
12
|
-
|
13
|
-
tslib_1.__exportStar(require("./useField"), exports);
|
14
|
-
|
15
|
-
tslib_1.__exportStar(require("./useFieldStyles"), exports);
|
16
13
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/Field/index.
|
1
|
+
{"version":3,"sources":["../../../lib/components/Field/index.js"],"sourcesContent":["export * from './Field.types';\nexport * from './Field';\nexport * from './renderField';\nexport * from './useField';\nexport * from './useFieldStyles';\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA;oBACA;oBACA;CACd,iCAAiC"}
|
@@ -1,31 +1,24 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
5
4
|
});
|
6
|
-
exports
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
const
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
}), slots.validationMessage && React.createElement(slots.validationMessage, { ...slotProps.validationMessage
|
25
|
-
}, slots.validationMessageIcon && React.createElement(slots.validationMessageIcon, { ...slotProps.validationMessageIcon
|
26
|
-
}), slotProps.validationMessage.children), slots.hint && React.createElement(slots.hint, { ...slotProps.hint
|
27
|
-
}));
|
28
|
-
};
|
5
|
+
Object.defineProperty(exports, "renderField_unstable", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>renderField_unstable
|
8
|
+
});
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
11
|
+
const _reactUtilities = require("@fluentui/react-utilities");
|
12
|
+
const _index = require("../../contexts/index");
|
13
|
+
const renderField_unstable = (state, contextValues)=>{
|
14
|
+
const { slots , slotProps } = (0, _reactUtilities.getSlots)(state);
|
15
|
+
let { children } = state;
|
16
|
+
if (typeof children === 'function') {
|
17
|
+
children = children((0, _index.getFieldControlProps)(contextValues === null || contextValues === void 0 ? void 0 : contextValues.field) || {});
|
18
|
+
}
|
19
|
+
return /*#__PURE__*/ _react.createElement(_index.FieldContextProvider, {
|
20
|
+
value: contextValues === null || contextValues === void 0 ? void 0 : contextValues.field
|
21
|
+
}, /*#__PURE__*/ _react.createElement(slots.root, slotProps.root, slots.label && /*#__PURE__*/ _react.createElement(slots.label, slotProps.label), children, slots.validationMessage && /*#__PURE__*/ _react.createElement(slots.validationMessage, slotProps.validationMessage, slots.validationMessageIcon && /*#__PURE__*/ _react.createElement(slots.validationMessageIcon, slotProps.validationMessageIcon), slotProps.validationMessage.children), slots.hint && /*#__PURE__*/ _react.createElement(slots.hint, slotProps.hint)));
|
22
|
+
}; //# sourceMappingURL=renderField.js.map
|
29
23
|
|
30
|
-
exports.renderField_unstable = renderField_unstable;
|
31
24
|
//# sourceMappingURL=renderField.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/Field/renderField.
|
1
|
+
{"version":3,"sources":["../../../lib/components/Field/renderField.js"],"sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport { FieldContextProvider, getFieldControlProps } from '../../contexts/index';\n/**\n * Render the final JSX of Field\n */\nexport const renderField_unstable = (state, contextValues) => {\n const {\n slots,\n slotProps\n } = getSlots(state);\n let {\n children\n } = state;\n if (typeof children === 'function') {\n children = children(getFieldControlProps(contextValues === null || contextValues === void 0 ? void 0 : contextValues.field) || {});\n }\n return /*#__PURE__*/React.createElement(FieldContextProvider, {\n value: contextValues === null || contextValues === void 0 ? void 0 : contextValues.field\n }, /*#__PURE__*/React.createElement(slots.root, slotProps.root, slots.label && /*#__PURE__*/React.createElement(slots.label, slotProps.label), children, slots.validationMessage && /*#__PURE__*/React.createElement(slots.validationMessage, slotProps.validationMessage, slots.validationMessageIcon && /*#__PURE__*/React.createElement(slots.validationMessageIcon, slotProps.validationMessageIcon), slotProps.validationMessage.children), slots.hint && /*#__PURE__*/React.createElement(slots.hint, slotProps.hint)));\n};\n//# sourceMappingURL=renderField.js.map"],"names":["renderField_unstable","state","contextValues","slots","slotProps","getSlots","children","getFieldControlProps","field","React","createElement","FieldContextProvider","value","root","label","validationMessage","validationMessageIcon","hint"],"mappings":";;;;+BAMaA;;aAAAA;;;6DANU;gCACE;uBACkC;AAIpD,MAAMA,uBAAuB,CAACC,OAAOC,gBAAkB;IAC5D,MAAM,EACJC,MAAK,EACLC,UAAS,EACV,GAAGC,IAAAA,wBAAQ,EAACJ;IACb,IAAI,EACFK,SAAQ,EACT,GAAGL;IACJ,IAAI,OAAOK,aAAa,YAAY;QAClCA,WAAWA,SAASC,IAAAA,2BAAoB,EAACL,kBAAkB,IAAI,IAAIA,kBAAkB,KAAK,IAAI,KAAK,IAAIA,cAAcM,KAAK,KAAK,CAAC;IAClI,CAAC;IACD,OAAO,WAAW,GAAEC,OAAMC,aAAa,CAACC,2BAAoB,EAAE;QAC5DC,OAAOV,kBAAkB,IAAI,IAAIA,kBAAkB,KAAK,IAAI,KAAK,IAAIA,cAAcM,KAAK;IAC1F,GAAG,WAAW,GAAEC,OAAMC,aAAa,CAACP,MAAMU,IAAI,EAAET,UAAUS,IAAI,EAAEV,MAAMW,KAAK,IAAI,WAAW,GAAEL,OAAMC,aAAa,CAACP,MAAMW,KAAK,EAAEV,UAAUU,KAAK,GAAGR,UAAUH,MAAMY,iBAAiB,IAAI,WAAW,GAAEN,OAAMC,aAAa,CAACP,MAAMY,iBAAiB,EAAEX,UAAUW,iBAAiB,EAAEZ,MAAMa,qBAAqB,IAAI,WAAW,GAAEP,OAAMC,aAAa,CAACP,MAAMa,qBAAqB,EAAEZ,UAAUY,qBAAqB,GAAGZ,UAAUW,iBAAiB,CAACT,QAAQ,GAAGH,MAAMc,IAAI,IAAI,WAAW,GAAER,OAAMC,aAAa,CAACP,MAAMc,IAAI,EAAEb,UAAUa,IAAI;AAC5f,GACA,uCAAuC"}
|
@@ -1,162 +1,78 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
5
4
|
});
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
const
|
11
|
-
|
12
|
-
const
|
13
|
-
|
14
|
-
const
|
15
|
-
|
5
|
+
Object.defineProperty(exports, "useField_unstable", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>useField_unstable
|
8
|
+
});
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
11
|
+
const _reactIcons = require("@fluentui/react-icons");
|
12
|
+
const _reactLabel = require("@fluentui/react-label");
|
13
|
+
const _reactUtilities = require("@fluentui/react-utilities");
|
16
14
|
const validationMessageIcons = {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
/**
|
22
|
-
* Partition the props used by the Field itself, from the props that are passed to the underlying field component.
|
23
|
-
*/
|
24
|
-
|
25
|
-
const getPartitionedFieldProps = props => {
|
26
|
-
const {
|
27
|
-
className,
|
28
|
-
control,
|
29
|
-
hint,
|
30
|
-
label,
|
31
|
-
orientation,
|
32
|
-
root,
|
33
|
-
style,
|
34
|
-
validationMessage,
|
35
|
-
validationMessageIcon,
|
36
|
-
validationState,
|
37
|
-
...restOfProps
|
38
|
-
} = props;
|
39
|
-
const fieldProps = {
|
40
|
-
className,
|
41
|
-
control,
|
42
|
-
hint,
|
43
|
-
label,
|
44
|
-
orientation,
|
45
|
-
root,
|
46
|
-
style,
|
47
|
-
validationMessage,
|
48
|
-
validationMessageIcon,
|
49
|
-
validationState
|
50
|
-
};
|
51
|
-
return [fieldProps, restOfProps];
|
52
|
-
};
|
53
|
-
|
54
|
-
exports.getPartitionedFieldProps = getPartitionedFieldProps;
|
55
|
-
/**
|
56
|
-
* Create the state required to render Field.
|
57
|
-
*
|
58
|
-
* The returned state can be modified with hooks such as useFieldStyles_unstable,
|
59
|
-
* before being passed to renderField_unstable.
|
60
|
-
*
|
61
|
-
* @param props - Props passed to this field
|
62
|
-
* @param ref - Ref to the control slot (primary slot)
|
63
|
-
* @param params - Configuration parameters for this Field
|
64
|
-
*/
|
65
|
-
|
66
|
-
const useField_unstable = (props, ref, params) => {
|
67
|
-
var _a, _b, _c, _d, _e;
|
68
|
-
|
69
|
-
const [fieldProps, controlProps] = exports.getPartitionedFieldProps(props);
|
70
|
-
const {
|
71
|
-
orientation = 'vertical',
|
72
|
-
validationState
|
73
|
-
} = fieldProps;
|
74
|
-
const {
|
75
|
-
labelConnection = 'htmlFor',
|
76
|
-
ariaInvalidOnError = true
|
77
|
-
} = params;
|
78
|
-
const baseId = react_utilities_1.useId('field-');
|
79
|
-
const root = react_utilities_1.resolveShorthand(fieldProps.root, {
|
80
|
-
required: true,
|
81
|
-
defaultProps: react_utilities_1.getNativeElementProps('div', fieldProps)
|
82
|
-
});
|
83
|
-
const control = react_utilities_1.resolveShorthand(fieldProps.control, {
|
84
|
-
required: true,
|
85
|
-
defaultProps: {
|
86
|
-
ref,
|
87
|
-
id: baseId + '__control',
|
88
|
-
...controlProps
|
89
|
-
}
|
90
|
-
});
|
91
|
-
const label = react_utilities_1.resolveShorthand(fieldProps.label, {
|
92
|
-
defaultProps: {
|
93
|
-
id: baseId + '__label',
|
94
|
-
required: controlProps.required,
|
95
|
-
size: typeof controlProps.size === 'string' ? controlProps.size : undefined,
|
96
|
-
htmlFor: labelConnection === 'htmlFor' ? control.id : undefined
|
97
|
-
}
|
98
|
-
});
|
99
|
-
const validationMessage = react_utilities_1.resolveShorthand(fieldProps.validationMessage, {
|
100
|
-
defaultProps: {
|
101
|
-
id: baseId + '__validationMessage'
|
102
|
-
}
|
103
|
-
});
|
104
|
-
const hint = react_utilities_1.resolveShorthand(fieldProps.hint, {
|
105
|
-
defaultProps: {
|
106
|
-
id: baseId + '__hint'
|
107
|
-
}
|
108
|
-
});
|
109
|
-
const validationMessageIcon = react_utilities_1.resolveShorthand(fieldProps.validationMessageIcon, {
|
110
|
-
required: !!validationState,
|
111
|
-
defaultProps: {
|
112
|
-
children: validationState ? validationMessageIcons[validationState] : undefined
|
113
|
-
}
|
114
|
-
}); // Hook up aria props on the control
|
115
|
-
|
116
|
-
if (label && labelConnection === 'aria-labelledby') {
|
117
|
-
(_a = control['aria-labelledby']) !== null && _a !== void 0 ? _a : control['aria-labelledby'] = label.id;
|
118
|
-
}
|
119
|
-
|
120
|
-
if (validationState === 'error' && ariaInvalidOnError) {
|
121
|
-
(_b = control['aria-invalid']) !== null && _b !== void 0 ? _b : control['aria-invalid'] = true;
|
122
|
-
|
123
|
-
if (validationMessage) {
|
124
|
-
(_c = control['aria-errormessage']) !== null && _c !== void 0 ? _c : control['aria-errormessage'] = validationMessage.id;
|
125
|
-
}
|
126
|
-
|
127
|
-
if (hint) {
|
128
|
-
(_d = control['aria-describedby']) !== null && _d !== void 0 ? _d : control['aria-describedby'] = hint.id;
|
129
|
-
}
|
130
|
-
} else {
|
131
|
-
// If the state is not an error, then the control is described by the validation message, or hint, or both
|
132
|
-
const describedby = validationMessage || hint;
|
133
|
-
|
134
|
-
if (describedby) {
|
135
|
-
(_e = control['aria-describedby']) !== null && _e !== void 0 ? _e : control['aria-describedby'] = validationMessage && hint ? `${validationMessage.id} ${hint.id}` : describedby.id;
|
136
|
-
}
|
137
|
-
}
|
138
|
-
|
139
|
-
const state = {
|
140
|
-
orientation,
|
141
|
-
validationState,
|
142
|
-
classNames: params.classNames,
|
143
|
-
components: {
|
144
|
-
root: 'div',
|
145
|
-
control: params.component,
|
146
|
-
label: react_label_1.Label,
|
147
|
-
validationMessage: 'div',
|
148
|
-
validationMessageIcon: 'span',
|
149
|
-
hint: 'div'
|
150
|
-
},
|
151
|
-
root,
|
152
|
-
control,
|
153
|
-
label,
|
154
|
-
validationMessageIcon,
|
155
|
-
validationMessage,
|
156
|
-
hint
|
157
|
-
};
|
158
|
-
return state;
|
15
|
+
error: /*#__PURE__*/ _react.createElement(_reactIcons.ErrorCircle12Filled, null),
|
16
|
+
warning: /*#__PURE__*/ _react.createElement(_reactIcons.Warning12Filled, null),
|
17
|
+
success: /*#__PURE__*/ _react.createElement(_reactIcons.CheckmarkCircle12Filled, null),
|
18
|
+
none: undefined
|
159
19
|
};
|
20
|
+
const useField_unstable = (props, ref)=>{
|
21
|
+
const { children , orientation ='vertical' , required =false , validationState =props.validationMessage ? 'error' : 'none' , size ='medium' } = props;
|
22
|
+
const baseId = (0, _reactUtilities.useId)('field-');
|
23
|
+
const generatedControlId = baseId + '__control';
|
24
|
+
const root = (0, _reactUtilities.getNativeElementProps)('div', {
|
25
|
+
...props,
|
26
|
+
ref
|
27
|
+
}, /*excludedPropNames:*/ [
|
28
|
+
'children'
|
29
|
+
]);
|
30
|
+
const label = (0, _reactUtilities.resolveShorthand)(props.label, {
|
31
|
+
defaultProps: {
|
32
|
+
htmlFor: generatedControlId,
|
33
|
+
id: baseId + '__label',
|
34
|
+
required,
|
35
|
+
size
|
36
|
+
}
|
37
|
+
});
|
38
|
+
const validationMessage = (0, _reactUtilities.resolveShorthand)(props.validationMessage, {
|
39
|
+
defaultProps: {
|
40
|
+
id: baseId + '__validationMessage',
|
41
|
+
role: validationState === 'error' ? 'alert' : undefined
|
42
|
+
}
|
43
|
+
});
|
44
|
+
const hint = (0, _reactUtilities.resolveShorthand)(props.hint, {
|
45
|
+
defaultProps: {
|
46
|
+
id: baseId + '__hint'
|
47
|
+
}
|
48
|
+
});
|
49
|
+
const defaultIcon = validationMessageIcons[validationState];
|
50
|
+
const validationMessageIcon = (0, _reactUtilities.resolveShorthand)(props.validationMessageIcon, {
|
51
|
+
required: !!defaultIcon,
|
52
|
+
defaultProps: {
|
53
|
+
children: defaultIcon
|
54
|
+
}
|
55
|
+
});
|
56
|
+
return {
|
57
|
+
children,
|
58
|
+
generatedControlId,
|
59
|
+
orientation,
|
60
|
+
required,
|
61
|
+
size,
|
62
|
+
validationState,
|
63
|
+
components: {
|
64
|
+
root: 'div',
|
65
|
+
label: _reactLabel.Label,
|
66
|
+
validationMessage: 'div',
|
67
|
+
validationMessageIcon: 'span',
|
68
|
+
hint: 'div'
|
69
|
+
},
|
70
|
+
root,
|
71
|
+
label,
|
72
|
+
validationMessageIcon,
|
73
|
+
validationMessage,
|
74
|
+
hint
|
75
|
+
};
|
76
|
+
}; //# sourceMappingURL=useField.js.map
|
160
77
|
|
161
|
-
exports.useField_unstable = useField_unstable;
|
162
78
|
//# sourceMappingURL=useField.js.map
|