File tree Expand file tree Collapse file tree 8 files changed +40
-26
lines changed
Expand file tree Collapse file tree 8 files changed +40
-26
lines changed Original file line number Diff line number Diff line change 1+ const features = new Map ( ) ;
2+
3+ const registerFeature = ( name , feature ) => {
4+ features . set ( name , feature ) ;
5+ } ;
6+
7+ const getFeature = name => {
8+ return features . get ( name ) ;
9+ } ;
10+
11+ export { registerFeature , getFeature } ;
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import Bootstrap from "@ui5/webcomponents-base/src/Bootstrap.js";
33import { isSpace , isEnter } from "@ui5/webcomponents-base/src/events/PseudoEvents.js" ;
44import { getCompactSize } from "@ui5/webcomponents-base/src/Configuration.js" ;
55import getEffectiveRTL from "@ui5/webcomponents-base/src/util/getEffectiveRTL.js" ;
6+ import { getFeature } from "@ui5/webcomponents-base/src/FeaturesRegistry.js" ;
67import ButtonType from "./types/ButtonType.js" ;
78import ButtonRenderer from "./build/compiled/ButtonRenderer.lit.js" ;
89import Icon from "./Icon.js" ;
@@ -193,7 +194,8 @@ class Button extends UI5Element {
193194 }
194195
195196 onBeforeRendering ( ) {
196- if ( this . submits && ! Button . FormSupport ) {
197+ const FormSupport = getFeature ( "FormSupport" ) ;
198+ if ( this . submits && ! FormSupport ) {
197199 console . warn ( `In order for the "submits" property to have effect, you should also: import InputElementsFormSupport from "@ui5/webcomponents/dist/InputElementsFormSupport";` ) ; // eslint-disable-line
198200 }
199201 }
@@ -210,8 +212,9 @@ class Button extends UI5Element {
210212 event . isMarked = "button" ;
211213 if ( ! this . disabled ) {
212214 this . fireEvent ( "press" , { } ) ;
213- if ( Button . FormSupport ) {
214- Button . FormSupport . triggerFormSubmit ( this ) ;
215+ const FormSupport = getFeature ( "FormSupport" ) ;
216+ if ( FormSupport ) {
217+ FormSupport . triggerFormSubmit ( this ) ;
215218 }
216219 }
217220 }
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import UI5Element from "@ui5/webcomponents-base/src/UI5Element.js";
33import Bootstrap from "@ui5/webcomponents-base/src/Bootstrap.js" ;
44import ValueState from "@ui5/webcomponents-base/src/types/ValueState.js" ;
55import { getCompactSize } from "@ui5/webcomponents-base/src/Configuration.js" ;
6+ import { getFeature } from "@ui5/webcomponents-base/src/FeaturesRegistry.js" ;
67import getEffectiveRTL from "@ui5/webcomponents-base/src/util/getEffectiveRTL.js" ;
78import { isSpace , isEnter } from "@ui5/webcomponents-base/src/events/PseudoEvents.js" ;
89import CheckBoxRenderer from "./build/compiled/CheckBoxRenderer.lit.js" ;
@@ -204,8 +205,9 @@ class CheckBox extends UI5Element {
204205 }
205206
206207 _enableFormSupport ( ) {
207- if ( CheckBox . FormSupport ) {
208- CheckBox . FormSupport . syncNativeHiddenInput ( this , ( element , nativeInput ) => {
208+ const FormSupport = getFeature ( "FormSupport" ) ;
209+ if ( FormSupport ) {
210+ FormSupport . syncNativeHiddenInput ( this , ( element , nativeInput ) => {
209211 nativeInput . disabled = element . disabled || ! element . checked ;
210212 nativeInput . value = element . checked ? "on" : "" ;
211213 } ) ;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import Bootstrap from "@ui5/webcomponents-base/src/Bootstrap.js";
66import { getCalendarType } from "@ui5/webcomponents-base/src/Configuration.js" ;
77import { getLocale } from "@ui5/webcomponents-base/src/LocaleProvider.js" ;
88import { getIconURI } from "@ui5/webcomponents-base/src/IconPool.js" ;
9+ import { getFeature } from "@ui5/webcomponents-base/src/FeaturesRegistry.js" ;
910import LocaleData from "@ui5/webcomponents-core/dist/sap/ui/core/LocaleData.js" ;
1011import DateFormat from "@ui5/webcomponents-core/dist/sap/ui/core/format/DateFormat.js" ;
1112import CalendarType from "@ui5/webcomponents-base/src/dates/CalendarType.js" ;
@@ -308,8 +309,9 @@ class DatePicker extends UI5Element {
308309 this . _calendar . selectedDates = [ ] ;
309310 }
310311
311- if ( DatePicker . FormSupport ) {
312- DatePicker . FormSupport . syncNativeHiddenInput ( this ) ;
312+ const FormSupport = getFeature ( "FormSupport" ) ;
313+ if ( FormSupport ) {
314+ FormSupport . syncNativeHiddenInput ( this ) ;
313315 } else if ( this . name ) {
314316 console . warn ( `In order for the "name" property to have effect, you should also: import InputElementsFormSupport from "@ui5/webcomponents/dist/InputElementsFormSupport";` ) ; // eslint-disable-line
315317 }
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import Bootstrap from "@ui5/webcomponents-base/src/Bootstrap.js";
33import { isIE } from "@ui5/webcomponents-core/dist/sap/ui/Device.js" ;
44import ValueState from "@ui5/webcomponents-base/src/types/ValueState.js" ;
55import { getCompactSize } from "@ui5/webcomponents-base/src/Configuration.js" ;
6+ import { getFeature } from "@ui5/webcomponents-base/src/FeaturesRegistry.js" ;
67import {
78 isUp ,
89 isDown ,
@@ -329,8 +330,9 @@ class Input extends UI5Element {
329330 this . enableSuggestions ( ) ;
330331 }
331332
332- if ( Input . FormSupport ) {
333- Input . FormSupport . syncNativeHiddenInput ( this ) ;
333+ const FormSupport = getFeature ( "FormSupport" ) ;
334+ if ( FormSupport ) {
335+ FormSupport . syncNativeHiddenInput ( this ) ;
334336 } else if ( this . name ) {
335337 console . warn ( `In order for the "name" property to have effect, you should also: import InputElementsFormSupport from "@ui5/webcomponents/dist/InputElementsFormSupport";` ) ; // eslint-disable-line
336338 }
Original file line number Diff line number Diff line change 1- import Input from "./Input.js" ;
2- import TextArea from "./TextArea.js" ;
3- import DatePicker from "./DatePicker.js" ;
4- import CheckBox from "./CheckBox.js" ;
5- import RadioButton from "./RadioButton.js" ;
6- import Button from "./Button.js" ;
7-
1+ import { registerFeature } from "@ui5/webcomponents-base/src/FeaturesRegistry.js" ;
82import FormSupport from "./util/FormSupport.js" ;
93
10- Input . FormSupport = FormSupport ;
11- TextArea . FormSupport = FormSupport ;
12- DatePicker . FormSupport = FormSupport ;
13- CheckBox . FormSupport = FormSupport ;
14- RadioButton . FormSupport = FormSupport ;
15- Button . FormSupport = FormSupport ;
4+ // Add form support to the global features registry so that Web Components can find and use it
5+ registerFeature ( "FormSupport" , FormSupport ) ;
166
177export default { } ;
Original file line number Diff line number Diff line change 11import { isDesktop } from "@ui5/webcomponents-core/dist/sap/ui/Device.js" ;
22import { getCompactSize } from "@ui5/webcomponents-base/src/Configuration.js" ;
33import getEffectiveRTL from "@ui5/webcomponents-base/src/util/getEffectiveRTL.js" ;
4+ import { getFeature } from "@ui5/webcomponents-base/src/FeaturesRegistry.js" ;
45import UI5Element from "@ui5/webcomponents-base/src/UI5Element.js" ;
56import Bootstrap from "@ui5/webcomponents-base/src/Bootstrap.js" ;
67import ValueState from "@ui5/webcomponents-base/src/types/ValueState.js" ;
@@ -253,8 +254,9 @@ class RadioButton extends UI5Element {
253254 }
254255
255256 _enableFormSupport ( ) {
256- if ( RadioButton . FormSupport ) {
257- RadioButton . FormSupport . syncNativeHiddenInput ( this , ( element , nativeInput ) => {
257+ const FormSupport = getFeature ( "FormSupport" ) ;
258+ if ( FormSupport ) {
259+ FormSupport . syncNativeHiddenInput ( this , ( element , nativeInput ) => {
258260 nativeInput . disabled = element . disabled || ! element . selected ;
259261 nativeInput . value = element . selected ? element . value : "" ;
260262 } ) ;
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import UI5Element from "@ui5/webcomponents-base/src/UI5Element.js";
33import CSSSize from "@ui5/webcomponents-base/src/types/CSSSize.js" ;
44import Integer from "@ui5/webcomponents-base/src/types/Integer.js" ;
55import { fetchResourceBundle , getResourceBundle } from "@ui5/webcomponents-base/src/ResourceBundle.js" ;
6+ import { getFeature } from "@ui5/webcomponents-base/src/FeaturesRegistry.js" ;
67import TextAreaRenderer from "./build/compiled/TextAreaRenderer.lit.js" ;
78
89import { TEXTAREA_CHARACTERS_LEFT , TEXTAREA_CHARACTERS_EXCEEDED } from "./i18n/defaults.js" ;
@@ -249,8 +250,9 @@ class TextArea extends UI5Element {
249250 this . _maxHeight = `${ this . growingMaxLines * 1.4 * 14 + 9 } px` ;
250251 }
251252
252- if ( TextArea . FormSupport ) {
253- TextArea . FormSupport . syncNativeHiddenInput ( this ) ;
253+ const FormSupport = getFeature ( "FormSupport" ) ;
254+ if ( FormSupport ) {
255+ FormSupport . syncNativeHiddenInput ( this ) ;
254256 } else if ( this . name ) {
255257 console . warn ( `In order for the "name" property to have effect, you should also: import InputElementsFormSupport from "@ui5/webcomponents/dist/InputElementsFormSupport";` ) ; // eslint-disable-line
256258 }
You can’t perform that action at this time.
0 commit comments