@foundrykit/payload-fields 1.0.0 → 1.1.0

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/index.d.ts CHANGED
@@ -16,3 +16,4 @@ export { SOCIAL_PLATFORMS, socials } from './fields/socials/index.js';
16
16
  export { tags } from './fields/tags/index.js';
17
17
  export { tag } from './fields/tags/tag.js';
18
18
  export { default as deepMerge } from './utilities/deepMerge.js';
19
+ export { recordActivePlugin } from './utilities/recordActivePlugin.js';
package/dist/index.js CHANGED
@@ -17,5 +17,6 @@ export { SOCIAL_PLATFORMS, socials } from './fields/socials/index.js';
17
17
  export { tags } from './fields/tags/index.js';
18
18
  export { tag } from './fields/tags/tag.js';
19
19
  export { default as deepMerge } from './utilities/deepMerge.js';
20
+ export { recordActivePlugin } from './utilities/recordActivePlugin.js';
20
21
 
21
22
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Field factories and RSC-safe helpers: safe to import in payload.config and in Server Components.\n\nexport { address } from './fields/address/index.js';\nexport { bestTimeToVisitMonths } from './fields/bestTimeToVisit/index.js';\nexport { budgetField } from './fields/budget/index.js';\nexport { changedByFields } from './fields/changedBy/index.js';\nexport { populateChangedBy } from './fields/changedBy/populateChangedBy.js';\nexport {\n countryCodeField,\n ISO_COUNTRY_OPTIONS,\n} from './fields/countryCode/index.js';\nexport { dateRangeField } from './fields/dateRange/index.js';\nexport { gallery } from './fields/gallery/index.js';\nexport { ICONS, icon } from './fields/icon/index.js';\nexport {\n type ImageMapValue,\n imageMap,\n type Waypoint,\n} from './fields/imageMap/index.js';\nexport { type LinkOptions, link, linkGroup } from './fields/link/index.js';\nexport {\n type LinkValue,\n type ResolvedLink,\n resolveLink,\n} from './fields/link/resolveLink.js';\nexport { openingTimes } from './fields/openingTimes/index.js';\nexport { openingTime } from './fields/openingTimes/opening-time.js';\nexport { SOCIAL_PLATFORMS, socials } from './fields/socials/index.js';\nexport { tags } from './fields/tags/index.js';\nexport { tag } from './fields/tags/tag.js';\nexport { default as deepMerge } from './utilities/deepMerge.js';\n"],"names":["address","bestTimeToVisitMonths","budgetField","changedByFields","populateChangedBy","countryCodeField","ISO_COUNTRY_OPTIONS","dateRangeField","gallery","ICONS","icon","imageMap","link","linkGroup","resolveLink","openingTimes","openingTime","SOCIAL_PLATFORMS","socials","tags","tag","default","deepMerge"],"mappings":"AAAA,mGAAmG;AAEnG,SAASA,OAAO,QAAQ,4BAA4B;AACpD,SAASC,qBAAqB,QAAQ,oCAAoC;AAC1E,SAASC,WAAW,QAAQ,2BAA2B;AACvD,SAASC,eAAe,QAAQ,8BAA8B;AAC9D,SAASC,iBAAiB,QAAQ,0CAA0C;AAC5E,SACEC,gBAAgB,EAChBC,mBAAmB,QACd,gCAAgC;AACvC,SAASC,cAAc,QAAQ,8BAA8B;AAC7D,SAASC,OAAO,QAAQ,4BAA4B;AACpD,SAASC,KAAK,EAAEC,IAAI,QAAQ,yBAAyB;AACrD,SAEEC,QAAQ,QAEH,6BAA6B;AACpC,SAA2BC,IAAI,EAAEC,SAAS,QAAQ,yBAAyB;AAC3E,SAGEC,WAAW,QACN,+BAA+B;AACtC,SAASC,YAAY,QAAQ,iCAAiC;AAC9D,SAASC,WAAW,QAAQ,wCAAwC;AACpE,SAASC,gBAAgB,EAAEC,OAAO,QAAQ,4BAA4B;AACtE,SAASC,IAAI,QAAQ,yBAAyB;AAC9C,SAASC,GAAG,QAAQ,uBAAuB;AAC3C,SAASC,WAAWC,SAAS,QAAQ,2BAA2B"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Field factories and RSC-safe helpers: safe to import in payload.config and in Server Components.\n\nexport { address } from './fields/address/index.js';\nexport { bestTimeToVisitMonths } from './fields/bestTimeToVisit/index.js';\nexport { budgetField } from './fields/budget/index.js';\nexport { changedByFields } from './fields/changedBy/index.js';\nexport { populateChangedBy } from './fields/changedBy/populateChangedBy.js';\nexport {\n countryCodeField,\n ISO_COUNTRY_OPTIONS,\n} from './fields/countryCode/index.js';\nexport { dateRangeField } from './fields/dateRange/index.js';\nexport { gallery } from './fields/gallery/index.js';\nexport { ICONS, icon } from './fields/icon/index.js';\nexport {\n type ImageMapValue,\n imageMap,\n type Waypoint,\n} from './fields/imageMap/index.js';\nexport { type LinkOptions, link, linkGroup } from './fields/link/index.js';\nexport {\n type LinkValue,\n type ResolvedLink,\n resolveLink,\n} from './fields/link/resolveLink.js';\nexport { openingTimes } from './fields/openingTimes/index.js';\nexport { openingTime } from './fields/openingTimes/opening-time.js';\nexport { SOCIAL_PLATFORMS, socials } from './fields/socials/index.js';\nexport { tags } from './fields/tags/index.js';\nexport { tag } from './fields/tags/tag.js';\nexport { default as deepMerge } from './utilities/deepMerge.js';\nexport { recordActivePlugin } from './utilities/recordActivePlugin.js';\n"],"names":["address","bestTimeToVisitMonths","budgetField","changedByFields","populateChangedBy","countryCodeField","ISO_COUNTRY_OPTIONS","dateRangeField","gallery","ICONS","icon","imageMap","link","linkGroup","resolveLink","openingTimes","openingTime","SOCIAL_PLATFORMS","socials","tags","tag","default","deepMerge","recordActivePlugin"],"mappings":"AAAA,mGAAmG;AAEnG,SAASA,OAAO,QAAQ,4BAA4B;AACpD,SAASC,qBAAqB,QAAQ,oCAAoC;AAC1E,SAASC,WAAW,QAAQ,2BAA2B;AACvD,SAASC,eAAe,QAAQ,8BAA8B;AAC9D,SAASC,iBAAiB,QAAQ,0CAA0C;AAC5E,SACEC,gBAAgB,EAChBC,mBAAmB,QACd,gCAAgC;AACvC,SAASC,cAAc,QAAQ,8BAA8B;AAC7D,SAASC,OAAO,QAAQ,4BAA4B;AACpD,SAASC,KAAK,EAAEC,IAAI,QAAQ,yBAAyB;AACrD,SAEEC,QAAQ,QAEH,6BAA6B;AACpC,SAA2BC,IAAI,EAAEC,SAAS,QAAQ,yBAAyB;AAC3E,SAGEC,WAAW,QACN,+BAA+B;AACtC,SAASC,YAAY,QAAQ,iCAAiC;AAC9D,SAASC,WAAW,QAAQ,wCAAwC;AACpE,SAASC,gBAAgB,EAAEC,OAAO,QAAQ,4BAA4B;AACtE,SAASC,IAAI,QAAQ,yBAAyB;AAC9C,SAASC,GAAG,QAAQ,uBAAuB;AAC3C,SAASC,WAAWC,SAAS,QAAQ,2BAA2B;AAChE,SAASC,kBAAkB,QAAQ,oCAAoC"}
@@ -0,0 +1,7 @@
1
+ import type { Config } from 'payload';
2
+ /**
3
+ * Records a plugin as active in `config.custom.foundrykit.activePlugins`, the list
4
+ * `@foundrykit/guides-plugin` sends to the guides hub so the site gets that plugin's guides.
5
+ * Only call it on the enabled path: installed-but-disabled doesn't count.
6
+ */
7
+ export declare const recordActivePlugin: (config: Config, name: string) => Config;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Records a plugin as active in `config.custom.foundrykit.activePlugins`, the list
3
+ * `@foundrykit/guides-plugin` sends to the guides hub so the site gets that plugin's guides.
4
+ * Only call it on the enabled path: installed-but-disabled doesn't count.
5
+ */ export const recordActivePlugin = (config, name)=>{
6
+ const foundrykit = config.custom?.foundrykit ?? {};
7
+ return {
8
+ ...config,
9
+ custom: {
10
+ ...config.custom,
11
+ foundrykit: {
12
+ ...foundrykit,
13
+ activePlugins: [
14
+ ...new Set([
15
+ ...foundrykit.activePlugins ?? [],
16
+ name
17
+ ])
18
+ ]
19
+ }
20
+ }
21
+ };
22
+ };
23
+
24
+ //# sourceMappingURL=recordActivePlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/recordActivePlugin.ts"],"sourcesContent":["import type { Config } from 'payload';\n\n/**\n * Records a plugin as active in `config.custom.foundrykit.activePlugins`, the list\n * `@foundrykit/guides-plugin` sends to the guides hub so the site gets that plugin's guides.\n * Only call it on the enabled path: installed-but-disabled doesn't count.\n */\nexport const recordActivePlugin = (config: Config, name: string): Config => {\n const foundrykit = (config.custom?.foundrykit ?? {}) as {\n activePlugins?: string[];\n };\n return {\n ...config,\n custom: {\n ...config.custom,\n foundrykit: {\n ...foundrykit,\n activePlugins: [\n ...new Set([...(foundrykit.activePlugins ?? []), name]),\n ],\n },\n },\n };\n};\n"],"names":["recordActivePlugin","config","name","foundrykit","custom","activePlugins","Set"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,MAAMA,qBAAqB,CAACC,QAAgBC;IACjD,MAAMC,aAAcF,OAAOG,MAAM,EAAED,cAAc,CAAC;IAGlD,OAAO;QACL,GAAGF,MAAM;QACTG,QAAQ;YACN,GAAGH,OAAOG,MAAM;YAChBD,YAAY;gBACV,GAAGA,UAAU;gBACbE,eAAe;uBACV,IAAIC,IAAI;2BAAKH,WAAWE,aAAa,IAAI,EAAE;wBAAGH;qBAAK;iBACvD;YACH;QACF;IACF;AACF,EAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foundrykit/payload-fields",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Reusable field factories for Payload CMS 3: link, linkGroup, socials, icon, address, opening times, gallery, tags, image map and more, plus RSC-safe frontend helpers like resolveLink.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -39,25 +39,6 @@
39
39
  "files": [
40
40
  "dist"
41
41
  ],
42
- "scripts": {
43
- "build": "pnpm copyfiles && pnpm build:types && pnpm build:swc",
44
- "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths --ignore \"**/*.test.ts\" --ignore \"**/*.test.tsx\" --ignore \"**/*.d.ts\"",
45
- "build:types": "tsc --outDir dist --rootDir ./src",
46
- "clean": "rimraf {dist,*.tsbuildinfo}",
47
- "copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
48
- "dev": "next dev dev",
49
- "dev:generate-importmap": "pnpm dev:payload generate:importmap",
50
- "dev:generate-types": "pnpm dev:payload generate:types",
51
- "dev:payload": "cross-env PAYLOAD_CONFIG_PATH=./dev/payload.config.ts payload",
52
- "generate:importmap": "pnpm dev:generate-importmap",
53
- "generate:types": "pnpm dev:generate-types",
54
- "prepublishOnly": "pnpm build && node scripts/verify-pack.mjs",
55
- "verify:pack": "node scripts/verify-pack.mjs",
56
- "test": "pnpm test:unit && pnpm test:int",
57
- "test:unit": "vitest run src",
58
- "test:int": "vitest run dev/int.spec.ts",
59
- "test:e2e": "playwright test"
60
- },
61
42
  "dependencies": {
62
43
  "@radix-ui/react-context-menu": "^2.2.0",
63
44
  "@radix-ui/react-dialog": "^1.1.0",
@@ -66,30 +47,30 @@
66
47
  "lucide-react": "^0.378.0"
67
48
  },
68
49
  "devDependencies": {
69
- "@payloadcms/db-postgres": "catalog:",
70
- "@payloadcms/db-sqlite": "catalog:",
71
- "@payloadcms/next": "catalog:",
72
- "@payloadcms/richtext-lexical": "catalog:",
73
- "@payloadcms/ui": "catalog:",
74
- "@playwright/test": "catalog:",
50
+ "@payloadcms/db-postgres": "3.90.0",
51
+ "@payloadcms/db-sqlite": "3.90.0",
52
+ "@payloadcms/next": "3.90.0",
53
+ "@payloadcms/richtext-lexical": "3.90.0",
54
+ "@payloadcms/ui": "3.90.0",
55
+ "@playwright/test": "1.58.2",
75
56
  "@swc-node/register": "1.10.9",
76
- "@swc/cli": "catalog:",
57
+ "@swc/cli": "0.6.0",
77
58
  "@types/node": "22.19.9",
78
59
  "@types/react": "19.2.14",
79
60
  "@types/react-dom": "19.2.3",
80
61
  "copyfiles": "2.4.1",
81
62
  "cross-env": "^7.0.3",
82
63
  "graphql": "^16.8.1",
83
- "next": "catalog:",
84
- "payload": "catalog:",
85
- "react": "catalog:",
86
- "react-dom": "catalog:",
64
+ "next": "16.3.8",
65
+ "payload": "3.90.0",
66
+ "react": "19.2.8",
67
+ "react-dom": "19.2.8",
87
68
  "rimraf": "3.0.2",
88
69
  "sass": "^1.77.0",
89
70
  "sharp": "0.34.2",
90
- "typescript": "catalog:",
71
+ "typescript": "5.9.2",
91
72
  "vite-tsconfig-paths": "6.0.5",
92
- "vitest": "catalog:"
73
+ "vitest": "4.1.10"
93
74
  },
94
75
  "peerDependencies": {
95
76
  "@payloadcms/ui": "^3.84.0",
@@ -118,5 +99,23 @@
118
99
  "homepage": "https://github.com/umi-labs/foundry/tree/prod/packages/payload/payload-fields#readme",
119
100
  "bugs": {
120
101
  "url": "https://github.com/umi-labs/foundry/issues"
102
+ },
103
+ "scripts": {
104
+ "build": "pnpm copyfiles && pnpm build:types && pnpm build:swc",
105
+ "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths --ignore \"**/*.test.ts\" --ignore \"**/*.test.tsx\" --ignore \"**/*.d.ts\"",
106
+ "build:types": "tsc --outDir dist --rootDir ./src",
107
+ "clean": "rimraf {dist,*.tsbuildinfo}",
108
+ "copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
109
+ "dev": "next dev dev",
110
+ "dev:generate-importmap": "pnpm dev:payload generate:importmap",
111
+ "dev:generate-types": "pnpm dev:payload generate:types",
112
+ "dev:payload": "cross-env PAYLOAD_CONFIG_PATH=./dev/payload.config.ts payload",
113
+ "generate:importmap": "pnpm dev:generate-importmap",
114
+ "generate:types": "pnpm dev:generate-types",
115
+ "verify:pack": "node scripts/verify-pack.mjs",
116
+ "test": "pnpm test:unit && pnpm test:int",
117
+ "test:unit": "vitest run src",
118
+ "test:int": "vitest run dev/int.spec.ts",
119
+ "test:e2e": "playwright test"
121
120
  }
122
- }
121
+ }
@@ -1 +0,0 @@
1
- export declare const GalleryLabel: () => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- export const GalleryLabel = ()=>/*#__PURE__*/ _jsx("div", {
4
- children: "Gallery"
5
- });
6
-
7
- //# sourceMappingURL=RowLabel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/fields/gallery/RowLabel.tsx"],"sourcesContent":["'use client';\nexport const GalleryLabel = () => <div>Gallery</div>;\n"],"names":["GalleryLabel","div"],"mappings":"AAAA;;AACA,OAAO,MAAMA,eAAe,kBAAM,KAACC;kBAAI;OAAc"}
@@ -1,9 +0,0 @@
1
- import type { TextFieldClientProps } from 'payload';
2
- import type React from 'react';
3
- import './index.css';
4
- type SlugComponentProps = {
5
- fieldToUse: string;
6
- checkboxFieldPath: string;
7
- } & TextFieldClientProps;
8
- export declare const SlugComponent: React.FC<SlugComponentProps>;
9
- export {};
@@ -1,72 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { Button, FieldLabel, TextInput, useField, useForm, useFormFields } from '@payloadcms/ui';
4
- import { useCallback, useEffect } from 'react';
5
- import { formatSlug } from './formatSlug.js';
6
- import './index.css';
7
- export const SlugComponent = ({ field, fieldToUse, checkboxFieldPath: checkboxFieldPathFromProps, path, readOnly: readOnlyFromProps })=>{
8
- const { label } = field;
9
- const checkboxFieldPath = path?.includes('.') ? `${path}.${checkboxFieldPathFromProps}` : checkboxFieldPathFromProps;
10
- const { value, setValue } = useField({
11
- path: path || field.name
12
- });
13
- const { dispatchFields } = useForm();
14
- const checkboxValue = useFormFields(([fields])=>fields[checkboxFieldPath]?.value);
15
- const targetFieldValue = useFormFields(([fields])=>fields[fieldToUse]?.value);
16
- useEffect(()=>{
17
- if (checkboxValue) {
18
- if (targetFieldValue) {
19
- const formattedSlug = formatSlug(targetFieldValue);
20
- if (value !== formattedSlug) setValue(formattedSlug);
21
- } else if (value !== '') {
22
- setValue('');
23
- }
24
- }
25
- }, [
26
- targetFieldValue,
27
- checkboxValue,
28
- setValue,
29
- value
30
- ]);
31
- const handleLock = useCallback((e)=>{
32
- e.preventDefault();
33
- dispatchFields({
34
- type: 'UPDATE',
35
- path: checkboxFieldPath,
36
- value: !checkboxValue
37
- });
38
- }, [
39
- checkboxValue,
40
- checkboxFieldPath,
41
- dispatchFields
42
- ]);
43
- const readOnly = readOnlyFromProps || checkboxValue;
44
- return /*#__PURE__*/ _jsxs("div", {
45
- className: "field-type slug-field-component",
46
- children: [
47
- /*#__PURE__*/ _jsxs("div", {
48
- className: "label-wrapper",
49
- children: [
50
- /*#__PURE__*/ _jsx(FieldLabel, {
51
- htmlFor: `field-${path}`,
52
- label: label
53
- }),
54
- /*#__PURE__*/ _jsx(Button, {
55
- className: "lock-button",
56
- buttonStyle: "none",
57
- onClick: handleLock,
58
- children: checkboxValue ? 'Unlock' : 'Lock'
59
- })
60
- ]
61
- }),
62
- /*#__PURE__*/ _jsx(TextInput, {
63
- value: value,
64
- onChange: setValue,
65
- path: path || field.name,
66
- readOnly: Boolean(readOnly)
67
- })
68
- ]
69
- });
70
- };
71
-
72
- //# sourceMappingURL=SlugComponent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/fields/slug/SlugComponent.tsx"],"sourcesContent":["'use client';\n\nimport {\n Button,\n FieldLabel,\n TextInput,\n useField,\n useForm,\n useFormFields,\n} from '@payloadcms/ui';\nimport type { TextFieldClientProps } from 'payload';\nimport type React from 'react';\nimport { useCallback, useEffect } from 'react';\nimport { formatSlug } from './formatSlug.js';\nimport './index.css';\n\ntype SlugComponentProps = {\n fieldToUse: string;\n checkboxFieldPath: string;\n} & TextFieldClientProps;\n\nexport const SlugComponent: React.FC<SlugComponentProps> = ({\n field,\n fieldToUse,\n checkboxFieldPath: checkboxFieldPathFromProps,\n path,\n readOnly: readOnlyFromProps,\n}) => {\n const { label } = field;\n\n const checkboxFieldPath = path?.includes('.')\n ? `${path}.${checkboxFieldPathFromProps}`\n : checkboxFieldPathFromProps;\n\n const { value, setValue } = useField<string>({ path: path || field.name });\n const { dispatchFields } = useForm();\n\n const checkboxValue = useFormFields(\n ([fields]) => fields[checkboxFieldPath]?.value as string\n );\n const targetFieldValue = useFormFields(\n ([fields]) => fields[fieldToUse]?.value as string\n );\n\n useEffect(() => {\n if (checkboxValue) {\n if (targetFieldValue) {\n const formattedSlug = formatSlug(targetFieldValue);\n if (value !== formattedSlug) setValue(formattedSlug);\n } else if (value !== '') {\n setValue('');\n }\n }\n }, [targetFieldValue, checkboxValue, setValue, value]);\n\n const handleLock = useCallback(\n (e: React.MouseEvent<Element>) => {\n e.preventDefault();\n dispatchFields({\n type: 'UPDATE',\n path: checkboxFieldPath,\n value: !checkboxValue,\n });\n },\n [checkboxValue, checkboxFieldPath, dispatchFields]\n );\n\n const readOnly = readOnlyFromProps || checkboxValue;\n\n return (\n <div className='field-type slug-field-component'>\n <div className='label-wrapper'>\n <FieldLabel htmlFor={`field-${path}`} label={label} />\n <Button className='lock-button' buttonStyle='none' onClick={handleLock}>\n {checkboxValue ? 'Unlock' : 'Lock'}\n </Button>\n </div>\n <TextInput\n value={value}\n onChange={setValue}\n path={path || field.name}\n readOnly={Boolean(readOnly)}\n />\n </div>\n );\n};\n"],"names":["Button","FieldLabel","TextInput","useField","useForm","useFormFields","useCallback","useEffect","formatSlug","SlugComponent","field","fieldToUse","checkboxFieldPath","checkboxFieldPathFromProps","path","readOnly","readOnlyFromProps","label","includes","value","setValue","name","dispatchFields","checkboxValue","fields","targetFieldValue","formattedSlug","handleLock","e","preventDefault","type","div","className","htmlFor","buttonStyle","onClick","onChange","Boolean"],"mappings":"AAAA;;AAEA,SACEA,MAAM,EACNC,UAAU,EACVC,SAAS,EACTC,QAAQ,EACRC,OAAO,EACPC,aAAa,QACR,iBAAiB;AAGxB,SAASC,WAAW,EAAEC,SAAS,QAAQ,QAAQ;AAC/C,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,OAAO,cAAc;AAOrB,OAAO,MAAMC,gBAA8C,CAAC,EAC1DC,KAAK,EACLC,UAAU,EACVC,mBAAmBC,0BAA0B,EAC7CC,IAAI,EACJC,UAAUC,iBAAiB,EAC5B;IACC,MAAM,EAAEC,KAAK,EAAE,GAAGP;IAElB,MAAME,oBAAoBE,MAAMI,SAAS,OACrC,GAAGJ,KAAK,CAAC,EAAED,4BAA4B,GACvCA;IAEJ,MAAM,EAAEM,KAAK,EAAEC,QAAQ,EAAE,GAAGjB,SAAiB;QAAEW,MAAMA,QAAQJ,MAAMW,IAAI;IAAC;IACxE,MAAM,EAAEC,cAAc,EAAE,GAAGlB;IAE3B,MAAMmB,gBAAgBlB,cACpB,CAAC,CAACmB,OAAO,GAAKA,MAAM,CAACZ,kBAAkB,EAAEO;IAE3C,MAAMM,mBAAmBpB,cACvB,CAAC,CAACmB,OAAO,GAAKA,MAAM,CAACb,WAAW,EAAEQ;IAGpCZ,UAAU;QACR,IAAIgB,eAAe;YACjB,IAAIE,kBAAkB;gBACpB,MAAMC,gBAAgBlB,WAAWiB;gBACjC,IAAIN,UAAUO,eAAeN,SAASM;YACxC,OAAO,IAAIP,UAAU,IAAI;gBACvBC,SAAS;YACX;QACF;IACF,GAAG;QAACK;QAAkBF;QAAeH;QAAUD;KAAM;IAErD,MAAMQ,aAAarB,YACjB,CAACsB;QACCA,EAAEC,cAAc;QAChBP,eAAe;YACbQ,MAAM;YACNhB,MAAMF;YACNO,OAAO,CAACI;QACV;IACF,GACA;QAACA;QAAeX;QAAmBU;KAAe;IAGpD,MAAMP,WAAWC,qBAAqBO;IAEtC,qBACE,MAACQ;QAAIC,WAAU;;0BACb,MAACD;gBAAIC,WAAU;;kCACb,KAAC/B;wBAAWgC,SAAS,CAAC,MAAM,EAAEnB,MAAM;wBAAEG,OAAOA;;kCAC7C,KAACjB;wBAAOgC,WAAU;wBAAcE,aAAY;wBAAOC,SAASR;kCACzDJ,gBAAgB,WAAW;;;;0BAGhC,KAACrB;gBACCiB,OAAOA;gBACPiB,UAAUhB;gBACVN,MAAMA,QAAQJ,MAAMW,IAAI;gBACxBN,UAAUsB,QAAQtB;;;;AAI1B,EAAE"}
@@ -1,3 +0,0 @@
1
- import type { FieldHook } from 'payload';
2
- export declare const formatSlug: (val: string) => string;
3
- export declare const formatSlugHook: (fallback: string) => FieldHook;
@@ -1,17 +0,0 @@
1
- export const formatSlug = (val)=>val// Transliterate accented Latin characters to ASCII (á→a, é→e, ñ→n, …) by
2
- // decomposing to base char + combining mark, then dropping the marks.
3
- .normalize('NFKD').replace(/[̀-ͯ]/g, '').replace(/ /g, '-').replace(/[^\w-]+/g, '').toLowerCase();
4
- export const formatSlugHook = (fallback)=>({ data, operation, value })=>{
5
- if (typeof value === 'string') {
6
- return formatSlug(value);
7
- }
8
- if (operation === 'create' || !data?.slug) {
9
- const fallbackData = data?.[fallback];
10
- if (fallbackData && typeof fallbackData === 'string') {
11
- return formatSlug(fallbackData);
12
- }
13
- }
14
- return value;
15
- };
16
-
17
- //# sourceMappingURL=formatSlug.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/fields/slug/formatSlug.ts"],"sourcesContent":["import type { FieldHook } from 'payload';\n\nexport const formatSlug = (val: string): string =>\n val\n // Transliterate accented Latin characters to ASCII (á→a, é→e, ñ→n, …) by\n // decomposing to base char + combining mark, then dropping the marks.\n .normalize('NFKD')\n .replace(/[̀-ͯ]/g, '')\n .replace(/ /g, '-')\n .replace(/[^\\w-]+/g, '')\n .toLowerCase();\n\nexport const formatSlugHook =\n (fallback: string): FieldHook =>\n ({ data, operation, value }) => {\n if (typeof value === 'string') {\n return formatSlug(value);\n }\n if (operation === 'create' || !data?.slug) {\n const fallbackData = data?.[fallback];\n if (fallbackData && typeof fallbackData === 'string') {\n return formatSlug(fallbackData);\n }\n }\n return value;\n };\n"],"names":["formatSlug","val","normalize","replace","toLowerCase","formatSlugHook","fallback","data","operation","value","slug","fallbackData"],"mappings":"AAEA,OAAO,MAAMA,aAAa,CAACC,MACzBA,GACE,yEAAyE;IACzE,sEAAsE;KACrEC,SAAS,CAAC,QACVC,OAAO,CAAC,UAAU,IAClBA,OAAO,CAAC,MAAM,KACdA,OAAO,CAAC,YAAY,IACpBC,WAAW,GAAG;AAEnB,OAAO,MAAMC,iBACX,CAACC,WACD,CAAC,EAAEC,IAAI,EAAEC,SAAS,EAAEC,KAAK,EAAE;QACzB,IAAI,OAAOA,UAAU,UAAU;YAC7B,OAAOT,WAAWS;QACpB;QACA,IAAID,cAAc,YAAY,CAACD,MAAMG,MAAM;YACzC,MAAMC,eAAeJ,MAAM,CAACD,SAAS;YACrC,IAAIK,gBAAgB,OAAOA,iBAAiB,UAAU;gBACpD,OAAOX,WAAWW;YACpB;QACF;QACA,OAAOF;IACT,EAAE"}
@@ -1,11 +0,0 @@
1
- .slug-field-component {
2
- .label-wrapper {
3
- display: flex;
4
- justify-content: space-between;
5
- align-items: center;
6
- }
7
- .lock-button {
8
- margin: 0;
9
- padding-bottom: 0.3125rem;
10
- }
11
- }
@@ -1,12 +0,0 @@
1
- import type { CheckboxField, TextField } from 'payload';
2
- type Overrides = {
3
- slugOverrides?: Partial<TextField>;
4
- checkboxOverrides?: Partial<CheckboxField>;
5
- };
6
- type Slug = (fieldToUse?: string, overrides?: Overrides) => [TextField, CheckboxField];
7
- /**
8
- * A slug text field that auto-formats from a source field (default `title`),
9
- * with a lock toggle so editors can override it. Returns `[slugField, lockField]`.
10
- */
11
- export declare const slugField: Slug;
12
- export {};
@@ -1,49 +0,0 @@
1
- import { formatSlugHook } from './formatSlug.js';
2
- /**
3
- * A slug text field that auto-formats from a source field (default `title`),
4
- * with a lock toggle so editors can override it. Returns `[slugField, lockField]`.
5
- */ export const slugField = (fieldToUse = 'title', overrides = {})=>{
6
- const { slugOverrides, checkboxOverrides } = overrides;
7
- const checkBoxField = {
8
- name: 'slugLock',
9
- type: 'checkbox',
10
- defaultValue: true,
11
- admin: {
12
- hidden: true,
13
- position: 'sidebar'
14
- },
15
- ...checkboxOverrides
16
- };
17
- // @ts-expect-error - ts mismatch Partial<TextField> with TextField
18
- const slug = {
19
- name: 'slug',
20
- type: 'text',
21
- index: true,
22
- label: 'Slug',
23
- ...slugOverrides || {},
24
- hooks: {
25
- beforeValidate: [
26
- formatSlugHook(fieldToUse)
27
- ]
28
- },
29
- admin: {
30
- position: 'sidebar',
31
- ...slugOverrides?.admin || {},
32
- components: {
33
- Field: {
34
- path: '@foundrykit/payload-fields/client#SlugComponent',
35
- clientProps: {
36
- fieldToUse,
37
- checkboxFieldPath: checkBoxField.name
38
- }
39
- }
40
- }
41
- }
42
- };
43
- return [
44
- slug,
45
- checkBoxField
46
- ];
47
- };
48
-
49
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/fields/slug/index.ts"],"sourcesContent":["import type { CheckboxField, TextField } from 'payload';\nimport { formatSlugHook } from './formatSlug.js';\n\ntype Overrides = {\n slugOverrides?: Partial<TextField>;\n checkboxOverrides?: Partial<CheckboxField>;\n};\n\ntype Slug = (\n fieldToUse?: string,\n overrides?: Overrides\n) => [TextField, CheckboxField];\n\n/**\n * A slug text field that auto-formats from a source field (default `title`),\n * with a lock toggle so editors can override it. Returns `[slugField, lockField]`.\n */\nexport const slugField: Slug = (fieldToUse = 'title', overrides = {}) => {\n const { slugOverrides, checkboxOverrides } = overrides;\n\n const checkBoxField: CheckboxField = {\n name: 'slugLock',\n type: 'checkbox',\n defaultValue: true,\n admin: { hidden: true, position: 'sidebar' },\n ...checkboxOverrides,\n };\n\n // @ts-expect-error - ts mismatch Partial<TextField> with TextField\n const slug: TextField = {\n name: 'slug',\n type: 'text',\n index: true,\n label: 'Slug',\n ...(slugOverrides || {}),\n hooks: {\n beforeValidate: [formatSlugHook(fieldToUse)],\n },\n admin: {\n position: 'sidebar',\n ...(slugOverrides?.admin || {}),\n components: {\n Field: {\n path: '@foundrykit/payload-fields/client#SlugComponent',\n clientProps: { fieldToUse, checkboxFieldPath: checkBoxField.name },\n },\n },\n },\n };\n\n return [slug, checkBoxField];\n};\n"],"names":["formatSlugHook","slugField","fieldToUse","overrides","slugOverrides","checkboxOverrides","checkBoxField","name","type","defaultValue","admin","hidden","position","slug","index","label","hooks","beforeValidate","components","Field","path","clientProps","checkboxFieldPath"],"mappings":"AACA,SAASA,cAAc,QAAQ,kBAAkB;AAYjD;;;CAGC,GACD,OAAO,MAAMC,YAAkB,CAACC,aAAa,OAAO,EAAEC,YAAY,CAAC,CAAC;IAClE,MAAM,EAAEC,aAAa,EAAEC,iBAAiB,EAAE,GAAGF;IAE7C,MAAMG,gBAA+B;QACnCC,MAAM;QACNC,MAAM;QACNC,cAAc;QACdC,OAAO;YAAEC,QAAQ;YAAMC,UAAU;QAAU;QAC3C,GAAGP,iBAAiB;IACtB;IAEA,mEAAmE;IACnE,MAAMQ,OAAkB;QACtBN,MAAM;QACNC,MAAM;QACNM,OAAO;QACPC,OAAO;QACP,GAAIX,iBAAiB,CAAC,CAAC;QACvBY,OAAO;YACLC,gBAAgB;gBAACjB,eAAeE;aAAY;QAC9C;QACAQ,OAAO;YACLE,UAAU;YACV,GAAIR,eAAeM,SAAS,CAAC,CAAC;YAC9BQ,YAAY;gBACVC,OAAO;oBACLC,MAAM;oBACNC,aAAa;wBAAEnB;wBAAYoB,mBAAmBhB,cAAcC,IAAI;oBAAC;gBACnE;YACF;QACF;IACF;IAEA,OAAO;QAACM;QAAMP;KAAc;AAC9B,EAAE"}