@rubenpazch/month-navigator 0.0.0-stage → 0.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.
- package/README.md +34 -2
- package/dist/MonthNavigator.d.ts +29 -0
- package/dist/MonthNavigator.d.ts.map +1 -0
- package/dist/index.cjs.js +2 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +2 -0
- package/dist/index.esm.js.map +1 -0
- package/package.json +75 -3
package/README.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @rubenpazch/month-navigator
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<!-- catalogo:inicio (generado por pnpm catalogo, no editar) -->
|
|
4
|
+
|
|
5
|
+
Navegador de periodos ‹ noviembre de 2026 › con valor "AAAA-MM", mínimo, máximo y botón Hoy; incluye addMonths() y currentMonth().
|
|
6
|
+
|
|
7
|
+
- **Usar cuando:** Elegir el mes de trabajo: obligaciones, cierres contables, cronogramas, reportes mensuales.
|
|
8
|
+
- **Evitar cuando:** Elegir un día: usa DateInput o DatePicker. Un rango libre de fechas: usa DateRangePicker.
|
|
9
|
+
|
|
10
|
+
Se recomienda instalar el paquete completo `@rubenpazch/ui` (incluye este). Por separado:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @rubenpazch/month-navigator
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## MonthNavigator
|
|
17
|
+
|
|
18
|
+
Navegador de periodos: ‹ noviembre de 2026 › para finanzas, contabilidad y cronogramas.
|
|
19
|
+
|
|
20
|
+
| Prop | Tipo | Req. | Por defecto | Descripción |
|
|
21
|
+
| ----------- | ------------------------------------------------------------- | ---- | ----------- | --------------------------------------------------- |
|
|
22
|
+
| `onChange` | `(value: string) => void` | sí | | Recibe el nuevo mes "AAAA-MM". |
|
|
23
|
+
| `value` | `string` | sí | | Mes actual en formato "AAAA-MM" (p. ej. "2026-11"). |
|
|
24
|
+
| `className` | `string` | | | Clase extra. |
|
|
25
|
+
| `labels` | `Partial<{ previous: string; next: string; today: string; }>` | | | Textos accesibles. |
|
|
26
|
+
| `locale` | `string` | | `es` | Idioma del nombre del mes (por defecto "es"). |
|
|
27
|
+
| `max` | `string` | | | Último mes permitido "AAAA-MM". |
|
|
28
|
+
| `min` | `string` | | | Primer mes permitido "AAAA-MM". |
|
|
29
|
+
| `showToday` | `boolean` | | `false` | Muestra el botón "Hoy" para volver al mes actual. |
|
|
30
|
+
|
|
31
|
+
Otras exportaciones: `addMonths`, `currentMonth`.
|
|
32
|
+
|
|
33
|
+
Tipos: `MonthNavigatorProps`.
|
|
34
|
+
|
|
35
|
+
<!-- catalogo:fin -->
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface MonthNavigatorProps {
|
|
2
|
+
/** Mes actual en formato "AAAA-MM" (p. ej. "2026-11"). */
|
|
3
|
+
value: string;
|
|
4
|
+
/** Recibe el nuevo mes "AAAA-MM". */
|
|
5
|
+
onChange: (value: string) => void;
|
|
6
|
+
/** Primer mes permitido "AAAA-MM". */
|
|
7
|
+
min?: string;
|
|
8
|
+
/** Último mes permitido "AAAA-MM". */
|
|
9
|
+
max?: string;
|
|
10
|
+
/** Muestra el botón "Hoy" para volver al mes actual. */
|
|
11
|
+
showToday?: boolean;
|
|
12
|
+
/** Idioma del nombre del mes (por defecto "es"). */
|
|
13
|
+
locale?: string;
|
|
14
|
+
/** Textos accesibles. */
|
|
15
|
+
labels?: Partial<{
|
|
16
|
+
previous: string;
|
|
17
|
+
next: string;
|
|
18
|
+
today: string;
|
|
19
|
+
}>;
|
|
20
|
+
/** Clase extra. */
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
/** Suma meses a "AAAA-MM": addMonths("2026-12", 1) === "2027-01". */
|
|
24
|
+
export declare function addMonths(value: string, delta: number): string;
|
|
25
|
+
/** Mes actual "AAAA-MM" en hora local. */
|
|
26
|
+
export declare function currentMonth(): string;
|
|
27
|
+
/** Navegador de periodos: ‹ noviembre de 2026 › para finanzas, contabilidad y cronogramas. */
|
|
28
|
+
export default function MonthNavigator({ value, onChange, min, max, showToday, locale, labels, className, }: MonthNavigatorProps): import("react").JSX.Element;
|
|
29
|
+
//# sourceMappingURL=MonthNavigator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MonthNavigator.d.ts","sourceRoot":"","sources":["../src/MonthNavigator.tsx"],"names":[],"mappings":"AAGA,MAAM,WAAW,mBAAmB;IAClC,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,sCAAsC;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yBAAyB;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpE,mBAAmB;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD,qEAAqE;AACrE,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI9D;AAED,0CAA0C;AAC1C,wBAAgB,YAAY,IAAI,MAAM,CAGrC;AAED,8FAA8F;AAC9F,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,KAAK,EACL,QAAQ,EACR,GAAG,EACH,GAAG,EACH,SAAiB,EACjB,MAAa,EACb,MAAM,EACN,SAAS,GACV,EAAE,mBAAmB,+BA6ErB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("@rubenpazch/shared");var o="MonthNavigator-module_nav__qdh3-",t="MonthNavigator-module_arrow__4z85x",r="MonthNavigator-module_today__IzaYx",a="MonthNavigator-module_title__aHCSD";!function(e,n){void 0===n&&(n={});var o=n.insertAt;if("undefined"!=typeof document){var t=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===o&&t.firstChild?t.insertBefore(r,t.firstChild):t.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}(".MonthNavigator-module_nav__qdh3- {\n display: inline-flex;\n align-items: center;\n gap: var(--lb-space-1);\n font-family: var(--lb-font-sans);\n}\n\n.MonthNavigator-module_arrow__4z85x {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 2rem;\n height: 2rem;\n padding: 0;\n border: 1px solid var(--lb-color-border);\n border-radius: var(--lb-radius-md);\n background: var(--lb-color-background);\n color: var(--lb-color-foreground);\n cursor: pointer;\n}\n\n.MonthNavigator-module_arrow__4z85x:hover:not(:disabled) {\n background: var(--lb-color-muted);\n}\n\n.MonthNavigator-module_arrow__4z85x:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n.MonthNavigator-module_arrow__4z85x:focus-visible,\n.MonthNavigator-module_today__IzaYx:focus-visible {\n outline: 2px solid var(--lb-color-ring);\n outline-offset: 1px;\n}\n\n.MonthNavigator-module_title__aHCSD {\n min-width: 10rem;\n text-align: center;\n font-size: var(--lb-font-size-sm);\n font-weight: var(--lb-font-weight-semibold);\n color: var(--lb-color-foreground);\n}\n\n.MonthNavigator-module_title__aHCSD::first-letter {\n text-transform: uppercase;\n}\n\n.MonthNavigator-module_today__IzaYx {\n margin-left: var(--lb-space-2);\n padding: var(--lb-space-1) var(--lb-space-3);\n border: 1px solid var(--lb-color-border);\n border-radius: var(--lb-radius-full);\n background: var(--lb-color-background);\n color: var(--lb-color-link);\n font: inherit;\n font-size: var(--lb-font-size-xs);\n cursor: pointer;\n}\n");const l=(...e)=>e.filter(Boolean).join(" "),i=e=>String(e).padStart(2,"0");function d(e,n){const[o,t]=e.split("-").map(Number),r=new Date(o,t-1+n,1);return`${r.getFullYear()}-${i(r.getMonth()+1)}`}function s(){const e=new Date;return`${e.getFullYear()}-${i(e.getMonth()+1)}`}exports.addMonths=d,exports.currentMonth=s,exports.default=function({value:i,onChange:u,min:c,max:h,showToday:v=!1,locale:b="es",labels:m,className:p}){const g={previous:"Mes anterior",next:"Mes siguiente",today:"Hoy",...m},[f,_]=i.split("-").map(Number),x=n.formatMonthYear(new Date(f,_-1,1),b),M=d(i,-1),N=d(i,1),y=s(),w=!c||M>=c,j=!h||N<=h;return e.jsxs("div",{className:l(o,p),role:"group","aria-label":"Periodo",children:[e.jsx("button",{type:"button",className:t,onClick:()=>u(M),disabled:!w,"aria-label":g.previous,children:e.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",width:"18",height:"18","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M12.79 5.23a.75.75 0 0 1-.02 1.06L8.83 10l3.94 3.71a.75.75 0 1 1-1.04 1.08l-4.5-4.25a.75.75 0 0 1 0-1.08l4.5-4.25a.75.75 0 0 1 1.06.02Z",clipRule:"evenodd"})})}),e.jsx("span",{className:a,"aria-live":"polite",children:x}),e.jsx("button",{type:"button",className:t,onClick:()=>u(N),disabled:!j,"aria-label":g.next,children:e.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",width:"18",height:"18","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 0 1 .02-1.06L11.17 10 7.23 6.29a.75.75 0 1 1 1.04-1.08l4.5 4.25a.75.75 0 0 1 0 1.08l-4.5 4.25a.75.75 0 0 1-1.06-.02Z",clipRule:"evenodd"})})}),v&&i!==y&&e.jsx("button",{type:"button",className:r,onClick:()=>u(y),children:g.today})]})};
|
|
2
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js","../src/MonthNavigator.tsx"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import { formatMonthYear } from \"@rubenpazch/shared\";\nimport styles from \"./MonthNavigator.module.css\";\n\nexport interface MonthNavigatorProps {\n /** Mes actual en formato \"AAAA-MM\" (p. ej. \"2026-11\"). */\n value: string;\n /** Recibe el nuevo mes \"AAAA-MM\". */\n onChange: (value: string) => void;\n /** Primer mes permitido \"AAAA-MM\". */\n min?: string;\n /** Último mes permitido \"AAAA-MM\". */\n max?: string;\n /** Muestra el botón \"Hoy\" para volver al mes actual. */\n showToday?: boolean;\n /** Idioma del nombre del mes (por defecto \"es\"). */\n locale?: string;\n /** Textos accesibles. */\n labels?: Partial<{ previous: string; next: string; today: string }>;\n /** Clase extra. */\n className?: string;\n}\n\nconst cx = (...c: Array<string | false | undefined>) =>\n c.filter(Boolean).join(\" \");\nconst pad = (n: number) => String(n).padStart(2, \"0\");\n\n/** Suma meses a \"AAAA-MM\": addMonths(\"2026-12\", 1) === \"2027-01\". */\nexport function addMonths(value: string, delta: number): string {\n const [y, m] = value.split(\"-\").map(Number);\n const d = new Date(y, m - 1 + delta, 1);\n return `${d.getFullYear()}-${pad(d.getMonth() + 1)}`;\n}\n\n/** Mes actual \"AAAA-MM\" en hora local. */\nexport function currentMonth(): string {\n const d = new Date();\n return `${d.getFullYear()}-${pad(d.getMonth() + 1)}`;\n}\n\n/** Navegador de periodos: ‹ noviembre de 2026 › para finanzas, contabilidad y cronogramas. */\nexport default function MonthNavigator({\n value,\n onChange,\n min,\n max,\n showToday = false,\n locale = \"es\",\n labels,\n className,\n}: MonthNavigatorProps) {\n const text = {\n previous: \"Mes anterior\",\n next: \"Mes siguiente\",\n today: \"Hoy\",\n ...labels,\n };\n const [y, m] = value.split(\"-\").map(Number);\n const title = formatMonthYear(new Date(y, m - 1, 1), locale);\n const prev = addMonths(value, -1);\n const next = addMonths(value, 1);\n const hoy = currentMonth();\n const canPrev = !min || prev >= min;\n const canNext = !max || next <= max;\n\n return (\n <div\n className={cx(styles.nav, className)}\n role=\"group\"\n aria-label=\"Periodo\"\n >\n <button\n type=\"button\"\n className={styles.arrow}\n onClick={() => onChange(prev)}\n disabled={!canPrev}\n aria-label={text.previous}\n >\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n width=\"18\"\n height=\"18\"\n aria-hidden=\"true\"\n >\n <path\n fillRule=\"evenodd\"\n d=\"M12.79 5.23a.75.75 0 0 1-.02 1.06L8.83 10l3.94 3.71a.75.75 0 1 1-1.04 1.08l-4.5-4.25a.75.75 0 0 1 0-1.08l4.5-4.25a.75.75 0 0 1 1.06.02Z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </button>\n <span className={styles.title} aria-live=\"polite\">\n {title}\n </span>\n <button\n type=\"button\"\n className={styles.arrow}\n onClick={() => onChange(next)}\n disabled={!canNext}\n aria-label={text.next}\n >\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n width=\"18\"\n height=\"18\"\n aria-hidden=\"true\"\n >\n <path\n fillRule=\"evenodd\"\n d=\"M7.21 14.77a.75.75 0 0 1 .02-1.06L11.17 10 7.23 6.29a.75.75 0 1 1 1.04-1.08l4.5 4.25a.75.75 0 0 1 0 1.08l-4.5 4.25a.75.75 0 0 1-1.06-.02Z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </button>\n {showToday && value !== hoy && (\n <button\n type=\"button\"\n className={styles.today}\n onClick={() => onChange(hoy)}\n >\n {text.today}\n </button>\n )}\n </div>\n );\n}\n"],"names":["css","ref","insertAt","document","head","getElementsByTagName","style","createElement","type","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode","cx","c","filter","Boolean","join","pad","n","String","padStart","addMonths","value","delta","y","m","split","map","Number","d","Date","getFullYear","getMonth","currentMonth","onChange","min","max","showToday","locale","labels","className","text","previous","next","today","title","formatMonthYear","prev","hoy","canPrev","canNext","_jsxs","styles","role","children","_jsx","onClick","disabled","viewBox","fill","width","height","fillRule","clipRule"],"mappings":"sSAAA,SAAqBA,EAAKC,YACnBA,IAAiBA,EAAM,CAAA,GAC5B,IAAIC,EAAWD,EAAIC,SAEnB,GAAgC,oBAAbC,SAAnB,CAEA,IAAIC,EAAOD,SAASC,MAAQD,SAASE,qBAAqB,QAAQ,GAC9DC,EAAQH,SAASI,cAAc,SACnCD,EAAME,KAAO,WAEI,QAAbN,GACEE,EAAKK,WACPL,EAAKM,aAAaJ,EAAOF,EAAKK,YAKhCL,EAAKO,YAAYL,GAGfA,EAAMM,WACRN,EAAMM,WAAWC,QAAUb,EAE3BM,EAAMK,YAAYR,SAASW,eAAed,GAnBW,CAqBzD,ihDCHA,MAAMe,EAAK,IAAIC,IACbA,EAAEC,OAAOC,SAASC,KAAK,KACnBC,EAAOC,GAAcC,OAAOD,GAAGE,SAAS,EAAG,KAG3C,SAAUC,EAAUC,EAAeC,GACvC,MAAOC,EAAGC,GAAKH,EAAMI,MAAM,KAAKC,IAAIC,QAC9BC,EAAI,IAAIC,KAAKN,EAAGC,EAAI,EAAIF,EAAO,GACrC,MAAO,GAAGM,EAAEE,iBAAiBd,EAAIY,EAAEG,WAAa,IAClD,UAGgBC,IACd,MAAMJ,EAAI,IAAIC,KAC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A,SAAA,CACElD,KAAK,SACLmC,UAAWY,EACXI,QAAS,IAAMtB,EAASc,YAEvBP,EAAKG,UAKhB","x_google_ignoreList":[0]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
|
|
3
|
+
interface MonthNavigatorProps {
|
|
4
|
+
/** Mes actual en formato "AAAA-MM" (p. ej. "2026-11"). */
|
|
5
|
+
value: string;
|
|
6
|
+
/** Recibe el nuevo mes "AAAA-MM". */
|
|
7
|
+
onChange: (value: string) => void;
|
|
8
|
+
/** Primer mes permitido "AAAA-MM". */
|
|
9
|
+
min?: string;
|
|
10
|
+
/** Último mes permitido "AAAA-MM". */
|
|
11
|
+
max?: string;
|
|
12
|
+
/** Muestra el botón "Hoy" para volver al mes actual. */
|
|
13
|
+
showToday?: boolean;
|
|
14
|
+
/** Idioma del nombre del mes (por defecto "es"). */
|
|
15
|
+
locale?: string;
|
|
16
|
+
/** Textos accesibles. */
|
|
17
|
+
labels?: Partial<{
|
|
18
|
+
previous: string;
|
|
19
|
+
next: string;
|
|
20
|
+
today: string;
|
|
21
|
+
}>;
|
|
22
|
+
/** Clase extra. */
|
|
23
|
+
className?: string;
|
|
24
|
+
}
|
|
25
|
+
/** Suma meses a "AAAA-MM": addMonths("2026-12", 1) === "2027-01". */
|
|
26
|
+
declare function addMonths(value: string, delta: number): string;
|
|
27
|
+
/** Mes actual "AAAA-MM" en hora local. */
|
|
28
|
+
declare function currentMonth(): string;
|
|
29
|
+
/** Navegador de periodos: ‹ noviembre de 2026 › para finanzas, contabilidad y cronogramas. */
|
|
30
|
+
declare function MonthNavigator({ value, onChange, min, max, showToday, locale, labels, className, }: MonthNavigatorProps): react.JSX.Element;
|
|
31
|
+
|
|
32
|
+
export { addMonths, currentMonth, MonthNavigator as default };
|
|
33
|
+
export type { MonthNavigatorProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACpE,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsxs as e,jsx as n}from"react/jsx-runtime";import{formatMonthYear as o}from"@rubenpazch/shared";var t="MonthNavigator-module_nav__qdh3-",a="MonthNavigator-module_arrow__4z85x",r="MonthNavigator-module_today__IzaYx",l="MonthNavigator-module_title__aHCSD";!function(e,n){void 0===n&&(n={});var o=n.insertAt;if("undefined"!=typeof document){var t=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===o&&t.firstChild?t.insertBefore(a,t.firstChild):t.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}(".MonthNavigator-module_nav__qdh3- {\n display: inline-flex;\n align-items: center;\n gap: var(--lb-space-1);\n font-family: var(--lb-font-sans);\n}\n\n.MonthNavigator-module_arrow__4z85x {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 2rem;\n height: 2rem;\n padding: 0;\n border: 1px solid var(--lb-color-border);\n border-radius: var(--lb-radius-md);\n background: var(--lb-color-background);\n color: var(--lb-color-foreground);\n cursor: pointer;\n}\n\n.MonthNavigator-module_arrow__4z85x:hover:not(:disabled) {\n background: var(--lb-color-muted);\n}\n\n.MonthNavigator-module_arrow__4z85x:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n.MonthNavigator-module_arrow__4z85x:focus-visible,\n.MonthNavigator-module_today__IzaYx:focus-visible {\n outline: 2px solid var(--lb-color-ring);\n outline-offset: 1px;\n}\n\n.MonthNavigator-module_title__aHCSD {\n min-width: 10rem;\n text-align: center;\n font-size: var(--lb-font-size-sm);\n font-weight: var(--lb-font-weight-semibold);\n color: var(--lb-color-foreground);\n}\n\n.MonthNavigator-module_title__aHCSD::first-letter {\n text-transform: uppercase;\n}\n\n.MonthNavigator-module_today__IzaYx {\n margin-left: var(--lb-space-2);\n padding: var(--lb-space-1) var(--lb-space-3);\n border: 1px solid var(--lb-color-border);\n border-radius: var(--lb-radius-full);\n background: var(--lb-color-background);\n color: var(--lb-color-link);\n font: inherit;\n font-size: var(--lb-font-size-xs);\n cursor: pointer;\n}\n");const i=(...e)=>e.filter(Boolean).join(" "),d=e=>String(e).padStart(2,"0");function s(e,n){const[o,t]=e.split("-").map(Number),a=new Date(o,t-1+n,1);return`${a.getFullYear()}-${d(a.getMonth()+1)}`}function u(){const e=new Date;return`${e.getFullYear()}-${d(e.getMonth()+1)}`}function c({value:d,onChange:c,min:h,max:v,showToday:m=!1,locale:b="es",labels:p,className:g}){const f={previous:"Mes anterior",next:"Mes siguiente",today:"Hoy",...p},[_,x]=d.split("-").map(Number),N=o(new Date(_,x-1,1),b),y=s(d,-1),M=s(d,1),w=u(),z=!h||y>=h,C=!v||M<=v;return e("div",{className:i(t,g),role:"group","aria-label":"Periodo",children:[n("button",{type:"button",className:a,onClick:()=>c(y),disabled:!z,"aria-label":f.previous,children:n("svg",{viewBox:"0 0 20 20",fill:"currentColor",width:"18",height:"18","aria-hidden":"true",children:n("path",{fillRule:"evenodd",d:"M12.79 5.23a.75.75 0 0 1-.02 1.06L8.83 10l3.94 3.71a.75.75 0 1 1-1.04 1.08l-4.5-4.25a.75.75 0 0 1 0-1.08l4.5-4.25a.75.75 0 0 1 1.06.02Z",clipRule:"evenodd"})})}),n("span",{className:l,"aria-live":"polite",children:N}),n("button",{type:"button",className:a,onClick:()=>c(M),disabled:!C,"aria-label":f.next,children:n("svg",{viewBox:"0 0 20 20",fill:"currentColor",width:"18",height:"18","aria-hidden":"true",children:n("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 0 1 .02-1.06L11.17 10 7.23 6.29a.75.75 0 1 1 1.04-1.08l4.5 4.25a.75.75 0 0 1 0 1.08l-4.5 4.25a.75.75 0 0 1-1.06-.02Z",clipRule:"evenodd"})})}),m&&d!==w&&n("button",{type:"button",className:r,onClick:()=>c(w),children:f.today})]})}export{s as addMonths,u as currentMonth,c as default};
|
|
2
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js","../src/MonthNavigator.tsx"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import { formatMonthYear } from \"@rubenpazch/shared\";\nimport styles from \"./MonthNavigator.module.css\";\n\nexport interface MonthNavigatorProps {\n /** Mes actual en formato \"AAAA-MM\" (p. ej. \"2026-11\"). */\n value: string;\n /** Recibe el nuevo mes \"AAAA-MM\". */\n onChange: (value: string) => void;\n /** Primer mes permitido \"AAAA-MM\". */\n min?: string;\n /** Último mes permitido \"AAAA-MM\". */\n max?: string;\n /** Muestra el botón \"Hoy\" para volver al mes actual. */\n showToday?: boolean;\n /** Idioma del nombre del mes (por defecto \"es\"). */\n locale?: string;\n /** Textos accesibles. */\n labels?: Partial<{ previous: string; next: string; today: string }>;\n /** Clase extra. */\n className?: string;\n}\n\nconst cx = (...c: Array<string | false | undefined>) =>\n c.filter(Boolean).join(\" \");\nconst pad = (n: number) => String(n).padStart(2, \"0\");\n\n/** Suma meses a \"AAAA-MM\": addMonths(\"2026-12\", 1) === \"2027-01\". */\nexport function addMonths(value: string, delta: number): string {\n const [y, m] = value.split(\"-\").map(Number);\n const d = new Date(y, m - 1 + delta, 1);\n return `${d.getFullYear()}-${pad(d.getMonth() + 1)}`;\n}\n\n/** Mes actual \"AAAA-MM\" en hora local. */\nexport function currentMonth(): string {\n const d = new Date();\n return `${d.getFullYear()}-${pad(d.getMonth() + 1)}`;\n}\n\n/** Navegador de periodos: ‹ noviembre de 2026 › para finanzas, contabilidad y cronogramas. */\nexport default function MonthNavigator({\n value,\n onChange,\n min,\n max,\n showToday = false,\n locale = \"es\",\n labels,\n className,\n}: MonthNavigatorProps) {\n const text = {\n previous: \"Mes anterior\",\n next: \"Mes siguiente\",\n today: \"Hoy\",\n ...labels,\n };\n const [y, m] = value.split(\"-\").map(Number);\n const title = formatMonthYear(new Date(y, m - 1, 1), locale);\n const prev = addMonths(value, -1);\n const next = addMonths(value, 1);\n const hoy = currentMonth();\n const canPrev = !min || prev >= min;\n const canNext = !max || next <= max;\n\n return (\n <div\n className={cx(styles.nav, className)}\n role=\"group\"\n aria-label=\"Periodo\"\n >\n <button\n type=\"button\"\n className={styles.arrow}\n onClick={() => onChange(prev)}\n disabled={!canPrev}\n aria-label={text.previous}\n >\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n width=\"18\"\n height=\"18\"\n aria-hidden=\"true\"\n >\n <path\n fillRule=\"evenodd\"\n d=\"M12.79 5.23a.75.75 0 0 1-.02 1.06L8.83 10l3.94 3.71a.75.75 0 1 1-1.04 1.08l-4.5-4.25a.75.75 0 0 1 0-1.08l4.5-4.25a.75.75 0 0 1 1.06.02Z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </button>\n <span className={styles.title} aria-live=\"polite\">\n {title}\n </span>\n <button\n type=\"button\"\n className={styles.arrow}\n onClick={() => onChange(next)}\n disabled={!canNext}\n aria-label={text.next}\n >\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n width=\"18\"\n height=\"18\"\n aria-hidden=\"true\"\n >\n <path\n fillRule=\"evenodd\"\n d=\"M7.21 14.77a.75.75 0 0 1 .02-1.06L11.17 10 7.23 6.29a.75.75 0 1 1 1.04-1.08l4.5 4.25a.75.75 0 0 1 0 1.08l-4.5 4.25a.75.75 0 0 1-1.06-.02Z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </button>\n {showToday && value !== hoy && (\n <button\n type=\"button\"\n className={styles.today}\n onClick={() => onChange(hoy)}\n >\n {text.today}\n </button>\n )}\n </div>\n );\n}\n"],"names":["css","ref","insertAt","document","head","getElementsByTagName","style","createElement","type","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode","cx","c","filter","Boolean","join","pad","n","String","padStart","addMonths","value","delta","y","m","split","map","Number","d","Date","getFullYear","getMonth","currentMonth","MonthNavigator","onChange","min","max","showToday","locale","labels","className","text","previous","next","today","title","formatMonthYear","prev","hoy","canPrev","canNext","_jsxs","styles","role","children","_jsx","onClick","disabled","viewBox","fill","width","height","fillRule","clipRule"],"mappings":"sQAAA,SAAqBA,EAAKC,YACnBA,IAAiBA,EAAM,CAAA,GAC5B,IAAIC,EAAWD,EAAIC,SAEnB,GAAgC,oBAAbC,SAAnB,CAEA,IAAIC,EAAOD,SAASC,MAAQD,SAASE,qBAAqB,QAAQ,GAC9DC,EAAQH,SAASI,cAAc,SACnCD,EAAME,KAAO,WAEI,QAAbN,GACEE,EAAKK,WACPL,EAAKM,aAAaJ,EAAOF,EAAKK,YAKhCL,EAAKO,YAAYL,GAGfA,EAAMM,WACRN,EAAMM,WAAWC,QAAUb,EAE3BM,EAAMK,YAAYR,SAASW,eAAed,GAnBW,CAqBzD,ihDCHA,MAAMe,EAAK,IAAIC,IACbA,EAAEC,OAAOC,SAASC,KAAK,KACnBC,EAAOC,GAAcC,OAAOD,GAAGE,SAAS,EAAG,KAG3C,SAAUC,EAAUC,EAAeC,GACvC,MAAOC,EAAGC,GAAKH,EAAMI,MAAM,KAAKC,IAAIC,QAC9BC,EAAI,IAAIC,KAAKN,EAAGC,EAAI,EAAIF,EAAO,GACrC,MAAO,G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AS,gBAId1B,GAAahB,IAAU2B,GACtBO,EAAA,SAAA,CACEnD,KAAK,SACLoC,UAAWY,EACXI,QAAS,IAAMtB,EAASc,YAEvBP,EAAKG,UAKhB","x_google_ignoreList":[0]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,78 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rubenpazch/month-navigator",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Navegador de meses para periodos",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/rubenpazch/lbyte-ui-library.git",
|
|
8
|
+
"directory": "packages/month-navigator"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"main": "dist/index.cjs.js",
|
|
12
|
+
"module": "dist/index.esm.js",
|
|
13
|
+
"types": "dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.esm.js",
|
|
18
|
+
"require": "./dist/index.cjs.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"sideEffects": [
|
|
25
|
+
"**/*.css"
|
|
26
|
+
],
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"react": "^19.2.3",
|
|
29
|
+
"react-dom": "^19.2.3",
|
|
30
|
+
"@rubenpazch/tokens": "0.4.0"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@rubenpazch/shared": "5.2.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@rollup/plugin-commonjs": "^29.0.3",
|
|
37
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
38
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
39
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
40
|
+
"@testing-library/react": "^16.3.3",
|
|
41
|
+
"@types/jest": "^30.0.0",
|
|
42
|
+
"@types/react": "^19.2.18",
|
|
43
|
+
"@types/react-dom": "^19.2.5",
|
|
44
|
+
"autoprefixer": "^10.5.4",
|
|
45
|
+
"eslint": "^9.39.5",
|
|
46
|
+
"identity-obj-proxy": "^3.0.0",
|
|
47
|
+
"jest": "^30.5.0",
|
|
48
|
+
"jest-environment-jsdom": "^30.5.0",
|
|
49
|
+
"postcss": "^8.5.26",
|
|
50
|
+
"prettier": "^3.9.6",
|
|
51
|
+
"react": "^19.2.8",
|
|
52
|
+
"react-dom": "^19.2.8",
|
|
53
|
+
"rollup": "^4.63.1",
|
|
54
|
+
"rollup-plugin-dts": "^6.5.1",
|
|
55
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
56
|
+
"rollup-plugin-typescript2": "^0.37.0",
|
|
57
|
+
"tslib": "^2.8.1",
|
|
58
|
+
"typescript": "^6.0.3",
|
|
59
|
+
"@rubenpazch/eslint-config": "4.0.0",
|
|
60
|
+
"@rubenpazch/typescript-config": "3.0.0"
|
|
61
|
+
},
|
|
62
|
+
"publishConfig": {
|
|
63
|
+
"access": "public"
|
|
64
|
+
},
|
|
65
|
+
"lbyte": {
|
|
66
|
+
"categoria": "navegacion",
|
|
67
|
+
"resumen": "Navegador de periodos ‹ noviembre de 2026 › con valor \"AAAA-MM\", mínimo, máximo y botón Hoy; incluye addMonths() y currentMonth().",
|
|
68
|
+
"usarCuando": "Elegir el mes de trabajo: obligaciones, cierres contables, cronogramas, reportes mensuales.",
|
|
69
|
+
"evitarCuando": "Elegir un día: usa DateInput o DatePicker. Un rango libre de fechas: usa DateRangePicker."
|
|
70
|
+
},
|
|
71
|
+
"scripts": {
|
|
72
|
+
"build": "rollup -c",
|
|
73
|
+
"test": "jest --passWithNoTests",
|
|
74
|
+
"test:watch": "jest --watch",
|
|
75
|
+
"lint": "eslint src",
|
|
76
|
+
"clean": "rm -rf dist"
|
|
77
|
+
}
|
|
6
78
|
}
|