@fluid-app/rep-core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-6QLUUNJL.cjs +153 -0
- package/dist/chunk-6QLUUNJL.cjs.map +1 -0
- package/dist/chunk-EWR5EIBP.js +136 -0
- package/dist/chunk-EWR5EIBP.js.map +1 -0
- package/dist/data-sources/context.cjs +26 -0
- package/dist/data-sources/context.cjs.map +1 -0
- package/dist/data-sources/context.d.cts +16 -0
- package/dist/data-sources/context.d.ts +16 -0
- package/dist/data-sources/context.js +23 -0
- package/dist/data-sources/context.js.map +1 -0
- package/dist/data-sources/types.cjs +4 -0
- package/dist/data-sources/types.cjs.map +1 -0
- package/dist/data-sources/types.d.cts +122 -0
- package/dist/data-sources/types.d.ts +122 -0
- package/dist/data-sources/types.js +3 -0
- package/dist/data-sources/types.js.map +1 -0
- package/dist/registries/index.cjs +156 -0
- package/dist/registries/index.cjs.map +1 -0
- package/dist/registries/index.d.cts +303 -0
- package/dist/registries/index.d.ts +303 -0
- package/dist/registries/index.js +143 -0
- package/dist/registries/index.js.map +1 -0
- package/dist/shareable-item-DPmNZkE1.d.cts +138 -0
- package/dist/shareable-item-DPmNZkE1.d.ts +138 -0
- package/dist/theme/index.cjs +1013 -0
- package/dist/theme/index.cjs.map +1 -0
- package/dist/theme/index.d.cts +2680 -0
- package/dist/theme/index.d.ts +2680 -0
- package/dist/theme/index.js +956 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme-DrMUYZTO.d.cts +22 -0
- package/dist/theme-DrMUYZTO.d.ts +22 -0
- package/dist/types/index.cjs +72 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +227 -0
- package/dist/types/index.d.ts +227 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/widget-utils/index.cjs +123 -0
- package/dist/widget-utils/index.cjs.map +1 -0
- package/dist/widget-utils/index.d.cts +43 -0
- package/dist/widget-utils/index.d.ts +43 -0
- package/dist/widget-utils/index.js +111 -0
- package/dist/widget-utils/index.js.map +1 -0
- package/package.json +99 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
type DataSourceType = "api" | "custom" | "static";
|
|
2
|
+
type StaticSourceType = "collections" | "categories" | "tags";
|
|
3
|
+
type ShareableType = "Medium" | "Page" | "EnrollmentPack" | "Library" | "Product";
|
|
4
|
+
interface SelectedItem {
|
|
5
|
+
/** The unique ID of the selected item */
|
|
6
|
+
id: string | number;
|
|
7
|
+
/** The type of shareable content */
|
|
8
|
+
shareableType: ShareableType;
|
|
9
|
+
/** Optional cached data for preview/display purposes in the editor UI */
|
|
10
|
+
cachedData?: {
|
|
11
|
+
title?: string;
|
|
12
|
+
imageUrl?: string;
|
|
13
|
+
kind?: string;
|
|
14
|
+
};
|
|
15
|
+
/** Widget-specific per-item configuration overrides */
|
|
16
|
+
widgetConfig?: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
interface ApiDataSource {
|
|
19
|
+
type: "api";
|
|
20
|
+
/** API endpoint URL (can include {variable} placeholders, e.g., /api/reps/{rep_id}/items) */
|
|
21
|
+
endpoint: string;
|
|
22
|
+
/** HTTP method (defaults to GET) */
|
|
23
|
+
method?: "GET" | "POST" | "PUT" | "DELETE";
|
|
24
|
+
/** Request headers */
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
/** Request body for POST/PUT (will be JSON.stringify'd) */
|
|
27
|
+
body?: unknown;
|
|
28
|
+
/**
|
|
29
|
+
* Path to extract from response using dot notation
|
|
30
|
+
* e.g., "data.items" extracts response.data.items
|
|
31
|
+
*/
|
|
32
|
+
resultPath?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Which widget props this source populates
|
|
35
|
+
* e.g., ['data'] means the fetched result goes to props.data
|
|
36
|
+
*/
|
|
37
|
+
targetProps: string[];
|
|
38
|
+
/**
|
|
39
|
+
* Name of a registered transform function to process the data
|
|
40
|
+
* Transform is applied after resultPath extraction
|
|
41
|
+
*/
|
|
42
|
+
transform?: string;
|
|
43
|
+
/** Per-source variables for endpoint template interpolation (e.g., { limit: "10" }) */
|
|
44
|
+
variables?: Record<string, string>;
|
|
45
|
+
/**
|
|
46
|
+
* Auto-refresh interval in milliseconds
|
|
47
|
+
* 0 or undefined = no auto-refresh
|
|
48
|
+
*/
|
|
49
|
+
refreshInterval?: number;
|
|
50
|
+
}
|
|
51
|
+
interface CustomDataSource {
|
|
52
|
+
type: "custom";
|
|
53
|
+
/** Array of selected items to fetch */
|
|
54
|
+
selectedItems: SelectedItem[];
|
|
55
|
+
/**
|
|
56
|
+
* Which widget props this source populates
|
|
57
|
+
* e.g., ['slides'] means the fetched results go to props.slides
|
|
58
|
+
*/
|
|
59
|
+
targetProps: string[];
|
|
60
|
+
/**
|
|
61
|
+
* Name of a registered transform function to process the data
|
|
62
|
+
* Transform is applied after all items are fetched
|
|
63
|
+
*/
|
|
64
|
+
transform?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Auto-refresh interval in milliseconds
|
|
67
|
+
* 0 or undefined = no auto-refresh
|
|
68
|
+
*/
|
|
69
|
+
refreshInterval?: number;
|
|
70
|
+
}
|
|
71
|
+
interface StaticDataSource {
|
|
72
|
+
type: "static";
|
|
73
|
+
/** The type of static data (collections, categories, tags) */
|
|
74
|
+
staticType: StaticSourceType;
|
|
75
|
+
/** The selected item ID */
|
|
76
|
+
selectedId: string | number;
|
|
77
|
+
/** Cached data for preview/display in editor UI */
|
|
78
|
+
cachedData?: {
|
|
79
|
+
title?: string;
|
|
80
|
+
imageUrl?: string;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Which widget props this source populates
|
|
84
|
+
*/
|
|
85
|
+
targetProps: string[];
|
|
86
|
+
/**
|
|
87
|
+
* Name of a registered transform function to process the data
|
|
88
|
+
*/
|
|
89
|
+
transform?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Auto-refresh interval in milliseconds
|
|
92
|
+
* 0 or undefined = no auto-refresh
|
|
93
|
+
*/
|
|
94
|
+
refreshInterval?: number;
|
|
95
|
+
}
|
|
96
|
+
type DataSource = ApiDataSource | CustomDataSource | StaticDataSource;
|
|
97
|
+
interface DataSourceConfig {
|
|
98
|
+
/** Array of data sources (usually just one, but supports multiple) */
|
|
99
|
+
sources: DataSource[];
|
|
100
|
+
/** Loading state configuration */
|
|
101
|
+
loading?: {
|
|
102
|
+
/** Show skeleton placeholder while loading (default: true) */
|
|
103
|
+
showSkeleton?: boolean;
|
|
104
|
+
};
|
|
105
|
+
/** Error handling configuration */
|
|
106
|
+
error?: {
|
|
107
|
+
/** Fallback props to use when fetch fails */
|
|
108
|
+
fallback?: Record<string, unknown>;
|
|
109
|
+
/** Number of retry attempts (default: 0) */
|
|
110
|
+
retryCount?: number;
|
|
111
|
+
/** Delay between retries in ms (default: 1000) */
|
|
112
|
+
retryDelay?: number;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/** Item returned by static data fetchers */
|
|
116
|
+
interface StaticItem {
|
|
117
|
+
id: string | number;
|
|
118
|
+
title: string;
|
|
119
|
+
imageUrl?: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export type { ApiDataSource, CustomDataSource, DataSource, DataSourceConfig, DataSourceType, SelectedItem, ShareableType, StaticDataSource, StaticItem, StaticSourceType };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"types.js"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/registries/property-schema-types.ts
|
|
4
|
+
var PROPERTY_FIELD_TYPES = {
|
|
5
|
+
text: "text",
|
|
6
|
+
textarea: "textarea",
|
|
7
|
+
number: "number",
|
|
8
|
+
boolean: "boolean",
|
|
9
|
+
select: "select",
|
|
10
|
+
color: "color",
|
|
11
|
+
range: "range",
|
|
12
|
+
dataSource: "dataSource",
|
|
13
|
+
resource: "resource",
|
|
14
|
+
alignment: "alignment",
|
|
15
|
+
slider: "slider",
|
|
16
|
+
colorPicker: "colorPicker",
|
|
17
|
+
sectionHeader: "sectionHeader",
|
|
18
|
+
separator: "separator",
|
|
19
|
+
buttonGroup: "buttonGroup",
|
|
20
|
+
colorSelect: "colorSelect",
|
|
21
|
+
sectionLayoutSelect: "sectionLayoutSelect",
|
|
22
|
+
background: "background",
|
|
23
|
+
contentPosition: "contentPosition"
|
|
24
|
+
};
|
|
25
|
+
function isPropertyFieldType(value) {
|
|
26
|
+
return Object.values(PROPERTY_FIELD_TYPES).includes(
|
|
27
|
+
value
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
function groupPropertyFields(fields) {
|
|
31
|
+
const grouped = {};
|
|
32
|
+
fields.forEach((field) => {
|
|
33
|
+
const group = field.group || "General";
|
|
34
|
+
if (!grouped[group]) {
|
|
35
|
+
grouped[group] = [];
|
|
36
|
+
}
|
|
37
|
+
grouped[group].push(field);
|
|
38
|
+
});
|
|
39
|
+
return grouped;
|
|
40
|
+
}
|
|
41
|
+
function extractPropertyValues(widget, fields) {
|
|
42
|
+
const values = {};
|
|
43
|
+
fields.forEach((field) => {
|
|
44
|
+
const value = widget.props[field.key];
|
|
45
|
+
values[field.key] = value !== void 0 ? value : field.defaultValue;
|
|
46
|
+
});
|
|
47
|
+
return values;
|
|
48
|
+
}
|
|
49
|
+
function applyPropertyValues(widget, values) {
|
|
50
|
+
return {
|
|
51
|
+
...widget,
|
|
52
|
+
props: {
|
|
53
|
+
...widget.props,
|
|
54
|
+
...values
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/registries/field-helpers.ts
|
|
60
|
+
var getColorField = (props) => {
|
|
61
|
+
return {
|
|
62
|
+
...props,
|
|
63
|
+
type: "colorSelect"
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
var getBorderRadiusField = (props) => {
|
|
67
|
+
return {
|
|
68
|
+
...props,
|
|
69
|
+
type: "buttonGroup",
|
|
70
|
+
options: [
|
|
71
|
+
{ label: "None", value: "none" },
|
|
72
|
+
{ label: "SM", value: "sm" },
|
|
73
|
+
{ label: "MD", value: "md" },
|
|
74
|
+
{ label: "LG", value: "lg" },
|
|
75
|
+
{ label: "XL", value: "xl" },
|
|
76
|
+
{ label: "FULL", value: "full" }
|
|
77
|
+
]
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
var getPaddingField = (props) => {
|
|
81
|
+
return {
|
|
82
|
+
...props,
|
|
83
|
+
type: "buttonGroup",
|
|
84
|
+
options: [
|
|
85
|
+
{ label: "None", value: 0 },
|
|
86
|
+
{ label: "SM", value: 2 },
|
|
87
|
+
{ label: "MD", value: 4 },
|
|
88
|
+
{ label: "LG", value: 6 },
|
|
89
|
+
{ label: "XL", value: 8 },
|
|
90
|
+
{ label: "FULL", value: 10 }
|
|
91
|
+
]
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
var getButtonSizeField = (props) => {
|
|
95
|
+
return {
|
|
96
|
+
...props,
|
|
97
|
+
type: "buttonGroup",
|
|
98
|
+
options: [
|
|
99
|
+
{ label: "SM", value: "sm" },
|
|
100
|
+
{ label: "MD", value: "default" },
|
|
101
|
+
{ label: "LG", value: "lg" },
|
|
102
|
+
{ label: "XL", value: "xl" }
|
|
103
|
+
]
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
var getFontSizeField = (props) => {
|
|
107
|
+
return {
|
|
108
|
+
...props,
|
|
109
|
+
type: "select",
|
|
110
|
+
options: [
|
|
111
|
+
{ label: "Giant", value: "2xl" },
|
|
112
|
+
{ label: "Extra Large", value: "xl" },
|
|
113
|
+
{ label: "Large", value: "lg" },
|
|
114
|
+
{ label: "Regular", value: "md" },
|
|
115
|
+
{ label: "Small", value: "sm" },
|
|
116
|
+
{ label: "Extra Small", value: "xs" }
|
|
117
|
+
]
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
var getGapField = (props) => {
|
|
121
|
+
return {
|
|
122
|
+
...props,
|
|
123
|
+
type: "buttonGroup",
|
|
124
|
+
options: [
|
|
125
|
+
{ label: "None", value: "none" },
|
|
126
|
+
{ label: "XS", value: "xs" },
|
|
127
|
+
{ label: "SM", value: "sm" },
|
|
128
|
+
{ label: "MD", value: "md" },
|
|
129
|
+
{ label: "LG", value: "lg" },
|
|
130
|
+
{ label: "XL", value: "xl" }
|
|
131
|
+
]
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
var gapValues = {
|
|
135
|
+
none: 0,
|
|
136
|
+
xs: 1,
|
|
137
|
+
sm: 2,
|
|
138
|
+
md: 4,
|
|
139
|
+
lg: 6,
|
|
140
|
+
xl: 8
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
exports.PROPERTY_FIELD_TYPES = PROPERTY_FIELD_TYPES;
|
|
144
|
+
exports.applyPropertyValues = applyPropertyValues;
|
|
145
|
+
exports.extractPropertyValues = extractPropertyValues;
|
|
146
|
+
exports.gapValues = gapValues;
|
|
147
|
+
exports.getBorderRadiusField = getBorderRadiusField;
|
|
148
|
+
exports.getButtonSizeField = getButtonSizeField;
|
|
149
|
+
exports.getColorField = getColorField;
|
|
150
|
+
exports.getFontSizeField = getFontSizeField;
|
|
151
|
+
exports.getGapField = getGapField;
|
|
152
|
+
exports.getPaddingField = getPaddingField;
|
|
153
|
+
exports.groupPropertyFields = groupPropertyFields;
|
|
154
|
+
exports.isPropertyFieldType = isPropertyFieldType;
|
|
155
|
+
//# sourceMappingURL=index.cjs.map
|
|
156
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/registries/property-schema-types.ts","../../src/registries/field-helpers.ts"],"names":[],"mappings":";;;AA2BO,IAAM,oBAAA,GAAuB;AAAA,EAClC,IAAA,EAAM,MAAA;AAAA,EACN,QAAA,EAAU,UAAA;AAAA,EACV,MAAA,EAAQ,QAAA;AAAA,EACR,OAAA,EAAS,SAAA;AA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EAAO,IAAA;AAAK;AACtC,GACF;AACF;AAEO,IAAM,WAAA,GAAc,CACzB,KAAA,KACuC;AACvC,EAAA,OAAO;AAAA,IACL,GAAG,KAAA;AAAA,IACH,IAAA,EAAM,aAAA;AAAA,IACN,OAAA,EAAS;AAAA,MACP,EAAE,KAAA,EAAO,MAAA,EAAQ,KAAA,EAAO,MAAA,EAAO;AAAA,MAC/B,EAAE,KAAA,EAAO,IAAA,EAAM,KAAA,EAAO,IAAA,EAAK;AAAA,MAC3B,EAAE,KAAA,EAAO,IAAA,EAAM,KAAA,EAAO,IAAA,EAAK;AAAA,MAC3B,EAAE,KAAA,EAAO,IAAA,EAAM,KAAA,EAAO,IAAA,EAAK;AAAA,MAC3B,EAAE,KAAA,EAAO,IAAA,EAAM,KAAA,EAAO,IAAA,EAAK;AAAA,MAC3B,EAAE,KAAA,EAAO,IAAA,EAAM,KAAA,EAAO,IAAA;AAAK;AAC7B,GACF;AACF;AAMO,IAAM,SAAA,GAAY;AAAA,EACvB,IAAA,EAAM,CAAA;AAAA,EACN,EAAA,EAAI,CAAA;AAAA,EACJ,EAAA,EAAI,CAAA;AAAA,EACJ,EAAA,EAAI,CAAA;AAAA,EACJ,EAAA,EAAI,CAAA;AAAA,EACJ,EAAA,EAAI;AACN","file":"index.cjs","sourcesContent":["import type {\n WidgetType,\n WidgetSchema,\n AlignOptions,\n ColorOptions,\n SectionLayoutType,\n StrictOmit,\n} from \"../types\";\n\n/**\n * Tab configuration for organizing properties\n */\nexport interface TabConfig {\n /** Unique identifier for the tab */\n id: string;\n /** Display label for the tab */\n label: string;\n}\n\n// ============================================================================\n// Property Field Types - Derive from constant for single source of truth\n// ============================================================================\n\n/**\n * Property field type constant - single source of truth for field types.\n * Use PROPERTY_FIELD_TYPES.text instead of \"text\" for type-safe comparisons.\n */\nexport const PROPERTY_FIELD_TYPES = {\n text: \"text\",\n textarea: \"textarea\",\n number: \"number\",\n boolean: \"boolean\",\n select: \"select\",\n color: \"color\",\n range: \"range\",\n dataSource: \"dataSource\",\n resource: \"resource\",\n alignment: \"alignment\",\n slider: \"slider\",\n colorPicker: \"colorPicker\",\n sectionHeader: \"sectionHeader\",\n separator: \"separator\",\n buttonGroup: \"buttonGroup\",\n colorSelect: \"colorSelect\",\n sectionLayoutSelect: \"sectionLayoutSelect\",\n background: \"background\",\n contentPosition: \"contentPosition\",\n} as const;\n\n/**\n * Union type of all property field types, derived from PROPERTY_FIELD_TYPES constant.\n * @see deriving-typeof-for-object-keys pattern\n */\nexport type PropertyFieldType =\n (typeof PROPERTY_FIELD_TYPES)[keyof typeof PROPERTY_FIELD_TYPES];\n\n/**\n * Runtime validation for property field types.\n * @param value - The value to check\n * @returns true if value is a valid PropertyFieldType\n */\nexport function isPropertyFieldType(value: string): value is PropertyFieldType {\n return Object.values(PROPERTY_FIELD_TYPES).includes(\n value as PropertyFieldType,\n );\n}\n\n/**\n * Base schema for a property field\n */\nexport interface PropertyFieldSchema {\n /** Property key in the widget props */\n key: string;\n /** Display label for the field */\n label: string;\n /** Field type determines the input control */\n type: PropertyFieldType;\n /** Optional description/help text */\n description?: string;\n /** Optional default value */\n defaultValue?: unknown;\n /** Optional tab ID (must match a TabConfig id if widget has tabsConfig) */\n tab?: string;\n /** Optional group for organizing fields within a tab */\n group?: string;\n /**\n * @deprecated Use requiresKeyValue instead\n */\n requiresKeyToBeTrue?: string;\n /** Optional requires a specific key to have a specific value */\n requiresKeyValue?: { key: string; value: unknown };\n}\n\n/**\n * Text field schema\n */\nexport interface TextFieldSchema extends PropertyFieldSchema {\n type: \"text\";\n placeholder?: string;\n maxLength?: number;\n}\n\n/**\n * Textarea field schema\n */\nexport interface TextareaFieldSchema extends PropertyFieldSchema {\n type: \"textarea\";\n placeholder?: string;\n rows?: number;\n maxLength?: number;\n}\n\n/**\n * Number field schema\n */\nexport interface NumberFieldSchema extends PropertyFieldSchema {\n type: \"number\";\n min?: number;\n max?: number;\n step?: number;\n}\n\n/**\n * Boolean field schema\n */\nexport interface BooleanFieldSchema extends PropertyFieldSchema {\n type: \"boolean\";\n}\n\n/**\n * Select field schema with type-safe option values.\n * Uses StrictOmit to ensure \"defaultValue\" key exists on PropertyFieldSchema.\n */\nexport interface SelectFieldSchema<T extends string | number = string | number>\n extends StrictOmit<PropertyFieldSchema, \"defaultValue\"> {\n type: \"select\";\n options: Array<{ label: string; value: T }>;\n defaultValue?: T;\n}\n\n/**\n * Color field schema\n */\nexport interface ColorFieldSchema extends PropertyFieldSchema {\n type: \"color\";\n}\n\n/**\n * Range slider field schema\n */\nexport interface RangeFieldSchema extends PropertyFieldSchema {\n type: \"range\";\n min: number;\n max: number;\n step?: number;\n}\n\n/**\n * Data source field schema for configuring widget data sources\n */\nexport interface DataSourceFieldSchema extends PropertyFieldSchema {\n type: \"dataSource\";\n}\n\n/**\n * Resource field schema for selecting a single resource from the selection modal\n */\nexport interface ResourceFieldSchema extends PropertyFieldSchema {\n type: \"resource\";\n /** Optional filter to specific shareable types */\n allowedTypes?: string[];\n}\n\n/**\n * Alignment field schema\n */\nexport interface AlignmentFieldSchema extends PropertyFieldSchema {\n type: \"alignment\";\n options: {\n verticalEnabled: boolean;\n horizontalEnabled: boolean;\n };\n defaultValue?: AlignOptions;\n}\n\n/**\n * Slider field schema with optional unit suffix (e.g., \"rem\", \"px\")\n */\nexport interface SliderFieldSchema extends PropertyFieldSchema {\n type: \"slider\";\n min: number;\n max: number;\n step?: number;\n unit?: string;\n}\n\n/**\n * Color picker field schema with optional swatches\n */\nexport interface ColorPickerFieldSchema extends PropertyFieldSchema {\n type: \"colorPicker\";\n swatches?: string[];\n}\n\n/**\n * Section header field schema for visual grouping\n */\nexport interface SectionHeaderFieldSchema extends PropertyFieldSchema {\n type: \"sectionHeader\";\n subtitle?: string;\n}\n\n/**\n * Separator field schema for visual separation\n */\nexport interface SeparatorFieldSchema extends PropertyFieldSchema {\n type: \"separator\";\n}\n\n/**\n * Button group field schema.\n * Uses StrictOmit to ensure \"defaultValue\" key exists on PropertyFieldSchema.\n */\nexport interface ButtonGroupFieldSchema<\n T extends string | number = string | number,\n> extends StrictOmit<PropertyFieldSchema, \"defaultValue\"> {\n type: \"buttonGroup\";\n options: Array<{ label: string; value: T }>;\n defaultValue?: T;\n}\n\n/**\n * Color select field schema\n */\nexport interface ColorSelectFieldSchema extends PropertyFieldSchema {\n type: \"colorSelect\";\n defaultValue?: ColorOptions;\n}\n\n/**\n * Section layout select field schema for visual masonry layout selector\n */\nexport interface SectionLayoutSelectFieldSchema extends PropertyFieldSchema {\n type: \"sectionLayoutSelect\";\n defaultValue?: SectionLayoutType;\n}\n\n/**\n * Background field combines resource selection and color properties.\n * Uses StrictOmit to exclude conflicting \"type\" discriminant from parents.\n */\nexport interface BackgroundFieldSchema\n extends StrictOmit<ResourceFieldSchema, \"type\">,\n StrictOmit<ColorFieldSchema, \"type\"> {\n type: \"background\";\n}\n\n/**\n * Content position field schema for 3x3 grid position picker\n */\nexport interface ContentPositionFieldSchema extends PropertyFieldSchema {\n type: \"contentPosition\";\n defaultValue?: string;\n}\n\n/**\n * Union of all field schema types\n */\nexport type PropertyField =\n | TextFieldSchema\n | TextareaFieldSchema\n | NumberFieldSchema\n | BooleanFieldSchema\n | SelectFieldSchema<string | number>\n | ColorFieldSchema\n | RangeFieldSchema\n | DataSourceFieldSchema\n | ResourceFieldSchema\n | AlignmentFieldSchema\n | SliderFieldSchema\n | ColorPickerFieldSchema\n | SectionHeaderFieldSchema\n | SeparatorFieldSchema\n | ButtonGroupFieldSchema<string | number>\n | ColorSelectFieldSchema\n | SectionLayoutSelectFieldSchema\n | BackgroundFieldSchema\n | ContentPositionFieldSchema;\n\n/**\n * Schema for per-item configuration in custom data sources.\n * Widgets can define this to allow users to configure widget-specific\n * settings for each selected item (e.g., title, description, button).\n */\nexport interface ItemConfigSchema {\n /** Fields available for per-item configuration */\n fields: PropertyField[];\n /** Optional description shown at top of item config panel */\n description?: string;\n}\n\n/**\n * Schema for a widget's editable properties\n */\nexport interface WidgetPropertySchema {\n /** Widget type this schema applies to */\n widgetType: WidgetType;\n /** Display name for the widget */\n displayName: string;\n /** Optional tab configuration - if present, tabs are enabled */\n tabsConfig?: TabConfig[];\n /** Editable property fields */\n fields: PropertyField[];\n /** Optional custom validator function */\n validate?: (props: Record<string, unknown>) => string | null;\n /** Props that can be populated from data sources */\n dataSourceTargetProps?: string[];\n /** Optional schema for per-item configurations in custom data sources */\n itemConfigSchema?: ItemConfigSchema;\n}\n\n/**\n * Registry mapping widget types to their property schemas\n */\nexport type PropertySchemaRegistry = Record<WidgetType, WidgetPropertySchema>;\n\n/**\n * Group property fields by their group property\n */\nexport function groupPropertyFields(\n fields: readonly PropertyField[],\n): Record<string, PropertyField[]> {\n const grouped: Record<string, PropertyField[]> = {};\n\n fields.forEach((field) => {\n const group = field.group || \"General\";\n if (!grouped[group]) {\n grouped[group] = [];\n }\n grouped[group].push(field);\n });\n\n return grouped;\n}\n\n/**\n * Extract current values from widget props based on property fields\n */\nexport function extractPropertyValues(\n widget: Readonly<WidgetSchema>,\n fields: readonly PropertyField[],\n): Record<string, unknown> {\n const values: Record<string, unknown> = {};\n\n fields.forEach((field) => {\n const value = widget.props[field.key];\n values[field.key] = value !== undefined ? value : field.defaultValue;\n });\n\n return values;\n}\n\n/**\n * Apply property values to widget props\n */\nexport function applyPropertyValues(\n widget: Readonly<WidgetSchema>,\n values: Readonly<Record<string, unknown>>,\n): WidgetSchema {\n return {\n ...widget,\n props: {\n ...widget.props,\n ...values,\n },\n };\n}\n","import type {\n ButtonGroupFieldSchema,\n ColorSelectFieldSchema,\n SelectFieldSchema,\n} from \"./property-schema-types\";\nimport type {\n BorderRadiusOptions,\n FontSizeOptions,\n PaddingOptions,\n ButtonSizeOptions,\n GapOptions,\n} from \"../types\";\n\nexport const getColorField = (\n props: Readonly<Omit<ColorSelectFieldSchema, \"type\">>,\n): ColorSelectFieldSchema => {\n return {\n ...props,\n type: \"colorSelect\",\n };\n};\n\nexport const getBorderRadiusField = (\n props: Readonly<\n Omit<ButtonGroupFieldSchema<BorderRadiusOptions>, \"options\" | \"type\">\n >,\n): ButtonGroupFieldSchema<BorderRadiusOptions> => {\n return {\n ...props,\n type: \"buttonGroup\",\n options: [\n { label: \"None\", value: \"none\" },\n { label: \"SM\", value: \"sm\" },\n { label: \"MD\", value: \"md\" },\n { label: \"LG\", value: \"lg\" },\n { label: \"XL\", value: \"xl\" },\n { label: \"FULL\", value: \"full\" },\n ],\n };\n};\n\nexport const getPaddingField = (\n props: Readonly<\n Omit<ButtonGroupFieldSchema<PaddingOptions>, \"options\" | \"type\">\n >,\n): ButtonGroupFieldSchema<PaddingOptions> => {\n return {\n ...props,\n type: \"buttonGroup\",\n options: [\n { label: \"None\", value: 0 },\n { label: \"SM\", value: 2 },\n { label: \"MD\", value: 4 },\n { label: \"LG\", value: 6 },\n { label: \"XL\", value: 8 },\n { label: \"FULL\", value: 10 },\n ],\n };\n};\n\nexport const getButtonSizeField = (\n props: Readonly<\n Omit<ButtonGroupFieldSchema<ButtonSizeOptions>, \"options\" | \"type\">\n >,\n): ButtonGroupFieldSchema<ButtonSizeOptions> => {\n return {\n ...props,\n type: \"buttonGroup\",\n options: [\n { label: \"SM\", value: \"sm\" },\n { label: \"MD\", value: \"default\" },\n { label: \"LG\", value: \"lg\" },\n { label: \"XL\", value: \"xl\" },\n ],\n };\n};\n\nexport const getFontSizeField = (\n props: Readonly<Omit<SelectFieldSchema<FontSizeOptions>, \"options\" | \"type\">>,\n): SelectFieldSchema<FontSizeOptions> => {\n return {\n ...props,\n type: \"select\",\n options: [\n { label: \"Giant\", value: \"2xl\" },\n { label: \"Extra Large\", value: \"xl\" },\n { label: \"Large\", value: \"lg\" },\n { label: \"Regular\", value: \"md\" },\n { label: \"Small\", value: \"sm\" },\n { label: \"Extra Small\", value: \"xs\" },\n ],\n };\n};\n\nexport const getGapField = (\n props: Readonly<Omit<ButtonGroupFieldSchema<GapOptions>, \"options\" | \"type\">>,\n): ButtonGroupFieldSchema<GapOptions> => {\n return {\n ...props,\n type: \"buttonGroup\",\n options: [\n { label: \"None\", value: \"none\" },\n { label: \"XS\", value: \"xs\" },\n { label: \"SM\", value: \"sm\" },\n { label: \"MD\", value: \"md\" },\n { label: \"LG\", value: \"lg\" },\n { label: \"XL\", value: \"xl\" },\n ],\n };\n};\n\n/**\n * Gap value mapping - use `as const satisfies` for compile-time validation\n * with literal type preservation.\n */\nexport const gapValues = {\n none: 0,\n xs: 1,\n sm: 2,\n md: 4,\n lg: 6,\n xl: 8,\n} as const satisfies Record<GapOptions, number>;\n"]}
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { StrictOmit, AlignOptions, ColorOptions, SectionLayoutType, BorderRadiusOptions, PaddingOptions, ButtonSizeOptions, FontSizeOptions, GapOptions } from '../types/index.cjs';
|
|
2
|
+
import { b as WidgetType, a as WidgetSchema } from '../shareable-item-DPmNZkE1.cjs';
|
|
3
|
+
import '../theme-DrMUYZTO.cjs';
|
|
4
|
+
import 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Tab configuration for organizing properties
|
|
8
|
+
*/
|
|
9
|
+
interface TabConfig {
|
|
10
|
+
/** Unique identifier for the tab */
|
|
11
|
+
id: string;
|
|
12
|
+
/** Display label for the tab */
|
|
13
|
+
label: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Property field type constant - single source of truth for field types.
|
|
17
|
+
* Use PROPERTY_FIELD_TYPES.text instead of "text" for type-safe comparisons.
|
|
18
|
+
*/
|
|
19
|
+
declare const PROPERTY_FIELD_TYPES: {
|
|
20
|
+
readonly text: "text";
|
|
21
|
+
readonly textarea: "textarea";
|
|
22
|
+
readonly number: "number";
|
|
23
|
+
readonly boolean: "boolean";
|
|
24
|
+
readonly select: "select";
|
|
25
|
+
readonly color: "color";
|
|
26
|
+
readonly range: "range";
|
|
27
|
+
readonly dataSource: "dataSource";
|
|
28
|
+
readonly resource: "resource";
|
|
29
|
+
readonly alignment: "alignment";
|
|
30
|
+
readonly slider: "slider";
|
|
31
|
+
readonly colorPicker: "colorPicker";
|
|
32
|
+
readonly sectionHeader: "sectionHeader";
|
|
33
|
+
readonly separator: "separator";
|
|
34
|
+
readonly buttonGroup: "buttonGroup";
|
|
35
|
+
readonly colorSelect: "colorSelect";
|
|
36
|
+
readonly sectionLayoutSelect: "sectionLayoutSelect";
|
|
37
|
+
readonly background: "background";
|
|
38
|
+
readonly contentPosition: "contentPosition";
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Union type of all property field types, derived from PROPERTY_FIELD_TYPES constant.
|
|
42
|
+
* @see deriving-typeof-for-object-keys pattern
|
|
43
|
+
*/
|
|
44
|
+
type PropertyFieldType = (typeof PROPERTY_FIELD_TYPES)[keyof typeof PROPERTY_FIELD_TYPES];
|
|
45
|
+
/**
|
|
46
|
+
* Runtime validation for property field types.
|
|
47
|
+
* @param value - The value to check
|
|
48
|
+
* @returns true if value is a valid PropertyFieldType
|
|
49
|
+
*/
|
|
50
|
+
declare function isPropertyFieldType(value: string): value is PropertyFieldType;
|
|
51
|
+
/**
|
|
52
|
+
* Base schema for a property field
|
|
53
|
+
*/
|
|
54
|
+
interface PropertyFieldSchema {
|
|
55
|
+
/** Property key in the widget props */
|
|
56
|
+
key: string;
|
|
57
|
+
/** Display label for the field */
|
|
58
|
+
label: string;
|
|
59
|
+
/** Field type determines the input control */
|
|
60
|
+
type: PropertyFieldType;
|
|
61
|
+
/** Optional description/help text */
|
|
62
|
+
description?: string;
|
|
63
|
+
/** Optional default value */
|
|
64
|
+
defaultValue?: unknown;
|
|
65
|
+
/** Optional tab ID (must match a TabConfig id if widget has tabsConfig) */
|
|
66
|
+
tab?: string;
|
|
67
|
+
/** Optional group for organizing fields within a tab */
|
|
68
|
+
group?: string;
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated Use requiresKeyValue instead
|
|
71
|
+
*/
|
|
72
|
+
requiresKeyToBeTrue?: string;
|
|
73
|
+
/** Optional requires a specific key to have a specific value */
|
|
74
|
+
requiresKeyValue?: {
|
|
75
|
+
key: string;
|
|
76
|
+
value: unknown;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Text field schema
|
|
81
|
+
*/
|
|
82
|
+
interface TextFieldSchema extends PropertyFieldSchema {
|
|
83
|
+
type: "text";
|
|
84
|
+
placeholder?: string;
|
|
85
|
+
maxLength?: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Textarea field schema
|
|
89
|
+
*/
|
|
90
|
+
interface TextareaFieldSchema extends PropertyFieldSchema {
|
|
91
|
+
type: "textarea";
|
|
92
|
+
placeholder?: string;
|
|
93
|
+
rows?: number;
|
|
94
|
+
maxLength?: number;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Number field schema
|
|
98
|
+
*/
|
|
99
|
+
interface NumberFieldSchema extends PropertyFieldSchema {
|
|
100
|
+
type: "number";
|
|
101
|
+
min?: number;
|
|
102
|
+
max?: number;
|
|
103
|
+
step?: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Boolean field schema
|
|
107
|
+
*/
|
|
108
|
+
interface BooleanFieldSchema extends PropertyFieldSchema {
|
|
109
|
+
type: "boolean";
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Select field schema with type-safe option values.
|
|
113
|
+
* Uses StrictOmit to ensure "defaultValue" key exists on PropertyFieldSchema.
|
|
114
|
+
*/
|
|
115
|
+
interface SelectFieldSchema<T extends string | number = string | number> extends StrictOmit<PropertyFieldSchema, "defaultValue"> {
|
|
116
|
+
type: "select";
|
|
117
|
+
options: Array<{
|
|
118
|
+
label: string;
|
|
119
|
+
value: T;
|
|
120
|
+
}>;
|
|
121
|
+
defaultValue?: T;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Color field schema
|
|
125
|
+
*/
|
|
126
|
+
interface ColorFieldSchema extends PropertyFieldSchema {
|
|
127
|
+
type: "color";
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Range slider field schema
|
|
131
|
+
*/
|
|
132
|
+
interface RangeFieldSchema extends PropertyFieldSchema {
|
|
133
|
+
type: "range";
|
|
134
|
+
min: number;
|
|
135
|
+
max: number;
|
|
136
|
+
step?: number;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Data source field schema for configuring widget data sources
|
|
140
|
+
*/
|
|
141
|
+
interface DataSourceFieldSchema extends PropertyFieldSchema {
|
|
142
|
+
type: "dataSource";
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Resource field schema for selecting a single resource from the selection modal
|
|
146
|
+
*/
|
|
147
|
+
interface ResourceFieldSchema extends PropertyFieldSchema {
|
|
148
|
+
type: "resource";
|
|
149
|
+
/** Optional filter to specific shareable types */
|
|
150
|
+
allowedTypes?: string[];
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Alignment field schema
|
|
154
|
+
*/
|
|
155
|
+
interface AlignmentFieldSchema extends PropertyFieldSchema {
|
|
156
|
+
type: "alignment";
|
|
157
|
+
options: {
|
|
158
|
+
verticalEnabled: boolean;
|
|
159
|
+
horizontalEnabled: boolean;
|
|
160
|
+
};
|
|
161
|
+
defaultValue?: AlignOptions;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Slider field schema with optional unit suffix (e.g., "rem", "px")
|
|
165
|
+
*/
|
|
166
|
+
interface SliderFieldSchema extends PropertyFieldSchema {
|
|
167
|
+
type: "slider";
|
|
168
|
+
min: number;
|
|
169
|
+
max: number;
|
|
170
|
+
step?: number;
|
|
171
|
+
unit?: string;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Color picker field schema with optional swatches
|
|
175
|
+
*/
|
|
176
|
+
interface ColorPickerFieldSchema extends PropertyFieldSchema {
|
|
177
|
+
type: "colorPicker";
|
|
178
|
+
swatches?: string[];
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Section header field schema for visual grouping
|
|
182
|
+
*/
|
|
183
|
+
interface SectionHeaderFieldSchema extends PropertyFieldSchema {
|
|
184
|
+
type: "sectionHeader";
|
|
185
|
+
subtitle?: string;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Separator field schema for visual separation
|
|
189
|
+
*/
|
|
190
|
+
interface SeparatorFieldSchema extends PropertyFieldSchema {
|
|
191
|
+
type: "separator";
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Button group field schema.
|
|
195
|
+
* Uses StrictOmit to ensure "defaultValue" key exists on PropertyFieldSchema.
|
|
196
|
+
*/
|
|
197
|
+
interface ButtonGroupFieldSchema<T extends string | number = string | number> extends StrictOmit<PropertyFieldSchema, "defaultValue"> {
|
|
198
|
+
type: "buttonGroup";
|
|
199
|
+
options: Array<{
|
|
200
|
+
label: string;
|
|
201
|
+
value: T;
|
|
202
|
+
}>;
|
|
203
|
+
defaultValue?: T;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Color select field schema
|
|
207
|
+
*/
|
|
208
|
+
interface ColorSelectFieldSchema extends PropertyFieldSchema {
|
|
209
|
+
type: "colorSelect";
|
|
210
|
+
defaultValue?: ColorOptions;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Section layout select field schema for visual masonry layout selector
|
|
214
|
+
*/
|
|
215
|
+
interface SectionLayoutSelectFieldSchema extends PropertyFieldSchema {
|
|
216
|
+
type: "sectionLayoutSelect";
|
|
217
|
+
defaultValue?: SectionLayoutType;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Background field combines resource selection and color properties.
|
|
221
|
+
* Uses StrictOmit to exclude conflicting "type" discriminant from parents.
|
|
222
|
+
*/
|
|
223
|
+
interface BackgroundFieldSchema extends StrictOmit<ResourceFieldSchema, "type">, StrictOmit<ColorFieldSchema, "type"> {
|
|
224
|
+
type: "background";
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Content position field schema for 3x3 grid position picker
|
|
228
|
+
*/
|
|
229
|
+
interface ContentPositionFieldSchema extends PropertyFieldSchema {
|
|
230
|
+
type: "contentPosition";
|
|
231
|
+
defaultValue?: string;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Union of all field schema types
|
|
235
|
+
*/
|
|
236
|
+
type PropertyField = TextFieldSchema | TextareaFieldSchema | NumberFieldSchema | BooleanFieldSchema | SelectFieldSchema<string | number> | ColorFieldSchema | RangeFieldSchema | DataSourceFieldSchema | ResourceFieldSchema | AlignmentFieldSchema | SliderFieldSchema | ColorPickerFieldSchema | SectionHeaderFieldSchema | SeparatorFieldSchema | ButtonGroupFieldSchema<string | number> | ColorSelectFieldSchema | SectionLayoutSelectFieldSchema | BackgroundFieldSchema | ContentPositionFieldSchema;
|
|
237
|
+
/**
|
|
238
|
+
* Schema for per-item configuration in custom data sources.
|
|
239
|
+
* Widgets can define this to allow users to configure widget-specific
|
|
240
|
+
* settings for each selected item (e.g., title, description, button).
|
|
241
|
+
*/
|
|
242
|
+
interface ItemConfigSchema {
|
|
243
|
+
/** Fields available for per-item configuration */
|
|
244
|
+
fields: PropertyField[];
|
|
245
|
+
/** Optional description shown at top of item config panel */
|
|
246
|
+
description?: string;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Schema for a widget's editable properties
|
|
250
|
+
*/
|
|
251
|
+
interface WidgetPropertySchema {
|
|
252
|
+
/** Widget type this schema applies to */
|
|
253
|
+
widgetType: WidgetType;
|
|
254
|
+
/** Display name for the widget */
|
|
255
|
+
displayName: string;
|
|
256
|
+
/** Optional tab configuration - if present, tabs are enabled */
|
|
257
|
+
tabsConfig?: TabConfig[];
|
|
258
|
+
/** Editable property fields */
|
|
259
|
+
fields: PropertyField[];
|
|
260
|
+
/** Optional custom validator function */
|
|
261
|
+
validate?: (props: Record<string, unknown>) => string | null;
|
|
262
|
+
/** Props that can be populated from data sources */
|
|
263
|
+
dataSourceTargetProps?: string[];
|
|
264
|
+
/** Optional schema for per-item configurations in custom data sources */
|
|
265
|
+
itemConfigSchema?: ItemConfigSchema;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Registry mapping widget types to their property schemas
|
|
269
|
+
*/
|
|
270
|
+
type PropertySchemaRegistry = Record<WidgetType, WidgetPropertySchema>;
|
|
271
|
+
/**
|
|
272
|
+
* Group property fields by their group property
|
|
273
|
+
*/
|
|
274
|
+
declare function groupPropertyFields(fields: readonly PropertyField[]): Record<string, PropertyField[]>;
|
|
275
|
+
/**
|
|
276
|
+
* Extract current values from widget props based on property fields
|
|
277
|
+
*/
|
|
278
|
+
declare function extractPropertyValues(widget: Readonly<WidgetSchema>, fields: readonly PropertyField[]): Record<string, unknown>;
|
|
279
|
+
/**
|
|
280
|
+
* Apply property values to widget props
|
|
281
|
+
*/
|
|
282
|
+
declare function applyPropertyValues(widget: Readonly<WidgetSchema>, values: Readonly<Record<string, unknown>>): WidgetSchema;
|
|
283
|
+
|
|
284
|
+
declare const getColorField: (props: Readonly<Omit<ColorSelectFieldSchema, "type">>) => ColorSelectFieldSchema;
|
|
285
|
+
declare const getBorderRadiusField: (props: Readonly<Omit<ButtonGroupFieldSchema<BorderRadiusOptions>, "options" | "type">>) => ButtonGroupFieldSchema<BorderRadiusOptions>;
|
|
286
|
+
declare const getPaddingField: (props: Readonly<Omit<ButtonGroupFieldSchema<PaddingOptions>, "options" | "type">>) => ButtonGroupFieldSchema<PaddingOptions>;
|
|
287
|
+
declare const getButtonSizeField: (props: Readonly<Omit<ButtonGroupFieldSchema<ButtonSizeOptions>, "options" | "type">>) => ButtonGroupFieldSchema<ButtonSizeOptions>;
|
|
288
|
+
declare const getFontSizeField: (props: Readonly<Omit<SelectFieldSchema<FontSizeOptions>, "options" | "type">>) => SelectFieldSchema<FontSizeOptions>;
|
|
289
|
+
declare const getGapField: (props: Readonly<Omit<ButtonGroupFieldSchema<GapOptions>, "options" | "type">>) => ButtonGroupFieldSchema<GapOptions>;
|
|
290
|
+
/**
|
|
291
|
+
* Gap value mapping - use `as const satisfies` for compile-time validation
|
|
292
|
+
* with literal type preservation.
|
|
293
|
+
*/
|
|
294
|
+
declare const gapValues: {
|
|
295
|
+
readonly none: 0;
|
|
296
|
+
readonly xs: 1;
|
|
297
|
+
readonly sm: 2;
|
|
298
|
+
readonly md: 4;
|
|
299
|
+
readonly lg: 6;
|
|
300
|
+
readonly xl: 8;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
export { type AlignmentFieldSchema, type BackgroundFieldSchema, type BooleanFieldSchema, type ButtonGroupFieldSchema, type ColorFieldSchema, type ColorPickerFieldSchema, type ColorSelectFieldSchema, type ContentPositionFieldSchema, type DataSourceFieldSchema, type ItemConfigSchema, type NumberFieldSchema, PROPERTY_FIELD_TYPES, type PropertyField, type PropertyFieldSchema, type PropertyFieldType, type PropertySchemaRegistry, type RangeFieldSchema, type ResourceFieldSchema, type SectionHeaderFieldSchema, type SectionLayoutSelectFieldSchema, type SelectFieldSchema, type SeparatorFieldSchema, type SliderFieldSchema, type TabConfig, type TextFieldSchema, type TextareaFieldSchema, type WidgetPropertySchema, applyPropertyValues, extractPropertyValues, gapValues, getBorderRadiusField, getButtonSizeField, getColorField, getFontSizeField, getGapField, getPaddingField, groupPropertyFields, isPropertyFieldType };
|