@artemis-apps/ui 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/dist/brand/app-brands.d.ts +38 -0
  2. package/dist/brand/app-brands.js +110 -0
  3. package/dist/brand/app-icon.d.ts +34 -0
  4. package/dist/brand/app-icon.js +65 -0
  5. package/dist/brand/app-logo.d.ts +14 -0
  6. package/dist/brand/app-logo.js +27 -0
  7. package/dist/brand/favicons/account.svg +1 -0
  8. package/dist/brand/favicons/admin.svg +1 -0
  9. package/dist/brand/favicons/bridge.svg +1 -0
  10. package/dist/brand/favicons/calendar.svg +1 -0
  11. package/dist/brand/favicons/contacts.svg +1 -0
  12. package/dist/brand/favicons/core.svg +1 -0
  13. package/dist/brand/favicons/drive.svg +1 -0
  14. package/dist/brand/favicons/office.svg +1 -0
  15. package/dist/brand/file-icons/archive.svg +1 -0
  16. package/dist/brand/file-icons/audio.svg +1 -0
  17. package/dist/brand/file-icons/code.svg +1 -0
  18. package/dist/brand/file-icons/diagram.svg +1 -0
  19. package/dist/brand/file-icons/document.svg +1 -0
  20. package/dist/brand/file-icons/form.svg +1 -0
  21. package/dist/brand/file-icons/image.svg +1 -0
  22. package/dist/brand/file-icons/markdown.svg +1 -0
  23. package/dist/brand/file-icons/other.svg +1 -0
  24. package/dist/brand/file-icons/pdf.svg +1 -0
  25. package/dist/brand/file-icons/presentation.svg +1 -0
  26. package/dist/brand/file-icons/spreadsheet.svg +1 -0
  27. package/dist/brand/file-icons/text.svg +1 -0
  28. package/dist/brand/file-icons/video.svg +1 -0
  29. package/dist/brand/grain-surface.d.ts +8 -0
  30. package/dist/brand/grain-surface.js +10 -0
  31. package/dist/brand/kind-icons.d.ts +36 -0
  32. package/dist/brand/kind-icons.js +149 -0
  33. package/dist/components/account-menu.d.ts +20 -0
  34. package/dist/components/account-menu.js +13 -0
  35. package/dist/components/alert.d.ts +10 -0
  36. package/dist/components/alert.js +28 -0
  37. package/dist/components/app-switcher.d.ts +21 -0
  38. package/dist/components/app-switcher.js +17 -0
  39. package/dist/components/area-selection.d.ts +21 -0
  40. package/dist/components/area-selection.js +91 -0
  41. package/dist/components/avatar-picker-dialog.d.ts +40 -0
  42. package/dist/components/avatar-picker-dialog.js +110 -0
  43. package/dist/components/avatar.d.ts +5 -0
  44. package/dist/components/avatar.js +10 -0
  45. package/dist/components/badge-list.d.ts +7 -0
  46. package/dist/components/badge-list.js +7 -0
  47. package/dist/components/badge.d.ts +9 -0
  48. package/dist/components/badge.js +32 -0
  49. package/dist/components/breadcrumbs.d.ts +20 -0
  50. package/dist/components/breadcrumbs.js +16 -0
  51. package/dist/components/button.d.ts +12 -0
  52. package/dist/components/button.js +38 -0
  53. package/dist/components/caption.d.ts +3 -0
  54. package/dist/components/caption.js +6 -0
  55. package/dist/components/card.d.ts +8 -0
  56. package/dist/components/card.js +23 -0
  57. package/dist/components/checkbox-field.d.ts +10 -0
  58. package/dist/components/checkbox-field.js +8 -0
  59. package/dist/components/checkbox.d.ts +3 -0
  60. package/dist/components/checkbox.js +7 -0
  61. package/dist/components/code.d.ts +16 -0
  62. package/dist/components/code.js +32 -0
  63. package/dist/components/color-dot.d.ts +11 -0
  64. package/dist/components/color-dot.js +34 -0
  65. package/dist/components/corner-mark.d.ts +14 -0
  66. package/dist/components/corner-mark.js +27 -0
  67. package/dist/components/date-range-field.d.ts +9 -0
  68. package/dist/components/date-range-field.js +9 -0
  69. package/dist/components/description-list.d.ts +11 -0
  70. package/dist/components/description-list.js +10 -0
  71. package/dist/components/dialog.d.ts +16 -0
  72. package/dist/components/dialog.js +38 -0
  73. package/dist/components/drag-and-drop.d.ts +60 -0
  74. package/dist/components/drag-and-drop.js +141 -0
  75. package/dist/components/dropdown-menu.d.ts +27 -0
  76. package/dist/components/dropdown-menu.js +44 -0
  77. package/dist/components/entity-avatar.d.ts +28 -0
  78. package/dist/components/entity-avatar.js +22 -0
  79. package/dist/components/entity-menu.d.ts +67 -0
  80. package/dist/components/entity-menu.js +74 -0
  81. package/dist/components/error-alert.d.ts +7 -0
  82. package/dist/components/error-alert.js +9 -0
  83. package/dist/components/event-chip.d.ts +16 -0
  84. package/dist/components/event-chip.js +19 -0
  85. package/dist/components/fab.d.ts +21 -0
  86. package/dist/components/fab.js +14 -0
  87. package/dist/components/file-drop-zone.d.ts +35 -0
  88. package/dist/components/file-drop-zone.js +44 -0
  89. package/dist/components/file-type-icon.d.ts +44 -0
  90. package/dist/components/file-type-icon.js +147 -0
  91. package/dist/components/icon-image.d.ts +10 -0
  92. package/dist/components/icon-image.js +11 -0
  93. package/dist/components/identity.d.ts +27 -0
  94. package/dist/components/identity.js +22 -0
  95. package/dist/components/inline-field.d.ts +40 -0
  96. package/dist/components/inline-field.js +110 -0
  97. package/dist/components/input.d.ts +17 -0
  98. package/dist/components/input.js +14 -0
  99. package/dist/components/item-list.d.ts +11 -0
  100. package/dist/components/item-list.js +15 -0
  101. package/dist/components/label.d.ts +3 -0
  102. package/dist/components/label.js +6 -0
  103. package/dist/components/mini-month.d.ts +15 -0
  104. package/dist/components/mini-month.js +35 -0
  105. package/dist/components/placeholder-avatar.d.ts +12 -0
  106. package/dist/components/placeholder-avatar.js +6 -0
  107. package/dist/components/popover.d.ts +7 -0
  108. package/dist/components/popover.js +16 -0
  109. package/dist/components/progress-list.d.ts +31 -0
  110. package/dist/components/progress-list.js +15 -0
  111. package/dist/components/progress-ring.d.ts +13 -0
  112. package/dist/components/progress-ring.js +14 -0
  113. package/dist/components/progress.d.ts +10 -0
  114. package/dist/components/progress.js +12 -0
  115. package/dist/components/search-box.d.ts +25 -0
  116. package/dist/components/search-box.js +56 -0
  117. package/dist/components/searchable-options.d.ts +32 -0
  118. package/dist/components/searchable-options.js +17 -0
  119. package/dist/components/section-label.d.ts +7 -0
  120. package/dist/components/section-label.js +8 -0
  121. package/dist/components/segmented-control.d.ts +21 -0
  122. package/dist/components/segmented-control.js +9 -0
  123. package/dist/components/select-menu.d.ts +38 -0
  124. package/dist/components/select-menu.js +26 -0
  125. package/dist/components/selection-bar.d.ts +17 -0
  126. package/dist/components/selection-bar.js +15 -0
  127. package/dist/components/separator.d.ts +3 -0
  128. package/dist/components/separator.js +6 -0
  129. package/dist/components/share-dialog.d.ts +63 -0
  130. package/dist/components/share-dialog.js +74 -0
  131. package/dist/components/sheet.d.ts +20 -0
  132. package/dist/components/sheet.js +24 -0
  133. package/dist/components/skeleton.d.ts +2 -0
  134. package/dist/components/skeleton.js +5 -0
  135. package/dist/components/spinner.d.ts +3 -0
  136. package/dist/components/spinner.js +8 -0
  137. package/dist/components/table.d.ts +7 -0
  138. package/dist/components/table.js +20 -0
  139. package/dist/components/text-link.d.ts +9 -0
  140. package/dist/components/text-link.js +9 -0
  141. package/dist/components/text.d.ts +13 -0
  142. package/dist/components/text.js +8 -0
  143. package/dist/components/toaster.d.ts +8 -0
  144. package/dist/components/toaster.js +27 -0
  145. package/dist/components/viewer-dialog.d.ts +37 -0
  146. package/dist/components/viewer-dialog.js +53 -0
  147. package/dist/index.d.ts +87 -0
  148. package/dist/index.js +87 -0
  149. package/dist/layout/app-frame.d.ts +42 -0
  150. package/dist/layout/app-frame.js +62 -0
  151. package/dist/layout/app-shell.d.ts +11 -0
  152. package/dist/layout/app-shell.js +7 -0
  153. package/dist/layout/document-title.d.ts +14 -0
  154. package/dist/layout/document-title.js +39 -0
  155. package/dist/layout/empty-state.d.ts +16 -0
  156. package/dist/layout/empty-state.js +19 -0
  157. package/dist/layout/entity-header.d.ts +14 -0
  158. package/dist/layout/entity-header.js +6 -0
  159. package/dist/layout/form-field.d.ts +10 -0
  160. package/dist/layout/form-field.js +9 -0
  161. package/dist/layout/form-grid.d.ts +6 -0
  162. package/dist/layout/form-grid.js +9 -0
  163. package/dist/layout/full-page-message.d.ts +10 -0
  164. package/dist/layout/full-page-message.js +5 -0
  165. package/dist/layout/full-page-surface.d.ts +12 -0
  166. package/dist/layout/full-page-surface.js +8 -0
  167. package/dist/layout/month-grid.d.ts +31 -0
  168. package/dist/layout/month-grid.js +12 -0
  169. package/dist/layout/page-header.d.ts +14 -0
  170. package/dist/layout/page-header.js +11 -0
  171. package/dist/layout/panel.d.ts +15 -0
  172. package/dist/layout/panel.js +12 -0
  173. package/dist/layout/retry-message.d.ts +8 -0
  174. package/dist/layout/retry-message.js +9 -0
  175. package/dist/layout/route-error-message.d.ts +9 -0
  176. package/dist/layout/route-error-message.js +9 -0
  177. package/dist/layout/row-list.d.ts +87 -0
  178. package/dist/layout/row-list.js +67 -0
  179. package/dist/layout/settings-section.d.ts +14 -0
  180. package/dist/layout/settings-section.js +11 -0
  181. package/dist/layout/sidebar-nav.d.ts +79 -0
  182. package/dist/layout/sidebar-nav.js +59 -0
  183. package/dist/layout/sign-in-layout.d.ts +19 -0
  184. package/dist/layout/sign-in-layout.js +11 -0
  185. package/dist/layout/sortable-row-list.d.ts +27 -0
  186. package/dist/layout/sortable-row-list.js +61 -0
  187. package/dist/layout/stack.d.ts +41 -0
  188. package/dist/layout/stack.js +51 -0
  189. package/dist/layout/tile-grid.d.ts +75 -0
  190. package/dist/layout/tile-grid.js +71 -0
  191. package/dist/layout/time-grid.d.ts +40 -0
  192. package/dist/layout/time-grid.js +63 -0
  193. package/dist/layout/use-favicon.d.ts +5 -0
  194. package/dist/layout/use-favicon.js +20 -0
  195. package/dist/lib/cn.d.ts +2 -0
  196. package/dist/lib/cn.js +5 -0
  197. package/dist/lib/initials.d.ts +2 -0
  198. package/dist/lib/initials.js +7 -0
  199. package/dist/mascot/mascot.d.ts +23 -0
  200. package/dist/mascot/mascot.definition.json +14 -0
  201. package/dist/mascot/mascot.js +49 -0
  202. package/dist/mascot/use-thinking-motion.d.ts +8 -0
  203. package/dist/mascot/use-thinking-motion.js +68 -0
  204. package/dist/styles.css +385 -0
  205. package/dist/vite/artemis-favicon.plugin.d.ts +10 -0
  206. package/dist/vite/artemis-favicon.plugin.js +67 -0
  207. package/dist/vite/phosphor-icons.plugin.d.ts +8 -0
  208. package/dist/vite/phosphor-icons.plugin.js +61 -0
  209. package/package.json +97 -3
  210. package/README.md +0 -3
@@ -0,0 +1,20 @@
1
+ import type * as React from 'react';
2
+ import { type DropState } from './drag-and-drop.tsx';
3
+ export interface BreadcrumbsProps extends React.ComponentProps<'nav'> {
4
+ /** Accessible name of the trail, e.g. "Folder path". */
5
+ label: string;
6
+ }
7
+ /** Where something sits: its containers from the outermost one, each leading back to it. */
8
+ export declare function Breadcrumbs({ label, className, children, ...props }: BreadcrumbsProps): React.JSX.Element;
9
+ export interface BreadcrumbItemProps extends React.ComponentProps<'a'> {
10
+ /** The last step, where the account is: not a link, marked `aria-current`. */
11
+ current?: boolean;
12
+ /** A small icon before the label, e.g. the drive's on its first step. */
13
+ icon?: React.ReactNode;
14
+ /** Render the child element (the router's `<Link>`) as the step's link. */
15
+ asChild?: boolean;
16
+ /** The step is a drop target (`useDropTarget`): pass the hook's `ref` as the step's `ref`. */
17
+ dropState?: DropState;
18
+ }
19
+ /** One step of `Breadcrumbs`: a link back to it, or the current place. */
20
+ export declare function BreadcrumbItem({ current, icon, asChild, dropState, className, children, ...props }: BreadcrumbItemProps): React.JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CaretRightIcon } from '@phosphor-icons/react';
3
+ import { Slot as SlotPrimitive } from 'radix-ui';
4
+ import { cn } from '../lib/cn.js';
5
+ import { DROP_TARGET_CLASS_NAME } from './drag-and-drop.js';
6
+ /** Where something sits: its containers from the outermost one, each leading back to it. */
7
+ export function Breadcrumbs({ label, className, children, ...props }) {
8
+ return (_jsx("nav", { "data-slot": "breadcrumbs", "aria-label": label, className: cn('min-w-0', className), ...props, children: _jsx("ol", { className: "flex min-w-0 flex-wrap items-center gap-0.5 text-muted-foreground text-sm", children: children }) }));
9
+ }
10
+ /** One step of `Breadcrumbs`: a link back to it, or the current place. */
11
+ export function BreadcrumbItem({ current = false, icon, asChild = false, dropState, className, children, ...props }) {
12
+ const Comp = asChild && !current ? SlotPrimitive.Slot : current ? 'span' : 'a';
13
+ return (_jsxs("li", { className: "flex min-w-0 items-center gap-0.5", children: [_jsxs(Comp, { "data-slot": "breadcrumb-item", "data-drop": dropState, "aria-current": current ? 'page' : undefined, className: cn('flex h-7 min-w-0 max-w-56 items-center gap-1.5 rounded-md px-1.5 outline-none transition-colors', "[&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0", current
14
+ ? 'font-medium text-foreground'
15
+ : 'hover:bg-accent hover:text-accent-foreground focus-ring', DROP_TARGET_CLASS_NAME, className), ...props, children: [icon, _jsx(SlotPrimitive.Slottable, { children: asChild && !current ? children : _jsx("span", { className: "truncate", children: children }) })] }), !current && _jsx(CaretRightIcon, { "aria-hidden": true, className: "size-3.5 shrink-0" })] }));
16
+ }
@@ -0,0 +1,12 @@
1
+ import { type VariantProps } from 'class-variance-authority';
2
+ import type * as React from 'react';
3
+ export declare const buttonVariants: (props?: ({
4
+ variant?: "danger" | "default" | "destructive" | "ghost" | "link" | "outline" | "secondary" | null | undefined;
5
+ size?: "default" | "icon" | "icon-sm" | "icon-xs" | "lg" | "sm" | null | undefined;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
+ export interface ButtonProps extends React.ComponentProps<'button'>, VariantProps<typeof buttonVariants> {
8
+ asChild?: boolean;
9
+ /** An action in progress: a spinner before the label, and the button disabled meanwhile. */
10
+ loading?: boolean;
11
+ }
12
+ export declare function Button({ className, variant, size, asChild, loading, disabled, children, ...props }: ButtonProps): React.JSX.Element;
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cva } from 'class-variance-authority';
3
+ import { Slot as SlotPrimitive } from 'radix-ui';
4
+ import { cn } from '../lib/cn.js';
5
+ import { Spinner } from './spinner.js';
6
+ export const buttonVariants = cva("inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md font-medium text-sm outline-none transition-colors focus-visible:border-ring focus-ring disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-danger aria-invalid:ring-danger/20 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0", {
7
+ variants: {
8
+ variant: {
9
+ // The primary texture: grain over a light gradient of the app's primary.
10
+ default: 'primary-texture-subtle shadow-xs hover:brightness-105 active:brightness-95 [text-shadow:0_1px_1px_rgb(0_0_0/0.12)]',
11
+ secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
12
+ outline: 'border bg-card shadow-xs hover:bg-accent hover:text-accent-foreground',
13
+ ghost: 'hover:bg-accent hover:text-accent-foreground',
14
+ danger: 'bg-danger text-white shadow-xs hover:bg-danger/90 focus-visible:ring-danger/20',
15
+ /** Alias of `danger`. */
16
+ destructive: 'bg-danger text-white shadow-xs hover:bg-danger/90 focus-visible:ring-danger/20',
17
+ link: 'text-primary underline-offset-4 hover:underline',
18
+ },
19
+ size: {
20
+ sm: 'h-8 gap-1.5 px-3 has-[>svg]:px-2.5',
21
+ default: 'h-9 px-4 py-2 has-[>svg]:px-3',
22
+ lg: 'h-10 px-6 has-[>svg]:px-4',
23
+ icon: 'size-9',
24
+ /** A compact icon button: row actions, panel bars. */
25
+ 'icon-sm': 'size-8',
26
+ /** The smallest icon button: inside sidebar items and fields. */
27
+ 'icon-xs': 'size-6',
28
+ },
29
+ },
30
+ defaultVariants: {
31
+ variant: 'default',
32
+ size: 'default',
33
+ },
34
+ });
35
+ export function Button({ className, variant, size, asChild = false, loading = false, disabled, children, ...props }) {
36
+ const Comp = asChild ? SlotPrimitive.Slot : 'button';
37
+ return (_jsxs(Comp, { "data-slot": "button", "data-variant": variant ?? 'default', className: cn(buttonVariants({ variant, size, className })), disabled: disabled || loading, "aria-busy": loading || undefined, ...props, children: [loading && !asChild && _jsx(Spinner, { className: "text-current" }), _jsx(SlotPrimitive.Slottable, { children: children })] }));
38
+ }
@@ -0,0 +1,3 @@
1
+ import type * as React from 'react';
2
+ /** A quiet line of small text: where something comes from, a list's end, a footnote. */
3
+ export declare function Caption({ className, ...props }: React.ComponentProps<'p'>): React.JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cn } from '../lib/cn.js';
3
+ /** A quiet line of small text: where something comes from, a list's end, a footnote. */
4
+ export function Caption({ className, ...props }) {
5
+ return (_jsx("p", { "data-slot": "caption", className: cn('text-muted-foreground text-xs leading-5', className), ...props }));
6
+ }
@@ -0,0 +1,8 @@
1
+ import type * as React from 'react';
2
+ export declare function Card({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
3
+ export declare function CardHeader({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
4
+ export declare function CardTitle({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
5
+ export declare function CardDescription({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
6
+ export declare function CardAction({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
7
+ export declare function CardContent({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
8
+ export declare function CardFooter({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cn } from '../lib/cn.js';
3
+ export function Card({ className, ...props }) {
4
+ return (_jsx("div", { "data-slot": "card", className: cn('flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-xs', className), ...props }));
5
+ }
6
+ export function CardHeader({ className, ...props }) {
7
+ return (_jsx("div", { "data-slot": "card-header", className: cn('grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6', className), ...props }));
8
+ }
9
+ export function CardTitle({ className, ...props }) {
10
+ return (_jsx("div", { "data-slot": "card-title", className: cn('font-semibold leading-none', className), ...props }));
11
+ }
12
+ export function CardDescription({ className, ...props }) {
13
+ return (_jsx("div", { "data-slot": "card-description", className: cn('text-muted-foreground text-sm', className), ...props }));
14
+ }
15
+ export function CardAction({ className, ...props }) {
16
+ return (_jsx("div", { "data-slot": "card-action", className: cn('col-start-2 row-span-2 row-start-1 self-start justify-self-end', className), ...props }));
17
+ }
18
+ export function CardContent({ className, ...props }) {
19
+ return _jsx("div", { "data-slot": "card-content", className: cn('px-6', className), ...props });
20
+ }
21
+ export function CardFooter({ className, ...props }) {
22
+ return (_jsx("div", { "data-slot": "card-footer", className: cn('flex items-center px-6 [.border-t]:pt-6', className), ...props }));
23
+ }
@@ -0,0 +1,10 @@
1
+ import type * as React from 'react';
2
+ import { Checkbox } from './checkbox.tsx';
3
+ export interface CheckboxFieldProps extends Omit<React.ComponentProps<typeof Checkbox>, 'id' | 'children'> {
4
+ id: string;
5
+ label: React.ReactNode;
6
+ /** What checking it means, under the label. */
7
+ description?: React.ReactNode;
8
+ }
9
+ /** A checkbox with its label and, under it, what it means. */
10
+ export declare function CheckboxField({ id, label, description, ...props }: CheckboxFieldProps): React.JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Checkbox } from './checkbox.js';
3
+ import { Label } from './label.js';
4
+ /** A checkbox with its label and, under it, what it means. */
5
+ export function CheckboxField({ id, label, description, ...props }) {
6
+ const descriptionId = `${id}-description`;
7
+ return (_jsxs("div", { "data-slot": "checkbox-field", className: "flex items-start gap-3", children: [_jsx(Checkbox, { id: id, className: "mt-0.5", "aria-describedby": description ? descriptionId : undefined, ...props }), _jsxs("div", { className: "grid gap-1", children: [_jsx(Label, { htmlFor: id, children: label }), description && (_jsx("p", { id: descriptionId, className: "text-muted-foreground text-sm", children: description }))] })] }));
8
+ }
@@ -0,0 +1,3 @@
1
+ import { Checkbox as CheckboxPrimitive } from 'radix-ui';
2
+ import type * as React from 'react';
3
+ export declare function Checkbox({ className, ...props }: React.ComponentProps<typeof CheckboxPrimitive.Root>): React.JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { CheckIcon } from '@phosphor-icons/react';
3
+ import { Checkbox as CheckboxPrimitive } from 'radix-ui';
4
+ import { cn } from '../lib/cn.js';
5
+ export function Checkbox({ className, ...props }) {
6
+ return (_jsx(CheckboxPrimitive.Root, { "data-slot": "checkbox", className: cn('peer size-4 shrink-0 rounded-sm border border-input bg-card shadow-xs outline-none transition-shadow focus-visible:border-ring focus-ring disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-danger aria-invalid:ring-danger/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground', className), ...props, children: _jsx(CheckboxPrimitive.Indicator, { "data-slot": "checkbox-indicator", className: "grid place-content-center text-current", children: _jsx(CheckIcon, { className: "size-3.5" }) }) }));
7
+ }
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ export interface CodeProps extends React.ComponentProps<'code'> {
3
+ /** An identifier rather than something to read: muted, and broken anywhere to fit. */
4
+ identifier?: boolean;
5
+ }
6
+ /** A technical value inline: an action name, an id. */
7
+ export declare function Code({ identifier, className, ...props }: CodeProps): React.JSX.Element;
8
+ /** A block of formatted data, e.g. pretty-printed JSON; scrolls sideways when too wide. */
9
+ export declare function CodeBlock({ className, ...props }: React.ComponentProps<'pre'>): React.JSX.Element;
10
+ export interface CopyableCodeBlockProps {
11
+ /** The text shown, and copied as it is. */
12
+ value: string;
13
+ className?: string;
14
+ }
15
+ /** A block of formatted data people copy elsewhere (a manifest to paste), with its copy button. */
16
+ export declare function CopyableCodeBlock({ value, className }: CopyableCodeBlockProps): React.JSX.Element;
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useSharedMessages } from '@artemis-apps/translations/react';
3
+ import { CheckIcon, CopyIcon } from '@phosphor-icons/react';
4
+ import * as React from 'react';
5
+ import { cn } from '../lib/cn.js';
6
+ import { Button } from './button.js';
7
+ /** How long "Copied" shows after a copy. */
8
+ const COPIED_FEEDBACK_MS = 2000;
9
+ /** A technical value inline: an action name, an id. */
10
+ export function Code({ identifier = false, className, ...props }) {
11
+ return (_jsx("code", { "data-slot": "code", className: cn('font-mono text-xs', identifier && 'break-all text-muted-foreground', className), ...props }));
12
+ }
13
+ /** A block of formatted data, e.g. pretty-printed JSON; scrolls sideways when too wide. */
14
+ export function CodeBlock({ className, ...props }) {
15
+ return (_jsx("pre", { "data-slot": "code-block", className: cn('overflow-x-auto rounded-lg bg-muted/60 p-3 font-mono text-xs leading-relaxed', className), ...props }));
16
+ }
17
+ /** A block of formatted data people copy elsewhere (a manifest to paste), with its copy button. */
18
+ export function CopyableCodeBlock({ value, className }) {
19
+ const messages = useSharedMessages();
20
+ const [copied, setCopied] = React.useState(false);
21
+ React.useEffect(() => {
22
+ if (!copied)
23
+ return;
24
+ const timer = setTimeout(() => setCopied(false), COPIED_FEEDBACK_MS);
25
+ return () => clearTimeout(timer);
26
+ }, [copied]);
27
+ const copy = async () => {
28
+ await navigator.clipboard.writeText(value);
29
+ setCopied(true);
30
+ };
31
+ return (_jsxs("div", { "data-slot": "copyable-code-block", className: cn('relative', className), children: [_jsx(CodeBlock, { className: "max-h-96 pr-24 text-left", children: value }), _jsxs(Button, { size: "sm", variant: "outline", className: "absolute top-2 right-2", onClick: copy, children: [copied ? _jsx(CheckIcon, {}) : _jsx(CopyIcon, {}), copied ? messages.ui.codeBlock.copied : messages.common.copy] })] }));
32
+ }
@@ -0,0 +1,11 @@
1
+ import type { PaletteColor } from '../brand/app-brands.ts';
2
+ export interface ColorDotProps {
3
+ color: PaletteColor;
4
+ /** Only its outline: something of that colour, switched off (a hidden calendar). */
5
+ hollow?: boolean;
6
+ className?: string;
7
+ }
8
+ /** A small disc of a palette colour: the colour of a calendar, a label, a category. */
9
+ export declare function ColorDot({ color, hollow, className }: ColorDotProps): import("react").JSX.Element;
10
+ /** The palette colours, in the order pickers show them. */
11
+ export declare const PALETTE_COLORS: readonly PaletteColor[];
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cn } from '../lib/cn.js';
3
+ const FILLED = {
4
+ blue: 'bg-blue',
5
+ cyan: 'bg-cyan',
6
+ green: 'bg-green',
7
+ violet: 'bg-violet',
8
+ yellow: 'bg-yellow',
9
+ orange: 'bg-orange',
10
+ red: 'bg-red',
11
+ };
12
+ const HOLLOW = {
13
+ blue: 'ring-blue',
14
+ cyan: 'ring-cyan',
15
+ green: 'ring-green',
16
+ violet: 'ring-violet',
17
+ yellow: 'ring-yellow',
18
+ orange: 'ring-orange',
19
+ red: 'ring-red',
20
+ };
21
+ /** A small disc of a palette colour: the colour of a calendar, a label, a category. */
22
+ export function ColorDot({ color, hollow = false, className }) {
23
+ return (_jsx("span", { "aria-hidden": true, "data-slot": "color-dot", className: cn('inline-block size-2.5 shrink-0 rounded-full', hollow ? cn('ring-2 ring-inset', HOLLOW[color]) : FILLED[color], className) }));
24
+ }
25
+ /** The palette colours, in the order pickers show them. */
26
+ export const PALETTE_COLORS = [
27
+ 'blue',
28
+ 'cyan',
29
+ 'green',
30
+ 'violet',
31
+ 'yellow',
32
+ 'orange',
33
+ 'red',
34
+ ];
@@ -0,0 +1,14 @@
1
+ import { type VariantProps } from 'class-variance-authority';
2
+ import type * as React from 'react';
3
+ declare const cornerMarkVariants: (props?: ({
4
+ size?: "lg" | "md" | "sm" | "xl" | "xs" | null | undefined;
5
+ placement?: "corner" | "icon" | null | undefined;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
+ export interface CornerMarkProps extends VariantProps<typeof cornerMarkVariants> {
8
+ /** A Phosphor icon saying something of the item (a person: shared with you). */
9
+ children: React.ReactNode;
10
+ className?: string;
11
+ }
12
+ /** A small disc over the bottom-right corner of a picture or an icon, with a mark in it. */
13
+ export declare function CornerMark({ size, placement, children, className }: CornerMarkProps): React.JSX.Element;
14
+ export {};
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cva } from 'class-variance-authority';
3
+ import { cn } from '../lib/cn.js';
4
+ const cornerMarkVariants = cva('absolute flex items-center justify-center rounded-full bg-card text-foreground shadow-xs ring-2 ring-panel', {
5
+ variants: {
6
+ size: {
7
+ xs: 'size-3 [&_svg]:size-2',
8
+ sm: 'size-3.5 [&_svg]:size-2.5',
9
+ md: 'size-4.5 [&_svg]:size-3',
10
+ lg: 'size-5 [&_svg]:size-3.5',
11
+ xl: 'size-6 [&_svg]:size-4',
12
+ },
13
+ /**
14
+ * Where it sits on the bottom-right corner of its (relative) parent: just past it, over an
15
+ * icon; centred on it, half over a picture.
16
+ */
17
+ placement: {
18
+ icon: '-right-1 -bottom-1',
19
+ corner: 'right-0 bottom-0 translate-x-1/2 translate-y-1/2',
20
+ },
21
+ },
22
+ defaultVariants: { size: 'md', placement: 'icon' },
23
+ });
24
+ /** A small disc over the bottom-right corner of a picture or an icon, with a mark in it. */
25
+ export function CornerMark({ size, placement, children, className }) {
26
+ return (_jsx("span", { "aria-hidden": true, "data-slot": "corner-mark", className: cn(cornerMarkVariants({ size, placement }), className), children: children }));
27
+ }
@@ -0,0 +1,9 @@
1
+ export interface DateRangeFieldProps {
2
+ /** `YYYY-MM-DD`, or `undefined` for an open start. */
3
+ from: string | undefined;
4
+ to: string | undefined;
5
+ onFromChange: (from: string | undefined) => void;
6
+ onToChange: (to: string | undefined) => void;
7
+ }
8
+ /** Two small dates, "from … to …", muted while unset; each bounds the other. */
9
+ export declare function DateRangeField({ from, to, onFromChange, onToChange }: DateRangeFieldProps): import("react").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useSharedMessages } from '@artemis-apps/translations/react';
3
+ import { Input } from './input.js';
4
+ /** Two small dates, "from … to …", muted while unset; each bounds the other. */
5
+ export function DateRangeField({ from, to, onFromChange, onToChange }) {
6
+ const t = useSharedMessages().ui.dateRange;
7
+ const className = 'w-auto text-muted-foreground data-[filled=true]:text-foreground';
8
+ return (_jsxs("div", { "data-slot": "date-range-field", className: "flex items-center gap-1.5", children: [_jsx(Input, { type: "date", size: "sm", "aria-label": t.from, value: from ?? '', max: to, onChange: (event) => onFromChange(event.target.value || undefined), "data-filled": from !== undefined, className: className }), _jsx("span", { className: "text-muted-foreground text-sm", children: t.separator }), _jsx(Input, { type: "date", size: "sm", "aria-label": t.to, value: to ?? '', min: from, onChange: (event) => onToChange(event.target.value || undefined), "data-filled": to !== undefined, className: className })] }));
9
+ }
@@ -0,0 +1,11 @@
1
+ import type * as React from 'react';
2
+ /** Properties of one thing, a label then its value on each line, with hairlines between. */
3
+ export declare function DescriptionList({ className, ...props }: React.ComponentProps<'dl'>): React.JSX.Element;
4
+ export interface DescriptionItemProps {
5
+ label: React.ReactNode;
6
+ children: React.ReactNode;
7
+ /** A small control at the end of the line, shown while the line is hovered or focused. */
8
+ action?: React.ReactNode;
9
+ }
10
+ /** One property of a `DescriptionList`. */
11
+ export declare function DescriptionItem({ label, children, action }: DescriptionItemProps): React.JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from '../lib/cn.js';
3
+ /** Properties of one thing, a label then its value on each line, with hairlines between. */
4
+ export function DescriptionList({ className, ...props }) {
5
+ return (_jsx("dl", { "data-slot": "description-list", className: cn('divide-y text-sm', className), ...props }));
6
+ }
7
+ /** One property of a `DescriptionList`. */
8
+ export function DescriptionItem({ label, children, action }) {
9
+ return (_jsxs("div", { "data-slot": "description-item", className: "group/item flex items-center gap-3 py-2.5", children: [_jsx("dt", { className: "w-28 shrink-0 text-muted-foreground", children: label }), _jsx("dd", { className: "min-w-0 flex-1", children: children }), action && (_jsx("div", { className: "flex shrink-0 text-muted-foreground opacity-0 transition-opacity focus-within:opacity-100 group-hover/item:opacity-100", children: action }))] }));
10
+ }
@@ -0,0 +1,16 @@
1
+ import { Dialog as DialogPrimitive } from 'radix-ui';
2
+ import type * as React from 'react';
3
+ export declare function Dialog(props: React.ComponentProps<typeof DialogPrimitive.Root>): React.JSX.Element;
4
+ export declare function DialogTrigger(props: React.ComponentProps<typeof DialogPrimitive.Trigger>): React.JSX.Element;
5
+ export declare function DialogClose(props: React.ComponentProps<typeof DialogPrimitive.Close>): React.JSX.Element;
6
+ export declare function DialogOverlay({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Overlay>): React.JSX.Element;
7
+ export interface DialogContentProps extends React.ComponentProps<typeof DialogPrimitive.Content> {
8
+ showCloseButton?: boolean;
9
+ }
10
+ export declare function DialogContent({ className, children, showCloseButton, ...props }: DialogContentProps): React.JSX.Element;
11
+ /** The × in the corner of a dialog or a sheet. */
12
+ export declare function DialogCloseButton(): React.JSX.Element;
13
+ export declare function DialogHeader({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
14
+ export declare function DialogFooter({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
15
+ export declare function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>): React.JSX.Element;
16
+ export declare function DialogDescription({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Description>): React.JSX.Element;
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useSharedMessages } from '@artemis-apps/translations/react';
3
+ import { XIcon } from '@phosphor-icons/react';
4
+ import { Dialog as DialogPrimitive } from 'radix-ui';
5
+ import { cn } from '../lib/cn.js';
6
+ import { Button } from './button.js';
7
+ export function Dialog(props) {
8
+ return _jsx(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
9
+ }
10
+ export function DialogTrigger(props) {
11
+ return _jsx(DialogPrimitive.Trigger, { "data-slot": "dialog-trigger", ...props });
12
+ }
13
+ export function DialogClose(props) {
14
+ return _jsx(DialogPrimitive.Close, { "data-slot": "dialog-close", ...props });
15
+ }
16
+ export function DialogOverlay({ className, ...props }) {
17
+ return (_jsx(DialogPrimitive.Overlay, { "data-slot": "dialog-overlay", className: cn('data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-foreground/20 backdrop-blur-xs data-[state=closed]:animate-out data-[state=open]:animate-in', className), ...props }));
18
+ }
19
+ export function DialogContent({ className, children, showCloseButton = true, ...props }) {
20
+ return (_jsxs(DialogPrimitive.Portal, { "data-slot": "dialog-portal", children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Content, { "data-slot": "dialog-content", className: cn('data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-1/2 left-1/2 z-50 grid max-h-[calc(100svh-2rem)] w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 overflow-y-auto rounded-xl border bg-popover p-6 text-popover-foreground shadow-lg duration-200 data-[state=closed]:animate-out data-[state=open]:animate-in sm:max-w-lg', className), ...props, children: [children, showCloseButton && _jsx(DialogCloseButton, {})] })] }));
21
+ }
22
+ /** The × in the corner of a dialog or a sheet. */
23
+ export function DialogCloseButton() {
24
+ const t = useSharedMessages();
25
+ return (_jsx(DialogPrimitive.Close, { asChild: true, children: _jsxs(Button, { variant: "ghost", size: "icon-sm", "data-slot": "dialog-close", className: "absolute top-3 right-3 text-muted-foreground", children: [_jsx(XIcon, {}), _jsx("span", { className: "sr-only", children: t.common.close })] }) }));
26
+ }
27
+ export function DialogHeader({ className, ...props }) {
28
+ return (_jsx("div", { "data-slot": "dialog-header", className: cn('flex flex-col gap-2 text-center sm:text-left', className), ...props }));
29
+ }
30
+ export function DialogFooter({ className, ...props }) {
31
+ return (_jsx("div", { "data-slot": "dialog-footer", className: cn('flex flex-col-reverse gap-2 sm:flex-row sm:justify-end', className), ...props }));
32
+ }
33
+ export function DialogTitle({ className, ...props }) {
34
+ return (_jsx(DialogPrimitive.Title, { "data-slot": "dialog-title", className: cn('font-semibold text-lg leading-none', className), ...props }));
35
+ }
36
+ export function DialogDescription({ className, ...props }) {
37
+ return (_jsx(DialogPrimitive.Description, { "data-slot": "dialog-description", className: cn('text-muted-foreground text-sm', className), ...props }));
38
+ }
@@ -0,0 +1,60 @@
1
+ import * as React from 'react';
2
+ /** What is being dragged: an entity, described well enough to show and announce it. */
3
+ export interface DragItem {
4
+ /** The entity type, checked by drop targets (`'contact'`). */
5
+ type: string;
6
+ id: string;
7
+ /** Its name, shown beside the pointer and read by screen readers. */
8
+ label: string;
9
+ /** A small visual shown before the label while dragging, e.g. an avatar. */
10
+ preview?: React.ReactNode;
11
+ }
12
+ /**
13
+ * Lets the entities of an app be dragged onto drop targets (`useDragSource`, `useDropTarget`).
14
+ * `AppFrame` mounts it around the whole app. A drag starts once the pointer moves a few pixels,
15
+ * or after a long press on touch screens, so clicks and scrolling stay as they were.
16
+ */
17
+ export declare function DragDropProvider({ children }: {
18
+ children: React.ReactNode;
19
+ }): React.JSX.Element;
20
+ export interface DragSourceOptions {
21
+ /** Not draggable, e.g. when the account may not move it. */
22
+ disabled?: boolean;
23
+ }
24
+ /**
25
+ * Makes an element draggable as `item`: spread `props` on it and give it `ref`. Works on links:
26
+ * the browser's own link dragging is turned off.
27
+ */
28
+ export declare function useDragSource(item: DragItem, { disabled }?: DragSourceOptions): {
29
+ ref: (element: HTMLElement | null) => void;
30
+ isDragging: boolean;
31
+ props: {
32
+ draggable: boolean;
33
+ onDragStart: (event: React.DragEvent) => void;
34
+ 'data-dragging': true | undefined;
35
+ };
36
+ };
37
+ export interface DropTargetOptions {
38
+ /** Unique among the drop targets on screen. */
39
+ id: string;
40
+ /** Its name, read by screen readers ("Jane is over Friends"). */
41
+ label: string;
42
+ /** Whether `item` may be dropped here; others are ignored and the target stays unmarked. */
43
+ accepts: (item: DragItem) => boolean;
44
+ onDrop: (item: DragItem) => void;
45
+ }
46
+ /** What a drop target shows: `available` while an item it accepts is dragged, `over` above it. */
47
+ export type DropState = 'available' | 'over';
48
+ /**
49
+ * The look of every drop target, keyed on `data-drop={state}`: outlined while an item it accepts
50
+ * is dragged, tinted while that item is over it.
51
+ */
52
+ export declare const DROP_TARGET_CLASS_NAME = "data-[drop=available]:ring-1 data-[drop=available]:ring-primary/35 data-[drop=available]:ring-inset data-[drop=over]:bg-primary-soft data-[drop=over]:text-foreground data-[drop=over]:ring-2 data-[drop=over]:ring-primary data-[drop=over]:ring-inset";
53
+ /**
54
+ * Makes an element a drop target: give it `ref`, and `data-drop={state}` to style it
55
+ * (`SidebarNavItem` takes `dropState`).
56
+ */
57
+ export declare function useDropTarget({ id, label, accepts, onDrop }: DropTargetOptions): {
58
+ ref: (element: HTMLElement | null) => void;
59
+ state: DropState | undefined;
60
+ };
@@ -0,0 +1,141 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useSharedMessages } from '@artemis-apps/translations/react';
3
+ import { DndContext, DragOverlay, MouseSensor, pointerWithin, TouchSensor, useDndContext, useDraggable, useDroppable, useSensor, useSensors, } from '@dnd-kit/core';
4
+ import * as React from 'react';
5
+ function dragItemOf(data) {
6
+ return data?.item;
7
+ }
8
+ function dropTargetOf(data) {
9
+ return data?.target;
10
+ }
11
+ /** Where the dragging started inside the item, to keep the preview by the pointer. */
12
+ function pointerOf(event) {
13
+ if (!event)
14
+ return undefined;
15
+ if ('touches' in event) {
16
+ const touch = event.touches[0];
17
+ return touch && { x: touch.clientX, y: touch.clientY };
18
+ }
19
+ if ('clientX' in event) {
20
+ const { clientX, clientY } = event;
21
+ return { x: clientX, y: clientY };
22
+ }
23
+ return undefined;
24
+ }
25
+ /** The preview starts where the dragged element was: move it to just below-right of the pointer. */
26
+ const followPointer = ({ transform, activatorEvent, activeNodeRect }) => {
27
+ const pointer = pointerOf(activatorEvent);
28
+ if (!pointer || !activeNodeRect)
29
+ return transform;
30
+ return {
31
+ ...transform,
32
+ x: transform.x + pointer.x - activeNodeRect.left + 12,
33
+ y: transform.y + pointer.y - activeNodeRect.top + 12,
34
+ };
35
+ };
36
+ /**
37
+ * Cancels the click the browser sends when the button is released at the end of a drag.
38
+ * dnd-kit only stops its propagation: React never sees it, so a router `<Link>` under it doesn't
39
+ * handle it, and the browser follows the link itself (a full page load).
40
+ */
41
+ function swallowNextClick() {
42
+ const swallow = (event) => {
43
+ event.preventDefault();
44
+ event.stopPropagation();
45
+ };
46
+ window.addEventListener('click', swallow, { capture: true, once: true });
47
+ // The click, if any, comes right after the release: a later, real click must go through.
48
+ setTimeout(() => window.removeEventListener('click', swallow, { capture: true }), 0);
49
+ }
50
+ /** What screen readers hear as an item is dragged, in the language spoken. */
51
+ function announcements(t) {
52
+ const nameOf = (data) => dragItemOf(data)?.label ?? t.item;
53
+ return {
54
+ onDragStart: ({ active }) => t.pickedUp(nameOf(active.data.current)),
55
+ onDragOver: ({ active, over }) => {
56
+ const item = dragItemOf(active.data.current);
57
+ const target = dropTargetOf(over?.data.current);
58
+ if (!item || !target)
59
+ return undefined;
60
+ return target.accepts(item)
61
+ ? t.over(item.label, target.label)
62
+ : t.notAccepted(item.label, target.label);
63
+ },
64
+ onDragEnd: ({ active, over }) => {
65
+ const item = dragItemOf(active.data.current);
66
+ const target = dropTargetOf(over?.data.current);
67
+ if (!item)
68
+ return undefined;
69
+ return target?.accepts(item) ? t.droppedOn(item.label, target.label) : t.dropped(item.label);
70
+ },
71
+ onDragCancel: ({ active }) => t.cancelled(nameOf(active.data.current)),
72
+ };
73
+ }
74
+ /**
75
+ * Lets the entities of an app be dragged onto drop targets (`useDragSource`, `useDropTarget`).
76
+ * `AppFrame` mounts it around the whole app. A drag starts once the pointer moves a few pixels,
77
+ * or after a long press on touch screens, so clicks and scrolling stay as they were.
78
+ */
79
+ export function DragDropProvider({ children }) {
80
+ const t = useSharedMessages().ui.dragAndDrop;
81
+ const accessibility = React.useMemo(() => ({ announcements: announcements(t) }), [t]);
82
+ const [dragged, setDragged] = React.useState();
83
+ const sensors = useSensors(useSensor(MouseSensor, { activationConstraint: { distance: 6 } }), useSensor(TouchSensor, { activationConstraint: { delay: 250, tolerance: 6 } }));
84
+ function handleDragStart({ active }) {
85
+ setDragged(dragItemOf(active.data.current));
86
+ }
87
+ function handleDragEnd({ active, over }) {
88
+ swallowNextClick();
89
+ setDragged(undefined);
90
+ const item = dragItemOf(active.data.current);
91
+ const target = dropTargetOf(over?.data.current);
92
+ if (item && target?.accepts(item))
93
+ target.onDrop(item);
94
+ }
95
+ return (_jsxs(DndContext, { sensors: sensors, collisionDetection: pointerWithin, accessibility: accessibility, onDragStart: handleDragStart, onDragEnd: handleDragEnd, onDragCancel: () => {
96
+ swallowNextClick();
97
+ setDragged(undefined);
98
+ }, children: [children, _jsx(DragOverlay, { dropAnimation: null, modifiers: [followPointer], className: "cursor-grabbing", children: dragged && (_jsxs("div", { className: "pointer-events-none inline-flex max-w-64 items-center gap-2 rounded-full border bg-popover py-1 pr-3.5 pl-1 text-popover-foreground text-sm shadow-lg", children: [dragged.preview, _jsx("span", { className: "truncate font-medium", children: dragged.label })] })) })] }));
99
+ }
100
+ /**
101
+ * Makes an element draggable as `item`: spread `props` on it and give it `ref`. Works on links:
102
+ * the browser's own link dragging is turned off.
103
+ */
104
+ export function useDragSource(item, { disabled = false } = {}) {
105
+ const { setNodeRef, listeners, isDragging } = useDraggable({
106
+ id: `${item.type}:${item.id}`,
107
+ data: { item },
108
+ disabled,
109
+ });
110
+ return {
111
+ ref: setNodeRef,
112
+ isDragging,
113
+ props: {
114
+ ...listeners,
115
+ draggable: false,
116
+ // A link (or an image inside) would start the browser's own drag instead.
117
+ onDragStart: (event) => event.preventDefault(),
118
+ 'data-dragging': isDragging || undefined,
119
+ },
120
+ };
121
+ }
122
+ /**
123
+ * The look of every drop target, keyed on `data-drop={state}`: outlined while an item it accepts
124
+ * is dragged, tinted while that item is over it.
125
+ */
126
+ export const DROP_TARGET_CLASS_NAME = 'data-[drop=available]:ring-1 data-[drop=available]:ring-primary/35 data-[drop=available]:ring-inset data-[drop=over]:bg-primary-soft data-[drop=over]:text-foreground data-[drop=over]:ring-2 data-[drop=over]:ring-primary data-[drop=over]:ring-inset';
127
+ /**
128
+ * Makes an element a drop target: give it `ref`, and `data-drop={state}` to style it
129
+ * (`SidebarNavItem` takes `dropState`).
130
+ */
131
+ export function useDropTarget({ id, label, accepts, onDrop }) {
132
+ const { active } = useDndContext();
133
+ const dragged = dragItemOf(active?.data.current);
134
+ const accepted = dragged !== undefined && accepts(dragged);
135
+ const { setNodeRef, isOver } = useDroppable({
136
+ id,
137
+ data: { target: { label, accepts, onDrop } },
138
+ });
139
+ const state = !accepted ? undefined : isOver ? 'over' : 'available';
140
+ return { ref: setNodeRef, state };
141
+ }