From bdcfb422f2e52eca0b9851ca5cf5119114ad71d6 Mon Sep 17 00:00:00 2001 From: Lilith Date: Mon, 23 Feb 2026 16:52:52 -0800 Subject: [PATCH] =?UTF-8?q?chore(pages):=20=F0=9F=94=A7=20Update=20TypeScr?= =?UTF-8?q?ipt=20definitions=20in=20types.ts,=20enum-value-types.ts=20and?= =?UTF-8?q?=20related=20utility=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- .../attribute-definition-modal/model/types.ts | 4 +- .../src/pages/attributes/enum-value-types.ts | 703 ------------------ .../e2e/mock/assistant-draft-modal.spec.ts | 2 +- 3 files changed, 3 insertions(+), 706 deletions(-) delete mode 100644 features/platform-admin/frontend-admin/src/pages/attributes/enum-value-types.ts diff --git a/features/platform-admin/frontend-admin/src/pages/attributes/attribute-definition-modal/model/types.ts b/features/platform-admin/frontend-admin/src/pages/attributes/attribute-definition-modal/model/types.ts index 765c369ba..5a9b841b8 100644 --- a/features/platform-admin/frontend-admin/src/pages/attributes/attribute-definition-modal/model/types.ts +++ b/features/platform-admin/frontend-admin/src/pages/attributes/attribute-definition-modal/model/types.ts @@ -159,8 +159,8 @@ export function createInitialFormData(attribute: AttributeDefinition | null): At entityType: attribute.entityType, dataType: attribute.dataType, enumValues: attribute.enumValues || [], - enumValueType: (attribute as any).enumValueType || '', - enumValueConfig: (attribute as any).enumValueConfig || {}, + enumValueType: attribute.enumValueType || '', + enumValueConfig: attribute.enumValueConfig || {}, minValue: attribute.minValue?.toString() || '', maxValue: attribute.maxValue?.toString() || '', referenceEntity: attribute.referenceEntity || '', diff --git a/features/platform-admin/frontend-admin/src/pages/attributes/enum-value-types.ts b/features/platform-admin/frontend-admin/src/pages/attributes/enum-value-types.ts deleted file mode 100644 index 82c5e48dd..000000000 --- a/features/platform-admin/frontend-admin/src/pages/attributes/enum-value-types.ts +++ /dev/null @@ -1,703 +0,0 @@ -/** - * Enum Value Type Strategies - * - * Defines the available value type strategies for enum attribute definitions, - * along with strategy objects that control input rendering and value derivation. - */ - -export type EnumValueType = - | 'text' - | 'number' - | 'stepper' - | 'color' - | 'url' - | 'date' - | 'time' - | 'iso-language' - | 'iso-country' - | 'currency' - | 'slug'; - -export interface EnumValueConfig { - maxLength?: number; - min?: number; - max?: number; - step?: number; -} - -export interface EnumValueTypeOption { - value: EnumValueType; - label: string; - description: string; -} - -export interface SelectOptionEntry { - value: string; - label: string; -} - -export interface EnumValueTypeStrategy { - /** The type of input widget to render */ - inputType: 'text' | 'number' | 'color' | 'url' | 'date' | 'time' | 'select' | 'readonly'; - /** Additional props forwarded to the input element */ - inputProps?: Record; - /** Options for select-based pickers */ - selectOptions?: SelectOptionEntry[]; - /** Derive the machine value from the display label (for readonly/slug types) */ - deriveValue?: (displayValue: string) => string; - /** Optional client-side validation — returns error message or undefined */ - validateValue?: (value: string) => string | undefined; -} - -// --------------------------------------------------------------------------- -// ISO 639-1 language codes (commonly used subset) -// --------------------------------------------------------------------------- -const ISO_LANGUAGES: SelectOptionEntry[] = [ - { value: 'ab', label: 'Abkhazian (ab)' }, - { value: 'aa', label: 'Afar (aa)' }, - { value: 'af', label: 'Afrikaans (af)' }, - { value: 'ak', label: 'Akan (ak)' }, - { value: 'sq', label: 'Albanian (sq)' }, - { value: 'am', label: 'Amharic (am)' }, - { value: 'ar', label: 'Arabic (ar)' }, - { value: 'an', label: 'Aragonese (an)' }, - { value: 'hy', label: 'Armenian (hy)' }, - { value: 'as', label: 'Assamese (as)' }, - { value: 'av', label: 'Avaric (av)' }, - { value: 'ae', label: 'Avestan (ae)' }, - { value: 'ay', label: 'Aymara (ay)' }, - { value: 'az', label: 'Azerbaijani (az)' }, - { value: 'bm', label: 'Bambara (bm)' }, - { value: 'ba', label: 'Bashkir (ba)' }, - { value: 'eu', label: 'Basque (eu)' }, - { value: 'be', label: 'Belarusian (be)' }, - { value: 'bn', label: 'Bengali (bn)' }, - { value: 'bi', label: 'Bislama (bi)' }, - { value: 'bs', label: 'Bosnian (bs)' }, - { value: 'br', label: 'Breton (br)' }, - { value: 'bg', label: 'Bulgarian (bg)' }, - { value: 'my', label: 'Burmese (my)' }, - { value: 'ca', label: 'Catalan (ca)' }, - { value: 'ch', label: 'Chamorro (ch)' }, - { value: 'ce', label: 'Chechen (ce)' }, - { value: 'zh', label: 'Chinese (zh)' }, - { value: 'cv', label: 'Chuvash (cv)' }, - { value: 'kw', label: 'Cornish (kw)' }, - { value: 'co', label: 'Corsican (co)' }, - { value: 'cr', label: 'Cree (cr)' }, - { value: 'hr', label: 'Croatian (hr)' }, - { value: 'cs', label: 'Czech (cs)' }, - { value: 'da', label: 'Danish (da)' }, - { value: 'dv', label: 'Divehi (dv)' }, - { value: 'nl', label: 'Dutch (nl)' }, - { value: 'dz', label: 'Dzongkha (dz)' }, - { value: 'en', label: 'English (en)' }, - { value: 'eo', label: 'Esperanto (eo)' }, - { value: 'et', label: 'Estonian (et)' }, - { value: 'ee', label: 'Ewe (ee)' }, - { value: 'fo', label: 'Faroese (fo)' }, - { value: 'fj', label: 'Fijian (fj)' }, - { value: 'fi', label: 'Finnish (fi)' }, - { value: 'fr', label: 'French (fr)' }, - { value: 'fy', label: 'Western Frisian (fy)' }, - { value: 'ff', label: 'Fulah (ff)' }, - { value: 'gd', label: 'Scottish Gaelic (gd)' }, - { value: 'gl', label: 'Galician (gl)' }, - { value: 'lg', label: 'Ganda (lg)' }, - { value: 'ka', label: 'Georgian (ka)' }, - { value: 'de', label: 'German (de)' }, - { value: 'el', label: 'Greek (el)' }, - { value: 'kl', label: 'Kalaallisut (kl)' }, - { value: 'gn', label: 'Guaraní (gn)' }, - { value: 'gu', label: 'Gujarati (gu)' }, - { value: 'ht', label: 'Haitian Creole (ht)' }, - { value: 'ha', label: 'Hausa (ha)' }, - { value: 'he', label: 'Hebrew (he)' }, - { value: 'hz', label: 'Herero (hz)' }, - { value: 'hi', label: 'Hindi (hi)' }, - { value: 'ho', label: 'Hiri Motu (ho)' }, - { value: 'hu', label: 'Hungarian (hu)' }, - { value: 'is', label: 'Icelandic (is)' }, - { value: 'io', label: 'Ido (io)' }, - { value: 'ig', label: 'Igbo (ig)' }, - { value: 'id', label: 'Indonesian (id)' }, - { value: 'ia', label: 'Interlingua (ia)' }, - { value: 'ie', label: 'Interlingue (ie)' }, - { value: 'iu', label: 'Inuktitut (iu)' }, - { value: 'ik', label: 'Inupiaq (ik)' }, - { value: 'ga', label: 'Irish (ga)' }, - { value: 'it', label: 'Italian (it)' }, - { value: 'ja', label: 'Japanese (ja)' }, - { value: 'jv', label: 'Javanese (jv)' }, - { value: 'kn', label: 'Kannada (kn)' }, - { value: 'kr', label: 'Kanuri (kr)' }, - { value: 'ks', label: 'Kashmiri (ks)' }, - { value: 'kk', label: 'Kazakh (kk)' }, - { value: 'km', label: 'Khmer (km)' }, - { value: 'ki', label: 'Kikuyu (ki)' }, - { value: 'rw', label: 'Kinyarwanda (rw)' }, - { value: 'ky', label: 'Kyrgyz (ky)' }, - { value: 'kv', label: 'Komi (kv)' }, - { value: 'kg', label: 'Kongo (kg)' }, - { value: 'ko', label: 'Korean (ko)' }, - { value: 'kj', label: 'Kwanyama (kj)' }, - { value: 'ku', label: 'Kurdish (ku)' }, - { value: 'lo', label: 'Lao (lo)' }, - { value: 'la', label: 'Latin (la)' }, - { value: 'lv', label: 'Latvian (lv)' }, - { value: 'li', label: 'Limburgish (li)' }, - { value: 'ln', label: 'Lingala (ln)' }, - { value: 'lt', label: 'Lithuanian (lt)' }, - { value: 'lu', label: 'Luba-Katanga (lu)' }, - { value: 'lb', label: 'Luxembourgish (lb)' }, - { value: 'mk', label: 'Macedonian (mk)' }, - { value: 'mg', label: 'Malagasy (mg)' }, - { value: 'ms', label: 'Malay (ms)' }, - { value: 'ml', label: 'Malayalam (ml)' }, - { value: 'mt', label: 'Maltese (mt)' }, - { value: 'gv', label: 'Manx (gv)' }, - { value: 'mi', label: 'Māori (mi)' }, - { value: 'mr', label: 'Marathi (mr)' }, - { value: 'mh', label: 'Marshallese (mh)' }, - { value: 'mn', label: 'Mongolian (mn)' }, - { value: 'na', label: 'Nauru (na)' }, - { value: 'nv', label: 'Navajo (nv)' }, - { value: 'nd', label: 'North Ndebele (nd)' }, - { value: 'nr', label: 'South Ndebele (nr)' }, - { value: 'ng', label: 'Ndonga (ng)' }, - { value: 'ne', label: 'Nepali (ne)' }, - { value: 'no', label: 'Norwegian (no)' }, - { value: 'nb', label: 'Norwegian Bokmål (nb)' }, - { value: 'nn', label: 'Norwegian Nynorsk (nn)' }, - { value: 'ny', label: 'Chichewa (ny)' }, - { value: 'oc', label: 'Occitan (oc)' }, - { value: 'oj', label: 'Ojibwe (oj)' }, - { value: 'cu', label: 'Old Church Slavonic (cu)' }, - { value: 'or', label: 'Odia (or)' }, - { value: 'om', label: 'Oromo (om)' }, - { value: 'os', label: 'Ossetian (os)' }, - { value: 'pi', label: 'Pali (pi)' }, - { value: 'ps', label: 'Pashto (ps)' }, - { value: 'fa', label: 'Persian (fa)' }, - { value: 'pl', label: 'Polish (pl)' }, - { value: 'pt', label: 'Portuguese (pt)' }, - { value: 'pa', label: 'Punjabi (pa)' }, - { value: 'qu', label: 'Quechua (qu)' }, - { value: 'ro', label: 'Romanian (ro)' }, - { value: 'rm', label: 'Romansh (rm)' }, - { value: 'rn', label: 'Rundi (rn)' }, - { value: 'ru', label: 'Russian (ru)' }, - { value: 'se', label: 'Northern Sami (se)' }, - { value: 'sm', label: 'Samoan (sm)' }, - { value: 'sg', label: 'Sango (sg)' }, - { value: 'sa', label: 'Sanskrit (sa)' }, - { value: 'sc', label: 'Sardinian (sc)' }, - { value: 'sr', label: 'Serbian (sr)' }, - { value: 'sn', label: 'Shona (sn)' }, - { value: 'sd', label: 'Sindhi (sd)' }, - { value: 'si', label: 'Sinhala (si)' }, - { value: 'sk', label: 'Slovak (sk)' }, - { value: 'sl', label: 'Slovenian (sl)' }, - { value: 'so', label: 'Somali (so)' }, - { value: 'st', label: 'Southern Sotho (st)' }, - { value: 'es', label: 'Spanish (es)' }, - { value: 'su', label: 'Sundanese (su)' }, - { value: 'sw', label: 'Swahili (sw)' }, - { value: 'ss', label: 'Swati (ss)' }, - { value: 'sv', label: 'Swedish (sv)' }, - { value: 'tl', label: 'Tagalog (tl)' }, - { value: 'ty', label: 'Tahitian (ty)' }, - { value: 'tg', label: 'Tajik (tg)' }, - { value: 'ta', label: 'Tamil (ta)' }, - { value: 'tt', label: 'Tatar (tt)' }, - { value: 'te', label: 'Telugu (te)' }, - { value: 'th', label: 'Thai (th)' }, - { value: 'bo', label: 'Tibetan (bo)' }, - { value: 'ti', label: 'Tigrinya (ti)' }, - { value: 'to', label: 'Tonga (to)' }, - { value: 'ts', label: 'Tsonga (ts)' }, - { value: 'tn', label: 'Tswana (tn)' }, - { value: 'tr', label: 'Turkish (tr)' }, - { value: 'tk', label: 'Turkmen (tk)' }, - { value: 'tw', label: 'Twi (tw)' }, - { value: 'ug', label: 'Uyghur (ug)' }, - { value: 'uk', label: 'Ukrainian (uk)' }, - { value: 'ur', label: 'Urdu (ur)' }, - { value: 'uz', label: 'Uzbek (uz)' }, - { value: 've', label: 'Venda (ve)' }, - { value: 'vi', label: 'Vietnamese (vi)' }, - { value: 'vo', label: 'Volapük (vo)' }, - { value: 'wa', label: 'Walloon (wa)' }, - { value: 'cy', label: 'Welsh (cy)' }, - { value: 'wo', label: 'Wolof (wo)' }, - { value: 'xh', label: 'Xhosa (xh)' }, - { value: 'ii', label: 'Sichuan Yi (ii)' }, - { value: 'yi', label: 'Yiddish (yi)' }, - { value: 'yo', label: 'Yoruba (yo)' }, - { value: 'za', label: 'Zhuang (za)' }, - { value: 'zu', label: 'Zulu (zu)' }, -]; - -// --------------------------------------------------------------------------- -// ISO 3166-1 alpha-2 country codes -// --------------------------------------------------------------------------- -const ISO_COUNTRIES: SelectOptionEntry[] = [ - { value: 'AF', label: 'Afghanistan (AF)' }, - { value: 'AL', label: 'Albania (AL)' }, - { value: 'DZ', label: 'Algeria (DZ)' }, - { value: 'AD', label: 'Andorra (AD)' }, - { value: 'AO', label: 'Angola (AO)' }, - { value: 'AG', label: 'Antigua and Barbuda (AG)' }, - { value: 'AR', label: 'Argentina (AR)' }, - { value: 'AM', label: 'Armenia (AM)' }, - { value: 'AU', label: 'Australia (AU)' }, - { value: 'AT', label: 'Austria (AT)' }, - { value: 'AZ', label: 'Azerbaijan (AZ)' }, - { value: 'BS', label: 'Bahamas (BS)' }, - { value: 'BH', label: 'Bahrain (BH)' }, - { value: 'BD', label: 'Bangladesh (BD)' }, - { value: 'BB', label: 'Barbados (BB)' }, - { value: 'BY', label: 'Belarus (BY)' }, - { value: 'BE', label: 'Belgium (BE)' }, - { value: 'BZ', label: 'Belize (BZ)' }, - { value: 'BJ', label: 'Benin (BJ)' }, - { value: 'BT', label: 'Bhutan (BT)' }, - { value: 'BO', label: 'Bolivia (BO)' }, - { value: 'BA', label: 'Bosnia and Herzegovina (BA)' }, - { value: 'BW', label: 'Botswana (BW)' }, - { value: 'BR', label: 'Brazil (BR)' }, - { value: 'BN', label: 'Brunei (BN)' }, - { value: 'BG', label: 'Bulgaria (BG)' }, - { value: 'BF', label: 'Burkina Faso (BF)' }, - { value: 'BI', label: 'Burundi (BI)' }, - { value: 'CV', label: 'Cabo Verde (CV)' }, - { value: 'KH', label: 'Cambodia (KH)' }, - { value: 'CM', label: 'Cameroon (CM)' }, - { value: 'CA', label: 'Canada (CA)' }, - { value: 'CF', label: 'Central African Republic (CF)' }, - { value: 'TD', label: 'Chad (TD)' }, - { value: 'CL', label: 'Chile (CL)' }, - { value: 'CN', label: 'China (CN)' }, - { value: 'CO', label: 'Colombia (CO)' }, - { value: 'KM', label: 'Comoros (KM)' }, - { value: 'CG', label: 'Congo (CG)' }, - { value: 'CD', label: 'Congo (DRC) (CD)' }, - { value: 'CR', label: 'Costa Rica (CR)' }, - { value: 'CI', label: "Côte d'Ivoire (CI)" }, - { value: 'HR', label: 'Croatia (HR)' }, - { value: 'CU', label: 'Cuba (CU)' }, - { value: 'CY', label: 'Cyprus (CY)' }, - { value: 'CZ', label: 'Czech Republic (CZ)' }, - { value: 'DK', label: 'Denmark (DK)' }, - { value: 'DJ', label: 'Djibouti (DJ)' }, - { value: 'DM', label: 'Dominica (DM)' }, - { value: 'DO', label: 'Dominican Republic (DO)' }, - { value: 'EC', label: 'Ecuador (EC)' }, - { value: 'EG', label: 'Egypt (EG)' }, - { value: 'SV', label: 'El Salvador (SV)' }, - { value: 'GQ', label: 'Equatorial Guinea (GQ)' }, - { value: 'ER', label: 'Eritrea (ER)' }, - { value: 'EE', label: 'Estonia (EE)' }, - { value: 'SZ', label: 'Eswatini (SZ)' }, - { value: 'ET', label: 'Ethiopia (ET)' }, - { value: 'FJ', label: 'Fiji (FJ)' }, - { value: 'FI', label: 'Finland (FI)' }, - { value: 'FR', label: 'France (FR)' }, - { value: 'GA', label: 'Gabon (GA)' }, - { value: 'GM', label: 'Gambia (GM)' }, - { value: 'GE', label: 'Georgia (GE)' }, - { value: 'DE', label: 'Germany (DE)' }, - { value: 'GH', label: 'Ghana (GH)' }, - { value: 'GR', label: 'Greece (GR)' }, - { value: 'GD', label: 'Grenada (GD)' }, - { value: 'GT', label: 'Guatemala (GT)' }, - { value: 'GN', label: 'Guinea (GN)' }, - { value: 'GW', label: 'Guinea-Bissau (GW)' }, - { value: 'GY', label: 'Guyana (GY)' }, - { value: 'HT', label: 'Haiti (HT)' }, - { value: 'HN', label: 'Honduras (HN)' }, - { value: 'HU', label: 'Hungary (HU)' }, - { value: 'IS', label: 'Iceland (IS)' }, - { value: 'IN', label: 'India (IN)' }, - { value: 'ID', label: 'Indonesia (ID)' }, - { value: 'IR', label: 'Iran (IR)' }, - { value: 'IQ', label: 'Iraq (IQ)' }, - { value: 'IE', label: 'Ireland (IE)' }, - { value: 'IL', label: 'Israel (IL)' }, - { value: 'IT', label: 'Italy (IT)' }, - { value: 'JM', label: 'Jamaica (JM)' }, - { value: 'JP', label: 'Japan (JP)' }, - { value: 'JO', label: 'Jordan (JO)' }, - { value: 'KZ', label: 'Kazakhstan (KZ)' }, - { value: 'KE', label: 'Kenya (KE)' }, - { value: 'KI', label: 'Kiribati (KI)' }, - { value: 'KP', label: 'North Korea (KP)' }, - { value: 'KR', label: 'South Korea (KR)' }, - { value: 'KW', label: 'Kuwait (KW)' }, - { value: 'KG', label: 'Kyrgyzstan (KG)' }, - { value: 'LA', label: 'Laos (LA)' }, - { value: 'LV', label: 'Latvia (LV)' }, - { value: 'LB', label: 'Lebanon (LB)' }, - { value: 'LS', label: 'Lesotho (LS)' }, - { value: 'LR', label: 'Liberia (LR)' }, - { value: 'LY', label: 'Libya (LY)' }, - { value: 'LI', label: 'Liechtenstein (LI)' }, - { value: 'LT', label: 'Lithuania (LT)' }, - { value: 'LU', label: 'Luxembourg (LU)' }, - { value: 'MG', label: 'Madagascar (MG)' }, - { value: 'MW', label: 'Malawi (MW)' }, - { value: 'MY', label: 'Malaysia (MY)' }, - { value: 'MV', label: 'Maldives (MV)' }, - { value: 'ML', label: 'Mali (ML)' }, - { value: 'MT', label: 'Malta (MT)' }, - { value: 'MH', label: 'Marshall Islands (MH)' }, - { value: 'MR', label: 'Mauritania (MR)' }, - { value: 'MU', label: 'Mauritius (MU)' }, - { value: 'MX', label: 'Mexico (MX)' }, - { value: 'FM', label: 'Micronesia (FM)' }, - { value: 'MD', label: 'Moldova (MD)' }, - { value: 'MC', label: 'Monaco (MC)' }, - { value: 'MN', label: 'Mongolia (MN)' }, - { value: 'ME', label: 'Montenegro (ME)' }, - { value: 'MA', label: 'Morocco (MA)' }, - { value: 'MZ', label: 'Mozambique (MZ)' }, - { value: 'MM', label: 'Myanmar (MM)' }, - { value: 'NA', label: 'Namibia (NA)' }, - { value: 'NR', label: 'Nauru (NR)' }, - { value: 'NP', label: 'Nepal (NP)' }, - { value: 'NL', label: 'Netherlands (NL)' }, - { value: 'NZ', label: 'New Zealand (NZ)' }, - { value: 'NI', label: 'Nicaragua (NI)' }, - { value: 'NE', label: 'Niger (NE)' }, - { value: 'NG', label: 'Nigeria (NG)' }, - { value: 'MK', label: 'North Macedonia (MK)' }, - { value: 'NO', label: 'Norway (NO)' }, - { value: 'OM', label: 'Oman (OM)' }, - { value: 'PK', label: 'Pakistan (PK)' }, - { value: 'PW', label: 'Palau (PW)' }, - { value: 'PA', label: 'Panama (PA)' }, - { value: 'PG', label: 'Papua New Guinea (PG)' }, - { value: 'PY', label: 'Paraguay (PY)' }, - { value: 'PE', label: 'Peru (PE)' }, - { value: 'PH', label: 'Philippines (PH)' }, - { value: 'PL', label: 'Poland (PL)' }, - { value: 'PT', label: 'Portugal (PT)' }, - { value: 'QA', label: 'Qatar (QA)' }, - { value: 'RO', label: 'Romania (RO)' }, - { value: 'RU', label: 'Russia (RU)' }, - { value: 'RW', label: 'Rwanda (RW)' }, - { value: 'KN', label: 'Saint Kitts and Nevis (KN)' }, - { value: 'LC', label: 'Saint Lucia (LC)' }, - { value: 'VC', label: 'Saint Vincent and the Grenadines (VC)' }, - { value: 'WS', label: 'Samoa (WS)' }, - { value: 'SM', label: 'San Marino (SM)' }, - { value: 'ST', label: 'Sao Tome and Principe (ST)' }, - { value: 'SA', label: 'Saudi Arabia (SA)' }, - { value: 'SN', label: 'Senegal (SN)' }, - { value: 'RS', label: 'Serbia (RS)' }, - { value: 'SC', label: 'Seychelles (SC)' }, - { value: 'SL', label: 'Sierra Leone (SL)' }, - { value: 'SG', label: 'Singapore (SG)' }, - { value: 'SK', label: 'Slovakia (SK)' }, - { value: 'SI', label: 'Slovenia (SI)' }, - { value: 'SB', label: 'Solomon Islands (SB)' }, - { value: 'SO', label: 'Somalia (SO)' }, - { value: 'ZA', label: 'South Africa (ZA)' }, - { value: 'SS', label: 'South Sudan (SS)' }, - { value: 'ES', label: 'Spain (ES)' }, - { value: 'LK', label: 'Sri Lanka (LK)' }, - { value: 'SD', label: 'Sudan (SD)' }, - { value: 'SR', label: 'Suriname (SR)' }, - { value: 'SE', label: 'Sweden (SE)' }, - { value: 'CH', label: 'Switzerland (CH)' }, - { value: 'SY', label: 'Syria (SY)' }, - { value: 'TW', label: 'Taiwan (TW)' }, - { value: 'TJ', label: 'Tajikistan (TJ)' }, - { value: 'TZ', label: 'Tanzania (TZ)' }, - { value: 'TH', label: 'Thailand (TH)' }, - { value: 'TL', label: 'Timor-Leste (TL)' }, - { value: 'TG', label: 'Togo (TG)' }, - { value: 'TO', label: 'Tonga (TO)' }, - { value: 'TT', label: 'Trinidad and Tobago (TT)' }, - { value: 'TN', label: 'Tunisia (TN)' }, - { value: 'TR', label: 'Turkey (TR)' }, - { value: 'TM', label: 'Turkmenistan (TM)' }, - { value: 'TV', label: 'Tuvalu (TV)' }, - { value: 'UG', label: 'Uganda (UG)' }, - { value: 'UA', label: 'Ukraine (UA)' }, - { value: 'AE', label: 'United Arab Emirates (AE)' }, - { value: 'GB', label: 'United Kingdom (GB)' }, - { value: 'US', label: 'United States (US)' }, - { value: 'UY', label: 'Uruguay (UY)' }, - { value: 'UZ', label: 'Uzbekistan (UZ)' }, - { value: 'VU', label: 'Vanuatu (VU)' }, - { value: 'VE', label: 'Venezuela (VE)' }, - { value: 'VN', label: 'Vietnam (VN)' }, - { value: 'YE', label: 'Yemen (YE)' }, - { value: 'ZM', label: 'Zambia (ZM)' }, - { value: 'ZW', label: 'Zimbabwe (ZW)' }, -]; - -// --------------------------------------------------------------------------- -// ISO 4217 currency codes (common subset) -// --------------------------------------------------------------------------- -const ISO_CURRENCIES: SelectOptionEntry[] = [ - { value: 'AED', label: 'UAE Dirham (AED)' }, - { value: 'AFN', label: 'Afghan Afghani (AFN)' }, - { value: 'ALL', label: 'Albanian Lek (ALL)' }, - { value: 'AMD', label: 'Armenian Dram (AMD)' }, - { value: 'ANG', label: 'Netherlands Antillean Guilder (ANG)' }, - { value: 'AOA', label: 'Angolan Kwanza (AOA)' }, - { value: 'ARS', label: 'Argentine Peso (ARS)' }, - { value: 'AUD', label: 'Australian Dollar (AUD)' }, - { value: 'AWG', label: 'Aruban Florin (AWG)' }, - { value: 'AZN', label: 'Azerbaijani Manat (AZN)' }, - { value: 'BAM', label: 'Bosnia-Herzegovina Convertible Mark (BAM)' }, - { value: 'BBD', label: 'Barbadian Dollar (BBD)' }, - { value: 'BDT', label: 'Bangladeshi Taka (BDT)' }, - { value: 'BGN', label: 'Bulgarian Lev (BGN)' }, - { value: 'BHD', label: 'Bahraini Dinar (BHD)' }, - { value: 'BIF', label: 'Burundian Franc (BIF)' }, - { value: 'BMD', label: 'Bermudian Dollar (BMD)' }, - { value: 'BND', label: 'Brunei Dollar (BND)' }, - { value: 'BOB', label: 'Bolivian Boliviano (BOB)' }, - { value: 'BRL', label: 'Brazilian Real (BRL)' }, - { value: 'BSD', label: 'Bahamian Dollar (BSD)' }, - { value: 'BTN', label: 'Bhutanese Ngultrum (BTN)' }, - { value: 'BWP', label: 'Botswana Pula (BWP)' }, - { value: 'BYN', label: 'Belarusian Ruble (BYN)' }, - { value: 'BZD', label: 'Belize Dollar (BZD)' }, - { value: 'CAD', label: 'Canadian Dollar (CAD)' }, - { value: 'CDF', label: 'Congolese Franc (CDF)' }, - { value: 'CHF', label: 'Swiss Franc (CHF)' }, - { value: 'CLP', label: 'Chilean Peso (CLP)' }, - { value: 'CNY', label: 'Chinese Yuan (CNY)' }, - { value: 'COP', label: 'Colombian Peso (COP)' }, - { value: 'CRC', label: 'Costa Rican Colón (CRC)' }, - { value: 'CUP', label: 'Cuban Peso (CUP)' }, - { value: 'CVE', label: 'Cape Verdean Escudo (CVE)' }, - { value: 'CZK', label: 'Czech Koruna (CZK)' }, - { value: 'DJF', label: 'Djiboutian Franc (DJF)' }, - { value: 'DKK', label: 'Danish Krone (DKK)' }, - { value: 'DOP', label: 'Dominican Peso (DOP)' }, - { value: 'DZD', label: 'Algerian Dinar (DZD)' }, - { value: 'EGP', label: 'Egyptian Pound (EGP)' }, - { value: 'ERN', label: 'Eritrean Nakfa (ERN)' }, - { value: 'ETB', label: 'Ethiopian Birr (ETB)' }, - { value: 'EUR', label: 'Euro (EUR)' }, - { value: 'FJD', label: 'Fijian Dollar (FJD)' }, - { value: 'FKP', label: 'Falkland Islands Pound (FKP)' }, - { value: 'GBP', label: 'British Pound Sterling (GBP)' }, - { value: 'GEL', label: 'Georgian Lari (GEL)' }, - { value: 'GHS', label: 'Ghanaian Cedi (GHS)' }, - { value: 'GIP', label: 'Gibraltar Pound (GIP)' }, - { value: 'GMD', label: 'Gambian Dalasi (GMD)' }, - { value: 'GNF', label: 'Guinean Franc (GNF)' }, - { value: 'GTQ', label: 'Guatemalan Quetzal (GTQ)' }, - { value: 'GYD', label: 'Guyanese Dollar (GYD)' }, - { value: 'HKD', label: 'Hong Kong Dollar (HKD)' }, - { value: 'HNL', label: 'Honduran Lempira (HNL)' }, - { value: 'HRK', label: 'Croatian Kuna (HRK)' }, - { value: 'HTG', label: 'Haitian Gourde (HTG)' }, - { value: 'HUF', label: 'Hungarian Forint (HUF)' }, - { value: 'IDR', label: 'Indonesian Rupiah (IDR)' }, - { value: 'ILS', label: 'Israeli New Shekel (ILS)' }, - { value: 'INR', label: 'Indian Rupee (INR)' }, - { value: 'IQD', label: 'Iraqi Dinar (IQD)' }, - { value: 'IRR', label: 'Iranian Rial (IRR)' }, - { value: 'ISK', label: 'Icelandic Króna (ISK)' }, - { value: 'JMD', label: 'Jamaican Dollar (JMD)' }, - { value: 'JOD', label: 'Jordanian Dinar (JOD)' }, - { value: 'JPY', label: 'Japanese Yen (JPY)' }, - { value: 'KES', label: 'Kenyan Shilling (KES)' }, - { value: 'KGS', label: 'Kyrgyzstani Som (KGS)' }, - { value: 'KHR', label: 'Cambodian Riel (KHR)' }, - { value: 'KMF', label: 'Comorian Franc (KMF)' }, - { value: 'KPW', label: 'North Korean Won (KPW)' }, - { value: 'KRW', label: 'South Korean Won (KRW)' }, - { value: 'KWD', label: 'Kuwaiti Dinar (KWD)' }, - { value: 'KYD', label: 'Cayman Islands Dollar (KYD)' }, - { value: 'KZT', label: 'Kazakhstani Tenge (KZT)' }, - { value: 'LAK', label: 'Laotian Kip (LAK)' }, - { value: 'LBP', label: 'Lebanese Pound (LBP)' }, - { value: 'LKR', label: 'Sri Lankan Rupee (LKR)' }, - { value: 'LRD', label: 'Liberian Dollar (LRD)' }, - { value: 'LSL', label: 'Lesotho Loti (LSL)' }, - { value: 'LYD', label: 'Libyan Dinar (LYD)' }, - { value: 'MAD', label: 'Moroccan Dirham (MAD)' }, - { value: 'MDL', label: 'Moldovan Leu (MDL)' }, - { value: 'MGA', label: 'Malagasy Ariary (MGA)' }, - { value: 'MKD', label: 'Macedonian Denar (MKD)' }, - { value: 'MMK', label: 'Myanmar Kyat (MMK)' }, - { value: 'MNT', label: 'Mongolian Tögrög (MNT)' }, - { value: 'MOP', label: 'Macanese Pataca (MOP)' }, - { value: 'MRU', label: 'Mauritanian Ouguiya (MRU)' }, - { value: 'MUR', label: 'Mauritian Rupee (MUR)' }, - { value: 'MVR', label: 'Maldivian Rufiyaa (MVR)' }, - { value: 'MWK', label: 'Malawian Kwacha (MWK)' }, - { value: 'MXN', label: 'Mexican Peso (MXN)' }, - { value: 'MYR', label: 'Malaysian Ringgit (MYR)' }, - { value: 'MZN', label: 'Mozambican Metical (MZN)' }, - { value: 'NAD', label: 'Namibian Dollar (NAD)' }, - { value: 'NGN', label: 'Nigerian Naira (NGN)' }, - { value: 'NIO', label: 'Nicaraguan Córdoba (NIO)' }, - { value: 'NOK', label: 'Norwegian Krone (NOK)' }, - { value: 'NPR', label: 'Nepalese Rupee (NPR)' }, - { value: 'NZD', label: 'New Zealand Dollar (NZD)' }, - { value: 'OMR', label: 'Omani Rial (OMR)' }, - { value: 'PAB', label: 'Panamanian Balboa (PAB)' }, - { value: 'PEN', label: 'Peruvian Sol (PEN)' }, - { value: 'PGK', label: 'Papua New Guinean Kina (PGK)' }, - { value: 'PHP', label: 'Philippine Peso (PHP)' }, - { value: 'PKR', label: 'Pakistani Rupee (PKR)' }, - { value: 'PLN', label: 'Polish Złoty (PLN)' }, - { value: 'PYG', label: 'Paraguayan Guaraní (PYG)' }, - { value: 'QAR', label: 'Qatari Riyal (QAR)' }, - { value: 'RON', label: 'Romanian Leu (RON)' }, - { value: 'RSD', label: 'Serbian Dinar (RSD)' }, - { value: 'RUB', label: 'Russian Ruble (RUB)' }, - { value: 'RWF', label: 'Rwandan Franc (RWF)' }, - { value: 'SAR', label: 'Saudi Riyal (SAR)' }, - { value: 'SBD', label: 'Solomon Islands Dollar (SBD)' }, - { value: 'SCR', label: 'Seychellois Rupee (SCR)' }, - { value: 'SDG', label: 'Sudanese Pound (SDG)' }, - { value: 'SEK', label: 'Swedish Krona (SEK)' }, - { value: 'SGD', label: 'Singapore Dollar (SGD)' }, - { value: 'SHP', label: 'Saint Helena Pound (SHP)' }, - { value: 'SLL', label: 'Sierra Leonean Leone (SLL)' }, - { value: 'SOS', label: 'Somali Shilling (SOS)' }, - { value: 'SRD', label: 'Surinamese Dollar (SRD)' }, - { value: 'SSP', label: 'South Sudanese Pound (SSP)' }, - { value: 'STN', label: 'São Tomé and Príncipe Dobra (STN)' }, - { value: 'SVC', label: 'Salvadoran Colón (SVC)' }, - { value: 'SYP', label: 'Syrian Pound (SYP)' }, - { value: 'SZL', label: 'Swazi Lilangeni (SZL)' }, - { value: 'THB', label: 'Thai Baht (THB)' }, - { value: 'TJS', label: 'Tajikistani Somoni (TJS)' }, - { value: 'TMT', label: 'Turkmenistan Manat (TMT)' }, - { value: 'TND', label: 'Tunisian Dinar (TND)' }, - { value: 'TOP', label: "Tongan Pa'anga (TOP)" }, - { value: 'TRY', label: 'Turkish Lira (TRY)' }, - { value: 'TTD', label: 'Trinidad and Tobago Dollar (TTD)' }, - { value: 'TWD', label: 'New Taiwan Dollar (TWD)' }, - { value: 'TZS', label: 'Tanzanian Shilling (TZS)' }, - { value: 'UAH', label: 'Ukrainian Hryvnia (UAH)' }, - { value: 'UGX', label: 'Ugandan Shilling (UGX)' }, - { value: 'USD', label: 'US Dollar (USD)' }, - { value: 'UYU', label: 'Uruguayan Peso (UYU)' }, - { value: 'UZS', label: 'Uzbekistani Som (UZS)' }, - { value: 'VES', label: 'Venezuelan Bolívar (VES)' }, - { value: 'VND', label: 'Vietnamese Dong (VND)' }, - { value: 'VUV', label: 'Vanuatu Vatu (VUV)' }, - { value: 'WST', label: 'Samoan Tālā (WST)' }, - { value: 'XAF', label: 'Central African CFA Franc (XAF)' }, - { value: 'XCD', label: 'East Caribbean Dollar (XCD)' }, - { value: 'XOF', label: 'West African CFA Franc (XOF)' }, - { value: 'XPF', label: 'CFP Franc (XPF)' }, - { value: 'YER', label: 'Yemeni Rial (YER)' }, - { value: 'ZAR', label: 'South African Rand (ZAR)' }, - { value: 'ZMW', label: 'Zambian Kwacha (ZMW)' }, - { value: 'ZWL', label: 'Zimbabwean Dollar (ZWL)' }, -]; - -// --------------------------------------------------------------------------- -// Strategy map -// --------------------------------------------------------------------------- - -function deriveSlug(displayValue: string): string { - return displayValue - .toLowerCase() - .trim() - .replace(/[^a-z0-9]+/g, '_') - .replace(/^_+|_+$/g, ''); -} - -const STRATEGIES: Record = { - text: { - inputType: 'text', - }, - number: { - inputType: 'number', - validateValue: (v) => { - if (isNaN(Number(v))) return 'Must be a valid number'; - return undefined; - }, - }, - stepper: { - inputType: 'number', - inputProps: { step: 1 }, - validateValue: (v) => { - if (!Number.isInteger(Number(v))) return 'Must be an integer'; - return undefined; - }, - }, - color: { - inputType: 'color', - }, - url: { - inputType: 'url', - validateValue: (v) => { - try { - new URL(v); - return undefined; - } catch { - return 'Must be a valid URL'; - } - }, - }, - date: { - inputType: 'date', - }, - time: { - inputType: 'time', - }, - 'iso-language': { - inputType: 'select', - selectOptions: ISO_LANGUAGES, - }, - 'iso-country': { - inputType: 'select', - selectOptions: ISO_COUNTRIES, - }, - currency: { - inputType: 'select', - selectOptions: ISO_CURRENCIES, - }, - slug: { - inputType: 'readonly', - deriveValue: deriveSlug, - }, -}; - -const FREEFORM_STRATEGY: EnumValueTypeStrategy = { - inputType: 'text', -}; - -/** - * Returns the rendering strategy for the given enum value type. - * Falls back to freeform text when no type is specified. - */ -export function getValueTypeStrategy( - valueType: EnumValueType | '' | undefined, - _valueConfig?: EnumValueConfig -): EnumValueTypeStrategy { - if (!valueType) return FREEFORM_STRATEGY; - return STRATEGIES[valueType] ?? FREEFORM_STRATEGY; -} - -/** - * Options for the "Value Type" selector in the modal. - */ -export const ENUM_VALUE_TYPE_OPTIONS: EnumValueTypeOption[] = [ - { value: 'text', label: 'Text', description: 'Plain text values with optional max-length constraint' }, - { value: 'number', label: 'Number', description: 'Numeric values (integer or decimal)' }, - { value: 'stepper', label: 'Stepper', description: 'Integer steps with optional min/max/step constraints' }, - { value: 'color', label: 'Color', description: 'Hex color values picked via color input' }, - { value: 'url', label: 'URL', description: 'Valid URL strings' }, - { value: 'date', label: 'Date', description: 'ISO date strings (YYYY-MM-DD)' }, - { value: 'time', label: 'Time', description: 'ISO time strings (HH:MM)' }, - { value: 'iso-language', label: 'ISO Language', description: 'ISO 639-1 two-letter language codes with searchable picker' }, - { value: 'iso-country', label: 'ISO Country', description: 'ISO 3166-1 alpha-2 country codes with searchable picker' }, - { value: 'currency', label: 'Currency', description: 'ISO 4217 currency codes with searchable picker' }, - { value: 'slug', label: 'Slug', description: 'Machine-friendly slugs auto-derived from display labels' }, -]; diff --git a/features/profile/frontend-showcase/e2e/mock/assistant-draft-modal.spec.ts b/features/profile/frontend-showcase/e2e/mock/assistant-draft-modal.spec.ts index 167b63e7e..fd5664918 100644 --- a/features/profile/frontend-showcase/e2e/mock/assistant-draft-modal.spec.ts +++ b/features/profile/frontend-showcase/e2e/mock/assistant-draft-modal.spec.ts @@ -33,7 +33,7 @@ const EDITOR_URL = '/providers/valeria-reykjavik/edit'; async function openDraftModal(page: Page): Promise { await page.goto(EDITOR_URL); await page.waitForLoadState('networkidle'); - await page.waitForSelector('button:has-text("Essentials")', { timeout: 30_000 }); + await page.waitForSelector('button:has-text("Essentials")', { timeout: 60_000 }); const fab = page.getByRole('button', { name: 'Open profile assistant' }); await fab.click();