diff --git a/packages/base/src/UI5Element.js b/packages/base/src/UI5Element.js index 9ab23904e245..9060f853f26f 100644 --- a/packages/base/src/UI5Element.js +++ b/packages/base/src/UI5Element.js @@ -11,6 +11,7 @@ import getConstructableStyle from "./theming/getConstructableStyle.js"; import createComponentStyleTag from "./theming/createComponentStyleTag.js"; import getEffectiveStyle from "./theming/getEffectiveStyle.js"; import Integer from "./types/Integer.js"; +import Float from "./types/Float.js"; import { kebabToCamelCase, camelToKebabCase } from "./util/StringHelper.js"; import isValidPropertyName from "./util/isValidPropertyName.js"; import isSlot from "./util/isSlot.js"; @@ -306,6 +307,9 @@ class UI5Element extends HTMLElement { if (propertyTypeClass === Integer) { newValue = parseInt(newValue); } + if (propertyTypeClass === Float) { + newValue = parseFloat(newValue); + } this[nameInCamelCase] = newValue; } } diff --git a/packages/base/src/types/Float.js b/packages/base/src/types/Float.js new file mode 100644 index 000000000000..37508022a7fc --- /dev/null +++ b/packages/base/src/types/Float.js @@ -0,0 +1,10 @@ +import DataType from "./DataType.js"; + +class Float extends DataType { + static isValid(value) { + // Assuming that integers are floats as well! + return Number(value) === value; + } +} + +export default Float; diff --git a/packages/main/bundle.esm.js b/packages/main/bundle.esm.js index 08b5728da6e8..df743600da70 100644 --- a/packages/main/bundle.esm.js +++ b/packages/main/bundle.esm.js @@ -57,6 +57,7 @@ import Select from "./dist/Select.js"; import Switch from "./dist/Switch.js"; import MessageStrip from "./dist/MessageStrip.js"; import MultiComboBox from "./dist/MultiComboBox.js"; +import RatingIndicator from "./dist/RatingIndicator.js"; import TabContainer from "./dist/TabContainer.js"; import Tab from "./dist/Tab.js"; import TabSeparator from "./dist/TabSeparator.js"; diff --git a/packages/main/src/RatingIndicator.hbs b/packages/main/src/RatingIndicator.hbs new file mode 100644 index 000000000000..cc111850e83a --- /dev/null +++ b/packages/main/src/RatingIndicator.hbs @@ -0,0 +1,29 @@ +
+
+ {{#each _stars}} + {{#if this.selected}} +
+ {{else if this.halfStar}} +
+ {{else}} +
+ {{/if}} + {{/each}} +
+
diff --git a/packages/main/src/RatingIndicator.js b/packages/main/src/RatingIndicator.js new file mode 100644 index 000000000000..b5ca70e6f9f0 --- /dev/null +++ b/packages/main/src/RatingIndicator.js @@ -0,0 +1,256 @@ +import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js"; +import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js"; +import { + isDown, + isUp, + isLeft, + isRight, + isSpace, + isEnter, +} from "@ui5/webcomponents-base/dist/Keys.js"; +import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js"; +import Integer from "@ui5/webcomponents-base/dist/types/Integer.js"; +import Float from "@ui5/webcomponents-base/dist/types/Float.js"; +import { + RATING_INDICATOR_TEXT, +} from "./generated/i18n/i18n-defaults.js"; +import RatingIndicatorTemplate from "./generated/templates/RatingIndicatorTemplate.lit.js"; + +// Styles +import RatingIndicatorCss from "./generated/themes/RatingIndicator.css.js"; + +/** + * @public + */ +const metadata = { + tag: "ui5-rating-indicator", + properties: /** @lends sap.ui.webcomponents.main.RatingIndicator.prototype */ { + + /** + * The indicated value of the rating + *

+ * Note: If you set a number which is not round, it would be shown as follows: + *