@webiny/admin-ui 6.4.0-beta.2 → 6.4.0-beta.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 (40) hide show
  1. package/AdminUiProvider/AdminUiProvider.d.ts +3 -0
  2. package/AdminUiProvider/AdminUiProvider.js +15 -5
  3. package/AdminUiProvider/AdminUiProvider.js.map +1 -1
  4. package/AdminUiProvider/FileUrlFormatter.d.ts +7 -0
  5. package/AdminUiProvider/FileUrlFormatter.js +0 -0
  6. package/AdminUiProvider/index.d.ts +1 -0
  7. package/AdminUiProvider/index.js +1 -0
  8. package/FilePicker/domains/FileItem.js +3 -2
  9. package/FilePicker/domains/FileItem.js.map +1 -1
  10. package/FilePicker/domains/FileItemDto.d.ts +9 -2
  11. package/FilePicker/primitives/components/previews/FilePreview.js +5 -3
  12. package/FilePicker/primitives/components/previews/FilePreview.js.map +1 -1
  13. package/FilePicker/primitives/useFilePicker.js +24 -1
  14. package/FilePicker/primitives/useFilePicker.js.map +1 -1
  15. package/TimeAgo/TimeAgo.d.ts +3 -0
  16. package/TimeAgo/TimeAgo.js +45 -0
  17. package/TimeAgo/TimeAgo.js.map +1 -0
  18. package/TimeAgo/TimeAgo.stories.d.ts +15 -0
  19. package/TimeAgo/TimeAgo.stories.js +71 -0
  20. package/TimeAgo/TimeAgo.stories.js.map +1 -0
  21. package/TimeAgo/formatElapsed.d.ts +1 -0
  22. package/TimeAgo/formatElapsed.js +27 -0
  23. package/TimeAgo/formatElapsed.js.map +1 -0
  24. package/TimeAgo/getElapsedSeconds.d.ts +2 -0
  25. package/TimeAgo/getElapsedSeconds.js +9 -0
  26. package/TimeAgo/getElapsedSeconds.js.map +1 -0
  27. package/TimeAgo/getUpdateDelay.d.ts +3 -0
  28. package/TimeAgo/getUpdateDelay.js +24 -0
  29. package/TimeAgo/getUpdateDelay.js.map +1 -0
  30. package/TimeAgo/index.d.ts +2 -3
  31. package/TimeAgo/index.js +1 -1
  32. package/TimeAgo/toEpochMs.d.ts +2 -0
  33. package/TimeAgo/toEpochMs.js +8 -0
  34. package/TimeAgo/toEpochMs.js.map +1 -0
  35. package/TimeAgo/toISOString.d.ts +2 -0
  36. package/TimeAgo/toISOString.js +8 -0
  37. package/TimeAgo/toISOString.js.map +1 -0
  38. package/TimeAgo/types.d.ts +18 -0
  39. package/TimeAgo/types.js +0 -0
  40. package/package.json +10 -11
@@ -1,9 +1,11 @@
1
1
  import React from "react";
2
2
  import { type LinkComponent } from "../index.js";
3
+ import type { FileUrlFormatter } from "./FileUrlFormatter.js";
3
4
  export type CompileMarkdown = (markdown: React.ReactNode) => React.ReactNode;
4
5
  export interface AdminUiContextValue {
5
6
  linkComponent: LinkComponent;
6
7
  compileMarkdown: CompileMarkdown;
8
+ fileUrlFormatter: FileUrlFormatter;
7
9
  }
8
10
  export declare const AdminUiContext: React.Context<AdminUiContextValue | undefined>;
9
11
  interface MarkdownCompiler {
@@ -12,6 +14,7 @@ interface MarkdownCompiler {
12
14
  export interface AdminUiProviderProps {
13
15
  linkComponent?: LinkComponent;
14
16
  markdownCompiler?: MarkdownCompiler;
17
+ fileUrlFormatter?: FileUrlFormatter;
15
18
  children: React.ReactNode;
16
19
  }
17
20
  export declare const AdminUiProvider: ({ children, ...props }: AdminUiProviderProps) => React.JSX.Element;
@@ -1,12 +1,16 @@
1
- import react, { useCallback, useEffect, useRef } from "react";
1
+ import react, { useCallback, useEffect, useMemo, useRef } from "react";
2
2
  import { Toast } from "../Toast/index.js";
3
3
  import { Tooltip } from "../Tooltip/index.js";
4
4
  import { DefaultLinkComponent } from "../index.js";
5
5
  const passthrough = (markdown)=>markdown;
6
+ const passthroughFileUrlFormatter = {
7
+ format (_url) {}
8
+ };
6
9
  const AdminUiContext = /*#__PURE__*/ react.createContext(void 0);
7
10
  const AdminUiProvider = ({ children, ...props })=>{
8
11
  const linkComponent = props.linkComponent ?? DefaultLinkComponent;
9
12
  const markdownCompiler = props.markdownCompiler ?? passthrough;
13
+ const fileUrlFormatter = props.fileUrlFormatter ?? passthroughFileUrlFormatter;
10
14
  const cacheRef = useRef(new Map());
11
15
  useEffect(()=>{
12
16
  cacheRef.current.clear();
@@ -27,11 +31,17 @@ const AdminUiProvider = ({ children, ...props })=>{
27
31
  }, [
28
32
  markdownCompiler
29
33
  ]);
30
- return /*#__PURE__*/ react.createElement(AdminUiContext.Provider, {
31
- value: {
34
+ const contextValue = useMemo(()=>({
32
35
  linkComponent,
33
- compileMarkdown
34
- }
36
+ compileMarkdown,
37
+ fileUrlFormatter
38
+ }), [
39
+ linkComponent,
40
+ compileMarkdown,
41
+ fileUrlFormatter
42
+ ]);
43
+ return /*#__PURE__*/ react.createElement(AdminUiContext.Provider, {
44
+ value: contextValue
35
45
  }, /*#__PURE__*/ react.createElement(Tooltip.Provider, null, children), /*#__PURE__*/ react.createElement(Toast.Provider, null));
36
46
  };
37
47
  const useAdminUi = ()=>{
@@ -1 +1 @@
1
- {"version":3,"file":"AdminUiProvider/AdminUiProvider.js","sources":["../../src/AdminUiProvider/AdminUiProvider.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef } from \"react\";\nimport { Toast } from \"~/Toast/index.js\";\nimport { Tooltip } from \"~/Tooltip/index.js\";\nimport { type LinkComponent, DefaultLinkComponent } from \"~/index.js\";\n\nexport type CompileMarkdown = (markdown: React.ReactNode) => React.ReactNode;\n\nexport interface AdminUiContextValue {\n linkComponent: LinkComponent;\n compileMarkdown: CompileMarkdown;\n}\n\nconst passthrough = (markdown: string) => markdown;\n\nexport const AdminUiContext = React.createContext<AdminUiContextValue | undefined>(undefined);\n\ninterface MarkdownCompiler {\n (markdown: string): React.ReactNode;\n}\n\nexport interface AdminUiProviderProps {\n linkComponent?: LinkComponent;\n markdownCompiler?: MarkdownCompiler;\n children: React.ReactNode;\n}\n\nexport const AdminUiProvider = ({ children, ...props }: AdminUiProviderProps) => {\n const linkComponent = props.linkComponent ?? DefaultLinkComponent;\n const markdownCompiler = props.markdownCompiler ?? passthrough;\n\n // Cache to store compiled markdown results\n const cacheRef = useRef(new Map<string, React.ReactNode>());\n\n // Clear cache when markdownCompiler changes\n useEffect(() => {\n cacheRef.current.clear();\n }, [markdownCompiler]);\n\n const compileMarkdown = useCallback(\n (markdown: React.ReactNode) => {\n if (!markdownCompiler) {\n return markdown;\n }\n\n if (React.isValidElement(markdown)) {\n return markdown;\n }\n\n if (typeof markdown === \"string\") {\n // Check cache first\n const cached = cacheRef.current.get(markdown);\n if (cached !== undefined) {\n return cached;\n }\n\n // Compile and cache\n const compiled = markdownCompiler(markdown);\n cacheRef.current.set(markdown, compiled);\n return compiled;\n }\n\n return markdown;\n },\n [markdownCompiler]\n );\n\n return (\n <AdminUiContext.Provider value={{ linkComponent, compileMarkdown }}>\n <Tooltip.Provider>{children}</Tooltip.Provider>\n <Toast.Provider />\n </AdminUiContext.Provider>\n );\n};\n\nexport const useAdminUi = () => {\n const context = React.useContext(AdminUiContext);\n if (!context) {\n throw new Error(\"AdminUiProvider is missing from the component tree.\");\n }\n return context;\n};\n"],"names":["passthrough","markdown","AdminUiContext","React","undefined","AdminUiProvider","children","props","linkComponent","DefaultLinkComponent","markdownCompiler","cacheRef","useRef","Map","useEffect","compileMarkdown","useCallback","cached","compiled","Tooltip","Toast","useAdminUi","context","Error"],"mappings":";;;;AAYA,MAAMA,cAAc,CAACC,WAAqBA;AAEnC,MAAMC,iBAAiB,WAAHA,GAAGC,MAAAA,aAAmB,CAAkCC;AAY5E,MAAMC,kBAAkB,CAAC,EAAEC,QAAQ,EAAE,GAAGC,OAA6B;IACxE,MAAMC,gBAAgBD,MAAM,aAAa,IAAIE;IAC7C,MAAMC,mBAAmBH,MAAM,gBAAgB,IAAIP;IAGnD,MAAMW,WAAWC,OAAO,IAAIC;IAG5BC,UAAU;QACNH,SAAS,OAAO,CAAC,KAAK;IAC1B,GAAG;QAACD;KAAiB;IAErB,MAAMK,kBAAkBC,YACpB,CAACf;QACG,IAAI,CAACS,kBACD,OAAOT;QAGX,IAAI,WAAJ,GAAIE,MAAAA,cAAoB,CAACF,WACrB,OAAOA;QAGX,IAAI,AAAoB,YAApB,OAAOA,UAAuB;YAE9B,MAAMgB,SAASN,SAAS,OAAO,CAAC,GAAG,CAACV;YACpC,IAAIgB,AAAWb,WAAXa,QACA,OAAOA;YAIX,MAAMC,WAAWR,iBAAiBT;YAClCU,SAAS,OAAO,CAAC,GAAG,CAACV,UAAUiB;YAC/B,OAAOA;QACX;QAEA,OAAOjB;IACX,GACA;QAACS;KAAiB;IAGtB,OAAO,WAAP,GACI,oBAACR,eAAe,QAAQ;QAAC,OAAO;YAAEM;YAAeO;QAAgB;qBAC7D,oBAACI,QAAQ,QAAQ,QAAEb,WAAAA,WAAAA,GACnB,oBAACc,MAAM,QAAQ;AAG3B;AAEO,MAAMC,aAAa;IACtB,MAAMC,UAAUnB,MAAAA,UAAgB,CAACD;IACjC,IAAI,CAACoB,SACD,MAAM,IAAIC,MAAM;IAEpB,OAAOD;AACX"}
1
+ {"version":3,"file":"AdminUiProvider/AdminUiProvider.js","sources":["../../src/AdminUiProvider/AdminUiProvider.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { Toast } from \"~/Toast/index.js\";\nimport { Tooltip } from \"~/Tooltip/index.js\";\nimport { type LinkComponent, DefaultLinkComponent } from \"~/index.js\";\nimport type { FileUrlFormatter } from \"./FileUrlFormatter.js\";\n\nexport type CompileMarkdown = (markdown: React.ReactNode) => React.ReactNode;\n\nexport interface AdminUiContextValue {\n linkComponent: LinkComponent;\n compileMarkdown: CompileMarkdown;\n fileUrlFormatter: FileUrlFormatter;\n}\n\nconst passthrough = (markdown: string) => markdown;\n\nconst passthroughFileUrlFormatter: FileUrlFormatter = {\n format(_url: URL): void {\n // passthrough — no-op\n }\n};\n\nexport const AdminUiContext = React.createContext<AdminUiContextValue | undefined>(undefined);\n\ninterface MarkdownCompiler {\n (markdown: string): React.ReactNode;\n}\n\nexport interface AdminUiProviderProps {\n linkComponent?: LinkComponent;\n markdownCompiler?: MarkdownCompiler;\n fileUrlFormatter?: FileUrlFormatter;\n children: React.ReactNode;\n}\n\nexport const AdminUiProvider = ({ children, ...props }: AdminUiProviderProps) => {\n const linkComponent = props.linkComponent ?? DefaultLinkComponent;\n const markdownCompiler = props.markdownCompiler ?? passthrough;\n const fileUrlFormatter = props.fileUrlFormatter ?? passthroughFileUrlFormatter;\n\n // Cache to store compiled markdown results\n const cacheRef = useRef(new Map<string, React.ReactNode>());\n\n // Clear cache when markdownCompiler changes\n useEffect(() => {\n cacheRef.current.clear();\n }, [markdownCompiler]);\n\n const compileMarkdown = useCallback(\n (markdown: React.ReactNode) => {\n if (!markdownCompiler) {\n return markdown;\n }\n\n if (React.isValidElement(markdown)) {\n return markdown;\n }\n\n if (typeof markdown === \"string\") {\n // Check cache first\n const cached = cacheRef.current.get(markdown);\n if (cached !== undefined) {\n return cached;\n }\n\n // Compile and cache\n const compiled = markdownCompiler(markdown);\n cacheRef.current.set(markdown, compiled);\n return compiled;\n }\n\n return markdown;\n },\n [markdownCompiler]\n );\n\n const contextValue = useMemo(\n () => ({ linkComponent, compileMarkdown, fileUrlFormatter }),\n [linkComponent, compileMarkdown, fileUrlFormatter]\n );\n\n return (\n <AdminUiContext.Provider value={contextValue}>\n <Tooltip.Provider>{children}</Tooltip.Provider>\n <Toast.Provider />\n </AdminUiContext.Provider>\n );\n};\n\nexport const useAdminUi = () => {\n const context = React.useContext(AdminUiContext);\n if (!context) {\n throw new Error(\"AdminUiProvider is missing from the component tree.\");\n }\n return context;\n};\n"],"names":["passthrough","markdown","passthroughFileUrlFormatter","_url","AdminUiContext","React","undefined","AdminUiProvider","children","props","linkComponent","DefaultLinkComponent","markdownCompiler","fileUrlFormatter","cacheRef","useRef","Map","useEffect","compileMarkdown","useCallback","cached","compiled","contextValue","useMemo","Tooltip","Toast","useAdminUi","context","Error"],"mappings":";;;;AAcA,MAAMA,cAAc,CAACC,WAAqBA;AAE1C,MAAMC,8BAAgD;IAClD,QAAOC,IAAS,GAEhB;AACJ;AAEO,MAAMC,iBAAiB,WAAHA,GAAGC,MAAAA,aAAmB,CAAkCC;AAa5E,MAAMC,kBAAkB,CAAC,EAAEC,QAAQ,EAAE,GAAGC,OAA6B;IACxE,MAAMC,gBAAgBD,MAAM,aAAa,IAAIE;IAC7C,MAAMC,mBAAmBH,MAAM,gBAAgB,IAAIT;IACnD,MAAMa,mBAAmBJ,MAAM,gBAAgB,IAAIP;IAGnD,MAAMY,WAAWC,OAAO,IAAIC;IAG5BC,UAAU;QACNH,SAAS,OAAO,CAAC,KAAK;IAC1B,GAAG;QAACF;KAAiB;IAErB,MAAMM,kBAAkBC,YACpB,CAAClB;QACG,IAAI,CAACW,kBACD,OAAOX;QAGX,IAAI,WAAJ,GAAII,MAAAA,cAAoB,CAACJ,WACrB,OAAOA;QAGX,IAAI,AAAoB,YAApB,OAAOA,UAAuB;YAE9B,MAAMmB,SAASN,SAAS,OAAO,CAAC,GAAG,CAACb;YACpC,IAAImB,AAAWd,WAAXc,QACA,OAAOA;YAIX,MAAMC,WAAWT,iBAAiBX;YAClCa,SAAS,OAAO,CAAC,GAAG,CAACb,UAAUoB;YAC/B,OAAOA;QACX;QAEA,OAAOpB;IACX,GACA;QAACW;KAAiB;IAGtB,MAAMU,eAAeC,QACjB,IAAO;YAAEb;YAAeQ;YAAiBL;QAAiB,IAC1D;QAACH;QAAeQ;QAAiBL;KAAiB;IAGtD,OAAO,WAAP,GACI,oBAACT,eAAe,QAAQ;QAAC,OAAOkB;qBAC5B,oBAACE,QAAQ,QAAQ,QAAEhB,WAAAA,WAAAA,GACnB,oBAACiB,MAAM,QAAQ;AAG3B;AAEO,MAAMC,aAAa;IACtB,MAAMC,UAAUtB,MAAAA,UAAgB,CAACD;IACjC,IAAI,CAACuB,SACD,MAAM,IAAIC,MAAM;IAEpB,OAAOD;AACX"}
@@ -0,0 +1,7 @@
1
+ export interface FileUrlParams {
2
+ width?: number;
3
+ [key: string]: unknown;
4
+ }
5
+ export interface FileUrlFormatter {
6
+ format(url: URL, params?: FileUrlParams): void;
7
+ }
File without changes
@@ -1 +1,2 @@
1
1
  export * from "./AdminUiProvider.js";
2
+ export * from "./FileUrlFormatter.js";
@@ -1 +1,2 @@
1
1
  export * from "./AdminUiProvider.js";
2
+ export * from "./FileUrlFormatter.js";
@@ -8,10 +8,11 @@ class FileItem {
8
8
  this._size = data.size;
9
9
  }
10
10
  static create(data) {
11
+ const url = "url" in data ? data.url : data.src;
11
12
  return new FileItem({
12
13
  id: generateId(data.id),
13
- name: data.name ?? data.url,
14
- url: data.url,
14
+ name: data.name ?? url,
15
+ url,
15
16
  mimeType: data.mimeType ?? this.getDefaultMimeType(),
16
17
  size: data.size ?? 0
17
18
  });
@@ -1 +1 @@
1
- {"version":3,"file":"FilePicker/domains/FileItem.js","sources":["../../../src/FilePicker/domains/FileItem.ts"],"sourcesContent":["import type { FileItemDto } from \"./FileItemDto.js\";\nimport { generateId } from \"~/utils.js\";\n\nexport class FileItem {\n private readonly _id: string;\n private readonly _name: string;\n private readonly _url: string;\n private readonly _mimeType: string;\n private readonly _size: number;\n\n protected constructor(data: {\n id: string;\n name: string;\n url: string;\n mimeType: string;\n size: number;\n }) {\n this._id = data.id;\n this._name = data.name;\n this._url = data.url;\n this._mimeType = data.mimeType;\n this._size = data.size;\n }\n\n static create(data: FileItemDto): FileItem {\n return new FileItem({\n id: generateId(data.id),\n name: data.name ?? data.url,\n url: data.url,\n mimeType: data.mimeType ?? this.getDefaultMimeType(),\n size: data.size ?? 0\n });\n }\n\n static createFromUrl(url: string): FileItem {\n const documentUrl = new URL(url);\n const pathname = documentUrl.pathname;\n const name = pathname.substring(pathname.lastIndexOf(\"/\") + 1);\n const extension = name.split(\".\").pop()?.toLowerCase() || \"\";\n\n // Map extensions to mimetypes\n const mimeTypes: Record<string, string> = {\n // Images\n jpg: \"image/jpeg\",\n jpeg: \"image/jpeg\",\n png: \"image/png\",\n gif: \"image/gif\",\n bmp: \"image/bmp\",\n webp: \"image/webp\",\n svg: \"image/svg+xml\",\n ico: \"image/x-icon\",\n tif: \"image/tiff\",\n tiff: \"image/tiff\",\n\n // Documents\n pdf: \"application/pdf\",\n txt: \"text/plain\",\n csv: \"text/csv\",\n json: \"application/json\",\n xml: \"application/xml\",\n html: \"text/html\",\n xhtml: \"application/xhtml+xml\",\n md: \"text/markdown\",\n\n // Microsoft Office\n doc: \"application/msword\",\n docx: \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n xls: \"application/vnd.ms-excel\",\n xlsx: \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n ppt: \"application/vnd.ms-powerpoint\",\n pptx: \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n\n // Open Document Format\n odt: \"application/vnd.oasis.opendocument.text\",\n ods: \"application/vnd.oasis.opendocument.spreadsheet\",\n odp: \"application/vnd.oasis.opendocument.presentation\",\n\n // Audio\n mp3: \"audio/mpeg\",\n wav: \"audio/wav\",\n ogg: \"audio/ogg\",\n flac: \"audio/flac\",\n aac: \"audio/aac\",\n m4a: \"audio/mp4\",\n\n // Video\n mp4: \"video/mp4\",\n avi: \"video/x-msvideo\",\n mov: \"video/quicktime\",\n mkv: \"video/x-matroska\",\n webm: \"video/webm\",\n flv: \"video/x-flv\",\n wmv: \"video/x-ms-wmv\",\n\n // Archives & Compressed\n zip: \"application/zip\",\n rar: \"application/vnd.rar\",\n tar: \"application/x-tar\",\n gz: \"application/gzip\",\n bz2: \"application/x-bzip2\",\n \"7z\": \"application/x-7z-compressed\",\n\n // Code & Scripts\n js: \"application/javascript\",\n ts: \"application/typescript\",\n css: \"text/css\",\n py: \"text/x-python\",\n java: \"text/x-java-source\",\n c: \"text/x-c\",\n cpp: \"text/x-c++\",\n sh: \"application/x-sh\",\n php: \"application/x-httpd-php\",\n rb: \"application/x-ruby\",\n go: \"text/x-go\",\n swift: \"text/x-swift\"\n };\n\n return new FileItem({\n id: generateId(),\n name,\n url,\n mimeType: mimeTypes[extension] ?? this.getDefaultMimeType(),\n size: 0\n });\n }\n\n get id() {\n return this._id;\n }\n\n get name() {\n return this._name;\n }\n\n get url() {\n return this._url;\n }\n\n get size() {\n return this._size;\n }\n\n get mimeType() {\n return this._mimeType;\n }\n\n private static getDefaultMimeType(): string {\n return \"application/octet-stream\";\n }\n}\n"],"names":["FileItem","data","generateId","url","documentUrl","URL","pathname","name","extension","mimeTypes"],"mappings":";AAGO,MAAMA;IAOT,YAAsBC,IAMrB,CAAE;QACC,IAAI,CAAC,GAAG,GAAGA,KAAK,EAAE;QAClB,IAAI,CAAC,KAAK,GAAGA,KAAK,IAAI;QACtB,IAAI,CAAC,IAAI,GAAGA,KAAK,GAAG;QACpB,IAAI,CAAC,SAAS,GAAGA,KAAK,QAAQ;QAC9B,IAAI,CAAC,KAAK,GAAGA,KAAK,IAAI;IAC1B;IAEA,OAAO,OAAOA,IAAiB,EAAY;QACvC,OAAO,IAAID,SAAS;YAChB,IAAIE,WAAWD,KAAK,EAAE;YACtB,MAAMA,KAAK,IAAI,IAAIA,KAAK,GAAG;YAC3B,KAAKA,KAAK,GAAG;YACb,UAAUA,KAAK,QAAQ,IAAI,IAAI,CAAC,kBAAkB;YAClD,MAAMA,KAAK,IAAI,IAAI;QACvB;IACJ;IAEA,OAAO,cAAcE,GAAW,EAAY;QACxC,MAAMC,cAAc,IAAIC,IAAIF;QAC5B,MAAMG,WAAWF,YAAY,QAAQ;QACrC,MAAMG,OAAOD,SAAS,SAAS,CAACA,SAAS,WAAW,CAAC,OAAO;QAC5D,MAAME,YAAYD,KAAK,KAAK,CAAC,KAAK,GAAG,IAAI,iBAAiB;QAG1D,MAAME,YAAoC;YAEtC,KAAK;YACL,MAAM;YACN,KAAK;YACL,KAAK;YACL,KAAK;YACL,MAAM;YACN,KAAK;YACL,KAAK;YACL,KAAK;YACL,MAAM;YAGN,KAAK;YACL,KAAK;YACL,KAAK;YACL,MAAM;YACN,KAAK;YACL,MAAM;YACN,OAAO;YACP,IAAI;YAGJ,KAAK;YACL,MAAM;YACN,KAAK;YACL,MAAM;YACN,KAAK;YACL,MAAM;YAGN,KAAK;YACL,KAAK;YACL,KAAK;YAGL,KAAK;YACL,KAAK;YACL,KAAK;YACL,MAAM;YACN,KAAK;YACL,KAAK;YAGL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,MAAM;YACN,KAAK;YACL,KAAK;YAGL,KAAK;YACL,KAAK;YACL,KAAK;YACL,IAAI;YACJ,KAAK;YACL,MAAM;YAGN,IAAI;YACJ,IAAI;YACJ,KAAK;YACL,IAAI;YACJ,MAAM;YACN,GAAG;YACH,KAAK;YACL,IAAI;YACJ,KAAK;YACL,IAAI;YACJ,IAAI;YACJ,OAAO;QACX;QAEA,OAAO,IAAIT,SAAS;YAChB,IAAIE;YACJK;YACAJ;YACA,UAAUM,SAAS,CAACD,UAAU,IAAI,IAAI,CAAC,kBAAkB;YACzD,MAAM;QACV;IACJ;IAEA,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,GAAG;IACnB;IAEA,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,KAAK;IACrB;IAEA,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,IAAI;IACpB;IAEA,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,KAAK;IACrB;IAEA,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,SAAS;IACzB;IAEA,OAAe,qBAA6B;QACxC,OAAO;IACX;AACJ"}
1
+ {"version":3,"file":"FilePicker/domains/FileItem.js","sources":["../../../src/FilePicker/domains/FileItem.ts"],"sourcesContent":["import type { FileItemDto } from \"./FileItemDto.js\";\nimport { generateId } from \"~/utils.js\";\n\nexport class FileItem {\n private readonly _id: string;\n private readonly _name: string;\n private readonly _url: string;\n private readonly _mimeType: string;\n private readonly _size: number;\n\n protected constructor(data: {\n id: string;\n name: string;\n url: string;\n mimeType: string;\n size: number;\n }) {\n this._id = data.id;\n this._name = data.name;\n this._url = data.url;\n this._mimeType = data.mimeType;\n this._size = data.size;\n }\n\n static create(data: FileItemDto): FileItem {\n const url = \"url\" in data ? data.url : data.src;\n return new FileItem({\n id: generateId(data.id),\n name: data.name ?? url,\n url,\n mimeType: data.mimeType ?? this.getDefaultMimeType(),\n size: data.size ?? 0\n });\n }\n\n static createFromUrl(url: string): FileItem {\n const documentUrl = new URL(url);\n const pathname = documentUrl.pathname;\n const name = pathname.substring(pathname.lastIndexOf(\"/\") + 1);\n const extension = name.split(\".\").pop()?.toLowerCase() || \"\";\n\n // Map extensions to mimetypes\n const mimeTypes: Record<string, string> = {\n // Images\n jpg: \"image/jpeg\",\n jpeg: \"image/jpeg\",\n png: \"image/png\",\n gif: \"image/gif\",\n bmp: \"image/bmp\",\n webp: \"image/webp\",\n svg: \"image/svg+xml\",\n ico: \"image/x-icon\",\n tif: \"image/tiff\",\n tiff: \"image/tiff\",\n\n // Documents\n pdf: \"application/pdf\",\n txt: \"text/plain\",\n csv: \"text/csv\",\n json: \"application/json\",\n xml: \"application/xml\",\n html: \"text/html\",\n xhtml: \"application/xhtml+xml\",\n md: \"text/markdown\",\n\n // Microsoft Office\n doc: \"application/msword\",\n docx: \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n xls: \"application/vnd.ms-excel\",\n xlsx: \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n ppt: \"application/vnd.ms-powerpoint\",\n pptx: \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n\n // Open Document Format\n odt: \"application/vnd.oasis.opendocument.text\",\n ods: \"application/vnd.oasis.opendocument.spreadsheet\",\n odp: \"application/vnd.oasis.opendocument.presentation\",\n\n // Audio\n mp3: \"audio/mpeg\",\n wav: \"audio/wav\",\n ogg: \"audio/ogg\",\n flac: \"audio/flac\",\n aac: \"audio/aac\",\n m4a: \"audio/mp4\",\n\n // Video\n mp4: \"video/mp4\",\n avi: \"video/x-msvideo\",\n mov: \"video/quicktime\",\n mkv: \"video/x-matroska\",\n webm: \"video/webm\",\n flv: \"video/x-flv\",\n wmv: \"video/x-ms-wmv\",\n\n // Archives & Compressed\n zip: \"application/zip\",\n rar: \"application/vnd.rar\",\n tar: \"application/x-tar\",\n gz: \"application/gzip\",\n bz2: \"application/x-bzip2\",\n \"7z\": \"application/x-7z-compressed\",\n\n // Code & Scripts\n js: \"application/javascript\",\n ts: \"application/typescript\",\n css: \"text/css\",\n py: \"text/x-python\",\n java: \"text/x-java-source\",\n c: \"text/x-c\",\n cpp: \"text/x-c++\",\n sh: \"application/x-sh\",\n php: \"application/x-httpd-php\",\n rb: \"application/x-ruby\",\n go: \"text/x-go\",\n swift: \"text/x-swift\"\n };\n\n return new FileItem({\n id: generateId(),\n name,\n url,\n mimeType: mimeTypes[extension] ?? this.getDefaultMimeType(),\n size: 0\n });\n }\n\n get id() {\n return this._id;\n }\n\n get name() {\n return this._name;\n }\n\n get url() {\n return this._url;\n }\n\n get size() {\n return this._size;\n }\n\n get mimeType() {\n return this._mimeType;\n }\n\n private static getDefaultMimeType(): string {\n return \"application/octet-stream\";\n }\n}\n"],"names":["FileItem","data","url","generateId","documentUrl","URL","pathname","name","extension","mimeTypes"],"mappings":";AAGO,MAAMA;IAOT,YAAsBC,IAMrB,CAAE;QACC,IAAI,CAAC,GAAG,GAAGA,KAAK,EAAE;QAClB,IAAI,CAAC,KAAK,GAAGA,KAAK,IAAI;QACtB,IAAI,CAAC,IAAI,GAAGA,KAAK,GAAG;QACpB,IAAI,CAAC,SAAS,GAAGA,KAAK,QAAQ;QAC9B,IAAI,CAAC,KAAK,GAAGA,KAAK,IAAI;IAC1B;IAEA,OAAO,OAAOA,IAAiB,EAAY;QACvC,MAAMC,MAAM,SAASD,OAAOA,KAAK,GAAG,GAAGA,KAAK,GAAG;QAC/C,OAAO,IAAID,SAAS;YAChB,IAAIG,WAAWF,KAAK,EAAE;YACtB,MAAMA,KAAK,IAAI,IAAIC;YACnBA;YACA,UAAUD,KAAK,QAAQ,IAAI,IAAI,CAAC,kBAAkB;YAClD,MAAMA,KAAK,IAAI,IAAI;QACvB;IACJ;IAEA,OAAO,cAAcC,GAAW,EAAY;QACxC,MAAME,cAAc,IAAIC,IAAIH;QAC5B,MAAMI,WAAWF,YAAY,QAAQ;QACrC,MAAMG,OAAOD,SAAS,SAAS,CAACA,SAAS,WAAW,CAAC,OAAO;QAC5D,MAAME,YAAYD,KAAK,KAAK,CAAC,KAAK,GAAG,IAAI,iBAAiB;QAG1D,MAAME,YAAoC;YAEtC,KAAK;YACL,MAAM;YACN,KAAK;YACL,KAAK;YACL,KAAK;YACL,MAAM;YACN,KAAK;YACL,KAAK;YACL,KAAK;YACL,MAAM;YAGN,KAAK;YACL,KAAK;YACL,KAAK;YACL,MAAM;YACN,KAAK;YACL,MAAM;YACN,OAAO;YACP,IAAI;YAGJ,KAAK;YACL,MAAM;YACN,KAAK;YACL,MAAM;YACN,KAAK;YACL,MAAM;YAGN,KAAK;YACL,KAAK;YACL,KAAK;YAGL,KAAK;YACL,KAAK;YACL,KAAK;YACL,MAAM;YACN,KAAK;YACL,KAAK;YAGL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,MAAM;YACN,KAAK;YACL,KAAK;YAGL,KAAK;YACL,KAAK;YACL,KAAK;YACL,IAAI;YACJ,KAAK;YACL,MAAM;YAGN,IAAI;YACJ,IAAI;YACJ,KAAK;YACL,IAAI;YACJ,MAAM;YACN,GAAG;YACH,KAAK;YACL,IAAI;YACJ,KAAK;YACL,IAAI;YACJ,IAAI;YACJ,OAAO;QACX;QAEA,OAAO,IAAIT,SAAS;YAChB,IAAIG;YACJI;YACAL;YACA,UAAUO,SAAS,CAACD,UAAU,IAAI,IAAI,CAAC,kBAAkB;YACzD,MAAM;QACV;IACJ;IAEA,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,GAAG;IACnB;IAEA,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,KAAK;IACrB;IAEA,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,IAAI;IACpB;IAEA,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,KAAK;IACrB;IAEA,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,SAAS;IACzB;IAEA,OAAe,qBAA6B;QACxC,OAAO;IACX;AACJ"}
@@ -1,7 +1,14 @@
1
- export interface FileItemDto {
1
+ interface BaseFileItemDto {
2
2
  id?: string;
3
3
  name?: string;
4
- url: string;
5
4
  mimeType?: string;
6
5
  size?: number;
7
6
  }
7
+ interface SrcFileItemDto extends BaseFileItemDto {
8
+ src: string;
9
+ }
10
+ interface UrlFileItemDto extends BaseFileItemDto {
11
+ url: string;
12
+ }
13
+ export type FileItemDto = SrcFileItemDto | UrlFileItemDto;
14
+ export {};
@@ -1,8 +1,10 @@
1
- import { RichItemPreview, TextOnlyPreview } from "./index.js";
1
+ import { RichItemPreview } from "./index.js";
2
2
  import * as __rspack_external_react from "react";
3
3
  const FilePreview = ({ type, renderFilePreview, ...props })=>{
4
- if ("function" == typeof renderFilePreview) return renderFilePreview(props);
5
- if ("compact" === type) return /*#__PURE__*/ __rspack_external_react.createElement(TextOnlyPreview, props);
4
+ if ("function" == typeof renderFilePreview) return renderFilePreview({
5
+ type,
6
+ ...props
7
+ });
6
8
  return /*#__PURE__*/ __rspack_external_react.createElement(RichItemPreview, props);
7
9
  };
8
10
  export { FilePreview };
@@ -1 +1 @@
1
- {"version":3,"file":"FilePicker/primitives/components/previews/FilePreview.js","sources":["../../../../../src/FilePicker/primitives/components/previews/FilePreview.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { type VariantProps } from \"~/utils.js\";\nimport type { filePickerVariants } from \"~/FilePicker/index.js\";\nimport type { FilePreviewDefaultProps } from \"../types.js\";\nimport { RichItemPreview, TextOnlyPreview } from \"../previews/index.js\";\n\ntype FilePreviewProps = FilePreviewDefaultProps & {\n type: VariantProps<typeof filePickerVariants>[\"type\"];\n renderFilePreview?: (props: any) => React.ReactElement<any>;\n};\n\nconst FilePreview = ({ type, renderFilePreview, ...props }: FilePreviewProps) => {\n if (typeof renderFilePreview === \"function\") {\n return renderFilePreview(props);\n }\n\n if (type === \"compact\") {\n return <TextOnlyPreview {...props} />;\n }\n\n return <RichItemPreview {...props} />;\n};\n\nexport { FilePreview, type FilePreviewProps };\n"],"names":["FilePreview","type","renderFilePreview","props","TextOnlyPreview","RichItemPreview"],"mappings":";;AAWA,MAAMA,cAAc,CAAC,EAAEC,IAAI,EAAEC,iBAAiB,EAAE,GAAGC,OAAyB;IACxE,IAAI,AAA6B,cAA7B,OAAOD,mBACP,OAAOA,kBAAkBC;IAG7B,IAAIF,AAAS,cAATA,MACA,OAAO,WAAP,GAAO,sCAACG,iBAAoBD;IAGhC,OAAO,WAAP,GAAO,sCAACE,iBAAoBF;AAChC"}
1
+ {"version":3,"file":"FilePicker/primitives/components/previews/FilePreview.js","sources":["../../../../../src/FilePicker/primitives/components/previews/FilePreview.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { type VariantProps } from \"~/utils.js\";\nimport type { filePickerVariants } from \"~/FilePicker/index.js\";\nimport type { FilePreviewDefaultProps } from \"../types.js\";\nimport { RichItemPreview } from \"../previews/index.js\";\n\ntype FilePreviewProps = FilePreviewDefaultProps & {\n type: VariantProps<typeof filePickerVariants>[\"type\"];\n renderFilePreview?: (props: any) => React.ReactElement<any>;\n};\n\nconst FilePreview = ({ type, renderFilePreview, ...props }: FilePreviewProps) => {\n if (typeof renderFilePreview === \"function\") {\n return renderFilePreview({ type, ...props });\n }\n\n return <RichItemPreview {...props} />;\n};\n\nexport { FilePreview, type FilePreviewProps };\n"],"names":["FilePreview","type","renderFilePreview","props","RichItemPreview"],"mappings":";;AAWA,MAAMA,cAAc,CAAC,EAAEC,IAAI,EAAEC,iBAAiB,EAAE,GAAGC,OAAyB;IACxE,IAAI,AAA6B,cAA7B,OAAOD,mBACP,OAAOA,kBAAkB;QAAED;QAAM,GAAGE,KAAK;IAAC;IAG9C,OAAO,WAAP,GAAO,sCAACC,iBAAoBD;AAChC"}
@@ -1,7 +1,9 @@
1
1
  import { useEffect, useMemo, useState } from "react";
2
2
  import { autorun } from "mobx";
3
3
  import { FilePickerPresenter } from "./presenters/index.js";
4
+ import { useAdminUi } from "../../AdminUiProvider/index.js";
4
5
  const useFilePicker = (props)=>{
6
+ const { fileUrlFormatter } = useAdminUi();
5
7
  const params = useMemo(()=>({
6
8
  value: props.value
7
9
  }), [
@@ -19,8 +21,29 @@ const useFilePicker = (props)=>{
19
21
  }), [
20
22
  presenter
21
23
  ]);
24
+ const formattedVm = useMemo(()=>{
25
+ if (!vm.file) return vm;
26
+ try {
27
+ const url = new URL(vm.file.url);
28
+ fileUrlFormatter.format(url, {
29
+ width: 128
30
+ });
31
+ return {
32
+ ...vm,
33
+ file: {
34
+ ...vm.file,
35
+ url: url.toString()
36
+ }
37
+ };
38
+ } catch {
39
+ return vm;
40
+ }
41
+ }, [
42
+ vm,
43
+ fileUrlFormatter
44
+ ]);
22
45
  return {
23
- vm
46
+ vm: formattedVm
24
47
  };
25
48
  };
26
49
  export { useFilePicker };
@@ -1 +1 @@
1
- {"version":3,"file":"FilePicker/primitives/useFilePicker.js","sources":["../../../src/FilePicker/primitives/useFilePicker.ts"],"sourcesContent":["import { useEffect, useMemo, useState } from \"react\";\nimport { autorun } from \"mobx\";\nimport { FilePickerPresenter, type FilePickerPresenterParams } from \"./presenters/index.js\";\nimport type { FilePickerPrimitiveProps } from \"~/FilePicker/index.js\";\n\ntype IFilePickerPrimitiveProps = Pick<FilePickerPrimitiveProps, \"value\">;\n\nexport const useFilePicker = (props: IFilePickerPrimitiveProps) => {\n const params: FilePickerPresenterParams = useMemo(\n () => ({\n value: props.value\n }),\n [props.value]\n );\n\n const presenter = useMemo(() => {\n return new FilePickerPresenter();\n }, []);\n\n const [vm, setVm] = useState(presenter.vm);\n\n useEffect(() => {\n presenter.init(params);\n }, [params]);\n\n useEffect(() => {\n return autorun(() => {\n setVm(presenter.vm);\n });\n }, [presenter]);\n\n return {\n vm\n };\n};\n"],"names":["useFilePicker","props","params","useMemo","presenter","FilePickerPresenter","vm","setVm","useState","useEffect","autorun"],"mappings":";;;AAOO,MAAMA,gBAAgB,CAACC;IAC1B,MAAMC,SAAoCC,QACtC,IAAO;YACH,OAAOF,MAAM,KAAK;QACtB,IACA;QAACA,MAAM,KAAK;KAAC;IAGjB,MAAMG,YAAYD,QAAQ,IACf,IAAIE,uBACZ,EAAE;IAEL,MAAM,CAACC,IAAIC,MAAM,GAAGC,SAASJ,UAAU,EAAE;IAEzCK,UAAU;QACNL,UAAU,IAAI,CAACF;IACnB,GAAG;QAACA;KAAO;IAEXO,UAAU,IACCC,QAAQ;YACXH,MAAMH,UAAU,EAAE;QACtB,IACD;QAACA;KAAU;IAEd,OAAO;QACHE;IACJ;AACJ"}
1
+ {"version":3,"file":"FilePicker/primitives/useFilePicker.js","sources":["../../../src/FilePicker/primitives/useFilePicker.ts"],"sourcesContent":["import { useEffect, useMemo, useState } from \"react\";\nimport { autorun } from \"mobx\";\nimport { FilePickerPresenter, type FilePickerPresenterParams } from \"./presenters/index.js\";\nimport type { FilePickerPrimitiveProps } from \"~/FilePicker/index.js\";\nimport { useAdminUi } from \"~/AdminUiProvider/index.js\";\n\ntype IFilePickerPrimitiveProps = Pick<FilePickerPrimitiveProps, \"value\">;\n\nexport const useFilePicker = (props: IFilePickerPrimitiveProps) => {\n const { fileUrlFormatter } = useAdminUi();\n\n const params: FilePickerPresenterParams = useMemo(\n () => ({\n value: props.value\n }),\n [props.value]\n );\n\n const presenter = useMemo(() => {\n return new FilePickerPresenter();\n }, []);\n\n const [vm, setVm] = useState(presenter.vm);\n\n useEffect(() => {\n presenter.init(params);\n }, [params]);\n\n useEffect(() => {\n return autorun(() => {\n setVm(presenter.vm);\n });\n }, [presenter]);\n\n const formattedVm = useMemo(() => {\n if (!vm.file) {\n return vm;\n }\n try {\n const url = new URL(vm.file.url);\n fileUrlFormatter.format(url, { width: 128 });\n return { ...vm, file: { ...vm.file, url: url.toString() } };\n } catch {\n return vm;\n }\n }, [vm, fileUrlFormatter]);\n\n return {\n vm: formattedVm\n };\n};\n"],"names":["useFilePicker","props","fileUrlFormatter","useAdminUi","params","useMemo","presenter","FilePickerPresenter","vm","setVm","useState","useEffect","autorun","formattedVm","url","URL"],"mappings":";;;;AAQO,MAAMA,gBAAgB,CAACC;IAC1B,MAAM,EAAEC,gBAAgB,EAAE,GAAGC;IAE7B,MAAMC,SAAoCC,QACtC,IAAO;YACH,OAAOJ,MAAM,KAAK;QACtB,IACA;QAACA,MAAM,KAAK;KAAC;IAGjB,MAAMK,YAAYD,QAAQ,IACf,IAAIE,uBACZ,EAAE;IAEL,MAAM,CAACC,IAAIC,MAAM,GAAGC,SAASJ,UAAU,EAAE;IAEzCK,UAAU;QACNL,UAAU,IAAI,CAACF;IACnB,GAAG;QAACA;KAAO;IAEXO,UAAU,IACCC,QAAQ;YACXH,MAAMH,UAAU,EAAE;QACtB,IACD;QAACA;KAAU;IAEd,MAAMO,cAAcR,QAAQ;QACxB,IAAI,CAACG,GAAG,IAAI,EACR,OAAOA;QAEX,IAAI;YACA,MAAMM,MAAM,IAAIC,IAAIP,GAAG,IAAI,CAAC,GAAG;YAC/BN,iBAAiB,MAAM,CAACY,KAAK;gBAAE,OAAO;YAAI;YAC1C,OAAO;gBAAE,GAAGN,EAAE;gBAAE,MAAM;oBAAE,GAAGA,GAAG,IAAI;oBAAE,KAAKM,IAAI,QAAQ;gBAAG;YAAE;QAC9D,EAAE,OAAM;YACJ,OAAON;QACX;IACJ,GAAG;QAACA;QAAIN;KAAiB;IAEzB,OAAO;QACH,IAAIW;IACR;AACJ"}
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ import type { TimeAgoProps } from "./types.js";
3
+ export declare function TimeAgo({ datetime, live, opts, locale: _locale, ...rest }: TimeAgoProps): React.JSX.Element;
@@ -0,0 +1,45 @@
1
+ import react, { useEffect, useMemo, useState } from "react";
2
+ import { formatElapsed } from "./formatElapsed.js";
3
+ import { DEFAULT_INTERVALS, getUpdateDelay } from "./getUpdateDelay.js";
4
+ import { getElapsedSeconds } from "./getElapsedSeconds.js";
5
+ import { toISOString } from "./toISOString.js";
6
+ function TimeAgo({ datetime, live = true, opts, locale: _locale, ...rest }) {
7
+ const [, setTick] = useState(0);
8
+ const intervals = useMemo(()=>({
9
+ ...DEFAULT_INTERVALS,
10
+ ...opts?.updateIntervals
11
+ }), [
12
+ opts?.updateIntervals?.underFiveMinutes,
13
+ opts?.updateIntervals?.underFifteenMinutes,
14
+ opts?.updateIntervals?.underOneHour
15
+ ]);
16
+ useEffect(()=>{
17
+ if (!live) return;
18
+ let timer;
19
+ function schedule() {
20
+ const elapsed = getElapsedSeconds(datetime, opts?.relativeDate);
21
+ const delay = getUpdateDelay(elapsed, opts?.minInterval, intervals);
22
+ if (null === delay) return;
23
+ timer = setTimeout(()=>{
24
+ setTick((t)=>t + 1);
25
+ schedule();
26
+ }, delay);
27
+ }
28
+ schedule();
29
+ return ()=>clearTimeout(timer);
30
+ }, [
31
+ datetime,
32
+ live,
33
+ opts?.relativeDate,
34
+ opts?.minInterval,
35
+ intervals
36
+ ]);
37
+ const seconds = getElapsedSeconds(datetime, opts?.relativeDate);
38
+ return /*#__PURE__*/ react.createElement("time", {
39
+ dateTime: toISOString(datetime),
40
+ ...rest
41
+ }, formatElapsed(seconds));
42
+ }
43
+ export { TimeAgo };
44
+
45
+ //# sourceMappingURL=TimeAgo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimeAgo/TimeAgo.js","sources":["../../src/TimeAgo/TimeAgo.tsx"],"sourcesContent":["import React from \"react\";\nimport { useState, useEffect, useMemo } from \"react\";\nimport type { TimeAgoProps } from \"./types.js\";\nimport { formatElapsed } from \"./formatElapsed.js\";\nimport { DEFAULT_INTERVALS, getUpdateDelay } from \"./getUpdateDelay.js\";\nimport { getElapsedSeconds } from \"./getElapsedSeconds.js\";\nimport { toISOString } from \"./toISOString.js\";\n\nexport function TimeAgo({ datetime, live = true, opts, locale: _locale, ...rest }: TimeAgoProps) {\n const [, setTick] = useState(0);\n\n const intervals = useMemo(\n () => ({ ...DEFAULT_INTERVALS, ...opts?.updateIntervals }),\n [\n opts?.updateIntervals?.underFiveMinutes,\n opts?.updateIntervals?.underFifteenMinutes,\n opts?.updateIntervals?.underOneHour\n ]\n );\n\n useEffect(() => {\n if (!live) {\n return;\n }\n\n let timer: ReturnType<typeof setTimeout>;\n\n function schedule() {\n const elapsed = getElapsedSeconds(datetime, opts?.relativeDate);\n const delay = getUpdateDelay(elapsed, opts?.minInterval, intervals);\n if (delay === null) {\n return;\n }\n timer = setTimeout(() => {\n setTick(t => t + 1);\n schedule();\n }, delay);\n }\n\n schedule();\n\n return () => clearTimeout(timer);\n }, [datetime, live, opts?.relativeDate, opts?.minInterval, intervals]);\n\n const seconds = getElapsedSeconds(datetime, opts?.relativeDate);\n\n return (\n <time dateTime={toISOString(datetime)} {...rest}>\n {formatElapsed(seconds)}\n </time>\n );\n}\n"],"names":["TimeAgo","datetime","live","opts","_locale","rest","setTick","useState","intervals","useMemo","DEFAULT_INTERVALS","useEffect","timer","schedule","elapsed","getElapsedSeconds","delay","getUpdateDelay","setTimeout","t","clearTimeout","seconds","toISOString","formatElapsed"],"mappings":";;;;;AAQO,SAASA,QAAQ,EAAEC,QAAQ,EAAEC,OAAO,IAAI,EAAEC,IAAI,EAAE,QAAQC,OAAO,EAAE,GAAGC,MAAoB;IAC3F,MAAM,GAAGC,QAAQ,GAAGC,SAAS;IAE7B,MAAMC,YAAYC,QACd,IAAO;YAAE,GAAGC,iBAAiB;YAAE,GAAGP,MAAM,eAAe;QAAC,IACxD;QACIA,MAAM,iBAAiB;QACvBA,MAAM,iBAAiB;QACvBA,MAAM,iBAAiB;KAC1B;IAGLQ,UAAU;QACN,IAAI,CAACT,MACD;QAGJ,IAAIU;QAEJ,SAASC;YACL,MAAMC,UAAUC,kBAAkBd,UAAUE,MAAM;YAClD,MAAMa,QAAQC,eAAeH,SAASX,MAAM,aAAaK;YACzD,IAAIQ,AAAU,SAAVA,OACA;YAEJJ,QAAQM,WAAW;gBACfZ,QAAQa,CAAAA,IAAKA,IAAI;gBACjBN;YACJ,GAAGG;QACP;QAEAH;QAEA,OAAO,IAAMO,aAAaR;IAC9B,GAAG;QAACX;QAAUC;QAAMC,MAAM;QAAcA,MAAM;QAAaK;KAAU;IAErE,MAAMa,UAAUN,kBAAkBd,UAAUE,MAAM;IAElD,OAAO,WAAP,GACI,oBAAC;QAAK,UAAUmB,YAAYrB;QAAY,GAAGI,IAAI;OAC1CkB,cAAcF;AAG3B"}
@@ -0,0 +1,15 @@
1
+ import type { Meta, StoryObj } from "@storybook/react-webpack5";
2
+ import { TimeAgo } from "./TimeAgo.js";
3
+ declare const meta: Meta<typeof TimeAgo>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof TimeAgo>;
6
+ export declare const JustNow: Story;
7
+ export declare const SecondsAgo: Story;
8
+ export declare const MinutesAgo: Story;
9
+ export declare const HoursAgo: Story;
10
+ export declare const DaysAgo: Story;
11
+ export declare const WeeksAgo: Story;
12
+ export declare const MonthsAgo: Story;
13
+ export declare const YearsAgo: Story;
14
+ export declare const ISOString: Story;
15
+ export declare const NotLive: Story;
@@ -0,0 +1,71 @@
1
+ import "react";
2
+ import { TimeAgo } from "./TimeAgo.js";
3
+ const meta = {
4
+ title: "Components/TimeAgo",
5
+ component: TimeAgo
6
+ };
7
+ const TimeAgo_stories = meta;
8
+ const JustNow = {
9
+ args: {
10
+ datetime: new Date()
11
+ }
12
+ };
13
+ const SecondsAgo = {
14
+ name: "Seconds ago",
15
+ args: {
16
+ datetime: new Date(Date.now() - 45000)
17
+ }
18
+ };
19
+ const MinutesAgo = {
20
+ name: "Minutes ago",
21
+ args: {
22
+ datetime: new Date(Date.now() - 900000)
23
+ }
24
+ };
25
+ const HoursAgo = {
26
+ name: "Hours ago",
27
+ args: {
28
+ datetime: new Date(Date.now() - 10800000)
29
+ }
30
+ };
31
+ const DaysAgo = {
32
+ name: "Days ago",
33
+ args: {
34
+ datetime: new Date(Date.now() - 432000000)
35
+ }
36
+ };
37
+ const WeeksAgo = {
38
+ name: "Weeks ago",
39
+ args: {
40
+ datetime: new Date(Date.now() - 1814400000)
41
+ }
42
+ };
43
+ const MonthsAgo = {
44
+ name: "Months ago",
45
+ args: {
46
+ datetime: new Date(Date.now() - 10368000000)
47
+ }
48
+ };
49
+ const YearsAgo = {
50
+ name: "Years ago",
51
+ args: {
52
+ datetime: new Date(Date.now() - 63072000000)
53
+ }
54
+ };
55
+ const ISOString = {
56
+ name: "From ISO string",
57
+ args: {
58
+ datetime: "2024-01-15T12:00:00Z"
59
+ }
60
+ };
61
+ const NotLive = {
62
+ name: "Live updates disabled",
63
+ args: {
64
+ datetime: new Date(),
65
+ live: false
66
+ }
67
+ };
68
+ export default TimeAgo_stories;
69
+ export { DaysAgo, HoursAgo, ISOString, JustNow, MinutesAgo, MonthsAgo, NotLive, SecondsAgo, WeeksAgo, YearsAgo };
70
+
71
+ //# sourceMappingURL=TimeAgo.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimeAgo/TimeAgo.stories.js","sources":["../../src/TimeAgo/TimeAgo.stories.tsx"],"sourcesContent":["import React from \"react\";\nimport type { Meta, StoryObj } from \"@storybook/react-webpack5\";\nimport { TimeAgo } from \"./TimeAgo.js\";\n\nconst meta: Meta<typeof TimeAgo> = {\n title: \"Components/TimeAgo\",\n component: TimeAgo\n};\n\nexport default meta;\n\ntype Story = StoryObj<typeof TimeAgo>;\n\nexport const JustNow: Story = {\n args: {\n datetime: new Date()\n }\n};\n\nexport const SecondsAgo: Story = {\n name: \"Seconds ago\",\n args: {\n datetime: new Date(Date.now() - 45 * 1000)\n }\n};\n\nexport const MinutesAgo: Story = {\n name: \"Minutes ago\",\n args: {\n datetime: new Date(Date.now() - 15 * 60 * 1000)\n }\n};\n\nexport const HoursAgo: Story = {\n name: \"Hours ago\",\n args: {\n datetime: new Date(Date.now() - 3 * 60 * 60 * 1000)\n }\n};\n\nexport const DaysAgo: Story = {\n name: \"Days ago\",\n args: {\n datetime: new Date(Date.now() - 5 * 24 * 60 * 60 * 1000)\n }\n};\n\nexport const WeeksAgo: Story = {\n name: \"Weeks ago\",\n args: {\n datetime: new Date(Date.now() - 3 * 7 * 24 * 60 * 60 * 1000)\n }\n};\n\nexport const MonthsAgo: Story = {\n name: \"Months ago\",\n args: {\n datetime: new Date(Date.now() - 4 * 30 * 24 * 60 * 60 * 1000)\n }\n};\n\nexport const YearsAgo: Story = {\n name: \"Years ago\",\n args: {\n datetime: new Date(Date.now() - 2 * 365 * 24 * 60 * 60 * 1000)\n }\n};\n\nexport const ISOString: Story = {\n name: \"From ISO string\",\n args: {\n datetime: \"2024-01-15T12:00:00Z\"\n }\n};\n\nexport const NotLive: Story = {\n name: \"Live updates disabled\",\n args: {\n datetime: new Date(),\n live: false\n }\n};\n"],"names":["meta","TimeAgo","JustNow","Date","SecondsAgo","MinutesAgo","HoursAgo","DaysAgo","WeeksAgo","MonthsAgo","YearsAgo","ISOString","NotLive"],"mappings":";;AAIA,MAAMA,OAA6B;IAC/B,OAAO;IACP,WAAWC;AACf;AAEA,wBAAeD;AAIR,MAAME,UAAiB;IAC1B,MAAM;QACF,UAAU,IAAIC;IAClB;AACJ;AAEO,MAAMC,aAAoB;IAC7B,MAAM;IACN,MAAM;QACF,UAAU,IAAID,KAAKA,KAAK,GAAG,KAAK;IACpC;AACJ;AAEO,MAAME,aAAoB;IAC7B,MAAM;IACN,MAAM;QACF,UAAU,IAAIF,KAAKA,KAAK,GAAG,KAAK;IACpC;AACJ;AAEO,MAAMG,WAAkB;IAC3B,MAAM;IACN,MAAM;QACF,UAAU,IAAIH,KAAKA,KAAK,GAAG,KAAK;IACpC;AACJ;AAEO,MAAMI,UAAiB;IAC1B,MAAM;IACN,MAAM;QACF,UAAU,IAAIJ,KAAKA,KAAK,GAAG,KAAK;IACpC;AACJ;AAEO,MAAMK,WAAkB;IAC3B,MAAM;IACN,MAAM;QACF,UAAU,IAAIL,KAAKA,KAAK,GAAG,KAAK;IACpC;AACJ;AAEO,MAAMM,YAAmB;IAC5B,MAAM;IACN,MAAM;QACF,UAAU,IAAIN,KAAKA,KAAK,GAAG,KAAK;IACpC;AACJ;AAEO,MAAMO,WAAkB;IAC3B,MAAM;IACN,MAAM;QACF,UAAU,IAAIP,KAAKA,KAAK,GAAG,KAAK;IACpC;AACJ;AAEO,MAAMQ,YAAmB;IAC5B,MAAM;IACN,MAAM;QACF,UAAU;IACd;AACJ;AAEO,MAAMC,UAAiB;IAC1B,MAAM;IACN,MAAM;QACF,UAAU,IAAIT;QACd,MAAM;IACV;AACJ"}
@@ -0,0 +1 @@
1
+ export declare function formatElapsed(seconds: number): string;
@@ -0,0 +1,27 @@
1
+ const MINUTE = 60;
2
+ const HOUR = 3600;
3
+ const DAY = 86400;
4
+ const WEEK = 604800;
5
+ const MONTH = 2592000;
6
+ const YEAR = 31536000;
7
+ function formatElapsed(seconds) {
8
+ const abs = Math.abs(seconds);
9
+ const suffix = seconds < 0 ? "from now" : "ago";
10
+ if (abs < 30) return "just now";
11
+ if (abs < MINUTE) return `${abs} seconds ${suffix}`;
12
+ if (abs < 2 * MINUTE) return `1 minute ${suffix}`;
13
+ if (abs < HOUR) return `${Math.floor(abs / MINUTE)} minutes ${suffix}`;
14
+ if (abs < 2 * HOUR) return `1 hour ${suffix}`;
15
+ if (abs < DAY) return `${Math.floor(abs / HOUR)} hours ${suffix}`;
16
+ if (abs < 2 * DAY) return `1 day ${suffix}`;
17
+ if (abs < WEEK) return `${Math.floor(abs / DAY)} days ${suffix}`;
18
+ if (abs < 2 * WEEK) return `1 week ${suffix}`;
19
+ if (abs < MONTH) return `${Math.floor(abs / WEEK)} weeks ${suffix}`;
20
+ if (abs < 2 * MONTH) return `1 month ${suffix}`;
21
+ if (abs < YEAR) return `${Math.floor(abs / MONTH)} months ${suffix}`;
22
+ if (abs < 2 * YEAR) return `1 year ${suffix}`;
23
+ return `${Math.floor(abs / YEAR)} years ${suffix}`;
24
+ }
25
+ export { formatElapsed };
26
+
27
+ //# sourceMappingURL=formatElapsed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimeAgo/formatElapsed.js","sources":["../../src/TimeAgo/formatElapsed.ts"],"sourcesContent":["const MINUTE = 60;\nconst HOUR = 3600;\nconst DAY = 86400;\nconst WEEK = 604800;\nconst MONTH = 2_592_000;\nconst YEAR = 31_536_000;\n\nexport function formatElapsed(seconds: number): string {\n const abs = Math.abs(seconds);\n const suffix = seconds < 0 ? \"from now\" : \"ago\";\n\n if (abs < 30) {\n return \"just now\";\n }\n if (abs < MINUTE) {\n return `${abs} seconds ${suffix}`;\n }\n if (abs < 2 * MINUTE) {\n return `1 minute ${suffix}`;\n }\n if (abs < HOUR) {\n return `${Math.floor(abs / MINUTE)} minutes ${suffix}`;\n }\n if (abs < 2 * HOUR) {\n return `1 hour ${suffix}`;\n }\n if (abs < DAY) {\n return `${Math.floor(abs / HOUR)} hours ${suffix}`;\n }\n if (abs < 2 * DAY) {\n return `1 day ${suffix}`;\n }\n if (abs < WEEK) {\n return `${Math.floor(abs / DAY)} days ${suffix}`;\n }\n if (abs < 2 * WEEK) {\n return `1 week ${suffix}`;\n }\n if (abs < MONTH) {\n return `${Math.floor(abs / WEEK)} weeks ${suffix}`;\n }\n if (abs < 2 * MONTH) {\n return `1 month ${suffix}`;\n }\n if (abs < YEAR) {\n return `${Math.floor(abs / MONTH)} months ${suffix}`;\n }\n if (abs < 2 * YEAR) {\n return `1 year ${suffix}`;\n }\n return `${Math.floor(abs / YEAR)} years ${suffix}`;\n}\n"],"names":["MINUTE","HOUR","DAY","WEEK","MONTH","YEAR","formatElapsed","seconds","abs","Math","suffix"],"mappings":"AAAA,MAAMA,SAAS;AACf,MAAMC,OAAO;AACb,MAAMC,MAAM;AACZ,MAAMC,OAAO;AACb,MAAMC,QAAQ;AACd,MAAMC,OAAO;AAEN,SAASC,cAAcC,OAAe;IACzC,MAAMC,MAAMC,KAAK,GAAG,CAACF;IACrB,MAAMG,SAASH,UAAU,IAAI,aAAa;IAE1C,IAAIC,MAAM,IACN,OAAO;IAEX,IAAIA,MAAMR,QACN,OAAO,GAAGQ,IAAI,SAAS,EAAEE,QAAQ;IAErC,IAAIF,MAAM,IAAIR,QACV,OAAO,CAAC,SAAS,EAAEU,QAAQ;IAE/B,IAAIF,MAAMP,MACN,OAAO,GAAGQ,KAAK,KAAK,CAACD,MAAMR,QAAQ,SAAS,EAAEU,QAAQ;IAE1D,IAAIF,MAAM,IAAIP,MACV,OAAO,CAAC,OAAO,EAAES,QAAQ;IAE7B,IAAIF,MAAMN,KACN,OAAO,GAAGO,KAAK,KAAK,CAACD,MAAMP,MAAM,OAAO,EAAES,QAAQ;IAEtD,IAAIF,MAAM,IAAIN,KACV,OAAO,CAAC,MAAM,EAAEQ,QAAQ;IAE5B,IAAIF,MAAML,MACN,OAAO,GAAGM,KAAK,KAAK,CAACD,MAAMN,KAAK,MAAM,EAAEQ,QAAQ;IAEpD,IAAIF,MAAM,IAAIL,MACV,OAAO,CAAC,OAAO,EAAEO,QAAQ;IAE7B,IAAIF,MAAMJ,OACN,OAAO,GAAGK,KAAK,KAAK,CAACD,MAAML,MAAM,OAAO,EAAEO,QAAQ;IAEtD,IAAIF,MAAM,IAAIJ,OACV,OAAO,CAAC,QAAQ,EAAEM,QAAQ;IAE9B,IAAIF,MAAMH,MACN,OAAO,GAAGI,KAAK,KAAK,CAACD,MAAMJ,OAAO,QAAQ,EAAEM,QAAQ;IAExD,IAAIF,MAAM,IAAIH,MACV,OAAO,CAAC,OAAO,EAAEK,QAAQ;IAE7B,OAAO,GAAGD,KAAK,KAAK,CAACD,MAAMH,MAAM,OAAO,EAAEK,QAAQ;AACtD"}
@@ -0,0 +1,2 @@
1
+ import type { TDate } from "./types.js";
2
+ export declare function getElapsedSeconds(datetime: TDate, relativeDate?: TDate): number;
@@ -0,0 +1,9 @@
1
+ import { toEpochMs } from "./toEpochMs.js";
2
+ function getElapsedSeconds(datetime, relativeDate) {
3
+ const now = relativeDate ? Temporal.Instant.fromEpochMilliseconds(toEpochMs(relativeDate)) : Temporal.Now.instant();
4
+ const past = Temporal.Instant.fromEpochMilliseconds(toEpochMs(datetime));
5
+ return Math.round(now.since(past).total("second"));
6
+ }
7
+ export { getElapsedSeconds };
8
+
9
+ //# sourceMappingURL=getElapsedSeconds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimeAgo/getElapsedSeconds.js","sources":["../../src/TimeAgo/getElapsedSeconds.ts"],"sourcesContent":["import type { TDate } from \"./types.js\";\nimport { toEpochMs } from \"./toEpochMs.js\";\n\nexport function getElapsedSeconds(datetime: TDate, relativeDate?: TDate): number {\n const now = relativeDate\n ? Temporal.Instant.fromEpochMilliseconds(toEpochMs(relativeDate))\n : Temporal.Now.instant();\n const past = Temporal.Instant.fromEpochMilliseconds(toEpochMs(datetime));\n return Math.round(now.since(past).total(\"second\"));\n}\n"],"names":["getElapsedSeconds","datetime","relativeDate","now","Temporal","toEpochMs","past","Math"],"mappings":";AAGO,SAASA,kBAAkBC,QAAe,EAAEC,YAAoB;IACnE,MAAMC,MAAMD,eACNE,SAAS,OAAO,CAAC,qBAAqB,CAACC,UAAUH,iBACjDE,SAAS,GAAG,CAAC,OAAO;IAC1B,MAAME,OAAOF,SAAS,OAAO,CAAC,qBAAqB,CAACC,UAAUJ;IAC9D,OAAOM,KAAK,KAAK,CAACJ,IAAI,KAAK,CAACG,MAAM,KAAK,CAAC;AAC5C"}
@@ -0,0 +1,3 @@
1
+ import type { UpdateIntervals } from "./types.js";
2
+ export declare const DEFAULT_INTERVALS: Required<UpdateIntervals>;
3
+ export declare function getUpdateDelay(seconds: number, minInterval?: number, intervals?: Required<UpdateIntervals>): number | null;
@@ -0,0 +1,24 @@
1
+ const MINUTE = 60;
2
+ const HOUR = 3600;
3
+ const FIVE_MINUTES = 5 * MINUTE;
4
+ const FIFTEEN_MINUTES = 15 * MINUTE;
5
+ const DEFAULT_INTERVALS = {
6
+ underFiveMinutes: 1000,
7
+ underFifteenMinutes: 10000,
8
+ underOneHour: 30000
9
+ };
10
+ function getUpdateDelay(seconds, minInterval, intervals = DEFAULT_INTERVALS) {
11
+ const abs = Math.abs(seconds);
12
+ let delay;
13
+ if (abs < FIVE_MINUTES) delay = intervals.underFiveMinutes;
14
+ else if (abs < FIFTEEN_MINUTES) delay = intervals.underFifteenMinutes;
15
+ else {
16
+ if (!(abs < HOUR)) return null;
17
+ delay = intervals.underOneHour;
18
+ }
19
+ if (minInterval) delay = Math.max(delay, 1000 * minInterval);
20
+ return delay;
21
+ }
22
+ export { DEFAULT_INTERVALS, getUpdateDelay };
23
+
24
+ //# sourceMappingURL=getUpdateDelay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimeAgo/getUpdateDelay.js","sources":["../../src/TimeAgo/getUpdateDelay.ts"],"sourcesContent":["import type { UpdateIntervals } from \"./types.js\";\n\nconst MINUTE = 60;\nconst HOUR = 3600;\nconst FIVE_MINUTES = 5 * MINUTE;\nconst FIFTEEN_MINUTES = 15 * MINUTE;\n\nexport const DEFAULT_INTERVALS: Required<UpdateIntervals> = {\n underFiveMinutes: 1_000,\n underFifteenMinutes: 10_000,\n underOneHour: 30_000\n};\n\nexport function getUpdateDelay(\n seconds: number,\n minInterval?: number,\n intervals: Required<UpdateIntervals> = DEFAULT_INTERVALS\n): number | null {\n const abs = Math.abs(seconds);\n let delay: number;\n\n if (abs < FIVE_MINUTES) {\n delay = intervals.underFiveMinutes;\n } else if (abs < FIFTEEN_MINUTES) {\n delay = intervals.underFifteenMinutes;\n } else if (abs < HOUR) {\n delay = intervals.underOneHour;\n } else {\n return null;\n }\n\n if (minInterval) {\n delay = Math.max(delay, minInterval * 1000);\n }\n\n return delay;\n}\n"],"names":["MINUTE","HOUR","FIVE_MINUTES","FIFTEEN_MINUTES","DEFAULT_INTERVALS","getUpdateDelay","seconds","minInterval","intervals","abs","Math","delay"],"mappings":"AAEA,MAAMA,SAAS;AACf,MAAMC,OAAO;AACb,MAAMC,eAAe,IAAIF;AACzB,MAAMG,kBAAkB,KAAKH;AAEtB,MAAMI,oBAA+C;IACxD,kBAAkB;IAClB,qBAAqB;IACrB,cAAc;AAClB;AAEO,SAASC,eACZC,OAAe,EACfC,WAAoB,EACpBC,YAAuCJ,iBAAiB;IAExD,MAAMK,MAAMC,KAAK,GAAG,CAACJ;IACrB,IAAIK;IAEJ,IAAIF,MAAMP,cACNS,QAAQH,UAAU,gBAAgB;SAC/B,IAAIC,MAAMN,iBACbQ,QAAQH,UAAU,mBAAmB;;QAClC,KAAIC,CAAAA,MAAMR,IAAG,GAGhB,OAAO;QAFPU,QAAQH,UAAU,YAAY;;IAKlC,IAAID,aACAI,QAAQD,KAAK,GAAG,CAACC,OAAOJ,AAAc,OAAdA;IAG5B,OAAOI;AACX"}
@@ -1,3 +1,2 @@
1
- import TimeAgo from "timeago-react";
2
- export type { TimeAgoProps, Opts, TDate } from "timeago-react";
3
- export { TimeAgo };
1
+ export type { TimeAgoProps, Opts, TDate, UpdateIntervals } from "./types.js";
2
+ export { TimeAgo } from "./TimeAgo.js";
package/TimeAgo/index.js CHANGED
@@ -1 +1 @@
1
- export { default as TimeAgo } from "timeago-react";
1
+ export { TimeAgo } from "./TimeAgo.js";
@@ -0,0 +1,2 @@
1
+ import type { TDate } from "./types.js";
2
+ export declare function toEpochMs(date: TDate): number;
@@ -0,0 +1,8 @@
1
+ function toEpochMs(date) {
2
+ if (date instanceof Date) return date.getTime();
3
+ if ("number" == typeof date) return date;
4
+ return new Date(date).getTime();
5
+ }
6
+ export { toEpochMs };
7
+
8
+ //# sourceMappingURL=toEpochMs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimeAgo/toEpochMs.js","sources":["../../src/TimeAgo/toEpochMs.ts"],"sourcesContent":["import type { TDate } from \"./types.js\";\n\nexport function toEpochMs(date: TDate): number {\n if (date instanceof Date) {\n return date.getTime();\n }\n if (typeof date === \"number\") {\n return date;\n }\n return new Date(date).getTime();\n}\n"],"names":["toEpochMs","date","Date"],"mappings":"AAEO,SAASA,UAAUC,IAAW;IACjC,IAAIA,gBAAgBC,MAChB,OAAOD,KAAK,OAAO;IAEvB,IAAI,AAAgB,YAAhB,OAAOA,MACP,OAAOA;IAEX,OAAO,IAAIC,KAAKD,MAAM,OAAO;AACjC"}
@@ -0,0 +1,2 @@
1
+ import type { TDate } from "./types.js";
2
+ export declare function toISOString(date: TDate): string;
@@ -0,0 +1,8 @@
1
+ function toISOString(date) {
2
+ if (date instanceof Date) return date.toISOString();
3
+ if ("number" == typeof date) return new Date(date).toISOString();
4
+ return date;
5
+ }
6
+ export { toISOString };
7
+
8
+ //# sourceMappingURL=toISOString.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimeAgo/toISOString.js","sources":["../../src/TimeAgo/toISOString.ts"],"sourcesContent":["import type { TDate } from \"./types.js\";\n\nexport function toISOString(date: TDate): string {\n if (date instanceof Date) {\n return date.toISOString();\n }\n if (typeof date === \"number\") {\n return new Date(date).toISOString();\n }\n return date;\n}\n"],"names":["toISOString","date","Date"],"mappings":"AAEO,SAASA,YAAYC,IAAW;IACnC,IAAIA,gBAAgBC,MAChB,OAAOD,KAAK,WAAW;IAE3B,IAAI,AAAgB,YAAhB,OAAOA,MACP,OAAO,IAAIC,KAAKD,MAAM,WAAW;IAErC,OAAOA;AACX"}
@@ -0,0 +1,18 @@
1
+ import type { ComponentProps } from "react";
2
+ export type TDate = Date | string | number;
3
+ export interface UpdateIntervals {
4
+ readonly underFiveMinutes?: number;
5
+ readonly underFifteenMinutes?: number;
6
+ readonly underOneHour?: number;
7
+ }
8
+ export interface Opts {
9
+ readonly relativeDate?: TDate;
10
+ readonly minInterval?: number;
11
+ readonly updateIntervals?: UpdateIntervals;
12
+ }
13
+ export interface TimeAgoProps extends ComponentProps<"time"> {
14
+ readonly datetime: TDate;
15
+ readonly live?: boolean;
16
+ readonly opts?: Opts;
17
+ readonly locale?: string;
18
+ }
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/admin-ui",
3
- "version": "6.4.0-beta.2",
3
+ "version": "6.4.0-beta.3",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -15,13 +15,13 @@
15
15
  "dependencies": {
16
16
  "@fortawesome/fontawesome-svg-core": "7.2.0",
17
17
  "@fortawesome/react-fontawesome": "3.3.1",
18
- "@minoru/react-dnd-treeview": "3.5.3",
18
+ "@minoru/react-dnd-treeview": "3.5.4",
19
19
  "@monaco-editor/react": "4.7.0",
20
20
  "@radix-ui/react-scroll-area": "1.2.10",
21
21
  "@tanstack/react-table": "8.21.3",
22
- "@webiny/icons": "6.4.0-beta.2",
23
- "@webiny/react-composition": "6.4.0-beta.2",
24
- "@webiny/utils": "6.4.0-beta.2",
22
+ "@webiny/icons": "6.4.0-beta.3",
23
+ "@webiny/react-composition": "6.4.0-beta.3",
24
+ "@webiny/utils": "6.4.0-beta.3",
25
25
  "bytes": "3.1.2",
26
26
  "class-variance-authority": "0.7.1",
27
27
  "clsx": "2.1.1",
@@ -41,7 +41,6 @@
41
41
  "sonner": "2.0.7",
42
42
  "tailwind-merge": "2.6.1",
43
43
  "tailwindcss": "4.3.0",
44
- "timeago-react": "3.0.7",
45
44
  "tw-animate-css": "1.4.0",
46
45
  "type-fest": "5.6.0"
47
46
  },
@@ -49,7 +48,7 @@
49
48
  "@fortawesome/free-solid-svg-icons": "7.2.0",
50
49
  "@storybook/addon-a11y": "10.4.0",
51
50
  "@storybook/addon-docs": "10.4.0",
52
- "@storybook/addon-webpack5-compiler-babel": "4.0.1",
51
+ "@storybook/addon-webpack5-compiler-swc": "4.0.3",
53
52
  "@storybook/react-webpack5": "10.4.0",
54
53
  "@svgr/webpack": "8.1.0",
55
54
  "@tailwindcss/postcss": "4.3.0",
@@ -57,12 +56,12 @@
57
56
  "@types/react-color": "3.0.13",
58
57
  "@types/react-custom-scrollbars": "4.0.13",
59
58
  "@types/react-virtualized": "9.22.3",
60
- "@webiny/build-tools": "6.4.0-beta.2",
61
- "@webiny/project": "6.4.0-beta.2",
59
+ "@webiny/build-tools": "6.4.0-beta.3",
60
+ "@webiny/project": "6.4.0-beta.3",
62
61
  "chalk": "5.6.2",
63
62
  "css-loader": "7.1.4",
64
63
  "file-loader": "6.2.0",
65
- "oxfmt": "0.49.0",
64
+ "oxfmt": "0.51.0",
66
65
  "postcss-loader": "8.2.1",
67
66
  "rimraf": "6.1.3",
68
67
  "sass": "1.99.0",
@@ -88,5 +87,5 @@
88
87
  ]
89
88
  }
90
89
  },
91
- "gitHead": "872f9f50baa1ff6915a5f338216f84bf0b6dfd24"
90
+ "gitHead": "2e58681d4344024bfb60e6180338e2f154ec87f0"
92
91
  }