From aa12c13b2073103a07e6074d9ee682254d0244b4 Mon Sep 17 00:00:00 2001 From: martynasma Date: Fri, 10 May 2024 10:59:18 +0300 Subject: [PATCH] Version 5.9.8 --- package.json | 2 +- packages/shared/CHANGELOG.md | 11 ++++++++ src/.internal/charts/map/MapPolygonSeries.ts | 29 +++++++++++++++++++- src/.internal/charts/xy/XYCursor.ts | 19 ++++++++----- src/.internal/core/Registry.ts | 2 +- src/.internal/core/Root.ts | 16 +++++++++++ src/.internal/core/render/EditableLabel.ts | 13 ++++++--- src/.internal/core/util/Accessibility.ts | 16 +++++++++++ 8 files changed, 94 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 711ab641..cbdbd5d8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@amcharts/amcharts5", - "version": "5.9.7", + "version": "5.9.8", "author": "amCharts (https://www.amcharts.com/)", "description": "amCharts 5", "homepage": "https://www.amcharts.com/", diff --git a/packages/shared/CHANGELOG.md b/packages/shared/CHANGELOG.md index 81bb4560..5a175986 100644 --- a/packages/shared/CHANGELOG.md +++ b/packages/shared/CHANGELOG.md @@ -5,6 +5,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). Please note, that this project, while following numbering syntax, it DOES NOT adhere to [Semantic Versioning](http://semver.org/spec/v2.0.0.html) rules. +## [5.9.8] - 2024-05-10 + +### Added +- Two new settings for `Sprite` added: `ariaCurrent` (sets [`aria-current`](https://w3c.github.io/aria/#aria-current)) and `ariaSelected` (sets [`aria-selected`](https://w3c.github.io/aria/#aria-selected)). +- Two new methods for `MapPolygonSeries` added: `getPolygonByPoint()` and `getPolygonByGeoPoint()`. + +### Fixed +- Better positioning of `EditableLabel` when its `width` is set. +- `alwaysShow` setting of `XYCursor` was not working properly. + + ## [5.9.7] - 2024-05-07 ### Fixed diff --git a/src/.internal/charts/map/MapPolygonSeries.ts b/src/.internal/charts/map/MapPolygonSeries.ts index 7e2c70f8..9c94b464 100644 --- a/src/.internal/charts/map/MapPolygonSeries.ts +++ b/src/.internal/charts/map/MapPolygonSeries.ts @@ -1,5 +1,7 @@ import type { DataItem } from "../../core/render/Component"; import type { Animation } from "../../core/util/Entity"; +import type { IPoint } from "../../core/util/IPoint"; +import type { IGeoPoint } from "../../core/util/IGeoPoint"; import { MapSeries, IMapSeriesSettings, IMapSeriesDataItem, IMapSeriesPrivate } from "./MapSeries"; import { MapPolygon } from "./MapPolygon"; @@ -295,4 +297,29 @@ export class MapPolygonSeries extends MapSeries { } } } -} + + /** + * Returns a [[MapPolygon]] that is under specific X/Y point. + * + * @since 5.9.8 + * @param point X/Y + * @return Polygon + */ + public getPolygonByPoint(point: IPoint): MapPolygon | undefined { + let found: MapPolygon | undefined; + const renderer = this._display._renderer; + const displayObject = (renderer as any).getObjectAtPoint(point); + if (displayObject) { + this.mapPolygons.each(function(polygon) { + if (polygon._display == displayObject) { + found = polygon; + } + }); + return found; + } + } + + public getPolygonByGeoPoint(point: IGeoPoint): MapPolygon | undefined { + return this.getPolygonByPoint(this.chart!.convert(point)); + } +} \ No newline at end of file diff --git a/src/.internal/charts/xy/XYCursor.ts b/src/.internal/charts/xy/XYCursor.ts index 61758ee8..b3961383 100644 --- a/src/.internal/charts/xy/XYCursor.ts +++ b/src/.internal/charts/xy/XYCursor.ts @@ -220,6 +220,8 @@ export class XYCursor extends Container { declare public _privateSettings: IXYCursorPrivate; declare public _events: IXYCursorEvents; + protected _alwaysShow: boolean = false; + /** * A [[Grid]] elment that used for horizontal line of the cursor crosshair. * @@ -366,6 +368,7 @@ export class XYCursor extends Container { } protected _handleLineFocus() { + this._alwaysShow = this.get("alwaysShow", false); this.setAll({ positionX: this.getPrivate("positionX", 0), positionY: this.getPrivate("positionY", 0), @@ -376,11 +379,13 @@ export class XYCursor extends Container { } protected _handleLineBlur() { - this.setAll({ - positionX: undefined, - positionY: undefined, - alwaysShow: false - }); + if (this.lineX.isFocus() || this.lineY.isFocus()) { + this.setAll({ + positionX: undefined, + positionY: undefined, + alwaysShow: this._alwaysShow + }); + } } public _prepareChildren() { @@ -533,8 +538,8 @@ export class XYCursor extends Container { } } this._handleMove(event); - - if(Math.hypot(this._lastPoint2.x - event.point.x, this._lastPoint2.y - event.point.y) > 1) { + + if (Math.hypot(this._lastPoint2.x - event.point.x, this._lastPoint2.y - event.point.y) > 1) { this._handleLineBlur(); this._lastPoint2 = event.point; } diff --git a/src/.internal/core/Registry.ts b/src/.internal/core/Registry.ts index 10967a3f..74b26738 100644 --- a/src/.internal/core/Registry.ts +++ b/src/.internal/core/Registry.ts @@ -6,7 +6,7 @@ export class Registry { /** * Currently running version of amCharts. */ - readonly version: string = "5.9.7"; + readonly version: string = "5.9.8"; /** * List of applied licenses. diff --git a/src/.internal/core/Root.ts b/src/.internal/core/Root.ts index 72f6f4b5..7694bed9 100644 --- a/src/.internal/core/Root.ts +++ b/src/.internal/core/Root.ts @@ -1482,6 +1482,22 @@ export class Root implements IDisposer { focusElement.removeAttribute("aria-checked"); } + const ariaCurrent = target.get("ariaCurrent"); + if (ariaCurrent != null) { + focusElement.setAttribute("aria-current", ariaCurrent); + } + else { + focusElement.removeAttribute("aria-current"); + } + + const ariaSelected = target.get("ariaSelected"); + if (ariaSelected != null && role && ["gridcell", "option", "row", "tab", "columnheader", "rowheader", "treeitem"].indexOf(role) !== -1) { + focusElement.setAttribute("aria-selected", ariaSelected ? "true" : "false"); + } + else { + focusElement.removeAttribute("aria-selected"); + } + if (target.get("ariaHidden")) { focusElement.setAttribute("aria-hidden", "true"); } diff --git a/src/.internal/core/render/EditableLabel.ts b/src/.internal/core/render/EditableLabel.ts index a5e205c3..d02050d3 100644 --- a/src/.internal/core/render/EditableLabel.ts +++ b/src/.internal/core/render/EditableLabel.ts @@ -245,7 +245,6 @@ export class EditableLabel extends Label { // @todo // Size - // Handle maxWidth textarea.style.overflow = "hidden"; const maxWidth = this.get("maxWidth", 0) - this.get("paddingLeft", 0) - this.get("paddingRight", 0); if (maxWidth > 0) { @@ -258,6 +257,12 @@ export class EditableLabel extends Label { textarea.style.height = "auto"; textarea.style.minHeight = textarea.scrollHeight + "px"; + // If width is explicitly set on a label, use it for textarea + if (this.get("width")) { + textarea.style.width = (this.width() - this.get("paddingLeft", 0) - this.get("paddingRight", 0)) + "px"; + textarea.style.minWidth = ""; + } + // Line height const lineHeight = this.get("lineHeight"); if (!lineHeight) { @@ -320,14 +325,14 @@ export class EditableLabel extends Label { const textAlign = this.get("textAlign", "start"); if (textAlign == "center") { textarea.style.textAlign = "center"; - if (!el.style.transform.match(/translateX/)) { + if (!el.style.transform.match(/translateX/) && !this.get("width")) { el.style.transform += " translateX(-50%)"; } } else if (textAlign == "end") { textarea.style.textAlign = "right"; - if (!el.style.transform.match(/translateX/)) { - el.style.transform += "translateX(-100%)"; + if (!el.style.transform.match(/translateX/) && !this.get("width")) { + el.style.transform += " translateX(-100%)"; } } else { diff --git a/src/.internal/core/util/Accessibility.ts b/src/.internal/core/util/Accessibility.ts index 09d8e281..0ac1b364 100644 --- a/src/.internal/core/util/Accessibility.ts +++ b/src/.internal/core/util/Accessibility.ts @@ -72,6 +72,22 @@ export interface IAccessibilitySettings { */ ariaChecked?: boolean; + /** + * `aria-current` setting. + * + * @see {@link https://w3c.github.io/aria/#aria-current} for more info + * @since 5.9.8 + */ + ariaCurrent?: string; + + /** + * `aria-selected` setting. + * + * @see {@link https://w3c.github.io/aria/#aria-selected} for more info + * @since 5.9.8 + */ + ariaSelected?: boolean; + /** * `aria-hidden` setting. */