@fluentui/react-label 9.0.0-alpha.8 → 9.0.0-beta.10

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 (84) hide show
  1. package/CHANGELOG.json +1624 -1
  2. package/CHANGELOG.md +561 -2
  3. package/README.md +2 -1
  4. package/Spec.md +23 -33
  5. package/dist/react-label.d.ts +34 -52
  6. package/lib/components/Label/Label.d.ts +3 -4
  7. package/lib/components/Label/Label.js +8 -8
  8. package/lib/components/Label/Label.js.map +1 -1
  9. package/lib/components/Label/Label.types.d.ts +20 -35
  10. package/lib/components/Label/Label.types.js.map +1 -1
  11. package/lib/components/Label/renderLabel.d.ts +2 -3
  12. package/lib/components/Label/renderLabel.js +9 -8
  13. package/lib/components/Label/renderLabel.js.map +1 -1
  14. package/lib/components/Label/useLabel.d.ts +4 -12
  15. package/lib/components/Label/useLabel.js +30 -42
  16. package/lib/components/Label/useLabel.js.map +1 -1
  17. package/lib/components/Label/useLabelStyles.d.ts +8 -2
  18. package/lib/components/Label/useLabelStyles.js +53 -37
  19. package/lib/components/Label/useLabelStyles.js.map +1 -1
  20. package/lib/index.d.ts +2 -2
  21. package/lib/index.js +2 -1
  22. package/lib/index.js.map +1 -1
  23. package/lib/tsdoc-metadata.json +1 -1
  24. package/lib-commonjs/Label.js +7 -2
  25. package/lib-commonjs/Label.js.map +1 -1
  26. package/lib-commonjs/components/Label/Label.d.ts +3 -4
  27. package/lib-commonjs/components/Label/Label.js +18 -10
  28. package/lib-commonjs/components/Label/Label.js.map +1 -1
  29. package/lib-commonjs/components/Label/Label.types.d.ts +20 -35
  30. package/lib-commonjs/components/Label/Label.types.js +4 -1
  31. package/lib-commonjs/components/Label/Label.types.js.map +1 -1
  32. package/lib-commonjs/components/Label/index.js +11 -2
  33. package/lib-commonjs/components/Label/index.js.map +1 -1
  34. package/lib-commonjs/components/Label/renderLabel.d.ts +2 -3
  35. package/lib-commonjs/components/Label/renderLabel.js +21 -13
  36. package/lib-commonjs/components/Label/renderLabel.js.map +1 -1
  37. package/lib-commonjs/components/Label/useLabel.d.ts +4 -12
  38. package/lib-commonjs/components/Label/useLabel.js +40 -45
  39. package/lib-commonjs/components/Label/useLabel.js.map +1 -1
  40. package/lib-commonjs/components/Label/useLabelStyles.d.ts +8 -2
  41. package/lib-commonjs/components/Label/useLabelStyles.js +63 -40
  42. package/lib-commonjs/components/Label/useLabelStyles.js.map +1 -1
  43. package/lib-commonjs/index.d.ts +2 -2
  44. package/lib-commonjs/index.js +45 -3
  45. package/lib-commonjs/index.js.map +1 -1
  46. package/package.json +23 -23
  47. package/config/api-extractor.json +0 -3
  48. package/config/tests.js +0 -7
  49. package/etc/react-label.api.md +0 -51
  50. package/just.config.ts +0 -3
  51. package/lib/common/isConformant.d.ts +0 -4
  52. package/lib/common/isConformant.js +0 -9
  53. package/lib/common/isConformant.js.map +0 -1
  54. package/lib-amd/Label.d.ts +0 -1
  55. package/lib-amd/Label.js +0 -6
  56. package/lib-amd/Label.js.map +0 -1
  57. package/lib-amd/common/isConformant.d.ts +0 -4
  58. package/lib-amd/common/isConformant.js +0 -14
  59. package/lib-amd/common/isConformant.js.map +0 -1
  60. package/lib-amd/components/Label/Label.d.ts +0 -7
  61. package/lib-amd/components/Label/Label.js +0 -16
  62. package/lib-amd/components/Label/Label.js.map +0 -1
  63. package/lib-amd/components/Label/Label.types.d.ts +0 -53
  64. package/lib-amd/components/Label/Label.types.js +0 -5
  65. package/lib-amd/components/Label/Label.types.js.map +0 -1
  66. package/lib-amd/components/Label/index.d.ts +0 -5
  67. package/lib-amd/components/Label/index.js +0 -10
  68. package/lib-amd/components/Label/index.js.map +0 -1
  69. package/lib-amd/components/Label/renderLabel.d.ts +0 -6
  70. package/lib-amd/components/Label/renderLabel.js +0 -17
  71. package/lib-amd/components/Label/renderLabel.js.map +0 -1
  72. package/lib-amd/components/Label/useLabel.d.ts +0 -20
  73. package/lib-amd/components/Label/useLabel.js +0 -55
  74. package/lib-amd/components/Label/useLabel.js.map +0 -1
  75. package/lib-amd/components/Label/useLabelStyles.d.ts +0 -5
  76. package/lib-amd/components/Label/useLabelStyles.js +0 -51
  77. package/lib-amd/components/Label/useLabelStyles.js.map +0 -1
  78. package/lib-amd/index.d.ts +0 -2
  79. package/lib-amd/index.js +0 -6
  80. package/lib-amd/index.js.map +0 -1
  81. package/lib-commonjs/common/isConformant.d.ts +0 -4
  82. package/lib-commonjs/common/isConformant.js +0 -13
  83. package/lib-commonjs/common/isConformant.js.map +0 -1
  84. package/src/components/Label/Label.types.ts +0 -61
package/Spec.md CHANGED
@@ -75,58 +75,48 @@ The Label component should be simple as shown below. It will just need the text
75
75
  ## API
76
76
 
77
77
  ```ts
78
- /**
79
- * Label Props
80
- * {@docCategory Label}
81
- */
82
- export interface LabelProps extends ComponentProps, React.LabelHTMLAttributes<HTMLElement> {
78
+ export type LabelCommons = {
83
79
  /**
84
80
  * Renders the label as disabled
85
81
  * @defaultvalue false
86
82
  */
87
- disabled?: boolean;
88
-
89
- /**
90
- * Whether the associated form field is required or not. If true it will be an asterisk, otherwise it will be what is provided.
91
- * @defaultvalue false
92
- */
93
- required?: boolean | ShorthandProps<ComponentProps>;
83
+ disabled: boolean;
94
84
 
95
85
  /**
96
- * A label supports different font sizes, see tokens for reference.
86
+ * A label supports different sizes.
97
87
  * @defaultvalue 'medium'
98
88
  */
99
- size?: 'small' | 'medium' | 'large';
89
+ size: 'small' | 'medium' | 'large';
100
90
 
101
91
  /**
102
- * A label supports semibold/strong fontweight. When size is set to large, label strong will be set by default.
92
+ * A label supports semibold/strong fontweight.
103
93
  * @defaultvalue false
104
94
  */
105
- strong?: boolean;
106
- }
95
+ strong: boolean;
96
+ };
107
97
 
108
- /**
109
- * Names of the shorthand properties in LabelProps
110
- * {@docCategory Label}
111
- */
112
- export type LabelShorthandProps = 'required';
98
+ export type LabelSlots = {
99
+ root: IntrinsicSlotProps<'label'>;
100
+ required?: IntrinsicSlotProps<'span'>;
101
+ };
113
102
 
114
103
  /**
115
- * Names of LabelProps that have a default value in useLabel
116
- * {@docCategory Label}
104
+ * State used in rendering Label
117
105
  */
118
- export type LabelDefaultedProps = never;
106
+ export type LabelState = ComponentState<LabelSlots> & LabelCommons;
119
107
 
120
108
  /**
121
- * State used in rendering Label
122
- * {@docCategory Label}
109
+ * Label Props
123
110
  */
124
- export interface LabelState extends ComponentState<LabelProps, LabelShorthandProps, LabelDefaultedProps> {
125
- /**
126
- * Ref to the root element
127
- */
128
- ref: React.Ref<HTMLElement>;
129
- }
111
+ export type LabelProps = Omit<ComponentProps<LabelSlots>, 'required'> &
112
+ Partial<LabelCommons> & {
113
+ /**
114
+ * Displays and indicator that the label is for a required field. The required prop can be set to true to display
115
+ * an asterisk (*). Or it can be set to a string or jsx content to display a different indicator.
116
+ * @defaultvalue false
117
+ */
118
+ required?: boolean | IntrinsicSlotProps<'span'> | React.ReactNode;
119
+ };
130
120
  ```
131
121
 
132
122
  ## Structure
@@ -1,99 +1,81 @@
1
- import { ComponentProps } from '@fluentui/react-utilities';
2
- import { ComponentState } from '@fluentui/react-utilities';
3
- import { ObjectShorthandProps } from '@fluentui/react-utilities';
1
+ import type { ComponentProps } from '@fluentui/react-utilities';
2
+ import type { ComponentState } from '@fluentui/react-utilities';
3
+ import type { ForwardRefComponent } from '@fluentui/react-utilities';
4
4
  import * as React_2 from 'react';
5
- import { ShorthandProps } from '@fluentui/react-utilities';
5
+ import type { Slot } from '@fluentui/react-utilities';
6
+ import type { SlotClassNames } from '@fluentui/react-utilities';
6
7
 
7
8
  /**
8
9
  * A label component provides a title or name to a component.
9
- * {@docCategory Label}
10
10
  */
11
- export declare const Label: React_2.ForwardRefExoticComponent<LabelProps & React_2.RefAttributes<HTMLElement>>;
11
+ export declare const Label: ForwardRefComponent<LabelProps>;
12
12
 
13
13
  /**
14
- * Names of LabelProps that have a default value in useLabel
15
- * {@docCategory Label}
14
+ * @deprecated Use `labelClassNames.root` instead.
16
15
  */
17
- export declare type LabelDefaultedProps = 'size';
16
+ export declare const labelClassName = "fui-Label";
18
17
 
19
- /**
20
- * Label Props
21
- * {@docCategory Label}
22
- */
23
- export declare interface LabelProps extends ComponentProps, React_2.LabelHTMLAttributes<HTMLLabelElement> {
18
+ export declare const labelClassNames: SlotClassNames<LabelSlots>;
19
+
20
+ declare type LabelCommons = {
24
21
  /**
25
22
  * Renders the label as disabled
26
23
  * @defaultvalue false
27
24
  */
28
- disabled?: boolean;
29
- /**
30
- * Displays and indicator that the label is for a required field. The required prop can be set to true to display
31
- * an asterisk (*). Or it can be set to a string or jsx content to display a different indicator.
32
- * @defaultvalue false
33
- */
34
- required?: boolean | ShorthandProps<ComponentProps>;
25
+ disabled: boolean;
35
26
  /**
36
27
  * A label supports different sizes.
37
28
  * @defaultvalue 'medium'
38
29
  */
39
- size?: 'small' | 'medium' | 'large';
30
+ size: 'small' | 'medium' | 'large';
40
31
  /**
41
32
  * A label supports semibold/strong fontweight.
42
33
  * @defaultvalue false
43
34
  */
44
- strong?: boolean;
45
- }
35
+ strong: boolean;
36
+ };
46
37
 
47
38
  /**
48
- * Names of the shorthand properties in LabelProps
49
- * {@docCategory Label}
39
+ * Label Props
50
40
  */
51
- export declare type LabelShorthandProps = 'required';
41
+ export declare type LabelProps = Omit<ComponentProps<LabelSlots>, 'required'> & Partial<LabelCommons> & {
42
+ /**
43
+ * Displays and indicator that the label is for a required field. The required prop can be set to true to display
44
+ * an asterisk (*). Or it can be set to a string or jsx content to display a different indicator.
45
+ * @defaultvalue false
46
+ */
47
+ required?: boolean | Slot<'span'>;
48
+ };
52
49
 
53
- /**
54
- * Array of all shorthand properties listed in LabelShorthandProps
55
- * {@docCatergory Label}
56
- */
57
- export declare const labelShorthandProps: LabelShorthandProps[];
50
+ export declare type LabelSlots = {
51
+ root: Slot<'label'>;
52
+ required?: Slot<'span'>;
53
+ };
58
54
 
59
55
  /**
60
56
  * State used in rendering Label
61
- * {@docCategory Label}
62
57
  */
63
- export declare interface LabelState extends ComponentState<LabelProps, LabelShorthandProps, LabelDefaultedProps> {
64
- /**
65
- * Ref to the root element
66
- */
67
- ref: React_2.Ref<HTMLElement>;
68
- /**
69
- * The required prop resolved to a slot object
70
- */
71
- required?: ObjectShorthandProps<ComponentProps>;
72
- }
58
+ export declare type LabelState = ComponentState<LabelSlots> & LabelCommons;
73
59
 
74
60
  /**
75
61
  * Render the final JSX of Label
76
- * {@docCategory Label}
77
62
  */
78
- export declare const renderLabel: (state: LabelState) => JSX.Element;
63
+ export declare const renderLabel_unstable: (state: LabelState) => JSX.Element;
79
64
 
80
65
  /**
81
66
  * Create the state required to render Label.
82
67
  *
83
- * The returned state can be modified with hooks such as useLabelStyles,
84
- * before being passed to renderLabel.
68
+ * The returned state can be modified with hooks such as useLabelStyles_unstable,
69
+ * before being passed to renderLabel_unstable.
85
70
  *
86
71
  * @param props - props from this instance of Label
87
72
  * @param ref - reference to root HTMLElement of Label
88
- * @param defaultProps - (optional) default prop values provided by the implementing type
89
- *
90
- * {@docCategory Label}
91
73
  */
92
- export declare const useLabel: (props: LabelProps, ref: React_2.Ref<HTMLElement>, defaultProps?: LabelProps | undefined) => LabelState;
74
+ export declare const useLabel_unstable: (props: LabelProps, ref: React_2.Ref<HTMLElement>) => LabelState;
93
75
 
94
76
  /**
95
77
  * Apply styling to the Label slots based on the state
96
78
  */
97
- export declare const useLabelStyles: (state: LabelState) => LabelState;
79
+ export declare const useLabelStyles_unstable: (state: LabelState) => LabelState;
98
80
 
99
81
  export { }
@@ -1,7 +1,6 @@
1
- import * as React from 'react';
2
- import { LabelProps } from './Label.types';
1
+ import type { LabelProps } from './Label.types';
2
+ import type { ForwardRefComponent } from '@fluentui/react-utilities';
3
3
  /**
4
4
  * A label component provides a title or name to a component.
5
- * {@docCategory Label}
6
5
  */
7
- export declare const Label: React.ForwardRefExoticComponent<LabelProps & React.RefAttributes<HTMLElement>>;
6
+ export declare const Label: ForwardRefComponent<LabelProps>;
@@ -1,15 +1,15 @@
1
1
  import * as React from 'react';
2
- import { useLabel } from './useLabel';
3
- import { renderLabel } from './renderLabel';
4
- import { useLabelStyles } from './useLabelStyles';
2
+ import { useLabel_unstable } from './useLabel';
3
+ import { renderLabel_unstable } from './renderLabel';
4
+ import { useLabelStyles_unstable } from './useLabelStyles';
5
5
  /**
6
6
  * A label component provides a title or name to a component.
7
- * {@docCategory Label}
8
7
  */
9
- export var Label = React.forwardRef(function (props, ref) {
10
- var state = useLabel(props, ref);
11
- useLabelStyles(state);
12
- return renderLabel(state);
8
+
9
+ export const Label = /*#__PURE__*/React.forwardRef((props, ref) => {
10
+ const state = useLabel_unstable(props, ref);
11
+ useLabelStyles_unstable(state);
12
+ return renderLabel_unstable(state);
13
13
  });
14
14
  Label.displayName = 'Label';
15
15
  //# sourceMappingURL=Label.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Label.js","sourceRoot":"../src/","sources":["components/Label/Label.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;GAGG;AACH,MAAM,CAAC,IAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAA0B,UAAC,KAAK,EAAE,GAAG;IACxE,IAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAEnC,cAAc,CAAC,KAAK,CAAC,CAAC;IACtB,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC,CAAC,CAAC;AAEH,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC","sourcesContent":["import * as React from 'react';\nimport { useLabel } from './useLabel';\nimport { LabelProps } from './Label.types';\nimport { renderLabel } from './renderLabel';\nimport { useLabelStyles } from './useLabelStyles';\n\n/**\n * A label component provides a title or name to a component.\n * {@docCategory Label}\n */\nexport const Label = React.forwardRef<HTMLElement, LabelProps>((props, ref) => {\n const state = useLabel(props, ref);\n\n useLabelStyles(state);\n return renderLabel(state);\n});\n\nLabel.displayName = 'Label';\n"]}
1
+ {"version":3,"sources":["components/Label/Label.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,iBAAT,QAAkC,YAAlC;AACA,SAAS,oBAAT,QAAqC,eAArC;AACA,SAAS,uBAAT,QAAwC,kBAAxC;AAIA;;AAEG;;AACH,OAAO,MAAM,KAAK,gBAAoC,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;AACpF,QAAM,KAAK,GAAG,iBAAiB,CAAC,KAAD,EAAQ,GAAR,CAA/B;AAEA,EAAA,uBAAuB,CAAC,KAAD,CAAvB;AACA,SAAO,oBAAoB,CAAC,KAAD,CAA3B;AACD,CALqD,CAA/C;AAOP,KAAK,CAAC,WAAN,GAAoB,OAApB","sourcesContent":["import * as React from 'react';\nimport { useLabel_unstable } from './useLabel';\nimport { renderLabel_unstable } from './renderLabel';\nimport { useLabelStyles_unstable } from './useLabelStyles';\nimport type { LabelProps } from './Label.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * A label component provides a title or name to a component.\n */\nexport const Label: ForwardRefComponent<LabelProps> = React.forwardRef((props, ref) => {\n const state = useLabel_unstable(props, ref);\n\n useLabelStyles_unstable(state);\n return renderLabel_unstable(state);\n});\n\nLabel.displayName = 'Label';\n"],"sourceRoot":"../src/"}
@@ -1,53 +1,38 @@
1
- import * as React from 'react';
2
- import { ComponentProps, ComponentState, ObjectShorthandProps, ShorthandProps } from '@fluentui/react-utilities';
3
- /**
4
- * Label Props
5
- * {@docCategory Label}
6
- */
7
- export interface LabelProps extends ComponentProps, React.LabelHTMLAttributes<HTMLLabelElement> {
1
+ import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';
2
+ declare type LabelCommons = {
8
3
  /**
9
4
  * Renders the label as disabled
10
5
  * @defaultvalue false
11
6
  */
12
- disabled?: boolean;
13
- /**
14
- * Displays and indicator that the label is for a required field. The required prop can be set to true to display
15
- * an asterisk (*). Or it can be set to a string or jsx content to display a different indicator.
16
- * @defaultvalue false
17
- */
18
- required?: boolean | ShorthandProps<ComponentProps>;
7
+ disabled: boolean;
19
8
  /**
20
9
  * A label supports different sizes.
21
10
  * @defaultvalue 'medium'
22
11
  */
23
- size?: 'small' | 'medium' | 'large';
12
+ size: 'small' | 'medium' | 'large';
24
13
  /**
25
14
  * A label supports semibold/strong fontweight.
26
15
  * @defaultvalue false
27
16
  */
28
- strong?: boolean;
29
- }
30
- /**
31
- * Names of the shorthand properties in LabelProps
32
- * {@docCategory Label}
33
- */
34
- export declare type LabelShorthandProps = 'required';
17
+ strong: boolean;
18
+ };
19
+ export declare type LabelSlots = {
20
+ root: Slot<'label'>;
21
+ required?: Slot<'span'>;
22
+ };
35
23
  /**
36
- * Names of LabelProps that have a default value in useLabel
37
- * {@docCategory Label}
24
+ * State used in rendering Label
38
25
  */
39
- export declare type LabelDefaultedProps = 'size';
26
+ export declare type LabelState = ComponentState<LabelSlots> & LabelCommons;
40
27
  /**
41
- * State used in rendering Label
42
- * {@docCategory Label}
28
+ * Label Props
43
29
  */
44
- export interface LabelState extends ComponentState<LabelProps, LabelShorthandProps, LabelDefaultedProps> {
30
+ export declare type LabelProps = Omit<ComponentProps<LabelSlots>, 'required'> & Partial<LabelCommons> & {
45
31
  /**
46
- * Ref to the root element
47
- */
48
- ref: React.Ref<HTMLElement>;
49
- /**
50
- * The required prop resolved to a slot object
32
+ * Displays and indicator that the label is for a required field. The required prop can be set to true to display
33
+ * an asterisk (*). Or it can be set to a string or jsx content to display a different indicator.
34
+ * @defaultvalue false
51
35
  */
52
- required?: ObjectShorthandProps<ComponentProps>;
53
- }
36
+ required?: boolean | Slot<'span'>;
37
+ };
38
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"Label.types.js","sourceRoot":"../src/","sources":["components/Label/Label.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { ComponentProps, ComponentState, ObjectShorthandProps, ShorthandProps } from '@fluentui/react-utilities';\n\n/**\n * Label Props\n * {@docCategory Label}\n */\nexport interface LabelProps extends ComponentProps, React.LabelHTMLAttributes<HTMLLabelElement> {\n /**\n * Renders the label as disabled\n * @defaultvalue false\n */\n disabled?: boolean;\n\n /**\n * Displays and indicator that the label is for a required field. The required prop can be set to true to display\n * an asterisk (*). Or it can be set to a string or jsx content to display a different indicator.\n * @defaultvalue false\n */\n required?: boolean | ShorthandProps<ComponentProps>;\n\n /**\n * A label supports different sizes.\n * @defaultvalue 'medium'\n */\n size?: 'small' | 'medium' | 'large';\n\n /**\n * A label supports semibold/strong fontweight.\n * @defaultvalue false\n */\n strong?: boolean;\n}\n\n/**\n * Names of the shorthand properties in LabelProps\n * {@docCategory Label}\n */\nexport type LabelShorthandProps = 'required';\n\n/**\n * Names of LabelProps that have a default value in useLabel\n * {@docCategory Label}\n */\nexport type LabelDefaultedProps = 'size';\n\n/**\n * State used in rendering Label\n * {@docCategory Label}\n */\nexport interface LabelState extends ComponentState<LabelProps, LabelShorthandProps, LabelDefaultedProps> {\n /**\n * Ref to the root element\n */\n ref: React.Ref<HTMLElement>;\n\n /**\n * The required prop resolved to a slot object\n */\n required?: ObjectShorthandProps<ComponentProps>;\n}\n"]}
1
+ {"version":3,"file":"Label.types.js","sourceRoot":"../src/","sources":["components/Label/Label.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\ntype LabelCommons = {\n /**\n * Renders the label as disabled\n * @defaultvalue false\n */\n disabled: boolean;\n\n /**\n * A label supports different sizes.\n * @defaultvalue 'medium'\n */\n size: 'small' | 'medium' | 'large';\n\n /**\n * A label supports semibold/strong fontweight.\n * @defaultvalue false\n */\n strong: boolean;\n};\n\nexport type LabelSlots = {\n root: Slot<'label'>;\n required?: Slot<'span'>;\n};\n\n/**\n * State used in rendering Label\n */\nexport type LabelState = ComponentState<LabelSlots> & LabelCommons;\n\n/**\n * Label Props\n */\nexport type LabelProps = Omit<ComponentProps<LabelSlots>, 'required'> &\n Partial<LabelCommons> & {\n /**\n * Displays and indicator that the label is for a required field. The required prop can be set to true to display\n * an asterisk (*). Or it can be set to a string or jsx content to display a different indicator.\n * @defaultvalue false\n */\n required?: boolean | Slot<'span'>;\n };\n"]}
@@ -1,6 +1,5 @@
1
- import { LabelState } from './Label.types';
1
+ import type { LabelState } from './Label.types';
2
2
  /**
3
3
  * Render the final JSX of Label
4
- * {@docCategory Label}
5
4
  */
6
- export declare const renderLabel: (state: LabelState) => JSX.Element;
5
+ export declare const renderLabel_unstable: (state: LabelState) => JSX.Element;
@@ -1,15 +1,16 @@
1
- import { __assign } from "tslib";
2
1
  import * as React from 'react';
3
2
  import { getSlots } from '@fluentui/react-utilities';
4
- import { labelShorthandProps } from './useLabel';
5
3
  /**
6
4
  * Render the final JSX of Label
7
- * {@docCategory Label}
8
5
  */
9
- export var renderLabel = function (state) {
10
- var _a = getSlots(state, labelShorthandProps), slots = _a.slots, slotProps = _a.slotProps;
11
- return (React.createElement(slots.root, __assign({}, slotProps.root),
12
- state.children,
13
- state.required && React.createElement(slots.required, __assign({}, slotProps.required))));
6
+
7
+ export const renderLabel_unstable = state => {
8
+ const {
9
+ slots,
10
+ slotProps
11
+ } = getSlots(state);
12
+ return /*#__PURE__*/React.createElement(slots.root, { ...slotProps.root
13
+ }, state.root.children, slots.required && /*#__PURE__*/React.createElement(slots.required, { ...slotProps.required
14
+ }));
14
15
  };
15
16
  //# sourceMappingURL=renderLabel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderLabel.js","sourceRoot":"../src/","sources":["components/Label/renderLabel.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD;;;GAGG;AACH,MAAM,CAAC,IAAM,WAAW,GAAG,UAAC,KAAiB;IACrC,IAAA,KAAuB,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC,EAAzD,KAAK,WAAA,EAAE,SAAS,eAAyC,CAAC;IAElE,OAAO,CACL,oBAAC,KAAK,CAAC,IAAI,eAAK,SAAS,CAAC,IAAI;QAC3B,KAAK,CAAC,QAAQ;QACd,KAAK,CAAC,QAAQ,IAAI,oBAAC,KAAK,CAAC,QAAQ,eAAK,SAAS,CAAC,QAAQ,EAAI,CAClD,CACd,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport { LabelState } from './Label.types';\nimport { labelShorthandProps } from './useLabel';\n\n/**\n * Render the final JSX of Label\n * {@docCategory Label}\n */\nexport const renderLabel = (state: LabelState) => {\n const { slots, slotProps } = getSlots(state, labelShorthandProps);\n\n return (\n <slots.root {...slotProps.root}>\n {state.children}\n {state.required && <slots.required {...slotProps.required} />}\n </slots.root>\n );\n};\n"]}
1
+ {"version":3,"sources":["components/Label/renderLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAGA;;AAEG;;AACH,OAAO,MAAM,oBAAoB,GAAI,KAAD,IAAsB;AACxD,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,MAAuB,QAAQ,CAAa,KAAb,CAArC;AAEA,sBACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;AAAf,GAAX,EACG,KAAK,CAAC,IAAN,CAAW,QADd,EAEG,KAAK,CAAC,QAAN,iBAAkB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,QAAP,EAAe,EAAA,GAAK,SAAS,CAAC;AAAf,GAAf,CAFrB,CADF;AAMD,CATM","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { LabelState, LabelSlots } from './Label.types';\n\n/**\n * Render the final JSX of Label\n */\nexport const renderLabel_unstable = (state: LabelState) => {\n const { slots, slotProps } = getSlots<LabelSlots>(state);\n\n return (\n <slots.root {...slotProps.root}>\n {state.root.children}\n {slots.required && <slots.required {...slotProps.required} />}\n </slots.root>\n );\n};\n"],"sourceRoot":"../src/"}
@@ -1,20 +1,12 @@
1
1
  import * as React from 'react';
2
- import { LabelProps, LabelShorthandProps, LabelState } from './Label.types';
3
- /**
4
- * Array of all shorthand properties listed in LabelShorthandProps
5
- * {@docCatergory Label}
6
- */
7
- export declare const labelShorthandProps: LabelShorthandProps[];
2
+ import type { LabelProps, LabelState } from './Label.types';
8
3
  /**
9
4
  * Create the state required to render Label.
10
5
  *
11
- * The returned state can be modified with hooks such as useLabelStyles,
12
- * before being passed to renderLabel.
6
+ * The returned state can be modified with hooks such as useLabelStyles_unstable,
7
+ * before being passed to renderLabel_unstable.
13
8
  *
14
9
  * @param props - props from this instance of Label
15
10
  * @param ref - reference to root HTMLElement of Label
16
- * @param defaultProps - (optional) default prop values provided by the implementing type
17
- *
18
- * {@docCategory Label}
19
11
  */
20
- export declare const useLabel: (props: LabelProps, ref: React.Ref<HTMLElement>, defaultProps?: LabelProps | undefined) => LabelState;
12
+ export declare const useLabel_unstable: (props: LabelProps, ref: React.Ref<HTMLElement>) => LabelState;
@@ -1,51 +1,39 @@
1
- import { __assign } from "tslib";
2
- import { makeMergeProps, resolveShorthandProps } from '@fluentui/react-utilities';
3
- /**
4
- * Array of all shorthand properties listed in LabelShorthandProps
5
- * {@docCatergory Label}
6
- */
7
- export var labelShorthandProps = ['required'];
8
- var mergeProps = makeMergeProps({ deepMerge: labelShorthandProps });
1
+ import { getNativeElementProps } from '@fluentui/react-utilities';
2
+ import { resolveShorthand } from '@fluentui/react-utilities';
9
3
  /**
10
4
  * Create the state required to render Label.
11
5
  *
12
- * The returned state can be modified with hooks such as useLabelStyles,
13
- * before being passed to renderLabel.
6
+ * The returned state can be modified with hooks such as useLabelStyles_unstable,
7
+ * before being passed to renderLabel_unstable.
14
8
  *
15
9
  * @param props - props from this instance of Label
16
10
  * @param ref - reference to root HTMLElement of Label
17
- * @param defaultProps - (optional) default prop values provided by the implementing type
18
- *
19
- * {@docCategory Label}
20
- */
21
- export var useLabel = function (props, ref, defaultProps) {
22
- var state = mergeProps({
23
- ref: ref,
24
- as: 'label',
25
- size: 'medium',
26
- required: {
27
- as: 'span',
28
- },
29
- }, defaultProps && resolveLabelShorthandProps(defaultProps), resolveLabelShorthandProps(props));
30
- return state;
31
- };
32
- /**
33
- * Label will first need to check if required is a boolean or shorthandprops,
34
- * this allows for the required prop to handle both the default asterisk for required
35
- * or a custom required text.
36
11
  */
37
- var resolveLabelShorthandProps = function (props) {
38
- var propsNormalized;
39
- if (props.required === true) {
40
- propsNormalized = __assign(__assign({}, props), { required: { children: '*' } });
41
- }
42
- else if (props.required === false) {
43
- propsNormalized = __assign(__assign({}, props), { required: undefined });
44
- }
45
- else {
46
- // TypeScript needs a nudge to figure out that props.required won't be a boolean here
47
- propsNormalized = props;
48
- }
49
- return resolveShorthandProps(propsNormalized, labelShorthandProps);
12
+
13
+ export const useLabel_unstable = (props, ref) => {
14
+ const {
15
+ disabled = false,
16
+ required = false,
17
+ strong = false,
18
+ size = 'medium'
19
+ } = props;
20
+ return {
21
+ disabled,
22
+ required: resolveShorthand(required === true ? '*' : required || undefined, {
23
+ defaultProps: {
24
+ 'aria-hidden': 'true'
25
+ }
26
+ }),
27
+ strong,
28
+ size,
29
+ components: {
30
+ root: 'label',
31
+ required: 'span'
32
+ },
33
+ root: getNativeElementProps('label', {
34
+ ref,
35
+ ...props
36
+ })
37
+ };
50
38
  };
51
39
  //# sourceMappingURL=useLabel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLabel.js","sourceRoot":"../src/","sources":["components/Label/useLabel.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGlF;;;GAGG;AACH,MAAM,CAAC,IAAM,mBAAmB,GAA0B,CAAC,UAAU,CAAC,CAAC;AAEvE,IAAM,UAAU,GAAG,cAAc,CAAa,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC,CAAC;AAElF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,IAAM,QAAQ,GAAG,UAAC,KAAiB,EAAE,GAA2B,EAAE,YAAyB;IAChG,IAAM,KAAK,GAAG,UAAU,CACtB;QACE,GAAG,KAAA;QACH,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE;YACR,EAAE,EAAE,MAAM;SACX;KACF,EACD,YAAY,IAAI,0BAA0B,CAAC,YAAY,CAAC,EACxD,0BAA0B,CAAC,KAAK,CAAC,CAClC,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF;;;;GAIG;AACH,IAAM,0BAA0B,GAAG,UAAC,KAAiB;IACnD,IAAI,eAAe,CAAC;IACpB,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,EAAE;QAC3B,eAAe,yBAAQ,KAAK,KAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;KAC7D;SAAM,IAAI,KAAK,CAAC,QAAQ,KAAK,KAAK,EAAE;QACnC,eAAe,yBAAQ,KAAK,KAAE,QAAQ,EAAE,SAAS,GAAE,CAAC;KACrD;SAAM;QACL,qFAAqF;QACrF,eAAe,GAAG,KAA6E,CAAC;KACjG;IAED,OAAO,qBAAqB,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAC;AACrE,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { makeMergeProps, resolveShorthandProps } from '@fluentui/react-utilities';\nimport { LabelProps, LabelShorthandProps, LabelState } from './Label.types';\n\n/**\n * Array of all shorthand properties listed in LabelShorthandProps\n * {@docCatergory Label}\n */\nexport const labelShorthandProps: LabelShorthandProps[] = ['required'];\n\nconst mergeProps = makeMergeProps<LabelState>({ deepMerge: labelShorthandProps });\n\n/**\n * Create the state required to render Label.\n *\n * The returned state can be modified with hooks such as useLabelStyles,\n * before being passed to renderLabel.\n *\n * @param props - props from this instance of Label\n * @param ref - reference to root HTMLElement of Label\n * @param defaultProps - (optional) default prop values provided by the implementing type\n *\n * {@docCategory Label}\n */\nexport const useLabel = (props: LabelProps, ref: React.Ref<HTMLElement>, defaultProps?: LabelProps): LabelState => {\n const state = mergeProps(\n {\n ref,\n as: 'label',\n size: 'medium',\n required: {\n as: 'span',\n },\n },\n defaultProps && resolveLabelShorthandProps(defaultProps),\n resolveLabelShorthandProps(props),\n );\n\n return state;\n};\n\n/**\n * Label will first need to check if required is a boolean or shorthandprops,\n * this allows for the required prop to handle both the default asterisk for required\n * or a custom required text.\n */\nconst resolveLabelShorthandProps = (props: LabelProps) => {\n let propsNormalized;\n if (props.required === true) {\n propsNormalized = { ...props, required: { children: '*' } };\n } else if (props.required === false) {\n propsNormalized = { ...props, required: undefined };\n } else {\n // TypeScript needs a nudge to figure out that props.required won't be a boolean here\n propsNormalized = props as LabelProps & { required?: Exclude<LabelProps['required'], boolean> };\n }\n\n return resolveShorthandProps(propsNormalized, labelShorthandProps);\n};\n"]}
1
+ {"version":3,"sources":["components/Label/useLabel.tsx"],"names":[],"mappings":"AACA,SAAS,qBAAT,QAAsC,2BAAtC;AAEA,SAAS,gBAAT,QAAiC,2BAAjC;AAEA;;;;;;;;AAQG;;AACH,OAAO,MAAM,iBAAiB,GAAG,CAAC,KAAD,EAAoB,GAApB,KAA+D;AAC9F,QAAM;AAAE,IAAA,QAAQ,GAAG,KAAb;AAAoB,IAAA,QAAQ,GAAG,KAA/B;AAAsC,IAAA,MAAM,GAAG,KAA/C;AAAsD,IAAA,IAAI,GAAG;AAA7D,MAA0E,KAAhF;AACA,SAAO;AACL,IAAA,QADK;AAEL,IAAA,QAAQ,EAAE,gBAAgB,CAAC,QAAQ,KAAK,IAAb,GAAoB,GAApB,GAA0B,QAAQ,IAAI,SAAvC,EAAkD;AAC1E,MAAA,YAAY,EAAE;AAAE,uBAAe;AAAjB;AAD4D,KAAlD,CAFrB;AAKL,IAAA,MALK;AAML,IAAA,IANK;AAOL,IAAA,UAAU,EAAE;AAAE,MAAA,IAAI,EAAE,OAAR;AAAiB,MAAA,QAAQ,EAAE;AAA3B,KAPP;AAQL,IAAA,IAAI,EAAE,qBAAqB,CAAC,OAAD,EAAU;AAAE,MAAA,GAAF;AAAO,SAAG;AAAV,KAAV;AARtB,GAAP;AAUD,CAZM","sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps } from '@fluentui/react-utilities';\nimport type { LabelProps, LabelState } from './Label.types';\nimport { resolveShorthand } from '@fluentui/react-utilities';\n\n/**\n * Create the state required to render Label.\n *\n * The returned state can be modified with hooks such as useLabelStyles_unstable,\n * before being passed to renderLabel_unstable.\n *\n * @param props - props from this instance of Label\n * @param ref - reference to root HTMLElement of Label\n */\nexport const useLabel_unstable = (props: LabelProps, ref: React.Ref<HTMLElement>): LabelState => {\n const { disabled = false, required = false, strong = false, size = 'medium' } = props;\n return {\n disabled,\n required: resolveShorthand(required === true ? '*' : required || undefined, {\n defaultProps: { 'aria-hidden': 'true' },\n }),\n strong,\n size,\n components: { root: 'label', required: 'span' },\n root: getNativeElementProps('label', { ref, ...props }),\n };\n};\n"],"sourceRoot":"../src/"}
@@ -1,5 +1,11 @@
1
- import { LabelState } from './Label.types';
1
+ import type { LabelSlots, LabelState } from './Label.types';
2
+ import type { SlotClassNames } from '@fluentui/react-utilities';
3
+ /**
4
+ * @deprecated Use `labelClassNames.root` instead.
5
+ */
6
+ export declare const labelClassName = "fui-Label";
7
+ export declare const labelClassNames: SlotClassNames<LabelSlots>;
2
8
  /**
3
9
  * Apply styling to the Label slots based on the state
4
10
  */
5
- export declare const useLabelStyles: (state: LabelState) => LabelState;
11
+ export declare const useLabelStyles_unstable: (state: LabelState) => LabelState;