plass-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.
- package/README.md +165 -0
- package/dist/components/accordion/PlAccordion.js +1 -131
- package/dist/components/accordion/index.js +1 -1
- package/dist/components/alert/PlAlert.js +1 -109
- package/dist/components/alert/index.js +1 -1
- package/dist/components/animate-appear/PlAnimateAppear.js +1 -71
- package/dist/components/animate-appear/index.js +1 -1
- package/dist/components/animate-blink/PlAnimateBlink.js +1 -47
- package/dist/components/animate-blink/index.js +1 -1
- package/dist/components/animate-fade/PlAnimateFade.js +1 -48
- package/dist/components/animate-fade/index.js +1 -1
- package/dist/components/animate-grow/PlAnimateGrow.js +1 -49
- package/dist/components/animate-grow/index.js +1 -1
- package/dist/components/animate-headline/PlAnimateHeadline.js +1 -120
- package/dist/components/animate-headline/index.js +1 -1
- package/dist/components/animate-lighting/PlAnimateLighting.js +1 -65
- package/dist/components/animate-lighting/index.js +1 -1
- package/dist/components/animate-marquee/PlAnimateMarquee.js +1 -94
- package/dist/components/animate-marquee/index.js +1 -1
- package/dist/components/animate-rotate/PlAnimateRotate.js +1 -50
- package/dist/components/animate-rotate/index.js +1 -1
- package/dist/components/animate-slide/PlAnimateSlide.js +1 -49
- package/dist/components/animate-slide/index.js +1 -1
- package/dist/components/animate-typing/PlAnimateTyping.js +1 -177
- package/dist/components/animate-typing/index.js +1 -1
- package/dist/components/animate-zoom/PlAnimateZoom.js +1 -45
- package/dist/components/animate-zoom/index.js +1 -1
- package/dist/components/aspect-ratio/PlAspectRatio.js +1 -58
- package/dist/components/aspect-ratio/index.js +1 -1
- package/dist/components/avatar/PlAvatar.js +1 -121
- package/dist/components/avatar/index.js +1 -1
- package/dist/components/badge/PlBadge.js +1 -168
- package/dist/components/badge/index.js +1 -1
- package/dist/components/blockquote/PlBlockquote.js +1 -112
- package/dist/components/blockquote/index.js +1 -1
- package/dist/components/bottom-navigation/PlBottomNavigation.js +1 -141
- package/dist/components/bottom-navigation/index.js +1 -1
- package/dist/components/box/PlBox.js +1 -46
- package/dist/components/box/index.js +1 -1
- package/dist/components/breadcrumb/PlBreadcrumb.js +1 -201
- package/dist/components/breadcrumb/index.js +1 -1
- package/dist/components/button/PlButton.js +1 -196
- package/dist/components/button/index.js +1 -1
- package/dist/components/button-group/PlButtonGroup.js +1 -64
- package/dist/components/button-group/index.js +1 -1
- package/dist/components/card/PlCard.js +1 -102
- package/dist/components/card/index.js +1 -1
- package/dist/components/carousel/PlCarousel.js +1 -177
- package/dist/components/carousel/index.js +1 -1
- package/dist/components/chat-bubble/PlChatBubble.js +1 -206
- package/dist/components/chat-bubble/index.js +1 -1
- package/dist/components/checkbox/PlCheckbox.js +1 -100
- package/dist/components/checkbox/index.js +1 -1
- package/dist/components/chip/PlChip.js +1 -144
- package/dist/components/chip/index.js +1 -1
- package/dist/components/collapsible/PlCollapsible.js +1 -65
- package/dist/components/collapsible/index.js +1 -1
- package/dist/components/combobox/PlCombobox.js +1 -199
- package/dist/components/combobox/index.js +1 -1
- package/dist/components/container/PlContainer.js +1 -47
- package/dist/components/container/index.js +1 -1
- package/dist/components/date-picker/PlDatePicker.js +1 -87
- package/dist/components/date-picker/index.js +1 -1
- package/dist/components/date-range-picker/PlDateRangePicker.js +1 -152
- package/dist/components/date-range-picker/index.js +1 -1
- package/dist/components/date-time-picker/PlDateTimePicker.js +1 -106
- package/dist/components/date-time-picker/index.js +1 -1
- package/dist/components/divider/PlDivider.js +1 -107
- package/dist/components/divider/index.js +1 -1
- package/dist/components/drawer/PlDrawer.js +1 -190
- package/dist/components/drawer/index.js +1 -1
- package/dist/components/file-picker/PlFilePicker.js +1 -274
- package/dist/components/file-picker/index.js +1 -1
- package/dist/components/floating-bottom-navigation/PlFloatingBottomNavigation.js +1 -291
- package/dist/components/floating-bottom-navigation/index.js +1 -1
- package/dist/components/grid/PlGrid.js +1 -51
- package/dist/components/grid/PlGridItem.js +1 -34
- package/dist/components/grid/index.js +1 -2
- package/dist/components/highlight/PlHighlight.js +1 -185
- package/dist/components/highlight/index.js +1 -1
- package/dist/components/hot-keys/PlHotKeys.js +1 -294
- package/dist/components/hot-keys/index.js +1 -1
- package/dist/components/icon/PlIcon.js +1 -58
- package/dist/components/icon/index.js +1 -1
- package/dist/components/icon-button/PlIconButton.js +1 -37
- package/dist/components/icon-button/index.js +1 -1
- package/dist/components/list/PlList.js +1 -160
- package/dist/components/list/index.js +1 -1
- package/dist/components/menu/PlMenu.js +1 -209
- package/dist/components/menu/index.js +1 -1
- package/dist/components/modal/PlModal.js +1 -150
- package/dist/components/modal/index.js +1 -1
- package/dist/components/number-field/PlNumberField.js +1 -111
- package/dist/components/number-field/index.js +1 -1
- package/dist/components/otp-field/PlOtpField.js +1 -109
- package/dist/components/otp-field/index.js +1 -1
- package/dist/components/overlay/PlOverlay.js +1 -77
- package/dist/components/overlay/index.js +1 -1
- package/dist/components/pagination/PlPagination.js +1 -159
- package/dist/components/pagination/index.js +1 -1
- package/dist/components/panes/PlPanes.js +1 -324
- package/dist/components/panes/index.js +1 -1
- package/dist/components/pill/PlPill.js +1 -154
- package/dist/components/pill/index.js +1 -1
- package/dist/components/popover/PlPopover.js +1 -113
- package/dist/components/popover/index.js +1 -1
- package/dist/components/progress-box/PlProgressBox.js +1 -34
- package/dist/components/progress-box/index.js +1 -1
- package/dist/components/progress-circular/PlProgressCircular.js +1 -47
- package/dist/components/progress-circular/index.js +1 -1
- package/dist/components/progress-linear/PlProgressLinear.js +1 -40
- package/dist/components/progress-linear/index.js +1 -1
- package/dist/components/radio-group/PlRadioGroup.js +1 -99
- package/dist/components/radio-group/index.js +1 -1
- package/dist/components/rating/PlRating.js +1 -101
- package/dist/components/rating/index.js +1 -1
- package/dist/components/scroll-zone/PlScrollZone.js +1 -411
- package/dist/components/scroll-zone/index.js +1 -1
- package/dist/components/segmented-button/PlSegmentedButton.js +1 -206
- package/dist/components/segmented-button/index.js +1 -1
- package/dist/components/select/PlSelect.js +1 -115
- package/dist/components/select/index.js +1 -1
- package/dist/components/skeleton/PlSkeleton.js +1 -142
- package/dist/components/skeleton/index.js +1 -1
- package/dist/components/slider/PlSlider.js +1 -132
- package/dist/components/slider/index.js +1 -1
- package/dist/components/spoiler/PlSpoiler.js +1 -74
- package/dist/components/spoiler/index.js +1 -1
- package/dist/components/switch/PlSwitch.js +1 -131
- package/dist/components/switch/index.js +1 -1
- package/dist/components/table/PlTable.js +1 -210
- package/dist/components/table/index.js +1 -1
- package/dist/components/tabs/PlTabs.js +1 -182
- package/dist/components/tabs/index.js +1 -1
- package/dist/components/text-field/PlTextField.js +1 -126
- package/dist/components/text-field/index.js +1 -1
- package/dist/components/text-link/PlTextLink.js +1 -136
- package/dist/components/text-link/index.js +1 -1
- package/dist/components/time-picker/PlTimePicker.js +1 -97
- package/dist/components/time-picker/index.js +1 -1
- package/dist/components/timeline/PlTimeline.js +1 -207
- package/dist/components/timeline/index.js +1 -1
- package/dist/components/toast/PlToast.js +1 -174
- package/dist/components/toast/index.js +1 -1
- package/dist/components/toolbar/PlToolbar.js +1 -65
- package/dist/components/toolbar/index.js +1 -1
- package/dist/components/tooltip/PlTooltip.js +1 -117
- package/dist/components/tooltip/index.js +1 -1
- package/dist/components/typography/PlTypography.js +1 -143
- package/dist/components/typography/index.js +1 -1
- package/dist/index.js +1 -75
- package/dist/internal/animate.js +1 -318
- package/dist/internal/button-group.js +2 -19
- package/dist/internal/calendar.js +1 -501
- package/dist/internal/date.js +1 -353
- package/dist/internal/format.js +1 -41
- package/dist/internal/grid.js +1 -143
- package/dist/internal/icons.js +1 -138
- package/dist/internal/menu.js +1 -18
- package/dist/internal/picker.js +1 -139
- package/dist/internal/progress.js +1 -167
- package/dist/internal/sizer.js +1 -35
- package/dist/internal/styles.js +1 -636
- package/dist/types.js +0 -8
- package/package.json +5 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{PlAnimateTyping}from"./PlAnimateTyping.js";
|
|
@@ -1,45 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
-
import { isInfinite, useAnimateElement } from '../../internal/animate.js';
|
|
4
|
-
import { cx } from '../../internal/styles.js';
|
|
5
|
-
/**
|
|
6
|
-
* Content arriving from the middle of where it will end up.
|
|
7
|
-
*
|
|
8
|
-
* The same arithmetic as Grow at more than twice the distance, and always about
|
|
9
|
-
* the centre — which is the whole difference. A Grow unfolds from somewhere; a
|
|
10
|
-
* Zoom comes at you. Use it for the one thing on a screen that is meant to
|
|
11
|
-
* interrupt: a confirmation, a result, a number that has just landed.
|
|
12
|
-
*
|
|
13
|
-
* There is no `origin`, on purpose. A zoom anchored to a corner is a grow, and
|
|
14
|
-
* the library does not offer two spellings of one idea.
|
|
15
|
-
*/
|
|
16
|
-
export const PlAnimateZoom = /* @__PURE__ */ React.forwardRef(function PlAnimateZoom({ duration = 320, delay = 0, easing, repeat = 1, alternate, paused, trigger = 'mount', play, once = true, threshold = 0.2, mode = 'in', from = 0.4, fade = true, render, className, style, children, ...props }, ref) {
|
|
17
|
-
const animate = useAnimateElement({
|
|
18
|
-
effect: 'zoom',
|
|
19
|
-
duration,
|
|
20
|
-
delay,
|
|
21
|
-
easing,
|
|
22
|
-
repeat,
|
|
23
|
-
alternate,
|
|
24
|
-
mode,
|
|
25
|
-
scale: from,
|
|
26
|
-
opacity: fade ? 0 : 1,
|
|
27
|
-
trigger,
|
|
28
|
-
play,
|
|
29
|
-
once,
|
|
30
|
-
threshold,
|
|
31
|
-
paused,
|
|
32
|
-
infinite: isInfinite(repeat)
|
|
33
|
-
});
|
|
34
|
-
return useRender({
|
|
35
|
-
render,
|
|
36
|
-
ref: [ref, animate.ref],
|
|
37
|
-
props: {
|
|
38
|
-
...props,
|
|
39
|
-
className: cx(animate.className, className),
|
|
40
|
-
style: { transformOrigin: 'center', ...animate.style, ...style },
|
|
41
|
-
...animate.props,
|
|
42
|
-
children
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
1
|
+
"use client";import*as e from"react";import{useRender as r}from"@base-ui/react/use-render";import{isInfinite as t,useAnimateElement as a}from"../../internal/animate.js";import{cx as n}from"../../internal/styles.js";export const PlAnimateZoom=/* @__PURE__ */e.forwardRef(function PlAnimateZoom({duration:e=320,delay:o=0,easing:s,repeat:i=1,alternate:l,paused:m,trigger:c="mount",play:d,once:p=!0,threshold:f=.2,mode:u="in",from:y=.4,fade:g=!0,render:h,className:N,style:j,children:A,...P},Z){const b=a({effect:"zoom",duration:e,delay:o,easing:s,repeat:i,alternate:l,mode:u,scale:y,opacity:g?0:1,trigger:c,play:d,once:p,threshold:f,paused:m,infinite:t(i)});return r({render:h,ref:[Z,b.ref],props:{...P,className:n(b.className,N),style:{transformOrigin:"center",...b.style,...j},...b.props,children:A}})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{PlAnimateZoom}from"./PlAnimateZoom.js";
|
|
@@ -1,58 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
-
import { cx, radiusClasses } from '../../internal/styles.js';
|
|
4
|
-
/**
|
|
5
|
-
* The media a `fit` reaches, stretched to the box first.
|
|
6
|
-
*
|
|
7
|
-
* Written out one selector at a time rather than as a comma list, because
|
|
8
|
-
* Tailwind only ever sees class names that appear literally in the source and a
|
|
9
|
-
* grouped arbitrary variant is one string it has to parse rather than match.
|
|
10
|
-
*
|
|
11
|
-
* `iframe` takes the sizing and not the fit: an embed lays its own content out
|
|
12
|
-
* and `object-fit` has nothing to act on.
|
|
13
|
-
*/
|
|
14
|
-
const stretchClasses = /* @__PURE__ */ [
|
|
15
|
-
'[&>img]:size-full',
|
|
16
|
-
'[&>video]:size-full',
|
|
17
|
-
'[&>canvas]:size-full',
|
|
18
|
-
'[&>svg]:size-full',
|
|
19
|
-
'[&>iframe]:size-full',
|
|
20
|
-
'[&>picture]:size-full',
|
|
21
|
-
'[&>picture>img]:size-full'
|
|
22
|
-
].join(' ');
|
|
23
|
-
const fitClasses = {
|
|
24
|
-
cover: '[&>img]:object-cover [&>video]:object-cover [&>picture>img]:object-cover',
|
|
25
|
-
contain: '[&>img]:object-contain [&>video]:object-contain [&>picture>img]:object-contain',
|
|
26
|
-
fill: '[&>img]:object-fill [&>video]:object-fill [&>picture>img]:object-fill',
|
|
27
|
-
none: '[&>img]:object-none [&>video]:object-none [&>picture>img]:object-none'
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* A box that keeps a proportion whatever width it is given.
|
|
31
|
-
*
|
|
32
|
-
* It draws nothing — no sheet, no hairline, no shadow — which is what puts it
|
|
33
|
-
* in `layout` beside `PlContainer` and `PlGrid` rather than in `surfaces`. What
|
|
34
|
-
* it does is reserve the space: a card whose image arrives late does not reflow
|
|
35
|
-
* the page around it, and a row of thumbnails is a row of one shape.
|
|
36
|
-
*
|
|
37
|
-
* The proportion is CSS's own `aspect-ratio`, so a caller who already knows
|
|
38
|
-
* `16 / 9` has nothing to translate. `fit` is the one convenience on top: the
|
|
39
|
-
* media inside is stretched to the box and then fitted, which is the pair of
|
|
40
|
-
* declarations every use of this component would otherwise start with.
|
|
41
|
-
*/
|
|
42
|
-
export const PlAspectRatio = /* @__PURE__ */ React.forwardRef(function PlAspectRatio({ ratio = 1, fit = 'cover', rounded = false, size = 'md', render, className, style, children, ...props }, ref) {
|
|
43
|
-
const classNames = cx(
|
|
44
|
-
// `overflow-hidden` is not decoration: without it a `cover` image spills
|
|
45
|
-
// out of the proportion it was just given, and the box would only be
|
|
46
|
-
// reserving space rather than holding anything to it.
|
|
47
|
-
'relative block w-full overflow-hidden', stretchClasses, fitClasses[fit], rounded ? radiusClasses[size] : '', className);
|
|
48
|
-
return useRender({
|
|
49
|
-
render,
|
|
50
|
-
ref,
|
|
51
|
-
props: {
|
|
52
|
-
className: classNames,
|
|
53
|
-
style: { aspectRatio: ratio, ...style },
|
|
54
|
-
children,
|
|
55
|
-
...props
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
});
|
|
1
|
+
"use client";import*as e from"react";import{useRender as i}from"@base-ui/react/use-render";import{cx as o,radiusClasses as t}from"../../internal/styles.js";const c=/* @__PURE__ */["[&>img]:size-full","[&>video]:size-full","[&>canvas]:size-full","[&>svg]:size-full","[&>iframe]:size-full","[&>picture]:size-full","[&>picture>img]:size-full"].join(" "),r={cover:"[&>img]:object-cover [&>video]:object-cover [&>picture>img]:object-cover",contain:"[&>img]:object-contain [&>video]:object-contain [&>picture>img]:object-contain",fill:"[&>img]:object-fill [&>video]:object-fill [&>picture>img]:object-fill",none:"[&>img]:object-none [&>video]:object-none [&>picture>img]:object-none"};export const PlAspectRatio=/* @__PURE__ */e.forwardRef(function PlAspectRatio({ratio:e=1,fit:l="cover",rounded:n=!1,size:s="md",render:a,className:f,style:m,children:u,...d},p){const b=o("relative block w-full overflow-hidden",c,r[l],n?t[s]:"",f);return i({render:a,ref:p,props:{className:b,style:{aspectRatio:e,...m},children:u,...d}})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{PlAspectRatio}from"./PlAspectRatio.js";
|
|
@@ -1,121 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { Avatar as BaseUIAvatar } from '@base-ui/react/avatar';
|
|
4
|
-
import { controlHeightClasses, controlSlots, controlSquareClasses, glassClasses, hasContent, radiusClasses, srOnlyClasses, transitionClasses } from '../../internal/styles.js';
|
|
5
|
-
/**
|
|
6
|
-
* The initials, sized off the box rather than off the row.
|
|
7
|
-
*
|
|
8
|
-
* Its own ladder and not `controlTextClasses`, because a control's label is
|
|
9
|
-
* measured against the words next to it and this one is measured against the
|
|
10
|
-
* circle around it: roughly 40% of the diameter at every step, which is where
|
|
11
|
-
* two characters fill the width without touching the edge.
|
|
12
|
-
*/
|
|
13
|
-
const initialsTextClasses = {
|
|
14
|
-
xs: 'text-[0.5625rem]',
|
|
15
|
-
sm: 'text-[0.6875rem]',
|
|
16
|
-
md: 'text-[0.8125rem]',
|
|
17
|
-
lg: 'text-[1rem]',
|
|
18
|
-
xl: 'text-[1.1875rem]'
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* The three materials, said the way a *control* says them: an avatar **is** the
|
|
22
|
-
* thing being coloured — a portrait of one particular person — so its sheet
|
|
23
|
-
* takes the tint, exactly as a `PlAlert`'s does and unlike a `PlCard`'s.
|
|
24
|
-
*
|
|
25
|
-
* `solid` carries no gloss line, for the reason a filled `PlButton` carries
|
|
26
|
-
* none: the gradient is the form.
|
|
27
|
-
*/
|
|
28
|
-
const variantClasses = {
|
|
29
|
-
solid: /* @__PURE__ */ [
|
|
30
|
-
'text-(--p-on-solid) [background-image:var(--p-fill)]',
|
|
31
|
-
'[box-shadow:var(--p-elev),var(--p-lift)]'
|
|
32
|
-
].join(' '),
|
|
33
|
-
glass: /* @__PURE__ */ [
|
|
34
|
-
glassClasses,
|
|
35
|
-
'border text-(--p-accent) bg-(--plass-glass)',
|
|
36
|
-
'[border-color:var(--plass-border)]',
|
|
37
|
-
'[box-shadow:var(--p-elev),var(--plass-gloss-glass)]'
|
|
38
|
-
].join(' '),
|
|
39
|
-
ghost: 'text-(--p-accent) bg-(--p-soft-press) [box-shadow:var(--p-elev)]'
|
|
40
|
-
};
|
|
41
|
-
const baseClasses = /* @__PURE__ */ [
|
|
42
|
-
'relative inline-flex shrink-0 select-none items-center justify-center overflow-hidden',
|
|
43
|
-
'align-middle leading-none font-semibold tracking-wide whitespace-nowrap',
|
|
44
|
-
// A glyph handed to `children` is drawn against the circle, not against a
|
|
45
|
-
// word, so it is sized off the box like the initials are rather than off the
|
|
46
|
-
// `1.2em` an icon riding on a label takes.
|
|
47
|
-
'[&_svg]:pointer-events-none [&_svg]:size-[55%]',
|
|
48
|
-
transitionClasses
|
|
49
|
-
].join(' ');
|
|
50
|
-
/**
|
|
51
|
-
* The default fallback: a shoulders-and-head silhouette, drawn here rather than
|
|
52
|
-
* in `internal/icons` because this is the only component that needs it.
|
|
53
|
-
*
|
|
54
|
-
* It exists so that `<PlAvatar />` with nothing at all is still an avatar. A box
|
|
55
|
-
* with no picture, no name and no glyph in it is indistinguishable from a
|
|
56
|
-
* component that failed to render.
|
|
57
|
-
*/
|
|
58
|
-
function PersonIcon() {
|
|
59
|
-
return (_jsxs("svg", { viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", children: [_jsx("path", { d: "M12 12a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9Z" }), _jsx("path", { d: "M12 14.25c-4.28 0-7.75 2.42-7.75 5.4 0 .75.6 1.35 1.35 1.35h12.8c.75 0 1.35-.6 1.35-1.35 0-2.98-3.47-5.4-7.75-5.4Z" })] }));
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* The first character of the first word, plus the first of the last.
|
|
63
|
-
*
|
|
64
|
-
* `Array.from` rather than `[0]`, so a name that starts with an emoji or with
|
|
65
|
-
* any character outside the basic plane is not cut in half between its two code
|
|
66
|
-
* units. `normalize('NFC')` first, so a name whose accents arrived decomposed —
|
|
67
|
-
* which is what a macOS filename and a good many APIs hand you — yields `Ä`
|
|
68
|
-
* rather than a bare `A`.
|
|
69
|
-
*
|
|
70
|
-
* One word gives one character on purpose. Korean, Japanese and Chinese names
|
|
71
|
-
* are a single token, and two of their characters at 40px is a smudge where one
|
|
72
|
-
* is a name.
|
|
73
|
-
*/
|
|
74
|
-
function initialsOf(name) {
|
|
75
|
-
const words = name.normalize('NFC').trim().split(/\s+/).filter(Boolean);
|
|
76
|
-
if (words.length === 0) {
|
|
77
|
-
return '';
|
|
78
|
-
}
|
|
79
|
-
const first = Array.from(words[0])[0] ?? '';
|
|
80
|
-
const last = words.length > 1 ? (Array.from(words[words.length - 1])[0] ?? '') : '';
|
|
81
|
-
return (first + last).toLocaleUpperCase();
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* A picture of a person or a thing, at a known size, that is never an empty box.
|
|
85
|
-
*
|
|
86
|
-
* Three things can be drawn in it and exactly one of them is at a time: the
|
|
87
|
-
* picture, if `src` is given and it loads; otherwise whatever stands in for it —
|
|
88
|
-
* `children`, or `initials`, or the initials derived from `name`; and failing
|
|
89
|
-
* all of those, a silhouette. Which one is showing is Base UI's `Avatar` to
|
|
90
|
-
* decide, because "has the image loaded" is a question with four answers and a
|
|
91
|
-
* race in the middle of it.
|
|
92
|
-
*
|
|
93
|
-
* It carries no status dot of its own. An avatar with a green mark on it is a
|
|
94
|
-
* `PlBadge` with an avatar in it, and inventing a second spelling for that would
|
|
95
|
-
* give the library two of them.
|
|
96
|
-
*/
|
|
97
|
-
export const PlAvatar = /* @__PURE__ */ React.forwardRef(function PlAvatar({ src, srcSet, alt, name, initials, shape = 'circle', variant = 'ghost', size = 'md', color = 'primary', elevation = 0, delay, imageProps, onLoadingStatusChange, className, style, children, ...props }, ref) {
|
|
98
|
-
const derived = name ? initialsOf(name) : '';
|
|
99
|
-
const label = alt ?? name;
|
|
100
|
-
// `children` beats the initials beats the silhouette. Only the last of the
|
|
101
|
-
// three has nothing to say, which is what decides whether the fallback needs
|
|
102
|
-
// the name spelled out beside it.
|
|
103
|
-
const stand = hasContent(children) ? children : (initials ?? derived) || _jsx(PersonIcon, {});
|
|
104
|
-
const speaks = hasContent(children) || Boolean(initials ?? derived);
|
|
105
|
-
const classNames = [
|
|
106
|
-
baseClasses,
|
|
107
|
-
controlHeightClasses[size],
|
|
108
|
-
controlSquareClasses[size],
|
|
109
|
-
initialsTextClasses[size],
|
|
110
|
-
shape === 'circle' ? 'rounded-full' : radiusClasses[size],
|
|
111
|
-
variantClasses[variant],
|
|
112
|
-
className ?? ''
|
|
113
|
-
]
|
|
114
|
-
.filter(Boolean)
|
|
115
|
-
.join(' ');
|
|
116
|
-
return (_jsxs(BaseUIAvatar.Root, { ref: ref, className: classNames, style: { ...controlSlots(color, elevation, variant), ...style }, ...props, children: [src ? (_jsx(BaseUIAvatar.Image, { src: src, srcSet: srcSet,
|
|
117
|
-
// Empty rather than absent: an avatar beside the person's own name is
|
|
118
|
-
// decoration, and `alt` left off is what makes a screen reader read
|
|
119
|
-
// the file name out instead.
|
|
120
|
-
alt: label ?? '', className: "size-full object-cover", onLoadingStatusChange: onLoadingStatusChange, ...imageProps })) : null, _jsxs(BaseUIAvatar.Fallback, { delay: src ? delay : undefined, className: "flex size-full items-center justify-center", children: [label && speaks ? _jsx("span", { className: srOnlyClasses, children: label }) : null, _jsx("span", { "aria-hidden": label && speaks ? true : undefined, className: "contents", children: stand })] })] }));
|
|
121
|
-
});
|
|
1
|
+
"use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{Avatar as t}from"@base-ui/react/avatar";import{controlHeightClasses as s,controlSlots as n,controlSquareClasses as l,glassClasses as o,hasContent as i,radiusClasses as c,srOnlyClasses as d,transitionClasses as m}from"../../internal/styles.js";const p={xs:"text-[0.5625rem]",sm:"text-[0.6875rem]",md:"text-[0.8125rem]",lg:"text-[1rem]",xl:"text-[1.1875rem]"},f={solid:/* @__PURE__ */["text-(--p-on-solid) [background-image:var(--p-fill)]","[box-shadow:var(--p-elev),var(--p-lift)]"].join(" "),glass:/* @__PURE__ */[o,"border text-(--p-accent) bg-(--plass-glass)","[border-color:var(--plass-border)]","[box-shadow:var(--p-elev),var(--plass-gloss-glass)]"].join(" "),ghost:"text-(--p-accent) bg-(--p-soft-press) [box-shadow:var(--p-elev)]"},g=/* @__PURE__ */["relative inline-flex shrink-0 select-none items-center justify-center overflow-hidden","align-middle leading-none font-semibold tracking-wide whitespace-nowrap","[&_svg]:pointer-events-none [&_svg]:size-[55%]",m].join(" ");function PersonIcon(){return a("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[e("path",{d:"M12 12a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9Z"}),e("path",{d:"M12 14.25c-4.28 0-7.75 2.42-7.75 5.4 0 .75.6 1.35 1.35 1.35h12.8c.75 0 1.35-.6 1.35-1.35 0-2.98-3.47-5.4-7.75-5.4Z"})]})}export const PlAvatar=/* @__PURE__ */r.forwardRef(function PlAvatar({src:r,srcSet:o,alt:m,name:v,initials:h,shape:u="circle",variant:x="ghost",size:b="md",color:j="primary",elevation:y=0,delay:w,imageProps:N,onLoadingStatusChange:z,className:A,style:C,children:P,...k},B){const S=v?function initialsOf(e){const a=e.normalize("NFC").trim().split(/\s+/).filter(Boolean);return 0===a.length?"":((Array.from(a[0])[0]??"")+(a.length>1?Array.from(a[a.length-1])[0]??"":"")).toLocaleUpperCase()}(v):"",I=m??v,L=i(P)?P:(h??S)||e(PersonIcon,{}),F=i(P)||Boolean(h??S),M=[g,s[b],l[b],p[b],"circle"===u?"rounded-full":c[b],f[x],A??""].filter(Boolean).join(" ");return a(t.Root,{ref:B,className:M,style:{...n(j,y,x),...C},...k,children:[r?e(t.Image,{src:r,srcSet:o,alt:I??"",className:"size-full object-cover",onLoadingStatusChange:z,...N}):null,a(t.Fallback,{delay:r?w:void 0,className:"flex size-full items-center justify-center",children:[I&&F?e("span",{className:d,children:I}):null,e("span",{"aria-hidden":!(!I||!F)||void 0,className:"contents",children:L})]})]})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{PlAvatar}from"./PlAvatar.js";
|
|
@@ -1,168 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { controlSlots, glassClasses, hasContent, srOnlyClasses, transitionClasses } from '../../internal/styles.js';
|
|
4
|
-
/**
|
|
5
|
-
* A badge is smaller than anything else in the library, so it has a ladder of
|
|
6
|
-
* its own rather than a step off `controlHeightClasses`.
|
|
7
|
-
*
|
|
8
|
-
* A control's height is the number a *row* lines up on; a badge lines up on
|
|
9
|
-
* nothing — it hangs off the corner of something else. `md` is 18px, which is
|
|
10
|
-
* the smallest a two-digit number stays legible at.
|
|
11
|
-
*/
|
|
12
|
-
const badgeHeightClasses = {
|
|
13
|
-
xs: 'h-3.5 min-w-3.5',
|
|
14
|
-
sm: 'h-4 min-w-4',
|
|
15
|
-
md: 'h-4.5 min-w-4.5',
|
|
16
|
-
lg: 'h-5 min-w-5',
|
|
17
|
-
xl: 'h-6 min-w-6'
|
|
18
|
-
};
|
|
19
|
-
/** The dot: the same ladder with the digits taken out, so it goes square. */
|
|
20
|
-
const dotSizeClasses = {
|
|
21
|
-
xs: 'size-1.5',
|
|
22
|
-
sm: 'size-2',
|
|
23
|
-
md: 'size-2.5',
|
|
24
|
-
lg: 'size-2.5',
|
|
25
|
-
xl: 'size-3'
|
|
26
|
-
};
|
|
27
|
-
const badgeTextClasses = {
|
|
28
|
-
xs: 'text-[0.5625rem]',
|
|
29
|
-
sm: 'text-[0.625rem]',
|
|
30
|
-
md: 'text-[0.6875rem]',
|
|
31
|
-
lg: 'text-[0.75rem]',
|
|
32
|
-
xl: 'text-[0.8125rem]'
|
|
33
|
-
};
|
|
34
|
-
/** Horizontal breathing room around the digits. `density` is what halves it. */
|
|
35
|
-
const badgePaddingClasses = {
|
|
36
|
-
default: { xs: 'px-1', sm: 'px-1', md: 'px-1.5', lg: 'px-1.5', xl: 'px-2' },
|
|
37
|
-
compact: { xs: 'px-0.5', sm: 'px-0.5', md: 'px-1', lg: 'px-1', xl: 'px-1.5' }
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* A badge sits well below the radius ladder — at 18px tall, `--plass-radius-xs`
|
|
41
|
-
* (8px) is already most of the way to a pill, and a badge *is* the one thing in
|
|
42
|
-
* the library allowed to be one.
|
|
43
|
-
*
|
|
44
|
-
* That is not a hole in the design language, it is the exception the language
|
|
45
|
-
* names. A Plass corner is a moulded fillet on a *surface*, and a badge is not a
|
|
46
|
-
* surface: it is a mark laid on one — which is also why it is the only component
|
|
47
|
-
* that overlaps its neighbour.
|
|
48
|
-
*/
|
|
49
|
-
const badgeRadiusClasses = 'rounded-full';
|
|
50
|
-
/**
|
|
51
|
-
* How far the marker is pulled out of the corner, per size.
|
|
52
|
-
*
|
|
53
|
-
* A negative margin rather than the `translate(50%,-50%)` every other library
|
|
54
|
-
* reaches for, because the house rule against `transform` is absolute and worth
|
|
55
|
-
* more than the two lines it costs here. The offsets are half the marker's own
|
|
56
|
-
* height, so the vertical overhang is exactly half — and horizontally a wide
|
|
57
|
-
* `99+` tucks in a little further than half, which is what you want anyway.
|
|
58
|
-
*/
|
|
59
|
-
const cornerOffsets = {
|
|
60
|
-
xs: { badge: '-mt-1.5 -mb-1.5 -ms-1.5 -me-1.5', dot: '-mt-0.5 -mb-0.5 -ms-0.5 -me-0.5' },
|
|
61
|
-
sm: { badge: '-mt-2 -mb-2 -ms-2 -me-2', dot: '-mt-1 -mb-1 -ms-1 -me-1' },
|
|
62
|
-
md: { badge: '-mt-2 -mb-2 -ms-2 -me-2', dot: '-mt-1 -mb-1 -ms-1 -me-1' },
|
|
63
|
-
lg: { badge: '-mt-2.5 -mb-2.5 -ms-2.5 -me-2.5', dot: '-mt-1 -mb-1 -ms-1 -me-1' },
|
|
64
|
-
xl: { badge: '-mt-3 -mb-3 -ms-3 -me-3', dot: '-mt-1.5 -mb-1.5 -ms-1.5 -me-1.5' }
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* Which two edges the marker is pinned to. Logical properties throughout, so the
|
|
68
|
-
* corner flips with the writing direction rather than staying stuck on the right.
|
|
69
|
-
*/
|
|
70
|
-
const placementClasses = {
|
|
71
|
-
'top-start': 'top-0 start-0',
|
|
72
|
-
'top-end': 'top-0 end-0',
|
|
73
|
-
'bottom-start': 'bottom-0 start-0',
|
|
74
|
-
'bottom-end': 'bottom-0 end-0'
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* The extra inset a round anchor needs. A circle's corner is `r·(1 − 1/√2)` —
|
|
78
|
-
* about 15% of its diameter — inside the bounding box the badge is positioned
|
|
79
|
-
* against, so without this the marker floats off an avatar with a gap under it.
|
|
80
|
-
*/
|
|
81
|
-
const circleInsetClasses = {
|
|
82
|
-
'top-start': 'mt-[7%] ms-[7%]',
|
|
83
|
-
'top-end': 'mt-[7%] me-[7%]',
|
|
84
|
-
'bottom-start': 'mb-[7%] ms-[7%]',
|
|
85
|
-
'bottom-end': 'mb-[7%] me-[7%]'
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* The three materials, said the way a *control* says them: the marker is the
|
|
89
|
-
* thing being coloured, so its sheet takes the tint.
|
|
90
|
-
*
|
|
91
|
-
* `solid` carries the gradient and the tinted lift and no gloss line, exactly as
|
|
92
|
-
* a filled `PlButton` does. `ghost` is the one to reach for on a busy surface —
|
|
93
|
-
* a soft tinted mark that reports without shouting.
|
|
94
|
-
*/
|
|
95
|
-
const variantClasses = {
|
|
96
|
-
solid: /* @__PURE__ */ [
|
|
97
|
-
'text-(--p-on-solid) [background-image:var(--p-fill)]',
|
|
98
|
-
'[box-shadow:var(--p-elev),var(--p-lift)]'
|
|
99
|
-
].join(' '),
|
|
100
|
-
glass: /* @__PURE__ */ [
|
|
101
|
-
glassClasses,
|
|
102
|
-
'border text-(--p-accent) bg-(--plass-glass)',
|
|
103
|
-
'[border-color:var(--plass-border)]',
|
|
104
|
-
'[box-shadow:var(--p-elev),var(--plass-gloss-glass)]'
|
|
105
|
-
].join(' '),
|
|
106
|
-
ghost: 'text-(--p-accent) bg-(--p-soft-press)'
|
|
107
|
-
};
|
|
108
|
-
/** `99+`, but only for a value a `+` means anything on. */
|
|
109
|
-
function capContent(content, max) {
|
|
110
|
-
return typeof content === 'number' && content > max ? `${max}+` : content;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* A small mark in the corner of something else: unread mail on an inbox icon, a
|
|
114
|
-
* status dot on an avatar, a count on a tab.
|
|
115
|
-
*
|
|
116
|
-
* The shell is a `<span>` that wraps the anchor and does nothing but establish a
|
|
117
|
-
* positioning context — no width, no padding, `align-middle` — so a badged icon
|
|
118
|
-
* button still measures and lines up exactly like a bare one. With no children
|
|
119
|
-
* the marker lays out inline instead, which is what a standalone status pill is.
|
|
120
|
-
*
|
|
121
|
-
* There is no Base UI primitive under this, and there should not be: a badge has
|
|
122
|
-
* no interaction, no state and no keyboard contract. It is a mark. Wiring it to a
|
|
123
|
-
* widget primitive would hand every decorative dot a role it cannot honour.
|
|
124
|
-
*
|
|
125
|
-
* What it does owe a screen reader is a sentence rather than a number, which is
|
|
126
|
-
* what `label` is for — `content={3}` beside a bell reads out as "3".
|
|
127
|
-
*/
|
|
128
|
-
export const PlBadge = /* @__PURE__ */ React.forwardRef(function PlBadge({ variant = 'solid', size = 'md', color = 'primary', density = 'default', elevation = 0, content, max = 99, dot = false, showZero = false, invisible = false, placement = 'top-end', overlap = 'square', label, className, style, children, ...props }, ref) {
|
|
129
|
-
const anchored = hasContent(children);
|
|
130
|
-
// `0` is content, and `hasContent` would agree — this is the one place the
|
|
131
|
-
// library asks a second question, because a count of nothing is not news.
|
|
132
|
-
const empty = !hasContent(content) || (content === 0 && !showZero);
|
|
133
|
-
const asDot = dot || empty;
|
|
134
|
-
const hidden = invisible || (empty && !dot);
|
|
135
|
-
const markerClasses = [
|
|
136
|
-
'pointer-events-none z-10 inline-flex shrink-0 items-center justify-center',
|
|
137
|
-
'font-semibold tabular-nums whitespace-nowrap',
|
|
138
|
-
badgeRadiusClasses,
|
|
139
|
-
transitionClasses,
|
|
140
|
-
variantClasses[variant],
|
|
141
|
-
asDot
|
|
142
|
-
? dotSizeClasses[size]
|
|
143
|
-
: [
|
|
144
|
-
badgeHeightClasses[size],
|
|
145
|
-
badgeTextClasses[size],
|
|
146
|
-
badgePaddingClasses[density][size]
|
|
147
|
-
].join(' '),
|
|
148
|
-
anchored ? `absolute ${placementClasses[placement]}` : 'relative align-middle',
|
|
149
|
-
anchored ? (asDot ? cornerOffsets[size].dot : cornerOffsets[size].badge) : '',
|
|
150
|
-
anchored && overlap === 'circle' ? circleInsetClasses[placement] : '',
|
|
151
|
-
// Visibility, not opacity: a half-faded badge is a badge you have to squint
|
|
152
|
-
// at to find out whether it is there. The marker keeps its box either way,
|
|
153
|
-
// so nothing around it moves when it comes back.
|
|
154
|
-
hidden ? 'invisible' : '',
|
|
155
|
-
className ?? ''
|
|
156
|
-
]
|
|
157
|
-
.filter(Boolean)
|
|
158
|
-
.join(' ');
|
|
159
|
-
const capped = capContent(content, max);
|
|
160
|
-
const marker = (_jsx("span", { ref: ref, className: markerClasses, style: { ...controlSlots(color, elevation, variant), ...style }, "aria-hidden": hidden ? true : undefined, ...props, children: hidden ? null : (_jsxs(_Fragment, { children: [asDot || label ? _jsx("span", { className: srOnlyClasses, children: label ?? capped }) : null, asDot ? null : _jsx("span", { "aria-hidden": label ? true : undefined, children: capped })] })) }));
|
|
161
|
-
if (!anchored) {
|
|
162
|
-
return marker;
|
|
163
|
-
}
|
|
164
|
-
// `inline-flex` rather than `inline-block`: the shell has to be exactly as
|
|
165
|
-
// wide and as tall as what it wraps, or a badged icon button stops lining up
|
|
166
|
-
// with the bare one beside it.
|
|
167
|
-
return (_jsxs("span", { className: "relative inline-flex shrink-0 align-middle", children: [children, marker] }));
|
|
168
|
-
});
|
|
1
|
+
"use client";import{jsx as e,Fragment as t,jsxs as s}from"react/jsx-runtime";import*as m from"react";import{controlSlots as o,glassClasses as a,hasContent as l,srOnlyClasses as n,transitionClasses as r}from"../../internal/styles.js";const i={xs:"h-3.5 min-w-3.5",sm:"h-4 min-w-4",md:"h-4.5 min-w-4.5",lg:"h-5 min-w-5",xl:"h-6 min-w-6"},d={xs:"size-1.5",sm:"size-2",md:"size-2.5",lg:"size-2.5",xl:"size-3"},p={xs:"text-[0.5625rem]",sm:"text-[0.625rem]",md:"text-[0.6875rem]",lg:"text-[0.75rem]",xl:"text-[0.8125rem]"},b={default:{xs:"px-1",sm:"px-1",md:"px-1.5",lg:"px-1.5",xl:"px-2"},compact:{xs:"px-0.5",sm:"px-0.5",md:"px-1",lg:"px-1",xl:"px-1.5"}},x="rounded-full",c={xs:{badge:"-mt-1.5 -mb-1.5 -ms-1.5 -me-1.5",dot:"-mt-0.5 -mb-0.5 -ms-0.5 -me-0.5"},sm:{badge:"-mt-2 -mb-2 -ms-2 -me-2",dot:"-mt-1 -mb-1 -ms-1 -me-1"},md:{badge:"-mt-2 -mb-2 -ms-2 -me-2",dot:"-mt-1 -mb-1 -ms-1 -me-1"},lg:{badge:"-mt-2.5 -mb-2.5 -ms-2.5 -me-2.5",dot:"-mt-1 -mb-1 -ms-1 -me-1"},xl:{badge:"-mt-3 -mb-3 -ms-3 -me-3",dot:"-mt-1.5 -mb-1.5 -ms-1.5 -me-1.5"}},g={"top-start":"top-0 start-0","top-end":"top-0 end-0","bottom-start":"bottom-0 start-0","bottom-end":"bottom-0 end-0"},f={"top-start":"mt-[7%] ms-[7%]","top-end":"mt-[7%] me-[7%]","bottom-start":"mb-[7%] ms-[7%]","bottom-end":"mb-[7%] me-[7%]"},h={solid:/* @__PURE__ */["text-(--p-on-solid) [background-image:var(--p-fill)]","[box-shadow:var(--p-elev),var(--p-lift)]"].join(" "),glass:/* @__PURE__ */[a,"border text-(--p-accent) bg-(--plass-glass)","[border-color:var(--plass-border)]","[box-shadow:var(--p-elev),var(--plass-gloss-glass)]"].join(" "),ghost:"text-(--p-accent) bg-(--p-soft-press)"};export const PlBadge=/* @__PURE__ */m.forwardRef(function PlBadge({variant:m="solid",size:a="md",color:u="primary",density:v="default",elevation:w=0,content:j,max:y=99,dot:z=!1,showZero:N=!1,invisible:k=!1,placement:B="top-end",overlap:P="square",label:$,className:q,style:C,children:F,...R},Z){const A=l(F),D=!l(j)||0===j&&!N,E=z||D,G=k||D&&!z,H=["pointer-events-none z-10 inline-flex shrink-0 items-center justify-center","font-semibold tabular-nums whitespace-nowrap",x,r,h[m],E?d[a]:[i[a],p[a],b[v][a]].join(" "),A?`absolute ${g[B]}`:"relative align-middle",A?E?c[a].dot:c[a].badge:"",A&&"circle"===P?f[B]:"",G?"invisible":"",q??""].filter(Boolean).join(" "),I=function capContent(e,t){return"number"==typeof e&&e>t?`${t}+`:e}(j,y),J=e("span",{ref:Z,className:H,style:{...o(u,w,m),...C},"aria-hidden":!!G||void 0,...R,children:G?null:s(t,{children:[E||$?e("span",{className:n,children:$??I}):null,E?null:e("span",{"aria-hidden":!!$||void 0,children:I})]})});return A?s("span",{className:"relative inline-flex shrink-0 align-middle",children:[F,J]}):J});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{PlBadge}from"./PlBadge.js";
|
|
@@ -1,112 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { glassClasses, hasContent, metaTextClasses, radiusClasses, sheetPaddingXClasses, sheetPaddingYClasses, surfaceSlots, transitionClasses } from '../../internal/styles.js';
|
|
4
|
-
/**
|
|
5
|
-
* The quote itself, one step above body copy with the leading opened up.
|
|
6
|
-
*
|
|
7
|
-
* The sizes are `sheetTitleClasses`', because a quote is set at a heading's
|
|
8
|
-
* scale — but the leading is not: a title is a line or two and a quote is a
|
|
9
|
-
* paragraph somebody has to read, so it gets the air a paragraph needs.
|
|
10
|
-
*/
|
|
11
|
-
const quoteTextClasses = {
|
|
12
|
-
xs: 'text-[0.75rem]/[1.25rem]',
|
|
13
|
-
sm: 'text-[0.8125rem]/[1.375rem]',
|
|
14
|
-
md: 'text-[0.9375rem]/[1.625rem]',
|
|
15
|
-
lg: 'text-[1.0625rem]/[1.875rem]',
|
|
16
|
-
xl: 'text-[1.25rem]/[2.125rem]'
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* The rule down the leading edge, and the one thing every variant has.
|
|
20
|
-
*
|
|
21
|
-
* `border-s`, not `border-l`: the rule belongs on the side the text starts on,
|
|
22
|
-
* which is the right edge under RTL. Its width is the one number here that does
|
|
23
|
-
* not come off a ladder — a quote rule is 2px at every size, because it is a
|
|
24
|
-
* mark in the margin rather than a part of the type.
|
|
25
|
-
*/
|
|
26
|
-
const ruleClasses = 'border-s-2 [border-inline-start-color:var(--p-accent)]';
|
|
27
|
-
/**
|
|
28
|
-
* The three materials, said the way a *container* says them — the sheet is never
|
|
29
|
-
* dyed, exactly as on a `PlCard`. A quote holds somebody else's words, and words
|
|
30
|
-
* on a tinted pane are words on a background nobody chose them against. The
|
|
31
|
-
* family reaches the rule and stops.
|
|
32
|
-
*
|
|
33
|
-
* `ghost` is the default and the one that belongs in running prose: a rule in
|
|
34
|
-
* the margin and nothing else, which is what a quote has looked like since long
|
|
35
|
-
* before there were surfaces to put one on.
|
|
36
|
-
*/
|
|
37
|
-
const variantClasses = {
|
|
38
|
-
solid: /* @__PURE__ */ [
|
|
39
|
-
glassClasses,
|
|
40
|
-
'bg-(--plass-glass-press)',
|
|
41
|
-
'[box-shadow:var(--p-elev),var(--plass-gloss-glass)]'
|
|
42
|
-
].join(' '),
|
|
43
|
-
// `border-s-2` again, after `border`, so the hairline on the other three edges
|
|
44
|
-
// does not flatten the rule back to a pixel.
|
|
45
|
-
glass: /* @__PURE__ */ [
|
|
46
|
-
glassClasses,
|
|
47
|
-
'border border-s-2 bg-(--plass-glass)',
|
|
48
|
-
'[border-color:var(--plass-glass-line)]',
|
|
49
|
-
'[box-shadow:var(--p-elev),var(--plass-gloss-glass)]'
|
|
50
|
-
].join(' '),
|
|
51
|
-
ghost: 'bg-transparent'
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* The quotation mark: a pair of commas turned up, drawn rather than typed.
|
|
55
|
-
*
|
|
56
|
-
* A real `“` would be set in whatever face the page uses and would change shape,
|
|
57
|
-
* weight and baseline with it — and at 2em it is the largest single glyph in the
|
|
58
|
-
* component, so it changing is the most visible thing that could. This is one
|
|
59
|
-
* drawing at one weight, and it lives here rather than in `internal/icons.tsx`
|
|
60
|
-
* because exactly one component draws it.
|
|
61
|
-
*/
|
|
62
|
-
function QuoteMarkIcon() {
|
|
63
|
-
return (_jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "M6.4 3.6c-2.3.9-3.7 2.8-3.7 5.1 0 2 1.2 3.3 2.8 3.3 1.4 0 2.5-1 2.5-2.4 0-1.3-.9-2.2-2.1-2.2-.2 0-.4 0-.6.1.3-1 1.1-1.8 2.2-2.3l-1.1-1.6ZM13.3 3.6c-2.3.9-3.7 2.8-3.7 5.1 0 2 1.2 3.3 2.8 3.3 1.4 0 2.5-1 2.5-2.4 0-1.3-.9-2.2-2.1-2.2-.2 0-.4 0-.6.1.3-1 1.1-1.8 2.2-2.3l-1.1-1.6Z", fill: "currentColor" }) }));
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Somebody else's words, set apart from your own.
|
|
67
|
-
*
|
|
68
|
-
* There is no Base UI primitive under this and there should not be: a quote has
|
|
69
|
-
* no state, no keyboard contract and nothing to interact with. What it has is
|
|
70
|
-
* markup that is easy to get wrong, and getting it right is most of the point.
|
|
71
|
-
*
|
|
72
|
-
* **Nothing is drawn on the `<blockquote>` itself.** The surface, the rule and
|
|
73
|
-
* the padding all belong to the element around it, and that is not tidiness —
|
|
74
|
-
* `blockquote` is one of the handful of tags a host stylesheet still styles by
|
|
75
|
-
* name. VitePress's `.vp-doc blockquote` sets a grey `border-left`, a
|
|
76
|
-
* `padding-left` and a `color`, all at a specificity a one-class utility cannot
|
|
77
|
-
* outrank, so a rule drawn on the quote itself would silently come out grey and
|
|
78
|
-
* a pixel too thin. Moving the drawing onto a wrapper is what lets the docs undo
|
|
79
|
-
* VitePress's version without also undoing this one.
|
|
80
|
-
*
|
|
81
|
-
* The wrapper is a `<figure>` when there is an attribution and a `<div>` when
|
|
82
|
-
* there is not, because the HTML spec is explicit that the attribution goes
|
|
83
|
-
* *outside* the blockquote — a name inside it claims the speaker said their own
|
|
84
|
-
* name — and a `<figure>` with no `<figcaption>` in it is a figure of nothing.
|
|
85
|
-
*/
|
|
86
|
-
export const PlBlockquote = /* @__PURE__ */ React.forwardRef(function PlBlockquote({ variant = 'ghost', size = 'md', color = 'primary', density = 'default', elevation = 0, author, source, cite, icon, className, style, children, ...props }, ref) {
|
|
87
|
-
const attributed = hasContent(author) || hasContent(source);
|
|
88
|
-
const glyph = icon === undefined ? _jsx(QuoteMarkIcon, {}) : icon;
|
|
89
|
-
const shellClasses = [
|
|
90
|
-
'flex flex-col text-(--plass-fg)',
|
|
91
|
-
ruleClasses,
|
|
92
|
-
// The corners on the ruled edge stay square: a 2px rule that curves away
|
|
93
|
-
// from the text it marks is a bracket, not a margin rule.
|
|
94
|
-
variant === 'ghost' ? '' : `${radiusClasses[size]} rounded-s-none`,
|
|
95
|
-
variantClasses[variant],
|
|
96
|
-
sheetPaddingXClasses[density][size],
|
|
97
|
-
sheetPaddingYClasses[density][size],
|
|
98
|
-
transitionClasses,
|
|
99
|
-
className ?? ''
|
|
100
|
-
]
|
|
101
|
-
.filter(Boolean)
|
|
102
|
-
.join(' ');
|
|
103
|
-
const quote = (_jsxs("blockquote", { cite: cite, className: quoteTextClasses[size], children: [hasContent(glyph) ? (_jsx("span", { "aria-hidden": "true", className: "mb-1 block size-[2em] text-(--p-soft-press) [&>svg]:size-full", children: glyph })) : null, children] }));
|
|
104
|
-
const shellStyle = { ...surfaceSlots(color, elevation), ...style };
|
|
105
|
-
if (!attributed) {
|
|
106
|
-
return (_jsx("div", { ref: ref, className: shellClasses, style: shellStyle, ...props, children: quote }));
|
|
107
|
-
}
|
|
108
|
-
return (_jsxs("figure", { ref: ref, className: shellClasses, style: shellStyle, ...props, children: [quote, _jsxs("figcaption", { className: [
|
|
109
|
-
'mt-2 flex flex-wrap items-baseline gap-x-1.5 text-(--plass-muted-fg)',
|
|
110
|
-
metaTextClasses[size]
|
|
111
|
-
].join(' '), children: [hasContent(author) ? (_jsxs("span", { className: "font-medium text-(--plass-fg)", children: [_jsx("span", { "aria-hidden": "true", children: "\u2014 " }), author] })) : null, hasContent(source) ? _jsx("cite", { className: "not-italic", children: source }) : null] })] }));
|
|
112
|
-
});
|
|
1
|
+
"use client";import{jsx as e,jsxs as s}from"react/jsx-runtime";import*as r from"react";import{glassClasses as l,hasContent as a,metaTextClasses as t,radiusClasses as o,sheetPaddingXClasses as n,sheetPaddingYClasses as i,surfaceSlots as c,transitionClasses as d}from"../../internal/styles.js";const m={xs:"text-[0.75rem]/[1.25rem]",sm:"text-[0.8125rem]/[1.375rem]",md:"text-[0.9375rem]/[1.625rem]",lg:"text-[1.0625rem]/[1.875rem]",xl:"text-[1.25rem]/[2.125rem]"},p="border-s-2 [border-inline-start-color:var(--p-accent)]",u={solid:/* @__PURE__ */[l,"bg-(--plass-glass-press)","[box-shadow:var(--p-elev),var(--plass-gloss-glass)]"].join(" "),glass:/* @__PURE__ */[l,"border border-s-2 bg-(--plass-glass)","[border-color:var(--plass-glass-line)]","[box-shadow:var(--p-elev),var(--plass-gloss-glass)]"].join(" "),ghost:"bg-transparent"};function QuoteMarkIcon(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e("path",{d:"M6.4 3.6c-2.3.9-3.7 2.8-3.7 5.1 0 2 1.2 3.3 2.8 3.3 1.4 0 2.5-1 2.5-2.4 0-1.3-.9-2.2-2.1-2.2-.2 0-.4 0-.6.1.3-1 1.1-1.8 2.2-2.3l-1.1-1.6ZM13.3 3.6c-2.3.9-3.7 2.8-3.7 5.1 0 2 1.2 3.3 2.8 3.3 1.4 0 2.5-1 2.5-2.4 0-1.3-.9-2.2-2.1-2.2-.2 0-.4 0-.6.1.3-1 1.1-1.8 2.2-2.3l-1.1-1.6Z",fill:"currentColor"})})}export const PlBlockquote=/* @__PURE__ */r.forwardRef(function PlBlockquote({variant:r="ghost",size:l="md",color:f="primary",density:g="default",elevation:x=0,author:h,source:v,cite:b,icon:j,className:N,style:k,children:y,...w},B){const M=a(h)||a(v),q=void 0===j?e(QuoteMarkIcon,{}):j,z=["flex flex-col text-(--plass-fg)",p,"ghost"===r?"":`${o[l]} rounded-s-none`,u[r],n[g][l],i[g][l],d,N??""].filter(Boolean).join(" "),I=s("blockquote",{cite:b,className:m[l],children:[a(q)?e("span",{"aria-hidden":"true",className:"mb-1 block size-[2em] text-(--p-soft-press) [&>svg]:size-full",children:q}):null,y]}),P={...c(f,x),...k};return M?s("figure",{ref:B,className:z,style:P,...w,children:[I,s("figcaption",{className:["mt-2 flex flex-wrap items-baseline gap-x-1.5 text-(--plass-muted-fg)",t[l]].join(" "),children:[a(h)?s("span",{className:"font-medium text-(--plass-fg)",children:[e("span",{"aria-hidden":"true",children:"— "}),h]}):null,a(v)?e("cite",{className:"not-italic",children:v}):null]})]}):e("div",{ref:B,className:z,style:P,...w,children:I})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{PlBlockquote}from"./PlBlockquote.js";
|