@ui5/webcomponents 1.7.2 → 1.7.4

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
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.7.4](https://github.com/SAP/ui5-webcomponents/compare/v1.7.3...v1.7.4) (2022-12-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **ui5-avatar:** fix icon rendering inside ui5-avatar ([#6060](https://github.com/SAP/ui5-webcomponents/issues/6060)) ([0fabac4](https://github.com/SAP/ui5-webcomponents/commit/0fabac43b9d7bc18f478f30177d99c3f63bafa88)), closes [#6043](https://github.com/SAP/ui5-webcomponents/issues/6043)
12
+
13
+
14
+
15
+
16
+
17
+ ## [1.7.2](https://github.com/SAP/ui5-webcomponents/compare/v1.7.1...v1.7.2) (2022-11-07)
18
+
19
+
20
+ ### Features
21
+
22
+ * **ui5-avatar:** support of 3 letters is enabled ([#5870](https://github.com/SAP/ui5-webcomponents/issues/5870)) ([dc533c5](https://github.com/SAP/ui5-webcomponents/commit/dc533c56284198ab80ddb671a0598f3b507fda2f))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [1.7.1](https://github.com/SAP/ui5-webcomponents/compare/v1.7.0...v1.7.1) (2022-09-08)
7
29
 
8
30
 
package/dist/Avatar.js CHANGED
@@ -16,6 +16,8 @@ import AvatarSize from "./types/AvatarSize.js";
16
16
  import AvatarShape from "./types/AvatarShape.js";
17
17
  import AvatarColorScheme from "./types/AvatarColorScheme.js";
18
18
 
19
+ // Icon
20
+ import "@ui5/webcomponents-icons/dist/employee.js";
19
21
  /**
20
22
  * @public
21
23
  */
@@ -372,30 +374,31 @@ class Avatar extends UI5Element {
372
374
  this._onclick = this.interactive ? this._onClickHandler.bind(this) : undefined;
373
375
  }
374
376
 
375
- onEnterDOM() {
376
- this._checkInitialsWidth();
377
+ onAfterRendering() {
378
+ this._checkInitials();
379
+ }
377
380
 
378
- if (!this.validInitials) {
379
- // if initials are not valid,an icon should be shown inside the avatar
380
- this._setFallbackIcon();
381
- }
381
+ onEnterDOM() {
382
+ this._checkInitials();
382
383
  }
383
384
 
384
385
  _setFallbackIcon() {
385
- // the default icon shown inside the avatar,
386
- // when the initials are not valid
387
- this.icon = "employee";
386
+ // if there isn`t icon set in the avatar the default one is shown, when the initials are not valid or are missing
387
+ this.icon = this.icon || "employee";
388
388
  return this.icon;
389
389
  }
390
390
 
391
- _checkInitialsWidth() {
392
- // if initials` width is bigger than the avatar,
393
- // an icon should be shown inside the avatar
391
+ _checkInitials() {
394
392
  const avatar = this.getDomRef(),
395
393
  avatarInitials = avatar.querySelector(".ui5-avatar-initials");
394
+ // if there aren`t initalts set - the fallBack icon should be shown
395
+ if (!this.validInitials) {
396
+ this._setFallbackIcon();
397
+ }
398
+ // if initials` width is bigger than the avatar, an icon should be shown inside the avatar
396
399
  if (this.initials && this.initials.length === 3) {
397
- if (avatarInitials.scrollWidth >= avatar.scrollWidth) {
398
- this.icon = "employee";
400
+ if (avatarInitials && avatarInitials.scrollWidth >= avatar.scrollWidth) {
401
+ this._setFallbackIcon();
399
402
  }
400
403
  }
401
404
  return this.icon;
@@ -1 +1 @@
1
- :host{-webkit-tap-highlight-color:rgba(0,0,0,0)}:host([hidden]){display:none}:host([invalid]){display:none}:host(:not([hidden]).ui5_hovered){opacity:.7}:host{display:inline-block;width:1rem;height:1rem;color:var(--sapContent_NonInteractiveIconColor);fill:currentColor;outline:none}:host([interactive][focused]) .ui5-icon-root{outline:var(--sapContent_FocusWidth) var(--sapContent_FocusStyle) var(--sapContent_FocusColor);border-radius:var(--ui5-icon-focus-border-radius)}.ui5-icon-root{display:flex;outline:none;vertical-align:top}.ui5-icon-root:not([dir=ltr]){transform:var(--_ui5_icon_transform_scale);transform-origin:center}
1
+ :host{-webkit-tap-highlight-color:rgba(0,0,0,0)}:host([hidden]){display:none}:host([invalid]){display:none}:host(:not([hidden]).ui5_hovered){opacity:.7}:host{display:inline-block;width:1rem;height:1rem;color:var(--sapContent_NonInteractiveIconColor);fill:currentColor;outline:none}:host([interactive][focused]) .ui5-icon-root{outline:var(--sapContent_FocusWidth) var(--sapContent_FocusStyle) var(--sapContent_FocusColor);border-radius:var(--ui5-icon-focus-border-radius)}.ui5-icon-root{display:flex;height:100%;width:100%;outline:none;vertical-align:top}.ui5-icon-root:not([dir=ltr]){transform:var(--_ui5_icon_transform_scale);transform-origin:center}
@@ -5,4 +5,4 @@ import defaultTheme from "./sap_fiori_3/parameters-bundle.css.js";
5
5
 
6
6
  registerThemePropertiesLoader("@ui5/webcomponents-theming", "sap_fiori_3", () => defaultThemeBase);
7
7
  registerThemePropertiesLoader("@ui5/webcomponents", "sap_fiori_3", () => defaultTheme);
8
- export default {packageName:"@ui5/webcomponents",fileName:"themes/Icon.css",content:":host{-webkit-tap-highlight-color:rgba(0,0,0,0)}:host([hidden]){display:none}:host([invalid]){display:none}:host(:not([hidden]).ui5_hovered){opacity:.7}:host{display:inline-block;width:1rem;height:1rem;color:var(--sapContent_NonInteractiveIconColor);fill:currentColor;outline:none}:host([interactive][focused]) .ui5-icon-root{outline:var(--sapContent_FocusWidth) var(--sapContent_FocusStyle) var(--sapContent_FocusColor);border-radius:var(--ui5-icon-focus-border-radius)}.ui5-icon-root{display:flex;outline:none;vertical-align:top}.ui5-icon-root:not([dir=ltr]){transform:var(--_ui5_icon_transform_scale);transform-origin:center}"}
8
+ export default {packageName:"@ui5/webcomponents",fileName:"themes/Icon.css",content:":host{-webkit-tap-highlight-color:rgba(0,0,0,0)}:host([hidden]){display:none}:host([invalid]){display:none}:host(:not([hidden]).ui5_hovered){opacity:.7}:host{display:inline-block;width:1rem;height:1rem;color:var(--sapContent_NonInteractiveIconColor);fill:currentColor;outline:none}:host([interactive][focused]) .ui5-icon-root{outline:var(--sapContent_FocusWidth) var(--sapContent_FocusStyle) var(--sapContent_FocusColor);border-radius:var(--ui5-icon-focus-border-radius)}.ui5-icon-root{display:flex;height:100%;width:100%;outline:none;vertical-align:top}.ui5-icon-root:not([dir=ltr]){transform:var(--_ui5_icon_transform_scale);transform-origin:center}"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/webcomponents",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "description": "UI5 Web Components: webcomponents.main",
5
5
  "ui5": {
6
6
  "webComponentsPackage": true
@@ -41,13 +41,13 @@
41
41
  "directory": "packages/main"
42
42
  },
43
43
  "dependencies": {
44
- "@ui5/webcomponents-base": "1.7.2",
45
- "@ui5/webcomponents-icons": "1.7.2",
46
- "@ui5/webcomponents-localization": "1.7.2",
47
- "@ui5/webcomponents-theming": "1.7.2"
44
+ "@ui5/webcomponents-base": "1.7.4",
45
+ "@ui5/webcomponents-icons": "1.7.4",
46
+ "@ui5/webcomponents-localization": "1.7.4",
47
+ "@ui5/webcomponents-theming": "1.7.4"
48
48
  },
49
49
  "devDependencies": {
50
- "@ui5/webcomponents-tools": "1.7.2",
50
+ "@ui5/webcomponents-tools": "1.7.4",
51
51
  "chromedriver": "104.0.0"
52
52
  }
53
53
  }
package/src/Avatar.js CHANGED
@@ -16,6 +16,8 @@ import AvatarSize from "./types/AvatarSize.js";
16
16
  import AvatarShape from "./types/AvatarShape.js";
17
17
  import AvatarColorScheme from "./types/AvatarColorScheme.js";
18
18
 
19
+ // Icon
20
+ import "@ui5/webcomponents-icons/dist/employee.js";
19
21
  /**
20
22
  * @public
21
23
  */
@@ -372,30 +374,31 @@ class Avatar extends UI5Element {
372
374
  this._onclick = this.interactive ? this._onClickHandler.bind(this) : undefined;
373
375
  }
374
376
 
375
- onEnterDOM() {
376
- this._checkInitialsWidth();
377
+ onAfterRendering() {
378
+ this._checkInitials();
379
+ }
377
380
 
378
- if (!this.validInitials) {
379
- // if initials are not valid,an icon should be shown inside the avatar
380
- this._setFallbackIcon();
381
- }
381
+ onEnterDOM() {
382
+ this._checkInitials();
382
383
  }
383
384
 
384
385
  _setFallbackIcon() {
385
- // the default icon shown inside the avatar,
386
- // when the initials are not valid
387
- this.icon = "employee";
386
+ // if there isn`t icon set in the avatar the default one is shown, when the initials are not valid or are missing
387
+ this.icon = this.icon || "employee";
388
388
  return this.icon;
389
389
  }
390
390
 
391
- _checkInitialsWidth() {
392
- // if initials` width is bigger than the avatar,
393
- // an icon should be shown inside the avatar
391
+ _checkInitials() {
394
392
  const avatar = this.getDomRef(),
395
393
  avatarInitials = avatar.querySelector(".ui5-avatar-initials");
394
+ // if there aren`t initalts set - the fallBack icon should be shown
395
+ if (!this.validInitials) {
396
+ this._setFallbackIcon();
397
+ }
398
+ // if initials` width is bigger than the avatar, an icon should be shown inside the avatar
396
399
  if (this.initials && this.initials.length === 3) {
397
- if (avatarInitials.scrollWidth >= avatar.scrollWidth) {
398
- this.icon = "employee";
400
+ if (avatarInitials && avatarInitials.scrollWidth >= avatar.scrollWidth) {
401
+ this._setFallbackIcon();
399
402
  }
400
403
  }
401
404
  return this.icon;
@@ -0,0 +1,176 @@
1
+ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
2
+ import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
3
+ import { fetchCldr } from "@ui5/webcomponents-base/dist/asset-registries/LocaleData.js";
4
+ import I18nBundle, { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
5
+ import { getCalendarType } from "@ui5/webcomponents-base/dist/config/CalendarType.js";
6
+ import DateFormat from "@ui5/webcomponents-localization/dist/DateFormat.js";
7
+ import getCachedLocaleDataInstance from "@ui5/webcomponents-localization/dist/getCachedLocaleDataInstance.js";
8
+ import CalendarType from "@ui5/webcomponents-base/dist/types/CalendarType.js";
9
+ import getLocale from "@ui5/webcomponents-base/dist/locale/getLocale.js";
10
+ import CalendarDate from "@ui5/webcomponents-localization/dist/dates/CalendarDate.js";
11
+ // @ts-ignore
12
+ import { getMaxCalendarDate, getMinCalendarDate } from "@ui5/webcomponents-localization/dist/dates/ExtremeDates.js";
13
+
14
+ /**
15
+ * @public
16
+ */
17
+ const metadata = {
18
+ languageAware: true,
19
+ properties: /** @lends sap.ui.webc.main.DateComponentBase.prototype */ {
20
+ /**
21
+ * Sets a calendar type used for display.
22
+ * If not set, the calendar type of the global configuration is used.
23
+ * @type {sap.ui.webc.base.types.CalendarType}
24
+ * @public
25
+ */
26
+ primaryCalendarType: {
27
+ type: CalendarType,
28
+ },
29
+
30
+ /**
31
+ * Defines the secondary calendar type.
32
+ * If not set, the calendar will only show the primary calendar type.
33
+ * @type {sap.ui.webc.base.types.CalendarType}
34
+ * @since 1.0.0-rc.16
35
+ * @defaultvalue undefined
36
+ * @public
37
+ */
38
+ secondaryCalendarType: {
39
+ type: CalendarType,
40
+ },
41
+
42
+ /**
43
+ * Determines the minimum date available for selection.
44
+ *
45
+ * @type {string}
46
+ * @defaultvalue ""
47
+ * @since 1.0.0-rc.6
48
+ * @public
49
+ */
50
+ minDate: {
51
+ type: String,
52
+ },
53
+
54
+ /**
55
+ * Determines the maximum date available for selection.
56
+ *
57
+ * @type {string}
58
+ * @defaultvalue ""
59
+ * @since 1.0.0-rc.6
60
+ * @public
61
+ */
62
+ maxDate: {
63
+ type: String,
64
+ },
65
+
66
+ /**
67
+ * Determines the format, displayed in the input field.
68
+ *
69
+ * @type {string}
70
+ * @defaultvalue ""
71
+ * @public
72
+ */
73
+ formatPattern: {
74
+ type: String,
75
+ },
76
+ },
77
+ };
78
+
79
+ /**
80
+ * @class
81
+ *
82
+ * Abstract class that provides common functionality for date-related components (day picker, month picker, year picker, calendar, date picker, date range picker, date time picker)
83
+ * This includes:
84
+ * - "languageAware: true" metadata setting, CLDR fetch and i18n initialization
85
+ * - common properties (primaryCalendar, minDate, maxDate and formatPattern) declaration and methods that operate on them
86
+ * - additional common methods
87
+ *
88
+ * @constructor
89
+ * @author SAP SE
90
+ * @alias sap.ui.webc.main.DateComponentBase
91
+ * @extends sap.ui.webc.base.UI5Element
92
+ * @public
93
+ */
94
+ class DateComponentBase extends UI5Element {
95
+ primaryCalendarType!: string;
96
+ minDate!: string;
97
+ maxDate!: string;
98
+ formatPattern!: string;
99
+
100
+ static i18nBundle?: I18nBundle;
101
+
102
+ static get metadata() {
103
+ return metadata;
104
+ }
105
+
106
+ static get render() {
107
+ return litRender;
108
+ }
109
+
110
+ constructor() {
111
+ super();
112
+ }
113
+
114
+ get _primaryCalendarType() {
115
+ const localeData = getCachedLocaleDataInstance(getLocale());
116
+ return this.primaryCalendarType || getCalendarType() || localeData.getPreferredCalendarType();
117
+ }
118
+
119
+ get _minDate() {
120
+ return this.minDate && this.getFormat().parse(this.minDate) ? this._getCalendarDateFromString(this.minDate) : getMinCalendarDate(this._primaryCalendarType);
121
+ }
122
+
123
+ get _maxDate() {
124
+ return this.maxDate && this.getFormat().parse(this.maxDate) ? this._getCalendarDateFromString(this.maxDate) : getMaxCalendarDate(this._primaryCalendarType);
125
+ }
126
+
127
+ get _formatPattern() {
128
+ return this.formatPattern || "medium"; // get from config
129
+ }
130
+
131
+ get _isPattern() {
132
+ return this._formatPattern !== "medium" && this._formatPattern !== "short" && this._formatPattern !== "long";
133
+ }
134
+
135
+ _getCalendarDateFromString(value: string) {
136
+ const jsDate = this.getFormat().parse(value);
137
+ if (jsDate) {
138
+ return CalendarDate.fromLocalJSDate(jsDate, this._primaryCalendarType);
139
+ }
140
+ }
141
+
142
+ _getTimeStampFromString(value: string) {
143
+ const calDate = this._getCalendarDateFromString(value);
144
+ if (calDate) {
145
+ return calDate.toUTCJSDate().valueOf();
146
+ }
147
+ }
148
+
149
+ _getStringFromTimestamp(timestamp: number) {
150
+ const localDate = new Date(timestamp);
151
+ return this.getFormat().format(localDate, true);
152
+ }
153
+
154
+ getFormat() {
155
+ return this._isPattern
156
+ ? DateFormat.getInstance({
157
+ strictParsing: true,
158
+ pattern: this._formatPattern,
159
+ calendarType: this._primaryCalendarType,
160
+ })
161
+ : DateFormat.getInstance({
162
+ strictParsing: true,
163
+ style: this._formatPattern,
164
+ calendarType: this._primaryCalendarType,
165
+ });
166
+ }
167
+
168
+ static async onDefine() {
169
+ [DateComponentBase.i18nBundle] = await Promise.all([
170
+ getI18nBundle("@ui5/webcomponents"),
171
+ fetchCldr(getLocale().getLanguage(), getLocale().getRegion(), getLocale().getScript()),
172
+ ]);
173
+ }
174
+ }
175
+
176
+ export default DateComponentBase;
@@ -29,6 +29,8 @@
29
29
 
30
30
  .ui5-icon-root {
31
31
  display:flex;
32
+ height: 100%;
33
+ width: 100%;
32
34
  outline: none;
33
35
  vertical-align: top;
34
36
  }