@shipfox/react-ui 0.0.1

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 (224) hide show
  1. package/.storybook/main.ts +18 -0
  2. package/.storybook/preview.tsx +48 -0
  3. package/.turbo/turbo-build.log +6 -0
  4. package/.turbo/turbo-check.log +6 -0
  5. package/.turbo/turbo-type.log +5 -0
  6. package/CHANGELOG.md +7 -0
  7. package/LICENSE +21 -0
  8. package/dist/colors.stories.conts.d.ts +33 -0
  9. package/dist/colors.stories.conts.d.ts.map +1 -0
  10. package/dist/colors.stories.conts.js +166 -0
  11. package/dist/colors.stories.conts.js.map +1 -0
  12. package/dist/colors.stories.js +61 -0
  13. package/dist/colors.stories.js.map +1 -0
  14. package/dist/components/button.d.ts +13 -0
  15. package/dist/components/button.d.ts.map +1 -0
  16. package/dist/components/button.js +51 -0
  17. package/dist/components/button.js.map +1 -0
  18. package/dist/components/button.stories.js +174 -0
  19. package/dist/components/button.stories.js.map +1 -0
  20. package/dist/components/icon/custom/badge.d.ts +4 -0
  21. package/dist/components/icon/custom/badge.d.ts.map +1 -0
  22. package/dist/components/icon/custom/badge.js +20 -0
  23. package/dist/components/icon/custom/badge.js.map +1 -0
  24. package/dist/components/icon/custom/check-circle-solid.d.ts +4 -0
  25. package/dist/components/icon/custom/check-circle-solid.d.ts.map +1 -0
  26. package/dist/components/icon/custom/check-circle-solid.js +34 -0
  27. package/dist/components/icon/custom/check-circle-solid.js.map +1 -0
  28. package/dist/components/icon/custom/circle-dotted-line.d.ts +4 -0
  29. package/dist/components/icon/custom/circle-dotted-line.d.ts.map +1 -0
  30. package/dist/components/icon/custom/circle-dotted-line.js +20 -0
  31. package/dist/components/icon/custom/circle-dotted-line.js.map +1 -0
  32. package/dist/components/icon/custom/component-fill.d.ts +4 -0
  33. package/dist/components/icon/custom/component-fill.d.ts.map +1 -0
  34. package/dist/components/icon/custom/component-fill.js +20 -0
  35. package/dist/components/icon/custom/component-fill.js.map +1 -0
  36. package/dist/components/icon/custom/component-line.d.ts +4 -0
  37. package/dist/components/icon/custom/component-line.d.ts.map +1 -0
  38. package/dist/components/icon/custom/component-line.js +20 -0
  39. package/dist/components/icon/custom/component-line.js.map +1 -0
  40. package/dist/components/icon/custom/ellipse-mini-solid.d.ts +4 -0
  41. package/dist/components/icon/custom/ellipse-mini-solid.d.ts.map +1 -0
  42. package/dist/components/icon/custom/ellipse-mini-solid.js +22 -0
  43. package/dist/components/icon/custom/ellipse-mini-solid.js.map +1 -0
  44. package/dist/components/icon/custom/index.d.ts +12 -0
  45. package/dist/components/icon/custom/index.d.ts.map +1 -0
  46. package/dist/components/icon/custom/index.js +13 -0
  47. package/dist/components/icon/custom/index.js.map +1 -0
  48. package/dist/components/icon/custom/info-tooltip-fill.d.ts +4 -0
  49. package/dist/components/icon/custom/info-tooltip-fill.d.ts.map +1 -0
  50. package/dist/components/icon/custom/info-tooltip-fill.js +22 -0
  51. package/dist/components/icon/custom/info-tooltip-fill.js.map +1 -0
  52. package/dist/components/icon/custom/resize.d.ts +4 -0
  53. package/dist/components/icon/custom/resize.d.ts.map +1 -0
  54. package/dist/components/icon/custom/resize.js +20 -0
  55. package/dist/components/icon/custom/resize.js.map +1 -0
  56. package/dist/components/icon/custom/spinner.d.ts +4 -0
  57. package/dist/components/icon/custom/spinner.d.ts.map +1 -0
  58. package/dist/components/icon/custom/spinner.js +145 -0
  59. package/dist/components/icon/custom/spinner.js.map +1 -0
  60. package/dist/components/icon/custom/thunder.d.ts +4 -0
  61. package/dist/components/icon/custom/thunder.d.ts.map +1 -0
  62. package/dist/components/icon/custom/thunder.js +20 -0
  63. package/dist/components/icon/custom/thunder.js.map +1 -0
  64. package/dist/components/icon/custom/x-circle-solid.d.ts +4 -0
  65. package/dist/components/icon/custom/x-circle-solid.d.ts.map +1 -0
  66. package/dist/components/icon/custom/x-circle-solid.js +34 -0
  67. package/dist/components/icon/custom/x-circle-solid.js.map +1 -0
  68. package/dist/components/icon/icon.d.ts +27 -0
  69. package/dist/components/icon/icon.d.ts.map +1 -0
  70. package/dist/components/icon/icon.js +27 -0
  71. package/dist/components/icon/icon.js.map +1 -0
  72. package/dist/components/icon/icon.stories.js +35 -0
  73. package/dist/components/icon/icon.stories.js.map +1 -0
  74. package/dist/components/icon/index.d.ts +2 -0
  75. package/dist/components/icon/index.d.ts.map +1 -0
  76. package/dist/components/icon/index.js +3 -0
  77. package/dist/components/icon/index.js.map +1 -0
  78. package/dist/components/index.d.ts +5 -0
  79. package/dist/components/index.d.ts.map +1 -0
  80. package/dist/components/index.js +6 -0
  81. package/dist/components/index.js.map +1 -0
  82. package/dist/components/theme-provider.d.ts +10 -0
  83. package/dist/components/theme-provider.d.ts.map +1 -0
  84. package/dist/components/theme-provider.js +32 -0
  85. package/dist/components/theme-provider.js.map +1 -0
  86. package/dist/components/typography/code.d.ts +11 -0
  87. package/dist/components/typography/code.d.ts.map +1 -0
  88. package/dist/components/typography/code.js +28 -0
  89. package/dist/components/typography/code.js.map +1 -0
  90. package/dist/components/typography/code.stories.js +54 -0
  91. package/dist/components/typography/code.stories.js.map +1 -0
  92. package/dist/components/typography/header.d.ts +10 -0
  93. package/dist/components/typography/header.d.ts.map +1 -0
  94. package/dist/components/typography/header.js +34 -0
  95. package/dist/components/typography/header.js.map +1 -0
  96. package/dist/components/typography/header.stories.js +34 -0
  97. package/dist/components/typography/header.stories.js.map +1 -0
  98. package/dist/components/typography/index.d.ts +4 -0
  99. package/dist/components/typography/index.d.ts.map +1 -0
  100. package/dist/components/typography/index.js +5 -0
  101. package/dist/components/typography/index.js.map +1 -0
  102. package/dist/components/typography/text.d.ts +12 -0
  103. package/dist/components/typography/text.d.ts.map +1 -0
  104. package/dist/components/typography/text.js +32 -0
  105. package/dist/components/typography/text.js.map +1 -0
  106. package/dist/components/typography/text.stories.js +105 -0
  107. package/dist/components/typography/text.stories.js.map +1 -0
  108. package/dist/hooks/index.d.ts +3 -0
  109. package/dist/hooks/index.d.ts.map +1 -0
  110. package/dist/hooks/index.js +4 -0
  111. package/dist/hooks/index.js.map +1 -0
  112. package/dist/hooks/useCopy.d.ts +1 -0
  113. package/dist/hooks/useCopy.d.ts.map +1 -0
  114. package/dist/hooks/useCopy.js +2 -0
  115. package/dist/hooks/useCopy.js.map +1 -0
  116. package/dist/hooks/useCopyToClipboard.d.ts +10 -0
  117. package/dist/hooks/useCopyToClipboard.d.ts.map +1 -0
  118. package/dist/hooks/useCopyToClipboard.js +16 -0
  119. package/dist/hooks/useCopyToClipboard.js.map +1 -0
  120. package/dist/hooks/useTheme.d.ts +2 -0
  121. package/dist/hooks/useTheme.d.ts.map +1 -0
  122. package/dist/hooks/useTheme.js +9 -0
  123. package/dist/hooks/useTheme.js.map +1 -0
  124. package/dist/index.d.ts +4 -0
  125. package/dist/index.d.ts.map +1 -0
  126. package/dist/index.js +5 -0
  127. package/dist/index.js.map +1 -0
  128. package/dist/state/theme.d.ts +7 -0
  129. package/dist/state/theme.d.ts.map +1 -0
  130. package/dist/state/theme.js +8 -0
  131. package/dist/state/theme.js.map +1 -0
  132. package/dist/utils/clipboard.d.ts +2 -0
  133. package/dist/utils/clipboard.d.ts.map +1 -0
  134. package/dist/utils/clipboard.js +6 -0
  135. package/dist/utils/clipboard.js.map +1 -0
  136. package/dist/utils/cn.d.ts +3 -0
  137. package/dist/utils/cn.d.ts.map +1 -0
  138. package/dist/utils/cn.js +7 -0
  139. package/dist/utils/cn.js.map +1 -0
  140. package/dist/utils/date.d.ts +16 -0
  141. package/dist/utils/date.d.ts.map +1 -0
  142. package/dist/utils/date.js +79 -0
  143. package/dist/utils/date.js.map +1 -0
  144. package/dist/utils/format/chart.d.ts +3 -0
  145. package/dist/utils/format/chart.d.ts.map +1 -0
  146. package/dist/utils/format/chart.js +14 -0
  147. package/dist/utils/format/chart.js.map +1 -0
  148. package/dist/utils/format/date.d.ts +10 -0
  149. package/dist/utils/format/date.d.ts.map +1 -0
  150. package/dist/utils/format/date.js +57 -0
  151. package/dist/utils/format/date.js.map +1 -0
  152. package/dist/utils/format/duration.d.ts +9 -0
  153. package/dist/utils/format/duration.d.ts.map +1 -0
  154. package/dist/utils/format/duration.js +71 -0
  155. package/dist/utils/format/duration.js.map +1 -0
  156. package/dist/utils/format/index.d.ts +5 -0
  157. package/dist/utils/format/index.d.ts.map +1 -0
  158. package/dist/utils/format/index.js +6 -0
  159. package/dist/utils/format/index.js.map +1 -0
  160. package/dist/utils/format/number.d.ts +7 -0
  161. package/dist/utils/format/number.d.ts.map +1 -0
  162. package/dist/utils/format/number.js +20 -0
  163. package/dist/utils/format/number.js.map +1 -0
  164. package/dist/utils/index.d.ts +5 -0
  165. package/dist/utils/index.d.ts.map +1 -0
  166. package/dist/utils/index.js +6 -0
  167. package/dist/utils/index.js.map +1 -0
  168. package/index.css +778 -0
  169. package/package.json +74 -0
  170. package/src/colors.stories.conts.ts +164 -0
  171. package/src/colors.stories.tsx +66 -0
  172. package/src/components/button.stories.tsx +126 -0
  173. package/src/components/button.tsx +63 -0
  174. package/src/components/icon/custom/badge.tsx +17 -0
  175. package/src/components/icon/custom/check-circle-solid.tsx +24 -0
  176. package/src/components/icon/custom/circle-dotted-line.tsx +17 -0
  177. package/src/components/icon/custom/component-fill.tsx +17 -0
  178. package/src/components/icon/custom/component-line.tsx +17 -0
  179. package/src/components/icon/custom/ellipse-mini-solid.tsx +17 -0
  180. package/src/components/icon/custom/index.ts +11 -0
  181. package/src/components/icon/custom/info-tooltip-fill.tsx +21 -0
  182. package/src/components/icon/custom/resize.tsx +17 -0
  183. package/src/components/icon/custom/spinner.tsx +98 -0
  184. package/src/components/icon/custom/thunder.tsx +17 -0
  185. package/src/components/icon/custom/x-circle-solid.tsx +24 -0
  186. package/src/components/icon/icon.stories.tsx +29 -0
  187. package/src/components/icon/icon.tsx +42 -0
  188. package/src/components/icon/index.ts +1 -0
  189. package/src/components/index.ts +4 -0
  190. package/src/components/renovate.json +23 -0
  191. package/src/components/theme-provider.tsx +50 -0
  192. package/src/components/typography/code.stories.tsx +36 -0
  193. package/src/components/typography/code.tsx +38 -0
  194. package/src/components/typography/header.stories.tsx +27 -0
  195. package/src/components/typography/header.tsx +41 -0
  196. package/src/components/typography/index.ts +3 -0
  197. package/src/components/typography/text.stories.tsx +67 -0
  198. package/src/components/typography/text.tsx +42 -0
  199. package/src/hooks/index.ts +2 -0
  200. package/src/hooks/useCopy.ts +0 -0
  201. package/src/hooks/useCopyToClipboard.ts +20 -0
  202. package/src/hooks/useTheme.ts +10 -0
  203. package/src/index.ts +3 -0
  204. package/src/state/theme.ts +15 -0
  205. package/src/utils/clipboard.ts +4 -0
  206. package/src/utils/cn.ts +6 -0
  207. package/src/utils/date.test.ts +119 -0
  208. package/src/utils/date.ts +99 -0
  209. package/src/utils/format/chart.ts +16 -0
  210. package/src/utils/format/date.test.ts +65 -0
  211. package/src/utils/format/date.ts +75 -0
  212. package/src/utils/format/duration.test.ts +58 -0
  213. package/src/utils/format/duration.ts +82 -0
  214. package/src/utils/format/index.ts +4 -0
  215. package/src/utils/format/number.test.ts +38 -0
  216. package/src/utils/format/number.ts +33 -0
  217. package/src/utils/index.ts +4 -0
  218. package/test/global.ts +3 -0
  219. package/test/setup.ts +9 -0
  220. package/tsconfig.build.json +13 -0
  221. package/tsconfig.json +11 -0
  222. package/tsconfig.test.json +12 -0
  223. package/vercel.json +8 -0
  224. package/vitest.config.ts +17 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/typography/header.tsx"],"sourcesContent":["import {cva, type VariantProps} from 'class-variance-authority';\nimport type {ElementType, HTMLAttributes, PropsWithChildren} from 'react';\nimport {cn} from 'utils';\n\nexport const headerVariants = cva('', {\n variants: {\n variant: {\n h1: 'text-3xl',\n h2: 'text-xl',\n h3: 'text-lg',\n h4: 'text-md',\n },\n },\n defaultVariants: {\n variant: 'h1',\n },\n});\n\nconst components = {\n h1: 'h1',\n h2: 'h2',\n h3: 'h3',\n h4: 'h4',\n} as const;\n\nexport type HeaderProps = PropsWithChildren<HTMLAttributes<HTMLParagraphElement>> &\n VariantProps<typeof headerVariants> & {\n as?: ElementType;\n };\n\nexport function Header({children, className, variant, as, ...props}: HeaderProps) {\n const Component = as ?? (variant ? components[variant] : 'h1');\n return (\n <Component\n className={cn(headerVariants({variant}), 'font-display font-medium', className)}\n {...props}\n >\n {children}\n </Component>\n );\n}\n"],"names":["cva","cn","headerVariants","variants","variant","h1","h2","h3","h4","defaultVariants","components","Header","children","className","as","props","Component"],"mappings":";AAAA,SAAQA,GAAG,QAA0B,2BAA2B;AAEhE,SAAQC,EAAE,QAAO,QAAQ;AAEzB,OAAO,MAAMC,iBAAiBF,IAAI,IAAI;IACpCG,UAAU;QACRC,SAAS;YACPC,IAAI;YACJC,IAAI;YACJC,IAAI;YACJC,IAAI;QACN;IACF;IACAC,iBAAiB;QACfL,SAAS;IACX;AACF,GAAG;AAEH,MAAMM,aAAa;IACjBL,IAAI;IACJC,IAAI;IACJC,IAAI;IACJC,IAAI;AACN;AAOA,OAAO,SAASG,OAAO,EAACC,QAAQ,EAAEC,SAAS,EAAET,OAAO,EAAEU,EAAE,EAAE,GAAGC,OAAmB;IAC9E,MAAMC,YAAYF,MAAOV,CAAAA,UAAUM,UAAU,CAACN,QAAQ,GAAG,IAAG;IAC5D,qBACE,KAACY;QACCH,WAAWZ,GAAGC,eAAe;YAACE;QAAO,IAAI,4BAA4BS;QACpE,GAAGE,KAAK;kBAERH;;AAGP"}
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Code } from './code.js';
3
+ import { Header } from './header.js';
4
+ const meta = {
5
+ title: 'Typography/Header'
6
+ };
7
+ export default meta;
8
+ const variants = [
9
+ 'h1',
10
+ 'h2',
11
+ 'h3',
12
+ 'h4'
13
+ ];
14
+ export const Default = {
15
+ render: ()=>/*#__PURE__*/ _jsx("div", {
16
+ className: "flex flex-col gap-16",
17
+ children: variants.map((variant)=>/*#__PURE__*/ _jsxs("div", {
18
+ className: "flex flex-col gap-4",
19
+ children: [
20
+ /*#__PURE__*/ _jsx(Code, {
21
+ variant: "label",
22
+ className: "text-foreground-neutral-subtle",
23
+ children: variant
24
+ }),
25
+ /*#__PURE__*/ _jsx(Header, {
26
+ variant: variant,
27
+ children: "The quick brown fox jumps over the lazy dog"
28
+ })
29
+ ]
30
+ }, variant))
31
+ })
32
+ };
33
+
34
+ //# sourceMappingURL=header.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/typography/header.stories.tsx"],"sourcesContent":["import type {Meta, StoryObj} from '@storybook/react';\nimport {Code} from './code';\nimport {Header} from './header';\n\nconst meta: Meta = {\n title: 'Typography/Header',\n};\nexport default meta;\n\ntype Story = StoryObj;\n\nconst variants = ['h1', 'h2', 'h3', 'h4'] as const;\n\nexport const Default: Story = {\n render: () => (\n <div className=\"flex flex-col gap-16\">\n {variants.map((variant) => (\n <div key={variant} className=\"flex flex-col gap-4\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n {variant}\n </Code>\n <Header variant={variant}>The quick brown fox jumps over the lazy dog</Header>\n </div>\n ))}\n </div>\n ),\n};\n"],"names":["Code","Header","meta","title","variants","Default","render","div","className","map","variant"],"mappings":";AACA,SAAQA,IAAI,QAAO,SAAS;AAC5B,SAAQC,MAAM,QAAO,WAAW;AAEhC,MAAMC,OAAa;IACjBC,OAAO;AACT;AACA,eAAeD,KAAK;AAIpB,MAAME,WAAW;IAAC;IAAM;IAAM;IAAM;CAAK;AAEzC,OAAO,MAAMC,UAAiB;IAC5BC,QAAQ,kBACN,KAACC;YAAIC,WAAU;sBACZJ,SAASK,GAAG,CAAC,CAACC,wBACb,MAACH;oBAAkBC,WAAU;;sCAC3B,KAACR;4BAAKU,SAAQ;4BAAQF,WAAU;sCAC7BE;;sCAEH,KAACT;4BAAOS,SAASA;sCAAS;;;mBAJlBA;;AASlB,EAAE"}
@@ -0,0 +1,4 @@
1
+ export * from './code';
2
+ export * from './header';
3
+ export * from './text';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/typography/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './code.js';
2
+ export * from './header.js';
3
+ export * from './text.js';
4
+
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/typography/index.ts"],"sourcesContent":["export * from './code';\nexport * from './header';\nexport * from './text';\n"],"names":[],"mappings":"AAAA,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,SAAS"}
@@ -0,0 +1,12 @@
1
+ import { type VariantProps } from 'class-variance-authority';
2
+ import type { ElementType, HTMLAttributes, PropsWithChildren } from 'react';
3
+ export declare const textVariants: (props?: ({
4
+ size?: "xs" | "sm" | "md" | "lg" | "xl" | null | undefined;
5
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
+ export type TextProps = PropsWithChildren<HTMLAttributes<HTMLParagraphElement>> & VariantProps<typeof textVariants> & {
7
+ as?: ElementType;
8
+ compact?: boolean;
9
+ bold?: boolean;
10
+ };
11
+ export declare function Text({ children, className, size, as, compact, bold, ...props }: TextProps): import("react/jsx-runtime").JSX.Element;
12
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/components/typography/text.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAM,KAAK,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAC,WAAW,EAAE,cAAc,EAAE,iBAAiB,EAAC,MAAM,OAAO,CAAC;AAG1E,eAAO,MAAM,YAAY;;8EAavB,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,iBAAiB,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC,GAC7E,YAAY,CAAC,OAAO,YAAY,CAAC,GAAG;IAClC,EAAE,CAAC,EAAE,WAAW,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEJ,wBAAgB,IAAI,CAAC,EAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,EAAC,EAAE,SAAS,2CAevF"}
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cva } from 'class-variance-authority';
3
+ import { cn } from '../../utils/index.js';
4
+ export const textVariants = cva('', {
5
+ variants: {
6
+ size: {
7
+ xs: 'text-xs',
8
+ sm: 'text-sm',
9
+ md: 'text-md',
10
+ lg: 'text-lg',
11
+ xl: 'text-xl'
12
+ }
13
+ },
14
+ defaultVariants: {
15
+ size: 'md'
16
+ }
17
+ });
18
+ export function Text({ children, className, size, as, compact, bold, ...props }) {
19
+ const Component = as ?? 'p';
20
+ return /*#__PURE__*/ _jsx(Component, {
21
+ className: cn(textVariants({
22
+ size
23
+ }), 'font-display', {
24
+ 'leading-20': compact,
25
+ 'font-medium': bold
26
+ }, className),
27
+ ...props,
28
+ children: children
29
+ });
30
+ }
31
+
32
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/typography/text.tsx"],"sourcesContent":["import {cva, type VariantProps} from 'class-variance-authority';\nimport type {ElementType, HTMLAttributes, PropsWithChildren} from 'react';\nimport {cn} from 'utils';\n\nexport const textVariants = cva('', {\n variants: {\n size: {\n xs: 'text-xs',\n sm: 'text-sm',\n md: 'text-md',\n lg: 'text-lg',\n xl: 'text-xl',\n },\n },\n defaultVariants: {\n size: 'md',\n },\n});\n\nexport type TextProps = PropsWithChildren<HTMLAttributes<HTMLParagraphElement>> &\n VariantProps<typeof textVariants> & {\n as?: ElementType;\n compact?: boolean;\n bold?: boolean;\n };\n\nexport function Text({children, className, size, as, compact, bold, ...props}: TextProps) {\n const Component = as ?? 'p';\n return (\n <Component\n className={cn(\n textVariants({size}),\n 'font-display',\n {'leading-20': compact, 'font-medium': bold},\n className,\n )}\n {...props}\n >\n {children}\n </Component>\n );\n}\n"],"names":["cva","cn","textVariants","variants","size","xs","sm","md","lg","xl","defaultVariants","Text","children","className","as","compact","bold","props","Component"],"mappings":";AAAA,SAAQA,GAAG,QAA0B,2BAA2B;AAEhE,SAAQC,EAAE,QAAO,QAAQ;AAEzB,OAAO,MAAMC,eAAeF,IAAI,IAAI;IAClCG,UAAU;QACRC,MAAM;YACJC,IAAI;YACJC,IAAI;YACJC,IAAI;YACJC,IAAI;YACJC,IAAI;QACN;IACF;IACAC,iBAAiB;QACfN,MAAM;IACR;AACF,GAAG;AASH,OAAO,SAASO,KAAK,EAACC,QAAQ,EAAEC,SAAS,EAAET,IAAI,EAAEU,EAAE,EAAEC,OAAO,EAAEC,IAAI,EAAE,GAAGC,OAAiB;IACtF,MAAMC,YAAYJ,MAAM;IACxB,qBACE,KAACI;QACCL,WAAWZ,GACTC,aAAa;YAACE;QAAI,IAClB,gBACA;YAAC,cAAcW;YAAS,eAAeC;QAAI,GAC3CH;QAED,GAAGI,KAAK;kBAERL;;AAGP"}
@@ -0,0 +1,105 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Code } from './code.js';
3
+ import { Text } from './text.js';
4
+ const meta = {
5
+ title: 'Typography/Text'
6
+ };
7
+ export default meta;
8
+ const sizes = [
9
+ 'xs',
10
+ 'sm',
11
+ 'md',
12
+ 'lg',
13
+ 'xl'
14
+ ];
15
+ export const Default = {
16
+ render: ()=>/*#__PURE__*/ _jsx("div", {
17
+ className: "flex flex-col gap-16",
18
+ children: sizes.map((size)=>/*#__PURE__*/ _jsxs("div", {
19
+ className: "grid grid-cols-2 gap-8",
20
+ children: [
21
+ /*#__PURE__*/ _jsxs("div", {
22
+ className: "flex flex-col gap-4",
23
+ children: [
24
+ /*#__PURE__*/ _jsx(Code, {
25
+ variant: "label",
26
+ className: "text-foreground-neutral-subtle",
27
+ children: size
28
+ }),
29
+ /*#__PURE__*/ _jsx(Text, {
30
+ size: size,
31
+ children: "The quick brown fox jumps over the lazy dog"
32
+ })
33
+ ]
34
+ }),
35
+ /*#__PURE__*/ _jsxs("div", {
36
+ className: "flex flex-col gap-4",
37
+ children: [
38
+ /*#__PURE__*/ _jsxs(Code, {
39
+ variant: "label",
40
+ className: "text-foreground-neutral-subtle",
41
+ children: [
42
+ size,
43
+ " - Bold"
44
+ ]
45
+ }),
46
+ /*#__PURE__*/ _jsx(Text, {
47
+ size: size,
48
+ bold: true,
49
+ children: "The quick brown fox jumps over the lazy dog"
50
+ })
51
+ ]
52
+ })
53
+ ]
54
+ }, size))
55
+ })
56
+ };
57
+ const textParagraph = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
58
+ export const Paragraph = {
59
+ render: ()=>/*#__PURE__*/ _jsx("div", {
60
+ className: "flex flex-col gap-16",
61
+ children: sizes.map((size)=>/*#__PURE__*/ _jsxs("div", {
62
+ className: "grid grid-cols-2 gap-8",
63
+ children: [
64
+ /*#__PURE__*/ _jsxs("div", {
65
+ className: "flex flex-col gap-4",
66
+ children: [
67
+ /*#__PURE__*/ _jsxs(Code, {
68
+ variant: "label",
69
+ className: "text-foreground-neutral-subtle",
70
+ children: [
71
+ size,
72
+ " - Regular"
73
+ ]
74
+ }),
75
+ /*#__PURE__*/ _jsx(Text, {
76
+ size: size,
77
+ compact: false,
78
+ children: textParagraph
79
+ })
80
+ ]
81
+ }),
82
+ /*#__PURE__*/ _jsxs("div", {
83
+ className: "flex flex-col gap-4",
84
+ children: [
85
+ /*#__PURE__*/ _jsxs(Code, {
86
+ variant: "label",
87
+ className: "text-foreground-neutral-subtle",
88
+ children: [
89
+ size,
90
+ " - Compact"
91
+ ]
92
+ }),
93
+ /*#__PURE__*/ _jsx(Text, {
94
+ size: size,
95
+ compact: true,
96
+ children: textParagraph
97
+ })
98
+ ]
99
+ })
100
+ ]
101
+ }, size))
102
+ })
103
+ };
104
+
105
+ //# sourceMappingURL=text.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/typography/text.stories.tsx"],"sourcesContent":["import type {Meta, StoryObj} from '@storybook/react';\nimport {Code} from './code';\nimport {Text} from './text';\n\nconst meta: Meta = {\n title: 'Typography/Text',\n};\nexport default meta;\n\ntype Story = StoryObj;\n\nconst sizes = ['xs', 'sm', 'md', 'lg', 'xl'] as const;\n\nexport const Default: Story = {\n render: () => (\n <div className=\"flex flex-col gap-16\">\n {sizes.map((size) => (\n <div key={size} className=\"grid grid-cols-2 gap-8\">\n <div className=\"flex flex-col gap-4\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n {size}\n </Code>\n <Text size={size}>The quick brown fox jumps over the lazy dog</Text>\n </div>\n <div className=\"flex flex-col gap-4\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n {size} - Bold\n </Code>\n <Text size={size} bold>\n The quick brown fox jumps over the lazy dog\n </Text>\n </div>\n </div>\n ))}\n </div>\n ),\n};\n\nconst textParagraph =\n 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';\n\nexport const Paragraph: Story = {\n render: () => (\n <div className=\"flex flex-col gap-16\">\n {sizes.map((size) => (\n <div key={size} className=\"grid grid-cols-2 gap-8\">\n <div className=\"flex flex-col gap-4\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n {size} - Regular\n </Code>\n <Text size={size} compact={false}>\n {textParagraph}\n </Text>\n </div>\n <div className=\"flex flex-col gap-4\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n {size} - Compact\n </Code>\n <Text size={size} compact={true}>\n {textParagraph}\n </Text>\n </div>\n </div>\n ))}\n </div>\n ),\n};\n"],"names":["Code","Text","meta","title","sizes","Default","render","div","className","map","size","variant","bold","textParagraph","Paragraph","compact"],"mappings":";AACA,SAAQA,IAAI,QAAO,SAAS;AAC5B,SAAQC,IAAI,QAAO,SAAS;AAE5B,MAAMC,OAAa;IACjBC,OAAO;AACT;AACA,eAAeD,KAAK;AAIpB,MAAME,QAAQ;IAAC;IAAM;IAAM;IAAM;IAAM;CAAK;AAE5C,OAAO,MAAMC,UAAiB;IAC5BC,QAAQ,kBACN,KAACC;YAAIC,WAAU;sBACZJ,MAAMK,GAAG,CAAC,CAACC,qBACV,MAACH;oBAAeC,WAAU;;sCACxB,MAACD;4BAAIC,WAAU;;8CACb,KAACR;oCAAKW,SAAQ;oCAAQH,WAAU;8CAC7BE;;8CAEH,KAACT;oCAAKS,MAAMA;8CAAM;;;;sCAEpB,MAACH;4BAAIC,WAAU;;8CACb,MAACR;oCAAKW,SAAQ;oCAAQH,WAAU;;wCAC7BE;wCAAK;;;8CAER,KAACT;oCAAKS,MAAMA;oCAAME,IAAI;8CAAC;;;;;mBAXjBF;;AAmBlB,EAAE;AAEF,MAAMG,gBACJ;AAEF,OAAO,MAAMC,YAAmB;IAC9BR,QAAQ,kBACN,KAACC;YAAIC,WAAU;sBACZJ,MAAMK,GAAG,CAAC,CAACC,qBACV,MAACH;oBAAeC,WAAU;;sCACxB,MAACD;4BAAIC,WAAU;;8CACb,MAACR;oCAAKW,SAAQ;oCAAQH,WAAU;;wCAC7BE;wCAAK;;;8CAER,KAACT;oCAAKS,MAAMA;oCAAMK,SAAS;8CACxBF;;;;sCAGL,MAACN;4BAAIC,WAAU;;8CACb,MAACR;oCAAKW,SAAQ;oCAAQH,WAAU;;wCAC7BE;wCAAK;;;8CAER,KAACT;oCAAKS,MAAMA;oCAAMK,SAAS;8CACxBF;;;;;mBAdGH;;AAqBlB,EAAE"}
@@ -0,0 +1,3 @@
1
+ export * from './useCopyToClipboard';
2
+ export * from './useTheme';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './useCopyToClipboard.js';
2
+ export * from './useTheme.js';
3
+
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/index.ts"],"sourcesContent":["export * from './useCopyToClipboard';\nexport * from './useTheme';\n"],"names":[],"mappings":"AAAA,cAAc,uBAAuB;AACrC,cAAc,aAAa"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=useCopy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCopy.d.ts","sourceRoot":"","sources":["../../src/hooks/useCopy.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=useCopy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/useCopy.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ interface UseCopyToClipboardParams {
2
+ text: string;
3
+ onCopy?: (text: string) => void;
4
+ }
5
+ export declare function useCopyToClipboard({ text, onCopy }: UseCopyToClipboardParams): {
6
+ copy: () => Promise<void>;
7
+ copied: boolean;
8
+ };
9
+ export {};
10
+ //# sourceMappingURL=useCopyToClipboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCopyToClipboard.d.ts","sourceRoot":"","sources":["../../src/hooks/useCopyToClipboard.ts"],"names":[],"mappings":"AAGA,UAAU,wBAAwB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED,wBAAgB,kBAAkB,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,EAAE,wBAAwB;;;EAW1E"}
@@ -0,0 +1,16 @@
1
+ import { useState } from 'react';
2
+ import { copyTextToClipboard } from '../utils/index.js';
3
+ export function useCopyToClipboard({ text, onCopy }) {
4
+ const [copied, setCopied] = useState(false);
5
+ const copy = async ()=>{
6
+ await copyTextToClipboard(text);
7
+ if (onCopy) onCopy(text);
8
+ setCopied(true);
9
+ };
10
+ return {
11
+ copy,
12
+ copied
13
+ };
14
+ }
15
+
16
+ //# sourceMappingURL=useCopyToClipboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/useCopyToClipboard.ts"],"sourcesContent":["import {useState} from 'react';\nimport {copyTextToClipboard} from 'utils';\n\ninterface UseCopyToClipboardParams {\n text: string;\n onCopy?: (text: string) => void;\n}\n\nexport function useCopyToClipboard({text, onCopy}: UseCopyToClipboardParams) {\n const [copied, setCopied] = useState(false);\n\n const copy = async () => {\n await copyTextToClipboard(text);\n\n if (onCopy) onCopy(text);\n setCopied(true);\n };\n\n return {copy, copied};\n}\n"],"names":["useState","copyTextToClipboard","useCopyToClipboard","text","onCopy","copied","setCopied","copy"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,QAAQ;AAC/B,SAAQC,mBAAmB,QAAO,QAAQ;AAO1C,OAAO,SAASC,mBAAmB,EAACC,IAAI,EAAEC,MAAM,EAA2B;IACzE,MAAM,CAACC,QAAQC,UAAU,GAAGN,SAAS;IAErC,MAAMO,OAAO;QACX,MAAMN,oBAAoBE;QAE1B,IAAIC,QAAQA,OAAOD;QACnBG,UAAU;IACZ;IAEA,OAAO;QAACC;QAAMF;IAAM;AACtB"}
@@ -0,0 +1,2 @@
1
+ export declare const useTheme: () => import("../state/theme").ThemeProviderState;
2
+ //# sourceMappingURL=useTheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,QAAQ,gDAMpB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { useContext } from 'react';
2
+ import { ThemeProviderContext } from '../state/theme.js';
3
+ export const useTheme = ()=>{
4
+ const context = useContext(ThemeProviderContext);
5
+ if (context === undefined) throw new Error('useTheme must be used within a ThemeProvider');
6
+ return context;
7
+ };
8
+
9
+ //# sourceMappingURL=useTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/useTheme.ts"],"sourcesContent":["import {useContext} from 'react';\nimport {ThemeProviderContext} from 'state/theme';\n\nexport const useTheme = () => {\n const context = useContext(ThemeProviderContext);\n\n if (context === undefined) throw new Error('useTheme must be used within a ThemeProvider');\n\n return context;\n};\n"],"names":["useContext","ThemeProviderContext","useTheme","context","undefined","Error"],"mappings":"AAAA,SAAQA,UAAU,QAAO,QAAQ;AACjC,SAAQC,oBAAoB,QAAO,cAAc;AAEjD,OAAO,MAAMC,WAAW;IACtB,MAAMC,UAAUH,WAAWC;IAE3B,IAAIE,YAAYC,WAAW,MAAM,IAAIC,MAAM;IAE3C,OAAOF;AACT,EAAE"}
@@ -0,0 +1,4 @@
1
+ export * from './components';
2
+ export * from './hooks';
3
+ export * from './utils';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from './components/index.js';
2
+ export * from './hooks/index.js';
3
+ export * from './utils/index.js';
4
+
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './components';\nexport * from './hooks';\nexport * from './utils';\n"],"names":[],"mappings":"AAAA,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,UAAU"}
@@ -0,0 +1,7 @@
1
+ export type Theme = 'dark' | 'light' | 'system';
2
+ export type ThemeProviderState = {
3
+ theme: Theme;
4
+ setTheme: (theme: Theme) => void;
5
+ };
6
+ export declare const ThemeProviderContext: import("react").Context<ThemeProviderState>;
7
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/state/theme.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEhD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC,CAAC;AAOF,eAAO,MAAM,oBAAoB,6CAAkD,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { createContext } from 'react';
2
+ const initialState = {
3
+ theme: 'system',
4
+ setTheme: ()=>null
5
+ };
6
+ export const ThemeProviderContext = createContext(initialState);
7
+
8
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/state/theme.ts"],"sourcesContent":["import {createContext} from 'react';\n\nexport type Theme = 'dark' | 'light' | 'system';\n\nexport type ThemeProviderState = {\n theme: Theme;\n setTheme: (theme: Theme) => void;\n};\n\nconst initialState: ThemeProviderState = {\n theme: 'system',\n setTheme: () => null,\n};\n\nexport const ThemeProviderContext = createContext<ThemeProviderState>(initialState);\n"],"names":["createContext","initialState","theme","setTheme","ThemeProviderContext"],"mappings":"AAAA,SAAQA,aAAa,QAAO,QAAQ;AASpC,MAAMC,eAAmC;IACvCC,OAAO;IACPC,UAAU,IAAM;AAClB;AAEA,OAAO,MAAMC,uBAAuBJ,cAAkCC,cAAc"}
@@ -0,0 +1,2 @@
1
+ export declare function copyTextToClipboard(text: string): Promise<boolean | void>;
2
+ //# sourceMappingURL=clipboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clipboard.d.ts","sourceRoot":"","sources":["../../src/utils/clipboard.ts"],"names":[],"mappings":"AAAA,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,2BAGrD"}
@@ -0,0 +1,6 @@
1
+ export async function copyTextToClipboard(text) {
2
+ if ('clipboard' in navigator) return await navigator.clipboard.writeText(text);
3
+ return document.execCommand('copy', true, text);
4
+ }
5
+
6
+ //# sourceMappingURL=clipboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/clipboard.ts"],"sourcesContent":["export async function copyTextToClipboard(text: string) {\n if ('clipboard' in navigator) return await navigator.clipboard.writeText(text);\n return document.execCommand('copy', true, text);\n}\n"],"names":["copyTextToClipboard","text","navigator","clipboard","writeText","document","execCommand"],"mappings":"AAAA,OAAO,eAAeA,oBAAoBC,IAAY;IACpD,IAAI,eAAeC,WAAW,OAAO,MAAMA,UAAUC,SAAS,CAACC,SAAS,CAACH;IACzE,OAAOI,SAASC,WAAW,CAAC,QAAQ,MAAML;AAC5C"}
@@ -0,0 +1,3 @@
1
+ import { type ClassValue } from 'clsx';
2
+ export declare function cn(...inputs: ClassValue[]): string;
3
+ //# sourceMappingURL=cn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cn.d.ts","sourceRoot":"","sources":["../../src/utils/cn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,UAAU,EAAO,MAAM,MAAM,CAAC;AAG3C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC"}
@@ -0,0 +1,7 @@
1
+ import { clsx } from 'clsx';
2
+ import { twMerge } from 'tailwind-merge';
3
+ export function cn(...inputs) {
4
+ return twMerge(clsx(inputs));
5
+ }
6
+
7
+ //# sourceMappingURL=cn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/cn.ts"],"sourcesContent":["import {type ClassValue, clsx} from 'clsx';\nimport {twMerge} from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n"],"names":["clsx","twMerge","cn","inputs"],"mappings":"AAAA,SAAyBA,IAAI,QAAO,OAAO;AAC3C,SAAQC,OAAO,QAAO,iBAAiB;AAEvC,OAAO,SAASC,GAAG,GAAGC,MAAoB;IACxC,OAAOF,QAAQD,KAAKG;AACtB"}
@@ -0,0 +1,16 @@
1
+ import { type Duration, type NormalizedInterval } from 'date-fns';
2
+ export declare function isStartOfDay(date: Date): boolean;
3
+ export declare function isStartOfMonth(date: Date): boolean;
4
+ export declare function isEndOfDay(date: Date): boolean;
5
+ export declare function humanizeDurationToNow(duration: Duration): string;
6
+ export interface IntervalToNowFromDurationOptions {
7
+ /** When set, if an interval is given in a precise unit, it will be rounded to full days
8
+ * (ex: 1 day, will generate intervals from midnight (d-1) to midnight (d))
9
+ * Does not apply to units lower than day */
10
+ attemptRounding?: boolean;
11
+ }
12
+ export declare function intervalToNowFromDuration(duration: Duration, options?: IntervalToNowFromDurationOptions): NormalizedInterval;
13
+ export declare function generateDurationShortcut(duration: Duration): string;
14
+ export declare function parseTextDurationShortcut(text: string): Duration | undefined;
15
+ export declare function parseTextInterval(text: string): NormalizedInterval | undefined;
16
+ //# sourceMappingURL=date.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/utils/date.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EAGb,KAAK,kBAAkB,EAIxB,MAAM,UAAU,CAAC;AAElB,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAEhD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAElD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAE9C;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAEhE;AAED,MAAM,WAAW,gCAAgC;IAC/C;;iDAE6C;IAC7C,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,gCAAgC,GACzC,kBAAkB,CAcpB;AAoBD,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAMnE;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAM5E;AAID,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAU9E"}
@@ -0,0 +1,79 @@
1
+ import { endOfDay, formatDuration, startOfDay, startOfMonth, sub } from 'date-fns';
2
+ export function isStartOfDay(date) {
3
+ return date.getTime() === startOfDay(date).getTime();
4
+ }
5
+ export function isStartOfMonth(date) {
6
+ return date.getTime() === startOfMonth(date).getTime();
7
+ }
8
+ export function isEndOfDay(date) {
9
+ return date.getTime() === endOfDay(date).getTime();
10
+ }
11
+ export function humanizeDurationToNow(duration) {
12
+ return `Past ${formatDuration(duration)}`;
13
+ }
14
+ export function intervalToNowFromDuration(duration, options) {
15
+ const now = new Date();
16
+ const interval = {
17
+ start: sub(now, duration),
18
+ end: now
19
+ };
20
+ if (!options?.attemptRounding) return interval;
21
+ const units = Object.keys(duration);
22
+ if (units.length !== 1) return interval;
23
+ if ([
24
+ 'hours',
25
+ 'minutes',
26
+ 'seconds'
27
+ ].includes(units[0])) return interval;
28
+ return {
29
+ start: startOfDay(interval.start),
30
+ end: endOfDay(interval.end)
31
+ };
32
+ }
33
+ const DURATION_SHORTCUTS = {
34
+ years: 'y',
35
+ months: 'mo',
36
+ weeks: 'w',
37
+ days: 'd',
38
+ hours: 'h',
39
+ minutes: 'm',
40
+ seconds: 's'
41
+ };
42
+ const DURATION_SHORTCUTS_REVERSED = Object.fromEntries(Object.entries(DURATION_SHORTCUTS).map(([key, value])=>[
43
+ value,
44
+ key
45
+ ]));
46
+ const DURATION_SHORTCUT_REGEX = new RegExp(`^(\\d+)(${Object.keys(DURATION_SHORTCUTS_REVERSED).join('|')})$`);
47
+ export function generateDurationShortcut(duration) {
48
+ const keys = Object.keys(duration);
49
+ if (keys.length !== 1) return '';
50
+ const key = keys[0];
51
+ const value = duration[key];
52
+ return `${value}${DURATION_SHORTCUTS[key]}`;
53
+ }
54
+ export function parseTextDurationShortcut(text) {
55
+ const match = text.match(DURATION_SHORTCUT_REGEX);
56
+ if (!match) return;
57
+ const [_, value, shortcut] = match;
58
+ const unit = DURATION_SHORTCUTS_REVERSED[shortcut];
59
+ return {
60
+ [unit]: Number.parseInt(value, 10)
61
+ };
62
+ }
63
+ const dateSplitterRefex = /[-\u2013]/;
64
+ export function parseTextInterval(text) {
65
+ const durationShortcut = parseTextDurationShortcut(text);
66
+ if (durationShortcut) return intervalToNowFromDuration(durationShortcut);
67
+ const textDates = text.split(dateSplitterRefex).map((token)=>token.trim());
68
+ if (textDates.length !== 2) return;
69
+ const start = new Date(textDates[0]);
70
+ const end = new Date(textDates[1]);
71
+ if (Number.isNaN(start.getTime())) return;
72
+ if (Number.isNaN(end.getTime())) return;
73
+ return {
74
+ start,
75
+ end
76
+ };
77
+ }
78
+
79
+ //# sourceMappingURL=date.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/date.ts"],"sourcesContent":["import {\n type Duration,\n endOfDay,\n formatDuration,\n type NormalizedInterval,\n startOfDay,\n startOfMonth,\n sub,\n} from 'date-fns';\n\nexport function isStartOfDay(date: Date): boolean {\n return date.getTime() === startOfDay(date).getTime();\n}\n\nexport function isStartOfMonth(date: Date): boolean {\n return date.getTime() === startOfMonth(date).getTime();\n}\n\nexport function isEndOfDay(date: Date): boolean {\n return date.getTime() === endOfDay(date).getTime();\n}\n\nexport function humanizeDurationToNow(duration: Duration): string {\n return `Past ${formatDuration(duration)}`;\n}\n\nexport interface IntervalToNowFromDurationOptions {\n /** When set, if an interval is given in a precise unit, it will be rounded to full days\n * (ex: 1 day, will generate intervals from midnight (d-1) to midnight (d))\n * Does not apply to units lower than day */\n attemptRounding?: boolean;\n}\n\nexport function intervalToNowFromDuration(\n duration: Duration,\n options?: IntervalToNowFromDurationOptions,\n): NormalizedInterval {\n const now = new Date();\n const interval = {\n start: sub(now, duration),\n end: now,\n };\n if (!options?.attemptRounding) return interval;\n const units = Object.keys(duration);\n if (units.length !== 1) return interval;\n if (['hours', 'minutes', 'seconds'].includes(units[0])) return interval;\n return {\n start: startOfDay(interval.start),\n end: endOfDay(interval.end),\n };\n}\n\nconst DURATION_SHORTCUTS: Record<keyof Duration, string> = {\n years: 'y',\n months: 'mo',\n weeks: 'w',\n days: 'd',\n hours: 'h',\n minutes: 'm',\n seconds: 's',\n};\n\nconst DURATION_SHORTCUTS_REVERSED: Record<string, keyof Duration> = Object.fromEntries(\n Object.entries(DURATION_SHORTCUTS).map(([key, value]) => [value, key as keyof Duration]),\n);\n\nconst DURATION_SHORTCUT_REGEX = new RegExp(\n `^(\\\\d+)(${Object.keys(DURATION_SHORTCUTS_REVERSED).join('|')})$`,\n);\n\nexport function generateDurationShortcut(duration: Duration): string {\n const keys = Object.keys(duration) as (keyof Duration)[];\n if (keys.length !== 1) return '';\n const key = keys[0];\n const value = duration[key];\n return `${value}${DURATION_SHORTCUTS[key]}`;\n}\n\nexport function parseTextDurationShortcut(text: string): Duration | undefined {\n const match = text.match(DURATION_SHORTCUT_REGEX);\n if (!match) return;\n const [_, value, shortcut] = match;\n const unit = DURATION_SHORTCUTS_REVERSED[shortcut];\n return {[unit]: Number.parseInt(value, 10)};\n}\n\nconst dateSplitterRefex = /[-\\u2013]/;\n\nexport function parseTextInterval(text: string): NormalizedInterval | undefined {\n const durationShortcut = parseTextDurationShortcut(text);\n if (durationShortcut) return intervalToNowFromDuration(durationShortcut);\n const textDates = text.split(dateSplitterRefex).map((token) => token.trim());\n if (textDates.length !== 2) return;\n const start = new Date(textDates[0]);\n const end = new Date(textDates[1]);\n if (Number.isNaN(start.getTime())) return;\n if (Number.isNaN(end.getTime())) return;\n return {start, end};\n}\n"],"names":["endOfDay","formatDuration","startOfDay","startOfMonth","sub","isStartOfDay","date","getTime","isStartOfMonth","isEndOfDay","humanizeDurationToNow","duration","intervalToNowFromDuration","options","now","Date","interval","start","end","attemptRounding","units","Object","keys","length","includes","DURATION_SHORTCUTS","years","months","weeks","days","hours","minutes","seconds","DURATION_SHORTCUTS_REVERSED","fromEntries","entries","map","key","value","DURATION_SHORTCUT_REGEX","RegExp","join","generateDurationShortcut","parseTextDurationShortcut","text","match","_","shortcut","unit","Number","parseInt","dateSplitterRefex","parseTextInterval","durationShortcut","textDates","split","token","trim","isNaN"],"mappings":"AAAA,SAEEA,QAAQ,EACRC,cAAc,EAEdC,UAAU,EACVC,YAAY,EACZC,GAAG,QACE,WAAW;AAElB,OAAO,SAASC,aAAaC,IAAU;IACrC,OAAOA,KAAKC,OAAO,OAAOL,WAAWI,MAAMC,OAAO;AACpD;AAEA,OAAO,SAASC,eAAeF,IAAU;IACvC,OAAOA,KAAKC,OAAO,OAAOJ,aAAaG,MAAMC,OAAO;AACtD;AAEA,OAAO,SAASE,WAAWH,IAAU;IACnC,OAAOA,KAAKC,OAAO,OAAOP,SAASM,MAAMC,OAAO;AAClD;AAEA,OAAO,SAASG,sBAAsBC,QAAkB;IACtD,OAAO,CAAC,KAAK,EAAEV,eAAeU,WAAW;AAC3C;AASA,OAAO,SAASC,0BACdD,QAAkB,EAClBE,OAA0C;IAE1C,MAAMC,MAAM,IAAIC;IAChB,MAAMC,WAAW;QACfC,OAAOb,IAAIU,KAAKH;QAChBO,KAAKJ;IACP;IACA,IAAI,CAACD,SAASM,iBAAiB,OAAOH;IACtC,MAAMI,QAAQC,OAAOC,IAAI,CAACX;IAC1B,IAAIS,MAAMG,MAAM,KAAK,GAAG,OAAOP;IAC/B,IAAI;QAAC;QAAS;QAAW;KAAU,CAACQ,QAAQ,CAACJ,KAAK,CAAC,EAAE,GAAG,OAAOJ;IAC/D,OAAO;QACLC,OAAOf,WAAWc,SAASC,KAAK;QAChCC,KAAKlB,SAASgB,SAASE,GAAG;IAC5B;AACF;AAEA,MAAMO,qBAAqD;IACzDC,OAAO;IACPC,QAAQ;IACRC,OAAO;IACPC,MAAM;IACNC,OAAO;IACPC,SAAS;IACTC,SAAS;AACX;AAEA,MAAMC,8BAA8DZ,OAAOa,WAAW,CACpFb,OAAOc,OAAO,CAACV,oBAAoBW,GAAG,CAAC,CAAC,CAACC,KAAKC,MAAM,GAAK;QAACA;QAAOD;KAAsB;AAGzF,MAAME,0BAA0B,IAAIC,OAClC,CAAC,QAAQ,EAAEnB,OAAOC,IAAI,CAACW,6BAA6BQ,IAAI,CAAC,KAAK,EAAE,CAAC;AAGnE,OAAO,SAASC,yBAAyB/B,QAAkB;IACzD,MAAMW,OAAOD,OAAOC,IAAI,CAACX;IACzB,IAAIW,KAAKC,MAAM,KAAK,GAAG,OAAO;IAC9B,MAAMc,MAAMf,IAAI,CAAC,EAAE;IACnB,MAAMgB,QAAQ3B,QAAQ,CAAC0B,IAAI;IAC3B,OAAO,GAAGC,QAAQb,kBAAkB,CAACY,IAAI,EAAE;AAC7C;AAEA,OAAO,SAASM,0BAA0BC,IAAY;IACpD,MAAMC,QAAQD,KAAKC,KAAK,CAACN;IACzB,IAAI,CAACM,OAAO;IACZ,MAAM,CAACC,GAAGR,OAAOS,SAAS,GAAGF;IAC7B,MAAMG,OAAOf,2BAA2B,CAACc,SAAS;IAClD,OAAO;QAAC,CAACC,KAAK,EAAEC,OAAOC,QAAQ,CAACZ,OAAO;IAAG;AAC5C;AAEA,MAAMa,oBAAoB;AAE1B,OAAO,SAASC,kBAAkBR,IAAY;IAC5C,MAAMS,mBAAmBV,0BAA0BC;IACnD,IAAIS,kBAAkB,OAAOzC,0BAA0ByC;IACvD,MAAMC,YAAYV,KAAKW,KAAK,CAACJ,mBAAmBf,GAAG,CAAC,CAACoB,QAAUA,MAAMC,IAAI;IACzE,IAAIH,UAAU/B,MAAM,KAAK,GAAG;IAC5B,MAAMN,QAAQ,IAAIF,KAAKuC,SAAS,CAAC,EAAE;IACnC,MAAMpC,MAAM,IAAIH,KAAKuC,SAAS,CAAC,EAAE;IACjC,IAAIL,OAAOS,KAAK,CAACzC,MAAMV,OAAO,KAAK;IACnC,IAAI0C,OAAOS,KAAK,CAACxC,IAAIX,OAAO,KAAK;IACjC,OAAO;QAACU;QAAOC;IAAG;AACpB"}
@@ -0,0 +1,3 @@
1
+ export declare function formatAxisTick(value: unknown): string;
2
+ export declare function formatTooltipLabel(value: unknown): string;
3
+ //# sourceMappingURL=chart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["../../../src/utils/format/chart.ts"],"names":[],"mappings":"AAGA,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,UAK5C;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,UAKhD"}
@@ -0,0 +1,14 @@
1
+ import { formatDateTime, formatTimeSeriesTick } from './date.js';
2
+ import { formatNumber, formatNumberCompact } from './number.js';
3
+ export function formatAxisTick(value) {
4
+ if (value instanceof Date) return formatTimeSeriesTick(value);
5
+ if (typeof value !== 'number') throw new Error(`Expecting value to be a number, got ${typeof value}`);
6
+ return formatNumberCompact(value);
7
+ }
8
+ export function formatTooltipLabel(value) {
9
+ if (value instanceof Date) return formatDateTime(value);
10
+ if (typeof value !== 'number') throw new Error(`Expecting value to be a number, got ${typeof value}`);
11
+ return formatNumber(value);
12
+ }
13
+
14
+ //# sourceMappingURL=chart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/format/chart.ts"],"sourcesContent":["import {formatDateTime, formatTimeSeriesTick} from './date';\nimport {formatNumber, formatNumberCompact} from './number';\n\nexport function formatAxisTick(value: unknown) {\n if (value instanceof Date) return formatTimeSeriesTick(value);\n if (typeof value !== 'number')\n throw new Error(`Expecting value to be a number, got ${typeof value}`);\n return formatNumberCompact(value);\n}\n\nexport function formatTooltipLabel(value: unknown) {\n if (value instanceof Date) return formatDateTime(value);\n if (typeof value !== 'number')\n throw new Error(`Expecting value to be a number, got ${typeof value}`);\n return formatNumber(value);\n}\n"],"names":["formatDateTime","formatTimeSeriesTick","formatNumber","formatNumberCompact","formatAxisTick","value","Date","Error","formatTooltipLabel"],"mappings":"AAAA,SAAQA,cAAc,EAAEC,oBAAoB,QAAO,SAAS;AAC5D,SAAQC,YAAY,EAAEC,mBAAmB,QAAO,WAAW;AAE3D,OAAO,SAASC,eAAeC,KAAc;IAC3C,IAAIA,iBAAiBC,MAAM,OAAOL,qBAAqBI;IACvD,IAAI,OAAOA,UAAU,UACnB,MAAM,IAAIE,MAAM,CAAC,oCAAoC,EAAE,OAAOF,OAAO;IACvE,OAAOF,oBAAoBE;AAC7B;AAEA,OAAO,SAASG,mBAAmBH,KAAc;IAC/C,IAAIA,iBAAiBC,MAAM,OAAON,eAAeK;IACjD,IAAI,OAAOA,UAAU,UACnB,MAAM,IAAIE,MAAM,CAAC,oCAAoC,EAAE,OAAOF,OAAO;IACvE,OAAOH,aAAaG;AACtB"}
@@ -0,0 +1,10 @@
1
+ import { type NormalizedInterval } from 'date-fns';
2
+ interface DateTimeFormatOptions extends Intl.DateTimeFormatOptions {
3
+ locale?: string;
4
+ }
5
+ export declare function formatDateTime(date: Date, options?: DateTimeFormatOptions): string;
6
+ export declare function formatDateTimeRelativeToInterval(date: Date, interval: NormalizedInterval, options?: DateTimeFormatOptions): string;
7
+ export declare function formatDateTimeRange(interval: NormalizedInterval, options?: DateTimeFormatOptions): string;
8
+ export declare function formatTimeSeriesTick(date: Date, { locale, ...options }?: DateTimeFormatOptions): string;
9
+ export {};
10
+ //# sourceMappingURL=date.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../../src/utils/format/date.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,kBAAkB,EAAC,MAAM,UAAU,CAAC;AAG1D,UAAU,qBAAsB,SAAQ,IAAI,CAAC,qBAAqB;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAyBD,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,MAAM,CAGlF;AAED,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,CAAC,EAAE,qBAAqB,UAOhC;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,CAAC,EAAE,qBAAqB,GAC9B,MAAM,CAUR;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,IAAI,EACV,EAAC,MAAM,EAAE,GAAG,OAAO,EAAC,GAAE,qBAA0B,GAC/C,MAAM,CASR"}