@fluentui/react-field 9.0.0-alpha.9 → 9.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/.swcrc +30 -0
  2. package/CHANGELOG.json +666 -1
  3. package/CHANGELOG.md +242 -2
  4. package/README.md +66 -1
  5. package/dist/index.d.ts +153 -80
  6. package/lib/Field.js.map +1 -1
  7. package/lib/components/Field/Field.js +13 -0
  8. package/lib/components/Field/Field.js.map +1 -0
  9. package/lib/components/Field/Field.types.js +1 -1
  10. package/lib/components/Field/Field.types.js.map +1 -1
  11. package/lib/components/Field/index.js +1 -0
  12. package/lib/components/Field/index.js.map +1 -1
  13. package/lib/components/Field/renderField.js +11 -9
  14. package/lib/components/Field/renderField.js.map +1 -1
  15. package/lib/components/Field/useField.js +32 -98
  16. package/lib/components/Field/useField.js.map +1 -1
  17. package/lib/components/Field/useFieldStyles.js +61 -76
  18. package/lib/components/Field/useFieldStyles.js.map +1 -1
  19. package/lib/contexts/FieldContext.js +5 -0
  20. package/lib/contexts/FieldContext.js.map +1 -0
  21. package/lib/contexts/index.js +4 -0
  22. package/lib/contexts/index.js.map +1 -0
  23. package/lib/contexts/useFieldContextValues.js +33 -0
  24. package/lib/contexts/useFieldContextValues.js.map +1 -0
  25. package/lib/contexts/useFieldControlProps.js +65 -0
  26. package/lib/contexts/useFieldControlProps.js.map +1 -0
  27. package/lib/index.js +4 -1
  28. package/lib/index.js.map +1 -1
  29. package/lib/util/makeDeprecatedField.js +68 -0
  30. package/lib/util/makeDeprecatedField.js.map +1 -0
  31. package/lib-commonjs/Field.js +4 -5
  32. package/lib-commonjs/Field.js.map +1 -1
  33. package/lib-commonjs/components/Field/Field.js +23 -0
  34. package/lib-commonjs/components/Field/Field.js.map +1 -0
  35. package/lib-commonjs/components/Field/Field.types.js +5 -2
  36. package/lib-commonjs/components/Field/Field.types.js.map +1 -1
  37. package/lib-commonjs/components/Field/index.js +8 -11
  38. package/lib-commonjs/components/Field/index.js.map +1 -1
  39. package/lib-commonjs/components/Field/renderField.js +19 -26
  40. package/lib-commonjs/components/Field/renderField.js.map +1 -1
  41. package/lib-commonjs/components/Field/useField.js +71 -155
  42. package/lib-commonjs/components/Field/useField.js.map +1 -1
  43. package/lib-commonjs/components/Field/useFieldStyles.js +138 -118
  44. package/lib-commonjs/components/Field/useFieldStyles.js.map +1 -1
  45. package/lib-commonjs/contexts/FieldContext.js +21 -0
  46. package/lib-commonjs/contexts/FieldContext.js.map +1 -0
  47. package/lib-commonjs/contexts/index.js +11 -0
  48. package/lib-commonjs/contexts/index.js.map +1 -0
  49. package/lib-commonjs/contexts/useFieldContextValues.js +44 -0
  50. package/lib-commonjs/contexts/useFieldContextValues.js.map +1 -0
  51. package/lib-commonjs/contexts/useFieldControlProps.js +71 -0
  52. package/lib-commonjs/contexts/useFieldControlProps.js.map +1 -0
  53. package/lib-commonjs/index.js +24 -29
  54. package/lib-commonjs/index.js.map +1 -1
  55. package/lib-commonjs/util/makeDeprecatedField.js +61 -0
  56. package/lib-commonjs/util/makeDeprecatedField.js.map +1 -0
  57. package/package.json +14 -11
  58. package/Spec.md +0 -354
  59. package/lib/components/Field/SlotComponent.types.js +0 -2
  60. package/lib/components/Field/SlotComponent.types.js.map +0 -1
  61. package/lib-amd/Field.js +0 -6
  62. package/lib-amd/Field.js.map +0 -1
  63. package/lib-amd/components/Field/Field.types.js +0 -5
  64. package/lib-amd/components/Field/Field.types.js.map +0 -1
  65. package/lib-amd/components/Field/SlotComponent.types.js +0 -5
  66. package/lib-amd/components/Field/SlotComponent.types.js.map +0 -1
  67. package/lib-amd/components/Field/index.js +0 -9
  68. package/lib-amd/components/Field/index.js.map +0 -1
  69. package/lib-amd/components/Field/renderField.js +0 -20
  70. package/lib-amd/components/Field/renderField.js.map +0 -1
  71. package/lib-amd/components/Field/useField.js +0 -121
  72. package/lib-amd/components/Field/useField.js.map +0 -1
  73. package/lib-amd/components/Field/useFieldStyles.js +0 -97
  74. package/lib-amd/components/Field/useFieldStyles.js.map +0 -1
  75. package/lib-amd/index.js +0 -10
  76. package/lib-amd/index.js.map +0 -1
  77. package/lib-commonjs/components/Field/SlotComponent.types.js +0 -6
  78. package/lib-commonjs/components/Field/SlotComponent.types.js.map +0 -1
@@ -1,121 +0,0 @@
1
- define(["require", "exports", "tslib", "react", "@fluentui/react-icons", "@fluentui/react-label", "@fluentui/react-utilities"], function (require, exports, tslib_1, React, react_icons_1, react_label_1, react_utilities_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.useField_unstable = exports.getPartitionedFieldProps = void 0;
5
- var validationMessageIcons = {
6
- error: React.createElement(react_icons_1.ErrorCircle12Filled, null),
7
- warning: React.createElement(react_icons_1.Warning12Filled, null),
8
- success: React.createElement(react_icons_1.CheckmarkCircle12Filled, null),
9
- };
10
- /**
11
- * Partition the props used by the Field itself, from the props that are passed to the underlying field component.
12
- */
13
- var getPartitionedFieldProps = function (props) {
14
- var className = props.className, control = props.control, hint = props.hint, label = props.label, orientation = props.orientation, root = props.root, style = props.style, validationMessage = props.validationMessage, validationMessageIcon = props.validationMessageIcon, validationState = props.validationState, restOfProps = tslib_1.__rest(props, ["className", "control", "hint", "label", "orientation", "root", "style", "validationMessage", "validationMessageIcon", "validationState"]);
15
- var fieldProps = {
16
- className: className,
17
- control: control,
18
- hint: hint,
19
- label: label,
20
- orientation: orientation,
21
- root: root,
22
- style: style,
23
- validationMessage: validationMessage,
24
- validationMessageIcon: validationMessageIcon,
25
- validationState: validationState,
26
- };
27
- return [fieldProps, restOfProps];
28
- };
29
- exports.getPartitionedFieldProps = getPartitionedFieldProps;
30
- /**
31
- * Create the state required to render Field.
32
- *
33
- * The returned state can be modified with hooks such as useFieldStyles_unstable,
34
- * before being passed to renderField_unstable.
35
- *
36
- * @param props - Props passed to this field
37
- * @param ref - Ref to the control slot (primary slot)
38
- * @param params - Configuration parameters for this Field
39
- */
40
- var useField_unstable = function (props, ref, params) {
41
- var _a, _b, _c, _d, _e;
42
- var _f = exports.getPartitionedFieldProps(props), fieldProps = _f[0], controlProps = _f[1];
43
- var _g = fieldProps.orientation, orientation = _g === void 0 ? 'vertical' : _g, validationState = fieldProps.validationState;
44
- var _h = params.labelConnection, labelConnection = _h === void 0 ? 'htmlFor' : _h, _j = params.ariaInvalidOnError, ariaInvalidOnError = _j === void 0 ? true : _j;
45
- var baseId = react_utilities_1.useId('field-');
46
- var root = react_utilities_1.resolveShorthand(fieldProps.root, {
47
- required: true,
48
- defaultProps: react_utilities_1.getNativeElementProps('div', fieldProps),
49
- });
50
- var control = react_utilities_1.resolveShorthand(fieldProps.control, {
51
- required: true,
52
- defaultProps: tslib_1.__assign({ ref: ref, id: baseId + '__control' }, controlProps),
53
- });
54
- var label = react_utilities_1.resolveShorthand(fieldProps.label, {
55
- defaultProps: {
56
- id: baseId + '__label',
57
- required: controlProps.required,
58
- size: typeof controlProps.size === 'string' ? controlProps.size : undefined,
59
- htmlFor: labelConnection === 'htmlFor' ? control.id : undefined,
60
- },
61
- });
62
- var validationMessage = react_utilities_1.resolveShorthand(fieldProps.validationMessage, {
63
- defaultProps: {
64
- id: baseId + '__validationMessage',
65
- },
66
- });
67
- var hint = react_utilities_1.resolveShorthand(fieldProps.hint, {
68
- defaultProps: {
69
- id: baseId + '__hint',
70
- },
71
- });
72
- var validationMessageIcon = react_utilities_1.resolveShorthand(fieldProps.validationMessageIcon, {
73
- required: !!validationState,
74
- defaultProps: {
75
- children: validationState ? validationMessageIcons[validationState] : undefined,
76
- },
77
- });
78
- // Hook up aria props on the control
79
- if (label && labelConnection === 'aria-labelledby') {
80
- (_a = control['aria-labelledby']) !== null && _a !== void 0 ? _a : (control['aria-labelledby'] = label.id);
81
- }
82
- if (validationState === 'error' && ariaInvalidOnError) {
83
- (_b = control['aria-invalid']) !== null && _b !== void 0 ? _b : (control['aria-invalid'] = true);
84
- if (validationMessage) {
85
- (_c = control['aria-errormessage']) !== null && _c !== void 0 ? _c : (control['aria-errormessage'] = validationMessage.id);
86
- }
87
- if (hint) {
88
- (_d = control['aria-describedby']) !== null && _d !== void 0 ? _d : (control['aria-describedby'] = hint.id);
89
- }
90
- }
91
- else {
92
- // If the state is not an error, then the control is described by the validation message, or hint, or both
93
- var describedby = validationMessage || hint;
94
- if (describedby) {
95
- (_e = control['aria-describedby']) !== null && _e !== void 0 ? _e : (control['aria-describedby'] = validationMessage && hint ? validationMessage.id + " " + hint.id : describedby.id);
96
- }
97
- }
98
- var state = {
99
- orientation: orientation,
100
- validationState: validationState,
101
- classNames: params.classNames,
102
- components: {
103
- root: 'div',
104
- control: params.component,
105
- label: react_label_1.Label,
106
- validationMessage: 'div',
107
- validationMessageIcon: 'span',
108
- hint: 'div',
109
- },
110
- root: root,
111
- control: control,
112
- label: label,
113
- validationMessageIcon: validationMessageIcon,
114
- validationMessage: validationMessage,
115
- hint: hint,
116
- };
117
- return state;
118
- };
119
- exports.useField_unstable = useField_unstable;
120
- });
121
- //# sourceMappingURL=useField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useField.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-field/src/components/Field/useField.tsx"],"names":[],"mappings":";;;;IAYA,IAAM,sBAAsB,GAAG;QAC7B,KAAK,EAAE,oBAAC,iCAAmB,OAAG;QAC9B,OAAO,EAAE,oBAAC,6BAAe,OAAG;QAC5B,OAAO,EAAE,oBAAC,qCAAuB,OAAG;KAC5B,CAAC;IAEX;;OAEG;IACI,IAAM,wBAAwB,GAAG,UAAyC,KAAY;QAEzF,IAAA,SAAS,GAWP,KAAK,UAXE,EACT,OAAO,GAUL,KAAK,QAVA,EACP,IAAI,GASF,KAAK,KATH,EACJ,KAAK,GAQH,KAAK,MARF,EACL,WAAW,GAOT,KAAK,YAPI,EACX,IAAI,GAMF,KAAK,KANH,EACJ,KAAK,GAKH,KAAK,MALF,EACL,iBAAiB,GAIf,KAAK,kBAJU,EACjB,qBAAqB,GAGnB,KAAK,s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BAAiB,EAAE;gBACrB,MAAA,OAAO,CAAC,mBAAmB,qCAA3B,OAAO,CAAC,mBAAmB,IAAM,iBAAiB,CAAC,EAAE,EAAC;aACvD;YACD,IAAI,IAAI,EAAE;gBACR,MAAA,OAAO,CAAC,kBAAkB,qCAA1B,OAAO,CAAC,kBAAkB,IAAM,IAAI,CAAC,EAAE,EAAC;aACzC;SACF;aAAM;YACL,0GAA0G;YAC1G,IAAM,WAAW,GAAG,iBAAiB,IAAI,IAAI,CAAC;YAC9C,IAAI,WAAW,EAAE;gBACf,MAAA,OAAO,CAAC,kBAAkB,qCAA1B,OAAO,CAAC,kBAAkB,IAAM,iBAAiB,IAAI,IAAI,CAAC,CAAC,CAAI,iBAAiB,CAAC,EAAE,SAAI,IAAI,CAAC,EAAI,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,EAAC;aACnH;SACF;QAED,IAAM,KAAK,GAA6B;YACtC,WAAW,aAAA;YACX,eAAe,iBAAA;YACf,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,UAAU,EAAE;gBACV,IAAI,EAAE,KAAK;gBACX,OAAO,EAAE,MAAM,CAAC,SAAS;gBACzB,KAAK,EAAE,mBAAK;gBACZ,iBAAiB,EAAE,KAAK;gBACxB,qBAAqB,EAAE,MAAM;gBAC7B,IAAI,EAAE,KAAK;aACZ;YACD,IAAI,MAAA;YACJ,OAAO,SAAA;YACP,KAAK,OAAA;YACL,qBAAqB,uBAAA;YACrB,iBAAiB,mBAAA;YACjB,IAAI,MAAA;SACL,CAAC;QAEF,OAAO,KAAsB,CAAC;IAChC,CAAC,CAAC;IA/FW,QAAA,iBAAiB,qBA+F5B","sourcesContent":["import * as React from 'react';\nimport { CheckmarkCircle12Filled, ErrorCircle12Filled, Warning12Filled } from '@fluentui/react-icons';\nimport { Label } from '@fluentui/react-label';\nimport { getNativeElementProps, resolveShorthand, useId } from '@fluentui/react-utilities';\nimport type {\n FieldConfig,\n FieldControl,\n FieldProps,\n FieldPropsWithOptionalComponentProps,\n FieldState,\n} from './Field.types';\n\nconst validationMessageIcons = {\n error: <ErrorCircle12Filled />,\n warning: <Warning12Filled />,\n success: <CheckmarkCircle12Filled />,\n} as const;\n\n/**\n * Partition the props used by the Field itself, from the props that are passed to the underlying field component.\n */\nexport const getPartitionedFieldProps = <Props extends FieldProps<FieldControl>>(props: Props) => {\n const {\n className,\n control,\n hint,\n label,\n orientation,\n root,\n style,\n validationMessage,\n validationMessageIcon,\n validationState,\n ...restOfProps\n } = props;\n\n const fieldProps = {\n className,\n control,\n hint,\n label,\n orientation,\n root,\n style,\n validationMessage,\n validationMessageIcon,\n validationState,\n };\n\n return [fieldProps, restOfProps] as const;\n};\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 control slot (primary slot)\n * @param params - Configuration parameters for this Field\n */\nexport const useField_unstable = <T extends FieldControl>(\n props: FieldPropsWithOptionalComponentProps<T>,\n ref: React.Ref<HTMLElement>,\n params: FieldConfig<T>,\n): FieldState<T> => {\n const [fieldProps, controlProps] = getPartitionedFieldProps(props);\n const { orientation = 'vertical', validationState } = fieldProps;\n const { labelConnection = 'htmlFor', ariaInvalidOnError = true } = params;\n\n const baseId = useId('field-');\n\n const root = resolveShorthand(fieldProps.root, {\n required: true,\n defaultProps: getNativeElementProps('div', fieldProps),\n });\n\n const control = resolveShorthand(fieldProps.control, {\n required: true,\n defaultProps: {\n ref,\n id: baseId + '__control',\n ...controlProps,\n },\n });\n\n const label = resolveShorthand(fieldProps.label, {\n defaultProps: {\n id: baseId + '__label',\n required: controlProps.required,\n size: typeof controlProps.size === 'string' ? controlProps.size : undefined,\n htmlFor: labelConnection === 'htmlFor' ? control.id : undefined,\n },\n });\n\n const validationMessage = resolveShorthand(fieldProps.validationMessage, {\n defaultProps: {\n id: baseId + '__validationMessage',\n },\n });\n\n const hint = resolveShorthand(fieldProps.hint, {\n defaultProps: {\n id: baseId + '__hint',\n },\n });\n\n const validationMessageIcon = resolveShorthand(fieldProps.validationMessageIcon, {\n required: !!validationState,\n defaultProps: {\n children: validationState ? validationMessageIcons[validationState] : undefined,\n },\n });\n\n // Hook up aria props on the control\n if (label && labelConnection === 'aria-labelledby') {\n control['aria-labelledby'] ??= label.id;\n }\n\n if (validationState === 'error' && ariaInvalidOnError) {\n control['aria-invalid'] ??= true;\n if (validationMessage) {\n control['aria-errormessage'] ??= validationMessage.id;\n }\n if (hint) {\n control['aria-describedby'] ??= hint.id;\n }\n } else {\n // If the state is not an error, then the control is described by the validation message, or hint, or both\n const describedby = validationMessage || hint;\n if (describedby) {\n control['aria-describedby'] ??= validationMessage && hint ? `${validationMessage.id} ${hint.id}` : describedby.id;\n }\n }\n\n const state: FieldState<FieldControl> = {\n orientation,\n validationState,\n classNames: params.classNames,\n components: {\n root: 'div',\n control: params.component,\n label: Label,\n validationMessage: 'div',\n validationMessageIcon: 'span',\n hint: 'div',\n },\n root,\n control,\n label,\n validationMessageIcon,\n validationMessage,\n hint,\n };\n\n return state as FieldState<T>;\n};\n"]}
@@ -1,97 +0,0 @@
1
- define(["require", "exports", "tslib", "@fluentui/react-theme", "@griffel/react"], function (require, exports, tslib_1, react_theme_1, react_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.useFieldStyles_unstable = exports.getFieldClassNames = void 0;
5
- var getFieldClassNames = function (name) { return ({
6
- root: "fui-" + name,
7
- control: "fui-" + name + "__control",
8
- label: "fui-" + name + "__label",
9
- validationMessage: "fui-" + name + "__validationMessage",
10
- validationMessageIcon: "fui-" + name + "__validationMessageIcon",
11
- hint: "fui-" + name + "__hint",
12
- }); };
13
- exports.getFieldClassNames = getFieldClassNames;
14
- /**
15
- * Styles for the root slot
16
- */
17
- var useRootStyles = react_1.makeStyles({
18
- base: {
19
- display: 'grid',
20
- gridAutoFlow: 'row',
21
- justifyItems: 'start',
22
- },
23
- horizontal: {
24
- gridTemplateRows: 'auto auto auto auto',
25
- gridTemplateColumns: '1fr 2fr',
26
- },
27
- secondColumn: {
28
- gridColumnStart: '2',
29
- },
30
- });
31
- var useLabelStyles = react_1.makeStyles({
32
- base: {
33
- marginTop: react_theme_1.tokens.spacingVerticalXXS,
34
- marginBottom: react_theme_1.tokens.spacingVerticalXXS,
35
- },
36
- horizontal: {
37
- gridRowStart: '1',
38
- gridRowEnd: '-1',
39
- marginRight: react_theme_1.tokens.spacingHorizontalM,
40
- alignSelf: 'start',
41
- justifySelf: 'stretch',
42
- },
43
- });
44
- var useSecondaryTextStyles = react_1.makeStyles({
45
- base: tslib_1.__assign({ marginTop: react_theme_1.tokens.spacingVerticalXXS, color: react_theme_1.tokens.colorNeutralForeground3 }, react_theme_1.typographyStyles.caption1),
46
- error: {
47
- color: react_theme_1.tokens.colorPaletteRedForeground1,
48
- },
49
- });
50
- var useValidationMessageIconStyles = react_1.makeStyles({
51
- base: {
52
- fontSize: '12px',
53
- lineHeight: '12px',
54
- verticalAlign: 'middle',
55
- marginRight: react_theme_1.tokens.spacingHorizontalXS,
56
- },
57
- error: {
58
- color: react_theme_1.tokens.colorPaletteRedForeground1,
59
- },
60
- warning: {
61
- color: react_theme_1.tokens.colorPaletteDarkOrangeForeground1,
62
- },
63
- success: {
64
- color: react_theme_1.tokens.colorPaletteGreenForeground1,
65
- },
66
- });
67
- /**
68
- * Apply styling to the Field slots based on the state
69
- */
70
- var useFieldStyles_unstable = function (state) {
71
- var classNames = state.classNames;
72
- var validationState = state.validationState;
73
- var horizontal = state.orientation === 'horizontal';
74
- var rootStyles = useRootStyles();
75
- state.root.className = react_1.mergeClasses(classNames.root, rootStyles.base, horizontal && rootStyles.horizontal, state.root.className);
76
- if (state.control) {
77
- state.control.className = react_1.mergeClasses(classNames.control, horizontal && rootStyles.secondColumn, state.control.className);
78
- }
79
- var labelStyles = useLabelStyles();
80
- if (state.label) {
81
- state.label.className = react_1.mergeClasses(classNames.label, labelStyles.base, horizontal && labelStyles.horizontal, state.label.className);
82
- }
83
- var validationMessageIconStyles = useValidationMessageIconStyles();
84
- if (state.validationMessageIcon) {
85
- state.validationMessageIcon.className = react_1.mergeClasses(classNames.validationMessageIcon, validationMessageIconStyles.base, !!validationState && validationMessageIconStyles[validationState], state.validationMessageIcon.className);
86
- }
87
- var secondaryTextStyles = useSecondaryTextStyles();
88
- if (state.validationMessage) {
89
- state.validationMessage.className = react_1.mergeClasses(classNames.validationMessage, secondaryTextStyles.base, horizontal && rootStyles.secondColumn, validationState === 'error' && secondaryTextStyles.error, state.validationMessage.className);
90
- }
91
- if (state.hint) {
92
- state.hint.className = react_1.mergeClasses(classNames.hint, secondaryTextStyles.base, horizontal && rootStyles.secondColumn, state.hint.className);
93
- }
94
- };
95
- exports.useFieldStyles_unstable = useFieldStyles_unstable;
96
- });
97
- //# sourceMappingURL=useFieldStyles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useFieldStyles.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-field/src/components/Field/useFieldStyles.ts"],"names":[],"mappings":";;;;IAKO,IAAM,kBAAkB,GAAG,UAAC,IAAY,IAA+C,OAAA,CAAC;QAC7F,IAAI,EAAE,SAAO,IAAM;QACnB,OAAO,EAAE,SAAO,IAAI,cAAW;QAC/B,KAAK,EAAE,SAAO,IAAI,YAAS;QAC3B,iBAAiB,EAAE,SAAO,IAAI,wBAAqB;QACnD,qBAAqB,EAAE,SAAO,IAAI,4BAAyB;QAC3D,IAAI,EAAE,SAAO,IAAI,WAAQ;KAC1B,CAAC,EAP4F,CAO5F,CAAC;IAPU,QAAA,kBAAkB,sBAO5B;IAEH;;OAEG;IACH,IAAM,aAAa,GAAG,kBAAU,CAAC;QAC/B,IAAI,EAAE;YACJ,OAAO,EAAE,MAAM;YACf,YAAY,EAAE,KAAK;YACnB,YAAY,EAAE,OAAO;SACtB;QAED,UAAU,EAAE;YACV,gBAAgB,EAAE,qBAAqB;YACvC,mBAAmB,EAAE,SAAS;SAC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BAAmB,CAAC,KAAK,EACxD,KAAK,CAAC,iBAAiB,CAAC,SAAS,CAClC,CAAC;SACH;QAED,IAAI,KAAK,CAAC,IAAI,EAAE;YACd,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,oBAAY,CACjC,UAAU,CAAC,IAAI,EACf,mBAAmB,CAAC,IAAI,EACxB,UAAU,IAAI,UAAU,CAAC,YAAY,EACrC,KAAK,CAAC,IAAI,CAAC,SAAS,CACrB,CAAC;SACH;IACH,CAAC,CAAC;IA5DW,QAAA,uBAAuB,2BA4DlC","sourcesContent":["import { tokens, typographyStyles } from '@fluentui/react-theme';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { makeStyles, mergeClasses } from '@griffel/react';\nimport type { FieldControl, FieldProps, FieldSlots, FieldState } from './Field.types';\n\nexport const getFieldClassNames = (name: string): SlotClassNames<FieldSlots<FieldControl>> => ({\n root: `fui-${name}`,\n control: `fui-${name}__control`,\n label: `fui-${name}__label`,\n validationMessage: `fui-${name}__validationMessage`,\n validationMessageIcon: `fui-${name}__validationMessageIcon`,\n hint: `fui-${name}__hint`,\n});\n\n/**\n * Styles for the root slot\n */\nconst useRootStyles = makeStyles({\n base: {\n display: 'grid',\n gridAutoFlow: 'row',\n justifyItems: 'start',\n },\n\n horizontal: {\n gridTemplateRows: 'auto auto auto auto',\n gridTemplateColumns: '1fr 2fr',\n },\n\n secondColumn: {\n gridColumnStart: '2',\n },\n});\n\nconst useLabelStyles = makeStyles({\n base: {\n marginTop: tokens.spacingVerticalXXS,\n marginBottom: tokens.spacingVerticalXXS,\n },\n\n horizontal: {\n gridRowStart: '1',\n gridRowEnd: '-1',\n marginRight: tokens.spacingHorizontalM,\n alignSelf: 'start',\n justifySelf: 'stretch',\n },\n});\n\nconst useSecondaryTextStyles = makeStyles({\n base: {\n marginTop: tokens.spacingVerticalXXS,\n color: tokens.colorNeutralForeground3,\n ...typographyStyles.caption1,\n },\n\n error: {\n color: tokens.colorPaletteRedForeground1,\n },\n});\n\nconst useValidationMessageIconStyles = makeStyles({\n base: {\n fontSize: '12px',\n lineHeight: '12px',\n verticalAlign: 'middle',\n marginRight: tokens.spacingHorizontalXS,\n },\n\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 = <T extends FieldControl>(state: FieldState<T>) => {\n const classNames = state.classNames;\n const validationState: FieldProps<FieldControl>['validationState'] = state.validationState;\n const horizontal = state.orientation === 'horizontal';\n\n const rootStyles = useRootStyles();\n state.root.className = mergeClasses(\n classNames.root,\n rootStyles.base,\n horizontal && rootStyles.horizontal,\n state.root.className,\n );\n\n if (state.control) {\n state.control.className = mergeClasses(\n classNames.control,\n horizontal && rootStyles.secondColumn,\n state.control.className,\n );\n }\n\n const labelStyles = useLabelStyles();\n if (state.label) {\n state.label.className = mergeClasses(\n classNames.label,\n labelStyles.base,\n horizontal && labelStyles.horizontal,\n state.label.className,\n );\n }\n\n const validationMessageIconStyles = useValidationMessageIconStyles();\n if (state.validationMessageIcon) {\n state.validationMessageIcon.className = mergeClasses(\n classNames.validationMessageIcon,\n validationMessageIconStyles.base,\n !!validationState && validationMessageIconStyles[validationState],\n state.validationMessageIcon.className,\n );\n }\n\n const secondaryTextStyles = useSecondaryTextStyles();\n if (state.validationMessage) {\n state.validationMessage.className = mergeClasses(\n classNames.validationMessage,\n secondaryTextStyles.base,\n horizontal && rootStyles.secondColumn,\n validationState === 'error' && secondaryTextStyles.error,\n state.validationMessage.className,\n );\n }\n\n if (state.hint) {\n state.hint.className = mergeClasses(\n classNames.hint,\n secondaryTextStyles.base,\n horizontal && rootStyles.secondColumn,\n state.hint.className,\n );\n }\n};\n"]}
package/lib-amd/index.js DELETED
@@ -1,10 +0,0 @@
1
- define(["require", "exports", "./Field"], function (require, exports, Field_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.useField_unstable = exports.useFieldStyles_unstable = exports.renderField_unstable = exports.getFieldClassNames = void 0;
5
- Object.defineProperty(exports, "getFieldClassNames", { enumerable: true, get: function () { return Field_1.getFieldClassNames; } });
6
- Object.defineProperty(exports, "renderField_unstable", { enumerable: true, get: function () { return Field_1.renderField_unstable; } });
7
- Object.defineProperty(exports, "useFieldStyles_unstable", { enumerable: true, get: function () { return Field_1.useFieldStyles_unstable; } });
8
- Object.defineProperty(exports, "useField_unstable", { enumerable: true, get: function () { return Field_1.useField_unstable; } });
9
- });
10
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-field/src/index.ts"],"names":[],"mappings":";;;;IAAS,2GAAA,kBAAkB,OAAA;IAAE,6GAAA,oBAAoB,OAAA;IAAE,gHAAA,uBAAuB,OAAA;IAAE,0GAAA,iBAAiB,OAAA","sourcesContent":["export { getFieldClassNames, renderField_unstable, useFieldStyles_unstable, useField_unstable } from './Field';\nexport type { FieldConfig, FieldControl, FieldProps, FieldSlots, FieldState } from './Field';\n"]}
@@ -1,6 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- //# sourceMappingURL=SlotComponent.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":"../src/"}