@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":"TreeFocusContext.js","names":["c","_c","createContext","use","useCallback","useEffect","useRef","useState","TreeFocusContext","undefined","TreeFocusProvider","children","focusedId","setFocusedIdState","itemsRef","Map","setFocusedId","id","item","current","get","ref","document","activeElement","focus","registerItem","set","unregisterItem","delete","moveFocus","direction","items","Array","from","values","length","sortedItems","filter","sort","a","b","aElement","bElement","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","currentIndex","findIndex","nextIndex","Math","min","max","nextItem","_jsx","value","useTreeFocus","context","Error","useFocusableItem","t0","$","type","isFocused","isFirstItemEver","t1","t2","t3","handleFocus","tabIndex","
|
|
1
|
+
{"version":3,"file":"TreeFocusContext.js","names":["c","_c","createContext","use","useCallback","useEffect","useLayoutEffect","useRef","useState","TreeFocusContext","undefined","TreeFocusProvider","children","focusedId","setFocusedIdState","itemsRef","Map","setFocusedId","id","item","current","get","ref","document","activeElement","focus","registerItem","set","unregisterItem","delete","moveFocus","direction","items","Array","from","values","length","sortedItems","filter","sort","a","b","aElement","bElement","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","currentIndex","findIndex","nextIndex","Math","min","max","nextItem","_jsx","value","useTreeFocus","context","Error","useFocusableItem","t0","$","type","isFocused","isFirstItemEver","wasFocusedRef","t1","t2","t3","t4","t5","handleFocus","tabIndex","t6"],"sources":["../../../../src/elements/Hierarchy/Tree/TreeFocusContext.tsx"],"sourcesContent":["'use client'\n\nimport type React from 'react'\n\nimport {\n createContext,\n use,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react'\n\ntype FocusableItem = {\n id: string\n ref: React.RefObject<HTMLElement>\n type: 'load-more' | 'node'\n}\n\ntype TreeFocusContextType = {\n focusedId: null | string\n moveFocus: (direction: 'down' | 'up') => void\n registerItem: (item: FocusableItem) => void\n setFocusedId: (id: null | string) => void\n unregisterItem: (id: string) => void\n}\n\nconst TreeFocusContext = createContext<TreeFocusContextType | undefined>(undefined)\n\nexport const TreeFocusProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const [focusedId, setFocusedIdState] = useState<null | string>(null)\n const itemsRef = useRef<Map<string, FocusableItem>>(new Map())\n\n const setFocusedId = useCallback((id: null | string) => {\n setFocusedIdState(id)\n if (id) {\n const item = itemsRef.current.get(id)\n if (item?.ref.current && document.activeElement !== item.ref.current) {\n item.ref.current.focus()\n }\n }\n }, [])\n\n const registerItem = useCallback((item: FocusableItem) => {\n itemsRef.current.set(item.id, item)\n }, [])\n\n const unregisterItem = useCallback((id: string) => {\n itemsRef.current.delete(id)\n }, [])\n\n const moveFocus = useCallback(\n (direction: 'down' | 'up') => {\n const items = Array.from(itemsRef.current.values())\n if (items.length === 0) {\n return\n }\n\n // Sort items by their DOM position to ensure correct navigation order\n const sortedItems = items\n .filter((item) => item.ref.current)\n .sort((a, b) => {\n const aElement = a.ref.current\n const bElement = b.ref.current\n if (!aElement || !bElement) {\n return 0\n }\n\n const position = aElement.compareDocumentPosition(bElement)\n if (position & Node.DOCUMENT_POSITION_FOLLOWING) {\n return -1\n }\n if (position & Node.DOCUMENT_POSITION_PRECEDING) {\n return 1\n }\n return 0\n })\n\n const currentIndex = focusedId ? sortedItems.findIndex((item) => item.id === focusedId) : -1\n\n let nextIndex: number\n if (direction === 'down') {\n nextIndex = currentIndex === -1 ? 0 : Math.min(currentIndex + 1, sortedItems.length - 1)\n } else {\n nextIndex = Math.max(currentIndex - 1, 0)\n }\n\n const nextItem = sortedItems[nextIndex]\n if (nextItem && nextItem.ref.current) {\n nextItem.ref.current.focus()\n setFocusedId(nextItem.id)\n }\n },\n [focusedId, setFocusedId],\n )\n\n return (\n <TreeFocusContext\n value={{\n focusedId,\n moveFocus,\n registerItem,\n setFocusedId,\n unregisterItem,\n }}\n >\n {children}\n </TreeFocusContext>\n )\n}\n\nexport const useTreeFocus = () => {\n const context = use(TreeFocusContext)\n if (!context) {\n throw new Error('useTreeFocus must be used within TreeFocusProvider')\n }\n return context\n}\n\nexport const useFocusableItem = ({\n id,\n type,\n ref,\n}: {\n id: string\n ref: React.RefObject<HTMLElement>\n type: 'load-more' | 'node'\n}) => {\n const { focusedId, registerItem, setFocusedId, unregisterItem } = useTreeFocus()\n const isFocused = focusedId === id\n const isFirstItemEver = focusedId === null\n const wasFocusedRef = useRef(false)\n\n useEffect(() => {\n registerItem({ id, type, ref })\n return () => {\n unregisterItem(id)\n }\n }, [id, ref, type, registerItem, unregisterItem])\n\n useLayoutEffect(() => {\n if (\n isFocused &&\n !wasFocusedRef.current &&\n ref.current &&\n document.activeElement !== ref.current\n ) {\n ref.current.focus()\n }\n\n wasFocusedRef.current = isFocused\n }, [isFocused, ref])\n\n const handleFocus = useCallback(() => {\n setFocusedId(id)\n }, [id, setFocusedId])\n\n // Roving tabindex: focused item gets 0, first item (when nothing focused) gets 0, all others get -1\n const tabIndex = isFocused ? 0 : isFirstItemEver ? 0 : -1\n\n return {\n handleFocus,\n isFocused,\n tabIndex,\n }\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAIA,SACEC,aAAa,EACbC,GAAG,EACHC,WAAW,EACXC,SAAS,EACTC,eAAe,EACfC,MAAM,EACNC,QAAQ,QACH;AAgBP,MAAMC,gBA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@@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/Hierarchy/Tree/TreeNode/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAQhD,OAAO,aAAa,CAAA;AAqBpB,eAAO,MAAM,QAAQ,GAAI,uNAkBtB,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/Hierarchy/Tree/TreeNode/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAQhD,OAAO,aAAa,CAAA;AAqBpB,eAAO,MAAM,QAAQ,GAAI,uNAkBtB,aAAa,sBA0Mf,CAAA"}
|
|
@@ -75,7 +75,9 @@ export const TreeNode = ({
|
|
|
75
75
|
if (newDocs && newDocs.length > 0) {
|
|
76
76
|
const firstNewDoc = newDocs[0];
|
|
77
77
|
const docId = firstNewDoc.id;
|
|
78
|
-
|
|
78
|
+
window.requestAnimationFrame(() => {
|
|
79
|
+
setFocusedId(`node-${docId}`);
|
|
80
|
+
});
|
|
79
81
|
}
|
|
80
82
|
}, [loadMoreFromHook, setFocusedId]);
|
|
81
83
|
const {
|
|
@@ -92,21 +94,22 @@ export const TreeNode = ({
|
|
|
92
94
|
// - If expanded and loaded, check the actual children
|
|
93
95
|
// - Otherwise, assume it might have children (show chevron until proven otherwise)
|
|
94
96
|
const hasChildren = node.hasChildren === true || (expanded && children !== null ? children.length > 0 : true);
|
|
95
|
-
const
|
|
96
|
-
e
|
|
97
|
-
|
|
98
|
-
void load();
|
|
99
|
-
}
|
|
97
|
+
const handleToggle = useCallback(e => {
|
|
98
|
+
e?.stopPropagation();
|
|
99
|
+
void load();
|
|
100
100
|
onToggle({
|
|
101
101
|
id: node.id
|
|
102
102
|
});
|
|
103
|
-
}, [node.id, onToggle
|
|
103
|
+
}, [load, node.id, onToggle]);
|
|
104
104
|
const handleSelectClick = useCallback(() => {
|
|
105
105
|
onSelect?.({
|
|
106
106
|
id: node.id
|
|
107
107
|
});
|
|
108
108
|
}, [node.id, onSelect]);
|
|
109
109
|
const handleKeyDown = useCallback(e_0 => {
|
|
110
|
+
if (e_0.target !== e_0.currentTarget) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
110
113
|
switch (e_0.key) {
|
|
111
114
|
case ' ':
|
|
112
115
|
case 'Enter':
|
|
@@ -127,19 +130,21 @@ export const TreeNode = ({
|
|
|
127
130
|
e_0.preventDefault();
|
|
128
131
|
e_0.stopPropagation();
|
|
129
132
|
if (hasChildren && !expanded) {
|
|
130
|
-
|
|
131
|
-
id: node.id
|
|
132
|
-
});
|
|
133
|
+
handleToggle();
|
|
133
134
|
}
|
|
134
135
|
break;
|
|
135
136
|
}
|
|
136
|
-
}, [
|
|
137
|
+
}, [expanded, handleSelectClick, handleToggle, hasChildren, node.id, onToggle]);
|
|
137
138
|
return /*#__PURE__*/_jsxs("div", {
|
|
138
139
|
"aria-expanded": hasChildren ? expanded : undefined,
|
|
139
140
|
"aria-level": depth + 1,
|
|
140
141
|
"aria-selected": selected,
|
|
141
142
|
className: baseClass,
|
|
142
|
-
onFocus:
|
|
143
|
+
onFocus: e_1 => {
|
|
144
|
+
if (e_1.target === e_1.currentTarget) {
|
|
145
|
+
handleFocus();
|
|
146
|
+
}
|
|
147
|
+
},
|
|
143
148
|
onKeyDown: handleKeyDown,
|
|
144
149
|
ref: nodeRef,
|
|
145
150
|
role: "treeitem",
|
|
@@ -152,8 +157,8 @@ export const TreeNode = ({
|
|
|
152
157
|
children: [hasChildren ? /*#__PURE__*/_jsx("button", {
|
|
153
158
|
"aria-label": expanded ? t('general:collapse') : t('general:open'),
|
|
154
159
|
className: `${baseClass}__toggle`,
|
|
155
|
-
onClick:
|
|
156
|
-
onMouseDown:
|
|
160
|
+
onClick: handleToggle,
|
|
161
|
+
onMouseDown: e_2 => e_2.preventDefault(),
|
|
157
162
|
tabIndex: -1,
|
|
158
163
|
type: "button",
|
|
159
164
|
children: /*#__PURE__*/_jsx(ChevronIcon, {
|
|
@@ -167,7 +172,7 @@ export const TreeNode = ({
|
|
|
167
172
|
}), /*#__PURE__*/_jsx("span", {
|
|
168
173
|
className: `${baseClass}__title sidebar-row__title`,
|
|
169
174
|
onClick: handleSelectClick,
|
|
170
|
-
onMouseDown:
|
|
175
|
+
onMouseDown: e_3 => e_3.preventDefault(),
|
|
171
176
|
title: node.title,
|
|
172
177
|
children: node.title
|
|
173
178
|
}), isLoading && expanded && /*#__PURE__*/_jsx("span", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useCallback","useRef","Spinner","ChevronIcon","useTranslation","LoadMore","useFocusableItem","useTreeFocus","useChildren","DEFAULT_TREE_LIMIT","baseClass","getDocumentTitle","doc","useAsTitle","docId","id","idStr","String","value","TreeNode","allPossibleTypeValues","baseFilter","cache","collectionSlug","depth","expandedNodes","filterByCollections","icon","limit","node","onSelect","onToggle","parentFieldName","selected","selectedNodeId","typeFieldName","t","expanded","has","nodeRef","setFocusedId","children","hasMore","isLoading","load","loadMore","loadMoreFromHook","totalDocs","enabled","parentId","handleLoadMore","newDocs","length","firstNewDoc","handleFocus","isFocused","tabIndex","type","ref","hasChildren","handleToggleClick","e","stopPropagation","handleSelectClick","handleKeyDown","key","preventDefault","_jsxs","undefined","className","onFocus","onKeyDown","role","style","filter","Boolean","join","_jsx","onClick","onMouseDown","direction","title","loadingText","size","_Fragment","map","child","childData","childId","childTitle","currentCount","onLoadMore"],"sources":["../../../../../src/elements/Hierarchy/Tree/TreeNode/index.tsx"],"sourcesContent":["'use client'\n\nimport React, { useCallback, useRef } from 'react'\n\nimport type { TreeNodeProps } from '../types.js'\n\nimport { Spinner } from '../../../../elements/Spinner/index.js'\nimport { ChevronIcon } from '../../../../icons/Chevron/index.js'\nimport { useTranslation } from '../../../../providers/Translation/index.js'\nimport { LoadMore } from '../LoadMore/index.js'\nimport { useFocusableItem, useTreeFocus } from '../TreeFocusContext.js'\nimport { useChildren } from '../useChildren.js'\nimport './index.css'\n\nconst DEFAULT_TREE_LIMIT = 10\n\nconst baseClass = 'tree-node'\n\nconst getDocumentTitle = (doc: Record<string, unknown>, useAsTitle: string | undefined): string => {\n const docId: number | string = doc.id as number | string\n const idStr = typeof docId === 'number' ? String(docId) : docId\n\n if (!useAsTitle) {\n return idStr\n }\n\n const value = doc[useAsTitle]\n if (value && (typeof value === 'string' || typeof value === 'number')) {\n return String(value)\n }\n return idStr\n}\n\nexport const TreeNode = ({\n allPossibleTypeValues,\n baseFilter,\n cache,\n collectionSlug,\n depth = 0,\n expandedNodes,\n filterByCollections,\n icon,\n limit = DEFAULT_TREE_LIMIT,\n node,\n onSelect,\n onToggle,\n parentFieldName,\n selected,\n selectedNodeId,\n typeFieldName,\n useAsTitle,\n}: TreeNodeProps) => {\n const { t } = useTranslation()\n const expanded = expandedNodes.has(node.id)\n const nodeRef = useRef<HTMLDivElement>(null)\n const { setFocusedId } = useTreeFocus()\n\n const {\n children,\n hasMore,\n isLoading,\n load,\n loadMore: loadMoreFromHook,\n totalDocs,\n } = useChildren({\n allPossibleTypeValues,\n baseFilter,\n cache,\n collectionSlug,\n enabled: expanded,\n filterByCollections,\n limit,\n parentFieldName,\n parentId: node.id,\n typeFieldName,\n useAsTitle,\n })\n\n const handleLoadMore = React.useCallback(async () => {\n const newDocs = await loadMoreFromHook()\n\n if (newDocs && newDocs.length > 0) {\n const firstNewDoc = newDocs[0]\n const docId: number | string = (firstNewDoc as { id: number | string }).id\n setFocusedId(`node-${docId}`)\n }\n }, [loadMoreFromHook, setFocusedId])\n\n const { handleFocus, isFocused, tabIndex } = useFocusableItem({\n id: `node-${node.id}`,\n type: 'node',\n ref: nodeRef,\n })\n\n // Determine if node has children:\n // - If explicitly set in data, use that\n // - If expanded and loaded, check the actual children\n // - Otherwise, assume it might have children (show chevron until proven otherwise)\n const hasChildren =\n node.hasChildren === true || (expanded && children !== null ? children.length > 0 : true)\n\n const handleToggleClick = useCallback(\n (e: React.MouseEvent) => {\n e.stopPropagation()\n if (!expanded) {\n void load()\n }\n onToggle({ id: node.id })\n },\n [node.id, onToggle, expanded, load],\n )\n\n const handleSelectClick = useCallback(() => {\n onSelect?.({ id: node.id })\n }, [node.id, onSelect])\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n switch (e.key) {\n case ' ':\n case 'Enter':\n e.preventDefault()\n e.stopPropagation()\n handleSelectClick()\n break\n case 'ArrowLeft':\n e.preventDefault()\n e.stopPropagation()\n if (hasChildren && expanded) {\n onToggle({ id: node.id })\n }\n break\n case 'ArrowRight':\n e.preventDefault()\n e.stopPropagation()\n if (hasChildren && !expanded) {\n onToggle({ id: node.id })\n }\n break\n }\n },\n [hasChildren, expanded, handleSelectClick, onToggle, node.id],\n )\n\n return (\n <div\n aria-expanded={hasChildren ? expanded : undefined}\n aria-level={depth + 1}\n aria-selected={selected}\n className={baseClass}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n ref={nodeRef}\n role=\"treeitem\"\n style={{ '--tree-depth': depth } as React.CSSProperties}\n tabIndex={tabIndex}\n >\n <div\n className={[\n `${baseClass}__content`,\n 'sidebar-row',\n selected && `${baseClass}__content--selected`,\n selected && 'sidebar-row--selected',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {hasChildren ? (\n <button\n aria-label={expanded ? t('general:collapse') : t('general:open')}\n className={`${baseClass}__toggle`}\n onClick={handleToggleClick}\n onMouseDown={(e) => e.preventDefault()}\n tabIndex={-1}\n type=\"button\"\n >\n <ChevronIcon direction={expanded ? 'down' : 'right'} />\n </button>\n ) : (\n <div className={`${baseClass}__toggle-spacer`} />\n )}\n {Boolean(icon) && <span className=\"sidebar-row__icon\">{icon}</span>}\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- keyboard handled by parent */}\n <span\n className={`${baseClass}__title sidebar-row__title`}\n onClick={handleSelectClick}\n onMouseDown={(e) => e.preventDefault()}\n title={node.title}\n >\n {node.title}\n </span>\n {isLoading && expanded && (\n <span className={`${baseClass}__loading`}>\n <Spinner loadingText={null} size=\"sm\" />\n </span>\n )}\n </div>\n\n {expanded && children && children.length > 0 && (\n <>\n <div className={`${baseClass}__children`} role=\"group\">\n {children.map((child) => {\n const childData = child as { id: number | string }\n const childId = childData.id\n const childTitle = getDocumentTitle(child, useAsTitle)\n return (\n <TreeNode\n allPossibleTypeValues={allPossibleTypeValues}\n baseFilter={baseFilter}\n cache={cache}\n collectionSlug={collectionSlug}\n depth={depth + 1}\n expandedNodes={expandedNodes}\n filterByCollections={filterByCollections}\n icon={icon}\n key={String(childId)}\n limit={limit}\n node={{\n id: childId,\n hasChildren: true,\n title: childTitle,\n }}\n onSelect={onSelect}\n onToggle={onToggle}\n parentFieldName={parentFieldName}\n selected={String(childId) === String(selectedNodeId)}\n selectedNodeId={selectedNodeId}\n typeFieldName={typeFieldName}\n useAsTitle={useAsTitle}\n />\n )\n })}\n </div>\n {hasMore && (\n <LoadMore\n currentCount={children.length}\n depth={depth + 1}\n id={`load-more-${node.id}`}\n onLoadMore={handleLoadMore}\n totalDocs={totalDocs}\n />\n )}\n </>\n )}\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAEA,OAAOA,KAAA,IAASC,WAAW,EAAEC,MAAM,QAAQ;AAI3C,SAASC,OAAO,QAAQ;AACxB,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,gBAAgB,EAAEC,YAAY,QAAQ;AAC/C,SAASC,WAAW,QAAQ;AAC5B,OAAO;AAEP,MAAMC,kBAAA,GAAqB;AAE3B,MAAMC,SAAA,GAAY;AAElB,MAAMC,gBAAA,GAAmBA,CAACC,GAAA,EAA8BC,UAAA;EACtD,MAAMC,KAAA,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ACPC,IAAA,EAAM;cACJd,EAAA,EAAIyE,OAAA;cACJ7B,WAAA,EAAa;cACbsB,KAAA,EAAOQ;YACT;YACA3D,QAAA,EAAUA,QAAA;YACVC,QAAA,EAAUA,QAAA;YACVC,eAAA,EAAiBA,eAAA;YACjBC,QAAA,EAAUhB,MAAA,CAAOuE,OAAA,MAAavE,MAAA,CAAOiB,cAAA;YACrCA,cAAA,EAAgBA,cAAA;YAChBC,aAAA,EAAeA,aAAA;YACftB,UAAA,EAAYA;aAbPI,MAAA,CAAOuE,OAAA;QAgBlB;UAED9C,OAAA,iBACCmC,IAAA,CAACxE,QAAA;QACCqF,YAAA,EAAcjD,QAAA,CAASW,MAAM;QAC7B5B,KAAA,EAAOA,KAAA,GAAQ;QACfT,EAAA,EAAI,aAAac,IAAA,CAAKd,EAAE,EAAE;QAC1B4E,UAAA,EAAYzC,cAAA;QACZH,SAAA,EAAWA;;;;AAOzB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","useRef","Spinner","ChevronIcon","useTranslation","LoadMore","useFocusableItem","useTreeFocus","useChildren","DEFAULT_TREE_LIMIT","baseClass","getDocumentTitle","doc","useAsTitle","docId","id","idStr","String","value","TreeNode","allPossibleTypeValues","baseFilter","cache","collectionSlug","depth","expandedNodes","filterByCollections","icon","limit","node","onSelect","onToggle","parentFieldName","selected","selectedNodeId","typeFieldName","t","expanded","has","nodeRef","setFocusedId","children","hasMore","isLoading","load","loadMore","loadMoreFromHook","totalDocs","enabled","parentId","handleLoadMore","newDocs","length","firstNewDoc","window","requestAnimationFrame","handleFocus","isFocused","tabIndex","type","ref","hasChildren","handleToggle","e","stopPropagation","handleSelectClick","handleKeyDown","target","currentTarget","key","preventDefault","_jsxs","undefined","className","onFocus","onKeyDown","role","style","filter","Boolean","join","_jsx","onClick","onMouseDown","direction","title","loadingText","size","_Fragment","map","child","childData","childId","childTitle","currentCount","onLoadMore"],"sources":["../../../../../src/elements/Hierarchy/Tree/TreeNode/index.tsx"],"sourcesContent":["'use client'\n\nimport React, { useCallback, useRef } from 'react'\n\nimport type { TreeNodeProps } from '../types.js'\n\nimport { Spinner } from '../../../../elements/Spinner/index.js'\nimport { ChevronIcon } from '../../../../icons/Chevron/index.js'\nimport { useTranslation } from '../../../../providers/Translation/index.js'\nimport { LoadMore } from '../LoadMore/index.js'\nimport { useFocusableItem, useTreeFocus } from '../TreeFocusContext.js'\nimport { useChildren } from '../useChildren.js'\nimport './index.css'\n\nconst DEFAULT_TREE_LIMIT = 10\n\nconst baseClass = 'tree-node'\n\nconst getDocumentTitle = (doc: Record<string, unknown>, useAsTitle: string | undefined): string => {\n const docId: number | string = doc.id as number | string\n const idStr = typeof docId === 'number' ? String(docId) : docId\n\n if (!useAsTitle) {\n return idStr\n }\n\n const value = doc[useAsTitle]\n if (value && (typeof value === 'string' || typeof value === 'number')) {\n return String(value)\n }\n return idStr\n}\n\nexport const TreeNode = ({\n allPossibleTypeValues,\n baseFilter,\n cache,\n collectionSlug,\n depth = 0,\n expandedNodes,\n filterByCollections,\n icon,\n limit = DEFAULT_TREE_LIMIT,\n node,\n onSelect,\n onToggle,\n parentFieldName,\n selected,\n selectedNodeId,\n typeFieldName,\n useAsTitle,\n}: TreeNodeProps) => {\n const { t } = useTranslation()\n const expanded = expandedNodes.has(node.id)\n const nodeRef = useRef<HTMLDivElement>(null)\n const { setFocusedId } = useTreeFocus()\n\n const {\n children,\n hasMore,\n isLoading,\n load,\n loadMore: loadMoreFromHook,\n totalDocs,\n } = useChildren({\n allPossibleTypeValues,\n baseFilter,\n cache,\n collectionSlug,\n enabled: expanded,\n filterByCollections,\n limit,\n parentFieldName,\n parentId: node.id,\n typeFieldName,\n useAsTitle,\n })\n\n const handleLoadMore = React.useCallback(async () => {\n const newDocs = await loadMoreFromHook()\n\n if (newDocs && newDocs.length > 0) {\n const firstNewDoc = newDocs[0]\n const docId: number | string = (firstNewDoc as { id: number | string }).id\n window.requestAnimationFrame(() => {\n setFocusedId(`node-${docId}`)\n })\n }\n }, [loadMoreFromHook, setFocusedId])\n\n const { handleFocus, isFocused, tabIndex } = useFocusableItem({\n id: `node-${node.id}`,\n type: 'node',\n ref: nodeRef,\n })\n\n // Determine if node has children:\n // - If explicitly set in data, use that\n // - If expanded and loaded, check the actual children\n // - Otherwise, assume it might have children (show chevron until proven otherwise)\n const hasChildren =\n node.hasChildren === true || (expanded && children !== null ? children.length > 0 : true)\n\n const handleToggle = useCallback(\n (e?: React.SyntheticEvent) => {\n e?.stopPropagation()\n void load()\n onToggle({ id: node.id })\n },\n [load, node.id, onToggle],\n )\n\n const handleSelectClick = useCallback(() => {\n onSelect?.({ id: node.id })\n }, [node.id, onSelect])\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.target !== e.currentTarget) {\n return\n }\n switch (e.key) {\n case ' ':\n case 'Enter':\n e.preventDefault()\n e.stopPropagation()\n handleSelectClick()\n break\n case 'ArrowLeft':\n e.preventDefault()\n e.stopPropagation()\n if (hasChildren && expanded) {\n onToggle({ id: node.id })\n }\n break\n case 'ArrowRight':\n e.preventDefault()\n e.stopPropagation()\n if (hasChildren && !expanded) {\n handleToggle()\n }\n break\n }\n },\n [expanded, handleSelectClick, handleToggle, hasChildren, node.id, onToggle],\n )\n\n return (\n <div\n aria-expanded={hasChildren ? expanded : undefined}\n aria-level={depth + 1}\n aria-selected={selected}\n className={baseClass}\n onFocus={(e) => {\n if (e.target === e.currentTarget) {\n handleFocus()\n }\n }}\n onKeyDown={handleKeyDown}\n ref={nodeRef}\n role=\"treeitem\"\n style={{ '--tree-depth': depth } as React.CSSProperties}\n tabIndex={tabIndex}\n >\n <div\n className={[\n `${baseClass}__content`,\n 'sidebar-row',\n selected && `${baseClass}__content--selected`,\n selected && 'sidebar-row--selected',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {hasChildren ? (\n <button\n aria-label={expanded ? t('general:collapse') : t('general:open')}\n className={`${baseClass}__toggle`}\n onClick={handleToggle}\n onMouseDown={(e) => e.preventDefault()}\n tabIndex={-1}\n type=\"button\"\n >\n <ChevronIcon direction={expanded ? 'down' : 'right'} />\n </button>\n ) : (\n <div className={`${baseClass}__toggle-spacer`} />\n )}\n {Boolean(icon) && <span className=\"sidebar-row__icon\">{icon}</span>}\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- keyboard handled by parent */}\n <span\n className={`${baseClass}__title sidebar-row__title`}\n onClick={handleSelectClick}\n onMouseDown={(e) => e.preventDefault()}\n title={node.title}\n >\n {node.title}\n </span>\n {isLoading && expanded && (\n <span className={`${baseClass}__loading`}>\n <Spinner loadingText={null} size=\"sm\" />\n </span>\n )}\n </div>\n\n {expanded && children && children.length > 0 && (\n <>\n <div className={`${baseClass}__children`} role=\"group\">\n {children.map((child) => {\n const childData = child as { id: number | string }\n const childId = childData.id\n const childTitle = getDocumentTitle(child, useAsTitle)\n return (\n <TreeNode\n allPossibleTypeValues={allPossibleTypeValues}\n baseFilter={baseFilter}\n cache={cache}\n collectionSlug={collectionSlug}\n depth={depth + 1}\n expandedNodes={expandedNodes}\n filterByCollections={filterByCollections}\n icon={icon}\n key={String(childId)}\n limit={limit}\n node={{\n id: childId,\n hasChildren: true,\n title: childTitle,\n }}\n onSelect={onSelect}\n onToggle={onToggle}\n parentFieldName={parentFieldName}\n selected={String(childId) === String(selectedNodeId)}\n selectedNodeId={selectedNodeId}\n typeFieldName={typeFieldName}\n useAsTitle={useAsTitle}\n />\n )\n })}\n </div>\n {hasMore && (\n <LoadMore\n currentCount={children.length}\n depth={depth + 1}\n id={`load-more-${node.id}`}\n onLoadMore={handleLoadMore}\n totalDocs={totalDocs}\n />\n )}\n </>\n )}\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAEA,OAAOA,KAAA,IAASC,WAAW,EAAEC,MAAM,QAAQ;AAI3C,SAASC,OAAO,QAAQ;AACxB,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAA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5B,MAAM8E,UAAA,GAAalF,gBAAA,CAAiB+E,KAAA,EAAO7E,UAAA;UAC3C,oBACEoE,IAAA,CAAC9D,QAAA;YACCC,qBAAA,EAAuBA,qBAAA;YACvBC,UAAA,EAAYA,UAAA;YACZC,KAAA,EAAOA,KAAA;YACPC,cAAA,EAAgBA,cAAA;YAChBC,KAAA,EAAOA,KAAA,GAAQ;YACfC,aAAA,EAAeA,aAAA;YACfC,mBAAA,EAAqBA,mBAAA;YACrBC,IAAA,EAAMA,IAAA;YAENC,KAAA,EAAOA,KAAA;YACPC,IAAA,EAAM;cACJd,EAAA,EAAI6E,OAAA;cACJ/B,WAAA,EAAa;cACbwB,KAAA,EAAOQ;YACT;YACA/D,QAAA,EAAUA,QAAA;YACVC,QAAA,EAAUA,QAAA;YACVC,eAAA,EAAiBA,eAAA;YACjBC,QAAA,EAAUhB,MAAA,CAAO2E,OAAA,MAAa3E,MAAA,CAAOiB,cAAA;YACrCA,cAAA,EAAgBA,cAAA;YAChBC,aAAA,EAAeA,aAAA;YACftB,UAAA,EAAYA;aAbPI,MAAA,CAAO2E,OAAA;QAgBlB;UAEDlD,OAAA,iBACCuC,IAAA,CAAC5E,QAAA;QACCyF,YAAA,EAAcrD,QAAA,CAASW,MAAM;QAC7B5B,KAAA,EAAOA,KAAA,GAAQ;QACfT,EAAA,EAAI,aAAac,IAAA,CAAKd,EAAE,EAAE;QAC1BgF,UAAA,EAAY7C,cAAA;QACZH,SAAA,EAAWA;;;;AAOzB","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
@layer payload-default {
|
|
2
|
+
.load-more-row {
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
gap: var(--stroke-width-medium);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.load-more-row__text {
|
|
9
|
+
margin: 0;
|
|
10
|
+
color: var(--color-text-secondary);
|
|
11
|
+
white-space: nowrap;
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
gap: var(--spacer-1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.load-more-row__button.btn {
|
|
18
|
+
background-color: transparent;
|
|
19
|
+
padding: 0;
|
|
20
|
+
color: var(--color-text);
|
|
21
|
+
font-size: inherit;
|
|
22
|
+
text-decoration: underline;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.load-more-row__button.btn:hover:not(.btn--disabled) {
|
|
26
|
+
color: var(--color-text-secondary);
|
|
27
|
+
background-color: transparent;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.load-more-row__button.btn:active:not(.btn--disabled) {
|
|
31
|
+
color: var(--color-text);
|
|
32
|
+
background-color: transparent;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/LoadMoreRow/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/LoadMoreRow/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,aAAa,CAAA;AAIpB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,gFAAgF;IAChF,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAChC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAA;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAC3B,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAsClD,CAAA"}
|
|
@@ -5,8 +5,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { useTranslation } from '../../providers/Translation/index.js';
|
|
7
7
|
import { Button } from '../Button/index.js';
|
|
8
|
-
import
|
|
9
|
-
import './index.scss';
|
|
8
|
+
import './index.css';
|
|
10
9
|
const baseClass = 'load-more-row';
|
|
11
10
|
export const LoadMoreRow = t0 => {
|
|
12
11
|
const $ = _c(12);
|
|
@@ -42,20 +41,17 @@ export const LoadMoreRow = t0 => {
|
|
|
42
41
|
} else {
|
|
43
42
|
t3 = $[11];
|
|
44
43
|
}
|
|
45
|
-
t2 =
|
|
44
|
+
t2 = _jsx("div", {
|
|
46
45
|
className: t3.join(" "),
|
|
47
46
|
style,
|
|
48
|
-
children:
|
|
49
|
-
className: `${baseClass}__connector`,
|
|
50
|
-
children: _jsx(TreeConnector, {})
|
|
51
|
-
}), _jsx("p", {
|
|
47
|
+
children: _jsx("p", {
|
|
52
48
|
className: `${baseClass}__text`,
|
|
53
49
|
children: hasMore ? _jsxs(_Fragment, {
|
|
54
50
|
children: ["Showing ", currentCount, " of ", totalDocs, " \u2014 ", loadMoreButton || defaultButton]
|
|
55
51
|
}) : _jsxs(_Fragment, {
|
|
56
52
|
children: ["Showing ", totalDocs, " of ", totalDocs]
|
|
57
53
|
})
|
|
58
|
-
})
|
|
54
|
+
})
|
|
59
55
|
});
|
|
60
56
|
$[0] = className;
|
|
61
57
|
$[1] = currentCount;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","React","useTranslation","Button","
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","React","useTranslation","Button","baseClass","LoadMoreRow","t0","$","className","currentCount","hasMore","isLoading","t1","loadMoreButton","onLoadMore","style","totalDocs","undefined","t","t2","defaultButton","_jsx","buttonStyle","disabled","margin","onClick","children","t3","filter","Boolean","join","_jsxs","_Fragment"],"sources":["../../../src/elements/LoadMoreRow/index.tsx"],"sourcesContent":["'use client'\n\nimport React from 'react'\n\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { Button } from '../Button/index.js'\nimport './index.css'\n\nconst baseClass = 'load-more-row'\n\nexport type LoadMoreRowProps = {\n className?: string\n currentCount: number\n hasMore: boolean\n isLoading?: boolean\n /** Custom button element - if provided, onLoadMore and isLoading are ignored */\n loadMoreButton?: React.ReactNode\n onLoadMore?: () => void\n style?: React.CSSProperties\n totalDocs: number\n}\n\nexport const LoadMoreRow: React.FC<LoadMoreRowProps> = ({\n className,\n currentCount,\n hasMore,\n isLoading = false,\n loadMoreButton,\n onLoadMore,\n style,\n totalDocs,\n}) => {\n const { t } = useTranslation()\n const defaultButton = onLoadMore && (\n <Button\n buttonStyle=\"ghost\"\n className={`${baseClass}__button`}\n disabled={isLoading}\n margin={false}\n onClick={onLoadMore}\n >\n {isLoading ? t('general:loading') : t('general:loadMore')}\n </Button>\n )\n\n return (\n <div className={[baseClass, className].filter(Boolean).join(' ')} style={style}>\n <p className={`${baseClass}__text`}>\n {hasMore ? (\n <>\n Showing {currentCount} of {totalDocs} — {loadMoreButton || defaultButton}\n </>\n ) : (\n <>\n Showing {totalDocs} of {totalDocs}\n </>\n )}\n </p>\n </div>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAEA,OAAOC,KAAA,MAAW;AAElB,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,OAAO;AAEP,MAAMC,SAAA,GAAY;AAclB,OAAO,MAAMC,WAAA,GAA0CC,EAAA;EAAA,MAAAC,CAAA,GAAAP,EAAA;EAAC;IAAAQ,SAAA;IAAAC,YAAA;IAAAC,OAAA;IAAAC,SAAA,EAAAC,EAAA;IAAAC,cAAA;IAAAC,UAAA;IAAAC,KAAA;IAAAC;EAAA,IAAAV,EASvD;EALC,MAAAK,SAAA,GAAAC,EAAiB,KAAAK,SAAA,WAAjBL,EAAiB;EAMjB;IA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
|
7
7
|
margin-bottom: var(--spacer-2);
|
|
8
8
|
}
|
|
9
|
+
|
|
10
|
+
/* Align the label's text with its sibling button labels, which carry a
|
|
11
|
+
var(--spacer-1) inset. The icon variants reserve an extra icon-slot
|
|
12
|
+
inset, so their labels sit one more var(--spacer-1) in. */
|
|
13
|
+
.popup-button-list .popup-list-group-label {
|
|
14
|
+
padding-inline-start: var(--spacer-1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.popup-button-list--with-actions .popup-list-group-label,
|
|
18
|
+
.popup-button-list--with-icons .popup-list-group-label {
|
|
19
|
+
padding-inline-start: calc(var(--spacer-1) * 2);
|
|
20
|
+
}
|
|
9
21
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Where } from 'payload';
|
|
2
|
+
type Args = {
|
|
3
|
+
collectionSlug?: string;
|
|
4
|
+
globalSlug?: string;
|
|
5
|
+
id?: number | string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Builds the `where` query used to find upcoming scheduled
|
|
9
|
+
* publish/unpublish jobs for a given document or global.
|
|
10
|
+
*/
|
|
11
|
+
export declare const buildUpcomingScheduleWhere: ({ id, collectionSlug, globalSlug }: Args) => Where;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=buildUpcomingScheduleWhere.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildUpcomingScheduleWhere.d.ts","sourceRoot":"","sources":["../../../../src/elements/PublishButton/ScheduleDrawer/buildUpcomingScheduleWhere.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,KAAK,IAAI,GAAG;IACV,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACrB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,0BAA0B,GAAI,oCAAoC,IAAI,KAAG,KAsCrF,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the `where` query used to find upcoming scheduled
|
|
3
|
+
* publish/unpublish jobs for a given document or global.
|
|
4
|
+
*/export const buildUpcomingScheduleWhere = ({
|
|
5
|
+
id,
|
|
6
|
+
collectionSlug,
|
|
7
|
+
globalSlug
|
|
8
|
+
}) => {
|
|
9
|
+
const where = {
|
|
10
|
+
and: [{
|
|
11
|
+
taskSlug: {
|
|
12
|
+
equals: 'schedulePublish'
|
|
13
|
+
}
|
|
14
|
+
}, {
|
|
15
|
+
waitUntil: {
|
|
16
|
+
greater_than: new Date()
|
|
17
|
+
}
|
|
18
|
+
}]
|
|
19
|
+
};
|
|
20
|
+
if (collectionSlug) {
|
|
21
|
+
where.and.push({
|
|
22
|
+
'input.doc.value': {
|
|
23
|
+
equals: String(id)
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
where.and.push({
|
|
27
|
+
'input.doc.relationTo': {
|
|
28
|
+
equals: collectionSlug
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (globalSlug) {
|
|
33
|
+
where.and.push({
|
|
34
|
+
'input.global': {
|
|
35
|
+
equals: globalSlug
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return where;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=buildUpcomingScheduleWhere.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildUpcomingScheduleWhere.js","names":["buildUpcomingScheduleWhere","id","collectionSlug","globalSlug","where","and","taskSlug","equals","waitUntil","greater_than","Date","push","String"],"sources":["../../../../src/elements/PublishButton/ScheduleDrawer/buildUpcomingScheduleWhere.ts"],"sourcesContent":["import type { Where } from 'payload'\n\ntype Args = {\n collectionSlug?: string\n globalSlug?: string\n id?: number | string\n}\n\n/**\n * Builds the `where` query used to find upcoming scheduled\n * publish/unpublish jobs for a given document or global.\n */\nexport const buildUpcomingScheduleWhere = ({ id, collectionSlug, globalSlug }: Args): Where => {\n const where: Where = {\n and: [\n {\n taskSlug: {\n equals: 'schedulePublish',\n },\n },\n {\n waitUntil: {\n greater_than: new Date(),\n },\n },\n ],\n }\n\n if (collectionSlug) {\n where.and.push({\n 'input.doc.value': {\n equals: String(id),\n },\n })\n where.and.push({\n 'input.doc.relationTo': {\n equals: collectionSlug,\n },\n })\n }\n\n if (globalSlug) {\n where.and.push({\n 'input.global': {\n equals: globalSlug,\n },\n })\n }\n\n return where\n}\n"],"mappings":"AAQA;;;GAIA,OAAO,MAAMA,0BAAA,GAA6BA,CAAC;EAAEC,EAAE;EAAEC,cAAc;EAAEC;AAAU,CAAQ;EACjF,MAAMC,KAAA,GAAe;IACnBC,GAAA,EAAK,CACH;MACEC,QAAA,EAAU;QACRC,MAAA,EAAQ;MACV;IACF,GACA;MACEC,SAAA,EAAW;QACTC,YAAA,EAAc,IAAIC,IAAA;MACpB;IACF;EAEJ;EAEA,IAAIR,cAAA,EAAgB;IAClBE,KAAA,CAAMC,GAAG,CAACM,IAAI,CAAC;MACb,mBAAmB;QACjBJ,MAAA,EAAQK,MAAA,CAAOX,EAAA;MACjB;IACF;IACAG,KAAA,CAAMC,GAAG,CAACM,IAAI,CAAC;MACb,wBAAwB;QACtBJ,MAAA,EAAQL;MACV;IACF;EACF;EAEA,IAAIC,UAAA,EAAY;IACdC,KAAA,CAAMC,GAAG,CAACM,IAAI,CAAC;MACb,gBAAgB;QACdJ,MAAA,EAAQJ;MACV;IACF;EACF;EAEA,OAAOC,KAAA;AACT","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/PublishButton/ScheduleDrawer/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAU,eAAe,EAAS,MAAM,SAAS,CAAA;AAQ7D,OAAO,KAA+B,MAAM,OAAO,CAAA;AAGnD,OAAO,KAAK,EAAE,WAAW,EAAiB,MAAM,YAAY,CAAA;AAe5D,OAAO,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/PublishButton/ScheduleDrawer/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAU,eAAe,EAAS,MAAM,SAAS,CAAA;AAQ7D,OAAO,KAA+B,MAAM,OAAO,CAAA;AAGnD,OAAO,KAAK,EAAE,WAAW,EAAiB,MAAM,YAAY,CAAA;AAe5D,OAAO,aAAa,CAAA;AAUpB,KAAK,KAAK,GAAG;IACX,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,gBAAgB,CAAC,EAAE,CAAC,WAAW,EAAE,OAAO,KAAK,IAAI,CAAA;IACjD,qBAAqB,CAAC,EAAE,eAAe,CAAA;IACvC,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAOD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAiT1C,CAAA"}
|
|
@@ -28,6 +28,7 @@ import { ShimmerEffect } from '../../ShimmerEffect/index.js';
|
|
|
28
28
|
import { Table } from '../../Table/index.js';
|
|
29
29
|
import { TimezonePicker } from '../../TimezonePicker/index.js';
|
|
30
30
|
import { buildUpcomingColumns } from './buildUpcomingColumns.js';
|
|
31
|
+
import { buildUpcomingScheduleWhere } from './buildUpcomingScheduleWhere.js';
|
|
31
32
|
const baseClass = 'schedule-publish';
|
|
32
33
|
const defaultLocaleOption = {
|
|
33
34
|
label: 'All',
|
|
@@ -36,6 +37,7 @@ const defaultLocaleOption = {
|
|
|
36
37
|
export const ScheduleDrawer = ({
|
|
37
38
|
slug,
|
|
38
39
|
defaultType,
|
|
40
|
+
onUpcomingChange,
|
|
39
41
|
schedulePublishConfig
|
|
40
42
|
}) => {
|
|
41
43
|
const {
|
|
@@ -98,37 +100,12 @@ export const ScheduleDrawer = ({
|
|
|
98
100
|
const fetchUpcoming = React.useCallback(async () => {
|
|
99
101
|
const query = {
|
|
100
102
|
sort: 'waitUntil',
|
|
101
|
-
where: {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}, {
|
|
107
|
-
waitUntil: {
|
|
108
|
-
greater_than: new Date()
|
|
109
|
-
}
|
|
110
|
-
}]
|
|
111
|
-
}
|
|
103
|
+
where: buildUpcomingScheduleWhere({
|
|
104
|
+
id,
|
|
105
|
+
collectionSlug,
|
|
106
|
+
globalSlug
|
|
107
|
+
})
|
|
112
108
|
};
|
|
113
|
-
if (collectionSlug) {
|
|
114
|
-
query.where.and.push({
|
|
115
|
-
'input.doc.value': {
|
|
116
|
-
equals: String(id)
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
query.where.and.push({
|
|
120
|
-
'input.doc.relationTo': {
|
|
121
|
-
equals: collectionSlug
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
if (globalSlug) {
|
|
126
|
-
query.where.and.push({
|
|
127
|
-
'input.global': {
|
|
128
|
-
equals: globalSlug
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
109
|
const {
|
|
133
110
|
docs
|
|
134
111
|
} = await requests.post(formatAdminURL({
|
|
@@ -153,7 +130,8 @@ export const ScheduleDrawer = ({
|
|
|
153
130
|
t
|
|
154
131
|
}));
|
|
155
132
|
setUpcoming(docs);
|
|
156
|
-
|
|
133
|
+
onUpcomingChange?.(docs.length > 0);
|
|
134
|
+
}, [collectionSlug, globalSlug, api, i18n, dateFormat, localization, supportedTimezones, t, id, onUpcomingChange]);
|
|
157
135
|
const deleteHandler = React.useCallback(async id_0 => {
|
|
158
136
|
try {
|
|
159
137
|
await schedulePublish({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["TZDateMini","TZDate","getTranslation","endOfToday","isToday","startOfDay","transpose","formatAdminURL","qs","React","useCallback","useMemo","toast","FieldLabel","Radio","useConfig","useDocumentInfo","useDocumentTitle","useServerFunctions","useTranslation","requests","Banner","Button","DatePickerField","Drawer","Gutter","ReactSelect","ShimmerEffect","Table","TimezonePicker","buildUpcomingColumns","baseClass","defaultLocaleOption","label","value","ScheduleDrawer","slug","defaultType","schedulePublishConfig","config","admin","dateFormat","timezones","defaultTimezone","supportedTimezones","localization","routes","api","id","collectionSlug","globalSlug","title","i18n","t","schedulePublish","type","setType","useState","date","setDate","timezone","setTimezone","locale","setLocale","processing","setProcessing","modalTitle","upcoming","setUpcoming","upcomingColumns","setUpcomingColumns","deleteHandlerRef","useRef","userTimezone","Intl","DateTimeFormat","resolvedOptions","timeZone","localeOptions","options","locales","map","code","unshift","fetchUpcoming","query","sort","where","and","taskSlug","equals","waitUntil","greater_than","Date","push","String","docs","post","apiRoute","path","body","stringify","headers","language","then","res","json","deleteHandler","current","deleteID","success","err","console","error","message","useEffect","handleSave","localeToPublish","doc","relationTo","undefined","global","displayedValue","DateWithOriginalTz","tz","DateWithUserTz","modifiedDate","withTimeZone","dateWithTimezone","dateWithUserTimezone","toISOString","onChangeDate","incomingDate","tzDateWithUTC","dateToUserTz","fetchInitialUpcoming","minTime","_jsxs","className","_jsx","required","isSelected","onChange","option","readOnly","maxTime","minDate","e","pickerAppearance","timeFormat","timeIntervals","length","selectedTimezone","buttonStyle","disabled","onClick","appearance","columns","data"],"sources":["../../../../src/elements/PublishButton/ScheduleDrawer/index.tsx"],"sourcesContent":["/* eslint-disable no-console */\n'use client'\n\nimport type { Column, SchedulePublish, Where } from 'payload'\n\nimport { TZDateMini as TZDate } from '@date-fns/tz/date/mini'\nimport { getTranslation } from '@payloadcms/translations'\nimport { endOfToday, isToday, startOfDay } from 'date-fns'\nimport { transpose } from 'date-fns/transpose'\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { useCallback, useMemo } from 'react'\nimport { toast } from 'sonner'\n\nimport type { PublishType, UpcomingEvent } from './types.js'\n\nimport { FieldLabel } from '../../../fields/FieldLabel/index.js'\nimport { Radio } from '../../../fields/RadioGroup/Radio/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../../providers/DocumentInfo/index.js'\nimport { useDocumentTitle } from '../../../providers/DocumentTitle/index.js'\nimport { useServerFunctions } from '../../../providers/ServerFunctions/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { requests } from '../../../utilities/api.js'\nimport { Banner } from '../../Banner/index.js'\nimport { Button } from '../../Button/index.js'\nimport { DatePickerField } from '../../DatePicker/index.js'\nimport { Drawer } from '../../Drawer/index.js'\nimport { Gutter } from '../../Gutter/index.js'\nimport './index.css'\nimport { ReactSelect } from '../../ReactSelect/index.js'\nimport { ShimmerEffect } from '../../ShimmerEffect/index.js'\nimport { Table } from '../../Table/index.js'\nimport { TimezonePicker } from '../../TimezonePicker/index.js'\nimport { buildUpcomingColumns } from './buildUpcomingColumns.js'\n\nconst baseClass = 'schedule-publish'\n\ntype Props = {\n defaultType?: PublishType\n schedulePublishConfig?: SchedulePublish\n slug: string\n}\n\nconst defaultLocaleOption = {\n label: 'All',\n value: 'all',\n}\n\nexport const ScheduleDrawer: React.FC<Props> = ({ slug, defaultType, schedulePublishConfig }) => {\n const {\n config: {\n admin: {\n dateFormat,\n timezones: { defaultTimezone, supportedTimezones },\n },\n localization,\n routes: { api },\n },\n } = useConfig()\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n const { title } = useDocumentTitle()\n const { i18n, t } = useTranslation()\n const { schedulePublish } = useServerFunctions()\n const [type, setType] = React.useState<PublishType>(defaultType || 'publish')\n const [date, setDate] = React.useState<Date>()\n const [timezone, setTimezone] = React.useState<string>(defaultTimezone)\n const [locale, setLocale] = React.useState<{ label: string; value: string }>(defaultLocaleOption)\n const [processing, setProcessing] = React.useState(false)\n const modalTitle = t('general:schedulePublishFor', { title })\n const [upcoming, setUpcoming] = React.useState<UpcomingEvent[]>()\n const [upcomingColumns, setUpcomingColumns] = React.useState<Column[]>()\n const deleteHandlerRef = React.useRef<((id: number | string) => Promise<void>) | null>(() => null)\n\n // Get the user timezone so we can adjust the displayed value against it\n const userTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone\n\n const localeOptions = React.useMemo(() => {\n if (localization) {\n const options = localization.locales.map(({ code, label }) => ({\n label: getTranslation(label, i18n),\n value: code,\n }))\n\n options.unshift(defaultLocaleOption)\n\n return options\n }\n\n return []\n }, [localization, i18n])\n\n const fetchUpcoming = React.useCallback(async () => {\n const query: { sort: string; where: Where } = {\n sort: 'waitUntil',\n where: {\n and: [\n {\n taskSlug: {\n equals: 'schedulePublish',\n },\n },\n {\n waitUntil: {\n greater_than: new Date(),\n },\n },\n ],\n },\n }\n\n if (collectionSlug) {\n query.where.and.push({\n 'input.doc.value': {\n equals: String(id),\n },\n })\n query.where.and.push({\n 'input.doc.relationTo': {\n equals: collectionSlug,\n },\n })\n }\n\n if (globalSlug) {\n query.where.and.push({\n 'input.global': {\n equals: globalSlug,\n },\n })\n }\n\n const { docs } = await requests\n .post(formatAdminURL({ apiRoute: api, path: `/payload-jobs` }), {\n body: qs.stringify(query),\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/x-www-form-urlencoded',\n 'X-Payload-HTTP-Method-Override': 'GET',\n },\n })\n .then((res) => res.json())\n\n setUpcomingColumns(\n buildUpcomingColumns({\n dateFormat,\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n deleteHandler: deleteHandlerRef.current,\n docs,\n i18n,\n localization,\n supportedTimezones,\n t,\n }),\n )\n setUpcoming(docs)\n }, [collectionSlug, globalSlug, api, i18n, dateFormat, localization, supportedTimezones, t, id])\n\n const deleteHandler = React.useCallback(\n async (id: number | string) => {\n try {\n await schedulePublish({\n deleteID: id,\n })\n await fetchUpcoming()\n toast.success(t('general:deletedSuccessfully'))\n } catch (err) {\n console.error(err)\n toast.error(err.message)\n }\n },\n [fetchUpcoming, schedulePublish, t],\n )\n\n React.useEffect(() => {\n deleteHandlerRef.current = deleteHandler\n }, [deleteHandler])\n\n const handleSave = React.useCallback(async () => {\n if (!date) {\n return toast.error(t('general:noDateSelected'))\n }\n\n setProcessing(true)\n\n let localeToPublish: string\n\n if (typeof locale === 'object' && locale.value !== 'all' && type === 'publish') {\n localeToPublish = locale.value\n }\n\n try {\n await schedulePublish({\n type,\n date,\n doc: collectionSlug\n ? {\n relationTo: collectionSlug,\n value: String(id),\n }\n : undefined,\n global: globalSlug || undefined,\n localeToPublish,\n timezone,\n })\n\n setDate(undefined)\n toast.success(t('version:scheduledSuccessfully'))\n void fetchUpcoming()\n } catch (err) {\n console.error(err)\n toast.error(err.message)\n }\n\n setProcessing(false)\n }, [\n date,\n locale,\n type,\n t,\n schedulePublish,\n collectionSlug,\n id,\n globalSlug,\n timezone,\n fetchUpcoming,\n ])\n\n const displayedValue = useMemo(() => {\n if (timezone && userTimezone && date) {\n // Create TZDate instances for the selected timezone and the user's timezone\n // These instances allow us to transpose the date between timezones while keeping the same time value\n const DateWithOriginalTz = TZDate.tz(timezone)\n const DateWithUserTz = TZDate.tz(userTimezone)\n\n const modifiedDate = new TZDate(date).withTimeZone(timezone)\n\n // Transpose the date to the selected timezone\n const dateWithTimezone = transpose(modifiedDate, DateWithOriginalTz)\n\n // Transpose the date to the user's timezone - this is necessary because the react-datepicker component insists on displaying the date in the user's timezone\n const dateWithUserTimezone = transpose(dateWithTimezone, DateWithUserTz)\n\n return dateWithUserTimezone.toISOString()\n }\n\n return date\n }, [timezone, date, userTimezone])\n\n const onChangeDate = useCallback(\n (incomingDate: Date) => {\n if (timezone && incomingDate) {\n // Create TZDate instances for the selected timezone\n const tzDateWithUTC = TZDate.tz(timezone)\n\n // Creates a TZDate instance for the user's timezone — this is default behaviour of TZDate as it wraps the Date constructor\n const dateToUserTz = new TZDate(incomingDate)\n\n // Transpose the date to the selected timezone\n const dateWithTimezone = transpose(dateToUserTz, tzDateWithUTC)\n\n setDate(dateWithTimezone || null)\n } else {\n setDate(incomingDate || null)\n }\n },\n [setDate, timezone],\n )\n\n React.useEffect(() => {\n if (!upcoming) {\n const fetchInitialUpcoming = async () => {\n await fetchUpcoming()\n }\n\n void fetchInitialUpcoming()\n }\n }, [upcoming, fetchUpcoming])\n\n const minTime = useMemo(() => {\n if (date && isToday(date)) {\n return new Date()\n }\n\n return startOfDay(new Date())\n }, [date])\n\n return (\n <Drawer className={baseClass} slug={slug} title={modalTitle}>\n <Gutter className={`${baseClass}__scheduler`}>\n <div className={`${baseClass}__section`}>\n <FieldLabel label={t('version:type')} required />\n <ul className={`${baseClass}__type`}>\n <li>\n <Radio\n id={`${slug}-type`}\n isSelected={type === 'publish'}\n onChange={() => setType('publish')}\n option={{ label: t('version:publish'), value: 'publish' }}\n path={`${slug}-type`}\n readOnly={processing}\n />\n </li>\n <li>\n <Radio\n id={`${slug}-type`}\n isSelected={type === 'unpublish'}\n onChange={() => setType('unpublish')}\n option={{ label: t('version:unpublish'), value: 'unpublish' }}\n path={`${slug}-type`}\n readOnly={processing}\n />\n </li>\n </ul>\n </div>\n <div className={`${baseClass}__section`}>\n <FieldLabel label={t('general:time')} path={'time'} required />\n <DatePickerField\n id=\"time\"\n maxTime={endOfToday()}\n minDate={new Date()}\n minTime={minTime}\n onChange={(e) => onChangeDate(e)}\n pickerAppearance=\"dayAndTime\"\n readOnly={processing}\n timeFormat={schedulePublishConfig?.timeFormat}\n timeIntervals={schedulePublishConfig?.timeIntervals ?? 5}\n value={displayedValue}\n />\n {supportedTimezones.length > 0 && (\n <TimezonePicker\n id={`timezone-picker`}\n onChange={setTimezone}\n options={supportedTimezones}\n selectedTimezone={timezone}\n />\n )}\n </div>\n {localeOptions.length > 0 && type === 'publish' && (\n <div className={`${baseClass}__section`}>\n <FieldLabel label={t('localization:localeToPublish')} />\n <ReactSelect\n onChange={(e) => setLocale(e as { label: string; value: string })}\n options={localeOptions}\n value={locale}\n />\n </div>\n )}\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"primary\"\n disabled={processing}\n id=\"scheduled-publish-save\"\n onClick={handleSave}\n type=\"button\"\n >\n {t('general:save')}\n </Button>\n {processing ? <span>{t('general:saving')}</span> : null}\n </div>\n </Gutter>\n <Gutter className={`${baseClass}__upcoming`}>\n <h4>{t('general:upcomingEvents')}</h4>\n {!upcoming && <ShimmerEffect />}\n {upcoming?.length === 0 && <Banner>{t('general:noUpcomingEventsScheduled')}</Banner>}\n {upcoming?.length > 0 && (\n <Table appearance=\"condensed\" columns={upcomingColumns} data={upcoming} />\n )}\n </Gutter>\n </Drawer>\n )\n}\n"],"mappings":"AAAA,+BACA;;;AAIA,SAASA,UAAA,IAAcC,MAAM,QAAQ;AACrC,SAASC,cAAc,QAAQ;AAC/B,SAASC,UAAU,EAAEC,OAAO,EAAEC,UAAU,QAAQ;AAChD,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,WAAW,EAAEC,OAAO,QAAQ;AAC5C,SAASC,KAAK,QAAQ;AAItB,SAASC,UAAU,QAAQ;AAC3B,SAASC,KAAK,QAAQ;AACtB,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAQ;AAChC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,MAAM,QAAQ;AACvB,SAASC,MAAM,QAAQ;AACvB,SAASC,eAAe,QAAQ;AAChC,SAASC,MAAM,QAAQ;AACvB,SAASC,MAAM,QAAQ;AACvB,OAAO;AACP,SAASC,WAAW,QAAQ;AAC5B,SAASC,aAAa,QAAQ;AAC9B,SAASC,KAAK,QAAQ;AACtB,SAASC,cAAc,QAAQ;AAC/B,SAASC,oBAAoB,QAAQ;AAErC,MAAMC,SAAA,GAAY;AAQlB,MAAMC,mBAAA,GAAsB;EAC1BC,KAAA,EAAO;EACPC,KAAA,EAAO;AACT;AAEA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OAAA,EAASxF,eAAA;QAAiByF,IAAA,EAAM3F;;;;AAKxE","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["TZDateMini","TZDate","getTranslation","endOfToday","isToday","startOfDay","transpose","formatAdminURL","qs","React","useCallback","useMemo","toast","FieldLabel","Radio","useConfig","useDocumentInfo","useDocumentTitle","useServerFunctions","useTranslation","requests","Banner","Button","DatePickerField","Drawer","Gutter","ReactSelect","ShimmerEffect","Table","TimezonePicker","buildUpcomingColumns","buildUpcomingScheduleWhere","baseClass","defaultLocaleOption","label","value","ScheduleDrawer","slug","defaultType","onUpcomingChange","schedulePublishConfig","config","admin","dateFormat","timezones","defaultTimezone","supportedTimezones","localization","routes","api","id","collectionSlug","globalSlug","title","i18n","t","schedulePublish","type","setType","useState","date","setDate","timezone","setTimezone","locale","setLocale","processing","setProcessing","modalTitle","upcoming","setUpcoming","upcomingColumns","setUpcomingColumns","deleteHandlerRef","useRef","userTimezone","Intl","DateTimeFormat","resolvedOptions","timeZone","localeOptions","options","locales","map","code","unshift","fetchUpcoming","query","sort","where","docs","post","apiRoute","path","body","stringify","headers","language","then","res","json","deleteHandler","current","length","deleteID","success","err","console","error","message","useEffect","handleSave","localeToPublish","doc","relationTo","String","undefined","global","displayedValue","DateWithOriginalTz","tz","DateWithUserTz","modifiedDate","withTimeZone","dateWithTimezone","dateWithUserTimezone","toISOString","onChangeDate","incomingDate","tzDateWithUTC","dateToUserTz","fetchInitialUpcoming","minTime","Date","_jsxs","className","_jsx","required","isSelected","onChange","option","readOnly","maxTime","minDate","e","pickerAppearance","timeFormat","timeIntervals","selectedTimezone","buttonStyle","disabled","onClick","appearance","columns","data"],"sources":["../../../../src/elements/PublishButton/ScheduleDrawer/index.tsx"],"sourcesContent":["/* eslint-disable no-console */\n'use client'\n\nimport type { Column, SchedulePublish, Where } from 'payload'\n\nimport { TZDateMini as TZDate } from '@date-fns/tz/date/mini'\nimport { getTranslation } from '@payloadcms/translations'\nimport { endOfToday, isToday, startOfDay } from 'date-fns'\nimport { transpose } from 'date-fns/transpose'\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { useCallback, useMemo } from 'react'\nimport { toast } from 'sonner'\n\nimport type { PublishType, UpcomingEvent } from './types.js'\n\nimport { FieldLabel } from '../../../fields/FieldLabel/index.js'\nimport { Radio } from '../../../fields/RadioGroup/Radio/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../../providers/DocumentInfo/index.js'\nimport { useDocumentTitle } from '../../../providers/DocumentTitle/index.js'\nimport { useServerFunctions } from '../../../providers/ServerFunctions/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { requests } from '../../../utilities/api.js'\nimport { Banner } from '../../Banner/index.js'\nimport { Button } from '../../Button/index.js'\nimport { DatePickerField } from '../../DatePicker/index.js'\nimport { Drawer } from '../../Drawer/index.js'\nimport { Gutter } from '../../Gutter/index.js'\nimport './index.css'\nimport { ReactSelect } from '../../ReactSelect/index.js'\nimport { ShimmerEffect } from '../../ShimmerEffect/index.js'\nimport { Table } from '../../Table/index.js'\nimport { TimezonePicker } from '../../TimezonePicker/index.js'\nimport { buildUpcomingColumns } from './buildUpcomingColumns.js'\nimport { buildUpcomingScheduleWhere } from './buildUpcomingScheduleWhere.js'\n\nconst baseClass = 'schedule-publish'\n\ntype Props = {\n defaultType?: PublishType\n onUpcomingChange?: (hasUpcoming: boolean) => void\n schedulePublishConfig?: SchedulePublish\n slug: string\n}\n\nconst defaultLocaleOption = {\n label: 'All',\n value: 'all',\n}\n\nexport const ScheduleDrawer: React.FC<Props> = ({\n slug,\n defaultType,\n onUpcomingChange,\n schedulePublishConfig,\n}) => {\n const {\n config: {\n admin: {\n dateFormat,\n timezones: { defaultTimezone, supportedTimezones },\n },\n localization,\n routes: { api },\n },\n } = useConfig()\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n const { title } = useDocumentTitle()\n const { i18n, t } = useTranslation()\n const { schedulePublish } = useServerFunctions()\n const [type, setType] = React.useState<PublishType>(defaultType || 'publish')\n const [date, setDate] = React.useState<Date>()\n const [timezone, setTimezone] = React.useState<string>(defaultTimezone)\n const [locale, setLocale] = React.useState<{ label: string; value: string }>(defaultLocaleOption)\n const [processing, setProcessing] = React.useState(false)\n const modalTitle = t('general:schedulePublishFor', { title })\n const [upcoming, setUpcoming] = React.useState<UpcomingEvent[]>()\n const [upcomingColumns, setUpcomingColumns] = React.useState<Column[]>()\n const deleteHandlerRef = React.useRef<((id: number | string) => Promise<void>) | null>(() => null)\n\n // Get the user timezone so we can adjust the displayed value against it\n const userTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone\n\n const localeOptions = React.useMemo(() => {\n if (localization) {\n const options = localization.locales.map(({ code, label }) => ({\n label: getTranslation(label, i18n),\n value: code,\n }))\n\n options.unshift(defaultLocaleOption)\n\n return options\n }\n\n return []\n }, [localization, i18n])\n\n const fetchUpcoming = React.useCallback(async () => {\n const query: { sort: string; where: Where } = {\n sort: 'waitUntil',\n where: buildUpcomingScheduleWhere({ id, collectionSlug, globalSlug }),\n }\n\n const { docs } = await requests\n .post(formatAdminURL({ apiRoute: api, path: `/payload-jobs` }), {\n body: qs.stringify(query),\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/x-www-form-urlencoded',\n 'X-Payload-HTTP-Method-Override': 'GET',\n },\n })\n .then((res) => res.json())\n\n setUpcomingColumns(\n buildUpcomingColumns({\n dateFormat,\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n deleteHandler: deleteHandlerRef.current,\n docs,\n i18n,\n localization,\n supportedTimezones,\n t,\n }),\n )\n setUpcoming(docs)\n onUpcomingChange?.(docs.length > 0)\n }, [\n collectionSlug,\n globalSlug,\n api,\n i18n,\n dateFormat,\n localization,\n supportedTimezones,\n t,\n id,\n onUpcomingChange,\n ])\n\n const deleteHandler = React.useCallback(\n async (id: number | string) => {\n try {\n await schedulePublish({\n deleteID: id,\n })\n await fetchUpcoming()\n toast.success(t('general:deletedSuccessfully'))\n } catch (err) {\n console.error(err)\n toast.error(err.message)\n }\n },\n [fetchUpcoming, schedulePublish, t],\n )\n\n React.useEffect(() => {\n deleteHandlerRef.current = deleteHandler\n }, [deleteHandler])\n\n const handleSave = React.useCallback(async () => {\n if (!date) {\n return toast.error(t('general:noDateSelected'))\n }\n\n setProcessing(true)\n\n let localeToPublish: string\n\n if (typeof locale === 'object' && locale.value !== 'all' && type === 'publish') {\n localeToPublish = locale.value\n }\n\n try {\n await schedulePublish({\n type,\n date,\n doc: collectionSlug\n ? {\n relationTo: collectionSlug,\n value: String(id),\n }\n : undefined,\n global: globalSlug || undefined,\n localeToPublish,\n timezone,\n })\n\n setDate(undefined)\n toast.success(t('version:scheduledSuccessfully'))\n void fetchUpcoming()\n } catch (err) {\n console.error(err)\n toast.error(err.message)\n }\n\n setProcessing(false)\n }, [\n date,\n locale,\n type,\n t,\n schedulePublish,\n collectionSlug,\n id,\n globalSlug,\n timezone,\n fetchUpcoming,\n ])\n\n const displayedValue = useMemo(() => {\n if (timezone && userTimezone && date) {\n // Create TZDate instances for the selected timezone and the user's timezone\n // These instances allow us to transpose the date between timezones while keeping the same time value\n const DateWithOriginalTz = TZDate.tz(timezone)\n const DateWithUserTz = TZDate.tz(userTimezone)\n\n const modifiedDate = new TZDate(date).withTimeZone(timezone)\n\n // Transpose the date to the selected timezone\n const dateWithTimezone = transpose(modifiedDate, DateWithOriginalTz)\n\n // Transpose the date to the user's timezone - this is necessary because the react-datepicker component insists on displaying the date in the user's timezone\n const dateWithUserTimezone = transpose(dateWithTimezone, DateWithUserTz)\n\n return dateWithUserTimezone.toISOString()\n }\n\n return date\n }, [timezone, date, userTimezone])\n\n const onChangeDate = useCallback(\n (incomingDate: Date) => {\n if (timezone && incomingDate) {\n // Create TZDate instances for the selected timezone\n const tzDateWithUTC = TZDate.tz(timezone)\n\n // Creates a TZDate instance for the user's timezone — this is default behaviour of TZDate as it wraps the Date constructor\n const dateToUserTz = new TZDate(incomingDate)\n\n // Transpose the date to the selected timezone\n const dateWithTimezone = transpose(dateToUserTz, tzDateWithUTC)\n\n setDate(dateWithTimezone || null)\n } else {\n setDate(incomingDate || null)\n }\n },\n [setDate, timezone],\n )\n\n React.useEffect(() => {\n if (!upcoming) {\n const fetchInitialUpcoming = async () => {\n await fetchUpcoming()\n }\n\n void fetchInitialUpcoming()\n }\n }, [upcoming, fetchUpcoming])\n\n const minTime = useMemo(() => {\n if (date && isToday(date)) {\n return new Date()\n }\n\n return startOfDay(new Date())\n }, [date])\n\n return (\n <Drawer className={baseClass} slug={slug} title={modalTitle}>\n <Gutter className={`${baseClass}__scheduler`}>\n <div className={`${baseClass}__section`}>\n <FieldLabel label={t('version:type')} required />\n <ul className={`${baseClass}__type`}>\n <li>\n <Radio\n id={`${slug}-type`}\n isSelected={type === 'publish'}\n onChange={() => setType('publish')}\n option={{ label: t('version:publish'), value: 'publish' }}\n path={`${slug}-type`}\n readOnly={processing}\n />\n </li>\n <li>\n <Radio\n id={`${slug}-type`}\n isSelected={type === 'unpublish'}\n onChange={() => setType('unpublish')}\n option={{ label: t('version:unpublish'), value: 'unpublish' }}\n path={`${slug}-type`}\n readOnly={processing}\n />\n </li>\n </ul>\n </div>\n <div className={`${baseClass}__section`}>\n <FieldLabel label={t('general:time')} path={'time'} required />\n <DatePickerField\n id=\"time\"\n maxTime={endOfToday()}\n minDate={new Date()}\n minTime={minTime}\n onChange={(e) => onChangeDate(e)}\n pickerAppearance=\"dayAndTime\"\n readOnly={processing}\n timeFormat={schedulePublishConfig?.timeFormat}\n timeIntervals={schedulePublishConfig?.timeIntervals ?? 5}\n value={displayedValue}\n />\n {supportedTimezones.length > 0 && (\n <TimezonePicker\n id={`timezone-picker`}\n onChange={setTimezone}\n options={supportedTimezones}\n selectedTimezone={timezone}\n />\n )}\n </div>\n {localeOptions.length > 0 && type === 'publish' && (\n <div className={`${baseClass}__section`}>\n <FieldLabel label={t('localization:localeToPublish')} />\n <ReactSelect\n onChange={(e) => setLocale(e as { label: string; value: string })}\n options={localeOptions}\n value={locale}\n />\n </div>\n )}\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"primary\"\n disabled={processing}\n id=\"scheduled-publish-save\"\n onClick={handleSave}\n type=\"button\"\n >\n {t('general:save')}\n </Button>\n {processing ? <span>{t('general:saving')}</span> : null}\n </div>\n </Gutter>\n <Gutter className={`${baseClass}__upcoming`}>\n <h4>{t('general:upcomingEvents')}</h4>\n {!upcoming && <ShimmerEffect />}\n {upcoming?.length === 0 && <Banner>{t('general:noUpcomingEventsScheduled')}</Banner>}\n {upcoming?.length > 0 && (\n <Table appearance=\"condensed\" columns={upcomingColumns} data={upcoming} />\n )}\n </Gutter>\n </Drawer>\n )\n}\n"],"mappings":"AAAA,+BACA;;;AAIA,SAASA,UAAA,IAAcC,MAAM,QAAQ;AACrC,SAASC,cAAc,QAAQ;AAC/B,SAASC,UAAU,EAAEC,OAAO,EAAEC,UAAU,QAAQ;AAChD,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,WAAW,EAAEC,OAAO,QAAQ;AAC5C,SAASC,KAAK,QAAQ;AAItB,SAASC,UAAU,QAAQ;AAC3B,SAASC,KAAK,QAAQ;AACtB,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAQ;AAChC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,MAAM,QAAQ;AACvB,SAASC,MAAM,QAAQ;AACvB,SAASC,eAAe,QAAQ;AAChC,SAASC,MAAM,QAAQ;AACvB,SAASC,MAAM,QAAQ;AACvB,OAAO;AACP,SAASC,WAAW,QAAQ;AAC5B,SAASC,aAAa,QAAQ;AAC9B,SAASC,KAAK,QAAQ;AACtB,SAASC,cAAc,QAAQ;AAC/B,SAASC,oB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,CAAA;AAa/D,OAAO,aAAa,CAAA;AAEpB,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EAAE,SAAS,GACjB,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,wBAA6B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/PublishButton/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAKvD,OAAO,KAA2C,MAAM,OAAO,CAAA;AAa/D,OAAO,aAAa,CAAA;AAEpB,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EAAE,SAAS,GACjB,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,wBAA6B,qBAiRpD"}
|