plass-ui 1.0.0 → 1.0.1
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/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 +3 -2
|
@@ -1,201 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { ArrowRightIcon, ChevronIcon, EllipsisIcon } from '../../internal/icons.js';
|
|
4
|
-
import { controlTextClasses, cx, focusRingClasses, gapClasses, hasContent, iconClasses, radiusClasses, transitionClasses } from '../../internal/styles.js';
|
|
5
|
-
const BreadcrumbContext = /* @__PURE__ */ React.createContext({
|
|
6
|
-
size: 'md',
|
|
7
|
-
last: false
|
|
8
|
-
});
|
|
9
|
-
/** Between the steps, and the only thing `density` touches. */
|
|
10
|
-
const trailGapClasses = {
|
|
11
|
-
default: { xs: 'gap-1', sm: 'gap-1.5', md: 'gap-2', lg: 'gap-2.5', xl: 'gap-3' },
|
|
12
|
-
compact: { xs: 'gap-0.5', sm: 'gap-1', md: 'gap-1', lg: 'gap-1.5', xl: 'gap-2' }
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* A step's corner, read two steps down the radius ladder.
|
|
16
|
-
*
|
|
17
|
-
* `radiusClasses.md` is 12px, which on a line of text 20px tall is most of the
|
|
18
|
-
* way to a pill — and a breadcrumb step is not a `PlChip`. What the hover tint
|
|
19
|
-
* needs is a rectangle with the corners taken off, which is what the ladder says
|
|
20
|
-
* everywhere else; it just has to be read further down for something this short.
|
|
21
|
-
*/
|
|
22
|
-
const stepRadiusClasses = {
|
|
23
|
-
xs: radiusClasses.xs,
|
|
24
|
-
sm: radiusClasses.xs,
|
|
25
|
-
md: radiusClasses.xs,
|
|
26
|
-
lg: radiusClasses.sm,
|
|
27
|
-
xl: radiusClasses.sm
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* The four marks.
|
|
31
|
-
*
|
|
32
|
-
* The two that point are glyphs turned rather than redrawn, the same allowance
|
|
33
|
-
* the no-transform rule makes for the chevron on a `PlAccordion`: the wedge is
|
|
34
|
-
* drawn pointing down once, and a trail turns it a quarter. Both turn back under
|
|
35
|
-
* RTL, because a trail runs the way the language does.
|
|
36
|
-
*/
|
|
37
|
-
function separatorMark(separator) {
|
|
38
|
-
switch (separator) {
|
|
39
|
-
case 'chevron':
|
|
40
|
-
return (_jsx("span", { className: "flex -rotate-90 items-center rtl:rotate-90", children: _jsx(ChevronIcon, {}) }));
|
|
41
|
-
case 'arrow':
|
|
42
|
-
return (_jsx("span", { className: "flex items-center rtl:rotate-180", children: _jsx(ArrowRightIcon, {}) }));
|
|
43
|
-
case 'slash':
|
|
44
|
-
return _jsx("span", { className: "opacity-70", children: "/" });
|
|
45
|
-
case 'dot':
|
|
46
|
-
return _jsx("span", { className: "opacity-70", children: "\u00B7" });
|
|
47
|
-
default:
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
const separatorNames = ['chevron', 'arrow', 'slash', 'dot'];
|
|
52
|
-
/**
|
|
53
|
-
* The words in a step, with everything that is not a word left out.
|
|
54
|
-
*
|
|
55
|
-
* A step's label is a `ReactNode` and `name` in the structured data is a string,
|
|
56
|
-
* so the tree is walked for its text. Only `children` is read — a `startIcon` is
|
|
57
|
-
* a picture of the thing rather than its name, and a home glyph contributing
|
|
58
|
-
* nothing is exactly right.
|
|
59
|
-
*/
|
|
60
|
-
function textOf(node) {
|
|
61
|
-
if (typeof node === 'string' || typeof node === 'number') {
|
|
62
|
-
return String(node);
|
|
63
|
-
}
|
|
64
|
-
if (Array.isArray(node)) {
|
|
65
|
-
return node.map(textOf).join('');
|
|
66
|
-
}
|
|
67
|
-
if (React.isValidElement(node)) {
|
|
68
|
-
return textOf(node.props.children);
|
|
69
|
-
}
|
|
70
|
-
return '';
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* A step's `href` as a search engine wants it: absolute.
|
|
74
|
-
*
|
|
75
|
-
* `new URL` is what resolves `../guide` against a base rather than pasting the
|
|
76
|
-
* two together, and it throws on anything it cannot make sense of — a base that
|
|
77
|
-
* is not a URL, an `href` that is a router-only path. Falling back to the `href`
|
|
78
|
-
* as written is better than dropping the entry: a relative URL is a weaker
|
|
79
|
-
* signal, an absent one is none.
|
|
80
|
-
*/
|
|
81
|
-
function absoluteHref(href, baseUrl) {
|
|
82
|
-
if (!baseUrl) {
|
|
83
|
-
return href;
|
|
84
|
-
}
|
|
85
|
-
try {
|
|
86
|
-
return new URL(href, baseUrl).href;
|
|
87
|
-
}
|
|
88
|
-
catch {
|
|
89
|
-
return href;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* The trail as `schema.org`'s `BreadcrumbList`.
|
|
94
|
-
*
|
|
95
|
-
* `item` is omitted where a step has no `href`, which is the last step's usual
|
|
96
|
-
* case: a crawler reads a final entry without one as the page being looked at,
|
|
97
|
-
* and a `ListItem` pointing at nothing would be worse than one pointing nowhere.
|
|
98
|
-
*/
|
|
99
|
-
function breadcrumbListData(steps, baseUrl) {
|
|
100
|
-
const itemListElement = steps.map((step, index) => {
|
|
101
|
-
const { href, children } = step.props;
|
|
102
|
-
return {
|
|
103
|
-
'@type': 'ListItem',
|
|
104
|
-
position: index + 1,
|
|
105
|
-
name: textOf(children),
|
|
106
|
-
...(href ? { item: absoluteHref(href, baseUrl) } : null)
|
|
107
|
-
};
|
|
108
|
-
});
|
|
109
|
-
// `<` is escaped because this string is written into a `<script>`: a label
|
|
110
|
-
// holding `</script>` would otherwise close the tag and turn the rest of the
|
|
111
|
-
// JSON into markup.
|
|
112
|
-
return JSON.stringify({
|
|
113
|
-
'@context': 'https://schema.org',
|
|
114
|
-
'@type': 'BreadcrumbList',
|
|
115
|
-
itemListElement
|
|
116
|
-
}).replace(/</g, '\\u003c');
|
|
117
|
-
}
|
|
118
|
-
function isSeparatorName(value) {
|
|
119
|
-
return typeof value === 'string' && separatorNames.includes(value);
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* The trail of pages above the one being read.
|
|
123
|
-
*
|
|
124
|
-
* Two things make this more than a row of links. The first is that the last step
|
|
125
|
-
* is where the reader already is, so it is not a link at all — it carries
|
|
126
|
-
* `aria-current="page"` and stops being pressable, and the component works that
|
|
127
|
-
* out rather than asking every caller to remember it. The second is the fold: a
|
|
128
|
-
* trail seven levels deep is a trail nobody reads, so the middle collapses to a
|
|
129
|
-
* `…` that puts it back when pressed.
|
|
130
|
-
*
|
|
131
|
-
* The separators are drawn by the trail rather than by the steps. A step does
|
|
132
|
-
* not know whether anything follows it, and a mark that belonged to a step would
|
|
133
|
-
* have to be taken off the last one by hand.
|
|
134
|
-
*
|
|
135
|
-
* There is no `variant` and no `elevation`: a trail is a line of text above the
|
|
136
|
-
* page, not a surface laid on it.
|
|
137
|
-
*/
|
|
138
|
-
export const PlBreadcrumb = /* @__PURE__ */ React.forwardRef(function PlBreadcrumb({ size = 'md', color = 'primary', density = 'default', separator = 'chevron', maxItems, itemsBeforeCollapse = 1, itemsAfterCollapse = 1, expandable = true, label = 'Breadcrumb', expandLabel = 'Show the hidden steps', structuredData = false, baseUrl, className, style, children, ...props }, ref) {
|
|
139
|
-
const [unfolded, setUnfolded] = React.useState(false);
|
|
140
|
-
const steps = React.Children.toArray(children).filter(React.isValidElement);
|
|
141
|
-
const total = steps.length;
|
|
142
|
-
/*
|
|
143
|
-
* The last step is the page you are on — unless a step says it is. Exactly one
|
|
144
|
-
* element in a trail may carry `aria-current="page"`, so a caller who marks an
|
|
145
|
-
* earlier step has to take the mark off the last one, and doing that by hand
|
|
146
|
-
* would mean writing `current={false}` on a step that never asked for it.
|
|
147
|
-
*/
|
|
148
|
-
const claimed = steps.some((step) => step.props.current === true);
|
|
149
|
-
const folding = !unfolded &&
|
|
150
|
-
maxItems !== undefined &&
|
|
151
|
-
total > Math.max(maxItems, 1) &&
|
|
152
|
-
// A fold has to actually remove something. With `1` before and `1` after on
|
|
153
|
-
// a three-step trail the `…` would stand in for exactly one step, which is
|
|
154
|
-
// longer than the step it replaced.
|
|
155
|
-
total - itemsBeforeCollapse - itemsAfterCollapse > 1;
|
|
156
|
-
const shown = folding
|
|
157
|
-
? [
|
|
158
|
-
...steps.slice(0, Math.max(0, itemsBeforeCollapse)),
|
|
159
|
-
null,
|
|
160
|
-
...steps.slice(total - Math.max(0, itemsAfterCollapse))
|
|
161
|
-
]
|
|
162
|
-
: steps;
|
|
163
|
-
const mark = isSeparatorName(separator) ? separatorMark(separator) : separator;
|
|
164
|
-
const foldClassNames = cx('inline-flex items-center rounded-(--plass-radius-xs) px-0.5', 'text-(--plass-muted-fg)', transitionClasses, iconClasses, expandable
|
|
165
|
-
? cx('cursor-pointer hover:bg-(--p-soft) hover:text-(--p-accent)', focusRingClasses)
|
|
166
|
-
: '');
|
|
167
|
-
return (_jsxs("nav", { ref: ref, "aria-label": label, className: cx('flex', controlTextClasses[size], iconClasses, className), style: {
|
|
168
|
-
'--p-accent': `var(--plass-${color}-accent)`,
|
|
169
|
-
'--p-soft': `var(--plass-${color}-soft)`,
|
|
170
|
-
'--p-ring': `var(--plass-${color}-ring)`,
|
|
171
|
-
...style
|
|
172
|
-
}, ...props, children: [structuredData && total > 0 ? (_jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: breadcrumbListData(steps, baseUrl) } })) : null, _jsx("ol", {
|
|
173
|
-
// `role="list"` said out loud: Tailwind's reset takes the bullets off
|
|
174
|
-
// every `<ol>`, and Safari takes the list semantics off with them.
|
|
175
|
-
role: "list", className: cx('flex list-none flex-wrap items-center p-0', trailGapClasses[density][size]), children: shown.map((step, index) => (_jsxs(React.Fragment, { children: [index > 0 ? (_jsx("li", { "aria-hidden": "true", className: "flex shrink-0 items-center text-(--plass-muted-fg) select-none", children: mark })) : null, step ? (_jsx(BreadcrumbContext.Provider, { value: { size, last: !claimed && index === shown.length - 1 }, children: step })) : (_jsx("li", { className: "flex shrink-0 items-center", children: expandable ? (_jsx("button", { type: "button", className: foldClassNames, "aria-label": expandLabel, onClick: () => setUnfolded(true), children: _jsx(EllipsisIcon, {}) })) : (_jsx("span", { className: foldClassNames, "aria-hidden": "true", children: _jsx(EllipsisIcon, {}) })) }))] }, step ? (step.key ?? index) : 'fold'))) })] }));
|
|
176
|
-
});
|
|
177
|
-
/**
|
|
178
|
-
* One step of the trail.
|
|
179
|
-
*
|
|
180
|
-
* It renders three different things and the caller picks by what they pass: an
|
|
181
|
-
* `<a>` with an `href`, a `<button>` with an `onClick`, and a plain `<span>` with
|
|
182
|
-
* neither — which is what the last step is, because the page you are already on
|
|
183
|
-
* is not somewhere to go.
|
|
184
|
-
*/
|
|
185
|
-
export const PlBreadcrumbItem = /* @__PURE__ */ React.forwardRef(function PlBreadcrumbItem({ href, onClick, startIcon, endIcon, current, disabled = false, className, children, ...props }, ref) {
|
|
186
|
-
const { size, last } = React.useContext(BreadcrumbContext);
|
|
187
|
-
const isCurrent = current ?? last;
|
|
188
|
-
const interactive = Boolean(href || onClick) && !isCurrent && !disabled;
|
|
189
|
-
const stepClassNames = cx('inline-flex min-w-0 items-center px-1', gapClasses[size], stepRadiusClasses[size], transitionClasses,
|
|
190
|
-
// An if/else rather than stacked variants: two Tailwind classes of equal
|
|
191
|
-
// specificity resolve by their order in the generated stylesheet.
|
|
192
|
-
disabled
|
|
193
|
-
? 'cursor-not-allowed text-(--plass-muted-fg) opacity-50'
|
|
194
|
-
: isCurrent
|
|
195
|
-
? 'font-medium text-(--plass-fg)'
|
|
196
|
-
: interactive
|
|
197
|
-
? cx('cursor-pointer text-(--plass-muted-fg)', 'hover:bg-(--p-soft) hover:text-(--p-accent)', focusRingClasses)
|
|
198
|
-
: 'text-(--plass-muted-fg)');
|
|
199
|
-
const body = (_jsxs(_Fragment, { children: [hasContent(startIcon) ? (_jsx("span", { className: "flex h-[1lh] shrink-0 items-center", children: startIcon })) : null, _jsx("span", { className: "truncate", children: children }), hasContent(endIcon) ? (_jsx("span", { className: "flex h-[1lh] shrink-0 items-center", children: endIcon })) : null] }));
|
|
200
|
-
return (_jsx("li", { ref: ref, className: cx('flex min-w-0 items-center', className), ...props, children: interactive && href ? (_jsx("a", { href: href, className: stepClassNames, onClick: onClick, children: body })) : interactive ? (_jsx("button", { type: "button", className: stepClassNames, onClick: onClick, children: body })) : (_jsx("span", { className: stepClassNames, "aria-current": isCurrent ? 'page' : undefined, "aria-disabled": disabled || undefined, children: body })) }));
|
|
201
|
-
});
|
|
1
|
+
"use client";import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import*as a from"react";import{ArrowRightIcon as s,ChevronIcon as n,EllipsisIcon as l}from"../../internal/icons.js";import{controlTextClasses as i,cx as c,focusRingClasses as o,gapClasses as m,hasContent as p,iconClasses as d,radiusClasses as u,transitionClasses as f}from"../../internal/styles.js";const h=/* @__PURE__ */a.createContext({size:"md",last:!1}),x={default:{xs:"gap-1",sm:"gap-1.5",md:"gap-2",lg:"gap-2.5",xl:"gap-3"},compact:{xs:"gap-0.5",sm:"gap-1",md:"gap-1",lg:"gap-1.5",xl:"gap-2"}},g={xs:u.xs,sm:u.xs,md:u.xs,lg:u.sm,xl:u.sm},b=["chevron","arrow","slash","dot"];function textOf(e){return"string"==typeof e||"number"==typeof e?String(e):Array.isArray(e)?e.map(textOf).join(""):a.isValidElement(e)?textOf(e.props.children):""}function absoluteHref(e,t){if(!t)return e;try{return new URL(e,t).href}catch{return e}}function breadcrumbListData(e,t){const r=e.map((e,r)=>{const{href:a,children:s}=e.props;return{"@type":"ListItem",position:r+1,name:textOf(s),...a?{item:absoluteHref(a,t)}:null}});return JSON.stringify({"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:r}).replace(/</g,"\\u003c")}export const PlBreadcrumb=/* @__PURE__ */a.forwardRef(function PlBreadcrumb({size:r="md",color:m="primary",density:p="default",separator:u="chevron",maxItems:g,itemsBeforeCollapse:y=1,itemsAfterCollapse:N=1,expandable:v=!0,label:w="Breadcrumb",expandLabel:k="Show the hidden steps",structuredData:C=!1,baseUrl:B,className:L,style:j,children:I,...S},M){const[O,P]=a.useState(!1),z=a.Children.toArray(I).filter(a.isValidElement),A=z.length,D=z.some(e=>!0===e.props.current),E=!O&&void 0!==g&&A>Math.max(g,1)&&A-y-N>1?[...z.slice(0,Math.max(0,y)),null,...z.slice(A-Math.max(0,N))]:z,H=function isSeparatorName(e){return"string"==typeof e&&b.includes(e)}(u)?function separatorMark(t){switch(t){case"chevron":return e("span",{className:"flex -rotate-90 items-center rtl:rotate-90",children:e(n,{})});case"arrow":return e("span",{className:"flex items-center rtl:rotate-180",children:e(s,{})});case"slash":return e("span",{className:"opacity-70",children:"/"});case"dot":return e("span",{className:"opacity-70",children:"·"});default:return null}}(u):u,R=c("inline-flex items-center rounded-(--plass-radius-xs) px-0.5","text-(--plass-muted-fg)",f,d,v?c("cursor-pointer hover:bg-(--p-soft) hover:text-(--p-accent)",o):"");return t("nav",{ref:M,"aria-label":w,className:c("flex",i[r],d,L),style:{"--p-accent":`var(--plass-${m}-accent)`,"--p-soft":`var(--plass-${m}-soft)`,"--p-ring":`var(--plass-${m}-ring)`,...j},...S,children:[C&&A>0?e("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:breadcrumbListData(z,B)}}):null,e("ol",{role:"list",className:c("flex list-none flex-wrap items-center p-0",x[p][r]),children:E.map((s,n)=>t(a.Fragment,{children:[n>0?e("li",{"aria-hidden":"true",className:"flex shrink-0 items-center text-(--plass-muted-fg) select-none",children:H}):null,s?e(h.Provider,{value:{size:r,last:!D&&n===E.length-1},children:s}):e("li",{className:"flex shrink-0 items-center",children:v?e("button",{type:"button",className:R,"aria-label":k,onClick:()=>P(!0),children:e(l,{})}):e("span",{className:R,"aria-hidden":"true",children:e(l,{})})})]},s?s.key??n:"fold"))})]})});export const PlBreadcrumbItem=/* @__PURE__ */a.forwardRef(function PlBreadcrumbItem({href:s,onClick:n,startIcon:l,endIcon:i,current:d,disabled:u=!1,className:x,children:b,...y},N){const{size:v,last:w}=a.useContext(h),k=d??w,C=Boolean(s||n)&&!k&&!u,B=c("inline-flex min-w-0 items-center px-1",m[v],g[v],f,u?"cursor-not-allowed text-(--plass-muted-fg) opacity-50":k?"font-medium text-(--plass-fg)":C?c("cursor-pointer text-(--plass-muted-fg)","hover:bg-(--p-soft) hover:text-(--p-accent)",o):"text-(--plass-muted-fg)"),L=t(r,{children:[p(l)?e("span",{className:"flex h-[1lh] shrink-0 items-center",children:l}):null,e("span",{className:"truncate",children:b}),p(i)?e("span",{className:"flex h-[1lh] shrink-0 items-center",children:i}):null]});return e("li",{ref:N,className:c("flex min-w-0 items-center",x),...y,children:C&&s?e("a",{href:s,className:B,onClick:n,children:L}):C?e("button",{type:"button",className:B,onClick:n,children:L}):e("span",{className:B,"aria-current":k?"page":void 0,"aria-disabled":u||void 0,children:L})})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{PlBreadcrumb,PlBreadcrumbItem}from"./PlBreadcrumb.js";
|
|
@@ -1,196 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { Button as BaseUIButton } from '@base-ui/react/button';
|
|
4
|
-
import { useRender } from '@base-ui/react/use-render';
|
|
5
|
-
import { ButtonGroupContext } from '../../internal/button-group.js';
|
|
6
|
-
import { Spinner } from '../../internal/icons.js';
|
|
7
|
-
import { controlHeightClasses, controlSlots, controlSquareClasses, controlTextClasses, disabledClasses, focusRingClasses, gapClasses, glassClasses, hasContent, iconClasses, paddingXClasses, radiusClasses, readOnlyFilterClasses, transitionClasses } from '../../internal/styles.js';
|
|
8
|
-
/**
|
|
9
|
-
* The scales all come from `internal/styles` — a button's height *is* the
|
|
10
|
-
* library's control height, and the same numbers have to hold on a PlTextField,
|
|
11
|
-
* a Select and a Chip for a mixed row to keep its baseline.
|
|
12
|
-
*/
|
|
13
|
-
const sizeClasses = {
|
|
14
|
-
xs: `${controlHeightClasses.xs} ${gapClasses.xs} ${radiusClasses.xs} ${controlTextClasses.xs}`,
|
|
15
|
-
sm: `${controlHeightClasses.sm} ${gapClasses.sm} ${radiusClasses.sm} ${controlTextClasses.sm}`,
|
|
16
|
-
md: `${controlHeightClasses.md} ${gapClasses.md} ${radiusClasses.md} ${controlTextClasses.md}`,
|
|
17
|
-
lg: `${controlHeightClasses.lg} ${gapClasses.lg} ${radiusClasses.lg} ${controlTextClasses.lg}`,
|
|
18
|
-
xl: `${controlHeightClasses.xl} ${gapClasses.xl} ${radiusClasses.xl} ${controlTextClasses.xl}`
|
|
19
|
-
};
|
|
20
|
-
/** With no label there is nothing to pad against, so the button goes square. */
|
|
21
|
-
const iconOnlyClasses = {
|
|
22
|
-
xs: `${controlSquareClasses.xs} px-0`,
|
|
23
|
-
sm: `${controlSquareClasses.sm} px-0`,
|
|
24
|
-
md: `${controlSquareClasses.md} px-0`,
|
|
25
|
-
lg: `${controlSquareClasses.lg} px-0`,
|
|
26
|
-
xl: `${controlSquareClasses.xl} px-0`
|
|
27
|
-
};
|
|
28
|
-
const baseClasses = /* @__PURE__ */ [
|
|
29
|
-
// `relative` because `.plass-glow` hangs its two light layers off `::before`/`::after`.
|
|
30
|
-
'relative inline-flex shrink-0 select-none items-center justify-center',
|
|
31
|
-
'whitespace-nowrap align-middle font-semibold leading-none',
|
|
32
|
-
'[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]',
|
|
33
|
-
transitionClasses,
|
|
34
|
-
focusRingClasses,
|
|
35
|
-
iconClasses
|
|
36
|
-
].join(' ');
|
|
37
|
-
/**
|
|
38
|
-
* The three materials.
|
|
39
|
-
*
|
|
40
|
-
* `solid` is the only one with a `background-image`, and that gradient is the
|
|
41
|
-
* whole of the form: two ends of the family swept across the control, with no
|
|
42
|
-
* highlight over the top of it. A filled control deliberately carries **no**
|
|
43
|
-
* gloss line — an inset white edge on a coloured surface is what reads as
|
|
44
|
-
* lacquer, and the sweep is already saying everything about the shape that
|
|
45
|
-
* needs saying. The hairline belongs to `glass`, which has a real cut edge.
|
|
46
|
-
*
|
|
47
|
-
* `glass` wears the family in its **text** rather than in its sheet, which is
|
|
48
|
-
* why `color="secondary"` is the neutral, quiet button and not a second grey
|
|
49
|
-
* variant nobody would remember the name of.
|
|
50
|
-
*/
|
|
51
|
-
const restClasses = {
|
|
52
|
-
solid: /* @__PURE__ */ [
|
|
53
|
-
'text-(--p-on-solid) [background-image:var(--p-fill)]',
|
|
54
|
-
'[box-shadow:var(--p-elev),var(--p-lift)]'
|
|
55
|
-
].join(' '),
|
|
56
|
-
glass: /* @__PURE__ */ [
|
|
57
|
-
glassClasses,
|
|
58
|
-
'border text-(--p-accent) bg-(--plass-glass)',
|
|
59
|
-
'[border-color:var(--plass-glass-line)]',
|
|
60
|
-
'[box-shadow:var(--p-elev),var(--plass-gloss-glass)]'
|
|
61
|
-
].join(' '),
|
|
62
|
-
// Nothing to catch the light on, and nothing to cast a shadow.
|
|
63
|
-
ghost: 'text-(--p-accent) bg-transparent'
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Hover lifts the control and turns the light up; press puts it down and turns
|
|
67
|
-
* the light down. Both are `filter: brightness()` rather than a second set of
|
|
68
|
-
* colours, because the fill is a gradient and a gradient cannot be transitioned
|
|
69
|
-
* — but light falling on one can. The pointer bloom `.plass-glow` draws rides
|
|
70
|
-
* on top of this; the brightness is the state, the bloom is where the pointer
|
|
71
|
-
* is.
|
|
72
|
-
*/
|
|
73
|
-
const hoverClasses = {
|
|
74
|
-
solid: /* @__PURE__ */ [
|
|
75
|
-
'hover:brightness-105',
|
|
76
|
-
'hover:[box-shadow:var(--p-elev-hover),var(--p-lift-hover)]',
|
|
77
|
-
'active:brightness-95',
|
|
78
|
-
'active:[box-shadow:var(--p-elev-press),var(--p-lift-press)]'
|
|
79
|
-
].join(' '),
|
|
80
|
-
glass: /* @__PURE__ */ [
|
|
81
|
-
'hover:bg-(--plass-glass-hover) hover:[border-color:var(--p-line)]',
|
|
82
|
-
'hover:[box-shadow:var(--p-elev-hover),var(--plass-gloss-glass)]',
|
|
83
|
-
'active:bg-(--plass-glass-press)',
|
|
84
|
-
'active:[box-shadow:var(--p-elev-press),var(--plass-gloss-glass)]'
|
|
85
|
-
].join(' '),
|
|
86
|
-
ghost: 'hover:bg-(--p-soft) active:bg-(--p-soft-hover)'
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Read-only keeps the shape, the colour and the edge but goes flat, loses its
|
|
90
|
-
* lift and drains most of the saturation.
|
|
91
|
-
*/
|
|
92
|
-
const readOnlyClasses = {
|
|
93
|
-
solid: /* @__PURE__ */ [
|
|
94
|
-
'cursor-default text-(--p-on-solid) [background-image:var(--p-fill)]',
|
|
95
|
-
`shadow-none ${readOnlyFilterClasses}`
|
|
96
|
-
].join(' '),
|
|
97
|
-
glass: /* @__PURE__ */ [
|
|
98
|
-
glassClasses,
|
|
99
|
-
'cursor-default border text-(--p-accent) bg-(--plass-glass)',
|
|
100
|
-
'[border-color:var(--plass-glass-line)]',
|
|
101
|
-
`[box-shadow:var(--plass-gloss-glass)] ${readOnlyFilterClasses}`
|
|
102
|
-
].join(' '),
|
|
103
|
-
ghost: `cursor-default text-(--p-accent) bg-transparent ${readOnlyFilterClasses}`
|
|
104
|
-
};
|
|
105
|
-
export const PlButton = /* @__PURE__ */ React.forwardRef(function PlButton({ variant: variantProp, size: sizeProp, color: colorProp, density: densityProp, elevation: elevationProp, startIcon, endIcon, loading = false, readOnly = false, fullWidth = false, disabled: disabledProp, render, className, style, children, onClick, onPointerMove, ...props }, ref) {
|
|
106
|
-
/*
|
|
107
|
-
* A `PlButtonGroup` around this button sets the axes once for the set. The
|
|
108
|
-
* button's own prop still wins — a row of secondary actions with one danger
|
|
109
|
-
* button in it is a real thing — and with no group around it the fallbacks
|
|
110
|
-
* are the defaults they always were.
|
|
111
|
-
*/
|
|
112
|
-
const group = React.useContext(ButtonGroupContext);
|
|
113
|
-
const variant = variantProp ?? group?.variant ?? 'solid';
|
|
114
|
-
const size = sizeProp ?? group?.size ?? 'md';
|
|
115
|
-
const color = colorProp ?? group?.color ?? 'primary';
|
|
116
|
-
const density = densityProp ?? group?.density ?? 'default';
|
|
117
|
-
const elevation = elevationProp ?? group?.elevation ?? 1;
|
|
118
|
-
const disabled = disabledProp ?? group?.disabled ?? false;
|
|
119
|
-
const iconOnly = !hasContent(children);
|
|
120
|
-
// `disabled` and `readOnly` change how the button looks; `loading` only stops
|
|
121
|
-
// it from firing.
|
|
122
|
-
const inert = loading || readOnly;
|
|
123
|
-
const interactive = !disabled && !inert;
|
|
124
|
-
const classNames = [
|
|
125
|
-
baseClasses,
|
|
126
|
-
sizeClasses[size],
|
|
127
|
-
iconOnly ? iconOnlyClasses[size] : paddingXClasses[density][size],
|
|
128
|
-
// Deliberately an if/else rather than stacked `data-*` variants: two
|
|
129
|
-
// Tailwind variants of equal specificity resolve by their order in the
|
|
130
|
-
// generated stylesheet, which is not something a component should depend on.
|
|
131
|
-
disabled
|
|
132
|
-
? disabledClasses[variant]
|
|
133
|
-
: readOnly
|
|
134
|
-
? readOnlyClasses[variant]
|
|
135
|
-
: restClasses[variant],
|
|
136
|
-
interactive ? `${hoverClasses[variant]} cursor-pointer` : '',
|
|
137
|
-
// The interaction light. Every variant takes it, because it is about where
|
|
138
|
-
// the pointer is rather than about what the surface is made of — the two
|
|
139
|
-
// colour slots behind it are what switch with the variant.
|
|
140
|
-
interactive ? 'plass-glow' : '',
|
|
141
|
-
loading ? 'cursor-progress' : '',
|
|
142
|
-
fullWidth ? 'w-full' : '',
|
|
143
|
-
className ?? ''
|
|
144
|
-
]
|
|
145
|
-
.filter(Boolean)
|
|
146
|
-
.join(' ');
|
|
147
|
-
/*
|
|
148
|
-
* `render` deliberately steps around Base UI's PlButton rather than being handed
|
|
149
|
-
* to it. Told to render a non-`<button>`, that component puts `role="button"`
|
|
150
|
-
* on whatever it was given — which is right for a `<div>` and wrong for the
|
|
151
|
-
* case this prop exists for: an `<a href>` under a `role="button"` stops being
|
|
152
|
-
* a link to everything that reads the page, and the link list, the status bar
|
|
153
|
-
* and the crawler all lose it.
|
|
154
|
-
*
|
|
155
|
-
* What Base UI's PlButton adds over a bare `<button>` is its disabled handling,
|
|
156
|
-
* and `disabled` is the one thing that cannot travel to an `<a>` anyway.
|
|
157
|
-
*/
|
|
158
|
-
return useRender({
|
|
159
|
-
render: render ?? _jsx(BaseUIButton, { disabled: disabled }),
|
|
160
|
-
ref,
|
|
161
|
-
props: {
|
|
162
|
-
className: classNames,
|
|
163
|
-
style: { ...controlSlots(color, elevation, variant), ...style },
|
|
164
|
-
'aria-disabled': inert || undefined,
|
|
165
|
-
'aria-busy': loading || undefined,
|
|
166
|
-
'data-loading': loading || undefined,
|
|
167
|
-
'data-readonly': readOnly || undefined,
|
|
168
|
-
onClick: (event) => {
|
|
169
|
-
if (inert) {
|
|
170
|
-
event.preventDefault();
|
|
171
|
-
event.stopPropagation();
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
onClick?.(event);
|
|
175
|
-
},
|
|
176
|
-
onPointerMove: (event) => {
|
|
177
|
-
// Feeds the two light layers in `styles.css`. Written straight to the
|
|
178
|
-
// element rather than held in state: this fires at pointer rate, and a
|
|
179
|
-
// `setState` here would re-render the tree on every mouse move. Reading
|
|
180
|
-
// `offsetX/offsetY` costs nothing — no `getBoundingClientRect`, so no
|
|
181
|
-
// forced layout. Icons carry `pointer-events: none`, so the offsets are
|
|
182
|
-
// always relative to the button itself.
|
|
183
|
-
//
|
|
184
|
-
// It runs while a finger is down too, which is what makes the light
|
|
185
|
-
// follow a drag on a touch screen — there is no hover there, and the
|
|
186
|
-
// `:active` layer is the one doing the work.
|
|
187
|
-
const element = event.currentTarget;
|
|
188
|
-
element.style.setProperty('--p-mx', `${event.nativeEvent.offsetX}px`);
|
|
189
|
-
element.style.setProperty('--p-my', `${event.nativeEvent.offsetY}px`);
|
|
190
|
-
onPointerMove?.(event);
|
|
191
|
-
},
|
|
192
|
-
...props,
|
|
193
|
-
children: (_jsxs(_Fragment, { children: [loading ? _jsx(Spinner, {}) : startIcon, children, endIcon] }))
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
});
|
|
1
|
+
"use client";import{jsx as s,Fragment as e,jsxs as o}from"react/jsx-runtime";import*as r from"react";import{Button as a}from"@base-ui/react/button";import{useRender as t}from"@base-ui/react/use-render";import{ButtonGroupContext as l}from"../../internal/button-group.js";import{Spinner as n}from"../../internal/icons.js";import{controlHeightClasses as i,controlSlots as p,controlSquareClasses as d,controlTextClasses as v,disabledClasses as c,focusRingClasses as g,gapClasses as m,glassClasses as x,hasContent as b,iconClasses as f,paddingXClasses as h,radiusClasses as u,readOnlyFilterClasses as $,transitionClasses as j}from"../../internal/styles.js";const y={xs:`${i.xs} ${m.xs} ${u.xs} ${v.xs}`,sm:`${i.sm} ${m.sm} ${u.sm} ${v.sm}`,md:`${i.md} ${m.md} ${u.md} ${v.md}`,lg:`${i.lg} ${m.lg} ${u.lg} ${v.lg}`,xl:`${i.xl} ${m.xl} ${u.xl} ${v.xl}`},w={xs:`${d.xs} px-0`,sm:`${d.sm} px-0`,md:`${d.md} px-0`,lg:`${d.lg} px-0`,xl:`${d.xl} px-0`},P=/* @__PURE__ */["relative inline-flex shrink-0 select-none items-center justify-center","whitespace-nowrap align-middle font-semibold leading-none","[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]",j,g,f].join(" "),k={solid:/* @__PURE__ */["text-(--p-on-solid) [background-image:var(--p-fill)]","[box-shadow:var(--p-elev),var(--p-lift)]"].join(" "),glass:/* @__PURE__ */[x,"border text-(--p-accent) bg-(--plass-glass)","[border-color:var(--plass-glass-line)]","[box-shadow:var(--p-elev),var(--plass-gloss-glass)]"].join(" "),ghost:"text-(--p-accent) bg-transparent"},B={solid:/* @__PURE__ */["hover:brightness-105","hover:[box-shadow:var(--p-elev-hover),var(--p-lift-hover)]","active:brightness-95","active:[box-shadow:var(--p-elev-press),var(--p-lift-press)]"].join(" "),glass:/* @__PURE__ */["hover:bg-(--plass-glass-hover) hover:[border-color:var(--p-line)]","hover:[box-shadow:var(--p-elev-hover),var(--plass-gloss-glass)]","active:bg-(--plass-glass-press)","active:[box-shadow:var(--p-elev-press),var(--plass-gloss-glass)]"].join(" "),ghost:"hover:bg-(--p-soft) active:bg-(--p-soft-hover)"},C={solid:/* @__PURE__ */["cursor-default text-(--p-on-solid) [background-image:var(--p-fill)]",`shadow-none ${$}`].join(" "),glass:/* @__PURE__ */[x,"cursor-default border text-(--p-accent) bg-(--plass-glass)","[border-color:var(--plass-glass-line)]",`[box-shadow:var(--plass-gloss-glass)] ${$}`].join(" "),ghost:`cursor-default text-(--p-accent) bg-transparent ${$}`};export const PlButton=/* @__PURE__ */r.forwardRef(function PlButton({variant:i,size:d,color:v,density:g,elevation:m,startIcon:x,endIcon:f,loading:u=!1,readOnly:$=!1,fullWidth:j=!1,disabled:z,render:E,className:I,style:M,children:N,onClick:D,onPointerMove:F,...O},R){const T=r.useContext(l),W=i??T?.variant??"solid",X=d??T?.size??"md",Y=v??T?.color??"primary",q=g??T?.density??"default",A=m??T?.elevation??1,G=z??T?.disabled??!1,H=!b(N),J=u||$,K=!G&&!J,L=[P,y[X],H?w[X]:h[q][X],G?c[W]:$?C[W]:k[W],K?`${B[W]} cursor-pointer`:"",K?"plass-glow":"",u?"cursor-progress":"",j?"w-full":"",I??""].filter(Boolean).join(" ");return t({render:E??s(a,{disabled:G}),ref:R,props:{className:L,style:{...p(Y,A,W),...M},"aria-disabled":J||void 0,"aria-busy":u||void 0,"data-loading":u||void 0,"data-readonly":$||void 0,onClick:s=>{if(J)return s.preventDefault(),void s.stopPropagation();D?.(s)},onPointerMove:s=>{const e=s.currentTarget;e.style.setProperty("--p-mx",`${s.nativeEvent.offsetX}px`),e.style.setProperty("--p-my",`${s.nativeEvent.offsetY}px`),F?.(s)},...O,children:o(e,{children:[u?s(n,{}):x,N,f]})}})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{PlButton}from"./PlButton.js";
|
|
@@ -1,64 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { ButtonGroupContext } from '../../internal/button-group.js';
|
|
4
|
-
import { cx } from '../../internal/styles.js';
|
|
5
|
-
/**
|
|
6
|
-
* The corners that face a neighbour are squared off, so the run reads as one
|
|
7
|
-
* piece scored into segments rather than as three keys that happen to be
|
|
8
|
-
* touching.
|
|
9
|
-
*
|
|
10
|
-
* Logical properties (`s`/`e`) rather than left/right: under RTL the first
|
|
11
|
-
* button is on the right, and `rounded-l-none` would flatten the wrong side.
|
|
12
|
-
*/
|
|
13
|
-
const joinClasses = {
|
|
14
|
-
horizontal: '[&>*:not(:first-child)]:rounded-s-none [&>*:not(:last-child)]:rounded-e-none',
|
|
15
|
-
vertical: '[&>*:not(:first-child)]:rounded-t-none [&>*:not(:last-child)]:rounded-b-none'
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Only `glass` needs the overlap, because it is the only variant that draws an
|
|
19
|
-
* edge. Two glass keys meeting would otherwise show both of their hairlines and
|
|
20
|
-
* the seam would be twice as heavy as every other edge on the page; pulling the
|
|
21
|
-
* second one back a pixel makes the two share one line.
|
|
22
|
-
*
|
|
23
|
-
* A `solid` group must **not** do this. Its keys have no border to double up,
|
|
24
|
-
* and overlapping would put one gradient over the start of the next — which is
|
|
25
|
-
* exactly the join the squared corners are drawing.
|
|
26
|
-
*/
|
|
27
|
-
const overlapClasses = {
|
|
28
|
-
horizontal: '[&>*:not(:first-child)]:-ms-px',
|
|
29
|
-
vertical: '[&>*:not(:first-child)]:-mt-px'
|
|
30
|
-
};
|
|
31
|
-
const baseClasses = /* @__PURE__ */ [
|
|
32
|
-
'inline-flex align-middle',
|
|
33
|
-
// Every child gets a stacking context so the hovered or focused one can come
|
|
34
|
-
// forward. Without it the focus ring — which is drawn outside the border box —
|
|
35
|
-
// is painted over by whichever neighbour happens to come after it.
|
|
36
|
-
'[&>*]:relative [&>*:hover]:z-10 [&>*:focus-visible]:z-10',
|
|
37
|
-
// A group is a set of equal actions, so they stay the same height even when
|
|
38
|
-
// one of them has an icon and the others do not.
|
|
39
|
-
'[&>*]:shrink-0'
|
|
40
|
-
].join(' ');
|
|
41
|
-
/**
|
|
42
|
-
* A run of buttons that belong together.
|
|
43
|
-
*
|
|
44
|
-
* Two things are happening here and only one of them is visual. The corners
|
|
45
|
-
* that face a neighbour are squared off — that is the look. The other half is
|
|
46
|
-
* that `variant`, `size`, `color`, `density`, `elevation` and `disabled` are
|
|
47
|
-
* stated once for the set rather than repeated on every button; a group where
|
|
48
|
-
* one button is a size out is the failure this exists to prevent.
|
|
49
|
-
*
|
|
50
|
-
* The buttons stay real `PlButton`s and nothing about them is replaced. Which
|
|
51
|
-
* also means this is **not** a segmented control and it does not manage
|
|
52
|
-
* selection: for one-of-a-set reach for `PlSegmentedButton`, which is what that
|
|
53
|
-
* actually is.
|
|
54
|
-
*/
|
|
55
|
-
export const PlButtonGroup = /* @__PURE__ */ React.forwardRef(function PlButtonGroup({ variant, size, color, density, elevation, orientation = 'horizontal', disabled, fullWidth = false, className, children, ...props }, ref) {
|
|
56
|
-
// Every value is passed through as it arrived, `undefined` included. A
|
|
57
|
-
// PlButton reads the group only as a fallback, so "not set here" goes on
|
|
58
|
-
// meaning "use the button's own default" rather than turning into one.
|
|
59
|
-
const context = React.useMemo(() => ({ variant, size, color, density, elevation, disabled }), [variant, size, color, density, elevation, disabled]);
|
|
60
|
-
return (_jsx(ButtonGroupContext.Provider, { value: context, children: _jsx("div", { ref: ref, role: "group", className: cx(baseClasses, orientation === 'vertical' ? 'flex-col' : 'flex-row', joinClasses[orientation],
|
|
61
|
-
// `variant` defaults to `solid` on a PlButton, so a group that says
|
|
62
|
-
// nothing is a solid group and must not overlap.
|
|
63
|
-
(variant ?? 'solid') === 'glass' ? overlapClasses[orientation] : '', fullWidth ? 'flex w-full [&>*]:flex-1' : '', className), ...props, children: children }) }));
|
|
64
|
-
});
|
|
1
|
+
"use client";import{jsx as o}from"react/jsx-runtime";import*as e from"react";import{ButtonGroupContext as i}from"../../internal/button-group.js";import{cx as t}from"../../internal/styles.js";const n={horizontal:"[&>*:not(:first-child)]:rounded-s-none [&>*:not(:last-child)]:rounded-e-none",vertical:"[&>*:not(:first-child)]:rounded-t-none [&>*:not(:last-child)]:rounded-b-none"},r={horizontal:"[&>*:not(:first-child)]:-ms-px",vertical:"[&>*:not(:first-child)]:-mt-px"},l=/* @__PURE__ */["inline-flex align-middle","[&>*]:relative [&>*:hover]:z-10 [&>*:focus-visible]:z-10","[&>*]:shrink-0"].join(" ");export const PlButtonGroup=/* @__PURE__ */e.forwardRef(function PlButtonGroup({variant:s,size:a,color:d,density:c,elevation:f,orientation:u="horizontal",disabled:h,fullWidth:m=!1,className:v,children:p,...x},z){const b=e.useMemo(()=>({variant:s,size:a,color:d,density:c,elevation:f,disabled:h}),[s,a,d,c,f,h]);return o(i.Provider,{value:b,children:o("div",{ref:z,role:"group",className:t(l,"vertical"===u?"flex-col":"flex-row",n[u],"glass"===(s??"solid")?r[u]:"",m?"flex w-full [&>*]:flex-1":"",v),...x,children:p})})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{PlButtonGroup}from"./PlButtonGroup.js";
|
|
@@ -1,102 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { useRender } from '@base-ui/react/use-render';
|
|
4
|
-
import { focusRingClasses, hasContent, metaTextClasses, radiusClasses, sheetBodyClasses, sheetHeaderGapClasses, sheetLineClasses, sheetPaddingXClasses, sheetPaddingYClasses, sheetRestClasses, sheetSectionGapClasses, sheetTitleClasses, surfaceSlots } from '../../internal/styles.js';
|
|
5
|
-
/**
|
|
6
|
-
* The house transition with `transform` added to the property list.
|
|
7
|
-
*
|
|
8
|
-
* `transitionClasses` deliberately leaves it out, because no *control* may be
|
|
9
|
-
* transformed. A card is the other kind of surface, so it writes its own list
|
|
10
|
-
* rather than stacking a `transition-[transform]` on top of the shared one —
|
|
11
|
-
* two `transition-property` declarations of equal specificity resolve by their
|
|
12
|
-
* order in the generated stylesheet, which is not something a component should
|
|
13
|
-
* depend on.
|
|
14
|
-
*/
|
|
15
|
-
const cardTransitionClasses = /* @__PURE__ */ [
|
|
16
|
-
'[transition-property:background-color,border-color,box-shadow,color,transform]',
|
|
17
|
-
'[transition-duration:var(--plass-duration)]',
|
|
18
|
-
'[transition-timing-function:var(--plass-ease)]'
|
|
19
|
-
].join(' ');
|
|
20
|
-
/**
|
|
21
|
-
* Hover lifts the sheet and puts a level of shadow under it; the press sets it
|
|
22
|
-
* back down. Both directions take the house duration, and no `filter` is
|
|
23
|
-
* involved — a card is not a coloured surface, so there is no brightness to
|
|
24
|
-
* turn up.
|
|
25
|
-
*/
|
|
26
|
-
const interactiveClasses = {
|
|
27
|
-
solid: /* @__PURE__ */ [
|
|
28
|
-
'cursor-pointer hover:-translate-y-0.5',
|
|
29
|
-
'hover:[box-shadow:var(--p-elev-hover),var(--plass-gloss-glass)]',
|
|
30
|
-
'active:translate-y-0 active:[box-shadow:var(--p-elev-press),var(--plass-gloss-glass)]'
|
|
31
|
-
].join(' '),
|
|
32
|
-
glass: /* @__PURE__ */ [
|
|
33
|
-
'cursor-pointer hover:-translate-y-0.5 hover:bg-(--plass-glass-hover)',
|
|
34
|
-
'hover:[border-color:var(--p-line)]',
|
|
35
|
-
'hover:[box-shadow:var(--p-elev-hover),var(--plass-gloss-glass)]',
|
|
36
|
-
'active:translate-y-0 active:[box-shadow:var(--p-elev-press),var(--plass-gloss-glass)]'
|
|
37
|
-
].join(' '),
|
|
38
|
-
ghost: 'cursor-pointer hover:bg-(--p-soft) active:bg-(--p-soft-hover)'
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* The sheet everything else on a screen is grouped onto, with the parts a card
|
|
42
|
-
* is made of laid out on it: a title, a subtitle, a body and a footer.
|
|
43
|
-
*
|
|
44
|
-
* The sections are props rather than compound sub-components — `<Card.Header>`,
|
|
45
|
-
* `<Card.Title>` — for the same reason `PlTextField` takes `label` and
|
|
46
|
-
* `description` as props: the arrangement is fixed, and what a caller wants to
|
|
47
|
-
* decide is what goes in each slot, not what order the slots come in.
|
|
48
|
-
*
|
|
49
|
-
* There is no Base UI primitive under this, and there should not be. A card has
|
|
50
|
-
* no interaction to delegate: it is a surface with a layout, and the moment it
|
|
51
|
-
* becomes something you press it is a `render` away from being a real one.
|
|
52
|
-
*/
|
|
53
|
-
export const PlCard = /* @__PURE__ */ React.forwardRef(function PlCard({ variant = 'glass', size = 'md', color = 'primary', density = 'default', elevation = 1, title, subtitle, headerAction, footer, dividers = false, padded = true, interactive = false, render, className, style, children, ...props }, ref) {
|
|
54
|
-
const insetX = padded ? sheetPaddingXClasses[density][size] : '';
|
|
55
|
-
const insetY = padded ? sheetPaddingYClasses[density][size] : '';
|
|
56
|
-
// Scored, the rules have to reach both edges, so the sheet gives up its
|
|
57
|
-
// padding and every section takes it on instead. Unscored, the sheet keeps
|
|
58
|
-
// its vertical padding and the sections are told apart by a gap.
|
|
59
|
-
const sectionClasses = dividers ? `${insetX} ${insetY}` : insetX;
|
|
60
|
-
const hasHeader = hasContent(title) || hasContent(subtitle) || hasContent(headerAction);
|
|
61
|
-
const header = (_jsxs(_Fragment, { children: [hasContent(title) || hasContent(subtitle) ? (_jsxs("div", { className: `flex min-w-0 flex-1 flex-col ${sheetHeaderGapClasses[size]}`, children: [hasContent(title) ? (_jsx("div", { className: `plass-title font-semibold ${sheetTitleClasses[size]}`, children: title })) : null, hasContent(subtitle) ? (_jsx("div", { className: `text-(--plass-muted-fg) ${metaTextClasses[size]}`, children: subtitle })) : null] })) : null, hasContent(headerAction) ? _jsx("div", { className: "ml-auto shrink-0", children: headerAction }) : null] }));
|
|
62
|
-
const sections = [
|
|
63
|
-
hasHeader ? { key: 'header', className: 'flex items-start gap-3', content: header } : null,
|
|
64
|
-
hasContent(children)
|
|
65
|
-
? { key: 'content', className: sheetBodyClasses[size], content: children }
|
|
66
|
-
: null,
|
|
67
|
-
hasContent(footer)
|
|
68
|
-
? {
|
|
69
|
-
key: 'footer',
|
|
70
|
-
className: `flex flex-wrap items-center gap-2 ${sheetBodyClasses[size]}`,
|
|
71
|
-
content: footer
|
|
72
|
-
}
|
|
73
|
-
: null
|
|
74
|
-
].filter((section) => section !== null);
|
|
75
|
-
const classNames = [
|
|
76
|
-
'flex flex-col',
|
|
77
|
-
radiusClasses[size],
|
|
78
|
-
sheetRestClasses[variant],
|
|
79
|
-
cardTransitionClasses,
|
|
80
|
-
interactive ? `${interactiveClasses[variant]} ${focusRingClasses}` : '',
|
|
81
|
-
dividers ? 'overflow-hidden' : `${insetY} ${sheetSectionGapClasses[size]}`,
|
|
82
|
-
className ?? ''
|
|
83
|
-
]
|
|
84
|
-
.filter(Boolean)
|
|
85
|
-
.join(' ');
|
|
86
|
-
return useRender({
|
|
87
|
-
render: render ?? _jsx("div", {}),
|
|
88
|
-
ref,
|
|
89
|
-
props: {
|
|
90
|
-
className: classNames,
|
|
91
|
-
style: { ...surfaceSlots(color, elevation), ...style },
|
|
92
|
-
...props,
|
|
93
|
-
children: sections.map((section, index) => (_jsx("div", { className: [
|
|
94
|
-
sectionClasses,
|
|
95
|
-
section.className,
|
|
96
|
-
dividers && index > 0 ? sheetLineClasses : ''
|
|
97
|
-
]
|
|
98
|
-
.filter(Boolean)
|
|
99
|
-
.join(' '), children: section.content }, section.key)))
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
});
|
|
1
|
+
"use client";import{jsx as e,jsxs as s,Fragment as r}from"react/jsx-runtime";import*as a from"react";import{useRender as l}from"@base-ui/react/use-render";import{focusRingClasses as o,hasContent as t,metaTextClasses as n,radiusClasses as i,sheetBodyClasses as c,sheetHeaderGapClasses as d,sheetLineClasses as v,sheetPaddingXClasses as p,sheetPaddingYClasses as m,sheetRestClasses as f,sheetSectionGapClasses as h,sheetTitleClasses as u,surfaceSlots as g}from"../../internal/styles.js";const x=/* @__PURE__ */["[transition-property:background-color,border-color,box-shadow,color,transform]","[transition-duration:var(--plass-duration)]","[transition-timing-function:var(--plass-ease)]"].join(" "),b={solid:/* @__PURE__ */["cursor-pointer hover:-translate-y-0.5","hover:[box-shadow:var(--p-elev-hover),var(--plass-gloss-glass)]","active:translate-y-0 active:[box-shadow:var(--p-elev-press),var(--plass-gloss-glass)]"].join(" "),glass:/* @__PURE__ */["cursor-pointer hover:-translate-y-0.5 hover:bg-(--plass-glass-hover)","hover:[border-color:var(--p-line)]","hover:[box-shadow:var(--p-elev-hover),var(--plass-gloss-glass)]","active:translate-y-0 active:[box-shadow:var(--p-elev-press),var(--plass-gloss-glass)]"].join(" "),ghost:"cursor-pointer hover:bg-(--p-soft) active:bg-(--p-soft-hover)"};export const PlCard=/* @__PURE__ */a.forwardRef(function PlCard({variant:a="glass",size:y="md",color:N="primary",density:$="default",elevation:j=1,title:w,subtitle:k,headerAction:B,footer:C,dividers:P=!1,padded:z=!0,interactive:A=!1,render:F,className:R,style:q,children:D,...E},G){const H=z?p[$][y]:"",I=z?m[$][y]:"",J=P?`${H} ${I}`:H,K=t(w)||t(k)||t(B),L=s(r,{children:[t(w)||t(k)?s("div",{className:`flex min-w-0 flex-1 flex-col ${d[y]}`,children:[t(w)?e("div",{className:`plass-title font-semibold ${u[y]}`,children:w}):null,t(k)?e("div",{className:`text-(--plass-muted-fg) ${n[y]}`,children:k}):null]}):null,t(B)?e("div",{className:"ml-auto shrink-0",children:B}):null]}),M=[K?{key:"header",className:"flex items-start gap-3",content:L}:null,t(D)?{key:"content",className:c[y],content:D}:null,t(C)?{key:"footer",className:`flex flex-wrap items-center gap-2 ${c[y]}`,content:C}:null].filter(e=>null!==e),O=["flex flex-col",i[y],f[a],x,A?`${b[a]} ${o}`:"",P?"overflow-hidden":`${I} ${h[y]}`,R??""].filter(Boolean).join(" ");return l({render:F??e("div",{}),ref:G,props:{className:O,style:{...g(N,j),...q},...E,children:M.map((s,r)=>e("div",{className:[J,s.className,P&&r>0?v:""].filter(Boolean).join(" "),children:s.content},s.key))}})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{PlCard}from"./PlCard.js";
|