@payloadcms/ui 3.59.0-internal.3d25465 → 3.59.0-internal.3d3f76c
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/Collapsible/index.d.ts +2 -15
- package/dist/elements/Collapsible/index.d.ts.map +1 -1
- package/dist/elements/Collapsible/index.js +60 -59
- package/dist/elements/Collapsible/index.js.map +1 -1
- package/dist/elements/Collapsible/index.scss +2 -6
- package/dist/elements/Nav/context.d.ts +0 -6
- package/dist/elements/Nav/context.d.ts.map +1 -1
- package/dist/elements/Nav/context.js +0 -6
- package/dist/elements/Nav/context.js.map +1 -1
- package/dist/elements/PageControls/index.d.ts +0 -9
- package/dist/elements/PageControls/index.d.ts.map +1 -1
- package/dist/elements/PageControls/index.js +45 -101
- package/dist/elements/PageControls/index.js.map +1 -1
- package/dist/elements/StickyToolbar/index.d.ts +0 -3
- package/dist/elements/StickyToolbar/index.d.ts.map +1 -1
- package/dist/elements/StickyToolbar/index.js +0 -3
- package/dist/elements/StickyToolbar/index.js.map +1 -1
- package/dist/exports/client/index.d.ts +1 -4
- 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 +4 -4
- package/dist/fields/Code/index.d.ts.map +1 -1
- package/dist/fields/Code/index.js +1 -3
- package/dist/fields/Code/index.js.map +1 -1
- package/dist/hooks/useControllableState.d.ts +0 -2
- package/dist/hooks/useControllableState.d.ts.map +1 -1
- package/dist/hooks/useControllableState.js +11 -44
- package/dist/hooks/useControllableState.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Code/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAWxE,OAAO,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Code/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAWxE,OAAO,cAAc,CAAA;AAkIrB,eAAO,MAAM,SAAS;;;;;;;+EAAoC,CAAA"}
|
|
@@ -25,7 +25,6 @@ const CodeFieldComponent = props => {
|
|
|
25
25
|
className,
|
|
26
26
|
description,
|
|
27
27
|
editorOptions,
|
|
28
|
-
editorProps,
|
|
29
28
|
language = 'javascript'
|
|
30
29
|
} = {},
|
|
31
30
|
label,
|
|
@@ -116,8 +115,7 @@ const CodeFieldComponent = props => {
|
|
|
116
115
|
value: stringValueRef.current,
|
|
117
116
|
wrapperProps: {
|
|
118
117
|
id: `field-${path?.replace(/\./g, '__')}`
|
|
119
|
-
}
|
|
120
|
-
...(editorProps || {})
|
|
118
|
+
}
|
|
121
119
|
}), AfterInput]
|
|
122
120
|
}), /*#__PURE__*/_jsx(RenderCustomComponent, {
|
|
123
121
|
CustomComponent: Description,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useCallback","useEffect","useMemo","useState","CodeEditor","RenderCustomComponent","FieldDescription","FieldError","FieldLabel","useField","withCondition","mergeFieldStyles","fieldBaseClass","prismToMonacoLanguageMap","js","ts","baseClass","CodeFieldComponent","props","field","admin","className","description","editorOptions","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","useEffect","useMemo","useState","CodeEditor","RenderCustomComponent","FieldDescription","FieldError","FieldLabel","useField","withCondition","mergeFieldStyles","fieldBaseClass","prismToMonacoLanguageMap","js","ts","baseClass","CodeFieldComponent","props","field","admin","className","description","editorOptions","language","label","localized","required","onMount","path","pathFromProps","readOnly","validate","inputChangeFromRef","useRef","recalculatedHeightAt","setRecalculatedHeightAt","Date","now","memoizedValidate","value","options","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","initialValue","setValue","showError","potentiallyStalePath","stringValueRef","undefined","handleChange","val","current","e","styles","_jsxs","filter","Boolean","join","style","_jsx","CustomComponent","Fallback","defaultLanguage","onChange","wrapperProps","id","replace","CodeField"],"sources":["../../../src/fields/Code/index.tsx"],"sourcesContent":["'use client'\nimport type { CodeFieldClientComponent } from 'payload'\n\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\n\nimport { CodeEditor } from '../../elements/CodeEditor/index.js'\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { FieldDescription } from '../../fields/FieldDescription/index.js'\nimport { FieldError } from '../../fields/FieldError/index.js'\nimport { FieldLabel } from '../../fields/FieldLabel/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { mergeFieldStyles } from '../mergeFieldStyles.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst prismToMonacoLanguageMap = {\n js: 'javascript',\n ts: 'typescript',\n}\n\nconst baseClass = 'code-field'\n\nconst CodeFieldComponent: CodeFieldClientComponent = (props) => {\n const {\n field,\n field: {\n admin: { className, description, editorOptions, language = 'javascript' } = {},\n label,\n localized,\n required,\n },\n onMount,\n path: pathFromProps,\n readOnly,\n validate,\n } = props\n\n const inputChangeFromRef = React.useRef<'formState' | 'internalEditor'>('formState')\n const [recalculatedHeightAt, setRecalculatedHeightAt] = useState<number | undefined>(Date.now())\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, required })\n }\n },\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled,\n initialValue,\n path,\n setValue,\n showError,\n value,\n } = useField<string>({\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const stringValueRef = React.useRef<string>(\n (value || initialValue) !== undefined ? (value ?? initialValue) : undefined,\n )\n\n const handleChange = useCallback(\n (val: string) => {\n if (readOnly || disabled) {\n return\n }\n inputChangeFromRef.current = 'internalEditor'\n\n try {\n setValue(val ? val : null)\n stringValueRef.current = val\n } catch (e) {\n setValue(val ? val : null)\n stringValueRef.current = val\n }\n },\n [readOnly, disabled, setValue],\n )\n\n useEffect(() => {\n if (inputChangeFromRef.current === 'formState') {\n stringValueRef.current =\n (value || initialValue) !== undefined ? (value ?? initialValue) : undefined\n setRecalculatedHeightAt(Date.now())\n }\n\n inputChangeFromRef.current = 'formState'\n }, [initialValue, path, value])\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && 'error',\n (readOnly || disabled) && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={styles}\n >\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n }\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {BeforeInput}\n <CodeEditor\n defaultLanguage={prismToMonacoLanguageMap[language] || language}\n onChange={handleChange}\n onMount={onMount}\n options={editorOptions}\n readOnly={readOnly || disabled}\n recalculatedHeightAt={recalculatedHeightAt}\n value={stringValueRef.current}\n wrapperProps={{\n id: `field-${path?.replace(/\\./g, '__')}`,\n }}\n />\n {AfterInput}\n </div>\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n )\n}\n\nexport const CodeField = withCondition(CodeFieldComponent)\n"],"mappings":"AAAA;;;AAGA,OAAOA,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AAEjE,SAASC,UAAU,QAAQ;AAC3B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,UAAU,QAAQ;AAC3B,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAC/B,OAA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qBAG1EiC,KAAA,CAAC;MAAIvC,SAAA,EAAW,GAAGT,cAAA,QAAsB;8BACvCqD,IAAA,CAAC5D,qBAAA;QACC6D,eAAA,EAAiBpB,KAAA;QACjBqB,QAAA,eAAUF,IAAA,CAAC1D,UAAA;UAAWsB,IAAA,EAAMA,IAAA;UAAMsB,SAAA,EAAWA;;UAE9CP,WAAA,E,aACDqB,IAAA,CAAC7D,UAAA;QACCgE,eAAA,EAAiBvD,wBAAwB,CAACW,QAAA,CAAS,IAAIA,QAAA;QACvD6C,QAAA,EAAUd,YAAA;QACV3B,OAAA,EAASA,OAAA;QACTa,OAAA,EAASlB,aAAA;QACTQ,QAAA,EAAUA,QAAA,IAAYiB,QAAA;QACtBb,oBAAA,EAAsBA,oBAAA;QACtBK,KAAA,EAAOa,cAAA,CAAeI,OAAO;QAC7Ba,YAAA,EAAc;UACZC,EAAA,EAAI,SAAS1C,IAAA,EAAM2C,OAAA,CAAQ,OAAO;QACpC;UAED7B,UAAA;qBAEHsB,IAAA,CAAC5D,qBAAA;MACC6D,eAAA,EAAiBrB,WAAA;MACjBsB,QAAA,eAAUF,IAAA,CAAC3D,gBAAA;QAAiBgB,WAAA,EAAaA,WAAA;QAAaO,IAAA,EAAMA;;;;AAIpE;AAEA,OAAO,MAAM4C,SAAA,GAAY/D,aAAA,CAAcO,kBAAA","ignoreList":[]}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A hook for managing state that can be controlled by props but also overridden locally.
|
|
3
3
|
* Props always take precedence if they change, but local state can override them temporarily.
|
|
4
|
-
*
|
|
5
|
-
* @internal - may change or be removed without a major version bump
|
|
6
4
|
*/
|
|
7
5
|
export declare function useControllableState<T>(propValue: T, defaultValue?: T): [T, (value: ((prev: T) => T) | T) => void];
|
|
8
6
|
//# sourceMappingURL=useControllableState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useControllableState.d.ts","sourceRoot":"","sources":["../../src/hooks/useControllableState.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useControllableState.d.ts","sourceRoot":"","sources":["../../src/hooks/useControllableState.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,SAAS,EAAE,CAAC,EACZ,YAAY,CAAC,EAAE,CAAC,GACf,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,CAkB5C"}
|
|
@@ -1,54 +1,21 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { c as _c } from "react/compiler-runtime";
|
|
4
1
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
5
2
|
/**
|
|
6
3
|
* A hook for managing state that can be controlled by props but also overridden locally.
|
|
7
4
|
* Props always take precedence if they change, but local state can override them temporarily.
|
|
8
|
-
*
|
|
9
|
-
* @internal - may change or be removed without a major version bump
|
|
10
5
|
*/
|
|
11
6
|
export function useControllableState(propValue, defaultValue) {
|
|
12
|
-
const $ = _c(6);
|
|
13
7
|
const [localValue, setLocalValue] = useState(propValue ?? defaultValue);
|
|
14
8
|
const initialRenderRef = useRef(true);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
$[0] = propValue;
|
|
27
|
-
$[1] = t0;
|
|
28
|
-
$[2] = t1;
|
|
29
|
-
} else {
|
|
30
|
-
t0 = $[1];
|
|
31
|
-
t1 = $[2];
|
|
32
|
-
}
|
|
33
|
-
useEffect(t0, t1);
|
|
34
|
-
let t2;
|
|
35
|
-
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
36
|
-
t2 = value => {
|
|
37
|
-
setLocalValue(value);
|
|
38
|
-
};
|
|
39
|
-
$[3] = t2;
|
|
40
|
-
} else {
|
|
41
|
-
t2 = $[3];
|
|
42
|
-
}
|
|
43
|
-
const setValue = t2;
|
|
44
|
-
let t3;
|
|
45
|
-
if ($[4] !== localValue) {
|
|
46
|
-
t3 = [localValue, setValue];
|
|
47
|
-
$[4] = localValue;
|
|
48
|
-
$[5] = t3;
|
|
49
|
-
} else {
|
|
50
|
-
t3 = $[5];
|
|
51
|
-
}
|
|
52
|
-
return t3;
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (initialRenderRef.current) {
|
|
11
|
+
initialRenderRef.current = false;
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
setLocalValue(propValue);
|
|
15
|
+
}, [propValue]);
|
|
16
|
+
const setValue = useCallback(value => {
|
|
17
|
+
setLocalValue(value);
|
|
18
|
+
}, []);
|
|
19
|
+
return [localValue, setValue];
|
|
53
20
|
}
|
|
54
21
|
//# sourceMappingURL=useControllableState.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useControllableState.js","names":["
|
|
1
|
+
{"version":3,"file":"useControllableState.js","names":["useCallback","useEffect","useRef","useState","useControllableState","propValue","defaultValue","localValue","setLocalValue","initialRenderRef","current","setValue","value"],"sources":["../../src/hooks/useControllableState.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react'\n\n/**\n * A hook for managing state that can be controlled by props but also overridden locally.\n * Props always take precedence if they change, but local state can override them temporarily.\n */\nexport function useControllableState<T>(\n propValue: T,\n defaultValue?: T,\n): [T, (value: ((prev: T) => T) | T) => void] {\n const [localValue, setLocalValue] = useState<T>(propValue ?? defaultValue)\n const initialRenderRef = useRef(true)\n\n useEffect(() => {\n if (initialRenderRef.current) {\n initialRenderRef.current = false\n return\n }\n\n setLocalValue(propValue)\n }, [propValue])\n\n const setValue = useCallback((value: ((prev: T) => T) | T) => {\n setLocalValue(value)\n }, [])\n\n return [localValue, setValue]\n}\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAEzD;;;;AAIA,OAAO,SAASC,qBACdC,SAAY,EACZC,YAAgB;EAEhB,MAAM,CAACC,UAAA,EAAYC,aAAA,CAAc,GAAGL,QAAA,CAAYE,SAAA,IAAaC,YAAA;EAC7D,MAAMG,gBAAA,GAAmBP,MAAA,CAAO;EAEhCD,SAAA,CAAU;IACR,IAAIQ,gBAAA,CAAiBC,OAAO,EAAE;MAC5BD,gBAAA,CAAiBC,OAAO,GAAG;MAC3B;IACF;IAEAF,aAAA,CAAcH,SAAA;EAChB,GAAG,CAACA,SAAA,CAAU;EAEd,MAAMM,QAAA,GAAWX,WAAA,CAAaY,KAAA;IAC5BJ,aAAA,CAAcI,KAAA;EAChB,GAAG,EAAE;EAEL,OAAO,CAACL,UAAA,EAAYI,QAAA,CAAS;AAC/B","ignoreList":[]}
|