payload-intl 1.2.2 → 1.2.4
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 +21 -18
- package/dist/components/MessageFormField.d.ts +15 -0
- package/dist/components/MessageFormField.d.ts.map +1 -0
- package/dist/components/{MessageController.js → MessageFormField.js} +5 -3
- package/dist/components/MessageFormField.js.map +1 -0
- package/dist/components/MessagesForm.d.ts +3 -1
- package/dist/components/MessagesForm.d.ts.map +1 -1
- package/dist/components/MessagesForm.js +25 -36
- package/dist/components/MessagesForm.js.map +1 -1
- package/dist/components/{MessageFormContext.d.ts → MessagesFormProvider.d.ts} +6 -2
- package/dist/components/MessagesFormProvider.d.ts.map +1 -0
- package/dist/components/{MessageFormContext.js → MessagesFormProvider.js} +8 -4
- package/dist/components/MessagesFormProvider.js.map +1 -0
- package/dist/components/MessagesLink.js +5 -2
- package/dist/components/MessagesLink.js.map +1 -1
- package/dist/components/MessagesView.d.ts +1 -1
- package/dist/components/MessagesView.d.ts.map +1 -1
- package/dist/components/MessagesView.js +13 -4
- package/dist/components/MessagesView.js.map +1 -1
- package/dist/components/actions/CopyMessages.d.ts +2 -0
- package/dist/components/actions/CopyMessages.d.ts.map +1 -0
- package/dist/components/actions/{Move.js → CopyMessages.js} +6 -6
- package/dist/components/actions/CopyMessages.js.map +1 -0
- package/dist/components/actions/JsonImport.d.ts +4 -1
- package/dist/components/actions/JsonImport.d.ts.map +1 -1
- package/dist/components/actions/JsonImport.js +7 -25
- package/dist/components/actions/JsonImport.js.map +1 -1
- package/dist/components/hooks/useHtmlLexicalAdapter.d.ts +12 -0
- package/dist/components/hooks/useHtmlLexicalAdapter.d.ts.map +1 -0
- package/dist/components/hooks/useHtmlLexicalAdapter.js +63 -0
- package/dist/components/hooks/useHtmlLexicalAdapter.js.map +1 -0
- package/dist/components/hooks/useMessagesFormSubmit.d.ts +11 -0
- package/dist/components/hooks/useMessagesFormSubmit.d.ts.map +1 -0
- package/dist/components/hooks/useMessagesFormSubmit.js +44 -0
- package/dist/components/hooks/useMessagesFormSubmit.js.map +1 -0
- package/dist/components/inputs/FieldWrapper.d.ts +9 -0
- package/dist/components/inputs/FieldWrapper.d.ts.map +1 -0
- package/dist/components/inputs/FieldWrapper.js +24 -0
- package/dist/components/inputs/FieldWrapper.js.map +1 -0
- package/dist/components/inputs/{InputWrapper.module.css → FieldWrapper.module.css} +2 -12
- package/dist/components/inputs/LexicalInput.d.ts +2 -13
- package/dist/components/inputs/LexicalInput.d.ts.map +1 -1
- package/dist/components/inputs/LexicalInput.js +4 -63
- package/dist/components/inputs/LexicalInput.js.map +1 -1
- package/dist/components/inputs/MessageInput.d.ts +6 -3
- package/dist/components/inputs/MessageInput.d.ts.map +1 -1
- package/dist/components/inputs/MessageInput.js +47 -43
- package/dist/components/inputs/MessageInput.js.map +1 -1
- package/dist/components/inputs/MessageInput.module.css +23 -4
- package/dist/components/inputs/ReferencePopover.d.ts +7 -0
- package/dist/components/inputs/ReferencePopover.d.ts.map +1 -0
- package/dist/components/inputs/ReferencePopover.js +42 -0
- package/dist/components/inputs/ReferencePopover.js.map +1 -0
- package/dist/components/inputs/ReferencePopover.module.css +70 -0
- package/dist/components/inputs/SingleLinePlugin.d.ts +2 -0
- package/dist/components/inputs/SingleLinePlugin.d.ts.map +1 -0
- package/dist/components/inputs/SingleLinePlugin.js +24 -0
- package/dist/components/inputs/SingleLinePlugin.js.map +1 -0
- package/dist/components/inputs/variables/VariableChip.d.ts.map +1 -1
- package/dist/components/inputs/variables/VariableChip.js +31 -32
- package/dist/components/inputs/variables/VariableChip.js.map +1 -1
- package/dist/components/inputs/variables/VariableChip.module.css +3 -3
- package/dist/components/inputs/variables/VariableSuggestion.d.ts +4 -0
- package/dist/components/inputs/variables/VariableSuggestion.d.ts.map +1 -0
- package/dist/components/inputs/variables/VariableSuggestion.js +24 -0
- package/dist/components/inputs/variables/VariableSuggestion.js.map +1 -0
- package/dist/components/inputs/variables/editors/PluralVariableEditor.d.ts.map +1 -1
- package/dist/components/inputs/variables/editors/PluralVariableEditor.js +62 -60
- package/dist/components/inputs/variables/editors/PluralVariableEditor.js.map +1 -1
- package/dist/components/inputs/variables/editors/PluralVariableEditor.module.css +4 -4
- package/dist/components/inputs/variables/editors/TemporalVariableEditor.d.ts +11 -0
- package/dist/components/inputs/variables/editors/TemporalVariableEditor.d.ts.map +1 -0
- package/dist/components/inputs/variables/editors/{DateVariableEditor.js → TemporalVariableEditor.js} +3 -3
- package/dist/components/inputs/variables/editors/TemporalVariableEditor.js.map +1 -0
- package/dist/components/inputs/variables/pickers/NumericVariableEditor.d.ts +7 -0
- package/dist/components/inputs/variables/pickers/{NumericVariablePicker.d.ts.map → NumericVariableEditor.d.ts.map} +1 -1
- package/dist/components/inputs/variables/pickers/{NumericVariablePicker.js → NumericVariableEditor.js} +15 -9
- package/dist/components/inputs/variables/pickers/NumericVariableEditor.js.map +1 -0
- package/dist/components/inputs/variables/pickers/{NumericVariablePicker.module.css → NumericVariableEditor.module.css} +3 -3
- package/dist/components/inputs/variables/pickers/TemporalVariablePicker.d.ts +7 -0
- package/dist/components/inputs/variables/pickers/TemporalVariablePicker.d.ts.map +1 -0
- package/dist/components/inputs/variables/pickers/TemporalVariablePicker.js +57 -0
- package/dist/components/inputs/variables/pickers/TemporalVariablePicker.js.map +1 -0
- package/dist/components/inputs/variables/pickers/{TemporalElementEditor.module.css → TemporalVariablePicker.module.css} +3 -3
- package/dist/components/layout/GroupStatusDot.d.ts +6 -0
- package/dist/components/layout/GroupStatusDot.d.ts.map +1 -0
- package/dist/components/layout/GroupStatusDot.js +24 -0
- package/dist/components/layout/GroupStatusDot.js.map +1 -0
- package/dist/components/layout/MessageField.d.ts +2 -1
- package/dist/components/layout/MessageField.d.ts.map +1 -1
- package/dist/components/layout/MessageField.js +52 -33
- package/dist/components/layout/MessageField.js.map +1 -1
- package/dist/components/layout/MessageField.module.css +21 -10
- package/dist/components/layout/MessagesTabs.d.ts.map +1 -1
- package/dist/components/layout/MessagesTabs.js +3 -5
- package/dist/components/layout/MessagesTabs.js.map +1 -1
- package/dist/components/layout/MessagesTree.d.ts +1 -1
- package/dist/components/layout/MessagesTree.d.ts.map +1 -1
- package/dist/components/layout/MessagesTree.js +33 -43
- package/dist/components/layout/MessagesTree.js.map +1 -1
- package/dist/components/layout/MessagesTree.module.css +10 -5
- package/dist/components/layout/StatusDot.d.ts +7 -0
- package/dist/components/layout/StatusDot.d.ts.map +1 -0
- package/dist/components/layout/StatusDot.js +12 -0
- package/dist/components/layout/StatusDot.js.map +1 -0
- package/dist/components/layout/StatusDot.module.css +16 -0
- package/dist/const.d.ts +2 -2
- package/dist/const.js +1 -1
- package/dist/entities.d.ts +1 -1
- package/dist/entities.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internals/index.d.ts +30 -0
- package/dist/internals/index.d.ts.map +1 -0
- package/dist/internals/index.js +81 -0
- package/dist/internals/index.js.map +1 -0
- package/dist/internals/procedure.d.ts.map +1 -0
- package/dist/{_common → internals}/procedure.js +1 -0
- package/dist/internals/procedure.js.map +1 -0
- package/dist/internals/urls.d.ts.map +1 -0
- package/dist/internals/urls.js.map +1 -0
- package/dist/internals/utils.d.ts +8 -0
- package/dist/internals/utils.d.ts.map +1 -0
- package/dist/{_common → internals}/utils.js +20 -5
- package/dist/internals/utils.js.map +1 -0
- package/dist/utils/sanitize.d.ts +7 -6
- package/dist/utils/sanitize.d.ts.map +1 -1
- package/dist/utils/sanitize.js +11 -8
- package/dist/utils/sanitize.js.map +1 -1
- package/package.json +4 -3
- package/dist/_common/index.d.ts +0 -17
- package/dist/_common/index.d.ts.map +0 -1
- package/dist/_common/index.js +0 -27
- package/dist/_common/index.js.map +0 -1
- package/dist/_common/procedure.d.ts.map +0 -1
- package/dist/_common/procedure.js.map +0 -1
- package/dist/_common/urls.d.ts.map +0 -1
- package/dist/_common/urls.js.map +0 -1
- package/dist/_common/utils.d.ts +0 -5
- package/dist/_common/utils.d.ts.map +0 -1
- package/dist/_common/utils.js.map +0 -1
- package/dist/components/MessageController.d.ts +0 -13
- package/dist/components/MessageController.d.ts.map +0 -1
- package/dist/components/MessageController.js.map +0 -1
- package/dist/components/MessageFormContext.d.ts.map +0 -1
- package/dist/components/MessageFormContext.js.map +0 -1
- package/dist/components/actions/Move.d.ts +0 -2
- package/dist/components/actions/Move.d.ts.map +0 -1
- package/dist/components/actions/Move.js.map +0 -1
- package/dist/components/inputs/InputWrapper.d.ts +0 -8
- package/dist/components/inputs/InputWrapper.d.ts.map +0 -1
- package/dist/components/inputs/InputWrapper.js +0 -34
- package/dist/components/inputs/InputWrapper.js.map +0 -1
- package/dist/components/inputs/variables/editors/DateVariableEditor.d.ts +0 -10
- package/dist/components/inputs/variables/editors/DateVariableEditor.d.ts.map +0 -1
- package/dist/components/inputs/variables/editors/DateVariableEditor.js.map +0 -1
- package/dist/components/inputs/variables/editors/TimeVariableEditor.d.ts +0 -10
- package/dist/components/inputs/variables/editors/TimeVariableEditor.d.ts.map +0 -1
- package/dist/components/inputs/variables/editors/TimeVariableEditor.js +0 -15
- package/dist/components/inputs/variables/editors/TimeVariableEditor.js.map +0 -1
- package/dist/components/inputs/variables/pickers/NumericVariablePicker.d.ts +0 -7
- package/dist/components/inputs/variables/pickers/NumericVariablePicker.js.map +0 -1
- package/dist/components/inputs/variables/pickers/TemporalElementEditor.d.ts +0 -7
- package/dist/components/inputs/variables/pickers/TemporalElementEditor.d.ts.map +0 -1
- package/dist/components/inputs/variables/pickers/TemporalElementEditor.js +0 -58
- package/dist/components/inputs/variables/pickers/TemporalElementEditor.js.map +0 -1
- /package/dist/components/actions/{Move.module.css → CopyMessages.module.css} +0 -0
- /package/dist/{_common → internals}/procedure.d.ts +0 -0
- /package/dist/{_common → internals}/urls.d.ts +0 -0
- /package/dist/{_common → internals}/urls.js +0 -0
package/dist/utils/sanitize.d.ts
CHANGED
|
@@ -5,12 +5,13 @@ import type { DeepPartial, Messages } from '../types';
|
|
|
5
5
|
* This happens when messages in the config were (re)moved.
|
|
6
6
|
*
|
|
7
7
|
* Keep exactly the keys from `shape`, fill values from `source` when present.
|
|
8
|
+
* When `useSchemaDefaults` is true, missing leaves fall back to the schema value.
|
|
8
9
|
* - Leaf present as string -> included
|
|
9
|
-
* - Leaf missing/non-string ->
|
|
10
|
-
* -
|
|
10
|
+
* - Leaf missing/non-string + useSchemaDefaults -> schema value used
|
|
11
|
+
* - Leaf missing/non-string + !useSchemaDefaults -> omitted
|
|
12
|
+
* - Empty nested groups -> omitted (unless filled by defaults)
|
|
11
13
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export declare function sanitizeMessages(config: Messages, data: unknown): DeepPartial<Messages>;
|
|
14
|
+
export declare function sanitizeMessages(config: Messages, data: unknown, { useSchemaDefaults }?: {
|
|
15
|
+
useSchemaDefaults?: boolean;
|
|
16
|
+
}): DeepPartial<Messages>;
|
|
16
17
|
//# sourceMappingURL=sanitize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/utils/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAErD
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/utils/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAErD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,QAAQ,EAChB,IAAI,EAAE,OAAO,EACb,EAAE,iBAAyB,EAAE,GAAE;IAAE,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAO,GAClE,WAAW,CAAC,QAAQ,CAAC,CA2BvB"}
|
package/dist/utils/sanitize.js
CHANGED
|
@@ -4,29 +4,32 @@
|
|
|
4
4
|
* This happens when messages in the config were (re)moved.
|
|
5
5
|
*
|
|
6
6
|
* Keep exactly the keys from `shape`, fill values from `source` when present.
|
|
7
|
+
* When `useSchemaDefaults` is true, missing leaves fall back to the schema value.
|
|
7
8
|
* - Leaf present as string -> included
|
|
8
|
-
* - Leaf missing/non-string ->
|
|
9
|
-
* -
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*/ export function sanitizeMessages(config, data) {
|
|
9
|
+
* - Leaf missing/non-string + useSchemaDefaults -> schema value used
|
|
10
|
+
* - Leaf missing/non-string + !useSchemaDefaults -> omitted
|
|
11
|
+
* - Empty nested groups -> omitted (unless filled by defaults)
|
|
12
|
+
*/ export function sanitizeMessages(config, data, { useSchemaDefaults = false } = {}) {
|
|
13
13
|
const out = {};
|
|
14
14
|
const src = isObj(data) ? data : {};
|
|
15
15
|
for (const key of Object.keys(config)){
|
|
16
16
|
const shapeVal = config[key];
|
|
17
17
|
const srcVal = src[key];
|
|
18
18
|
if (isObj(shapeVal)) {
|
|
19
|
-
const child = sanitizeMessages(shapeVal, srcVal
|
|
19
|
+
const child = sanitizeMessages(shapeVal, srcVal, {
|
|
20
|
+
useSchemaDefaults
|
|
21
|
+
});
|
|
20
22
|
if (isObj(child) && Object.keys(child).length > 0) {
|
|
21
23
|
out[key] = child;
|
|
22
24
|
}
|
|
23
25
|
// else: omit empty group
|
|
24
26
|
} else {
|
|
25
|
-
// Leaf:
|
|
27
|
+
// Leaf: keep source string, or fall back to schema value
|
|
26
28
|
if (typeof srcVal === 'string') {
|
|
27
29
|
out[key] = srcVal;
|
|
30
|
+
} else if (useSchemaDefaults && typeof shapeVal === 'string') {
|
|
31
|
+
out[key] = shapeVal;
|
|
28
32
|
}
|
|
29
|
-
// else: omit leaf
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
35
|
return out;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/sanitize.ts"],"sourcesContent":["import type { DeepPartial, Messages } from '@/types';\n\n/**\n * Sanitize messages data to match the schema.\n * Stored messages might contain keys that are not in the config.\n * This happens when messages in the config were (re)moved.\n *\n * Keep exactly the keys from `shape`, fill values from `source` when present.\n * - Leaf present as string -> included\n * - Leaf missing/non-string -> omitted\n * - Empty nested groups -> omitted
|
|
1
|
+
{"version":3,"sources":["../../src/utils/sanitize.ts"],"sourcesContent":["import type { DeepPartial, Messages } from '@/types';\n\n/**\n * Sanitize messages data to match the schema.\n * Stored messages might contain keys that are not in the config.\n * This happens when messages in the config were (re)moved.\n *\n * Keep exactly the keys from `shape`, fill values from `source` when present.\n * When `useSchemaDefaults` is true, missing leaves fall back to the schema value.\n * - Leaf present as string -> included\n * - Leaf missing/non-string + useSchemaDefaults -> schema value used\n * - Leaf missing/non-string + !useSchemaDefaults -> omitted\n * - Empty nested groups -> omitted (unless filled by defaults)\n */\nexport function sanitizeMessages(\n config: Messages,\n data: unknown,\n { useSchemaDefaults = false }: { useSchemaDefaults?: boolean } = {},\n): DeepPartial<Messages> {\n const out: Record<string, unknown> = {};\n const src = isObj(data) ? data : {};\n\n for (const key of Object.keys(config)) {\n const shapeVal = (config as Record<string, unknown>)[key];\n const srcVal = src[key];\n\n if (isObj(shapeVal)) {\n const child = sanitizeMessages(shapeVal as Messages, srcVal, {\n useSchemaDefaults,\n });\n if (isObj(child) && Object.keys(child).length > 0) {\n out[key] = child;\n }\n // else: omit empty group\n } else {\n // Leaf: keep source string, or fall back to schema value\n if (typeof srcVal === 'string') {\n out[key] = srcVal;\n } else if (useSchemaDefaults && typeof shapeVal === 'string') {\n out[key] = shapeVal;\n }\n }\n }\n\n return out as DeepPartial<Messages>;\n}\n\nfunction isObj(x: unknown): x is Record<string, unknown> {\n return !!x && typeof x === 'object' && !Array.isArray(x);\n}\n"],"names":["sanitizeMessages","config","data","useSchemaDefaults","out","src","isObj","key","Object","keys","shapeVal","srcVal","child","length","x","Array","isArray"],"mappings":"AAEA;;;;;;;;;;;CAWC,GACD,OAAO,SAASA,iBACdC,MAAgB,EAChBC,IAAa,EACb,EAAEC,oBAAoB,KAAK,EAAmC,GAAG,CAAC,CAAC;IAEnE,MAAMC,MAA+B,CAAC;IACtC,MAAMC,MAAMC,MAAMJ,QAAQA,OAAO,CAAC;IAElC,KAAK,MAAMK,OAAOC,OAAOC,IAAI,CAACR,QAAS;QACrC,MAAMS,WAAW,AAACT,MAAkC,CAACM,IAAI;QACzD,MAAMI,SAASN,GAAG,CAACE,IAAI;QAEvB,IAAID,MAAMI,WAAW;YACnB,MAAME,QAAQZ,iBAAiBU,UAAsBC,QAAQ;gBAC3DR;YACF;YACA,IAAIG,MAAMM,UAAUJ,OAAOC,IAAI,CAACG,OAAOC,MAAM,GAAG,GAAG;gBACjDT,GAAG,CAACG,IAAI,GAAGK;YACb;QACA,yBAAyB;QAC3B,OAAO;YACL,yDAAyD;YACzD,IAAI,OAAOD,WAAW,UAAU;gBAC9BP,GAAG,CAACG,IAAI,GAAGI;YACb,OAAO,IAAIR,qBAAqB,OAAOO,aAAa,UAAU;gBAC5DN,GAAG,CAACG,IAAI,GAAGG;YACb;QACF;IACF;IAEA,OAAON;AACT;AAEA,SAASE,MAAMQ,CAAU;IACvB,OAAO,CAAC,CAACA,KAAK,OAAOA,MAAM,YAAY,CAACC,MAAMC,OAAO,CAACF;AACxD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload-intl",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "Payload Plugin for I18N using ICU Messages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -45,11 +45,12 @@
|
|
|
45
45
|
"dist"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
+
"@base-ui/react": "^1.1.0",
|
|
48
49
|
"@formatjs/icu-messageformat-parser": "^2.11.2",
|
|
49
50
|
"@tabler/icons-react": "^3.36.1",
|
|
51
|
+
"clsx": "^2.1.1",
|
|
50
52
|
"lexical-beautiful-mentions": "^0.1.48",
|
|
51
53
|
"lodash-es": "^4.17.21",
|
|
52
|
-
"radix-ui": "^1.4.2",
|
|
53
54
|
"react-hook-form": "^7.58.1",
|
|
54
55
|
"zod": "4.3.5"
|
|
55
56
|
},
|
|
@@ -84,7 +85,7 @@
|
|
|
84
85
|
"access": "public"
|
|
85
86
|
},
|
|
86
87
|
"scripts": {
|
|
87
|
-
"prebuild": "rm -f src/
|
|
88
|
+
"prebuild": "rm -f src/internals 2>/dev/null; pnpm typecheck",
|
|
88
89
|
"build": "plugin-build",
|
|
89
90
|
"clean": "rm -rf dist && rm -rf node_modules",
|
|
90
91
|
"dev": "plugin-build --watch",
|
package/dist/_common/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { CollectionConfig, CollectionSlug, TypeWithID } from 'payload';
|
|
2
|
-
import z from 'zod';
|
|
3
|
-
export declare const entityIdSchema: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
4
|
-
export type EntityID = TypeWithID['id'] & z.infer<typeof entityIdSchema>;
|
|
5
|
-
export declare const isPopulated: <T extends TypeWithID>(relationship: T | EntityID) => relationship is T;
|
|
6
|
-
export declare function assertPopulated<T extends TypeWithID | null>(docsOrIds: (T | EntityID)[], errorMessage?: (id: EntityID) => string): T[];
|
|
7
|
-
export declare function assertPopulated<T extends TypeWithID | null>(docOrId: T | EntityID, errorMessage?: (id: EntityID) => string): T;
|
|
8
|
-
export declare const createCollectionConfigFactory: <T extends Record<string, unknown>>(factory: Omit<CollectionConfig, "slug"> | ((options: T & {
|
|
9
|
-
slug: CollectionSlug;
|
|
10
|
-
}) => Omit<CollectionConfig, "slug">)) => (options: T & {
|
|
11
|
-
slug: CollectionSlug;
|
|
12
|
-
}) => CollectionConfig;
|
|
13
|
-
export declare const resolveForeignKey: (entity: TypeWithID["id"] | TypeWithID) => string | number;
|
|
14
|
-
export { defineProcedure, type Procedure, type ProcedureBuilder, } from './procedure';
|
|
15
|
-
export { getAdminURL, getApiURL, getServerURL } from './urls';
|
|
16
|
-
export { findFields, uncaughtSwitchCase } from './utils';
|
|
17
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/_common/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,CAAC,MAAM,KAAK,CAAC;AAIpB,eAAO,MAAM,cAAc,iDAAoC,CAAC;AAChE,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAIzE,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,UAAU,gBAChC,CAAC,GAAG,QAAQ,KACzB,YAAY,IAAI,CAAqC,CAAC;AAEzD,wBAAgB,eAAe,CAAC,CAAC,SAAS,UAAU,GAAG,IAAI,EACzD,SAAS,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,EAAE,EAC3B,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,MAAM,GACtC,CAAC,EAAE,CAAC;AACP,wBAAgB,eAAe,CAAC,CAAC,SAAS,UAAU,GAAG,IAAI,EACzD,OAAO,EAAE,CAAC,GAAG,QAAQ,EACrB,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,MAAM,GACtC,CAAC,CAAC;AAeL,eAAO,MAAM,6BAA6B,GACvC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,WAE5B,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,GAC9B,CAAC,CACC,OAAO,EAAE,CAAC,GAAG;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,KAClC,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,eAEhC,CAAC,GAAG;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,KAAG,gBAGvC,CAAC;AAEL,eAAO,MAAM,iBAAiB,WAAY,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,oBACtB,CAAC;AAElD,OAAO,EACL,eAAe,EACf,KAAK,SAAS,EACd,KAAK,gBAAgB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/_common/index.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import z from 'zod';
|
|
2
|
-
// MARK: Types
|
|
3
|
-
export const entityIdSchema = z.union([
|
|
4
|
-
z.number(),
|
|
5
|
-
z.string()
|
|
6
|
-
]);
|
|
7
|
-
// MARK: Type Guards
|
|
8
|
-
export const isPopulated = (relationship)=>typeof relationship === 'object';
|
|
9
|
-
export function assertPopulated(value, errorMessage = (id)=>`Doc is not populated: [${id}]`) {
|
|
10
|
-
if (value === null) return value;
|
|
11
|
-
if (Array.isArray(value)) {
|
|
12
|
-
return value.map((item)=>assertPopulated(item, errorMessage));
|
|
13
|
-
}
|
|
14
|
-
if (isPopulated(value)) return value;
|
|
15
|
-
throw new Error(errorMessage(value));
|
|
16
|
-
}
|
|
17
|
-
// MARK: Utilities
|
|
18
|
-
export const createCollectionConfigFactory = (factory)=>(options)=>({
|
|
19
|
-
slug: options.slug,
|
|
20
|
-
...typeof factory === 'function' ? factory(options) : factory
|
|
21
|
-
});
|
|
22
|
-
export const resolveForeignKey = (entity)=>typeof entity === 'object' ? entity.id : entity;
|
|
23
|
-
export { defineProcedure } from './procedure';
|
|
24
|
-
export { getAdminURL, getApiURL, getServerURL } from './urls';
|
|
25
|
-
export { findFields, uncaughtSwitchCase } from './utils';
|
|
26
|
-
|
|
27
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/_common/index.ts"],"sourcesContent":["import type { CollectionConfig, CollectionSlug, TypeWithID } from 'payload';\nimport z from 'zod';\n\n// MARK: Types\n\nexport const entityIdSchema = z.union([z.number(), z.string()]);\nexport type EntityID = TypeWithID['id'] & z.infer<typeof entityIdSchema>;\n\n// MARK: Type Guards\n\nexport const isPopulated = <T extends TypeWithID>(\n relationship: T | EntityID,\n): relationship is T => typeof relationship === 'object';\n\nexport function assertPopulated<T extends TypeWithID | null>(\n docsOrIds: (T | EntityID)[],\n errorMessage?: (id: EntityID) => string,\n): T[];\nexport function assertPopulated<T extends TypeWithID | null>(\n docOrId: T | EntityID,\n errorMessage?: (id: EntityID) => string,\n): T;\nexport function assertPopulated<T extends TypeWithID | null>(\n value: T | EntityID | (T | EntityID)[],\n errorMessage = (id: EntityID) => `Doc is not populated: [${id}]`,\n): T | T[] {\n if (value === null) return value;\n if (Array.isArray(value)) {\n return value.map((item) => assertPopulated(item, errorMessage));\n }\n if (isPopulated(value)) return value;\n throw new Error(errorMessage(value as EntityID));\n}\n\n// MARK: Utilities\n\nexport const createCollectionConfigFactory =\n <T extends Record<string, unknown>>(\n factory:\n | Omit<CollectionConfig, 'slug'>\n | ((\n options: T & { slug: CollectionSlug },\n ) => Omit<CollectionConfig, 'slug'>),\n ) =>\n (options: T & { slug: CollectionSlug }): CollectionConfig => ({\n slug: options.slug,\n ...(typeof factory === 'function' ? factory(options) : factory),\n });\n\nexport const resolveForeignKey = (entity: TypeWithID['id'] | TypeWithID) =>\n typeof entity === 'object' ? entity.id : entity;\n\nexport {\n defineProcedure,\n type Procedure,\n type ProcedureBuilder,\n} from './procedure';\nexport { getAdminURL, getApiURL, getServerURL } from './urls';\nexport { findFields, uncaughtSwitchCase } from './utils';\n"],"names":["z","entityIdSchema","union","number","string","isPopulated","relationship","assertPopulated","value","errorMessage","id","Array","isArray","map","item","Error","createCollectionConfigFactory","factory","options","slug","resolveForeignKey","entity","defineProcedure","getAdminURL","getApiURL","getServerURL","findFields","uncaughtSwitchCase"],"mappings":"AACA,OAAOA,OAAO,MAAM;AAEpB,cAAc;AAEd,OAAO,MAAMC,iBAAiBD,EAAEE,KAAK,CAAC;IAACF,EAAEG,MAAM;IAAIH,EAAEI,MAAM;CAAG,EAAE;AAGhE,oBAAoB;AAEpB,OAAO,MAAMC,cAAc,CACzBC,eACsB,OAAOA,iBAAiB,SAAS;AAUzD,OAAO,SAASC,gBACdC,KAAsC,EACtCC,eAAe,CAACC,KAAiB,CAAC,uBAAuB,EAAEA,GAAG,CAAC,CAAC;IAEhE,IAAIF,UAAU,MAAM,OAAOA;IAC3B,IAAIG,MAAMC,OAAO,CAACJ,QAAQ;QACxB,OAAOA,MAAMK,GAAG,CAAC,CAACC,OAASP,gBAAgBO,MAAML;IACnD;IACA,IAAIJ,YAAYG,QAAQ,OAAOA;IAC/B,MAAM,IAAIO,MAAMN,aAAaD;AAC/B;AAEA,kBAAkB;AAElB,OAAO,MAAMQ,gCACX,CACEC,UAMF,CAACC,UAA6D,CAAA;YAC5DC,MAAMD,QAAQC,IAAI;YAClB,GAAI,OAAOF,YAAY,aAAaA,QAAQC,WAAWD,OAAO;QAChE,CAAA,EAAG;AAEL,OAAO,MAAMG,oBAAoB,CAACC,SAChC,OAAOA,WAAW,WAAWA,OAAOX,EAAE,GAAGW,OAAO;AAElD,SACEC,eAAe,QAGV,cAAc;AACrB,SAASC,WAAW,EAAEC,SAAS,EAAEC,YAAY,QAAQ,SAAS;AAC9D,SAASC,UAAU,EAAEC,kBAAkB,QAAQ,UAAU"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"procedure.d.ts","sourceRoot":"","sources":["../../src/_common/procedure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAExD,KAAK,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE1D,6DAA6D;AAC7D,UAAU,OAAO,CAAC,OAAO,GAAG,OAAO;IACjC,SAAS,CACP,IAAI,EAAE,OAAO,GACZ;QAAE,OAAO,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;CAC1E;AAED,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAE7D,UAAU,eAAe,CAAC,OAAO,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS;IACvE,IAAI,EAAE,IAAI,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,SAAS,CAAC,MAAM,EAAE,OAAO;IACxC,IAAI,EAAE,IAAI,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CACN,OAAO,EAAE,CACP,GAAG,EAAE,cAAc,EACnB,GAAG,IAAI,EAAE,MAAM,SAAS,IAAI,GAAG,EAAE,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,KAChD,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC,GAC/B,QAAQ,CAAC;IACZ,IAAI,CACF,MAAM,EAAE,MAAM,EACd,GAAG,IAAI,EAAE,MAAM,SAAS,IAAI,GAAG,EAAE,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,GAClD,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB,CAAC,MAAM;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,OAAO,KAAK,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/C,QAAQ,CACN,OAAO,EAAE,CACP,GAAG,EAAE,cAAc,EACnB,GAAG,IAAI,EAAE,MAAM,SAAS,IAAI,GAAG,EAAE,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,KAChD,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC,GAC/B,QAAQ,CAAC;IACZ,IAAI,CACF,MAAM,EAAE,MAAM,EACd,GAAG,IAAI,EAAE,MAAM,SAAS,IAAI,GAAG,EAAE,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,GAClD,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB;AA2GD,wBAAgB,eAAe,CAC7B,OAAO,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,EAE/C,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,GAC/B,gBAAgB,CAAC,OAAO,SAAS,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAazE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/_common/procedure.ts"],"sourcesContent":["import type { Endpoint, PayloadRequest } from 'payload';\n\ntype Method = 'get' | 'post' | 'put' | 'patch' | 'delete';\n\n/** Any Zod-like schema with safeParse and inferred output */\ninterface ZodLike<TOutput = unknown> {\n safeParse(\n data: unknown,\n ): { success: true; data: TOutput } | { success: false; error: unknown };\n}\n\ntype InferOutput<T> = T extends ZodLike<infer O> ? O : never;\n\ninterface ProcedureConfig<TSchema extends ZodLike | undefined = undefined> {\n path: `/${string}`;\n method: Method;\n input?: TSchema;\n}\n\nexport interface Procedure<TInput, TOutput> {\n path: `/${string}`;\n method: Method;\n endpoint(\n handler: (\n req: PayloadRequest,\n ...args: TInput extends void ? [] : [input: TInput]\n ) => Promise<unknown | Response>,\n ): Endpoint;\n call(\n apiUrl: string,\n ...args: TInput extends void ? [] : [input: TInput]\n ): Promise<TOutput>;\n}\n\nexport interface ProcedureBuilder<TInput> {\n path: string;\n method: Method;\n returns<TOutput>(): Procedure<TInput, TOutput>;\n endpoint(\n handler: (\n req: PayloadRequest,\n ...args: TInput extends void ? [] : [input: TInput]\n ) => Promise<unknown | Response>,\n ): Endpoint;\n call(\n apiUrl: string,\n ...args: TInput extends void ? [] : [input: TInput]\n ): Promise<unknown>;\n}\n\nfunction wrapOutput(output: unknown): Response {\n if (output instanceof Response) return output;\n return Response.json(output);\n}\n\nfunction createProcedure<TInput, TOutput>(\n config: ProcedureConfig<ZodLike | undefined>,\n inputSchema: ZodLike | undefined,\n): Procedure<TInput, TOutput> {\n return {\n path: config.path,\n method: config.method,\n endpoint(handler) {\n return {\n path: config.path,\n method: config.method,\n handler: async (req) => {\n if (inputSchema) {\n if (config.method === 'get') {\n const routeParams = req.routeParams ?? {};\n const searchParams = req.searchParams\n ? Object.fromEntries(req.searchParams.entries())\n : {};\n const merged = { ...searchParams, ...routeParams };\n const result = inputSchema.safeParse(merged);\n if (!result.success) {\n return Response.json({ error: result.error }, { status: 400 });\n }\n // biome-ignore lint/complexity/noBannedTypes: ugly type cast\n const output = await (handler as Function)(req, result.data);\n return wrapOutput(output);\n }\n\n const { addDataAndFileToRequest } = await import(\n /* webpackIgnore: true */ 'payload'\n );\n await addDataAndFileToRequest(req);\n const result = inputSchema.safeParse(req.data);\n if (!result.success) {\n return Response.json({ error: result.error }, { status: 400 });\n }\n // biome-ignore lint/complexity/noBannedTypes: ugly type cast\n const output = await (handler as Function)(req, result.data);\n return wrapOutput(output);\n }\n // biome-ignore lint/complexity/noBannedTypes: ugly type cast\n const output = await (handler as Function)(req);\n return wrapOutput(output);\n },\n };\n },\n call(apiUrl, ...args) {\n const input = args[0] as Record<string, unknown> | undefined;\n\n if (config.method === 'get') {\n let resolvedPath = config.path;\n const queryParams: Record<string, string> = {};\n\n if (input) {\n for (const [key, value] of Object.entries(input)) {\n if (resolvedPath.includes(`:${key}`)) {\n resolvedPath = resolvedPath.replace(\n `:${key}`,\n encodeURIComponent(String(value)),\n ) as `/${string}`;\n } else {\n queryParams[key] = String(value);\n }\n }\n }\n\n const queryString = new URLSearchParams(queryParams).toString();\n const url = `${apiUrl}${resolvedPath}${queryString ? `?${queryString}` : ''}`;\n\n return fetch(url, {\n method: 'GET',\n credentials: 'include',\n }).then(async (response) => {\n if (!response.ok) {\n throw new Error(\n `Request failed: ${response.status} ${response.statusText}`,\n );\n }\n return response.json();\n }) as Promise<TOutput>;\n }\n\n const url = `${apiUrl}${config.path}`;\n return fetch(url, {\n method: config.method.toUpperCase(),\n credentials: 'include',\n headers: { 'Content-Type': 'application/json' },\n body: input ? JSON.stringify(input) : undefined,\n }).then(async (response) => {\n if (!response.ok) {\n throw new Error(\n `Request failed: ${response.status} ${response.statusText}`,\n );\n }\n return response.json();\n }) as Promise<TOutput>;\n },\n };\n}\n\nexport function defineProcedure<\n TSchema extends ZodLike | undefined = undefined,\n>(\n config: ProcedureConfig<TSchema>,\n): ProcedureBuilder<TSchema extends ZodLike ? InferOutput<TSchema> : void> {\n type TInput = TSchema extends ZodLike ? InferOutput<TSchema> : undefined;\n const proc = createProcedure<TInput, unknown>(config, config.input);\n\n return {\n path: config.path,\n method: config.method,\n returns<TOutput>(): Procedure<TInput, TOutput> {\n return createProcedure<TInput, TOutput>(config, config.input);\n },\n endpoint: proc.endpoint as unknown as ProcedureBuilder<TInput>['endpoint'],\n call: proc.call as ProcedureBuilder<TInput>['call'],\n };\n}\n"],"names":["wrapOutput","output","Response","json","createProcedure","config","inputSchema","path","method","endpoint","handler","req","routeParams","searchParams","Object","fromEntries","entries","merged","result","safeParse","success","error","status","data","addDataAndFileToRequest","call","apiUrl","args","input","resolvedPath","queryParams","key","value","includes","replace","encodeURIComponent","String","queryString","URLSearchParams","toString","url","fetch","credentials","then","response","ok","Error","statusText","toUpperCase","headers","body","JSON","stringify","undefined","defineProcedure","proc","returns"],"mappings":"AAkDA,SAASA,WAAWC,MAAe;IACjC,IAAIA,kBAAkBC,UAAU,OAAOD;IACvC,OAAOC,SAASC,IAAI,CAACF;AACvB;AAEA,SAASG,gBACPC,MAA4C,EAC5CC,WAAgC;IAEhC,OAAO;QACLC,MAAMF,OAAOE,IAAI;QACjBC,QAAQH,OAAOG,MAAM;QACrBC,UAASC,OAAO;YACd,OAAO;gBACLH,MAAMF,OAAOE,IAAI;gBACjBC,QAAQH,OAAOG,MAAM;gBACrBE,SAAS,OAAOC;oBACd,IAAIL,aAAa;wBACf,IAAID,OAAOG,MAAM,KAAK,OAAO;4BAC3B,MAAMI,cAAcD,IAAIC,WAAW,IAAI,CAAC;4BACxC,MAAMC,eAAeF,IAAIE,YAAY,GACjCC,OAAOC,WAAW,CAACJ,IAAIE,YAAY,CAACG,OAAO,MAC3C,CAAC;4BACL,MAAMC,SAAS;gCAAE,GAAGJ,YAAY;gCAAE,GAAGD,WAAW;4BAAC;4BACjD,MAAMM,SAASZ,YAAYa,SAAS,CAACF;4BACrC,IAAI,CAACC,OAAOE,OAAO,EAAE;gCACnB,OAAOlB,SAASC,IAAI,CAAC;oCAAEkB,OAAOH,OAAOG,KAAK;gCAAC,GAAG;oCAAEC,QAAQ;gCAAI;4BAC9D;4BACA,6DAA6D;4BAC7D,MAAMrB,SAAS,MAAM,AAACS,QAAqBC,KAAKO,OAAOK,IAAI;4BAC3D,OAAOvB,WAAWC;wBACpB;wBAEA,MAAM,EAAEuB,uBAAuB,EAAE,GAAG,MAAM,MAAM,CAC9C,uBAAuB,GAAG;wBAE5B,MAAMA,wBAAwBb;wBAC9B,MAAMO,SAASZ,YAAYa,SAAS,CAACR,IAAIY,IAAI;wBAC7C,IAAI,CAACL,OAAOE,OAAO,EAAE;4BACnB,OAAOlB,SAASC,IAAI,CAAC;gCAAEkB,OAAOH,OAAOG,KAAK;4BAAC,GAAG;gCAAEC,QAAQ;4BAAI;wBAC9D;wBACA,6DAA6D;wBAC7D,MAAMrB,SAAS,MAAM,AAACS,QAAqBC,KAAKO,OAAOK,IAAI;wBAC3D,OAAOvB,WAAWC;oBACpB;oBACA,6DAA6D;oBAC7D,MAAMA,SAAS,MAAM,AAACS,QAAqBC;oBAC3C,OAAOX,WAAWC;gBACpB;YACF;QACF;QACAwB,MAAKC,MAAM,EAAE,GAAGC,IAAI;YAClB,MAAMC,QAAQD,IAAI,CAAC,EAAE;YAErB,IAAItB,OAAOG,MAAM,KAAK,OAAO;gBAC3B,IAAIqB,eAAexB,OAAOE,IAAI;gBAC9B,MAAMuB,cAAsC,CAAC;gBAE7C,IAAIF,OAAO;oBACT,KAAK,MAAM,CAACG,KAAKC,MAAM,IAAIlB,OAAOE,OAAO,CAACY,OAAQ;wBAChD,IAAIC,aAAaI,QAAQ,CAAC,CAAC,CAAC,EAAEF,KAAK,GAAG;4BACpCF,eAAeA,aAAaK,OAAO,CACjC,CAAC,CAAC,EAAEH,KAAK,EACTI,mBAAmBC,OAAOJ;wBAE9B,OAAO;4BACLF,WAAW,CAACC,IAAI,GAAGK,OAAOJ;wBAC5B;oBACF;gBACF;gBAEA,MAAMK,cAAc,IAAIC,gBAAgBR,aAAaS,QAAQ;gBAC7D,MAAMC,MAAM,GAAGd,SAASG,eAAeQ,cAAc,CAAC,CAAC,EAAEA,aAAa,GAAG,IAAI;gBAE7E,OAAOI,MAAMD,KAAK;oBAChBhC,QAAQ;oBACRkC,aAAa;gBACf,GAAGC,IAAI,CAAC,OAAOC;oBACb,IAAI,CAACA,SAASC,EAAE,EAAE;wBAChB,MAAM,IAAIC,MACR,CAAC,gBAAgB,EAAEF,SAAStB,MAAM,CAAC,CAAC,EAAEsB,SAASG,UAAU,EAAE;oBAE/D;oBACA,OAAOH,SAASzC,IAAI;gBACtB;YACF;YAEA,MAAMqC,MAAM,GAAGd,SAASrB,OAAOE,IAAI,EAAE;YACrC,OAAOkC,MAAMD,KAAK;gBAChBhC,QAAQH,OAAOG,MAAM,CAACwC,WAAW;gBACjCN,aAAa;gBACbO,SAAS;oBAAE,gBAAgB;gBAAmB;gBAC9CC,MAAMtB,QAAQuB,KAAKC,SAAS,CAACxB,SAASyB;YACxC,GAAGV,IAAI,CAAC,OAAOC;gBACb,IAAI,CAACA,SAASC,EAAE,EAAE;oBAChB,MAAM,IAAIC,MACR,CAAC,gBAAgB,EAAEF,SAAStB,MAAM,CAAC,CAAC,EAAEsB,SAASG,UAAU,EAAE;gBAE/D;gBACA,OAAOH,SAASzC,IAAI;YACtB;QACF;IACF;AACF;AAEA,OAAO,SAASmD,gBAGdjD,MAAgC;IAGhC,MAAMkD,OAAOnD,gBAAiCC,QAAQA,OAAOuB,KAAK;IAElE,OAAO;QACLrB,MAAMF,OAAOE,IAAI;QACjBC,QAAQH,OAAOG,MAAM;QACrBgD;YACE,OAAOpD,gBAAiCC,QAAQA,OAAOuB,KAAK;QAC9D;QACAnB,UAAU8C,KAAK9C,QAAQ;QACvBgB,MAAM8B,KAAK9B,IAAI;IACjB;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"urls.d.ts","sourceRoot":"","sources":["../../src/_common/urls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG9C,wBAAgB,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM,CAWxD;AAED,wBAAgB,WAAW,CAAC,EAC1B,GAAG,EACH,IAAI,GACL,EAAE;IACD,GAAG,EAAE,cAAc,CAAC;IACpB,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,IAAI,CAAC;CACjC,GAAG,MAAM,CAMT;AAED,wBAAgB,SAAS,CAAC,EACxB,GAAG,EACH,IAAI,GACL,EAAE;IACD,GAAG,EAAE,cAAc,CAAC;IACpB,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,IAAI,CAAC;CACjC,GAAG,MAAM,CAMT"}
|
package/dist/_common/urls.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/_common/urls.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload';\nimport { formatAdminURL } from 'payload/shared';\n\nexport function getServerURL(req: PayloadRequest): string {\n if (!req.url)\n throw new Error(\n 'Could not get serverURL, since request URL is not available',\n );\n\n const { config } = req.payload;\n\n if (config.serverURL) return config.serverURL;\n\n return `${new URL(req.url).protocol}//${req.headers.get('host')}`;\n}\n\nexport function getAdminURL({\n req,\n path,\n}: {\n req: PayloadRequest;\n path?: '' | `/${string}` | null;\n}): string {\n return formatAdminURL({\n adminRoute: req.payload.config.routes.admin,\n serverURL: getServerURL(req),\n path,\n });\n}\n\nexport function getApiURL({\n req,\n path,\n}: {\n req: PayloadRequest;\n path?: '' | `/${string}` | null;\n}): string {\n return formatAdminURL({\n apiRoute: req.payload.config.routes.api,\n serverURL: getServerURL(req),\n path,\n });\n}\n"],"names":["formatAdminURL","getServerURL","req","url","Error","config","payload","serverURL","URL","protocol","headers","get","getAdminURL","path","adminRoute","routes","admin","getApiURL","apiRoute","api"],"mappings":"AACA,SAASA,cAAc,QAAQ,iBAAiB;AAEhD,OAAO,SAASC,aAAaC,GAAmB;IAC9C,IAAI,CAACA,IAAIC,GAAG,EACV,MAAM,IAAIC,MACR;IAGJ,MAAM,EAAEC,MAAM,EAAE,GAAGH,IAAII,OAAO;IAE9B,IAAID,OAAOE,SAAS,EAAE,OAAOF,OAAOE,SAAS;IAE7C,OAAO,GAAG,IAAIC,IAAIN,IAAIC,GAAG,EAAEM,QAAQ,CAAC,EAAE,EAAEP,IAAIQ,OAAO,CAACC,GAAG,CAAC,SAAS;AACnE;AAEA,OAAO,SAASC,YAAY,EAC1BV,GAAG,EACHW,IAAI,EAIL;IACC,OAAOb,eAAe;QACpBc,YAAYZ,IAAII,OAAO,CAACD,MAAM,CAACU,MAAM,CAACC,KAAK;QAC3CT,WAAWN,aAAaC;QACxBW;IACF;AACF;AAEA,OAAO,SAASI,UAAU,EACxBf,GAAG,EACHW,IAAI,EAIL;IACC,OAAOb,eAAe;QACpBkB,UAAUhB,IAAII,OAAO,CAACD,MAAM,CAACU,MAAM,CAACI,GAAG;QACvCZ,WAAWN,aAAaC;QACxBW;IACF;AACF"}
|
package/dist/_common/utils.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Field } from 'payload';
|
|
2
|
-
export declare const uncaughtSwitchCase: (value: never) => never;
|
|
3
|
-
export declare function findFields<T extends Field>(fields: Field[], condition: (field: Field) => field is T): T[];
|
|
4
|
-
export declare function findFields(fields: Field[], condition: (field: Field) => boolean): Field[];
|
|
5
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/_common/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,eAAO,MAAM,kBAAkB,UAAW,KAAK,UAE9C,CAAC;AAEF,wBAAgB,UAAU,CAAC,CAAC,SAAS,KAAK,EACxC,MAAM,EAAE,KAAK,EAAE,EACf,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,IAAI,CAAC,GACtC,CAAC,EAAE,CAAC;AACP,wBAAgB,UAAU,CACxB,MAAM,EAAE,KAAK,EAAE,EACf,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,GACnC,KAAK,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/_common/utils.ts"],"sourcesContent":["import type { Field } from 'payload';\n\nexport const uncaughtSwitchCase = (value: never) => {\n throw new Error(`Unhandled switch case: ${value}`);\n};\n\nexport function findFields<T extends Field>(\n fields: Field[],\n condition: (field: Field) => field is T,\n): T[];\nexport function findFields(\n fields: Field[],\n condition: (field: Field) => boolean,\n): Field[];\nexport function findFields(\n fields: Field[],\n condition: (field: Field) => boolean,\n): Field[] {\n return fields.flatMap((field) => {\n if (condition(field)) {\n return [field];\n }\n\n if ('fields' in field) {\n return findFields(field.fields, condition);\n }\n\n switch (field.type) {\n case 'blocks':\n return field.blocks.flatMap((block) =>\n findFields(block.fields, condition),\n );\n case 'tabs':\n return field.tabs.flatMap((tab) => findFields(tab.fields, condition));\n case 'text':\n case 'richText':\n case 'number':\n case 'checkbox':\n case 'date':\n case 'email':\n case 'select':\n case 'json':\n case 'code':\n case 'join':\n case 'point':\n case 'radio':\n case 'textarea':\n case 'ui':\n case 'relationship':\n case 'upload':\n return [];\n default:\n return uncaughtSwitchCase(field);\n }\n });\n}\n"],"names":["uncaughtSwitchCase","value","Error","findFields","fields","condition","flatMap","field","type","blocks","block","tabs","tab"],"mappings":"AAEA,OAAO,MAAMA,qBAAqB,CAACC;IACjC,MAAM,IAAIC,MAAM,CAAC,uBAAuB,EAAED,OAAO;AACnD,EAAE;AAUF,OAAO,SAASE,WACdC,MAAe,EACfC,SAAoC;IAEpC,OAAOD,OAAOE,OAAO,CAAC,CAACC;QACrB,IAAIF,UAAUE,QAAQ;YACpB,OAAO;gBAACA;aAAM;QAChB;QAEA,IAAI,YAAYA,OAAO;YACrB,OAAOJ,WAAWI,MAAMH,MAAM,EAAEC;QAClC;QAEA,OAAQE,MAAMC,IAAI;YAChB,KAAK;gBACH,OAAOD,MAAME,MAAM,CAACH,OAAO,CAAC,CAACI,QAC3BP,WAAWO,MAAMN,MAAM,EAAEC;YAE7B,KAAK;gBACH,OAAOE,MAAMI,IAAI,CAACL,OAAO,CAAC,CAACM,MAAQT,WAAWS,IAAIR,MAAM,EAAEC;YAC5D,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;gBACH,OAAO,EAAE;YACX;gBACE,OAAOL,mBAAmBO;QAC9B;IACF;AACF"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Locale, TemplateVariable } from '../types';
|
|
2
|
-
import type { MessageValidator } from '../utils/validate';
|
|
3
|
-
interface MessageControllerProps {
|
|
4
|
-
label?: string;
|
|
5
|
-
locale: Locale;
|
|
6
|
-
name: string;
|
|
7
|
-
className?: string;
|
|
8
|
-
variables: TemplateVariable[];
|
|
9
|
-
validate: MessageValidator;
|
|
10
|
-
}
|
|
11
|
-
export declare function MessageController({ name, variables, label, locale, validate, className, }: MessageControllerProps): React.ReactNode;
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=MessageController.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MessageController.d.ts","sourceRoot":"","sources":["../../src/components/MessageController.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAIzD,UAAU,sBAAsB;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AAED,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,SAAS,EACT,KAAK,EACL,MAAM,EACN,QAAQ,EACR,SAAS,GACV,EAAE,sBAAsB,GAAG,KAAK,CAAC,SAAS,CAyB1C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/MessageController.tsx"],"sourcesContent":["import { Controller } from 'react-hook-form';\nimport { useMessagesForm } from '@/components/MessageFormContext';\nimport type { Locale, TemplateVariable } from '@/types';\nimport type { MessageValidator } from '@/utils/validate';\n\nimport { MessageInput } from './inputs/MessageInput';\n\ninterface MessageControllerProps {\n label?: string;\n locale: Locale;\n name: string;\n className?: string;\n variables: TemplateVariable[];\n validate: MessageValidator;\n}\n\nexport function MessageController({\n name,\n variables,\n label,\n locale,\n validate,\n className,\n}: MessageControllerProps): React.ReactNode {\n const { control } = useMessagesForm();\n\n return (\n <Controller\n control={control}\n name={name}\n render={({ field, fieldState }) => (\n <MessageInput\n className={className}\n error={fieldState.error}\n label={label}\n lang={locale}\n onBlur={field.onBlur}\n onChange={field.onChange}\n value={(field.value as unknown as string) || ''}\n variables={variables}\n />\n )}\n rules={{\n required: true,\n validate,\n }}\n />\n );\n}\n"],"names":["Controller","useMessagesForm","MessageInput","MessageController","name","variables","label","locale","validate","className","control","render","field","fieldState","error","lang","onBlur","onChange","value","rules","required"],"mappings":";AAAA,SAASA,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,eAAe,QAAQ,kCAAkC;AAIlE,SAASC,YAAY,QAAQ,wBAAwB;AAWrD,OAAO,SAASC,kBAAkB,EAChCC,IAAI,EACJC,SAAS,EACTC,KAAK,EACLC,MAAM,EACNC,QAAQ,EACRC,SAAS,EACc;IACvB,MAAM,EAAEC,OAAO,EAAE,GAAGT;IAEpB,qBACE,KAACD;QACCU,SAASA;QACTN,MAAMA;QACNO,QAAQ,CAAC,EAAEC,KAAK,EAAEC,UAAU,EAAE,iBAC5B,KAACX;gBACCO,WAAWA;gBACXK,OAAOD,WAAWC,KAAK;gBACvBR,OAAOA;gBACPS,MAAMR;gBACNS,QAAQJ,MAAMI,MAAM;gBACpBC,UAAUL,MAAMK,QAAQ;gBACxBC,OAAO,AAACN,MAAMM,KAAK,IAA0B;gBAC7Cb,WAAWA;;QAGfc,OAAO;YACLC,UAAU;YACVZ;QACF;;AAGN"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MessageFormContext.d.ts","sourceRoot":"","sources":["../../src/components/MessageFormContext.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE9D,MAAM,MAAM,UAAU,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;AAQhD,UAAU,yBAAyB;IACjC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;CACjC;AAED,wBAAgB,oBAAoB,CAAC,EACnC,OAAO,EACP,IAAI,EACJ,QAAQ,GACT,EAAE,KAAK,CAAC,iBAAiB,CAAC,yBAAyB,CAAC,2CAMpD;AAED,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;aAtBjB,MAAM,EAAE;CA6BlB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/MessageFormContext.tsx"],"sourcesContent":["'use client';\n\nimport { createContext, use } from 'react';\nimport type { UseFormReturn } from 'react-hook-form';\nimport { FormProvider, useFormContext } from 'react-hook-form';\nimport type { Locale, Messages, Translations } from '@/types';\n\nexport type FormValues = Translations<Messages>;\n\nconst MessagesFormContext = createContext<{\n locales: Locale[];\n}>({\n locales: ['en'],\n});\n\ninterface MessagesFormProviderProps {\n locales: Locale[];\n form: UseFormReturn<FormValues>;\n}\n\nexport function MessagesFormProvider({\n locales,\n form,\n children,\n}: React.PropsWithChildren<MessagesFormProviderProps>) {\n return (\n <MessagesFormContext value={{ locales }}>\n <FormProvider {...form}>{children}</FormProvider>\n </MessagesFormContext>\n );\n}\n\nexport const useMessagesForm = () => {\n const context = use(MessagesFormContext);\n const form = useFormContext<FormValues>();\n return {\n ...context,\n ...form,\n };\n};\n"],"names":["createContext","use","FormProvider","useFormContext","MessagesFormContext","locales","MessagesFormProvider","form","children","value","useMessagesForm","context"],"mappings":"AAAA;;AAEA,SAASA,aAAa,EAAEC,GAAG,QAAQ,QAAQ;AAE3C,SAASC,YAAY,EAAEC,cAAc,QAAQ,kBAAkB;AAK/D,MAAMC,oCAAsBJ,cAEzB;IACDK,SAAS;QAAC;KAAK;AACjB;AAOA,OAAO,SAASC,qBAAqB,EACnCD,OAAO,EACPE,IAAI,EACJC,QAAQ,EAC2C;IACnD,qBACE,KAACJ;QAAoBK,OAAO;YAAEJ;QAAQ;kBACpC,cAAA,KAACH;YAAc,GAAGK,IAAI;sBAAGC;;;AAG/B;AAEA,OAAO,MAAME,kBAAkB;IAC7B,MAAMC,UAAUV,IAAIG;IACpB,MAAMG,OAAOJ;IACb,OAAO;QACL,GAAGQ,OAAO;QACV,GAAGJ,IAAI;IACT;AACF,EAAE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Move.d.ts","sourceRoot":"","sources":["../../../src/components/actions/Move.tsx"],"names":[],"mappings":"AAQA,wBAAgB,IAAI,4CA4BnB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/actions/Move.tsx"],"sourcesContent":["import { Button } from '@payloadcms/ui';\nimport { IconBraces } from '@tabler/icons-react';\nimport { get } from 'lodash-es';\n\nimport { useMessagesForm } from '@/components/MessageFormContext';\n\nimport styles from './Move.module.css';\n\nexport function Move() {\n const { getValues, setValue, locales } = useMessagesForm();\n const handleMove = () => {\n const sourcePath = prompt('Source path');\n if (!sourcePath) {\n return;\n }\n const targetPath = prompt('Target path');\n if (!targetPath) {\n return;\n }\n\n locales.forEach((locale) => {\n const sourceValue = get(getValues(), [locale, sourcePath].join('.'));\n setValue([locale, targetPath].join('.'), sourceValue);\n });\n };\n return (\n <Button\n buttonStyle=\"subtle\"\n className={styles.button}\n icon={<IconBraces className={styles.icon} />}\n iconPosition=\"left\"\n onClick={handleMove}\n >\n Copy\n </Button>\n );\n}\n"],"names":["Button","IconBraces","get","useMessagesForm","styles","Move","getValues","setValue","locales","handleMove","sourcePath","prompt","targetPath","forEach","locale","sourceValue","join","buttonStyle","className","button","icon","iconPosition","onClick"],"mappings":";AAAA,SAASA,MAAM,QAAQ,iBAAiB;AACxC,SAASC,UAAU,QAAQ,sBAAsB;AACjD,SAASC,GAAG,QAAQ,YAAY;AAEhC,SAASC,eAAe,QAAQ,kCAAkC;AAElE,OAAOC,YAAY,oBAAoB;AAEvC,OAAO,SAASC;IACd,MAAM,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,OAAO,EAAE,GAAGL;IACzC,MAAMM,aAAa;QACjB,MAAMC,aAAaC,OAAO;QAC1B,IAAI,CAACD,YAAY;YACf;QACF;QACA,MAAME,aAAaD,OAAO;QAC1B,IAAI,CAACC,YAAY;YACf;QACF;QAEAJ,QAAQK,OAAO,CAAC,CAACC;YACf,MAAMC,cAAcb,IAAII,aAAa;gBAACQ;gBAAQJ;aAAW,CAACM,IAAI,CAAC;YAC/DT,SAAS;gBAACO;gBAAQF;aAAW,CAACI,IAAI,CAAC,MAAMD;QAC3C;IACF;IACA,qBACE,KAACf;QACCiB,aAAY;QACZC,WAAWd,OAAOe,MAAM;QACxBC,oBAAM,KAACnB;YAAWiB,WAAWd,OAAOgB,IAAI;;QACxCC,cAAa;QACbC,SAASb;kBACV;;AAIL"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { FieldError } from 'react-hook-form';
|
|
2
|
-
export interface InputWrapperProps {
|
|
3
|
-
label?: string;
|
|
4
|
-
error: FieldError | undefined;
|
|
5
|
-
className?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare function InputWrapper({ label, error, className, children, }: React.PropsWithChildren<InputWrapperProps>): import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
//# sourceMappingURL=InputWrapper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InputWrapper.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/InputWrapper.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,KAAK,EACL,SAAS,EACT,QAAQ,GACT,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,2CAkB5C"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { FieldLabel } from '@payloadcms/ui';
|
|
3
|
-
import styles from './InputWrapper.module.css';
|
|
4
|
-
export function InputWrapper({ label, error, className, children }) {
|
|
5
|
-
return /*#__PURE__*/ _jsxs("div", {
|
|
6
|
-
className: [
|
|
7
|
-
styles.wrapper,
|
|
8
|
-
className
|
|
9
|
-
].filter(Boolean).join(' '),
|
|
10
|
-
children: [
|
|
11
|
-
/*#__PURE__*/ _jsxs("fieldset", {
|
|
12
|
-
className: [
|
|
13
|
-
styles.fieldset,
|
|
14
|
-
error ? styles.fieldsetError : undefined
|
|
15
|
-
].filter(Boolean).join(' '),
|
|
16
|
-
children: [
|
|
17
|
-
label && /*#__PURE__*/ _jsx("legend", {
|
|
18
|
-
className: styles.legend,
|
|
19
|
-
children: /*#__PURE__*/ _jsx(FieldLabel, {
|
|
20
|
-
label: label
|
|
21
|
-
})
|
|
22
|
-
}),
|
|
23
|
-
children
|
|
24
|
-
]
|
|
25
|
-
}),
|
|
26
|
-
/*#__PURE__*/ _jsx("p", {
|
|
27
|
-
className: styles.errorMessage,
|
|
28
|
-
children: error?.message
|
|
29
|
-
})
|
|
30
|
-
]
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
//# sourceMappingURL=InputWrapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/inputs/InputWrapper.tsx"],"sourcesContent":["import { FieldLabel } from '@payloadcms/ui';\nimport type { FieldError } from 'react-hook-form';\n\nimport styles from './InputWrapper.module.css';\n\nexport interface InputWrapperProps {\n label?: string;\n error: FieldError | undefined;\n className?: string;\n}\n\nexport function InputWrapper({\n label,\n error,\n className,\n children,\n}: React.PropsWithChildren<InputWrapperProps>) {\n return (\n <div className={[styles.wrapper, className].filter(Boolean).join(' ')}>\n <fieldset\n className={[styles.fieldset, error ? styles.fieldsetError : undefined]\n .filter(Boolean)\n .join(' ')}\n >\n {label && (\n <legend className={styles.legend}>\n <FieldLabel label={label} />\n </legend>\n )}\n {children}\n </fieldset>\n <p className={styles.errorMessage}>{error?.message}</p>\n </div>\n );\n}\n"],"names":["FieldLabel","styles","InputWrapper","label","error","className","children","div","wrapper","filter","Boolean","join","fieldset","fieldsetError","undefined","legend","p","errorMessage","message"],"mappings":";AAAA,SAASA,UAAU,QAAQ,iBAAiB;AAG5C,OAAOC,YAAY,4BAA4B;AAQ/C,OAAO,SAASC,aAAa,EAC3BC,KAAK,EACLC,KAAK,EACLC,SAAS,EACTC,QAAQ,EACmC;IAC3C,qBACE,MAACC;QAAIF,WAAW;YAACJ,OAAOO,OAAO;YAAEH;SAAU,CAACI,MAAM,CAACC,SAASC,IAAI,CAAC;;0BAC/D,MAACC;gBACCP,WAAW;oBAACJ,OAAOW,QAAQ;oBAAER,QAAQH,OAAOY,aAAa,GAAGC;iBAAU,CACnEL,MAAM,CAACC,SACPC,IAAI,CAAC;;oBAEPR,uBACC,KAACY;wBAAOV,WAAWJ,OAAOc,MAAM;kCAC9B,cAAA,KAACf;4BAAWG,OAAOA;;;oBAGtBG;;;0BAEH,KAACU;gBAAEX,WAAWJ,OAAOgB,YAAY;0BAAGb,OAAOc;;;;AAGjD"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { DateElement } from '../../../../types';
|
|
2
|
-
export interface DateVariableEditorProps {
|
|
3
|
-
name: string;
|
|
4
|
-
element: DateElement | undefined;
|
|
5
|
-
ref: React.Ref<{
|
|
6
|
-
getValue: () => string;
|
|
7
|
-
}>;
|
|
8
|
-
}
|
|
9
|
-
export declare function DateVariableEditor({ ref }: DateVariableEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
//# sourceMappingURL=DateVariableEditor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DateVariableEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components/inputs/variables/editors/DateVariableEditor.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,WAAW,GAAG,SAAS,CAAC;IACjC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC;QAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5C;AAED,wBAAgB,kBAAkB,CAAC,EAAE,GAAG,EAAE,EAAE,uBAAuB,2CASlE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/inputs/variables/editors/DateVariableEditor.tsx"],"sourcesContent":["import { useImperativeHandle } from 'react';\nimport type { DateElement } from '@/types';\n\nexport interface DateVariableEditorProps {\n name: string;\n element: DateElement | undefined;\n ref: React.Ref<{ getValue: () => string }>;\n}\n\nexport function DateVariableEditor({ ref }: DateVariableEditorProps) {\n useImperativeHandle(ref, () => ({\n getValue: () => {\n // TODO\n return '';\n },\n }));\n\n return <>DateElementEditor</>;\n}\n"],"names":["useImperativeHandle","DateVariableEditor","ref","getValue"],"mappings":";AAAA,SAASA,mBAAmB,QAAQ,QAAQ;AAS5C,OAAO,SAASC,mBAAmB,EAAEC,GAAG,EAA2B;IACjEF,oBAAoBE,KAAK,IAAO,CAAA;YAC9BC,UAAU;gBACR,OAAO;gBACP,OAAO;YACT;QACF,CAAA;IAEA,qBAAO;kBAAE;;AACX"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { TimeElement } from '../../../../types';
|
|
2
|
-
export interface TimeElementEditorProps {
|
|
3
|
-
name: string;
|
|
4
|
-
element: TimeElement | undefined;
|
|
5
|
-
ref: React.Ref<{
|
|
6
|
-
getValue: () => string;
|
|
7
|
-
}>;
|
|
8
|
-
}
|
|
9
|
-
export declare function TimeElementEditor({ ref }: TimeElementEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
//# sourceMappingURL=TimeVariableEditor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TimeVariableEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components/inputs/variables/editors/TimeVariableEditor.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,WAAW,GAAG,SAAS,CAAC;IACjC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC;QAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5C;AAED,wBAAgB,iBAAiB,CAAC,EAAE,GAAG,EAAE,EAAE,sBAAsB,2CAShE"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useImperativeHandle } from 'react';
|
|
3
|
-
export function TimeElementEditor({ ref }) {
|
|
4
|
-
useImperativeHandle(ref, ()=>({
|
|
5
|
-
getValue: ()=>{
|
|
6
|
-
// TODO
|
|
7
|
-
return '';
|
|
8
|
-
}
|
|
9
|
-
}));
|
|
10
|
-
return /*#__PURE__*/ _jsx(_Fragment, {
|
|
11
|
-
children: "TimeElementEditor"
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=TimeVariableEditor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/inputs/variables/editors/TimeVariableEditor.tsx"],"sourcesContent":["import { useImperativeHandle } from 'react';\nimport type { TimeElement } from '@/types';\n\nexport interface TimeElementEditorProps {\n name: string;\n element: TimeElement | undefined;\n ref: React.Ref<{ getValue: () => string }>;\n}\n\nexport function TimeElementEditor({ ref }: TimeElementEditorProps) {\n useImperativeHandle(ref, () => ({\n getValue: () => {\n // TODO\n return '';\n },\n }));\n\n return <>TimeElementEditor</>;\n}\n"],"names":["useImperativeHandle","TimeElementEditor","ref","getValue"],"mappings":";AAAA,SAASA,mBAAmB,QAAQ,QAAQ;AAS5C,OAAO,SAASC,kBAAkB,EAAEC,GAAG,EAA0B;IAC/DF,oBAAoBE,KAAK,IAAO,CAAA;YAC9BC,UAAU;gBACR,OAAO;gBACP,OAAO;YACT;QACF,CAAA;IAEA,qBAAO;kBAAE;;AACX"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { NumberElement, PluralElement } from '../../../../types';
|
|
2
|
-
export interface NumericVariablePickerProps {
|
|
3
|
-
element: NumberElement | PluralElement;
|
|
4
|
-
onUpdate: (value: string) => void;
|
|
5
|
-
}
|
|
6
|
-
export declare function NumericVariablePicker({ element, onUpdate, }: NumericVariablePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
//# sourceMappingURL=NumericVariablePicker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/inputs/variables/pickers/NumericVariablePicker.tsx"],"sourcesContent":["import { ToggleGroup } from 'radix-ui';\nimport { useEffect, useRef, useState } from 'react';\nimport type { NumberElement, PluralElement } from '@/types';\n\nimport { isNumberElement, isPluralElement } from '@/utils/guards';\n\nimport { PluralVariableEditor } from '../editors/PluralVariableEditor';\nimport styles from './NumericVariablePicker.module.css';\n\nconst NUMERIC_TYPES = [\n 'number',\n 'plural',\n // \"selectordinal\"\n] as const;\n\ntype NumericType = (typeof NUMERIC_TYPES)[number];\n\nexport interface NumericVariablePickerProps {\n element: NumberElement | PluralElement;\n onUpdate: (value: string) => void;\n}\n\nexport function NumericVariablePicker({\n element,\n onUpdate,\n}: NumericVariablePickerProps) {\n const [type, setType] = useState<NumericType | undefined>(() => {\n if (isNumberElement(element)) return 'number';\n if (isPluralElement(element)) return 'plural';\n return undefined;\n });\n const getValueRef = useRef<{ getValue: () => string }>(null);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: useEffectEvent\n useEffect(() => {\n return () => {\n if (!getValueRef.current) return;\n onUpdate(getValueRef.current.getValue());\n };\n }, []);\n\n return (\n <div>\n <ToggleGroup.Root\n className={styles.toggleGroup}\n onValueChange={(value) => setType(value as NumericType)}\n type=\"single\"\n value={type}\n >\n {NUMERIC_TYPES.map((type) => (\n <ToggleGroup.Item\n className={styles.toggleItem}\n key={type}\n value={type}\n >\n {type}\n </ToggleGroup.Item>\n ))}\n </ToggleGroup.Root>\n\n <div className={styles.content}>\n {type === 'plural' && (\n <PluralVariableEditor\n element={isPluralElement(element) ? element : undefined}\n ref={getValueRef}\n variableName={element.value}\n />\n )}\n </div>\n </div>\n );\n}\n"],"names":["ToggleGroup","useEffect","useRef","useState","isNumberElement","isPluralElement","PluralVariableEditor","styles","NUMERIC_TYPES","NumericVariablePicker","element","onUpdate","type","setType","undefined","getValueRef","current","getValue","div","Root","className","toggleGroup","onValueChange","value","map","Item","toggleItem","content","ref","variableName"],"mappings":";AAAA,SAASA,WAAW,QAAQ,WAAW;AACvC,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAGpD,SAASC,eAAe,EAAEC,eAAe,QAAQ,iBAAiB;AAElE,SAASC,oBAAoB,QAAQ,kCAAkC;AACvE,OAAOC,YAAY,qCAAqC;AAExD,MAAMC,gBAAgB;IACpB;IACA;CAED;AASD,OAAO,SAASC,sBAAsB,EACpCC,OAAO,EACPC,QAAQ,EACmB;IAC3B,MAAM,CAACC,MAAMC,QAAQ,GAAGV,SAAkC;QACxD,IAAIC,gBAAgBM,UAAU,OAAO;QACrC,IAAIL,gBAAgBK,UAAU,OAAO;QACrC,OAAOI;IACT;IACA,MAAMC,cAAcb,OAAmC;IAEvD,0EAA0E;IAC1ED,UAAU;QACR,OAAO;YACL,IAAI,CAACc,YAAYC,OAAO,EAAE;YAC1BL,SAASI,YAAYC,OAAO,CAACC,QAAQ;QACvC;IACF,GAAG,EAAE;IAEL,qBACE,MAACC;;0BACC,KAAClB,YAAYmB,IAAI;gBACfC,WAAWb,OAAOc,WAAW;gBAC7BC,eAAe,CAACC,QAAUV,QAAQU;gBAClCX,MAAK;gBACLW,OAAOX;0BAENJ,cAAcgB,GAAG,CAAC,CAACZ,qBAClB,KAACZ,YAAYyB,IAAI;wBACfL,WAAWb,OAAOmB,UAAU;wBAE5BH,OAAOX;kCAENA;uBAHIA;;0BAQX,KAACM;gBAAIE,WAAWb,OAAOoB,OAAO;0BAC3Bf,SAAS,0BACR,KAACN;oBACCI,SAASL,gBAAgBK,WAAWA,UAAUI;oBAC9Cc,KAAKb;oBACLc,cAAcnB,QAAQa,KAAK;;;;;AAMvC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { DateElement, TimeElement } from '../../../../types';
|
|
2
|
-
export interface TemporalElementEditorProps {
|
|
3
|
-
element: DateElement | TimeElement;
|
|
4
|
-
onUpdate: (value: string) => void;
|
|
5
|
-
}
|
|
6
|
-
export declare function TemporalElementEditor({ element, onUpdate, }: TemporalElementEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
//# sourceMappingURL=TemporalElementEditor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TemporalElementEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components/inputs/variables/pickers/TemporalElementEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAYxD,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,WAAW,GAAG,WAAW,CAAC;IACnC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,wBAAgB,qBAAqB,CAAC,EACpC,OAAO,EACP,QAAQ,GACT,EAAE,0BAA0B,2CAqD5B"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ToggleGroup } from 'radix-ui';
|
|
3
|
-
import { useEffect, useRef, useState } from 'react';
|
|
4
|
-
import { isDateElement, isTimeElement } from '../../../../utils/guards';
|
|
5
|
-
import { DateVariableEditor } from '../editors/DateVariableEditor';
|
|
6
|
-
import { TimeElementEditor } from '../editors/TimeVariableEditor';
|
|
7
|
-
import styles from './TemporalElementEditor.module.css';
|
|
8
|
-
const TEMPORAL_TYPES = [
|
|
9
|
-
'date',
|
|
10
|
-
'time'
|
|
11
|
-
];
|
|
12
|
-
export function TemporalElementEditor({ element, onUpdate }) {
|
|
13
|
-
const [type, setType] = useState(()=>{
|
|
14
|
-
if (isDateElement(element)) return 'date';
|
|
15
|
-
if (isTimeElement(element)) return 'time';
|
|
16
|
-
return undefined;
|
|
17
|
-
});
|
|
18
|
-
const getValueRef = useRef(null);
|
|
19
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: useEffectEvent
|
|
20
|
-
useEffect(()=>{
|
|
21
|
-
return ()=>{
|
|
22
|
-
if (!getValueRef.current) return;
|
|
23
|
-
onUpdate(getValueRef.current.getValue());
|
|
24
|
-
};
|
|
25
|
-
}, []);
|
|
26
|
-
return /*#__PURE__*/ _jsxs("div", {
|
|
27
|
-
children: [
|
|
28
|
-
/*#__PURE__*/ _jsx(ToggleGroup.Root, {
|
|
29
|
-
className: styles.toggleGroup,
|
|
30
|
-
onValueChange: (value)=>setType(value),
|
|
31
|
-
type: "single",
|
|
32
|
-
value: type,
|
|
33
|
-
children: TEMPORAL_TYPES.map((type)=>/*#__PURE__*/ _jsx(ToggleGroup.Item, {
|
|
34
|
-
className: styles.toggleItem,
|
|
35
|
-
value: type,
|
|
36
|
-
children: type
|
|
37
|
-
}, type))
|
|
38
|
-
}),
|
|
39
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
40
|
-
className: styles.content,
|
|
41
|
-
children: [
|
|
42
|
-
type === 'date' && /*#__PURE__*/ _jsx(DateVariableEditor, {
|
|
43
|
-
element: isDateElement(element) ? element : undefined,
|
|
44
|
-
name: element.value,
|
|
45
|
-
ref: getValueRef
|
|
46
|
-
}),
|
|
47
|
-
type === 'time' && /*#__PURE__*/ _jsx(TimeElementEditor, {
|
|
48
|
-
element: isTimeElement(element) ? element : undefined,
|
|
49
|
-
name: element.value,
|
|
50
|
-
ref: getValueRef
|
|
51
|
-
})
|
|
52
|
-
]
|
|
53
|
-
})
|
|
54
|
-
]
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
//# sourceMappingURL=TemporalElementEditor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/inputs/variables/pickers/TemporalElementEditor.tsx"],"sourcesContent":["import { ToggleGroup } from 'radix-ui';\nimport { useEffect, useRef, useState } from 'react';\nimport type { DateElement, TimeElement } from '@/types';\n\nimport { isDateElement, isTimeElement } from '@/utils/guards';\n\nimport { DateVariableEditor } from '../editors/DateVariableEditor';\nimport { TimeElementEditor } from '../editors/TimeVariableEditor';\nimport styles from './TemporalElementEditor.module.css';\n\nconst TEMPORAL_TYPES = ['date', 'time'] as const;\n\ntype TemporalType = (typeof TEMPORAL_TYPES)[number];\n\nexport interface TemporalElementEditorProps {\n element: DateElement | TimeElement;\n onUpdate: (value: string) => void;\n}\n\nexport function TemporalElementEditor({\n element,\n onUpdate,\n}: TemporalElementEditorProps) {\n const [type, setType] = useState<TemporalType | undefined>(() => {\n if (isDateElement(element)) return 'date';\n if (isTimeElement(element)) return 'time';\n return undefined;\n });\n const getValueRef = useRef<{ getValue: () => string }>(null);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: useEffectEvent\n useEffect(() => {\n return () => {\n if (!getValueRef.current) return;\n onUpdate(getValueRef.current.getValue());\n };\n }, []);\n\n return (\n <div>\n <ToggleGroup.Root\n className={styles.toggleGroup}\n onValueChange={(value) => setType(value as TemporalType)}\n type=\"single\"\n value={type}\n >\n {TEMPORAL_TYPES.map((type) => (\n <ToggleGroup.Item\n className={styles.toggleItem}\n key={type}\n value={type}\n >\n {type}\n </ToggleGroup.Item>\n ))}\n </ToggleGroup.Root>\n\n <div className={styles.content}>\n {type === 'date' && (\n <DateVariableEditor\n element={isDateElement(element) ? element : undefined}\n name={element.value}\n ref={getValueRef}\n />\n )}\n {type === 'time' && (\n <TimeElementEditor\n element={isTimeElement(element) ? element : undefined}\n name={element.value}\n ref={getValueRef}\n />\n )}\n </div>\n </div>\n );\n}\n"],"names":["ToggleGroup","useEffect","useRef","useState","isDateElement","isTimeElement","DateVariableEditor","TimeElementEditor","styles","TEMPORAL_TYPES","TemporalElementEditor","element","onUpdate","type","setType","undefined","getValueRef","current","getValue","div","Root","className","toggleGroup","onValueChange","value","map","Item","toggleItem","content","name","ref"],"mappings":";AAAA,SAASA,WAAW,QAAQ,WAAW;AACvC,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAGpD,SAASC,aAAa,EAAEC,aAAa,QAAQ,iBAAiB;AAE9D,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,iBAAiB,QAAQ,gCAAgC;AAClE,OAAOC,YAAY,qCAAqC;AAExD,MAAMC,iBAAiB;IAAC;IAAQ;CAAO;AASvC,OAAO,SAASC,sBAAsB,EACpCC,OAAO,EACPC,QAAQ,EACmB;IAC3B,MAAM,CAACC,MAAMC,QAAQ,GAAGX,SAAmC;QACzD,IAAIC,cAAcO,UAAU,OAAO;QACnC,IAAIN,cAAcM,UAAU,OAAO;QACnC,OAAOI;IACT;IACA,MAAMC,cAAcd,OAAmC;IAEvD,0EAA0E;IAC1ED,UAAU;QACR,OAAO;YACL,IAAI,CAACe,YAAYC,OAAO,EAAE;YAC1BL,SAASI,YAAYC,OAAO,CAACC,QAAQ;QACvC;IACF,GAAG,EAAE;IAEL,qBACE,MAACC;;0BACC,KAACnB,YAAYoB,IAAI;gBACfC,WAAWb,OAAOc,WAAW;gBAC7BC,eAAe,CAACC,QAAUV,QAAQU;gBAClCX,MAAK;gBACLW,OAAOX;0BAENJ,eAAegB,GAAG,CAAC,CAACZ,qBACnB,KAACb,YAAY0B,IAAI;wBACfL,WAAWb,OAAOmB,UAAU;wBAE5BH,OAAOX;kCAENA;uBAHIA;;0BAQX,MAACM;gBAAIE,WAAWb,OAAOoB,OAAO;;oBAC3Bf,SAAS,wBACR,KAACP;wBACCK,SAASP,cAAcO,WAAWA,UAAUI;wBAC5Cc,MAAMlB,QAAQa,KAAK;wBACnBM,KAAKd;;oBAGRH,SAAS,wBACR,KAACN;wBACCI,SAASN,cAAcM,WAAWA,UAAUI;wBAC5Cc,MAAMlB,QAAQa,KAAK;wBACnBM,KAAKd;;;;;;AAMjB"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|