@fluentui/react-label 9.3.15 → 9.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,12 +1,21 @@
1
1
  # Change Log - @fluentui/react-label
2
2
 
3
- This log was last generated on Wed, 25 Feb 2026 13:28:23 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 01 Apr 2026 15:50:21 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.4.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-label_v9.4.0)
8
+
9
+ Wed, 01 Apr 2026 15:50:21 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-label_v9.3.15..@fluentui/react-label_v9.4.0)
11
+
12
+ ### Minor changes
13
+
14
+ - feat: add useLabelBase_unstable hook ([PR #35905](https://github.com/microsoft/fluentui/pull/35905) by dmytrokirpa@microsoft.com)
15
+
7
16
  ## [9.3.15](https://github.com/microsoft/fluentui/tree/@fluentui/react-label_v9.3.15)
8
17
 
9
- Wed, 25 Feb 2026 13:28:23 GMT
18
+ Wed, 25 Feb 2026 13:32:28 GMT
10
19
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-label_v9.3.14..@fluentui/react-label_v9.3.15)
11
20
 
12
21
  ### Patches
package/dist/index.d.ts CHANGED
@@ -11,6 +11,17 @@ import type { SlotClassNames } from '@fluentui/react-utilities';
11
11
  */
12
12
  export declare const Label: ForwardRefComponent<LabelProps>;
13
13
 
14
+ /**
15
+ * Label props without design-specific props (size, weight).
16
+ * Use this when building a label that is unstyled or uses a custom design system.
17
+ */
18
+ export declare type LabelBaseProps = Omit<LabelProps, 'size' | 'weight'>;
19
+
20
+ /**
21
+ * Label state without design-specific state (size, weight).
22
+ */
23
+ export declare type LabelBaseState = Omit<LabelState, 'size' | 'weight'>;
24
+
14
25
  export declare const labelClassNames: SlotClassNames<LabelSlots>;
15
26
 
16
27
  /**
@@ -53,7 +64,7 @@ export declare type LabelState = ComponentState<LabelSlots> & Required<Pick<Labe
53
64
  /**
54
65
  * Render the final JSX of Label
55
66
  */
56
- export declare const renderLabel_unstable: (state: LabelState) => JSXElement;
67
+ export declare const renderLabel_unstable: (state: LabelBaseState) => JSXElement;
57
68
 
58
69
  /**
59
70
  * Create the state required to render Label.
@@ -66,6 +77,14 @@ export declare const renderLabel_unstable: (state: LabelState) => JSXElement;
66
77
  */
67
78
  export declare const useLabel_unstable: (props: LabelProps, ref: React_2.Ref<HTMLElement>) => LabelState;
68
79
 
80
+ /**
81
+ * Create the base state required to render Label, without design-specific props (size, weight).
82
+ *
83
+ * @param props - props from this instance of Label
84
+ * @param ref - reference to root HTMLElement of Label
85
+ */
86
+ export declare const useLabelBase_unstable: (props: LabelBaseProps, ref: React_2.Ref<HTMLLabelElement>) => LabelBaseState;
87
+
69
88
  /**
70
89
  * Apply styling to the Label slots based on the state
71
90
  */
package/lib/Label.js CHANGED
@@ -1 +1 @@
1
- export { Label, labelClassNames, renderLabel_unstable, useLabelStyles_unstable, useLabel_unstable } from './components/Label/index';
1
+ export { Label, labelClassNames, renderLabel_unstable, useLabelStyles_unstable, useLabel_unstable, useLabelBase_unstable } from './components/Label/index';
package/lib/Label.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/Label.ts"],"sourcesContent":["export type { LabelProps, LabelSlots, LabelState } from './components/Label/index';\nexport {\n Label,\n labelClassNames,\n renderLabel_unstable,\n useLabelStyles_unstable,\n useLabel_unstable,\n} from './components/Label/index';\n"],"names":["Label","labelClassNames","renderLabel_unstable","useLabelStyles_unstable","useLabel_unstable"],"mappings":"AACA,SACEA,KAAK,EACLC,eAAe,EACfC,oBAAoB,EACpBC,uBAAuB,EACvBC,iBAAiB,QACZ,2BAA2B"}
1
+ {"version":3,"sources":["../src/Label.ts"],"sourcesContent":["export type { LabelBaseProps, LabelBaseState, LabelProps, LabelSlots, LabelState } from './components/Label/index';\nexport {\n Label,\n labelClassNames,\n renderLabel_unstable,\n useLabelStyles_unstable,\n useLabel_unstable,\n useLabelBase_unstable,\n} from './components/Label/index';\n"],"names":["Label","labelClassNames","renderLabel_unstable","useLabelStyles_unstable","useLabel_unstable","useLabelBase_unstable"],"mappings":"AACA,SACEA,KAAK,EACLC,eAAe,EACfC,oBAAoB,EACpBC,uBAAuB,EACvBC,iBAAiB,EACjBC,qBAAqB,QAChB,2BAA2B"}
@@ -1,3 +1,3 @@
1
1
  /**
2
- * State used in rendering Label
2
+ * Label state without design-specific state (size, weight).
3
3
  */ export { };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Label/Label.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\n/**\n * Label Props\n */\nexport type LabelProps = Omit<ComponentProps<LabelSlots>, 'required'> & {\n /**\n * Renders the label as disabled\n * @default false\n */\n disabled?: boolean;\n\n /**\n * Displays an 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 * @default false\n */\n required?: boolean | Slot<'span'>;\n\n /**\n * A label supports different sizes.\n * @default 'medium'\n */\n size?: 'small' | 'medium' | 'large';\n\n /**\n * A label supports regular and semibold fontweight.\n * @default regular\n */\n weight?: 'regular' | 'semibold';\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> & Required<Pick<LabelProps, 'disabled' | 'size' | 'weight'>>;\n"],"names":[],"mappings":"AAqCA;;CAEC,GACD,WAAiH"}
1
+ {"version":3,"sources":["../src/components/Label/Label.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\n/**\n * Label Props\n */\nexport type LabelProps = Omit<ComponentProps<LabelSlots>, 'required'> & {\n /**\n * Renders the label as disabled\n * @default false\n */\n disabled?: boolean;\n\n /**\n * Displays an 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 * @default false\n */\n required?: boolean | Slot<'span'>;\n\n /**\n * A label supports different sizes.\n * @default 'medium'\n */\n size?: 'small' | 'medium' | 'large';\n\n /**\n * A label supports regular and semibold fontweight.\n * @default regular\n */\n weight?: 'regular' | 'semibold';\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> & Required<Pick<LabelProps, 'disabled' | 'size' | 'weight'>>;\n\n/**\n * Label props without design-specific props (size, weight).\n * Use this when building a label that is unstyled or uses a custom design system.\n */\nexport type LabelBaseProps = Omit<LabelProps, 'size' | 'weight'>;\n\n/**\n * Label state without design-specific state (size, weight).\n */\nexport type LabelBaseState = Omit<LabelState, 'size' | 'weight'>;\n"],"names":[],"mappings":"AAgDA;;CAEC,GACD,WAAiE"}
@@ -1,4 +1,4 @@
1
1
  export { Label } from './Label';
2
2
  export { renderLabel_unstable } from './renderLabel';
3
- export { useLabel_unstable } from './useLabel';
3
+ export { useLabel_unstable, useLabelBase_unstable } from './useLabel';
4
4
  export { labelClassNames, useLabelStyles_unstable } from './useLabelStyles.styles';
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Label/index.ts"],"sourcesContent":["export { Label } from './Label';\nexport type { LabelProps, LabelSlots, LabelState } from './Label.types';\nexport { renderLabel_unstable } from './renderLabel';\nexport { useLabel_unstable } from './useLabel';\nexport { labelClassNames, useLabelStyles_unstable } from './useLabelStyles.styles';\n"],"names":["Label","renderLabel_unstable","useLabel_unstable","labelClassNames","useLabelStyles_unstable"],"mappings":"AAAA,SAASA,KAAK,QAAQ,UAAU;AAEhC,SAASC,oBAAoB,QAAQ,gBAAgB;AACrD,SAASC,iBAAiB,QAAQ,aAAa;AAC/C,SAASC,eAAe,EAAEC,uBAAuB,QAAQ,0BAA0B"}
1
+ {"version":3,"sources":["../src/components/Label/index.ts"],"sourcesContent":["export { Label } from './Label';\nexport type { LabelBaseProps, LabelBaseState, LabelProps, LabelSlots, LabelState } from './Label.types';\nexport { renderLabel_unstable } from './renderLabel';\nexport { useLabel_unstable, useLabelBase_unstable } from './useLabel';\nexport { labelClassNames, useLabelStyles_unstable } from './useLabelStyles.styles';\n"],"names":["Label","renderLabel_unstable","useLabel_unstable","useLabelBase_unstable","labelClassNames","useLabelStyles_unstable"],"mappings":"AAAA,SAASA,KAAK,QAAQ,UAAU;AAEhC,SAASC,oBAAoB,QAAQ,gBAAgB;AACrD,SAASC,iBAAiB,EAAEC,qBAAqB,QAAQ,aAAa;AACtE,SAASC,eAAe,EAAEC,uBAAuB,QAAQ,0BAA0B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Label/renderLabel.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } 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): JSXElement => {\n assertSlots<LabelSlots>(state);\n\n return (\n <state.root>\n {state.root.children}\n {state.required && <state.required />}\n </state.root>\n );\n};\n"],"names":["assertSlots","renderLabel_unstable","state","root","children","required"],"mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,4BAA4B;AAIxD;;CAEC,GACD,OAAO,MAAMC,uBAAuB,CAACC;IACnCF,YAAwBE;IAExB,qBACE,MAACA,MAAMC,IAAI;;YACRD,MAAMC,IAAI,CAACC,QAAQ;YACnBF,MAAMG,QAAQ,kBAAI,KAACH,MAAMG,QAAQ;;;AAGxC,EAAE"}
1
+ {"version":3,"sources":["../src/components/Label/renderLabel.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport type { LabelBaseState, LabelSlots } from './Label.types';\n\n/**\n * Render the final JSX of Label\n */\nexport const renderLabel_unstable = (state: LabelBaseState): JSXElement => {\n assertSlots<LabelSlots>(state);\n\n return (\n <state.root>\n {state.root.children}\n {state.required && <state.required />}\n </state.root>\n );\n};\n"],"names":["assertSlots","renderLabel_unstable","state","root","children","required"],"mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,4BAA4B;AAIxD;;CAEC,GACD,OAAO,MAAMC,uBAAuB,CAACC;IACnCF,YAAwBE;IAExB,qBACE,MAACA,MAAMC,IAAI;;YACRD,MAAMC,IAAI,CAACC,QAAQ;YACnBF,MAAMG,QAAQ,kBAAI,KAACH,MAAMG,QAAQ;;;AAGxC,EAAE"}
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from 'react';
2
3
  import { getIntrinsicElementProps, slot } from '@fluentui/react-utilities';
3
4
  /**
@@ -9,7 +10,21 @@ import { getIntrinsicElementProps, slot } from '@fluentui/react-utilities';
9
10
  * @param props - props from this instance of Label
10
11
  * @param ref - reference to root HTMLElement of Label
11
12
  */ export const useLabel_unstable = (props, ref)=>{
12
- const { disabled = false, required = false, weight = 'regular', size = 'medium' } = props;
13
+ const { weight = 'regular', size = 'medium', ...baseProps } = props;
14
+ const state = useLabelBase_unstable(baseProps, ref);
15
+ return {
16
+ weight,
17
+ size,
18
+ ...state
19
+ };
20
+ };
21
+ /**
22
+ * Create the base state required to render Label, without design-specific props (size, weight).
23
+ *
24
+ * @param props - props from this instance of Label
25
+ * @param ref - reference to root HTMLElement of Label
26
+ */ export const useLabelBase_unstable = (props, ref)=>{
27
+ const { disabled = false, required = false, ...rest } = props;
13
28
  return {
14
29
  disabled,
15
30
  required: slot.optional(required === true ? '*' : required || undefined, {
@@ -18,18 +33,13 @@ import { getIntrinsicElementProps, slot } from '@fluentui/react-utilities';
18
33
  },
19
34
  elementType: 'span'
20
35
  }),
21
- weight,
22
- size,
23
36
  components: {
24
37
  root: 'label',
25
38
  required: 'span'
26
39
  },
27
40
  root: slot.always(getIntrinsicElementProps('label', {
28
- // FIXME:
29
- // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLLabelElement`
30
- // but since it would be a breaking change to fix it, we are casting ref to it's proper type
31
41
  ref: ref,
32
- ...props
42
+ ...rest
33
43
  }), {
34
44
  elementType: 'label'
35
45
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Label/useLabel.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getIntrinsicElementProps, slot } from '@fluentui/react-utilities';\nimport type { LabelProps, LabelState } from './Label.types';\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, weight = 'regular', size = 'medium' } = props;\n return {\n disabled,\n required: slot.optional(required === true ? '*' : required || undefined, {\n defaultProps: { 'aria-hidden': 'true' },\n elementType: 'span',\n }),\n weight,\n size,\n components: { root: 'label', required: 'span' },\n root: slot.always(\n getIntrinsicElementProps('label', {\n // FIXME:\n // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLLabelElement`\n // but since it would be a breaking change to fix it, we are casting ref to it's proper type\n ref: ref as React.Ref<HTMLLabelElement>,\n ...props,\n }),\n { elementType: 'label' },\n ),\n };\n};\n"],"names":["React","getIntrinsicElementProps","slot","useLabel_unstable","props","ref","disabled","required","weight","size","optional","undefined","defaultProps","elementType","components","root","always"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,wBAAwB,EAAEC,IAAI,QAAQ,4BAA4B;AAG3E;;;;;;;;CAQC,GACD,OAAO,MAAMC,oBAAoB,CAACC,OAAmBC;IACnD,MAAM,EAAEC,WAAW,KAAK,EAAEC,WAAW,KAAK,EAAEC,SAAS,SAAS,EAAEC,OAAO,QAAQ,EAAE,GAAGL;IACpF,OAAO;QACLE;QACAC,UAAUL,KAAKQ,QAAQ,CAACH,aAAa,OAAO,MAAMA,YAAYI,WAAW;YACvEC,cAAc;gBAAE,eAAe;YAAO;YACtCC,aAAa;QACf;QACAL;QACAC;QACAK,YAAY;YAAEC,MAAM;YAASR,UAAU;QAAO;QAC9CQ,MAAMb,KAAKc,MAAM,CACff,yBAAyB,SAAS;YAChC,SAAS;YACT,8EAA8E;YAC9E,4FAA4F;YAC5FI,KAAKA;YACL,GAAGD,KAAK;QACV,IACA;YAAES,aAAa;QAAQ;IAE3B;AACF,EAAE"}
1
+ {"version":3,"sources":["../src/components/Label/useLabel.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { getIntrinsicElementProps, slot } from '@fluentui/react-utilities';\nimport type { LabelBaseProps, LabelBaseState, LabelProps, LabelState } from './Label.types';\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 { weight = 'regular', size = 'medium', ...baseProps } = props;\n const state = useLabelBase_unstable(baseProps, ref as React.Ref<HTMLLabelElement>);\n\n return {\n weight,\n size,\n ...state,\n };\n};\n\n/**\n * Create the base state required to render Label, without design-specific props (size, weight).\n *\n * @param props - props from this instance of Label\n * @param ref - reference to root HTMLElement of Label\n */\nexport const useLabelBase_unstable = (props: LabelBaseProps, ref: React.Ref<HTMLLabelElement>): LabelBaseState => {\n const { disabled = false, required = false, ...rest } = props;\n return {\n disabled,\n required: slot.optional(required === true ? '*' : required || undefined, {\n defaultProps: { 'aria-hidden': 'true' },\n elementType: 'span',\n }),\n components: { root: 'label', required: 'span' },\n root: slot.always(\n getIntrinsicElementProps('label', {\n ref: ref as React.Ref<HTMLLabelElement>,\n ...rest,\n }),\n { elementType: 'label' },\n ),\n };\n};\n"],"names":["React","getIntrinsicElementProps","slot","useLabel_unstable","props","ref","weight","size","baseProps","state","useLabelBase_unstable","disabled","required","rest","optional","undefined","defaultProps","elementType","components","root","always"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,wBAAwB,EAAEC,IAAI,QAAQ,4BAA4B;AAG3E;;;;;;;;CAQC,GACD,OAAO,MAAMC,oBAAoB,CAACC,OAAmBC;IACnD,MAAM,EAAEC,SAAS,SAAS,EAAEC,OAAO,QAAQ,EAAE,GAAGC,WAAW,GAAGJ;IAC9D,MAAMK,QAAQC,sBAAsBF,WAAWH;IAE/C,OAAO;QACLC;QACAC;QACA,GAAGE,KAAK;IACV;AACF,EAAE;AAEF;;;;;CAKC,GACD,OAAO,MAAMC,wBAAwB,CAACN,OAAuBC;IAC3D,MAAM,EAAEM,WAAW,KAAK,EAAEC,WAAW,KAAK,EAAE,GAAGC,MAAM,GAAGT;IACxD,OAAO;QACLO;QACAC,UAAUV,KAAKY,QAAQ,CAACF,aAAa,OAAO,MAAMA,YAAYG,WAAW;YACvEC,cAAc;gBAAE,eAAe;YAAO;YACtCC,aAAa;QACf;QACAC,YAAY;YAAEC,MAAM;YAASP,UAAU;QAAO;QAC9CO,MAAMjB,KAAKkB,MAAM,CACfnB,yBAAyB,SAAS;YAChCI,KAAKA;YACL,GAAGQ,IAAI;QACT,IACA;YAAEI,aAAa;QAAQ;IAE3B;AACF,EAAE"}
package/lib/index.js CHANGED
@@ -1 +1 @@
1
- export { Label, labelClassNames, renderLabel_unstable, useLabelStyles_unstable, useLabel_unstable } from './Label';
1
+ export { Label, labelClassNames, renderLabel_unstable, useLabelStyles_unstable, useLabel_unstable, useLabelBase_unstable } from './Label';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { Label, labelClassNames, renderLabel_unstable, useLabelStyles_unstable, useLabel_unstable } from './Label';\nexport type { LabelProps, LabelSlots, LabelState } from './Label';\n"],"names":["Label","labelClassNames","renderLabel_unstable","useLabelStyles_unstable","useLabel_unstable"],"mappings":"AAAA,SAASA,KAAK,EAAEC,eAAe,EAAEC,oBAAoB,EAAEC,uBAAuB,EAAEC,iBAAiB,QAAQ,UAAU"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\n Label,\n labelClassNames,\n renderLabel_unstable,\n useLabelStyles_unstable,\n useLabel_unstable,\n useLabelBase_unstable,\n} from './Label';\nexport type { LabelBaseProps, LabelBaseState, LabelProps, LabelSlots, LabelState } from './Label';\n"],"names":["Label","labelClassNames","renderLabel_unstable","useLabelStyles_unstable","useLabel_unstable","useLabelBase_unstable"],"mappings":"AAAA,SACEA,KAAK,EACLC,eAAe,EACfC,oBAAoB,EACpBC,uBAAuB,EACvBC,iBAAiB,EACjBC,qBAAqB,QAChB,UAAU"}
@@ -18,6 +18,9 @@ _export(exports, {
18
18
  renderLabel_unstable: function() {
19
19
  return _index.renderLabel_unstable;
20
20
  },
21
+ useLabelBase_unstable: function() {
22
+ return _index.useLabelBase_unstable;
23
+ },
21
24
  useLabelStyles_unstable: function() {
22
25
  return _index.useLabelStyles_unstable;
23
26
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/Label.ts"],"sourcesContent":["export type { LabelProps, LabelSlots, LabelState } from './components/Label/index';\nexport {\n Label,\n labelClassNames,\n renderLabel_unstable,\n useLabelStyles_unstable,\n useLabel_unstable,\n} from './components/Label/index';\n"],"names":["Label","labelClassNames","renderLabel_unstable","useLabelStyles_unstable","useLabel_unstable"],"mappings":";;;;;;;;;;;;eAEEA,YAAK;;;eACLC,sBAAe;;;eACfC,2BAAoB;;;eACpBC,8BAAuB;;;eACvBC,wBAAiB;;;uBACZ,2BAA2B"}
1
+ {"version":3,"sources":["../src/Label.ts"],"sourcesContent":["export type { LabelBaseProps, LabelBaseState, LabelProps, LabelSlots, LabelState } from './components/Label/index';\nexport {\n Label,\n labelClassNames,\n renderLabel_unstable,\n useLabelStyles_unstable,\n useLabel_unstable,\n useLabelBase_unstable,\n} from './components/Label/index';\n"],"names":["Label","labelClassNames","renderLabel_unstable","useLabelStyles_unstable","useLabel_unstable","useLabelBase_unstable"],"mappings":";;;;;;;;;;;;eAEEA,YAAK;;;eACLC,sBAAe;;;eACfC,2BAAoB;;;eAGpBG,4BAAqB;;;eAFrBF,8BAAuB;;;eACvBC,wBAAiB;;;uBAEZ,2BAA2B"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * State used in rendering Label
2
+ * Label state without design-specific state (size, weight).
3
3
  */ "use strict";
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Label/Label.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\n/**\n * Label Props\n */\nexport type LabelProps = Omit<ComponentProps<LabelSlots>, 'required'> & {\n /**\n * Renders the label as disabled\n * @default false\n */\n disabled?: boolean;\n\n /**\n * Displays an 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 * @default false\n */\n required?: boolean | Slot<'span'>;\n\n /**\n * A label supports different sizes.\n * @default 'medium'\n */\n size?: 'small' | 'medium' | 'large';\n\n /**\n * A label supports regular and semibold fontweight.\n * @default regular\n */\n weight?: 'regular' | 'semibold';\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> & Required<Pick<LabelProps, 'disabled' | 'size' | 'weight'>>;\n"],"names":[],"mappings":"AAqCA;;CAEC,GACD,WAAiH"}
1
+ {"version":3,"sources":["../src/components/Label/Label.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\n/**\n * Label Props\n */\nexport type LabelProps = Omit<ComponentProps<LabelSlots>, 'required'> & {\n /**\n * Renders the label as disabled\n * @default false\n */\n disabled?: boolean;\n\n /**\n * Displays an 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 * @default false\n */\n required?: boolean | Slot<'span'>;\n\n /**\n * A label supports different sizes.\n * @default 'medium'\n */\n size?: 'small' | 'medium' | 'large';\n\n /**\n * A label supports regular and semibold fontweight.\n * @default regular\n */\n weight?: 'regular' | 'semibold';\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> & Required<Pick<LabelProps, 'disabled' | 'size' | 'weight'>>;\n\n/**\n * Label props without design-specific props (size, weight).\n * Use this when building a label that is unstyled or uses a custom design system.\n */\nexport type LabelBaseProps = Omit<LabelProps, 'size' | 'weight'>;\n\n/**\n * Label state without design-specific state (size, weight).\n */\nexport type LabelBaseState = Omit<LabelState, 'size' | 'weight'>;\n"],"names":[],"mappings":"AAgDA;;CAEC,GACD,WAAiE"}
@@ -18,6 +18,9 @@ _export(exports, {
18
18
  renderLabel_unstable: function() {
19
19
  return _renderLabel.renderLabel_unstable;
20
20
  },
21
+ useLabelBase_unstable: function() {
22
+ return _useLabel.useLabelBase_unstable;
23
+ },
21
24
  useLabelStyles_unstable: function() {
22
25
  return _useLabelStylesstyles.useLabelStyles_unstable;
23
26
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Label/index.ts"],"sourcesContent":["export { Label } from './Label';\nexport type { LabelProps, LabelSlots, LabelState } from './Label.types';\nexport { renderLabel_unstable } from './renderLabel';\nexport { useLabel_unstable } from './useLabel';\nexport { labelClassNames, useLabelStyles_unstable } from './useLabelStyles.styles';\n"],"names":["Label","renderLabel_unstable","useLabel_unstable","labelClassNames","useLabelStyles_unstable"],"mappings":";;;;;;;;;;;;eAASA,YAAK;;;eAILG,qCAAe;;;eAFfF,iCAAoB;;;eAEHG,6CAAuB;;;eADxCF,2BAAiB;;;uBAHJ,UAAU;6BAEK,gBAAgB;0BACnB,aAAa;sCACU,0BAA0B"}
1
+ {"version":3,"sources":["../src/components/Label/index.ts"],"sourcesContent":["export { Label } from './Label';\nexport type { LabelBaseProps, LabelBaseState, LabelProps, LabelSlots, LabelState } from './Label.types';\nexport { renderLabel_unstable } from './renderLabel';\nexport { useLabel_unstable, useLabelBase_unstable } from './useLabel';\nexport { labelClassNames, useLabelStyles_unstable } from './useLabelStyles.styles';\n"],"names":["Label","renderLabel_unstable","useLabel_unstable","useLabelBase_unstable","labelClassNames","useLabelStyles_unstable"],"mappings":";;;;;;;;;;;;eAASA,YAAK;;;eAILI,qCAAe;;;eAFfH,iCAAoB;;;eACDE,+BAAqB;;;eACvBE,6CAAuB;;;eADxCH,2BAAiB;;;uBAHJ,UAAU;6BAEK,gBAAgB;0BACI,aAAa;sCACb,0BAA0B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Label/renderLabel.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } 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): JSXElement => {\n assertSlots<LabelSlots>(state);\n\n return (\n <state.root>\n {state.root.children}\n {state.required && <state.required />}\n </state.root>\n );\n};\n"],"names":["assertSlots","renderLabel_unstable","state","root","children","required"],"mappings":";;;;+BAUaC;;;;;;4BATb,iCAAiD;gCAErB,4BAA4B;AAOjD,6BAA6B,CAACC;QACnCF,2BAAAA,EAAwBE;IAExB,OAAA,WAAA,OACE,gBAAA,EAACA,MAAMC,IAAI,EAAA;;YACRD,MAAMC,IAAI,CAACC,QAAQ;YACnBF,MAAMG,QAAQ,IAAA,WAAA,OAAI,eAAA,EAACH,MAAMG,QAAQ,EAAA,CAAA;;;AAGxC,EAAE"}
1
+ {"version":3,"sources":["../src/components/Label/renderLabel.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport type { LabelBaseState, LabelSlots } from './Label.types';\n\n/**\n * Render the final JSX of Label\n */\nexport const renderLabel_unstable = (state: LabelBaseState): JSXElement => {\n assertSlots<LabelSlots>(state);\n\n return (\n <state.root>\n {state.root.children}\n {state.required && <state.required />}\n </state.root>\n );\n};\n"],"names":["assertSlots","renderLabel_unstable","state","root","children","required"],"mappings":";;;;+BAUaC;;;;;;4BATb,iCAAiD;gCAErB,4BAA4B;AAOjD,6BAA6B,CAACC;QACnCF,2BAAAA,EAAwBE;IAExB,OAAA,WAAA,OACE,gBAAA,EAACA,MAAMC,IAAI,EAAA;;YACRD,MAAMC,IAAI,CAACC,QAAQ;YACnBF,MAAMG,QAAQ,IAAA,WAAA,OAAI,eAAA,EAACH,MAAMG,QAAQ,EAAA,CAAA;;;AAGxC,EAAE"}
@@ -1,10 +1,19 @@
1
+ 'use client';
1
2
  "use strict";
2
3
  Object.defineProperty(exports, "__esModule", {
3
4
  value: true
4
5
  });
5
- Object.defineProperty(exports, "useLabel_unstable", {
6
- enumerable: true,
7
- get: function() {
6
+ function _export(target, all) {
7
+ for(var name in all)Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
13
+ useLabelBase_unstable: function() {
14
+ return useLabelBase_unstable;
15
+ },
16
+ useLabel_unstable: function() {
8
17
  return useLabel_unstable;
9
18
  }
10
19
  });
@@ -12,7 +21,16 @@ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildc
12
21
  const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
22
  const _reactutilities = require("@fluentui/react-utilities");
14
23
  const useLabel_unstable = (props, ref)=>{
15
- const { disabled = false, required = false, weight = 'regular', size = 'medium' } = props;
24
+ const { weight = 'regular', size = 'medium', ...baseProps } = props;
25
+ const state = useLabelBase_unstable(baseProps, ref);
26
+ return {
27
+ weight,
28
+ size,
29
+ ...state
30
+ };
31
+ };
32
+ const useLabelBase_unstable = (props, ref)=>{
33
+ const { disabled = false, required = false, ...rest } = props;
16
34
  return {
17
35
  disabled,
18
36
  required: _reactutilities.slot.optional(required === true ? '*' : required || undefined, {
@@ -21,18 +39,13 @@ const useLabel_unstable = (props, ref)=>{
21
39
  },
22
40
  elementType: 'span'
23
41
  }),
24
- weight,
25
- size,
26
42
  components: {
27
43
  root: 'label',
28
44
  required: 'span'
29
45
  },
30
46
  root: _reactutilities.slot.always((0, _reactutilities.getIntrinsicElementProps)('label', {
31
- // FIXME:
32
- // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLLabelElement`
33
- // but since it would be a breaking change to fix it, we are casting ref to it's proper type
34
47
  ref: ref,
35
- ...props
48
+ ...rest
36
49
  }), {
37
50
  elementType: 'label'
38
51
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Label/useLabel.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getIntrinsicElementProps, slot } from '@fluentui/react-utilities';\nimport type { LabelProps, LabelState } from './Label.types';\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, weight = 'regular', size = 'medium' } = props;\n return {\n disabled,\n required: slot.optional(required === true ? '*' : required || undefined, {\n defaultProps: { 'aria-hidden': 'true' },\n elementType: 'span',\n }),\n weight,\n size,\n components: { root: 'label', required: 'span' },\n root: slot.always(\n getIntrinsicElementProps('label', {\n // FIXME:\n // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLLabelElement`\n // but since it would be a breaking change to fix it, we are casting ref to it's proper type\n ref: ref as React.Ref<HTMLLabelElement>,\n ...props,\n }),\n { elementType: 'label' },\n ),\n };\n};\n"],"names":["React","getIntrinsicElementProps","slot","useLabel_unstable","props","ref","disabled","required","weight","size","optional","undefined","defaultProps","elementType","components","root","always"],"mappings":";;;;+BAaaG;;;;;;;iEAbU,QAAQ;gCACgB,4BAA4B;AAYpE,0BAA0B,CAACC,OAAmBC;IACnD,MAAM,EAAEC,WAAW,KAAK,EAAEC,WAAW,KAAK,EAAEC,SAAS,SAAS,EAAEC,OAAO,QAAQ,EAAE,GAAGL;IACpF,OAAO;QACLE;QACAC,UAAUL,oBAAAA,CAAKQ,QAAQ,CAACH,aAAa,OAAO,MAAMA,YAAYI,WAAW;YACvEC,cAAc;gBAAE,eAAe;YAAO;YACtCC,aAAa;QACf;QACAL;QACAC;QACAK,YAAY;YAAEC,MAAM;YAASR,UAAU;QAAO;QAC9CQ,MAAMb,oBAAAA,CAAKc,MAAM,KACff,wCAAAA,EAAyB,SAAS;YAChC,SAAS;YACT,8EAA8E;YAC9E,4FAA4F;YAC5FI,KAAKA;YACL,GAAGD,KAAK;QACV,IACA;YAAES,aAAa;QAAQ;IAE3B;AACF,EAAE"}
1
+ {"version":3,"sources":["../src/components/Label/useLabel.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { getIntrinsicElementProps, slot } from '@fluentui/react-utilities';\nimport type { LabelBaseProps, LabelBaseState, LabelProps, LabelState } from './Label.types';\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 { weight = 'regular', size = 'medium', ...baseProps } = props;\n const state = useLabelBase_unstable(baseProps, ref as React.Ref<HTMLLabelElement>);\n\n return {\n weight,\n size,\n ...state,\n };\n};\n\n/**\n * Create the base state required to render Label, without design-specific props (size, weight).\n *\n * @param props - props from this instance of Label\n * @param ref - reference to root HTMLElement of Label\n */\nexport const useLabelBase_unstable = (props: LabelBaseProps, ref: React.Ref<HTMLLabelElement>): LabelBaseState => {\n const { disabled = false, required = false, ...rest } = props;\n return {\n disabled,\n required: slot.optional(required === true ? '*' : required || undefined, {\n defaultProps: { 'aria-hidden': 'true' },\n elementType: 'span',\n }),\n components: { root: 'label', required: 'span' },\n root: slot.always(\n getIntrinsicElementProps('label', {\n ref: ref as React.Ref<HTMLLabelElement>,\n ...rest,\n }),\n { elementType: 'label' },\n ),\n };\n};\n"],"names":["React","getIntrinsicElementProps","slot","useLabel_unstable","props","ref","weight","size","baseProps","state","useLabelBase_unstable","disabled","required","rest","optional","undefined","defaultProps","elementType","components","root","always"],"mappings":"AAAA;;;;;;;;;;;;yBAgCaU;eAAAA;;qBAjBAP;;;;;iEAbU,QAAQ;gCACgB,4BAA4B;AAYpE,MAAMA,oBAAoB,CAACC,OAAmBC;IACnD,MAAM,EAAEC,SAAS,SAAS,EAAEC,OAAO,QAAQ,EAAE,GAAGC,WAAW,GAAGJ;IAC9D,MAAMK,QAAQC,sBAAsBF,WAAWH;IAE/C,OAAO;QACLC;QACAC;QACA,GAAGE,KAAK;IACV;AACF,EAAE;AAQK,8BAA8B,CAACL,OAAuBC;IAC3D,MAAM,EAAEM,WAAW,KAAK,EAAEC,WAAW,KAAK,EAAE,GAAGC,MAAM,GAAGT;IACxD,OAAO;QACLO;QACAC,UAAUV,oBAAAA,CAAKY,QAAQ,CAACF,aAAa,OAAO,MAAMA,YAAYG,WAAW;YACvEC,cAAc;gBAAE,eAAe;YAAO;YACtCC,aAAa;QACf;QACAC,YAAY;YAAEC,MAAM;YAASP,UAAU;QAAO;QAC9CO,MAAMjB,oBAAAA,CAAKkB,MAAM,KACfnB,wCAAAA,EAAyB,SAAS;YAChCI,KAAKA;YACL,GAAGQ,IAAI;QACT,IACA;YAAEI,aAAa;QAAQ;IAE3B;AACF,EAAE"}
@@ -18,6 +18,9 @@ _export(exports, {
18
18
  renderLabel_unstable: function() {
19
19
  return _Label.renderLabel_unstable;
20
20
  },
21
+ useLabelBase_unstable: function() {
22
+ return _Label.useLabelBase_unstable;
23
+ },
21
24
  useLabelStyles_unstable: function() {
22
25
  return _Label.useLabelStyles_unstable;
23
26
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { Label, labelClassNames, renderLabel_unstable, useLabelStyles_unstable, useLabel_unstable } from './Label';\nexport type { LabelProps, LabelSlots, LabelState } from './Label';\n"],"names":["Label","labelClassNames","renderLabel_unstable","useLabelStyles_unstable","useLabel_unstable"],"mappings":";;;;;;;;;;;;eAASA,YAAK;;;eAAEC,sBAAe;;;eAAEC,2BAAoB;;;eAAEC,8BAAuB;;;eAAEC,wBAAiB;;;uBAAQ,UAAU"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\n Label,\n labelClassNames,\n renderLabel_unstable,\n useLabelStyles_unstable,\n useLabel_unstable,\n useLabelBase_unstable,\n} from './Label';\nexport type { LabelBaseProps, LabelBaseState, LabelProps, LabelSlots, LabelState } from './Label';\n"],"names":["Label","labelClassNames","renderLabel_unstable","useLabelStyles_unstable","useLabel_unstable","useLabelBase_unstable"],"mappings":";;;;;;;;;;;;eACEA,YAAK;;;eACLC,sBAAe;;;eACfC,2BAAoB;;;eAGpBG,4BAAqB;;;eAFrBF,8BAAuB;;;eACvBC,wBAAiB;;;uBAEZ,UAAU"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-label",
3
- "version": "9.3.15",
3
+ "version": "9.4.0",
4
4
  "description": "Fluent UI React Label component",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",