@aleph-alpha/ui-library 5.9.0 → 5.10.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/config.js +157 -4
- package/dist/system/components/UiFileItem/UiFileItem.vue.d.ts +3 -1
- package/dist/system/components/UiFileType/types.d.ts +2 -1
- package/dist/system/components/UiSwitch/UiSwitch.vue.d.ts +1 -0
- package/dist/system/components/UiSwitch/types.d.ts +12 -0
- package/dist/system/components/core/switch/Switch.vue.d.ts +2 -0
- package/dist/system/components/core/switch/index.d.ts +8 -0
- package/dist/system/index.d.ts +1 -0
- package/dist/system/lib/scrollbar.d.ts +37 -0
- package/dist/system/lib/useAnchorFloat.d.ts +0 -2
- package/dist/system/lib/useIsTruncated.d.ts +15 -0
- package/dist/system/lib.js +15052 -14843
- package/dist/system/patterns/UiFloatActions/types.d.ts +0 -1
- package/dist/system/story-sidebar-icons.json +4 -1
- package/docs/public-docs/foundations.md +17 -15
- package/package.json +3 -3
- package/src/components/UiCodeBlock/UiCodeBlock.stories.ts +54 -0
- package/src/components/UiCodeBlock/UiCodeBlock.vue +84 -32
- package/src/components/UiCodeBlock/__tests__/UiCodeBlock.test.ts +65 -21
- package/src/components/UiFileItem/UiFileItem.vue +17 -4
- package/src/components/UiFileItem/__tests__/UiFileItem.test.ts +49 -90
- package/src/components/UiFileType/UiFileType.stories.ts +13 -2
- package/src/components/UiFileType/UiFileType.vue +8 -0
- package/src/components/UiFileType/__tests__/UiFileType.test.ts +10 -0
- package/src/components/UiFileType/types.ts +3 -1
- package/src/components/UiSnackbar/UiSnackbar.stories.ts +4 -5
- package/src/components/UiSwitch/UiSwitch.stories.ts +658 -7
- package/src/components/UiSwitch/UiSwitch.vue +1 -0
- package/src/components/UiSwitch/__tests__/UiSwitch.test.ts +48 -0
- package/src/components/UiSwitch/types.ts +13 -0
- package/src/components/UiToggleGroup/UiToggleGroup.vue +1 -1
- package/src/components/core/field/FieldLabel.vue +1 -1
- package/src/components/core/label/Label.vue +1 -1
- package/src/components/core/switch/Switch.vue +23 -17
- package/src/components/core/switch/index.ts +36 -0
- package/src/index.ts +3 -0
- package/src/lib/scrollbar.ts +295 -0
- package/src/lib/useAnchorFloat.ts +0 -2
- package/src/lib/useIsTruncated.test.ts +174 -0
- package/src/lib/useIsTruncated.ts +75 -0
- package/src/patterns/UiFileUpload/UiFileItem.stories.ts +1162 -0
- package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +552 -1
- package/src/patterns/UiFileUpload/__tests__/UiFileUpload.test.ts +5 -21
- package/src/patterns/UiFloatActions/UiFloatActionItems.vue +0 -1
- package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +0 -1
- package/src/patterns/UiFloatActions/UiFloatActions.vue +1 -2
- package/src/patterns/UiFloatActions/types.ts +0 -1
- package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +132 -117
- package/src/theme/Background.stories.ts +27 -1
- package/src/theme/BorderRadius.stories.ts +5 -0
- package/src/theme/Overlay.stories.ts +12 -1
- package/src/theme/Scrollbar.stories.ts +260 -0
- package/tokens.json +224 -2
- package/src/components/UiFileItem/UiFileItem.stories.ts +0 -442
package/config.js
CHANGED
|
@@ -407,6 +407,7 @@ const buildShadcnVarsFromModeSet = (modeSetName, options = {}) => {
|
|
|
407
407
|
|
|
408
408
|
// Modal overlay
|
|
409
409
|
const modalOverlay = resolve('overlay.surface.modal-overlay');
|
|
410
|
+
const modalOverlayInverse = resolve('overlay.surface.modal-overlay-inverse');
|
|
410
411
|
|
|
411
412
|
// Inverse surfaces (for tooltips)
|
|
412
413
|
const inverse = resolve('background.surface.inverse');
|
|
@@ -457,6 +458,7 @@ const buildShadcnVarsFromModeSet = (modeSetName, options = {}) => {
|
|
|
457
458
|
'overlay-hover-subtle': overlayHoverSubtle,
|
|
458
459
|
'overlay-hover-strong': overlayHoverStrong,
|
|
459
460
|
'modal-overlay': modalOverlay,
|
|
461
|
+
'modal-overlay-inverse': modalOverlayInverse,
|
|
460
462
|
inverse,
|
|
461
463
|
'inverse-foreground': inverseForeground,
|
|
462
464
|
'secondary-content': secondaryContent,
|
|
@@ -646,9 +648,6 @@ const getBorderRadiusExactUtilityRules = () => {
|
|
|
646
648
|
const className = key === 'DEFAULT' ? 'rounded' : `rounded-${key}`;
|
|
647
649
|
entries.push([className, { 'border-radius': value }]);
|
|
648
650
|
}
|
|
649
|
-
// Manual intermediate radius between the `xl` and `2xl` tokens; not sourced
|
|
650
|
-
// from Figma, so it's declared here rather than in tokens.json.
|
|
651
|
-
entries.push(['rounded-xl-2xl', { 'border-radius': '1.375rem' }]);
|
|
652
651
|
return entriesToRules(entries);
|
|
653
652
|
};
|
|
654
653
|
|
|
@@ -910,6 +909,7 @@ export const presetUiLibraryThemeFromTokens = (options = {}) => {
|
|
|
910
909
|
'overlay-hover-subtle': 'oklch(var(--overlay-hover-subtle))',
|
|
911
910
|
'overlay-hover-strong': 'oklch(var(--overlay-hover-strong))',
|
|
912
911
|
'modal-overlay': 'oklch(var(--modal-overlay))',
|
|
912
|
+
'modal-overlay-inverse': 'oklch(var(--modal-overlay-inverse))',
|
|
913
913
|
inverse: 'oklch(var(--inverse))',
|
|
914
914
|
'inverse-foreground': 'oklch(var(--inverse-foreground))',
|
|
915
915
|
'secondary-content': 'oklch(var(--secondary-content))',
|
|
@@ -1187,6 +1187,143 @@ const vHoverOverlayCSS = `
|
|
|
1187
1187
|
}
|
|
1188
1188
|
`.trim();
|
|
1189
1189
|
|
|
1190
|
+
/**
|
|
1191
|
+
* Painted width of the thumb, and the full width of the lane it sits in. The
|
|
1192
|
+
* lane is deliberately no wider than the thumb: a wider lane stacks on top of
|
|
1193
|
+
* whatever padding a scroll container already has instead of sitting inside it,
|
|
1194
|
+
* which pushed content away from the edge everywhere in the library.
|
|
1195
|
+
*/
|
|
1196
|
+
const SCROLLBAR_THUMB_WIDTH_PX = 4;
|
|
1197
|
+
/**
|
|
1198
|
+
* Corner radius asked for by the design. A rounded rectangle can never curve by
|
|
1199
|
+
* more than half its own width, so at a 4px thumb this resolves to 2px and the
|
|
1200
|
+
* thumb reads as a pill. Raising the thumb width lets more of it through.
|
|
1201
|
+
*/
|
|
1202
|
+
const SCROLLBAR_THUMB_RADIUS_PX = Math.min(12, SCROLLBAR_THUMB_WIDTH_PX / 2);
|
|
1203
|
+
|
|
1204
|
+
const SCROLLBAR_THUMB_SIZE = `${SCROLLBAR_THUMB_WIDTH_PX}px`;
|
|
1205
|
+
const SCROLLBAR_LANE_SIZE = SCROLLBAR_THUMB_SIZE;
|
|
1206
|
+
const SCROLLBAR_THUMB_RADIUS = `${SCROLLBAR_THUMB_RADIUS_PX}px`;
|
|
1207
|
+
/** Shortest the thumb may get on very long content, so it stays grabbable. */
|
|
1208
|
+
const SCROLLBAR_MIN_THUMB_LENGTH = '32px';
|
|
1209
|
+
const SCROLLBAR_THUMB_COLOR = 'oklch(var(--background-surface-muted-default))';
|
|
1210
|
+
const SCROLLBAR_FADE_IN_DURATION = '100ms';
|
|
1211
|
+
const SCROLLBAR_FADE_OUT_DURATION = '200ms';
|
|
1212
|
+
|
|
1213
|
+
const scrollbarCSS = `
|
|
1214
|
+
/* Scrollbar — global default for every scroll container.
|
|
1215
|
+
|
|
1216
|
+
Anatomy:
|
|
1217
|
+
- Thumb: the ${SCROLLBAR_THUMB_SIZE} bar the user drags. The only part anyone sees.
|
|
1218
|
+
- Track: the channel the thumb runs in. Always invisible.
|
|
1219
|
+
- Lane: the strip of layout the scrollbar occupies, exactly as wide as the
|
|
1220
|
+
thumb. The gap between content and thumb is whatever padding the scroll
|
|
1221
|
+
container already has, so the lane sits inside that padding rather than
|
|
1222
|
+
adding a second gap on top of it.
|
|
1223
|
+
|
|
1224
|
+
The lane is not reserved by default. Reserving it on every element padded out
|
|
1225
|
+
every scroll container in the library by a full lane width, including ones
|
|
1226
|
+
that never scroll. Containers that must not shift when their scrollbar
|
|
1227
|
+
appears can opt in with "ui-scrollbar-stable".
|
|
1228
|
+
|
|
1229
|
+
Auto-hide (thumb visible only while scrolling, hovering the lane, or dragging)
|
|
1230
|
+
needs timers, so it is opt-in through "installScrollbarBehavior()", which adds
|
|
1231
|
+
the "ui-scrollbar-autohide" class to <html>. Without it the thumb stays
|
|
1232
|
+
visible, which is the safe fallback when the runtime is not installed.
|
|
1233
|
+
|
|
1234
|
+
Escape hatches:
|
|
1235
|
+
- "ui-scrollbar-none" no scrollbar at all.
|
|
1236
|
+
- "ui-scrollbar-always" thumb always visible, opting out of auto-hide.
|
|
1237
|
+
- "ui-scrollbar-stable" reserve the lane so content never shifts. */
|
|
1238
|
+
.ui-scrollbar-stable {
|
|
1239
|
+
scrollbar-gutter: stable;
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
/* Engines without ::-webkit-scrollbar (Firefox). "thin" is the closest match to
|
|
1243
|
+
the 4px thumb; the gap and the corner radius are not controllable there.
|
|
1244
|
+
Chromium ignores ::-webkit-scrollbar as soon as scrollbar-width or
|
|
1245
|
+
scrollbar-color is set, so these are guarded rather than declared alongside. */
|
|
1246
|
+
@supports not selector(::-webkit-scrollbar) {
|
|
1247
|
+
* {
|
|
1248
|
+
scrollbar-width: thin;
|
|
1249
|
+
scrollbar-color: ${SCROLLBAR_THUMB_COLOR} transparent;
|
|
1250
|
+
}
|
|
1251
|
+
html.ui-scrollbar-autohide,
|
|
1252
|
+
html.ui-scrollbar-autohide * {
|
|
1253
|
+
scrollbar-color: transparent transparent;
|
|
1254
|
+
}
|
|
1255
|
+
html.ui-scrollbar-autohide[data-ui-scrollbar='visible'],
|
|
1256
|
+
html.ui-scrollbar-autohide [data-ui-scrollbar='visible'],
|
|
1257
|
+
html.ui-scrollbar-autohide.ui-scrollbar-always,
|
|
1258
|
+
html.ui-scrollbar-autohide .ui-scrollbar-always {
|
|
1259
|
+
scrollbar-color: ${SCROLLBAR_THUMB_COLOR} transparent;
|
|
1260
|
+
}
|
|
1261
|
+
.ui-scrollbar-none {
|
|
1262
|
+
scrollbar-width: none;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
@supports selector(::-webkit-scrollbar) {
|
|
1267
|
+
::-webkit-scrollbar {
|
|
1268
|
+
width: ${SCROLLBAR_LANE_SIZE};
|
|
1269
|
+
height: ${SCROLLBAR_LANE_SIZE};
|
|
1270
|
+
background-color: transparent;
|
|
1271
|
+
}
|
|
1272
|
+
::-webkit-scrollbar-track,
|
|
1273
|
+
::-webkit-scrollbar-track-piece,
|
|
1274
|
+
::-webkit-scrollbar-corner {
|
|
1275
|
+
background-color: transparent;
|
|
1276
|
+
}
|
|
1277
|
+
::-webkit-scrollbar-button {
|
|
1278
|
+
display: none;
|
|
1279
|
+
width: 0;
|
|
1280
|
+
height: 0;
|
|
1281
|
+
}
|
|
1282
|
+
::-webkit-scrollbar-thumb {
|
|
1283
|
+
background-color: ${SCROLLBAR_THUMB_COLOR};
|
|
1284
|
+
border-radius: ${SCROLLBAR_THUMB_RADIUS};
|
|
1285
|
+
}
|
|
1286
|
+
::-webkit-scrollbar-thumb:vertical {
|
|
1287
|
+
min-height: ${SCROLLBAR_MIN_THUMB_LENGTH};
|
|
1288
|
+
}
|
|
1289
|
+
::-webkit-scrollbar-thumb:horizontal {
|
|
1290
|
+
min-width: ${SCROLLBAR_MIN_THUMB_LENGTH};
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
html.ui-scrollbar-autohide::-webkit-scrollbar-thumb,
|
|
1294
|
+
html.ui-scrollbar-autohide ::-webkit-scrollbar-thumb {
|
|
1295
|
+
background-color: transparent;
|
|
1296
|
+
transition: background-color ${SCROLLBAR_FADE_OUT_DURATION} ease;
|
|
1297
|
+
}
|
|
1298
|
+
html.ui-scrollbar-autohide[data-ui-scrollbar='visible']::-webkit-scrollbar-thumb,
|
|
1299
|
+
html.ui-scrollbar-autohide [data-ui-scrollbar='visible']::-webkit-scrollbar-thumb,
|
|
1300
|
+
html.ui-scrollbar-autohide.ui-scrollbar-always::-webkit-scrollbar-thumb,
|
|
1301
|
+
html.ui-scrollbar-autohide .ui-scrollbar-always::-webkit-scrollbar-thumb {
|
|
1302
|
+
background-color: ${SCROLLBAR_THUMB_COLOR};
|
|
1303
|
+
transition-duration: ${SCROLLBAR_FADE_IN_DURATION};
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
.ui-scrollbar-none::-webkit-scrollbar {
|
|
1307
|
+
display: none;
|
|
1308
|
+
width: 0;
|
|
1309
|
+
height: 0;
|
|
1310
|
+
}
|
|
1311
|
+
.ui-scrollbar-none {
|
|
1312
|
+
scrollbar-gutter: auto;
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1317
|
+
@supports selector(::-webkit-scrollbar) {
|
|
1318
|
+
::-webkit-scrollbar-thumb,
|
|
1319
|
+
html.ui-scrollbar-autohide::-webkit-scrollbar-thumb,
|
|
1320
|
+
html.ui-scrollbar-autohide ::-webkit-scrollbar-thumb {
|
|
1321
|
+
transition: none;
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
`.trim();
|
|
1326
|
+
|
|
1190
1327
|
/**
|
|
1191
1328
|
* UnoCSS preset with utility rules and preflight classes required by the UI
|
|
1192
1329
|
* library's components.
|
|
@@ -1215,6 +1352,19 @@ const vHoverOverlayCSS = `
|
|
|
1215
1352
|
* `focus-ring` would be parsed by UnoCSS as the `focus:` variant of the `ring`
|
|
1216
1353
|
* utility and emit an unintended `.focus-ring:focus` rule.
|
|
1217
1354
|
*
|
|
1355
|
+
* ## Scrollbars
|
|
1356
|
+
*
|
|
1357
|
+
* Every scroll container gets the library scrollbar by default: a 4px thumb on
|
|
1358
|
+
* an invisible track, in a lane no wider than the thumb so it sits inside the
|
|
1359
|
+
* container's own padding rather than adding space beside it. No class needed.
|
|
1360
|
+
* Import `installScrollbarBehavior` from the library to additionally auto-hide
|
|
1361
|
+
* the thumb when the user is idle. Three modifiers:
|
|
1362
|
+
*
|
|
1363
|
+
* - `ui-scrollbar-none` — no scrollbar at all.
|
|
1364
|
+
* - `ui-scrollbar-always` — thumb always visible, ignoring auto-hide.
|
|
1365
|
+
* - `ui-scrollbar-stable` — reserve the lane so content never shifts when the
|
|
1366
|
+
* scrollbar appears.
|
|
1367
|
+
*
|
|
1218
1368
|
* @example
|
|
1219
1369
|
* ```html
|
|
1220
1370
|
* <button class="ui-focus-ring border border-transparent">Save</button>
|
|
@@ -1227,7 +1377,10 @@ const vHoverOverlayCSS = `
|
|
|
1227
1377
|
export const presetUiLibraryUtils = () =>
|
|
1228
1378
|
definePreset(() => ({
|
|
1229
1379
|
name: '@aleph-alpha/ui-library-utils',
|
|
1230
|
-
preflights: [
|
|
1380
|
+
preflights: [
|
|
1381
|
+
{ getCSS: () => vHoverOverlayCSS },
|
|
1382
|
+
{ getCSS: () => scrollbarCSS },
|
|
1383
|
+
],
|
|
1231
1384
|
rules: [
|
|
1232
1385
|
[/^w-\(--(.+)\)$/, ([, name]) => ({ width: `var(--${name})` })],
|
|
1233
1386
|
[/^max-w-\(--(.+)\)$/, ([, name]) => ({ 'max-width': `var(--${name})` })],
|
|
@@ -15,5 +15,7 @@ declare const _default: import('vue').DefineComponent<UiFileItemProps, {}, {}, {
|
|
|
15
15
|
progressLabel: string;
|
|
16
16
|
mediaTone: import('./types').UiFileItemMediaTone;
|
|
17
17
|
mediaIcon: string;
|
|
18
|
-
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
18
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
19
|
+
titleRef: HTMLSpanElement;
|
|
20
|
+
}, HTMLDivElement>;
|
|
19
21
|
export default _default;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* - `Type=Text` (`pdf` / `doc` / `docx` / `txt` / `rtf`) → `accent-pink` + `file`
|
|
7
7
|
* - `Type=Markdown` (`html` / `htm` / `md` / `mdx`) → `accent-soft` + `code-xml`
|
|
8
8
|
* - `Type=Tabular` (`csv` / `tsv` / `xls` / `xlsx`) → `accent-yellow` + `table-2`
|
|
9
|
+
* - `Type=Media` (`mp4` / `mov` / `webm` / `mkv` / …) → `accent-orange` + `image-play`
|
|
9
10
|
* - everything else → `default` + `file`
|
|
10
11
|
* @see {@link https://www.figma.com/design/SrZQ19QVN1sQkuAMnMC746/AA26--WIP-?node-id=26438-42144}
|
|
11
12
|
* @category Data Display
|
|
@@ -13,7 +14,7 @@
|
|
|
13
14
|
* @keywords file, badge, attachment, filetype, icon
|
|
14
15
|
* @related UiFileItem, UiFileUploadBox
|
|
15
16
|
*/
|
|
16
|
-
export type UiFileTypeTone = 'default' | 'accent-pink' | 'accent-soft' | 'accent-yellow';
|
|
17
|
+
export type UiFileTypeTone = 'default' | 'accent-pink' | 'accent-soft' | 'accent-yellow' | 'accent-orange';
|
|
17
18
|
export interface UiFileTypeProps {
|
|
18
19
|
/**
|
|
19
20
|
* File name used to auto-derive the tone + icon from its extension. Pass
|
|
@@ -9,6 +9,7 @@ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {},
|
|
|
9
9
|
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
10
10
|
}>, {
|
|
11
11
|
disabled: boolean;
|
|
12
|
+
size: import('./types').UiSwitchSize;
|
|
12
13
|
required: boolean;
|
|
13
14
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
14
15
|
export default _default;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Size options for the UiSwitch component.
|
|
3
|
+
* - `default`: 36×20px track with a 16px thumb
|
|
4
|
+
* - `sm`: 28×16px track with a 12px thumb, for dense rows and table cells
|
|
5
|
+
*/
|
|
6
|
+
export type UiSwitchSize = 'default' | 'sm';
|
|
1
7
|
/**
|
|
2
8
|
* A toggle switch for on/off states. Use for settings, preferences,
|
|
3
9
|
* or any binary choice that takes effect immediately.
|
|
@@ -21,4 +27,10 @@ export type UiSwitchProps = {
|
|
|
21
27
|
* @default false
|
|
22
28
|
*/
|
|
23
29
|
required?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Track and thumb scale. Neither size reaches the 24px minimum target height,
|
|
32
|
+
* so pair the switch with a label that extends the target (WCAG 2.5.8).
|
|
33
|
+
* @default 'default'
|
|
34
|
+
*/
|
|
35
|
+
size?: UiSwitchSize;
|
|
24
36
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { SwitchRootProps } from 'reka-ui';
|
|
2
2
|
import { HTMLAttributes } from 'vue';
|
|
3
|
+
import { SwitchVariants } from '.';
|
|
3
4
|
type __VLS_Props = SwitchRootProps & {
|
|
4
5
|
class?: HTMLAttributes['class'];
|
|
6
|
+
size?: SwitchVariants['size'];
|
|
5
7
|
};
|
|
6
8
|
declare function __VLS_template(): {
|
|
7
9
|
attrs: Partial<{}>;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
+
import { VariantProps } from 'class-variance-authority';
|
|
1
2
|
export { default as Switch } from './Switch.vue';
|
|
3
|
+
export declare const switchRootVariants: (props?: ({
|
|
4
|
+
size?: "default" | "sm" | null | undefined;
|
|
5
|
+
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
6
|
+
export declare const switchThumbVariants: (props?: ({
|
|
7
|
+
size?: "default" | "sm" | null | undefined;
|
|
8
|
+
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
9
|
+
export type SwitchVariants = VariantProps<typeof switchRootVariants>;
|
package/dist/system/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './patterns';
|
|
|
5
5
|
export * from './templates';
|
|
6
6
|
export * from './lib/useDevice';
|
|
7
7
|
export * from './lib/useAnchorFloat';
|
|
8
|
+
export * from './lib/scrollbar';
|
|
8
9
|
export * from './directives';
|
|
9
10
|
export { Primitive } from 'reka-ui';
|
|
10
11
|
export type PrimitiveProps = RekaPrimitiveProps;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-hide behavior for the library scrollbar.
|
|
3
|
+
*
|
|
4
|
+
* The look of the scrollbar (4px thumb, invisible track, reserved 16px lane) is
|
|
5
|
+
* pure CSS and ships with the UnoCSS preset. Only the *timing* rules need a
|
|
6
|
+
* runtime, because CSS has no way to express "one second after the last scroll":
|
|
7
|
+
*
|
|
8
|
+
* | Situation | Thumb |
|
|
9
|
+
* | -------------------------- | ------------------------------------------- |
|
|
10
|
+
* | At rest | Hidden |
|
|
11
|
+
* | Scrolling, incl. keyboard | Visible, fades in quickly |
|
|
12
|
+
* | Scrolling stops | Stays ~1s, then fades out |
|
|
13
|
+
* | Pointer hovering the lane | Visible, stays visible |
|
|
14
|
+
* | Being dragged | Visible until released, even off-element |
|
|
15
|
+
* | Content too short | No thumb, lane stays reserved |
|
|
16
|
+
* | Reduced motion | Appears and disappears instantly, no fade |
|
|
17
|
+
*
|
|
18
|
+
* The fades and the reduced-motion rule are CSS; this module only decides when
|
|
19
|
+
* a scroll container counts as active.
|
|
20
|
+
*/
|
|
21
|
+
export type ScrollbarBehaviorOptions = {
|
|
22
|
+
/** Milliseconds the thumb stays visible after the last scroll. Defaults to 1000. */
|
|
23
|
+
idleDelay?: number;
|
|
24
|
+
/** Document to attach the listeners to. Defaults to the ambient `document`. */
|
|
25
|
+
document?: Document;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Installs the scroll, hover, and drag listeners that reveal and hide scrollbar
|
|
29
|
+
* thumbs, and puts the document into auto-hide mode.
|
|
30
|
+
*
|
|
31
|
+
* The library's Vue plugin calls this for you. Call it directly when you
|
|
32
|
+
* register components individually instead of installing the plugin. Safe to
|
|
33
|
+
* call during SSR and safe to call more than once per document.
|
|
34
|
+
* @param options Idle delay and target document overrides.
|
|
35
|
+
* @returns Teardown that removes the listeners and restores always-visible thumbs.
|
|
36
|
+
*/
|
|
37
|
+
export declare function installScrollbarBehavior(options?: ScrollbarBehaviorOptions): () => void;
|
|
@@ -10,7 +10,6 @@ export interface AnchorFloatOffset {
|
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Options for {@link useAnchorFloat}.
|
|
13
|
-
*
|
|
14
13
|
* @category Composables
|
|
15
14
|
* @useCases contextual toolbar positioning, custom floating panels
|
|
16
15
|
* @keywords float, anchor, floating-ui, composable, positioning
|
|
@@ -74,7 +73,6 @@ export interface UseAnchorFloatOptions {
|
|
|
74
73
|
*
|
|
75
74
|
* Prefer {@link UiFloatActions} for the standard component API. Use this composable
|
|
76
75
|
* when you need full control over markup, animation, or teleport targets.
|
|
77
|
-
*
|
|
78
76
|
* @param options - Trigger, placement, offset, and dismiss behaviour.
|
|
79
77
|
* @returns Refs, computed styles, open state, and event handlers to wire up
|
|
80
78
|
* anchor and floating elements manually.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Ref, ShallowRef } from 'vue';
|
|
2
|
+
/** An element ref as produced by `useTemplateRef`. */
|
|
3
|
+
type ElementRef = Readonly<ShallowRef<HTMLElement | null>>;
|
|
4
|
+
/**
|
|
5
|
+
* Whether an element's text is currently clipped by `text-overflow: ellipsis`.
|
|
6
|
+
*
|
|
7
|
+
* Re-measures when the element resizes and whenever `watchSource` changes, so
|
|
8
|
+
* it stays correct as the container narrows or the text is swapped out. Use it
|
|
9
|
+
* to show a tooltip only for names that are actually cut off.
|
|
10
|
+
* @param elementRef - The element whose text may be clipped
|
|
11
|
+
* @param watchSource - Value to re-measure on, e.g. the rendered text
|
|
12
|
+
* @returns Reactive truncation state
|
|
13
|
+
*/
|
|
14
|
+
export declare function useIsTruncated(elementRef: ElementRef, watchSource?: () => unknown): Ref<boolean>;
|
|
15
|
+
export {};
|