@fluentui/web-components 3.0.0-beta.54 → 3.0.0-beta.55

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.
@@ -8685,7 +8685,7 @@ var __decorateClass$8 = (decorators, target, key, kind) => {
8685
8685
  if (kind && result) __defProp$8(target, key, result);
8686
8686
  return result;
8687
8687
  };
8688
- class RatingDisplay extends FASTElement {
8688
+ class BaseRatingDisplay extends FASTElement {
8689
8689
  constructor() {
8690
8690
  super();
8691
8691
  /**
@@ -8694,10 +8694,62 @@ class RatingDisplay extends FASTElement {
8694
8694
  * @internal
8695
8695
  */
8696
8696
  this.elementInternals = this.attachInternals();
8697
- this.compact = false;
8698
8697
  this.intlNumberFormatter = new Intl.NumberFormat();
8699
8698
  this.elementInternals.role = "img";
8700
8699
  }
8700
+ /**
8701
+ * Returns "count" as string, formatted according to the locale.
8702
+ *
8703
+ * @internal
8704
+ */
8705
+ get formattedCount() {
8706
+ return this.count ? this.intlNumberFormatter.format(this.count) : "";
8707
+ }
8708
+ /**
8709
+ * Gets the selected value
8710
+ *
8711
+ * @protected
8712
+ */
8713
+ getSelectedValue() {
8714
+ return Math.round((this.value ?? 0) * 2) / 2;
8715
+ }
8716
+ /**
8717
+ * Gets the maximum icons to render
8718
+ *
8719
+ * @protected
8720
+ */
8721
+ getMaxIcons() {
8722
+ return (this.max ?? 5) * 2;
8723
+ }
8724
+ /**
8725
+ * Generates the icon SVG elements based on the "max" attribute.
8726
+ *
8727
+ * @internal
8728
+ */
8729
+ generateIcons() {
8730
+ let htmlString = "";
8731
+ const selectedValue = this.getSelectedValue();
8732
+ for (let i = 0; i < this.getMaxIcons(); i++) {
8733
+ const iconValue = (i + 1) / 2;
8734
+ htmlString += `<svg aria-hidden="true" ${iconValue === selectedValue ? "selected" : ""}><use href="#star"></use></svg>`;
8735
+ }
8736
+ return htmlString;
8737
+ }
8738
+ }
8739
+ __decorateClass$8([attr({
8740
+ converter: nullableNumberConverter
8741
+ })], BaseRatingDisplay.prototype, "count", 2);
8742
+ __decorateClass$8([attr({
8743
+ converter: nullableNumberConverter
8744
+ })], BaseRatingDisplay.prototype, "max", 2);
8745
+ __decorateClass$8([attr({
8746
+ converter: nullableNumberConverter
8747
+ })], BaseRatingDisplay.prototype, "value", 2);
8748
+ class RatingDisplay extends BaseRatingDisplay {
8749
+ constructor() {
8750
+ super(...arguments);
8751
+ this.compact = false;
8752
+ }
8701
8753
  /**
8702
8754
  * Handles changes to the color attribute.
8703
8755
  *
@@ -8719,42 +8771,27 @@ class RatingDisplay extends FASTElement {
8719
8771
  if (next) toggleState(this.elementInternals, next, true);
8720
8772
  }
8721
8773
  /**
8722
- * Returns "count" as string, formatted according to the locale.
8774
+ * Overrides the selected value and returns 1 if compact is true.
8723
8775
  *
8724
- * @internal
8776
+ * @override
8725
8777
  */
8726
- get formattedCount() {
8727
- return this.count ? this.intlNumberFormatter.format(this.count) : "";
8778
+ getSelectedValue() {
8779
+ return Math.round((this.compact ? 1 : this.value ?? 0) * 2) / 2;
8728
8780
  }
8729
8781
  /**
8730
- * Generates the icon SVG elements based on the "max" attribute.
8782
+ * Overrides the maximum icons and returns a max of 1 if compact is true.
8731
8783
  *
8732
- * @internal
8784
+ * @override
8733
8785
  */
8734
- generateIcons() {
8735
- let htmlString = "";
8736
- const selectedValue = Math.round((this.compact ? 1 : this.value ?? 0) * 2) / 2;
8737
- for (let i = 0; i < (this.compact ? 1 : this.max ?? 5) * 2; i++) {
8738
- const iconValue = (i + 1) / 2;
8739
- htmlString += `<svg aria-hidden="true" ${iconValue === selectedValue ? "selected" : ""}><use href="#star"></use></svg>`;
8740
- }
8741
- return htmlString;
8786
+ getMaxIcons() {
8787
+ return (this.compact ? 1 : this.max ?? 5) * 2;
8742
8788
  }
8743
8789
  }
8744
8790
  __decorateClass$8([attr], RatingDisplay.prototype, "color", 2);
8791
+ __decorateClass$8([attr], RatingDisplay.prototype, "size", 2);
8745
8792
  __decorateClass$8([attr({
8746
8793
  mode: "boolean"
8747
8794
  })], RatingDisplay.prototype, "compact", 2);
8748
- __decorateClass$8([attr({
8749
- converter: nullableNumberConverter
8750
- })], RatingDisplay.prototype, "count", 2);
8751
- __decorateClass$8([attr({
8752
- converter: nullableNumberConverter
8753
- })], RatingDisplay.prototype, "max", 2);
8754
- __decorateClass$8([attr], RatingDisplay.prototype, "size", 2);
8755
- __decorateClass$8([attr({
8756
- converter: nullableNumberConverter
8757
- })], RatingDisplay.prototype, "value", 2);
8758
8795
 
8759
8796
  const styles$a = css`
8760
8797
  ${display("inline-flex")}