niuma-ui 1.0.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/CHANGELOG.md +29 -0
- package/LICENSE +202 -0
- package/NOTICE +25 -0
- package/README.en.md +99 -0
- package/README.md +161 -0
- package/package.json +106 -0
- package/src/__tests__/RsBadge.spec.ts +40 -0
- package/src/__tests__/RsBreadcrumb.spec.ts +172 -0
- package/src/__tests__/RsButton.spec.ts +108 -0
- package/src/__tests__/RsCalendarGrid.spec.ts +82 -0
- package/src/__tests__/RsCard.spec.ts +97 -0
- package/src/__tests__/RsCheckbox.spec.ts +36 -0
- package/src/__tests__/RsCodeEditor.spec.ts +111 -0
- package/src/__tests__/RsConfirmDialog.spec.ts +158 -0
- package/src/__tests__/RsContainer.spec.ts +89 -0
- package/src/__tests__/RsContextMenu.spec.ts +118 -0
- package/src/__tests__/RsDatePicker.spec.ts +88 -0
- package/src/__tests__/RsDateTimePicker.spec.ts +69 -0
- package/src/__tests__/RsDialog.spec.ts +404 -0
- package/src/__tests__/RsDrawer.spec.ts +145 -0
- package/src/__tests__/RsDropdown.spec.ts +135 -0
- package/src/__tests__/RsEmpty.spec.ts +99 -0
- package/src/__tests__/RsForm.spec.ts +173 -0
- package/src/__tests__/RsIcon.spec.ts +244 -0
- package/src/__tests__/RsInput.spec.ts +269 -0
- package/src/__tests__/RsInputNumber.spec.ts +118 -0
- package/src/__tests__/RsLabel.spec.ts +106 -0
- package/src/__tests__/RsLink.spec.ts +49 -0
- package/src/__tests__/RsLoading.spec.ts +84 -0
- package/src/__tests__/RsMarkdown.spec.ts +143 -0
- package/src/__tests__/RsMenu.spec.ts +119 -0
- package/src/__tests__/RsNewComponents.spec.ts +17 -0
- package/src/__tests__/RsPagination.spec.ts +158 -0
- package/src/__tests__/RsPopover.spec.ts +126 -0
- package/src/__tests__/RsScrollbar.spec.ts +53 -0
- package/src/__tests__/RsSelect.spec.ts +291 -0
- package/src/__tests__/RsSidebar.spec.ts +119 -0
- package/src/__tests__/RsSplitPane.spec.ts +177 -0
- package/src/__tests__/RsStatCard.spec.ts +79 -0
- package/src/__tests__/RsSteps.spec.ts +125 -0
- package/src/__tests__/RsTable.perf.spec.ts +103 -0
- package/src/__tests__/RsTable.spec.ts +1135 -0
- package/src/__tests__/RsTabs.spec.ts +328 -0
- package/src/__tests__/RsTerminal.spec.ts +218 -0
- package/src/__tests__/RsTimePicker.spec.ts +77 -0
- package/src/__tests__/RsToaster.spec.ts +95 -0
- package/src/__tests__/RsToolbar.spec.ts +75 -0
- package/src/__tests__/RsTooltip.spec.ts +111 -0
- package/src/__tests__/RsTree.spec.ts +572 -0
- package/src/__tests__/RsUpload.spec.ts +160 -0
- package/src/__tests__/RsVirtualList.spec.ts +77 -0
- package/src/__tests__/date-picker-utils.spec.ts +70 -0
- package/src/__tests__/dialog-viewport.spec.ts +38 -0
- package/src/__tests__/iso-local-datetime.spec.ts +58 -0
- package/src/__tests__/rs-clipboard.spec.ts +142 -0
- package/src/__tests__/setup.ts +12 -0
- package/src/__tests__/split-pane-utils.spec.ts +136 -0
- package/src/__tests__/table-drag.spec.ts +35 -0
- package/src/__tests__/table-edit-utils.spec.ts +194 -0
- package/src/__tests__/table-utils.spec.ts +286 -0
- package/src/__tests__/theme.spec.ts +22 -0
- package/src/__tests__/tree-utils.spec.ts +234 -0
- package/src/__tests__/useTableCellTooltip.spec.ts +101 -0
- package/src/components/RsAvatar.vue +115 -0
- package/src/components/RsBadge.vue +59 -0
- package/src/components/RsBreadcrumb.vue +65 -0
- package/src/components/RsBreadcrumbItems.vue +36 -0
- package/src/components/RsButton.vue +393 -0
- package/src/components/RsCalendarGrid.vue +284 -0
- package/src/components/RsCard.vue +237 -0
- package/src/components/RsCheckbox.vue +189 -0
- package/src/components/RsCodeBlock.vue +278 -0
- package/src/components/RsCodeEditor.vue +597 -0
- package/src/components/RsConfigProvider.vue +92 -0
- package/src/components/RsConfirmDialog.vue +178 -0
- package/src/components/RsContainer.vue +235 -0
- package/src/components/RsContextMenu.vue +238 -0
- package/src/components/RsContextMenuItems.vue +77 -0
- package/src/components/RsDatePicker.vue +756 -0
- package/src/components/RsDateTimePicker.vue +42 -0
- package/src/components/RsDialog.vue +486 -0
- package/src/components/RsDrawer.vue +175 -0
- package/src/components/RsDropdown.vue +252 -0
- package/src/components/RsDropdownItems.vue +90 -0
- package/src/components/RsEmpty.vue +107 -0
- package/src/components/RsForm.vue +131 -0
- package/src/components/RsIcon.vue +104 -0
- package/src/components/RsInput.vue +1101 -0
- package/src/components/RsInputNumber.vue +532 -0
- package/src/components/RsLabel.vue +54 -0
- package/src/components/RsLink.vue +106 -0
- package/src/components/RsLoading.vue +171 -0
- package/src/components/RsMarkdown.vue +329 -0
- package/src/components/RsMenu.vue +256 -0
- package/src/components/RsMenuItems.vue +125 -0
- package/src/components/RsMonacoEditor.vue +541 -0
- package/src/components/RsPagination.vue +184 -0
- package/src/components/RsPopover.vue +77 -0
- package/src/components/RsProseEditor.vue +160 -0
- package/src/components/RsScrollbar.vue +171 -0
- package/src/components/RsSelect.vue +1045 -0
- package/src/components/RsSidebar.vue +121 -0
- package/src/components/RsSidebarGroup.vue +32 -0
- package/src/components/RsSidebarItem.vue +72 -0
- package/src/components/RsSplitPane.vue +619 -0
- package/src/components/RsStatCard.vue +85 -0
- package/src/components/RsSteps.vue +138 -0
- package/src/components/RsTable.vue +2664 -0
- package/src/components/RsTableColgroup.vue +17 -0
- package/src/components/RsTableHeaderRow.vue +30 -0
- package/src/components/RsTabs.vue +951 -0
- package/src/components/RsTerminal.vue +697 -0
- package/src/components/RsTimePicker.vue +554 -0
- package/src/components/RsTimePickerColumns.vue +226 -0
- package/src/components/RsToaster.vue +396 -0
- package/src/components/RsToolbar.vue +135 -0
- package/src/components/RsTooltip.vue +142 -0
- package/src/components/RsTooltipProvider.vue +20 -0
- package/src/components/RsTree.vue +1248 -0
- package/src/components/RsUpload.vue +279 -0
- package/src/components/RsVirtualList.vue +217 -0
- package/src/components/avatar-utils.ts +19 -0
- package/src/components/breadcrumb-utils.ts +19 -0
- package/src/components/class-utils.ts +29 -0
- package/src/components/code-editor-utils.ts +106 -0
- package/src/components/code-mirror-completion.ts +40 -0
- package/src/components/code-mirror-diagnostics.ts +52 -0
- package/src/components/code-mirror-ghost.ts +158 -0
- package/src/components/code-mirror-inline-edit.ts +55 -0
- package/src/components/code-mirror-intel.ts +81 -0
- package/src/components/code-mirror-lang.ts +128 -0
- package/src/components/context-menu-utils.ts +20 -0
- package/src/components/date-picker-utils.ts +284 -0
- package/src/components/date-range-validation.ts +29 -0
- package/src/components/date-validation.ts +38 -0
- package/src/components/dialog-viewport.ts +48 -0
- package/src/components/dialog-window.ts +253 -0
- package/src/components/dropdown-utils.ts +31 -0
- package/src/components/form-utils.ts +77 -0
- package/src/components/input-number-utils.ts +128 -0
- package/src/components/input-rules.ts +84 -0
- package/src/components/loading-utils.ts +8 -0
- package/src/components/markdown-utils.ts +126 -0
- package/src/components/menu-utils.ts +48 -0
- package/src/components/overlay-utils.ts +47 -0
- package/src/components/pagination-utils.ts +38 -0
- package/src/components/popover-utils.ts +8 -0
- package/src/components/reka.ts +106 -0
- package/src/components/resolve-radius.ts +22 -0
- package/src/components/resolve-size.ts +29 -0
- package/src/components/scrollbar-utils.ts +10 -0
- package/src/components/select-utils.ts +72 -0
- package/src/components/split-pane-utils.ts +187 -0
- package/src/components/steps-utils.ts +22 -0
- package/src/components/table/RsTableBodyRow.vue +287 -0
- package/src/components/table/RsTableCell.vue +239 -0
- package/src/components/table/RsTableCellContent.ts +18 -0
- package/src/components/table/RsTableCellEditor.vue +351 -0
- package/src/components/table/RsTableEditGutter.vue +54 -0
- package/src/components/table/RsTableHeaderFilter.vue +107 -0
- package/src/components/table/RsTableRowStatus.vue +69 -0
- package/src/components/table/rs-table.css +1141 -0
- package/src/components/table/table-context-menu.ts +53 -0
- package/src/components/table/table-edit-utils.ts +496 -0
- package/src/components/table/table-keys.ts +12 -0
- package/src/components/table-drag.ts +215 -0
- package/src/components/table-utils.ts +950 -0
- package/src/components/tabs-utils.ts +107 -0
- package/src/components/terminal-utils.ts +301 -0
- package/src/components/terminal-wheel.ts +49 -0
- package/src/components/time-picker-utils.ts +167 -0
- package/src/components/time-range-validation.ts +23 -0
- package/src/components/time-validation.ts +20 -0
- package/src/components/tree-utils.ts +518 -0
- package/src/components/upload-utils.ts +55 -0
- package/src/components/virtual-list-utils.ts +17 -0
- package/src/composables/useClickOutside.ts +22 -0
- package/src/composables/useRsConfig.ts +91 -0
- package/src/composables/useRsI18n.ts +22 -0
- package/src/composables/useRsTabsNav.ts +187 -0
- package/src/composables/useRsToast.ts +48 -0
- package/src/composables/useTableCellTooltip.ts +239 -0
- package/src/composables/useTableEdit.ts +271 -0
- package/src/composables/useTableRowHighlight.ts +50 -0
- package/src/dev/vite-codemirror-deps.ts +20 -0
- package/src/icons/custom/api.ts +54 -0
- package/src/icons/custom/clickhouse.ts +52 -0
- package/src/icons/custom/dameng.ts +83 -0
- package/src/icons/custom/ftp.ts +61 -0
- package/src/icons/custom/kingbase.ts +52 -0
- package/src/icons/custom/mongodb.ts +50 -0
- package/src/icons/custom/mysql.ts +51 -0
- package/src/icons/custom/oracle.ts +52 -0
- package/src/icons/custom/redis.ts +51 -0
- package/src/icons/custom/sqlite.ts +50 -0
- package/src/icons/custom/sqlserver.ts +52 -0
- package/src/icons/custom/vastbase.ts +57 -0
- package/src/icons/lucide.ts +78 -0
- package/src/icons/registry.ts +35 -0
- package/src/index.ts +425 -0
- package/src/lib/iso-local-datetime.ts +152 -0
- package/src/lib/rs-dayjs.ts +56 -0
- package/src/locale/messages.ts +362 -0
- package/src/locale/types.ts +5 -0
- package/src/monaco/debug-decorations.css +20 -0
- package/src/monaco/debug-decorations.ts +70 -0
- package/src/monaco/index.ts +22 -0
- package/src/monaco/languages/index.ts +21 -0
- package/src/monaco/languages/mongodb-shell.ts +125 -0
- package/src/monaco/languages/types.ts +55 -0
- package/src/monaco/setup.ts +101 -0
- package/src/styles.css +1040 -0
- package/src/theme/apply.ts +12 -0
- package/src/theme/brand.example.css +37 -0
- package/src/theme/presets.ts +69 -0
- package/src/theme/types.ts +81 -0
- package/src/utils/rs-clipboard.ts +272 -0
- package/src/vite-env.d.ts +7 -0
- package/vite-plugins/monaco-zh-nls.ts +101 -0
- package/vite-plugins/silence-antlr-parse-console.ts +29 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
export { default as RsConfigProvider } from './components/RsConfigProvider.vue'
|
|
2
|
+
export { default as RsBadge } from './components/RsBadge.vue'
|
|
3
|
+
export { default as RsContainer } from './components/RsContainer.vue'
|
|
4
|
+
export { default as RsBreadcrumb } from './components/RsBreadcrumb.vue'
|
|
5
|
+
export { default as RsToolbar } from './components/RsToolbar.vue'
|
|
6
|
+
export { default as RsButton } from './components/RsButton.vue'
|
|
7
|
+
export { default as RsCheckbox } from './components/RsCheckbox.vue'
|
|
8
|
+
export { default as RsDropdown } from './components/RsDropdown.vue'
|
|
9
|
+
export { default as RsIcon } from './components/RsIcon.vue'
|
|
10
|
+
export { default as RsInput } from './components/RsInput.vue'
|
|
11
|
+
export { default as RsInputNumber } from './components/RsInputNumber.vue'
|
|
12
|
+
export type { RsInputNumberValue } from './components/input-number-utils'
|
|
13
|
+
export {
|
|
14
|
+
clampNumber,
|
|
15
|
+
formatNumberValue,
|
|
16
|
+
fromModelValue,
|
|
17
|
+
isNumberInputInterim,
|
|
18
|
+
normalizeCommittedNumber,
|
|
19
|
+
parseNumberInput,
|
|
20
|
+
resolveNumberPrecision,
|
|
21
|
+
roundToPrecision,
|
|
22
|
+
stepNumberValue,
|
|
23
|
+
toModelValue,
|
|
24
|
+
} from './components/input-number-utils'
|
|
25
|
+
export { default as RsLabel } from './components/RsLabel.vue'
|
|
26
|
+
export { default as RsLink } from './components/RsLink.vue'
|
|
27
|
+
export { default as RsMenu } from './components/RsMenu.vue'
|
|
28
|
+
export { default as RsSelect } from './components/RsSelect.vue'
|
|
29
|
+
export { default as RsScrollbar } from './components/RsScrollbar.vue'
|
|
30
|
+
export { default as RsAvatar } from './components/RsAvatar.vue'
|
|
31
|
+
export { default as RsCard } from './components/RsCard.vue'
|
|
32
|
+
export type { RsCardVariant } from './components/RsCard.vue'
|
|
33
|
+
export { default as RsEmpty } from './components/RsEmpty.vue'
|
|
34
|
+
export { default as RsLoading } from './components/RsLoading.vue'
|
|
35
|
+
export { default as RsTabs } from './components/RsTabs.vue'
|
|
36
|
+
export { default as RsTooltip } from './components/RsTooltip.vue'
|
|
37
|
+
export { default as RsTooltipProvider } from './components/RsTooltipProvider.vue'
|
|
38
|
+
export { default as RsPopover } from './components/RsPopover.vue'
|
|
39
|
+
export { default as RsDialog } from './components/RsDialog.vue'
|
|
40
|
+
export { default as RsContextMenu } from './components/RsContextMenu.vue'
|
|
41
|
+
export { default as RsConfirmDialog } from './components/RsConfirmDialog.vue'
|
|
42
|
+
export { default as RsDrawer } from './components/RsDrawer.vue'
|
|
43
|
+
export { default as RsForm } from './components/RsForm.vue'
|
|
44
|
+
export { default as RsToaster } from './components/RsToaster.vue'
|
|
45
|
+
export { default as RsDatePicker } from './components/RsDatePicker.vue'
|
|
46
|
+
export { default as RsDateTimePicker } from './components/RsDateTimePicker.vue'
|
|
47
|
+
export { default as RsTimePicker } from './components/RsTimePicker.vue'
|
|
48
|
+
export { default as RsCalendarGrid } from './components/RsCalendarGrid.vue'
|
|
49
|
+
export { default as RsTimePickerColumns } from './components/RsTimePickerColumns.vue'
|
|
50
|
+
export { default as RsSidebar } from './components/RsSidebar.vue'
|
|
51
|
+
export { default as RsSidebarGroup } from './components/RsSidebarGroup.vue'
|
|
52
|
+
export { default as RsSidebarItem } from './components/RsSidebarItem.vue'
|
|
53
|
+
export { default as RsSplitPane } from './components/RsSplitPane.vue'
|
|
54
|
+
export { default as RsStatCard } from './components/RsStatCard.vue'
|
|
55
|
+
export { default as RsSteps } from './components/RsSteps.vue'
|
|
56
|
+
export { default as RsTable } from './components/RsTable.vue'
|
|
57
|
+
export { default as RsTableCellEditor } from './components/table/RsTableCellEditor.vue'
|
|
58
|
+
export { default as RsTableHeaderRow } from './components/RsTableHeaderRow.vue'
|
|
59
|
+
export { default as RsTableColgroup } from './components/RsTableColgroup.vue'
|
|
60
|
+
export { default as RsPagination } from './components/RsPagination.vue'
|
|
61
|
+
export { default as RsTree } from './components/RsTree.vue'
|
|
62
|
+
export { default as RsUpload } from './components/RsUpload.vue'
|
|
63
|
+
export { default as RsVirtualList } from './components/RsVirtualList.vue'
|
|
64
|
+
export { default as RsCodeEditor } from './components/RsCodeEditor.vue'
|
|
65
|
+
export { default as RsMonacoEditor } from './components/RsMonacoEditor.vue'
|
|
66
|
+
export type {
|
|
67
|
+
MonacoCompletionContext,
|
|
68
|
+
MonacoCompletionPrefixResolver,
|
|
69
|
+
MonacoCompletionRequest,
|
|
70
|
+
MonacoCompletionSnippet,
|
|
71
|
+
} from './components/RsMonacoEditor.vue'
|
|
72
|
+
export type {
|
|
73
|
+
MonacoBuiltinLanguage,
|
|
74
|
+
MonacoLanguage,
|
|
75
|
+
MonacoSqlLanguageId,
|
|
76
|
+
} from './monaco'
|
|
77
|
+
export {
|
|
78
|
+
applyMonacoDebugDecorations,
|
|
79
|
+
buildMonacoDebugDecorations,
|
|
80
|
+
ensureMongodbShellLanguage,
|
|
81
|
+
MONACO_GENERIC_SQL_LANGUAGE,
|
|
82
|
+
MONACO_MONGODB_SHELL_LANGUAGE,
|
|
83
|
+
MONACO_PGSQL_LANGUAGE,
|
|
84
|
+
MONACO_MYSQL_LANGUAGE,
|
|
85
|
+
MONACO_DAMENG_LANGUAGE,
|
|
86
|
+
MONACO_KINGBASE_LANGUAGE,
|
|
87
|
+
MONACO_SQLITE_LANGUAGE,
|
|
88
|
+
RS_MONACO_DEBUG,
|
|
89
|
+
setupMonacoWorkers,
|
|
90
|
+
} from './monaco'
|
|
91
|
+
export type { MonacoDebugDecorationState } from './monaco'
|
|
92
|
+
export { default as RsCodeBlock } from './components/RsCodeBlock.vue'
|
|
93
|
+
export { default as RsMarkdown } from './components/RsMarkdown.vue'
|
|
94
|
+
export type { RsMarkdownMode, RsMarkdownRenderOptions } from './components/markdown-utils'
|
|
95
|
+
export {
|
|
96
|
+
escapeHtml,
|
|
97
|
+
isSafeHref,
|
|
98
|
+
isSafeImageSrc,
|
|
99
|
+
renderMarkdown,
|
|
100
|
+
resolveMarkdownHeight,
|
|
101
|
+
resolveMarkdownMode,
|
|
102
|
+
} from './components/markdown-utils'
|
|
103
|
+
export { default as RsProseEditor } from './components/RsProseEditor.vue'
|
|
104
|
+
export { default as RsTerminal } from './components/RsTerminal.vue'
|
|
105
|
+
export {
|
|
106
|
+
beginClipboardPrefetch,
|
|
107
|
+
copyTextToClipboard,
|
|
108
|
+
copyTextWithExecCommand,
|
|
109
|
+
prefetchClipboardText,
|
|
110
|
+
readClipboardText,
|
|
111
|
+
writeClipboardText,
|
|
112
|
+
} from './utils/rs-clipboard'
|
|
113
|
+
export { resolveCodeMirrorLanguage, isCodeMirrorLightTheme, prewarmCodeMirrorEditor } from './components/code-mirror-lang'
|
|
114
|
+
export {
|
|
115
|
+
buildAnsiColorDemo,
|
|
116
|
+
containsEscapeSequence,
|
|
117
|
+
getTerminalThemePalette,
|
|
118
|
+
mergeTerminalTheme,
|
|
119
|
+
readTerminalThemeFromCss,
|
|
120
|
+
resolveTerminalTheme,
|
|
121
|
+
terminalShortcutLabel,
|
|
122
|
+
} from './components/terminal-utils'
|
|
123
|
+
export type {
|
|
124
|
+
RsResolvedTerminalTheme,
|
|
125
|
+
RsTerminalAction,
|
|
126
|
+
RsTerminalThemeMode,
|
|
127
|
+
} from './components/terminal-utils'
|
|
128
|
+
|
|
129
|
+
export type {
|
|
130
|
+
RsContainerBreakpoint,
|
|
131
|
+
RsContainerGap,
|
|
132
|
+
RsContainerMaxWidth,
|
|
133
|
+
RsContainerMaybeResponsive,
|
|
134
|
+
RsContainerPadding,
|
|
135
|
+
RsContainerResponsive,
|
|
136
|
+
} from './components/RsContainer.vue'
|
|
137
|
+
export type { RsBreadcrumbItem } from './components/RsBreadcrumb.vue'
|
|
138
|
+
export type { RsToolbarBorder, RsToolbarSize } from './components/RsToolbar.vue'
|
|
139
|
+
export type { RsContextMenuItem } from './components/context-menu-utils'
|
|
140
|
+
export type { RsDropdownItem, RsDropdownItemGroup, RsDropdownItems } from './components/dropdown-utils'
|
|
141
|
+
export type { RsMenuItem, RsMenuItemGroup, RsMenuItems } from './components/menu-utils'
|
|
142
|
+
export type { RsScrollbarOrientation, RsScrollbarType } from './components/scrollbar-utils'
|
|
143
|
+
export type { RsSelectOption, RsSelectOptionGroup, RsSelectOptions } from './components/select-utils'
|
|
144
|
+
export type { RsFeedbackTone, RsToastPosition, RsToastType } from './components/overlay-utils'
|
|
145
|
+
export { RS_TOAST_DEFAULT_GAP, RS_TOAST_DEFAULT_POSITION, rsToastPositions, rsFeedbackIconClass } from './components/overlay-utils'
|
|
146
|
+
export type {
|
|
147
|
+
RsFormContext,
|
|
148
|
+
RsFormFieldExpose,
|
|
149
|
+
RsFormGap,
|
|
150
|
+
RsFormLabelAlign,
|
|
151
|
+
RsFormLabelPosition,
|
|
152
|
+
RsFormMaxWidth,
|
|
153
|
+
RsFormSize,
|
|
154
|
+
RsFormValidationResult,
|
|
155
|
+
} from './components/form-utils'
|
|
156
|
+
export {
|
|
157
|
+
cloneFormFieldValue,
|
|
158
|
+
RS_FORM_INJECTION_KEY,
|
|
159
|
+
useRsFormContext,
|
|
160
|
+
useRsFormField,
|
|
161
|
+
} from './components/form-utils'
|
|
162
|
+
export type { RsTabItem, RsTabsOverflow, RsTabsSize, RsTabsVariant } from './components/tabs-utils'
|
|
163
|
+
export {
|
|
164
|
+
getNextTabAfterClose,
|
|
165
|
+
isTabClosable,
|
|
166
|
+
isTabRenamable,
|
|
167
|
+
reorderTabItems,
|
|
168
|
+
resolveVisibleTabValues,
|
|
169
|
+
} from './components/tabs-utils'
|
|
170
|
+
export type { RsStepItem, RsStepStatus, RsStepsOrientation, RsStepsSize } from './components/steps-utils'
|
|
171
|
+
export { isStepSeparatorCompleted, resolveStepStatus } from './components/steps-utils'
|
|
172
|
+
export type { RsSplitConstraint, RsSplitOrientation, RsSplitPaneItem } from './components/split-pane-utils'
|
|
173
|
+
export {
|
|
174
|
+
applySplitResize,
|
|
175
|
+
collapseSplitPane,
|
|
176
|
+
expandSplitPane,
|
|
177
|
+
isSplitPaneCollapsed,
|
|
178
|
+
normalizeSplitSizes,
|
|
179
|
+
resolveSplitConstraints,
|
|
180
|
+
splitSizesEqual,
|
|
181
|
+
} from './components/split-pane-utils'
|
|
182
|
+
export type {
|
|
183
|
+
RsTableCellCommitTrigger,
|
|
184
|
+
RsTableCellEditFocusMode,
|
|
185
|
+
RsTableCellEditTrigger,
|
|
186
|
+
RsTableCellEditorInputType,
|
|
187
|
+
RsTableCellNavigateDirection,
|
|
188
|
+
RsTableEditableCellRef,
|
|
189
|
+
} from './components/table/table-edit-utils'
|
|
190
|
+
export {
|
|
191
|
+
RS_TABLE_NULL_DRAFT,
|
|
192
|
+
isNullDraft,
|
|
193
|
+
nullToEditText,
|
|
194
|
+
parseClipboardGrid,
|
|
195
|
+
navigateEditableCell,
|
|
196
|
+
listEditableCells,
|
|
197
|
+
listBatchColumnTargets,
|
|
198
|
+
validateCellValueAsync,
|
|
199
|
+
} from './components/table/table-edit-utils'
|
|
200
|
+
export type { RsTableStagedCell, RsTableUndoEntry, RsTableFocusCell } from './composables/useTableEdit'
|
|
201
|
+
export type { RsTableRowDragTrigger, RsTableRowDropMode } from './components/table-drag'
|
|
202
|
+
export type {
|
|
203
|
+
RsTableCellRenderResult,
|
|
204
|
+
RsTableColumn,
|
|
205
|
+
RsTableColumnAlign,
|
|
206
|
+
RsTableColumnEditorOptions,
|
|
207
|
+
RsTableColumnEditorOptionsResolved,
|
|
208
|
+
RsTableColumnFixed,
|
|
209
|
+
RsTableCellValueType,
|
|
210
|
+
RsTableFieldAccessor,
|
|
211
|
+
RsTableGroupBy,
|
|
212
|
+
RsTableRowConvention,
|
|
213
|
+
RsTableRowData,
|
|
214
|
+
RsTableRowDropPosition,
|
|
215
|
+
RsTableRowEntry,
|
|
216
|
+
RsTableRowKey,
|
|
217
|
+
RsTableSelectAllState,
|
|
218
|
+
RsTableSelectionType,
|
|
219
|
+
RsTableSize,
|
|
220
|
+
RsTableSortOrder,
|
|
221
|
+
RsTableSortState,
|
|
222
|
+
} from './components/table-utils'
|
|
223
|
+
export {
|
|
224
|
+
buildTableEntries,
|
|
225
|
+
clampColumnWidth,
|
|
226
|
+
compareTableValues,
|
|
227
|
+
createInitialColumnWidths,
|
|
228
|
+
filterTableRows,
|
|
229
|
+
fixedCellStyle,
|
|
230
|
+
getCellValue,
|
|
231
|
+
getSortOrderForKey,
|
|
232
|
+
getSortPriorityForKey,
|
|
233
|
+
groupTableRows,
|
|
234
|
+
injectExpandRows,
|
|
235
|
+
isNearScrollBottom,
|
|
236
|
+
isTableRowDisabled,
|
|
237
|
+
parseColumnWidth,
|
|
238
|
+
reorderColumnKeys,
|
|
239
|
+
reorderTableRows,
|
|
240
|
+
resolveColumnOrder,
|
|
241
|
+
resolveEntryKey,
|
|
242
|
+
resolveFixedColumnStyles,
|
|
243
|
+
resolveOrderedColumns,
|
|
244
|
+
resolveRowKey,
|
|
245
|
+
resolveSelectableRowKeys,
|
|
246
|
+
resolveSelectAllState,
|
|
247
|
+
resolveTableSize,
|
|
248
|
+
resolveTableVirtualEnabled,
|
|
249
|
+
selectRowKeys,
|
|
250
|
+
selectRowKeysByClick,
|
|
251
|
+
sliceVirtualTableEntries,
|
|
252
|
+
sortTableRows,
|
|
253
|
+
sortTableRowsMulti,
|
|
254
|
+
toggleExpandedRowKeys,
|
|
255
|
+
toggleMultiSortState,
|
|
256
|
+
toggleRowSelection,
|
|
257
|
+
toggleSelectAll,
|
|
258
|
+
toggleSortState,
|
|
259
|
+
} from './components/table-utils'
|
|
260
|
+
export type {
|
|
261
|
+
RsTreeCheckState,
|
|
262
|
+
RsTreeDragTrigger,
|
|
263
|
+
RsTreeDropPosition,
|
|
264
|
+
RsTreeFieldNames,
|
|
265
|
+
RsTreeFlatNode,
|
|
266
|
+
RsTreeFocusMove,
|
|
267
|
+
RsTreeNode,
|
|
268
|
+
RsTreeNodeIndex,
|
|
269
|
+
RsTreeSize,
|
|
270
|
+
} from './components/tree-utils'
|
|
271
|
+
export {
|
|
272
|
+
buildTreeNodeIndex,
|
|
273
|
+
collectDescendantKeys,
|
|
274
|
+
collectExpandableKeys,
|
|
275
|
+
collectHalfCheckedKeys,
|
|
276
|
+
defaultTreeFilterNode,
|
|
277
|
+
filterTreeNodes,
|
|
278
|
+
flattenTreeNodeIds,
|
|
279
|
+
flattenVisibleTreeNodes,
|
|
280
|
+
getTreeChildren,
|
|
281
|
+
getTreeKey,
|
|
282
|
+
getTreeLabel,
|
|
283
|
+
hasTreeChildren,
|
|
284
|
+
isTreeAncestorKey,
|
|
285
|
+
resolveAccordionExpandedKeys,
|
|
286
|
+
resolveTreeCheckState,
|
|
287
|
+
resolveTreeFieldNames,
|
|
288
|
+
resolveTreeFocusKey,
|
|
289
|
+
resolveTreeIndent,
|
|
290
|
+
resolveTreeRowHeight,
|
|
291
|
+
resolveTreeVirtualEnabled,
|
|
292
|
+
sliceVirtualTreeNodes,
|
|
293
|
+
splitTreeLabelHighlight,
|
|
294
|
+
shouldShowTreeCheckbox,
|
|
295
|
+
toggleTreeCheck,
|
|
296
|
+
} from './components/tree-utils'
|
|
297
|
+
export type { RsUploadValidationError, RsUploadValidationRules } from './components/upload-utils'
|
|
298
|
+
export {
|
|
299
|
+
formatFileSize,
|
|
300
|
+
isFileAccepted,
|
|
301
|
+
mergeUploadFiles,
|
|
302
|
+
removeUploadFileAt,
|
|
303
|
+
validateUploadFiles,
|
|
304
|
+
} from './components/upload-utils'
|
|
305
|
+
export type { RsVirtualListItemSize } from './components/virtual-list-utils'
|
|
306
|
+
export { resolveItemSize, resolveVirtualListHeight } from './components/virtual-list-utils'
|
|
307
|
+
export type {
|
|
308
|
+
RsCodeEditorDiagnostic,
|
|
309
|
+
RsCodeEditorLanguage,
|
|
310
|
+
RsCodeEditorSqlColumn,
|
|
311
|
+
RsCodeEditorSqlConfig,
|
|
312
|
+
RsCodeEditorSqlDialect,
|
|
313
|
+
RsCodeEditorSqlNamespace,
|
|
314
|
+
RsCodeEditorTheme,
|
|
315
|
+
RsResolvedCodeEditorTheme,
|
|
316
|
+
} from './components/code-editor-utils'
|
|
317
|
+
export {
|
|
318
|
+
codeEditorLanguageLabel,
|
|
319
|
+
readDocumentTheme,
|
|
320
|
+
resolveCodeEditorLanguage,
|
|
321
|
+
resolveCodeEditorSize,
|
|
322
|
+
resolveCodeEditorTheme,
|
|
323
|
+
} from './components/code-editor-utils'
|
|
324
|
+
export type { RsDateRangeValue, RsParsedDate, RsParsedDateTime } from './components/date-picker-utils'
|
|
325
|
+
export {
|
|
326
|
+
EMPTY_DATE_RANGE,
|
|
327
|
+
formatDateDisplay,
|
|
328
|
+
formatDateParts,
|
|
329
|
+
formatDateRangeDisplay,
|
|
330
|
+
formatDateTimeDisplay,
|
|
331
|
+
formatDateTimeValue,
|
|
332
|
+
formatDateValue,
|
|
333
|
+
isDateRangeEmpty,
|
|
334
|
+
isDateRangeOrdered,
|
|
335
|
+
isDateTimeRangeOrdered,
|
|
336
|
+
parseDateTimeValue,
|
|
337
|
+
parseDateValue,
|
|
338
|
+
} from './components/date-picker-utils'
|
|
339
|
+
export {
|
|
340
|
+
RS_DATE_FORMAT,
|
|
341
|
+
RS_DATETIME_FORMAT,
|
|
342
|
+
RS_TIME_MINUTE_FORMAT,
|
|
343
|
+
RS_TIME_SECONDS_FORMAT,
|
|
344
|
+
} from './lib/rs-dayjs'
|
|
345
|
+
export {
|
|
346
|
+
formatIsoUtcToLocal,
|
|
347
|
+
looksLikeIsoDateTimeWithTz,
|
|
348
|
+
parseLocalDateTimeToUtcIso,
|
|
349
|
+
} from './lib/iso-local-datetime'
|
|
350
|
+
export type { RsParsedTime, RsTimeRangeValue } from './components/time-picker-utils'
|
|
351
|
+
export {
|
|
352
|
+
EMPTY_TIME_RANGE,
|
|
353
|
+
formatTimeFromParts,
|
|
354
|
+
formatTimeParts,
|
|
355
|
+
formatTimeRangeDisplay,
|
|
356
|
+
formatTimeValue,
|
|
357
|
+
isTimeRangeEmpty,
|
|
358
|
+
isTimeRangeOrdered,
|
|
359
|
+
isTimeWithinBounds,
|
|
360
|
+
parseTimeValue,
|
|
361
|
+
} from './components/time-picker-utils'
|
|
362
|
+
export type {
|
|
363
|
+
RsDateTimeValidationError,
|
|
364
|
+
RsDateTimeValidationResult,
|
|
365
|
+
RsDateTimeValidationRules,
|
|
366
|
+
RsDateValidationError,
|
|
367
|
+
RsDateValidationResult,
|
|
368
|
+
RsDateValidationRules,
|
|
369
|
+
} from './components/date-validation'
|
|
370
|
+
export { validateDateTimeValue, validateDateValue } from './components/date-validation'
|
|
371
|
+
export type { RsTimeValidationError, RsTimeValidationResult, RsTimeValidationRules } from './components/time-validation'
|
|
372
|
+
export { validateTimeValue } from './components/time-validation'
|
|
373
|
+
export type {
|
|
374
|
+
RsDateRangeValidationError,
|
|
375
|
+
RsDateRangeValidationResult,
|
|
376
|
+
RsDateRangeValidationRules,
|
|
377
|
+
RsDateTimeRangeValidationError,
|
|
378
|
+
RsDateTimeRangeValidationResult,
|
|
379
|
+
RsDateTimeRangeValidationRules,
|
|
380
|
+
} from './components/date-range-validation'
|
|
381
|
+
export { validateDateRangeValue, validateDateTimeRangeValue } from './components/date-range-validation'
|
|
382
|
+
export type {
|
|
383
|
+
RsTimeRangeValidationError,
|
|
384
|
+
RsTimeRangeValidationResult,
|
|
385
|
+
RsTimeRangeValidationRules,
|
|
386
|
+
} from './components/time-range-validation'
|
|
387
|
+
export { validateTimeRangeValue } from './components/time-range-validation'
|
|
388
|
+
export {
|
|
389
|
+
clampPage,
|
|
390
|
+
createPageSizeSelectOptions,
|
|
391
|
+
DEFAULT_PAGE_SIZE_OPTIONS,
|
|
392
|
+
getPageCount,
|
|
393
|
+
getPaginationRange,
|
|
394
|
+
slicePageData,
|
|
395
|
+
} from './components/pagination-utils'
|
|
396
|
+
export type {
|
|
397
|
+
RsInputRule,
|
|
398
|
+
RsInputValidateTrigger,
|
|
399
|
+
RsInputValidateResult,
|
|
400
|
+
} from './components/input-rules'
|
|
401
|
+
export {
|
|
402
|
+
validateInputRule,
|
|
403
|
+
runInputValidation,
|
|
404
|
+
getInputRuleMessage,
|
|
405
|
+
inputRuleMessageKeys,
|
|
406
|
+
} from './components/input-rules'
|
|
407
|
+
export { useRsI18n, createTranslator } from './composables/useRsI18n'
|
|
408
|
+
export type { RsTranslateFn } from './composables/useRsI18n'
|
|
409
|
+
export { useRsToast } from './composables/useRsToast'
|
|
410
|
+
export type { RsToastInput } from './composables/useRsToast'
|
|
411
|
+
export {
|
|
412
|
+
rsCommonIconNames,
|
|
413
|
+
LUCIDE_ATTRIBUTION,
|
|
414
|
+
LUCIDE_LICENSE,
|
|
415
|
+
lucideIconCount,
|
|
416
|
+
isRsIconName,
|
|
417
|
+
} from './icons/registry'
|
|
418
|
+
export type { RsThemeMode, RsThemeTokens, RsComponentSize, RsRadius } from './theme/types'
|
|
419
|
+
export { RS_COMPONENT_SIZES, RS_COMPONENT_SIZE_ICON_PX, RS_RADII, RS_RADIUS_CSS } from './theme/types'
|
|
420
|
+
export type { RsLocale } from './locale/types'
|
|
421
|
+
export { useRsConfig, useRsConfigOptional, createRsConfigState } from './composables/useRsConfig'
|
|
422
|
+
export { useResolvedRsComponentSize, resolveRsComponentSize } from './components/resolve-size'
|
|
423
|
+
export { useResolvedRsRadius, rsRadiusCss } from './components/resolve-radius'
|
|
424
|
+
export { themePresets } from './theme/presets'
|
|
425
|
+
export { applyTheme } from './theme/apply'
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 带显式时区的 ISO-8601 ↔ 本机本地墙钟。
|
|
3
|
+
* 用于表格展示 / 编辑草稿 / 写回,避免剥 Z 丢时区,并尽量保留毫秒。
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** `YYYY-MM-DDTHH:mm:ssZ` = 20;含毫秒/偏移上限约 35,放宽到 40 */
|
|
7
|
+
const ISO_TZ_MIN_LEN = 20
|
|
8
|
+
const ISO_TZ_MAX_LEN = 40
|
|
9
|
+
|
|
10
|
+
const ISO_WITH_TZ_RE =
|
|
11
|
+
/^(\d{4}-\d{2}-\d{2})[T ](\d{2}:\d{2}:\d{2})(\.\d{1,9})?(Z|[+-]\d{2}:?\d{2})$/i
|
|
12
|
+
|
|
13
|
+
/** 本地墙钟(无时区) */
|
|
14
|
+
const LOCAL_DATETIME_RE =
|
|
15
|
+
/^(\d{4}-\d{2}-\d{2})[T ](\d{2}:\d{2}:\d{2})(\.\d{1,9})?$/
|
|
16
|
+
|
|
17
|
+
function pad2(n: number): string {
|
|
18
|
+
return String(n).padStart(2, '0')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function pad3(n: number): string {
|
|
22
|
+
return String(n).padStart(3, '0')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function isDigit(c: string): boolean {
|
|
26
|
+
return c >= '0' && c <= '9'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 廉价判定:是否像「带时区的 ISO 日期时间」。
|
|
31
|
+
* 失败路径只做长度/字符检查,避免对普通文本跑正则。
|
|
32
|
+
*/
|
|
33
|
+
export function looksLikeIsoDateTimeWithTz(value: string): boolean {
|
|
34
|
+
const n = value.length
|
|
35
|
+
if (n < ISO_TZ_MIN_LEN || n > ISO_TZ_MAX_LEN) return false
|
|
36
|
+
if (
|
|
37
|
+
!isDigit(value[0]!) ||
|
|
38
|
+
!isDigit(value[1]!) ||
|
|
39
|
+
!isDigit(value[2]!) ||
|
|
40
|
+
!isDigit(value[3]!) ||
|
|
41
|
+
value[4] !== '-' ||
|
|
42
|
+
!isDigit(value[5]!) ||
|
|
43
|
+
!isDigit(value[6]!) ||
|
|
44
|
+
value[7] !== '-' ||
|
|
45
|
+
!isDigit(value[8]!) ||
|
|
46
|
+
!isDigit(value[9]!)
|
|
47
|
+
) {
|
|
48
|
+
return false
|
|
49
|
+
}
|
|
50
|
+
const sep = value[10]
|
|
51
|
+
if (sep !== 'T' && sep !== 't' && sep !== ' ') return false
|
|
52
|
+
const last = value[n - 1]!
|
|
53
|
+
if (last === 'Z' || last === 'z') return true
|
|
54
|
+
if (n >= 25 && (value.includes('+', 19) || value.lastIndexOf('-') > 19)) return true
|
|
55
|
+
return false
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function formatLocalFromDate(d: Date, withMs: boolean): string {
|
|
59
|
+
const base =
|
|
60
|
+
`${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())} ` +
|
|
61
|
+
`${pad2(d.getHours())}:${pad2(d.getMinutes())}:${pad2(d.getSeconds())}`
|
|
62
|
+
if (!withMs) return base
|
|
63
|
+
return `${base}.${pad3(d.getMilliseconds())}`
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function formatUtcIsoFromDate(d: Date, withMs: boolean): string {
|
|
67
|
+
const base =
|
|
68
|
+
`${d.getUTCFullYear()}-${pad2(d.getUTCMonth() + 1)}-${pad2(d.getUTCDate())}T` +
|
|
69
|
+
`${pad2(d.getUTCHours())}:${pad2(d.getUTCMinutes())}:${pad2(d.getUTCSeconds())}`
|
|
70
|
+
if (!withMs) return `${base}Z`
|
|
71
|
+
return `${base}.${pad3(d.getUTCMilliseconds())}Z`
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function localSecondKey(local: string): string {
|
|
75
|
+
// `YYYY-MM-DD HH:mm:ss` 前 19 字符;兼容 T 分隔
|
|
76
|
+
const t = local.trim().replace('T', ' ')
|
|
77
|
+
return t.length >= 19 ? t.slice(0, 19) : t
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** 将带时区的 ISO 串转为本地时间;无法识别则返回 null。 */
|
|
81
|
+
export function formatIsoUtcToLocal(value: string): string | null {
|
|
82
|
+
const t = value.trim()
|
|
83
|
+
if (!looksLikeIsoDateTimeWithTz(t)) return null
|
|
84
|
+
|
|
85
|
+
const m = ISO_WITH_TZ_RE.exec(t)
|
|
86
|
+
if (!m) return null
|
|
87
|
+
|
|
88
|
+
const hasFrac = Boolean(m[3])
|
|
89
|
+
const frac = hasFrac ? m[3]!.slice(0, 4) : ''
|
|
90
|
+
const iso = `${m[1]}T${m[2]}${frac}${m[4]}`
|
|
91
|
+
const d = new Date(iso)
|
|
92
|
+
if (Number.isNaN(d.getTime())) return null
|
|
93
|
+
|
|
94
|
+
return formatLocalFromDate(d, hasFrac)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 将本地墙钟(或已带时区的 ISO)写回 UTC ISO。
|
|
99
|
+
* - 与 previousIso 在「秒」级一致且输入无新小数秒 → 原样返回 previous(保留毫秒/更长小数)
|
|
100
|
+
* - 否则按输入精度生成 `...Z`(有小数秒则到毫秒)
|
|
101
|
+
*/
|
|
102
|
+
export function parseLocalDateTimeToUtcIso(
|
|
103
|
+
local: string,
|
|
104
|
+
previousIso?: string,
|
|
105
|
+
): string | null {
|
|
106
|
+
const t = local.trim()
|
|
107
|
+
if (!t) return null
|
|
108
|
+
|
|
109
|
+
if (looksLikeIsoDateTimeWithTz(t)) {
|
|
110
|
+
const m = ISO_WITH_TZ_RE.exec(t)
|
|
111
|
+
if (!m) return null
|
|
112
|
+
const hasFrac = Boolean(m[3])
|
|
113
|
+
const frac = hasFrac ? m[3]!.slice(0, 4) : ''
|
|
114
|
+
const d = new Date(`${m[1]}T${m[2]}${frac}${m[4]}`)
|
|
115
|
+
if (Number.isNaN(d.getTime())) return null
|
|
116
|
+
const prev = previousIso?.trim()
|
|
117
|
+
if (prev && looksLikeIsoDateTimeWithTz(prev)) {
|
|
118
|
+
const prevLocal = formatIsoUtcToLocal(prev)
|
|
119
|
+
if (
|
|
120
|
+
prevLocal &&
|
|
121
|
+
!hasFrac &&
|
|
122
|
+
localSecondKey(prevLocal) === localSecondKey(formatLocalFromDate(d, false))
|
|
123
|
+
) {
|
|
124
|
+
return prev
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return formatUtcIsoFromDate(d, hasFrac)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const m = LOCAL_DATETIME_RE.exec(t)
|
|
131
|
+
if (!m) return null
|
|
132
|
+
|
|
133
|
+
const hasFrac = Boolean(m[3])
|
|
134
|
+
const frac = hasFrac ? m[3]!.slice(0, 4) : ''
|
|
135
|
+
// 无 Z 的日期时间按 ES 本地时区解析
|
|
136
|
+
const d = new Date(`${m[1]}T${m[2]}${frac}`)
|
|
137
|
+
if (Number.isNaN(d.getTime())) return null
|
|
138
|
+
|
|
139
|
+
const prev = previousIso?.trim()
|
|
140
|
+
if (prev && looksLikeIsoDateTimeWithTz(prev)) {
|
|
141
|
+
const prevLocal = formatIsoUtcToLocal(prev)
|
|
142
|
+
if (prevLocal) {
|
|
143
|
+
const inputNorm = t.replace('T', ' ')
|
|
144
|
+
// 草稿与展示本地值完全一致 → 原样写回(保留 .NET 7 位等超毫秒小数)
|
|
145
|
+
if (inputNorm === prevLocal) return prev
|
|
146
|
+
// 日期选择器通常只到秒:未改秒则保留原始精度
|
|
147
|
+
if (!hasFrac && localSecondKey(prevLocal) === localSecondKey(inputNorm)) return prev
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return formatUtcIsoFromDate(d, hasFrac)
|
|
152
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import dayjs, { type Dayjs } from 'dayjs'
|
|
2
|
+
import customParseFormat from 'dayjs/plugin/customParseFormat'
|
|
3
|
+
|
|
4
|
+
dayjs.extend(customParseFormat)
|
|
5
|
+
|
|
6
|
+
/** 日期 v-model / 展示格式 */
|
|
7
|
+
export const RS_DATE_FORMAT = 'YYYY-MM-DD'
|
|
8
|
+
|
|
9
|
+
/** 日期时间 v-model / 展示格式 */
|
|
10
|
+
export const RS_DATETIME_FORMAT = 'YYYY-MM-DD HH:mm:ss'
|
|
11
|
+
|
|
12
|
+
/** 时间片段格式(含秒) */
|
|
13
|
+
export const RS_TIME_SECONDS_FORMAT = 'HH:mm:ss'
|
|
14
|
+
|
|
15
|
+
/** 时间片段格式(分钟精度) */
|
|
16
|
+
export const RS_TIME_MINUTE_FORMAT = 'HH:mm'
|
|
17
|
+
|
|
18
|
+
export const RS_DATE_PARSE_FORMATS = [
|
|
19
|
+
RS_DATE_FORMAT,
|
|
20
|
+
'YYYY/MM/DD',
|
|
21
|
+
'YYYY-M-D',
|
|
22
|
+
] as const
|
|
23
|
+
|
|
24
|
+
/** 日期时间解析:兼容空格分隔与 ISO `T` 分隔(表格/后端常见) */
|
|
25
|
+
export const RS_DATETIME_PARSE_FORMATS = [
|
|
26
|
+
RS_DATETIME_FORMAT,
|
|
27
|
+
'YYYY-MM-DD HH:mm',
|
|
28
|
+
'YYYY-MM-DDTHH:mm:ss',
|
|
29
|
+
'YYYY-MM-DDTHH:mm',
|
|
30
|
+
'YYYY-MM-DDTHH:mm:ss.SSS',
|
|
31
|
+
] as const
|
|
32
|
+
|
|
33
|
+
export function parseRsDayjs(
|
|
34
|
+
value?: string,
|
|
35
|
+
formats: readonly string[] = RS_DATE_PARSE_FORMATS,
|
|
36
|
+
): Dayjs | null {
|
|
37
|
+
if (!value) return null
|
|
38
|
+
const parsed = dayjs(value, [...formats], true)
|
|
39
|
+
return parsed.isValid() ? parsed : null
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function parseRsDateTimeDayjs(value?: string): Dayjs | null {
|
|
43
|
+
if (!value) return null
|
|
44
|
+
// 去掉末尾 Z / 偏移,按本地墙钟解析(选中态与展示一致)
|
|
45
|
+
const normalized = value
|
|
46
|
+
.trim()
|
|
47
|
+
.replace(/Z$/i, '')
|
|
48
|
+
.replace(/[+-]\d{2}:?\d{2}$/, '')
|
|
49
|
+
for (const format of RS_DATETIME_PARSE_FORMATS) {
|
|
50
|
+
const parsed = dayjs(normalized, format, true)
|
|
51
|
+
if (parsed.isValid()) return parsed
|
|
52
|
+
}
|
|
53
|
+
return null
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { dayjs }
|