frappe-ui 1.1.0 → 1.2.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/experimental/Calendar/CalendarEventRow.vue +0 -4
- package/experimental/CommandPalette/CommandPaletteItem.vue +9 -1
- package/experimental/SpriteIcons/IconPicker.vue +2 -1
- package/experimental.ts +0 -21
- package/package.json +1 -3
- package/src/components/Breadcrumbs/Breadcrumbs.vue +2 -1
- package/src/components/DatePicker/DatePicker.md +7 -0
- package/src/components/DatePicker/DatePicker.vue +6 -0
- package/src/components/DatePicker/DateTimePicker.vue +6 -0
- package/src/components/DatePicker/composables.ts +18 -1
- package/src/components/DatePicker/utils.ts +53 -0
- package/src/components/HoverCard/HoverCard.vue +21 -5
- package/src/components/MobileNav/MobileNavItem.vue +3 -22
- package/src/components/SettingsDialog/SettingsDialog.api.md +7 -2
- package/src/components/SettingsDialog/SettingsDialog.md +2 -1
- package/src/components/SettingsDialog/SettingsRow.vue +12 -2
- package/src/components/Sidebar/SidebarItem.vue +3 -33
- package/src/components/SidebarRail/SidebarRailItem.vue +4 -17
- package/src/components/Tooltip/Tooltip.vue +8 -0
- package/src/components/shared/deferredTrigger.ts +174 -0
- package/src/components/shared/navLink.ts +45 -0
- package/src/molecules/editor/extensions/attachment/attachment-engine.ts +1 -1
- package/src/molecules/editor/extensions/content-paste/paste-html-utils.ts +16 -6
- package/src/molecules/editor/extensions/iframe/IframeNodeView.vue +26 -9
- package/src/molecules/editor/extensions/iframe/iframe-allowlist.ts +35 -16
- package/src/molecules/editor/extensions/iframe/iframe-embed-utils.ts +1 -1
- package/src/molecules/editor/extensions/iframe/iframe-extension.ts +30 -30
- package/src/molecules/editor/extensions/link/LinkEditorPopup.vue +1 -1
- package/src/molecules/editor/extensions/link/link-paste-plugin.ts +1 -1
- package/src/molecules/editor/extensions/shared/media-upload-engine.ts +1 -1
- package/src/molecules/list/ListRow.vue +8 -1
- package/src/utils/dialog.ts +20 -2
- package/src/{molecules/editor/extensions/shared → utils}/url-safety.ts +28 -16
- package/tailwind/content.js +0 -1
- package/tailwind/plugin.js +22 -0
- package/vite/doctypeInterfaceGenerator.js +52 -39
- package/vitepress/index.node.ts +0 -2
- package/experimental/TextEditor/TextEditor.api.md +0 -161
- package/experimental/TextEditor/TextEditor.vue +0 -298
- package/experimental/TextEditor/classIcon.ts +0 -21
- package/experimental/TextEditor/commands.js +0 -344
- package/experimental/TextEditor/components/CodeBlockComponent.vue +0 -103
- package/experimental/TextEditor/components/FontColor.vue +0 -153
- package/experimental/TextEditor/components/ImageViewerModal.vue +0 -463
- package/experimental/TextEditor/components/InsertImage.vue +0 -54
- package/experimental/TextEditor/components/InsertLink.vue +0 -13
- package/experimental/TextEditor/components/InsertVideo.vue +0 -14
- package/experimental/TextEditor/components/LinkPopup.vue +0 -99
- package/experimental/TextEditor/components/MediaNodeView.vue +0 -398
- package/experimental/TextEditor/components/MentionList.vue +0 -95
- package/experimental/TextEditor/components/TextEditorBubbleMenu.vue +0 -78
- package/experimental/TextEditor/components/TextEditorFixedMenu.vue +0 -78
- package/experimental/TextEditor/components/TextEditorFloatingMenu.vue +0 -61
- package/experimental/TextEditor/components/TextEditorMenu.vue +0 -218
- package/experimental/TextEditor/components/index.js +0 -0
- package/experimental/TextEditor/extensions/code-block.ts +0 -119
- package/experimental/TextEditor/extensions/color/color-extension.ts +0 -140
- package/experimental/TextEditor/extensions/color/color-styles.css +0 -25
- package/experimental/TextEditor/extensions/color/index.ts +0 -2
- package/experimental/TextEditor/extensions/content-paste-extension.ts +0 -160
- package/experimental/TextEditor/extensions/copy-styles.ts +0 -160
- package/experimental/TextEditor/extensions/emoji/EmojiList.vue +0 -55
- package/experimental/TextEditor/extensions/emoji/emoji-extension.ts +0 -55
- package/experimental/TextEditor/extensions/emoji/emojis.json +0 -7422
- package/experimental/TextEditor/extensions/heading/heading.ts +0 -20
- package/experimental/TextEditor/extensions/highlight/highlight-extension.ts +0 -241
- package/experimental/TextEditor/extensions/highlight/highlight-styles.css +0 -31
- package/experimental/TextEditor/extensions/highlight/index.ts +0 -2
- package/experimental/TextEditor/extensions/iframe/IframeNodeView.vue +0 -308
- package/experimental/TextEditor/extensions/iframe/InsertIframe.vue +0 -209
- package/experimental/TextEditor/extensions/iframe/iframe-extension.ts +0 -404
- package/experimental/TextEditor/extensions/iframe/index.ts +0 -11
- package/experimental/TextEditor/extensions/iframe/utils.ts +0 -283
- package/experimental/TextEditor/extensions/image/image-extension.ts +0 -661
- package/experimental/TextEditor/extensions/image/index.ts +0 -5
- package/experimental/TextEditor/extensions/image-group/ImageGroupNodeView.vue +0 -182
- package/experimental/TextEditor/extensions/image-group/ImageGroupUploadDialog.vue +0 -740
- package/experimental/TextEditor/extensions/image-group/image-group-extension.ts +0 -187
- package/experimental/TextEditor/extensions/image-viewer-extension.ts +0 -162
- package/experimental/TextEditor/extensions/link/index.ts +0 -1
- package/experimental/TextEditor/extensions/link/link-extension.ts +0 -323
- package/experimental/TextEditor/extensions/link/linkPasteHandler.ts +0 -51
- package/experimental/TextEditor/extensions/mention/index.ts +0 -1
- package/experimental/TextEditor/extensions/mention/mention-extension.ts +0 -204
- package/experimental/TextEditor/extensions/mention/style.css +0 -11
- package/experimental/TextEditor/extensions/shared/color-utils.ts +0 -236
- package/experimental/TextEditor/extensions/slash-commands/SlashCommandsList.vue +0 -59
- package/experimental/TextEditor/extensions/slash-commands/slash-commands-extension.ts +0 -184
- package/experimental/TextEditor/extensions/suggestion/SuggestionList.vue +0 -130
- package/experimental/TextEditor/extensions/suggestion/createSuggestionExtension.ts +0 -151
- package/experimental/TextEditor/extensions/suggestion/index.ts +0 -5
- package/experimental/TextEditor/extensions/tag/index.ts +0 -1
- package/experimental/TextEditor/extensions/tag/tag-extension.ts +0 -170
- package/experimental/TextEditor/extensions/toc-node/TocNodeView.vue +0 -439
- package/experimental/TextEditor/extensions/toc-node/index.ts +0 -3
- package/experimental/TextEditor/extensions/toc-node/toc-node-extension.ts +0 -167
- package/experimental/TextEditor/extensions/video-extension.ts +0 -653
- package/experimental/TextEditor/hljs-github.css +0 -197
- package/experimental/TextEditor/index.ts +0 -21
- package/experimental/TextEditor/style.css +0 -190
- package/experimental/TextEditor/types.ts +0 -72
- package/experimental/TextEditor/utils.js +0 -11
- package/src/utils/url-validation.ts +0 -39
|
@@ -132,10 +132,6 @@
|
|
|
132
132
|
>
|
|
133
133
|
<!-- Declined reads the same here as on a pill: struck through and
|
|
134
134
|
muted, still plainly the event you said no to. -->
|
|
135
|
-
<!-- leading-5 and leading-4 below, rather than the sizes' own 1.15: at
|
|
136
|
-
13px that leaves a 14.95px line box for glyphs that stand 16px, and
|
|
137
|
-
truncate's overflow-hidden then slices the descender off a g or a y.
|
|
138
|
-
The line box has to clear the ink before it can be clipped for width. -->
|
|
139
135
|
<span
|
|
140
136
|
class="calendar-row-title truncate leading-5"
|
|
141
137
|
:class="[
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
:data-state="active ? 'active' : undefined"
|
|
15
15
|
:data-disabled="disabled ? '' : undefined"
|
|
16
16
|
class="mx-2.5 flex min-w-0 cursor-default items-center rounded-4 px-2 py-2 text-base-medium leading-tighter text-ink-gray-8 outline-none data-[state=active]:bg-surface-gray-2 data-[disabled]:cursor-not-allowed data-[disabled]:text-ink-gray-4"
|
|
17
|
-
v-bind="$attrs"
|
|
17
|
+
v-bind="{ ...$attrs, ...checkedHref($attrs) }"
|
|
18
18
|
>
|
|
19
19
|
<slot name="prefix" v-bind="slotProps" />
|
|
20
20
|
<span
|
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
useCommandPaletteGroupContext,
|
|
49
49
|
useCommandPaletteListContext,
|
|
50
50
|
} from './context'
|
|
51
|
+
import { safeHref } from '#utils/url-safety'
|
|
51
52
|
import type {
|
|
52
53
|
CommandPaletteItemEmits,
|
|
53
54
|
CommandPaletteItemProps,
|
|
@@ -73,6 +74,7 @@ defineSlots<{
|
|
|
73
74
|
}>()
|
|
74
75
|
|
|
75
76
|
const palette = useCommandPaletteContext()
|
|
77
|
+
|
|
76
78
|
const group = useCommandPaletteGroupContext()
|
|
77
79
|
const list = useCommandPaletteListContext()
|
|
78
80
|
|
|
@@ -174,6 +176,12 @@ const slotProps = computed<CommandPaletteItemSlotProps>(() => ({
|
|
|
174
176
|
disabled: props.disabled ?? false,
|
|
175
177
|
}))
|
|
176
178
|
|
|
179
|
+
// Check only an href the caller passed. Adding `href: undefined` would fall
|
|
180
|
+
// through a RouterLink onto its anchor and erase the href it generates.
|
|
181
|
+
function checkedHref(attrs: Record<string, unknown>) {
|
|
182
|
+
return 'href' in attrs ? { href: safeHref(attrs.href) } : {}
|
|
183
|
+
}
|
|
184
|
+
|
|
177
185
|
function onSelect(event: CommandPaletteSelectEvent) {
|
|
178
186
|
emit('select', event)
|
|
179
187
|
if (event.defaultPrevented) return
|
|
@@ -167,6 +167,7 @@ defineExpose({
|
|
|
167
167
|
<Icon
|
|
168
168
|
:name="internalModelValue || 'circle-dashed'"
|
|
169
169
|
class="w-4 h-4 flex-shrink-0"
|
|
170
|
+
:class="internalModelValue ? 'text-ink-gray-8' : 'text-ink-gray-4'"
|
|
170
171
|
/>
|
|
171
172
|
<ComboboxInput
|
|
172
173
|
:value="searchTerm"
|
|
@@ -207,7 +208,7 @@ defineExpose({
|
|
|
207
208
|
:key="iconName"
|
|
208
209
|
@click="handleIconClick(iconName)"
|
|
209
210
|
type="button"
|
|
210
|
-
class="w-8 h-8 flex items-center justify-center rounded-4 hover:bg-surface-gray-3 transition-colors"
|
|
211
|
+
class="w-8 h-8 flex items-center justify-center rounded-4 text-ink-gray-7 hover:bg-surface-gray-3 transition-colors"
|
|
211
212
|
:class="{
|
|
212
213
|
'bg-surface-gray-3': internalModelValue === iconName,
|
|
213
214
|
}"
|
package/experimental.ts
CHANGED
|
@@ -54,27 +54,6 @@ export type {
|
|
|
54
54
|
PickerShellSlots,
|
|
55
55
|
PickerShellExposed,
|
|
56
56
|
} from './src/components/shared/picker/types'
|
|
57
|
-
// v0 TextEditor family. Moved out of root (#974) — `frappe-ui/editor` is the
|
|
58
|
-
// composition-based replacement. Parked here (#1007), unstable, as an interim
|
|
59
|
-
// import path while apps migrate. Deletion stays human-gated (spec/editor.md
|
|
60
|
-
// §12).
|
|
61
|
-
export {
|
|
62
|
-
TextEditor,
|
|
63
|
-
TextEditorBubbleMenu,
|
|
64
|
-
TextEditorFixedMenu,
|
|
65
|
-
TextEditorFloatingMenu,
|
|
66
|
-
TextEditorContent,
|
|
67
|
-
createEditorButton,
|
|
68
|
-
} from './experimental/TextEditor'
|
|
69
|
-
export {
|
|
70
|
-
ImageExtension,
|
|
71
|
-
type SetImageOptions,
|
|
72
|
-
} from './experimental/TextEditor/extensions/image'
|
|
73
|
-
export {
|
|
74
|
-
createSuggestionExtension,
|
|
75
|
-
type BaseSuggestionItem,
|
|
76
|
-
type CreateSuggestionExtensionOptions,
|
|
77
|
-
} from './experimental/TextEditor/extensions/suggestion'
|
|
78
57
|
// ThemeSwitcher. Moved out of root (#1094) — `Select` bound to
|
|
79
58
|
// `useColorScheme()` is the replacement, and it replaces the behavior rather
|
|
80
59
|
// than the markup: this renders a reka-ui `RadioGroupRoot` of preview cards.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "frappe-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A set of components and utilities for rapid UI development",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.19.0"
|
|
@@ -203,7 +203,6 @@
|
|
|
203
203
|
"@tiptap/extensions": "^3.26.0",
|
|
204
204
|
"@tiptap/markdown": "^3.26.0",
|
|
205
205
|
"@tiptap/pm": "^3.26.0",
|
|
206
|
-
"@tiptap/starter-kit": "^3.26.0",
|
|
207
206
|
"@tiptap/suggestion": "^3.26.0",
|
|
208
207
|
"@tiptap/vue-3": "^3.26.0",
|
|
209
208
|
"@vue/compiler-sfc": "^3.5.13",
|
|
@@ -221,7 +220,6 @@
|
|
|
221
220
|
"marked": "^15.0.12",
|
|
222
221
|
"reka-ui": "^2.9.9",
|
|
223
222
|
"socket.io-client": "^4.5.1",
|
|
224
|
-
"tippy.js": "^6.3.7",
|
|
225
223
|
"typescript": "^5.0.2",
|
|
226
224
|
"unplugin-auto-import": "^19.3.0",
|
|
227
225
|
"unplugin-icons": "^22.1.0",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
</router-link>
|
|
40
40
|
<a
|
|
41
41
|
v-else-if="item.href"
|
|
42
|
-
:href="item.href"
|
|
42
|
+
:href="safeHref(item.href)"
|
|
43
43
|
@click="onLinkClick(item, $event)"
|
|
44
44
|
class="flex items-center rounded-4 px-0.5 py-1 text-lg-medium leading-tighter"
|
|
45
45
|
:class="[
|
|
@@ -93,6 +93,7 @@ import { useRouter } from 'vue-router'
|
|
|
93
93
|
import { Dropdown } from '../Dropdown'
|
|
94
94
|
import { Button } from '../Button'
|
|
95
95
|
import type { BreadcrumbsProps } from './types'
|
|
96
|
+
import { safeHref } from '../../utils/url-safety'
|
|
96
97
|
import { ref, computed, nextTick, useTemplateRef } from 'vue'
|
|
97
98
|
import { useResizeObserver } from '@vueuse/core'
|
|
98
99
|
import type { BreadcrumbItem } from './types'
|
|
@@ -57,6 +57,13 @@ People can type a date into the input by default. Set `:typeable="false"` to
|
|
|
57
57
|
allow picking from the calendar only. On `DateTimePicker`, `typeable` covers
|
|
58
58
|
both the date and the time inputs.
|
|
59
59
|
|
|
60
|
+
With a `format`, typed numbers read in that format's day-month-year order.
|
|
61
|
+
Under `DD-MM-YYYY`, `3-11-2026`, `3/11/26` and `03.11.2026` all mean
|
|
62
|
+
3 November 2026. A `DateTimePicker` also takes the date without its seconds or
|
|
63
|
+
without a time, and a 12-hour time in either AM/PM case. ISO text (`2026-11-03`) and text with a month name
|
|
64
|
+
(`Nov 3, 2026`) read as they do with no `format`. A focus and blur with no edit
|
|
65
|
+
leaves the value as it is.
|
|
66
|
+
|
|
60
67
|
### Clearing
|
|
61
68
|
|
|
62
69
|
`clearable` is `true` by default, and an empty input clears the value. On
|
|
@@ -254,6 +254,12 @@ function commitInput(close = false): void {
|
|
|
254
254
|
}
|
|
255
255
|
return
|
|
256
256
|
}
|
|
257
|
+
// An unedited blur keeps the value. Reading the shown text back would drop
|
|
258
|
+
// what the format leaves out, such as the seconds.
|
|
259
|
+
if (props.modelValue && raw === displayLabel.value) {
|
|
260
|
+
if (close && !shouldKeepOpen.value) isOpen.value = false
|
|
261
|
+
return
|
|
262
|
+
}
|
|
257
263
|
const d = coerceToDayjs(raw)
|
|
258
264
|
if (d && !checkUnavailable(d)) {
|
|
259
265
|
selectDate(d)
|
|
@@ -320,6 +320,12 @@ function commitInput(close = false): void {
|
|
|
320
320
|
if (close && !shouldKeepOpen.value) isOpen.value = false
|
|
321
321
|
return
|
|
322
322
|
}
|
|
323
|
+
// An unedited blur keeps the value. Reading the shown text back would drop
|
|
324
|
+
// what the format leaves out, such as the seconds.
|
|
325
|
+
if (props.modelValue && raw === displayLabel.value) {
|
|
326
|
+
if (close && !shouldKeepOpen.value) isOpen.value = false
|
|
327
|
+
return
|
|
328
|
+
}
|
|
323
329
|
const parsed = coerceToDayjs(raw)
|
|
324
330
|
if (parsed && !checkUnavailable(parsed)) {
|
|
325
331
|
selectDate(parsed)
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { ref, computed, watch } from 'vue'
|
|
2
2
|
import type { Dayjs } from 'dayjs/esm'
|
|
3
3
|
import { dayjs } from '../../utils/dayjs'
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
generateWeeks,
|
|
6
|
+
monthStart,
|
|
7
|
+
getDateValue,
|
|
8
|
+
ISO_DATE,
|
|
9
|
+
typedFormats,
|
|
10
|
+
withFormatSeparator,
|
|
11
|
+
} from './utils'
|
|
5
12
|
import type { CalendarPanelExposed } from './calendarTypes'
|
|
6
13
|
import type {
|
|
7
14
|
CommonDatePickerProps,
|
|
@@ -94,6 +101,9 @@ export function useKeepOpen(props: CommonDatePickerProps) {
|
|
|
94
101
|
}
|
|
95
102
|
|
|
96
103
|
// Coerce arbitrary string input to a Dayjs, respecting an optional explicit format.
|
|
104
|
+
// With a format, text of numbers alone reads in that format's day-month-year
|
|
105
|
+
// order: `3-11-2026` under `DD-MM-YYYY` is 3 November, not 11 March. ISO text
|
|
106
|
+
// (the value itself) and text with a month name keep the loose parse.
|
|
97
107
|
export function useDateCoercion(getFormat: () => string | undefined) {
|
|
98
108
|
return function coerceToDayjs(val?: string | null): Dayjs | null {
|
|
99
109
|
if (!val) return null
|
|
@@ -103,6 +113,13 @@ export function useDateCoercion(getFormat: () => string | undefined) {
|
|
|
103
113
|
if (format) {
|
|
104
114
|
const dStrict = dayjs(raw, format, true)
|
|
105
115
|
if (dStrict.isValid()) return dStrict
|
|
116
|
+
if (!ISO_DATE.test(raw)) {
|
|
117
|
+
const typed = withFormatSeparator(raw, format)
|
|
118
|
+
const dTyped = dayjs(typed, typedFormats(format), true)
|
|
119
|
+
if (dTyped.isValid()) return dTyped
|
|
120
|
+
// AM/PM is not a month name: the loose parse would read it month-first.
|
|
121
|
+
if (!/[a-z]/i.test(raw.replace(/[ap]\.?m\.?/gi, ''))) return null
|
|
122
|
+
}
|
|
106
123
|
}
|
|
107
124
|
const dLoose = dayjs(raw)
|
|
108
125
|
if (dLoose.isValid()) return dLoose
|
|
@@ -53,6 +53,59 @@ export function generateWeeks(
|
|
|
53
53
|
return chunked
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
/** Text that starts like an ISO date (`2026-11-03`, `2026/11/03`), which a loose parse reads right. */
|
|
57
|
+
export const ISO_DATE = /^\d{4}[-/]\d{1,2}[-/]\d{1,2}/
|
|
58
|
+
|
|
59
|
+
// A format token, or a `[literal]` that must stay as written.
|
|
60
|
+
const TOKEN_OR_LITERAL = /\[[^\]]*\]|[aA]/g
|
|
61
|
+
|
|
62
|
+
// Each turns a format into one more a person may type under it.
|
|
63
|
+
const TYPED_VARIANTS: ((format: string) => string)[] = [
|
|
64
|
+
(f) => f.replace(/(?<!D)DD(?!D)/, 'D'),
|
|
65
|
+
(f) => f.replace(/(?<!M)MM(?!M)/, 'M'),
|
|
66
|
+
(f) => f.replace(/(?<!Y)YYYY(?!Y)/, 'YY'),
|
|
67
|
+
(f) => f.replace(/(?<![Hh])(HH|hh)(?![Hh])/, (t) => t[0]),
|
|
68
|
+
(f) => f.replace(/:ss/, ''),
|
|
69
|
+
(f) => (/s/.test(f) ? f : f.replace(/mm/, 'mm:ss')),
|
|
70
|
+
(f) => f.replace(/\s+[Hh].*$/, ''),
|
|
71
|
+
// `PM` typed under `a`, or `pm` under `A`.
|
|
72
|
+
(f) =>
|
|
73
|
+
f.replace(TOKEN_OR_LITERAL, (t) => (t === 'a' ? 'A' : t === 'A' ? 'a' : t)),
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
const typedFormatCache = new Map<string, string[]>()
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The formats a person may type a date in under a display `format`, in its
|
|
80
|
+
* day-month-year order: a day, month or hour with no leading zero, a two-digit
|
|
81
|
+
* year, seconds added or left out, no time, or the other AM/PM case.
|
|
82
|
+
* `DD-MM-YYYY HH:mm:ss` takes `3-11-26 9:15` and `03-11-2026`. Pass the text
|
|
83
|
+
* through `withFormatSeparator` first, so `3/11/26` is read too.
|
|
84
|
+
*/
|
|
85
|
+
export function typedFormats(format: string): string[] {
|
|
86
|
+
const cached = typedFormatCache.get(format)
|
|
87
|
+
if (cached) return cached
|
|
88
|
+
let formats = [format]
|
|
89
|
+
for (const variant of TYPED_VARIANTS) {
|
|
90
|
+
formats = [...new Set(formats.flatMap((f) => [f, variant(f)]))]
|
|
91
|
+
}
|
|
92
|
+
typedFormatCache.set(format, formats)
|
|
93
|
+
return formats
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* `text` with `-`, `/` or `.` between its date numbers changed to the one
|
|
98
|
+
* `format` uses. Only the date, before the first space, changes: a time such
|
|
99
|
+
* as `9.15` keeps its own separator.
|
|
100
|
+
*/
|
|
101
|
+
export function withFormatSeparator(text: string, format: string): string {
|
|
102
|
+
const separator = /(?<=[DMY])[-/.](?=[DMY])/.exec(format)?.[0]
|
|
103
|
+
if (!separator) return text
|
|
104
|
+
return text.replace(/^\S+/, (date) =>
|
|
105
|
+
date.replace(/(?<=\d)[-/.](?=\d)/g, separator),
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
|
|
56
109
|
export function getDateValue(date: Date | string) {
|
|
57
110
|
if (!date || date.toString() === 'Invalid Date') return ''
|
|
58
111
|
|
|
@@ -5,11 +5,13 @@ import {
|
|
|
5
5
|
HoverCardPortal,
|
|
6
6
|
HoverCardRoot,
|
|
7
7
|
HoverCardTrigger,
|
|
8
|
+
Slot,
|
|
8
9
|
injectHoverCardRootContext,
|
|
9
10
|
} from 'reka-ui'
|
|
10
11
|
import { computed, defineComponent, ref, watch } from 'vue'
|
|
11
12
|
import PopoverPanel from '../shared/popover/PopoverPanel.vue'
|
|
12
13
|
import { usePortalTarget } from '../../composables/usePortalTarget'
|
|
14
|
+
import { useDeferredTrigger } from '../shared/deferredTrigger'
|
|
13
15
|
import type {
|
|
14
16
|
HoverCardExposed,
|
|
15
17
|
HoverCardProps,
|
|
@@ -40,6 +42,9 @@ const closeDelay = computed(() => props.leaveDelay)
|
|
|
40
42
|
const triggerRef = ref<{ $el: Element } | null>(null)
|
|
41
43
|
const controllerRef = ref<{ setOpen: (value: boolean) => void } | null>(null)
|
|
42
44
|
|
|
45
|
+
// The trigger renders alone until it is first hovered or focused.
|
|
46
|
+
const { mounted, mount, shellProps } = useDeferredTrigger('hoverCard')
|
|
47
|
+
|
|
43
48
|
const HoverCardController = defineComponent({
|
|
44
49
|
setup(_, { expose }) {
|
|
45
50
|
const context = injectHoverCardRootContext()
|
|
@@ -69,11 +74,18 @@ function close() {
|
|
|
69
74
|
setOpen(false)
|
|
70
75
|
}
|
|
71
76
|
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
// Opening from the model, a template ref or a slot control mounts the card
|
|
78
|
+
// without a hover first. A controlled parent can also close without calling
|
|
79
|
+
// the slot control, so clear any imperative-open timer then, or Reka could
|
|
80
|
+
// reopen after the model turns false.
|
|
81
|
+
watch(
|
|
82
|
+
open,
|
|
83
|
+
(isOpen) => {
|
|
84
|
+
if (isOpen) mount()
|
|
85
|
+
else controllerRef.value?.setOpen(false)
|
|
86
|
+
},
|
|
87
|
+
{ immediate: true },
|
|
88
|
+
)
|
|
77
89
|
|
|
78
90
|
const slotProps = computed<HoverCardSlotProps>(() => ({
|
|
79
91
|
open: open.value,
|
|
@@ -102,7 +114,11 @@ function onPointerDownOutside(event: Event) {
|
|
|
102
114
|
</script>
|
|
103
115
|
|
|
104
116
|
<template>
|
|
117
|
+
<Slot v-if="!mounted" v-bind="shellProps">
|
|
118
|
+
<slot name="trigger" v-bind="slotProps" />
|
|
119
|
+
</Slot>
|
|
105
120
|
<HoverCardRoot
|
|
121
|
+
v-else
|
|
106
122
|
v-model:open="open"
|
|
107
123
|
:open-delay="openDelay"
|
|
108
124
|
:close-delay="closeDelay"
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
</template>
|
|
61
61
|
|
|
62
62
|
<script setup lang="ts">
|
|
63
|
-
import { computed
|
|
64
|
-
import { RouterLink } from 'vue-router'
|
|
63
|
+
import { computed } from 'vue'
|
|
65
64
|
import Icon from '../Icon/Icon.vue'
|
|
65
|
+
import { useNavLink } from '../shared/navLink'
|
|
66
66
|
import { scrollShellToTop } from '../../composables/useShellScrolled'
|
|
67
67
|
import type { MobileNavItemProps } from './types'
|
|
68
68
|
|
|
@@ -73,26 +73,7 @@ defineSlots<{
|
|
|
73
73
|
default?: (props: { active: boolean }) => any
|
|
74
74
|
}>()
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
// works without warnings when mounted outside a vue-router app — docs, tests,
|
|
78
|
-
// embedded use. Same approach as SidebarItem.
|
|
79
|
-
const globals = getCurrentInstance()?.appContext.config.globalProperties
|
|
80
|
-
const hasRouter = computed(() => Boolean(globals?.$router))
|
|
81
|
-
|
|
82
|
-
const linkComponent = computed(() =>
|
|
83
|
-
props.route && hasRouter.value ? RouterLink : 'a',
|
|
84
|
-
)
|
|
85
|
-
const linkAttrs = computed(() =>
|
|
86
|
-
props.route
|
|
87
|
-
? hasRouter.value
|
|
88
|
-
? { to: props.route }
|
|
89
|
-
: { href: typeof props.route === 'string' ? props.route : undefined }
|
|
90
|
-
: { href: props.href },
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
const resolvedRoute = computed(() =>
|
|
94
|
-
props.route && globals?.$router ? globals.$router.resolve(props.route) : null,
|
|
95
|
-
)
|
|
76
|
+
const { globals, linkComponent, linkAttrs, resolvedRoute } = useNavLink(props)
|
|
96
77
|
|
|
97
78
|
// Is this item's target the exact current route? Drives scroll-vs-navigate and
|
|
98
79
|
// aria-current — distinct from `active`, which may span a whole section.
|
|
@@ -223,8 +223,13 @@
|
|
|
223
223
|
const settingsRowSlots = [
|
|
224
224
|
{
|
|
225
225
|
name: 'default',
|
|
226
|
-
description: '',
|
|
227
|
-
type: '
|
|
226
|
+
description: 'The setting\'s control, on the right.',
|
|
227
|
+
type: 'any'
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
name: 'description',
|
|
231
|
+
description: 'Replaces the `description` text, for content such as a link.',
|
|
232
|
+
type: 'any'
|
|
228
233
|
}
|
|
229
234
|
]
|
|
230
235
|
</script>
|
|
@@ -92,7 +92,8 @@ headers never scroll away. `SettingsHeader` takes `title`, `description` and an
|
|
|
92
92
|
`SettingsRow` shows a setting's title and description on the left and its
|
|
93
93
|
control on the right. When the control is a frappe-ui control such as `Switch`,
|
|
94
94
|
the title becomes its `<label>`, with no `label-for` needed. Set `labelFor` to
|
|
95
|
-
point the label at another element's id.
|
|
95
|
+
point the label at another element's id. The `#description` slot replaces the
|
|
96
|
+
`description` text, for a description that holds markup such as a link.
|
|
96
97
|
|
|
97
98
|
## Accessibility
|
|
98
99
|
|
|
@@ -9,8 +9,11 @@
|
|
|
9
9
|
>
|
|
10
10
|
{{ title }}
|
|
11
11
|
</component>
|
|
12
|
-
<div
|
|
13
|
-
|
|
12
|
+
<div
|
|
13
|
+
v-if="description || $slots.description"
|
|
14
|
+
class="mt-1 text-base leading-5 text-ink-gray-6"
|
|
15
|
+
>
|
|
16
|
+
<slot name="description">{{ description }}</slot>
|
|
14
17
|
</div>
|
|
15
18
|
</div>
|
|
16
19
|
<div ref="control" class="flex shrink-0 items-start justify-end">
|
|
@@ -31,6 +34,13 @@ const props = defineProps<{
|
|
|
31
34
|
labelFor?: string
|
|
32
35
|
}>()
|
|
33
36
|
|
|
37
|
+
defineSlots<{
|
|
38
|
+
/** The setting's control, on the right. */
|
|
39
|
+
default?: () => any
|
|
40
|
+
/** Replaces the `description` text, for content such as a link. */
|
|
41
|
+
description?: () => any
|
|
42
|
+
}>()
|
|
43
|
+
|
|
34
44
|
// frappe-ui form controls (Switch, Checkbox, …) render their interactive
|
|
35
45
|
// element with `data-slot="control"` and an auto-generated id. Detect it so the
|
|
36
46
|
// title acts as a clickable <label> without the caller wiring up an id.
|
|
@@ -128,17 +128,9 @@
|
|
|
128
128
|
</template>
|
|
129
129
|
|
|
130
130
|
<script setup lang="ts">
|
|
131
|
-
import {
|
|
132
|
-
computed,
|
|
133
|
-
getCurrentInstance,
|
|
134
|
-
inject,
|
|
135
|
-
onMounted,
|
|
136
|
-
ref,
|
|
137
|
-
useAttrs,
|
|
138
|
-
useTemplateRef,
|
|
139
|
-
} from 'vue'
|
|
140
|
-
import { RouterLink } from 'vue-router'
|
|
131
|
+
import { computed, inject, onMounted, ref, useAttrs, useTemplateRef } from 'vue'
|
|
141
132
|
import Icon from '../Icon/Icon.vue'
|
|
133
|
+
import { useNavLink } from '../shared/navLink'
|
|
142
134
|
import Tooltip from '../Tooltip/Tooltip.vue'
|
|
143
135
|
import { SidebarItemProps, sidebarCollapsedKey } from './types'
|
|
144
136
|
|
|
@@ -210,29 +202,7 @@ const ariaLabel = computed(
|
|
|
210
202
|
() => (attrs['aria-label'] as string) || tooltipText.value || undefined,
|
|
211
203
|
)
|
|
212
204
|
|
|
213
|
-
|
|
214
|
-
// so this component works — without warnings or crashes — when mounted outside a
|
|
215
|
-
// vue-router app (docs, tests, embedded use). vue-router installs $router/$route
|
|
216
|
-
// here; the $route getter stays reactive when read inside a computed.
|
|
217
|
-
const globals = getCurrentInstance()?.appContext.config.globalProperties
|
|
218
|
-
const hasRouter = computed(() => Boolean(globals?.$router))
|
|
219
|
-
|
|
220
|
-
// With a router, render RouterLink; without one, degrade to a plain <a> (with an
|
|
221
|
-
// href only when `route` is a string — we can't resolve a route-location object).
|
|
222
|
-
const linkComponent = computed(() =>
|
|
223
|
-
props.route && hasRouter.value ? RouterLink : 'a',
|
|
224
|
-
)
|
|
225
|
-
const linkAttrs = computed(() =>
|
|
226
|
-
props.route
|
|
227
|
-
? hasRouter.value
|
|
228
|
-
? { to: props.route }
|
|
229
|
-
: { href: typeof props.route === 'string' ? props.route : undefined }
|
|
230
|
-
: { href: props.href },
|
|
231
|
-
)
|
|
232
|
-
|
|
233
|
-
const resolvedRoute = computed(() =>
|
|
234
|
-
props.route && globals?.$router ? globals.$router.resolve(props.route) : null,
|
|
235
|
-
)
|
|
205
|
+
const { globals, linkComponent, linkAttrs, resolvedRoute } = useNavLink(props)
|
|
236
206
|
|
|
237
207
|
// Explicit `active` wins; otherwise infer from the current route so
|
|
238
208
|
// router-driven items light up without extra wiring.
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
</template>
|
|
73
73
|
|
|
74
74
|
<script setup lang="ts">
|
|
75
|
-
import { computed
|
|
76
|
-
import { RouterLink } from 'vue-router'
|
|
75
|
+
import { computed } from 'vue'
|
|
77
76
|
import Icon from '../Icon/Icon.vue'
|
|
77
|
+
import { useNavLink } from '../shared/navLink'
|
|
78
78
|
import Tooltip from '../Tooltip/Tooltip.vue'
|
|
79
79
|
import SidebarRailItemBadge from './SidebarRailItemBadge.vue'
|
|
80
80
|
import type { SidebarRailItemProps } from './types'
|
|
@@ -98,21 +98,8 @@ defineSlots<{
|
|
|
98
98
|
default?: () => any
|
|
99
99
|
}>()
|
|
100
100
|
|
|
101
|
-
const globals =
|
|
102
|
-
|
|
103
|
-
const linkComponent = computed(() =>
|
|
104
|
-
props.route && hasRouter.value ? RouterLink : 'a',
|
|
105
|
-
)
|
|
106
|
-
const linkAttrs = computed(() =>
|
|
107
|
-
props.route
|
|
108
|
-
? hasRouter.value
|
|
109
|
-
? { to: props.route }
|
|
110
|
-
: { href: typeof props.route === 'string' ? props.route : undefined }
|
|
111
|
-
: { href: props.href },
|
|
112
|
-
)
|
|
113
|
-
const resolvedRoute = computed(() =>
|
|
114
|
-
props.route && globals?.$router ? globals.$router.resolve(props.route) : null,
|
|
115
|
-
)
|
|
101
|
+
const { globals, linkComponent, linkAttrs, resolvedRoute } = useNavLink(props)
|
|
102
|
+
|
|
116
103
|
const resolvedActive = computed(() => {
|
|
117
104
|
if (props.active !== undefined) return props.active
|
|
118
105
|
const target = resolvedRoute.value
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import {
|
|
3
|
+
Slot,
|
|
3
4
|
TooltipProvider,
|
|
4
5
|
TooltipRoot,
|
|
5
6
|
TooltipTrigger,
|
|
@@ -7,6 +8,7 @@ import {
|
|
|
7
8
|
} from 'reka-ui'
|
|
8
9
|
import TooltipBubble from './TooltipBubble.vue'
|
|
9
10
|
import { computed, type Component } from 'vue'
|
|
11
|
+
import { useDeferredTrigger } from '../shared/deferredTrigger'
|
|
10
12
|
import type { TooltipProps } from './types'
|
|
11
13
|
|
|
12
14
|
defineOptions({
|
|
@@ -36,6 +38,9 @@ const providerProps = computed(() =>
|
|
|
36
38
|
parentProvider ? {} : { delayDuration: delayDuration.value },
|
|
37
39
|
)
|
|
38
40
|
|
|
41
|
+
// The trigger renders alone until it is first hovered or focused.
|
|
42
|
+
const { mounted, shellProps } = useDeferredTrigger('tooltip')
|
|
43
|
+
|
|
39
44
|
defineSlots<{
|
|
40
45
|
/**
|
|
41
46
|
* The trigger. Tooltip is the one overlay whose `#default` is the trigger
|
|
@@ -51,6 +56,9 @@ defineSlots<{
|
|
|
51
56
|
|
|
52
57
|
<template>
|
|
53
58
|
<slot v-if="disabled" />
|
|
59
|
+
<Slot v-else-if="!mounted" v-bind="shellProps">
|
|
60
|
+
<slot />
|
|
61
|
+
</Slot>
|
|
54
62
|
<component :is="Provider" v-else v-bind="providerProps">
|
|
55
63
|
<TooltipRoot>
|
|
56
64
|
<TooltipTrigger as-child data-slot="trigger">
|