shevchenko 2.1.1 → 2.1.3

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 (90) hide show
  1. package/dist/cjs/shevchenko.js +97 -7
  2. package/dist/cjs/shevchenko.js.map +1 -1
  3. package/dist/es/shevchenko.js +97 -7
  4. package/dist/es/shevchenko.js.map +1 -1
  5. package/dist/umd/shevchenko.min.js +3 -3
  6. package/dist/umd/shevchenko.min.js.map +1 -1
  7. package/nuxt/.eslintrc.json +27 -0
  8. package/nuxt/.prettierrc.json +6 -0
  9. package/nuxt/README.md +27 -0
  10. package/nuxt/app.config.ts +3 -0
  11. package/nuxt/app.vue +5 -0
  12. package/nuxt/assets/img/shevchenko_pixelized_304x304.jpg +0 -0
  13. package/nuxt/assets/img/shevchenko_pixelized_304x304.png +0 -0
  14. package/nuxt/assets/img/shevchenko_pixelized_608x608.jpg +0 -0
  15. package/nuxt/assets/style/main.scss +3 -0
  16. package/nuxt/components/about-modal.vue +58 -0
  17. package/nuxt/components/api-spec.vue +25 -0
  18. package/nuxt/components/contact-me-button.vue +11 -0
  19. package/nuxt/components/contact-me-modal.vue +63 -0
  20. package/nuxt/components/copy-button.vue +38 -0
  21. package/nuxt/components/declension-demo.vue +38 -0
  22. package/nuxt/components/declension-form.vue +158 -0
  23. package/nuxt/components/declension-preview.vue +170 -0
  24. package/nuxt/components/declension-results.vue +135 -0
  25. package/nuxt/components/error-404.vue +15 -0
  26. package/nuxt/components/github-issue-count.vue +18 -0
  27. package/nuxt/components/how-it-works.vue +51 -0
  28. package/nuxt/components/installation-instructions.vue +33 -0
  29. package/nuxt/components/library-docs.vue +27 -0
  30. package/nuxt/components/page-copyright.vue +15 -0
  31. package/nuxt/components/page-footer.vue +32 -0
  32. package/nuxt/components/page-header.vue +4 -0
  33. package/nuxt/components/preview-banner.vue +32 -0
  34. package/nuxt/components/share-links.vue +108 -0
  35. package/nuxt/components/top-nav-bar.vue +165 -0
  36. package/nuxt/components/ukrainian-flag.vue +37 -0
  37. package/nuxt/components/usage-example.vue +32 -0
  38. package/nuxt/composables/declension.ts +124 -0
  39. package/nuxt/composables/page-i18n.ts +11 -0
  40. package/nuxt/composables/page-meta.ts +5 -0
  41. package/nuxt/composables/route-utils.ts +17 -0
  42. package/nuxt/config.ts +20 -0
  43. package/nuxt/data/female-first-names.json +556 -0
  44. package/nuxt/data/male-first-names.json +603 -0
  45. package/nuxt/error.vue +25 -0
  46. package/nuxt/layouts/default.vue +5 -0
  47. package/nuxt/locales/en-US.json +63 -0
  48. package/nuxt/locales/uk-UA.json +65 -0
  49. package/nuxt/nuxt.config.ts +99 -0
  50. package/nuxt/package-lock.json +19524 -0
  51. package/nuxt/package.json +37 -0
  52. package/nuxt/pages/en-US/index.vue +41 -0
  53. package/nuxt/pages/index.vue +68 -0
  54. package/nuxt/plugins/i18n.ts +26 -0
  55. package/nuxt/public/.nojekyll +0 -0
  56. package/nuxt/public/CNAME +1 -0
  57. package/nuxt/public/android-icon-144x144.png +0 -0
  58. package/nuxt/public/android-icon-192x192.png +0 -0
  59. package/nuxt/public/android-icon-36x36.png +0 -0
  60. package/nuxt/public/android-icon-48x48.png +0 -0
  61. package/nuxt/public/android-icon-72x72.png +0 -0
  62. package/nuxt/public/android-icon-96x96.png +0 -0
  63. package/nuxt/public/apple-icon-114x114.png +0 -0
  64. package/nuxt/public/apple-icon-120x120.png +0 -0
  65. package/nuxt/public/apple-icon-144x144.png +0 -0
  66. package/nuxt/public/apple-icon-152x152.png +0 -0
  67. package/nuxt/public/apple-icon-180x180.png +0 -0
  68. package/nuxt/public/apple-icon-57x57.png +0 -0
  69. package/nuxt/public/apple-icon-60x60.png +0 -0
  70. package/nuxt/public/apple-icon-72x72.png +0 -0
  71. package/nuxt/public/apple-icon-76x76.png +0 -0
  72. package/nuxt/public/apple-icon-precomposed.png +0 -0
  73. package/nuxt/public/apple-icon.png +0 -0
  74. package/nuxt/public/browserconfig.xml +2 -0
  75. package/nuxt/public/favicon-16x16.png +0 -0
  76. package/nuxt/public/favicon-32x32.png +0 -0
  77. package/nuxt/public/favicon-96x96.png +0 -0
  78. package/nuxt/public/favicon.ico +0 -0
  79. package/nuxt/public/manifest.json +41 -0
  80. package/nuxt/public/ms-icon-144x144.png +0 -0
  81. package/nuxt/public/ms-icon-150x150.png +0 -0
  82. package/nuxt/public/ms-icon-310x310.png +0 -0
  83. package/nuxt/public/ms-icon-70x70.png +0 -0
  84. package/nuxt/public/preview-608x608.jpg +0 -0
  85. package/nuxt/scripts/postgenerate.js +7 -0
  86. package/nuxt/scripts/publish.js +7 -0
  87. package/nuxt/server/plugins/google-tag-manager.js +37 -0
  88. package/nuxt/tsconfig.json +11 -0
  89. package/package.json +3 -2
  90. package/src/resources/inflector/rules.json +94 -5
@@ -0,0 +1,32 @@
1
+ <script setup lang="ts">
2
+ const appConfig = useAppConfig();
3
+
4
+ const usageExample = `
5
+ const anthroponym = {
6
+ gender: 'male', // or 'female'
7
+ firstName: 'Тарас',
8
+ middleName: 'Григорович',
9
+ lastName: 'Шевченко'
10
+ };
11
+
12
+ const result = shevchenko.inVocative(anthroponym);
13
+
14
+ console.log(result); // { gender: "male", firstName: "Тарасе", middleName: "Григоровичу", lastName: "Шевченку" }
15
+ `;
16
+ </script>
17
+
18
+ <template>
19
+ <div id="usage-example" class="card my-3">
20
+ <div class="card-body">
21
+ <h5 class="card-title mb-3">
22
+ {{ $t('usageExample') }}
23
+ <small
24
+ ><a :href="appConfig.library.runKitUrl" target="_blank">
25
+ {{ $t('action.tryItOut') }}
26
+ </a></small
27
+ >
28
+ </h5>
29
+ <pre class="mb-0">{{ usageExample.trim() }}</pre>
30
+ </div>
31
+ </div>
32
+ </template>
@@ -0,0 +1,124 @@
1
+ import { createSharedComposable } from '@vueuse/core';
2
+ import { reactive } from 'vue';
3
+ import {
4
+ Anthroponym,
5
+ Gender,
6
+ inNominative,
7
+ inGenitive,
8
+ inDative,
9
+ inAccusative,
10
+ inAblative,
11
+ inLocative,
12
+ inVocative,
13
+ } from 'shevchenko';
14
+ import maleFirstNames from '~/data/male-first-names.json';
15
+ import femaleFirstNames from '~/data/female-first-names.json';
16
+
17
+ export type GenderlessAnthroponym = Omit<Anthroponym, 'gender'>;
18
+
19
+ export const shevchenkoAnthroponym: Anthroponym = {
20
+ gender: Gender.Male,
21
+ lastName: 'Шевченко',
22
+ firstName: 'Тарас',
23
+ middleName: 'Григорович',
24
+ };
25
+
26
+ export interface DeclensionResults {
27
+ nominativeCase: Anthroponym;
28
+ genitiveCase: Anthroponym;
29
+ dativeCase: Anthroponym;
30
+ accusativeCase: Anthroponym;
31
+ ablativeCase: Anthroponym;
32
+ locativeCase: Anthroponym;
33
+ vocativeCase: Anthroponym;
34
+ }
35
+
36
+ /**
37
+ * Returns true if the given anthroponym is correctly defined.
38
+ * Returns false otherwise.
39
+ */
40
+ export function isDefinedAnthroponym(
41
+ anthroponym: Partial<Anthroponym>,
42
+ ): anthroponym is Anthroponym {
43
+ return Boolean(
44
+ anthroponym.gender &&
45
+ Object.values(Gender).includes(anthroponym.gender) &&
46
+ (anthroponym.firstName || anthroponym.middleName || anthroponym.lastName),
47
+ );
48
+ }
49
+
50
+ export function isShevchenkoAnthroponym(anthroponym: Partial<Anthroponym>): boolean {
51
+ return (
52
+ anthroponym.gender === shevchenkoAnthroponym.gender &&
53
+ anthroponym.lastName === shevchenkoAnthroponym.lastName &&
54
+ anthroponym.firstName === shevchenkoAnthroponym.firstName &&
55
+ anthroponym.middleName === shevchenkoAnthroponym.middleName
56
+ );
57
+ }
58
+
59
+ export const useDeclension = createSharedComposable((predefinedAnthroponym: Anthroponym) => {
60
+ let anthroponym: Anthroponym = reactive({
61
+ gender: Gender.Male,
62
+ lastName: '',
63
+ firstName: '',
64
+ middleName: '',
65
+ });
66
+
67
+ let initialAnthroponym: Anthroponym = reactive(shevchenkoAnthroponym);
68
+ if (isDefinedAnthroponym(predefinedAnthroponym)) {
69
+ initialAnthroponym = reactive(predefinedAnthroponym);
70
+ anthroponym = reactive(predefinedAnthroponym);
71
+ }
72
+
73
+ const declensionResults: DeclensionResults = reactive({
74
+ nominativeCase: inNominative(initialAnthroponym),
75
+ genitiveCase: inGenitive(initialAnthroponym),
76
+ dativeCase: inDative(initialAnthroponym),
77
+ accusativeCase: inAccusative(initialAnthroponym),
78
+ ablativeCase: inAblative(initialAnthroponym),
79
+ locativeCase: inLocative(initialAnthroponym),
80
+ vocativeCase: inVocative(initialAnthroponym),
81
+ });
82
+
83
+ function setAnthroponym(source: Anthroponym): void {
84
+ anthroponym.gender = source.gender;
85
+ anthroponym.lastName = source.lastName;
86
+ anthroponym.firstName = source.firstName;
87
+ anthroponym.middleName = source.middleName;
88
+ }
89
+
90
+ function inflect(source: Anthroponym): void {
91
+ setAnthroponym(source);
92
+ declensionResults.nominativeCase = inNominative(anthroponym);
93
+ declensionResults.genitiveCase = inGenitive(anthroponym);
94
+ declensionResults.dativeCase = inDative(anthroponym);
95
+ declensionResults.accusativeCase = inAccusative(anthroponym);
96
+ declensionResults.ablativeCase = inAblative(anthroponym);
97
+ declensionResults.locativeCase = inLocative(anthroponym);
98
+ declensionResults.vocativeCase = inVocative(anthroponym);
99
+ }
100
+
101
+ function detectGender(anthroponym: GenderlessAnthroponym): Gender | null {
102
+ if (anthroponym.middleName) {
103
+ const middleName = anthroponym.middleName.replace(/[`"]/g, "'").toLocaleLowerCase();
104
+ if (/(и|і)ч$/.test(middleName)) {
105
+ return Gender.Male;
106
+ } else if (/на$/.test(middleName)) {
107
+ return Gender.Female;
108
+ }
109
+ }
110
+
111
+ if (anthroponym.firstName) {
112
+ const firstName = anthroponym.firstName.replace(/[`"]/g, "'").toLocaleLowerCase();
113
+ if (maleFirstNames.includes(firstName)) {
114
+ return Gender.Male;
115
+ } else if (femaleFirstNames.includes(firstName)) {
116
+ return Gender.Female;
117
+ }
118
+ }
119
+
120
+ return null;
121
+ }
122
+
123
+ return { anthroponym, declensionResults, inflect, detectGender };
124
+ });
@@ -0,0 +1,11 @@
1
+ import { useI18n } from 'vue-i18n';
2
+ import type { LocaleName } from '~/plugins/i18n';
3
+
4
+ export interface PageI18nOptions {
5
+ locale: LocaleName;
6
+ }
7
+
8
+ export const usePageI18n = (options: PageI18nOptions) => {
9
+ const { locale } = useI18n();
10
+ locale.value = options.locale;
11
+ };
@@ -0,0 +1,5 @@
1
+ export const usePageMeta = () => {
2
+ const appConfig = useAppConfig();
3
+ const buildPageTitle = (title: string) => appConfig.library.name + ' - ' + title;
4
+ return { buildPageTitle };
5
+ };
@@ -0,0 +1,17 @@
1
+ import config from '../config';
2
+
3
+ /**
4
+ * Builds the absolute page URL for the given path.
5
+ */
6
+ export const buildPageUrl = (fullPath = '') => config.website.url + fullPath;
7
+
8
+ export const useRouteUtils = () => {
9
+ const route = useRoute();
10
+
11
+ /**
12
+ * The absolute URL of the current page.
13
+ */
14
+ const pageUrl = computed(() => buildPageUrl(route.fullPath));
15
+
16
+ return { buildPageUrl, pageUrl };
17
+ };
package/nuxt/config.ts ADDED
@@ -0,0 +1,20 @@
1
+ // const baseUrl = 'https://tooleks.github.io/shevchenko-js';
2
+ const baseUrl = 'https://shevchenko-js.tooleks.com';
3
+
4
+ export default {
5
+ website: {
6
+ url: baseUrl,
7
+ email: 'tooleks@gmail.com',
8
+ },
9
+ library: {
10
+ name: 'shevchenko',
11
+ releaseYear: 2017,
12
+ npmUrl: 'https://www.npmjs.com/package/shevchenko',
13
+ gitHubUrl: 'https://github.com/tooleks/shevchenko-js',
14
+ gitHubStatsUrl: 'https://api.github.com/repos/tooleks/shevchenko-js',
15
+ issuesUrl: 'https://github.com/tooleks/shevchenko-js/issues',
16
+ licenseUrl: 'https://github.com/tooleks/shevchenko-js/blob/master/LICENSE',
17
+ runKitUrl: 'https://runkit.com/tooleks/shevchenko',
18
+ cdnUrl: 'https://unpkg.com/shevchenko',
19
+ },
20
+ };