profile-pane 3.1.5 → 3.2.1
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/README.md +16 -0
- package/icons-png/discord.png +0 -0
- package/icons-png/dribbble.png +0 -0
- package/icons-png/facebook.png +0 -0
- package/icons-png/instagram.png +0 -0
- package/icons-png/linkedin.png +0 -0
- package/icons-png/pinterest.png +0 -0
- package/icons-png/sharechat.png +0 -0
- package/icons-png/signup.png +0 -0
- package/icons-png/snapchat.png +0 -0
- package/icons-png/spotify.png +0 -0
- package/icons-png/telegram.png +0 -0
- package/icons-png/tiktok.png +0 -0
- package/icons-png/whatsapp.png +0 -0
- package/icons-png/x.png +0 -0
- package/icons-png/youtube.png +0 -0
- package/lib/04567ff683933c35c465.png +0 -0
- package/lib/10163fd9b5a0e00d63a0.png +0 -0
- package/lib/1234dcb2eec2e45f252b.png +0 -0
- package/lib/20899934157df4db56cb.png +0 -0
- package/lib/33760bf79f097f449da5.png +0 -0
- package/lib/578d2b6ed32e7624164e.png +0 -0
- package/lib/5f62a5b2b7e99b9640c7.png +0 -0
- package/lib/6525766ecd288ec60129.png +0 -0
- package/lib/7800be6f6c4b5b0f4f20.png +0 -0
- package/lib/976473cf5fe24d657d4b.png +0 -0
- package/lib/ChatWithMe.d.ts +2 -1
- package/lib/ChatWithMe.d.ts.map +1 -1
- package/lib/ChatWithMe.js +3 -3
- package/lib/ProfileView.d.ts +1 -1
- package/lib/ProfileView.d.ts.map +1 -1
- package/lib/ProfileView.js +71 -131
- package/lib/ProfileViewModelPresenter.d.ts +23 -0
- package/lib/ProfileViewModelPresenter.d.ts.map +1 -0
- package/lib/ProfileViewModelPresenter.js +37 -0
- package/lib/QRCodeCard.d.ts +3 -1
- package/lib/QRCodeCard.d.ts.map +1 -1
- package/lib/QRCodeCard.js +86 -66
- package/lib/addMeToYourFriends.d.ts +3 -3
- package/lib/addMeToYourFriends.d.ts.map +1 -1
- package/lib/addMeToYourFriends.js +14 -30
- package/lib/bda84f59e7216675a208.png +0 -0
- package/lib/buttonsHelper.js +1 -1
- package/lib/cd68e8f3990ba8b2139e.png +0 -0
- package/lib/e7074a7e2cb69e51cfd3.png +0 -0
- package/lib/editProfilePane/EditCVCard.d.ts +1 -0
- package/lib/editProfilePane/EditCVCard.d.ts.map +1 -1
- package/lib/editProfilePane/EditCVCard.js +2 -1
- package/lib/editProfilePane/EditCommunitiesCard.d.ts +1 -1
- package/lib/editProfilePane/EditCommunitiesCard.d.ts.map +1 -1
- package/lib/editProfilePane/EditCommunitiesCard.js +2 -1
- package/lib/editProfilePane/EditContactsCard.d.ts +1 -0
- package/lib/editProfilePane/EditContactsCard.d.ts.map +1 -1
- package/lib/editProfilePane/EditContactsCard.js +2 -0
- package/lib/editProfilePane/EditFriendsCard.d.ts +1 -1
- package/lib/editProfilePane/EditFriendsCard.d.ts.map +1 -1
- package/lib/editProfilePane/EditFriendsCard.js +2 -1
- package/lib/editProfilePane/EditOtherPreferences.d.ts +1 -0
- package/lib/editProfilePane/EditOtherPreferences.d.ts.map +1 -1
- package/lib/editProfilePane/EditOtherPreferences.js +1 -0
- package/lib/editProfilePane/EditProfileView.d.ts +1 -1
- package/lib/editProfilePane/EditProfileView.d.ts.map +1 -1
- package/lib/editProfilePane/EditProfileView.js +1 -1
- package/lib/editProfilePane/EditSocialCard.d.ts +1 -0
- package/lib/editProfilePane/EditSocialCard.d.ts.map +1 -1
- package/lib/editProfilePane/EditSocialCard.js +2 -1
- package/lib/editProfilePane/editProfilePresenter.d.ts +1 -0
- package/lib/editProfilePane/editProfilePresenter.d.ts.map +1 -1
- package/lib/editProfilePane/editProfilePresenter.js +2 -0
- package/lib/f3772696fb7ee53c23d8.png +0 -0
- package/lib/icons-svg/contactIcons.d.ts +3 -0
- package/lib/icons-svg/contactIcons.d.ts.map +1 -0
- package/lib/icons-svg/contactIcons.js +32 -0
- package/lib/icons-svg/profileIcons.d.ts +22 -0
- package/lib/icons-svg/profileIcons.d.ts.map +1 -0
- package/lib/icons-svg/profileIcons.js +309 -0
- package/lib/index.d.ts +1 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +42 -19
- package/lib/profile-pane.js +15629 -5670
- package/lib/profile-pane.js.map +1 -1
- package/lib/profile-pane.min.js +2171 -230
- package/lib/profile-pane.min.js.map +1 -1
- package/lib/rdfFormsHelper.d.ts +1 -0
- package/lib/rdfFormsHelper.d.ts.map +1 -1
- package/lib/rdfFormsHelper.js +2 -0
- package/lib/sections/bio/BioEditDialog.d.ts +6 -0
- package/lib/sections/bio/BioEditDialog.d.ts.map +1 -0
- package/lib/sections/bio/BioEditDialog.js +119 -0
- package/lib/sections/bio/BioSection.d.ts +7 -0
- package/lib/sections/bio/BioSection.d.ts.map +1 -0
- package/lib/sections/bio/BioSection.js +131 -0
- package/lib/sections/bio/mutations.d.ts +4 -0
- package/lib/sections/bio/mutations.d.ts.map +1 -0
- package/lib/sections/bio/mutations.js +43 -0
- package/lib/sections/bio/selectors.d.ts +4 -0
- package/lib/sections/bio/selectors.d.ts.map +1 -0
- package/lib/sections/bio/selectors.js +15 -0
- package/lib/sections/bio/types.d.ts +15 -0
- package/lib/sections/bio/types.d.ts.map +1 -0
- package/lib/sections/bio/types.js +5 -0
- package/lib/sections/contactInfo/ContactInfoEditDialog.d.ts +7 -0
- package/lib/sections/contactInfo/ContactInfoEditDialog.d.ts.map +1 -0
- package/lib/sections/contactInfo/ContactInfoEditDialog.js +658 -0
- package/lib/sections/contactInfo/ContactInfoSection.d.ts +5 -0
- package/lib/sections/contactInfo/ContactInfoSection.d.ts.map +1 -0
- package/lib/sections/contactInfo/ContactInfoSection.js +229 -0
- package/lib/sections/contactInfo/mutations.d.ts +4 -0
- package/lib/sections/contactInfo/mutations.d.ts.map +1 -0
- package/lib/sections/contactInfo/mutations.js +150 -0
- package/lib/sections/contactInfo/selectors.d.ts +4 -0
- package/lib/sections/contactInfo/selectors.d.ts.map +1 -0
- package/lib/sections/contactInfo/selectors.js +104 -0
- package/lib/sections/contactInfo/types.d.ts +44 -0
- package/lib/sections/contactInfo/types.d.ts.map +1 -0
- package/lib/sections/contactInfo/types.js +5 -0
- package/lib/sections/education/EducationEditDialog.d.ts +7 -0
- package/lib/sections/education/EducationEditDialog.d.ts.map +1 -0
- package/lib/sections/education/EducationEditDialog.js +459 -0
- package/lib/sections/education/EducationSection.d.ts +7 -0
- package/lib/sections/education/EducationSection.d.ts.map +1 -0
- package/lib/sections/education/EducationSection.js +126 -0
- package/lib/sections/education/mutations.d.ts +4 -0
- package/lib/sections/education/mutations.d.ts.map +1 -0
- package/lib/sections/education/mutations.js +60 -0
- package/lib/sections/education/selectors.d.ts +4 -0
- package/lib/sections/education/selectors.d.ts.map +1 -0
- package/lib/sections/education/selectors.js +64 -0
- package/lib/sections/education/types.d.ts +20 -0
- package/lib/sections/education/types.d.ts.map +1 -0
- package/lib/sections/education/types.js +5 -0
- package/lib/sections/heading/HeadingEditDialog.d.ts +6 -0
- package/lib/sections/heading/HeadingEditDialog.d.ts.map +1 -0
- package/lib/sections/heading/HeadingEditDialog.js +742 -0
- package/lib/sections/heading/HeadingSection.d.ts +9 -0
- package/lib/sections/heading/HeadingSection.d.ts.map +1 -0
- package/lib/sections/heading/HeadingSection.js +97 -0
- package/lib/sections/heading/camera.d.ts +19 -0
- package/lib/sections/heading/camera.d.ts.map +1 -0
- package/lib/sections/heading/camera.js +199 -0
- package/lib/sections/heading/dateHelpers.d.ts +4 -0
- package/lib/sections/heading/dateHelpers.d.ts.map +1 -0
- package/lib/sections/heading/dateHelpers.js +48 -0
- package/lib/sections/heading/imageHelpers.d.ts +4 -0
- package/lib/sections/heading/imageHelpers.d.ts.map +1 -0
- package/lib/sections/heading/imageHelpers.js +81 -0
- package/lib/sections/heading/mutations.d.ts +4 -0
- package/lib/sections/heading/mutations.d.ts.map +1 -0
- package/lib/sections/heading/mutations.js +190 -0
- package/lib/sections/heading/selectors.d.ts +5 -0
- package/lib/sections/heading/selectors.d.ts.map +1 -0
- package/lib/sections/heading/selectors.js +157 -0
- package/lib/sections/heading/types.d.ts +36 -0
- package/lib/sections/heading/types.d.ts.map +1 -0
- package/lib/sections/heading/types.js +5 -0
- package/lib/sections/languages/LanguageEditDialog.d.ts +7 -0
- package/lib/sections/languages/LanguageEditDialog.d.ts.map +1 -0
- package/lib/sections/languages/LanguageEditDialog.js +457 -0
- package/lib/sections/languages/LanguageSection.d.ts +5 -0
- package/lib/sections/languages/LanguageSection.d.ts.map +1 -0
- package/lib/sections/languages/LanguageSection.js +137 -0
- package/lib/sections/languages/mutations.d.ts +6 -0
- package/lib/sections/languages/mutations.d.ts.map +1 -0
- package/lib/sections/languages/mutations.js +296 -0
- package/lib/sections/languages/selectors.d.ts +5 -0
- package/lib/sections/languages/selectors.d.ts.map +1 -0
- package/lib/sections/languages/selectors.js +146 -0
- package/lib/sections/languages/types.d.ts +15 -0
- package/lib/sections/languages/types.d.ts.map +1 -0
- package/lib/sections/languages/types.js +5 -0
- package/lib/sections/projects/ProjectEditDialog.d.ts +7 -0
- package/lib/sections/projects/ProjectEditDialog.d.ts.map +1 -0
- package/lib/sections/projects/ProjectEditDialog.js +182 -0
- package/lib/sections/projects/ProjectSection.d.ts +6 -0
- package/lib/sections/projects/ProjectSection.d.ts.map +1 -0
- package/lib/sections/projects/ProjectSection.js +220 -0
- package/lib/sections/projects/mutations.d.ts +4 -0
- package/lib/sections/projects/mutations.d.ts.map +1 -0
- package/lib/sections/projects/mutations.js +188 -0
- package/lib/sections/projects/selectors.d.ts +5 -0
- package/lib/sections/projects/selectors.d.ts.map +1 -0
- package/lib/sections/projects/selectors.js +163 -0
- package/lib/sections/projects/types.d.ts +28 -0
- package/lib/sections/projects/types.d.ts.map +1 -0
- package/lib/sections/projects/types.js +8 -0
- package/lib/sections/resume/ResumeEditDialog.d.ts +7 -0
- package/lib/sections/resume/ResumeEditDialog.d.ts.map +1 -0
- package/lib/sections/resume/ResumeEditDialog.js +629 -0
- package/lib/sections/resume/ResumeSection.d.ts +7 -0
- package/lib/sections/resume/ResumeSection.d.ts.map +1 -0
- package/lib/sections/resume/ResumeSection.js +160 -0
- package/lib/sections/resume/mutations.d.ts +6 -0
- package/lib/sections/resume/mutations.d.ts.map +1 -0
- package/lib/sections/resume/mutations.js +172 -0
- package/lib/sections/resume/selectors.d.ts +4 -0
- package/lib/sections/resume/selectors.d.ts.map +1 -0
- package/lib/sections/resume/selectors.js +142 -0
- package/lib/sections/resume/types.d.ts +33 -0
- package/lib/sections/resume/types.d.ts.map +1 -0
- package/lib/sections/resume/types.js +8 -0
- package/lib/sections/shared/collapsibleSection.d.ts +2 -0
- package/lib/sections/shared/collapsibleSection.d.ts.map +1 -0
- package/lib/sections/shared/collapsibleSection.js +24 -0
- package/lib/sections/shared/contactTypeUtils.d.ts +7 -0
- package/lib/sections/shared/contactTypeUtils.d.ts.map +1 -0
- package/lib/sections/shared/contactTypeUtils.js +48 -0
- package/lib/sections/shared/idNodeFactory.d.ts +3 -0
- package/lib/sections/shared/idNodeFactory.d.ts.map +1 -0
- package/lib/sections/shared/idNodeFactory.js +14 -0
- package/lib/sections/shared/phoneCountries.d.ts +20 -0
- package/lib/sections/shared/phoneCountries.d.ts.map +1 -0
- package/lib/sections/shared/phoneCountries.js +1080 -0
- package/lib/sections/shared/rdfList.d.ts +3 -0
- package/lib/sections/shared/rdfList.d.ts.map +1 -0
- package/lib/sections/shared/rdfList.js +34 -0
- package/lib/sections/shared/rdfMutationHelpers.d.ts +12 -0
- package/lib/sections/shared/rdfMutationHelpers.d.ts.map +1 -0
- package/lib/sections/shared/rdfMutationHelpers.js +82 -0
- package/lib/sections/shared/rowState.d.ts +21 -0
- package/lib/sections/shared/rowState.d.ts.map +1 -0
- package/lib/sections/shared/rowState.js +52 -0
- package/lib/sections/shared/sanitizeUtils.d.ts +5 -0
- package/lib/sections/shared/sanitizeUtils.d.ts.map +1 -0
- package/lib/sections/shared/sanitizeUtils.js +22 -0
- package/lib/sections/shared/sectionCardHelpers.d.ts +11 -0
- package/lib/sections/shared/sectionCardHelpers.d.ts.map +1 -0
- package/lib/sections/shared/sectionCardHelpers.js +105 -0
- package/lib/sections/shared/types.d.ts +7 -0
- package/lib/sections/shared/types.d.ts.map +1 -0
- package/lib/sections/shared/types.js +5 -0
- package/lib/sections/skills/SkillsEditDialog.d.ts +7 -0
- package/lib/sections/skills/SkillsEditDialog.d.ts.map +1 -0
- package/lib/sections/skills/SkillsEditDialog.js +340 -0
- package/lib/sections/skills/SkillsSection.d.ts +5 -0
- package/lib/sections/skills/SkillsSection.d.ts.map +1 -0
- package/lib/sections/skills/SkillsSection.js +169 -0
- package/lib/sections/skills/mutations.d.ts +6 -0
- package/lib/sections/skills/mutations.d.ts.map +1 -0
- package/lib/sections/skills/mutations.js +110 -0
- package/lib/sections/skills/selectors.d.ts +6 -0
- package/lib/sections/skills/selectors.d.ts.map +1 -0
- package/lib/sections/skills/selectors.js +37 -0
- package/lib/sections/skills/types.d.ts +14 -0
- package/lib/sections/skills/types.d.ts.map +1 -0
- package/lib/sections/skills/types.js +5 -0
- package/lib/sections/social/SocialEditDialog.d.ts +7 -0
- package/lib/sections/social/SocialEditDialog.d.ts.map +1 -0
- package/lib/sections/social/SocialEditDialog.js +362 -0
- package/lib/sections/social/SocialSection.d.ts +8 -0
- package/lib/sections/social/SocialSection.d.ts.map +1 -0
- package/lib/sections/social/SocialSection.js +201 -0
- package/lib/sections/social/constants.d.ts +3 -0
- package/lib/sections/social/constants.d.ts.map +1 -0
- package/lib/sections/social/constants.js +16 -0
- package/lib/sections/social/helpers.d.ts +15 -0
- package/lib/sections/social/helpers.d.ts.map +1 -0
- package/lib/sections/social/helpers.js +316 -0
- package/lib/sections/social/mutations.d.ts +4 -0
- package/lib/sections/social/mutations.d.ts.map +1 -0
- package/lib/sections/social/mutations.js +298 -0
- package/lib/sections/social/selectors.d.ts +4 -0
- package/lib/sections/social/selectors.d.ts.map +1 -0
- package/lib/sections/social/selectors.js +43 -0
- package/lib/sections/social/types.d.ts +19 -0
- package/lib/sections/social/types.d.ts.map +1 -0
- package/lib/sections/social/types.js +5 -0
- package/lib/styles/BioSection.css +77 -0
- package/lib/styles/CVCard.css +107 -2
- package/lib/styles/ContactInfoEditDialog.css +153 -0
- package/lib/styles/EditDialogs.css +1028 -0
- package/lib/styles/EducationCard.css +103 -0
- package/lib/styles/HeadingSection.css +309 -0
- package/lib/styles/ProfileCard.css +10 -42
- package/lib/styles/ProfileView.css +53 -8
- package/lib/styles/ProjectsCard.css +206 -0
- package/lib/styles/QRCodeCard.css +29 -10
- package/lib/styles/SocialCard.css +41 -13
- package/lib/styles/dialog.css +209 -0
- package/lib/styles/utilities.css +638 -256
- package/lib/textUtils.d.ts +6 -0
- package/lib/textUtils.d.ts.map +1 -0
- package/lib/textUtils.js +44 -0
- package/lib/texts.d.ts +45 -4
- package/lib/texts.d.ts.map +1 -1
- package/lib/texts.js +46 -5
- package/lib/types.d.ts +2 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +5 -0
- package/lib/ui/dialog.d.ts +29 -0
- package/lib/ui/dialog.d.ts.map +1 -0
- package/lib/ui/dialog.js +269 -0
- package/lib/ui/errors.d.ts +2 -0
- package/lib/ui/errors.d.ts.map +1 -0
- package/lib/ui/errors.js +10 -0
- package/package.json +8 -5
- package/lib/CVCard.d.ts +0 -4
- package/lib/CVCard.d.ts.map +0 -1
- package/lib/CVCard.js +0 -114
- package/lib/CVPresenter.d.ts +0 -25
- package/lib/CVPresenter.d.ts.map +0 -1
- package/lib/CVPresenter.js +0 -119
- package/lib/FriendList.d.ts +0 -6
- package/lib/FriendList.d.ts.map +0 -1
- package/lib/FriendList.js +0 -27
- package/lib/ProfileCard.d.ts +0 -6
- package/lib/ProfileCard.d.ts.map +0 -1
- package/lib/ProfileCard.js +0 -62
- package/lib/SocialCard.d.ts +0 -5
- package/lib/SocialCard.d.ts.map +0 -1
- package/lib/SocialCard.js +0 -51
- package/lib/SocialPresenter.d.ts +0 -11
- package/lib/SocialPresenter.d.ts.map +0 -1
- package/lib/SocialPresenter.js +0 -117
- package/lib/StuffCard.d.ts +0 -10
- package/lib/StuffCard.d.ts.map +0 -1
- package/lib/StuffCard.js +0 -52
- package/lib/StuffPresenter.d.ts +0 -14
- package/lib/StuffPresenter.d.ts.map +0 -1
- package/lib/StuffPresenter.js +0 -53
- package/lib/presenter.d.ts +0 -14
- package/lib/presenter.d.ts.map +0 -1
- package/lib/presenter.js +0 -68
- package/lib/styles/FriendList.css +0 -12
- package/lib/styles/StuffCard.css +0 -23
- package/lib/styles/editProfile.css +0 -62
- package/lib/styles/profileRDFFormsEnforced.css +0 -431
|
@@ -0,0 +1,658 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createContactInfoEditDialog = createContactInfoEditDialog;
|
|
7
|
+
var _dialog = require("../../ui/dialog");
|
|
8
|
+
var _litHtml = require("lit-html");
|
|
9
|
+
require("../../styles/EditDialogs.css");
|
|
10
|
+
require("../../styles/ContactInfoEditDialog.css");
|
|
11
|
+
var _mutations = require("./mutations");
|
|
12
|
+
var _phoneCountries = require("../shared/phoneCountries");
|
|
13
|
+
var _contactTypeUtils = require("../shared/contactTypeUtils");
|
|
14
|
+
var _rowState = require("../shared/rowState");
|
|
15
|
+
var _textUtils = require("../../textUtils");
|
|
16
|
+
var _texts = require("../../texts");
|
|
17
|
+
var _sanitizeUtils = require("../shared/sanitizeUtils");
|
|
18
|
+
var _profileIcons = require("../../icons-svg/profileIcons");
|
|
19
|
+
var _contactIcons = require("../../icons-svg/contactIcons");
|
|
20
|
+
/* Some of the code in this file was generated by AI Model: GPT-5.3-Codex */
|
|
21
|
+
/* Prompt: 1. are you able to create a little trash can icon at the end of
|
|
22
|
+
each entry so for each phone, email and address line.
|
|
23
|
+
2. are you able to add all the country flags and prefix next to
|
|
24
|
+
the phone numbers?
|
|
25
|
+
3. can you write functions to sanitize the input values for emails, phones, and addresses? */
|
|
26
|
+
|
|
27
|
+
function isContactPointRow(row) {
|
|
28
|
+
return 'value' in row;
|
|
29
|
+
}
|
|
30
|
+
function rowHasContent(row) {
|
|
31
|
+
if (isContactPointRow(row)) {
|
|
32
|
+
return (0, _textUtils.hasNonEmptyText)(row.value);
|
|
33
|
+
}
|
|
34
|
+
return [row.streetAddress, row.locality, row.region, row.postalCode, row.countryName].some(_textUtils.hasNonEmptyText);
|
|
35
|
+
}
|
|
36
|
+
function toFormState(contactInfo) {
|
|
37
|
+
const emails = (contactInfo.emails || []).map(email => ({
|
|
38
|
+
value: (0, _sanitizeUtils.sanitizeEmailValue)((0, _textUtils.toText)(email.valueNode).replace(/^mailto:/i, '')),
|
|
39
|
+
type: (0, _contactTypeUtils.normalizeEmailTypeForContactInfoEdit)(email.type),
|
|
40
|
+
entryNode: (0, _textUtils.toText)(email.entryNode),
|
|
41
|
+
status: (0, _textUtils.toText)(email.entryNode) ? 'existing' : 'new'
|
|
42
|
+
})).filter(email => Boolean(email.value || email.entryNode || email.type));
|
|
43
|
+
const phones = (contactInfo.phones || []).map(phone => ({
|
|
44
|
+
value: (0, _textUtils.sanitizeTextValue)((0, _textUtils.toText)(phone.valueNode).replace(/^tel:/i, '')),
|
|
45
|
+
type: (0, _contactTypeUtils.normalizePhoneTypeForContactInfoEdit)(phone.type),
|
|
46
|
+
entryNode: (0, _textUtils.toText)(phone.entryNode),
|
|
47
|
+
status: 'existing'
|
|
48
|
+
})).filter(phone => Boolean(phone.value));
|
|
49
|
+
const addresses = (contactInfo.addresses || []).map(address => ({
|
|
50
|
+
streetAddress: (0, _sanitizeUtils.sanitizeAddressFieldValue)((0, _textUtils.toText)(address.streetAddress)),
|
|
51
|
+
locality: (0, _sanitizeUtils.sanitizeAddressFieldValue)((0, _textUtils.toText)(address.locality)),
|
|
52
|
+
region: (0, _sanitizeUtils.sanitizeAddressFieldValue)((0, _textUtils.toText)(address.region)),
|
|
53
|
+
postalCode: (0, _sanitizeUtils.sanitizeAddressFieldValue)((0, _textUtils.toText)(address.postalCode)),
|
|
54
|
+
countryName: (0, _sanitizeUtils.sanitizeAddressFieldValue)((0, _textUtils.toText)(address.countryName)),
|
|
55
|
+
type: (0, _textUtils.toText)(address.type),
|
|
56
|
+
entryNode: (0, _textUtils.toText)(address.entryNode),
|
|
57
|
+
status: (0, _textUtils.toText)(address.entryNode) ? 'existing' : 'new'
|
|
58
|
+
})).filter(address => rowHasContent(address) || Boolean(address.entryNode || address.type));
|
|
59
|
+
return {
|
|
60
|
+
emails: emails.length ? emails : [{
|
|
61
|
+
value: '',
|
|
62
|
+
type: '',
|
|
63
|
+
entryNode: '',
|
|
64
|
+
status: 'new'
|
|
65
|
+
}],
|
|
66
|
+
phones: phones.length ? phones : [{
|
|
67
|
+
value: '',
|
|
68
|
+
type: '',
|
|
69
|
+
entryNode: '',
|
|
70
|
+
status: 'new'
|
|
71
|
+
}],
|
|
72
|
+
addresses: addresses.length ? addresses : [{
|
|
73
|
+
streetAddress: '',
|
|
74
|
+
locality: '',
|
|
75
|
+
region: '',
|
|
76
|
+
postalCode: '',
|
|
77
|
+
countryName: '',
|
|
78
|
+
type: '',
|
|
79
|
+
entryNode: '',
|
|
80
|
+
status: 'new'
|
|
81
|
+
}]
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/* not needed for now
|
|
85
|
+
function renderCountryPrefixSelect(
|
|
86
|
+
name: string,
|
|
87
|
+
value: string,
|
|
88
|
+
label: string,
|
|
89
|
+
onChange: (event: Event) => void
|
|
90
|
+
) {
|
|
91
|
+
return html`
|
|
92
|
+
<label class="label profile-edit-dialog__phone-prefix-field" aria-label=${label}>
|
|
93
|
+
<select class="phonePrefixSelect" name=${name} .value=${value} @change=${onChange}>
|
|
94
|
+
${COUNTRY_PREFIX_OPTIONS.map((option) => html`
|
|
95
|
+
<option value=${option.dialCode}>
|
|
96
|
+
${countryCodeToFlag(option.iso2)} ${option.dialCode}
|
|
97
|
+
</option>
|
|
98
|
+
`)}
|
|
99
|
+
</select>
|
|
100
|
+
</label>
|
|
101
|
+
`
|
|
102
|
+
} */
|
|
103
|
+
|
|
104
|
+
function renderContactPhoneInputRow({
|
|
105
|
+
phones,
|
|
106
|
+
index,
|
|
107
|
+
displayIndex,
|
|
108
|
+
onDelete
|
|
109
|
+
}) {
|
|
110
|
+
const phoneRow = phones[index];
|
|
111
|
+
const label = `Phone Number ${displayIndex + 1}`;
|
|
112
|
+
// const countryCodeLabel = `Country Calling Code ${displayIndex + 1}`
|
|
113
|
+
const typeLabel = `Phone Type ${displayIndex + 1}`;
|
|
114
|
+
// const prefixInputName = `phone-prefix-${index}`
|
|
115
|
+
const inputName = `phone-value-${index}`;
|
|
116
|
+
const typeInputName = `phone-type-${index}`;
|
|
117
|
+
const splitValue = (0, _phoneCountries.splitPhoneValue)(phoneRow?.value || '');
|
|
118
|
+
let selectedDialCode = splitValue.dialCode;
|
|
119
|
+
const handleValueInput = e => {
|
|
120
|
+
const target = e.target;
|
|
121
|
+
const nextValue = (0, _sanitizeUtils.sanitizePhoneLocalValue)(target.value);
|
|
122
|
+
if (phones[index]) {
|
|
123
|
+
(0, _rowState.applyRowFieldChange)(phones[index], 'value', (0, _phoneCountries.combinePhoneValue)(selectedDialCode, nextValue), rowHasContent);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
/* Not needed for now
|
|
127
|
+
const handleCountryCodeInput = (e: Event) => {
|
|
128
|
+
const target = e.target as HTMLSelectElement
|
|
129
|
+
selectedDialCode = target.value
|
|
130
|
+
|
|
131
|
+
if (phones[index]) {
|
|
132
|
+
const localNumber = splitPhoneValue(phones[index].value).localNumber
|
|
133
|
+
applyRowFieldChange(phones[index], 'value', combinePhoneValue(selectedDialCode, localNumber), rowHasContent)
|
|
134
|
+
}
|
|
135
|
+
} */
|
|
136
|
+
|
|
137
|
+
const handleTypeInput = e => {
|
|
138
|
+
const target = e.target;
|
|
139
|
+
const nextType = target.value;
|
|
140
|
+
if (phones[index]) {
|
|
141
|
+
(0, _rowState.applyRowSelectChange)(phones[index], 'type', nextType);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
const handleDelete = event => {
|
|
145
|
+
event.preventDefault();
|
|
146
|
+
onDelete();
|
|
147
|
+
};
|
|
148
|
+
return (0, _litHtml.html)`
|
|
149
|
+
<div class="profile-edit-dialog__row profile-edit-dialog__row--contact-point">
|
|
150
|
+
<div class="profile-edit-dialog__field">
|
|
151
|
+
<label aria-label=${label} class="label">
|
|
152
|
+
<input
|
|
153
|
+
class="input"
|
|
154
|
+
type="tel"
|
|
155
|
+
name=${inputName}
|
|
156
|
+
.value=${splitValue.localNumber}
|
|
157
|
+
required
|
|
158
|
+
data-contact-field="value"
|
|
159
|
+
data-entry-node=${phoneRow?.entryNode || ''}
|
|
160
|
+
data-row-status=${phoneRow?.status || 'n/a'}
|
|
161
|
+
placeholder="Phone Number"
|
|
162
|
+
autocomplete="tel-national"
|
|
163
|
+
inputmode="tel"
|
|
164
|
+
@input=${handleValueInput}
|
|
165
|
+
/>
|
|
166
|
+
</label>
|
|
167
|
+
</div>
|
|
168
|
+
<label aria-label=${typeLabel} class="label profile-edit-dialog__field-type profile-edit-dialog__phone-type-row">
|
|
169
|
+
<select name=${typeInputName} id="phone-type-select-${inputName}" @change=${handleTypeInput} .value=${phoneRow?.type || ''}>
|
|
170
|
+
<option value="Cell">Mobile</option>
|
|
171
|
+
<option value="Home">Home</option>
|
|
172
|
+
<option value="Work">Work</option>
|
|
173
|
+
</select>
|
|
174
|
+
</label>
|
|
175
|
+
<div class="profile-edit-dialog__actions">
|
|
176
|
+
<button
|
|
177
|
+
type="button"
|
|
178
|
+
class="profile-edit-dialog__delete-button"
|
|
179
|
+
aria-label=${`Delete phone number ${displayIndex + 1}`}
|
|
180
|
+
title=${_texts.deleteEntryButtonTitleText}
|
|
181
|
+
@click=${handleDelete}
|
|
182
|
+
>
|
|
183
|
+
<span class="profile-edit-dialog__delete-icon" aria-hidden="true">${_profileIcons.trashIcon}</span>
|
|
184
|
+
</button>
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
`;
|
|
188
|
+
}
|
|
189
|
+
function renderContactInfoPhoneSection(phones, onAddRow) {
|
|
190
|
+
const createNewRow = event => {
|
|
191
|
+
event.preventDefault();
|
|
192
|
+
phones.unshift({
|
|
193
|
+
value: '',
|
|
194
|
+
type: '',
|
|
195
|
+
entryNode: '',
|
|
196
|
+
status: 'new'
|
|
197
|
+
});
|
|
198
|
+
onAddRow({
|
|
199
|
+
focusSelector: '[name="phone-value-0"]'
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
const visiblePhones = phones.map((phone, index) => ({
|
|
203
|
+
phone,
|
|
204
|
+
index
|
|
205
|
+
})).filter(({
|
|
206
|
+
phone
|
|
207
|
+
}) => phone.status !== 'deleted');
|
|
208
|
+
return (0, _litHtml.html)`
|
|
209
|
+
<section
|
|
210
|
+
aria-labelledby="phone-numbers-heading"
|
|
211
|
+
class="profile-edit-dialog__section">
|
|
212
|
+
<header class="profile__section-header">
|
|
213
|
+
<h3 id="phone-numbers-heading" class="profile-edit-dialog__section-heading">
|
|
214
|
+
<span class="sectionTitleIcon" aria-hidden="true">${_contactIcons.phoneIcon}</span>
|
|
215
|
+
Phone Numbers
|
|
216
|
+
</h3>
|
|
217
|
+
<button
|
|
218
|
+
type="button"
|
|
219
|
+
class="profile__action-button profile-action-text flex-center"
|
|
220
|
+
aria-label="Add another phone number"
|
|
221
|
+
@click=${createNewRow}
|
|
222
|
+
>
|
|
223
|
+
<span class="profile__add-more-content inline-flex-row">
|
|
224
|
+
<span class="profile__add-more-icon inline-flex-row" aria-hidden="true">${_profileIcons.addIcon}</span>
|
|
225
|
+
Add More
|
|
226
|
+
</span>
|
|
227
|
+
</button>
|
|
228
|
+
</header>
|
|
229
|
+
<fieldset>
|
|
230
|
+
<legend class="sr-only">Phone number entries</legend>
|
|
231
|
+
${visiblePhones.map(({
|
|
232
|
+
index
|
|
233
|
+
}, displayIndex) => renderContactPhoneInputRow({
|
|
234
|
+
phones,
|
|
235
|
+
index,
|
|
236
|
+
displayIndex,
|
|
237
|
+
onDelete: () => {
|
|
238
|
+
(0, _rowState.deleteRow)(phones, index);
|
|
239
|
+
onAddRow();
|
|
240
|
+
}
|
|
241
|
+
}))}
|
|
242
|
+
</fieldset>
|
|
243
|
+
</section>
|
|
244
|
+
`;
|
|
245
|
+
}
|
|
246
|
+
function renderContactEmailInputRow({
|
|
247
|
+
emails,
|
|
248
|
+
index,
|
|
249
|
+
displayIndex,
|
|
250
|
+
onDelete
|
|
251
|
+
}) {
|
|
252
|
+
const emailRow = emails[index];
|
|
253
|
+
const label = `Email Address ${displayIndex + 1}`;
|
|
254
|
+
const typeLabel = `Email Type ${displayIndex + 1}`;
|
|
255
|
+
const inputName = `email-value-${index}`;
|
|
256
|
+
const typeInputName = `email-type-${index}`;
|
|
257
|
+
const handleValueInput = e => {
|
|
258
|
+
const target = e.target;
|
|
259
|
+
const nextValue = (0, _sanitizeUtils.sanitizeEmailValue)(target.value);
|
|
260
|
+
if (emails[index]) {
|
|
261
|
+
(0, _rowState.applyRowFieldChange)(emails[index], 'value', nextValue, rowHasContent);
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
const handleTypeInput = e => {
|
|
265
|
+
const target = e.target;
|
|
266
|
+
const nextType = target.value;
|
|
267
|
+
if (emails[index]) {
|
|
268
|
+
(0, _rowState.applyRowSelectChange)(emails[index], 'type', nextType);
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
const handleDelete = event => {
|
|
272
|
+
event.preventDefault();
|
|
273
|
+
onDelete();
|
|
274
|
+
};
|
|
275
|
+
return (0, _litHtml.html)`
|
|
276
|
+
<div class="profile-edit-dialog__row profile-edit-dialog__row--contact-point">
|
|
277
|
+
<label aria-label=${label} class="label profile-edit-dialog__field">
|
|
278
|
+
<input
|
|
279
|
+
class="input"
|
|
280
|
+
type="email"
|
|
281
|
+
name=${inputName}
|
|
282
|
+
.value=${emailRow?.value || ''}
|
|
283
|
+
required
|
|
284
|
+
data-contact-field="value"
|
|
285
|
+
data-entry-node=${emailRow?.entryNode || ''}
|
|
286
|
+
data-row-status=${emailRow?.status || 'n/a'}
|
|
287
|
+
placeholder="Email Address"
|
|
288
|
+
autocomplete="email"
|
|
289
|
+
inputmode="email"
|
|
290
|
+
@input=${handleValueInput}
|
|
291
|
+
/>
|
|
292
|
+
</label>
|
|
293
|
+
<label aria-label=${typeLabel} class="label profile-edit-dialog__field-type emailTypeRow">
|
|
294
|
+
<select name=${typeInputName} id="email-type-select-${inputName}" @change=${handleTypeInput} .value=${emailRow?.type || ''}>
|
|
295
|
+
<option value="Home">Personal</option>
|
|
296
|
+
<option value="Office">Office</option>
|
|
297
|
+
</select>
|
|
298
|
+
</label>
|
|
299
|
+
<div class="profile-edit-dialog__actions">
|
|
300
|
+
<button
|
|
301
|
+
type="button"
|
|
302
|
+
class="profile-edit-dialog__delete-button"
|
|
303
|
+
aria-label=${`Delete email address ${displayIndex + 1}`}
|
|
304
|
+
title=${_texts.deleteEntryButtonTitleText}
|
|
305
|
+
@click=${handleDelete}
|
|
306
|
+
>
|
|
307
|
+
<span class="profile-edit-dialog__delete-icon" aria-hidden="true">${_profileIcons.trashIcon}</span>
|
|
308
|
+
</button>
|
|
309
|
+
</div>
|
|
310
|
+
</div>
|
|
311
|
+
`;
|
|
312
|
+
}
|
|
313
|
+
function renderContactInfoEmailSection(emails, onAddRow) {
|
|
314
|
+
const createNewRow = event => {
|
|
315
|
+
event.preventDefault();
|
|
316
|
+
emails.unshift({
|
|
317
|
+
value: '',
|
|
318
|
+
type: '',
|
|
319
|
+
entryNode: '',
|
|
320
|
+
status: 'new'
|
|
321
|
+
});
|
|
322
|
+
onAddRow({
|
|
323
|
+
focusSelector: '[name="email-value-0"]'
|
|
324
|
+
});
|
|
325
|
+
};
|
|
326
|
+
const visibleEmails = emails.map((email, index) => ({
|
|
327
|
+
email,
|
|
328
|
+
index
|
|
329
|
+
})).filter(({
|
|
330
|
+
email
|
|
331
|
+
}) => email.status !== 'deleted');
|
|
332
|
+
return (0, _litHtml.html)`
|
|
333
|
+
<section
|
|
334
|
+
aria-labelledby="email-addresses-heading"
|
|
335
|
+
class="profile-edit-dialog__section">
|
|
336
|
+
<header class="profile__section-header">
|
|
337
|
+
<h3 id="email-addresses-heading" class="profile-edit-dialog__section-heading">
|
|
338
|
+
<span class="sectionTitleIcon" aria-hidden="true">${_contactIcons.emailIcon}</span>
|
|
339
|
+
Email Addresses
|
|
340
|
+
</h3>
|
|
341
|
+
<button
|
|
342
|
+
type="button"
|
|
343
|
+
class="profile__action-button profile-action-text flex-center"
|
|
344
|
+
aria-label="Add another email address"
|
|
345
|
+
@click=${createNewRow}
|
|
346
|
+
>
|
|
347
|
+
<span class="profile__add-more-content inline-flex-row">
|
|
348
|
+
<span class="profile__add-more-icon inline-flex-row" aria-hidden="true">${_profileIcons.addIcon}</span>
|
|
349
|
+
Add More
|
|
350
|
+
</span>
|
|
351
|
+
</button>
|
|
352
|
+
</header>
|
|
353
|
+
<fieldset>
|
|
354
|
+
<legend class="sr-only">Email address entries</legend>
|
|
355
|
+
${visibleEmails.map(({
|
|
356
|
+
index
|
|
357
|
+
}, displayIndex) => renderContactEmailInputRow({
|
|
358
|
+
emails,
|
|
359
|
+
index,
|
|
360
|
+
displayIndex,
|
|
361
|
+
onDelete: () => {
|
|
362
|
+
(0, _rowState.deleteRow)(emails, index);
|
|
363
|
+
onAddRow();
|
|
364
|
+
}
|
|
365
|
+
}))}
|
|
366
|
+
</fieldset>
|
|
367
|
+
</section>
|
|
368
|
+
`;
|
|
369
|
+
}
|
|
370
|
+
function renderContactAddressInputRow({
|
|
371
|
+
addresses,
|
|
372
|
+
index,
|
|
373
|
+
displayIndex,
|
|
374
|
+
onDelete
|
|
375
|
+
}) {
|
|
376
|
+
const addressRow = addresses[index];
|
|
377
|
+
const label = `Address ${displayIndex + 1}`;
|
|
378
|
+
const typeLabel = `Address Type ${displayIndex + 1}`;
|
|
379
|
+
const streetAddressName = `address-street-${index}`;
|
|
380
|
+
const localityName = `address-locality-${index}`;
|
|
381
|
+
const regionName = `address-region-${index}`;
|
|
382
|
+
const postalCodeName = `address-postal-${index}`;
|
|
383
|
+
const countryName = `address-country-${index}`;
|
|
384
|
+
const typeInputName = `address-type-${index}`;
|
|
385
|
+
const addressTypeSelectId = `address-type-select-${index}`;
|
|
386
|
+
const handleAddressInput = field => e => {
|
|
387
|
+
const target = e.target;
|
|
388
|
+
const nextValue = (0, _sanitizeUtils.sanitizeAddressFieldValue)(target.value);
|
|
389
|
+
if (addresses[index]) {
|
|
390
|
+
(0, _rowState.applyRowFieldChange)(addresses[index], field, nextValue, rowHasContent);
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
const handleTypeInput = e => {
|
|
394
|
+
const target = e.target;
|
|
395
|
+
const nextType = target.value;
|
|
396
|
+
if (addresses[index]) {
|
|
397
|
+
(0, _rowState.applyRowSelectChange)(addresses[index], 'type', nextType);
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
const handleDelete = event => {
|
|
401
|
+
event.preventDefault();
|
|
402
|
+
onDelete();
|
|
403
|
+
};
|
|
404
|
+
return (0, _litHtml.html)`
|
|
405
|
+
<div class="profile-edit-dialog__row profile-edit-dialog__row--address-header profile-edit-dialog__row--full">
|
|
406
|
+
<p class="profile-edit-dialog__address-title">${label}</p>
|
|
407
|
+
<label aria-label=${typeLabel} class="label profile-edit-dialog__field-type profile-edit-dialog__field-type--wide hidden">
|
|
408
|
+
Address Type
|
|
409
|
+
<select name=${typeInputName} id=${addressTypeSelectId} @change=${handleTypeInput} .value=${addressRow?.type || ''}>
|
|
410
|
+
<option value="Home">Home</option>
|
|
411
|
+
<option value="Work">Work</option>
|
|
412
|
+
</select>
|
|
413
|
+
</label>
|
|
414
|
+
<div class="profile-edit-dialog__actions profile-edit-dialog__actions--edge">
|
|
415
|
+
<button
|
|
416
|
+
type="button"
|
|
417
|
+
class="profile-edit-dialog__delete-button"
|
|
418
|
+
aria-label=${`Delete address ${displayIndex + 1}`}
|
|
419
|
+
title=${_texts.deleteEntryButtonTitleText}
|
|
420
|
+
@click=${handleDelete}
|
|
421
|
+
>
|
|
422
|
+
<span class="profile-edit-dialog__delete-icon" aria-hidden="true">${_profileIcons.trashIcon}</span>
|
|
423
|
+
</button>
|
|
424
|
+
</div>
|
|
425
|
+
</div>
|
|
426
|
+
<div class="profile-edit-dialog__row profile-edit-dialog__row--full">
|
|
427
|
+
<label aria-label=${`${label} Street`} class="label profile-edit-dialog__field profile-edit-dialog__field--full">
|
|
428
|
+
Street Address
|
|
429
|
+
<input
|
|
430
|
+
class="input"
|
|
431
|
+
type="text"
|
|
432
|
+
name=${streetAddressName}
|
|
433
|
+
.value=${addressRow?.streetAddress || ''}
|
|
434
|
+
required
|
|
435
|
+
data-contact-field="streetAddress"
|
|
436
|
+
data-entry-node=${addressRow?.entryNode || ''}
|
|
437
|
+
data-row-status=${addressRow?.status || 'n/a'}
|
|
438
|
+
placeholder="Street Address"
|
|
439
|
+
autocomplete="street-address"
|
|
440
|
+
inputmode="text"
|
|
441
|
+
@change=${handleAddressInput('streetAddress')}
|
|
442
|
+
/>
|
|
443
|
+
</label>
|
|
444
|
+
</div>
|
|
445
|
+
<div class="profile-edit-dialog__row profile-edit-dialog__row--full profile-edit-dialog__row--equal">
|
|
446
|
+
<label aria-label=${`${label} Locality`} class="label profile-edit-dialog__field">
|
|
447
|
+
Locality
|
|
448
|
+
<input
|
|
449
|
+
class="input"
|
|
450
|
+
type="text"
|
|
451
|
+
name=${localityName}
|
|
452
|
+
.value=${addressRow?.locality || ''}
|
|
453
|
+
data-contact-field="locality"
|
|
454
|
+
data-entry-node=${addressRow?.entryNode || ''}
|
|
455
|
+
data-row-status=${addressRow?.status || 'n/a'}
|
|
456
|
+
placeholder="City / Locality"
|
|
457
|
+
autocomplete="address-level2"
|
|
458
|
+
inputmode="text"
|
|
459
|
+
@change=${handleAddressInput('locality')}
|
|
460
|
+
/>
|
|
461
|
+
</label>
|
|
462
|
+
<label aria-label=${`${label} Postal Code`} class="label profile-edit-dialog__field">
|
|
463
|
+
Postal Code
|
|
464
|
+
<input
|
|
465
|
+
class="input"
|
|
466
|
+
type="text"
|
|
467
|
+
name=${postalCodeName}
|
|
468
|
+
.value=${addressRow?.postalCode || ''}
|
|
469
|
+
data-contact-field="postalCode"
|
|
470
|
+
data-entry-node=${addressRow?.entryNode || ''}
|
|
471
|
+
data-row-status=${addressRow?.status || 'n/a'}
|
|
472
|
+
placeholder="Postal Code"
|
|
473
|
+
autocomplete="postal-code"
|
|
474
|
+
inputmode="text"
|
|
475
|
+
@change=${handleAddressInput('postalCode')}
|
|
476
|
+
/>
|
|
477
|
+
</label>
|
|
478
|
+
</div>
|
|
479
|
+
|
|
480
|
+
<div class="profile-edit-dialog__row profile-edit-dialog__row--full profile-edit-dialog__row--equal">
|
|
481
|
+
<label aria-label=${`${label} Region`} class="label profile-edit-dialog__field">
|
|
482
|
+
Region
|
|
483
|
+
<input
|
|
484
|
+
class="input"
|
|
485
|
+
type="text"
|
|
486
|
+
name=${regionName}
|
|
487
|
+
.value=${addressRow?.region || ''}
|
|
488
|
+
data-contact-field="region"
|
|
489
|
+
data-entry-node=${addressRow?.entryNode || ''}
|
|
490
|
+
data-row-status=${addressRow?.status || 'n/a'}
|
|
491
|
+
placeholder="State / Region"
|
|
492
|
+
autocomplete="address-level1"
|
|
493
|
+
inputmode="text"
|
|
494
|
+
@change=${handleAddressInput('region')}
|
|
495
|
+
/>
|
|
496
|
+
</label>
|
|
497
|
+
<label aria-label=${`${label} Country`} class="label profile-edit-dialog__field">
|
|
498
|
+
Country
|
|
499
|
+
<input
|
|
500
|
+
class="input"
|
|
501
|
+
type="text"
|
|
502
|
+
name=${countryName}
|
|
503
|
+
.value=${addressRow?.countryName || ''}
|
|
504
|
+
data-contact-field="countryName"
|
|
505
|
+
data-entry-node=${addressRow?.entryNode || ''}
|
|
506
|
+
data-row-status=${addressRow?.status || 'n/a'}
|
|
507
|
+
placeholder="Country"
|
|
508
|
+
autocomplete="country-name"
|
|
509
|
+
inputmode="text"
|
|
510
|
+
@change=${handleAddressInput('countryName')}
|
|
511
|
+
/>
|
|
512
|
+
</label>
|
|
513
|
+
</div>
|
|
514
|
+
`;
|
|
515
|
+
}
|
|
516
|
+
function renderContactInfoAddressSection(addresses, onAddRow) {
|
|
517
|
+
const createNewRow = event => {
|
|
518
|
+
event.preventDefault();
|
|
519
|
+
addresses.unshift({
|
|
520
|
+
streetAddress: '',
|
|
521
|
+
locality: '',
|
|
522
|
+
region: '',
|
|
523
|
+
postalCode: '',
|
|
524
|
+
countryName: '',
|
|
525
|
+
type: '',
|
|
526
|
+
entryNode: '',
|
|
527
|
+
status: 'new'
|
|
528
|
+
});
|
|
529
|
+
onAddRow({
|
|
530
|
+
focusSelector: '[name="address-street-0"]'
|
|
531
|
+
});
|
|
532
|
+
};
|
|
533
|
+
const visibleAddresses = addresses.map((address, index) => ({
|
|
534
|
+
address,
|
|
535
|
+
index
|
|
536
|
+
})).filter(({
|
|
537
|
+
address
|
|
538
|
+
}) => address.status !== 'deleted');
|
|
539
|
+
return (0, _litHtml.html)`
|
|
540
|
+
<section
|
|
541
|
+
aria-labelledby="address-heading"
|
|
542
|
+
class="profile-edit-dialog__section">
|
|
543
|
+
<header class="profile__section-header">
|
|
544
|
+
<h3 id="address-heading" class="profile-edit-dialog__section-heading">
|
|
545
|
+
<span class="sectionTitleIcon" aria-hidden="true">${_profileIcons.locationIcon}</span>
|
|
546
|
+
Addresses
|
|
547
|
+
</h3>
|
|
548
|
+
<button
|
|
549
|
+
type="button"
|
|
550
|
+
class="profile__action-button profile-action-text flex-center"
|
|
551
|
+
aria-label="Add another address"
|
|
552
|
+
@click=${createNewRow}
|
|
553
|
+
>
|
|
554
|
+
<span class="profile__add-more-content inline-flex-row">
|
|
555
|
+
<span class="profile__add-more-icon inline-flex-row" aria-hidden="true">${_profileIcons.addIcon}</span>
|
|
556
|
+
Add More
|
|
557
|
+
</span>
|
|
558
|
+
</button>
|
|
559
|
+
</header>
|
|
560
|
+
<fieldset>
|
|
561
|
+
<legend class="sr-only">Address entries</legend>
|
|
562
|
+
${visibleAddresses.map(({
|
|
563
|
+
index
|
|
564
|
+
}, displayIndex) => renderContactAddressInputRow({
|
|
565
|
+
addresses,
|
|
566
|
+
index,
|
|
567
|
+
displayIndex,
|
|
568
|
+
onDelete: () => {
|
|
569
|
+
(0, _rowState.deleteRow)(addresses, index);
|
|
570
|
+
onAddRow();
|
|
571
|
+
}
|
|
572
|
+
}))}
|
|
573
|
+
</fieldset>
|
|
574
|
+
</section>
|
|
575
|
+
`;
|
|
576
|
+
}
|
|
577
|
+
function focusContactInfoField(form, selector) {
|
|
578
|
+
const nextField = form.querySelector(selector);
|
|
579
|
+
if (!nextField || typeof nextField.focus !== 'function') return;
|
|
580
|
+
nextField.scrollIntoView({
|
|
581
|
+
block: 'nearest',
|
|
582
|
+
behavior: 'auto'
|
|
583
|
+
});
|
|
584
|
+
nextField.focus();
|
|
585
|
+
if (nextField instanceof HTMLInputElement || nextField instanceof HTMLTextAreaElement) {
|
|
586
|
+
nextField.select();
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
function renderContactInfoEditTemplate(form, formState, viewerMode, options = {}) {
|
|
590
|
+
const rerender = (nextOptions = {}) => renderContactInfoEditTemplate(form, formState, viewerMode, nextOptions);
|
|
591
|
+
(0, _litHtml.render)((0, _litHtml.html)`
|
|
592
|
+
${renderContactInfoPhoneSection(formState.phones, rerender)}
|
|
593
|
+
${renderContactInfoEmailSection(formState.emails, rerender)}
|
|
594
|
+
${renderContactInfoAddressSection(formState.addresses, rerender)}
|
|
595
|
+
${viewerMode !== 'owner' ? (0, _litHtml.html)`<p class="profile-edit-dialog__login-message">${_texts.ownerLoginRequiredDialogMessageText}</p>` : null}
|
|
596
|
+
`, form);
|
|
597
|
+
if (options.focusSelector) {
|
|
598
|
+
focusContactInfoField(form, options.focusSelector);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
function createContactInfoEditForm(contactInfo, viewerMode) {
|
|
602
|
+
const form = document.createElement('form');
|
|
603
|
+
form.classList.add('profile__edit-form');
|
|
604
|
+
form.classList.add('profile__edit-form--contact-info');
|
|
605
|
+
const formState = toFormState(contactInfo);
|
|
606
|
+
renderContactInfoEditTemplate(form, formState, viewerMode);
|
|
607
|
+
return {
|
|
608
|
+
form,
|
|
609
|
+
formState
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
function validateContactInfoBeforeSave(formState) {
|
|
613
|
+
const phoneOps = (0, _rowState.summarizeRowOps)(formState.phones, rowHasContent);
|
|
614
|
+
const emailOps = (0, _rowState.summarizeRowOps)(formState.emails, rowHasContent);
|
|
615
|
+
const addressOps = (0, _rowState.summarizeRowOps)(formState.addresses, rowHasContent);
|
|
616
|
+
const hasChanges = phoneOps.create.length > 0 || phoneOps.update.length > 0 || phoneOps.remove.length > 0 || emailOps.create.length > 0 || emailOps.update.length > 0 || emailOps.remove.length > 0 || addressOps.create.length > 0 || addressOps.update.length > 0 || addressOps.remove.length > 0;
|
|
617
|
+
if (!hasChanges) return 'No contact info changes detected.';
|
|
618
|
+
return null;
|
|
619
|
+
}
|
|
620
|
+
async function createContactInfoEditDialog(event, store, subject, contactInfo, viewerMode, onSaved) {
|
|
621
|
+
const dom = event.currentTarget?.ownerDocument || document;
|
|
622
|
+
const {
|
|
623
|
+
form,
|
|
624
|
+
formState
|
|
625
|
+
} = createContactInfoEditForm(contactInfo, viewerMode);
|
|
626
|
+
const result = await (0, _dialog.openInputDialog)({
|
|
627
|
+
title: _texts.editContactInfoDialogTitleText,
|
|
628
|
+
dom,
|
|
629
|
+
form,
|
|
630
|
+
headerAction: {
|
|
631
|
+
type: 'close'
|
|
632
|
+
},
|
|
633
|
+
submitLabel: _texts.dialogSubmitLabelText,
|
|
634
|
+
cancelLabel: _texts.dialogCancelLabelText,
|
|
635
|
+
validate: () => {
|
|
636
|
+
if (viewerMode !== 'owner') {
|
|
637
|
+
return _texts.ownerLoginRequiredDialogMessageText;
|
|
638
|
+
}
|
|
639
|
+
return validateContactInfoBeforeSave(formState);
|
|
640
|
+
},
|
|
641
|
+
onSave: async () => {
|
|
642
|
+
const plan = {
|
|
643
|
+
phoneOps: (0, _rowState.summarizeRowOps)(formState.phones, rowHasContent),
|
|
644
|
+
emailOps: (0, _rowState.summarizeRowOps)(formState.emails, rowHasContent),
|
|
645
|
+
addressOps: (0, _rowState.summarizeRowOps)(formState.addresses, rowHasContent)
|
|
646
|
+
};
|
|
647
|
+
await (0, _mutations.processContactInfoMutations)(store, subject, plan);
|
|
648
|
+
},
|
|
649
|
+
formatSaveError: error => {
|
|
650
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
651
|
+
return `${_texts.saveContactUpdatesFailedPrefixText} ${message}`;
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
if (!result) return;
|
|
655
|
+
if (onSaved) {
|
|
656
|
+
await onSaved();
|
|
657
|
+
}
|
|
658
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ViewerMode } from '../../types';
|
|
2
|
+
import { LiveStore, NamedNode } from 'rdflib';
|
|
3
|
+
import { ContactInfo } from './types';
|
|
4
|
+
export declare function renderContactInfoSection(store: LiveStore, subject: NamedNode, contactInfo: ContactInfo, viewerMode: ViewerMode, onSaved?: () => Promise<void> | void): import("lit-html").TemplateResult<1> | "";
|
|
5
|
+
//# sourceMappingURL=ContactInfoSection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContactInfoSection.d.ts","sourceRoot":"","sources":["../../../src/sections/contactInfo/ContactInfoSection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAI7C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAgRrC,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,SAAS,EAClB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,EACtB,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,6CAoBrC"}
|