frappe-ui 1.0.0 → 1.0.2

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.
Files changed (34) hide show
  1. package/experimental/TextEditor/TextEditor.vue +7 -0
  2. package/package.json +6 -4
  3. package/src/charts/axisChartCommon.ts +97 -33
  4. package/src/charts/axisChartOptions.ts +3 -22
  5. package/src/charts/core/dataLabelFit.ts +88 -0
  6. package/src/charts/core/useAxisChart.ts +37 -0
  7. package/src/charts/scatterOptions.ts +1 -6
  8. package/src/components/Checkbox/Checkbox.vue +8 -4
  9. package/src/components/Combobox/Combobox.vue +20 -7
  10. package/src/components/Combobox/ComboboxResults.vue +2 -0
  11. package/src/components/Dialog/Dialog.vue +8 -1
  12. package/src/components/MobileNav/MobileNav.vue +4 -3
  13. package/src/components/MobileShell/MobileShell.md +4 -1
  14. package/src/components/MultiSelect/MultiSelect.vue +2 -0
  15. package/src/components/PageHeader/PageHeaderMobile.vue +2 -2
  16. package/src/components/Progress/Progress.md +2 -2
  17. package/src/components/Progress/Progress.vue +4 -5
  18. package/src/components/SidebarRail/SidebarRail.api.md +1 -1
  19. package/src/components/SidebarRail/SidebarRail.md +3 -1
  20. package/src/components/SidebarRail/SidebarRailItem.vue +7 -3
  21. package/src/components/SidebarRail/types.ts +2 -1
  22. package/src/components/shared/selection/useFilteredGroups.ts +39 -5
  23. package/src/molecules/editor/extensions/mention/mention-extension.ts +2 -2
  24. package/src/molecules/editor/extensions/shared/media-plugin.ts +30 -7
  25. package/src/molecules/editor/extensions/shared/suggestion-helpers.ts +9 -0
  26. package/src/molecules/editor/extensions/shared/suggestion-renderer.ts +30 -2
  27. package/src/molecules/editor/useEditor.ts +8 -0
  28. package/src/resources/realtime.ts +20 -4
  29. package/src/style.css +12 -0
  30. package/src/utils/rankMatch.ts +18 -0
  31. package/tailwind/plugin.js +7 -13
  32. package/vite/benchFiles.js +36 -0
  33. package/vite/index.js +4 -0
  34. package/vite/utils.js +57 -7
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <nav
3
3
  data-slot="mobile-nav"
4
- class="grid shrink-0 auto-cols-fr grid-flow-col border-t border-outline-gray-2 bg-surface-elevation-2 [@media(display-mode:standalone)]:pb-4"
4
+ class="grid shrink-0 auto-cols-fr grid-flow-col border-t border-outline-gray-2 bg-surface-elevation-2 [@media(display-mode:standalone)]:pb-[max(1rem,env(safe-area-inset-bottom))]"
5
5
  >
6
6
  <slot />
7
7
  </nav>
@@ -10,8 +10,9 @@
10
10
  <script setup lang="ts">
11
11
  // A bare grid frame: each MobileNavItem becomes one equal-width column
12
12
  // (auto-cols-fr + grid-flow-col), so the bar adapts to any item count without
13
- // hardcoding a column class. Bottom padding clears the home indicator in an
14
- // installed PWA (display-mode: standalone).
13
+ // hardcoding a column class. In an installed PWA (display-mode: standalone)
14
+ // the bar runs to the bottom edge and its padding clears the home indicator:
15
+ // the safe-area inset, or 1rem where the inset is smaller.
15
16
 
16
17
  defineSlots<{
17
18
  /** One or more `MobileNavItem`s, each becoming an equal-width tab. */
@@ -48,7 +48,10 @@ shell.
48
48
 
49
49
  The content area uses the browser's native scrolling, with momentum and
50
50
  overscroll. The header and the tab bar stay fixed to the edges. In an installed
51
- PWA, the header gets extra top padding to clear the status bar.
51
+ PWA, the header gets extra top padding to clear the status bar, and the tab bar
52
+ gets bottom padding to clear the home indicator. On iOS 26 the tab bar reaches
53
+ the bottom edge only when the app loads `frappe-ui/style.css`, which gives the
54
+ installed app its full-screen viewport.
52
55
 
53
56
  ### Desktop is a separate component
54
57
 
@@ -16,6 +16,7 @@ import { useReactiveSlots } from '../../composables/useReactiveSlots'
16
16
  import { usePortalTarget } from '../../composables/usePortalTarget'
17
17
  import { useEmptyValueMapping } from '../shared/selection/useEmptyValueMapping'
18
18
  import { useFilteredGroups } from '../shared/selection/useFilteredGroups'
19
+ import { rankMatch } from '../../utils/rankMatch'
19
20
  import { useIsModelBound } from '../shared/selection/useIsModelBound'
20
21
  import OptionIcon from '../shared/selection/OptionIcon.vue'
21
22
  import {
@@ -195,6 +196,7 @@ const filteredGroups = useFilteredGroups({
195
196
  hasTypedSinceOpen,
196
197
  query,
197
198
  matches: matchesOption,
199
+ rank: (item, q) => rankMatch(item.label, q),
198
200
  filterable: () => props.filterable ?? true,
199
201
  })
200
202
 
@@ -9,7 +9,7 @@
9
9
  <div
10
10
  v-if="hasPrefixSlot"
11
11
  ref="prefixSlotEl"
12
- class="absolute left-0 top-1/2 z-[1] flex max-w-[35%] -translate-y-1/2 justify-start"
12
+ class="absolute start-0 top-1/2 z-[1] flex max-w-[35%] -translate-y-1/2 justify-start"
13
13
  >
14
14
  <slot name="prefix" />
15
15
  </div>
@@ -26,7 +26,7 @@
26
26
  <div
27
27
  v-if="hasSuffixSlot"
28
28
  ref="suffixSlotEl"
29
- class="absolute right-0 top-1/2 z-[1] flex max-w-[35%] -translate-y-1/2 justify-end"
29
+ class="absolute end-0 top-1/2 z-[1] flex max-w-[35%] -translate-y-1/2 justify-end"
30
30
  >
31
31
  <slot name="suffix" />
32
32
  </div>
@@ -57,7 +57,7 @@ number. Leave `intervals` out for a continuous bar.
57
57
  ## Accessibility
58
58
 
59
59
  The bar has the `progressbar` role, with `aria-valuenow` set to the value
60
- from 0 to 100. Screen readers read `label` as the value text, or the
61
- percentage when there is no label.
60
+ from 0 to 100. `label` is the bar's accessible name. A bar without a label is
61
+ named "Progress".
62
62
 
63
63
  <!-- @include: ./Progress.api.md -->
@@ -94,12 +94,11 @@ const clampedValue = computed(() =>
94
94
  const fillOffset = computed(() => clampedValue.value - MAX_VALUE)
95
95
 
96
96
  /**
97
- * A bare percentage (reka-ui's default) says how far along the bar is but not
98
- * what it measures, so prefer the visible label when there is one.
97
+ * The progressbar's accessible name: the visible label, or a generic name.
98
+ * Not reka-ui's default percentage, because `aria-valuenow` already announces
99
+ * the value and a "40%" name would be read twice.
99
100
  */
100
- const valueLabel = computed(
101
- () => props.label || `${Math.round(clampedValue.value)}%`,
102
- )
101
+ const valueLabel = computed(() => props.label || 'Progress')
103
102
 
104
103
  const filledIntervalCount = computed(() =>
105
104
  Math.round((clampedValue.value / MAX_VALUE) * (props.intervals ?? 0)),
@@ -65,7 +65,7 @@
65
65
  },
66
66
  {
67
67
  name: 'variant',
68
- description: 'Visual treatment.\n- `subtle` (default): a filled cell with a left indicator bar when active —\n for image/avatar items like communities or workspaces.\n- `ghost`: transparent until hovered, a raised highlight when active — for\n icon shortcuts like Search or Notifications.',
68
+ description: 'Visual treatment.\n- `subtle` (default): a filled cell with a left indicator bar when active —\n for image/avatar items like communities or workspaces. The cell paints\n no fill when its default slot holds an `<img>`.\n- `ghost`: transparent until hovered, a raised highlight when active — for\n icon shortcuts like Search or Notifications.',
69
69
  required: false,
70
70
  type: '"subtle" | "ghost"',
71
71
  default: '"subtle"'
@@ -52,7 +52,9 @@ its items, so moving between items shows each tooltip with no delay.
52
52
  ### Variants
53
53
 
54
54
  - `variant="subtle"` (default) is a filled cell with a bar on its left edge when
55
- active. Use the default slot for an image, an avatar or initials.
55
+ active. Use the default slot for an image, an avatar or initials. When the
56
+ slot holds an `<img>`, the cell paints no fill, so the image's rounded corners
57
+ show no gray rim. The bar still marks the active item.
56
58
  - `variant="ghost"` is transparent until hovered, and raised when active. Pass
57
59
  an `icon` for a shortcut such as Search or Notifications.
58
60
 
@@ -134,10 +134,14 @@ const cellClasses = computed(() => [
134
134
  // `subtle` uses the community-tile radius; `ghost` mirrors frappe-ui's icon
135
135
  // button (rounded-4 = 8px).
136
136
  props.variant === 'subtle' ? 'rounded-[7px]' : 'rounded-4',
137
+ // A `subtle` item paints no fill under an image. Two anti-aliased curves
138
+ // never cover each other exactly, so a fill under a rounded image shows at
139
+ // its corners as a gray rim.
137
140
  props.variant === 'subtle'
138
- ? resolvedActive.value
139
- ? 'bg-surface-gray-4'
140
- : 'bg-surface-gray-3'
141
+ ? [
142
+ resolvedActive.value ? 'bg-surface-gray-4' : 'bg-surface-gray-3',
143
+ 'has-[img]:bg-transparent',
144
+ ]
141
145
  : resolvedActive.value
142
146
  ? 'text-ink-gray-8 !bg-surface-elevation-3 shadow-sm'
143
147
  : 'text-ink-gray-8 bg-transparent hover:bg-surface-gray-3',
@@ -38,7 +38,8 @@ export interface SidebarRailItemProps {
38
38
  /**
39
39
  * Visual treatment.
40
40
  * - `subtle` (default): a filled cell with a left indicator bar when active —
41
- * for image/avatar items like communities or workspaces.
41
+ * for image/avatar items like communities or workspaces. The cell paints
42
+ * no fill when its default slot holds an `<img>`.
42
43
  * - `ghost`: transparent until hovered, a raised highlight when active — for
43
44
  * icon shortcuts like Search or Notifications.
44
45
  */
@@ -17,6 +17,10 @@ import {
17
17
  * `condition` callback must be authoritative even before the user
18
18
  * types). Default: include every item.
19
19
  * - On the typing path, items must pass BOTH `alwaysMatch` AND `matches`.
20
+ * - On the typing path, `rank` then orders the matches within each group,
21
+ * lower first; ties keep their source order. Items ranked `null` (e.g.
22
+ * custom action rows) keep their slot. Ranking is skipped when
23
+ * `filterable` is false.
20
24
  * - `filterable: false` switches the `matches` filter off entirely, for
21
25
  * pickers whose options come from a server search — the backend already
22
26
  * decided what matches, and a second literal substring pass on the
@@ -37,6 +41,8 @@ export function useFilteredGroups<
37
41
  hasTypedSinceOpen: Ref<boolean>
38
42
  query: Ref<string>
39
43
  matches: (item: TItem, query: string) => boolean
44
+ /** Orders matches while typing, lower first; `null` keeps an item where it is. */
45
+ rank: (item: TItem, query: string) => number | null
40
46
  alwaysMatch?: (item: TItem) => boolean
41
47
  /** Client-side query filtering. Defaults to `true`. */
42
48
  filterable?: MaybeRefOrGetter<boolean>
@@ -48,14 +54,42 @@ export function useFilteredGroups<
48
54
  filterable && source.open.value && source.hasTypedSinceOpen.value
49
55
 
50
56
  return source.groups.value
51
- .map((group) => ({
52
- ...group,
53
- options: group.options.filter((item) => {
57
+ .map((group) => {
58
+ const options = group.options.filter((item) => {
54
59
  if (!alwaysMatch(item)) return false
55
60
  if (!filterByTypedQuery) return true
56
61
  return source.matches(item, source.query.value)
57
- }),
58
- }))
62
+ })
63
+ return {
64
+ ...group,
65
+ options: filterByTypedQuery
66
+ ? rankOptions(options, source.rank, source.query.value)
67
+ : options,
68
+ }
69
+ })
59
70
  .filter((group) => group.options.length > 0) as TGroup[]
60
71
  })
61
72
  }
73
+
74
+ // sort the rankable items among themselves; unranked items (rank `null`) keep their slot
75
+ function rankOptions<TItem>(
76
+ options: TItem[],
77
+ rank: (item: TItem, query: string) => number | null,
78
+ query: string,
79
+ ): TItem[] {
80
+ const entries = options.map((item, index) => ({
81
+ item,
82
+ index,
83
+ rank: rank(item, query),
84
+ }))
85
+ const ranked = entries
86
+ .filter(
87
+ (entry): entry is { item: TItem; index: number; rank: number } =>
88
+ entry.rank !== null,
89
+ )
90
+ .sort((a, b) => a.rank - b.rank || a.index - b.index)
91
+ let next = 0
92
+ return entries.map((entry) =>
93
+ entry.rank === null ? entry.item : ranked[next++].item,
94
+ )
95
+ }
@@ -17,7 +17,7 @@ import SuggestionList from '../suggestion/SuggestionList.vue'
17
17
  import { warnRemoved } from '#utils/warnDeprecated'
18
18
  import {
19
19
  insertSuggestionNode,
20
- filterByQuery,
20
+ rankByQuery,
21
21
  getSuggestionOptions,
22
22
  } from '#molecules/editor/extensions/shared/suggestion-helpers'
23
23
  import './style.css'
@@ -168,7 +168,7 @@ const MentionSuggestionExtension =
168
168
 
169
169
  // The matched items are passed through as they came in, so the item
170
170
  // slot receives the caller's own object, extra fields and all.
171
- return filterByQuery(mentions, query, 'label').slice(0, 10)
171
+ return rankByQuery(mentions, query, 'label').slice(0, 10)
172
172
  },
173
173
 
174
174
  command: ({ editor, range, props }) => {
@@ -9,10 +9,12 @@
9
9
  * conventions §1.6 contract.
10
10
  */
11
11
  import { Plugin } from '@tiptap/pm/state'
12
+ import { isHistoryTransaction } from '@tiptap/pm/history'
12
13
  import type { Transaction, EditorState } from '@tiptap/pm/state'
13
14
  import type { EditorView } from '@tiptap/pm/view'
14
15
  import type { Editor } from '@tiptap/core'
15
16
  import { dispatchIfAlive } from '#molecules/editor/extensions/shared/node-view'
17
+ import { isRemoteChange } from '#molecules/editor/extensions/shared/collaboration'
16
18
  import { resolveUploadOptions } from '#molecules/editor/extensions/shared/media-upload-engine'
17
19
  import type {
18
20
  MediaUploadConfig,
@@ -44,6 +46,19 @@ function collectFiles(
44
46
  return files
45
47
  }
46
48
 
49
+ /** Whether a transaction loads content or undoes/redoes, not a person's edit. */
50
+ function isLoadOrUndo(transaction: Transaction): boolean {
51
+ // A transaction another plugin appends (TrailingNode, ListJoin) carries no
52
+ // meta of its own. ProseMirror tags it with the root transaction that
53
+ // caused it, so ask that one too.
54
+ const root = transaction.getMeta('appendedTransaction') as
55
+ | Transaction
56
+ | undefined
57
+ return [transaction, root].some(
58
+ (tr) => tr && (tr.getMeta('preventUpdate') || isHistoryTransaction(tr)),
59
+ )
60
+ }
61
+
47
62
  /**
48
63
  * Build the drop + paste + dimension-back-fill plugin for one media node type.
49
64
  *
@@ -79,8 +94,12 @@ export function createMediaPlugin(
79
94
  },
80
95
 
81
96
  /**
82
- * After any doc-changing transaction, back-fill width/height onto freshly
83
- * inserted nodes that have a `src` but no dimensions and are not loading.
97
+ * Back-fill width/height onto every media node that has a `src` but no
98
+ * dimensions and is not loading, after the person's own edit. This heals
99
+ * new and stored media alike. Loaded content, a collaborator's change and
100
+ * undo/redo write nothing, so opening or watching a document never
101
+ * changes it. The write is kept out of undo history, so Ctrl+Z reverts
102
+ * the person's edit.
84
103
  */
85
104
  appendTransaction(
86
105
  transactions: readonly Transaction[],
@@ -88,6 +107,8 @@ export function createMediaPlugin(
88
107
  newState: EditorState,
89
108
  ): Transaction | null {
90
109
  if (!transactions.some((tr) => tr.docChanged)) return null
110
+ if (isRemoteChange(transactions, newState)) return null
111
+ if (transactions.some(isLoadOrUndo)) return null
91
112
 
92
113
  const pending: number[] = []
93
114
  newState.doc.descendants((node, pos) => {
@@ -118,11 +139,13 @@ export function createMediaPlugin(
118
139
  if (live.attrs.width != null && live.attrs.height != null) return
119
140
  dispatchIfAlive(
120
141
  view,
121
- view.state.tr.setNodeMarkup(pos, undefined, {
122
- ...live.attrs,
123
- width: live.attrs.width ?? dims.width,
124
- height: live.attrs.height ?? dims.height,
125
- }),
142
+ view.state.tr
143
+ .setNodeMarkup(pos, undefined, {
144
+ ...live.attrs,
145
+ width: live.attrs.width ?? dims.width,
146
+ height: live.attrs.height ?? dims.height,
147
+ })
148
+ .setMeta('addToHistory', false),
126
149
  )
127
150
  })
128
151
  .catch(() => {
@@ -1,6 +1,7 @@
1
1
  import type { Editor, Range } from '@tiptap/core'
2
2
  import type { Node as ProseMirrorNode } from '@tiptap/pm/model'
3
3
  import type { EditorState } from '@tiptap/pm/state'
4
+ import { rankMatch } from '#utils/rankMatch'
4
5
 
5
6
  /**
6
7
  * Shared helpers for slash/emoji/mention/tag suggesters: DRY node-insertion,
@@ -49,6 +50,14 @@ export function filterByQuery<T>(items: T[], query: string, key: keyof T): T[] {
49
50
  })
50
51
  }
51
52
 
53
+ /** `filterByQuery` in `rankMatch` order: best match first, ties keep input order. */
54
+ export function rankByQuery<T>(items: T[], query: string, key: keyof T): T[] {
55
+ return filterByQuery(items, query, key).sort(
56
+ (a, b) =>
57
+ rankMatch(String(a[key]), query) - rankMatch(String(b[key]), query),
58
+ )
59
+ }
60
+
52
61
  /**
53
62
  * True when `pos` sits inside a code context — either a code-block node or text
54
63
  * carrying the inline `code` mark. Suggesters (`@`/`#`/`:`) use this to stay
@@ -5,6 +5,7 @@ import type {
5
5
  } from '@tiptap/suggestion'
6
6
  import type { Component } from 'vue'
7
7
  import {
8
+ autoUpdate,
8
9
  computePosition,
9
10
  flip,
10
11
  offset,
@@ -40,6 +41,9 @@ export function createSuggestionRenderer(
40
41
  let isActive = false
41
42
  // Monotonic token; a stale onUpdate from a superseded query bails.
42
43
  let renderToken = 0
44
+ // Monotonic token; a stale computePosition settling later bails.
45
+ let positionToken = 0
46
+ let cleanupAutoUpdate: (() => void) | null = null
43
47
 
44
48
  function getListExpose(): SuggestionListExpose | null {
45
49
  const ref = renderer?.ref as SuggestionListExpose | null | undefined
@@ -52,6 +56,7 @@ export function createSuggestionRenderer(
52
56
  const rect = getReferenceClientRect()
53
57
  if (!rect) return
54
58
  const reference = { getBoundingClientRect: () => rect }
59
+ const token = ++positionToken
55
60
  void computePosition(reference, floatingEl, {
56
61
  placement: floatingOptions?.placement ?? 'bottom-start',
57
62
  middleware: [
@@ -60,7 +65,7 @@ export function createSuggestionRenderer(
60
65
  shift({ padding: 8 }),
61
66
  ],
62
67
  }).then(({ x, y }) => {
63
- if (!floatingEl) return
68
+ if (!floatingEl || token !== positionToken) return
64
69
  Object.assign(floatingEl.style, {
65
70
  position: 'absolute',
66
71
  left: `${x}px`,
@@ -91,9 +96,29 @@ export function createSuggestionRenderer(
91
96
 
92
97
  floatingEl = wrapper
93
98
  floatingEl.style.position = 'absolute'
99
+ // A modal Dialog lets this <body> popup take clicks when the editor is
100
+ // inside it. A popup left open in an editor behind the Dialog stays
101
+ // unclickable, so it can't insert into that editor.
102
+ if (props.editor.view.dom.closest('[role=dialog]'))
103
+ floatingEl.style.pointerEvents = 'auto'
104
+ floatingEl.dataset.editorFloating = ''
94
105
  document.body.appendChild(floatingEl)
95
106
  getReferenceClientRect = props.clientRect as () => DOMRect | null
96
- updatePosition()
107
+
108
+ // Positions once, then keeps the popup on the caret through scroll, window
109
+ // resize and its own height changes (`flip()` measures a height that async
110
+ // rows and late fonts change after the fact). autoUpdate reads only
111
+ // `contextElement`, to find the editor's scroll ancestors; `updatePosition`
112
+ // reads the caret rect itself.
113
+ cleanupAutoUpdate = autoUpdate(
114
+ {
115
+ getBoundingClientRect: () =>
116
+ getReferenceClientRect?.() ?? new DOMRect(),
117
+ contextElement: props.editor.view.dom,
118
+ },
119
+ floatingEl,
120
+ updatePosition,
121
+ )
97
122
  }
98
123
 
99
124
  return {
@@ -139,6 +164,9 @@ export function createSuggestionRenderer(
139
164
  onExit() {
140
165
  isActive = false
141
166
  renderToken++
167
+ positionToken++
168
+ cleanupAutoUpdate?.()
169
+ cleanupAutoUpdate = null
142
170
  floatingEl?.remove()
143
171
  renderer?.destroy()
144
172
  floatingEl = null
@@ -100,6 +100,14 @@ export function useEditor(
100
100
  extensions,
101
101
  editable: toValue(options.editable) ?? true,
102
102
  autofocus: options.autofocus,
103
+ editorProps: {
104
+ handleDOMEvents: {
105
+ // ProseMirror's dragstart runs even when read-only and overwrites the drag
106
+ // data; claiming the event (without preventDefault) keeps the browser's
107
+ // native payload, such as a link URL.
108
+ dragstart: (view) => !view.editable,
109
+ },
110
+ },
103
111
  onUpdate: ({ editor: tiptapEditor }) => {
104
112
  if (!isCollaborationMode && options.content && !applyingExternalUpdate) {
105
113
  const value = serialize(tiptapEditor)
@@ -17,9 +17,25 @@ export function onDocUpdate(
17
17
  })
18
18
  }
19
19
 
20
- let subscribed: Record<string, boolean> = {}
20
+ // Doctypes subscribed per socket, so each new Socket subscribes on its own and
21
+ // a closed one can be garbage collected.
22
+ const subscribed = new WeakMap<Socket, Set<string>>()
23
+
21
24
  function subscribe(socket: Socket, doctype: string): void {
22
- if (subscribed[doctype]) return
23
- socket.emit('doctype_subscribe', doctype)
24
- subscribed[doctype] = true
25
+ const doctypes = subscribed.get(socket) ?? new Set<string>()
26
+ if (!subscribed.has(socket)) {
27
+ subscribed.set(socket, doctypes)
28
+ // Server-side rooms are per-socket and dropped on disconnect. This handler
29
+ // subscribes to every doctype on the first connect and on each reconnect.
30
+ socket.on('connect', () => {
31
+ for (const type of doctypes) {
32
+ socket.emit('doctype_subscribe', type)
33
+ }
34
+ })
35
+ }
36
+ if (doctypes.has(doctype)) return
37
+ doctypes.add(doctype)
38
+ // socket.io buffers emits while disconnected and flushes them before
39
+ // `connect`, so emit directly only on a connected socket.
40
+ if (socket.connected) socket.emit('doctype_subscribe', doctype)
25
41
  }
package/src/style.css CHANGED
@@ -14,3 +14,15 @@
14
14
  .no-transition *::after {
15
15
  transition: none !important;
16
16
  }
17
+
18
+ /* MobileShell: iOS 26 sizes an installed web app's viewport short by the status
19
+ bar height while the page is shorter than the screen, so the fixed shell and
20
+ its tab bar stop above a strip of page background (WebKit 301108). A page at
21
+ least as tall as the screen gets the full viewport. The cap keeps the page
22
+ from scrolling in apps with an opaque status bar, where 100lvh overstates the
23
+ viewport and the top inset is 0 (WebKit 316008). */
24
+ @media (display-mode: standalone) {
25
+ html {
26
+ min-height: min(100lvh, calc(100% + env(safe-area-inset-top)));
27
+ }
28
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * How well `text` matches `query`, lower is better. Case-insensitive.
3
+ *
4
+ * 0: exact match, or an empty query
5
+ * 1: `text` starts with the query
6
+ * 2: a word in `text` starts with the query (words split on anything that is
7
+ * not a letter or digit)
8
+ * 3: any other match
9
+ */
10
+ export function rankMatch(text: string, query: string): number {
11
+ const normalizedText = text.toLowerCase()
12
+ const normalizedQuery = query.toLowerCase()
13
+ if (!normalizedQuery || normalizedText === normalizedQuery) return 0
14
+ if (normalizedText.startsWith(normalizedQuery)) return 1
15
+ const words = normalizedText.split(/[^\p{L}\p{N}]+/u)
16
+ if (words.some((word) => word.startsWith(normalizedQuery))) return 2
17
+ return 3
18
+ }
@@ -333,6 +333,13 @@ export default plugin(
333
333
  'h5 strong': {
334
334
  fontWeight: 600,
335
335
  },
336
+ // keep a named text color on bold text (typography's `strong` color would override it)
337
+ ':where(span[style*="--prose-color-"]) strong': {
338
+ color: 'inherit',
339
+ },
340
+ 'strong:where([style*="--prose-color-"])': {
341
+ color: 'inherit',
342
+ },
336
343
  'img[data-align=right]': {
337
344
  marginLeft: 'auto',
338
345
  marginRight: '0',
@@ -436,19 +443,6 @@ export default plugin(
436
443
  borderBottom: '1px solid var(--ink-gray-6)',
437
444
  },
438
445
 
439
- // named text color + bold: the color lives on a `textStyle`
440
- // span that wraps (or is wrapped by) `<strong>`. Typography's
441
- // `strong { color: var(--tw-prose-bold) }` otherwise overrides
442
- // the inherited named color, painting bold text gray. Mirror the
443
- // base preset's `a strong { color: inherit }` so bold keeps the
444
- // span's color in both nesting orders.
445
- ':where(span[style*="--prose-color-"]) strong': {
446
- color: 'inherit',
447
- },
448
- 'strong:where([style*="--prose-color-"])': {
449
- color: 'inherit',
450
- },
451
-
452
446
  // inline code: subtle pill — strip Tailwind's added quotes
453
447
  'code::before': { content: 'none' },
454
448
  'code::after': { content: 'none' },
@@ -0,0 +1,36 @@
1
+ import path from 'path'
2
+ import { findBenchPath } from './utils.js'
3
+
4
+ const SITES_IMPORT = /^(?:\.\.\/)+sites\/(.+)$/
5
+
6
+ // Apps read bench files with a relative import such as
7
+ // '../../../../sites/common_site_config.json', which only resolves while the app
8
+ // sits in the bench's apps/ folder. When it does not, as for an app linked into
9
+ // apps/ from elsewhere, resolve the file in the bench instead.
10
+ export function benchFiles() {
11
+ return {
12
+ name: 'frappeui-bench-files',
13
+ enforce: 'pre',
14
+ async resolveId(source, importer, options) {
15
+ const match = source.match(SITES_IMPORT)
16
+ if (!match) {
17
+ return null
18
+ }
19
+ const resolved = await this.resolve(source, importer, {
20
+ ...options,
21
+ skipSelf: true,
22
+ })
23
+ if (resolved) {
24
+ return resolved
25
+ }
26
+ const benchPath = findBenchPath()
27
+ if (!benchPath) {
28
+ return null
29
+ }
30
+ return this.resolve(path.join(benchPath, 'sites', match[1]), importer, {
31
+ ...options,
32
+ skipSelf: true,
33
+ })
34
+ },
35
+ }
36
+ }
package/vite/index.js CHANGED
@@ -6,6 +6,7 @@ import { buildConfig } from './buildConfig.js'
6
6
  import { siteBanner } from './siteBanner.js'
7
7
  import { barrelImports } from './barrelImports.js'
8
8
  import { codeLanguages } from './codeLanguages.js'
9
+ import { benchFiles } from './benchFiles.js'
9
10
 
10
11
  function frappeuiPlugin(options = {}) {
11
12
  let plugins = []
@@ -19,6 +20,9 @@ function frappeuiPlugin(options = {}) {
19
20
  const barrelImportsOpt = options.barrelImports ?? true
20
21
  const codeLanguagesOpt = options.codeLanguages ?? true
21
22
 
23
+ // Resolve `../…/sites/<file>` imports in the bench when they do not resolve
24
+ // in place, as for an app linked into apps/ from another folder.
25
+ plugins.push(benchFiles())
22
26
  if (codeLanguagesOpt) {
23
27
  // Stub the `@codemirror/lang-*` packages this app did not install, so
24
28
  // `frappe-ui/code-editor` builds with the languages it renders and no more.