{"version":3,"file":"index-DKC-bIST.mjs","sources":["../../admin/src/pluginId.ts","../../admin/src/utils/prefixPluginTranslations.ts","../../admin/src/components/CountrySelectIcon/index.tsx","../../admin/src/utils/getTrad.ts","../../admin/src/index.ts"],"sourcesContent":["export const PLUGIN_ID = 'country-select';\n","import { PLUGIN_ID } from '../pluginId';\n\ntype TradOptions = Record<string, string>;\n\nexport const prefixPluginTranslations = (\n    trad: TradOptions,\n): TradOptions => {\n    return Object.keys(trad).reduce((acc, current) => {\n        acc[`${PLUGIN_ID}.${current}`] = trad[current];\n        return acc;\n    }, {} as TradOptions);\n};","import styled from 'styled-components';\nimport { Flex, } from '@strapi/design-system';\nimport { Globe } from '@strapi/icons';\n\nconst IconBox = styled(Flex)`\n    background-color: #f0f0ff; /* primary100 */\n    border: 1px solid #d9d8ff; /* primary200 */\n    \n    svg > path {\n        fill: #4945ff; /* primary600 */\n    }\n`;\n\nconst CountrySelectIcon = () => {\n    return (\n        <IconBox justifyContent=\"center\" alignItems=\"center\" width={7} height={6} hasRadius aria-hidden>\n            <Globe />\n        </IconBox>\n    );\n};\n\nexport default CountrySelectIcon;","import { PLUGIN_ID } from '../pluginId';\n\nconst getTranslation = (id: string) => `${PLUGIN_ID}.${id}`;\n\nexport { getTranslation };","import { prefixPluginTranslations } from './utils/prefixPluginTranslations';\nimport { PLUGIN_ID } from './pluginId';\nimport CountrySelectIcon from './components/CountrySelectIcon';\nimport { getTranslation } from './utils/getTrad';\nimport countries from 'i18n-iso-countries';\n\nexport default {\n    register(app: any) {\n        app.customFields.register({\n            name: 'country',\n            pluginId: 'country-select',\n            type: 'string',\n            icon: CountrySelectIcon,\n            intlLabel: {\n                id: getTranslation('label'),\n                defaultMessage: 'Country',\n            },\n            intlDescription: {\n                id: getTranslation('description'),\n                defaultMessage: 'Select any country',\n            },\n            components: {\n                Input: async () =>\n                    import('./components/CountrySelect'),\n            },\n            options: {\n                advanced: [\n                    {\n                        sectionTitle: null,\n                        items: [\n                            {\n                                name: 'default',\n                                type: 'text',\n                                intlLabel: {\n                                    id: 'form.attribute.settings.default',\n                                    defaultMessage: 'Default value',\n                                },\n                                description: {\n                                    id: getTranslation('default-value-description'),\n                                    defaultMessage: \"Has to be a an uppercase 2-letter ISO 3166-1 country code - e.g. DE\",\n                                },\n                            },\n                        ],\n                    },\n                    {\n                        sectionTitle: {\n                            id: 'global.settings',\n                            defaultMessage: 'Settings',\n                        },\n                        items: [\n                            {\n                                name: 'required',\n                                type: 'checkbox',\n                                intlLabel: {\n                                    id: 'form.attribute.item.requiredField',\n                                    defaultMessage: 'Required field',\n                                },\n                                description: {\n                                    id: 'form.attribute.item.requiredField.description',\n                                    defaultMessage: \"You won't be able to create an entry if this field is empty\",\n                                },\n                            },\n                        ],\n                    },\n                ],\n            },\n        });\n    },\n\n    async registerTrads({ locales }: { locales: string[] }) {\n        const importedTrads = await Promise.all(\n            locales.map((locale) => {\n                return Promise.all([\n                    /* webpackChunkName: \"[pluginId]-[request]\" */ import(`./translations/${locale}.json`),\n                    /* import(`i18n-iso-countries/langs/${locale}.json`})\n                \n                        as long as vite is unable to import dynamic files from node_modules folder, \n                        we have to import a single language by default\n\n                        https://github.com/vitejs/vite/issues/14102\n                    */\n                    import(`i18n-iso-countries/langs/en.json`)\n                ])\n                .then(([pluginTranslations, countryTranslations]) => {\n                    countries.registerLocale(countryTranslations.default);\n\n                    return {\n                        data: {\n                            ...prefixPluginTranslations(pluginTranslations.default),\n                            [`${PLUGIN_ID}.countries`]: JSON.stringify(countries.getNames(locale)) \n                        },\n                        locale,\n                    };\n                })\n                .catch((err) => {\n                    console.log(err);\n                    return {\n                        data: {},\n                        locale,\n                    };\n                });\n            })\n        );\n        \n        return Promise.resolve(importedTrads);\n    },\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,YAAY;ACIZ,MAAA,2BAA2B,CACpC,SACc;AACd,SAAO,OAAO,KAAK,IAAI,EAAE,OAAO,CAAC,KAAK,YAAY;AAC9C,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