diff --git a/CHANGELOG.md b/CHANGELOG.md index 627fc263..e9cf8cef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. See [standa #### Core - add component documentation generation script +- add publish ci #### QrCode @@ -33,6 +34,14 @@ All notable changes to this project will be documented in this file. See [standa - feat: support quick times - feat: support format +#### Color Picker + +- support disabled and readonly +- support presetColors +- support transparency +- support hsl +- support showPanel, showDropper, showTransparency, showFormat + ### 2024.5.2 (2024-12-15) ### ✨ Features diff --git a/configure/generate/component_doc.py b/configure/generate/component_doc.py index 84483648..5e0cad0a 100644 --- a/configure/generate/component_doc.py +++ b/configure/generate/component_doc.py @@ -128,13 +128,14 @@ def parse_types_file(file_path: str) -> Tuple[List[Dict], List[Dict], List[Dict] for line in emits_content.split('\n'): line = line.strip() if line: - emit_match = re.match(r"\(e:\s*'([\w:-]+)'(?:\s*,\s*(\w+):\s*(\w+))?\):\s*void", line) + # 修改正则表达式以支持联合类型 + emit_match = re.match(r"\(e:\s*'([\w:-]+)'(?:\s*,\s*(\w+):\s*([\w\[\],\s|]+))?\):\s*void", line) if emit_match: event_name = emit_match.group(1) params = '-' if emit_match.group(2) and emit_match.group(3): # 如果有参数 param_name = emit_match.group(2) - param_type = emit_match.group(3) + param_type = emit_match.group(3).strip() # 去除可能的空格 params = f'{param_name}: {param_type}' emits.append({ @@ -357,7 +358,7 @@ def generate_markdown(component_name: str, props: List[Dict], emits: List[Dict], for p in props: default_value = "-" if p["default"].startswith("t(") and p["default"].endswith(")") or p["default"] == "undefined" else p["default"] description = p['description'].replace("'", "`") - row = f" ['{p['name']}', '{description}', '{p['type']}', '{default_value}', '{p['list']}']" + row = f" ['{p['name']}', '{description}', '{p['type']}', '{default_value.replace('\n}', '').replace('\'', '')}', '{p['list']}']" prop_rows.append(row) markdown += ",\n".join(prop_rows) diff --git a/docs/.vitepress/config.js b/docs/.vitepress/config.js index 02963211..f5962887 100644 --- a/docs/.vitepress/config.js +++ b/docs/.vitepress/config.js @@ -223,7 +223,8 @@ export default { {text: 'Input Tag', link: 'form/input-tag', icon: '/components/form/input-tag.svg', version: '2024.5.2'}, {text: 'Map', link: 'form/map', icon: '/components/form/map.svg', version: '2024.5.2'}, {text: 'Time Picker', link: 'form/time-picker', icon: '/components/form/time-picker.svg', version: '2024.5.3'}, - {text: 'Color Picker', link: 'form/color-picker', icon: '/components/form/color-picker.svg', version: '2024.5.3'} + {text: 'Color Picker', link: 'form/color-picker', icon: '/components/form/color-picker.svg', version: '2024.5.3'}, + {text: 'Date Picker', link: 'form/date-picker', icon: '/components/form/date-picker.svg', version: '2024.5.3'} ] return { diff --git a/docs/components/form/date-picker.md b/docs/components/form/date-picker.md new file mode 100644 index 00000000..802785b4 --- /dev/null +++ b/docs/components/form/date-picker.md @@ -0,0 +1,209 @@ +--- +title: Shadcn DatePicker +--- + +# Introduction + +This document describes the features and usage of the ShadcnDatePicker component. + +## Usage + +::: raw + + + + + +::: + +::: details Show code + +```vue + + + +``` + +::: + +## Type + +::: raw + + + + + + +::: + +::: details Show code + +```vue + + + + +``` + +::: + +## Placeholder + +::: raw + + + + + +::: + +::: details Show code + +```vue + + + +``` + +::: + +## Disabled + +::: raw + + + + + + +::: + +::: details Show code + +```vue + + + + +``` + +::: + +## Readonly + +::: raw + + + + + + +::: + +::: details Show code + +```vue + + + + +``` + +::: + +## Format + +::: raw + + + + + +::: + +::: details Show code + +```vue + + + +``` + +::: + +## Clearable + +::: raw + + + + + + +::: + +::: details Show code + +```vue + + + + +``` + +::: + +## Show shortcuts + +::: raw + + + + + + +::: + +::: details Show code + +```vue + + + + +``` + +::: +## DatePicker Props + + + + +## DatePicker Events + + + + + + diff --git a/docs/public/components/form/date-picker.svg b/docs/public/components/form/date-picker.svg new file mode 100644 index 00000000..7e9e76bf --- /dev/null +++ b/docs/public/components/form/date-picker.svg @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/index.ts b/packages/index.ts index 6471499a..48e63324 100644 --- a/packages/index.ts +++ b/packages/index.ts @@ -95,6 +95,7 @@ import { ShadcnDataFilter, ShadcnHierarchicalDataFilter } from '@/ui/data-filter import ShadcnQrCode from '@/ui/qrcode/ShadcnQrCode.vue' import { ShadcnTimePicker } from '@/ui/time-picker' import { ShadcnColorPicker } from '@/ui/color-picker' +import { ShadcnDatePicker } from '@/ui/date-picker' let components = [ ShadcnButton, @@ -186,7 +187,8 @@ let components = [ ShadcnDataFilter, ShadcnHierarchicalDataFilter, ShadcnQrCode, ShadcnTimePicker, - ShadcnColorPicker + ShadcnColorPicker, + ShadcnDatePicker ] interface InstallOptions @@ -314,6 +316,7 @@ export { ShadcnDataFilter, ShadcnHierarchicalDataFilter } from '@/ui/data-filter export { ShadcnQrCode } from '@/ui/qrcode' export { ShadcnTimePicker } from '@/ui/time-picker' export { ShadcnColorPicker } from '@/ui/color-picker' +export { ShadcnDatePicker } from '@/ui/date-picker' // Export functions export { fnToString, fnToFunction } from '@/utils/formatter' diff --git a/src/App.vue b/src/App.vue index d210942b..fdcc0ccd 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,18 +1,20 @@ - Selected color: {{ selectedColor }} - - - - + Selected date: {{ selectDate }} + + + + + \ No newline at end of file diff --git a/src/locales/en-US.ts b/src/locales/en-US.ts index 810064df..86005c37 100644 --- a/src/locales/en-US.ts +++ b/src/locales/en-US.ts @@ -197,5 +197,30 @@ export default { transparency: 'Transparency', format: 'Format' } + }, + datePicker: { + text: { + sunday: 'Sun', + monday: 'Mon', + tuesday: 'Tue', + wednesday: 'Wed', + thursday: 'Thu', + friday: 'Fri', + saturday: 'Sat', + year: 'Year', + month: 'Month', + today: 'Today', + yesterday: 'Yesterday', + thisWeek: 'This week', + lastWeek: 'Last week', + thisMonth: 'This month', + lastMonth: 'Last month', + last3Months: 'Last 3 months', + thisYear: 'This year', + lastYear: 'Last year', + }, + placeholder: { + date: 'Please select a date' + } } -} +} \ No newline at end of file diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index f6e16661..540cad98 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -170,7 +170,7 @@ export default { addCondition: '添加条件', addGroup: '添加分组', and: '且', - or: '或', + or: '或' }, validated: { invalid: '无效的字段', @@ -197,5 +197,30 @@ export default { transparency: '透明度', format: '格式' } + }, + datePicker: { + text: { + sunday: '星期日', + monday: '星期一', + tuesday: '星期二', + wednesday: '星期三', + thursday: '星期四', + friday: '星期五', + saturday: '星期六', + year: '年', + month: '月', + today: '今天', + yesterday: '昨天', + thisWeek: '本周', + lastWeek: '上周', + thisMonth: '本月', + lastMonth: '上月', + last3Months: '过去 3 个月', + thisYear: '今年', + lastYear: '去年' + }, + placeholder: { + date: '请选择日期' + } } -} +} \ No newline at end of file diff --git a/src/ui/date-picker/ShadcnDatePicker.vue b/src/ui/date-picker/ShadcnDatePicker.vue new file mode 100644 index 00000000..dda21c32 --- /dev/null +++ b/src/ui/date-picker/ShadcnDatePicker.vue @@ -0,0 +1,664 @@ + + + + + + + + + + + + + + + + + + + + + + {{ currentMonthYear }} + + + + + + + + + + + + + {{ day }} + + + + + + + + {{ date.day }} + + {{ date.day }} + + + + + + + + + + + + + + + {{ endMonthYear }} + + + + + + + + + + + + + {{ day }} + + + + + + + + {{ date.day }} + + {{ date.day }} + + + + + + + + + {{ shortcut.label }} + + + + + + + \ No newline at end of file diff --git a/src/ui/date-picker/index.ts b/src/ui/date-picker/index.ts new file mode 100644 index 00000000..4559f6fe --- /dev/null +++ b/src/ui/date-picker/index.ts @@ -0,0 +1 @@ +export { default as ShadcnDatePicker } from './ShadcnDatePicker.vue' \ No newline at end of file diff --git a/src/ui/date-picker/types.ts b/src/ui/date-picker/types.ts new file mode 100644 index 00000000..9c6d0297 --- /dev/null +++ b/src/ui/date-picker/types.ts @@ -0,0 +1,16 @@ +export interface DatePickerProps +{ + modelValue?: Date | string + type?: 'date' | 'range' + placeholder?: string + disabled?: boolean + readonly?: boolean + format?: string + clearable?: boolean + showShortcuts?: boolean +} + +export type DatePickerEmits = { + (e: 'update:modelValue', value: string | [string, string]): void + (e: 'on-change', value: string | [string, string]): void +} \ No newline at end of file diff --git a/src/utils/date.ts b/src/utils/date.ts new file mode 100644 index 00000000..7230aa13 --- /dev/null +++ b/src/utils/date.ts @@ -0,0 +1,26 @@ +export const formatDate = (date: Date | string | undefined, format = 'YYYY-MM-DD'): string => { + if (!date) { + return '' + } + + const d = (date instanceof Date) ? date : new Date(date as string) + + if (isNaN(d.getTime())) { + return '' + } + + const year = d.getFullYear() + const month = String(d.getMonth() + 1).padStart(2, '0') + const day = String(d.getDate()).padStart(2, '0') + const hours = String(d.getHours()).padStart(2, '0') + const minutes = String(d.getMinutes()).padStart(2, '0') + const seconds = String(d.getSeconds()).padStart(2, '0') + + return format + .replace('YYYY', String(year)) + .replace('MM', month) + .replace('DD', day) + .replace('HH', hours) + .replace('mm', minutes) + .replace('ss', seconds) +} \ No newline at end of file