@vicacha-devs/strapi-plugin-notes 1.0.0 → 1.1.0

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.
@@ -5,7 +5,7 @@ import { Layouts } from "@strapi/strapi/admin";
5
5
  import * as React from "react";
6
6
  import { useIntl } from "react-intl";
7
7
  import { useNavigate } from "react-router-dom";
8
- import { N as NOTE_CATEGORIES, a as NOTE_CATEGORY_META, g as getTrad, u as useNotes, f as filterNotesList, b as NoteModal, D as DeleteNoteDialog, c as buildContentManagerNoteLink, d as formatNoteAuthorDisplay, e as formatNoteTimestamp } from "./index-DP_1HzPT.js";
8
+ import { N as NOTE_CATEGORIES, a as NOTE_CATEGORY_META, g as getTrad, u as useNotes, f as filterNotesList, b as NoteModal, D as DeleteNoteDialog, c as buildContentManagerNoteLink, d as formatNoteAuthorDisplay, e as formatNoteTimestamp } from "./index-ClQtejgN.js";
9
9
  const NotesHubFilterBar = ({
10
10
  summary,
11
11
  search,
@@ -7,7 +7,7 @@ const admin = require("@strapi/strapi/admin");
7
7
  const React = require("react");
8
8
  const reactIntl = require("react-intl");
9
9
  const reactRouterDom = require("react-router-dom");
10
- const index = require("./index-C7es-Q8Z.cjs");
10
+ const index = require("./index-BD0jLH1y.cjs");
11
11
  function _interopNamespace(e) {
12
12
  if (e && e.__esModule) return e;
13
13
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -39,141 +39,48 @@ const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
39
39
  );
40
40
  });
41
41
  };
42
- function freezeOptions(items) {
43
- return Object.freeze(items.map((item) => Object.freeze({ ...item })));
44
- }
45
- freezeOptions([
46
- { value: "es", label: "es — Español (Spanish)" },
47
- { value: "en", label: "en — English" },
48
- { value: "ar", label: "ar — العربية (Arabic)" },
49
- { value: "tr", label: "tr — Türkçe (Turkish)" },
50
- { value: "fr", label: "fr — Français (French)" },
51
- { value: "de", label: "de — Deutsch (German)" },
52
- { value: "pt", label: "pt — Português (Portuguese)" },
53
- { value: "it", label: "it — Italiano (Italian)" },
54
- { value: "nl", label: "nl — Nederlands (Dutch)" },
55
- { value: "pl", label: "pl — Polski (Polish)" },
56
- { value: "ru", label: "ru — Русский (Russian)" },
57
- { value: "id", label: "id — Bahasa Indonesia" },
58
- { value: "ur", label: "ur — اردو (Urdu)" },
59
- { value: "zh", label: "zh — 中文 (Chinese)" }
60
- ]);
61
- freezeOptions([
62
- {
63
- value: "islamic-umalqura",
64
- label: "islamic-umalqura (Hijri Umm al-Qura)"
65
- },
66
- { value: "islamic-civil", label: "islamic-civil (Tabular Islamic Civil)" },
67
- { value: "islamic-tbla", label: "islamic-tbla (Tabular Astronomical)" },
68
- { value: "hebrew", label: "hebrew (Hebrew)" },
69
- { value: "persian", label: "persian (Solar Hijri)" },
70
- { value: "none", label: "none (Gregorian Only)" }
71
- ]);
72
- const VALID_LOCALE_RE = /^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8}){0,4}$/;
73
- function isTranslationRecord(value) {
74
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
75
- }
76
- function extractDictionary(loaded) {
77
- if (!isTranslationRecord(loaded)) {
78
- return void 0;
79
- }
80
- if ("default" in loaded) {
81
- return isTranslationRecord(loaded.default) ? loaded.default : void 0;
82
- }
83
- return loaded;
84
- }
85
- function getLookupCandidates(locale, fallbackToLanguage) {
86
- const trimmed = locale.trim();
87
- if (!VALID_LOCALE_RE.test(trimmed)) {
88
- return [];
89
- }
90
- if (!fallbackToLanguage || !trimmed.includes("-")) {
91
- return [trimmed];
92
- }
93
- const base = trimmed.split("-")[0];
94
- return base && base !== trimmed ? [trimmed, base] : [trimmed];
95
- }
96
42
  function prefixPluginTranslations(trad, pluginId, options) {
97
- const normalizedPluginId = typeof pluginId === "string" ? pluginId.trim() : "";
98
- if (!normalizedPluginId) {
43
+ if (!pluginId) {
99
44
  throw new TypeError("pluginId can't be empty");
100
45
  }
101
- const result = {};
102
- if (options?.baseTranslations) {
103
- for (const [key, value] of Object.entries(options.baseTranslations)) {
104
- if (typeof value === "string") {
105
- result[key] = value;
106
- }
107
- }
108
- }
109
- const prefix = `${normalizedPluginId}.`;
110
- const explicitPrefixed = [];
46
+ const result = {
47
+ ...options?.baseTranslations
48
+ };
111
49
  for (const [key, value] of Object.entries(trad)) {
112
- if (typeof value !== "string") {
113
- continue;
114
- }
115
50
  if (options?.keepUnprefixed) {
116
51
  result[key] = value;
117
52
  }
118
- if (key.startsWith(prefix)) {
119
- explicitPrefixed.push([key, value]);
120
- } else {
121
- result[`${prefix}${key}`] = value;
122
- }
123
- }
124
- for (const [key, value] of explicitPrefixed) {
125
- result[key] = value;
53
+ const fullKey = key.startsWith(`${pluginId}.`) ? key : `${pluginId}.${key}`;
54
+ result[fullKey] = value;
126
55
  }
127
56
  return result;
128
57
  }
129
58
  function createRegisterTrads(options) {
130
- const { pluginId, defaultLocales = ["en", "es", "ar", "tr"], supportedLocales, keepUnprefixed = true, fallbackToLanguageCode = true, loadTranslation, translations, getBaseTranslations, onLoaded } = options;
131
- const normalizedPluginId = typeof pluginId === "string" ? pluginId.trim() : "";
132
- if (!normalizedPluginId) {
133
- throw new TypeError("pluginId can't be empty");
134
- }
135
- const supportedSet = supportedLocales ? new Set(supportedLocales) : void 0;
136
- const effectiveDefaults = supportedSet ? defaultLocales.filter((loc) => getLookupCandidates(loc, fallbackToLanguageCode).some((candidate) => supportedSet.has(candidate))) : defaultLocales;
59
+ const { pluginId, defaultLocales = ["en", "es", "ar", "tr"], supportedLocales, keepUnprefixed = true, loadTranslation, translations, getBaseTranslations, onLoaded } = options;
137
60
  return async function registerTrads({ locales = [] } = {}) {
138
- const allLocales = effectiveDefaults.length > 0 ? Array.from(/* @__PURE__ */ new Set([...locales, ...effectiveDefaults])) : Array.from(new Set(locales));
61
+ const allLocales = Array.from(/* @__PURE__ */ new Set([...locales, ...defaultLocales]));
139
62
  return Promise.all(allLocales.map(async (locale) => {
140
- const candidates = getLookupCandidates(locale, fallbackToLanguageCode);
141
- if (candidates.length === 0) {
63
+ if (supportedLocales && !supportedLocales.includes(locale)) {
142
64
  return { data: {}, locale };
143
65
  }
144
- if (supportedSet && !candidates.some((candidate) => supportedSet.has(candidate))) {
145
- return { data: {}, locale };
146
- }
147
- let rawData;
148
- for (const candidate of candidates) {
149
- if (translations && Object.hasOwn(translations, candidate)) {
150
- rawData = extractDictionary(translations[candidate]);
151
- if (rawData) {
152
- break;
153
- }
66
+ try {
67
+ let rawData = translations?.[locale];
68
+ if (!rawData && loadTranslation) {
69
+ const loaded = await loadTranslation(locale);
70
+ rawData = loaded && "default" in loaded && loaded.default ? loaded.default : loaded;
154
71
  }
155
- if (loadTranslation) {
156
- try {
157
- const loaded = await loadTranslation(candidate);
158
- rawData = extractDictionary(loaded);
159
- if (rawData) {
160
- break;
161
- }
162
- } catch {
163
- }
72
+ if (!rawData) {
73
+ return { data: {}, locale };
164
74
  }
165
- }
166
- const baseTranslations = getBaseTranslations?.(locale);
167
- const hasBase = Boolean(baseTranslations) && Object.keys(baseTranslations).length > 0;
168
- if (!rawData && !hasBase) {
75
+ const prefixed = prefixPluginTranslations(rawData, pluginId, {
76
+ keepUnprefixed,
77
+ baseTranslations: getBaseTranslations ? getBaseTranslations(locale) : void 0
78
+ });
79
+ onLoaded?.(locale, prefixed);
80
+ return { data: prefixed, locale };
81
+ } catch {
169
82
  return { data: {}, locale };
170
83
  }
171
- const prefixed = prefixPluginTranslations(rawData ?? {}, normalizedPluginId, {
172
- keepUnprefixed,
173
- baseTranslations
174
- });
175
- onLoaded?.(locale, prefixed);
176
- return { data: prefixed, locale };
177
84
  }));
178
85
  };
179
86
  }
@@ -1498,7 +1405,7 @@ const index = {
1498
1405
  id: `${PLUGIN_ID}.plugin.name`,
1499
1406
  defaultMessage: "Notes"
1500
1407
  },
1501
- Component: () => Promise.resolve().then(() => require("./NotesHomePage-C5eNNxl9.cjs")).then((mod) => ({
1408
+ Component: () => Promise.resolve().then(() => require("./NotesHomePage-Da5Eu2o9.cjs")).then((mod) => ({
1502
1409
  default: mod.NotesHomePage
1503
1410
  })),
1504
1411
  permissions: [
@@ -21,141 +21,48 @@ const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
21
21
  );
22
22
  });
23
23
  };
24
- function freezeOptions(items) {
25
- return Object.freeze(items.map((item) => Object.freeze({ ...item })));
26
- }
27
- freezeOptions([
28
- { value: "es", label: "es — Español (Spanish)" },
29
- { value: "en", label: "en — English" },
30
- { value: "ar", label: "ar — العربية (Arabic)" },
31
- { value: "tr", label: "tr — Türkçe (Turkish)" },
32
- { value: "fr", label: "fr — Français (French)" },
33
- { value: "de", label: "de — Deutsch (German)" },
34
- { value: "pt", label: "pt — Português (Portuguese)" },
35
- { value: "it", label: "it — Italiano (Italian)" },
36
- { value: "nl", label: "nl — Nederlands (Dutch)" },
37
- { value: "pl", label: "pl — Polski (Polish)" },
38
- { value: "ru", label: "ru — Русский (Russian)" },
39
- { value: "id", label: "id — Bahasa Indonesia" },
40
- { value: "ur", label: "ur — اردو (Urdu)" },
41
- { value: "zh", label: "zh — 中文 (Chinese)" }
42
- ]);
43
- freezeOptions([
44
- {
45
- value: "islamic-umalqura",
46
- label: "islamic-umalqura (Hijri Umm al-Qura)"
47
- },
48
- { value: "islamic-civil", label: "islamic-civil (Tabular Islamic Civil)" },
49
- { value: "islamic-tbla", label: "islamic-tbla (Tabular Astronomical)" },
50
- { value: "hebrew", label: "hebrew (Hebrew)" },
51
- { value: "persian", label: "persian (Solar Hijri)" },
52
- { value: "none", label: "none (Gregorian Only)" }
53
- ]);
54
- const VALID_LOCALE_RE = /^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8}){0,4}$/;
55
- function isTranslationRecord(value) {
56
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
57
- }
58
- function extractDictionary(loaded) {
59
- if (!isTranslationRecord(loaded)) {
60
- return void 0;
61
- }
62
- if ("default" in loaded) {
63
- return isTranslationRecord(loaded.default) ? loaded.default : void 0;
64
- }
65
- return loaded;
66
- }
67
- function getLookupCandidates(locale, fallbackToLanguage) {
68
- const trimmed = locale.trim();
69
- if (!VALID_LOCALE_RE.test(trimmed)) {
70
- return [];
71
- }
72
- if (!fallbackToLanguage || !trimmed.includes("-")) {
73
- return [trimmed];
74
- }
75
- const base = trimmed.split("-")[0];
76
- return base && base !== trimmed ? [trimmed, base] : [trimmed];
77
- }
78
24
  function prefixPluginTranslations(trad, pluginId, options) {
79
- const normalizedPluginId = typeof pluginId === "string" ? pluginId.trim() : "";
80
- if (!normalizedPluginId) {
25
+ if (!pluginId) {
81
26
  throw new TypeError("pluginId can't be empty");
82
27
  }
83
- const result = {};
84
- if (options?.baseTranslations) {
85
- for (const [key, value] of Object.entries(options.baseTranslations)) {
86
- if (typeof value === "string") {
87
- result[key] = value;
88
- }
89
- }
90
- }
91
- const prefix = `${normalizedPluginId}.`;
92
- const explicitPrefixed = [];
28
+ const result = {
29
+ ...options?.baseTranslations
30
+ };
93
31
  for (const [key, value] of Object.entries(trad)) {
94
- if (typeof value !== "string") {
95
- continue;
96
- }
97
32
  if (options?.keepUnprefixed) {
98
33
  result[key] = value;
99
34
  }
100
- if (key.startsWith(prefix)) {
101
- explicitPrefixed.push([key, value]);
102
- } else {
103
- result[`${prefix}${key}`] = value;
104
- }
105
- }
106
- for (const [key, value] of explicitPrefixed) {
107
- result[key] = value;
35
+ const fullKey = key.startsWith(`${pluginId}.`) ? key : `${pluginId}.${key}`;
36
+ result[fullKey] = value;
108
37
  }
109
38
  return result;
110
39
  }
111
40
  function createRegisterTrads(options) {
112
- const { pluginId, defaultLocales = ["en", "es", "ar", "tr"], supportedLocales, keepUnprefixed = true, fallbackToLanguageCode = true, loadTranslation, translations, getBaseTranslations, onLoaded } = options;
113
- const normalizedPluginId = typeof pluginId === "string" ? pluginId.trim() : "";
114
- if (!normalizedPluginId) {
115
- throw new TypeError("pluginId can't be empty");
116
- }
117
- const supportedSet = supportedLocales ? new Set(supportedLocales) : void 0;
118
- const effectiveDefaults = supportedSet ? defaultLocales.filter((loc) => getLookupCandidates(loc, fallbackToLanguageCode).some((candidate) => supportedSet.has(candidate))) : defaultLocales;
41
+ const { pluginId, defaultLocales = ["en", "es", "ar", "tr"], supportedLocales, keepUnprefixed = true, loadTranslation, translations, getBaseTranslations, onLoaded } = options;
119
42
  return async function registerTrads({ locales = [] } = {}) {
120
- const allLocales = effectiveDefaults.length > 0 ? Array.from(/* @__PURE__ */ new Set([...locales, ...effectiveDefaults])) : Array.from(new Set(locales));
43
+ const allLocales = Array.from(/* @__PURE__ */ new Set([...locales, ...defaultLocales]));
121
44
  return Promise.all(allLocales.map(async (locale) => {
122
- const candidates = getLookupCandidates(locale, fallbackToLanguageCode);
123
- if (candidates.length === 0) {
45
+ if (supportedLocales && !supportedLocales.includes(locale)) {
124
46
  return { data: {}, locale };
125
47
  }
126
- if (supportedSet && !candidates.some((candidate) => supportedSet.has(candidate))) {
127
- return { data: {}, locale };
128
- }
129
- let rawData;
130
- for (const candidate of candidates) {
131
- if (translations && Object.hasOwn(translations, candidate)) {
132
- rawData = extractDictionary(translations[candidate]);
133
- if (rawData) {
134
- break;
135
- }
48
+ try {
49
+ let rawData = translations?.[locale];
50
+ if (!rawData && loadTranslation) {
51
+ const loaded = await loadTranslation(locale);
52
+ rawData = loaded && "default" in loaded && loaded.default ? loaded.default : loaded;
136
53
  }
137
- if (loadTranslation) {
138
- try {
139
- const loaded = await loadTranslation(candidate);
140
- rawData = extractDictionary(loaded);
141
- if (rawData) {
142
- break;
143
- }
144
- } catch {
145
- }
54
+ if (!rawData) {
55
+ return { data: {}, locale };
146
56
  }
147
- }
148
- const baseTranslations = getBaseTranslations?.(locale);
149
- const hasBase = Boolean(baseTranslations) && Object.keys(baseTranslations).length > 0;
150
- if (!rawData && !hasBase) {
57
+ const prefixed = prefixPluginTranslations(rawData, pluginId, {
58
+ keepUnprefixed,
59
+ baseTranslations: getBaseTranslations ? getBaseTranslations(locale) : void 0
60
+ });
61
+ onLoaded?.(locale, prefixed);
62
+ return { data: prefixed, locale };
63
+ } catch {
151
64
  return { data: {}, locale };
152
65
  }
153
- const prefixed = prefixPluginTranslations(rawData ?? {}, normalizedPluginId, {
154
- keepUnprefixed,
155
- baseTranslations
156
- });
157
- onLoaded?.(locale, prefixed);
158
- return { data: prefixed, locale };
159
66
  }));
160
67
  };
161
68
  }
@@ -1480,7 +1387,7 @@ const index = {
1480
1387
  id: `${PLUGIN_ID}.plugin.name`,
1481
1388
  defaultMessage: "Notes"
1482
1389
  },
1483
- Component: () => import("./NotesHomePage-BBESzSxZ.js").then((mod) => ({
1390
+ Component: () => import("./NotesHomePage-CIWSOu3n.js").then((mod) => ({
1484
1391
  default: mod.NotesHomePage
1485
1392
  })),
1486
1393
  permissions: [
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const index = require("./index-C7es-Q8Z.cjs");
3
+ const index = require("./index-BD0jLH1y.cjs");
4
4
  exports.default = index.index;
@@ -1,4 +1,4 @@
1
- import { i } from "./index-DP_1HzPT.js";
1
+ import { i } from "./index-ClQtejgN.js";
2
2
  export {
3
3
  i as default
4
4
  };
@@ -1,4 +1,4 @@
1
- import { i } from "./index-DP_1HzPT.js";
1
+ import { i } from "./index-ClQtejgN.js";
2
2
  export {
3
3
  i as default
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vicacha-devs/strapi-plugin-notes",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Strapi v5 Entity Notes plugin (forked & evolved from strapi-community/strapi-plugin-notes) with Audit Logs-style modal metadata (Created/Updated At & By), pinned notes, category badges, document/locale scoping, and a Global Notes Hub.",
5
5
  "keywords": [
6
6
  "audit-metadata",
@@ -70,9 +70,9 @@
70
70
  "react-router-dom": "^6.26.2",
71
71
  "styled-components": "^6.1.13",
72
72
  "typescript": "^5.5.4",
73
+ "@vicacha-devs/plugin-shared": "1.0.0",
73
74
  "@vicacha-devs/eslint-config": "1.0.0",
74
- "@vicacha-devs/typescript-config": "1.0.0",
75
- "@vicacha-devs/plugin-shared": "1.0.0"
75
+ "@vicacha-devs/typescript-config": "1.0.0"
76
76
  },
77
77
  "peerDependencies": {
78
78
  "@strapi/strapi": "^5.0.0",