@payloadcms/ui 4.0.0-canary.1 → 4.0.0-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/radius.css +1 -3
- package/dist/css/theme.css +4 -0
- package/dist/css/utilities.css +5 -0
- package/dist/elements/APIKeyInput/index.css +92 -0
- package/dist/elements/APIKeyInput/index.d.ts +14 -0
- package/dist/elements/APIKeyInput/index.d.ts.map +1 -0
- package/dist/elements/APIKeyInput/index.js +86 -0
- package/dist/elements/APIKeyInput/index.js.map +1 -0
- package/dist/elements/BulkUpload/ActionsBar/index.css +10 -4
- package/dist/elements/BulkUpload/ActionsBar/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/ActionsBar/index.js +43 -40
- package/dist/elements/BulkUpload/ActionsBar/index.js.map +1 -1
- package/dist/elements/BulkUpload/AddFilesView/index.js +1 -1
- package/dist/elements/BulkUpload/AddFilesView/index.js.map +1 -1
- package/dist/elements/BulkUpload/AddingFilesView/index.css +25 -0
- package/dist/elements/BulkUpload/AddingFilesView/index.d.ts +1 -1
- package/dist/elements/BulkUpload/AddingFilesView/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/AddingFilesView/index.js +1 -1
- package/dist/elements/BulkUpload/AddingFilesView/index.js.map +1 -1
- package/dist/elements/BulkUpload/EditForm/index.css +9 -0
- package/dist/elements/BulkUpload/EditForm/index.d.ts +1 -1
- package/dist/elements/BulkUpload/EditForm/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/EditForm/index.js +1 -1
- package/dist/elements/BulkUpload/EditForm/index.js.map +1 -1
- package/dist/elements/BulkUpload/EditMany/DrawerContent.d.ts +1 -1
- package/dist/elements/BulkUpload/EditMany/DrawerContent.d.ts.map +1 -1
- package/dist/elements/BulkUpload/EditMany/DrawerContent.js +59 -55
- package/dist/elements/BulkUpload/EditMany/DrawerContent.js.map +1 -1
- package/dist/elements/BulkUpload/EditMany/index.css +71 -0
- package/dist/elements/BulkUpload/EditMany/index.d.ts +1 -1
- package/dist/elements/BulkUpload/EditMany/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/EditMany/index.js +1 -1
- package/dist/elements/BulkUpload/EditMany/index.js.map +1 -1
- package/dist/elements/BulkUpload/FileSidebar/index.css +54 -75
- package/dist/elements/BulkUpload/FileSidebar/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/FileSidebar/index.js +60 -50
- package/dist/elements/BulkUpload/FileSidebar/index.js.map +1 -1
- package/dist/elements/ColumnSelector/index.js +1 -1
- package/dist/elements/ColumnSelector/index.js.map +1 -1
- package/dist/elements/DocumentFields/index.css +1 -1
- package/dist/elements/Drawer/index.d.ts +25 -0
- package/dist/elements/Drawer/index.d.ts.map +1 -1
- package/dist/elements/Drawer/index.js +134 -62
- package/dist/elements/Drawer/index.js.map +1 -1
- package/dist/elements/FileDetails/DraggableFileDetails/index.css +32 -0
- package/dist/elements/FileDetails/DraggableFileDetails/index.d.ts +1 -1
- package/dist/elements/FileDetails/DraggableFileDetails/index.d.ts.map +1 -1
- package/dist/elements/FileDetails/DraggableFileDetails/index.js +19 -18
- package/dist/elements/FileDetails/DraggableFileDetails/index.js.map +1 -1
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.css +36 -0
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.d.ts +1 -1
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.js +1 -1
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.js.map +1 -1
- package/dist/elements/Hierarchy/Field/index.client.d.ts +1 -1
- package/dist/elements/Hierarchy/Field/index.client.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Field/index.client.js +5 -2
- package/dist/elements/Hierarchy/Field/index.client.js.map +1 -1
- package/dist/elements/Hierarchy/Field/index.css +37 -0
- package/dist/elements/Hierarchy/MoveMany/index.d.ts +0 -1
- package/dist/elements/Hierarchy/MoveMany/index.d.ts.map +1 -1
- package/dist/elements/Hierarchy/MoveMany/index.js +0 -1
- package/dist/elements/Hierarchy/MoveMany/index.js.map +1 -1
- package/dist/elements/Hierarchy/Tree/LoadMore/index.css +27 -0
- package/dist/elements/Hierarchy/Tree/LoadMore/index.d.ts +1 -1
- package/dist/elements/Hierarchy/Tree/LoadMore/index.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Tree/LoadMore/index.js +1 -1
- package/dist/elements/Hierarchy/Tree/LoadMore/index.js.map +1 -1
- package/dist/elements/Hierarchy/Tree/TreeFocusContext.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Tree/TreeFocusContext.js +36 -16
- package/dist/elements/Hierarchy/Tree/TreeFocusContext.js.map +1 -1
- package/dist/elements/Hierarchy/Tree/TreeNode/index.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Tree/TreeNode/index.js +20 -15
- package/dist/elements/Hierarchy/Tree/TreeNode/index.js.map +1 -1
- package/dist/elements/LoadMoreRow/index.css +34 -0
- package/dist/elements/LoadMoreRow/index.d.ts +1 -1
- package/dist/elements/LoadMoreRow/index.d.ts.map +1 -1
- package/dist/elements/LoadMoreRow/index.js +4 -8
- package/dist/elements/LoadMoreRow/index.js.map +1 -1
- package/dist/elements/Popup/PopupGroupLabel/index.css +12 -0
- package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingScheduleWhere.d.ts +13 -0
- package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingScheduleWhere.d.ts.map +1 -0
- package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingScheduleWhere.js +41 -0
- package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingScheduleWhere.js.map +1 -0
- package/dist/elements/PublishButton/ScheduleDrawer/index.d.ts +1 -0
- package/dist/elements/PublishButton/ScheduleDrawer/index.d.ts.map +1 -1
- package/dist/elements/PublishButton/ScheduleDrawer/index.js +9 -31
- package/dist/elements/PublishButton/ScheduleDrawer/index.js.map +1 -1
- package/dist/elements/PublishButton/index.d.ts.map +1 -1
- package/dist/elements/PublishButton/index.js +4 -5
- package/dist/elements/PublishButton/index.js.map +1 -1
- package/dist/elements/ReactSelect/MultiValue/index.css +1 -1
- package/dist/elements/ReactSelect/index.d.ts.map +1 -1
- package/dist/elements/ReactSelect/index.js +12 -4
- package/dist/elements/ReactSelect/index.js.map +1 -1
- package/dist/elements/SchedulePublishButton/index.d.ts.map +1 -1
- package/dist/elements/SchedulePublishButton/index.js +6 -1
- package/dist/elements/SchedulePublishButton/index.js.map +1 -1
- package/dist/elements/SelectMany/index.js +1 -1
- package/dist/elements/SelectMany/index.js.map +1 -1
- package/dist/elements/Table/index.css +7 -5
- package/dist/elements/Tabs/index.css +100 -0
- package/dist/elements/Tabs/index.d.ts +32 -0
- package/dist/elements/Tabs/index.d.ts.map +1 -0
- package/dist/elements/Tabs/index.js +62 -0
- package/dist/elements/Tabs/index.js.map +1 -0
- package/dist/elements/TimezonePicker/index.css +0 -15
- package/dist/elements/UnpublishButton/index.d.ts.map +1 -1
- package/dist/elements/UnpublishButton/index.js +5 -13
- package/dist/elements/UnpublishButton/index.js.map +1 -1
- package/dist/exports/client/index.d.ts +6 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +14 -14
- package/dist/exports/client/index.js.map +4 -4
- package/dist/fields/Tabs/Tab/index.d.ts +0 -1
- package/dist/fields/Tabs/Tab/index.d.ts.map +1 -1
- package/dist/fields/Tabs/Tab/index.js +12 -23
- package/dist/fields/Tabs/Tab/index.js.map +1 -1
- package/dist/fields/Tabs/index.d.ts.map +1 -1
- package/dist/fields/Tabs/index.js +37 -37
- package/dist/fields/Tabs/index.js.map +1 -1
- package/dist/fields/Upload/HasMany/index.css +4 -0
- package/dist/forms/RenderFields/RenderField.d.ts +1 -1
- package/dist/icons/Gear/index.d.ts.map +1 -1
- package/dist/icons/Gear/index.js +8 -1
- package/dist/icons/Gear/index.js.map +1 -1
- package/dist/icons/{Write → Key}/index.css +1 -1
- package/dist/icons/Key/index.d.ts +7 -0
- package/dist/icons/Key/index.d.ts.map +1 -0
- package/dist/icons/Key/index.js +24 -0
- package/dist/icons/Key/index.js.map +1 -0
- package/dist/icons/Schedule/index.d.ts.map +1 -1
- package/dist/icons/Schedule/index.js +38 -39
- package/dist/icons/Schedule/index.js.map +1 -1
- package/dist/icons/WarningTriangle/index.css +5 -0
- package/dist/icons/WarningTriangle/index.d.ts +6 -0
- package/dist/icons/WarningTriangle/index.d.ts.map +1 -0
- package/dist/icons/WarningTriangle/index.js +21 -0
- package/dist/icons/WarningTriangle/index.js.map +1 -0
- package/dist/icons/Write/index.d.ts +0 -1
- package/dist/icons/Write/index.d.ts.map +1 -1
- package/dist/icons/Write/index.js +1 -2
- package/dist/icons/Write/index.js.map +1 -1
- package/dist/providers/DocumentInfo/index.d.ts.map +1 -1
- package/dist/providers/DocumentInfo/index.js +4 -0
- package/dist/providers/DocumentInfo/index.js.map +1 -1
- package/dist/providers/DocumentInfo/types.d.ts +4 -0
- package/dist/providers/DocumentInfo/types.d.ts.map +1 -1
- package/dist/providers/DocumentInfo/types.js.map +1 -1
- package/dist/providers/Root/index.d.ts.map +1 -1
- package/dist/providers/Root/index.js +27 -24
- package/dist/providers/Root/index.js.map +1 -1
- package/dist/providers/TableColumns/RenderDefaultCell/index.css +1 -0
- package/dist/styles.css +1 -1
- package/dist/utilities/getHasScheduledPublish.d.ts +12 -0
- package/dist/utilities/getHasScheduledPublish.d.ts.map +1 -0
- package/dist/utilities/getHasScheduledPublish.js +38 -0
- package/dist/utilities/getHasScheduledPublish.js.map +1 -0
- package/dist/utilities/getVersions.d.ts.map +1 -1
- package/dist/utilities/getVersions.js +1 -21
- package/dist/utilities/getVersions.js.map +1 -1
- package/dist/views/Document/index.d.ts.map +1 -1
- package/dist/views/Document/index.js +10 -1
- package/dist/views/Document/index.js.map +1 -1
- package/dist/views/Edit/Auth/APIKey.d.ts.map +1 -1
- package/dist/views/Edit/Auth/APIKey.js +10 -32
- package/dist/views/Edit/Auth/APIKey.js.map +1 -1
- package/dist/views/Edit/Auth/index.css +0 -67
- package/dist/views/List/handleGroupBy.d.ts.map +1 -1
- package/dist/views/List/handleGroupBy.js +9 -0
- package/dist/views/List/handleGroupBy.js.map +1 -1
- package/dist/views/List/index.client.d.ts.map +1 -1
- package/dist/views/List/index.client.js +3 -2
- package/dist/views/List/index.client.js.map +1 -1
- package/dist/views/List/index.css +1 -1
- package/dist/views/List/index.d.ts.map +1 -1
- package/dist/views/List/index.js +2 -1
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/List/renderListViewSlots.d.ts.map +1 -1
- package/dist/views/List/renderListViewSlots.js +8 -0
- package/dist/views/List/renderListViewSlots.js.map +1 -1
- package/dist/views/Version/SelectComparison/VersionDrawer/index.css +5 -0
- package/dist/views/Version/SelectComparison/VersionDrawer/index.d.ts +1 -1
- package/dist/views/Version/SelectComparison/VersionDrawer/index.d.ts.map +1 -1
- package/dist/views/Version/SelectComparison/VersionDrawer/index.js +1 -2
- package/dist/views/Version/SelectComparison/VersionDrawer/index.js.map +1 -1
- package/dist/views/Version/SelectComparison/index.css +5 -0
- package/dist/views/Version/SelectComparison/index.d.ts +1 -1
- package/dist/views/Version/SelectComparison/index.d.ts.map +1 -1
- package/dist/views/Version/SelectComparison/index.js +1 -1
- package/dist/views/Version/SelectComparison/index.js.map +1 -1
- package/dist/views/Versions/index.css +2 -2
- package/dist/views/Versions/index.d.ts +1 -1
- package/dist/views/Versions/index.d.ts.map +1 -1
- package/dist/views/Versions/index.js +3 -26
- package/dist/views/Versions/index.js.map +1 -1
- package/package.json +5 -5
- package/dist/elements/BulkUpload/AddingFilesView/index.scss +0 -25
- package/dist/elements/BulkUpload/EditForm/index.scss +0 -11
- package/dist/elements/BulkUpload/EditMany/index.scss +0 -171
- package/dist/elements/FileDetails/DraggableFileDetails/index.scss +0 -35
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.scss +0 -78
- package/dist/elements/Hierarchy/Field/index.scss +0 -41
- package/dist/elements/Hierarchy/MoveMany/index.scss +0 -7
- package/dist/elements/Hierarchy/Tree/LoadMore/index.scss +0 -26
- package/dist/elements/Hierarchy/Tree/TreeConnector.d.ts +0 -7
- package/dist/elements/Hierarchy/Tree/TreeConnector.d.ts.map +0 -1
- package/dist/elements/Hierarchy/Tree/TreeConnector.js +0 -23
- package/dist/elements/Hierarchy/Tree/TreeConnector.js.map +0 -1
- package/dist/elements/LoadMoreRow/index.scss +0 -45
- package/dist/fields/Tabs/Tab/index.css +0 -82
- package/dist/views/Version/SelectComparison/VersionDrawer/index.scss +0 -18
- package/dist/views/Version/SelectComparison/index.scss +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","React","Button","Thumbnail","baseClass","DraggableSortableItem","AlignJustifiedIcon","EditIcon","useDocumentDrawer","DraggableFileDetails","props","$","collectionSlug","doc","hideRemoveFile","imageCacheTag","isSortable","removeItem","rowIndex","uploadConfig","id","filename","thumbnailURL","url","t0","DocumentDrawer","DocumentDrawerToggler","t1","draggableSortableItemProps","_jsxs","className","filter","Boolean","join","ref","setNodeRef","style","transform","transition","zIndex","isDragging","undefined","children","_jsx","attributes","listeners","fileSrc","buttonStyle","icon","onClick","round","t2"],"sources":["../../../../src/elements/FileDetails/DraggableFileDetails/index.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nimport { Button } from '../../Button/index.js'\nimport { Thumbnail } from '../../Thumbnail/index.js'\nimport './index.
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","React","Button","Thumbnail","baseClass","DraggableSortableItem","AlignJustifiedIcon","EditIcon","useDocumentDrawer","DraggableFileDetails","props","$","collectionSlug","doc","hideRemoveFile","imageCacheTag","isSortable","removeItem","rowIndex","uploadConfig","id","filename","thumbnailURL","url","t0","DocumentDrawer","DocumentDrawerToggler","t1","draggableSortableItemProps","_jsxs","className","filter","Boolean","join","ref","setNodeRef","style","transform","transition","zIndex","isDragging","undefined","children","_jsx","attributes","listeners","fileSrc","buttonStyle","icon","onClick","round","t2"],"sources":["../../../../src/elements/FileDetails/DraggableFileDetails/index.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nimport { Button } from '../../Button/index.js'\nimport { Thumbnail } from '../../Thumbnail/index.js'\nimport './index.css'\n\nconst baseClass = 'file-details-draggable'\n\nimport type { Data, FileSizes, SanitizedCollectionConfig } from 'payload'\n\nimport { DraggableSortableItem } from '../../../elements/DraggableSortable/DraggableSortableItem/index.js'\nimport { AlignJustifiedIcon } from '../../../icons/AlignJustified/index.js'\nimport { EditIcon } from '../../../icons/Edit/index.js'\nimport { useDocumentDrawer } from '../../DocumentDrawer/index.js'\n\nexport type DraggableFileDetailsProps = {\n collectionSlug: string\n customUploadActions?: React.ReactNode[]\n doc: {\n sizes?: FileSizes\n } & Data\n enableAdjustments?: boolean\n hasImageSizes?: boolean\n hasMany: boolean\n hideRemoveFile?: boolean\n imageCacheTag?: string\n isSortable?: boolean\n removeItem?: (index: number) => void\n rowIndex: number\n uploadConfig: SanitizedCollectionConfig['upload']\n}\n\nexport const DraggableFileDetails: React.FC<DraggableFileDetailsProps> = (props) => {\n const {\n collectionSlug,\n doc,\n hideRemoveFile,\n imageCacheTag,\n isSortable,\n removeItem,\n rowIndex,\n uploadConfig,\n } = props\n\n const { id, filename, thumbnailURL, url } = doc\n\n const [DocumentDrawer, DocumentDrawerToggler] = useDocumentDrawer({\n id,\n collectionSlug,\n })\n\n return (\n <DraggableSortableItem id={id} key={id}>\n {(draggableSortableItemProps) => (\n <div\n className={[\n baseClass,\n draggableSortableItemProps && isSortable && `${baseClass}--has-drag-handle`,\n ]\n .filter(Boolean)\n .join(' ')}\n key={id}\n ref={draggableSortableItemProps.setNodeRef}\n style={{\n transform: draggableSortableItemProps.transform,\n transition: draggableSortableItemProps.transition,\n zIndex: draggableSortableItemProps.isDragging ? 1 : undefined,\n }}\n >\n <div className={`${baseClass}--drag-wrapper`}>\n {isSortable && draggableSortableItemProps && (\n <div\n className={`${baseClass}__drag`}\n {...draggableSortableItemProps.attributes}\n {...draggableSortableItemProps.listeners}\n >\n <AlignJustifiedIcon />\n </div>\n )}\n <Thumbnail\n className={`${baseClass}__thumbnail`}\n collectionSlug={collectionSlug}\n doc={doc}\n fileSrc={thumbnailURL || url}\n imageCacheTag={imageCacheTag}\n uploadConfig={uploadConfig}\n />\n </div>\n <div className={`${baseClass}__main-detail`}>{filename}</div>\n\n <div className={`${baseClass}__actions`}>\n <DocumentDrawer />\n <DocumentDrawerToggler>\n <EditIcon />\n </DocumentDrawerToggler>\n {!hideRemoveFile && removeItem && (\n <Button\n buttonStyle=\"ghost\"\n className={`${baseClass}__remove`}\n icon=\"x\"\n onClick={() => removeItem(rowIndex)}\n round\n />\n )}\n </div>\n </div>\n )}\n </DraggableSortableItem>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,OAAOC,KAAA,MAAW;AAElB,SAASC,MAAM,QAAQ;AACvB,SAASC,SAAS,QAAQ;AAC1B,OAAO;AAEP,MAAMC,SAAA,GAAY;AAIlB,SAASC,qBAAqB,QAAQ;AACtC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,QAAQ,QAAQ;AACzB,SAASC,iBAAiB,QAAQ;AAmBlC,OAAO,MAAMC,oBAAA,GAA4DC,KAAA;EAAA,MAAAC,CAAA,GAAAX,EAAA;EACvE;IAAAY,cAAA;IAAAC,GAAA;IAAAC,cAAA;IAAAC,aAAA;IAAAC,UAAA;IAAAC,UAAA;IAAAC,QAAA;IAAAC;EAAA,IASIT,KAAA;EAEJ;IAAAU,EAAA;IAAAC,QAAA;IAAAC,YAAA;IAAAC;EAAA,IAA4CV,GAAA;EAAA,IAAAW,EAAA;EAAA,IAAAb,CAAA,QAAAC,cAAA,IAAAD,CAAA,QAAAS,EAAA;IAEsBI,EAAA;MAAAJ,EAAA;MAAAR;IAAA;IAGlED,CAAA,MAAAC,cAAA;IAAAD,CAAA,MAAAS,EAAA;IAAAT,CAAA,MA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AAsB,QAAA,EACGf;IAQQ,GATyBP,EAAA;IAAAT,CAAA,OAAAS,EAAA;IAAAT,CAAA,OAAAgB,EAAA;IAAAhB,CAAA,OAAAwC,EAAA;EAAA;IAAAA,EAAA,GAAAxC,CAAA;EAAA;EAAA,OAApCwC,EAAoC;AAAA,CAyDxC","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
@layer payload-default {
|
|
2
|
+
.selected-hierarchies__pills {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-wrap: wrap;
|
|
5
|
+
gap: var(--spacer-1);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.selected-hierarchies__pill .chip__label {
|
|
9
|
+
max-width: 200px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.selected-hierarchies__pill.chip--size-medium {
|
|
13
|
+
height: 1.25rem;
|
|
14
|
+
padding-inline-start: var(--spacer-1);
|
|
15
|
+
border-radius: var(--radius-chip);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.selected-hierarchies__pill .chip__remove {
|
|
19
|
+
color: var(--color-icon-secondary);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.selected-hierarchies__pill .chip__remove:hover {
|
|
23
|
+
color: var(--color-text);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.selected-hierarchies__empty {
|
|
27
|
+
color: var(--color-text-secondary);
|
|
28
|
+
font-style: italic;
|
|
29
|
+
padding: var(--spacer-1) 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.selected-hierarchies__loading {
|
|
33
|
+
color: var(--color-text-secondary);
|
|
34
|
+
padding: var(--spacer-1) 0;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectedHierarchies.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/Field/SelectedHierarchies.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA+C,MAAM,OAAO,CAAA;AAMnE,OAAO,
|
|
1
|
+
{"version":3,"file":"SelectedHierarchies.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/Field/SelectedHierarchies.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA+C,MAAM,OAAO,CAAA;AAMnE,OAAO,2BAA2B,CAAA;AASlC,MAAM,MAAM,wBAAwB,GAAG;IACrC,aAAa,EAAE,MAAM,CAAA;IACrB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IACnD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;CACjC,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA8HlE,CAAA"}
|
|
@@ -8,7 +8,7 @@ import { useConfig } from '../../../providers/Config/index.js';
|
|
|
8
8
|
import { useTranslation } from '../../../providers/Translation/index.js';
|
|
9
9
|
import { Chip } from '../../Chip/index.js';
|
|
10
10
|
import { Spinner } from '../../Spinner/index.js';
|
|
11
|
-
import './SelectedHierarchies.
|
|
11
|
+
import './SelectedHierarchies.css';
|
|
12
12
|
const baseClass = 'selected-hierarchies';
|
|
13
13
|
export const SelectedHierarchies = ({
|
|
14
14
|
hierarchySlug,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectedHierarchies.js","names":["formatAdminURL","qs","React","useEffect","useMemo","useRef","useState","useConfig","useTranslation","Chip","Spinner","baseClass","SelectedHierarchies","hierarchySlug","Icon","onRemove","readOnly","selectedIds","config","getEntityConfig","i18n","items","setItems","isInitialLoad","setIsInitialLoad","prevSelectedIdsRef","routes","api","serverURL","collectionConfig","collectionSlug","selectedIdsKey","slice","sort","join","length","current","fetchItems","useAsTitle","admin","query","depth","limit","select","where","id","in","queryString","stringify","url","apiRoute","path","response","fetch","credentials","headers","language","ok","data","json","fetchedItems","docs","map","doc","docId","titleValue","title","String","orderedItems","find","item","filter","undefined","_jsx","className","size","SelectedPill","disabled","icon"],"sources":["../../../../src/elements/Hierarchy/Field/SelectedHierarchies.tsx"],"sourcesContent":["'use client'\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { useEffect, useMemo, useRef, useState } from 'react'\n\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Chip } from '../../Chip/index.js'\nimport { Spinner } from '../../Spinner/index.js'\nimport './SelectedHierarchies.
|
|
1
|
+
{"version":3,"file":"SelectedHierarchies.js","names":["formatAdminURL","qs","React","useEffect","useMemo","useRef","useState","useConfig","useTranslation","Chip","Spinner","baseClass","SelectedHierarchies","hierarchySlug","Icon","onRemove","readOnly","selectedIds","config","getEntityConfig","i18n","items","setItems","isInitialLoad","setIsInitialLoad","prevSelectedIdsRef","routes","api","serverURL","collectionConfig","collectionSlug","selectedIdsKey","slice","sort","join","length","current","fetchItems","useAsTitle","admin","query","depth","limit","select","where","id","in","queryString","stringify","url","apiRoute","path","response","fetch","credentials","headers","language","ok","data","json","fetchedItems","docs","map","doc","docId","titleValue","title","String","orderedItems","find","item","filter","undefined","_jsx","className","size","SelectedPill","disabled","icon"],"sources":["../../../../src/elements/Hierarchy/Field/SelectedHierarchies.tsx"],"sourcesContent":["'use client'\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { useEffect, useMemo, useRef, useState } from 'react'\n\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Chip } from '../../Chip/index.js'\nimport { Spinner } from '../../Spinner/index.js'\nimport './SelectedHierarchies.css'\n\nconst baseClass = 'selected-hierarchies'\n\ntype HierarchyItem = {\n id: number | string\n title: string\n}\n\nexport type SelectedHierarchiesProps = {\n hierarchySlug: string\n Icon?: React.ReactNode\n onRemove: ({ id }: { id: number | string }) => void\n readOnly?: boolean\n selectedIds: (number | string)[]\n}\n\nexport const SelectedHierarchies: React.FC<SelectedHierarchiesProps> = ({\n hierarchySlug,\n Icon,\n onRemove,\n readOnly = false,\n selectedIds,\n}) => {\n const { config, getEntityConfig } = useConfig()\n const { i18n } = useTranslation()\n const [items, setItems] = useState<HierarchyItem[]>([])\n const [isInitialLoad, setIsInitialLoad] = useState(true)\n\n const prevSelectedIdsRef = useRef<string>('')\n\n const {\n routes: { api },\n serverURL,\n } = config\n\n const collectionConfig = getEntityConfig({ collectionSlug: hierarchySlug })\n\n const selectedIdsKey = useMemo(() => selectedIds.slice().sort().join(','), [selectedIds])\n\n useEffect(() => {\n if (!selectedIds || selectedIds.length === 0) {\n setItems([])\n setIsInitialLoad(false)\n return\n }\n\n if (prevSelectedIdsRef.current === selectedIdsKey) {\n return\n }\n prevSelectedIdsRef.current = selectedIdsKey\n\n const fetchItems = async () => {\n const useAsTitle = collectionConfig?.admin?.useAsTitle || 'id'\n\n const query = {\n depth: 0,\n limit: selectedIds.length,\n select: {\n [useAsTitle]: true,\n },\n where: {\n id: {\n in: selectedIds,\n },\n },\n }\n\n const queryString = qs.stringify(query)\n\n try {\n const url = formatAdminURL({\n apiRoute: api,\n path: `/${hierarchySlug}?${queryString}`,\n serverURL,\n })\n\n const response = await fetch(url, {\n credentials: 'include',\n headers: {\n 'Accept-Language': i18n.language,\n },\n })\n\n if (response.ok) {\n const data = await response.json()\n const fetchedItems: HierarchyItem[] = data.docs.map((doc: Record<string, unknown>) => {\n const docId = doc.id as number | string\n const titleValue = doc[useAsTitle] ?? docId\n const title =\n typeof titleValue === 'string' || typeof titleValue === 'number'\n ? String(titleValue)\n : String(docId)\n return {\n id: docId,\n title,\n }\n })\n\n // Order by selectedIds to preserve selection order\n const orderedItems = selectedIds\n .map((id) => fetchedItems.find((item) => item.id === id))\n .filter((item): item is HierarchyItem => item !== undefined)\n\n setItems(orderedItems)\n }\n } catch {\n // Silently fail - items will remain empty\n } finally {\n setIsInitialLoad(false)\n }\n }\n\n void fetchItems()\n }, [selectedIds, selectedIdsKey, hierarchySlug, collectionConfig, serverURL, api, i18n.language])\n\n if (isInitialLoad) {\n return (\n <div className={`${baseClass}__loading`}>\n <Spinner size=\"sm\" />\n </div>\n )\n }\n\n if (items.length === 0) {\n return null\n }\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__pills`}>\n {items.map((item) => (\n <SelectedPill\n Icon={Icon}\n item={item}\n key={item.id}\n onRemove={onRemove}\n readOnly={readOnly}\n />\n ))}\n </div>\n </div>\n )\n}\n\ntype SelectedPillProps = {\n Icon?: React.ReactNode\n item: HierarchyItem\n onRemove: ({ id }: { id: number | string }) => void\n readOnly: boolean\n}\n\nconst SelectedPill: React.FC<SelectedPillProps> = ({ Icon, item, onRemove, readOnly }) => {\n return (\n <Chip\n className={`${baseClass}__pill`}\n disabled={readOnly}\n icon={Icon}\n onRemove={() => onRemove({ id: item.id })}\n size=\"medium\"\n >\n {item.title}\n </Chip>\n )\n}\n"],"mappings":"AAAA;;;AACA,SAASA,cAAc,QAAQ;AAC/B,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAE5D,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,IAAI,QAAQ;AACrB,SAASC,OAAO,QAAQ;AACxB,OAAO;AAEP,MAAMC,SAAA,GAAY;AAelB,OAAO,MAAMC,mBAAA,GAA0DA,CAAC;EACtEC,aAAa;EACbC,IAAI;EACJC,QAAQ;EACRC,QAAA,GAAW,KAAK;EAChBC;AAAW,CACZ;EACC,MAAM;IAAEC,MAAM;IAAEC;EAAe,CAAE,GAAGZ,SAAA;EACpC,MAAM;IAAEa;EAAI,CAAE,GAAGZ,cAAA;EACjB,MAAM,CAACa,KAAA,EAAO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;EACT;EAEA,oBACEsC,IAAA,CAAC;IAAIC,SAAA,EAAW/D,SAAA;cACd,aAAA8D,IAAA,CAAC;MAAIC,SAAA,EAAW,GAAG/D,SAAA,SAAkB;gBAClCU,KAAA,CAAMyC,GAAG,CAAEQ,MAAA,iBACVG,IAAA,CAACG,YAAA;QACC9D,IAAA,EAAMA,IAAA;QACNwD,IAAA,EAAMA,MAAA;QAENvD,QAAA,EAAUA,QAAA;QACVC,QAAA,EAAUA;SAFLsD,MAAA,CAAKzB,EAAE;;;AAQxB;AASA,MAAM+B,YAAA,GAA4CA,CAAC;EAAE9D,IAAI;EAAEwD,IAAI;EAAEvD,QAAQ;EAAEC;AAAQ,CAAE;EACnF,oBACEyD,IAAA,CAAChE,IAAA;IACCiE,SAAA,EAAW,GAAG/D,SAAA,QAAiB;IAC/BkE,QAAA,EAAU7D,QAAA;IACV8D,IAAA,EAAMhE,IAAA;IACNC,QAAA,EAAUA,CAAA,KAAMA,QAAA,CAAS;MAAE8B,EAAA,EAAIyB,IAAA,CAAKzB;IAAG;IACvC8B,IAAA,EAAK;cAEJL,IAAA,CAAKJ;;AAGZ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/Field/index.client.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAA;AAG3D,OAAO,KAA+B,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/Field/index.client.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAA;AAG3D,OAAO,KAA+B,MAAM,OAAO,CAAA;AAkBnD,OAAO,aAAa,CAAA;AAMpB,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CACvB,GAAG,4BAA4B,CAAA;AAEhC,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CA2LpE,CAAA"}
|
|
@@ -9,6 +9,7 @@ import { FieldLabel } from '../../../fields/FieldLabel/index.js';
|
|
|
9
9
|
import { mergeFieldStyles } from '../../../fields/mergeFieldStyles.js';
|
|
10
10
|
import { fieldBaseClass } from '../../../fields/shared/index.js';
|
|
11
11
|
import { useField } from '../../../forms/useField/index.js';
|
|
12
|
+
import { CirclePlusIcon } from '../../../icons/CirclePlus/index.js';
|
|
12
13
|
import { useConfig } from '../../../providers/Config/index.js';
|
|
13
14
|
import { useDocumentInfo } from '../../../providers/DocumentInfo/index.js';
|
|
14
15
|
import { useTranslation } from '../../../providers/Translation/index.js';
|
|
@@ -16,7 +17,7 @@ import { Button } from '../../Button/index.js';
|
|
|
16
17
|
import { RenderCustomComponent } from '../../RenderCustomComponent/index.js';
|
|
17
18
|
import { useHierarchyDrawer } from '../Drawer/useHierarchyDrawer.js';
|
|
18
19
|
import { SelectedHierarchies } from './SelectedHierarchies.js';
|
|
19
|
-
import './index.
|
|
20
|
+
import './index.css';
|
|
20
21
|
const baseClass = 'hierarchy-field';
|
|
21
22
|
export const HierarchyFieldClient = props => {
|
|
22
23
|
const {
|
|
@@ -160,7 +161,9 @@ export const HierarchyFieldClient = props => {
|
|
|
160
161
|
buttonStyle: "dashed",
|
|
161
162
|
className: `${baseClass}__manage-button`,
|
|
162
163
|
disabled: disabled,
|
|
163
|
-
icon:
|
|
164
|
+
icon: /*#__PURE__*/_jsx(CirclePlusIcon, {
|
|
165
|
+
size: 24
|
|
166
|
+
}),
|
|
164
167
|
iconPosition: "left",
|
|
165
168
|
margin: false,
|
|
166
169
|
onClick: handleOpenDrawer,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.js","names":["getTranslation","React","useCallback","useMemo","FieldDescription","FieldError","FieldLabel","mergeFieldStyles","fieldBaseClass","useField","useConfig","useDocumentInfo","useTranslation","Button","RenderCustomComponent","useHierarchyDrawer","SelectedHierarchies","baseClass","HierarchyFieldClient","props","field","admin","className","description","hasMany","label","localized","relationTo","relationToProp","required","Icon","path","pathFromProps","readOnly","validate","hierarchySlug","Array","isArray","getEntityConfig","collectionSlug","documentCollectionSlug","i18n","t","collectionConfig","memoizedValidate","value","validationOptions","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","setValue","showError","potentiallyStalePath","styles","selectedIds","initialSelections","filterByCollection","undefined","HierarchyDrawer","openDrawer","hierarchyCollectionSlug","handleDrawerSave","closeDrawer","selections","ids","from","keys","newValue","handleRemove","id","idToRemove","newIds","filter","length","handleOpenDrawer","hierarchyLabel","labels","plural","singular","_jsxs","Boolean","join","replace","style","_jsx","CustomComponent","Fallback","onRemove","buttonStyle","icon","iconPosition","margin","onClick","size","onSave"],"sources":["../../../../src/elements/Hierarchy/Field/index.client.tsx"],"sourcesContent":["'use client'\nimport type { RelationshipFieldClientProps } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback, useMemo } from 'react'\n\nimport type { SelectionWithPath } from '../Drawer/types.js'\n\nimport { FieldDescription } from '../../../fields/FieldDescription/index.js'\nimport { FieldError } from '../../../fields/FieldError/index.js'\nimport { FieldLabel } from '../../../fields/FieldLabel/index.js'\nimport { mergeFieldStyles } from '../../../fields/mergeFieldStyles.js'\nimport { fieldBaseClass } from '../../../fields/shared/index.js'\nimport { useField } from '../../../forms/useField/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../../providers/DocumentInfo/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { RenderCustomComponent } from '../../RenderCustomComponent/index.js'\nimport { useHierarchyDrawer } from '../Drawer/useHierarchyDrawer.js'\nimport { SelectedHierarchies } from './SelectedHierarchies.js'\nimport './index.scss'\n\nconst baseClass = 'hierarchy-field'\n\ntype Value = (number | string)[] | null | (number | string)\n\nexport type HierarchyFieldClientProps = {\n Icon?: React.ReactNode\n} & RelationshipFieldClientProps\n\nexport const HierarchyFieldClient: React.FC<HierarchyFieldClientProps> = (props) => {\n const {\n field,\n field: {\n admin: { className, description } = {},\n hasMany,\n label,\n localized,\n relationTo: relationToProp,\n required,\n },\n Icon,\n path: pathFromProps,\n readOnly,\n validate,\n } = props\n\n const hierarchySlug = Array.isArray(relationToProp) ? relationToProp[0] : relationToProp\n\n const { getEntityConfig } = useConfig()\n const { collectionSlug: documentCollectionSlug } = useDocumentInfo()\n const { i18n, t } = useTranslation()\n\n const collectionConfig = getEntityConfig({ collectionSlug: hierarchySlug })\n\n const memoizedValidate = useCallback(\n (value: Value, validationOptions: Parameters<typeof validate>[1]) => {\n if (typeof validate === 'function') {\n return validate(value, { ...validationOptions, required })\n }\n },\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled,\n path,\n setValue,\n showError,\n value,\n } = useField<Value>({\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n // Normalize value to array of IDs for display\n const selectedIds = useMemo((): (number | string)[] => {\n if (!value) {\n return []\n }\n\n if (Array.isArray(value)) {\n return value\n }\n\n return [value]\n }, [value])\n\n // Initialize selections for the drawer - use current value so drawer expands to current selection\n const initialSelections = useMemo(() => {\n if (!value) {\n return []\n }\n\n if (Array.isArray(value)) {\n return value\n }\n\n return [value] as (number | string)[]\n }, [value])\n\n // Memoize to prevent new array references on every render\n const filterByCollection = useMemo(\n () => (documentCollectionSlug ? [documentCollectionSlug] : undefined),\n [documentCollectionSlug],\n )\n\n const [HierarchyDrawer, , { openDrawer }] = useHierarchyDrawer({\n filterByCollection,\n hierarchyCollectionSlug: hierarchySlug,\n Icon,\n })\n\n const handleDrawerSave = useCallback(\n ({\n closeDrawer,\n selections,\n }: {\n closeDrawer: () => void\n selections: Map<number | string, SelectionWithPath>\n }) => {\n const ids = Array.from(selections.keys())\n const newValue = hasMany ? ids : (ids[0] ?? null)\n setValue(newValue)\n closeDrawer()\n },\n [hasMany, setValue],\n )\n\n const handleRemove = useCallback(\n ({ id: idToRemove }: { id: number | string }) => {\n if (hasMany) {\n const newIds = selectedIds.filter((id) => id !== idToRemove)\n setValue(newIds.length > 0 ? newIds : null)\n } else {\n setValue(null)\n }\n },\n [hasMany, selectedIds, setValue],\n )\n\n const handleOpenDrawer = useCallback(() => {\n openDrawer()\n }, [openDrawer])\n\n const hierarchyLabel =\n getTranslation(\n hasMany ? collectionConfig?.labels?.plural : collectionConfig?.labels?.singular,\n i18n,\n ) || hierarchySlug\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && 'error',\n readOnly && `${baseClass}--read-only`,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${path?.replace(/\\./g, '__')}`}\n style={styles}\n >\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n }\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {BeforeInput}\n <div className={`${baseClass}__content`}>\n {selectedIds.length > 0 && (\n <SelectedHierarchies\n hierarchySlug={hierarchySlug}\n onRemove={handleRemove}\n readOnly={readOnly || disabled}\n selectedIds={selectedIds}\n />\n )}\n {!readOnly && (hasMany || selectedIds.length === 0) && (\n <Button\n buttonStyle=\"dashed\"\n className={`${baseClass}__manage-button`}\n disabled={disabled}\n icon=\"plus\"\n iconPosition=\"left\"\n margin={false}\n onClick={handleOpenDrawer}\n size=\"medium\"\n >\n {t('general:selectLabel', { label: hierarchyLabel })}\n </Button>\n )}\n </div>\n {AfterInput}\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n <HierarchyDrawer\n hasMany={hasMany}\n initialSelections={initialSelections}\n onSave={handleDr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,IAAA,EAAMA;;;qBAGhEyD,IAAA,CAAC1B,eAAA;MACCtC,OAAA,EAASA,OAAA;MACTmC,iBAAA,EAAmBA,iBAAA;MACnBuC,MAAA,EAAQjC;;;AAIhB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.client.js","names":["getTranslation","React","useCallback","useMemo","FieldDescription","FieldError","FieldLabel","mergeFieldStyles","fieldBaseClass","useField","CirclePlusIcon","useConfig","useDocumentInfo","useTranslation","Button","RenderCustomComponent","useHierarchyDrawer","SelectedHierarchies","baseClass","HierarchyFieldClient","props","field","admin","className","description","hasMany","label","localized","relationTo","relationToProp","required","Icon","path","pathFromProps","readOnly","validate","hierarchySlug","Array","isArray","getEntityConfig","collectionSlug","documentCollectionSlug","i18n","t","collectionConfig","memoizedValidate","value","validationOptions","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","setValue","showError","potentiallyStalePath","styles","selectedIds","initialSelections","filterByCollection","undefined","HierarchyDrawer","openDrawer","hierarchyCollectionSlug","handleDrawerSave","closeDrawer","selections","ids","from","keys","newValue","handleRemove","id","idToRemove","newIds","filter","length","handleOpenDrawer","hierarchyLabel","labels","plural","singular","_jsxs","Boolean","join","replace","style","_jsx","CustomComponent","Fallback","onRemove","buttonStyle","icon","size","iconPosition","margin","onClick","onSave"],"sources":["../../../../src/elements/Hierarchy/Field/index.client.tsx"],"sourcesContent":["'use client'\nimport type { RelationshipFieldClientProps } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback, useMemo } from 'react'\n\nimport type { SelectionWithPath } from '../Drawer/types.js'\n\nimport { FieldDescription } from '../../../fields/FieldDescription/index.js'\nimport { FieldError } from '../../../fields/FieldError/index.js'\nimport { FieldLabel } from '../../../fields/FieldLabel/index.js'\nimport { mergeFieldStyles } from '../../../fields/mergeFieldStyles.js'\nimport { fieldBaseClass } from '../../../fields/shared/index.js'\nimport { useField } from '../../../forms/useField/index.js'\nimport { CirclePlusIcon } from '../../../icons/CirclePlus/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../../providers/DocumentInfo/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { RenderCustomComponent } from '../../RenderCustomComponent/index.js'\nimport { useHierarchyDrawer } from '../Drawer/useHierarchyDrawer.js'\nimport { SelectedHierarchies } from './SelectedHierarchies.js'\nimport './index.css'\n\nconst baseClass = 'hierarchy-field'\n\ntype Value = (number | string)[] | null | (number | string)\n\nexport type HierarchyFieldClientProps = {\n Icon?: React.ReactNode\n} & RelationshipFieldClientProps\n\nexport const HierarchyFieldClient: React.FC<HierarchyFieldClientProps> = (props) => {\n const {\n field,\n field: {\n admin: { className, description } = {},\n hasMany,\n label,\n localized,\n relationTo: relationToProp,\n required,\n },\n Icon,\n path: pathFromProps,\n readOnly,\n validate,\n } = props\n\n const hierarchySlug = Array.isArray(relationToProp) ? relationToProp[0] : relationToProp\n\n const { getEntityConfig } = useConfig()\n const { collectionSlug: documentCollectionSlug } = useDocumentInfo()\n const { i18n, t } = useTranslation()\n\n const collectionConfig = getEntityConfig({ collectionSlug: hierarchySlug })\n\n const memoizedValidate = useCallback(\n (value: Value, validationOptions: Parameters<typeof validate>[1]) => {\n if (typeof validate === 'function') {\n return validate(value, { ...validationOptions, required })\n }\n },\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled,\n path,\n setValue,\n showError,\n value,\n } = useField<Value>({\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n // Normalize value to array of IDs for display\n const selectedIds = useMemo((): (number | string)[] => {\n if (!value) {\n return []\n }\n\n if (Array.isArray(value)) {\n return value\n }\n\n return [value]\n }, [value])\n\n // Initialize selections for the drawer - use current value so drawer expands to current selection\n const initialSelections = useMemo(() => {\n if (!value) {\n return []\n }\n\n if (Array.isArray(value)) {\n return value\n }\n\n return [value] as (number | string)[]\n }, [value])\n\n // Memoize to prevent new array references on every render\n const filterByCollection = useMemo(\n () => (documentCollectionSlug ? [documentCollectionSlug] : undefined),\n [documentCollectionSlug],\n )\n\n const [HierarchyDrawer, , { openDrawer }] = useHierarchyDrawer({\n filterByCollection,\n hierarchyCollectionSlug: hierarchySlug,\n Icon,\n })\n\n const handleDrawerSave = useCallback(\n ({\n closeDrawer,\n selections,\n }: {\n closeDrawer: () => void\n selections: Map<number | string, SelectionWithPath>\n }) => {\n const ids = Array.from(selections.keys())\n const newValue = hasMany ? ids : (ids[0] ?? null)\n setValue(newValue)\n closeDrawer()\n },\n [hasMany, setValue],\n )\n\n const handleRemove = useCallback(\n ({ id: idToRemove }: { id: number | string }) => {\n if (hasMany) {\n const newIds = selectedIds.filter((id) => id !== idToRemove)\n setValue(newIds.length > 0 ? newIds : null)\n } else {\n setValue(null)\n }\n },\n [hasMany, selectedIds, setValue],\n )\n\n const handleOpenDrawer = useCallback(() => {\n openDrawer()\n }, [openDrawer])\n\n const hierarchyLabel =\n getTranslation(\n hasMany ? collectionConfig?.labels?.plural : collectionConfig?.labels?.singular,\n i18n,\n ) || hierarchySlug\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && 'error',\n readOnly && `${baseClass}--read-only`,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${path?.replace(/\\./g, '__')}`}\n style={styles}\n >\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n }\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {BeforeInput}\n <div className={`${baseClass}__content`}>\n {selectedIds.length > 0 && (\n <SelectedHierarchies\n hierarchySlug={hierarchySlug}\n onRemove={handleRemove}\n readOnly={readOnly || disabled}\n selectedIds={selectedIds}\n />\n )}\n {!readOnly && (hasMany || selectedIds.length === 0) && (\n <Button\n buttonStyle=\"dashed\"\n className={`${baseClass}__manage-button`}\n disabled={disabled}\n icon={<CirclePlusIcon size={24} />}\n iconPosition=\"left\"\n margin={false}\n onClick={handleOpenDrawer}\n size=\"medium\"\n >\n {t('general:selectLabel', { label: hierarchyLabel })}\n </Button>\n )}\n </div>\n {AfterInput}\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n <HierarchyDrawer\n hasMany={hasMany}\n initialSelections={initialSelections}\n onSave={handleDrawerSave}\n />\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,WAAW,EAAEC,OAAO,QAAQ;AAI5C,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,UAAU,QAAQ;AAC3B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAC/B,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,SAASC,qBAAqB,QAAQ;AACtC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,mBAAmB,QAAQ;AACpC,OAAO;AAEP,MAAMC,SAAA,GAAY;AAQlB,OAAO,MAAMC,oBAAA,GAA6DC,KAAA;EACxE,MAAM;IACJC,KAAK;IACLA,KAAA,EAAO;MACLC,KAAA,EAAO;QAAEC,SAAS;QAAEC;MAAW,CAAE,GAAG,CAAC,CAAC;MACtCC,OAAO;MACPC,KAAK;MACLC,SAAS;MACTC,UAAA,EAAYC,cAAc;MAC1BC;IAAQ,CACT;IACDC,IAAI;IACJC,IAAA,EAAMC,aAAa;IACnBC,QAAQ;IACRC;EAAQ,CACT,GAAGf,KAAA;EAEJ,MAAMgB,aAAA,GAAgBC,KAAA,CAAMC,OAAO,CAACT,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A0B;UACxCoC,QAAA,EAAUA,QAAA;UACVwC,IAAA,eAAML,IAAA,CAAC/E,cAAA;YAAeqF,IAAA,EAAM;;UAC5BC,YAAA,EAAa;UACbC,MAAA,EAAQ;UACRC,OAAA,EAASnB,gBAAA;UACTgB,IAAA,EAAK;oBAEJpD,CAAA,CAAE,uBAAuB;YAAEjB,KAAA,EAAOsD;UAAe;;UAIvD/B,UAAA,E,aACDwC,IAAA,CAAC1E,qBAAA;QACC2E,eAAA,EAAiBvC,WAAA;QACjBwC,QAAA,eAAUF,IAAA,CAACrF,gBAAA;UAAiBoB,WAAA,EAAaA,WAAA;UAAaQ,IAAA,EAAMA;;;qBAGhEyD,IAAA,CAAC1B,eAAA;MACCtC,OAAA,EAASA,OAAA;MACTmC,iBAAA,EAAmBA,iBAAA;MACnBuC,MAAA,EAAQjC;;;AAIhB","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
@layer payload-default {
|
|
2
|
+
.hierarchy-field .field-type__wrap {
|
|
3
|
+
gap: var(--spacer-2);
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
display: flex;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.hierarchy-field .field-label {
|
|
9
|
+
display: flex;
|
|
10
|
+
font-family: var(--text-body-large-font-family);
|
|
11
|
+
font-size: var(--text-body-large-font-size);
|
|
12
|
+
font-weight: var(--text-body-large-font-weight);
|
|
13
|
+
line-height: var(--text-body-large-line-height);
|
|
14
|
+
letter-spacing: var(--text-body-large-letter-spacing);
|
|
15
|
+
margin: unset;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.hierarchy-field__label {
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
gap: var(--spacer-1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.hierarchy-field__content {
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
gap: var(--spacer-2-5);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.hierarchy-field__manage-button {
|
|
31
|
+
align-self: flex-start;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.hierarchy-field--read-only .hierarchy-field__content {
|
|
35
|
+
opacity: 0.75;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/MoveMany/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAyC,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/MoveMany/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAyC,MAAM,OAAO,CAAA;AAe7D,eAAO,MAAM,SAAS,cAAc,CAAA;AAEpC,KAAK,aAAa,GAAG;IACnB,qEAAqE;IACrE,eAAe,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAA;IACxC,sDAAsD;IACtD,aAAa,EAAE,MAAM,CAAA;IACrB,8CAA8C;IAC9C,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,+FAA+F;IAC/F,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,4CAA4C;IAC5C,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;KAAE,CAAC,CAAA;CACzD,CAAA;AAeD,wBAAgB,QAAQ,CAAC,EACvB,eAAe,EACf,aAAa,EACb,IAAI,EACJ,WAAW,EACX,SAAS,EACT,UAAU,GACX,EAAE,aAAa,qBA4Qf"}
|
|
@@ -16,7 +16,6 @@ import { ConfirmationModal } from '../../ConfirmationModal/index.js';
|
|
|
16
16
|
import { ListSelectionButton } from '../../ListSelection/index.js';
|
|
17
17
|
import { Translation } from '../../Translation/index.js';
|
|
18
18
|
import { useHierarchyDrawer } from '../Drawer/useHierarchyDrawer.js';
|
|
19
|
-
import './index.scss';
|
|
20
19
|
export const baseClass = 'move-many';
|
|
21
20
|
/**
|
|
22
21
|
* Gets the parent field name from the hierarchy config.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useModal","getTranslation","formatAdminURL","qs","React","useCallback","useMemo","useState","toast","useConfig","useDocumentSelection","useLocale","useTranslation","requests","ConfirmationModal","ListSelectionButton","Translation","useHierarchyDrawer","baseClass","getParentFieldName","hierarchyConfig","config","hierarchy","undefined","parentFieldName","MoveMany","currentParentID","hierarchySlug","Icon","modalPrefix","onSuccess","selections","i18n","t","code","locale","openModal","collections","routes","api","getSelectionsWithMetadata","destination","setDestination","confirmMoveDrawerSlug","requiredCollections","selectionsWithMeta","required","Set","collectionSlug","items","Object","entries","metadata","allowedCollections","slug","add","size","Array","from","disabledIds","parentIds","ids","length","HierarchyDrawer","closeDrawer","openDrawer","filterByCollection","hierarchyCollectionSlug","count","label","totalCount","labels","find","c","collectionLabel","plural","singular","push","join","hierarchyCollectionConfig","canMove","handleDrawerSave","selectionsMap","firstSelection","values","next","value","destinationId","id","destinationTitle","path","title","String","handleMoveToRoot","handleConfirmMove","totalMoved","hasErrors","queryString","stringify","where","in","addQueryPrefix","url","apiRoute","response","patch","body","JSON","headers","language","credentials","json","status","errors","error","message","description","map","movedCount","docs","successKey","success","_err","_jsxs","Fragment","_jsx","className","onClick","hasMany","initialSelections","onMoveToRoot","onSave","showMoveToRoot","elements","1","children","i18nKey","variables","confirmingLabel","heading","modalSlug","onConfirm"],"sources":["../../../../src/elements/Hierarchy/MoveMany/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientCollectionConfig } from 'payload'\n\nimport { useModal } from '@faceless-ui/modal'\nimport { getTranslation } from '@payloadcms/translations'\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { useCallback, useMemo, useState } from 'react'\nimport { toast } from 'sonner'\n\nimport type { SelectionWithPath } from '../Drawer/types.js'\n\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useDocumentSelection } from '../../../providers/DocumentSelection/index.js'\nimport { useLocale } from '../../../providers/Locale/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { requests } from '../../../utilities/api.js'\nimport { ConfirmationModal } from '../../ConfirmationModal/index.js'\nimport { ListSelectionButton } from '../../ListSelection/index.js'\nimport { Translation } from '../../Translation/index.js'\nimport { useHierarchyDrawer } from '../Drawer/useHierarchyDrawer.js'\nimport './index.scss'\n\nexport const baseClass = 'move-many'\n\ntype MoveManyProps = {\n /** Current parent ID - drawer will open expanded to this location */\n currentParentID?: null | number | string\n /** The hierarchy collection slug (e.g., 'folders') */\n hierarchySlug: string\n /** Icon to display in the hierarchy drawer */\n Icon?: React.ReactNode\n /** When multiple MoveMany components are rendered on the page, this will differentiate them */\n modalPrefix?: string\n /** Callback after successful move */\n onSuccess?: () => void\n /** Selections grouped by collection slug */\n selections: Record<string, { ids: (number | string)[] }>\n}\n\n/**\n * Gets the parent field name from the hierarchy config.\n */\nfunction getParentFieldName(\n hierarchyConfig: ClientCollectionConfig | undefined,\n): string | undefined {\n const config =\n hierarchyConfig?.hierarchy && typeof hierarchyConfig.hierarchy === 'object'\n ? hierarchyConfig.hierarchy\n : undefined\n return config?.parentFieldName\n}\n\nexport function MoveMany({\n currentParentID,\n hierarchySlug,\n Icon,\n modalPrefix,\n onSuccess,\n selections,\n}: MoveManyProps) {\n const { i18n, t } = useTranslation()\n const { code: locale } = useLocale()\n const { openModal } = useModal()\n const {\n config: {\n collections,\n routes: { api },\n },\n } = useConfig()\n\n const { getSelectionsWithMetadata } = useDocumentSelection()\n\n const [destination, setDestination] = useState<{\n id: null | number | string\n title: string\n } | null>(null)\n\n const confirmMoveDrawerSlug = `${modalPrefix ? `${modalPrefix}-` : ''}confirm-move-many`\n\n // Compute required collections from selection metadata\n // For related items: add their collection slug\n // For folders: add their allowedCollections values\n const requiredCollections = useMemo(() => {\n const selectionsWithMeta = getSelectionsWithMetadata()\n const required = new Set<string>()\n\n for (const [collectionSlug, { selections: items }] of Object.entries(selectionsWithMeta)) {\n if (collectionSlug === hierarchySlug) {\n // For folders, add their allowedCollections to required set\n for (const { metadata } of items) {\n if (metadata.allowedCollections) {\n for (const slug of metadata.allowedCollections) {\n required.add(slug)\n }\n }\n }\n } else {\n // For related items, add their collection slug\n required.add(collectionSlug)\n }\n }\n\n return required.size > 0 ? Array.from(required) : undefined\n }, [getSelectionsWithMetadata, hierarchySlug])\n\n // Folders being moved cannot be selected as destination (can't move into themselves)\n const disabledIds = useMemo(() => {\n const parentIds = selections[hierarchySlug]?.ids\n return parentIds?.length ? new Set(parentIds) : undefined\n }, [selections, hierarchySlug])\n\n const [HierarchyDrawer, , { closeDrawer, openDrawer }] = useHierarchyDrawer({\n disabledIds,\n filterByCollection: requiredCollections,\n hierarchyCollectionSlug: hierarchySlug,\n Icon,\n })\n\n // Calculate total count and label\n const { count, label } = useMemo(() => {\n let totalCount = 0\n const labels: string[] = []\n\n for (const [collectionSlug, { ids }] of Object.entries(selections)) {\n const config = collections.find((c) => c.slug === collectionSlug)\n\n if (config && ids.length > 0) {\n totalCount += ids.length\n const collectionLabel = getTranslation(\n ids.length > 1 ? config.labels.plural : config.labels.singular,\n i18n,\n )\n labels.push(collectionLabel)\n }\n }\n\n return {\n count: totalCount,\n label: labels.join(', '),\n }\n }, [selections, collections, i18n])\n\n const hierarchyCollectionConfig = collections.find((c) => c.slug === hierarchySlug)\n const parentFieldName = getParentFieldName(hierarchyCollectionConfig)\n\n // Check if hierarchy has a valid parentFieldName\n const canMove = parentFieldName !== undefined\n\n const handleDrawerSave = useCallback(\n ({ selections: selectionsMap }: { selections: Map<number | string, SelectionWithPath> }) => {\n if (selectionsMap.size === 0) {\n return\n }\n\n const firstSelection = selectionsMap.values().next().value\n const destinationId = firstSelection?.id\n const destinationTitle =\n firstSelection?.path?.[firstSelection.path.length - 1]?.title || String(destinationId)\n\n setDestination({ id: destinationId, title: destinationTitle })\n openModal(confirmMoveDrawerSlug)\n },\n [openModal, confirmMoveDrawerSlug],\n )\n\n const handleMoveToRoot = useCallback(() => {\n setDestination({ id: null, title: t('hierarchy:noParent') })\n openModal(confirmMoveDrawerSlug)\n }, [openModal, confirmMoveDrawerSlug, t])\n\n const handleConfirmMove = useCallback(async () => {\n if (destination === null) {\n return\n }\n\n let totalMoved = 0\n let hasErrors = false\n\n try {\n for (const [collectionSlug, { ids }] of Object.entries(selections)) {\n if (ids.length === 0) {\n continue\n }\n\n const queryString = qs.stringify(\n {\n locale,\n where: { id: { in: ids } },\n },\n { addQueryPrefix: true },\n )\n\n const url = formatAdminURL({\n apiRoute: api,\n path: `/${collectionSlug}${queryString}`,\n })\n\n const response = await requests.patch(url, {\n body: JSON.stringify({ [parentFieldName]: destination.id }),\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/json',\n credentials: 'include',\n },\n })\n\n const json = await response.json()\n\n if (response.status >= 400) {\n hasErrors = true\n\n if (json?.errors?.length > 0) {\n toast.error(json.message || t('error:unknown'), {\n description: json.errors\n .map((error: { message: string }) => error.message)\n .join('\\n'),\n })\n } else {\n toast.error(json?.message || t('error:unknown'))\n }\n\n continue\n }\n\n const movedCount = json?.docs?.length || 0\n totalMoved += movedCount\n\n if (json?.errors?.length > 0) {\n hasErrors = true\n toast.error(json.message, {\n description: json.errors.map((error: { message: string }) => error.message).join('\\n'),\n })\n }\n }\n\n if (totalMoved > 0) {\n const successKey =\n destination.id === null ? 'hierarchy:itemsMovedToRoot' : 'hierarchy:itemsMovedTo'\n\n toast.success(\n t(successKey, {\n destination: destination.title,\n title: label,\n }),\n )\n }\n\n if (!hasErrors || totalMoved > 0) {\n closeDrawer()\n onSuccess?.()\n }\n } catch (_err) {\n toast.error(t('error:unknown'))\n } finally {\n setDestination(null)\n }\n }, [\n closeDrawer,\n destination,\n selections,\n parentFieldName,\n locale,\n api,\n i18n,\n t,\n label,\n onSuccess,\n ])\n\n if (count === 0 || !canMove) {\n return null\n }\n\n return (\n <React.Fragment>\n <ListSelectionButton\n aria-label={t('general:move')}\n className={`${baseClass}__toggle`}\n onClick={openDrawer}\n >\n {t('general:move')}\n </ListSelectionButton>\n <HierarchyDrawer\n hasMany={false}\n initialSelections={currentParentID ? [currentParentID] : null}\n onMoveToRoot={handleMoveToRoot}\n onSave={handleDrawerSave}\n showMoveToRoot\n />\n <ConfirmationModal\n body={\n <p>\n {destination?.id === null ? (\n <Translation\n elements={{\n '1': ({ children }) => <strong>{children}</strong>,\n }}\n i18nKey=\"hierarchy:moveItemsToRootConfirmation\"\n t={t}\n variables={{\n count,\n label,\n }}\n />\n ) : (\n <Translation\n elements={{\n '1': ({ children }) => <strong>{children}</strong>,\n }}\n i18nKey=\"general:moveConfirm\"\n t={t}\n variables={{\n count,\n destination: destination?.title || '',\n label,\n }}\n />\n )}\n </p>\n }\n confirmingLabel={t('general:moving')}\n heading={t('general:confirmMove')}\n modalSlug={confirmMoveDrawerSlug}\n onConfirm={handleConfirmMove}\n />\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AACtD,SAASC,KAAK,QAAQ;AAItB,SAASC,SAAS,QAAQ;AAC1B,SAASC,oBAAoB,QAAQ;AACrC,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,iBAAiB,QAAQ;AAClC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,WAAW,QAAQ;AAC5B,SAASC,kBAAkB,QAAQ;AACnC,OAAO;AAEP,OAAO,MAAMC,SAAA,GAAY;AAiBzB;;;AAGA,SAASC,mBACPC,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A,CAAC9G,mBAAA;MACC,cAAYkB,CAAA,CAAE;MACd6F,SAAA,EAAW,GAAG5G,SAAA,UAAmB;MACjC6G,OAAA,EAAS9D,UAAA;gBAERhC,CAAA,CAAE;qBAEL4F,IAAA,CAAC9D,eAAA;MACCiE,OAAA,EAAS;MACTC,iBAAA,EAAmBvG,eAAA,GAAkB,CAACA,eAAA,CAAgB,GAAG;MACzDwG,YAAA,EAAcrC,gBAAA;MACdsC,MAAA,EAAQlD,gBAAA;MACRmD,cAAc;qBAEhBP,IAAA,CAAC/G,iBAAA;MACC4F,IAAA,eACEmB,IAAA,CAAC;kBACEpF,WAAA,EAAa+C,EAAA,KAAO,oBACnBqC,IAAA,CAAC7G,WAAA;UACCqH,QAAA,EAAU;YACR,KAAKC,CAAC;cAAEC;YAAQ,CAAE,kBAAKV,IAAA,CAAC;wBAAQU;;UAClC;UACAC,OAAA,EAAQ;UACRvG,CAAA,EAAGA,CAAA;UACHwG,SAAA,EAAW;YACTrE,KAAA;YACAC;UACF;0BAGFwD,IAAA,CAAC7G,WAAA;UACCqH,QAAA,EAAU;YACR,KAAKC,CAAC;cAAEC,QAAQ,EAARA;YAAQ,CAAE,kBAAKV,IAAA,CAAC;wBAAQU;;UAClC;UACAC,OAAA,EAAQ;UACRvG,CAAA,EAAGA,CAAA;UACHwG,SAAA,EAAW;YACTrE,KAAA;YACA3B,WAAA,EAAaA,WAAA,EAAakD,KAAA,IAAS;YACnCtB;UACF;;;MAKRqE,eAAA,EAAiBzG,CAAA,CAAE;MACnB0G,OAAA,EAAS1G,CAAA,CAAE;MACX2G,SAAA,EAAWjG,qBAAA;MACXkG,SAAA,EAAW/C;;;AAInB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["useModal","getTranslation","formatAdminURL","qs","React","useCallback","useMemo","useState","toast","useConfig","useDocumentSelection","useLocale","useTranslation","requests","ConfirmationModal","ListSelectionButton","Translation","useHierarchyDrawer","baseClass","getParentFieldName","hierarchyConfig","config","hierarchy","undefined","parentFieldName","MoveMany","currentParentID","hierarchySlug","Icon","modalPrefix","onSuccess","selections","i18n","t","code","locale","openModal","collections","routes","api","getSelectionsWithMetadata","destination","setDestination","confirmMoveDrawerSlug","requiredCollections","selectionsWithMeta","required","Set","collectionSlug","items","Object","entries","metadata","allowedCollections","slug","add","size","Array","from","disabledIds","parentIds","ids","length","HierarchyDrawer","closeDrawer","openDrawer","filterByCollection","hierarchyCollectionSlug","count","label","totalCount","labels","find","c","collectionLabel","plural","singular","push","join","hierarchyCollectionConfig","canMove","handleDrawerSave","selectionsMap","firstSelection","values","next","value","destinationId","id","destinationTitle","path","title","String","handleMoveToRoot","handleConfirmMove","totalMoved","hasErrors","queryString","stringify","where","in","addQueryPrefix","url","apiRoute","response","patch","body","JSON","headers","language","credentials","json","status","errors","error","message","description","map","movedCount","docs","successKey","success","_err","_jsxs","Fragment","_jsx","className","onClick","hasMany","initialSelections","onMoveToRoot","onSave","showMoveToRoot","elements","1","children","i18nKey","variables","confirmingLabel","heading","modalSlug","onConfirm"],"sources":["../../../../src/elements/Hierarchy/MoveMany/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientCollectionConfig } from 'payload'\n\nimport { useModal } from '@faceless-ui/modal'\nimport { getTranslation } from '@payloadcms/translations'\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { useCallback, useMemo, useState } from 'react'\nimport { toast } from 'sonner'\n\nimport type { SelectionWithPath } from '../Drawer/types.js'\n\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useDocumentSelection } from '../../../providers/DocumentSelection/index.js'\nimport { useLocale } from '../../../providers/Locale/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { requests } from '../../../utilities/api.js'\nimport { ConfirmationModal } from '../../ConfirmationModal/index.js'\nimport { ListSelectionButton } from '../../ListSelection/index.js'\nimport { Translation } from '../../Translation/index.js'\nimport { useHierarchyDrawer } from '../Drawer/useHierarchyDrawer.js'\n\nexport const baseClass = 'move-many'\n\ntype MoveManyProps = {\n /** Current parent ID - drawer will open expanded to this location */\n currentParentID?: null | number | string\n /** The hierarchy collection slug (e.g., 'folders') */\n hierarchySlug: string\n /** Icon to display in the hierarchy drawer */\n Icon?: React.ReactNode\n /** When multiple MoveMany components are rendered on the page, this will differentiate them */\n modalPrefix?: string\n /** Callback after successful move */\n onSuccess?: () => void\n /** Selections grouped by collection slug */\n selections: Record<string, { ids: (number | string)[] }>\n}\n\n/**\n * Gets the parent field name from the hierarchy config.\n */\nfunction getParentFieldName(\n hierarchyConfig: ClientCollectionConfig | undefined,\n): string | undefined {\n const config =\n hierarchyConfig?.hierarchy && typeof hierarchyConfig.hierarchy === 'object'\n ? hierarchyConfig.hierarchy\n : undefined\n return config?.parentFieldName\n}\n\nexport function MoveMany({\n currentParentID,\n hierarchySlug,\n Icon,\n modalPrefix,\n onSuccess,\n selections,\n}: MoveManyProps) {\n const { i18n, t } = useTranslation()\n const { code: locale } = useLocale()\n const { openModal } = useModal()\n const {\n config: {\n collections,\n routes: { api },\n },\n } = useConfig()\n\n const { getSelectionsWithMetadata } = useDocumentSelection()\n\n const [destination, setDestination] = useState<{\n id: null | number | string\n title: string\n } | null>(null)\n\n const confirmMoveDrawerSlug = `${modalPrefix ? `${modalPrefix}-` : ''}confirm-move-many`\n\n // Compute required collections from selection metadata\n // For related items: add their collection slug\n // For folders: add their allowedCollections values\n const requiredCollections = useMemo(() => {\n const selectionsWithMeta = getSelectionsWithMetadata()\n const required = new Set<string>()\n\n for (const [collectionSlug, { selections: items }] of Object.entries(selectionsWithMeta)) {\n if (collectionSlug === hierarchySlug) {\n // For folders, add their allowedCollections to required set\n for (const { metadata } of items) {\n if (metadata.allowedCollections) {\n for (const slug of metadata.allowedCollections) {\n required.add(slug)\n }\n }\n }\n } else {\n // For related items, add their collection slug\n required.add(collectionSlug)\n }\n }\n\n return required.size > 0 ? Array.from(required) : undefined\n }, [getSelectionsWithMetadata, hierarchySlug])\n\n // Folders being moved cannot be selected as destination (can't move into themselves)\n const disabledIds = useMemo(() => {\n const parentIds = selections[hierarchySlug]?.ids\n return parentIds?.length ? new Set(parentIds) : undefined\n }, [selections, hierarchySlug])\n\n const [HierarchyDrawer, , { closeDrawer, openDrawer }] = useHierarchyDrawer({\n disabledIds,\n filterByCollection: requiredCollections,\n hierarchyCollectionSlug: hierarchySlug,\n Icon,\n })\n\n // Calculate total count and label\n const { count, label } = useMemo(() => {\n let totalCount = 0\n const labels: string[] = []\n\n for (const [collectionSlug, { ids }] of Object.entries(selections)) {\n const config = collections.find((c) => c.slug === collectionSlug)\n\n if (config && ids.length > 0) {\n totalCount += ids.length\n const collectionLabel = getTranslation(\n ids.length > 1 ? config.labels.plural : config.labels.singular,\n i18n,\n )\n labels.push(collectionLabel)\n }\n }\n\n return {\n count: totalCount,\n label: labels.join(', '),\n }\n }, [selections, collections, i18n])\n\n const hierarchyCollectionConfig = collections.find((c) => c.slug === hierarchySlug)\n const parentFieldName = getParentFieldName(hierarchyCollectionConfig)\n\n // Check if hierarchy has a valid parentFieldName\n const canMove = parentFieldName !== undefined\n\n const handleDrawerSave = useCallback(\n ({ selections: selectionsMap }: { selections: Map<number | string, SelectionWithPath> }) => {\n if (selectionsMap.size === 0) {\n return\n }\n\n const firstSelection = selectionsMap.values().next().value\n const destinationId = firstSelection?.id\n const destinationTitle =\n firstSelection?.path?.[firstSelection.path.length - 1]?.title || String(destinationId)\n\n setDestination({ id: destinationId, title: destinationTitle })\n openModal(confirmMoveDrawerSlug)\n },\n [openModal, confirmMoveDrawerSlug],\n )\n\n const handleMoveToRoot = useCallback(() => {\n setDestination({ id: null, title: t('hierarchy:noParent') })\n openModal(confirmMoveDrawerSlug)\n }, [openModal, confirmMoveDrawerSlug, t])\n\n const handleConfirmMove = useCallback(async () => {\n if (destination === null) {\n return\n }\n\n let totalMoved = 0\n let hasErrors = false\n\n try {\n for (const [collectionSlug, { ids }] of Object.entries(selections)) {\n if (ids.length === 0) {\n continue\n }\n\n const queryString = qs.stringify(\n {\n locale,\n where: { id: { in: ids } },\n },\n { addQueryPrefix: true },\n )\n\n const url = formatAdminURL({\n apiRoute: api,\n path: `/${collectionSlug}${queryString}`,\n })\n\n const response = await requests.patch(url, {\n body: JSON.stringify({ [parentFieldName]: destination.id }),\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/json',\n credentials: 'include',\n },\n })\n\n const json = await response.json()\n\n if (response.status >= 400) {\n hasErrors = true\n\n if (json?.errors?.length > 0) {\n toast.error(json.message || t('error:unknown'), {\n description: json.errors\n .map((error: { message: string }) => error.message)\n .join('\\n'),\n })\n } else {\n toast.error(json?.message || t('error:unknown'))\n }\n\n continue\n }\n\n const movedCount = json?.docs?.length || 0\n totalMoved += movedCount\n\n if (json?.errors?.length > 0) {\n hasErrors = true\n toast.error(json.message, {\n description: json.errors.map((error: { message: string }) => error.message).join('\\n'),\n })\n }\n }\n\n if (totalMoved > 0) {\n const successKey =\n destination.id === null ? 'hierarchy:itemsMovedToRoot' : 'hierarchy:itemsMovedTo'\n\n toast.success(\n t(successKey, {\n destination: destination.title,\n title: label,\n }),\n )\n }\n\n if (!hasErrors || totalMoved > 0) {\n closeDrawer()\n onSuccess?.()\n }\n } catch (_err) {\n toast.error(t('error:unknown'))\n } finally {\n setDestination(null)\n }\n }, [\n closeDrawer,\n destination,\n selections,\n parentFieldName,\n locale,\n api,\n i18n,\n t,\n label,\n onSuccess,\n ])\n\n if (count === 0 || !canMove) {\n return null\n }\n\n return (\n <React.Fragment>\n <ListSelectionButton\n aria-label={t('general:move')}\n className={`${baseClass}__toggle`}\n onClick={openDrawer}\n >\n {t('general:move')}\n </ListSelectionButton>\n <HierarchyDrawer\n hasMany={false}\n initialSelections={currentParentID ? [currentParentID] : null}\n onMoveToRoot={handleMoveToRoot}\n onSave={handleDrawerSave}\n showMoveToRoot\n />\n <ConfirmationModal\n body={\n <p>\n {destination?.id === null ? (\n <Translation\n elements={{\n '1': ({ children }) => <strong>{children}</strong>,\n }}\n i18nKey=\"hierarchy:moveItemsToRootConfirmation\"\n t={t}\n variables={{\n count,\n label,\n }}\n />\n ) : (\n <Translation\n elements={{\n '1': ({ children }) => <strong>{children}</strong>,\n }}\n i18nKey=\"general:moveConfirm\"\n t={t}\n variables={{\n count,\n destination: destination?.title || '',\n label,\n }}\n />\n )}\n </p>\n }\n confirmingLabel={t('general:moving')}\n heading={t('general:confirmMove')}\n modalSlug={confirmMoveDrawerSlug}\n onConfirm={handleConfirmMove}\n />\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AACtD,SAASC,KAAK,QAAQ;AAItB,SAASC,SAAS,QAAQ;AAC1B,SAASC,oBAAoB,QAAQ;AACrC,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,iBAAiB,QAAQ;AAClC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,WAAW,QAAQ;AAC5B,SAASC,kBAAkB,QAAQ;AAEnC,OAAO,MAAMC,SAAA,GAAY;AAiBzB;;;AAGA,SAASC,mBACPC,eAAmD;EAEnD,MAAMC,MAAA,GACJD,eAAA,EAAiBE,SAAA,IAAa,OAAOF,eAAA,CAAgBE,SAAS,KAAK,WAC/DF,eAAA,CAAgBE,SAAS,GACzBC,SAAA;EACN,OAAOF,MAAA,EAAQG,eAAA;AACjB;AAEA,OAAO,SAASC,SAAS;EACvBC,eAAe;EACfC,aAAa;EACbC,IAAI;EACJC,WAAW;EACXC,SAAS;EACTC;AAAU,CACI;EACd,MAAM;IAAEC,IAAI;IAAEC;EAAC,CAAE,GAAGrB,cAAA;EACpB,MAAM;IAAEsB,IAAA,EAAMC;EAAM,CAAE,GAAGxB,SA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AAA,EAAa+C,EAAA,KAAO,oBACnBqC,IAAA,CAAC7G,WAAA;UACCqH,QAAA,EAAU;YACR,KAAKC,CAAC;cAAEC;YAAQ,CAAE,kBAAKV,IAAA,CAAC;wBAAQU;;UAClC;UACAC,OAAA,EAAQ;UACRvG,CAAA,EAAGA,CAAA;UACHwG,SAAA,EAAW;YACTrE,KAAA;YACAC;UACF;0BAGFwD,IAAA,CAAC7G,WAAA;UACCqH,QAAA,EAAU;YACR,KAAKC,CAAC;cAAEC,QAAQ,EAARA;YAAQ,CAAE,kBAAKV,IAAA,CAAC;wBAAQU;;UAClC;UACAC,OAAA,EAAQ;UACRvG,CAAA,EAAGA,CAAA;UACHwG,SAAA,EAAW;YACTrE,KAAA;YACA3B,WAAA,EAAaA,WAAA,EAAakD,KAAA,IAAS;YACnCtB;UACF;;;MAKRqE,eAAA,EAAiBzG,CAAA,CAAE;MACnB0G,OAAA,EAAS1G,CAAA,CAAE;MACX2G,SAAA,EAAWjG,qBAAA;MACXkG,SAAA,EAAW/C;;;AAInB","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* Tree-specific overrides for the shared LoadMoreRow component */
|
|
2
|
+
|
|
3
|
+
.tree__load-more.load-more-row {
|
|
4
|
+
padding-top: 0;
|
|
5
|
+
padding-left: calc(
|
|
6
|
+
(var(--tree-depth, 0) * var(--tree-indent)) + (var(--spacer-1) * var(--tree-depth)) +
|
|
7
|
+
var(--spacer-2-5) - 2px
|
|
8
|
+
);
|
|
9
|
+
height: var(--tree-node-content-height);
|
|
10
|
+
position: relative;
|
|
11
|
+
margin-block: var(--spacer-1) var(--spacer-2);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* Tree-specific button styling (uses native button for focus management) */
|
|
15
|
+
.tree__load-more-button {
|
|
16
|
+
color: var(--color-text);
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
text-decoration: underline;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.tree__load-more-button:hover {
|
|
22
|
+
color: var(--color-text-secondary);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.tree__load-more-button:active {
|
|
26
|
+
color: var(--color-text);
|
|
27
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/Hierarchy/Tree/LoadMore/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/Hierarchy/Tree/LoadMore/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,aAAa,CAAA;AAEpB,KAAK,aAAa,GAAG;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAA;IAChD,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAiB5C,CAAA"}
|
|
@@ -4,7 +4,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { LoadMoreRow } from '../../../LoadMoreRow/index.js';
|
|
6
6
|
import { LoadMoreButton } from './LoadMoreButton.js';
|
|
7
|
-
import './index.
|
|
7
|
+
import './index.css';
|
|
8
8
|
export const LoadMore = ({
|
|
9
9
|
id,
|
|
10
10
|
currentCount,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","LoadMoreRow","LoadMoreButton","LoadMore","id","currentCount","depth","onLoadMore","totalDocs","_jsx","className","hasMore","loadMoreButton","style"],"sources":["../../../../../src/elements/Hierarchy/Tree/LoadMore/index.tsx"],"sourcesContent":["'use client'\n\nimport React from 'react'\n\nimport { LoadMoreRow } from '../../../LoadMoreRow/index.js'\nimport { LoadMoreButton } from './LoadMoreButton.js'\nimport './index.
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","LoadMoreRow","LoadMoreButton","LoadMore","id","currentCount","depth","onLoadMore","totalDocs","_jsx","className","hasMore","loadMoreButton","style"],"sources":["../../../../../src/elements/Hierarchy/Tree/LoadMore/index.tsx"],"sourcesContent":["'use client'\n\nimport React from 'react'\n\nimport { LoadMoreRow } from '../../../LoadMoreRow/index.js'\nimport { LoadMoreButton } from './LoadMoreButton.js'\nimport './index.css'\n\ntype LoadMoreProps = {\n currentCount: number\n depth: number\n id: string\n onLoadMore: (() => Promise<void>) | (() => void)\n totalDocs: number\n}\n\nexport const LoadMore: React.FC<LoadMoreProps> = ({\n id,\n currentCount,\n depth,\n onLoadMore,\n totalDocs,\n}) => {\n return (\n <LoadMoreRow\n className=\"tree__load-more\"\n currentCount={currentCount}\n hasMore={currentCount < totalDocs}\n loadMoreButton={<LoadMoreButton id={id} onLoadMore={onLoadMore} />}\n style={{ '--tree-depth': depth } as React.CSSProperties}\n totalDocs={totalDocs}\n />\n )\n}\n"],"mappings":"AAAA;;;AAEA,OAAOA,KAAA,MAAW;AAElB,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,OAAO;AAUP,OAAO,MAAMC,QAAA,GAAoCA,CAAC;EAChDC,EAAE;EACFC,YAAY;EACZC,KAAK;EACLC,UAAU;EACVC;AAAS,CACV;EACC,oBACEC,IAAA,CAACR,WAAA;IACCS,SAAA,EAAU;IACVL,YAAA,EAAcA,YAAA;IACdM,OAAA,EAASN,YAAA,GAAeG,SAAA;IACxBI,cAAA,eAAgBH,IAAA,CAACP,cAAA;MAAeE,EAAA,EAAIA,EAAA;MAAIG,UAAA,EAAYA;;IACpDM,KAAA,EAAO;MAAE,gBAAgBP;IAAM;IAC/BE,SAAA,EAAWA;;AAGjB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeFocusContext.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/Tree/TreeFocusContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"TreeFocusContext.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/Tree/TreeFocusContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAY9B,KAAK,aAAa,GAAG;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IACjC,IAAI,EAAE,WAAW,GAAG,MAAM,CAAA;CAC3B,CAAA;AAED,KAAK,oBAAoB,GAAG;IAC1B,SAAS,EAAE,IAAI,GAAG,MAAM,CAAA;IACxB,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IAC7C,YAAY,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAA;IAC3C,YAAY,EAAE,CAAC,EAAE,EAAE,IAAI,GAAG,MAAM,KAAK,IAAI,CAAA;IACzC,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;CACrC,CAAA;AAID,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAgFrE,CAAA;AAED,eAAO,MAAM,YAAY,4BAMxB,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,oBAI9B;IACD,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IACjC,IAAI,EAAE,WAAW,GAAG,MAAM,CAAA;CAC3B;;;;CAsCA,CAAA"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { c as _c } from "react/compiler-runtime";
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
import { createContext, use, useCallback, useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { createContext, use, useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
6
6
|
const TreeFocusContext = /*#__PURE__*/createContext(undefined);
|
|
7
7
|
export const TreeFocusProvider = ({
|
|
8
8
|
children
|
|
@@ -77,7 +77,7 @@ export const useTreeFocus = () => {
|
|
|
77
77
|
return context;
|
|
78
78
|
};
|
|
79
79
|
export const useFocusableItem = t0 => {
|
|
80
|
-
const $ = _c(
|
|
80
|
+
const $ = _c(18);
|
|
81
81
|
const {
|
|
82
82
|
id,
|
|
83
83
|
type,
|
|
@@ -91,6 +91,7 @@ export const useFocusableItem = t0 => {
|
|
|
91
91
|
} = useTreeFocus();
|
|
92
92
|
const isFocused = focusedId === id;
|
|
93
93
|
const isFirstItemEver = focusedId === null;
|
|
94
|
+
const wasFocusedRef = useRef(false);
|
|
94
95
|
let t1;
|
|
95
96
|
let t2;
|
|
96
97
|
if ($[0] !== id || $[1] !== ref || $[2] !== registerItem || $[3] !== type || $[4] !== unregisterItem) {
|
|
@@ -118,32 +119,51 @@ export const useFocusableItem = t0 => {
|
|
|
118
119
|
}
|
|
119
120
|
useEffect(t1, t2);
|
|
120
121
|
let t3;
|
|
121
|
-
|
|
122
|
+
let t4;
|
|
123
|
+
if ($[7] !== isFocused || $[8] !== ref) {
|
|
122
124
|
t3 = () => {
|
|
123
|
-
|
|
125
|
+
if (isFocused && !wasFocusedRef.current && ref.current && document.activeElement !== ref.current) {
|
|
126
|
+
ref.current.focus();
|
|
127
|
+
}
|
|
128
|
+
wasFocusedRef.current = isFocused;
|
|
124
129
|
};
|
|
125
|
-
|
|
126
|
-
$[
|
|
130
|
+
t4 = [isFocused, ref];
|
|
131
|
+
$[7] = isFocused;
|
|
132
|
+
$[8] = ref;
|
|
127
133
|
$[9] = t3;
|
|
134
|
+
$[10] = t4;
|
|
128
135
|
} else {
|
|
129
136
|
t3 = $[9];
|
|
137
|
+
t4 = $[10];
|
|
138
|
+
}
|
|
139
|
+
useLayoutEffect(t3, t4);
|
|
140
|
+
let t5;
|
|
141
|
+
if ($[11] !== id || $[12] !== setFocusedId) {
|
|
142
|
+
t5 = () => {
|
|
143
|
+
setFocusedId(id);
|
|
144
|
+
};
|
|
145
|
+
$[11] = id;
|
|
146
|
+
$[12] = setFocusedId;
|
|
147
|
+
$[13] = t5;
|
|
148
|
+
} else {
|
|
149
|
+
t5 = $[13];
|
|
130
150
|
}
|
|
131
|
-
const handleFocus =
|
|
151
|
+
const handleFocus = t5;
|
|
132
152
|
const tabIndex = isFocused ? 0 : isFirstItemEver ? 0 : -1;
|
|
133
|
-
let
|
|
134
|
-
if ($[
|
|
135
|
-
|
|
153
|
+
let t6;
|
|
154
|
+
if ($[14] !== handleFocus || $[15] !== isFocused || $[16] !== tabIndex) {
|
|
155
|
+
t6 = {
|
|
136
156
|
handleFocus,
|
|
137
157
|
isFocused,
|
|
138
158
|
tabIndex
|
|
139
159
|
};
|
|
140
|
-
$[
|
|
141
|
-
$[
|
|
142
|
-
$[
|
|
143
|
-
$[
|
|
160
|
+
$[14] = handleFocus;
|
|
161
|
+
$[15] = isFocused;
|
|
162
|
+
$[16] = tabIndex;
|
|
163
|
+
$[17] = t6;
|
|
144
164
|
} else {
|
|
145
|
-
|
|
165
|
+
t6 = $[17];
|
|
146
166
|
}
|
|
147
|
-
return
|
|
167
|
+
return t6;
|
|
148
168
|
};
|
|
149
169
|
//# sourceMappingURL=TreeFocusContext.js.map
|