@damian-buho/support-ukraine 1.0.0 → 1.0.2

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.
Files changed (42) hide show
  1. package/README.md +1 -1
  2. package/dist/en-GV4YJRAZ.js +5 -0
  3. package/dist/i18n.d.ts +38 -0
  4. package/dist/index.d.ts +33 -0
  5. package/dist/index.js +58 -14536
  6. package/dist/locales/index.d.ts +11 -0
  7. package/dist/types.d.ts +51 -0
  8. package/package.json +15 -12
  9. package/dist/ar-NA7ELZKM.js +0 -7
  10. package/dist/chunk-MLKGABMK.js +0 -9
  11. package/dist/de-MG4UDXH7.js +0 -7
  12. package/dist/en-FKCBWFNK.js +0 -7
  13. package/dist/es-5PZ2EDK3.js +0 -7
  14. package/dist/fr-YCF5YNJR.js +0 -7
  15. package/dist/hi-USGSLGPA.js +0 -7
  16. package/dist/it-CCVJZTA7.js +0 -7
  17. package/dist/ja-GLVWQSXX.js +0 -7
  18. package/dist/ko-TUCKXPPI.js +0 -7
  19. package/dist/nl-4UUAXPR6.js +0 -7
  20. package/dist/pl-XH6443H4.js +0 -7
  21. package/dist/pt-S4DMPY6G.js +0 -7
  22. package/dist/sv-DCDB3USN.js +0 -7
  23. package/dist/test/en-PKQHFIBK.js +0 -5
  24. package/dist/test/index.test.js +0 -656
  25. package/dist/th-MZGGZOVG.js +0 -7
  26. package/dist/uk-T7ZTMJ3J.js +0 -7
  27. package/dist/zh-Q4XO2DAU.js +0 -7
  28. /package/dist/{test/ar-KPYMLJQQ.js → ar-KPYMLJQQ.js} +0 -0
  29. /package/dist/{test/de-TH7AAXFP.js → de-TH7AAXFP.js} +0 -0
  30. /package/dist/{test/es-O2475R7Z.js → es-O2475R7Z.js} +0 -0
  31. /package/dist/{test/fr-X6V3WLWM.js → fr-X6V3WLWM.js} +0 -0
  32. /package/dist/{test/hi-AGHL2F3M.js → hi-AGHL2F3M.js} +0 -0
  33. /package/dist/{test/it-2WUTSGIT.js → it-2WUTSGIT.js} +0 -0
  34. /package/dist/{test/ja-PRYDFFQ7.js → ja-PRYDFFQ7.js} +0 -0
  35. /package/dist/{test/ko-2G672DOI.js → ko-2G672DOI.js} +0 -0
  36. /package/dist/{test/nl-XSVZSNMF.js → nl-XSVZSNMF.js} +0 -0
  37. /package/dist/{test/pl-6W3JBZBK.js → pl-6W3JBZBK.js} +0 -0
  38. /package/dist/{test/pt-FYGLQOH5.js → pt-FYGLQOH5.js} +0 -0
  39. /package/dist/{test/sv-LSP66UWZ.js → sv-LSP66UWZ.js} +0 -0
  40. /package/dist/{test/th-PBC35HRN.js → th-PBC35HRN.js} +0 -0
  41. /package/dist/{test/uk-TI5W6EQE.js → uk-TI5W6EQE.js} +0 -0
  42. /package/dist/{test/zh-KPKJOFBN.js → zh-KPKJOFBN.js} +0 -0
package/README.md CHANGED
@@ -35,7 +35,7 @@ npm install @damian-buho/support-ukraine
35
35
  ```html
36
36
 
37
37
  <script type="module">
38
- import {supportUkraineBlock} from 'https://cdn.jsdelivr.net/npm/@damian-buho/support-ukraine'
38
+ import {supportUkraineBlock} from 'https://cdn.jsdelivr.net/npm/@damian-buho/support-ukraine@1/+esm'
39
39
 
40
40
  await supportUkraineBlock()
41
41
  </script>
@@ -0,0 +1,5 @@
1
+ // src/locales/en.yaml
2
+ var en_default = { "supportUkraine": "Support Ukraine", "allCharities": "All charities", "donate": "Donate", "charities": { "united24": { "tagline": "Official fundraising platform of Ukraine" }, "come-back-alive": { "tagline": "Supporting the Ukrainian Armed Forces since 2014" }, "razom-for-ukraine": { "tagline": "Emergency response and humanitarian aid" }, "ukrainian-red-cross": { "tagline": "Humanitarian assistance in conflict zones" }, "nova-ukraine": { "tagline": "Humanitarian aid and advocacy" }, "voices-of-children": { "tagline": "Psychological support for children affected by war" }, "prytula-foundation": { "tagline": "Defence technology and equipment for Ukraine" }, "army-of-drones": { "tagline": "Reconnaissance drones for the frontline" }, "world-central-kitchen": { "tagline": "Fresh meals for people in conflict zones" }, "cats-of-kyiv": { "tagline": "Cat shelter rescuing and rehoming cats in Kyiv" }, "uanimals": { "tagline": "Animal rescue and advocacy organization in Ukraine" }, "hospitallers": { "tagline": "Ukrainian voluntary paramedics providing first aid and evacuation" }, "sternenko-fund": { "tagline": "FPV drone supply for Ukrainian defence forces" }, "life-robots-ukraine": { "tagline": "Robots for demining Ukraine" }, "sirius-shelter": { "tagline": "Ukraine's largest animal shelter for dogs and cats" } } };
3
+ export {
4
+ en_default as default
5
+ };
package/dist/i18n.d.ts ADDED
@@ -0,0 +1,38 @@
1
+ import type { Charity, LocaleMessages } from './types.js';
2
+ import { type SupportedLocale } from './locales/index.js';
3
+ export type { SupportedLocale } from './locales/index.js';
4
+ /**
5
+ * Detect the user's preferred locale from browser APIs.
6
+ *
7
+ * Resolution order:
8
+ * 1. Explicit `locale` option
9
+ * 2. First match from `navigator.languages[]` (user-ordered preference list)
10
+ * 3. `navigator.language` base tag (e.g. "es" from "es-MX")
11
+ * 4. Fallback: "en"
12
+ */
13
+ export declare function detectLocale(preferred?: string): SupportedLocale;
14
+ /**
15
+ * Load locale messages for the given language code.
16
+ * Returns cached result on repeat calls. Falls back to 'en' on error.
17
+ */
18
+ export declare function loadLocale(lang: string): Promise<LocaleMessages>;
19
+ /**
20
+ * Merge base charities with locale-specific translations.
21
+ *
22
+ * For each charity: use the locale tagline if available, otherwise keep
23
+ * the English default from the base data.
24
+ */
25
+ export declare function mergeCharities(base: readonly Charity[], locale: LocaleMessages): Charity[];
26
+ /** Returns true if the locale uses right-to-left script. */
27
+ export declare function isRTL(lang: string): boolean;
28
+ /**
29
+ * Build a translated banner text line for a charity.
30
+ *
31
+ * @returns The formatted string "UA_FLAG supportUkraine: name: tagline"
32
+ */
33
+ export declare function formatBannerText(charity: Charity, messages: LocaleMessages): string;
34
+ /**
35
+ * Eagerly pre-load the English locale so it is always available synchronously.
36
+ * Other locales are loaded on demand via `loadLocale()`.
37
+ */
38
+ export declare function preloadDefault(): Promise<LocaleMessages>;
@@ -0,0 +1,33 @@
1
+ import { type Charity, type SupportUkraineBlockOptions } from './types.js';
2
+ export type { Charity, CharityTag, SupportUkraineBlockOptions } from './types.js';
3
+ export { charitySchema, charitiesSchema } from './types.js';
4
+ export { detectLocale, loadLocale, mergeCharities, isRTL, formatBannerText } from './i18n.js';
5
+ export { resolveLocale, RTL_LOCALES } from './locales/index.js';
6
+ export type { SupportedLocale } from './locales/index.js';
7
+ export declare const DEFAULT_CHARITIES: Charity[];
8
+ /**
9
+ * Pick a random item from an array.
10
+ *
11
+ * @internal
12
+ */
13
+ export declare function randomItem<T>(items: T[]): T;
14
+ /**
15
+ * Create and mount the Ukraine-support charity banner.
16
+ *
17
+ * The banner is placed at the top of the page. It displays a randomly
18
+ * selected charity with the format "🇺🇦 Support Ukraine: Name: tagline" —
19
+ * the entire block is a clickable link. Text is translated to the user's
20
+ * detected locale (or the explicit `locale` option).
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { supportUkraineBlock } from '@damian-buho/support-ukraine'
25
+ *
26
+ * // Auto-detect locale from navigator.language
27
+ * await supportUkraineBlock()
28
+ *
29
+ * // Force a specific locale
30
+ * await supportUkraineBlock({ locale: 'es' })
31
+ * ```
32
+ */
33
+ export declare function supportUkraineBlock(options?: SupportUkraineBlockOptions): Promise<HTMLElement>;