@blocklet/pages-kit 0.6.17 → 0.6.19
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/lib/cjs/builtin/color-picker.js +135 -87
- package/lib/cjs/builtin/zod.js +83 -0
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/builtin.js +2 -0
- package/lib/cjs/utils/inject-global-components.js +2 -0
- package/lib/cjs/utils/style.js +7 -1
- package/lib/esm/builtin/color-picker.js +135 -87
- package/lib/esm/builtin/zod.js +54 -0
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/utils/builtin.js +2 -0
- package/lib/esm/utils/inject-global-components.js +2 -0
- package/lib/esm/utils/style.js +7 -1
- package/lib/types/builtin/color-picker.d.ts +14 -3
- package/lib/types/builtin/zod.d.ts +269 -0
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/lib/types/types/style.d.ts +4 -1
- package/lib/types/utils/builtin.d.ts +2 -0
- package/package.json +6 -5
|
@@ -153,7 +153,82 @@ function ColorItem({ color, sx = {}, ...props }) {
|
|
|
153
153
|
...styleMap,
|
|
154
154
|
}, ...props }));
|
|
155
155
|
}
|
|
156
|
-
|
|
156
|
+
// MUI Theme Tab Component
|
|
157
|
+
const MuiThemeTab = ({ value, onChange, }) => {
|
|
158
|
+
const { t } = (0, context_1.useLocaleContext)();
|
|
159
|
+
const muiPalette = (0, color_1.useMuiColorPalette)();
|
|
160
|
+
const mode = muiPalette?.theme?.palette?.mode;
|
|
161
|
+
const isDark = mode === 'dark';
|
|
162
|
+
const { groupedMuiColors } = muiPalette;
|
|
163
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { height: HEIGHT }, children: [(0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "info", sx: { mb: 1.5, mr: -1.5, py: 0, px: 1.5 }, children: t('maker.configColorMuiThemeInfo') }), Object.entries(groupedMuiColors).map(([palette, paletteColors]) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { pb: 1.5 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle2", gutterBottom: true, sx: { textTransform: 'capitalize', mb: 0.5, lineHeight: 1 }, children: palette }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: 1 }, children: paletteColors.map((item) => {
|
|
164
|
+
let selectedColor = '';
|
|
165
|
+
if (value?.originalMuiKey === item.colorKey) {
|
|
166
|
+
if (item.colorValue === 'transparent') {
|
|
167
|
+
selectedColor = 'rgba(0,0,0,0.7)';
|
|
168
|
+
}
|
|
169
|
+
else if ((0, tinycolor2_1.default)(item.colorValue).isDark()) {
|
|
170
|
+
selectedColor = 'rgba(255,255,255,0.8)';
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
selectedColor = 'rgba(0,0,0,0.7)';
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// 是否有另一种模式的颜色值
|
|
177
|
+
const hasAlternateColor = !!item.alternateColorValue;
|
|
178
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: `${item.colorKey}${hasAlternateColor ? t('maker.configColorMuiThemeWithAlternateColor') : ''}`, sx: {
|
|
179
|
+
zIndex: 99999,
|
|
180
|
+
}, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { onClick: () => {
|
|
181
|
+
onChange({
|
|
182
|
+
value: item.colorValue,
|
|
183
|
+
originalMuiKey: item.colorKey,
|
|
184
|
+
});
|
|
185
|
+
}, sx: {
|
|
186
|
+
width: 32,
|
|
187
|
+
height: 32,
|
|
188
|
+
border: value?.originalMuiKey === item.colorKey
|
|
189
|
+
? `2px solid ${isDark ? 'rgba(255,255,255,0.8)' : 'rgba(0,0,0,0.7)'}`
|
|
190
|
+
: '1px solid #ccc',
|
|
191
|
+
borderRadius: 0.5,
|
|
192
|
+
cursor: 'pointer',
|
|
193
|
+
'&:hover': { opacity: 0.8 },
|
|
194
|
+
display: 'flex',
|
|
195
|
+
alignItems: 'center',
|
|
196
|
+
justifyContent: 'center',
|
|
197
|
+
position: 'relative',
|
|
198
|
+
overflow: 'hidden',
|
|
199
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
200
|
+
position: 'absolute',
|
|
201
|
+
top: 0,
|
|
202
|
+
right: 0,
|
|
203
|
+
bottom: 0,
|
|
204
|
+
left: 0,
|
|
205
|
+
...(item.colorValue === 'transparent'
|
|
206
|
+
? { background: (0, style_1.getTransparentBackground)() }
|
|
207
|
+
: { backgroundColor: item.colorValue }),
|
|
208
|
+
} }), hasAlternateColor && (0, jsx_runtime_1.jsx)(AlternateColorIndicator, { value: item.alternateColorValue }), value?.originalMuiKey === item.colorKey && ((0, jsx_runtime_1.jsx)("i", { className: "i-mdi:check", style: {
|
|
209
|
+
color: selectedColor,
|
|
210
|
+
fontSize: '1.2rem',
|
|
211
|
+
position: 'relative',
|
|
212
|
+
zIndex: 2,
|
|
213
|
+
} }))] }) }, item.colorKey));
|
|
214
|
+
}) })] }, palette)))] }));
|
|
215
|
+
};
|
|
216
|
+
// Custom Color Tab Component
|
|
217
|
+
const CustomColorTab = ({ value, onChange, }) => {
|
|
218
|
+
const muiPalette = (0, color_1.useMuiColorPalette)();
|
|
219
|
+
const mode = muiPalette?.theme?.palette?.mode;
|
|
220
|
+
const isDark = mode === 'dark';
|
|
221
|
+
const colorValue = value?.value && typeof value.value === 'string' ? value.value : '';
|
|
222
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { overflowY: 'auto', overflowX: 'hidden' }, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "rectangular", width: WIDTH, height: HEIGHT }), children: (0, jsx_runtime_1.jsx)(ColorPickerLib, { disableDarkMode: !isDark, disableLightMode: isDark, width: WIDTH,
|
|
223
|
+
// menu color picker height
|
|
224
|
+
height: WIDTH, value: colorValue, onChange: (colorValue) => {
|
|
225
|
+
onChange({
|
|
226
|
+
value: colorValue,
|
|
227
|
+
originalMuiKey: null,
|
|
228
|
+
});
|
|
229
|
+
}, hidePresets: true, hideAdvancedSliders: true, hideColorGuide: true, hideInputType: true }) }) }));
|
|
230
|
+
};
|
|
231
|
+
const ConfigColorDialog = function ConfigColorDialog({ ref, onSave, enableMuiPalette = true, renderTabs, }) {
|
|
157
232
|
const state = (0, ahooks_1.useReactive)({
|
|
158
233
|
value: '',
|
|
159
234
|
originalMuiKey: null,
|
|
@@ -165,6 +240,35 @@ const ConfigColorDialog = function ConfigColorDialog({ ref, onSave, enableMuiPal
|
|
|
165
240
|
const muiPalette = (0, color_1.useMuiColorPalette)();
|
|
166
241
|
const mode = muiPalette?.theme?.palette?.mode;
|
|
167
242
|
const isDark = mode === 'dark';
|
|
243
|
+
// Create default tabs
|
|
244
|
+
const defaultTabs = enableMuiPalette
|
|
245
|
+
? [
|
|
246
|
+
{
|
|
247
|
+
key: 'mui-theme',
|
|
248
|
+
label: t('maker.configColorMuiTheme') || 'Theme Color',
|
|
249
|
+
component: MuiThemeTab,
|
|
250
|
+
showPreview: true,
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
key: 'custom-color',
|
|
254
|
+
label: t('maker.configColorCustomColor') || 'Custom Color',
|
|
255
|
+
component: CustomColorTab,
|
|
256
|
+
showPreview: true,
|
|
257
|
+
},
|
|
258
|
+
]
|
|
259
|
+
: [
|
|
260
|
+
{
|
|
261
|
+
key: 'custom-color',
|
|
262
|
+
label: t('maker.configColorCustomColor') || 'Custom Color',
|
|
263
|
+
component: CustomColorTab,
|
|
264
|
+
showPreview: true,
|
|
265
|
+
},
|
|
266
|
+
];
|
|
267
|
+
// Use renderTabs function or fallback to default tabs
|
|
268
|
+
const allTabs = renderTabs ? renderTabs(defaultTabs) : defaultTabs;
|
|
269
|
+
// Get current active tab
|
|
270
|
+
const currentTab = allTabs[activeTab] || allTabs[0];
|
|
271
|
+
const CurrentTabComponent = currentTab?.component;
|
|
168
272
|
const previewStyle = {};
|
|
169
273
|
if (state.value) {
|
|
170
274
|
if ((0, style_1.isGradient)(state.value)) {
|
|
@@ -181,7 +285,7 @@ const ConfigColorDialog = function ConfigColorDialog({ ref, onSave, enableMuiPal
|
|
|
181
285
|
const handleClose = (0, react_1.useCallback)(() => {
|
|
182
286
|
setFalse();
|
|
183
287
|
}, [setFalse]);
|
|
184
|
-
const isActiveMuiTab =
|
|
288
|
+
const isActiveMuiTab = currentTab?.key === 'mui-theme';
|
|
185
289
|
(0, react_1.useImperativeHandle)(ref, () => {
|
|
186
290
|
return {
|
|
187
291
|
open({ value } = { value: '' }) {
|
|
@@ -190,16 +294,24 @@ const ConfigColorDialog = function ConfigColorDialog({ ref, onSave, enableMuiPal
|
|
|
190
294
|
state.originalMuiKey = value;
|
|
191
295
|
const colorValue = muiPalette.getColorByMuiKey(value);
|
|
192
296
|
state.value = (0, style_1.getSafeGradient)(colorValue || value);
|
|
193
|
-
// 如果是 MUI
|
|
194
|
-
|
|
297
|
+
// 如果是 MUI 颜色键,切换到 MUI Theme 标签
|
|
298
|
+
const muiTabIndex = allTabs.findIndex((tab) => tab.key === 'mui-theme');
|
|
299
|
+
if (muiTabIndex !== -1) {
|
|
300
|
+
setActiveTab(muiTabIndex);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
else if (typeof value === 'object' && value !== null && 'value' in value) {
|
|
304
|
+
const outerData = value;
|
|
305
|
+
state.value = outerData.value;
|
|
306
|
+
state.originalMuiKey = null;
|
|
195
307
|
}
|
|
196
308
|
else {
|
|
197
309
|
state.originalMuiKey = null;
|
|
198
310
|
state.value = (0, style_1.getSafeGradient)(value);
|
|
199
311
|
// 不自动切换标签,尊重用户上一次的选择
|
|
200
|
-
// 只有在 MUI
|
|
312
|
+
// 只有在 MUI 不可用时才强制切换到第一个
|
|
201
313
|
if (!enableMuiPalette) {
|
|
202
|
-
setActiveTab(
|
|
314
|
+
setActiveTab(0);
|
|
203
315
|
}
|
|
204
316
|
}
|
|
205
317
|
setTrue();
|
|
@@ -216,33 +328,17 @@ const ConfigColorDialog = function ConfigColorDialog({ ref, onSave, enableMuiPal
|
|
|
216
328
|
if (isActiveMuiTab) {
|
|
217
329
|
const muiKey = muiPalette.getMuiKeyByColor(state.value);
|
|
218
330
|
onSave({ value: muiKey || state.value }, handleClose);
|
|
219
|
-
|
|
220
|
-
else {
|
|
221
|
-
// 在自定义色彩标签页时,保持原始值
|
|
222
|
-
onSave({ value: state.value }, handleClose);
|
|
331
|
+
return;
|
|
223
332
|
}
|
|
224
333
|
}
|
|
225
|
-
|
|
226
|
-
onSave({ value: state.value }, handleClose);
|
|
227
|
-
}
|
|
334
|
+
onSave({ value: state.value }, handleClose);
|
|
228
335
|
};
|
|
229
|
-
// 直接从 hook 获取分组
|
|
230
|
-
const { groupedMuiColors } = muiPalette;
|
|
231
336
|
const rectWrapperBorder = `2px solid ${muiPalette?.theme?.palette?.divider}`;
|
|
232
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, { disableEnforceFocus: true, open: open, onClose: handleClose, children: [(0, jsx_runtime_1.jsxs)(material_1.DialogTitle, { sx: { display: 'flex', alignItems: 'center', justifyContent: 'space-between' }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "inherit", children: t('maker.configColor') }),
|
|
233
|
-
{
|
|
234
|
-
label: t('maker.configColorMuiTheme') || 'Theme Color',
|
|
235
|
-
value: 0,
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
label: t('maker.configColorCustomColor') || 'Custom Color',
|
|
239
|
-
value: 1,
|
|
240
|
-
},
|
|
241
|
-
].map((item) => ((0, jsx_runtime_1.jsx)(material_1.Button, { variant: activeTab === item.value ? 'contained' : 'outlined', onClick: () => setActiveTab(item.value), sx: {
|
|
337
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, { disableEnforceFocus: true, open: open, onClose: handleClose, children: [(0, jsx_runtime_1.jsxs)(material_1.DialogTitle, { sx: { display: 'flex', alignItems: 'center', justifyContent: 'space-between' }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "inherit", children: t('maker.configColor') }), allTabs.length > 1 && ((0, jsx_runtime_1.jsx)(material_1.ButtonGroup, { size: "small", "aria-label": "color mode selector", children: allTabs.map((tab, index) => ((0, jsx_runtime_1.jsx)(material_1.Button, { variant: activeTab === index ? 'contained' : 'outlined', onClick: () => setActiveTab(index), sx: {
|
|
242
338
|
fontWeight: 500,
|
|
243
339
|
textTransform: 'none',
|
|
244
340
|
minWidth: 'unset',
|
|
245
|
-
}, children:
|
|
341
|
+
}, children: tab.label }, tab.key))) }))] }), (0, jsx_runtime_1.jsxs)(material_1.DialogContent, { sx: { width: 600, display: 'flex', flexDirection: 'row', gap: 2, overflowX: 'hidden' }, children: [currentTab?.showPreview && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
246
342
|
...previewStyle,
|
|
247
343
|
flex: '0 0 270px',
|
|
248
344
|
borderRadius: 1,
|
|
@@ -275,72 +371,24 @@ const ConfigColorDialog = function ConfigColorDialog({ ref, onSave, enableMuiPal
|
|
|
275
371
|
} }), (0, jsx_runtime_1.jsx)(ThemeModeLabel, { mode: !isDark ? 'dark' : 'light', position: "bottom-right" })] }));
|
|
276
372
|
}
|
|
277
373
|
return null;
|
|
278
|
-
})() }))] }, "color-preview"), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { flex: 1 }, children:
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
else {
|
|
290
|
-
selectedColor = 'rgba(0,0,0,0.7)';
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
// 是否有另一种模式的颜色值
|
|
294
|
-
const hasAlternateColor = !!item.alternateColorValue;
|
|
295
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: `${item.colorKey}${hasAlternateColor ? t('maker.configColorMuiThemeWithAlternateColor') : ''}`, sx: {
|
|
296
|
-
zIndex: 99999,
|
|
297
|
-
}, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { onClick: () => {
|
|
298
|
-
state.value = item.colorValue;
|
|
299
|
-
state.originalMuiKey = item.colorKey;
|
|
300
|
-
}, sx: {
|
|
301
|
-
width: 32,
|
|
302
|
-
height: 32,
|
|
303
|
-
border: state.originalMuiKey === item.colorKey
|
|
304
|
-
? `2px solid ${isDark ? 'rgba(255,255,255,0.8)' : 'rgba(0,0,0,0.7)'}`
|
|
305
|
-
: '1px solid #ccc',
|
|
306
|
-
borderRadius: 0.5,
|
|
307
|
-
cursor: 'pointer',
|
|
308
|
-
'&:hover': { opacity: 0.8 },
|
|
309
|
-
display: 'flex',
|
|
310
|
-
alignItems: 'center',
|
|
311
|
-
justifyContent: 'center',
|
|
312
|
-
position: 'relative',
|
|
313
|
-
overflow: 'hidden',
|
|
314
|
-
}, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
315
|
-
position: 'absolute',
|
|
316
|
-
top: 0,
|
|
317
|
-
right: 0,
|
|
318
|
-
bottom: 0,
|
|
319
|
-
left: 0,
|
|
320
|
-
...(item.colorValue === 'transparent'
|
|
321
|
-
? { background: (0, style_1.getTransparentBackground)() }
|
|
322
|
-
: { backgroundColor: item.colorValue }),
|
|
323
|
-
} }), hasAlternateColor && (0, jsx_runtime_1.jsx)(AlternateColorIndicator, { value: item.alternateColorValue }), state.originalMuiKey === item.colorKey && ((0, jsx_runtime_1.jsx)("i", { className: "i-mdi:check", style: {
|
|
324
|
-
color: selectedColor,
|
|
325
|
-
fontSize: '1.2rem',
|
|
326
|
-
position: 'relative',
|
|
327
|
-
zIndex: 2,
|
|
328
|
-
} }))] }) }, item.colorKey));
|
|
329
|
-
}) })] }, palette)))] })) : (
|
|
330
|
-
// 自定义颜色选择器
|
|
331
|
-
(0, jsx_runtime_1.jsx)(material_1.Box, { sx: { overflowY: 'auto', overflowX: 'hidden' }, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "rectangular", width: WIDTH, height: HEIGHT }), children: (0, jsx_runtime_1.jsx)(ColorPickerLib, { disableDarkMode: !isDark, disableLightMode: isDark, width: WIDTH,
|
|
332
|
-
// menu color picker height
|
|
333
|
-
height: WIDTH, value: state.value, onChange: (value) => {
|
|
334
|
-
state.value = value;
|
|
335
|
-
state.originalMuiKey = null;
|
|
336
|
-
}, hidePresets: true, hideAdvancedSliders: true, hideColorGuide: true, hideInputType: true }) }) })) })] }), (0, jsx_runtime_1.jsxs)(material_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", size: "small", onClick: handleClose, children: t('common.cancel') }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", size: "small", onClick: handleSave, children: t('maker.save') })] })] }));
|
|
374
|
+
})() }))] }, "color-preview")), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { flex: 1 }, children: CurrentTabComponent && ((0, jsx_runtime_1.jsx)(CurrentTabComponent, { value: state, onChange: (value) => {
|
|
375
|
+
if (value && typeof value === 'object' && 'value' in value) {
|
|
376
|
+
state.value = value.value;
|
|
377
|
+
state.originalMuiKey = value.originalMuiKey || null;
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
// Handle simple string values for backward compatibility
|
|
381
|
+
state.value = value || '';
|
|
382
|
+
state.originalMuiKey = null;
|
|
383
|
+
}
|
|
384
|
+
} })) })] }), (0, jsx_runtime_1.jsxs)(material_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", size: "small", onClick: handleClose, children: t('common.cancel') }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", size: "small", onClick: handleSave, children: t('maker.save') })] })] }));
|
|
337
385
|
};
|
|
338
386
|
exports.ConfigColorDialog = ConfigColorDialog;
|
|
339
|
-
function ColorPicker({ value, onChange, style = {}, sx = {} }) {
|
|
387
|
+
function ColorPicker({ value, onChange, style = {}, sx = {}, renderTabs }) {
|
|
340
388
|
const refDialog = (0, react_1.useRef)(null);
|
|
341
389
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ColorItem, { color: value || '', style: { width: '1rem', height: '1rem', padding: 0, marginRight: '0.25rem', ...style }, sx: { ...sx }, onClick: () => {
|
|
342
390
|
refDialog.current?.open({ value });
|
|
343
|
-
} }), (0, jsx_runtime_1.jsx)(exports.ConfigColorDialog, { ref: refDialog, onSave: ({ value }, close) => {
|
|
391
|
+
} }), (0, jsx_runtime_1.jsx)(exports.ConfigColorDialog, { ref: refDialog, renderTabs: renderTabs, onSave: ({ value }, close) => {
|
|
344
392
|
onChange(value);
|
|
345
393
|
close();
|
|
346
394
|
} })] }));
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.z = exports.uploadSchema = exports.pagesKitRegistry = void 0;
|
|
30
|
+
const z4 = __importStar(require("zod/v4"));
|
|
31
|
+
// Re-export all zod/v4 types for compatibility
|
|
32
|
+
__exportStar(require("zod/v4"), exports);
|
|
33
|
+
exports.pagesKitRegistry = z4.registry();
|
|
34
|
+
// Define upload schema with metadata
|
|
35
|
+
exports.uploadSchema = z4
|
|
36
|
+
.object({
|
|
37
|
+
url: z4.string().nullable(),
|
|
38
|
+
mediaKitUrl: z4.string().nullable(),
|
|
39
|
+
width: z4.number().nullable(),
|
|
40
|
+
height: z4.number().nullable(),
|
|
41
|
+
})
|
|
42
|
+
.register(exports.pagesKitRegistry, {
|
|
43
|
+
id: 'pages_kit_upload',
|
|
44
|
+
type: 'upload',
|
|
45
|
+
locales: {
|
|
46
|
+
en: {
|
|
47
|
+
name: 'Media Upload',
|
|
48
|
+
description: 'Media upload component with URL, media kit URL and dimensions',
|
|
49
|
+
defaultValue: {
|
|
50
|
+
url: 'https://example.com/image.jpg',
|
|
51
|
+
mediaKitUrl: 'https://mediakit.example.com/image.jpg',
|
|
52
|
+
width: 1920,
|
|
53
|
+
height: 1080,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
zh: {
|
|
57
|
+
name: '媒体上传',
|
|
58
|
+
description: '支持URL、媒体工具包URL和尺寸的媒体上传组件',
|
|
59
|
+
defaultValue: {
|
|
60
|
+
url: 'https://example.com/image.jpg',
|
|
61
|
+
mediaKitUrl: 'https://mediakit.example.com/image.jpg',
|
|
62
|
+
width: 1920,
|
|
63
|
+
height: 1080,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
examples: [
|
|
68
|
+
{
|
|
69
|
+
url: 'https://example.com/image.jpg',
|
|
70
|
+
mediaKitUrl: 'https://mediakit.example.com/image.jpg',
|
|
71
|
+
width: 1920,
|
|
72
|
+
height: 1080,
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
});
|
|
76
|
+
// Create factory functions for custom types
|
|
77
|
+
const upload = () => exports.uploadSchema;
|
|
78
|
+
// Export enhanced zod with custom types
|
|
79
|
+
exports.z = {
|
|
80
|
+
...z4,
|
|
81
|
+
upload, // Factory function, consistent with z.string(), z.object()
|
|
82
|
+
};
|
|
83
|
+
exports.default = exports.z;
|