@foundrykit/payload-fields 0.0.0-stage → 1.0.1
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/README.md +208 -2
- package/dist/exports/client.d.ts +8 -0
- package/dist/exports/client.js +10 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/exports/rsc.d.ts +1 -0
- package/dist/exports/rsc.js +3 -0
- package/dist/exports/rsc.js.map +1 -0
- package/dist/fields/address/AddressInput.d.ts +7 -0
- package/dist/fields/address/AddressInput.js +203 -0
- package/dist/fields/address/AddressInput.js.map +1 -0
- package/dist/fields/address/index.d.ts +8 -0
- package/dist/fields/address/index.js +77 -0
- package/dist/fields/address/index.js.map +1 -0
- package/dist/fields/bestTimeToVisit/MonthRatingField.d.ts +3 -0
- package/dist/fields/bestTimeToVisit/MonthRatingField.js +206 -0
- package/dist/fields/bestTimeToVisit/MonthRatingField.js.map +1 -0
- package/dist/fields/bestTimeToVisit/index.d.ts +6 -0
- package/dist/fields/bestTimeToVisit/index.js +82 -0
- package/dist/fields/bestTimeToVisit/index.js.map +1 -0
- package/dist/fields/budget/PriceInput.d.ts +3 -0
- package/dist/fields/budget/PriceInput.js +65 -0
- package/dist/fields/budget/PriceInput.js.map +1 -0
- package/dist/fields/budget/RowLabel.d.ts +3 -0
- package/dist/fields/budget/RowLabel.js +22 -0
- package/dist/fields/budget/RowLabel.js.map +1 -0
- package/dist/fields/budget/index.d.ts +8 -0
- package/dist/fields/budget/index.js +111 -0
- package/dist/fields/budget/index.js.map +1 -0
- package/dist/fields/changedBy/index.d.ts +11 -0
- package/dist/fields/changedBy/index.js +30 -0
- package/dist/fields/changedBy/index.js.map +1 -0
- package/dist/fields/changedBy/populateChangedBy.d.ts +3 -0
- package/dist/fields/changedBy/populateChangedBy.js +12 -0
- package/dist/fields/changedBy/populateChangedBy.js.map +1 -0
- package/dist/fields/countryCode/index.d.ts +11 -0
- package/dist/fields/countryCode/index.js +880 -0
- package/dist/fields/countryCode/index.js.map +1 -0
- package/dist/fields/dateRange/DateRangeComponent.d.ts +3 -0
- package/dist/fields/dateRange/DateRangeComponent.js +77 -0
- package/dist/fields/dateRange/DateRangeComponent.js.map +1 -0
- package/dist/fields/dateRange/index.d.ts +11 -0
- package/dist/fields/dateRange/index.js +26 -0
- package/dist/fields/dateRange/index.js.map +1 -0
- package/dist/fields/gallery/index.d.ts +10 -0
- package/dist/fields/gallery/index.js +23 -0
- package/dist/fields/gallery/index.js.map +1 -0
- package/dist/fields/icon/index.d.ts +8 -0
- package/dist/fields/icon/index.js +30 -0
- package/dist/fields/icon/index.js.map +1 -0
- package/dist/fields/imageMap/ImageMapField.d.ts +13 -0
- package/dist/fields/imageMap/ImageMapField.js +67 -0
- package/dist/fields/imageMap/ImageMapField.js.map +1 -0
- package/dist/fields/imageMap/MapEditor/MapEditor.d.ts +13 -0
- package/dist/fields/imageMap/MapEditor/MapEditor.js +225 -0
- package/dist/fields/imageMap/MapEditor/MapEditor.js.map +1 -0
- package/dist/fields/imageMap/MapEditor/PinContextMenu.d.ts +12 -0
- package/dist/fields/imageMap/MapEditor/PinContextMenu.js +61 -0
- package/dist/fields/imageMap/MapEditor/PinContextMenu.js.map +1 -0
- package/dist/fields/imageMap/MapEditor/WaypointPopover.d.ts +14 -0
- package/dist/fields/imageMap/MapEditor/WaypointPopover.js +103 -0
- package/dist/fields/imageMap/MapEditor/WaypointPopover.js.map +1 -0
- package/dist/fields/imageMap/MapEditor/WaypointSheet.d.ts +9 -0
- package/dist/fields/imageMap/MapEditor/WaypointSheet.js +190 -0
- package/dist/fields/imageMap/MapEditor/WaypointSheet.js.map +1 -0
- package/dist/fields/imageMap/MapEditor/WaypointSheet.scss +128 -0
- package/dist/fields/imageMap/MapEditor/map-editor.scss +556 -0
- package/dist/fields/imageMap/MapEditor/types.d.ts +20 -0
- package/dist/fields/imageMap/MapEditor/types.js +3 -0
- package/dist/fields/imageMap/MapEditor/types.js.map +1 -0
- package/dist/fields/imageMap/index.d.ts +16 -0
- package/dist/fields/imageMap/index.js +35 -0
- package/dist/fields/imageMap/index.js.map +1 -0
- package/dist/fields/link/index.d.ts +21 -0
- package/dist/fields/link/index.js +134 -0
- package/dist/fields/link/index.js.map +1 -0
- package/dist/fields/link/resolveLink.d.ts +28 -0
- package/dist/fields/link/resolveLink.js +26 -0
- package/dist/fields/link/resolveLink.js.map +1 -0
- package/dist/fields/openingTimes/RowLabel.d.ts +2 -0
- package/dist/fields/openingTimes/RowLabel.js +12 -0
- package/dist/fields/openingTimes/RowLabel.js.map +1 -0
- package/dist/fields/openingTimes/index.d.ts +8 -0
- package/dist/fields/openingTimes/index.js +22 -0
- package/dist/fields/openingTimes/index.js.map +1 -0
- package/dist/fields/openingTimes/opening-time.d.ts +6 -0
- package/dist/fields/openingTimes/opening-time.js +37 -0
- package/dist/fields/openingTimes/opening-time.js.map +1 -0
- package/dist/fields/socials/index.d.ts +7 -0
- package/dist/fields/socials/index.js +70 -0
- package/dist/fields/socials/index.js.map +1 -0
- package/dist/fields/tags/RowLabel.d.ts +2 -0
- package/dist/fields/tags/RowLabel.js +12 -0
- package/dist/fields/tags/RowLabel.js.map +1 -0
- package/dist/fields/tags/index.d.ts +10 -0
- package/dist/fields/tags/index.js +22 -0
- package/dist/fields/tags/index.js.map +1 -0
- package/dist/fields/tags/tag.d.ts +6 -0
- package/dist/fields/tags/tag.js +18 -0
- package/dist/fields/tags/tag.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/utilities/deepMerge.d.ts +4 -0
- package/dist/utilities/deepMerge.js +30 -0
- package/dist/utilities/deepMerge.js.map +1 -0
- package/package.json +118 -3
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import deepMerge from '../../utilities/deepMerge.js';
|
|
2
|
+
import { SAFE_LINK } from './resolveLink.js';
|
|
3
|
+
const DEFAULT_APPEARANCES = [
|
|
4
|
+
{
|
|
5
|
+
label: 'Default',
|
|
6
|
+
value: 'default'
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
label: 'Outline',
|
|
10
|
+
value: 'outline'
|
|
11
|
+
}
|
|
12
|
+
];
|
|
13
|
+
/**
|
|
14
|
+
* A link group: internal reference or custom URL, open-in-new-tab, label and appearance.
|
|
15
|
+
* Stored as `{ type, newTab, reference, url, label, appearance }`. Render it with `resolveLink`.
|
|
16
|
+
*/ export const link = ({ relationTo = [
|
|
17
|
+
'pages'
|
|
18
|
+
], appearances = DEFAULT_APPEARANCES, disableLabel = false, required = true, overrides = {} } = {})=>{
|
|
19
|
+
const target = [
|
|
20
|
+
{
|
|
21
|
+
name: 'reference',
|
|
22
|
+
type: 'relationship',
|
|
23
|
+
label: 'Document to link to',
|
|
24
|
+
relationTo: relationTo,
|
|
25
|
+
required,
|
|
26
|
+
admin: {
|
|
27
|
+
condition: (_, sibling)=>sibling?.type === 'reference',
|
|
28
|
+
width: disableLabel ? undefined : '50%'
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'url',
|
|
33
|
+
type: 'text',
|
|
34
|
+
label: 'Custom URL',
|
|
35
|
+
required,
|
|
36
|
+
validate: (value, { siblingData })=>{
|
|
37
|
+
if (siblingData?.type !== 'custom' || !value) return true;
|
|
38
|
+
return SAFE_LINK.test(String(value).trim()) ? true : 'Use an http(s), mailto: or tel: link, a path starting with /, or #anchor.';
|
|
39
|
+
},
|
|
40
|
+
admin: {
|
|
41
|
+
condition: (_, sibling)=>sibling?.type === 'custom',
|
|
42
|
+
width: disableLabel ? undefined : '50%'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
const result = {
|
|
47
|
+
name: 'link',
|
|
48
|
+
type: 'group',
|
|
49
|
+
admin: {
|
|
50
|
+
hideGutter: true
|
|
51
|
+
},
|
|
52
|
+
fields: [
|
|
53
|
+
{
|
|
54
|
+
type: 'row',
|
|
55
|
+
fields: [
|
|
56
|
+
{
|
|
57
|
+
name: 'type',
|
|
58
|
+
type: 'radio',
|
|
59
|
+
defaultValue: 'reference',
|
|
60
|
+
options: [
|
|
61
|
+
{
|
|
62
|
+
label: 'Internal link',
|
|
63
|
+
value: 'reference'
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
label: 'Custom URL',
|
|
67
|
+
value: 'custom'
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
admin: {
|
|
71
|
+
layout: 'horizontal',
|
|
72
|
+
width: '50%'
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'newTab',
|
|
77
|
+
type: 'checkbox',
|
|
78
|
+
label: 'Open in new tab',
|
|
79
|
+
admin: {
|
|
80
|
+
style: {
|
|
81
|
+
alignSelf: 'flex-end'
|
|
82
|
+
},
|
|
83
|
+
width: '50%'
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
disableLabel ? {
|
|
89
|
+
type: 'row',
|
|
90
|
+
fields: target
|
|
91
|
+
} : {
|
|
92
|
+
type: 'row',
|
|
93
|
+
fields: [
|
|
94
|
+
...target,
|
|
95
|
+
{
|
|
96
|
+
name: 'label',
|
|
97
|
+
type: 'text',
|
|
98
|
+
label: 'Label',
|
|
99
|
+
required,
|
|
100
|
+
admin: {
|
|
101
|
+
width: '50%'
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
};
|
|
108
|
+
if (appearances) {
|
|
109
|
+
const first = appearances[0];
|
|
110
|
+
result.fields.push({
|
|
111
|
+
name: 'appearance',
|
|
112
|
+
type: 'select',
|
|
113
|
+
label: 'Appearance',
|
|
114
|
+
defaultValue: typeof first === 'string' ? first : first?.value,
|
|
115
|
+
options: appearances,
|
|
116
|
+
admin: {
|
|
117
|
+
description: 'Choose how the link should be rendered.'
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return deepMerge(result, overrides);
|
|
122
|
+
};
|
|
123
|
+
/** An array of `link`s, named `links`. Takes the same options as `link`, with `overrides` for the array. */ export const linkGroup = ({ overrides = {}, ...linkOptions } = {})=>deepMerge({
|
|
124
|
+
name: 'links',
|
|
125
|
+
type: 'array',
|
|
126
|
+
admin: {
|
|
127
|
+
initCollapsed: true
|
|
128
|
+
},
|
|
129
|
+
fields: [
|
|
130
|
+
link(linkOptions)
|
|
131
|
+
]
|
|
132
|
+
}, overrides);
|
|
133
|
+
|
|
134
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/link/index.ts"],"sourcesContent":["import type {\n ArrayField,\n CollectionSlug,\n Field,\n GroupField,\n Option,\n} from 'payload';\nimport deepMerge from '../../utilities/deepMerge.js';\nimport { SAFE_LINK } from './resolveLink.js';\n\nexport type LinkOptions = {\n /** Collections an internal link can point at. Default `['pages']`. */\n relationTo?: CollectionSlug | CollectionSlug[];\n /** Appearance (button style) options; the first is the default. `false` drops the field. Default `default` + `outline`. */\n appearances?: Option[] | false;\n /** Drop the label field (e.g. for icon-only links). */\n disableLabel?: boolean;\n /** Make the reference/URL and label required. Default true. */\n required?: boolean;\n overrides?: Partial<GroupField>;\n};\n\nconst DEFAULT_APPEARANCES: Option[] = [\n { label: 'Default', value: 'default' },\n { label: 'Outline', value: 'outline' },\n];\n\n/**\n * A link group: internal reference or custom URL, open-in-new-tab, label and appearance.\n * Stored as `{ type, newTab, reference, url, label, appearance }`. Render it with `resolveLink`.\n */\nexport const link = ({\n relationTo = ['pages'] as CollectionSlug[],\n appearances = DEFAULT_APPEARANCES,\n disableLabel = false,\n required = true,\n overrides = {},\n}: LinkOptions = {}): Field => {\n const target: Field[] = [\n {\n name: 'reference',\n type: 'relationship',\n label: 'Document to link to',\n relationTo: relationTo as CollectionSlug[],\n required,\n admin: {\n condition: (_, sibling) => sibling?.type === 'reference',\n width: disableLabel ? undefined : '50%',\n },\n },\n {\n name: 'url',\n type: 'text',\n label: 'Custom URL',\n required,\n validate: (\n value: unknown,\n { siblingData }: { siblingData?: { type?: string } }\n ) => {\n if (siblingData?.type !== 'custom' || !value) return true;\n return SAFE_LINK.test(String(value).trim())\n ? true\n : 'Use an http(s), mailto: or tel: link, a path starting with /, or #anchor.';\n },\n admin: {\n condition: (_, sibling) => sibling?.type === 'custom',\n width: disableLabel ? undefined : '50%',\n },\n },\n ];\n\n const result: GroupField = {\n name: 'link',\n type: 'group',\n admin: { hideGutter: true },\n fields: [\n {\n type: 'row',\n fields: [\n {\n name: 'type',\n type: 'radio',\n defaultValue: 'reference',\n options: [\n { label: 'Internal link', value: 'reference' },\n { label: 'Custom URL', value: 'custom' },\n ],\n admin: { layout: 'horizontal', width: '50%' },\n },\n {\n name: 'newTab',\n type: 'checkbox',\n label: 'Open in new tab',\n admin: { style: { alignSelf: 'flex-end' }, width: '50%' },\n },\n ],\n },\n disableLabel\n ? { type: 'row', fields: target }\n : {\n type: 'row',\n fields: [\n ...target,\n {\n name: 'label',\n type: 'text',\n label: 'Label',\n required,\n admin: { width: '50%' },\n },\n ],\n },\n ],\n };\n\n if (appearances) {\n const first = appearances[0];\n result.fields.push({\n name: 'appearance',\n type: 'select',\n label: 'Appearance',\n defaultValue: typeof first === 'string' ? first : first?.value,\n options: appearances,\n admin: { description: 'Choose how the link should be rendered.' },\n });\n }\n\n return deepMerge(result, overrides);\n};\n\n/** An array of `link`s, named `links`. Takes the same options as `link`, with `overrides` for the array. */\nexport const linkGroup = ({\n overrides = {},\n ...linkOptions\n}: Omit<LinkOptions, 'overrides'> & {\n overrides?: Partial<ArrayField>;\n} = {}): Field =>\n deepMerge(\n {\n name: 'links',\n type: 'array',\n admin: { initCollapsed: true },\n fields: [link(linkOptions)],\n } satisfies ArrayField,\n overrides\n );\n"],"names":["deepMerge","SAFE_LINK","DEFAULT_APPEARANCES","label","value","link","relationTo","appearances","disableLabel","required","overrides","target","name","type","admin","condition","_","sibling","width","undefined","validate","siblingData","test","String","trim","result","hideGutter","fields","defaultValue","options","layout","style","alignSelf","first","push","description","linkGroup","linkOptions","initCollapsed"],"mappings":"AAOA,OAAOA,eAAe,+BAA+B;AACrD,SAASC,SAAS,QAAQ,mBAAmB;AAc7C,MAAMC,sBAAgC;IACpC;QAAEC,OAAO;QAAWC,OAAO;IAAU;IACrC;QAAED,OAAO;QAAWC,OAAO;IAAU;CACtC;AAED;;;CAGC,GACD,OAAO,MAAMC,OAAO,CAAC,EACnBC,aAAa;IAAC;CAAQ,AAAoB,EAC1CC,cAAcL,mBAAmB,EACjCM,eAAe,KAAK,EACpBC,WAAW,IAAI,EACfC,YAAY,CAAC,CAAC,EACF,GAAG,CAAC,CAAC;IACjB,MAAMC,SAAkB;QACtB;YACEC,MAAM;YACNC,MAAM;YACNV,OAAO;YACPG,YAAYA;YACZG;YACAK,OAAO;gBACLC,WAAW,CAACC,GAAGC,UAAYA,SAASJ,SAAS;gBAC7CK,OAAOV,eAAeW,YAAY;YACpC;QACF;QACA;YACEP,MAAM;YACNC,MAAM;YACNV,OAAO;YACPM;YACAW,UAAU,CACRhB,OACA,EAAEiB,WAAW,EAAuC;gBAEpD,IAAIA,aAAaR,SAAS,YAAY,CAACT,OAAO,OAAO;gBACrD,OAAOH,UAAUqB,IAAI,CAACC,OAAOnB,OAAOoB,IAAI,MACpC,OACA;YACN;YACAV,OAAO;gBACLC,WAAW,CAACC,GAAGC,UAAYA,SAASJ,SAAS;gBAC7CK,OAAOV,eAAeW,YAAY;YACpC;QACF;KACD;IAED,MAAMM,SAAqB;QACzBb,MAAM;QACNC,MAAM;QACNC,OAAO;YAAEY,YAAY;QAAK;QAC1BC,QAAQ;YACN;gBACEd,MAAM;gBACNc,QAAQ;oBACN;wBACEf,MAAM;wBACNC,MAAM;wBACNe,cAAc;wBACdC,SAAS;4BACP;gCAAE1B,OAAO;gCAAiBC,OAAO;4BAAY;4BAC7C;gCAAED,OAAO;gCAAcC,OAAO;4BAAS;yBACxC;wBACDU,OAAO;4BAAEgB,QAAQ;4BAAcZ,OAAO;wBAAM;oBAC9C;oBACA;wBACEN,MAAM;wBACNC,MAAM;wBACNV,OAAO;wBACPW,OAAO;4BAAEiB,OAAO;gCAAEC,WAAW;4BAAW;4BAAGd,OAAO;wBAAM;oBAC1D;iBACD;YACH;YACAV,eACI;gBAAEK,MAAM;gBAAOc,QAAQhB;YAAO,IAC9B;gBACEE,MAAM;gBACNc,QAAQ;uBACHhB;oBACH;wBACEC,MAAM;wBACNC,MAAM;wBACNV,OAAO;wBACPM;wBACAK,OAAO;4BAAEI,OAAO;wBAAM;oBACxB;iBACD;YACH;SACL;IACH;IAEA,IAAIX,aAAa;QACf,MAAM0B,QAAQ1B,WAAW,CAAC,EAAE;QAC5BkB,OAAOE,MAAM,CAACO,IAAI,CAAC;YACjBtB,MAAM;YACNC,MAAM;YACNV,OAAO;YACPyB,cAAc,OAAOK,UAAU,WAAWA,QAAQA,OAAO7B;YACzDyB,SAAStB;YACTO,OAAO;gBAAEqB,aAAa;YAA0C;QAClE;IACF;IAEA,OAAOnC,UAAUyB,QAAQf;AAC3B,EAAE;AAEF,0GAA0G,GAC1G,OAAO,MAAM0B,YAAY,CAAC,EACxB1B,YAAY,CAAC,CAAC,EACd,GAAG2B,aAGJ,GAAG,CAAC,CAAC,GACJrC,UACE;QACEY,MAAM;QACNC,MAAM;QACNC,OAAO;YAAEwB,eAAe;QAAK;QAC7BX,QAAQ;YAACtB,KAAKgC;SAAa;IAC7B,GACA3B,WACA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** The stored shape of a `link` field (loosely typed so generated `payload-types` fit). */
|
|
2
|
+
export type LinkValue = {
|
|
3
|
+
type?: 'reference' | 'custom' | null;
|
|
4
|
+
newTab?: boolean | null;
|
|
5
|
+
url?: string | null;
|
|
6
|
+
label?: string | null;
|
|
7
|
+
reference?: {
|
|
8
|
+
relationTo: string;
|
|
9
|
+
value: string | number | {
|
|
10
|
+
slug?: string | null;
|
|
11
|
+
};
|
|
12
|
+
} | null;
|
|
13
|
+
};
|
|
14
|
+
/** Schemes a custom link may use; anything else (e.g. `javascript:`) is never rendered. */
|
|
15
|
+
export declare const SAFE_LINK: RegExp;
|
|
16
|
+
export type ResolvedLink = {
|
|
17
|
+
href: string;
|
|
18
|
+
target?: '_blank';
|
|
19
|
+
rel?: 'noopener noreferrer';
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Turns a stored `link` into `href`/`target`/`rel`. Pure, so it's safe in Server Components.
|
|
23
|
+
* Internal links need the reference populated (`depth >= 1`); an unpopulated or empty link returns `null`.
|
|
24
|
+
* `paths` maps a collection to its URL prefix; the default is `/<collection>`, and `/` for `pages`.
|
|
25
|
+
*/
|
|
26
|
+
export declare const resolveLink: (link: LinkValue | null | undefined, { paths }?: {
|
|
27
|
+
paths?: Record<string, string>;
|
|
28
|
+
}) => ResolvedLink | null;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** The stored shape of a `link` field (loosely typed so generated `payload-types` fit). */ /** Schemes a custom link may use; anything else (e.g. `javascript:`) is never rendered. */ export const SAFE_LINK = /^(https?:|mailto:|tel:|\/(?!\/)|#|\?)/i;
|
|
2
|
+
/**
|
|
3
|
+
* Turns a stored `link` into `href`/`target`/`rel`. Pure, so it's safe in Server Components.
|
|
4
|
+
* Internal links need the reference populated (`depth >= 1`); an unpopulated or empty link returns `null`.
|
|
5
|
+
* `paths` maps a collection to its URL prefix; the default is `/<collection>`, and `/` for `pages`.
|
|
6
|
+
*/ export const resolveLink = (link, { paths = {} } = {})=>{
|
|
7
|
+
let href;
|
|
8
|
+
if (link?.type === 'custom') {
|
|
9
|
+
const url = link.url?.trim();
|
|
10
|
+
href = url && SAFE_LINK.test(url) ? url : null;
|
|
11
|
+
} else if (link?.reference && typeof link.reference.value === 'object') {
|
|
12
|
+
const { relationTo, value } = link.reference;
|
|
13
|
+
const prefix = paths[relationTo] ?? (relationTo === 'pages' ? '' : `/${relationTo}`);
|
|
14
|
+
if (value.slug) href = `${prefix.replace(/\/$/, '')}/${value.slug}`;
|
|
15
|
+
}
|
|
16
|
+
if (!href) return null;
|
|
17
|
+
return link?.newTab ? {
|
|
18
|
+
href,
|
|
19
|
+
target: '_blank',
|
|
20
|
+
rel: 'noopener noreferrer'
|
|
21
|
+
} : {
|
|
22
|
+
href
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=resolveLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/link/resolveLink.ts"],"sourcesContent":["/** The stored shape of a `link` field (loosely typed so generated `payload-types` fit). */\nexport type LinkValue = {\n type?: 'reference' | 'custom' | null;\n newTab?: boolean | null;\n url?: string | null;\n label?: string | null;\n reference?: {\n relationTo: string;\n value: string | number | { slug?: string | null };\n } | null;\n};\n\n/** Schemes a custom link may use; anything else (e.g. `javascript:`) is never rendered. */\nexport const SAFE_LINK = /^(https?:|mailto:|tel:|\\/(?!\\/)|#|\\?)/i;\n\nexport type ResolvedLink = {\n href: string;\n target?: '_blank';\n rel?: 'noopener noreferrer';\n};\n\n/**\n * Turns a stored `link` into `href`/`target`/`rel`. Pure, so it's safe in Server Components.\n * Internal links need the reference populated (`depth >= 1`); an unpopulated or empty link returns `null`.\n * `paths` maps a collection to its URL prefix; the default is `/<collection>`, and `/` for `pages`.\n */\nexport const resolveLink = (\n link: LinkValue | null | undefined,\n { paths = {} }: { paths?: Record<string, string> } = {}\n): ResolvedLink | null => {\n let href: string | null | undefined;\n if (link?.type === 'custom') {\n const url = link.url?.trim();\n href = url && SAFE_LINK.test(url) ? url : null;\n } else if (link?.reference && typeof link.reference.value === 'object') {\n const { relationTo, value } = link.reference;\n const prefix =\n paths[relationTo] ?? (relationTo === 'pages' ? '' : `/${relationTo}`);\n if (value.slug) href = `${prefix.replace(/\\/$/, '')}/${value.slug}`;\n }\n if (!href) return null;\n return link?.newTab\n ? { href, target: '_blank', rel: 'noopener noreferrer' }\n : { href };\n};\n"],"names":["SAFE_LINK","resolveLink","link","paths","href","type","url","trim","test","reference","value","relationTo","prefix","slug","replace","newTab","target","rel"],"mappings":"AAAA,yFAAyF,GAYzF,yFAAyF,GACzF,OAAO,MAAMA,YAAY,yCAAyC;AAQlE;;;;CAIC,GACD,OAAO,MAAMC,cAAc,CACzBC,MACA,EAAEC,QAAQ,CAAC,CAAC,EAAsC,GAAG,CAAC,CAAC;IAEvD,IAAIC;IACJ,IAAIF,MAAMG,SAAS,UAAU;QAC3B,MAAMC,MAAMJ,KAAKI,GAAG,EAAEC;QACtBH,OAAOE,OAAON,UAAUQ,IAAI,CAACF,OAAOA,MAAM;IAC5C,OAAO,IAAIJ,MAAMO,aAAa,OAAOP,KAAKO,SAAS,CAACC,KAAK,KAAK,UAAU;QACtE,MAAM,EAAEC,UAAU,EAAED,KAAK,EAAE,GAAGR,KAAKO,SAAS;QAC5C,MAAMG,SACJT,KAAK,CAACQ,WAAW,IAAKA,CAAAA,eAAe,UAAU,KAAK,CAAC,CAAC,EAAEA,YAAY,AAAD;QACrE,IAAID,MAAMG,IAAI,EAAET,OAAO,GAAGQ,OAAOE,OAAO,CAAC,OAAO,IAAI,CAAC,EAAEJ,MAAMG,IAAI,EAAE;IACrE;IACA,IAAI,CAACT,MAAM,OAAO;IAClB,OAAOF,MAAMa,SACT;QAAEX;QAAMY,QAAQ;QAAUC,KAAK;IAAsB,IACrD;QAAEb;IAAK;AACb,EAAE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useRowLabel } from '@payloadcms/ui';
|
|
4
|
+
export const OpeningTimesRowLabel = ()=>{
|
|
5
|
+
const data = useRowLabel();
|
|
6
|
+
const label = data?.data?.opening_time?.day ? `Opening Time ${data.rowNumber !== undefined ? data.rowNumber + 1 : ''}: ${data.data.opening_time.day}` : 'Row';
|
|
7
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
8
|
+
children: label
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=RowLabel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/openingTimes/RowLabel.tsx"],"sourcesContent":["'use client';\nimport { type RowLabelProps, useRowLabel } from '@payloadcms/ui';\n\ntype OpeningRow = { opening_time: { day: string } };\n\nexport const OpeningTimesRowLabel: React.FC<RowLabelProps> = () => {\n const data = useRowLabel<NonNullable<OpeningRow>>();\n const label = data?.data?.opening_time?.day\n ? `Opening Time ${data.rowNumber !== undefined ? data.rowNumber + 1 : ''}: ${data.data.opening_time.day}`\n : 'Row';\n return <div>{label}</div>;\n};\n"],"names":["useRowLabel","OpeningTimesRowLabel","data","label","opening_time","day","rowNumber","undefined","div"],"mappings":"AAAA;;AACA,SAA6BA,WAAW,QAAQ,iBAAiB;AAIjE,OAAO,MAAMC,uBAAgD;IAC3D,MAAMC,OAAOF;IACb,MAAMG,QAAQD,MAAMA,MAAME,cAAcC,MACpC,CAAC,aAAa,EAAEH,KAAKI,SAAS,KAAKC,YAAYL,KAAKI,SAAS,GAAG,IAAI,GAAG,EAAE,EAAEJ,KAAKA,IAAI,CAACE,YAAY,CAACC,GAAG,EAAE,GACvG;IACJ,qBAAO,KAACG;kBAAKL;;AACf,EAAE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ArrayField, Field } from 'payload';
|
|
2
|
+
type OpeningTimesType = (options?: {
|
|
3
|
+
sidebar?: boolean;
|
|
4
|
+
overrides?: Partial<ArrayField>;
|
|
5
|
+
}) => Field;
|
|
6
|
+
/** A repeatable day/open/close list for venue opening hours. */
|
|
7
|
+
export declare const openingTimes: OpeningTimesType;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import deepMerge from '../../utilities/deepMerge.js';
|
|
2
|
+
import { openingTime } from './opening-time.js';
|
|
3
|
+
/** A repeatable day/open/close list for venue opening hours. */ export const openingTimes = ({ sidebar = false, overrides = {} } = {})=>{
|
|
4
|
+
const openingTimesResult = {
|
|
5
|
+
name: 'opening_times',
|
|
6
|
+
label: 'Opening Times',
|
|
7
|
+
type: 'array',
|
|
8
|
+
fields: [
|
|
9
|
+
openingTime()
|
|
10
|
+
],
|
|
11
|
+
admin: {
|
|
12
|
+
initCollapsed: true,
|
|
13
|
+
position: sidebar ? 'sidebar' : undefined,
|
|
14
|
+
components: {
|
|
15
|
+
RowLabel: '@foundrykit/payload-fields/client#OpeningTimesRowLabel'
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return deepMerge(openingTimesResult, overrides);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/openingTimes/index.ts"],"sourcesContent":["import type { ArrayField, Field } from 'payload';\nimport deepMerge from '../../utilities/deepMerge.js';\nimport { openingTime } from './opening-time.js';\n\ntype OpeningTimesType = (options?: {\n sidebar?: boolean;\n overrides?: Partial<ArrayField>;\n}) => Field;\n\n/** A repeatable day/open/close list for venue opening hours. */\nexport const openingTimes: OpeningTimesType = ({\n sidebar = false,\n overrides = {},\n} = {}) => {\n const openingTimesResult: Field = {\n name: 'opening_times',\n label: 'Opening Times',\n type: 'array',\n fields: [openingTime()],\n admin: {\n initCollapsed: true,\n position: sidebar ? 'sidebar' : undefined,\n components: {\n RowLabel: '@foundrykit/payload-fields/client#OpeningTimesRowLabel',\n },\n },\n };\n return deepMerge(openingTimesResult, overrides);\n};\n"],"names":["deepMerge","openingTime","openingTimes","sidebar","overrides","openingTimesResult","name","label","type","fields","admin","initCollapsed","position","undefined","components","RowLabel"],"mappings":"AACA,OAAOA,eAAe,+BAA+B;AACrD,SAASC,WAAW,QAAQ,oBAAoB;AAOhD,8DAA8D,GAC9D,OAAO,MAAMC,eAAiC,CAAC,EAC7CC,UAAU,KAAK,EACfC,YAAY,CAAC,CAAC,EACf,GAAG,CAAC,CAAC;IACJ,MAAMC,qBAA4B;QAChCC,MAAM;QACNC,OAAO;QACPC,MAAM;QACNC,QAAQ;YAACR;SAAc;QACvBS,OAAO;YACLC,eAAe;YACfC,UAAUT,UAAU,YAAYU;YAChCC,YAAY;gBACVC,UAAU;YACZ;QACF;IACF;IACA,OAAOf,UAAUK,oBAAoBD;AACvC,EAAE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import deepMerge from '../../utilities/deepMerge.js';
|
|
2
|
+
export const openingTime = ({ overrides = {} } = {})=>{
|
|
3
|
+
const openingTimeResult = {
|
|
4
|
+
name: 'opening_time',
|
|
5
|
+
label: 'Opening Time',
|
|
6
|
+
type: 'group',
|
|
7
|
+
fields: [
|
|
8
|
+
{
|
|
9
|
+
name: 'day',
|
|
10
|
+
label: 'Day',
|
|
11
|
+
type: 'select',
|
|
12
|
+
options: [
|
|
13
|
+
'Monday',
|
|
14
|
+
'Tuesday',
|
|
15
|
+
'Wednesday',
|
|
16
|
+
'Thursday',
|
|
17
|
+
'Friday',
|
|
18
|
+
'Saturday',
|
|
19
|
+
'Sunday'
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'opening_time',
|
|
24
|
+
label: 'Opening Time',
|
|
25
|
+
type: 'text'
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'closing_time',
|
|
29
|
+
label: 'Closing Time',
|
|
30
|
+
type: 'text'
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
};
|
|
34
|
+
return deepMerge(openingTimeResult, overrides);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=opening-time.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/openingTimes/opening-time.ts"],"sourcesContent":["import type { Field, GroupField } from 'payload';\nimport deepMerge from '../../utilities/deepMerge.js';\n\ntype OpeningTimeType = (options?: { overrides?: Partial<GroupField> }) => Field;\n\nexport const openingTime: OpeningTimeType = ({ overrides = {} } = {}) => {\n const openingTimeResult: GroupField = {\n name: 'opening_time',\n label: 'Opening Time',\n type: 'group',\n fields: [\n {\n name: 'day',\n label: 'Day',\n type: 'select',\n options: [\n 'Monday',\n 'Tuesday',\n 'Wednesday',\n 'Thursday',\n 'Friday',\n 'Saturday',\n 'Sunday',\n ],\n },\n { name: 'opening_time', label: 'Opening Time', type: 'text' },\n { name: 'closing_time', label: 'Closing Time', type: 'text' },\n ],\n };\n return deepMerge(openingTimeResult, overrides);\n};\n"],"names":["deepMerge","openingTime","overrides","openingTimeResult","name","label","type","fields","options"],"mappings":"AACA,OAAOA,eAAe,+BAA+B;AAIrD,OAAO,MAAMC,cAA+B,CAAC,EAAEC,YAAY,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAClE,MAAMC,oBAAgC;QACpCC,MAAM;QACNC,OAAO;QACPC,MAAM;QACNC,QAAQ;YACN;gBACEH,MAAM;gBACNC,OAAO;gBACPC,MAAM;gBACNE,SAAS;oBACP;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;iBACD;YACH;YACA;gBAAEJ,MAAM;gBAAgBC,OAAO;gBAAgBC,MAAM;YAAO;YAC5D;gBAAEF,MAAM;gBAAgBC,OAAO;gBAAgBC,MAAM;YAAO;SAC7D;IACH;IACA,OAAON,UAAUG,mBAAmBD;AACtC,EAAE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ArrayField, Field, Option } from 'payload';
|
|
2
|
+
export declare const SOCIAL_PLATFORMS: Option[];
|
|
3
|
+
/** An array of `{ platform, url }` social profile links, named `socials`. */
|
|
4
|
+
export declare const socials: ({ platforms, overrides, }?: {
|
|
5
|
+
platforms?: Option[];
|
|
6
|
+
overrides?: Partial<ArrayField>;
|
|
7
|
+
}) => Field;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import deepMerge from '../../utilities/deepMerge.js';
|
|
2
|
+
export const SOCIAL_PLATFORMS = [
|
|
3
|
+
{
|
|
4
|
+
label: 'Facebook',
|
|
5
|
+
value: 'facebook'
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
label: 'Instagram',
|
|
9
|
+
value: 'instagram'
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
label: 'X (Twitter)',
|
|
13
|
+
value: 'x'
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
label: 'LinkedIn',
|
|
17
|
+
value: 'linkedin'
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
label: 'YouTube',
|
|
21
|
+
value: 'youtube'
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
label: 'TikTok',
|
|
25
|
+
value: 'tiktok'
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
label: 'Pinterest',
|
|
29
|
+
value: 'pinterest'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
label: 'WhatsApp',
|
|
33
|
+
value: 'whatsapp'
|
|
34
|
+
}
|
|
35
|
+
];
|
|
36
|
+
/** An array of `{ platform, url }` social profile links, named `socials`. */ export const socials = ({ platforms = SOCIAL_PLATFORMS, overrides = {} } = {})=>deepMerge({
|
|
37
|
+
name: 'socials',
|
|
38
|
+
type: 'array',
|
|
39
|
+
admin: {
|
|
40
|
+
initCollapsed: true
|
|
41
|
+
},
|
|
42
|
+
fields: [
|
|
43
|
+
{
|
|
44
|
+
type: 'row',
|
|
45
|
+
fields: [
|
|
46
|
+
{
|
|
47
|
+
name: 'platform',
|
|
48
|
+
type: 'select',
|
|
49
|
+
options: platforms,
|
|
50
|
+
required: true,
|
|
51
|
+
admin: {
|
|
52
|
+
width: '30%'
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'url',
|
|
57
|
+
type: 'text',
|
|
58
|
+
label: 'URL',
|
|
59
|
+
required: true,
|
|
60
|
+
validate: (value)=>!value || URL.canParse(value) || 'Enter a full URL (https://…).',
|
|
61
|
+
admin: {
|
|
62
|
+
width: '70%'
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}, overrides);
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/socials/index.ts"],"sourcesContent":["import type { ArrayField, Field, Option } from 'payload';\nimport deepMerge from '../../utilities/deepMerge.js';\n\nexport const SOCIAL_PLATFORMS: Option[] = [\n { label: 'Facebook', value: 'facebook' },\n { label: 'Instagram', value: 'instagram' },\n { label: 'X (Twitter)', value: 'x' },\n { label: 'LinkedIn', value: 'linkedin' },\n { label: 'YouTube', value: 'youtube' },\n { label: 'TikTok', value: 'tiktok' },\n { label: 'Pinterest', value: 'pinterest' },\n { label: 'WhatsApp', value: 'whatsapp' },\n];\n\n/** An array of `{ platform, url }` social profile links, named `socials`. */\nexport const socials = ({\n platforms = SOCIAL_PLATFORMS,\n overrides = {},\n}: {\n platforms?: Option[];\n overrides?: Partial<ArrayField>;\n} = {}): Field =>\n deepMerge(\n {\n name: 'socials',\n type: 'array',\n admin: { initCollapsed: true },\n fields: [\n {\n type: 'row',\n fields: [\n {\n name: 'platform',\n type: 'select',\n options: platforms,\n required: true,\n admin: { width: '30%' },\n },\n {\n name: 'url',\n type: 'text',\n label: 'URL',\n required: true,\n validate: (value: null | string | undefined) =>\n !value ||\n URL.canParse(value) ||\n 'Enter a full URL (https://…).',\n admin: { width: '70%' },\n },\n ],\n },\n ],\n } satisfies ArrayField,\n overrides\n );\n"],"names":["deepMerge","SOCIAL_PLATFORMS","label","value","socials","platforms","overrides","name","type","admin","initCollapsed","fields","options","required","width","validate","URL","canParse"],"mappings":"AACA,OAAOA,eAAe,+BAA+B;AAErD,OAAO,MAAMC,mBAA6B;IACxC;QAAEC,OAAO;QAAYC,OAAO;IAAW;IACvC;QAAED,OAAO;QAAaC,OAAO;IAAY;IACzC;QAAED,OAAO;QAAeC,OAAO;IAAI;IACnC;QAAED,OAAO;QAAYC,OAAO;IAAW;IACvC;QAAED,OAAO;QAAWC,OAAO;IAAU;IACrC;QAAED,OAAO;QAAUC,OAAO;IAAS;IACnC;QAAED,OAAO;QAAaC,OAAO;IAAY;IACzC;QAAED,OAAO;QAAYC,OAAO;IAAW;CACxC,CAAC;AAEF,2EAA2E,GAC3E,OAAO,MAAMC,UAAU,CAAC,EACtBC,YAAYJ,gBAAgB,EAC5BK,YAAY,CAAC,CAAC,EAIf,GAAG,CAAC,CAAC,GACJN,UACE;QACEO,MAAM;QACNC,MAAM;QACNC,OAAO;YAAEC,eAAe;QAAK;QAC7BC,QAAQ;YACN;gBACEH,MAAM;gBACNG,QAAQ;oBACN;wBACEJ,MAAM;wBACNC,MAAM;wBACNI,SAASP;wBACTQ,UAAU;wBACVJ,OAAO;4BAAEK,OAAO;wBAAM;oBACxB;oBACA;wBACEP,MAAM;wBACNC,MAAM;wBACNN,OAAO;wBACPW,UAAU;wBACVE,UAAU,CAACZ,QACT,CAACA,SACDa,IAAIC,QAAQ,CAACd,UACb;wBACFM,OAAO;4BAAEK,OAAO;wBAAM;oBACxB;iBACD;YACH;SACD;IACH,GACAR,WACA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useRowLabel } from '@payloadcms/ui';
|
|
4
|
+
export const TagsRowLabel = ()=>{
|
|
5
|
+
const data = useRowLabel();
|
|
6
|
+
const label = data?.data?.tag?.tag ? `Tag ${data.rowNumber !== undefined ? data.rowNumber + 1 : ''}: ${data.data.tag.tag}` : 'Row';
|
|
7
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
8
|
+
children: label
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=RowLabel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/tags/RowLabel.tsx"],"sourcesContent":["'use client';\nimport { type RowLabelProps, useRowLabel } from '@payloadcms/ui';\n\ntype TagRow = { tag: { tag: string } };\n\nexport const TagsRowLabel: React.FC<RowLabelProps> = () => {\n const data = useRowLabel<NonNullable<TagRow>>();\n const label = data?.data?.tag?.tag\n ? `Tag ${data.rowNumber !== undefined ? data.rowNumber + 1 : ''}: ${data.data.tag.tag}`\n : 'Row';\n return <div>{label}</div>;\n};\n"],"names":["useRowLabel","TagsRowLabel","data","label","tag","rowNumber","undefined","div"],"mappings":"AAAA;;AACA,SAA6BA,WAAW,QAAQ,iBAAiB;AAIjE,OAAO,MAAMC,eAAwC;IACnD,MAAMC,OAAOF;IACb,MAAMG,QAAQD,MAAMA,MAAME,KAAKA,MAC3B,CAAC,IAAI,EAAEF,KAAKG,SAAS,KAAKC,YAAYJ,KAAKG,SAAS,GAAG,IAAI,GAAG,EAAE,EAAEH,KAAKA,IAAI,CAACE,GAAG,CAACA,GAAG,EAAE,GACrF;IACJ,qBAAO,KAACG;kBAAKJ;;AACf,EAAE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ArrayField, Field } from 'payload';
|
|
2
|
+
type TagsType = (options?: {
|
|
3
|
+
sidebar?: boolean;
|
|
4
|
+
name?: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
overrides?: Partial<ArrayField>;
|
|
7
|
+
}) => Field;
|
|
8
|
+
/** A repeatable array of free-text tags. */
|
|
9
|
+
export declare const tags: TagsType;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import deepMerge from '../../utilities/deepMerge.js';
|
|
2
|
+
import { tag } from './tag.js';
|
|
3
|
+
/** A repeatable array of free-text tags. */ export const tags = ({ sidebar = false, name = 'tags', label = 'Tags', overrides = {} } = {})=>{
|
|
4
|
+
const tagsResult = {
|
|
5
|
+
name,
|
|
6
|
+
label,
|
|
7
|
+
type: 'array',
|
|
8
|
+
fields: [
|
|
9
|
+
tag()
|
|
10
|
+
],
|
|
11
|
+
admin: {
|
|
12
|
+
initCollapsed: true,
|
|
13
|
+
position: sidebar ? 'sidebar' : undefined,
|
|
14
|
+
components: {
|
|
15
|
+
RowLabel: '@foundrykit/payload-fields/client#TagsRowLabel'
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return deepMerge(tagsResult, overrides);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/tags/index.ts"],"sourcesContent":["import type { ArrayField, Field } from 'payload';\nimport deepMerge from '../../utilities/deepMerge.js';\nimport { tag } from './tag.js';\n\ntype TagsType = (options?: {\n sidebar?: boolean;\n name?: string;\n label?: string;\n overrides?: Partial<ArrayField>;\n}) => Field;\n\n/** A repeatable array of free-text tags. */\nexport const tags: TagsType = ({\n sidebar = false,\n name = 'tags',\n label = 'Tags',\n overrides = {},\n} = {}) => {\n const tagsResult: Field = {\n name,\n label,\n type: 'array',\n fields: [tag()],\n admin: {\n initCollapsed: true,\n position: sidebar ? 'sidebar' : undefined,\n components: {\n RowLabel: '@foundrykit/payload-fields/client#TagsRowLabel',\n },\n },\n };\n return deepMerge(tagsResult, overrides);\n};\n"],"names":["deepMerge","tag","tags","sidebar","name","label","overrides","tagsResult","type","fields","admin","initCollapsed","position","undefined","components","RowLabel"],"mappings":"AACA,OAAOA,eAAe,+BAA+B;AACrD,SAASC,GAAG,QAAQ,WAAW;AAS/B,0CAA0C,GAC1C,OAAO,MAAMC,OAAiB,CAAC,EAC7BC,UAAU,KAAK,EACfC,OAAO,MAAM,EACbC,QAAQ,MAAM,EACdC,YAAY,CAAC,CAAC,EACf,GAAG,CAAC,CAAC;IACJ,MAAMC,aAAoB;QACxBH;QACAC;QACAG,MAAM;QACNC,QAAQ;YAACR;SAAM;QACfS,OAAO;YACLC,eAAe;YACfC,UAAUT,UAAU,YAAYU;YAChCC,YAAY;gBACVC,UAAU;YACZ;QACF;IACF;IACA,OAAOf,UAAUO,YAAYD;AAC/B,EAAE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import deepMerge from '../../utilities/deepMerge.js';
|
|
2
|
+
export const tag = ({ overrides = {} } = {})=>{
|
|
3
|
+
const tagResult = {
|
|
4
|
+
name: 'tag',
|
|
5
|
+
label: 'Tag',
|
|
6
|
+
type: 'group',
|
|
7
|
+
fields: [
|
|
8
|
+
{
|
|
9
|
+
name: 'tag',
|
|
10
|
+
label: 'Tag',
|
|
11
|
+
type: 'text'
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
};
|
|
15
|
+
return deepMerge(tagResult, overrides);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=tag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/tags/tag.ts"],"sourcesContent":["import type { Field, GroupField } from 'payload';\nimport deepMerge from '../../utilities/deepMerge.js';\n\ntype TagType = (options?: { overrides?: Partial<GroupField> }) => Field;\n\nexport const tag: TagType = ({ overrides = {} } = {}) => {\n const tagResult: GroupField = {\n name: 'tag',\n label: 'Tag',\n type: 'group',\n fields: [{ name: 'tag', label: 'Tag', type: 'text' }],\n };\n return deepMerge(tagResult, overrides);\n};\n"],"names":["deepMerge","tag","overrides","tagResult","name","label","type","fields"],"mappings":"AACA,OAAOA,eAAe,+BAA+B;AAIrD,OAAO,MAAMC,MAAe,CAAC,EAAEC,YAAY,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAClD,MAAMC,YAAwB;QAC5BC,MAAM;QACNC,OAAO;QACPC,MAAM;QACNC,QAAQ;YAAC;gBAAEH,MAAM;gBAAOC,OAAO;gBAAOC,MAAM;YAAO;SAAE;IACvD;IACA,OAAON,UAAUG,WAAWD;AAC9B,EAAE"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { address } from './fields/address/index.js';
|
|
2
|
+
export { bestTimeToVisitMonths } from './fields/bestTimeToVisit/index.js';
|
|
3
|
+
export { budgetField } from './fields/budget/index.js';
|
|
4
|
+
export { changedByFields } from './fields/changedBy/index.js';
|
|
5
|
+
export { populateChangedBy } from './fields/changedBy/populateChangedBy.js';
|
|
6
|
+
export { countryCodeField, ISO_COUNTRY_OPTIONS, } from './fields/countryCode/index.js';
|
|
7
|
+
export { dateRangeField } from './fields/dateRange/index.js';
|
|
8
|
+
export { gallery } from './fields/gallery/index.js';
|
|
9
|
+
export { ICONS, icon } from './fields/icon/index.js';
|
|
10
|
+
export { type ImageMapValue, imageMap, type Waypoint, } from './fields/imageMap/index.js';
|
|
11
|
+
export { type LinkOptions, link, linkGroup } from './fields/link/index.js';
|
|
12
|
+
export { type LinkValue, type ResolvedLink, resolveLink, } from './fields/link/resolveLink.js';
|
|
13
|
+
export { openingTimes } from './fields/openingTimes/index.js';
|
|
14
|
+
export { openingTime } from './fields/openingTimes/opening-time.js';
|
|
15
|
+
export { SOCIAL_PLATFORMS, socials } from './fields/socials/index.js';
|
|
16
|
+
export { tags } from './fields/tags/index.js';
|
|
17
|
+
export { tag } from './fields/tags/tag.js';
|
|
18
|
+
export { default as deepMerge } from './utilities/deepMerge.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Field factories and RSC-safe helpers: safe to import in payload.config and in Server Components.
|
|
2
|
+
export { address } from './fields/address/index.js';
|
|
3
|
+
export { bestTimeToVisitMonths } from './fields/bestTimeToVisit/index.js';
|
|
4
|
+
export { budgetField } from './fields/budget/index.js';
|
|
5
|
+
export { changedByFields } from './fields/changedBy/index.js';
|
|
6
|
+
export { populateChangedBy } from './fields/changedBy/populateChangedBy.js';
|
|
7
|
+
export { countryCodeField, ISO_COUNTRY_OPTIONS } from './fields/countryCode/index.js';
|
|
8
|
+
export { dateRangeField } from './fields/dateRange/index.js';
|
|
9
|
+
export { gallery } from './fields/gallery/index.js';
|
|
10
|
+
export { ICONS, icon } from './fields/icon/index.js';
|
|
11
|
+
export { imageMap } from './fields/imageMap/index.js';
|
|
12
|
+
export { link, linkGroup } from './fields/link/index.js';
|
|
13
|
+
export { resolveLink } from './fields/link/resolveLink.js';
|
|
14
|
+
export { openingTimes } from './fields/openingTimes/index.js';
|
|
15
|
+
export { openingTime } from './fields/openingTimes/opening-time.js';
|
|
16
|
+
export { SOCIAL_PLATFORMS, socials } from './fields/socials/index.js';
|
|
17
|
+
export { tags } from './fields/tags/index.js';
|
|
18
|
+
export { tag } from './fields/tags/tag.js';
|
|
19
|
+
export { default as deepMerge } from './utilities/deepMerge.js';
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
/** Simple object check. */ export function isObject(item) {
|
|
4
|
+
return typeof item === 'object' && item !== null && !Array.isArray(item);
|
|
5
|
+
}
|
|
6
|
+
/** Deep merge two objects (source wins). Arrays are replaced, not merged. */ export default function deepMerge(target, source) {
|
|
7
|
+
const output = {
|
|
8
|
+
...target
|
|
9
|
+
};
|
|
10
|
+
if (isObject(target) && isObject(source)) {
|
|
11
|
+
Object.keys(source).forEach((key)=>{
|
|
12
|
+
if (isObject(source[key])) {
|
|
13
|
+
if (!(key in target)) {
|
|
14
|
+
Object.assign(output, {
|
|
15
|
+
[key]: source[key]
|
|
16
|
+
});
|
|
17
|
+
} else {
|
|
18
|
+
output[key] = deepMerge(target[key], source[key]);
|
|
19
|
+
}
|
|
20
|
+
} else {
|
|
21
|
+
Object.assign(output, {
|
|
22
|
+
[key]: source[key]
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return output;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=deepMerge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/deepMerge.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\n\n/** Simple object check. */\nexport function isObject(item: unknown): item is object {\n return typeof item === 'object' && item !== null && !Array.isArray(item);\n}\n\n/** Deep merge two objects (source wins). Arrays are replaced, not merged. */\nexport default function deepMerge<T, R>(target: T, source: R): T {\n const output = { ...target };\n if (isObject(target) && isObject(source)) {\n Object.keys(source).forEach(key => {\n if (isObject(source[key])) {\n if (!(key in target)) {\n Object.assign(output, { [key]: source[key] });\n } else {\n output[key] = deepMerge(target[key], source[key]);\n }\n } else {\n Object.assign(output, { [key]: source[key] });\n }\n });\n }\n return output;\n}\n"],"names":["isObject","item","Array","isArray","deepMerge","target","source","output","Object","keys","forEach","key","assign"],"mappings":"AAAA,6DAA6D;AAC7D,cAAc;AAEd,yBAAyB,GACzB,OAAO,SAASA,SAASC,IAAa;IACpC,OAAO,OAAOA,SAAS,YAAYA,SAAS,QAAQ,CAACC,MAAMC,OAAO,CAACF;AACrE;AAEA,2EAA2E,GAC3E,eAAe,SAASG,UAAgBC,MAAS,EAAEC,MAAS;IAC1D,MAAMC,SAAS;QAAE,GAAGF,MAAM;IAAC;IAC3B,IAAIL,SAASK,WAAWL,SAASM,SAAS;QACxCE,OAAOC,IAAI,CAACH,QAAQI,OAAO,CAACC,CAAAA;YAC1B,IAAIX,SAASM,MAAM,CAACK,IAAI,GAAG;gBACzB,IAAI,CAAEA,CAAAA,OAAON,MAAK,GAAI;oBACpBG,OAAOI,MAAM,CAACL,QAAQ;wBAAE,CAACI,IAAI,EAAEL,MAAM,CAACK,IAAI;oBAAC;gBAC7C,OAAO;oBACLJ,MAAM,CAACI,IAAI,GAAGP,UAAUC,MAAM,CAACM,IAAI,EAAEL,MAAM,CAACK,IAAI;gBAClD;YACF,OAAO;gBACLH,OAAOI,MAAM,CAACL,QAAQ;oBAAE,CAACI,IAAI,EAAEL,MAAM,CAACK,IAAI;gBAAC;YAC7C;QACF;IACF;IACA,OAAOJ;AACT"}
|