@arbidocs/react 0.5.118 → 0.5.120

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.
@@ -0,0 +1,85 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useRef, useState } from "react";
3
+ import { User, Users } from "lucide-react";
4
+ import { cn } from "../lib/utils.js";
5
+ import { HoverCard, HoverCardContent, HoverCardTrigger } from "../ui/hover-card.js";
6
+ import { EntityPill } from "./EntityPill.js";
7
+ let sharedMembers = null;
8
+ function configureSharingMembers(members) {
9
+ sharedMembers = members;
10
+ }
11
+ const SHARING_LABELS = { onlyMe: "Only me", workspace: "Workspace" };
12
+ function SharingEntity({
13
+ shared,
14
+ variant = "full",
15
+ size = "sm",
16
+ onToggle,
17
+ disabled = false,
18
+ disabledTooltip,
19
+ tooltipActive,
20
+ tooltipInactive,
21
+ members: membersProp,
22
+ className,
23
+ "data-testid": testId
24
+ }) {
25
+ const members = membersProp ?? sharedMembers;
26
+ const [open, setOpen] = useState(false);
27
+ const lastPointer = useRef("mouse");
28
+ const canToggle = !!onToggle && !disabled;
29
+ const label = shared ? SHARING_LABELS.workspace : SHARING_LABELS.onlyMe;
30
+ const hint = disabled ? disabledTooltip : shared ? tooltipActive : tooltipInactive;
31
+ const handleClick = (e) => {
32
+ e.stopPropagation();
33
+ if (shared && lastPointer.current === "touch") {
34
+ setOpen(true);
35
+ return;
36
+ }
37
+ if (canToggle) onToggle(!shared);
38
+ };
39
+ const pill = /* @__PURE__ */ jsx(
40
+ EntityPill,
41
+ {
42
+ shape: "pill",
43
+ size,
44
+ icon: shared ? /* @__PURE__ */ jsx(Users, { className: "size-3.5 shrink-0 text-primary", "aria-hidden": true }) : /* @__PURE__ */ jsx(User, { className: "size-3.5 shrink-0 text-muted-foreground", "aria-hidden": true }),
45
+ label,
46
+ labelClassName: cn(variant === "icon" && "sr-only", !shared && "text-muted-foreground"),
47
+ className: cn(shared && "text-primary", className),
48
+ onClick: handleClick,
49
+ tooltipContent: !shared && hint ? hint : void 0,
50
+ "data-testid": testId
51
+ }
52
+ );
53
+ if (!shared) return pill;
54
+ return /* @__PURE__ */ jsxs(HoverCard, { open, onOpenChange: setOpen, openDelay: 200, closeDelay: 100, children: [
55
+ /* @__PURE__ */ jsx(
56
+ HoverCardTrigger,
57
+ {
58
+ asChild: true,
59
+ onPointerDown: (e) => {
60
+ lastPointer.current = e.pointerType;
61
+ },
62
+ children: /* @__PURE__ */ jsx(
63
+ "span",
64
+ {
65
+ className: "inline-flex",
66
+ role: "group",
67
+ "aria-label": `${SHARING_LABELS.workspace}: shared with all workspace members`,
68
+ children: pill
69
+ }
70
+ )
71
+ }
72
+ ),
73
+ open && /* @__PURE__ */ jsxs(HoverCardContent, { side: "left", align: "center", className: "w-60 space-y-2 p-3", children: [
74
+ /* @__PURE__ */ jsx("p", { className: "text-xs font-semibold", children: "Workspace members" }),
75
+ members,
76
+ hint && /* @__PURE__ */ jsx("p", { className: "border-t pt-2 text-xs text-muted-foreground", children: hint })
77
+ ] })
78
+ ] });
79
+ }
80
+ export {
81
+ SHARING_LABELS,
82
+ SharingEntity,
83
+ configureSharingMembers
84
+ };
85
+ //# sourceMappingURL=SharingEntity.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/entities/SharingEntity.tsx"],
4
+ "sourcesContent": ["/**\n * SharingEntity\n *\n * The entity pill of who can see an item: \"Only me\" (one person) or \"Workspace\" (several people).\n * It is the one pill every sharing indicator uses, in two variants: `full` (icon + label) and `icon`\n * (the glyph alone, for a narrow cell or a header; the label stays as its accessible name).\n *\n * The \"Workspace\" pill owns its hover: a card (opened by hover, keyboard focus, or a tap on a touch\n * screen) with `members`, the workspace's member list. `members` is only mounted while the card is\n * open, so a data-reading list costs nothing until someone looks. \"Only me\" has no card.\n *\n * With `onToggle` a click flips the visibility (a tap on a touch screen opens the card instead, so\n * a stray tap never changes who can see an item); without, the pill is a plain indicator. A click never reaches a parent's\n * handler (a row or card selection).\n */\n\nimport { useRef, useState, type MouseEvent, type PointerEvent, type ReactNode } from 'react'\nimport { User, Users } from 'lucide-react'\nimport { cn } from '../lib/utils'\nimport { HoverCard, HoverCardContent, HoverCardTrigger } from '../ui/hover-card'\nimport { EntityPill } from './EntityPill'\n\nlet sharedMembers: ReactNode = null\n\n/**\n * Where every `SharingEntity` finds the member list of its card (the entity registry's seam: the\n * connected layer, which can read the workspace's members, registers it once; panels that portal\n * outside any one subtree still get it).\n */\nexport function configureSharingMembers(members: ReactNode): void {\n sharedMembers = members\n}\n\nexport const SHARING_LABELS = { onlyMe: 'Only me', workspace: 'Workspace' } as const\n\nexport interface SharingEntityProps {\n shared: boolean\n /** `full` (default) icon + label; `icon` the glyph alone. */\n variant?: 'full' | 'icon'\n size?: 'sm' | 'md'\n /** Called with true to share, false to make private. Omit for an indicator that is not clickable. */\n onToggle?: (shouldShare: boolean) => void\n disabled?: boolean\n /** Why the visibility cannot be changed (a line in the card, or the tooltip). */\n disabledTooltip?: string\n /** What a click does while shared / private. */\n tooltipActive?: string\n tooltipInactive?: string\n /** The member list of the Workspace card (default: the registered one, `configureSharingMembers`); mounted only while the card is open. */\n members?: ReactNode\n className?: string\n 'data-testid'?: string\n}\n\nexport function SharingEntity({\n shared,\n variant = 'full',\n size = 'sm',\n onToggle,\n disabled = false,\n disabledTooltip,\n tooltipActive,\n tooltipInactive,\n members: membersProp,\n className,\n 'data-testid': testId,\n}: SharingEntityProps) {\n const members = membersProp ?? sharedMembers\n const [open, setOpen] = useState(false)\n const lastPointer = useRef<string>('mouse')\n const canToggle = !!onToggle && !disabled\n const label = shared ? SHARING_LABELS.workspace : SHARING_LABELS.onlyMe\n const hint = disabled ? disabledTooltip : shared ? tooltipActive : tooltipInactive\n\n const handleClick = (e: MouseEvent) => {\n e.stopPropagation()\n // A touch screen has no hover: a tap on a Workspace pill shows who is in it (and never flips it).\n if (shared && lastPointer.current === 'touch') {\n setOpen(true)\n return\n }\n if (canToggle) onToggle(!shared)\n }\n\n const pill = (\n <EntityPill\n shape=\"pill\"\n size={size}\n icon={\n shared ? (\n <Users className=\"size-3.5 shrink-0 text-primary\" aria-hidden />\n ) : (\n <User className=\"size-3.5 shrink-0 text-muted-foreground\" aria-hidden />\n )\n }\n label={label}\n labelClassName={cn(variant === 'icon' && 'sr-only', !shared && 'text-muted-foreground')}\n className={cn(shared && 'text-primary', className)}\n onClick={handleClick}\n tooltipContent={!shared && hint ? hint : undefined}\n data-testid={testId}\n />\n )\n\n if (!shared) return pill\n\n return (\n <HoverCard open={open} onOpenChange={setOpen} openDelay={200} closeDelay={100}>\n <HoverCardTrigger\n asChild\n onPointerDown={(e: PointerEvent) => {\n lastPointer.current = e.pointerType\n }}\n >\n <span\n className=\"inline-flex\"\n role=\"group\"\n aria-label={`${SHARING_LABELS.workspace}: shared with all workspace members`}\n >\n {pill}\n </span>\n </HoverCardTrigger>\n {open && (\n <HoverCardContent side=\"left\" align=\"center\" className=\"w-60 space-y-2 p-3\">\n <p className=\"text-xs font-semibold\">Workspace members</p>\n {members}\n {hint && <p className=\"border-t pt-2 text-xs text-muted-foreground\">{hint}</p>}\n </HoverCardContent>\n )}\n </HoverCard>\n )\n}\n"],
5
+ "mappings": "AA0FU,cAiCF,YAjCE;AA1EV,SAAS,QAAQ,gBAAoE;AACrF,SAAS,MAAM,aAAa;AAC5B,SAAS,UAAU;AACnB,SAAS,WAAW,kBAAkB,wBAAwB;AAC9D,SAAS,kBAAkB;AAE3B,IAAI,gBAA2B;AAOxB,SAAS,wBAAwB,SAA0B;AAChE,kBAAgB;AAClB;AAEO,MAAM,iBAAiB,EAAE,QAAQ,WAAW,WAAW,YAAY;AAqBnE,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA,UAAU;AAAA,EACV,OAAO;AAAA,EACP;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA,eAAe;AACjB,GAAuB;AACr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AAE,WAAU,yBAAwB,+BAAiB;AAAA,MACrD;AAAA,MACA,QAAQ,oBAAC,OAAE,WAAU,+CAA+C,gBAAK;AAAA,OAC5E;AAAA,KAEJ;AAEJ;",
6
+ "names": []
7
+ }
@@ -6,6 +6,11 @@ import {
6
6
  getDocumentTitle,
7
7
  isImageDocument
8
8
  } from "./DocumentEntity.js";
9
+ import {
10
+ SharingEntity,
11
+ configureSharingMembers,
12
+ SHARING_LABELS
13
+ } from "./SharingEntity.js";
9
14
  import { TagEntity } from "./TagEntity.js";
10
15
  import { TAG_TYPE_ICONS, TAG_TYPE_LABELS, getTagTypeIcon, getTagTypeLabel } from "./tag-types.js";
11
16
  import { tagKindTitle, tagKindNouns } from "./tag-kinds.js";
@@ -60,6 +65,8 @@ export {
60
65
  PLACEHOLDER_COLOR,
61
66
  PresenceLabel,
62
67
  ProjectEntity,
68
+ SHARING_LABELS,
69
+ SharingEntity,
63
70
  ShieldIcon,
64
71
  StatusPill,
65
72
  TAG_TYPE_ICONS,
@@ -74,6 +81,7 @@ export {
74
81
  configureEntityRegistry,
75
82
  configureEntityVocabulary,
76
83
  configureRagLabels,
84
+ configureSharingMembers,
77
85
  configureStatusRegistry,
78
86
  entityNoun,
79
87
  friendlyFileType,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/entities/index.ts"],
4
- "sourcesContent": ["export { ThreadVisibilityIcon } from './ThreadVisibilityIcon'\nexport { EntityPill, type EntitySize } from './EntityPill'\nexport {\n DocumentEntity,\n getDocIcon,\n getDocumentTitle,\n isImageDocument,\n type DocumentEntityProps,\n type DocumentLike,\n} from './DocumentEntity'\nexport { TagEntity, type TagEntityProps, type TagLike } from './TagEntity'\nexport { TAG_TYPE_ICONS, TAG_TYPE_LABELS, getTagTypeIcon, getTagTypeLabel } from './tag-types'\nexport { tagKindTitle, tagKindNouns } from './tag-kinds'\nexport { ProjectEntity, type ProjectEntityProps, type ProjectRelation } from './ProjectEntity'\nexport { UserEntity, type UserEntityProps, type PresenceDisplayStatus } from './UserEntity'\nexport { VerifiedBadge, type VerifiedBadgeProps } from './VerifiedBadge'\n// One agent stamp and one presence wording for every surface \u2014 see AgentMarkers.\nexport { AgentBadge, PresenceLabel } from './AgentMarkers'\n\n// Status pill + RAG dot \u2014 generic presentation, domain vocabulary INJECTED.\nexport {\n StatusPill,\n type StatusPillProps,\n type StatusVariant,\n type StatusBadgeProps,\n type StatusBadgeComponent,\n configureStatusRegistry,\n getStatusVariant,\n type Rag,\n configureRagLabels,\n} from './status'\n\n// Canonical entity registry \u2014 icons, names, and the deployment injection seam.\nexport {\n ENTITY_MAPPINGS,\n type EntityType,\n type EntityIconComponent,\n type EntityRegistryOverride,\n type EntityLabelForm,\n configureEntityRegistry,\n getEntityIcon,\n getEntityLabel,\n entityNoun,\n EntityIcon,\n VISIBILITY_ICONS,\n VisibilityIcon,\n} from './registry'\n\nexport { configureEntityVocabulary, type EntityNoun, type EntityVocabulary } from './vocabulary'\n\n// Entity colour system \u2014 deterministic id \u2192 colour derivation.\nexport {\n BASE_COLORS,\n PLACEHOLDER_COLOR,\n NEUTRAL_GRAY,\n getEntityColor,\n getEntityColorStyles,\n getWorkspaceColor,\n} from './colors'\n\n// Workspace square glyph (initial on a colour fill) and the outlined agent-avatar colours.\nexport { ShieldIcon, type ShieldIconProps } from './ShieldIcon'\nexport { agentAvatarColors } from './agent-avatar-colors'\n\n// What kind of file a document is: the viewer's choice of renderer and the short label of its type.\nexport {\n isAudioFile,\n isDownloadOnlyFile,\n isImageFile,\n isMediaFile,\n isVideoFile,\n usesOriginalBytesForViewer,\n} from './media-type'\nexport { friendlyFileType } from './file-type'\n"],
5
- "mappings": "AAAA,SAAS,4BAA4B;AACrC,SAAS,kBAAmC;AAC5C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,iBAAoD;AAC7D,SAAS,gBAAgB,iBAAiB,gBAAgB,uBAAuB;AACjF,SAAS,cAAc,oBAAoB;AAC3C,SAAS,qBAAoE;AAC7E,SAAS,kBAAoE;AAC7E,SAAS,qBAA8C;AAEvD,SAAS,YAAY,qBAAqB;AAG1C;AAAA,EACE;AAAA,EAKA;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EAKA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iCAAyE;AAGlF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,kBAAwC;AACjD,SAAS,yBAAyB;AAGlC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB;",
4
+ "sourcesContent": ["export { ThreadVisibilityIcon } from './ThreadVisibilityIcon'\nexport { EntityPill, type EntitySize } from './EntityPill'\nexport {\n DocumentEntity,\n getDocIcon,\n getDocumentTitle,\n isImageDocument,\n type DocumentEntityProps,\n type DocumentLike,\n} from './DocumentEntity'\nexport {\n SharingEntity,\n configureSharingMembers,\n SHARING_LABELS,\n type SharingEntityProps,\n} from './SharingEntity'\nexport { TagEntity, type TagEntityProps, type TagLike } from './TagEntity'\nexport { TAG_TYPE_ICONS, TAG_TYPE_LABELS, getTagTypeIcon, getTagTypeLabel } from './tag-types'\nexport { tagKindTitle, tagKindNouns } from './tag-kinds'\nexport { ProjectEntity, type ProjectEntityProps, type ProjectRelation } from './ProjectEntity'\nexport { UserEntity, type UserEntityProps, type PresenceDisplayStatus } from './UserEntity'\nexport { VerifiedBadge, type VerifiedBadgeProps } from './VerifiedBadge'\n// One agent stamp and one presence wording for every surface \u2014 see AgentMarkers.\nexport { AgentBadge, PresenceLabel } from './AgentMarkers'\n\n// Status pill + RAG dot \u2014 generic presentation, domain vocabulary INJECTED.\nexport {\n StatusPill,\n type StatusPillProps,\n type StatusVariant,\n type StatusBadgeProps,\n type StatusBadgeComponent,\n configureStatusRegistry,\n getStatusVariant,\n type Rag,\n configureRagLabels,\n} from './status'\n\n// Canonical entity registry \u2014 icons, names, and the deployment injection seam.\nexport {\n ENTITY_MAPPINGS,\n type EntityType,\n type EntityIconComponent,\n type EntityRegistryOverride,\n type EntityLabelForm,\n configureEntityRegistry,\n getEntityIcon,\n getEntityLabel,\n entityNoun,\n EntityIcon,\n VISIBILITY_ICONS,\n VisibilityIcon,\n} from './registry'\n\nexport { configureEntityVocabulary, type EntityNoun, type EntityVocabulary } from './vocabulary'\n\n// Entity colour system \u2014 deterministic id \u2192 colour derivation.\nexport {\n BASE_COLORS,\n PLACEHOLDER_COLOR,\n NEUTRAL_GRAY,\n getEntityColor,\n getEntityColorStyles,\n getWorkspaceColor,\n} from './colors'\n\n// Workspace square glyph (initial on a colour fill) and the outlined agent-avatar colours.\nexport { ShieldIcon, type ShieldIconProps } from './ShieldIcon'\nexport { agentAvatarColors } from './agent-avatar-colors'\n\n// What kind of file a document is: the viewer's choice of renderer and the short label of its type.\nexport {\n isAudioFile,\n isDownloadOnlyFile,\n isImageFile,\n isMediaFile,\n isVideoFile,\n usesOriginalBytesForViewer,\n} from './media-type'\nexport { friendlyFileType } from './file-type'\n"],
5
+ "mappings": "AAAA,SAAS,4BAA4B;AACrC,SAAS,kBAAmC;AAC5C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,iBAAoD;AAC7D,SAAS,gBAAgB,iBAAiB,gBAAgB,uBAAuB;AACjF,SAAS,cAAc,oBAAoB;AAC3C,SAAS,qBAAoE;AAC7E,SAAS,kBAAoE;AAC7E,SAAS,qBAA8C;AAEvD,SAAS,YAAY,qBAAqB;AAG1C;AAAA,EACE;AAAA,EAKA;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EAKA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iCAAyE;AAGlF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,kBAAwC;AACjD,SAAS,yBAAyB;AAGlC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB;",
6
6
  "names": []
7
7
  }