@ynput/ayon-frontend-shared 0.7.5 → 0.7.6

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 (37) hide show
  1. package/dist/DetailsPanel.es.js +376 -380
  2. package/dist/ListTable.es.js +2 -2
  3. package/dist/NewEntity.es.js +26 -26
  4. package/dist/ProjectTreeTable.es.js +2521 -2510
  5. package/dist/ProjectsTable.es.js +3 -3
  6. package/dist/Slicer.es.js +32 -32
  7. package/dist/Views.es.js +1 -1
  8. package/dist/chunks/ColumnDropIndicator.es.js +2 -2
  9. package/dist/chunks/ColumnHeaderMenuUI.es.js +1 -1
  10. package/dist/chunks/EntityPath.es.js +1 -1
  11. package/dist/chunks/EntityPickerDialog.es.js +481 -460
  12. package/dist/chunks/EntityTooltip.es.js +1 -1
  13. package/dist/chunks/Feed.es.js +11 -10
  14. package/dist/chunks/FilterErrorActions.es.js +1 -1
  15. package/dist/chunks/GroupSettingsFallback.es.js +2 -2
  16. package/dist/chunks/Menu.es.js +250 -247
  17. package/dist/chunks/MetaWidget.es.js +2 -2
  18. package/dist/chunks/PlayableIcon.es.js +368 -368
  19. package/dist/chunks/ProjectFoldersContext.es.js +237 -0
  20. package/dist/chunks/ReviewablesSelector.es.js +1223 -1170
  21. package/dist/chunks/SimpleTable.es.js +301 -296
  22. package/dist/chunks/Slicer.es.js +418 -410
  23. package/dist/chunks/TableExportContextInstance.es.js +428 -382
  24. package/dist/chunks/ThumbnailUploaderContext.es.js +48 -0
  25. package/dist/chunks/Watchers.es.js +2 -2
  26. package/dist/chunks/{ColumnDropIndicator.styled.es.js → addonColumnTags.es.js} +60 -47
  27. package/dist/components.es.js +1404 -1274
  28. package/dist/context.es.js +559 -657
  29. package/dist/hooks.es.js +2 -2
  30. package/dist/index.es.js +2 -2
  31. package/dist/types/EntityPickerDialog.d.ts +45 -2
  32. package/dist/types/ProjectTreeTable.d.ts +119 -17
  33. package/dist/types/components.d.ts +210 -23
  34. package/dist/types/context.d.ts +8 -0
  35. package/package.json +3 -3
  36. package/dist/chunks/ProjectContext.es.js +0 -158
  37. package/dist/chunks/useQueryArgumentChangeLoading.es.js +0 -11
package/dist/hooks.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { d as P, b as x } from "./chunks/TableExportContextInstance.es.js";
2
- import { r as ve, p as Ie, q as be, o as Ae, w as He, s as Pe } from "./chunks/TableExportContextInstance.es.js";
2
+ import { r as ve, q as Ie, s as be, p as Ae, w as He, v as Pe } from "./chunks/TableExportContextInstance.es.js";
3
3
  import { u as G } from "./chunks/useLoadModule.es.js";
4
4
  import { loadRemote as R } from "@module-federation/enhanced/runtime";
5
5
  import { useRef as T, useState as S, useEffect as v, useCallback as V } from "react";
@@ -22,7 +22,7 @@ import "react-dom";
22
22
  import "react-redux";
23
23
  import "react-router-dom";
24
24
  import { u as Ke } from "./chunks/EntityPickerDialog.es.js";
25
- import { u as _e } from "./chunks/useQueryArgumentChangeLoading.es.js";
25
+ import { u as _e } from "./chunks/ProjectFoldersContext.es.js";
26
26
  import { u as $e } from "./chunks/useGroupedPagination.es.js";
27
27
  import { G as O } from "./chunks/GroupSettingsFallback.es.js";
28
28
  import { i as K } from "./chunks/isHTMLElement.es.js";
package/dist/index.es.js CHANGED
@@ -43,9 +43,9 @@ import "@dnd-kit/sortable";
43
43
  import "@dnd-kit/utilities";
44
44
  import "./chunks/VersionUploadContextInstance.es.js";
45
45
  import "./chunks/EntityTooltip.es.js";
46
- import "./chunks/ColumnDropIndicator.styled.es.js";
47
- import "@tanstack/react-table";
46
+ import "./chunks/addonColumnTags.es.js";
48
47
  import "@ynput/ayon-addon";
48
+ import "@tanstack/react-table";
49
49
  import "./chunks/EntityPickerDialog.es.js";
50
50
  import "remark-gfm";
51
51
  import "react-markdown";
@@ -2,14 +2,20 @@ import { DialogProps } from '@ynput/ayon-react-components';
2
2
  import { FC } from 'react';
3
3
  import { RowSelectionState } from '@tanstack/react-table';
4
4
 
5
+ declare type EntityLinkThumbnail = {
6
+ entityType: string;
7
+ entityId: string;
8
+ thumbnailHash?: string;
9
+ };
10
+
5
11
  export declare const EntityPickerDialog: FC<EntityPickerDialogProps>;
6
12
 
7
- declare interface EntityPickerDialogProps extends Pick<DialogProps, 'onClose'> {
13
+ export declare interface EntityPickerDialogProps extends Pick<DialogProps, 'onClose'> {
8
14
  projectName: string;
9
15
  entityType: PickerEntityType;
10
16
  initialSelection?: Partial<PickerSelection>;
11
17
  isMultiSelect?: boolean;
12
- onSubmit: (selection: string[]) => void;
18
+ onSubmit: (selection: string[], entities: PickedEntity[]) => void;
13
19
  showMoveToRoot?: boolean;
14
20
  onMoveToRoot?: () => void;
15
21
  disabledIds?: string[];
@@ -22,12 +28,49 @@ declare interface EntityPickerDialogProps extends Pick<DialogProps, 'onClose'> {
22
28
  isLoading?: boolean;
23
29
  }
24
30
 
31
+ declare type FolderListItem = {
32
+ id: string;
33
+ path: string;
34
+ parentId?: string;
35
+ parents: string[];
36
+ name: string;
37
+ label?: string;
38
+ folderType: string;
39
+ hasTasks?: boolean;
40
+ hasChildren?: boolean;
41
+ hasReviewables?: boolean;
42
+ thumbnailHash: string;
43
+ taskNames?: string[];
44
+ tags?: string[];
45
+ status: string;
46
+ attrib?: object;
47
+ ownAttrib?: string[];
48
+ createdAt: string;
49
+ updatedAt: string;
50
+ };
51
+
52
+ /** a picked entity as the picker loaded it, `undefined` when it isn't loaded (a later page) */
53
+ export declare type PickedEntity = SearchEntityLink | FolderListItem | undefined;
54
+
25
55
  export declare type PickerEntityType = 'folder' | 'task' | 'product' | 'version' | 'representation' | 'workfile';
26
56
 
27
57
  export declare type PickerSearch = Record<PickerEntityType, string | undefined>;
28
58
 
29
59
  export declare type PickerSelection = Record<PickerEntityType, RowSelectionState>;
30
60
 
61
+ declare type SearchEntityLink = {
62
+ id: string;
63
+ name: string;
64
+ entityType: string;
65
+ parents: string[];
66
+ label: string;
67
+ icon: string | undefined;
68
+ subType: string | undefined;
69
+ hasReviewables?: boolean;
70
+ taskName?: string;
71
+ thumbnail?: EntityLinkThumbnail;
72
+ };
73
+
31
74
  export { }
32
75
 
33
76
 
@@ -105,8 +105,6 @@ export declare type ActivityOperationsResponseModel = {
105
105
  success: boolean;
106
106
  };
107
107
 
108
- export declare const ADDON_COLUMN_PREFIX = "addon__";
109
-
110
108
  /**
111
109
  * Gets the values of every shown addon column for the rows on screen (fetchValues), into the
112
110
  * store the cells read. Wraps the table body.
@@ -171,6 +169,22 @@ declare type AddonMenuItem =
171
169
  danger?: boolean
172
170
  }
173
171
 
172
+ /** The signed-in user, as addons see it: in every slot's context (`user`) and from `useUser`. */
173
+ declare interface AddonUser {
174
+ name: string
175
+ fullName?: string
176
+ email?: string
177
+ /** admins, and service users (the server treats them as admins) */
178
+ isAdmin: boolean
179
+ /** managers and admins */
180
+ isManager: boolean
181
+ isGuest: boolean
182
+ /** a service user: an API key session (services, agents, CI) */
183
+ isService: boolean
184
+ /** developer mode is on */
185
+ isDeveloper: boolean
186
+ }
187
+
174
188
  export declare const allowedGroupByFields: string[];
175
189
 
176
190
  export declare const ALWAYS_VISIBLE_COLUMNS: string[];
@@ -223,6 +237,18 @@ export declare const appliesToPage: (contribution: {
223
237
  pages?: ProjectTablePage[];
224
238
  }, page: ProjectTablePage) => boolean;
225
239
 
240
+ /** Context of a service. */
241
+ declare interface AppServiceContext {
242
+ /** the project whose page is open, else `null` */
243
+ projectName: string | null
244
+ }
245
+
246
+ /** Description of an `app.service` contribution. */
247
+ declare interface AppServiceMeta {
248
+ /** unique among the addon's services */
249
+ id: string
250
+ }
251
+
226
252
  declare type AttributeData = {
227
253
  /** Type of attribute value */
228
254
  type?: 'string' | 'integer' | 'float' | 'boolean' | 'datetime' | 'list_of_strings' | 'list_of_integers' | 'list_of_any' | 'list_of_submodels' | 'dict';
@@ -425,8 +451,20 @@ declare interface ButtonPieces<S extends SlotName> {
425
451
  dialog?: Loader<ComponentType<SlotProps<S> & DialogScope>>
426
452
  /** the items of a menu the host opens under the button, like the header's help menu */
427
453
  menu?: Loader<MenuPiece<S>>
428
- /** the addon's own component instead of the host's button: a dropdown, a toggle, anything */
429
- component?: Loader<ComponentType<SlotProps<S>>>
454
+ /**
455
+ * the content of a popover the host opens under the button, like the header's menus: the host
456
+ * positions it and closes it on a click outside or Escape (an Escape or click inside a menu or
457
+ * dialog opened from the popover closes only that). It gets `close`
458
+ */
459
+ popover?: Loader<ComponentType<SlotProps<S> & PopoverScope>>
460
+ /**
461
+ * the addon's own component instead of the host's button: a dropdown, a toggle, anything. With
462
+ * `popover`, it is the popover's button (its icon, a badge, a tooltip of its own) and gets
463
+ * `popoverOpen` and `togglePopover`
464
+ */
465
+ component?:
466
+ | Loader<ComponentType<SlotProps<S>>>
467
+ | Loader<ComponentType<SlotProps<S> & PopoverButtonScope>>
430
468
  }
431
469
 
432
470
  /** Context of a button's code (`run`, `dialog`, `menu`, `component`) besides the slot's own. */
@@ -842,11 +880,7 @@ export declare interface DetailsPanelEntityProviderProps {
842
880
  }
843
881
 
844
882
  /** Context of a details panel menu item. */
845
- declare interface DetailsPanelMenuItemContext extends ProjectNameScope {
846
- entityType: string
847
- /** the entities the panel shows */
848
- selectedEntities: EntityRef[]
849
- }
883
+ declare interface DetailsPanelMenuItemContext extends ProjectNameScope, EntityScope_2 {}
850
884
 
851
885
  /** Description of a `detailsPanel.menuItem` contribution. */
852
886
  declare interface DetailsPanelMenuItemMeta extends MenuItemMeta {
@@ -1150,7 +1184,9 @@ export declare type EntityScope = 'primary' | EntityType;
1150
1184
 
1151
1185
  /** Slots about one or more entities of one type. */
1152
1186
  declare interface EntityScope_2 {
1187
+ /** the type of every entity in `entities` */
1153
1188
  entityType: string
1189
+ /** the entities the slot is about, e.g. the ones the details panel shows */
1154
1190
  entities: EntityRef[]
1155
1191
  }
1156
1192
 
@@ -2679,6 +2715,23 @@ export declare type PatchOperation = Pick<OperationModel, 'entityId' | 'entityTy
2679
2715
  type?: OperationModel['type'];
2680
2716
  };
2681
2717
 
2718
+ /**
2719
+ * What a `component` gets besides the slot context when it draws the button of a `popover`. The
2720
+ * host anchors the popover on the component's box.
2721
+ */
2722
+ declare interface PopoverButtonScope {
2723
+ /** the popover is open: show the button as active (`aria-expanded`) */
2724
+ popoverOpen: boolean
2725
+ /** opens or closes the popover: the button's `onClick` */
2726
+ togglePopover: () => void
2727
+ }
2728
+
2729
+ /** What a `popover` piece gets besides the slot context. */
2730
+ declare interface PopoverScope {
2731
+ /** closes the popover */
2732
+ close: () => void
2733
+ }
2734
+
2682
2735
  declare type PowerpackContextType = {
2683
2736
  selectedPowerPack: PowerpackFeature | null;
2684
2737
  selectedAddon: AddonDialogSelection | null;
@@ -2889,6 +2942,7 @@ declare interface ProjectFolders {
2889
2942
  }
2890
2943
 
2891
2944
  declare interface ProjectFoldersContextValue {
2945
+ projectName: string;
2892
2946
  folders: FolderListItem_2[];
2893
2947
  getFolderById: (id: string) => FolderListItem_2 | undefined;
2894
2948
  findNonInheritedValues: (folderId: string | undefined, attribNames: string[], projectAttrib?: Record<string, any>) => Record<string, any>;
@@ -3611,6 +3665,8 @@ declare interface SlicerMenuItemContext extends ProjectNameScope {
3611
3665
  sliceType: string
3612
3666
  /** the rows it acts on: the selected ones, or the right-clicked one */
3613
3667
  selected: SlicerRowRef[]
3668
+ /** `hierarchy`: the folders and tasks of `selected`; empty for the other slice types */
3669
+ entities: EntityRef[]
3614
3670
  menu: MenuKind
3615
3671
  }
3616
3672
 
@@ -3647,9 +3703,12 @@ declare interface SlicerSelection {
3647
3703
  selection: string[]
3648
3704
  }
3649
3705
 
3650
- /** What the code of a contribution to slot `S` gets: `{ slot: S, ...context }`. */
3706
+ /**
3707
+ * What the code of a contribution to slot `S` gets: `{ slot: S, user, ...context }`. The host
3708
+ * passes the slot's own context; `ContributionView` and `runContribution` add `slot` and `user`.
3709
+ */
3651
3710
  declare type SlotContext<S extends SlotName> = S extends SlotName
3652
- ? { slot: S } & SlotMap[S]['context']
3711
+ ? { slot: S } & UserScope & SlotMap[S]['context']
3653
3712
  : never
3654
3713
 
3655
3714
  /**
@@ -3680,8 +3739,9 @@ declare interface SlotMap {
3680
3739
  }
3681
3740
  /**
3682
3741
  * A button in the main header, drawn by the host like its own buttons. What a click does is the
3683
- * addon's: navigate (`to`), run code (`run`), open a dialog (`dialog`) or a menu (`menu`); or the
3684
- * addon draws the item itself (`component`, loaded with the header). Set exactly one.
3742
+ * addon's: navigate (`to`), run code (`run`), open a dialog (`dialog`), a menu (`menu`) or a
3743
+ * popover (`popover`); or the addon draws the item itself (`component`, loaded with the header).
3744
+ * Set exactly one, except that `component` may draw the button of a `popover`.
3685
3745
  */
3686
3746
  'header.item': {
3687
3747
  version: 1
@@ -3742,8 +3802,9 @@ declare interface SlotMap {
3742
3802
  /**
3743
3803
  * A button in the project tables' toolbar, before Customize (Overview, Products, Lists), drawn
3744
3804
  * by the host like the toolbar's own. What a click does is the addon's: navigate (`to`), run code
3745
- * (`run`), open a dialog (`dialog`) or a menu (`menu`); or the addon draws the item itself
3746
- * (`component`, loaded with the toolbar). Set exactly one.
3805
+ * (`run`), open a dialog (`dialog`), a menu (`menu`) or a popover (`popover`); or the addon draws
3806
+ * the item itself (`component`, loaded with the toolbar). Set exactly one, except that
3807
+ * `component` may draw the button of a `popover`.
3747
3808
  */
3748
3809
  'projectTable.toolbarItem': {
3749
3810
  version: 1
@@ -3766,7 +3827,9 @@ declare interface SlotMap {
3766
3827
  * settings from the description; `cell` and `fetchValues` load with the table. The host draws
3767
3828
  * the cell box (padding, selection, focus), so `cell` renders only its content; selecting, the
3768
3829
  * right-click menu and Copy (the cell's `value` as text) work as in other columns. Not sortable,
3769
- * and pasting into it changes nothing.
3830
+ * and pasting into it changes nothing. When the values depend on data your mutations change, list
3831
+ * its cache tags in `providesTags` and the column refreshes itself when they are invalidated:
3832
+ * `tableColumn({ id, label, cell, fetchValues, providesTags: [{ type: 'myaddonLog', id: 'LIST' }] })`.
3770
3833
  */
3771
3834
  tableColumn: {
3772
3835
  version: 1
@@ -3790,6 +3853,19 @@ declare interface SlotMap {
3790
3853
  context: TableShortcutContext
3791
3854
  pieces: TableShortcutPieces
3792
3855
  }
3856
+ /**
3857
+ * Code with no UI that runs while AYON is open, whatever the page: keeping a state, listening to
3858
+ * websocket events, registering a store listener. `component` loads at startup and is mounted
3859
+ * once for the whole app, under AYON's providers (store, router, contexts), so it can use hooks;
3860
+ * it renders nothing (`return null`). Clean up in its effects. A crash unmounts it and shows a
3861
+ * toast; the rest of AYON keeps working.
3862
+ */
3863
+ 'app.service': {
3864
+ version: 1
3865
+ meta: AppServiceMeta
3866
+ context: AppServiceContext
3867
+ pieces: { component: Loader<ComponentType<SlotProps<'app.service'>>> }
3868
+ }
3793
3869
  }
3794
3870
 
3795
3871
  /** The name of a slot, e.g. `'project.page'`. */
@@ -4013,7 +4089,8 @@ export declare type TableCellContextValue = {
4013
4089
  * Gets a column's values, by entity id; each cell gets its own as `value`. AYON calls it with
4014
4090
  * the rows that come on screen and that it has no value for yet, in batches once scrolling
4015
4091
  * pauses, and keeps what it returns: scrolling back costs nothing. A row whose entity changes
4016
- * (here or by someone else) is asked for again; `refreshTableColumn(id)` asks again for all.
4092
+ * (here or by someone else) is asked for again; for anything else the values depend on, list its
4093
+ * cache tags in the column's `providesTags`, or call `refreshTableColumn(id)` to ask again for all.
4017
4094
  * When it throws, those cells show the error and are tried again when they next come on
4018
4095
  * screen. Fetch through AYON's store (`dispatch(api.endpoints.x.initiate(...))`) to share its
4019
4096
  * cache.
@@ -4048,8 +4125,23 @@ declare interface TableColumnMeta {
4048
4125
  * `false` for the menu's top level
4049
4126
  */
4050
4127
  menu?: string | false
4128
+ /**
4129
+ * cache tags of AYON's api that the values depend on: when one is invalidated (by your
4130
+ * mutations or AYON's), the values are fetched again as with `refreshTableColumn`. Needs
4131
+ * `fetchValues`. Names as you register them (`enhanceEndpoints({ addTagTypes })`, prefixed with
4132
+ * your addon name) or AYON's own. A plain name follows invalidations of the whole type only: to
4133
+ * follow `{ type, id }`, such as a list tag, give that tag
4134
+ */
4135
+ providesTags?: TableColumnTag[]
4051
4136
  }
4052
4137
 
4138
+ /**
4139
+ * A cache tag a `tableColumn` depends on (`providesTags`), as in RTK Query: a tag type, or a type
4140
+ * and id. Invalidating `'x'` refreshes columns that list `'x'` or `{ type: 'x', id }`;
4141
+ * invalidating `{ type: 'x', id: 'LIST' }` refreshes only columns that list that tag.
4142
+ */
4143
+ declare type TableColumnTag = string | { type: string; id?: string | number }
4144
+
4053
4145
  export declare interface TableGroupBy {
4054
4146
  desc: boolean;
4055
4147
  id: string;
@@ -4103,6 +4195,11 @@ declare interface TableShortcutContext {
4103
4195
  projectName: string | null
4104
4196
  /** the rows it acts on: the selected ones when the key was pressed in one of them, else its row */
4105
4197
  rows: TableRowRef[]
4198
+ /**
4199
+ * the entities of `rows` in the project tables (list items resolve to their entity); empty in
4200
+ * the panels' tables, whose rows are not all entities: read `rows` there
4201
+ */
4202
+ entities: EntityRef[]
4106
4203
  /** where the key was pressed: the row's id, and the column's in the project tables */
4107
4204
  focused: { rowId: string; columnId?: string }
4108
4205
  /** project tables: the selected cells, by row (entity) and column id; empty elsewhere */
@@ -4597,6 +4694,11 @@ declare type UserModel = {
4597
4694
  updatedAt?: string;
4598
4695
  };
4599
4696
 
4697
+ /** Every slot: the signed-in user. The host adds it; AYON renders addons only once signed in. */
4698
+ declare interface UserScope {
4699
+ user: AddonUser
4700
+ }
4701
+
4600
4702
  export declare const useScopedAttributeFields: <T extends AttributeField>({ attribFields, allowedScopes, }: UseScopedAttributeFieldsProps<T>) => T[];
4601
4703
 
4602
4704
  declare interface UseScopedAttributeFieldsProps<T extends AttributeField> {