1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FOUNDATION_ACE_FRAMEWORKS_BRIDGE_COMMON_DOM_INPUT_DOM_TEXTFIELD_UTIL_H 17 #define FOUNDATION_ACE_FRAMEWORKS_BRIDGE_COMMON_DOM_INPUT_DOM_TEXTFIELD_UTIL_H 18 19 #include "core/common/ime/text_input_action.h" 20 #include "core/common/ime/text_input_type.h" 21 #include "core/components/text_field/text_field_component.h" 22 #include "core/components/text_field/textfield_theme.h" 23 #include "core/components/theme/theme_manager.h" 24 #include "core/pipeline/base/component.h" 25 #include "frameworks/bridge/common/dom/dom_input.h" 26 27 namespace OHOS::Ace::Framework { 28 29 class DOMTextFieldUtil final { 30 public: 31 DOMTextFieldUtil() = delete; 32 ~DOMTextFieldUtil() = delete; 33 34 static RefPtr<TextFieldComponent> CreateComponentAndSetChildAttr(const RefPtr<BoxComponent>& boxComponent, 35 const std::string& type, const std::map<std::string, std::string>& attrs, const DOMInput& node); 36 37 static void SetChildAttr(const RefPtr<TextFieldComponent>& component, const RefPtr<BoxComponent>& boxComponent, 38 const std::string& type, const std::map<std::string, std::string>& attrs); 39 40 static void SetChildStyle(const RefPtr<BoxComponent>& boxComponent, const RefPtr<TextFieldComponent>& component, 41 const std::map<std::string, std::string>& styles, const Border& boxBorder, const DOMInput& node); 42 43 static void UpdateDecorationStyle(const RefPtr<BoxComponent>& boxComponent, 44 const RefPtr<TextFieldComponent>& component, const Border& boxBorder, bool hasBoxRadius); 45 46 static void AddChildEvent(const RefPtr<TextFieldComponent>& component, int32_t pageId, const std::string& nodeId, 47 const std::vector<std::string>& events); 48 49 static void InitDefaultValue(const RefPtr<BoxComponent>& boxComponent, 50 const RefPtr<TextFieldComponent>& component, const RefPtr<TextFieldTheme>& theme); 51 52 static void SetDisableStyle( 53 const RefPtr<TextFieldComponent>& component, const RefPtr<TextFieldTheme>& theme); 54 55 static void InitController(const RefPtr<TextFieldComponent>& component); 56 57 static bool IsRadiusStyle(const std::string& style); 58 59 private: 60 static Radius defaultRadius_; 61 }; 62 63 } // namespace OHOS::Ace::Framework 64 65 #endif // FOUNDATION_ACE_FRAMEWORKS_BRIDGE_COMMON_DOM_INPUT_DOM_TEXTFIELD_UTIL_H 66