@vexcms/core 0.0.20 → 0.1.0-alpha.3
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/LICENSE +202 -0
- package/dist/.build +1 -0
- package/dist/access/buildChecks.d.ts +58 -0
- package/dist/access/buildChecks.d.ts.map +1 -0
- package/dist/access/canAccessAdminPanel.d.ts +53 -0
- package/dist/access/canAccessAdminPanel.d.ts.map +1 -0
- package/dist/access/compileConstraints.d.ts +155 -0
- package/dist/access/compileConstraints.d.ts.map +1 -0
- package/dist/access/config.d.ts +62 -0
- package/dist/access/config.d.ts.map +1 -0
- package/dist/access/constants.d.ts +95 -0
- package/dist/access/constants.d.ts.map +1 -0
- package/dist/access/constraintTypes.d.ts +337 -0
- package/dist/access/constraintTypes.d.ts.map +1 -0
- package/dist/access/createAccessQueryBuilder.d.ts +59 -0
- package/dist/access/createAccessQueryBuilder.d.ts.map +1 -0
- package/dist/access/createFilterConstraintBuilder.d.ts +26 -0
- package/dist/access/createFilterConstraintBuilder.d.ts.map +1 -0
- package/dist/access/createIndexConstraintBuilder.d.ts +40 -0
- package/dist/access/createIndexConstraintBuilder.d.ts.map +1 -0
- package/dist/access/hasPermission.d.ts +85 -0
- package/dist/access/hasPermission.d.ts.map +1 -0
- package/dist/access/index.d.ts +13 -0
- package/dist/access/index.d.ts.map +1 -0
- package/dist/access/pickQueryIndex.d.ts +42 -0
- package/dist/access/pickQueryIndex.d.ts.map +1 -0
- package/dist/access/resolveAccessRule.d.ts +85 -0
- package/dist/access/resolveAccessRule.d.ts.map +1 -0
- package/dist/access/types.d.ts +738 -0
- package/dist/access/types.d.ts.map +1 -0
- package/dist/access/validateAccessConstraints.d.ts +57 -0
- package/dist/access/validateAccessConstraints.d.ts.map +1 -0
- package/dist/api/client.d.ts +20 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +117 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/convex.d.ts +296 -0
- package/dist/api/convex.d.ts.map +1 -0
- package/dist/api/create/client.d.ts +50 -0
- package/dist/api/create/client.d.ts.map +1 -0
- package/dist/api/create/server.d.ts +43 -0
- package/dist/api/create/server.d.ts.map +1 -0
- package/dist/api/depth.d.ts +39 -0
- package/dist/api/depth.d.ts.map +1 -0
- package/dist/api/find/client.d.ts +90 -0
- package/dist/api/find/client.d.ts.map +1 -0
- package/dist/api/find/server.d.ts +73 -0
- package/dist/api/find/server.d.ts.map +1 -0
- package/dist/api/get/client.d.ts +56 -0
- package/dist/api/get/client.d.ts.map +1 -0
- package/dist/api/get/server.d.ts +49 -0
- package/dist/api/get/server.d.ts.map +1 -0
- package/dist/api/globals/find.client.d.ts +20 -0
- package/dist/api/globals/find.client.d.ts.map +1 -0
- package/dist/api/globals/find.server.d.ts +29 -0
- package/dist/api/globals/find.server.d.ts.map +1 -0
- package/dist/api/globals/get.client.d.ts +46 -0
- package/dist/api/globals/get.client.d.ts.map +1 -0
- package/dist/api/globals/get.server.d.ts +55 -0
- package/dist/api/globals/get.server.d.ts.map +1 -0
- package/dist/api/globals/types.d.ts +65 -0
- package/dist/api/globals/types.d.ts.map +1 -0
- package/dist/api/globals/upsert.client.d.ts +24 -0
- package/dist/api/globals/upsert.client.d.ts.map +1 -0
- package/dist/api/globals/upsert.server.d.ts +47 -0
- package/dist/api/globals/upsert.server.d.ts.map +1 -0
- package/dist/api/populate.d.ts +23 -0
- package/dist/api/populate.d.ts.map +1 -0
- package/dist/api/remove/client.d.ts +58 -0
- package/dist/api/remove/client.d.ts.map +1 -0
- package/dist/api/remove/server.d.ts +65 -0
- package/dist/api/remove/server.d.ts.map +1 -0
- package/dist/api/search/client.d.ts +58 -0
- package/dist/api/search/client.d.ts.map +1 -0
- package/dist/api/search/server.d.ts +54 -0
- package/dist/api/search/server.d.ts.map +1 -0
- package/dist/api/server.d.ts +370 -0
- package/dist/api/server.d.ts.map +1 -0
- package/dist/api/server.js +33 -0
- package/dist/api/server.js.map +1 -0
- package/dist/api/types.d.ts +525 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/update/client.d.ts +53 -0
- package/dist/api/update/client.d.ts.map +1 -0
- package/dist/api/update/server.d.ts +47 -0
- package/dist/api/update/server.d.ts.map +1 -0
- package/dist/api/utils.d.ts +57 -0
- package/dist/api/utils.d.ts.map +1 -0
- package/dist/auth/mergeCollections.d.ts +28 -0
- package/dist/auth/mergeCollections.d.ts.map +1 -0
- package/dist/auth/types.d.ts +84 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/chunk-2DU7JDEX.js +1877 -0
- package/dist/chunk-2DU7JDEX.js.map +1 -0
- package/dist/chunk-2IB2DCN7.js +75 -0
- package/dist/chunk-2IB2DCN7.js.map +1 -0
- package/dist/collections/config.d.ts +28 -0
- package/dist/collections/config.d.ts.map +1 -0
- package/dist/collections/constants.d.ts +27 -0
- package/dist/collections/constants.d.ts.map +1 -0
- package/dist/collections/index.d.ts +7 -0
- package/dist/collections/index.d.ts.map +1 -0
- package/dist/collections/indexFields.d.ts +20 -0
- package/dist/collections/indexFields.d.ts.map +1 -0
- package/dist/collections/interfaceGen.d.ts +59 -0
- package/dist/collections/interfaceGen.d.ts.map +1 -0
- package/dist/collections/internal/index.d.ts +2 -0
- package/dist/collections/internal/index.d.ts.map +1 -0
- package/dist/collections/types.d.ts +282 -0
- package/dist/collections/types.d.ts.map +1 -0
- package/dist/collections/utils.d.ts +71 -0
- package/dist/collections/utils.d.ts.map +1 -0
- package/dist/collections/validator.d.ts +73 -0
- package/dist/collections/validator.d.ts.map +1 -0
- package/dist/config/config.d.ts +43 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/sanitizeConfig.d.ts +82 -0
- package/dist/config/sanitizeConfig.d.ts.map +1 -0
- package/dist/config/types.d.ts +316 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/fields/array/config.d.ts +57 -0
- package/dist/fields/array/config.d.ts.map +1 -0
- package/dist/fields/array/index.d.ts +5 -0
- package/dist/fields/array/index.d.ts.map +1 -0
- package/dist/fields/array/inputSchema.d.ts +32 -0
- package/dist/fields/array/inputSchema.d.ts.map +1 -0
- package/dist/fields/array/types.d.ts +127 -0
- package/dist/fields/array/types.d.ts.map +1 -0
- package/dist/fields/array/validator.d.ts +30 -0
- package/dist/fields/array/validator.d.ts.map +1 -0
- package/dist/fields/baseTypes.d.ts +251 -0
- package/dist/fields/baseTypes.d.ts.map +1 -0
- package/dist/fields/blocks/config.d.ts +63 -0
- package/dist/fields/blocks/config.d.ts.map +1 -0
- package/dist/fields/blocks/index.d.ts +5 -0
- package/dist/fields/blocks/index.d.ts.map +1 -0
- package/dist/fields/blocks/inputSchema.d.ts +22 -0
- package/dist/fields/blocks/inputSchema.d.ts.map +1 -0
- package/dist/fields/blocks/types.d.ts +253 -0
- package/dist/fields/blocks/types.d.ts.map +1 -0
- package/dist/fields/blocks/validator.d.ts +32 -0
- package/dist/fields/blocks/validator.d.ts.map +1 -0
- package/dist/fields/checkbox/config.d.ts +46 -0
- package/dist/fields/checkbox/config.d.ts.map +1 -0
- package/dist/fields/checkbox/index.d.ts +5 -0
- package/dist/fields/checkbox/index.d.ts.map +1 -0
- package/dist/fields/checkbox/inputSchema.d.ts +27 -0
- package/dist/fields/checkbox/inputSchema.d.ts.map +1 -0
- package/dist/fields/checkbox/types.d.ts +67 -0
- package/dist/fields/checkbox/types.d.ts.map +1 -0
- package/dist/fields/checkbox/validator.d.ts +34 -0
- package/dist/fields/checkbox/validator.d.ts.map +1 -0
- package/dist/fields/color/config.d.ts +49 -0
- package/dist/fields/color/config.d.ts.map +1 -0
- package/dist/fields/color/convert.d.ts +72 -0
- package/dist/fields/color/convert.d.ts.map +1 -0
- package/dist/fields/color/formats.d.ts +38 -0
- package/dist/fields/color/formats.d.ts.map +1 -0
- package/dist/fields/color/index.d.ts +8 -0
- package/dist/fields/color/index.d.ts.map +1 -0
- package/dist/fields/color/inputSchema.d.ts +29 -0
- package/dist/fields/color/inputSchema.d.ts.map +1 -0
- package/dist/fields/color/types.d.ts +100 -0
- package/dist/fields/color/types.d.ts.map +1 -0
- package/dist/fields/color/utils.d.ts +100 -0
- package/dist/fields/color/utils.d.ts.map +1 -0
- package/dist/fields/color/validator.d.ts +27 -0
- package/dist/fields/color/validator.d.ts.map +1 -0
- package/dist/fields/constants.d.ts +108 -0
- package/dist/fields/constants.d.ts.map +1 -0
- package/dist/fields/date/config.d.ts +57 -0
- package/dist/fields/date/config.d.ts.map +1 -0
- package/dist/fields/date/index.d.ts +5 -0
- package/dist/fields/date/index.d.ts.map +1 -0
- package/dist/fields/date/inputSchema.d.ts +29 -0
- package/dist/fields/date/inputSchema.d.ts.map +1 -0
- package/dist/fields/date/types.d.ts +147 -0
- package/dist/fields/date/types.d.ts.map +1 -0
- package/dist/fields/date/validator.d.ts +34 -0
- package/dist/fields/date/validator.d.ts.map +1 -0
- package/dist/fields/group/config.d.ts +47 -0
- package/dist/fields/group/config.d.ts.map +1 -0
- package/dist/fields/group/index.d.ts +5 -0
- package/dist/fields/group/index.d.ts.map +1 -0
- package/dist/fields/group/inputSchema.d.ts +27 -0
- package/dist/fields/group/inputSchema.d.ts.map +1 -0
- package/dist/fields/group/types.d.ts +105 -0
- package/dist/fields/group/types.d.ts.map +1 -0
- package/dist/fields/group/validator.d.ts +41 -0
- package/dist/fields/group/validator.d.ts.map +1 -0
- package/dist/fields/index.d.ts +20 -0
- package/dist/fields/index.d.ts.map +1 -0
- package/dist/fields/inputSchemas/index.d.ts +23 -0
- package/dist/fields/inputSchemas/index.d.ts.map +1 -0
- package/dist/fields/inputSchemas/utils.d.ts +25 -0
- package/dist/fields/inputSchemas/utils.d.ts.map +1 -0
- package/dist/fields/interfaceGen.d.ts +15 -0
- package/dist/fields/interfaceGen.d.ts.map +1 -0
- package/dist/fields/number/config.d.ts +48 -0
- package/dist/fields/number/config.d.ts.map +1 -0
- package/dist/fields/number/index.d.ts +5 -0
- package/dist/fields/number/index.d.ts.map +1 -0
- package/dist/fields/number/inputSchema.d.ts +23 -0
- package/dist/fields/number/inputSchema.d.ts.map +1 -0
- package/dist/fields/number/types.d.ts +100 -0
- package/dist/fields/number/types.d.ts.map +1 -0
- package/dist/fields/number/validator.d.ts +39 -0
- package/dist/fields/number/validator.d.ts.map +1 -0
- package/dist/fields/relationship/config.d.ts +45 -0
- package/dist/fields/relationship/config.d.ts.map +1 -0
- package/dist/fields/relationship/index.d.ts +5 -0
- package/dist/fields/relationship/index.d.ts.map +1 -0
- package/dist/fields/relationship/inputSchema.d.ts +31 -0
- package/dist/fields/relationship/inputSchema.d.ts.map +1 -0
- package/dist/fields/relationship/types.d.ts +126 -0
- package/dist/fields/relationship/types.d.ts.map +1 -0
- package/dist/fields/relationship/validator.d.ts +27 -0
- package/dist/fields/relationship/validator.d.ts.map +1 -0
- package/dist/fields/select/config.d.ts +59 -0
- package/dist/fields/select/config.d.ts.map +1 -0
- package/dist/fields/select/index.d.ts +5 -0
- package/dist/fields/select/index.d.ts.map +1 -0
- package/dist/fields/select/inputSchema.d.ts +28 -0
- package/dist/fields/select/inputSchema.d.ts.map +1 -0
- package/dist/fields/select/types.d.ts +89 -0
- package/dist/fields/select/types.d.ts.map +1 -0
- package/dist/fields/select/validator.d.ts +31 -0
- package/dist/fields/select/validator.d.ts.map +1 -0
- package/dist/fields/text/config.d.ts +48 -0
- package/dist/fields/text/config.d.ts.map +1 -0
- package/dist/fields/text/index.d.ts +5 -0
- package/dist/fields/text/index.d.ts.map +1 -0
- package/dist/fields/text/inputSchema.d.ts +24 -0
- package/dist/fields/text/inputSchema.d.ts.map +1 -0
- package/dist/fields/text/types.d.ts +132 -0
- package/dist/fields/text/types.d.ts.map +1 -0
- package/dist/fields/text/validator.d.ts +39 -0
- package/dist/fields/text/validator.d.ts.map +1 -0
- package/dist/fields/types.d.ts +135 -0
- package/dist/fields/types.d.ts.map +1 -0
- package/dist/fields/upload/config.d.ts +24 -0
- package/dist/fields/upload/config.d.ts.map +1 -0
- package/dist/fields/upload/index.d.ts +5 -0
- package/dist/fields/upload/index.d.ts.map +1 -0
- package/dist/fields/upload/inputSchema.d.ts +17 -0
- package/dist/fields/upload/inputSchema.d.ts.map +1 -0
- package/dist/fields/upload/types.d.ts +78 -0
- package/dist/fields/upload/types.d.ts.map +1 -0
- package/dist/fields/upload/validator.d.ts +16 -0
- package/dist/fields/upload/validator.d.ts.map +1 -0
- package/dist/fields/url/config.d.ts +49 -0
- package/dist/fields/url/config.d.ts.map +1 -0
- package/dist/fields/url/index.d.ts +5 -0
- package/dist/fields/url/index.d.ts.map +1 -0
- package/dist/fields/url/inputSchema.d.ts +31 -0
- package/dist/fields/url/inputSchema.d.ts.map +1 -0
- package/dist/fields/url/types.d.ts +70 -0
- package/dist/fields/url/types.d.ts.map +1 -0
- package/dist/fields/url/validator.d.ts +37 -0
- package/dist/fields/url/validator.d.ts.map +1 -0
- package/dist/fields/utils.d.ts +47 -0
- package/dist/fields/utils.d.ts.map +1 -0
- package/dist/fields/validators/index.d.ts +23 -0
- package/dist/fields/validators/index.d.ts.map +1 -0
- package/dist/fields/validators/utils.d.ts +24 -0
- package/dist/fields/validators/utils.d.ts.map +1 -0
- package/dist/framework.d.ts +227 -0
- package/dist/framework.d.ts.map +1 -0
- package/dist/globals/config/config.d.ts +1 -0
- package/dist/globals/config/config.d.ts.map +1 -0
- package/dist/globals/config/types.d.ts +1 -0
- package/dist/globals/config/types.d.ts.map +1 -0
- package/dist/globals/config.d.ts +47 -0
- package/dist/globals/config.d.ts.map +1 -0
- package/dist/globals/index.d.ts +5 -0
- package/dist/globals/index.d.ts.map +1 -0
- package/dist/globals/interfaceGen.d.ts +33 -0
- package/dist/globals/interfaceGen.d.ts.map +1 -0
- package/dist/globals/types.d.ts +175 -0
- package/dist/globals/types.d.ts.map +1 -0
- package/dist/globals/utils.d.ts +37 -0
- package/dist/globals/utils.d.ts.map +1 -0
- package/dist/index.d.ts +15 -3165
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2101 -3475
- package/dist/index.js.map +1 -1
- package/dist/media/api/index.d.ts +5 -0
- package/dist/media/api/index.d.ts.map +1 -0
- package/dist/media/api/mutations.d.ts +76 -0
- package/dist/media/api/mutations.d.ts.map +1 -0
- package/dist/media/api/queries.d.ts +28 -0
- package/dist/media/api/queries.d.ts.map +1 -0
- package/dist/media/api/server.d.ts +68 -0
- package/dist/media/api/server.d.ts.map +1 -0
- package/dist/media/api/types.d.ts +171 -0
- package/dist/media/api/types.d.ts.map +1 -0
- package/dist/media/config.d.ts +25 -0
- package/dist/media/config.d.ts.map +1 -0
- package/dist/media/index.d.ts +6 -0
- package/dist/media/index.d.ts.map +1 -0
- package/dist/media/types.d.ts +332 -0
- package/dist/media/types.d.ts.map +1 -0
- package/dist/media/utils.d.ts +35 -0
- package/dist/media/utils.d.ts.map +1 -0
- package/dist/media/validators.d.ts +61 -0
- package/dist/media/validators.d.ts.map +1 -0
- package/dist/schema/generateVexSchema.d.ts +36 -0
- package/dist/schema/generateVexSchema.d.ts.map +1 -0
- package/dist/schema/index.d.ts +3 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/migrate.d.ts +73 -0
- package/dist/schema/migrate.d.ts.map +1 -0
- package/dist/types/generateVexTypes.d.ts +41 -0
- package/dist/types/generateVexTypes.d.ts.map +1 -0
- package/dist/types/generated.d.ts +382 -0
- package/dist/types/generated.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils.d.ts +57 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +67 -24
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formats.d.ts","sourceRoot":"","sources":["../../../src/fields/color/formats.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa;;;QAGtB,iFAAiF;;;;;QAKjF,oDAAoD;;;;;QAMpD,0DAA0D;;;;;QAM1D,kEAAkE;;;CAI5D,CAAC;AAEX,6FAA6F;AAC7F,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC,QAAQ,CAAC,CAAC;AAEvF,gEAAgE;AAChE,eAAO,MAAM,qBAAqB,UAAqD,CAAC;AAExF,oFAAoF;AACpF,eAAO,MAAM,iBAAiB,QAA8B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/color/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ZodType } from "zod";
|
|
2
|
+
import { ColorField } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Builds a Zod schema for validating a colour field value in the admin form.
|
|
5
|
+
*
|
|
6
|
+
* Accepts hex, `rgb()`, `hsl()` and `oklch()` notation — plus `var(--token)`
|
|
7
|
+
* when the field enables `themeColors`. Required fields add a `.min(1)` check so
|
|
8
|
+
* an empty field reports "required" rather than a notation complaint. Optional
|
|
9
|
+
* fields accept the empty string, since `color()` defaults `defaultValue` to
|
|
10
|
+
* `""` and a cleared picker must round-trip.
|
|
11
|
+
*
|
|
12
|
+
* @param props - Input props.
|
|
13
|
+
* @param props.field - The resolved colour field definition.
|
|
14
|
+
* @returns A Zod string schema. Optional fields are wrapped in `.optional()` by
|
|
15
|
+
* `applyBaseInputSchemaMeta` and carry `.default(field.defaultValue)`.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* // Required — rejects "", "#fff" and "var(--primary)"
|
|
20
|
+
* colorFieldToInputSchema({ field: color({ required: true }) })
|
|
21
|
+
*
|
|
22
|
+
* // themeColors — additionally accepts "var(--primary)"
|
|
23
|
+
* colorFieldToInputSchema({ field: color({ required: true, themeColors: true }) })
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function colorFieldToInputSchema(props: {
|
|
27
|
+
field: ColorField;
|
|
28
|
+
}): ZodType;
|
|
29
|
+
//# sourceMappingURL=inputSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputSchema.d.ts","sourceRoot":"","sources":["../../../src/fields/color/inputSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAkDrC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,UAAU,CAAA;CAAE,GAAG,OAAO,CAkB7E"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { ADMIN_FIELDS } from "../constants";
|
|
2
|
+
import { BaseField, BaseFieldInput } from "../baseTypes";
|
|
3
|
+
import type { ColorFormat } from "./formats";
|
|
4
|
+
/**
|
|
5
|
+
* Configuration input for a `color()` field.
|
|
6
|
+
*
|
|
7
|
+
* Colour fields store a CSS colour string. `format` decides which notation the
|
|
8
|
+
* picker writes — `"hex"` (default), `"rgb"`, `"hsl"` or `"oklch"`. With
|
|
9
|
+
* `themeColors` the field may instead store a CSS custom-property reference,
|
|
10
|
+
* `var(--primary)`, which resolves per colour scheme at render time.
|
|
11
|
+
*
|
|
12
|
+
* **Defaults applied by `color()`:**
|
|
13
|
+
* ```ts
|
|
14
|
+
* {
|
|
15
|
+
* type: "color",
|
|
16
|
+
* label: "", // inferred from the field key by defineCollection
|
|
17
|
+
* required: false, // field is optional by default
|
|
18
|
+
* format: "hex", // picker writes #RRGGBB / #RRGGBBAA
|
|
19
|
+
* themeColors: false, // picker shows the custom swatch only
|
|
20
|
+
* admin: {
|
|
21
|
+
* hidden: false, // visible in the admin form
|
|
22
|
+
* readOnly: false, // editable by default
|
|
23
|
+
* position: "main", // placed in the main content column, not the sidebar
|
|
24
|
+
* width: "full", // spans the full form width, not half
|
|
25
|
+
* cellAlignment: "left", // swatch aligned left in the data table column
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* // Minimal — label inferred from the key ("Brand Color"), stored as hex
|
|
33
|
+
* brandColor: color()
|
|
34
|
+
*
|
|
35
|
+
* // Stored as oklch, ready to interpolate straight into a CSS custom property
|
|
36
|
+
* primaryLight: color({ format: "oklch", required: true, defaultValue: "oklch(65.7% 0.179 40.9)" })
|
|
37
|
+
*
|
|
38
|
+
* // Half-width, and offer the host app's design tokens as a second tab
|
|
39
|
+
* overlayTint: color({ themeColors: true, admin: { width: "half" } })
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @see {@link BaseFieldInput} for shared properties (`label`, `description`, `required`, `admin`, `index`, `searchIndex`)
|
|
43
|
+
*/
|
|
44
|
+
export interface ColorFieldInput<TFieldMeta extends {} = {}> extends BaseFieldInput<TFieldMeta> {
|
|
45
|
+
/**
|
|
46
|
+
* Pre-filled value shown in the admin form when creating a new document.
|
|
47
|
+
* Does not affect existing database values.
|
|
48
|
+
*/
|
|
49
|
+
defaultValue?: string;
|
|
50
|
+
/**
|
|
51
|
+
* The CSS notation the picker writes.
|
|
52
|
+
*
|
|
53
|
+
* Validation is deliberately wider than this: every supported notation is
|
|
54
|
+
* accepted on save, so changing `format` never invalidates existing
|
|
55
|
+
* documents. `format` governs new writes, not stored history.
|
|
56
|
+
*
|
|
57
|
+
* Pick the notation the front end consumes. A theme collection feeding CSS
|
|
58
|
+
* custom properties should use `"oklch"` so values interpolate directly with
|
|
59
|
+
* no conversion step.
|
|
60
|
+
*
|
|
61
|
+
* @defaultValue `"hex"`
|
|
62
|
+
*/
|
|
63
|
+
format?: ColorFormat;
|
|
64
|
+
/**
|
|
65
|
+
* When `true`, the picker gains a **Theme** tab listing the CSS custom
|
|
66
|
+
* properties declared by the host application's stylesheet, and selecting one
|
|
67
|
+
* stores a `var(--token)` reference instead of a literal colour.
|
|
68
|
+
*
|
|
69
|
+
* The admin panel renders inside the host app, so those tokens are the site's
|
|
70
|
+
* own tokens. Leave this `false` on the fields that *define* the tokens: a
|
|
71
|
+
* field whose value is written back out as `--primary: var(--primary)` is a
|
|
72
|
+
* custom-property cycle, which CSS discards at computed-value time.
|
|
73
|
+
*
|
|
74
|
+
* @defaultValue `false`
|
|
75
|
+
*/
|
|
76
|
+
themeColors?: boolean;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Resolved configuration for a `color()` field, after all defaults are applied.
|
|
80
|
+
*
|
|
81
|
+
* This is the type framework adapters and field components receive —
|
|
82
|
+
* `fieldDef` in `InputComponentProps<ColorField>` and
|
|
83
|
+
* `CellComponentProps<ColorField>` is this type.
|
|
84
|
+
*
|
|
85
|
+
* @see {@link ColorFieldInput} for the user-facing input type
|
|
86
|
+
* @see {@link color} for the config function that produces this type
|
|
87
|
+
*/
|
|
88
|
+
export interface ColorField<TFieldMeta extends {} = {}> extends BaseField<TFieldMeta> {
|
|
89
|
+
readonly type: typeof ADMIN_FIELDS.color.type;
|
|
90
|
+
/**
|
|
91
|
+
* Pre-filled value shown in the admin form when creating a new document.
|
|
92
|
+
* Defaults to `""` — an empty picker.
|
|
93
|
+
*/
|
|
94
|
+
defaultValue?: string;
|
|
95
|
+
/** The CSS notation the picker writes. */
|
|
96
|
+
format: ColorFormat;
|
|
97
|
+
/** Whether the picker offers the host app's design tokens as a second tab. */
|
|
98
|
+
themeColors: boolean;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/fields/color/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,WAAW,eAAe,CAAC,UAAU,SAAS,EAAE,GAAG,EAAE,CACzD,SAAQ,cAAc,CAAC,UAAU,CAAC;IAClC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;;;;;;;;;OAWG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,UAAU,CAAC,UAAU,SAAS,EAAE,GAAG,EAAE,CACpD,SAAQ,SAAS,CAAC,UAAU,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,OAAO,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC;IAC9C;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0CAA0C;IAC1C,MAAM,EAAE,WAAW,CAAC;IACpB,8EAA8E;IAC9E,WAAW,EAAE,OAAO,CAAC;CACtB"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme field key → CSS custom property, for the 32 shadcn design tokens.
|
|
3
|
+
*
|
|
4
|
+
* This map is the theming system's contract. `themeColorFields` derives the
|
|
5
|
+
* collection's colour fields from it, and `buildThemeCss` emits one declaration
|
|
6
|
+
* per entry — so a token cannot exist in the stored document without also being
|
|
7
|
+
* applied, or vice versa. The names are exactly the custom properties shadcn
|
|
8
|
+
* components consume and exactly the set tweakcn exports, so a preset maps
|
|
9
|
+
* across with no gaps.
|
|
10
|
+
*/
|
|
11
|
+
export declare const THEME_COLOR_TOKENS: {
|
|
12
|
+
readonly background: "--background";
|
|
13
|
+
readonly foreground: "--foreground";
|
|
14
|
+
readonly card: "--card";
|
|
15
|
+
readonly cardForeground: "--card-foreground";
|
|
16
|
+
readonly popover: "--popover";
|
|
17
|
+
readonly popoverForeground: "--popover-foreground";
|
|
18
|
+
readonly primary: "--primary";
|
|
19
|
+
readonly primaryForeground: "--primary-foreground";
|
|
20
|
+
readonly secondary: "--secondary";
|
|
21
|
+
readonly secondaryForeground: "--secondary-foreground";
|
|
22
|
+
readonly muted: "--muted";
|
|
23
|
+
readonly mutedForeground: "--muted-foreground";
|
|
24
|
+
readonly accent: "--accent";
|
|
25
|
+
readonly accentForeground: "--accent-foreground";
|
|
26
|
+
readonly destructive: "--destructive";
|
|
27
|
+
readonly destructiveForeground: "--destructive-foreground";
|
|
28
|
+
readonly border: "--border";
|
|
29
|
+
readonly input: "--input";
|
|
30
|
+
readonly ring: "--ring";
|
|
31
|
+
readonly chart1: "--chart-1";
|
|
32
|
+
readonly chart2: "--chart-2";
|
|
33
|
+
readonly chart3: "--chart-3";
|
|
34
|
+
readonly chart4: "--chart-4";
|
|
35
|
+
readonly chart5: "--chart-5";
|
|
36
|
+
readonly sidebar: "--sidebar";
|
|
37
|
+
readonly sidebarForeground: "--sidebar-foreground";
|
|
38
|
+
readonly sidebarPrimary: "--sidebar-primary";
|
|
39
|
+
readonly sidebarPrimaryForeground: "--sidebar-primary-foreground";
|
|
40
|
+
readonly sidebarAccent: "--sidebar-accent";
|
|
41
|
+
readonly sidebarAccentForeground: "--sidebar-accent-foreground";
|
|
42
|
+
readonly sidebarBorder: "--sidebar-border";
|
|
43
|
+
readonly sidebarRing: "--sidebar-ring";
|
|
44
|
+
};
|
|
45
|
+
/** One of the 32 shadcn colour-token keys, camelCased: `"cardForeground"`, `"chart1"`. */
|
|
46
|
+
export type ThemeColorTokenKey = keyof typeof THEME_COLOR_TOKENS;
|
|
47
|
+
/**
|
|
48
|
+
* Scheme-independent fields, read from the theme document root.
|
|
49
|
+
*
|
|
50
|
+
* `--font-sans` is commonly also set by the host's font loader (e.g.
|
|
51
|
+
* `next/font`) as a class on `<html>`; both are specificity (0,1,0), so the
|
|
52
|
+
* later declaration wins. A stack naming a font the app has not loaded degrades
|
|
53
|
+
* to the next entry rather than breaking.
|
|
54
|
+
*/
|
|
55
|
+
export declare const THEME_SHARED_TOKENS: {
|
|
56
|
+
readonly radius: "--radius";
|
|
57
|
+
readonly fontFamily: "--font-sans";
|
|
58
|
+
};
|
|
59
|
+
/** Where a theme's CSS applies. */
|
|
60
|
+
export type ThemeScope = "admin" | "site";
|
|
61
|
+
/**
|
|
62
|
+
* Stark × Ember — this repo's house palette, lifted verbatim from the `:root`
|
|
63
|
+
* block of `globals.css`. A freshly created theme starts from these values, so
|
|
64
|
+
* "new theme" means "fork the current look", not "32 empty pickers".
|
|
65
|
+
*/
|
|
66
|
+
export declare const EMBER_LIGHT: Record<ThemeColorTokenKey, string>;
|
|
67
|
+
/** Stark × Ember dark-mode values, from `globals.css`'s `.dark` block. */
|
|
68
|
+
export declare const EMBER_DARK: Record<ThemeColorTokenKey, string>;
|
|
69
|
+
/**
|
|
70
|
+
* Builds the stylesheet text applying a theme document at a scope.
|
|
71
|
+
*
|
|
72
|
+
* Values are written through verbatim — a `color()` field storing
|
|
73
|
+
* `oklch(60.5% 0.175 42)` needs no conversion, because custom properties accept
|
|
74
|
+
* any colour notation. `.dark` is assumed to sit on `<html>`, which *is*
|
|
75
|
+
* `:root`, so the dark selector is a compound, never a descendant.
|
|
76
|
+
*
|
|
77
|
+
* The two scopes form a specificity ladder that no injection order can upset:
|
|
78
|
+
* site light `:root` (0,1,0) < site dark `.dark` (0,1,0, later) < admin light
|
|
79
|
+
* `:root:root` (0,2,0) < admin dark `.dark:root:root` (0,3,0). Emit the site
|
|
80
|
+
* theme once for the whole document and the admin theme from the admin route
|
|
81
|
+
* only, and the admin block wins exactly where it renders.
|
|
82
|
+
*
|
|
83
|
+
* @param props - Input props.
|
|
84
|
+
* @param props.theme - The theme document — `light`/`dark` colour groups plus
|
|
85
|
+
* root-level `radius` and `fontFamily`, i.e. the shape `themeColorFields`
|
|
86
|
+
* stores.
|
|
87
|
+
* @param props.scope - `"site"` emits `:root`; `"admin"` emits `:root:root`.
|
|
88
|
+
* @returns The stylesheet text, or `""` when the theme sets nothing.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* const css = buildThemeCss({ theme, scope: "site" });
|
|
93
|
+
* // ":root {\n --background: oklch(96.1% 0 0);\n …\n}\n\n.dark {\n …\n}"
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare function buildThemeCss(props: {
|
|
97
|
+
theme: Record<string, unknown>;
|
|
98
|
+
scope: ThemeScope;
|
|
99
|
+
}): string;
|
|
100
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/fields/color/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCrB,CAAC;AAEX,0FAA0F;AAC1F,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,kBAAkB,CAAC;AAEjE;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB;;;CAGtB,CAAC;AAEX,mCAAmC;AACnC,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAE1C;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAiC1D,CAAC;AAEF,0EAA0E;AAC1E,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAiCzD,CAAC;AAuBF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE;IACnC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,KAAK,EAAE,UAAU,CAAC;CACnB,GAAG,MAAM,CAqBT"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ColorField } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Converts a colour field definition to a Convex schema validator string.
|
|
4
|
+
*
|
|
5
|
+
* Colour fields are stored as plain strings in Convex — the notation (and the
|
|
6
|
+
* `var(--token)` alternative allowed by `themeColors`) is enforced at the admin
|
|
7
|
+
* form layer, not in the database schema. This function generates only the type
|
|
8
|
+
* constraint, so changing `format` never triggers a schema migration.
|
|
9
|
+
*
|
|
10
|
+
* @param props - Input props.
|
|
11
|
+
* @param props.field - The resolved colour field definition.
|
|
12
|
+
* @returns Convex validator string: `"v.string()"` for required fields,
|
|
13
|
+
* `"v.optional(v.string())"` for optional fields.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* colorFieldToValidator({ field: color({ required: true }) }) // "v.string()"
|
|
18
|
+
* colorFieldToValidator({ field: color({ required: false }) }) // "v.optional(v.string())"
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @see {@link colorFieldToInputSchema} for the admin-form Zod schema that enforces the notation
|
|
22
|
+
* @internal Used by schema generation, not typically called directly.
|
|
23
|
+
*/
|
|
24
|
+
export declare function colorFieldToValidator(props: {
|
|
25
|
+
field: ColorField;
|
|
26
|
+
}): string;
|
|
27
|
+
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../../src/fields/color/validator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,UAAU,CAAA;CAAE,GAAG,MAAM,CAK1E"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convex schema value type constants for field types.
|
|
3
|
+
*
|
|
4
|
+
* These constants define the base Convex validator strings for each field type.
|
|
5
|
+
* They're used by schema generation logic to build the Convex schema.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
/** Convex schema metadata for each supported field type, keyed by field type name. */
|
|
10
|
+
export declare const ADMIN_FIELDS: {
|
|
11
|
+
readonly text: {
|
|
12
|
+
readonly type: "text";
|
|
13
|
+
readonly interfaceType: "string";
|
|
14
|
+
readonly validator: "v.string()";
|
|
15
|
+
readonly defaultValue: "";
|
|
16
|
+
};
|
|
17
|
+
readonly url: {
|
|
18
|
+
readonly type: "url";
|
|
19
|
+
readonly interfaceType: "string";
|
|
20
|
+
readonly validator: "v.string()";
|
|
21
|
+
readonly defaultValue: "";
|
|
22
|
+
};
|
|
23
|
+
readonly color: {
|
|
24
|
+
readonly type: "color";
|
|
25
|
+
readonly interfaceType: "string";
|
|
26
|
+
readonly validator: "v.string()";
|
|
27
|
+
readonly defaultValue: "";
|
|
28
|
+
};
|
|
29
|
+
readonly number: {
|
|
30
|
+
readonly type: "number";
|
|
31
|
+
readonly interfaceType: "number";
|
|
32
|
+
readonly validator: "v.number()";
|
|
33
|
+
readonly defaultValue: 0;
|
|
34
|
+
};
|
|
35
|
+
readonly checkbox: {
|
|
36
|
+
readonly type: "checkbox";
|
|
37
|
+
readonly interfaceType: "boolean";
|
|
38
|
+
readonly validator: "v.boolean()";
|
|
39
|
+
readonly defaultValue: false;
|
|
40
|
+
};
|
|
41
|
+
readonly date: {
|
|
42
|
+
readonly type: "date";
|
|
43
|
+
readonly interfaceType: "number";
|
|
44
|
+
readonly validator: "v.number()";
|
|
45
|
+
readonly defaultValue: undefined;
|
|
46
|
+
};
|
|
47
|
+
readonly select: {
|
|
48
|
+
readonly type: "select";
|
|
49
|
+
readonly interfaceType: "string[]";
|
|
50
|
+
readonly validator: "v.array(\nv.string()\n)";
|
|
51
|
+
readonly defaultValue: string[];
|
|
52
|
+
};
|
|
53
|
+
readonly relationship: {
|
|
54
|
+
readonly type: "relationship";
|
|
55
|
+
readonly interfaceType: "Id<CollectionSlug>[]";
|
|
56
|
+
readonly validator: "v.array(\nv.string()\n)";
|
|
57
|
+
readonly defaultValue: string[];
|
|
58
|
+
};
|
|
59
|
+
readonly array: {
|
|
60
|
+
readonly type: "array";
|
|
61
|
+
readonly interfaceType: "unknown[]";
|
|
62
|
+
readonly validator: "v.array(\nv.any()\n)";
|
|
63
|
+
readonly defaultValue: readonly [];
|
|
64
|
+
};
|
|
65
|
+
readonly group: {
|
|
66
|
+
readonly type: "group";
|
|
67
|
+
readonly interfaceType: "Record<string, any>";
|
|
68
|
+
readonly validator: "v.object({})";
|
|
69
|
+
readonly defaultValue: Record<string, any>;
|
|
70
|
+
};
|
|
71
|
+
readonly blocks: {
|
|
72
|
+
readonly type: "blocks";
|
|
73
|
+
readonly interfaceType: "Record<string, any>[]";
|
|
74
|
+
readonly validator: "v.array(v.any())";
|
|
75
|
+
readonly defaultValue: readonly [];
|
|
76
|
+
};
|
|
77
|
+
readonly upload: {
|
|
78
|
+
readonly type: "upload";
|
|
79
|
+
readonly interfaceType: "Id<MediaCollectionSlug>[]";
|
|
80
|
+
readonly validator: "v.array(\nv.string()\n)";
|
|
81
|
+
readonly defaultValue: undefined;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
/** Union of all supported field type name strings (e.g. `"text"` | `"number"` | `"checkbox"` | ...). */
|
|
85
|
+
export type AdminFieldType = (typeof ADMIN_FIELDS)[keyof typeof ADMIN_FIELDS]["type"];
|
|
86
|
+
/** Union of all Convex validator strings for the supported field types (e.g. `"v.string()"` | `"v.number()"` | ...). */
|
|
87
|
+
export type AdminFieldValidator = (typeof ADMIN_FIELDS)[keyof typeof ADMIN_FIELDS]["validator"];
|
|
88
|
+
/** Union of all TypeScript type strings corresponding to the supported field types (e.g. `"string"` | `"number"` | ...). */
|
|
89
|
+
export type AdminFieldTsType = (typeof ADMIN_FIELDS)[keyof typeof ADMIN_FIELDS]["interfaceType"];
|
|
90
|
+
/** Literal type `"text"` — the discriminant value on {@link TextField}. */
|
|
91
|
+
export type TextFieldType = typeof ADMIN_FIELDS.text.type;
|
|
92
|
+
/** Literal type `"url"` — the discriminant value on {@link UrlField}. */
|
|
93
|
+
export type UrlFieldType = typeof ADMIN_FIELDS.url.type;
|
|
94
|
+
/** Literal type `"color"` — the discriminant value on {@link ColorField}. */
|
|
95
|
+
export type ColorFieldType = typeof ADMIN_FIELDS.color.type;
|
|
96
|
+
/** Literal type `"number"` — the discriminant value on {@link NumberField}. */
|
|
97
|
+
export type NumberFieldType = typeof ADMIN_FIELDS.number.type;
|
|
98
|
+
/** Literal type `"checkbox"` — the discriminant value on {@link CheckboxField}. */
|
|
99
|
+
export type CheckboxFieldType = typeof ADMIN_FIELDS.checkbox.type;
|
|
100
|
+
/** Literal type `"date"` — the discriminant value on {@link DateField}. */
|
|
101
|
+
export type DateFieldType = typeof ADMIN_FIELDS.date.type;
|
|
102
|
+
/** Literal type `"select"` — the discriminant value on {@link SelectField}. */
|
|
103
|
+
export type SelectFieldType = typeof ADMIN_FIELDS.select.type;
|
|
104
|
+
/** Literal type `"relationship"` — the discriminant value on {@link RelationshipField}. */
|
|
105
|
+
export type RelationshipFieldType = typeof ADMIN_FIELDS.relationship.type;
|
|
106
|
+
/** Literal type `"array"` — the discriminant value on {@link ArrayField}. */
|
|
107
|
+
export type ArrayFieldType = typeof ADMIN_FIELDS.array.type;
|
|
108
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/fields/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,sFAAsF;AACtF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAyCD,MAAM,EAAE;;;;;;+BAMR,MAAM,EAAE;;;;;;;;;;;;+BAaR,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;;;;;;;;;;;;;CAmBjC,CAAC;AACX,wGAAwG;AACxG,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AACtF,wHAAwH;AACxH,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC,WAAW,CAAC,CAAC;AAChG,4HAA4H;AAC5H,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC,eAAe,CAAC,CAAC;AAEjG,2EAA2E;AAC3E,MAAM,MAAM,aAAa,GAAG,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;AAE1D,yEAAyE;AACzE,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC;AAExD,6EAA6E;AAC7E,MAAM,MAAM,cAAc,GAAG,OAAO,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC;AAE5D,+EAA+E;AAC/E,MAAM,MAAM,eAAe,GAAG,OAAO,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC;AAE9D,mFAAmF;AACnF,MAAM,MAAM,iBAAiB,GAAG,OAAO,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC;AAElE,2EAA2E;AAC3E,MAAM,MAAM,aAAa,GAAG,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;AAE1D,+EAA+E;AAC/E,MAAM,MAAM,eAAe,GAAG,OAAO,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC;AAE9D,2FAA2F;AAC3F,MAAM,MAAM,qBAAqB,GAAG,OAAO,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC;AAE1E,6EAA6E;AAC7E,MAAM,MAAM,cAAc,GAAG,OAAO,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { BaseFieldMeta } from "../types";
|
|
2
|
+
import type { DateFieldInput, DateField } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a date field with all defaults applied.
|
|
5
|
+
*
|
|
6
|
+
* Date fields store a Unix timestamp in milliseconds.
|
|
7
|
+
* Common uses: published dates, expiry dates, event times, timestamps.
|
|
8
|
+
*
|
|
9
|
+
* Accepts {@link DateFieldInput} (all optional) and returns {@link DateField} with all defaults applied.
|
|
10
|
+
*
|
|
11
|
+
* **Defaults applied:**
|
|
12
|
+
* - `label` — `""` (inferred from the field key by `defineCollection`)
|
|
13
|
+
* - `required` — `false`
|
|
14
|
+
* - `time.hidden` — `false` (time picker is visible)
|
|
15
|
+
* - `time.use12HourFormat` — `true` (AM/PM format)
|
|
16
|
+
* - `time.timePicker.hour` — `true`
|
|
17
|
+
* - `time.timePicker.minute` — `true`
|
|
18
|
+
* - `time.timePicker.second` — `false`
|
|
19
|
+
* - `admin.hidden` — `false`
|
|
20
|
+
* - `admin.readOnly` — `false`
|
|
21
|
+
* - `admin.position` — `"main"`
|
|
22
|
+
* - `admin.width` — `"full"`
|
|
23
|
+
* - `admin.cellAlignment` — `"left"`
|
|
24
|
+
*
|
|
25
|
+
* @param options - Date field configuration. All properties are optional.
|
|
26
|
+
* @returns Resolved date field definition with all defaults applied.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { date, defineCollection } from '@vexcms/core'
|
|
31
|
+
*
|
|
32
|
+
* posts: defineCollection({
|
|
33
|
+
* fields: {
|
|
34
|
+
* // Minimal — label inferred from key ("Published At")
|
|
35
|
+
* publishedAt: date(),
|
|
36
|
+
*
|
|
37
|
+
* // Required event date with a database index
|
|
38
|
+
* eventDate: date({ required: true, index: "by_event_date" }),
|
|
39
|
+
*
|
|
40
|
+
* // Date-only picker (hide the time UI)
|
|
41
|
+
* expiresOn: date({ time: { hidden: true } }),
|
|
42
|
+
*
|
|
43
|
+
* // Appointment in 24-hour format, shown in the sidebar
|
|
44
|
+
* appointmentAt: date({
|
|
45
|
+
* required: true,
|
|
46
|
+
* time: { use12HourFormat: false },
|
|
47
|
+
* admin: { position: "sidebar", width: "half" },
|
|
48
|
+
* }),
|
|
49
|
+
* }
|
|
50
|
+
* })
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @see {@link DateFieldInput} for the full input type
|
|
54
|
+
* @see {@link DateField} for the resolved output type
|
|
55
|
+
*/
|
|
56
|
+
export declare function date<TFieldMeta extends BaseFieldMeta = BaseFieldMeta>(options?: DateFieldInput<TFieldMeta>): DateField<TFieldMeta>;
|
|
57
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/fields/date/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,wBAAgB,IAAI,CAAC,UAAU,SAAS,aAAa,GAAG,aAAa,EACnE,OAAO,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,GACnC,SAAS,CAAC,UAAU,CAAC,CAsCvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/date/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ZodType } from "zod";
|
|
2
|
+
import { DateField } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Builds a Zod schema for validating a date field value in the admin form.
|
|
5
|
+
*
|
|
6
|
+
* Date values are Unix timestamps in milliseconds, so the base schema is
|
|
7
|
+
* `z.number()`. For required fields a `.default(Date.now())` is applied so
|
|
8
|
+
* the picker always has an initial value. Non-required fields are wrapped
|
|
9
|
+
* in `.optional()` via `applyBaseInputSchemaMeta`.
|
|
10
|
+
*
|
|
11
|
+
* @param props - Input props.
|
|
12
|
+
* @param props.field - The resolved date field definition
|
|
13
|
+
* @returns A Zod number schema with optionality applied
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const field = date({ required: true })
|
|
18
|
+
* dateFieldToInputSchema({ field })
|
|
19
|
+
* // → z.number().default(<now>)
|
|
20
|
+
*
|
|
21
|
+
* const optField = date({ required: false })
|
|
22
|
+
* dateFieldToInputSchema({ field: optField })
|
|
23
|
+
* // → z.number().optional()
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function dateFieldToInputSchema(props: {
|
|
27
|
+
field: DateField;
|
|
28
|
+
}): ZodType;
|
|
29
|
+
//# sourceMappingURL=inputSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputSchema.d.ts","sourceRoot":"","sources":["../../../src/fields/date/inputSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,OAAO,EAAyB,MAAM,KAAK,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,GAAG,OAAO,CAS3E"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { ADMIN_FIELDS } from "../constants";
|
|
2
|
+
import { BaseField, BaseFieldInput, FieldAdminConfig } from "../baseTypes";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration input for a `date()` field.
|
|
5
|
+
*
|
|
6
|
+
* Date fields store a Unix timestamp in milliseconds — event dates, publish
|
|
7
|
+
* dates, expiry times, etc. All properties are optional; unset properties fall
|
|
8
|
+
* back to the defaults listed below.
|
|
9
|
+
*
|
|
10
|
+
* **Defaults applied by `date()`:**
|
|
11
|
+
* ```ts
|
|
12
|
+
* {
|
|
13
|
+
* type: "date",
|
|
14
|
+
* label: "", // inferred from the field key by defineCollection
|
|
15
|
+
* required: false, // field is optional by default
|
|
16
|
+
* time: {
|
|
17
|
+
* hidden: false, // time picker is visible alongside the calendar
|
|
18
|
+
* use12HourFormat: true, // AM/PM format (set false for 24-hour)
|
|
19
|
+
* timePicker: {
|
|
20
|
+
* hour: true, // hour selector shown
|
|
21
|
+
* minute: true, // minute selector shown
|
|
22
|
+
* second: false, // seconds hidden
|
|
23
|
+
* },
|
|
24
|
+
* },
|
|
25
|
+
* admin: {
|
|
26
|
+
* hidden: false, // visible in the admin form
|
|
27
|
+
* readOnly: false, // editable by default
|
|
28
|
+
* position: "main", // placed in the main content column, not the sidebar
|
|
29
|
+
* width: "full", // spans the full form width, not half
|
|
30
|
+
* cellAlignment: "left", // text aligned left in the data table column
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* // Minimal — label is inferred from the key ("Published At")
|
|
38
|
+
* publishedAt: date()
|
|
39
|
+
*
|
|
40
|
+
* // Required event date with a database index
|
|
41
|
+
* eventDate: date({ required: true, index: "by_event_date" })
|
|
42
|
+
*
|
|
43
|
+
* // Appointment with 24-hour format and seconds hidden (overrides defaults)
|
|
44
|
+
* appointmentAt: date({
|
|
45
|
+
* required: true,
|
|
46
|
+
* time: { use12HourFormat: false },
|
|
47
|
+
* })
|
|
48
|
+
*
|
|
49
|
+
* // Date-only picker (hide the time UI entirely)
|
|
50
|
+
* expiresOn: date({ time: { hidden: true } })
|
|
51
|
+
*
|
|
52
|
+
* // Pre-filled default (Unix ms timestamp for 2025-01-01T00:00:00Z)
|
|
53
|
+
* startsAt: date({ defaultValue: 1735689600000 })
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @see {@link DateField} for the resolved type after defaults are applied
|
|
57
|
+
* @see {@link date} for the config function that applies defaults
|
|
58
|
+
* @see {@link BaseFieldInput} for shared properties (`label`, `description`, `required`, `admin`, `index`)
|
|
59
|
+
*/
|
|
60
|
+
export interface DateFieldInput<TFieldMeta extends {} = {}> extends BaseFieldInput<TFieldMeta> {
|
|
61
|
+
/**
|
|
62
|
+
* Pre-filled Unix timestamp (milliseconds) shown in the admin form when creating a new document.
|
|
63
|
+
* Does not apply to existing database values.
|
|
64
|
+
*/
|
|
65
|
+
defaultValue?: number | undefined;
|
|
66
|
+
/** Minimum allowed Unix timestamp (milliseconds). Validated in the input schema. */
|
|
67
|
+
min?: number;
|
|
68
|
+
/** Maximum allowed Unix timestamp (milliseconds). Validated in the input schema. */
|
|
69
|
+
max?: number;
|
|
70
|
+
/**
|
|
71
|
+
* Date/time picker display configuration. Each key is optional — omitted keys
|
|
72
|
+
* fall back to the defaults applied by `date()`. The `time` object is always
|
|
73
|
+
* fully resolved on `DateField` after defaults are merged.
|
|
74
|
+
*/
|
|
75
|
+
time?: {
|
|
76
|
+
/**
|
|
77
|
+
* Hide the time-of-day picker, showing only the calendar date selector.
|
|
78
|
+
*
|
|
79
|
+
* Default: `false` (time picker is visible)
|
|
80
|
+
*/
|
|
81
|
+
hidden?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Display time in 12-hour AM/PM format instead of 24-hour.
|
|
84
|
+
*
|
|
85
|
+
* Default: `true`
|
|
86
|
+
*/
|
|
87
|
+
use12HourFormat?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Control which time units are shown in the time picker.
|
|
90
|
+
* Each unit defaults to `true` for `hour` and `minute`, `false` for `second`.
|
|
91
|
+
*/
|
|
92
|
+
timePicker?: {
|
|
93
|
+
/** Show the hour selector. Default: `true`. */
|
|
94
|
+
hour: boolean;
|
|
95
|
+
/** Show the minute selector. Default: `true`. */
|
|
96
|
+
minute: boolean;
|
|
97
|
+
/** Show the seconds selector. Default: `false`. */
|
|
98
|
+
second: boolean;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Resolved configuration for a `date()` field, after all defaults are applied.
|
|
104
|
+
*
|
|
105
|
+
* This is the type that framework adapters and field components receive —
|
|
106
|
+
* `fieldDef` in `InputComponentProps<DateField>` and `CellComponentProps<DateField>`
|
|
107
|
+
* is this type.
|
|
108
|
+
*
|
|
109
|
+
* @see {@link DateFieldInput} for the user-facing input type
|
|
110
|
+
* @see {@link date} for the config function that produces this type
|
|
111
|
+
*/
|
|
112
|
+
export interface DateField<TFieldMeta extends {} = {}> extends BaseField<TFieldMeta> {
|
|
113
|
+
readonly type: typeof ADMIN_FIELDS.date.type;
|
|
114
|
+
/** Display label shown in the admin form. Always set — inferred from the field key if not provided. */
|
|
115
|
+
label: string;
|
|
116
|
+
/** Whether this field is required in the database schema. */
|
|
117
|
+
required: boolean;
|
|
118
|
+
/** Resolved admin UI configuration with all defaults applied. */
|
|
119
|
+
admin: FieldAdminConfig;
|
|
120
|
+
/** Pre-filled Unix timestamp (milliseconds) shown in the admin form when creating a new document. */
|
|
121
|
+
defaultValue: number | undefined;
|
|
122
|
+
/** Minimum allowed Unix timestamp (milliseconds). */
|
|
123
|
+
min?: number;
|
|
124
|
+
/** Maximum allowed Unix timestamp (milliseconds). */
|
|
125
|
+
max?: number;
|
|
126
|
+
/**
|
|
127
|
+
* Resolved date/time picker display configuration — all keys always present after defaults are applied.
|
|
128
|
+
*
|
|
129
|
+
* @see {@link DateFieldInput} for the user-facing input type where each key is optional
|
|
130
|
+
*/
|
|
131
|
+
time: {
|
|
132
|
+
/** Whether the time-of-day picker is hidden, leaving only the calendar date selector. */
|
|
133
|
+
hidden: boolean;
|
|
134
|
+
/** Whether time is displayed in 12-hour AM/PM format (`true`) or 24-hour format (`false`). */
|
|
135
|
+
use12HourFormat: boolean;
|
|
136
|
+
/** Which time unit selectors are shown in the time picker. */
|
|
137
|
+
timePicker: {
|
|
138
|
+
/** Whether the hour selector is shown. */
|
|
139
|
+
hour: boolean;
|
|
140
|
+
/** Whether the minute selector is shown. */
|
|
141
|
+
minute: boolean;
|
|
142
|
+
/** Whether the seconds selector is shown. */
|
|
143
|
+
second: boolean;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=types.d.ts.map
|