@fluentui/react-rating 9.0.24 → 9.0.26

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,33 @@
1
1
  # Change Log - @fluentui/react-rating
2
2
 
3
- This log was last generated on Mon, 09 Dec 2024 17:34:09 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 18 Dec 2024 10:58:15 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.0.26](https://github.com/microsoft/fluentui/tree/@fluentui/react-rating_v9.0.26)
8
+
9
+ Wed, 18 Dec 2024 10:58:15 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-rating_v9.0.25..@fluentui/react-rating_v9.0.26)
11
+
12
+ ### Patches
13
+
14
+ - fix: Pass missing Rating's itemLabel prop to its state so RatingItem consumes it from context. ([PR #33361](https://github.com/microsoft/fluentui/pull/33361) by derdem@microsoft.com)
15
+
16
+ ## [9.0.25](https://github.com/microsoft/fluentui/tree/@fluentui/react-rating_v9.0.25)
17
+
18
+ Mon, 16 Dec 2024 16:26:49 GMT
19
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-rating_v9.0.24..@fluentui/react-rating_v9.0.25)
20
+
21
+ ### Patches
22
+
23
+ - Bump @fluentui/react-jsx-runtime to v9.0.48 ([PR #33468](https://github.com/microsoft/fluentui/pull/33468) by beachball)
24
+ - Bump @fluentui/react-theme to v9.1.24 ([PR #33468](https://github.com/microsoft/fluentui/pull/33468) by beachball)
25
+ - Bump @fluentui/react-tabster to v9.23.2 ([PR #33468](https://github.com/microsoft/fluentui/pull/33468) by beachball)
26
+ - Bump @fluentui/react-utilities to v9.18.19 ([PR #33468](https://github.com/microsoft/fluentui/pull/33468) by beachball)
27
+
7
28
  ## [9.0.24](https://github.com/microsoft/fluentui/tree/@fluentui/react-rating_v9.0.24)
8
29
 
9
- Mon, 09 Dec 2024 17:34:09 GMT
30
+ Mon, 09 Dec 2024 17:38:15 GMT
10
31
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-rating_v9.0.23..@fluentui/react-rating_v9.0.24)
11
32
 
12
33
  ### Patches
@@ -12,7 +12,7 @@ import { StarFilled, StarRegular } from '@fluentui/react-icons';
12
12
  * @param ref - reference to root HTMLElement of Rating
13
13
  */ export const useRating_unstable = (props, ref)=>{
14
14
  const generatedName = useId('rating-');
15
- const { color = 'neutral', iconFilled = StarFilled, iconOutline = StarRegular, max = 5, name = generatedName, onChange, step = 1, size = 'extra-large' } = props;
15
+ const { color = 'neutral', iconFilled = StarFilled, iconOutline = StarRegular, max = 5, name = generatedName, onChange, step = 1, size = 'extra-large', itemLabel } = props;
16
16
  const [value, setValue] = useControllableState({
17
17
  state: props.value,
18
18
  defaultState: props.defaultValue,
@@ -38,6 +38,7 @@ import { StarFilled, StarRegular } from '@fluentui/react-icons';
38
38
  name,
39
39
  step,
40
40
  size,
41
+ itemLabel,
41
42
  value,
42
43
  hoveredValue,
43
44
  components: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Rating/useRating.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n getIntrinsicElementProps,\n isHTMLElement,\n mergeCallbacks,\n slot,\n useControllableState,\n useId,\n} from '@fluentui/react-utilities';\nimport type { RatingProps, RatingState } from './Rating.types';\nimport { RatingItem } from '../../RatingItem';\nimport { StarFilled, StarRegular } from '@fluentui/react-icons';\n\n/**\n * Create the state required to render Rating.\n *\n * The returned state can be modified with hooks such as useRatingStyles_unstable,\n * before being passed to renderRating_unstable.\n *\n * @param props - props from this instance of Rating\n * @param ref - reference to root HTMLElement of Rating\n */\nexport const useRating_unstable = (props: RatingProps, ref: React.Ref<HTMLDivElement>): RatingState => {\n const generatedName = useId('rating-');\n const {\n color = 'neutral',\n iconFilled = StarFilled,\n iconOutline = StarRegular,\n max = 5,\n name = generatedName,\n onChange,\n step = 1,\n size = 'extra-large',\n } = props;\n\n const [value, setValue] = useControllableState({\n state: props.value,\n defaultState: props.defaultValue,\n initialState: 0,\n });\n\n const isRatingRadioItem = (target: EventTarget): target is HTMLInputElement =>\n isHTMLElement(target, { constructorName: 'HTMLInputElement' }) && target.type === 'radio' && target.name === name;\n\n const [hoveredValue, setHoveredValue] = React.useState<number | undefined>(undefined);\n\n // Generate the child RatingItems and memoize them to prevent unnecessary re-rendering\n const rootChildren = React.useMemo(() => {\n return Array.from(Array(max), (_, i) => <RatingItem value={i + 1} key={i + 1} />);\n }, [max]);\n\n const state: RatingState = {\n color,\n iconFilled,\n iconOutline,\n name,\n step,\n size,\n value,\n hoveredValue,\n components: {\n root: 'div',\n },\n root: slot.always(\n getIntrinsicElementProps(\n 'div',\n {\n ref,\n children: rootChildren,\n role: 'radiogroup',\n ...props,\n },\n ['onChange'],\n ),\n { elementType: 'div' },\n ),\n };\n\n state.root.onChange = ev => {\n if (isRatingRadioItem(ev.target)) {\n const newValue = parseFloat(ev.target.value);\n if (!isNaN(newValue)) {\n setValue(newValue);\n onChange?.(ev, { type: 'change', event: ev, value: newValue });\n }\n }\n };\n state.root.onMouseOver = mergeCallbacks(props.onMouseOver, ev => {\n if (isRatingRadioItem(ev.target)) {\n const newValue = parseFloat(ev.target.value);\n if (!isNaN(newValue)) {\n setHoveredValue(newValue);\n }\n }\n });\n state.root.onMouseLeave = mergeCallbacks(props.onMouseLeave, ev => {\n setHoveredValue(undefined);\n });\n\n return state;\n};\n"],"names":["React","getIntrinsicElementProps","isHTMLElement","mergeCallbacks","slot","useControllableState","useId","RatingItem","StarFilled","StarRegular","useRating_unstable","props","ref","generatedName","color","iconFilled","iconOutline","max","name","onChange","step","size","value","setValue","state","defaultState","defaultValue","initialState","isRatingRadioItem","target","constructorName","type","hoveredValue","setHoveredValue","useState","undefined","rootChildren","useMemo","Array","from","_","i","key","components","root","always","children","role","elementType","ev","newValue","parseFloat","isNaN","event","onMouseOver","onMouseLeave"],"rangeMappings":";;;;;;;;;;;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,yBACE,OACA;YACEW;YACAkC,UAAUV;YACVW,MAAM;YACN,GAAGpC,KAAK;QACV,GACA;YAAC;SAAW,GAEd;YAAEqC,aAAa;QAAM;IAEzB;IAEAxB,MAAMoB,IAAI,CAACzB,QAAQ,GAAG8B,CAAAA;QACpB,IAAIrB,kBAAkBqB,GAAGpB,MAAM,GAAG;YAChC,MAAMqB,WAAWC,WAAWF,GAAGpB,MAAM,CAACP,KAAK;YAC3C,IAAI,CAAC8B,MAAMF,WAAW;gBACpB3B,SAAS2B;gBACT/B,qBAAAA,+BAAAA,SAAW8B,IAAI;oBAAElB,MAAM;oBAAUsB,OAAOJ;oBAAI3B,OAAO4B;gBAAS;YAC9D;QACF;IACF;IACA1B,MAAMoB,IAAI,CAACU,WAAW,GAAGnD,eAAeQ,MAAM2C,WAAW,EAAEL,CAAAA;QACzD,IAAIrB,kBAAkBqB,GAAGpB,MAAM,GAAG;YAChC,MAAMqB,WAAWC,WAAWF,GAAGpB,MAAM,CAACP,KAAK;YAC3C,IAAI,CAAC8B,MAAMF,WAAW;gBACpBjB,gBAAgBiB;YAClB;QACF;IACF;IACA1B,MAAMoB,IAAI,CAACW,YAAY,GAAGpD,eAAeQ,MAAM4C,YAAY,EAAEN,CAAAA;QAC3DhB,gBAAgBE;IAClB;IAEA,OAAOX;AACT,EAAE"}
1
+ {"version":3,"sources":["../src/components/Rating/useRating.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n getIntrinsicElementProps,\n isHTMLElement,\n mergeCallbacks,\n slot,\n useControllableState,\n useId,\n} from '@fluentui/react-utilities';\nimport type { RatingProps, RatingState } from './Rating.types';\nimport { RatingItem } from '../../RatingItem';\nimport { StarFilled, StarRegular } from '@fluentui/react-icons';\n\n/**\n * Create the state required to render Rating.\n *\n * The returned state can be modified with hooks such as useRatingStyles_unstable,\n * before being passed to renderRating_unstable.\n *\n * @param props - props from this instance of Rating\n * @param ref - reference to root HTMLElement of Rating\n */\nexport const useRating_unstable = (props: RatingProps, ref: React.Ref<HTMLDivElement>): RatingState => {\n const generatedName = useId('rating-');\n const {\n color = 'neutral',\n iconFilled = StarFilled,\n iconOutline = StarRegular,\n max = 5,\n name = generatedName,\n onChange,\n step = 1,\n size = 'extra-large',\n itemLabel,\n } = props;\n\n const [value, setValue] = useControllableState({\n state: props.value,\n defaultState: props.defaultValue,\n initialState: 0,\n });\n\n const isRatingRadioItem = (target: EventTarget): target is HTMLInputElement =>\n isHTMLElement(target, { constructorName: 'HTMLInputElement' }) && target.type === 'radio' && target.name === name;\n\n const [hoveredValue, setHoveredValue] = React.useState<number | undefined>(undefined);\n\n // Generate the child RatingItems and memoize them to prevent unnecessary re-rendering\n const rootChildren = React.useMemo(() => {\n return Array.from(Array(max), (_, i) => <RatingItem value={i + 1} key={i + 1} />);\n }, [max]);\n\n const state: RatingState = {\n color,\n iconFilled,\n iconOutline,\n name,\n step,\n size,\n itemLabel,\n value,\n hoveredValue,\n components: {\n root: 'div',\n },\n root: slot.always(\n getIntrinsicElementProps(\n 'div',\n {\n ref,\n children: rootChildren,\n role: 'radiogroup',\n ...props,\n },\n ['onChange'],\n ),\n { elementType: 'div' },\n ),\n };\n\n state.root.onChange = ev => {\n if (isRatingRadioItem(ev.target)) {\n const newValue = parseFloat(ev.target.value);\n if (!isNaN(newValue)) {\n setValue(newValue);\n onChange?.(ev, { type: 'change', event: ev, value: newValue });\n }\n }\n };\n state.root.onMouseOver = mergeCallbacks(props.onMouseOver, ev => {\n if (isRatingRadioItem(ev.target)) {\n const newValue = parseFloat(ev.target.value);\n if (!isNaN(newValue)) {\n setHoveredValue(newValue);\n }\n }\n });\n state.root.onMouseLeave = mergeCallbacks(props.onMouseLeave, ev => {\n setHoveredValue(undefined);\n });\n\n return state;\n};\n"],"names":["React","getIntrinsicElementProps","isHTMLElement","mergeCallbacks","slot","useControllableState","useId","RatingItem","StarFilled","StarRegular","useRating_unstable","props","ref","generatedName","color","iconFilled","iconOutline","max","name","onChange","step","size","itemLabel","value","setValue","state","defaultState","defaultValue","initialState","isRatingRadioItem","target","constructorName","type","hoveredValue","setHoveredValue","useState","undefined","rootChildren","useMemo","Array","from","_","i","key","components","root","always","children","role","elementType","ev","newValue","parseFloat","isNaN","event","onMouseOver","onMouseLeave"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,wBAAwB,EACxBC,aAAa,EACbC,cAAc,EACdC,IAAI,EACJC,oBAAoB,EACpBC,KAAK,QACA,4BAA4B;AAEnC,SAASC,UAAU,QAAQ,mBAAmB;AAC9C,SAASC,UAAU,EAAEC,WAAW,QAAQ,wBAAwB;AAEhE;;;;;;;;CAQC,GACD,OAAO,MAAMC,qBAAqB,CAACC,OAAoBC;IACrD,MAAMC,gBAAgBP,MAAM;IAC5B,MAAM,EACJQ,QAAQ,SAAS,EACjBC,aAAaP,UAAU,EACvBQ,cAAcP,WAAW,EACzBQ,MAAM,CAAC,EACPC,OAAOL,aAAa,EACpBM,QAAQ,EACRC,OAAO,CAAC,EACRC,OAAO,aAAa,EACpBC,SAAS,EACV,GAAGX;IAEJ,MAAM,CAACY,OAAOC,SAAS,GAAGnB,qBAAqB;QAC7CoB,OAAOd,MAAMY,KAAK;QAClBG,cAAcf,MAAMgB,YAAY;QAChCC,cAAc;IAChB;IAEA,MAAMC,oBAAoB,CAACC,SACzB5B,cAAc4B,QAAQ;YAAEC,iBAAiB;QAAmB,MAAMD,OAAOE,IAAI,KAAK,WAAWF,OAAOZ,IAAI,KAAKA;IAE/G,MAAM,CAACe,cAAcC,gBAAgB,GAAGlC,MAAMmC,QAAQ,CAAqBC;IAE3E,sFAAsF;IACtF,MAAMC,eAAerC,MAAMsC,OAAO,CAAC;QACjC,OAAOC,MAAMC,IAAI,CAACD,MAAMtB,MAAM,CAACwB,GAAGC,kBAAM,oBAACnC;gBAAWgB,OAAOmB,IAAI;gBAAGC,KAAKD,IAAI;;IAC7E,GAAG;QAACzB;KAAI;IAER,MAAMQ,QAAqB;QACzBX;QACAC;QACAC;QACAE;QACAE;QACAC;QACAC;QACAC;QACAU;QACAW,YAAY;YACVC,MAAM;QACR;QACAA,MAAMzC,KAAK0C,MAAM,CACf7C,yBACE,OACA;YACEW;YACAmC,UAAUV;YACVW,MAAM;YACN,GAAGrC,KAAK;QACV,GACA;YAAC;SAAW,GAEd;YAAEsC,aAAa;QAAM;IAEzB;IAEAxB,MAAMoB,IAAI,CAAC1B,QAAQ,GAAG+B,CAAAA;QACpB,IAAIrB,kBAAkBqB,GAAGpB,MAAM,GAAG;YAChC,MAAMqB,WAAWC,WAAWF,GAAGpB,MAAM,CAACP,KAAK;YAC3C,IAAI,CAAC8B,MAAMF,WAAW;gBACpB3B,SAAS2B;gBACThC,qBAAAA,+BAAAA,SAAW+B,IAAI;oBAAElB,MAAM;oBAAUsB,OAAOJ;oBAAI3B,OAAO4B;gBAAS;YAC9D;QACF;IACF;IACA1B,MAAMoB,IAAI,CAACU,WAAW,GAAGpD,eAAeQ,MAAM4C,WAAW,EAAEL,CAAAA;QACzD,IAAIrB,kBAAkBqB,GAAGpB,MAAM,GAAG;YAChC,MAAMqB,WAAWC,WAAWF,GAAGpB,MAAM,CAACP,KAAK;YAC3C,IAAI,CAAC8B,MAAMF,WAAW;gBACpBjB,gBAAgBiB;YAClB;QACF;IACF;IACA1B,MAAMoB,IAAI,CAACW,YAAY,GAAGrD,eAAeQ,MAAM6C,YAAY,EAAEN,CAAAA;QAC3DhB,gBAAgBE;IAClB;IAEA,OAAOX;AACT,EAAE"}
@@ -15,7 +15,7 @@ const _RatingItem = require("../../RatingItem");
15
15
  const _reacticons = require("@fluentui/react-icons");
16
16
  const useRating_unstable = (props, ref)=>{
17
17
  const generatedName = (0, _reactutilities.useId)('rating-');
18
- const { color = 'neutral', iconFilled = _reacticons.StarFilled, iconOutline = _reacticons.StarRegular, max = 5, name = generatedName, onChange, step = 1, size = 'extra-large' } = props;
18
+ const { color = 'neutral', iconFilled = _reacticons.StarFilled, iconOutline = _reacticons.StarRegular, max = 5, name = generatedName, onChange, step = 1, size = 'extra-large', itemLabel } = props;
19
19
  const [value, setValue] = (0, _reactutilities.useControllableState)({
20
20
  state: props.value,
21
21
  defaultState: props.defaultValue,
@@ -41,6 +41,7 @@ const useRating_unstable = (props, ref)=>{
41
41
  name,
42
42
  step,
43
43
  size,
44
+ itemLabel,
44
45
  value,
45
46
  hoveredValue,
46
47
  components: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Rating/useRating.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n getIntrinsicElementProps,\n isHTMLElement,\n mergeCallbacks,\n slot,\n useControllableState,\n useId,\n} from '@fluentui/react-utilities';\nimport type { RatingProps, RatingState } from './Rating.types';\nimport { RatingItem } from '../../RatingItem';\nimport { StarFilled, StarRegular } from '@fluentui/react-icons';\n\n/**\n * Create the state required to render Rating.\n *\n * The returned state can be modified with hooks such as useRatingStyles_unstable,\n * before being passed to renderRating_unstable.\n *\n * @param props - props from this instance of Rating\n * @param ref - reference to root HTMLElement of Rating\n */\nexport const useRating_unstable = (props: RatingProps, ref: React.Ref<HTMLDivElement>): RatingState => {\n const generatedName = useId('rating-');\n const {\n color = 'neutral',\n iconFilled = StarFilled,\n iconOutline = StarRegular,\n max = 5,\n name = generatedName,\n onChange,\n step = 1,\n size = 'extra-large',\n } = props;\n\n const [value, setValue] = useControllableState({\n state: props.value,\n defaultState: props.defaultValue,\n initialState: 0,\n });\n\n const isRatingRadioItem = (target: EventTarget): target is HTMLInputElement =>\n isHTMLElement(target, { constructorName: 'HTMLInputElement' }) && target.type === 'radio' && target.name === name;\n\n const [hoveredValue, setHoveredValue] = React.useState<number | undefined>(undefined);\n\n // Generate the child RatingItems and memoize them to prevent unnecessary re-rendering\n const rootChildren = React.useMemo(() => {\n return Array.from(Array(max), (_, i) => <RatingItem value={i + 1} key={i + 1} />);\n }, [max]);\n\n const state: RatingState = {\n color,\n iconFilled,\n iconOutline,\n name,\n step,\n size,\n value,\n hoveredValue,\n components: {\n root: 'div',\n },\n root: slot.always(\n getIntrinsicElementProps(\n 'div',\n {\n ref,\n children: rootChildren,\n role: 'radiogroup',\n ...props,\n },\n ['onChange'],\n ),\n { elementType: 'div' },\n ),\n };\n\n state.root.onChange = ev => {\n if (isRatingRadioItem(ev.target)) {\n const newValue = parseFloat(ev.target.value);\n if (!isNaN(newValue)) {\n setValue(newValue);\n onChange?.(ev, { type: 'change', event: ev, value: newValue });\n }\n }\n };\n state.root.onMouseOver = mergeCallbacks(props.onMouseOver, ev => {\n if (isRatingRadioItem(ev.target)) {\n const newValue = parseFloat(ev.target.value);\n if (!isNaN(newValue)) {\n setHoveredValue(newValue);\n }\n }\n });\n state.root.onMouseLeave = mergeCallbacks(props.onMouseLeave, ev => {\n setHoveredValue(undefined);\n });\n\n return state;\n};\n"],"names":["useRating_unstable","props","ref","generatedName","useId","color","iconFilled","StarFilled","iconOutline","StarRegular","max","name","onChange","step","size","value","setValue","useControllableState","state","defaultState","defaultValue","initialState","isRatingRadioItem","target","isHTMLElement","constructorName","type","hoveredValue","setHoveredValue","React","useState","undefined","rootChildren","useMemo","Array","from","_","i","createElement","RatingItem","key","components","root","slot","always","getIntrinsicElementProps","children","role","elementType","ev","newValue","parseFloat","isNaN","event","onMouseOver","mergeCallbacks","onMouseLeave"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAsBaA;;;eAAAA;;;;iEAtBU;gCAQhB;4BAEoB;4BACa;AAWjC,MAAMA,qBAAqB,CAACC,OAAoBC;IACrD,MAAMC,gBAAgBC,IAAAA,qBAAAA,EAAM;IAC5B,MAAM,EACJC,QAAQ,SAAS,EACjBC,aAAaC,sBAAU,EACvBC,cAAcC,uBAAW,EACzBC,MAAM,CAAC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AI;oBAAEvB,MAAM;oBAAU2B,OAAOJ;oBAAIlC,OAAOmC;gBAAS;YAC9D;QACF;IACF;IACAhC,MAAMwB,IAAI,CAACY,WAAW,GAAGC,IAAAA,8BAAAA,EAAetD,MAAMqD,WAAW,EAAEL,CAAAA;QACzD,IAAI3B,kBAAkB2B,GAAG1B,MAAM,GAAG;YAChC,MAAM2B,WAAWC,WAAWF,GAAG1B,MAAM,CAACR,KAAK;YAC3C,IAAI,CAACqC,MAAMF,WAAW;gBACpBtB,gBAAgBsB;YAClB;QACF;IACF;IACAhC,MAAMwB,IAAI,CAACc,YAAY,GAAGD,IAAAA,8BAAAA,EAAetD,MAAMuD,YAAY,EAAEP,CAAAA;QAC3DrB,gBAAgBG;IAClB;IAEA,OAAOb;AACT"}
1
+ {"version":3,"sources":["../src/components/Rating/useRating.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n getIntrinsicElementProps,\n isHTMLElement,\n mergeCallbacks,\n slot,\n useControllableState,\n useId,\n} from '@fluentui/react-utilities';\nimport type { RatingProps, RatingState } from './Rating.types';\nimport { RatingItem } from '../../RatingItem';\nimport { StarFilled, StarRegular } from '@fluentui/react-icons';\n\n/**\n * Create the state required to render Rating.\n *\n * The returned state can be modified with hooks such as useRatingStyles_unstable,\n * before being passed to renderRating_unstable.\n *\n * @param props - props from this instance of Rating\n * @param ref - reference to root HTMLElement of Rating\n */\nexport const useRating_unstable = (props: RatingProps, ref: React.Ref<HTMLDivElement>): RatingState => {\n const generatedName = useId('rating-');\n const {\n color = 'neutral',\n iconFilled = StarFilled,\n iconOutline = StarRegular,\n max = 5,\n name = generatedName,\n onChange,\n step = 1,\n size = 'extra-large',\n itemLabel,\n } = props;\n\n const [value, setValue] = useControllableState({\n state: props.value,\n defaultState: props.defaultValue,\n initialState: 0,\n });\n\n const isRatingRadioItem = (target: EventTarget): target is HTMLInputElement =>\n isHTMLElement(target, { constructorName: 'HTMLInputElement' }) && target.type === 'radio' && target.name === name;\n\n const [hoveredValue, setHoveredValue] = React.useState<number | undefined>(undefined);\n\n // Generate the child RatingItems and memoize them to prevent unnecessary re-rendering\n const rootChildren = React.useMemo(() => {\n return Array.from(Array(max), (_, i) => <RatingItem value={i + 1} key={i + 1} />);\n }, [max]);\n\n const state: RatingState = {\n color,\n iconFilled,\n iconOutline,\n name,\n step,\n size,\n itemLabel,\n value,\n hoveredValue,\n components: {\n root: 'div',\n },\n root: slot.always(\n getIntrinsicElementProps(\n 'div',\n {\n ref,\n children: rootChildren,\n role: 'radiogroup',\n ...props,\n },\n ['onChange'],\n ),\n { elementType: 'div' },\n ),\n };\n\n state.root.onChange = ev => {\n if (isRatingRadioItem(ev.target)) {\n const newValue = parseFloat(ev.target.value);\n if (!isNaN(newValue)) {\n setValue(newValue);\n onChange?.(ev, { type: 'change', event: ev, value: newValue });\n }\n }\n };\n state.root.onMouseOver = mergeCallbacks(props.onMouseOver, ev => {\n if (isRatingRadioItem(ev.target)) {\n const newValue = parseFloat(ev.target.value);\n if (!isNaN(newValue)) {\n setHoveredValue(newValue);\n }\n }\n });\n state.root.onMouseLeave = mergeCallbacks(props.onMouseLeave, ev => {\n setHoveredValue(undefined);\n });\n\n return state;\n};\n"],"names":["useRating_unstable","props","ref","generatedName","useId","color","iconFilled","StarFilled","iconOutline","StarRegular","max","name","onChange","step","size","itemLabel","value","setValue","useControllableState","state","defaultState","defaultValue","initialState","isRatingRadioItem","target","isHTMLElement","constructorName","type","hoveredValue","setHoveredValue","React","useState","undefined","rootChildren","useMemo","Array","from","_","i","createElement","RatingItem","key","components","root","slot","always","getIntrinsicElementProps","children","role","elementType","ev","newValue","parseFloat","isNaN","event","onMouseOver","mergeCallbacks","onMouseLeave"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAsBaA;;;eAAAA;;;;iEAtBU;gCAQhB;4BAEoB;4BACa;AAWjC,MAA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GAAG;YAChC,MAAM2B,WAAWC,WAAWF,GAAG1B,MAAM,CAACR,KAAK;YAC3C,IAAI,CAACqC,MAAMF,WAAW;gBACpBlC,SAASkC;gBACTvC,aAAAA,QAAAA,aAAAA,KAAAA,IAAAA,KAAAA,IAAAA,SAAWsC,IAAI;oBAAEvB,MAAM;oBAAU2B,OAAOJ;oBAAIlC,OAAOmC;gBAAS;YAC9D;QACF;IACF;IACAhC,MAAMwB,IAAI,CAACY,WAAW,GAAGC,IAAAA,8BAAAA,EAAevD,MAAMsD,WAAW,EAAEL,CAAAA;QACzD,IAAI3B,kBAAkB2B,GAAG1B,MAAM,GAAG;YAChC,MAAM2B,WAAWC,WAAWF,GAAG1B,MAAM,CAACR,KAAK;YAC3C,IAAI,CAACqC,MAAMF,WAAW;gBACpBtB,gBAAgBsB;YAClB;QACF;IACF;IACAhC,MAAMwB,IAAI,CAACc,YAAY,GAAGD,IAAAA,8BAAAA,EAAevD,MAAMwD,YAAY,EAAEP,CAAAA;QAC3DrB,gBAAgBG;IAClB;IAEA,OAAOb;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-rating",
3
- "version": "9.0.24",
3
+ "version": "9.0.26",
4
4
  "description": "Rating component for building web experiences",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -18,11 +18,11 @@
18
18
  "@fluentui/scripts-api-extractor": "*"
19
19
  },
20
20
  "dependencies": {
21
- "@fluentui/react-jsx-runtime": "^9.0.47",
21
+ "@fluentui/react-jsx-runtime": "^9.0.48",
22
22
  "@fluentui/react-icons": "^2.0.245",
23
- "@fluentui/react-theme": "^9.1.23",
24
- "@fluentui/react-tabster": "^9.23.1",
25
- "@fluentui/react-utilities": "^9.18.18",
23
+ "@fluentui/react-theme": "^9.1.24",
24
+ "@fluentui/react-tabster": "^9.23.2",
25
+ "@fluentui/react-utilities": "^9.18.19",
26
26
  "@griffel/react": "^1.5.22",
27
27
  "@swc/helpers": "^0.5.1"
28
28
  },