@payloadcms/ui 3.56.0-internal.299316b → 3.56.0-internal.457de85
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/ListControls/getTextFieldsToBeSearched.d.ts.map +1 -1
- package/dist/elements/ListControls/getTextFieldsToBeSearched.js +9 -1
- package/dist/elements/ListControls/getTextFieldsToBeSearched.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/index.d.ts +1 -1
- package/dist/elements/WhereBuilder/Condition/index.js +2 -2
- package/dist/elements/WhereBuilder/Condition/index.js.map +1 -1
- package/dist/elements/WhereBuilder/index.js +6 -6
- package/dist/elements/WhereBuilder/index.js.map +1 -1
- package/dist/exports/client/{CodeEditor-URFJPG6I.js → CodeEditor-4J4OH4TD.js} +2 -2
- package/dist/exports/client/chunk-HBCG32CP.js +26 -0
- package/dist/exports/client/{chunk-KPQQ5IUL.js.map → chunk-HBCG32CP.js.map} +3 -3
- package/dist/exports/client/index.d.ts +1 -1
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +12 -12
- package/dist/exports/client/index.js.map +3 -3
- package/dist/providers/Config/index.d.ts +17 -2
- package/dist/providers/Config/index.d.ts.map +1 -1
- package/dist/providers/Config/index.js +57 -20
- package/dist/providers/Config/index.js.map +1 -1
- package/dist/utilities/reduceFieldsToOptions.d.ts +2 -2
- package/dist/utilities/reduceFieldsToOptions.js +2 -2
- package/dist/utilities/reduceFieldsToOptions.js.map +1 -1
- package/package.json +5 -5
- package/dist/exports/client/chunk-KPQQ5IUL.js +0 -26
- /package/dist/exports/client/{CodeEditor-URFJPG6I.js.map → CodeEditor-4J4OH4TD.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClientCollectionConfig, ClientConfig, ClientGlobalConfig, CollectionSlug, GlobalSlug
|
|
1
|
+
import type { ClientCollectionConfig, ClientConfig, ClientGlobalConfig, CollectionSlug, GlobalSlug } from 'payload';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
type GetEntityConfigFn = {
|
|
4
4
|
(args: {
|
|
@@ -26,8 +26,23 @@ export type ClientConfigContext = {
|
|
|
26
26
|
};
|
|
27
27
|
export declare const ConfigProvider: React.FC<{
|
|
28
28
|
readonly children: React.ReactNode;
|
|
29
|
-
readonly config: ClientConfig
|
|
29
|
+
readonly config: ClientConfig;
|
|
30
30
|
}>;
|
|
31
31
|
export declare const useConfig: () => ClientConfigContext;
|
|
32
|
+
/**
|
|
33
|
+
* This provider shadows the `ConfigProvider` on the _page_ level, allowing us to
|
|
34
|
+
* update the config when needed, e.g. after authentication.
|
|
35
|
+
* The layout `ConfigProvider` is not updated on page navigation / authentication,
|
|
36
|
+
* as the layout does not re-render in those cases.
|
|
37
|
+
*
|
|
38
|
+
* If the config here has the same reference as the config from the layout, we
|
|
39
|
+
* simply reuse the context from the layout to avoid unnecessary re-renders.
|
|
40
|
+
*
|
|
41
|
+
* @experimental This component is experimental and may change or be removed in future releases. Use at your own discretion.
|
|
42
|
+
*/
|
|
43
|
+
export declare const PageConfigProvider: React.FC<{
|
|
44
|
+
readonly children: React.ReactNode;
|
|
45
|
+
readonly config: ClientConfig;
|
|
46
|
+
}>;
|
|
32
47
|
export {};
|
|
33
48
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/Config/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/Config/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,UAAU,EACX,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAgF,MAAM,OAAO,CAAA;AAEpG,KAAK,iBAAiB,GAAG;IAGvB,CAAC,IAAI,EAAE;QAAE,cAAc,EAAE,EAAE,GAAG,cAAc,CAAC;QAAC,UAAU,CAAC,EAAE,KAAK,CAAA;KAAE,GAAG,sBAAsB,CAAA;IAI3F,CAAC,IAAI,EAAE;QAAE,cAAc,CAAC,EAAE,KAAK,CAAC;QAAC,UAAU,EAAE,EAAE,GAAG,UAAU,CAAA;KAAE,GAAG,kBAAkB,CAAA;IAGnF,CAAC,IAAI,EAAE;QACL,cAAc,CAAC,EAAE,EAAE,GAAG,cAAc,CAAA;QACpC,UAAU,CAAC,EAAE,EAAE,GAAG,UAAU,CAAA;KAC7B,GAAG,sBAAsB,GAAG,kBAAkB,GAAG,IAAI,CAAA;CACvD,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,YAAY,CAAA;IACpB;;;;OAIG;IACH,eAAe,EAAE,iBAAiB,CAAA;IAClC,SAAS,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAA;CAC1C,CAAA;AAID,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IAClC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAA;CAC9B,CAqDA,CAAA;AAED,eAAO,MAAM,SAAS,QAAO,mBAA6C,CAAA;AAE1E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IAClC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAA;CAC9B,CAyBA,CAAA"}
|
|
@@ -1,33 +1,16 @@
|
|
|
1
1
|
/* eslint-disable perfectionist/sort-object-types */ // Need to disable this rule because the order of the overloads is important
|
|
2
2
|
'use client';
|
|
3
3
|
|
|
4
|
+
import { c as _c } from "react/compiler-runtime";
|
|
4
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
6
|
import React, { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
7
|
const RootConfigContext = /*#__PURE__*/createContext(undefined);
|
|
7
|
-
function sanitizeClientConfig(unSanitizedConfig) {
|
|
8
|
-
if (!unSanitizedConfig?.blocks?.length || unSanitizedConfig.blocksMap) {
|
|
9
|
-
;
|
|
10
|
-
unSanitizedConfig.blocksMap = {};
|
|
11
|
-
return unSanitizedConfig;
|
|
12
|
-
}
|
|
13
|
-
const sanitizedConfig = {
|
|
14
|
-
...unSanitizedConfig
|
|
15
|
-
};
|
|
16
|
-
sanitizedConfig.blocksMap = {};
|
|
17
|
-
for (const block of unSanitizedConfig.blocks) {
|
|
18
|
-
sanitizedConfig.blocksMap[block.slug] = block;
|
|
19
|
-
}
|
|
20
|
-
return sanitizedConfig;
|
|
21
|
-
}
|
|
22
8
|
export const ConfigProvider = ({
|
|
23
9
|
children,
|
|
24
10
|
config: configFromProps
|
|
25
11
|
}) => {
|
|
26
|
-
const [config,
|
|
12
|
+
const [config, setConfig] = useState(configFromProps);
|
|
27
13
|
const isFirstRenderRef = useRef(true);
|
|
28
|
-
const setConfig = useCallback(newConfig => {
|
|
29
|
-
setConfigFn(sanitizeClientConfig(newConfig));
|
|
30
|
-
}, []);
|
|
31
14
|
// Need to update local config state if config from props changes, for HMR.
|
|
32
15
|
// That way, config changes will be updated in the UI immediately without needing a refresh.
|
|
33
16
|
useEffect(() => {
|
|
@@ -68,11 +51,65 @@ export const ConfigProvider = ({
|
|
|
68
51
|
config,
|
|
69
52
|
getEntityConfig,
|
|
70
53
|
setConfig
|
|
71
|
-
}), [config, getEntityConfig]);
|
|
54
|
+
}), [config, getEntityConfig, setConfig]);
|
|
72
55
|
return /*#__PURE__*/_jsx(RootConfigContext, {
|
|
73
56
|
value: value,
|
|
74
57
|
children: children
|
|
75
58
|
});
|
|
76
59
|
};
|
|
77
60
|
export const useConfig = () => use(RootConfigContext);
|
|
61
|
+
/**
|
|
62
|
+
* This provider shadows the `ConfigProvider` on the _page_ level, allowing us to
|
|
63
|
+
* update the config when needed, e.g. after authentication.
|
|
64
|
+
* The layout `ConfigProvider` is not updated on page navigation / authentication,
|
|
65
|
+
* as the layout does not re-render in those cases.
|
|
66
|
+
*
|
|
67
|
+
* If the config here has the same reference as the config from the layout, we
|
|
68
|
+
* simply reuse the context from the layout to avoid unnecessary re-renders.
|
|
69
|
+
*
|
|
70
|
+
* @experimental This component is experimental and may change or be removed in future releases. Use at your own discretion.
|
|
71
|
+
*/
|
|
72
|
+
export const PageConfigProvider = t0 => {
|
|
73
|
+
const $ = _c(7);
|
|
74
|
+
const {
|
|
75
|
+
children,
|
|
76
|
+
config: configFromProps
|
|
77
|
+
} = t0;
|
|
78
|
+
const {
|
|
79
|
+
config: rootConfig,
|
|
80
|
+
setConfig: setRootConfig
|
|
81
|
+
} = useConfig();
|
|
82
|
+
let t1;
|
|
83
|
+
let t2;
|
|
84
|
+
if ($[0] !== configFromProps || $[1] !== setRootConfig) {
|
|
85
|
+
t1 = () => {
|
|
86
|
+
setRootConfig(configFromProps);
|
|
87
|
+
};
|
|
88
|
+
t2 = [configFromProps, setRootConfig];
|
|
89
|
+
$[0] = configFromProps;
|
|
90
|
+
$[1] = setRootConfig;
|
|
91
|
+
$[2] = t1;
|
|
92
|
+
$[3] = t2;
|
|
93
|
+
} else {
|
|
94
|
+
t1 = $[2];
|
|
95
|
+
t2 = $[3];
|
|
96
|
+
}
|
|
97
|
+
useEffect(t1, t2);
|
|
98
|
+
if (rootConfig !== configFromProps && rootConfig.unauthenticated !== configFromProps.unauthenticated) {
|
|
99
|
+
let t3;
|
|
100
|
+
if ($[4] !== children || $[5] !== configFromProps) {
|
|
101
|
+
t3 = _jsx(ConfigProvider, {
|
|
102
|
+
config: configFromProps,
|
|
103
|
+
children
|
|
104
|
+
});
|
|
105
|
+
$[4] = children;
|
|
106
|
+
$[5] = configFromProps;
|
|
107
|
+
$[6] = t3;
|
|
108
|
+
} else {
|
|
109
|
+
t3 = $[6];
|
|
110
|
+
}
|
|
111
|
+
return t3;
|
|
112
|
+
}
|
|
113
|
+
return children;
|
|
114
|
+
};
|
|
78
115
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","createContext","use","useCallback","useEffect","useMemo","useRef","useState","RootConfigContext","undefined","
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","React","createContext","use","useCallback","useEffect","useMemo","useRef","useState","RootConfigContext","undefined","ConfigProvider","children","config","configFromProps","setConfig","isFirstRenderRef","current","collectionsBySlug","globalsBySlug","collection","collections","slug","global","globals","getEntityConfig","args","collectionSlug","globalSlug","value","_jsx","useConfig","PageConfigProvider","t0","$","rootConfig","setRootConfig","t1","t2","unauthenticated","t3"],"sources":["../../../src/providers/Config/index.tsx"],"sourcesContent":["/* eslint-disable perfectionist/sort-object-types */ // Need to disable this rule because the order of the overloads is important\n'use client'\nimport type {\n ClientCollectionConfig,\n ClientConfig,\n ClientGlobalConfig,\n CollectionSlug,\n GlobalSlug,\n} from 'payload'\n\nimport React, { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\ntype GetEntityConfigFn = {\n // Overload #1: collectionSlug only\n // @todo remove \"{} |\" in 4.0, which would be a breaking change\n (args: { collectionSlug: {} | CollectionSlug; globalSlug?: never }): ClientCollectionConfig\n\n // Overload #2: globalSlug only\n // @todo remove \"{} |\" in 4.0, which would be a breaking change\n (args: { collectionSlug?: never; globalSlug: {} | GlobalSlug }): ClientGlobalConfig\n\n // Overload #3: both/none (fall back to union | null)\n (args: {\n collectionSlug?: {} | CollectionSlug\n globalSlug?: {} | GlobalSlug\n }): ClientCollectionConfig | ClientGlobalConfig | null\n}\n\nexport type ClientConfigContext = {\n config: ClientConfig\n /**\n * Get a collection or global config by its slug. This is preferred over\n * using `config.collections.find` or `config.globals.find`, because\n * getEntityConfig uses a lookup map for O(1) lookups.\n */\n getEntityConfig: GetEntityConfigFn\n setConfig: (config: ClientConfig) => void\n}\n\nconst RootConfigContext = createContext<ClientConfigContext | undefined>(undefined)\n\nexport const ConfigProvider: React.FC<{\n readonly children: React.ReactNode\n readonly config: ClientConfig\n}> = ({ children, config: configFromProps }) => {\n const [config, setConfig] = useState<ClientConfig>(configFromProps)\n\n const isFirstRenderRef = useRef(true)\n\n // Need to update local config state if config from props changes, for HMR.\n // That way, config changes will be updated in the UI immediately without needing a refresh.\n useEffect(() => {\n if (isFirstRenderRef.current) {\n isFirstRenderRef.current = false\n return\n }\n\n setConfig(configFromProps)\n }, [configFromProps, setConfig])\n\n // Build lookup maps for collections and globals so we can do O(1) lookups by slug\n const { collectionsBySlug, globalsBySlug } = useMemo(() => {\n const collectionsBySlug: Record<string, ClientCollectionConfig> = {}\n const globalsBySlug: Record<string, ClientGlobalConfig> = {}\n\n for (const collection of config.collections) {\n collectionsBySlug[collection.slug] = collection\n }\n\n for (const global of config.globals) {\n globalsBySlug[global.slug] = global\n }\n\n return { collectionsBySlug, globalsBySlug }\n }, [config])\n\n const getEntityConfig = useCallback<GetEntityConfigFn>(\n (args) => {\n if ('collectionSlug' in args) {\n return collectionsBySlug[args.collectionSlug] ?? null\n }\n\n if ('globalSlug' in args) {\n return globalsBySlug[args.globalSlug] ?? null\n }\n\n return null as any\n },\n [collectionsBySlug, globalsBySlug],\n )\n\n const value = useMemo(\n () => ({ config, getEntityConfig, setConfig }),\n [config, getEntityConfig, setConfig],\n )\n\n return <RootConfigContext value={value}>{children}</RootConfigContext>\n}\n\nexport const useConfig = (): ClientConfigContext => use(RootConfigContext)\n\n/**\n * This provider shadows the `ConfigProvider` on the _page_ level, allowing us to\n * update the config when needed, e.g. after authentication.\n * The layout `ConfigProvider` is not updated on page navigation / authentication,\n * as the layout does not re-render in those cases.\n *\n * If the config here has the same reference as the config from the layout, we\n * simply reuse the context from the layout to avoid unnecessary re-renders.\n *\n * @experimental This component is experimental and may change or be removed in future releases. Use at your own discretion.\n */\nexport const PageConfigProvider: React.FC<{\n readonly children: React.ReactNode\n readonly config: ClientConfig\n}> = ({ children, config: configFromProps }) => {\n const { config: rootConfig, setConfig: setRootConfig } = useConfig()\n\n /**\n * This `useEffect` is required in order for the _page_ to be able to refresh the client config,\n * which may have been cached on the _layout_ level, where the `ConfigProvider` is managed.\n * Since the layout does not re-render on page navigation / authentication, we need to manually\n * update the config, as the user may have been authenticated in the process, which affects the client config.\n */\n useEffect(() => {\n setRootConfig(configFromProps)\n }, [configFromProps, setRootConfig])\n\n // If this component receives a different config than what is in context from the layout, it is stale.\n // While stale, we instantiate a new context provider that provides the new config until the root context is updated.\n // Unfortunately, referential equality alone does not work bc the reference is lost during server/client serialization,\n // so we need to also compare the `unauthenticated` property.\n if (\n rootConfig !== configFromProps &&\n rootConfig.unauthenticated !== configFromProps.unauthenticated\n ) {\n return <ConfigProvider config={configFromProps}>{children}</ConfigProvider>\n }\n\n return children\n}\n"],"mappings":"AAAA,sDAAsD;AACtD;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AASA,OAAOC,KAAA,IAASC,aAAa,EAAEC,GAAG,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AA6B7F,MAAMC,iBAAA,gBAAoBP,aAAA,CAA+CQ,SAAA;AAEzE,OAAO,MAAMC,cAAA,GAGRA,CAAC;EAAEC,QAAQ;EAAEC,MAAA,EAAQC;AAAe,CAAE;EACzC,MAAM,CAACD,MAAA,EAAQE,SAAA,CAAU,GAAGP,QAAA,CAAuBM,eAAA;EAEnD,MAAME,gBAAA,GAAmBT,MAAA,CAAO;EAEhC;EACA;EACAF,SAAA,CAAU;IACR,IAAIW,gBAAA,CAAiBC,OAAO,EAAE;MAC5BD,gBAAA,CAAiBC,OAAO,GAAG;MAC3B;IACF;IAEAF,SAAA,CAAUD,eAAA;EACZ,GAAG,CAACA,eAAA,EAAiBC,SAAA,CAAU;EAE/B;EACA,MAAM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AApB,MAAA,EAAAsB,UAAA;IAAApB,SAAA,EAAAqB;EAAA,IAAyDL,SAAA;EAAA,IAAAM,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAJ,CAAA,QAAApB,eAAA,IAAAoB,CAAA,QAAAE,aAAA;IAQ/CC,EAAA,GAAAA,CAAA;MACRD,aAAA,CAActB,eAAA;IAAA;IACbwB,EAAA,IAACxB,eAAA,EAAiBsB,aAAA;IAAcF,CAAA,MAAApB,eAAA;IAAAoB,CAAA,MAAAE,aAAA;IAAAF,CAAA,MAAAG,EAAA;IAAAH,CAAA,MAAAI,EAAA;EAAA;IAAAD,EAAA,GAAAH,CAAA;IAAAI,EAAA,GAAAJ,CAAA;EAAA;EAFnC7B,SAAA,CAAUgC,EAEV,EAAGC,EAAgC;EAAA,IAOjCH,UAAA,KAAerB,eAAA,IACfqB,UAAA,CAAAI,eAAA,KAA+BzB,eAAA,CAAAyB,eAA+B;IAAA,IAAAC,EAAA;IAAA,IAAAN,CAAA,QAAAtB,QAAA,IAAAsB,CAAA,QAAApB,eAAA;MAEvD0B,EAAA,GAAAV,IAAA,CAAAnB,cAAA;QAAAE,MAAA,EAAwBC,eAAA;QAAAF;MAAA,C;;;;;;;WAAxB4B,E;;SAGF5B,QAAA;AAAA,CACT","ignoreList":[]}
|
|
@@ -8,8 +8,8 @@ type ReduceFieldOptionsArgs = {
|
|
|
8
8
|
pathPrefix?: string;
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
* Used in the WhereBuilder component to render the fields in the dropdown.
|
|
11
|
+
* Transforms a fields schema into a flattened array of fields with labels and values.
|
|
12
|
+
* Used in the `WhereBuilder` component to render the fields in the dropdown.
|
|
13
13
|
*/
|
|
14
14
|
export declare const reduceFieldsToOptions: ({ fields, i18n, labelPrefix, pathPrefix, }: ReduceFieldOptionsArgs) => ReducedField[];
|
|
15
15
|
export {};
|
|
@@ -6,8 +6,8 @@ import fieldTypes, { arrayOperators } from '../elements/WhereBuilder/field-types
|
|
|
6
6
|
import { createNestedClientFieldPath } from '../forms/Form/createNestedClientFieldPath.js';
|
|
7
7
|
import { combineFieldLabel } from './combineFieldLabel.js';
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
* Used in the WhereBuilder component to render the fields in the dropdown.
|
|
9
|
+
* Transforms a fields schema into a flattened array of fields with labels and values.
|
|
10
|
+
* Used in the `WhereBuilder` component to render the fields in the dropdown.
|
|
11
11
|
*/
|
|
12
12
|
export const reduceFieldsToOptions = ({
|
|
13
13
|
fields,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reduceFieldsToOptions.js","names":["getTranslation","fieldAffectsData","fieldIsHiddenOrDisabled","fieldIsID","tabHasName","fieldTypes","arrayOperators","createNestedClientFieldPath","combineFieldLabel","reduceFieldsToOptions","fields","i18n","labelPrefix","pathPrefix","reduce","reduced","field","virtual","baseLabel","label","name","localizedLabel","push","plainTextLabel","value","type","operators","tabs","forEach","tab","localizedTabLabel","labelWithPrefix","tabPathPrefix","translatedLabel","pathWithPrefix","operatorKeys","Set","fieldOperators","hasMany","acc","operator","has","add","operatorKey","t","formattedLabel","prefix","fieldPath","formattedField"],"sources":["../../src/utilities/reduceFieldsToOptions.tsx"],"sourcesContent":["'use client'\nimport type { ClientTranslationKeys, I18nClient } from '@payloadcms/translations'\nimport type { ClientField } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { fieldAffectsData, fieldIsHiddenOrDisabled, fieldIsID, tabHasName } from 'payload/shared'\n\nimport type { ReducedField } from '../elements/WhereBuilder/types.js'\n\nimport fieldTypes, { arrayOperators } from '../elements/WhereBuilder/field-types.js'\nimport { createNestedClientFieldPath } from '../forms/Form/createNestedClientFieldPath.js'\nimport { combineFieldLabel } from './combineFieldLabel.js'\n\ntype ReduceFieldOptionsArgs = {\n fields: ClientField[]\n i18n: I18nClient\n labelPrefix?: string\n pathPrefix?: string\n}\n\n/**\n * Reduces a field map to a flat array of fields with labels and values.\n * Used in the WhereBuilder component to render the fields in the dropdown.\n */\nexport const reduceFieldsToOptions = ({\n fields,\n i18n,\n labelPrefix,\n pathPrefix,\n}: ReduceFieldOptionsArgs): ReducedField[] => {\n return fields.reduce((reduced, field) => {\n // Do not filter out `field.admin.disableListFilter` fields here, as these should still render as disabled if they appear in the URL query\n // Filter out `virtual: true` fields since they are regular virtuals and not backed by a DB field\n if (\n (fieldIsHiddenOrDisabled(field) && !fieldIsID(field)) ||\n ('virtual' in field && field.virtual === true)\n ) {\n return reduced\n }\n\n // Handle virtual:string fields (virtual relationships, e.g. \"post.title\")\n if ('virtual' in field && typeof field.virtual === 'string') {\n const baseLabel = ('label' in field && field.label) || ('name' in field && field.name) || ''\n const localizedLabel = getTranslation(baseLabel, i18n)\n\n reduced.push({\n label: localizedLabel,\n plainTextLabel: localizedLabel,\n value: field.virtual, // e.g. \"post.title\"\n ...fieldTypes[field.type],\n field,\n operators: fieldTypes[field.type].operators,\n })\n return reduced\n }\n\n if (field.type === 'tabs' && 'tabs' in field) {\n const tabs = field.tabs\n\n tabs.forEach((tab) => {\n if (typeof tab.label !== 'boolean') {\n const localizedTabLabel = getTranslation(tab.label, i18n)\n\n const labelWithPrefix = labelPrefix\n ? labelPrefix + ' > ' + localizedTabLabel\n : localizedTabLabel\n\n // Make sure we handle nested tabs\n const tabPathPrefix =\n tabHasName(tab) && tab.name\n ? pathPrefix\n ? pathPrefix + '.' + tab.name\n : tab.name\n : pathPrefix\n\n if (typeof localizedTabLabel === 'string') {\n reduced.push(\n ...reduceFieldsToOptions({\n fields: tab.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix: tabPathPrefix,\n }),\n )\n }\n }\n })\n return reduced\n }\n\n // Rows cant have labels, so we need to handle them differently\n if (field.type === 'row' && 'fields' in field) {\n reduced.push(\n ...reduceFieldsToOptions({\n fields: field.fields,\n i18n,\n labelPrefix,\n pathPrefix,\n }),\n )\n return reduced\n }\n\n if (field.type === 'collapsible' && 'fields' in field) {\n const localizedTabLabel = getTranslation(field.label || '', i18n)\n\n const labelWithPrefix = labelPrefix\n ? labelPrefix + ' > ' + localizedTabLabel\n : localizedTabLabel\n\n reduced.push(\n ...reduceFieldsToOptions({\n fields: field.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix,\n }),\n )\n return reduced\n }\n\n if (field.type === 'group' && 'fields' in field) {\n const translatedLabel = getTranslation(field.label || '', i18n)\n\n const labelWithPrefix = labelPrefix\n ? translatedLabel\n ? labelPrefix + ' > ' + translatedLabel\n : labelPrefix\n : translatedLabel\n\n if (fieldAffectsData(field)) {\n // Make sure we handle deeply nested groups\n const pathWithPrefix = field.name\n ? pathPrefix\n ? pathPrefix + '.' + field.name\n : field.name\n : pathPrefix\n\n reduced.push(\n ...reduceFieldsToOptions({\n fields: field.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix: pathWithPrefix,\n }),\n )\n } else {\n reduced.push(\n ...reduceFieldsToOptions({\n fields: field.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix,\n }),\n )\n }\n\n return reduced\n }\n\n if (field.type === 'array' && 'fields' in field) {\n const translatedLabel = getTranslation(field.label || '', i18n)\n\n const labelWithPrefix = labelPrefix\n ? translatedLabel\n ? labelPrefix + ' > ' + translatedLabel\n : labelPrefix\n : translatedLabel\n\n // Make sure we handle deeply nested groups\n const pathWithPrefix = field.name\n ? pathPrefix\n ? pathPrefix + '.' + field.name\n : field.name\n : pathPrefix\n\n reduced.push(\n ...reduceFieldsToOptions({\n fields: field.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix: pathWithPrefix,\n }),\n )\n\n return reduced\n }\n\n if (typeof fieldTypes[field.type] === 'object') {\n const operatorKeys = new Set()\n\n const fieldOperators =\n 'hasMany' in field && field.hasMany ? arrayOperators : fieldTypes[field.type].operators\n\n const operators = fieldOperators.reduce((acc, operator) => {\n if (!operatorKeys.has(operator.value)) {\n operatorKeys.add(operator.value)\n const operatorKey = `operators:${operator.label}` as ClientTranslationKeys\n acc.push({\n ...operator,\n label: i18n.t(operatorKey),\n })\n }\n\n return acc\n }, [])\n\n const localizedLabel = getTranslation(field.label || '', i18n)\n\n const formattedLabel = labelPrefix\n ? combineFieldLabel({\n field,\n prefix: labelPrefix,\n })\n : localizedLabel\n\n const fieldPath = pathPrefix ? createNestedClientFieldPath(pathPrefix, field) : field.name\n\n const formattedField: ReducedField = {\n label: formattedLabel,\n plainTextLabel: `${labelPrefix ? labelPrefix + ' > ' : ''}${localizedLabel}`,\n value: fieldPath,\n ...fieldTypes[field.type],\n field,\n operators,\n }\n\n reduced.push(formattedField)\n return reduced\n }\n return reduced\n }, [])\n}\n"],"mappings":"AAAA;;AAIA,SAASA,cAAc,QAAQ;AAC/B,SAASC,gBAAgB,EAAEC,uBAAuB,EAAEC,SAAS,EAAEC,UAAU,QAAQ;AAIjF,OAAOC,UAAA,IAAcC,cAAc,QAAQ;AAC3C,SAASC,2BAA2B,QAAQ;AAC5C,SAASC,iBAAiB,QAAQ;AASlC;;;;AAIA,OAAO,MAAMC,qBAAA,GAAwBA,CAAC;EACpCC,MAAM;EACNC,IAAI;EACJC,WAAW;EACXC;AAAU,CACa;EACvB,OAAOH,MAAA,CAAOI,MAAM,CAAC,CAACC,OAAA,EAASC,KAAA;IAC7B;IACA;IACA,IACEd,uBAAC,CAAwBc,KAAA,KAAU,CAACb,SAAA,CAAUa,KAAA,KAC7C,aAAaA,KAAA,IAASA,KAAA,CAAMC,OAAO,KAAK,MACzC;MACA,OAAOF,OAAA;IACT;IAEA;IACA,IAAI,aAAaC,KAAA,IAAS,OAAOA,KAAA,CAAMC,OAAO,KAAK,UAAU;MAC3D,MAAMC,SAAA,GAAY,OAAC,IAAWF,KAAA,IAASA,KAAA,CAAMG,KAAK,IAAM,UAAUH,KAAA,IAASA,KAAA,CAAMI,IAAI,IAAK;MAC1F,MAAMC,cAAA,GAAiBrB,cAAA,CAAekB,SAAA,EAAWP,IAAA;MAEjDI,OAA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AE;MAEL,MAAMlB,cAAA,GAAiBrB,cAAA,CAAegB,KAAA,CAAMG,KAAK,IAAI,IAAIR,IAAA;MAEzD,MAAMkC,cAAA,GAAiBjC,WAAA,GACnBJ,iBAAA,CAAkB;QAChBQ,KAAA;QACA8B,MAAA,EAAQlC;MACV,KACAS,cAAA;MAEJ,MAAM0B,SAAA,GAAYlC,UAAA,GAAaN,2BAAA,CAA4BM,UAAA,EAAYG,KAAA,IAASA,KAAA,CAAMI,IAAI;MAE1F,MAAM4B,cAAA,GAA+B;QACnC7B,KAAA,EAAO0B,cAAA;QACPtB,cAAA,EAAgB,GAAGX,WAAA,GAAcA,WAAA,GAAc,QAAQ,KAAKS,cAAA,EAAgB;QAC5EG,KAAA,EAAOuB,SAAA;QACP,GAAG1C,UAAU,CAACW,KAAA,CAAMS,IAAI,CAAC;QACzBT,KAAA;QACAU;MACF;MAEAX,OAAA,CAAQO,IAAI,CAAC0B,cAAA;MACb,OAAOjC,OAAA;IACT;IACA,OAAOA,OAAA;EACT,GAAG,EAAE;AACP","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"reduceFieldsToOptions.js","names":["getTranslation","fieldAffectsData","fieldIsHiddenOrDisabled","fieldIsID","tabHasName","fieldTypes","arrayOperators","createNestedClientFieldPath","combineFieldLabel","reduceFieldsToOptions","fields","i18n","labelPrefix","pathPrefix","reduce","reduced","field","virtual","baseLabel","label","name","localizedLabel","push","plainTextLabel","value","type","operators","tabs","forEach","tab","localizedTabLabel","labelWithPrefix","tabPathPrefix","translatedLabel","pathWithPrefix","operatorKeys","Set","fieldOperators","hasMany","acc","operator","has","add","operatorKey","t","formattedLabel","prefix","fieldPath","formattedField"],"sources":["../../src/utilities/reduceFieldsToOptions.tsx"],"sourcesContent":["'use client'\nimport type { ClientTranslationKeys, I18nClient } from '@payloadcms/translations'\nimport type { ClientField } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { fieldAffectsData, fieldIsHiddenOrDisabled, fieldIsID, tabHasName } from 'payload/shared'\n\nimport type { ReducedField } from '../elements/WhereBuilder/types.js'\n\nimport fieldTypes, { arrayOperators } from '../elements/WhereBuilder/field-types.js'\nimport { createNestedClientFieldPath } from '../forms/Form/createNestedClientFieldPath.js'\nimport { combineFieldLabel } from './combineFieldLabel.js'\n\ntype ReduceFieldOptionsArgs = {\n fields: ClientField[]\n i18n: I18nClient\n labelPrefix?: string\n pathPrefix?: string\n}\n\n/**\n * Transforms a fields schema into a flattened array of fields with labels and values.\n * Used in the `WhereBuilder` component to render the fields in the dropdown.\n */\nexport const reduceFieldsToOptions = ({\n fields,\n i18n,\n labelPrefix,\n pathPrefix,\n}: ReduceFieldOptionsArgs): ReducedField[] => {\n return fields.reduce((reduced, field) => {\n // Do not filter out `field.admin.disableListFilter` fields here, as these should still render as disabled if they appear in the URL query\n // Filter out `virtual: true` fields since they are regular virtuals and not backed by a DB field\n if (\n (fieldIsHiddenOrDisabled(field) && !fieldIsID(field)) ||\n ('virtual' in field && field.virtual === true)\n ) {\n return reduced\n }\n\n // Handle virtual:string fields (virtual relationships, e.g. \"post.title\")\n if ('virtual' in field && typeof field.virtual === 'string') {\n const baseLabel = ('label' in field && field.label) || ('name' in field && field.name) || ''\n const localizedLabel = getTranslation(baseLabel, i18n)\n\n reduced.push({\n label: localizedLabel,\n plainTextLabel: localizedLabel,\n value: field.virtual, // e.g. \"post.title\"\n ...fieldTypes[field.type],\n field,\n operators: fieldTypes[field.type].operators,\n })\n return reduced\n }\n\n if (field.type === 'tabs' && 'tabs' in field) {\n const tabs = field.tabs\n\n tabs.forEach((tab) => {\n if (typeof tab.label !== 'boolean') {\n const localizedTabLabel = getTranslation(tab.label, i18n)\n\n const labelWithPrefix = labelPrefix\n ? labelPrefix + ' > ' + localizedTabLabel\n : localizedTabLabel\n\n // Make sure we handle nested tabs\n const tabPathPrefix =\n tabHasName(tab) && tab.name\n ? pathPrefix\n ? pathPrefix + '.' + tab.name\n : tab.name\n : pathPrefix\n\n if (typeof localizedTabLabel === 'string') {\n reduced.push(\n ...reduceFieldsToOptions({\n fields: tab.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix: tabPathPrefix,\n }),\n )\n }\n }\n })\n return reduced\n }\n\n // Rows cant have labels, so we need to handle them differently\n if (field.type === 'row' && 'fields' in field) {\n reduced.push(\n ...reduceFieldsToOptions({\n fields: field.fields,\n i18n,\n labelPrefix,\n pathPrefix,\n }),\n )\n return reduced\n }\n\n if (field.type === 'collapsible' && 'fields' in field) {\n const localizedTabLabel = getTranslation(field.label || '', i18n)\n\n const labelWithPrefix = labelPrefix\n ? labelPrefix + ' > ' + localizedTabLabel\n : localizedTabLabel\n\n reduced.push(\n ...reduceFieldsToOptions({\n fields: field.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix,\n }),\n )\n return reduced\n }\n\n if (field.type === 'group' && 'fields' in field) {\n const translatedLabel = getTranslation(field.label || '', i18n)\n\n const labelWithPrefix = labelPrefix\n ? translatedLabel\n ? labelPrefix + ' > ' + translatedLabel\n : labelPrefix\n : translatedLabel\n\n if (fieldAffectsData(field)) {\n // Make sure we handle deeply nested groups\n const pathWithPrefix = field.name\n ? pathPrefix\n ? pathPrefix + '.' + field.name\n : field.name\n : pathPrefix\n\n reduced.push(\n ...reduceFieldsToOptions({\n fields: field.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix: pathWithPrefix,\n }),\n )\n } else {\n reduced.push(\n ...reduceFieldsToOptions({\n fields: field.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix,\n }),\n )\n }\n\n return reduced\n }\n\n if (field.type === 'array' && 'fields' in field) {\n const translatedLabel = getTranslation(field.label || '', i18n)\n\n const labelWithPrefix = labelPrefix\n ? translatedLabel\n ? labelPrefix + ' > ' + translatedLabel\n : labelPrefix\n : translatedLabel\n\n // Make sure we handle deeply nested groups\n const pathWithPrefix = field.name\n ? pathPrefix\n ? pathPrefix + '.' + field.name\n : field.name\n : pathPrefix\n\n reduced.push(\n ...reduceFieldsToOptions({\n fields: field.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix: pathWithPrefix,\n }),\n )\n\n return reduced\n }\n\n if (typeof fieldTypes[field.type] === 'object') {\n const operatorKeys = new Set()\n\n const fieldOperators =\n 'hasMany' in field && field.hasMany ? arrayOperators : fieldTypes[field.type].operators\n\n const operators = fieldOperators.reduce((acc, operator) => {\n if (!operatorKeys.has(operator.value)) {\n operatorKeys.add(operator.value)\n const operatorKey = `operators:${operator.label}` as ClientTranslationKeys\n acc.push({\n ...operator,\n label: i18n.t(operatorKey),\n })\n }\n\n return acc\n }, [])\n\n const localizedLabel = getTranslation(field.label || '', i18n)\n\n const formattedLabel = labelPrefix\n ? combineFieldLabel({\n field,\n prefix: labelPrefix,\n })\n : localizedLabel\n\n const fieldPath = pathPrefix ? createNestedClientFieldPath(pathPrefix, field) : field.name\n\n const formattedField: ReducedField = {\n label: formattedLabel,\n plainTextLabel: `${labelPrefix ? labelPrefix + ' > ' : ''}${localizedLabel}`,\n value: fieldPath,\n ...fieldTypes[field.type],\n field,\n operators,\n }\n\n reduced.push(formattedField)\n return reduced\n }\n return reduced\n }, [])\n}\n"],"mappings":"AAAA;;AAIA,SAASA,cAAc,QAAQ;AAC/B,SAASC,gBAAgB,EAAEC,uBAAuB,EAAEC,SAAS,EAAEC,UAAU,QAAQ;AAIjF,OAAOC,UAAA,IAAcC,cAAc,QAAQ;AAC3C,SAASC,2BAA2B,QAAQ;AAC5C,SAASC,iBAAiB,QAAQ;AASlC;;;;AAIA,OAAO,MAAMC,qBAAA,GAAwBA,CAAC;EACpCC,MAAM;EACNC,IAAI;EACJC,WAAW;EACXC;AAAU,CACa;EACvB,OAAOH,MAAA,CAAOI,MAAM,CAAC,CAACC,OAAA,EAASC,KAAA;IAC7B;IACA;IACA,IACEd,uBAAC,CAAwBc,KAAA,KAAU,CAACb,SAAA,CAAUa,KAAA,KAC7C,aAAaA,KAAA,IAASA,KAAA,CAAMC,OAAO,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aM,GAAG,CAACD,QAAA,CAAShB,KAAK,GAAG;UACrCW,YAAA,CAAaO,GAAG,CAACF,QAAA,CAAShB,KAAK;UAC/B,MAAMmB,WAAA,GAAc,aAAaH,QAAA,CAASrB,KAAK,EAAE;UACjDoB,GAAA,CAAIjB,IAAI,CAAC;YACP,GAAGkB,QAAQ;YACXrB,KAAA,EAAOR,IAAA,CAAKiC,CAAC,CAACD,WAAA;UAChB;QACF;QAEA,OAAOJ,GAAA;MACT,GAAG,EAAE;MAEL,MAAMlB,cAAA,GAAiBrB,cAAA,CAAegB,KAAA,CAAMG,KAAK,IAAI,IAAIR,IAAA;MAEzD,MAAMkC,cAAA,GAAiBjC,WAAA,GACnBJ,iBAAA,CAAkB;QAChBQ,KAAA;QACA8B,MAAA,EAAQlC;MACV,KACAS,cAAA;MAEJ,MAAM0B,SAAA,GAAYlC,UAAA,GAAaN,2BAAA,CAA4BM,UAAA,EAAYG,KAAA,IAASA,KAAA,CAAMI,IAAI;MAE1F,MAAM4B,cAAA,GAA+B;QACnC7B,KAAA,EAAO0B,cAAA;QACPtB,cAAA,EAAgB,GAAGX,WAAA,GAAcA,WAAA,GAAc,QAAQ,KAAKS,cAAA,EAAgB;QAC5EG,KAAA,EAAOuB,SAAA;QACP,GAAG1C,UAAU,CAACW,KAAA,CAAMS,IAAI,CAAC;QACzBT,KAAA;QACAU;MACF;MAEAX,OAAA,CAAQO,IAAI,CAAC0B,cAAA;MACb,OAAOjC,OAAA;IACT;IACA,OAAOA,OAAA;EACT,GAAG,EAAE;AACP","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/ui",
|
|
3
|
-
"version": "3.56.0-internal.
|
|
3
|
+
"version": "3.56.0-internal.457de85",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
"ts-essentials": "10.0.3",
|
|
137
137
|
"use-context-selector": "2.0.0",
|
|
138
138
|
"uuid": "10.0.0",
|
|
139
|
-
"@payloadcms/translations": "3.56.0-internal.
|
|
139
|
+
"@payloadcms/translations": "3.56.0-internal.457de85"
|
|
140
140
|
},
|
|
141
141
|
"devDependencies": {
|
|
142
142
|
"@babel/cli": "7.27.2",
|
|
@@ -151,14 +151,14 @@
|
|
|
151
151
|
"babel-plugin-react-compiler": "19.1.0-rc.2",
|
|
152
152
|
"esbuild": "0.25.5",
|
|
153
153
|
"esbuild-sass-plugin": "3.3.1",
|
|
154
|
-
"
|
|
155
|
-
"
|
|
154
|
+
"@payloadcms/eslint-config": "3.28.0",
|
|
155
|
+
"payload": "3.56.0-internal.457de85"
|
|
156
156
|
},
|
|
157
157
|
"peerDependencies": {
|
|
158
158
|
"next": "^15.2.3",
|
|
159
159
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
160
160
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
161
|
-
"payload": "3.56.0-internal.
|
|
161
|
+
"payload": "3.56.0-internal.457de85"
|
|
162
162
|
},
|
|
163
163
|
"engines": {
|
|
164
164
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
// Workaround for react-datepicker and other cjs dependencies potentially inserting require("react") statements
|
|
3
|
-
import * as requireReact from 'react';
|
|
4
|
-
import * as requireReactDom from 'react-dom';
|
|
5
|
-
|
|
6
|
-
function require(m) {
|
|
7
|
-
if (m === 'react') return requireReact;
|
|
8
|
-
if (m === 'react-dom') return requireReactDom;
|
|
9
|
-
throw new Error(`Unknown module ${m}`);
|
|
10
|
-
}
|
|
11
|
-
// Workaround end
|
|
12
|
-
|
|
13
|
-
import{c as Er}from"react/compiler-runtime";import{jsx as qe}from"react/jsx-runtime";function Ke(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function le(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),r.push.apply(r,n)}return r}function ne(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?le(Object(r),!0).forEach(function(n){Ke(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):le(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Ge(t,e){if(t==null)return{};var r={},n=Object.keys(t),o,i;for(i=0;i<n.length;i++)o=n[i],!(e.indexOf(o)>=0)&&(r[o]=t[o]);return r}function de(t,e){if(t==null)return{};var r=Ge(t,e),n,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)n=i[o],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function me(t,e){return Ye(t)||Je(t,e)||Qe(t,e)||Xe()}function Ye(t){if(Array.isArray(t))return t}function Je(t,e){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(t)))){var r=[],n=!0,o=!1,i=void 0;try{for(var a=t[Symbol.iterator](),c;!(n=(c=a.next()).done)&&(r.push(c.value),!(e&&r.length===e));n=!0);}catch(u){o=!0,i=u}finally{try{!n&&a.return!=null&&a.return()}finally{if(o)throw i}}return r}}function Qe(t,e){if(t){if(typeof t=="string")return fe(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return fe(t,e)}}function fe(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Xe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
14
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ze(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function pe(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),r.push.apply(r,n)}return r}function ge(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?pe(Object(r),!0).forEach(function(n){Ze(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):pe(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function et(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return function(n){return e.reduceRight(function(o,i){return i(o)},n)}}function V(t){return function e(){for(var r=this,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=t.length?t.apply(this,o):function(){for(var a=arguments.length,c=new Array(a),u=0;u<a;u++)c[u]=arguments[u];return e.apply(r,[].concat(o,c))}}}function G(t){return{}.toString.call(t).includes("Object")}function tt(t){return!Object.keys(t).length}function B(t){return typeof t=="function"}function rt(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function nt(t,e){return G(e)||k("changeType"),Object.keys(e).some(function(r){return!rt(t,r)})&&k("changeField"),e}function ot(t){B(t)||k("selectorType")}function it(t){B(t)||G(t)||k("handlerType"),G(t)&&Object.values(t).some(function(e){return!B(e)})&&k("handlersType")}function at(t){t||k("initialIsRequired"),G(t)||k("initialType"),tt(t)&&k("initialContent")}function ct(t,e){throw new Error(t[e]||t.default)}var ut={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},k=V(ct)(ut),K={changes:nt,selector:ot,handler:it,initial:at};function st(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};K.initial(t),K.handler(e);var r={current:t},n=V(dt)(r,e),o=V(ft)(r),i=V(K.changes)(t),a=V(lt)(r);function c(){var f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(s){return s};return K.selector(f),f(r.current)}function u(f){et(n,o,i,a)(f)}return[c,u]}function lt(t,e){return B(e)?e(t.current):e}function ft(t,e){return t.current=ge(ge({},t.current),e),e}function dt(t,e,r){return B(e)?e(t.current):Object.keys(r).forEach(function(n){var o;return(o=e[n])===null||o===void 0?void 0:o.call(e,t.current[n])}),r}var mt={create:st},he=mt;var pt={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.2/min/vs"}},ve=pt;function gt(t){return function e(){for(var r=this,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=t.length?t.apply(this,o):function(){for(var a=arguments.length,c=new Array(a),u=0;u<a;u++)c[u]=arguments[u];return e.apply(r,[].concat(o,c))}}}var be=gt;function ht(t){return{}.toString.call(t).includes("Object")}var ye=ht;function vt(t){return t||we("configIsRequired"),ye(t)||we("configType"),t.urls?(bt(),{paths:{vs:t.urls.monacoBase}}):t}function bt(){console.warn(Oe.deprecation)}function yt(t,e){throw new Error(t[e]||t.default)}var Oe={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
15
|
-
You are using deprecated way of configuration.
|
|
16
|
-
|
|
17
|
-
Instead of using
|
|
18
|
-
monaco.config({ urls: { monacoBase: '...' } })
|
|
19
|
-
use
|
|
20
|
-
monaco.config({ paths: { vs: '...' } })
|
|
21
|
-
|
|
22
|
-
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
23
|
-
`},we=be(yt)(Oe),wt={config:vt},je=wt;var Ot=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return function(o){return r.reduceRight(function(i,a){return a(i)},o)}},Me=Ot;function Se(t,e){return Object.keys(e).forEach(function(r){e[r]instanceof Object&&t[r]&&Object.assign(e[r],Se(t[r],e[r]))}),ne(ne({},t),e)}var xe=Se;var jt={type:"cancelation",msg:"operation is manually canceled"};function Mt(t){var e=!1,r=new Promise(function(n,o){t.then(function(i){return e?o(jt):n(i)}),t.catch(o)});return r.cancel=function(){return e=!0},r}var Y=Mt;var St=he.create({config:ve,isInitialized:!1,resolve:null,reject:null,monaco:null}),Ee=me(St,2),H=Ee[0],J=Ee[1];function xt(t){var e=je.config(t),r=e.monaco,n=de(e,["monaco"]);J(function(o){return{config:xe(o.config,n),monaco:r}})}function Et(){var t=H(function(e){var r=e.monaco,n=e.isInitialized,o=e.resolve;return{monaco:r,isInitialized:n,resolve:o}});if(!t.isInitialized){if(J({isInitialized:!0}),t.monaco)return t.resolve(t.monaco),Y(oe);if(window.monaco&&window.monaco.editor)return Ce(window.monaco),t.resolve(window.monaco),Y(oe);Me(Ct,Tt)(It)}return Y(oe)}function Ct(t){return document.body.appendChild(t)}function Pt(t){var e=document.createElement("script");return t&&(e.src=t),e}function Tt(t){var e=H(function(n){var o=n.config,i=n.reject;return{config:o,reject:i}}),r=Pt("".concat(e.config.paths.vs,"/loader.js"));return r.onload=function(){return t()},r.onerror=e.reject,r}function It(){var t=H(function(r){var n=r.config,o=r.resolve,i=r.reject;return{config:n,resolve:o,reject:i}}),e=window.require;e.config(t.config),e(["vs/editor/editor.main"],function(r){Ce(r),t.resolve(r)},function(r){t.reject(r)})}function Ce(t){H().monaco||J({monaco:t})}function Rt(){return H(function(t){var e=t.monaco;return e})}var oe=new Promise(function(t,e){return J({resolve:t,reject:e})}),At={config:xt,init:Et,__getMonacoInstance:Rt},L=At;import{memo as Dt}from"react";import kt,{useState as Pe,useRef as _,useCallback as Te,useEffect as Ie}from"react";import{memo as Lt}from"react";import ie from"react";import $t from"react";import{useEffect as qt}from"react";import{useEffect as Kt,useRef as Gt}from"react";import{useState as mn}from"react";import{memo as er}from"react";import tr,{useState as Re,useEffect as Q,useRef as A,useCallback as rr}from"react";import{useEffect as nr,useRef as or}from"react";var _t={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},ae=_t,Wt={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Nt=Wt;function Vt({children:t}){return $t.createElement("div",{style:Nt.container},t)}var Bt=Vt,Ht=Bt;function Ft({width:t,height:e,isEditorReady:r,loading:n,_ref:o,className:i,wrapperProps:a}){return ie.createElement("section",{style:{...ae.wrapper,width:t,height:e},...a},!r&&ie.createElement(Ht,null,n),ie.createElement("div",{ref:o,style:{...ae.fullWidth,...!r&&ae.hide},className:i}))}var Ut=Ft,Ae=Lt(Ut);function zt(t){qt(t,[])}var De=zt;function Yt(t,e,r=!0){let n=Gt(!0);Kt(n.current||!r?()=>{n.current=!1}:t,e)}var E=Yt;function F(){}function $(t,e,r,n){return Jt(t,n)||Qt(t,e,r,n)}function Jt(t,e){return t.editor.getModel(ke(t,e))}function Qt(t,e,r,n){return t.editor.createModel(e,r,n?ke(t,n):void 0)}function ke(t,e){return t.Uri.parse(e)}function Xt({original:t,modified:e,language:r,originalLanguage:n,modifiedLanguage:o,originalModelPath:i,modifiedModelPath:a,keepCurrentOriginalModel:c=!1,keepCurrentModifiedModel:u=!1,theme:f="light",loading:s="Loading...",options:l={},height:m="100%",width:h="100%",className:O,wrapperProps:j={},beforeMount:M=F,onMount:C=F}){let[w,I]=Pe(!1),[P,b]=Pe(!0),y=_(null),p=_(null),T=_(null),v=_(C),d=_(M),R=_(!1);De(()=>{let g=L.init();return g.then(S=>(p.current=S)&&b(!1)).catch(S=>S?.type!=="cancelation"&&console.error("Monaco initialization: error:",S)),()=>y.current?N():g.cancel()}),E(()=>{if(y.current&&p.current){let g=y.current.getOriginalEditor(),S=$(p.current,t||"",n||r||"text",i||"");S!==g.getModel()&&g.setModel(S)}},[i],w),E(()=>{if(y.current&&p.current){let g=y.current.getModifiedEditor(),S=$(p.current,e||"",o||r||"text",a||"");S!==g.getModel()&&g.setModel(S)}},[a],w),E(()=>{let g=y.current.getModifiedEditor();g.getOption(p.current.editor.EditorOption.readOnly)?g.setValue(e||""):e!==g.getValue()&&(g.executeEdits("",[{range:g.getModel().getFullModelRange(),text:e||"",forceMoveMarkers:!0}]),g.pushUndoStop())},[e],w),E(()=>{y.current?.getModel()?.original.setValue(t||"")},[t],w),E(()=>{let{original:g,modified:S}=y.current.getModel();p.current.editor.setModelLanguage(g,n||r||"text"),p.current.editor.setModelLanguage(S,o||r||"text")},[r,n,o],w),E(()=>{p.current?.editor.setTheme(f)},[f],w),E(()=>{y.current?.updateOptions(l)},[l],w);let q=Te(()=>{if(!p.current)return;d.current(p.current);let g=$(p.current,t||"",n||r||"text",i||""),S=$(p.current,e||"",o||r||"text",a||"");y.current?.setModel({original:g,modified:S})},[r,e,o,t,n,i,a]),z=Te(()=>{!R.current&&T.current&&(y.current=p.current.editor.createDiffEditor(T.current,{automaticLayout:!0,...l}),q(),p.current?.editor.setTheme(f),I(!0),R.current=!0)},[l,f,q]);Ie(()=>{w&&v.current(y.current,p.current)},[w]),Ie(()=>{!P&&!w&&z()},[P,w,z]);function N(){let g=y.current?.getModel();c||g?.original?.dispose(),u||g?.modified?.dispose(),y.current?.dispose()}return kt.createElement(Ae,{width:h,height:m,isEditorReady:w,loading:s,_ref:T,className:O,wrapperProps:j})}var Zt=Xt,fn=Dt(Zt);function ir(t){let e=or();return nr(()=>{e.current=t},[t]),e.current}var ar=ir,X=new Map;function cr({defaultValue:t,defaultLanguage:e,defaultPath:r,value:n,language:o,path:i,theme:a="light",line:c,loading:u="Loading...",options:f={},overrideServices:s={},saveViewState:l=!0,keepCurrentModel:m=!1,width:h="100%",height:O="100%",className:j,wrapperProps:M={},beforeMount:C=F,onMount:w=F,onChange:I,onValidate:P=F}){let[b,y]=Re(!1),[p,T]=Re(!0),v=A(null),d=A(null),R=A(null),q=A(w),z=A(C),N=A(),g=A(n),S=ar(i),ue=A(!1),ee=A(!1);De(()=>{let x=L.init();return x.then(D=>(v.current=D)&&T(!1)).catch(D=>D?.type!=="cancelation"&&console.error("Monaco initialization: error:",D)),()=>d.current?ze():x.cancel()}),E(()=>{let x=$(v.current,t||n||"",e||o||"",i||r||"");x!==d.current?.getModel()&&(l&&X.set(S,d.current?.saveViewState()),d.current?.setModel(x),l&&d.current?.restoreViewState(X.get(i)))},[i],b),E(()=>{d.current?.updateOptions(f)},[f],b),E(()=>{!d.current||n===void 0||(d.current.getOption(v.current.editor.EditorOption.readOnly)?d.current.setValue(n):n!==d.current.getValue()&&(ee.current=!0,d.current.executeEdits("",[{range:d.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),d.current.pushUndoStop(),ee.current=!1))},[n],b),E(()=>{let x=d.current?.getModel();x&&o&&v.current?.editor.setModelLanguage(x,o)},[o],b),E(()=>{c!==void 0&&d.current?.revealLine(c)},[c],b),E(()=>{v.current?.editor.setTheme(a)},[a],b);let se=rr(()=>{if(!(!R.current||!v.current)&&!ue.current){z.current(v.current);let x=i||r,D=$(v.current,n||t||"",e||o||"",x||"");d.current=v.current?.editor.create(R.current,{model:D,automaticLayout:!0,...f},s),l&&d.current.restoreViewState(X.get(x)),v.current.editor.setTheme(a),c!==void 0&&d.current.revealLine(c),y(!0),ue.current=!0}},[t,e,r,n,o,i,f,s,l,a,c]);Q(()=>{b&&q.current(d.current,v.current)},[b]),Q(()=>{!p&&!b&&se()},[p,b,se]),g.current=n,Q(()=>{b&&I&&(N.current?.dispose(),N.current=d.current?.onDidChangeModelContent(x=>{ee.current||I(d.current.getValue(),x)}))},[b,I]),Q(()=>{if(b){let x=v.current.editor.onDidChangeMarkers(D=>{let te=d.current.getModel()?.uri;if(te&&D.find(re=>re.path===te.path)){let re=v.current.editor.getModelMarkers({resource:te});P?.(re)}});return()=>{x?.dispose()}}return()=>{}},[b,P]);function ze(){N.current?.dispose(),m?l&&X.set(i,d.current.saveViewState()):d.current.getModel()?.dispose(),d.current.dispose()}return tr.createElement(Ae,{width:h,height:O,isEditorReady:b,loading:u,_ref:R,className:j,wrapperProps:M})}var ur=cr,sr=er(ur),Z=sr;import{useState as Cr}from"react";import{c as hr}from"react/compiler-runtime";import{jsx as vr}from"react/jsx-runtime";import{createContext as br,use as yr,useEffect as wr,useState as Ve}from"react";import{jsx as lr}from"react/jsx-runtime";import{createContext as fr,use as dr,useCallback as Le,useEffect as mr,useMemo as _e,useRef as pr,useState as gr}from"react";var We=fr(void 0);function $e(t){if(!t?.blocks?.length||t.blocksMap)return t.blocksMap={},t;let e={...t};e.blocksMap={};for(let r of t.blocks)e.blocksMap[r.slug]=r;return e}var Mn=({children:t,config:e})=>{let[r,n]=gr(()=>$e(e)),o=pr(!0),i=Le(s=>{n($e(s))},[]);mr(()=>{if(o.current){o.current=!1;return}i(e)},[e,i]);let{collectionsBySlug:a,globalsBySlug:c}=_e(()=>{let s={},l={};for(let m of r.collections)s[m.slug]=m;for(let m of r.globals)l[m.slug]=m;return{collectionsBySlug:s,globalsBySlug:l}},[r]),u=Le(s=>"collectionSlug"in s?a[s.collectionSlug]??null:"globalSlug"in s?c[s.globalSlug]??null:null,[a,c]),f=_e(()=>({config:r,getEntityConfig:u,setConfig:i}),[r,u]);return lr(We,{value:f,children:t})},Ne=()=>dr(We);var Or={autoMode:!0,setTheme:()=>null,theme:"light"},He=br(Or);function Be(t,e,r){let n=new Date;n.setTime(n.getTime()+r*24*60*60*1e3);let o="expires="+n.toUTCString();document.cookie=t+"="+e+";"+o+";path=/"}var jr=t=>{let e,r=window.document.cookie.split("; ").find(n=>n.startsWith(`${t}=`))?.split("=")[1];return r==="light"||r==="dark"?e=r:e=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",document.documentElement.setAttribute("data-theme",e),{theme:e,themeFromCookies:r}},Mr="light",Rn=t=>{let e=hr(11),{children:r,theme:n}=t,{config:o}=Ne(),i=o.admin.theme,a=`${o.cookiePrefix||"payload"}-theme`,[c,u]=Ve(n||Mr),[f,s]=Ve(),l,m;e[0]!==a||e[1]!==i?(l=()=>{if(i!=="all")return;let{theme:M,themeFromCookies:C}=jr(a);u(M),s(!C)},m=[i,a],e[0]=a,e[1]=i,e[2]=l,e[3]=m):(l=e[2],m=e[3]),wr(l,m);let h;e[4]!==a?(h=M=>{if(M==="light"||M==="dark")u(M),s(!1),Be(a,M,365),document.documentElement.setAttribute("data-theme",M);else if(M==="auto"){Be(a,M,-1);let C=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";document.documentElement.setAttribute("data-theme",C),s(!0),u(C)}},e[4]=a,e[5]=h):h=e[5];let O=h,j;return e[6]!==f||e[7]!==r||e[8]!==O||e[9]!==c?(j=vr(He,{value:{autoMode:f,setTheme:O,theme:c},children:r}),e[6]=f,e[7]=r,e[8]=O,e[9]=c,e[10]=j):j=e[10],j},Fe=()=>yr(He);import{c as xr}from"react/compiler-runtime";import{jsx as U}from"react/jsx-runtime";import"react";import{c as Sr}from"react/compiler-runtime";import*as W from"react";var Ue=(t,e)=>{let r=Sr(9),n=e===void 0?!1:e,[o,i]=W.useState(!1),a=W.useRef(void 0),c;r[0]!==t?(c=()=>(i(!1),clearTimeout(a.current),a.current=setTimeout(()=>{i(!0)},t),()=>{clearTimeout(a.current)}),r[0]=t,r[1]=c):c=r[1];let u=c,f,s;r[2]!==u||r[3]!==n?(f=()=>{n&&u()},s=[u,n],r[2]=u,r[3]=n,r[4]=f,r[5]=s):(f=r[4],s=r[5]),W.useEffect(f,s);let l;return r[6]!==o||r[7]!==u?(l=[o,u],r[6]=o,r[7]=u,r[8]=l):l=r[8],l};var ce=({animationDelay:t="0ms",className:e,disableInlineStyles:r=!1,height:n="60px",width:o="100%"})=>U("div",{className:["shimmer-effect",e].filter(Boolean).join(" "),style:{height:!r&&(typeof n=="number"?`${n}px`:n),width:!r&&(typeof o=="number"?`${o}px`:o)},children:U("div",{className:"shimmer-effect__shine",style:{animationDelay:t}})}),Nn=t=>{let e=xr(7),{className:r,count:n,height:o,renderDelay:i,shimmerDelay:a,shimmerItemClassName:c,width:u}=t,f=i===void 0?500:i,s=a===void 0?25:a,l=typeof s=="number"?`${s}ms`:s,[m]=Ue(f,!0);if(!m)return null;let h;return e[0]!==r||e[1]!==n||e[2]!==o||e[3]!==l||e[4]!==c||e[5]!==u?(h=U("div",{className:r,children:[...Array(n)].map((O,j)=>U("div",{className:c,children:U(ce,{animationDelay:`calc(${j} * ${l})`,height:o,width:u})},j))}),e[0]=r,e[1]=n,e[2]=o,e[3]=l,e[4]=c,e[5]=u,e[6]=h):h=e[6],h};var Pr="default"in Z?Z.default:Z,Tr="code-editor",Ir=t=>{let e=Er(42),r,n,o,i,a,c;e[0]!==t?({className:r,maxHeight:n,minHeight:o,options:i,readOnly:a,...c}=t,e[0]=t,e[1]=r,e[2]=n,e[3]=o,e[4]=i,e[5]=a,e[6]=c):(r=e[1],n=e[2],o=e[3],i=e[4],a=e[5],c=e[6]);let u=o??56,f;e[7]!==i?(f=i||{},e[7]=i,e[8]=f):f=e[8];let s,l,m,h;e[9]!==f?({insertSpaces:l,tabSize:m,trimAutoWhitespace:h,...s}=f,e[9]=f,e[10]=s,e[11]=l,e[12]=m,e[13]=h):(s=e[10],l=e[11],m=e[12],h=e[13]);let O=i?.padding?(i.padding.top||0)+(i.padding?.bottom||0):0,[j,M]=Cr(u),{theme:C}=Fe(),w=c?.defaultLanguage?`language--${c.defaultLanguage}`:"",I=a&&"read-only",P;e[14]!==r||e[15]!==w||e[16]!==I?(P=[Tr,r,w,I].filter(Boolean),e[14]=r,e[15]=w,e[16]=I,e[17]=P):P=e[17];let b=P.join(" "),y;if(e[18]!==u||e[19]!==b||e[20]!==j||e[21]!==s||e[22]!==l||e[23]!==n||e[24]!==O||e[25]!==a||e[26]!==c||e[27]!==m||e[28]!==C||e[29]!==h){let p;e[31]!==u||e[32]!==O||e[33]!==c?(p=(v,d)=>{c.onChange?.(v,d),M(Math.max(u,v.split(`
|
|
24
|
-
`).length*18+2+O))},e[31]=u,e[32]=O,e[33]=c,e[34]=p):p=e[34];let T;e[35]!==u||e[36]!==l||e[37]!==O||e[38]!==c||e[39]!==m||e[40]!==h?(T=(v,d)=>{c.onMount?.(v,d);let R=v.getModel();R&&R.updateOptions({insertSpaces:l??!0,tabSize:m??4,trimAutoWhitespace:h??!0}),M(Math.max(u,v.getValue().split(`
|
|
25
|
-
`).length*18+2+O))},e[35]=u,e[36]=l,e[37]=O,e[38]=c,e[39]=m,e[40]=h,e[41]=T):T=e[41],y=qe(Pr,{className:b,loading:qe(ce,{height:j}),options:{detectIndentation:!1,hideCursorInOverviewRuler:!0,insertSpaces:!1,minimap:{enabled:!1},overviewRulerBorder:!1,readOnly:!!a,scrollbar:{alwaysConsumeMouseWheel:!1},scrollBeyondLastLine:!1,trimAutoWhitespace:!1,wordWrap:"on",...s},theme:C==="dark"?"vs-dark":"vs",...c,height:n?Math.min(j,n):j,onChange:p,onMount:T}),e[18]=u,e[19]=b,e[20]=j,e[21]=s,e[22]=l,e[23]=n,e[24]=O,e[25]=a,e[26]=c,e[27]=m,e[28]=C,e[29]=h,e[30]=y}else y=e[30];return y},Gn=Ir;export{Mn as a,Ne as b,Ue as c,ce as d,Nn as e,Mr as f,Rn as g,Fe as h,Gn as i};
|
|
26
|
-
//# sourceMappingURL=chunk-KPQQ5IUL.js.map
|
|
File without changes
|