From b37b1ce8a4171919d4f24cad22459bee4e4c74a0 Mon Sep 17 00:00:00 2001 From: Rishi Mehta Date: Wed, 10 Apr 2024 08:55:26 +0530 Subject: [PATCH] [Do not merge] Custom core component sample --- .../.content.xml | 2 +- .../components/addresslookup/.content.xml | 3 + .../components/addresslookup/v1/.content.xml | 5 ++ .../v1/addresslookup/.content.xml | 8 ++ .../v1/addresslookup/_cq_template.xml | 5 ++ .../v1/addresslookup/addresslookup.html | 73 +++++++++++++++ .../v1/addresslookup/clientlibs/.content.xml | 3 + .../clientlibs/site/.content.xml | 6 ++ .../v1/addresslookup/clientlibs/site/css.txt | 18 ++++ .../clientlibs/site/css/addresslookupview.css | 43 +++++++++ .../v1/addresslookup/clientlibs/site/js.txt | 18 ++++ .../clientlibs/site/js/addresslookupview.js | 90 +++++++++++++++++++ 12 files changed, 273 insertions(+), 1 deletion(-) create mode 100644 it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/.content.xml create mode 100644 it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/.content.xml create mode 100644 it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/.content.xml create mode 100644 it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/_cq_template.xml create mode 100644 it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/addresslookup.html create mode 100644 it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/.content.xml create mode 100644 it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/site/.content.xml create mode 100644 it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/site/css.txt create mode 100644 it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/site/css/addresslookupview.css create mode 100644 it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/site/js.txt create mode 100644 it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/site/js/addresslookupview.js diff --git a/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/clientlibs/custom-forms-components-runtime-all/.content.xml b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/clientlibs/custom-forms-components-runtime-all/.content.xml index 47d7031007..9aa607b0ec 100644 --- a/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/clientlibs/custom-forms-components-runtime-all/.content.xml +++ b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/clientlibs/custom-forms-components-runtime-all/.content.xml @@ -5,4 +5,4 @@ cssProcessor="[default:none,min:none]" jsProcessor="[default:none,min:none]" categories="[core.forms.components.it.runtime.all]" - embed="[core.forms.components.runtime.base,core.forms.components.container.v2.runtime,core.forms.components.datePicker.v1.runtime,core.forms.components.textinput.v1.runtime,core.forms.components.numberinput.v1.runtime,core.forms.components.panelcontainer.v1.runtime,core.forms.components.radiobutton.v1.runtime,core.forms.components.text.v1.runtime,core.forms.components.checkboxgroup.v1.runtime,core.forms.components.button.v1.runtime,core.forms.components.image.v1.runtime,core.forms.components.dropdown.v1.runtime,core.forms.components.fileinput.v2.runtime,core.forms.components.accordion.v1.runtime,core.forms.components.tabs.v1.runtime,core.forms.components.wizard.v1.runtime,core.forms.components.verticaltabs.v1.runtime,core.forms.components.recaptcha.v1.runtime,core.forms.components.checkbox.v1.runtime,core.forms.components.fragment.v1.runtime,core.forms.components.switch.v1.runtime,core.forms.components.termsandconditions.v1.runtime, core.forms.components.it.textinput.v1.runtime]"/> + embed="[core.forms.components.runtime.base,core.forms.components.container.v2.runtime,core.forms.components.datePicker.v1.runtime,core.forms.components.textinput.v1.runtime,core.forms.components.numberinput.v1.runtime,core.forms.components.panelcontainer.v1.runtime,core.forms.components.radiobutton.v1.runtime,core.forms.components.text.v1.runtime,core.forms.components.checkboxgroup.v1.runtime,core.forms.components.button.v1.runtime,core.forms.components.image.v1.runtime,core.forms.components.dropdown.v1.runtime,core.forms.components.fileinput.v2.runtime,core.forms.components.accordion.v1.runtime,core.forms.components.tabs.v1.runtime,core.forms.components.wizard.v1.runtime,core.forms.components.verticaltabs.v1.runtime,core.forms.components.recaptcha.v1.runtime,core.forms.components.checkbox.v1.runtime,core.forms.components.fragment.v1.runtime,core.forms.components.switch.v1.runtime,core.forms.components.termsandconditions.v1.runtime, core.forms.components.it.textinput.v1.runtime, core.forms.components.it.addresslookup.v1.runtime]"/> diff --git a/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/.content.xml b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/.content.xml new file mode 100644 index 0000000000..491392d539 --- /dev/null +++ b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/.content.xml @@ -0,0 +1,3 @@ + + diff --git a/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/.content.xml b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/.content.xml new file mode 100644 index 0000000000..e03f696dab --- /dev/null +++ b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/.content.xml @@ -0,0 +1,5 @@ + + + + diff --git a/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/.content.xml b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/.content.xml new file mode 100644 index 0000000000..48548e9d0d --- /dev/null +++ b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/.content.xml @@ -0,0 +1,8 @@ + + diff --git a/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/_cq_template.xml b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/_cq_template.xml new file mode 100644 index 0000000000..52818bb0af --- /dev/null +++ b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/_cq_template.xml @@ -0,0 +1,5 @@ + + diff --git a/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/addresslookup.html b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/addresslookup.html new file mode 100644 index 0000000000..f20be1effa --- /dev/null +++ b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/addresslookup.html @@ -0,0 +1,73 @@ + + + +
+
+
+
+
+ + +
+
+
+
+
diff --git a/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/.content.xml b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/.content.xml new file mode 100644 index 0000000000..491392d539 --- /dev/null +++ b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/.content.xml @@ -0,0 +1,3 @@ + + diff --git a/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/site/.content.xml b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/site/.content.xml new file mode 100644 index 0000000000..5dcdb61f00 --- /dev/null +++ b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/site/.content.xml @@ -0,0 +1,6 @@ + + diff --git a/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/site/css.txt b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/site/css.txt new file mode 100644 index 0000000000..8383b5127c --- /dev/null +++ b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/site/css.txt @@ -0,0 +1,18 @@ +############################################################################### +# Copyright 2022 Adobe +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +############################################################################### + +#base=css +addresslookupview.css diff --git a/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/site/css/addresslookupview.css b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/site/css/addresslookupview.css new file mode 100644 index 0000000000..cf79ed50f0 --- /dev/null +++ b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/site/css/addresslookupview.css @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright 2022 Adobe + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +.cmp-adaptiveform-textinput { + +} + +.cmp-adaptiveform-textinput__widget { + +} +textarea.cmp-adaptiveform-textinput__widget{ + +} + +.cmp-adaptiveform-textinput__label { + +} +.cmp-adaptiveform-textinput__label-container{ + +} + +.cmp-adaptiveform-textinput__longdescription { +} + +.cmp-adaptiveform-textinput__shortdescription { +} + +.cmp-adaptiveform-textinput__questionmark { + +} diff --git a/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/site/js.txt b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/site/js.txt new file mode 100644 index 0000000000..00092bfc1c --- /dev/null +++ b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/site/js.txt @@ -0,0 +1,18 @@ +############################################################################### +# Copyright 2022 Adobe +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +############################################################################### + +#base=js +addresslookupview.js diff --git a/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/site/js/addresslookupview.js b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/site/js/addresslookupview.js new file mode 100644 index 0000000000..c1b166c17d --- /dev/null +++ b/it/apps/src/main/content/jcr_root/apps/forms-core-components-it/components/addresslookup/v1/addresslookup/clientlibs/site/js/addresslookupview.js @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright 2022 Adobe + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ +(function() { + + "use strict"; + class EsriInput extends FormView.FormFieldBase { + + static NS = FormView.Constants.NS; + /** + * Each FormField has a data attribute class that is prefixed along with the global namespace to + * distinguish between them. If a component wants to put a data-attribute X, the attribute in HTML would be + * data-{NS}-{IS}-x="" + * @type {string} + */ + static IS = "adaptiveFormEsriInput"; + static bemBlock = 'cmp-adaptiveform-esriaddresslookup' + static selectors = { + self: "[data-" + this.NS + '-is="' + this.IS + '"]', + widget: `.${EsriInput.bemBlock}__widget`, + label: `.${EsriInput.bemBlock}__label`, + description: `.${EsriInput.bemBlock}__longdescription`, + qm: `.${EsriInput.bemBlock}__questionmark`, + errorDiv: `.${EsriInput.bemBlock}__errormessage`, + tooltipDiv: `.${EsriInput.bemBlock}__shortdescription` + }; + + constructor(params) { + super(params); + } + + getWidget() { + return this.element.querySelector(EsriInput.selectors.widget); + } + + getDescription() { + return this.element.querySelector(EsriInput.selectors.description); + } + + getLabel() { + return this.element.querySelector(EsriInput.selectors.label); + } + + getErrorDiv() { + return this.element.querySelector(EsriInput.selectors.errorDiv); + } + + getTooltipDiv() { + return this.element.querySelector(EsriInput.selectors.tooltipDiv); + } + + getQuestionMarkDiv() { + return this.element.querySelector(EsriInput.selectors.qm); + } + + setModel(model) { + super.setModel(model); + if (this.widget.value !== '') { + this._model.value = this.widget.value; + } + this.widget.addEventListener('blur', (e) => { + this._model.value = e.target.value; + this.setWidgetValueToDisplayValue(); + this.setInactive(); + }); + this.widget.addEventListener('focus', (e) => { + this.setActive(); + this.setWidgetValueToModelValue(); + }); + } + } + + + FormView.Utils.setupField(({element, formContainer}) => { + return new EsriInput({element, formContainer}) + }, EsriInput.selectors.self); + +})();