tools.equationzone 0.0.1 → 0.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.
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @returns
3
+ */
4
+ export function example(): {
5
+ name: string;
6
+ validate: (params: string) => boolean;
7
+ openRender: (tokens: {
8
+ [x: string]: {
9
+ info: string;
10
+ };
11
+ }, index: string | number) => string;
12
+ closeRender: () => string;
13
+ };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @returns
3
+ */
4
+ export function example() {
5
+ let name = 'example';
6
+
7
+ return {
8
+ name,
9
+ // Corregido: Permite opcionalmente un símbolo + o - al final
10
+ validate: (/** @type {string} */ params) =>
11
+ new RegExp(`^${name}(\\[(.+?)\\])?(\\+|-)?$`).test(params.trim()),
12
+
13
+ openRender: (/** @type {{ [x: string]: { info: string; }; }} */ tokens, /** @type {string | number} */ index) => {
14
+ const info = tokens[index].info.trim();
15
+
16
+ // Capturamos el título [1] y el estado (+/-) [3]
17
+ const match = info.match(new RegExp(`^${name}(\\[(.+?)\\])?(\\+|-)?$`));
18
+
19
+ const title = (match && match[2]) ? match[2] : 'Ejemplos';
20
+ const state = (match && match[3]) ? match[3] : ''; // "+" o "-" o ""
21
+
22
+ // Si tiene "+", el <details> debe estar abierto por defecto
23
+ const isOpen = state === '+' ? 'open' : '';
24
+
25
+ return `
26
+ <details
27
+ ${isOpen}
28
+ class="not-prose group mt-4 overflow-hidden rounded-xl border border-gray-200 bg-white transition-all dark:border-gray-800 dark:bg-[#0B0C0E]"
29
+ >
30
+ <summary
31
+ class="flex w-full cursor-pointer list-none items-center justify-between p-3.5 text-gray-600 transition-colors hover:bg-gray-50 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-white/5 dark:hover:text-gray-200 [&::-webkit-details-marker]:hidden"
32
+ >
33
+ <div class="flex items-center">
34
+ <svg
35
+ class="h-3 w-3 text-gray-400 transition-transform duration-200 group-open:rotate-90"
36
+ xmlns="http://www.w3.org/2000/svg"
37
+ viewBox="0 0 24 24"
38
+ fill="none"
39
+ stroke="currentColor"
40
+ stroke-width="3"
41
+ stroke-linecap="round"
42
+ stroke-linejoin="round"
43
+ >
44
+ <polyline points="9 18 15 12 9 6"></polyline>
45
+ </svg>
46
+ <div class="ml-3 flex items-center gap-2">
47
+ <h3 class="font-semibold text-inherit">${title}</h3>
48
+ </div>
49
+ </div>
50
+ </summary>
51
+
52
+ <div
53
+ class="prose max-w-none prose-sm md:prose-base border-t border-gray-100 bg-gray-50/30 px-5 py-4 dark:border-white/5 dark:bg-black/10 prose-hr:my-3 pl-4 md:pl-6 [&_ul]:list-disc [&_ul]:pl-4 md:[&_ul]:pl-4 [&_ul]:list-outside prose-li:marker:text-slate-700 "
54
+ >
55
+ `;
56
+ },
57
+
58
+ closeRender: () => `</div></details>`
59
+ };
60
+ }
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export { note } from './note.js';
2
+ export { example } from './example.js';
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  // Reexport your entry components here
2
2
  export { note } from './note.js';
3
+ export { example } from './example.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tools.equationzone",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "files": [
5
5
  "dist",
6
6
  "!dist/**/*.test.*",