@visin/frontend-core 1.11.0 → 1.12.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 (32) hide show
  1. package/README.md +15 -12
  2. package/dist/apiClient.js +2 -0
  3. package/dist/apiClient.js.map +1 -1
  4. package/dist/components/Ownership/OwnerChip.d.ts +11 -0
  5. package/dist/components/Ownership/OwnerChip.d.ts.map +1 -0
  6. package/dist/components/Ownership/OwnerChip.js +10 -0
  7. package/dist/components/Ownership/OwnerChip.js.map +1 -0
  8. package/dist/components/Ownership/OwnerPicker.d.ts +14 -0
  9. package/dist/components/Ownership/OwnerPicker.d.ts.map +1 -0
  10. package/dist/components/Ownership/OwnerPicker.js +14 -0
  11. package/dist/components/Ownership/OwnerPicker.js.map +1 -0
  12. package/dist/components/Ownership/TransferOwnershipDialog.d.ts +19 -0
  13. package/dist/components/Ownership/TransferOwnershipDialog.d.ts.map +1 -0
  14. package/dist/components/Ownership/TransferOwnershipDialog.js +22 -0
  15. package/dist/components/Ownership/TransferOwnershipDialog.js.map +1 -0
  16. package/dist/components/Ownership/VisibilitySwitch.d.ts +11 -0
  17. package/dist/components/Ownership/VisibilitySwitch.d.ts.map +1 -0
  18. package/dist/components/Ownership/VisibilitySwitch.js +11 -0
  19. package/dist/components/Ownership/VisibilitySwitch.js.map +1 -0
  20. package/dist/components/Ownership/index.d.ts +11 -0
  21. package/dist/components/Ownership/index.d.ts.map +1 -0
  22. package/dist/components/Ownership/index.js +6 -0
  23. package/dist/components/Ownership/index.js.map +1 -0
  24. package/dist/components/Ownership/types.d.ts +26 -0
  25. package/dist/components/Ownership/types.d.ts.map +1 -0
  26. package/dist/components/Ownership/types.js +23 -0
  27. package/dist/components/Ownership/types.js.map +1 -0
  28. package/dist/index.d.ts +2 -0
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +1 -0
  31. package/dist/index.js.map +1 -1
  32. package/package.json +1 -1
package/README.md CHANGED
@@ -12,22 +12,25 @@ npm install @visin/frontend-core
12
12
 
13
13
  ```typescript
14
14
  import { createApiClient } from '@visin/frontend-core';
15
+ import { getGlobalConfig } from './ConfigProvider';
15
16
 
16
17
  export const api = createApiClient({
17
- baseUrl: () => getGlobalConfig().VISION_API_URL,
18
- getToken: () => localStorage.getItem('authToken'),
19
- onUnauthorized: () => { window.location.href = '/login'; }
18
+ baseUrl: () => getGlobalConfig().VISION_API_URL || 'http://localhost:4010',
19
+ onUnauthorized: () => {
20
+ window.location.href = '/login';
21
+ }
20
22
  });
21
23
 
22
- const { id } = await api.get('/projects/123');
24
+ const { data: project } = await api.get<{ success: true; data: { _id: string; name: string } }>(
25
+ '/api/projects/<project-id>'
26
+ );
23
27
  ```
24
28
 
25
- ## Status
29
+ Adapt the config import to your app. The client sends the shared HTTP-only `access_token` cookie with each request
30
+ (`credentials: 'include'`). Browser code does not read or store the JWT. Use a
31
+ project token or user API key in a non-browser client instead.
26
32
 
27
- Only `createApiClient` is extracted so far — it matches the Bearer-token-from-
28
- `localStorage` transport already used independently in `account-front` and
29
- `vision-front`. Auth state (login/logout/session) is **not** unified yet:
30
- `account-front`, `auth-front`, and `vision-front` each implement it differently
31
- (`authService.ts`, `authFlow.ts`, `AuthContext.tsx`) rather than as copies of one
32
- pattern, so that needs its own design pass before landing here. See the repo's
33
- `TODO.md`.
33
+ The package also exports `createAuthService`, `createAuthContext`, route guards,
34
+ navigation, configuration and shared UI components. Each frontend creates its
35
+ own auth context with the shared factory so it can run both standalone and in
36
+ `shell-front`.
package/dist/apiClient.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export class ApiError extends Error {
2
+ status;
3
+ body;
2
4
  constructor(status, message, body) {
3
5
  super(message);
4
6
  this.name = 'ApiError';
@@ -1 +1 @@
1
- {"version":3,"file":"apiClient.js","sourceRoot":"","sources":["../src/apiClient.ts"],"names":[],"mappings":"AAYA,MAAM,OAAO,QAAS,SAAQ,KAAK;IAIjC,YAAY,MAAc,EAAE,OAAe,EAAE,IA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AC,CAAC,SAAS,EAAE,CAAC;QAC5G,GAAG,EAAE,CAAc,IAAY,EAAE,IAAc,EAAE,IAAwB,EAAE,EAAE,CAC3E,OAAO,CAAI,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;QAC3G,KAAK,EAAE,CAAc,IAAY,EAAE,IAAc,EAAE,IAAwB,EAAE,EAAE,CAC7E,OAAO,CAAI,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;QAC7G,MAAM,EAAE,CAAc,IAAY,EAAE,IAAwB,EAAE,EAAE,CAAC,OAAO,CAAI,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;KACjH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { type OwnerGroup, type OwnerRef } from './types';
2
+ export interface OwnerChipProps {
3
+ owner: OwnerRef;
4
+ userId?: string;
5
+ groups: OwnerGroup[];
6
+ /** the owning group's name when the user is not in it, if the API sent one */
7
+ ownerName?: string;
8
+ }
9
+ /** Who owns this, at a glance: "Me" or the group's name. */
10
+ export declare function OwnerChip({ owner, userId, groups, ownerName }: OwnerChipProps): import("react").JSX.Element;
11
+ //# sourceMappingURL=OwnerChip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OwnerChip.d.ts","sourceRoot":"","sources":["../../../src/components/Ownership/OwnerChip.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAc,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAErE,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,QAAQ,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,4DAA4D;AAC5D,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,cAAc,+BAW7E"}
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Chip } from '@mui/material';
3
+ import { Group, Person } from '@mui/icons-material';
4
+ import { ownerLabel } from './types';
5
+ /** Who owns this, at a glance: "Me" or the group's name. */
6
+ export function OwnerChip({ owner, userId, groups, ownerName }) {
7
+ const label = ownerName && !(owner.kind === 'user' && owner.id === userId) ? ownerName : ownerLabel(owner, userId, groups);
8
+ return (_jsx(Chip, { size: "small", variant: "outlined", icon: owner.kind === 'group' ? _jsx(Group, {}) : _jsx(Person, {}), label: label, "aria-label": `Owner: ${label}` }));
9
+ }
10
+ //# sourceMappingURL=OwnerChip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OwnerChip.js","sourceRoot":"","sources":["../../../src/components/Ownership/OwnerChip.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAkC,MAAM,SAAS,CAAC;AAUrE,4DAA4D;AAC5D,MAAM,UAAU,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAkB;IAC5E,MAAM,KAAK,GAAG,SAAS,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3H,OAAO,CACL,KAAC,IAAI,IACH,IAAI,EAAC,OAAO,EACZ,OAAO,EAAC,UAAU,EAClB,IAAI,EAAE,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,KAAC,KAAK,KAAG,CAAC,CAAC,CAAC,KAAC,MAAM,KAAG,EACrD,KAAK,EAAE,KAAK,gBACA,UAAU,KAAK,EAAE,GAC7B,CACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { type OwnerGroup, type OwnerRef } from './types';
2
+ export interface OwnerPickerProps {
3
+ value: OwnerRef;
4
+ onChange: (owner: OwnerRef) => void;
5
+ userId: string;
6
+ /** the signed-in user's groups; each is offered as an owner */
7
+ groups: OwnerGroup[];
8
+ disabled?: boolean;
9
+ label?: string;
10
+ helperText?: string;
11
+ }
12
+ /** Who a new project or dataset belongs to: the user, or one of their groups. */
13
+ export declare function OwnerPicker({ value, onChange, userId, groups, disabled, label, helperText }: OwnerPickerProps): import("react").JSX.Element;
14
+ //# sourceMappingURL=OwnerPicker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OwnerPicker.d.ts","sourceRoot":"","sources":["../../../src/components/Ownership/OwnerPicker.tsx"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAErE,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,QAAQ,CAAC;IAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAID,iFAAiF;AACjF,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAe,EAAE,UAAU,EAAE,EAAE,gBAAgB,+BAuBvH"}
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { MenuItem, TextField } from '@mui/material';
3
+ import { ownerLabel } from './types';
4
+ const keyOf = (owner) => `${owner.kind}:${owner.id}`;
5
+ /** Who a new project or dataset belongs to: the user, or one of their groups. */
6
+ export function OwnerPicker({ value, onChange, userId, groups, disabled, label = 'Owner', helperText }) {
7
+ const options = [{ kind: 'user', id: userId }, ...groups.map((group) => ({ kind: 'group', id: group.id }))];
8
+ return (_jsx(TextField, { select: true, size: "small", label: label, value: keyOf(value), disabled: disabled, helperText: helperText ?? (value.kind === 'group' ? "The group's roles decide who can do what with it." : 'Only you can see and change it, unless you make it public.'), onChange: (event) => {
9
+ const chosen = options.find((option) => keyOf(option) === event.target.value);
10
+ if (chosen)
11
+ onChange(chosen);
12
+ }, sx: { minWidth: 220 }, children: options.map((option) => (_jsx(MenuItem, { value: keyOf(option), children: ownerLabel(option, userId, groups) }, keyOf(option)))) }));
13
+ }
14
+ //# sourceMappingURL=OwnerPicker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OwnerPicker.js","sourceRoot":"","sources":["../../../src/components/Ownership/OwnerPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,UAAU,EAAkC,MAAM,SAAS,CAAC;AAarE,MAAM,KAAK,GAAG,CAAC,KAAe,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,EAAE,EAAE,CAAC;AAE/D,iFAAiF;AACjF,MAAM,UAAU,WAAW,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE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
+ /** what is being moved, for the title: "Road scenes" */
5
+ resourceName: string;
6
+ current: OwnerRef;
7
+ userId: string;
8
+ groups: OwnerGroup[];
9
+ busy?: boolean;
10
+ error?: string | null;
11
+ onClose: () => void;
12
+ onTransfer: (to: OwnerRef) => void;
13
+ }
14
+ /**
15
+ * Hand a project or dataset, with everything in it, to another owner. It
16
+ * offers only the moves the user may make; with none, it says why.
17
+ */
18
+ export declare function TransferOwnershipDialog({ open, resourceName, current, userId, groups, busy, error, onClose, onTransfer }: TransferOwnershipDialogProps): import("react").JSX.Element;
19
+ //# sourceMappingURL=TransferOwnershipDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransferOwnershipDialog.d.ts","sourceRoot":"","sources":["../../../src/components/Ownership/TransferOwnershipDialog.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA+B,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEtF,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,OAAO,CAAC;IACd,wDAAwD;IACxD,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,QAAQ,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,IAAI,CAAC;CACpC;AAID;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,MAAM,EACN,MAAM,EACN,IAAI,EACJ,KAAK,EACL,OAAO,EACP,UAAU,EACX,EAAE,4BAA4B,+BA6D9B"}
@@ -0,0 +1,22 @@
1
+ import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { Alert, Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, MenuItem, TextField } from '@mui/material';
4
+ import { ownerLabel, transferTargets } from './types';
5
+ const keyOf = (owner) => `${owner.kind}:${owner.id}`;
6
+ /**
7
+ * Hand a project or dataset, with everything in it, to another owner. It
8
+ * offers only the moves the user may make; with none, it says why.
9
+ */
10
+ export function TransferOwnershipDialog({ open, resourceName, current, userId, groups, busy, error, onClose, onTransfer }) {
11
+ const targets = transferTargets(current, userId, groups);
12
+ const [chosen, setChosen] = useState('');
13
+ const target = targets.find((option) => keyOf(option) === chosen);
14
+ const close = () => {
15
+ setChosen('');
16
+ onClose();
17
+ };
18
+ return (_jsxs(Dialog, { open: open, onClose: busy ? undefined : close, fullWidth: true, maxWidth: "xs", children: [_jsxs(DialogTitle, { children: ["Transfer ", resourceName] }), _jsxs(DialogContent, { children: [targets.length === 0 ? (_jsx(DialogContentText, { children: current.kind === 'user'
19
+ ? 'Only its owner can transfer it.'
20
+ : "Only the owning group's owner can transfer it." })) : (_jsxs(_Fragment, { children: [_jsxs(DialogContentText, { sx: { mb: 2 }, children: ["Everything in it moves too. Who can see and change it then follows the new owner.", current.kind === 'user' && ' Once it belongs to a group, only that group’s owner can move it again.'] }), _jsx(TextField, { select: true, fullWidth: true, size: "small", label: "New owner", value: chosen, disabled: busy, onChange: (event) => setChosen(event.target.value), children: targets.map((option) => (_jsx(MenuItem, { value: keyOf(option), children: ownerLabel(option, userId, groups) }, keyOf(option)))) })] })), error && (_jsx(Alert, { severity: "error", sx: { mt: 2 }, children: error }))] }), _jsxs(DialogActions, { children: [_jsx(Button, { onClick: close, disabled: busy, children: targets.length === 0 ? 'Close' : 'Cancel' }), targets.length > 0 && (_jsx(Button, { variant: "contained", disabled: !target || busy, onClick: () => target && onTransfer(target), children: "Transfer" }))] })] }));
21
+ }
22
+ //# sourceMappingURL=TransferOwnershipDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransferOwnershipDialog.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AAE,GAAG,EAAE,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC,yBAEzF,CACV,IACa,IACT,CACV,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { Visibility } from './types';
2
+ export interface VisibilitySwitchProps {
3
+ value: Visibility;
4
+ onChange: (visibility: Visibility) => void;
5
+ /** whoever owns it may have it stay private but not make it public; they see why */
6
+ canMakePublic?: boolean;
7
+ disabled?: boolean;
8
+ }
9
+ /** Private to its owner, or readable by anyone, signed in or not. There is no level between. */
10
+ export declare function VisibilitySwitch({ value, onChange, canMakePublic, disabled }: VisibilitySwitchProps): import("react").JSX.Element;
11
+ //# sourceMappingURL=VisibilitySwitch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VisibilitySwitch.d.ts","sourceRoot":"","sources":["../../../src/components/Ownership/VisibilitySwitch.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAC3C,oFAAoF;IACpF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,gGAAgG;AAChG,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAoB,EAAE,QAAQ,EAAE,EAAE,qBAAqB,+BAiB1G"}
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { FormControl, FormControlLabel, FormHelperText, FormLabel, Radio, RadioGroup } from '@mui/material';
3
+ /** Private to its owner, or readable by anyone, signed in or not. There is no level between. */
4
+ export function VisibilitySwitch({ value, onChange, canMakePublic = true, disabled }) {
5
+ return (_jsxs(FormControl, { disabled: disabled, children: [_jsx(FormLabel, { id: "visibility-label", children: "Who can see it" }), _jsxs(RadioGroup, { row: true, "aria-labelledby": "visibility-label", value: value, onChange: (event) => onChange(event.target.value), children: [_jsx(FormControlLabel, { value: "private", control: _jsx(Radio, {}), label: "Private" }), _jsx(FormControlLabel, { value: "public", control: _jsx(Radio, {}), label: "Public", disabled: disabled || (!canMakePublic && value !== 'public') })] }), _jsx(FormHelperText, { children: value === 'public'
6
+ ? 'Anyone can read it, even without signing in. Only its owner can change it.'
7
+ : canMakePublic
8
+ ? 'Only its owner, and the owning group’s members, can see it.'
9
+ : 'Only its owner, and the owning group’s members, can see it. Only the owner can make it public.' })] }));
10
+ }
11
+ //# sourceMappingURL=VisibilitySwitch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VisibilitySwitch.js","sourceRoot":"","sources":["../../../src/components/Ownership/VisibilitySwitch.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAW5G,gGAAgG;AAChG,MAAM,UAAU,gBAAgB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,EAAE,QAAQ,EAAyB;IACzG,OAAO,CACL,MAAC,WAAW,IAAC,QAAQ,EAAE,QAAQ,aAC7B,KAAC,SAAS,IAAC,EAAE,EAAC,kBAAkB,+BAA2B,EAC3D,MAAC,UAAU,IAAC,GAAG,2BAAiB,kBAAkB,EAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,KAAmB,CAAC,aAC9H,KAAC,gBAAgB,IAAC,KAAK,EAAC,SAAS,EAAC,OAAO,EAAE,KAAC,KAAK,KAAG,EAAE,KAAK,EAAC,SAAS,GAAG,EACxE,KAAC,gBAAgB,IAAC,KAAK,EAAC,QAAQ,EAAC,OAAO,EAAE,KAAC,KAAK,KAAG,EAAE,KAAK,EAAC,QAAQ,EAAC,QAAQ,EAAE,QAAQ,IAAI,CAAC,CAAC,aAAa,IAAI,KAAK,KAAK,QAAQ,CAAC,GAAI,IACzH,EACb,KAAC,cAAc,cACZ,KAAK,KAAK,QAAQ;oBACjB,CAAC,CAAC,4EAA4E;oBAC9E,CAAC,CAAC,aAAa;wBACb,CAAC,CAAC,6DAA6D;wBAC/D,CAAC,CAAC,gGAAgG,GACvF,IACL,CACf,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ export { OwnerPicker } from './OwnerPicker';
2
+ export type { OwnerPickerProps } from './OwnerPicker';
3
+ export { VisibilitySwitch } from './VisibilitySwitch';
4
+ export type { VisibilitySwitchProps } from './VisibilitySwitch';
5
+ export { OwnerChip } from './OwnerChip';
6
+ export type { OwnerChipProps } from './OwnerChip';
7
+ export { TransferOwnershipDialog } from './TransferOwnershipDialog';
8
+ export type { TransferOwnershipDialogProps } from './TransferOwnershipDialog';
9
+ export { transferTargets, ownerLabel } from './types';
10
+ export type { OwnerRef, OwnerGroup, OwnerRole, Visibility } from './types';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Ownership/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,YAAY,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACtD,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { OwnerPicker } from './OwnerPicker';
2
+ export { VisibilitySwitch } from './VisibilitySwitch';
3
+ export { OwnerChip } from './OwnerChip';
4
+ export { TransferOwnershipDialog } from './TransferOwnershipDialog';
5
+ export { transferTargets, ownerLabel } from './types';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Ownership/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,26 @@
1
+ /** Who controls a project or dataset, as the APIs send it. */
2
+ export interface OwnerRef {
3
+ kind: 'user' | 'group';
4
+ id: string;
5
+ }
6
+ export type OwnerRole = 'owner' | 'admin' | 'member';
7
+ /** One of the signed-in user's groups, with their role in it. */
8
+ export interface OwnerGroup {
9
+ id: string;
10
+ name: string;
11
+ role: OwnerRole;
12
+ }
13
+ export type Visibility = 'private' | 'public';
14
+ /**
15
+ * Where the signed-in user may move something owned by `current`: the same
16
+ * rules the backends enforce (backend-core `canTransfer`), for the choices a
17
+ * form offers. The server still decides.
18
+ *
19
+ * - Theirs: to any group they are in.
20
+ * - A group's, where they are its owner: to themself, or another group they are in.
21
+ * - Otherwise: nowhere.
22
+ */
23
+ export declare function transferTargets(current: OwnerRef, userId: string, groups: OwnerGroup[]): OwnerRef[];
24
+ /** "Me", a group's name, or "A group" for one the user is not in. */
25
+ export declare function ownerLabel(owner: OwnerRef, userId: string | undefined, groups: OwnerGroup[]): string;
26
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Ownership/types.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErD,iEAAiE;AACjE,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE9C;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,QAAQ,EAAE,CAMnG;AAED,qEAAqE;AACrE,wBAAgB,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAGpG"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Where the signed-in user may move something owned by `current`: the same
3
+ * rules the backends enforce (backend-core `canTransfer`), for the choices a
4
+ * form offers. The server still decides.
5
+ *
6
+ * - Theirs: to any group they are in.
7
+ * - A group's, where they are its owner: to themself, or another group they are in.
8
+ * - Otherwise: nowhere.
9
+ */
10
+ export function transferTargets(current, userId, groups) {
11
+ const groupTargets = (except) => groups.filter((group) => group.id !== except).map((group) => ({ kind: 'group', id: group.id }));
12
+ if (current.kind === 'user')
13
+ return current.id === userId ? groupTargets() : [];
14
+ const role = groups.find((group) => group.id === current.id)?.role;
15
+ return role === 'owner' ? [{ kind: 'user', id: userId }, ...groupTargets(current.id)] : [];
16
+ }
17
+ /** "Me", a group's name, or "A group" for one the user is not in. */
18
+ export function ownerLabel(owner, userId, groups) {
19
+ if (owner.kind === 'user')
20
+ return owner.id === userId ? 'Me' : 'Another person';
21
+ return groups.find((group) => group.id === owner.id)?.name ?? 'A group';
22
+ }
23
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/Ownership/types.ts"],"names":[],"mappings":"AAiBA;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,OAAiB,EAAE,MAAc,EAAE,MAAoB;IACrF,MAAM,YAAY,GAAG,CAAC,MAAe,EAAE,EAAE,CACvC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAY,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC5G,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,OAAO,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAChF,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,OAAO,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC;IACnE,OAAO,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,GAAG,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC7F,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,UAAU,CAAC,KAAe,EAAE,MAA0B,EAAE,MAAoB;IAC1F,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAChF,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC,EAAE,IAAI,IAAI,SAAS,CAAC;AAC1E,CAAC"}
package/dist/index.d.ts CHANGED
@@ -12,6 +12,8 @@ export { createVisinTheme, visinTheme, VISIN_COLORS, COLOR_SCHEME_ATTRIBUTE, COL
12
12
  export type { ColorSchemeName } from './theme';
13
13
  export { VisinThemeProvider, ColorModeSetting, COLOR_MODE_OPTIONS, useThemeColorMeta, useActivePalette, useChartColors } from './components/ColorMode';
14
14
  export type { VisinThemeProviderProps, ColorMode, ColorModeSettingProps, ChartColors } from './components/ColorMode';
15
+ export { OwnerPicker, VisibilitySwitch, OwnerChip, TransferOwnershipDialog, transferTargets, ownerLabel } from './components/Ownership';
16
+ export type { OwnerPickerProps, VisibilitySwitchProps, OwnerChipProps, TransferOwnershipDialogProps, OwnerRef, OwnerGroup, OwnerRole, Visibility } from './components/Ownership';
15
17
  export { createVisinNavigation } from './navigation';
16
18
  export type { VisinApp, VisinAppUrls, VisinNavigation } from './navigation';
17
19
  export { createProtectedRoute } from './components/ProtectedRoute';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxD,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAElF,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,YAAY,EAAE,WAA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mBAAmB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAE1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,YAAY,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC"}
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@ export { AppLayout } from './components/AppLayout';
6
6
  export { PageHeader, Panel, ListRow, RowIcon, SectionHeading, EmptyState, ResponsiveActions, TAB_BAR_HEIGHT, useCompactLayout } from './components/Page';
7
7
  export { createVisinTheme, visinTheme, VISIN_COLORS, COLOR_SCHEME_ATTRIBUTE, COLOR_MODE_STORAGE_KEY, COLOR_SCHEME_STORAGE_KEY, brand, schemes, ink, surface, pageBackground, glass, glassInteractive, liftOnHover, raisedShadow, mainAction, chrome, onImage, tint, livePalette, chartSeries } from './theme';
8
8
  export { VisinThemeProvider, ColorModeSetting, COLOR_MODE_OPTIONS, useThemeColorMeta, useActivePalette, useChartColors } from './components/ColorMode';
9
+ export { OwnerPicker, VisibilitySwitch, OwnerChip, TransferOwnershipDialog, transferTargets, ownerLabel } from './components/Ownership';
9
10
  export { createVisinNavigation } from './navigation';
10
11
  export { createProtectedRoute } from './components/ProtectedRoute';
11
12
  export { createLoginRedirect } from './components/LoginRedirect';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mFAAmF;AAEnF,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGxD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AASnD,OAAO,EACL,UAAU,EACV,KAAK,EACL,OAAO,EACP,OAAO,EACP,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAW3B,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,KAAK,EACL,OAAO,EACP,GAAG,EACH,OAAO,EACP,cAAc,EACd,KAAK,EACL,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,UAAU,EACV,MAAM,EACN,OAAO,EACP,IAAI,EACJ,WAAW,EACX,WAAW,EACZ,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACf,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mFAAmF;AAEnF,OAAO,EAAE,eAAe,EAAE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-core",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "description": "Shared frontend auth/API-client logic for Visin frontends",
5
5
  "author": "Toomas Tahves",
6
6
  "license": "MIT",