@eifi1/ui-kit 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -23
- package/dist/components/alert-banner.d.ts +57 -5
- package/dist/components/alert-banner.js +63 -17
- package/dist/components/alert-banner.js.map +1 -1
- package/dist/components/amount-input.d.ts +6 -0
- package/dist/components/breadcrumbs.d.ts +60 -0
- package/dist/components/breadcrumbs.js +88 -0
- package/dist/components/breadcrumbs.js.map +1 -0
- package/dist/components/bulk-action-bar.d.ts +112 -0
- package/dist/components/bulk-action-bar.js +196 -0
- package/dist/components/bulk-action-bar.js.map +1 -0
- package/dist/components/button-group.d.ts +58 -3
- package/dist/components/button-group.js +56 -5
- package/dist/components/button-group.js.map +1 -1
- package/dist/components/calculator.d.ts +6 -0
- package/dist/components/calendar-heatmap.d.ts +124 -0
- package/dist/components/calendar-heatmap.js +295 -0
- package/dist/components/calendar-heatmap.js.map +1 -0
- package/dist/components/chip.d.ts +31 -5
- package/dist/components/chip.js +85 -5
- package/dist/components/chip.js.map +1 -1
- package/dist/components/choice-card.d.ts +34 -2
- package/dist/components/choice-card.js +49 -0
- package/dist/components/choice-card.js.map +1 -1
- package/dist/components/copy-button.d.ts +14 -4
- package/dist/components/copy-button.js +17 -4
- package/dist/components/copy-button.js.map +1 -1
- package/dist/components/data-table.js +2 -0
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.d.ts +22 -2
- package/dist/components/date-picker.js +11 -3
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/description-list.d.ts +43 -6
- package/dist/components/description-list.js +91 -11
- package/dist/components/description-list.js.map +1 -1
- package/dist/components/dialog-frame.d.ts +7 -0
- package/dist/components/dialog-frame.js.map +1 -1
- package/dist/components/disclosure.d.ts +57 -2
- package/dist/components/disclosure.js +24 -12
- package/dist/components/disclosure.js.map +1 -1
- package/dist/components/field.d.ts +43 -0
- package/dist/components/field.js +52 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/file-button.d.ts +1 -0
- package/dist/components/file-dropzone.d.ts +4 -4
- package/dist/components/file-dropzone.js +2 -1
- package/dist/components/file-dropzone.js.map +1 -1
- package/dist/components/floating-panel.d.ts +147 -4
- package/dist/components/floating-panel.js +188 -28
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/full-bleed-dialog.d.ts +23 -4
- package/dist/components/full-bleed-dialog.js +11 -2
- package/dist/components/full-bleed-dialog.js.map +1 -1
- package/dist/components/list.d.ts +187 -0
- package/dist/components/list.js +221 -0
- package/dist/components/list.js.map +1 -0
- package/dist/components/menu-item.d.ts +109 -0
- package/dist/components/menu-item.js +88 -0
- package/dist/components/menu-item.js.map +1 -0
- package/dist/components/mini-calendar.d.ts +70 -5
- package/dist/components/mini-calendar.js +166 -62
- package/dist/components/mini-calendar.js.map +1 -1
- package/dist/components/modal.d.ts +23 -1
- package/dist/components/modal.js +36 -10
- package/dist/components/modal.js.map +1 -1
- package/dist/components/nav-pills.d.ts +66 -0
- package/dist/components/nav-pills.js +65 -0
- package/dist/components/nav-pills.js.map +1 -0
- package/dist/components/number-field.d.ts +6 -0
- package/dist/components/number-input.d.ts +6 -0
- package/dist/components/numpad-sheet.d.ts +6 -0
- package/dist/components/page-contents.js +1 -2
- package/dist/components/page-contents.js.map +1 -1
- package/dist/components/page-header.d.ts +37 -0
- package/dist/components/page-header.js +36 -0
- package/dist/components/page-header.js.map +1 -0
- package/dist/components/progress-bar.d.ts +31 -2
- package/dist/components/progress-bar.js +73 -7
- package/dist/components/progress-bar.js.map +1 -1
- package/dist/components/series-chart-labels.d.ts +3 -0
- package/dist/components/series-chart-labels.js +2 -1
- package/dist/components/series-chart-labels.js.map +1 -1
- package/dist/components/series-chart.d.ts +32 -0
- package/dist/components/series-chart.js +141 -4
- package/dist/components/series-chart.js.map +1 -1
- package/dist/components/settings-fields.d.ts +1 -0
- package/dist/components/status-dot.d.ts +53 -0
- package/dist/components/status-dot.js +57 -0
- package/dist/components/status-dot.js.map +1 -0
- package/dist/components/table.d.ts +78 -13
- package/dist/components/table.js +84 -11
- package/dist/components/table.js.map +1 -1
- package/dist/components/text.d.ts +70 -0
- package/dist/components/text.js +24 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/time-input.d.ts +1 -0
- package/dist/components/toast.d.ts +167 -0
- package/dist/components/toast.js +226 -0
- package/dist/components/toast.js.map +1 -0
- package/dist/components/toggle-group.d.ts +44 -1
- package/dist/components/toggle-group.js +73 -4
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/tooltip.d.ts +46 -15
- package/dist/components/tooltip.js +87 -47
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/ui.d.ts +158 -7
- package/dist/components/ui.js +191 -10
- package/dist/components/ui.js.map +1 -1
- package/dist/components/user-avatar.d.ts +25 -3
- package/dist/components/user-avatar.js +32 -3
- package/dist/components/user-avatar.js.map +1 -1
- package/dist/hooks/use-close-transition.d.ts +7 -1
- package/dist/hooks/use-close-transition.js +5 -2
- package/dist/hooks/use-close-transition.js.map +1 -1
- package/dist/hooks/use-copy-to-clipboard.js +1 -1
- package/dist/hooks/use-copy-to-clipboard.js.map +1 -1
- package/dist/hooks/use-file-drop.d.ts +1 -0
- package/dist/i18n/defaults.d.ts +6 -0
- package/dist/i18n/defaults.js +11 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +11 -0
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/de-CH-informal.d.ts +6 -0
- package/dist/i18n/locales/de-CH.d.ts +6 -0
- package/dist/i18n/locales/de-informal.d.ts +6 -0
- package/dist/i18n/locales/de.d.ts +6 -0
- package/dist/i18n/locales/de.js +30 -2
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +6 -0
- package/dist/i18n/locales/es.js +30 -2
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +6 -0
- package/dist/i18n/locales/fr.js +30 -2
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +6 -0
- package/dist/i18n/locales/hu.js +30 -2
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +6 -0
- package/dist/i18n/locales/it.js +30 -2
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +6 -0
- package/dist/i18n/locales/zh.js +30 -2
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.d.ts +27 -15
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/clipping.d.ts +25 -0
- package/dist/lib/clipping.js +17 -0
- package/dist/lib/clipping.js.map +1 -0
- package/dist/lib/dates.d.ts +17 -1
- package/dist/lib/dates.js +19 -0
- package/dist/lib/dates.js.map +1 -1
- package/dist/rhf/form.d.ts +1 -0
- package/dist/rhf/use-rhf-wizard-step.d.ts +22 -0
- package/dist/rhf/use-rhf-wizard-step.js +38 -0
- package/dist/rhf/use-rhf-wizard-step.js.map +1 -0
- package/dist/rhf.d.ts +2 -0
- package/dist/rhf.js +1 -0
- package/dist/rhf.js.map +1 -1
- package/dist/search/command-palette.d.ts +19 -2
- package/dist/search/command-palette.js +16 -5
- package/dist/search/command-palette.js.map +1 -1
- package/dist/search/global-search.d.ts +26 -1
- package/dist/search/global-search.js +29 -13
- package/dist/search/global-search.js.map +1 -1
- package/dist/search.d.ts +1 -1
- package/dist/shell/topbar-action-menu.d.ts +73 -3
- package/dist/shell/topbar-action-menu.js +100 -27
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell.d.ts +2 -1
- package/dist/wizard/stepper-nav.d.ts +1 -0
- package/dist/wizard/stepper-nav.js +1 -1
- package/dist/wizard/stepper-nav.js.map +1 -1
- package/dist/wizard/types.d.ts +2 -2
- package/dist/wizard/types.js.map +1 -1
- package/dist/wizard/use-wizard.js +1 -1
- package/dist/wizard/use-wizard.js.map +1 -1
- package/dist/wizard/wizard-context.d.ts +7 -1
- package/dist/wizard/wizard-context.js +4 -0
- package/dist/wizard/wizard-context.js.map +1 -1
- package/dist/wizard/wizard-summary.js +3 -3
- package/dist/wizard/wizard-summary.js.map +1 -1
- package/dist/wizard.d.ts +2 -1
- package/package.json +16 -12
- package/src/components/alert-banner.tsx +149 -21
- package/src/components/breadcrumbs.tsx +168 -0
- package/src/components/bulk-action-bar.tsx +362 -0
- package/src/components/button-group.tsx +124 -4
- package/src/components/calendar-heatmap.tsx +504 -0
- package/src/components/chip.tsx +128 -7
- package/src/components/choice-card.tsx +97 -1
- package/src/components/copy-button.tsx +29 -7
- package/src/components/data-table.tsx +7 -0
- package/src/components/date-picker.tsx +49 -1
- package/src/components/description-list.tsx +168 -15
- package/src/components/dialog-frame.tsx +7 -0
- package/src/components/disclosure.tsx +93 -21
- package/src/components/field.tsx +137 -0
- package/src/components/file-dropzone.tsx +9 -10
- package/src/components/floating-panel.tsx +366 -15
- package/src/components/full-bleed-dialog.tsx +42 -5
- package/src/components/list.tsx +443 -0
- package/src/components/menu-item.tsx +235 -0
- package/src/components/mini-calendar.tsx +245 -54
- package/src/components/modal.tsx +80 -17
- package/src/components/nav-pills.tsx +145 -0
- package/src/components/page-contents.tsx +4 -4
- package/src/components/page-header.tsx +68 -0
- package/src/components/progress-bar.tsx +129 -11
- package/src/components/series-chart-labels.ts +4 -0
- package/src/components/series-chart.tsx +274 -3
- package/src/components/status-dot.tsx +107 -0
- package/src/components/table.tsx +176 -17
- package/src/components/text.tsx +97 -0
- package/src/components/toast.tsx +441 -0
- package/src/components/toggle-group.tsx +128 -4
- package/src/components/tooltip.tsx +200 -100
- package/src/components/ui.tsx +381 -14
- package/src/components/user-avatar.tsx +57 -3
- package/src/hooks/use-close-transition.ts +14 -5
- package/src/hooks/use-copy-to-clipboard.ts +1 -1
- package/src/i18n/defaults.ts +10 -0
- package/src/i18n/kit-labels.tsx +10 -0
- package/src/i18n/locales/de.ts +29 -0
- package/src/i18n/locales/es.ts +29 -0
- package/src/i18n/locales/fr.ts +29 -0
- package/src/i18n/locales/hu.ts +29 -0
- package/src/i18n/locales/it.ts +29 -0
- package/src/i18n/locales/zh.ts +29 -0
- package/src/index.ts +31 -0
- package/src/lib/clipping.ts +34 -0
- package/src/lib/dates.ts +37 -0
- package/src/rhf/use-rhf-wizard-step.ts +113 -0
- package/src/rhf.ts +2 -0
- package/src/search/command-palette.tsx +42 -5
- package/src/search/global-search.tsx +59 -18
- package/src/shell/topbar-action-menu.tsx +239 -49
- package/src/wizard/stepper-nav.tsx +2 -1
- package/src/wizard/types.ts +2 -2
- package/src/wizard/use-wizard.ts +3 -3
- package/src/wizard/wizard-context.tsx +9 -0
- package/src/wizard/wizard-summary.tsx +14 -10
- package/tokens.css +97 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/button-group.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef } from \"react\";\nimport { cn } from \"../lib/cn\";\n\n// Every class below is spelled out in full rather than assembled from parts: the\n// consumer's Tailwind build finds classes by scanning this package's source as text,\n// and a class that exists only after a template literal runs is never generated.\n//\n// Each rule is written twice, once for a direct child and once for a `<button>` one\n// level down. The second is for a Tooltip-wrapped IconButton — the map zoom's + and −\n// both carry a tooltip — where the direct child is the tooltip's wrapper span and the\n// button that draws the border and the corners sits inside it.\nconst JOINED_COMMON = cn(\n \"inline-flex rounded-md border border-[var(--border)]\",\n // The group draws the frame; each member gives up its own border, radius and shadow.\n \"[&>*]:rounded-none [&>*]:border-0 [&>*]:shadow-none\",\n \"[&>*>button]:rounded-none [&>*>button]:border-0 [&>*>button]:shadow-none\",\n \"[&>*]:border-[var(--border)]\",\n // A focused member rises above its neighbours so its ring is not painted over by\n // the next one's background.\n \"[&>*]:relative [&>*:focus-within]:z-10\",\n);\n\nconst JOINED: Record<\"horizontal\" | \"vertical\", string> = {\n // Logical edges and corners throughout (`border-s`, `rounded-s-*`), so in RTL the\n // first member sits on the right with the right-hand corners rounded — the physical\n // pair would round the outside of the last button and square off the first.\n horizontal: cn(\n JOINED_COMMON,\n \"flex-row items-stretch\",\n \"[&>*:not(:first-child)]:border-s\",\n \"[&>:first-child]:rounded-s-md [&>:last-child]:rounded-e-md\",\n \"[&>:first-child>button]:rounded-s-md [&>:last-child>button]:rounded-e-md\",\n ),\n // The block axis is top-to-bottom in both reading directions, so top/bottom are\n // already the logical edges here.\n vertical: cn(\n JOINED_COMMON,\n \"flex-col items-stretch\",\n \"[&>*:not(:first-child)]:border-t\",\n \"[&>:first-child]:rounded-t-md [&>:last-child]:rounded-b-md\",\n \"[&>:first-child>button]:rounded-t-md [&>:last-child>button]:rounded-b-md\",\n ),\n};\n\nexport interface ButtonGroupProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"role\"> {\n /** `horizontal` (default): side by side, in reading order. `vertical`: stacked —\n * the map's zoom + over −. */\n orientation?: \"horizontal\" | \"vertical\";\n}\n\n/**\n * Adjacent `Button`s or `IconButton`s drawn as one joined control: a single frame,\n * hairline dividers between the members, rounded only at the outer corners.\n *\n * keksdose asked for it twice — \"collapse all / expand all\" above its category\n * tree, and the + and − of its map zoom — both hand-built with negative margins and\n * physical `rounded-l` / `rounded-r`, which came out inside-out under `dir=\"rtl\"`.\n *\n * `role=\"group\"` with a name: a reader then introduces the pair as \"Zoom, group\"\n * before reading \"Zoom in\", which is what tells a listener that the next button\n * belongs with this one. Pass `aria-label` (or `aria-labelledby`); a group with no\n * name is one more unlabelled wrapper. It is NOT a toolbar — it adds no arrow-key\n * roving, and every member keeps its own tab stop, as plain adjacent buttons do.\n * For one-of-many selection use `ToggleGroup`, which has the radio semantics.\n */\nexport function ButtonGroup({ orientation = \"horizontal\", className, ...rest }: ButtonGroupProps) {\n return (\n <div\n {...rest}\n role=\"group\"\n data-orientation={orientation}\n className={cn(JOINED[orientation], className)}\n />\n );\n}\n"],"mappings":";AAmEI;AAlEJ,SAAS,UAAU;AAUnB,MAAM,gBAAgB;AAAA,EACpB;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA,EAGA;AACF;AAEA,MAAM,SAAoD;AAAA;AAAA;AAAA;AAAA,EAIxD,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA;AAAA;AAAA,EAGA,UAAU;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAuBO,SAAS,YAAY,EAAE,cAAc,cAAc,WAAW,GAAG,KAAK,GAAqB;AAChG,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,MAAK;AAAA,MACL,oBAAkB;AAAA,MAClB,WAAW,GAAG,OAAO,WAAW,GAAG,SAAS;AAAA;AAAA,EAC9C;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/button-group.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, MouseEvent, ReactElement, ReactNode, Ref } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { buttonClasses, type ButtonSize, type ButtonVariant } from \"./ui\";\n\n// Every class below is spelled out in full rather than assembled from parts: the\n// consumer's Tailwind build finds classes by scanning this package's source as text,\n// and a class that exists only after a template literal runs is never generated.\n//\n// Each rule is written twice, once for a direct child and once for a `<button>` one\n// level down. The second is for a Tooltip-wrapped IconButton — the map zoom's + and −\n// both carry a tooltip — where the direct child is the tooltip's wrapper span and the\n// button that draws the border and the corners sits inside it. The same again for an\n// `<a>` one level down: a router link member (see {@link ButtonGroupLink}) under a\n// tooltip. A bare link is a direct child and needs nothing extra.\nconst JOINED_COMMON = cn(\n \"inline-flex rounded-md border border-[var(--border)]\",\n // The group draws the frame; each member gives up its own border, radius and shadow.\n \"[&>*]:rounded-none [&>*]:border-0 [&>*]:shadow-none\",\n \"[&>*>button]:rounded-none [&>*>button]:border-0 [&>*>button]:shadow-none\",\n \"[&>*>a]:rounded-none [&>*>a]:border-0 [&>*>a]:shadow-none\",\n \"[&>*]:border-[var(--border)]\",\n // A focused member rises above its neighbours so its ring is not painted over by\n // the next one's background.\n \"[&>*]:relative [&>*:focus-within]:z-10\",\n);\n\nconst JOINED: Record<\"horizontal\" | \"vertical\", string> = {\n // Logical edges and corners throughout (`border-s`, `rounded-s-*`), so in RTL the\n // first member sits on the right with the right-hand corners rounded — the physical\n // pair would round the outside of the last button and square off the first.\n horizontal: cn(\n JOINED_COMMON,\n \"flex-row items-stretch\",\n \"[&>*:not(:first-child)]:border-s\",\n \"[&>:first-child]:rounded-s-md [&>:last-child]:rounded-e-md\",\n \"[&>:first-child>button]:rounded-s-md [&>:last-child>button]:rounded-e-md\",\n \"[&>:first-child>a]:rounded-s-md [&>:last-child>a]:rounded-e-md\",\n ),\n // The block axis is top-to-bottom in both reading directions, so top/bottom are\n // already the logical edges here.\n vertical: cn(\n JOINED_COMMON,\n \"flex-col items-stretch\",\n \"[&>*:not(:first-child)]:border-t\",\n \"[&>:first-child]:rounded-t-md [&>:last-child]:rounded-b-md\",\n \"[&>:first-child>button]:rounded-t-md [&>:last-child>button]:rounded-b-md\",\n \"[&>:first-child>a]:rounded-t-md [&>:last-child>a]:rounded-b-md\",\n ),\n};\n\n// `gapped`: the members keep their own shape — round overlay discs, each its own\n// border and radius — and sit apart. Nothing is stripped, so there is nothing to\n// restore per edge, and the gap is logical by nature.\nconst GAPPED: Record<\"horizontal\" | \"vertical\", string> = {\n horizontal: \"inline-flex flex-row items-center gap-1\",\n vertical: \"inline-flex flex-col items-center gap-1\",\n};\n\n// `elevated`, joined: the frame itself floats — a filled surface under the members (a\n// ghost member would otherwise show the content through it) and the shadow of a\n// control lifted over the page.\nconst ELEVATED_JOINED = \"bg-[var(--bg-surface)] shadow-lg\";\n// `elevated`, gapped: there is no frame, so each disc carries the shadow. Aimed at the\n// control, not the tooltip's square wrapper span, whose shadow would be a box round a\n// round disc.\nconst ELEVATED_GAPPED =\n \"[&>button]:shadow-md [&>a]:shadow-md [&>*>button]:shadow-md [&>*>a]:shadow-md\";\n\nexport interface ButtonGroupProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"role\"> {\n /** `horizontal` (default): side by side, in reading order. `vertical`: stacked —\n * the map's zoom + over −. */\n orientation?: \"horizontal\" | \"vertical\";\n /**\n * `joined` (default): one frame, hairline dividers, outer corners rounded. `gapped`:\n * separate controls with a small gap, each keeping its own shape — the overlay\n * discs of keksdose's receipt preview zoom (scan-file-preview.tsx:362, the − and +\n * `IconButton variant=\"overlay\"` in a hand-made `flex gap-1`), where a joined frame\n * would be a box drawn over the photo.\n */\n variant?: \"joined\" | \"gapped\";\n /**\n * Float it: a surface with a shadow, for a toolbar that sits OVER content (a map's\n * zoom, a photo's controls) rather than in the page's flow — keksdose adds\n * `shadow-sm` to each disc on the receipt preview by hand. On a joined group the\n * frame is filled and shadowed; on a gapped one, each member.\n */\n elevated?: boolean;\n}\n\n/**\n * Adjacent `Button`s or `IconButton`s drawn as one joined control: a single frame,\n * hairline dividers between the members, rounded only at the outer corners.\n *\n * keksdose asked for it twice — \"collapse all / expand all\" above its category\n * tree, and the + and − of its map zoom — both hand-built with negative margins and\n * physical `rounded-l` / `rounded-r`, which came out inside-out under `dir=\"rtl\"`.\n *\n * `role=\"group\"` with a name: a reader then introduces the pair as \"Zoom, group\"\n * before reading \"Zoom in\", which is what tells a listener that the next button\n * belongs with this one. Pass `aria-label` (or `aria-labelledby`); a group with no\n * name is one more unlabelled wrapper. It is NOT a toolbar — it adds no arrow-key\n * roving, and every member keeps its own tab stop, as plain adjacent buttons do.\n * For one-of-many selection use `ToggleGroup`, which has the radio semantics.\n */\nexport function ButtonGroup({\n orientation = \"horizontal\",\n variant = \"joined\",\n elevated = false,\n className,\n ...rest\n}: ButtonGroupProps) {\n const joined = variant === \"joined\";\n return (\n <div\n {...rest}\n role=\"group\"\n data-orientation={orientation}\n data-variant={variant}\n className={cn(\n joined ? JOINED[orientation] : GAPPED[orientation],\n elevated && (joined ? ELEVATED_JOINED : ELEVATED_GAPPED),\n className,\n )}\n />\n );\n}\n\n/** What {@link ButtonGroupLinkProps.renderLink} is handed. Spread it onto your router's\n * link, mapping `href` — `renderLink={({ href, ...p }) => <Link to={href} {...p} />}`. */\nexport interface ButtonGroupLinkRenderProps {\n href: string;\n /** The button look — keep it, or the member is a bare link in the frame. */\n className: string;\n children: ReactNode;\n ref?: Ref<HTMLAnchorElement>;\n \"aria-current\"?: \"page\";\n onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;\n [key: `aria-${string}`]: string | boolean | number | undefined;\n [key: `data-${string}`]: unknown;\n}\n\nexport interface ButtonGroupLinkProps extends Omit<ComponentPropsWithoutRef<\"a\">, \"href\" | \"className\" | \"children\"> {\n href: string;\n /** The {@link Button} variant it looks like. Default `secondary`, the usual member. */\n variant?: ButtonVariant;\n size?: ButtonSize;\n /** The member for the page you are on: `aria-current=\"page\"` and the \"on\" look of a\n * pressed member, so a link row reads as a segmented switch between pages. */\n current?: boolean;\n /** Render through your router's `Link` — see {@link ButtonGroupLinkRenderProps}. */\n renderLink?: (props: ButtonGroupLinkRenderProps) => ReactElement;\n className?: string;\n children: ReactNode;\n ref?: Ref<HTMLAnchorElement>;\n}\n\nconst LINK_CURRENT = \"bg-[var(--brand-bg)] text-[var(--brand)] hover:bg-[var(--brand-bg-hover)]\";\n\n/**\n * A {@link ButtonGroup} member that navigates: a link drawn as a {@link Button}, so it\n * joins the frame like one. A group mixing actions and pages — \"Export\" beside \"Open\n * report\" — had to either make the page a button with an `onClick` navigate (no\n * middle-click, no \"open in new tab\", no link semantics) or style an `<a>` whose\n * corners the group did not know about. Plain `<a>` by default; `renderLink` for the\n * router's `Link`, the kit's usual shape (`Chip`, `MenuItem`, `StatTile`).\n */\nexport function ButtonGroupLink({\n href,\n variant = \"secondary\",\n size,\n current = false,\n renderLink,\n className,\n children,\n ...rest\n}: ButtonGroupLinkProps) {\n const props: ButtonGroupLinkRenderProps = {\n ...rest,\n href,\n \"aria-current\": current ? \"page\" : undefined,\n className: buttonClasses(variant, { size, className: cn(current && LINK_CURRENT, className) }),\n children,\n };\n if (renderLink) return <RenderedGroupLink render={renderLink} {...props} />;\n const { children: content, ...anchor } = props;\n return <a {...anchor}>{content}</a>;\n}\n\n/** Calls `renderLink` as a component, so the router link's hooks are its own. */\nfunction RenderedGroupLink({\n render,\n ...props\n}: ButtonGroupLinkRenderProps & { render: (props: ButtonGroupLinkRenderProps) => ReactElement }) {\n return render(props);\n}\n"],"mappings":";AAiHI;AAhHJ,SAAS,UAAU;AACnB,SAAS,qBAA0D;AAYnE,MAAM,gBAAgB;AAAA,EACpB;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA,EAGA;AACF;AAEA,MAAM,SAAoD;AAAA;AAAA;AAAA;AAAA,EAIxD,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA;AAAA;AAAA,EAGA,UAAU;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAKA,MAAM,SAAoD;AAAA,EACxD,YAAY;AAAA,EACZ,UAAU;AACZ;AAKA,MAAM,kBAAkB;AAIxB,MAAM,kBACJ;AAsCK,SAAS,YAAY;AAAA,EAC1B,cAAc;AAAA,EACd,UAAU;AAAA,EACV,WAAW;AAAA,EACX;AAAA,EACA,GAAG;AACL,GAAqB;AACnB,QAAM,SAAS,YAAY;AAC3B,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,MAAK;AAAA,MACL,oBAAkB;AAAA,MAClB,gBAAc;AAAA,MACd,WAAW;AAAA,QACT,SAAS,OAAO,WAAW,IAAI,OAAO,WAAW;AAAA,QACjD,aAAa,SAAS,kBAAkB;AAAA,QACxC;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;AA+BA,MAAM,eAAe;AAUd,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAyB;AACvB,QAAM,QAAoC;AAAA,IACxC,GAAG;AAAA,IACH;AAAA,IACA,gBAAgB,UAAU,SAAS;AAAA,IACnC,WAAW,cAAc,SAAS,EAAE,MAAM,WAAW,GAAG,WAAW,cAAc,SAAS,EAAE,CAAC;AAAA,IAC7F;AAAA,EACF;AACA,MAAI,WAAY,QAAO,oBAAC,qBAAkB,QAAQ,YAAa,GAAG,OAAO;AACzE,QAAM,EAAE,UAAU,SAAS,GAAG,OAAO,IAAI;AACzC,SAAO,oBAAC,OAAG,GAAG,QAAS,mBAAQ;AACjC;AAGA,SAAS,kBAAkB;AAAA,EACzB;AAAA,EACA,GAAG;AACL,GAAiG;AAC/F,SAAO,OAAO,KAAK;AACrB;","names":[]}
|
|
@@ -2,6 +2,7 @@ import * as react from 'react';
|
|
|
2
2
|
import { CalculatorLabels } from '../i18n/kit-labels.js';
|
|
3
3
|
import './data-table-labels.js';
|
|
4
4
|
import './mini-calendar.js';
|
|
5
|
+
import './calendar-heatmap.js';
|
|
5
6
|
import './popover.js';
|
|
6
7
|
import './chip.js';
|
|
7
8
|
import 'lucide-react';
|
|
@@ -9,6 +10,7 @@ import './field-sync.js';
|
|
|
9
10
|
import './ui.js';
|
|
10
11
|
import './tooltip.js';
|
|
11
12
|
import '../hooks/use-anchored-rect.js';
|
|
13
|
+
import '../lib/clipping.js';
|
|
12
14
|
import '../wizard/types.js';
|
|
13
15
|
import '../tour/tour.js';
|
|
14
16
|
import '../search/command-palette.js';
|
|
@@ -34,6 +36,10 @@ import '../feedback/feedback-dialog.js';
|
|
|
34
36
|
import './confirm-dialog.js';
|
|
35
37
|
import './floating-panel.js';
|
|
36
38
|
import './copy-button.js';
|
|
39
|
+
import './bulk-action-bar.js';
|
|
40
|
+
import './list.js';
|
|
41
|
+
import './breadcrumbs.js';
|
|
42
|
+
import './toast.js';
|
|
37
43
|
|
|
38
44
|
/** Screen-reader names for the calculator panel's own controls — any part of the
|
|
39
45
|
* kit's `calculator` namespace. Once three optional keys of its own; widened, not
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
3
|
+
import { WeekDay } from './mini-calendar.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Every string the heatmap speaks — the `calendarHeatmap` namespace of
|
|
7
|
+
* `<UiKitProvider labels>`, overridable per instance through `labels`. Dates and
|
|
8
|
+
* values arrive already formatted (in `locale`, and through `formatValue`), so the
|
|
9
|
+
* functions only arrange them.
|
|
10
|
+
*/
|
|
11
|
+
interface CalendarHeatmapLabels {
|
|
12
|
+
/** Accessible name of the grid. */
|
|
13
|
+
grid: string;
|
|
14
|
+
/**
|
|
15
|
+
* One day: its accessible name, and the tooltip unless `tooltip` is given. `date`
|
|
16
|
+
* is the whole date in `locale` ("Monday, 14 September 2026"), `value` the day's
|
|
17
|
+
* figure through `formatValue`.
|
|
18
|
+
*/
|
|
19
|
+
day: (date: string, value: string) => string;
|
|
20
|
+
/** The two ends of the legend's scale. */
|
|
21
|
+
less: string;
|
|
22
|
+
more: string;
|
|
23
|
+
/** `maxDays` cut the window: how many of its earliest days are not drawn. */
|
|
24
|
+
truncated: (count: number) => string;
|
|
25
|
+
}
|
|
26
|
+
/** English defaults, exported as the `calendarHeatmap` namespace of `UiKitLabels`. */
|
|
27
|
+
declare const DEFAULT_CALENDAR_HEATMAP_LABELS: CalendarHeatmapLabels;
|
|
28
|
+
/** One day's figure. Several entries for one date are added up. */
|
|
29
|
+
interface CalendarHeatmapDatum {
|
|
30
|
+
/** "YYYY-MM-DD". */
|
|
31
|
+
date: string;
|
|
32
|
+
value: number;
|
|
33
|
+
}
|
|
34
|
+
/** What `tooltip` is told about the day under the pointer. */
|
|
35
|
+
interface CalendarHeatmapDay {
|
|
36
|
+
iso: string;
|
|
37
|
+
date: Date;
|
|
38
|
+
/** The day's figure; `0` when `data` has no entry for it (see `hasData`). */
|
|
39
|
+
value: number;
|
|
40
|
+
hasData: boolean;
|
|
41
|
+
/** `0` = empty … `levels` = the busiest. */
|
|
42
|
+
level: number;
|
|
43
|
+
/** The whole date in `locale`. */
|
|
44
|
+
formattedDate: string;
|
|
45
|
+
/** `value` through `formatValue`. */
|
|
46
|
+
formattedValue: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* `onSelect` is omitted from the `<div>` attributes for the reason `MiniCalendar` gives:
|
|
50
|
+
* the DOM event of that name is a text-selection event, and this one answers with a date.
|
|
51
|
+
*/
|
|
52
|
+
interface CalendarHeatmapProps extends Omit<ComponentPropsWithoutRef<"div">, "onSelect"> {
|
|
53
|
+
data: readonly CalendarHeatmapDatum[];
|
|
54
|
+
/** The window, inclusive, as "YYYY-MM-DD". */
|
|
55
|
+
from: string;
|
|
56
|
+
to: string;
|
|
57
|
+
/**
|
|
58
|
+
* `"weeks"` (default): the contribution-graph shape — one COLUMN per week, the
|
|
59
|
+
* weekdays down the side, month names along the top; a year fits in ~53 small
|
|
60
|
+
* squares and scrolls sideways where it does not. `"month"`: a 7-column calendar
|
|
61
|
+
* with day numbers in large square cells, for a single month on a phone (switch on
|
|
62
|
+
* `useMediaQuery` and narrow `from`/`to` to the month).
|
|
63
|
+
*/
|
|
64
|
+
layout?: "weeks" | "month";
|
|
65
|
+
/** The day shown as selected ("YYYY-MM-DD"). */
|
|
66
|
+
selected?: string;
|
|
67
|
+
/** Makes each day a button: a click (or Enter/Space) selects it — a drill-down into
|
|
68
|
+
* that day's rows, a day panel. Without it the days are focusable but inert. */
|
|
69
|
+
onSelect?: (iso: string) => void;
|
|
70
|
+
/** How a value is written in the tooltip and the day's name. Default: `Intl.NumberFormat`
|
|
71
|
+
* in `locale`. Pass a currency formatter for money. */
|
|
72
|
+
formatValue?: (value: number) => string;
|
|
73
|
+
/** Tooltip content for a day. Default: `labels.day(date, value)`. */
|
|
74
|
+
tooltip?: (day: CalendarHeatmapDay) => ReactNode;
|
|
75
|
+
/**
|
|
76
|
+
* Tag each tooltip `data-private`, so the host's demo-mode rule blurs it (the
|
|
77
|
+
* attribute `Tooltip redact` and `StatTile sensitive` carry). ON by default: a heatmap
|
|
78
|
+
* is almost always the user's own figures, and a missing tag is silent — the grid
|
|
79
|
+
* looks anonymous and the bubble spells the amount out on hover.
|
|
80
|
+
*/
|
|
81
|
+
sensitive?: boolean;
|
|
82
|
+
/** The value that reaches the top of the scale. Default: the largest value ON SCREEN,
|
|
83
|
+
* so a peak outside the window does not wash the drawn days out to empty. */
|
|
84
|
+
max?: number;
|
|
85
|
+
/** How many non-empty intensity steps. Default 4. */
|
|
86
|
+
levels?: number;
|
|
87
|
+
/** The scale's colour, as any CSS colour. Default `var(--brand)`; each step is this
|
|
88
|
+
* mixed into `--bg-surface`, so the ramp follows the theme. */
|
|
89
|
+
color?: string;
|
|
90
|
+
/**
|
|
91
|
+
* The most days to draw. A longer window keeps its LATEST `maxDays` and says how many
|
|
92
|
+
* it left out (`labels.truncated`) rather than silently ending. Default: no cap.
|
|
93
|
+
*/
|
|
94
|
+
maxDays?: number;
|
|
95
|
+
/** Draw the Less … More legend. Default `true`. */
|
|
96
|
+
legend?: boolean;
|
|
97
|
+
/** BCP 47 tag for the dates, month and weekday names and numbers. */
|
|
98
|
+
locale?: string;
|
|
99
|
+
/** `0` = Sunday … `6` = Saturday. Default: the provider's, else the locale's. */
|
|
100
|
+
weekStartsOn?: WeekDay;
|
|
101
|
+
labels?: Partial<CalendarHeatmapLabels>;
|
|
102
|
+
className?: string;
|
|
103
|
+
}
|
|
104
|
+
/** The step a value falls on: 0 for nothing, else 1…levels by its share of `max`. */
|
|
105
|
+
declare function heatmapLevel(value: number, max: number, levels: number): number;
|
|
106
|
+
/**
|
|
107
|
+
* Days as a grid of shaded squares — how much happened on each, at a glance
|
|
108
|
+
* (a contribution graph, a spending calendar).
|
|
109
|
+
*
|
|
110
|
+
* **Every day is a cell you can reach.** The grid is a `role="grid"` with ONE tab
|
|
111
|
+
* stop (the roving tabindex, as in `MiniCalendar`); the arrows move by the grid's own
|
|
112
|
+
* geometry — in `"weeks"` ↑/↓ are the previous/next day and ←/→ a week, in `"month"`
|
|
113
|
+
* the other way round, mirrored in RTL — PageUp/PageDown move a month and Home/End go
|
|
114
|
+
* to the window's first/last day. Each cell is named with its whole date AND its value,
|
|
115
|
+
* because the colour is not something a screen reader can say, and carries
|
|
116
|
+
* `data-day="YYYY-MM-DD"` as its identity for tests and for the host.
|
|
117
|
+
*
|
|
118
|
+
* The tooltip is portalled (a year of squares always sits in a sideways scroller) and
|
|
119
|
+
* `data-private` unless `sensitive={false}`. Cell size in `"weeks"` is the CSS variable
|
|
120
|
+
* `--heatmap-cell` (default `0.75rem`): `style={{ "--heatmap-cell": "1rem" }}`.
|
|
121
|
+
*/
|
|
122
|
+
declare function CalendarHeatmap({ data, from, to, layout, selected, onSelect, formatValue: formatValueProp, tooltip, sensitive, max: maxProp, levels, color, maxDays, legend, locale: localeProp, weekStartsOn, labels: labelsProp, className, "aria-label": ariaLabel, ...rest }: CalendarHeatmapProps): react.JSX.Element;
|
|
123
|
+
|
|
124
|
+
export { CalendarHeatmap, type CalendarHeatmapDatum, type CalendarHeatmapDay, type CalendarHeatmapLabels, type CalendarHeatmapProps, DEFAULT_CALENDAR_HEATMAP_LABELS, heatmapLevel };
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { cn } from "../lib/cn.js";
|
|
5
|
+
import { dirOf, horizontalStep } from "../lib/direction.js";
|
|
6
|
+
import { addMonthsClamped, localeWeekStart, parseIsoDate, toLocalIso } from "../lib/dates.js";
|
|
7
|
+
import { useKitLabels, useKitLocale, useKitWeekStart } from "../i18n/kit-labels.js";
|
|
8
|
+
import { Tooltip } from "./tooltip.js";
|
|
9
|
+
const DEFAULT_CALENDAR_HEATMAP_LABELS = {
|
|
10
|
+
grid: "Daily values",
|
|
11
|
+
day: (date, value) => `${date}: ${value}`,
|
|
12
|
+
less: "Less",
|
|
13
|
+
more: "More",
|
|
14
|
+
truncated: (count) => `Showing the most recent days; ${count} earlier ${count === 1 ? "day is" : "days are"} not shown.`
|
|
15
|
+
};
|
|
16
|
+
const DAY_NAME_FORMAT = {
|
|
17
|
+
weekday: "long",
|
|
18
|
+
day: "numeric",
|
|
19
|
+
month: "long",
|
|
20
|
+
year: "numeric"
|
|
21
|
+
};
|
|
22
|
+
const EMPTY_FILL = "color-mix(in oklab, var(--text-primary) 8%, var(--bg-surface))";
|
|
23
|
+
const weekdayIndex = (d, weekStart) => (d.getDay() - weekStart + 7) % 7;
|
|
24
|
+
function heatmapLevel(value, max, levels) {
|
|
25
|
+
if (!(value > 0) || !(max > 0) || levels < 1) return 0;
|
|
26
|
+
return Math.min(levels, Math.max(1, Math.ceil(value / max * levels)));
|
|
27
|
+
}
|
|
28
|
+
function levelPercent(level, levels) {
|
|
29
|
+
if (levels <= 1) return 100;
|
|
30
|
+
return Math.round(20 + 80 * (level - 1) / (levels - 1));
|
|
31
|
+
}
|
|
32
|
+
function levelFill(level, levels, color) {
|
|
33
|
+
if (level === 0) return EMPTY_FILL;
|
|
34
|
+
return `color-mix(in oklab, ${color} ${levelPercent(level, levels)}%, var(--bg-surface))`;
|
|
35
|
+
}
|
|
36
|
+
function CalendarHeatmap({
|
|
37
|
+
data,
|
|
38
|
+
from,
|
|
39
|
+
to,
|
|
40
|
+
layout = "weeks",
|
|
41
|
+
selected,
|
|
42
|
+
onSelect,
|
|
43
|
+
formatValue: formatValueProp,
|
|
44
|
+
tooltip,
|
|
45
|
+
sensitive = true,
|
|
46
|
+
max: maxProp,
|
|
47
|
+
levels = 4,
|
|
48
|
+
color = "var(--brand)",
|
|
49
|
+
maxDays,
|
|
50
|
+
legend = true,
|
|
51
|
+
locale: localeProp,
|
|
52
|
+
weekStartsOn,
|
|
53
|
+
labels: labelsProp,
|
|
54
|
+
className,
|
|
55
|
+
"aria-label": ariaLabel,
|
|
56
|
+
...rest
|
|
57
|
+
}) {
|
|
58
|
+
const labels = useKitLabels("calendarHeatmap", DEFAULT_CALENDAR_HEATMAP_LABELS, labelsProp);
|
|
59
|
+
const locale = useKitLocale(localeProp);
|
|
60
|
+
const providerWeekStart = useKitWeekStart();
|
|
61
|
+
const weekStart = weekStartsOn ?? providerWeekStart ?? localeWeekStart(locale);
|
|
62
|
+
const numberFormat = useMemo(() => new Intl.NumberFormat(locale), [locale]);
|
|
63
|
+
const formatValue = formatValueProp ?? ((v) => numberFormat.format(v));
|
|
64
|
+
const values = useMemo(() => {
|
|
65
|
+
const m = /* @__PURE__ */ new Map();
|
|
66
|
+
for (const p of data) m.set(p.date, (m.get(p.date) ?? 0) + p.value);
|
|
67
|
+
return m;
|
|
68
|
+
}, [data]);
|
|
69
|
+
const { days, dropped } = useMemo(() => {
|
|
70
|
+
const start = parseIsoDate(from);
|
|
71
|
+
const end = parseIsoDate(to);
|
|
72
|
+
const list = [];
|
|
73
|
+
if (!start || !end || end < start) return { days: list, dropped: 0 };
|
|
74
|
+
const cursor = new Date(end);
|
|
75
|
+
const cap = maxDays && maxDays > 0 ? maxDays : Infinity;
|
|
76
|
+
while (cursor >= start && list.length < cap) {
|
|
77
|
+
list.unshift(new Date(cursor));
|
|
78
|
+
cursor.setDate(cursor.getDate() - 1);
|
|
79
|
+
}
|
|
80
|
+
const first = list[0];
|
|
81
|
+
const trimmed = first ? Math.round((first.getTime() - start.getTime()) / 864e5) : 0;
|
|
82
|
+
return { days: list, dropped: Math.max(0, trimmed) };
|
|
83
|
+
}, [from, to, maxDays]);
|
|
84
|
+
const firstIso = days.length ? toLocalIso(days[0]) : "";
|
|
85
|
+
const lastIso = days.length ? toLocalIso(days[days.length - 1]) : "";
|
|
86
|
+
const max = useMemo(() => {
|
|
87
|
+
if (maxProp !== void 0) return maxProp;
|
|
88
|
+
let m = 0;
|
|
89
|
+
for (const d of days) m = Math.max(m, values.get(toLocalIso(d)) ?? 0);
|
|
90
|
+
return m;
|
|
91
|
+
}, [maxProp, days, values]);
|
|
92
|
+
const clampIso = (iso) => iso < firstIso ? firstIso : iso > lastIso ? lastIso : iso;
|
|
93
|
+
const [activeState, setActiveIso] = useState(() => selected || lastIso);
|
|
94
|
+
const [lastSelected, setLastSelected] = useState(selected);
|
|
95
|
+
if (lastSelected !== selected) {
|
|
96
|
+
setLastSelected(selected);
|
|
97
|
+
if (selected) setActiveIso(selected);
|
|
98
|
+
}
|
|
99
|
+
const activeIso = days.length ? clampIso(activeState || lastIso) : "";
|
|
100
|
+
const gridRef = useRef(null);
|
|
101
|
+
const scrollerRef = useRef(null);
|
|
102
|
+
const pendingFocus = useRef(null);
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
const iso = pendingFocus.current;
|
|
105
|
+
if (!iso) return;
|
|
106
|
+
pendingFocus.current = null;
|
|
107
|
+
gridRef.current?.querySelector(`[data-day="${iso}"]`)?.focus();
|
|
108
|
+
});
|
|
109
|
+
useLayoutEffect(() => {
|
|
110
|
+
const el = scrollerRef.current;
|
|
111
|
+
if (!el || layout !== "weeks") return;
|
|
112
|
+
const toEnd = () => {
|
|
113
|
+
el.scrollLeft = dirOf(el) === "rtl" ? -el.scrollWidth : el.scrollWidth;
|
|
114
|
+
};
|
|
115
|
+
toEnd();
|
|
116
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
117
|
+
let pinned = true;
|
|
118
|
+
const onScroll = () => {
|
|
119
|
+
pinned = Math.abs(el.scrollLeft) >= el.scrollWidth - el.clientWidth - 1;
|
|
120
|
+
};
|
|
121
|
+
const ro = new ResizeObserver(() => {
|
|
122
|
+
if (pinned) toEnd();
|
|
123
|
+
});
|
|
124
|
+
el.addEventListener("scroll", onScroll, { passive: true });
|
|
125
|
+
ro.observe(el);
|
|
126
|
+
return () => {
|
|
127
|
+
ro.disconnect();
|
|
128
|
+
el.removeEventListener("scroll", onScroll);
|
|
129
|
+
};
|
|
130
|
+
}, [layout, firstIso, lastIso]);
|
|
131
|
+
const formatDay = (d) => d.toLocaleDateString(locale, DAY_NAME_FORMAT);
|
|
132
|
+
const weekdayLabels = useMemo(() => {
|
|
133
|
+
const ref = new Date(2024, 0, 7 + weekStart);
|
|
134
|
+
return Array.from({ length: 7 }, (_, i) => {
|
|
135
|
+
const d = new Date(ref);
|
|
136
|
+
d.setDate(ref.getDate() + i);
|
|
137
|
+
return {
|
|
138
|
+
short: d.toLocaleDateString(locale, { weekday: "short" }),
|
|
139
|
+
long: d.toLocaleDateString(locale, { weekday: "long" })
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
}, [locale, weekStart]);
|
|
143
|
+
const lead = days.length ? weekdayIndex(days[0], weekStart) : 0;
|
|
144
|
+
const weekCount = Math.ceil((lead + days.length) / 7);
|
|
145
|
+
const dayAt = (i) => i >= lead && i - lead < days.length ? days[i - lead] : null;
|
|
146
|
+
const move = (e) => {
|
|
147
|
+
const current = parseIsoDate(activeIso);
|
|
148
|
+
if (!current) return;
|
|
149
|
+
const next = new Date(current);
|
|
150
|
+
const step = horizontalStep(e.key, e.currentTarget);
|
|
151
|
+
const across = layout === "weeks" ? 7 : 1;
|
|
152
|
+
const down = layout === "weeks" ? 1 : 7;
|
|
153
|
+
switch (step ? "horizontal" : e.key) {
|
|
154
|
+
case "horizontal":
|
|
155
|
+
next.setDate(next.getDate() + step * across);
|
|
156
|
+
break;
|
|
157
|
+
case "ArrowUp":
|
|
158
|
+
next.setDate(next.getDate() - down);
|
|
159
|
+
break;
|
|
160
|
+
case "ArrowDown":
|
|
161
|
+
next.setDate(next.getDate() + down);
|
|
162
|
+
break;
|
|
163
|
+
case "PageUp":
|
|
164
|
+
next.setTime(addMonthsClamped(next, -1).getTime());
|
|
165
|
+
break;
|
|
166
|
+
case "PageDown":
|
|
167
|
+
next.setTime(addMonthsClamped(next, 1).getTime());
|
|
168
|
+
break;
|
|
169
|
+
case "Home":
|
|
170
|
+
next.setTime(days[0].getTime());
|
|
171
|
+
break;
|
|
172
|
+
case "End":
|
|
173
|
+
next.setTime(days[days.length - 1].getTime());
|
|
174
|
+
break;
|
|
175
|
+
default:
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
e.preventDefault();
|
|
179
|
+
const iso = clampIso(toLocalIso(next));
|
|
180
|
+
if (iso === activeIso) return;
|
|
181
|
+
pendingFocus.current = iso;
|
|
182
|
+
setActiveIso(iso);
|
|
183
|
+
};
|
|
184
|
+
const legendLevels = Array.from({ length: levels + 1 }, (_, l) => l);
|
|
185
|
+
const cell = (d, wrapClass, cellClass, withNumber) => {
|
|
186
|
+
const iso = toLocalIso(d);
|
|
187
|
+
const raw = values.get(iso);
|
|
188
|
+
const value = raw ?? 0;
|
|
189
|
+
const level = heatmapLevel(value, max, levels);
|
|
190
|
+
const fill = levelFill(level, levels, color);
|
|
191
|
+
const formattedDate = formatDay(d);
|
|
192
|
+
const formattedValue = formatValue(value);
|
|
193
|
+
const name = labels.day(formattedDate, formattedValue);
|
|
194
|
+
const label = tooltip ? tooltip({ iso, date: d, value, hasData: raw !== void 0, level, formattedDate, formattedValue }) : name;
|
|
195
|
+
const isSelected = selected === iso;
|
|
196
|
+
const strong = level > 0 && levelPercent(level, levels) >= 45;
|
|
197
|
+
const shared = {
|
|
198
|
+
role: "gridcell",
|
|
199
|
+
"data-day": iso,
|
|
200
|
+
"data-level": level,
|
|
201
|
+
tabIndex: iso === activeIso ? 0 : -1,
|
|
202
|
+
"aria-label": name,
|
|
203
|
+
"aria-selected": onSelect ? isSelected : void 0,
|
|
204
|
+
onKeyDown: move,
|
|
205
|
+
onFocus: () => {
|
|
206
|
+
if (iso !== activeIso) setActiveIso(iso);
|
|
207
|
+
},
|
|
208
|
+
style: { background: fill, color: strong ? "var(--bg-surface)" : "var(--text-primary)" },
|
|
209
|
+
className: cn(
|
|
210
|
+
cellClass,
|
|
211
|
+
isSelected && "ring-2 ring-[var(--text-primary)]",
|
|
212
|
+
onSelect && "cursor-pointer hover:ring-1 hover:ring-[var(--brand)]"
|
|
213
|
+
)
|
|
214
|
+
};
|
|
215
|
+
const inner = withNumber ? /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "text-[11px] leading-none tabular-nums", children: numberFormat.format(d.getDate()) }) : null;
|
|
216
|
+
return /* @__PURE__ */ jsx(Tooltip, { label, portal: true, redact: sensitive, role: "none", className: wrapClass, children: onSelect ? /* @__PURE__ */ jsx("button", { type: "button", ...shared, onClick: () => onSelect(iso), children: inner }) : /* @__PURE__ */ jsx("div", { ...shared, children: inner }) }, iso);
|
|
217
|
+
};
|
|
218
|
+
const gridName = ariaLabel ?? labels.grid;
|
|
219
|
+
let body;
|
|
220
|
+
if (layout === "weeks") {
|
|
221
|
+
const columns = { gridTemplateColumns: `var(--heatmap-label, 2rem) repeat(${weekCount}, var(--heatmap-cell, 0.75rem))` };
|
|
222
|
+
const cellSize = "size-[var(--heatmap-cell,0.75rem)]";
|
|
223
|
+
const monthLabels = Array.from({ length: weekCount }, (_, w) => {
|
|
224
|
+
for (let r = 0; r < 7; r++) {
|
|
225
|
+
const d = dayAt(w * 7 + r);
|
|
226
|
+
if (d && (d.getDate() === 1 || w === 0 && r === lead && d.getDate() <= 14)) {
|
|
227
|
+
return d.toLocaleDateString(locale, { month: "short" });
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return "";
|
|
231
|
+
});
|
|
232
|
+
body = /* @__PURE__ */ jsx("div", { ref: scrollerRef, className: "overflow-x-auto pb-1", children: /* @__PURE__ */ jsxs("div", { ref: gridRef, role: "grid", "aria-label": gridName, className: "inline-grid gap-0.5", children: [
|
|
233
|
+
/* @__PURE__ */ jsxs("div", { "aria-hidden": true, className: "grid gap-0.5 text-[10px] leading-3 text-[var(--text-muted)]", style: columns, children: [
|
|
234
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
235
|
+
monthLabels.map((m, w) => /* @__PURE__ */ jsx("span", { className: "overflow-visible whitespace-nowrap", children: m }, w))
|
|
236
|
+
] }),
|
|
237
|
+
Array.from({ length: 7 }, (_, r) => /* @__PURE__ */ jsxs("div", { role: "row", className: "grid gap-0.5", style: columns, children: [
|
|
238
|
+
/* @__PURE__ */ jsx(
|
|
239
|
+
"div",
|
|
240
|
+
{
|
|
241
|
+
role: "rowheader",
|
|
242
|
+
"aria-label": weekdayLabels[r].long,
|
|
243
|
+
className: "overflow-hidden pe-1 text-[10px] leading-3 text-[var(--text-muted)]",
|
|
244
|
+
children: r % 2 === 1 ? weekdayLabels[r].short : ""
|
|
245
|
+
}
|
|
246
|
+
),
|
|
247
|
+
Array.from({ length: weekCount }, (_2, w) => {
|
|
248
|
+
const d = dayAt(w * 7 + r);
|
|
249
|
+
return d ? cell(d, cellSize, cn(cellSize, "block rounded-sm"), false) : /* @__PURE__ */ jsx("div", { role: "gridcell", className: cellSize }, `pad-${w}`);
|
|
250
|
+
})
|
|
251
|
+
] }, r))
|
|
252
|
+
] }) });
|
|
253
|
+
} else {
|
|
254
|
+
const rows = Array.from({ length: weekCount }, (_, w) => w);
|
|
255
|
+
body = /* @__PURE__ */ jsxs("div", { ref: gridRef, role: "grid", "aria-label": gridName, className: "grid gap-1", children: [
|
|
256
|
+
/* @__PURE__ */ jsx("div", { role: "row", className: "grid grid-cols-7 gap-1", children: weekdayLabels.map((w, i) => /* @__PURE__ */ jsx(
|
|
257
|
+
"div",
|
|
258
|
+
{
|
|
259
|
+
role: "columnheader",
|
|
260
|
+
"aria-label": w.long,
|
|
261
|
+
className: "pb-0.5 text-center text-[10px] uppercase tracking-wide text-[var(--text-muted)]",
|
|
262
|
+
children: w.short
|
|
263
|
+
},
|
|
264
|
+
i
|
|
265
|
+
)) }),
|
|
266
|
+
rows.map((w) => /* @__PURE__ */ jsx("div", { role: "row", className: "grid grid-cols-7 gap-1", children: Array.from({ length: 7 }, (_, c) => {
|
|
267
|
+
const d = dayAt(w * 7 + c);
|
|
268
|
+
return d ? cell(d, "aspect-square w-full", "flex h-full w-full items-center justify-center rounded", true) : /* @__PURE__ */ jsx("div", { role: "gridcell", className: "aspect-square" }, `pad-${c}`);
|
|
269
|
+
}) }, w))
|
|
270
|
+
] });
|
|
271
|
+
}
|
|
272
|
+
return /* @__PURE__ */ jsxs("div", { ...rest, className: cn("min-w-0", className), children: [
|
|
273
|
+
dropped > 0 && /* @__PURE__ */ jsx("div", { className: "mb-2 text-xs text-[var(--text-muted)]", children: labels.truncated(dropped) }),
|
|
274
|
+
body,
|
|
275
|
+
legend && /* @__PURE__ */ jsxs("div", { "aria-hidden": true, className: "mt-2 flex items-center justify-end gap-1 text-[10px] text-[var(--text-muted)]", children: [
|
|
276
|
+
/* @__PURE__ */ jsx("span", { className: "me-0.5", children: labels.less }),
|
|
277
|
+
legendLevels.map((l) => /* @__PURE__ */ jsx(
|
|
278
|
+
"span",
|
|
279
|
+
{
|
|
280
|
+
"data-legend-level": l,
|
|
281
|
+
className: "size-2.5 rounded-sm",
|
|
282
|
+
style: { background: levelFill(l, levels, color) }
|
|
283
|
+
},
|
|
284
|
+
l
|
|
285
|
+
)),
|
|
286
|
+
/* @__PURE__ */ jsx("span", { className: "ms-0.5", children: labels.more })
|
|
287
|
+
] })
|
|
288
|
+
] });
|
|
289
|
+
}
|
|
290
|
+
export {
|
|
291
|
+
CalendarHeatmap,
|
|
292
|
+
DEFAULT_CALENDAR_HEATMAP_LABELS,
|
|
293
|
+
heatmapLevel
|
|
294
|
+
};
|
|
295
|
+
//# sourceMappingURL=calendar-heatmap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/calendar-heatmap.tsx"],"sourcesContent":["import { useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, CSSProperties, KeyboardEvent, ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { dirOf, horizontalStep } from \"../lib/direction\";\nimport { addMonthsClamped, localeWeekStart, parseIsoDate, toLocalIso } from \"../lib/dates\";\nimport { useKitLabels, useKitLocale, useKitWeekStart } from \"../i18n/kit-labels\";\nimport { Tooltip } from \"./tooltip\";\nimport type { WeekDay } from \"./mini-calendar\";\n\n/**\n * Every string the heatmap speaks — the `calendarHeatmap` namespace of\n * `<UiKitProvider labels>`, overridable per instance through `labels`. Dates and\n * values arrive already formatted (in `locale`, and through `formatValue`), so the\n * functions only arrange them.\n */\nexport interface CalendarHeatmapLabels {\n /** Accessible name of the grid. */\n grid: string;\n /**\n * One day: its accessible name, and the tooltip unless `tooltip` is given. `date`\n * is the whole date in `locale` (\"Monday, 14 September 2026\"), `value` the day's\n * figure through `formatValue`.\n */\n day: (date: string, value: string) => string;\n /** The two ends of the legend's scale. */\n less: string;\n more: string;\n /** `maxDays` cut the window: how many of its earliest days are not drawn. */\n truncated: (count: number) => string;\n}\n\n/** English defaults, exported as the `calendarHeatmap` namespace of `UiKitLabels`. */\nexport const DEFAULT_CALENDAR_HEATMAP_LABELS: CalendarHeatmapLabels = {\n grid: \"Daily values\",\n day: (date, value) => `${date}: ${value}`,\n less: \"Less\",\n more: \"More\",\n truncated: (count) =>\n `Showing the most recent days; ${count} earlier ${count === 1 ? \"day is\" : \"days are\"} not shown.`,\n};\n\n/** One day's figure. Several entries for one date are added up. */\nexport interface CalendarHeatmapDatum {\n /** \"YYYY-MM-DD\". */\n date: string;\n value: number;\n}\n\n/** What `tooltip` is told about the day under the pointer. */\nexport interface CalendarHeatmapDay {\n iso: string;\n date: Date;\n /** The day's figure; `0` when `data` has no entry for it (see `hasData`). */\n value: number;\n hasData: boolean;\n /** `0` = empty … `levels` = the busiest. */\n level: number;\n /** The whole date in `locale`. */\n formattedDate: string;\n /** `value` through `formatValue`. */\n formattedValue: string;\n}\n\n/**\n * `onSelect` is omitted from the `<div>` attributes for the reason `MiniCalendar` gives:\n * the DOM event of that name is a text-selection event, and this one answers with a date.\n */\nexport interface CalendarHeatmapProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"onSelect\"> {\n data: readonly CalendarHeatmapDatum[];\n /** The window, inclusive, as \"YYYY-MM-DD\". */\n from: string;\n to: string;\n /**\n * `\"weeks\"` (default): the contribution-graph shape — one COLUMN per week, the\n * weekdays down the side, month names along the top; a year fits in ~53 small\n * squares and scrolls sideways where it does not. `\"month\"`: a 7-column calendar\n * with day numbers in large square cells, for a single month on a phone (switch on\n * `useMediaQuery` and narrow `from`/`to` to the month).\n */\n layout?: \"weeks\" | \"month\";\n /** The day shown as selected (\"YYYY-MM-DD\"). */\n selected?: string;\n /** Makes each day a button: a click (or Enter/Space) selects it — a drill-down into\n * that day's rows, a day panel. Without it the days are focusable but inert. */\n onSelect?: (iso: string) => void;\n /** How a value is written in the tooltip and the day's name. Default: `Intl.NumberFormat`\n * in `locale`. Pass a currency formatter for money. */\n formatValue?: (value: number) => string;\n /** Tooltip content for a day. Default: `labels.day(date, value)`. */\n tooltip?: (day: CalendarHeatmapDay) => ReactNode;\n /**\n * Tag each tooltip `data-private`, so the host's demo-mode rule blurs it (the\n * attribute `Tooltip redact` and `StatTile sensitive` carry). ON by default: a heatmap\n * is almost always the user's own figures, and a missing tag is silent — the grid\n * looks anonymous and the bubble spells the amount out on hover.\n */\n sensitive?: boolean;\n /** The value that reaches the top of the scale. Default: the largest value ON SCREEN,\n * so a peak outside the window does not wash the drawn days out to empty. */\n max?: number;\n /** How many non-empty intensity steps. Default 4. */\n levels?: number;\n /** The scale's colour, as any CSS colour. Default `var(--brand)`; each step is this\n * mixed into `--bg-surface`, so the ramp follows the theme. */\n color?: string;\n /**\n * The most days to draw. A longer window keeps its LATEST `maxDays` and says how many\n * it left out (`labels.truncated`) rather than silently ending. Default: no cap.\n */\n maxDays?: number;\n /** Draw the Less … More legend. Default `true`. */\n legend?: boolean;\n /** BCP 47 tag for the dates, month and weekday names and numbers. */\n locale?: string;\n /** `0` = Sunday … `6` = Saturday. Default: the provider's, else the locale's. */\n weekStartsOn?: WeekDay;\n labels?: Partial<CalendarHeatmapLabels>;\n className?: string;\n}\n\nconst DAY_NAME_FORMAT: Intl.DateTimeFormatOptions = {\n weekday: \"long\",\n day: \"numeric\",\n month: \"long\",\n year: \"numeric\",\n};\n\n/** The empty day: a wash of the text colour, like `--bg-hover`, so it reads as a cell\n * on both themes without claiming any value. */\nconst EMPTY_FILL = \"color-mix(in oklab, var(--text-primary) 8%, var(--bg-surface))\";\n\nconst weekdayIndex = (d: Date, weekStart: WeekDay) => (d.getDay() - weekStart + 7) % 7;\n\n/** The step a value falls on: 0 for nothing, else 1…levels by its share of `max`. */\nexport function heatmapLevel(value: number, max: number, levels: number): number {\n if (!(value > 0) || !(max > 0) || levels < 1) return 0;\n return Math.min(levels, Math.max(1, Math.ceil((value / max) * levels)));\n}\n\n/** How much of `color` a step mixes into the surface: 20% for the first step, 100% for\n * the last — the floor keeps the smallest value visibly apart from an empty day. */\nfunction levelPercent(level: number, levels: number): number {\n if (levels <= 1) return 100;\n return Math.round(20 + (80 * (level - 1)) / (levels - 1));\n}\n\nfunction levelFill(level: number, levels: number, color: string): string {\n if (level === 0) return EMPTY_FILL;\n return `color-mix(in oklab, ${color} ${levelPercent(level, levels)}%, var(--bg-surface))`;\n}\n\n/**\n * Days as a grid of shaded squares — how much happened on each, at a glance\n * (a contribution graph, a spending calendar).\n *\n * **Every day is a cell you can reach.** The grid is a `role=\"grid\"` with ONE tab\n * stop (the roving tabindex, as in `MiniCalendar`); the arrows move by the grid's own\n * geometry — in `\"weeks\"` ↑/↓ are the previous/next day and ←/→ a week, in `\"month\"`\n * the other way round, mirrored in RTL — PageUp/PageDown move a month and Home/End go\n * to the window's first/last day. Each cell is named with its whole date AND its value,\n * because the colour is not something a screen reader can say, and carries\n * `data-day=\"YYYY-MM-DD\"` as its identity for tests and for the host.\n *\n * The tooltip is portalled (a year of squares always sits in a sideways scroller) and\n * `data-private` unless `sensitive={false}`. Cell size in `\"weeks\"` is the CSS variable\n * `--heatmap-cell` (default `0.75rem`): `style={{ \"--heatmap-cell\": \"1rem\" }}`.\n */\nexport function CalendarHeatmap({\n data,\n from,\n to,\n layout = \"weeks\",\n selected,\n onSelect,\n formatValue: formatValueProp,\n tooltip,\n sensitive = true,\n max: maxProp,\n levels = 4,\n color = \"var(--brand)\",\n maxDays,\n legend = true,\n locale: localeProp,\n weekStartsOn,\n labels: labelsProp,\n className,\n \"aria-label\": ariaLabel,\n ...rest\n}: CalendarHeatmapProps) {\n const labels = useKitLabels(\"calendarHeatmap\", DEFAULT_CALENDAR_HEATMAP_LABELS, labelsProp);\n const locale = useKitLocale(localeProp);\n const providerWeekStart = useKitWeekStart();\n const weekStart: WeekDay = weekStartsOn ?? providerWeekStart ?? localeWeekStart(locale);\n const numberFormat = useMemo(() => new Intl.NumberFormat(locale), [locale]);\n const formatValue = formatValueProp ?? ((v: number) => numberFormat.format(v));\n\n const values = useMemo(() => {\n const m = new Map<string, number>();\n for (const p of data) m.set(p.date, (m.get(p.date) ?? 0) + p.value);\n return m;\n }, [data]);\n\n // The window, trimmed from the FRONT: the days a person looks for are the recent\n // ones, and a cap that kept the oldest would end the calendar before today.\n const { days, dropped } = useMemo(() => {\n const start = parseIsoDate(from);\n const end = parseIsoDate(to);\n const list: Date[] = [];\n if (!start || !end || end < start) return { days: list, dropped: 0 };\n const cursor = new Date(end);\n const cap = maxDays && maxDays > 0 ? maxDays : Infinity;\n while (cursor >= start && list.length < cap) {\n list.unshift(new Date(cursor));\n cursor.setDate(cursor.getDate() - 1);\n }\n const first = list[0];\n const trimmed = first ? Math.round((first.getTime() - start.getTime()) / 86_400_000) : 0;\n return { days: list, dropped: Math.max(0, trimmed) };\n }, [from, to, maxDays]);\n\n const firstIso = days.length ? toLocalIso(days[0]) : \"\";\n const lastIso = days.length ? toLocalIso(days[days.length - 1]) : \"\";\n\n const max = useMemo(() => {\n if (maxProp !== undefined) return maxProp;\n let m = 0;\n for (const d of days) m = Math.max(m, values.get(toLocalIso(d)) ?? 0);\n return m;\n }, [maxProp, days, values]);\n\n const clampIso = (iso: string) => (iso < firstIso ? firstIso : iso > lastIso ? lastIso : iso);\n\n // The roving tab stop: the selected day, else the latest one.\n const [activeState, setActiveIso] = useState(() => selected || lastIso);\n const [lastSelected, setLastSelected] = useState(selected);\n if (lastSelected !== selected) {\n setLastSelected(selected);\n if (selected) setActiveIso(selected);\n }\n const activeIso = days.length ? clampIso(activeState || lastIso) : \"\";\n\n const gridRef = useRef<HTMLDivElement>(null);\n const scrollerRef = useRef<HTMLDivElement>(null);\n const pendingFocus = useRef<string | null>(null);\n useEffect(() => {\n const iso = pendingFocus.current;\n if (!iso) return;\n pendingFocus.current = null;\n gridRef.current?.querySelector<HTMLElement>(`[data-day=\"${iso}\"]`)?.focus();\n });\n\n // Open the sideways scroller on the latest weeks, not the oldest. In RTL the end is\n // on the left, where browsers count scrollLeft down from 0.\n //\n // And KEEP it there while the box changes size — a sidebar or a contents rail that\n // appears after mount narrows the scroller, which leaves scrollLeft where it was and\n // so shows older weeks than it opened on. The pin holds only while the view sits at\n // the end: a user who scrolls back through the year unpins it, and a resize then\n // leaves their position alone. (Scrolling back to the end pins it again.)\n useLayoutEffect(() => {\n const el = scrollerRef.current;\n if (!el || layout !== \"weeks\") return;\n const toEnd = () => {\n el.scrollLeft = dirOf(el) === \"rtl\" ? -el.scrollWidth : el.scrollWidth;\n };\n toEnd();\n if (typeof ResizeObserver === \"undefined\") return;\n // |scrollLeft| covers both directions: 0 → max in LTR, 0 → -max in RTL.\n let pinned = true;\n const onScroll = () => {\n pinned = Math.abs(el.scrollLeft) >= el.scrollWidth - el.clientWidth - 1;\n };\n const ro = new ResizeObserver(() => {\n if (pinned) toEnd();\n });\n el.addEventListener(\"scroll\", onScroll, { passive: true });\n ro.observe(el);\n return () => {\n ro.disconnect();\n el.removeEventListener(\"scroll\", onScroll);\n };\n }, [layout, firstIso, lastIso]);\n\n const formatDay = (d: Date) => d.toLocaleDateString(locale, DAY_NAME_FORMAT);\n\n const weekdayLabels = useMemo(() => {\n const ref = new Date(2024, 0, 7 + weekStart); // 7 January 2024 was a Sunday\n return Array.from({ length: 7 }, (_, i) => {\n const d = new Date(ref);\n d.setDate(ref.getDate() + i);\n return {\n short: d.toLocaleDateString(locale, { weekday: \"short\" }),\n long: d.toLocaleDateString(locale, { weekday: \"long\" }),\n };\n });\n }, [locale, weekStart]);\n\n const lead = days.length ? weekdayIndex(days[0], weekStart) : 0;\n const weekCount = Math.ceil((lead + days.length) / 7);\n /** The day at position `i` of the week-aligned sequence (blanks before the first). */\n const dayAt = (i: number): Date | null => (i >= lead && i - lead < days.length ? days[i - lead] : null);\n\n const move = (e: KeyboardEvent<HTMLElement>) => {\n const current = parseIsoDate(activeIso);\n if (!current) return;\n const next = new Date(current);\n const step = horizontalStep(e.key, e.currentTarget);\n // In \"weeks\" a row is a weekday, so sideways is a week and up/down is a day.\n const across = layout === \"weeks\" ? 7 : 1;\n const down = layout === \"weeks\" ? 1 : 7;\n switch (step ? \"horizontal\" : e.key) {\n case \"horizontal\":\n next.setDate(next.getDate() + step * across);\n break;\n case \"ArrowUp\":\n next.setDate(next.getDate() - down);\n break;\n case \"ArrowDown\":\n next.setDate(next.getDate() + down);\n break;\n case \"PageUp\":\n next.setTime(addMonthsClamped(next, -1).getTime());\n break;\n case \"PageDown\":\n next.setTime(addMonthsClamped(next, 1).getTime());\n break;\n case \"Home\":\n next.setTime(days[0].getTime());\n break;\n case \"End\":\n next.setTime(days[days.length - 1].getTime());\n break;\n default:\n return;\n }\n e.preventDefault();\n const iso = clampIso(toLocalIso(next));\n if (iso === activeIso) return;\n pendingFocus.current = iso;\n setActiveIso(iso);\n };\n\n const legendLevels = Array.from({ length: levels + 1 }, (_, l) => l);\n\n const cell = (d: Date, wrapClass: string, cellClass: string, withNumber: boolean) => {\n const iso = toLocalIso(d);\n const raw = values.get(iso);\n const value = raw ?? 0;\n const level = heatmapLevel(value, max, levels);\n const fill = levelFill(level, levels, color);\n const formattedDate = formatDay(d);\n const formattedValue = formatValue(value);\n const name = labels.day(formattedDate, formattedValue);\n const label = tooltip\n ? tooltip({ iso, date: d, value, hasData: raw !== undefined, level, formattedDate, formattedValue })\n : name;\n const isSelected = selected === iso;\n // Light text once the fill is the stronger half of the mix — `--bg-surface` is the\n // colour the scale is mixed INTO, so it is the one that contrasts with its far end\n // on either theme.\n const strong = level > 0 && levelPercent(level, levels) >= 45;\n const shared = {\n role: \"gridcell\",\n \"data-day\": iso,\n \"data-level\": level,\n tabIndex: iso === activeIso ? 0 : -1,\n \"aria-label\": name,\n \"aria-selected\": onSelect ? isSelected : undefined,\n onKeyDown: move,\n onFocus: () => {\n if (iso !== activeIso) setActiveIso(iso);\n },\n style: { background: fill, color: strong ? \"var(--bg-surface)\" : \"var(--text-primary)\" },\n className: cn(\n cellClass,\n isSelected && \"ring-2 ring-[var(--text-primary)]\",\n onSelect && \"cursor-pointer hover:ring-1 hover:ring-[var(--brand)]\",\n ),\n } as const;\n const inner = withNumber ? (\n <span aria-hidden className=\"text-[11px] leading-none tabular-nums\">\n {numberFormat.format(d.getDate())}\n </span>\n ) : null;\n return (\n <Tooltip key={iso} label={label} portal redact={sensitive} role=\"none\" className={wrapClass}>\n {onSelect ? (\n <button type=\"button\" {...shared} onClick={() => onSelect(iso)}>\n {inner}\n </button>\n ) : (\n <div {...shared}>{inner}</div>\n )}\n </Tooltip>\n );\n };\n\n const gridName = ariaLabel ?? labels.grid;\n let body: ReactNode;\n if (layout === \"weeks\") {\n const columns = { gridTemplateColumns: `var(--heatmap-label, 2rem) repeat(${weekCount}, var(--heatmap-cell, 0.75rem))` } as CSSProperties;\n const cellSize = \"size-[var(--heatmap-cell,0.75rem)]\";\n // A month's name over the first column that holds its 1st — or over the first\n // column, when the window opens far enough before the next month for it to fit.\n const monthLabels = Array.from({ length: weekCount }, (_, w) => {\n for (let r = 0; r < 7; r++) {\n const d = dayAt(w * 7 + r);\n if (d && (d.getDate() === 1 || (w === 0 && r === lead && d.getDate() <= 14))) {\n return d.toLocaleDateString(locale, { month: \"short\" });\n }\n }\n return \"\";\n });\n body = (\n <div ref={scrollerRef} className=\"overflow-x-auto pb-1\">\n <div ref={gridRef} role=\"grid\" aria-label={gridName} className=\"inline-grid gap-0.5\">\n {/* Decoration: every cell's name already carries its month. */}\n <div aria-hidden className=\"grid gap-0.5 text-[10px] leading-3 text-[var(--text-muted)]\" style={columns}>\n <span />\n {monthLabels.map((m, w) => (\n <span key={w} className=\"overflow-visible whitespace-nowrap\">\n {m}\n </span>\n ))}\n </div>\n {Array.from({ length: 7 }, (_, r) => (\n <div key={r} role=\"row\" className=\"grid gap-0.5\" style={columns}>\n <div\n role=\"rowheader\"\n aria-label={weekdayLabels[r].long}\n className=\"overflow-hidden pe-1 text-[10px] leading-3 text-[var(--text-muted)]\"\n >\n {/* Every other weekday, as a contribution graph does: seven labels\n at this size are a smear. The name is there for all seven. */}\n {r % 2 === 1 ? weekdayLabels[r].short : \"\"}\n </div>\n {Array.from({ length: weekCount }, (_, w) => {\n const d = dayAt(w * 7 + r);\n return d ? (\n cell(d, cellSize, cn(cellSize, \"block rounded-sm\"), false)\n ) : (\n <div key={`pad-${w}`} role=\"gridcell\" className={cellSize} />\n );\n })}\n </div>\n ))}\n </div>\n </div>\n );\n } else {\n const rows = Array.from({ length: weekCount }, (_, w) => w);\n body = (\n <div ref={gridRef} role=\"grid\" aria-label={gridName} className=\"grid gap-1\">\n <div role=\"row\" className=\"grid grid-cols-7 gap-1\">\n {weekdayLabels.map((w, i) => (\n <div\n key={i}\n role=\"columnheader\"\n aria-label={w.long}\n className=\"pb-0.5 text-center text-[10px] uppercase tracking-wide text-[var(--text-muted)]\"\n >\n {w.short}\n </div>\n ))}\n </div>\n {rows.map((w) => (\n <div key={w} role=\"row\" className=\"grid grid-cols-7 gap-1\">\n {Array.from({ length: 7 }, (_, c) => {\n const d = dayAt(w * 7 + c);\n return d ? (\n cell(d, \"aspect-square w-full\", \"flex h-full w-full items-center justify-center rounded\", true)\n ) : (\n <div key={`pad-${c}`} role=\"gridcell\" className=\"aspect-square\" />\n );\n })}\n </div>\n ))}\n </div>\n );\n }\n\n return (\n <div {...rest} className={cn(\"min-w-0\", className)}>\n {dropped > 0 && (\n <div className=\"mb-2 text-xs text-[var(--text-muted)]\">{labels.truncated(dropped)}</div>\n )}\n {body}\n {legend && (\n <div aria-hidden className=\"mt-2 flex items-center justify-end gap-1 text-[10px] text-[var(--text-muted)]\">\n <span className=\"me-0.5\">{labels.less}</span>\n {legendLevels.map((l) => (\n <span\n key={l}\n data-legend-level={l}\n className=\"size-2.5 rounded-sm\"\n style={{ background: levelFill(l, levels, color) }}\n />\n ))}\n <span className=\"ms-0.5\">{labels.more}</span>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";AA4XM,cAqCI,YArCJ;AA5XN,SAAS,WAAW,iBAAiB,SAAS,QAAQ,gBAAgB;AAEtE,SAAS,UAAU;AACnB,SAAS,OAAO,sBAAsB;AACtC,SAAS,kBAAkB,iBAAiB,cAAc,kBAAkB;AAC5E,SAAS,cAAc,cAAc,uBAAuB;AAC5D,SAAS,eAAe;AA0BjB,MAAM,kCAAyD;AAAA,EACpE,MAAM;AAAA,EACN,KAAK,CAAC,MAAM,UAAU,GAAG,IAAI,KAAK,KAAK;AAAA,EACvC,MAAM;AAAA,EACN,MAAM;AAAA,EACN,WAAW,CAAC,UACV,iCAAiC,KAAK,YAAY,UAAU,IAAI,WAAW,UAAU;AACzF;AAiFA,MAAM,kBAA8C;AAAA,EAClD,SAAS;AAAA,EACT,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AACR;AAIA,MAAM,aAAa;AAEnB,MAAM,eAAe,CAAC,GAAS,eAAwB,EAAE,OAAO,IAAI,YAAY,KAAK;AAG9E,SAAS,aAAa,OAAe,KAAa,QAAwB;AAC/E,MAAI,EAAE,QAAQ,MAAM,EAAE,MAAM,MAAM,SAAS,EAAG,QAAO;AACrD,SAAO,KAAK,IAAI,QAAQ,KAAK,IAAI,GAAG,KAAK,KAAM,QAAQ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AAC,SAAI,WAAU,yCAAyC,iBAAO,UAAU,OAAO,GAAE;AAAA,IAEnF;AAAA,IACA,UACC,qBAAC,SAAI,eAAW,MAAC,WAAU,iFACzB;AAAA,0BAAC,UAAK,WAAU,UAAU,iBAAO,MAAK;AAAA,MACrC,aAAa,IAAI,CAAC,MACjB;AAAA,QAAC;AAAA;AAAA,UAEC,qBAAmB;AAAA,UACnB,WAAU;AAAA,UACV,OAAO,EAAE,YAAY,UAAU,GAAG,QAAQ,KAAK,EAAE;AAAA;AAAA,QAH5C;AAAA,MAIP,CACD;AAAA,MACD,oBAAC,UAAK,WAAU,UAAU,iBAAO,MAAK;AAAA,OACxC;AAAA,KAEJ;AAEJ;","names":["_"]}
|
|
@@ -16,9 +16,21 @@ import { LucideIcon } from 'lucide-react';
|
|
|
16
16
|
* "choose one of eight things to do" and a row of eight chips says "here are eight
|
|
17
17
|
* things". Using `Button` for both is the mistake this exists to prevent.
|
|
18
18
|
*/
|
|
19
|
-
type ChipTone = "neutral" | "brand" | "danger" | "warning" | "success" | "info" | "income" | "expense";
|
|
20
|
-
/**
|
|
21
|
-
|
|
19
|
+
type ChipTone = "neutral" | "brand" | "danger" | "warning" | "success" | "info" | "income" | "expense" | ChipHue;
|
|
20
|
+
/**
|
|
21
|
+
* Categorical hues (0.10.0): colour that says "a different value" and nothing more —
|
|
22
|
+
* kastlan's status-badge.tsx paints ~15 enums in 9 Tailwind hues by hand. Four of those
|
|
23
|
+
* nine are semantic and already tones (green = `success`, yellow = `warning`, red =
|
|
24
|
+
* `danger`, gray = `neutral`); these five are the rest, each a `--hue-*` token triple
|
|
25
|
+
* in tokens.css with a light and a dark value. Use a semantic tone when the value HAS a
|
|
26
|
+
* meaning (overdue is `danger`), a hue when it only needs telling apart (sent vs
|
|
27
|
+
* accepted vs invoiced).
|
|
28
|
+
*/
|
|
29
|
+
type ChipHue = "blue" | "indigo" | "purple" | "teal" | "orange";
|
|
30
|
+
/** `lg` is the 44px touch target (`min-h-11`) a phone surface wants; `md` is ~28px.
|
|
31
|
+
* `xs` (0.10.0) is 11px type at `px-1.5` — keksdose's goal markers and budget-cell
|
|
32
|
+
* badges, which sit inside a figure's line and must not make it taller. */
|
|
33
|
+
type ChipSize = "xs" | "sm" | "md" | "lg";
|
|
22
34
|
/**
|
|
23
35
|
* How much of the tone the chip wears.
|
|
24
36
|
*
|
|
@@ -29,8 +41,12 @@ type ChipSize = "sm" | "md" | "lg";
|
|
|
29
41
|
* - `solid`: the tone as a fill under contrasting text — the "count" pill (unread
|
|
30
42
|
* messages, open tasks). It centres its content and sets figures tabular, so a
|
|
31
43
|
* one-digit count is a round dot and "9" → "10" does not jiggle the row.
|
|
44
|
+
* - `dot` (0.10.0): no pill at all — a dot in the tone's colour before plain text, for
|
|
45
|
+
* a status in a dense list or a table column where eight tinted pills in a column
|
|
46
|
+
* would outshout the figures beside them (kastlan's unit picker already draws its
|
|
47
|
+
* UnitStatus this way, from a separate `dotColor` map).
|
|
32
48
|
*/
|
|
33
|
-
type ChipVariant = "soft" | "outline" | "solid";
|
|
49
|
+
type ChipVariant = "soft" | "outline" | "solid" | "dot";
|
|
34
50
|
/** `pill` (default) is fully rounded; `square` has the small radius of a field or a
|
|
35
51
|
* button — for a chip that sits in a table cell or beside square controls. */
|
|
36
52
|
type ChipShape = "pill" | "square";
|
|
@@ -93,6 +109,16 @@ interface ChipBaseProps {
|
|
|
93
109
|
* it — "+ Outflow" in green next to an inflow (keksdose #417).
|
|
94
110
|
*/
|
|
95
111
|
selected?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Checkbox mode (0.10.0), for a toggle chip (`onClick` + `selected`): a small box
|
|
114
|
+
* at the start that shows a tick when `selected`, and the button reports
|
|
115
|
+
* `role="checkbox"` + `aria-checked` instead of `aria-pressed`. For a set of
|
|
116
|
+
* include/exclude choices where "on" must read as TICKED, not merely tinted —
|
|
117
|
+
* keksdose's add-group-card (the "which categories come along" pills), which put a
|
|
118
|
+
* real `<Checkbox>` inside a `<label>` pill by hand. The box is drawn in both
|
|
119
|
+
* states so ticking one never shifts its label.
|
|
120
|
+
*/
|
|
121
|
+
checkbox?: boolean;
|
|
96
122
|
/** Renders a dismiss affordance. Works alongside `href`/`onClick` — see the note below. */
|
|
97
123
|
onRemove?: () => void;
|
|
98
124
|
/** Accessible name for the dismiss button. Default: `common.remove` from the
|
|
@@ -247,4 +273,4 @@ interface ChipInputProps extends Omit<ComponentPropsWithoutRef<"div">, "onChange
|
|
|
247
273
|
*/
|
|
248
274
|
declare function ChipInput({ value, onChange, placeholder, label, ariaLabel, validate, separators, allowDuplicates, max, tone, size, disabled, invalid, error, labels, className, "aria-label": ariaLabelAttr, ...rest }: ChipInputProps): react.JSX.Element;
|
|
249
275
|
|
|
250
|
-
export { Chip, ChipInput, type ChipInputLabels, type ChipInputProps, type ChipLinkProps, type ChipProps, type ChipShape, type ChipSize, type ChipTone, type ChipVariant, DEFAULT_CHIP_INPUT_LABELS, resolveChipInputLabels };
|
|
276
|
+
export { Chip, type ChipHue, ChipInput, type ChipInputLabels, type ChipInputProps, type ChipLinkProps, type ChipProps, type ChipShape, type ChipSize, type ChipTone, type ChipVariant, DEFAULT_CHIP_INPUT_LABELS, resolveChipInputLabels };
|