@payloadcms/next 3.80.0-internal.21e9c47 → 3.80.0-internal.60d6f94
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/elements/Nav/getNavPrefs.d.ts.map +1 -1
- package/dist/elements/Nav/getNavPrefs.js +2 -36
- package/dist/elements/Nav/getNavPrefs.js.map +1 -1
- package/dist/elements/Nav/index.client.d.ts.map +1 -1
- package/dist/elements/Nav/index.client.js +44 -27
- package/dist/elements/Nav/index.client.js.map +1 -1
- package/dist/elements/Nav/index.d.ts.map +1 -1
- package/dist/elements/Nav/index.js +7 -34
- package/dist/elements/Nav/index.js.map +1 -1
- package/dist/exports/client.d.ts +1 -2
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +1 -2
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/rsc.d.ts +1 -2
- package/dist/exports/rsc.d.ts.map +1 -1
- package/dist/exports/rsc.js +1 -2
- package/dist/exports/rsc.js.map +1 -1
- package/dist/exports/utilities.d.ts +0 -2
- package/dist/exports/utilities.d.ts.map +1 -1
- package/dist/exports/utilities.js +0 -1
- package/dist/exports/utilities.js.map +1 -1
- package/dist/prod/styles.css +1 -1
- package/dist/utilities/handleServerFunctions.js +2 -2
- package/dist/utilities/handleServerFunctions.js.map +1 -1
- package/dist/views/BrowseByFolder/buildView.d.ts +13 -0
- package/dist/views/BrowseByFolder/buildView.d.ts.map +1 -0
- package/dist/views/BrowseByFolder/buildView.js +170 -0
- package/dist/views/BrowseByFolder/buildView.js.map +1 -0
- package/dist/views/BrowseByFolder/index.d.ts +4 -0
- package/dist/views/BrowseByFolder/index.d.ts.map +1 -0
- package/dist/views/BrowseByFolder/index.js +20 -0
- package/dist/views/BrowseByFolder/index.js.map +1 -0
- package/dist/views/BrowseByFolder/metadata.d.ts +4 -0
- package/dist/views/BrowseByFolder/metadata.d.ts.map +1 -0
- package/dist/views/BrowseByFolder/metadata.js +18 -0
- package/dist/views/BrowseByFolder/metadata.js.map +1 -0
- package/dist/views/CollectionFolders/buildView.d.ts +15 -0
- package/dist/views/CollectionFolders/buildView.d.ts.map +1 -0
- package/dist/views/CollectionFolders/buildView.js +156 -0
- package/dist/views/CollectionFolders/buildView.js.map +1 -0
- package/dist/views/CollectionFolders/index.d.ts +4 -0
- package/dist/views/CollectionFolders/index.d.ts.map +1 -0
- package/dist/views/CollectionFolders/index.js +20 -0
- package/dist/views/CollectionFolders/index.js.map +1 -0
- package/dist/views/CollectionFolders/metadata.d.ts +7 -0
- package/dist/views/CollectionFolders/metadata.d.ts.map +1 -0
- package/dist/views/CollectionFolders/metadata.js +25 -0
- package/dist/views/CollectionFolders/metadata.js.map +1 -0
- package/dist/views/CollectionFolders/renderFolderViewSlots.d.ts +11 -0
- package/dist/views/CollectionFolders/renderFolderViewSlots.d.ts.map +1 -0
- package/dist/views/CollectionFolders/renderFolderViewSlots.js +64 -0
- package/dist/views/CollectionFolders/renderFolderViewSlots.js.map +1 -0
- package/dist/views/Document/renderDocumentSlots.d.ts.map +1 -1
- package/dist/views/Document/renderDocumentSlots.js +0 -8
- package/dist/views/Document/renderDocumentSlots.js.map +1 -1
- package/dist/views/List/index.d.ts.map +1 -1
- package/dist/views/List/index.js +28 -81
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/Root/getRouteData.d.ts +4 -1
- package/dist/views/Root/getRouteData.d.ts.map +1 -1
- package/dist/views/Root/getRouteData.js +91 -27
- package/dist/views/Root/getRouteData.js.map +1 -1
- package/dist/views/Root/index.d.ts.map +1 -1
- package/dist/views/Root/index.js +11 -5
- package/dist/views/Root/index.js.map +1 -1
- package/dist/views/Root/metadata.d.ts.map +1 -1
- package/dist/views/Root/metadata.js +37 -1
- package/dist/views/Root/metadata.js.map +1 -1
- package/package.json +7 -7
- package/dist/elements/HierarchyTypeField/index.d.ts +0 -9
- package/dist/elements/HierarchyTypeField/index.d.ts.map +0 -1
- package/dist/elements/HierarchyTypeField/index.js +0 -114
- package/dist/elements/HierarchyTypeField/index.js.map +0 -1
- package/dist/elements/HierarchyTypeField/index.server.d.ts +0 -9
- package/dist/elements/HierarchyTypeField/index.server.d.ts.map +0 -1
- package/dist/elements/HierarchyTypeField/index.server.js +0 -32
- package/dist/elements/HierarchyTypeField/index.server.js.map +0 -1
- package/dist/elements/Nav/SidebarTabs/TabError/index.d.ts +0 -8
- package/dist/elements/Nav/SidebarTabs/TabError/index.d.ts.map +0 -1
- package/dist/elements/Nav/SidebarTabs/TabError/index.js +0 -42
- package/dist/elements/Nav/SidebarTabs/TabError/index.js.map +0 -1
- package/dist/elements/Nav/SidebarTabs/constants.d.ts +0 -2
- package/dist/elements/Nav/SidebarTabs/constants.d.ts.map +0 -1
- package/dist/elements/Nav/SidebarTabs/constants.js +0 -2
- package/dist/elements/Nav/SidebarTabs/constants.js.map +0 -1
- package/dist/elements/Nav/SidebarTabs/index.client.d.ts +0 -20
- package/dist/elements/Nav/SidebarTabs/index.client.d.ts.map +0 -1
- package/dist/elements/Nav/SidebarTabs/index.client.js +0 -155
- package/dist/elements/Nav/SidebarTabs/index.client.js.map +0 -1
- package/dist/elements/Nav/SidebarTabs/index.d.ts +0 -17
- package/dist/elements/Nav/SidebarTabs/index.d.ts.map +0 -1
- package/dist/elements/Nav/SidebarTabs/index.js +0 -80
- package/dist/elements/Nav/SidebarTabs/index.js.map +0 -1
- package/dist/elements/Nav/SidebarTabs/renderTabServerFn.d.ts +0 -10
- package/dist/elements/Nav/SidebarTabs/renderTabServerFn.d.ts.map +0 -1
- package/dist/elements/Nav/SidebarTabs/renderTabServerFn.js +0 -53
- package/dist/elements/Nav/SidebarTabs/renderTabServerFn.js.map +0 -1
- package/dist/utilities/getHierarchyAncestry.d.ts +0 -24
- package/dist/utilities/getHierarchyAncestry.d.ts.map +0 -1
- package/dist/utilities/getHierarchyAncestry.js +0 -103
- package/dist/utilities/getHierarchyAncestry.js.map +0 -1
- package/dist/views/List/handleHierarchy.d.ts +0 -17
- package/dist/views/List/handleHierarchy.d.ts.map +0 -1
- package/dist/views/List/handleHierarchy.js +0 -243
- package/dist/views/List/handleHierarchy.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/next",
|
|
3
|
-
"version": "3.80.0-internal.
|
|
3
|
+
"version": "3.80.0-internal.60d6f94",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -99,9 +99,9 @@
|
|
|
99
99
|
"qs-esm": "7.0.2",
|
|
100
100
|
"sass": "1.77.4",
|
|
101
101
|
"uuid": "10.0.0",
|
|
102
|
-
"@payloadcms/graphql": "3.80.0-internal.
|
|
103
|
-
"@payloadcms/translations": "3.80.0-internal.
|
|
104
|
-
"@payloadcms/ui": "3.80.0-internal.
|
|
102
|
+
"@payloadcms/graphql": "3.80.0-internal.60d6f94",
|
|
103
|
+
"@payloadcms/translations": "3.80.0-internal.60d6f94",
|
|
104
|
+
"@payloadcms/ui": "3.80.0-internal.60d6f94"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
107
|
"@babel/cli": "7.27.2",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"@babel/preset-env": "7.27.2",
|
|
110
110
|
"@babel/preset-react": "7.27.1",
|
|
111
111
|
"@babel/preset-typescript": "7.27.1",
|
|
112
|
-
"@next/eslint-plugin-next": "16.2.0-canary.
|
|
112
|
+
"@next/eslint-plugin-next": "16.2.0-canary.90",
|
|
113
113
|
"@types/busboy": "1.5.4",
|
|
114
114
|
"@types/react": "19.2.9",
|
|
115
115
|
"@types/react-dom": "19.2.3",
|
|
@@ -119,12 +119,12 @@
|
|
|
119
119
|
"esbuild-sass-plugin": "3.3.1",
|
|
120
120
|
"swc-plugin-transform-remove-imports": "8.3.0",
|
|
121
121
|
"@payloadcms/eslint-config": "3.28.0",
|
|
122
|
-
"payload": "3.80.0-internal.
|
|
122
|
+
"payload": "3.80.0-internal.60d6f94"
|
|
123
123
|
},
|
|
124
124
|
"peerDependencies": {
|
|
125
125
|
"graphql": "^16.8.1",
|
|
126
126
|
"next": ">=15.2.9 <15.3.0 || >=15.3.9 <15.4.0 || >=15.4.11 <15.5.0 || >=16.2.0-canary.10 <17.0.0",
|
|
127
|
-
"payload": "3.80.0-internal.
|
|
127
|
+
"payload": "3.80.0-internal.60d6f94"
|
|
128
128
|
},
|
|
129
129
|
"engines": {
|
|
130
130
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Option, SelectFieldClientProps } from 'payload';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
type HierarchyTypeFieldProps = {
|
|
4
|
-
options: Option[];
|
|
5
|
-
parentFieldName: string;
|
|
6
|
-
} & SelectFieldClientProps;
|
|
7
|
-
export declare const HierarchyTypeField: React.FC<HierarchyTypeFieldProps>;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/HierarchyTypeField/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAgB,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAS3E,OAAO,KAA+B,MAAM,OAAO,CAAA;AAEnD,KAAK,uBAAuB,GAAG;IAC7B,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,eAAe,EAAE,MAAM,CAAA;CACxB,GAAG,sBAAsB,CAAA;AAE1B,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAyHhE,CAAA"}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
import { formatOptions, mergeFieldStyles, SelectInput, useField, useHierarchy } from '@payloadcms/ui';
|
|
5
|
-
import React, { useCallback, useMemo } from 'react';
|
|
6
|
-
export const HierarchyTypeField = ({
|
|
7
|
-
options: allSelectOptions,
|
|
8
|
-
parentFieldName,
|
|
9
|
-
...props
|
|
10
|
-
}) => {
|
|
11
|
-
const {
|
|
12
|
-
field,
|
|
13
|
-
field: {
|
|
14
|
-
name,
|
|
15
|
-
admin: {
|
|
16
|
-
className,
|
|
17
|
-
isClearable = true,
|
|
18
|
-
isSortable = true,
|
|
19
|
-
placeholder
|
|
20
|
-
} = {},
|
|
21
|
-
hasMany = false,
|
|
22
|
-
label,
|
|
23
|
-
localized,
|
|
24
|
-
required
|
|
25
|
-
},
|
|
26
|
-
onChange: onChangeFromProps,
|
|
27
|
-
path: pathFromProps,
|
|
28
|
-
readOnly,
|
|
29
|
-
validate
|
|
30
|
-
} = props;
|
|
31
|
-
const {
|
|
32
|
-
allowedCollections
|
|
33
|
-
} = useHierarchy();
|
|
34
|
-
const options = useMemo(() => {
|
|
35
|
-
if (!allowedCollections || allowedCollections.length === 0) {
|
|
36
|
-
return formatOptions(allSelectOptions);
|
|
37
|
-
}
|
|
38
|
-
return formatOptions(allSelectOptions.filter(option => {
|
|
39
|
-
if (typeof option === 'object' && 'value' in option && option.value) {
|
|
40
|
-
return allowedCollections.some(c => c.slug === option.value);
|
|
41
|
-
}
|
|
42
|
-
return true;
|
|
43
|
-
}));
|
|
44
|
-
}, [allSelectOptions, allowedCollections]);
|
|
45
|
-
const {
|
|
46
|
-
customComponents: {
|
|
47
|
-
AfterInput,
|
|
48
|
-
BeforeInput,
|
|
49
|
-
Description,
|
|
50
|
-
Error,
|
|
51
|
-
Label
|
|
52
|
-
} = {},
|
|
53
|
-
disabled,
|
|
54
|
-
path,
|
|
55
|
-
selectFilterOptions,
|
|
56
|
-
setValue,
|
|
57
|
-
showError,
|
|
58
|
-
value
|
|
59
|
-
} = useField({
|
|
60
|
-
potentiallyStalePath: pathFromProps,
|
|
61
|
-
validate
|
|
62
|
-
});
|
|
63
|
-
const onChange = useCallback(selectedOption => {
|
|
64
|
-
if (readOnly || disabled) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
let newValue = null;
|
|
68
|
-
if (selectedOption && hasMany) {
|
|
69
|
-
if (Array.isArray(selectedOption)) {
|
|
70
|
-
newValue = selectedOption.map(option_0 => option_0.value);
|
|
71
|
-
} else {
|
|
72
|
-
newValue = [];
|
|
73
|
-
}
|
|
74
|
-
} else if (selectedOption && !Array.isArray(selectedOption)) {
|
|
75
|
-
newValue = selectedOption.value;
|
|
76
|
-
}
|
|
77
|
-
if (typeof onChangeFromProps === 'function') {
|
|
78
|
-
onChangeFromProps(newValue);
|
|
79
|
-
}
|
|
80
|
-
setValue(newValue);
|
|
81
|
-
}, [readOnly, disabled, hasMany, setValue, onChangeFromProps]);
|
|
82
|
-
const styles = useMemo(() => mergeFieldStyles(field), [field]);
|
|
83
|
-
const isRequired = required || Array.isArray(allowedCollections) && allowedCollections.length > 0;
|
|
84
|
-
return /*#__PURE__*/_jsx("div", {
|
|
85
|
-
children: /*#__PURE__*/_jsx(SelectInput, {
|
|
86
|
-
AfterInput: AfterInput,
|
|
87
|
-
BeforeInput: BeforeInput,
|
|
88
|
-
className: className,
|
|
89
|
-
Description: Description,
|
|
90
|
-
description: "Select the collection types this item can contain",
|
|
91
|
-
Error: Error,
|
|
92
|
-
filterOption: selectFilterOptions ? ({
|
|
93
|
-
value: optionValue
|
|
94
|
-
}) => selectFilterOptions?.some(option_1 => (typeof option_1 === 'string' ? option_1 : option_1.value) === optionValue) : undefined,
|
|
95
|
-
hasMany: hasMany,
|
|
96
|
-
isClearable: isClearable,
|
|
97
|
-
isSortable: isSortable,
|
|
98
|
-
Label: Label,
|
|
99
|
-
label: label,
|
|
100
|
-
localized: localized,
|
|
101
|
-
name: name,
|
|
102
|
-
onChange: onChange,
|
|
103
|
-
options: options,
|
|
104
|
-
path: path,
|
|
105
|
-
placeholder: placeholder,
|
|
106
|
-
readOnly: readOnly || disabled,
|
|
107
|
-
required: isRequired,
|
|
108
|
-
showError: showError,
|
|
109
|
-
style: styles,
|
|
110
|
-
value: value
|
|
111
|
-
})
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["formatOptions","mergeFieldStyles","SelectInput","useField","useHierarchy","React","useCallback","useMemo","HierarchyTypeField","options","allSelectOptions","parentFieldName","props","field","name","admin","className","isClearable","isSortable","placeholder","hasMany","label","localized","required","onChange","onChangeFromProps","path","pathFromProps","readOnly","validate","allowedCollections","length","filter","option","value","some","c","slug","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","selectFilterOptions","setValue","showError","potentiallyStalePath","selectedOption","newValue","Array","isArray","map","styles","isRequired","_jsx","description","filterOption","optionValue","undefined","style"],"sources":["../../../src/elements/HierarchyTypeField/index.tsx"],"sourcesContent":["'use client'\nimport type { ReactSelectAdapterProps } from '@payloadcms/ui'\nimport type { Option, OptionObject, SelectFieldClientProps } from 'payload'\n\nimport {\n formatOptions,\n mergeFieldStyles,\n SelectInput,\n useField,\n useHierarchy,\n} from '@payloadcms/ui'\nimport React, { useCallback, useMemo } from 'react'\n\ntype HierarchyTypeFieldProps = {\n options: Option[]\n parentFieldName: string\n} & SelectFieldClientProps\n\nexport const HierarchyTypeField: React.FC<HierarchyTypeFieldProps> = ({\n options: allSelectOptions,\n parentFieldName,\n ...props\n}) => {\n const {\n field,\n field: {\n name,\n admin: { className, isClearable = true, isSortable = true, placeholder } = {} as NonNullable<\n SelectFieldClientProps['field']['admin']\n >,\n hasMany = false,\n label,\n localized,\n required,\n },\n onChange: onChangeFromProps,\n path: pathFromProps,\n readOnly,\n validate,\n } = props\n\n const { allowedCollections } = useHierarchy()\n\n const options = useMemo(() => {\n if (!allowedCollections || allowedCollections.length === 0) {\n return formatOptions(allSelectOptions)\n }\n\n return formatOptions(\n allSelectOptions.filter((option) => {\n if (typeof option === 'object' && 'value' in option && option.value) {\n return allowedCollections.some((c) => c.slug === option.value)\n }\n return true\n }),\n )\n }, [allSelectOptions, allowedCollections])\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled,\n path,\n selectFilterOptions,\n setValue,\n showError,\n value,\n } = useField({\n potentiallyStalePath: pathFromProps,\n validate,\n })\n\n const onChange: ReactSelectAdapterProps['onChange'] = useCallback(\n (selectedOption: OptionObject | OptionObject[]) => {\n if (readOnly || disabled) {\n return\n }\n\n let newValue: null | string | string[] = null\n\n if (selectedOption && hasMany) {\n if (Array.isArray(selectedOption)) {\n newValue = selectedOption.map((option) => option.value)\n } else {\n newValue = []\n }\n } else if (selectedOption && !Array.isArray(selectedOption)) {\n newValue = selectedOption.value\n }\n\n if (typeof onChangeFromProps === 'function') {\n onChangeFromProps(newValue)\n }\n\n setValue(newValue)\n },\n [readOnly, disabled, hasMany, setValue, onChangeFromProps],\n )\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n const isRequired =\n required || (Array.isArray(allowedCollections) && allowedCollections.length > 0)\n\n return (\n <div>\n <SelectInput\n AfterInput={AfterInput}\n BeforeInput={BeforeInput}\n className={className}\n Description={Description}\n description=\"Select the collection types this item can contain\"\n Error={Error}\n filterOption={\n selectFilterOptions\n ? ({ value: optionValue }) =>\n selectFilterOptions?.some(\n (option) => (typeof option === 'string' ? option : option.value) === optionValue,\n )\n : undefined\n }\n hasMany={hasMany}\n isClearable={isClearable}\n isSortable={isSortable}\n Label={Label}\n label={label}\n localized={localized}\n name={name}\n onChange={onChange}\n options={options}\n path={path}\n placeholder={placeholder}\n readOnly={readOnly || disabled}\n required={isRequired}\n showError={showError}\n style={styles}\n value={value as string | string[]}\n />\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SACEA,aAAa,EACbC,gBAAgB,EAChBC,WAAW,EACXC,QAAQ,EACRC,YAAY,QACP;AACP,OAAOC,KAAA,IAASC,WAAW,EAAEC,OAAO,QAAQ;AAO5C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A,QAAA,GAASA,QAAA,CAAOC,KAAK,MAAMyB,WAAA,IAEzEC,SAAA;MAENxC,OAAA,EAASA,OAAA;MACTH,WAAA,EAAaA,WAAA;MACbC,UAAA,EAAYA,UAAA;MACZyB,KAAA,EAAOA,KAAA;MACPtB,KAAA,EAAOA,KAAA;MACPC,SAAA,EAAWA,SAAA;MACXR,IAAA,EAAMA,IAAA;MACNU,QAAA,EAAUA,QAAA;MACVf,OAAA,EAASA,OAAA;MACTiB,IAAA,EAAMA,IAAA;MACNP,WAAA,EAAaA,WAAA;MACbS,QAAA,EAAUA,QAAA,IAAYgB,QAAA;MACtBrB,QAAA,EAAUgC,UAAA;MACVR,SAAA,EAAWA,SAAA;MACXc,KAAA,EAAOP,MAAA;MACPpB,KAAA,EAAOA;;;AAIf","ignoreList":[]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Option, SelectFieldServerProps } from 'payload';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
type HierarchyTypeFieldServerProps = {
|
|
4
|
-
collectionOptions: Option[];
|
|
5
|
-
parentFieldName: string;
|
|
6
|
-
} & SelectFieldServerProps;
|
|
7
|
-
export declare const HierarchyTypeFieldServer: React.FC<HierarchyTypeFieldServerProps>;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=index.server.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.server.d.ts","sourceRoot":"","sources":["../../../src/elements/HierarchyTypeField/index.server.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAG7D,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,KAAK,6BAA6B,GAAG;IACnC,iBAAiB,EAAE,MAAM,EAAE,CAAA;IAC3B,eAAe,EAAE,MAAM,CAAA;CACxB,GAAG,sBAAsB,CAAA;AAE1B,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,6BAA6B,CA6B5E,CAAA"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { getTranslation } from '@payloadcms/translations';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { HierarchyTypeField } from './index.js';
|
|
5
|
-
export const HierarchyTypeFieldServer = ({
|
|
6
|
-
clientField,
|
|
7
|
-
collectionOptions,
|
|
8
|
-
i18n,
|
|
9
|
-
parentFieldName,
|
|
10
|
-
path,
|
|
11
|
-
permissions,
|
|
12
|
-
readOnly
|
|
13
|
-
}) => {
|
|
14
|
-
const translatedOptions = collectionOptions.map(option => {
|
|
15
|
-
if (typeof option === 'object' && 'label' in option) {
|
|
16
|
-
return {
|
|
17
|
-
...option,
|
|
18
|
-
label: getTranslation(option.label, i18n)
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
return option;
|
|
22
|
-
});
|
|
23
|
-
return /*#__PURE__*/_jsx(HierarchyTypeField, {
|
|
24
|
-
field: clientField,
|
|
25
|
-
options: translatedOptions,
|
|
26
|
-
parentFieldName: parentFieldName,
|
|
27
|
-
path: path,
|
|
28
|
-
permissions: permissions,
|
|
29
|
-
readOnly: readOnly
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=index.server.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.server.js","names":["getTranslation","React","HierarchyTypeField","HierarchyTypeFieldServer","clientField","collectionOptions","i18n","parentFieldName","path","permissions","readOnly","translatedOptions","map","option","label","_jsx","field","options"],"sources":["../../../src/elements/HierarchyTypeField/index.server.tsx"],"sourcesContent":["import type { Option, SelectFieldServerProps } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\n\nimport { HierarchyTypeField } from './index.js'\n\ntype HierarchyTypeFieldServerProps = {\n collectionOptions: Option[]\n parentFieldName: string\n} & SelectFieldServerProps\n\nexport const HierarchyTypeFieldServer: React.FC<HierarchyTypeFieldServerProps> = ({\n clientField,\n collectionOptions,\n i18n,\n parentFieldName,\n path,\n permissions,\n readOnly,\n}) => {\n const translatedOptions: Option[] = collectionOptions.map((option) => {\n if (typeof option === 'object' && 'label' in option) {\n return {\n ...option,\n label: getTranslation(option.label, i18n),\n }\n }\n return option\n })\n\n return (\n <HierarchyTypeField\n field={clientField}\n options={translatedOptions}\n parentFieldName={parentFieldName}\n path={path}\n permissions={permissions}\n readOnly={readOnly}\n />\n )\n}\n"],"mappings":";AAEA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAElB,SAASC,kBAAkB,QAAQ;AAOnC,OAAO,MAAMC,wBAAA,GAAoEA,CAAC;EAChFC,WAAW;EACXC,iBAAiB;EACjBC,IAAI;EACJC,eAAe;EACfC,IAAI;EACJC,WAAW;EACXC;AAAQ,CACT;EACC,MAAMC,iBAAA,GAA8BN,iBAAA,CAAkBO,GAAG,CAAEC,MAAA;IACzD,IAAI,OAAOA,MAAA,KAAW,YAAY,WAAWA,MAAA,EAAQ;MACnD,OAAO;QACL,GAAGA,MAAM;QACTC,KAAA,EAAOd,cAAA,CAAea,MAAA,CAAOC,KAAK,EAAER,IAAA;MACtC;IACF;IACA,OAAOO,MAAA;EACT;EAEA,oBACEE,IAAA,CAACb,kBAAA;IACCc,KAAA,EAAOZ,WAAA;IACPa,OAAA,EAASN,iBAAA;IACTJ,eAAA,EAAiBA,eAAA;IACjBC,IAAA,EAAMA,IAAA;IACNC,WAAA,EAAaA,WAAA;IACbC,QAAA,EAAUA;;AAGhB","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/Nav/SidebarTabs/TabError/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,cAAc,CAAA;AAIrB,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAY5C,CAAA"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { c as _c } from "react/compiler-runtime";
|
|
4
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
-
import { useTranslation } from '@payloadcms/ui';
|
|
6
|
-
import React from 'react';
|
|
7
|
-
const baseClass = 'sidebar-tab-error';
|
|
8
|
-
export const TabError = t0 => {
|
|
9
|
-
const $ = _c(4);
|
|
10
|
-
const {
|
|
11
|
-
message,
|
|
12
|
-
onRetry
|
|
13
|
-
} = t0;
|
|
14
|
-
const {
|
|
15
|
-
t
|
|
16
|
-
} = useTranslation();
|
|
17
|
-
let t1;
|
|
18
|
-
if ($[0] !== message || $[1] !== onRetry || $[2] !== t) {
|
|
19
|
-
t1 = _jsx("div", {
|
|
20
|
-
className: baseClass,
|
|
21
|
-
children: _jsxs("div", {
|
|
22
|
-
className: `${baseClass}__content`,
|
|
23
|
-
children: [_jsx("span", {
|
|
24
|
-
children: message
|
|
25
|
-
}), _jsx("button", {
|
|
26
|
-
className: `${baseClass}__retry`,
|
|
27
|
-
onClick: onRetry,
|
|
28
|
-
type: "button",
|
|
29
|
-
children: t("general:retry")
|
|
30
|
-
})]
|
|
31
|
-
})
|
|
32
|
-
});
|
|
33
|
-
$[0] = message;
|
|
34
|
-
$[1] = onRetry;
|
|
35
|
-
$[2] = t;
|
|
36
|
-
$[3] = t1;
|
|
37
|
-
} else {
|
|
38
|
-
t1 = $[3];
|
|
39
|
-
}
|
|
40
|
-
return t1;
|
|
41
|
-
};
|
|
42
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useTranslation","React","baseClass","TabError","t0","$","message","onRetry","t","t1","_jsx","className","children","_jsxs","onClick","type"],"sources":["../../../../../src/elements/Nav/SidebarTabs/TabError/index.tsx"],"sourcesContent":["'use client'\n\nimport { useTranslation } from '@payloadcms/ui'\nimport React from 'react'\n\nimport './index.scss'\n\nconst baseClass = 'sidebar-tab-error'\n\nexport type TabErrorProps = {\n message: string\n onRetry: () => void\n}\n\nexport const TabError: React.FC<TabErrorProps> = ({ message, onRetry }) => {\n const { t } = useTranslation()\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__content`}>\n <span>{message}</span>\n <button className={`${baseClass}__retry`} onClick={onRetry} type=\"button\">\n {t('general:retry')}\n </button>\n </div>\n </div>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAEA,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAIlB,MAAMC,SAAA,GAAY;AAOlB,OAAO,MAAMC,QAAA,GAAoCC,EAAA;EAAA,MAAAC,CAAA,GAAAN,EAAA;EAAC;IAAAO,OAAA;IAAAC;EAAA,IAAAH,EAAoB;EACpE;IAAAI;EAAA,IAAcR,cAAA;EAAA,IAAAS,EAAA;EAAA,IAAAJ,CAAA,QAAAC,OAAA,IAAAD,CAAA,QAAAE,OAAA,IAAAF,CAAA,QAAAG,CAAA;IAEZC,EAAA,GAAAC,IAAA,CAAC;MAAAC,SAAA,EAAAT,SAAA;MAAAU,QAAA,EACCC,KAAA,CAAC;QAAAF,SAAA,EAAe,GAAAT,SAAA,WAAuB;QAAAU,QAAA,GACrCF,IAAA,CAAC;UAAAE,QAAA,EAAMN;QAAA,C,GACPI,IAAA,CAAC;UAAAC,SAAA,EAAkB,GAAAT,SAAA,SAAqB;UAAAY,OAAA,EAAWP,OAAA;UAAAQ,IAAA,EAAc;UAAAH,QAAA,EAC9DJ,CAAA,CAAE;QAAA,C;;;;;;;;;;SAJTC,E;CASJ","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/elements/Nav/SidebarTabs/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,QAAQ,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["DEFAULT_NAV_TAB_SLUG"],"sources":["../../../../src/elements/Nav/SidebarTabs/constants.ts"],"sourcesContent":["export const DEFAULT_NAV_TAB_SLUG = 'nav'\n"],"mappings":"AAAA,OAAO,MAAMA,oBAAA,GAAuB","ignoreList":[]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export type TabMetadata = {
|
|
3
|
-
icon: React.ReactNode;
|
|
4
|
-
isDefaultActive?: boolean;
|
|
5
|
-
label: string;
|
|
6
|
-
slug: string;
|
|
7
|
-
};
|
|
8
|
-
export type SidebarTabsClientProps = {
|
|
9
|
-
baseClass: string;
|
|
10
|
-
initialActiveTabID: string;
|
|
11
|
-
initialTabContents: Record<string, React.ReactNode>;
|
|
12
|
-
/**
|
|
13
|
-
* Delay before showing loading spinner (in ms), prevents flashing on fast loads
|
|
14
|
-
* @default 200
|
|
15
|
-
*/
|
|
16
|
-
loadingDelay?: number;
|
|
17
|
-
tabs: TabMetadata[];
|
|
18
|
-
};
|
|
19
|
-
export declare const SidebarTabsClient: React.FC<SidebarTabsClientProps>;
|
|
20
|
-
//# sourceMappingURL=index.client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../../src/elements/Nav/SidebarTabs/index.client.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAwC,MAAM,OAAO,CAAA;AAM5D,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,KAAK,CAAC,SAAS,CAAA;IACrB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;IACnD;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,WAAW,EAAE,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CA0J9D,CAAA"}
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
4
|
-
import { DelayedSpinner, Tooltip, usePreferences, useServerFunctions } from '@payloadcms/ui';
|
|
5
|
-
import { PREFERENCE_KEYS } from 'payload/shared';
|
|
6
|
-
import React, { useCallback, useRef, useState } from 'react';
|
|
7
|
-
import { TabError } from './TabError/index.js';
|
|
8
|
-
export const SidebarTabsClient = ({
|
|
9
|
-
baseClass,
|
|
10
|
-
initialActiveTabID,
|
|
11
|
-
initialTabContents,
|
|
12
|
-
loadingDelay = 200,
|
|
13
|
-
tabs
|
|
14
|
-
}) => {
|
|
15
|
-
const {
|
|
16
|
-
setPreference
|
|
17
|
-
} = usePreferences();
|
|
18
|
-
const {
|
|
19
|
-
serverFunction
|
|
20
|
-
} = useServerFunctions();
|
|
21
|
-
const [activeTabID, setActiveTabID] = useState(initialActiveTabID);
|
|
22
|
-
const [tabContent, setTabContent] = useState(initialTabContents);
|
|
23
|
-
const [loadingTab, setLoadingTab] = useState(null);
|
|
24
|
-
const [hoveredTab, setHoveredTab] = useState(null);
|
|
25
|
-
const loadingTabsRef = useRef(new Set());
|
|
26
|
-
const tabContentRef = useRef(initialTabContents);
|
|
27
|
-
const loadTabContent = useCallback(async tabSlug => {
|
|
28
|
-
// Check if already loaded or currently loading
|
|
29
|
-
if (tabContentRef.current[tabSlug] || loadingTabsRef.current.has(tabSlug)) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
// Mark as loading
|
|
33
|
-
loadingTabsRef.current.add(tabSlug);
|
|
34
|
-
setLoadingTab(tabSlug);
|
|
35
|
-
try {
|
|
36
|
-
const result = await serverFunction({
|
|
37
|
-
name: 'render-tab',
|
|
38
|
-
args: {
|
|
39
|
-
tabSlug
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
const newContent_0 = {
|
|
43
|
-
...tabContentRef.current,
|
|
44
|
-
[tabSlug]: result.component
|
|
45
|
-
};
|
|
46
|
-
tabContentRef.current = newContent_0;
|
|
47
|
-
setTabContent(newContent_0);
|
|
48
|
-
} catch (error) {
|
|
49
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
50
|
-
const handleRetry = () => {
|
|
51
|
-
// Clear the error and retry loading
|
|
52
|
-
const clearedContent = {
|
|
53
|
-
...tabContentRef.current
|
|
54
|
-
};
|
|
55
|
-
delete clearedContent[tabSlug];
|
|
56
|
-
tabContentRef.current = clearedContent;
|
|
57
|
-
setTabContent(clearedContent);
|
|
58
|
-
void loadTabContent(tabSlug);
|
|
59
|
-
};
|
|
60
|
-
const newContent = {
|
|
61
|
-
...tabContentRef.current,
|
|
62
|
-
[tabSlug]: /*#__PURE__*/_jsx(TabError, {
|
|
63
|
-
message: errorMessage,
|
|
64
|
-
onRetry: handleRetry
|
|
65
|
-
})
|
|
66
|
-
};
|
|
67
|
-
tabContentRef.current = newContent;
|
|
68
|
-
setTabContent(newContent);
|
|
69
|
-
} finally {
|
|
70
|
-
loadingTabsRef.current.delete(tabSlug);
|
|
71
|
-
setLoadingTab(null);
|
|
72
|
-
}
|
|
73
|
-
}, [serverFunction]);
|
|
74
|
-
const handleTabChange = useCallback(slug => {
|
|
75
|
-
setActiveTabID(slug);
|
|
76
|
-
void setPreference(PREFERENCE_KEYS.NAV_SIDEBAR_ACTIVE_TAB, {
|
|
77
|
-
activeTab: slug
|
|
78
|
-
});
|
|
79
|
-
void loadTabContent(slug);
|
|
80
|
-
}, [setPreference, loadTabContent]);
|
|
81
|
-
const handleTabKeyDown = useCallback((e, currentIndex) => {
|
|
82
|
-
if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
|
|
83
|
-
e.preventDefault();
|
|
84
|
-
const direction = e.key === 'ArrowLeft' ? -1 : 1;
|
|
85
|
-
const newIndex = (currentIndex + direction + tabs.length) % tabs.length;
|
|
86
|
-
const newTab = tabs[newIndex];
|
|
87
|
-
handleTabChange(newTab.slug);
|
|
88
|
-
// Focus will be handled by the tabIndex change
|
|
89
|
-
setTimeout(() => {
|
|
90
|
-
document.querySelector(`.${baseClass}__tab--active`)?.focus();
|
|
91
|
-
}, 0);
|
|
92
|
-
}
|
|
93
|
-
}, [baseClass, handleTabChange, tabs]);
|
|
94
|
-
const activeContent = tabContent[activeTabID];
|
|
95
|
-
// If there's only one tab (the default nav), render it without tab UI
|
|
96
|
-
if (tabs.length === 1) {
|
|
97
|
-
return /*#__PURE__*/_jsx(_Fragment, {
|
|
98
|
-
children: activeContent
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
return /*#__PURE__*/_jsxs("div", {
|
|
102
|
-
className: baseClass,
|
|
103
|
-
children: [/*#__PURE__*/_jsx("div", {
|
|
104
|
-
className: `${baseClass}__tabs`,
|
|
105
|
-
role: "tablist",
|
|
106
|
-
children: tabs.map((tab, index) => {
|
|
107
|
-
const isActive = tab.slug === activeTabID;
|
|
108
|
-
return /*#__PURE__*/_jsxs("button", {
|
|
109
|
-
"aria-selected": isActive,
|
|
110
|
-
className: `${baseClass}__tab ${isActive ? `${baseClass}__tab--active` : ''}`,
|
|
111
|
-
onClick: () => handleTabChange(tab.slug),
|
|
112
|
-
onKeyDown: e_0 => handleTabKeyDown(e_0, index),
|
|
113
|
-
onMouseEnter: () => setHoveredTab(tab.slug),
|
|
114
|
-
onMouseLeave: () => setHoveredTab(null),
|
|
115
|
-
role: "tab",
|
|
116
|
-
tabIndex: isActive ? 0 : -1,
|
|
117
|
-
type: "button",
|
|
118
|
-
children: [/*#__PURE__*/_jsx(Tooltip, {
|
|
119
|
-
className: `${baseClass}__tooltip`,
|
|
120
|
-
position: index === 0 ? 'bottom' : 'top',
|
|
121
|
-
show: hoveredTab === tab.slug,
|
|
122
|
-
children: tab.label
|
|
123
|
-
}), /*#__PURE__*/_jsx("span", {
|
|
124
|
-
className: `${baseClass}__tab-icon`,
|
|
125
|
-
children: tab.icon
|
|
126
|
-
}), /*#__PURE__*/_jsx("span", {
|
|
127
|
-
className: `${baseClass}__tab-label`,
|
|
128
|
-
children: tab.label
|
|
129
|
-
})]
|
|
130
|
-
}, tab.slug);
|
|
131
|
-
})
|
|
132
|
-
}), /*#__PURE__*/_jsxs("div", {
|
|
133
|
-
className: `${baseClass}__content`,
|
|
134
|
-
role: "tabpanel",
|
|
135
|
-
children: [/*#__PURE__*/_jsx(DelayedSpinner, {
|
|
136
|
-
baseClass: baseClass,
|
|
137
|
-
delay: loadingDelay,
|
|
138
|
-
isLoading: loadingTab === activeTabID
|
|
139
|
-
}), tabs.map(tab_0 => {
|
|
140
|
-
const content = tabContent[tab_0.slug];
|
|
141
|
-
if (!content) {
|
|
142
|
-
return null;
|
|
143
|
-
}
|
|
144
|
-
const isActive_0 = tab_0.slug === activeTabID && loadingTab !== activeTabID;
|
|
145
|
-
return /*#__PURE__*/_jsx("div", {
|
|
146
|
-
style: isActive_0 ? undefined : {
|
|
147
|
-
display: 'none'
|
|
148
|
-
},
|
|
149
|
-
children: content
|
|
150
|
-
}, tab_0.slug);
|
|
151
|
-
})]
|
|
152
|
-
})]
|
|
153
|
-
});
|
|
154
|
-
};
|
|
155
|
-
//# sourceMappingURL=index.client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.js","names":["DelayedSpinner","Tooltip","usePreferences","useServerFunctions","PREFERENCE_KEYS","React","useCallback","useRef","useState","TabError","SidebarTabsClient","baseClass","initialActiveTabID","initialTabContents","loadingDelay","tabs","setPreference","serverFunction","activeTabID","setActiveTabID","tabContent","setTabContent","loadingTab","setLoadingTab","hoveredTab","setHoveredTab","loadingTabsRef","Set","tabContentRef","loadTabContent","tabSlug","current","has","add","result","name","args","newContent","component","error","errorMessage","Error","message","handleRetry","clearedContent","_jsx","onRetry","delete","handleTabChange","slug","NAV_SIDEBAR_ACTIVE_TAB","activeTab","handleTabKeyDown","e","currentIndex","key","preventDefault","direction","newIndex","length","newTab","setTimeout","document","querySelector","focus","activeContent","_Fragment","_jsxs","className","role","map","tab","index","isActive","onClick","onKeyDown","onMouseEnter","onMouseLeave","tabIndex","type","position","show","label","icon","delay","isLoading","content","style","undefined","display"],"sources":["../../../../src/elements/Nav/SidebarTabs/index.client.tsx"],"sourcesContent":["'use client'\n\nimport { DelayedSpinner, Tooltip, usePreferences, useServerFunctions } from '@payloadcms/ui'\nimport { PREFERENCE_KEYS } from 'payload/shared'\nimport React, { useCallback, useRef, useState } from 'react'\n\nimport type { RenderTabServerFnArgs, RenderTabServerFnReturnType } from './renderTabServerFn.js'\n\nimport { TabError } from './TabError/index.js'\n\nexport type TabMetadata = {\n icon: React.ReactNode\n isDefaultActive?: boolean\n label: string\n slug: string\n}\n\nexport type SidebarTabsClientProps = {\n baseClass: string\n initialActiveTabID: string\n initialTabContents: Record<string, React.ReactNode>\n /**\n * Delay before showing loading spinner (in ms), prevents flashing on fast loads\n * @default 200\n */\n loadingDelay?: number\n tabs: TabMetadata[]\n}\n\nexport const SidebarTabsClient: React.FC<SidebarTabsClientProps> = ({\n baseClass,\n initialActiveTabID,\n initialTabContents,\n loadingDelay = 200,\n tabs,\n}) => {\n const { setPreference } = usePreferences()\n const { serverFunction } = useServerFunctions()\n\n const [activeTabID, setActiveTabID] = useState(initialActiveTabID)\n const [tabContent, setTabContent] = useState<Record<string, React.ReactNode>>(initialTabContents)\n const [loadingTab, setLoadingTab] = useState<null | string>(null)\n const [hoveredTab, setHoveredTab] = useState<null | string>(null)\n const loadingTabsRef = useRef<Set<string>>(new Set())\n const tabContentRef = useRef(initialTabContents)\n\n const loadTabContent = useCallback(\n async (tabSlug: string) => {\n // Check if already loaded or currently loading\n if (tabContentRef.current[tabSlug] || loadingTabsRef.current.has(tabSlug)) {\n return\n }\n\n // Mark as loading\n loadingTabsRef.current.add(tabSlug)\n setLoadingTab(tabSlug)\n\n try {\n const result = (await serverFunction({\n name: 'render-tab',\n args: { tabSlug } as RenderTabServerFnArgs,\n })) as RenderTabServerFnReturnType\n\n const newContent = {\n ...tabContentRef.current,\n [tabSlug]: result.component,\n }\n\n tabContentRef.current = newContent\n setTabContent(newContent)\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n\n const handleRetry = () => {\n // Clear the error and retry loading\n const clearedContent = { ...tabContentRef.current }\n delete clearedContent[tabSlug]\n tabContentRef.current = clearedContent\n setTabContent(clearedContent)\n void loadTabContent(tabSlug)\n }\n\n const newContent = {\n ...tabContentRef.current,\n [tabSlug]: <TabError message={errorMessage} onRetry={handleRetry} />,\n }\n\n tabContentRef.current = newContent\n setTabContent(newContent)\n } finally {\n loadingTabsRef.current.delete(tabSlug)\n setLoadingTab(null)\n }\n },\n [serverFunction],\n )\n\n const handleTabChange = useCallback(\n (slug: string) => {\n setActiveTabID(slug)\n void setPreference(PREFERENCE_KEYS.NAV_SIDEBAR_ACTIVE_TAB, { activeTab: slug })\n void loadTabContent(slug)\n },\n [setPreference, loadTabContent],\n )\n\n const handleTabKeyDown = useCallback(\n (e: React.KeyboardEvent, currentIndex: number) => {\n if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {\n e.preventDefault()\n const direction = e.key === 'ArrowLeft' ? -1 : 1\n const newIndex = (currentIndex + direction + tabs.length) % tabs.length\n const newTab = tabs[newIndex]\n handleTabChange(newTab.slug)\n // Focus will be handled by the tabIndex change\n setTimeout(() => {\n document.querySelector<HTMLButtonElement>(`.${baseClass}__tab--active`)?.focus()\n }, 0)\n }\n },\n [baseClass, handleTabChange, tabs],\n )\n\n const activeContent = tabContent[activeTabID]\n\n // If there's only one tab (the default nav), render it without tab UI\n if (tabs.length === 1) {\n return <>{activeContent}</>\n }\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__tabs`} role=\"tablist\">\n {tabs.map((tab, index) => {\n const isActive = tab.slug === activeTabID\n\n return (\n <button\n aria-selected={isActive}\n className={`${baseClass}__tab ${isActive ? `${baseClass}__tab--active` : ''}`}\n key={tab.slug}\n onClick={() => handleTabChange(tab.slug)}\n onKeyDown={(e) => handleTabKeyDown(e, index)}\n onMouseEnter={() => setHoveredTab(tab.slug)}\n onMouseLeave={() => setHoveredTab(null)}\n role=\"tab\"\n tabIndex={isActive ? 0 : -1}\n type=\"button\"\n >\n <Tooltip\n className={`${baseClass}__tooltip`}\n position={index === 0 ? 'bottom' : 'top'} // TODO: set to \"top\" when we portal tooltips\n show={hoveredTab === tab.slug}\n >\n {tab.label}\n </Tooltip>\n <span className={`${baseClass}__tab-icon`}>{tab.icon}</span>\n <span className={`${baseClass}__tab-label`}>{tab.label}</span>\n </button>\n )\n })}\n </div>\n <div className={`${baseClass}__content`} role=\"tabpanel\">\n <DelayedSpinner\n baseClass={baseClass}\n delay={loadingDelay}\n isLoading={loadingTab === activeTabID}\n />\n {tabs.map((tab) => {\n const content = tabContent[tab.slug]\n if (!content) {\n return null\n }\n const isActive = tab.slug === activeTabID && loadingTab !== activeTabID\n return (\n <div key={tab.slug} style={isActive ? undefined : { display: 'none' }}>\n {content}\n </div>\n )\n })}\n </div>\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAEA,SAASA,cAAc,EAAEC,OAAO,EAAEC,cAAc,EAAEC,kBAAkB,QAAQ;AAC5E,SAASC,eAAe,QAAQ;AAChC,OAAOC,KAAA,IAASC,WAAW,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAIrD,SAASC,QAAQ,QAAQ;AAqBzB,OAAO,MAAMC,iBAAA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,IAAI,WAAW;YACnCS,IAAA,EAAMzD,UAAA,KAAe+C,GAAA,CAAItB,IAAI;sBAE5BsB,GAAA,CAAIW;2BAEPrC,IAAA,CAAC;YAAKuB,SAAA,EAAW,GAAGzD,SAAA,YAAqB;sBAAG4D,GAAA,CAAIY;2BAChDtC,IAAA,CAAC;YAAKuB,SAAA,EAAW,GAAGzD,SAAA,aAAsB;sBAAG4D,GAAA,CAAIW;;WAjB5CX,GAAA,CAAItB,IAAI;MAoBnB;qBAEFkB,KAAA,CAAC;MAAIC,SAAA,EAAW,GAAGzD,SAAA,WAAoB;MAAE0D,IAAA,EAAK;8BAC5CxB,IAAA,CAAC7C,cAAA;QACCW,SAAA,EAAWA,SAAA;QACXyE,KAAA,EAAOtE,YAAA;QACPuE,SAAA,EAAW/D,UAAA,KAAeJ;UAE3BH,IAAA,CAAKuD,GAAG,CAAEC,KAAA;QACT,MAAMe,OAAA,GAAUlE,UAAU,CAACmD,KAAA,CAAItB,IAAI,CAAC;QACpC,IAAI,CAACqC,OAAA,EAAS;UACZ,OAAO;QACT;QACA,MAAMb,UAAA,GAAWF,KAAA,CAAItB,IAAI,KAAK/B,WAAA,IAAeI,UAAA,KAAeJ,WAAA;QAC5D,oBACE2B,IAAA,CAAC;UAAmB0C,KAAA,EAAOd,UAAA,GAAWe,SAAA,GAAY;YAAEC,OAAA,EAAS;UAAO;oBACjEH;WADOf,KAAA,CAAItB,IAAI;MAItB;;;AAIR","ignoreList":[]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { NavPreferences, PayloadComponent, SidebarTab } from 'payload';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import type { NavProps } from '../index.js';
|
|
4
|
-
import './index.scss';
|
|
5
|
-
type SidebarTabWithReactNode = {
|
|
6
|
-
components: {
|
|
7
|
-
Content: PayloadComponent | React.ReactNode;
|
|
8
|
-
Icon: PayloadComponent | React.ReactNode;
|
|
9
|
-
};
|
|
10
|
-
} & Omit<SidebarTab, 'components'>;
|
|
11
|
-
export type SidebarTabsProps = {
|
|
12
|
-
navPreferences: NavPreferences;
|
|
13
|
-
tabs: SidebarTabWithReactNode[];
|
|
14
|
-
} & NavProps;
|
|
15
|
-
export declare const SidebarTabs: React.FC<SidebarTabsProps>;
|
|
16
|
-
export {};
|
|
17
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/Nav/SidebarTabs/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAI3E,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAG3C,OAAO,cAAc,CAAA;AAErB,KAAK,uBAAuB,GAAG;IAC7B,UAAU,EAAE;QACV,OAAO,EAAE,gBAAgB,GAAG,KAAK,CAAC,SAAS,CAAA;QAC3C,IAAI,EAAE,gBAAgB,GAAG,KAAK,CAAC,SAAS,CAAA;KACzC,CAAA;CACF,GAAG,IAAI,CAAC,UAAU,EAAE,YAAY,CAAC,CAAA;AAElC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,cAAc,EAAE,cAAc,CAAA;IAC9B,IAAI,EAAE,uBAAuB,EAAE,CAAA;CAChC,GAAG,QAAQ,CAAA;AAIZ,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAuFlD,CAAA"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { getTranslation } from '@payloadcms/translations';
|
|
3
|
-
import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import { SidebarTabsClient } from './index.client.js';
|
|
6
|
-
const baseClass = 'sidebar-tabs';
|
|
7
|
-
export const SidebarTabs = props => {
|
|
8
|
-
const {
|
|
9
|
-
documentSubViewType,
|
|
10
|
-
i18n,
|
|
11
|
-
locale,
|
|
12
|
-
navPreferences,
|
|
13
|
-
params,
|
|
14
|
-
payload,
|
|
15
|
-
permissions,
|
|
16
|
-
searchParams,
|
|
17
|
-
tabs,
|
|
18
|
-
user,
|
|
19
|
-
viewType
|
|
20
|
-
} = props;
|
|
21
|
-
// Determine which tab should be active on initial load
|
|
22
|
-
// First try saved preference, then default tab, then first tab
|
|
23
|
-
const preferredTabSlug = navPreferences.activeTab || tabs.find(tab => tab.isDefaultActive)?.slug || tabs[0]?.slug;
|
|
24
|
-
// Verify the preferred tab actually exists, otherwise fall back to default or first tab
|
|
25
|
-
const activeTab = tabs.find(t => t.slug === preferredTabSlug) || tabs.find(tab => tab.isDefaultActive) || tabs[0];
|
|
26
|
-
const initialActiveTabID = activeTab?.slug || tabs[0]?.slug;
|
|
27
|
-
// Build initial tab contents
|
|
28
|
-
// Strategy: Pre-render tabs that are already React elements (can't be lazy-loaded),
|
|
29
|
-
// and only render the initially active tab if it's a CustomComponent (can be lazy-loaded)
|
|
30
|
-
const initialTabContents = {};
|
|
31
|
-
const renderComponent = component => {
|
|
32
|
-
// Check if component is already a React node (payload provided React component)
|
|
33
|
-
if (/*#__PURE__*/React.isValidElement(component)) {
|
|
34
|
-
return component;
|
|
35
|
-
} else {
|
|
36
|
-
// Otherwise render it as a CustomComponent
|
|
37
|
-
return RenderServerComponent({
|
|
38
|
-
clientProps: {
|
|
39
|
-
documentSubViewType,
|
|
40
|
-
viewType
|
|
41
|
-
},
|
|
42
|
-
Component: component,
|
|
43
|
-
importMap: payload.importMap,
|
|
44
|
-
serverProps: {
|
|
45
|
-
i18n,
|
|
46
|
-
locale,
|
|
47
|
-
params,
|
|
48
|
-
payload,
|
|
49
|
-
permissions,
|
|
50
|
-
searchParams,
|
|
51
|
-
user
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
for (const tab of tabs) {
|
|
57
|
-
if (/*#__PURE__*/React.isValidElement(tab.components.Content)) {
|
|
58
|
-
initialTabContents[tab.slug] = tab.components.Content;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
// If the active tab is a CustomComponent (lazy-loadable), render it now
|
|
62
|
-
if (activeTab && ! /*#__PURE__*/React.isValidElement(activeTab.components.Content)) {
|
|
63
|
-
initialTabContents[activeTab.slug] = renderComponent(activeTab.components.Content);
|
|
64
|
-
}
|
|
65
|
-
return /*#__PURE__*/_jsx(SidebarTabsClient, {
|
|
66
|
-
baseClass: baseClass,
|
|
67
|
-
initialActiveTabID: initialActiveTabID,
|
|
68
|
-
initialTabContents: initialTabContents,
|
|
69
|
-
tabs: tabs.map(tab => {
|
|
70
|
-
const labelText = tab.label ? getTranslation(tab.label, i18n) : tab.slug;
|
|
71
|
-
return {
|
|
72
|
-
slug: tab.slug,
|
|
73
|
-
icon: renderComponent(tab.components.Icon),
|
|
74
|
-
isDefaultActive: tab.isDefaultActive,
|
|
75
|
-
label: labelText
|
|
76
|
-
};
|
|
77
|
-
})
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
//# sourceMappingURL=index.js.map
|