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
package/dist/internal/icons.js
CHANGED
|
@@ -1,138 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
/**
|
|
3
|
-
* The one thing in the library that moves on its own, and the only place that
|
|
4
|
-
* is allowed: an indeterminate indicator that does not move is a decoration.
|
|
5
|
-
*
|
|
6
|
-
* Sized in `em` by `iconClasses`, like every other glyph inside a control, so
|
|
7
|
-
* it tracks the label rather than carrying a size of its own.
|
|
8
|
-
*/
|
|
9
|
-
export function Spinner() {
|
|
10
|
-
return (_jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", className: "animate-spin", children: [_jsx("circle", { cx: "8", cy: "8", r: "6.5", stroke: "currentColor", strokeOpacity: "0.25", strokeWidth: "2" }), _jsx("path", { d: "M14.5 8A6.5 6.5 0 0 0 8 1.5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" })] }));
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* The disclosure chevron, drawn pointing **down**.
|
|
14
|
-
*
|
|
15
|
-
* One drawing for every direction: a PlAccordion's header, a PlSelect's
|
|
16
|
-
* trigger, a PlPagination's stepper all want the same wedge turned a different
|
|
17
|
-
* way. Turning it is the one allowance the no-transform rule makes — the rule
|
|
18
|
-
* is about a control resampling its own label under the pointer, and a glyph
|
|
19
|
-
* has no text in it to resample.
|
|
20
|
-
*/
|
|
21
|
-
export function ChevronIcon() {
|
|
22
|
-
return (_jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "m4.5 6.5 3.5 3.5 3.5-3.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* The arrow, drawn pointing **right**.
|
|
26
|
-
*
|
|
27
|
-
* One of the two marks a trail can put between its steps, and the one that says
|
|
28
|
-
* "and then" out loud. It is turned back under RTL by whoever draws it rather
|
|
29
|
-
* than being redrawn, the same allowance the chevron takes.
|
|
30
|
-
*/
|
|
31
|
-
export function ArrowRightIcon() {
|
|
32
|
-
return (_jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "M3 8h10m-3.5-3.5L13 8l-3.5 3.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
33
|
-
}
|
|
34
|
-
/** Three dots: the middle of something that has been folded away. */
|
|
35
|
-
export function EllipsisIcon() {
|
|
36
|
-
return (_jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [_jsx("circle", { cx: "3.5", cy: "8", r: "1.15", fill: "currentColor" }), _jsx("circle", { cx: "8", cy: "8", r: "1.15", fill: "currentColor" }), _jsx("circle", { cx: "12.5", cy: "8", r: "1.15", fill: "currentColor" })] }));
|
|
37
|
-
}
|
|
38
|
-
/** The tick: a chosen option, a ticked menu item, a checked box. */
|
|
39
|
-
export function CheckIcon() {
|
|
40
|
-
return (_jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "m3.5 8.5 3 3 6-6", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* The two steppers' marks.
|
|
44
|
-
*
|
|
45
|
-
* A pair, and they stay one: a minus drawn at a different weight from the plus
|
|
46
|
-
* beside it reads as two toolkits in one control.
|
|
47
|
-
*/
|
|
48
|
-
export function MinusIcon() {
|
|
49
|
-
return (_jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "M3.5 8h9", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round" }) }));
|
|
50
|
-
}
|
|
51
|
-
export function PlusIcon() {
|
|
52
|
-
return (_jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "M8 3.5v9M3.5 8h9", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round" }) }));
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* The ×.
|
|
56
|
-
*
|
|
57
|
-
* One drawing for every dismissal in the library — a file's remove button, an
|
|
58
|
-
* alert's close, a modal's. Two copies of an × drift by half a pixel of stroke
|
|
59
|
-
* weight, and then a page has two kinds of "close" on it.
|
|
60
|
-
*/
|
|
61
|
-
export function CloseIcon() {
|
|
62
|
-
return (_jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "m4.5 4.5 7 7m0-7-7 7", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round" }) }));
|
|
63
|
-
}
|
|
64
|
-
/** The clock: something that has been started and has not finished. */
|
|
65
|
-
export function ClockIcon() {
|
|
66
|
-
return (_jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [_jsx("circle", { cx: "8", cy: "8", r: "6.25", stroke: "currentColor", strokeWidth: "1.5" }), _jsx("path", { d: "M8 4.5V8l2.4 1.6", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] }));
|
|
67
|
-
}
|
|
68
|
-
/** The calendar: a page with a binding across the top. The pickers' glyph. */
|
|
69
|
-
export function CalendarIcon() {
|
|
70
|
-
return (_jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [_jsx("rect", { x: "2.25", y: "3.25", width: "11.5", height: "10.5", rx: "2", stroke: "currentColor", strokeWidth: "1.5" }), _jsx("path", { d: "M2.25 6.5h11.5", stroke: "currentColor", strokeWidth: "1.5" }), _jsx("path", { d: "M5.5 1.75v2.5M10.5 1.75v2.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })] }));
|
|
71
|
-
}
|
|
72
|
-
/** The chain: a link that stays on this page. */
|
|
73
|
-
export function LinkIcon() {
|
|
74
|
-
return (_jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [_jsx("path", { d: "M6.5 9.5a2.75 2.75 0 0 0 4 .25l1.75-1.75a2.75 2.75 0 0 0-3.9-3.9L7.75 5.2", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }), _jsx("path", { d: "M9.5 6.5a2.75 2.75 0 0 0-4-.25L3.75 8a2.75 2.75 0 0 0 3.9 3.9l.6-.6", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })] }));
|
|
75
|
-
}
|
|
76
|
-
/** The arrow leaving its box: a link that takes over a new tab. */
|
|
77
|
-
export function ExternalLinkIcon() {
|
|
78
|
-
return (_jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [_jsx("path", { d: "M12.75 9.25v2.5a1.5 1.5 0 0 1-1.5 1.5h-7a1.5 1.5 0 0 1-1.5-1.5v-7a1.5 1.5 0 0 1 1.5-1.5h2.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }), _jsx("path", { d: "M9.5 2.75h3.75V6.5M7.25 8.75l5.75-5.75", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] }));
|
|
79
|
-
}
|
|
80
|
-
/** The neutral note: a circled `i` without the serif problem an `i` has at 16px. */
|
|
81
|
-
function NoteIcon() {
|
|
82
|
-
return (_jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [_jsx("circle", { cx: "8", cy: "8", r: "6.25", stroke: "currentColor", strokeWidth: "1.5" }), _jsx("path", { d: "M8 7.25v4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }), _jsx("circle", { cx: "8", cy: "4.9", r: "0.85", fill: "currentColor" })] }));
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* The filled dot a chosen radio row is marked with.
|
|
86
|
-
*
|
|
87
|
-
* A dot and not a tick, which is the distinction `PlCheckbox` and `PlRadioGroup`
|
|
88
|
-
* make everywhere else: a tick says "and", a dot says "instead of".
|
|
89
|
-
*/
|
|
90
|
-
export function DotIcon() {
|
|
91
|
-
return (_jsx("svg", { viewBox: "0 0 16 16", fill: "currentColor", "aria-hidden": "true", children: _jsx("circle", { cx: "8", cy: "8", r: "3.25" }) }));
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* A star, filled, in the same 16-unit box every other glyph here uses.
|
|
95
|
-
*
|
|
96
|
-
* `StarIcon` and `StarOutlineIcon` are the same five points traced twice —
|
|
97
|
-
* once painted, once stroked — and they have to be, because `PlRating` lays one
|
|
98
|
-
* over the other and clips the top copy to a fraction of the width. Two stars
|
|
99
|
-
* of two shapes would show as a rim that does not line up with what is inside
|
|
100
|
-
* it.
|
|
101
|
-
*/
|
|
102
|
-
export function StarIcon() {
|
|
103
|
-
return (_jsx("svg", { viewBox: "0 0 16 16", fill: "currentColor", "aria-hidden": "true", children: _jsx("path", { d: "m8 1.6 1.86 3.9 4.14.56-3.02 2.9.76 4.24L8 11.16 4.26 13.2l.76-4.24L2 6.06l4.14-.56z" }) }));
|
|
104
|
-
}
|
|
105
|
-
/** The same five points, stroked. See `StarIcon`. */
|
|
106
|
-
export function StarOutlineIcon() {
|
|
107
|
-
return (_jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "m8 1.6 1.86 3.9 4.14.56-3.02 2.9.76 4.24L8 11.16 4.26 13.2l.76-4.24L2 6.06l4.14-.56z", stroke: "currentColor", strokeWidth: "1.3", strokeLinejoin: "round" }) }));
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* One drawing per colour family, and a piece of the design language rather than
|
|
111
|
-
* a convenience.
|
|
112
|
-
*
|
|
113
|
-
* An alert that says "this went wrong" only in red says it only to some
|
|
114
|
-
* readers, so the shape has to carry the meaning too — and that only holds if
|
|
115
|
-
* every component uses the same shape for the same family.
|
|
116
|
-
*
|
|
117
|
-
* `primary` and `secondary` have no severity to draw, so they take the note the
|
|
118
|
-
* informational one uses: three shapes for six families, because the three that
|
|
119
|
-
* mean something are the three worth telling apart.
|
|
120
|
-
*
|
|
121
|
-
* A function and not the table of elements it reads like, because a table is
|
|
122
|
-
* the one shape a bundler cannot take apart: six entries built at module load,
|
|
123
|
-
* kept whole or not at all, and pulled into every component that touches the
|
|
124
|
-
* file. A function declaration is dropped outright by anything that does not
|
|
125
|
-
* call it, which is most of the library.
|
|
126
|
-
*/
|
|
127
|
-
export function severityIcon(color) {
|
|
128
|
-
if (color === 'success') {
|
|
129
|
-
return (_jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [_jsx("circle", { cx: "8", cy: "8", r: "6.25", stroke: "currentColor", strokeWidth: "1.5" }), _jsx("path", { d: "m5.25 8.25 1.9 1.9 3.6-3.9", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] }));
|
|
130
|
-
}
|
|
131
|
-
if (color === 'warning') {
|
|
132
|
-
return (_jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [_jsx("path", { d: "M7.13 2.6 1.9 11.7a1 1 0 0 0 .87 1.5h10.46a1 1 0 0 0 .87-1.5L8.87 2.6a1 1 0 0 0-1.74 0Z", stroke: "currentColor", strokeWidth: "1.5", strokeLinejoin: "round" }), _jsx("path", { d: "M8 6.1v3", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }), _jsx("circle", { cx: "8", cy: "11.2", r: "0.85", fill: "currentColor" })] }));
|
|
133
|
-
}
|
|
134
|
-
if (color === 'danger') {
|
|
135
|
-
return (_jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [_jsx("circle", { cx: "8", cy: "8", r: "6.25", stroke: "currentColor", strokeWidth: "1.5" }), _jsx("path", { d: "m5.9 5.9 4.2 4.2m0-4.2-4.2 4.2", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })] }));
|
|
136
|
-
}
|
|
137
|
-
return _jsx(NoteIcon, {});
|
|
138
|
-
}
|
|
1
|
+
import{jsx as r,jsxs as e}from"react/jsx-runtime";export function Spinner(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"animate-spin",children:[r("circle",{cx:"8",cy:"8",r:"6.5",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"2"}),r("path",{d:"M14.5 8A6.5 6.5 0 0 0 8 1.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}export function ChevronIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r("path",{d:"m4.5 6.5 3.5 3.5 3.5-3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}export function ArrowRightIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r("path",{d:"M3 8h10m-3.5-3.5L13 8l-3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}export function EllipsisIcon(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("circle",{cx:"3.5",cy:"8",r:"1.15",fill:"currentColor"}),r("circle",{cx:"8",cy:"8",r:"1.15",fill:"currentColor"}),r("circle",{cx:"12.5",cy:"8",r:"1.15",fill:"currentColor"})]})}export function CheckIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r("path",{d:"m3.5 8.5 3 3 6-6",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}export function MinusIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r("path",{d:"M3.5 8h9",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round"})})}export function PlusIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r("path",{d:"M8 3.5v9M3.5 8h9",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round"})})}export function CloseIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r("path",{d:"m4.5 4.5 7 7m0-7-7 7",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round"})})}export function ClockIcon(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("circle",{cx:"8",cy:"8",r:"6.25",stroke:"currentColor",strokeWidth:"1.5"}),r("path",{d:"M8 4.5V8l2.4 1.6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}export function CalendarIcon(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("rect",{x:"2.25",y:"3.25",width:"11.5",height:"10.5",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),r("path",{d:"M2.25 6.5h11.5",stroke:"currentColor",strokeWidth:"1.5"}),r("path",{d:"M5.5 1.75v2.5M10.5 1.75v2.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}export function LinkIcon(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("path",{d:"M6.5 9.5a2.75 2.75 0 0 0 4 .25l1.75-1.75a2.75 2.75 0 0 0-3.9-3.9L7.75 5.2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),r("path",{d:"M9.5 6.5a2.75 2.75 0 0 0-4-.25L3.75 8a2.75 2.75 0 0 0 3.9 3.9l.6-.6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}export function ExternalLinkIcon(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("path",{d:"M12.75 9.25v2.5a1.5 1.5 0 0 1-1.5 1.5h-7a1.5 1.5 0 0 1-1.5-1.5v-7a1.5 1.5 0 0 1 1.5-1.5h2.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),r("path",{d:"M9.5 2.75h3.75V6.5M7.25 8.75l5.75-5.75",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}function NoteIcon(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("circle",{cx:"8",cy:"8",r:"6.25",stroke:"currentColor",strokeWidth:"1.5"}),r("path",{d:"M8 7.25v4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),r("circle",{cx:"8",cy:"4.9",r:"0.85",fill:"currentColor"})]})}export function DotIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:r("circle",{cx:"8",cy:"8",r:"3.25"})})}export function StarIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:r("path",{d:"m8 1.6 1.86 3.9 4.14.56-3.02 2.9.76 4.24L8 11.16 4.26 13.2l.76-4.24L2 6.06l4.14-.56z"})})}export function StarOutlineIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r("path",{d:"m8 1.6 1.86 3.9 4.14.56-3.02 2.9.76 4.24L8 11.16 4.26 13.2l.76-4.24L2 6.06l4.14-.56z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"})})}export function severityIcon(o){return"success"===o?e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("circle",{cx:"8",cy:"8",r:"6.25",stroke:"currentColor",strokeWidth:"1.5"}),r("path",{d:"m5.25 8.25 1.9 1.9 3.6-3.9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"warning"===o?e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("path",{d:"M7.13 2.6 1.9 11.7a1 1 0 0 0 .87 1.5h10.46a1 1 0 0 0 .87-1.5L8.87 2.6a1 1 0 0 0-1.74 0Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),r("path",{d:"M8 6.1v3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),r("circle",{cx:"8",cy:"11.2",r:"0.85",fill:"currentColor"})]}):"danger"===o?e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("circle",{cx:"8",cy:"8",r:"6.25",stroke:"currentColor",strokeWidth:"1.5"}),r("path",{d:"m5.9 5.9 4.2 4.2m0-4.2-4.2 4.2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}):r(NoteIcon,{})}
|
package/dist/internal/menu.js
CHANGED
|
@@ -1,18 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* What every row of a `PlMenu` inherits from the popup around it.
|
|
3
|
-
*
|
|
4
|
-
* A context rather than props threaded down, and a file of its own rather than
|
|
5
|
-
* something exported from the component, for one reason: `PlMenu` and
|
|
6
|
-
* `PlContextMenu` are two triggers onto the same surface, and a row written
|
|
7
|
-
* inside either has to come out identical. A context declared in one of them
|
|
8
|
-
* would make the other import from it.
|
|
9
|
-
*
|
|
10
|
-
* `size`, `color` and `density` belong to the *set*. A menu whose third row is
|
|
11
|
-
* a size out is not a menu.
|
|
12
|
-
*/
|
|
13
|
-
import * as React from 'react';
|
|
14
|
-
export const MenuContext = /* @__PURE__ */ React.createContext({
|
|
15
|
-
size: 'md',
|
|
16
|
-
color: 'primary',
|
|
17
|
-
density: 'default'
|
|
18
|
-
});
|
|
1
|
+
import*as t from"react";export const MenuContext=/* @__PURE__ */t.createContext({size:"md",color:"primary",density:"default"});
|
package/dist/internal/picker.js
CHANGED
|
@@ -1,139 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { Field } from '@base-ui/react/field';
|
|
4
|
-
import { Popover } from '@base-ui/react/popover';
|
|
5
|
-
import { CloseIcon } from './icons.js';
|
|
6
|
-
import { WidthSizer } from './sizer.js';
|
|
7
|
-
import { chipRemoveClasses, controlHeightClasses, controlTextLeadingClasses, cx, disabledClasses, fieldReadOnlyClasses, fieldRestClasses, focusWithinRingClasses, gapClasses, glassClasses, iconClasses, metaTextClasses, paddingXClasses, radiusClasses, stackGapClasses, surfaceSlots, transitionClasses } from './styles.js';
|
|
8
|
-
/**
|
|
9
|
-
* The shell all four pickers wear: a field-shaped trigger with a popup hanging
|
|
10
|
-
* off it.
|
|
11
|
-
*
|
|
12
|
-
* It is here rather than in one of the components for the reason the calendar
|
|
13
|
-
* is: four components need it, and none of them should have to import another.
|
|
14
|
-
* What it draws is deliberately not new — the trigger is `fieldRestClasses`,
|
|
15
|
-
* the same box a `PlTextField` and a `PlSelect`'s trigger are drawn on, to the
|
|
16
|
-
* pixel. A form where the date field is a different height, radius or material
|
|
17
|
-
* from the text field beside it is a form that looks assembled rather than
|
|
18
|
-
* designed.
|
|
19
|
-
*
|
|
20
|
-
* The one thing the pickers do *not* offer is typing a date into the trigger.
|
|
21
|
-
* Parsing a date out of free text is locale-dependent in a way that cannot be
|
|
22
|
-
* done honestly without a date library, and a field that understands `27/7/26`
|
|
23
|
-
* in one browser and not the next is worse than one that never claimed to. So
|
|
24
|
-
* the trigger is a button, exactly as a select's is, and the calendar is where
|
|
25
|
-
* the answer comes from.
|
|
26
|
-
*/
|
|
27
|
-
/* ---------------------------------------------------------------------------
|
|
28
|
-
* Colour
|
|
29
|
-
* ------------------------------------------------------------------------- */
|
|
30
|
-
/**
|
|
31
|
-
* The popup's slots: a container's undyed sheet with the *control* fill added
|
|
32
|
-
* back on top.
|
|
33
|
-
*
|
|
34
|
-
* Neither generator in `internal/styles` says this on its own, and the reason is
|
|
35
|
-
* that a picker's popup is both things at once. It is a container — it holds a
|
|
36
|
-
* grid of forty-two days, and dyeing the sheet under them would put every one of
|
|
37
|
-
* them on a background it was not chosen against — and it also holds the one
|
|
38
|
-
* filled token in the library that has to be found without being read, which is
|
|
39
|
-
* the day you picked. So the sheet stays clear glass and the family arrives in
|
|
40
|
-
* the two fill slots the chosen cell reads.
|
|
41
|
-
*/
|
|
42
|
-
export function popupSlots(color, elevation) {
|
|
43
|
-
return {
|
|
44
|
-
...surfaceSlots(color, elevation),
|
|
45
|
-
'--p-fill': `var(--plass-${color}-fill)`,
|
|
46
|
-
'--p-on-solid': `var(--plass-${color}-on-solid)`
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
/* ---------------------------------------------------------------------------
|
|
50
|
-
* Surfaces
|
|
51
|
-
* ------------------------------------------------------------------------- */
|
|
52
|
-
/** The trigger's box. A `PlTextField`'s shell, unchanged. */
|
|
53
|
-
const triggerShellClasses = /* @__PURE__ */ [
|
|
54
|
-
'group relative flex w-full items-center select-none',
|
|
55
|
-
'[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]',
|
|
56
|
-
transitionClasses,
|
|
57
|
-
focusWithinRingClasses,
|
|
58
|
-
iconClasses
|
|
59
|
-
].join(' ');
|
|
60
|
-
/**
|
|
61
|
-
* The popup. Like every floating surface in the library it carries a shadow by
|
|
62
|
-
* default, at level 3 — as far as the ladder goes without hovering — because it
|
|
63
|
-
* is genuinely off the page rather than merely on top of it.
|
|
64
|
-
*/
|
|
65
|
-
export const pickerPopupClasses = /* @__PURE__ */ [
|
|
66
|
-
glassClasses,
|
|
67
|
-
'border text-(--plass-fg) bg-(--plass-glass-press)',
|
|
68
|
-
'[border-color:var(--plass-glass-line)]',
|
|
69
|
-
'[box-shadow:var(--plass-shadow-3),var(--plass-gloss-glass)]',
|
|
70
|
-
'[outline:none]',
|
|
71
|
-
// Opacity only. A calendar that slid into place would move the cell the
|
|
72
|
-
// pointer was already reaching for.
|
|
73
|
-
'[transition:opacity_var(--plass-duration)_var(--plass-ease)]',
|
|
74
|
-
'data-[starting-style]:opacity-0 data-[ending-style]:opacity-0'
|
|
75
|
-
].join(' ');
|
|
76
|
-
/** The popup's own padding, one track tighter than a control's. */
|
|
77
|
-
export const popupPaddingClasses = {
|
|
78
|
-
xs: 'p-1.5',
|
|
79
|
-
sm: 'p-2',
|
|
80
|
-
md: 'p-2.5',
|
|
81
|
-
lg: 'p-3',
|
|
82
|
-
xl: 'p-3.5'
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* A trigger, a label, the two lines of text under it, and a popup.
|
|
86
|
-
*
|
|
87
|
-
* Everything about it that is visible is a decision already made elsewhere: the
|
|
88
|
-
* shell classes, the read-only and disabled treatments, the label's type scale
|
|
89
|
-
* and the way `invalid` re-points the whole colour family at `danger` so the
|
|
90
|
-
* edge, the ring and the message turn over together.
|
|
91
|
-
*/
|
|
92
|
-
export function PickerShell({ variant = 'glass', size = 'md', color = 'primary', density = 'default', elevation = 0, label, description, error, invalid, startIcon, fullWidth = false, disabled = false, readOnly = false, required = false, id, className, style, display, samples, empty, clearable = false, onClear, open, onOpenChange, labels, hiddenValues, children, triggerRef, ...props }) {
|
|
93
|
-
const generatedId = React.useId();
|
|
94
|
-
const triggerId = id ?? `${generatedId}-trigger`;
|
|
95
|
-
const labelId = `${generatedId}-label`;
|
|
96
|
-
const descriptionId = `${generatedId}-description`;
|
|
97
|
-
const errorId = `${generatedId}-error`;
|
|
98
|
-
const hasError = error !== undefined && error !== null && error !== false && error !== '';
|
|
99
|
-
const isInvalid = invalid ?? hasError;
|
|
100
|
-
const family = isInvalid ? 'danger' : color;
|
|
101
|
-
const inert = disabled || readOnly;
|
|
102
|
-
const describedBy = [description ? descriptionId : null, hasError ? errorId : null].filter(Boolean).join(' ') ||
|
|
103
|
-
undefined;
|
|
104
|
-
return (_jsxs(Field.Root, { disabled: disabled, invalid: isInvalid, className: cx('flex-col align-top', stackGapClasses[size], fullWidth ? 'flex w-full' : 'inline-flex', className), style: { ...surfaceSlots(family, elevation), ...style }, ...props, children: [label ? (_jsx(Field.Label, { id: labelId, htmlFor: triggerId, className: cx(metaTextClasses[size], 'font-semibold', disabled ? 'text-(--plass-muted-fg)' : 'text-(--plass-fg)'), children: label })) : null, _jsxs(Popover.Root, { open: open, onOpenChange: (next) => onOpenChange(next), children: [_jsxs("span", { className: cx(triggerShellClasses, controlHeightClasses[size], controlTextLeadingClasses[size], radiusClasses[size], gapClasses[size], paddingXClasses[density][size],
|
|
105
|
-
// An if/else rather than stacked variants: two Tailwind classes of
|
|
106
|
-
// equal specificity resolve by their order in the generated sheet.
|
|
107
|
-
disabled
|
|
108
|
-
? disabledClasses[variant]
|
|
109
|
-
: readOnly
|
|
110
|
-
? fieldReadOnlyClasses[variant]
|
|
111
|
-
: fieldRestClasses[variant]), children: [_jsxs(Popover.Trigger, { id: triggerId, ref: triggerRef, disabled: disabled, "aria-labelledby": label ? labelId : undefined, "aria-describedby": describedBy, "aria-required": required || undefined, "aria-invalid": isInvalid || undefined, className: cx('flex min-w-0 flex-1 items-center bg-transparent text-start [font:inherit] text-inherit', gapClasses[size], '[outline:none]', inert ? 'cursor-default' : 'cursor-pointer'), children: [startIcon ? (_jsx("span", { className: "flex h-[1lh] shrink-0 items-center text-(--plass-muted-fg)", children: startIcon })) : null, _jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [_jsx("span", { className: cx('w-full truncate', empty ? 'text-(--plass-muted-fg)' : 'text-(--plass-fg)'), children: display }), _jsx(WidthSizer, { samples: samples ?? [] })] })] }), clearable && !empty && !inert ? (_jsx("button", { type: "button", "aria-label": labels.clear, className: cx(chipRemoveClasses, 'text-(--plass-muted-fg)'), onClick: (event) => {
|
|
112
|
-
event.stopPropagation();
|
|
113
|
-
onClear();
|
|
114
|
-
}, children: _jsx(CloseIcon, {}) })) : null] }), _jsx(Popover.Portal, { children: _jsx(Popover.Positioner, { className: "plass-portal z-50 [outline:none]", sideOffset: 6, align: "start", children: _jsx(Popover.Popup
|
|
115
|
-
// Base UI is told to leave the focus alone so the calendar can take
|
|
116
|
-
// it into the grid itself. Its own move would land on the popup
|
|
117
|
-
// element and run *after* the grid's, undoing it.
|
|
118
|
-
, {
|
|
119
|
-
// Base UI is told to leave the focus alone so the calendar can take
|
|
120
|
-
// it into the grid itself. Its own move would land on the popup
|
|
121
|
-
// element and run *after* the grid's, undoing it.
|
|
122
|
-
initialFocus: false, className: cx(pickerPopupClasses, radiusClasses[size], popupPaddingClasses[size], controlTextLeadingClasses[size]), style: popupSlots(family, 3), children: children }) }) })] }), description ? (_jsx(Field.Description, { id: descriptionId, className: cx(metaTextClasses[size], 'text-(--plass-muted-fg)'), children: description })) : null, hasError ? (_jsx(Field.Error, { id: errorId, match: true, className: cx(metaTextClasses[size], 'text-(--p-accent)'), children: error })) : null, hiddenValues?.map((entry, index) => (_jsx("input", { type: "hidden", name: entry.name, value: entry.value }, index)))] }));
|
|
123
|
-
}
|
|
124
|
-
/* ---------------------------------------------------------------------------
|
|
125
|
-
* The footer
|
|
126
|
-
* ------------------------------------------------------------------------- */
|
|
127
|
-
/**
|
|
128
|
-
* The row of shortcuts under a picker's panel.
|
|
129
|
-
*
|
|
130
|
-
* A hairline above it rather than a gap, because the actions act on the panel
|
|
131
|
-
* and a gap would read as a second popup stacked under the first.
|
|
132
|
-
*/
|
|
133
|
-
export function PickerFooter({ size, children }) {
|
|
134
|
-
return (_jsx("div", { className: cx('flex items-center justify-end border-t pt-1.5', '[border-color:var(--plass-divider)]', gapClasses[size]), children: children }));
|
|
135
|
-
}
|
|
136
|
-
/** The vertical hairline between a calendar and the clock beside it. */
|
|
137
|
-
export function PickerDivider() {
|
|
138
|
-
return _jsx("div", { "aria-hidden": "true", className: "w-px self-stretch bg-(--plass-divider)" });
|
|
139
|
-
}
|
|
1
|
+
import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as s from"react";import{Field as a}from"@base-ui/react/field";import{Popover as r}from"@base-ui/react/popover";import{CloseIcon as t}from"./icons.js";import{WidthSizer as i}from"./sizer.js";import{chipRemoveClasses as n,controlHeightClasses as o,controlTextLeadingClasses as p,cx as d,disabledClasses as c,fieldReadOnlyClasses as u,fieldRestClasses as m,focusWithinRingClasses as f,gapClasses as h,glassClasses as g,iconClasses as x,metaTextClasses as b,paddingXClasses as v,radiusClasses as y,stackGapClasses as N,surfaceSlots as P,transitionClasses as j}from"./styles.js";export function popupSlots(e,l){return{...P(e,l),"--p-fill":`var(--plass-${e}-fill)`,"--p-on-solid":`var(--plass-${e}-on-solid)`}}const w=/* @__PURE__ */["group relative flex w-full items-center select-none","[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]",j,f,x].join(" ");export const pickerPopupClasses=/* @__PURE__ */[g,"border text-(--plass-fg) bg-(--plass-glass-press)","[border-color:var(--plass-glass-line)]","[box-shadow:var(--plass-shadow-3),var(--plass-gloss-glass)]","[outline:none]","[transition:opacity_var(--plass-duration)_var(--plass-ease)]","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0"].join(" ");export const popupPaddingClasses={xs:"p-1.5",sm:"p-2",md:"p-2.5",lg:"p-3",xl:"p-3.5"};export function PickerShell({variant:f="glass",size:g="md",color:x="primary",density:j="default",elevation:k=0,label:C,description:$,error:z,invalid:O,startIcon:F,fullWidth:R=!1,disabled:S=!1,readOnly:q=!1,required:D=!1,id:I,className:_,style:B,display:E,samples:L,empty:T,clearable:V=!1,onClear:W,open:A,onOpenChange:G,labels:H,hiddenValues:J,children:K,triggerRef:M,...Q}){const U=s.useId(),X=I??`${U}-trigger`,Y=`${U}-label`,Z=`${U}-description`,ee=`${U}-error`,le=null!=z&&!1!==z&&""!==z,se=O??le,ae=se?"danger":x,re=S||q,te=[$?Z:null,le?ee:null].filter(Boolean).join(" ")||void 0;return l(a.Root,{disabled:S,invalid:se,className:d("flex-col align-top",N[g],R?"flex w-full":"inline-flex",_),style:{...P(ae,k),...B},...Q,children:[C?e(a.Label,{id:Y,htmlFor:X,className:d(b[g],"font-semibold",S?"text-(--plass-muted-fg)":"text-(--plass-fg)"),children:C}):null,l(r.Root,{open:A,onOpenChange:e=>G(e),children:[l("span",{className:d(w,o[g],p[g],y[g],h[g],v[j][g],S?c[f]:q?u[f]:m[f]),children:[l(r.Trigger,{id:X,ref:M,disabled:S,"aria-labelledby":C?Y:void 0,"aria-describedby":te,"aria-required":D||void 0,"aria-invalid":se||void 0,className:d("flex min-w-0 flex-1 items-center bg-transparent text-start [font:inherit] text-inherit",h[g],"[outline:none]",re?"cursor-default":"cursor-pointer"),children:[F?e("span",{className:"flex h-[1lh] shrink-0 items-center text-(--plass-muted-fg)",children:F}):null,l("span",{className:"flex min-w-0 flex-1 flex-col",children:[e("span",{className:d("w-full truncate",T?"text-(--plass-muted-fg)":"text-(--plass-fg)"),children:E}),e(i,{samples:L??[]})]})]}),!V||T||re?null:e("button",{type:"button","aria-label":H.clear,className:d(n,"text-(--plass-muted-fg)"),onClick:e=>{e.stopPropagation(),W()},children:e(t,{})})]}),e(r.Portal,{children:e(r.Positioner,{className:"plass-portal z-50 [outline:none]",sideOffset:6,align:"start",children:e(r.Popup,{initialFocus:!1,className:d(pickerPopupClasses,y[g],popupPaddingClasses[g],p[g]),style:popupSlots(ae,3),children:K})})})]}),$?e(a.Description,{id:Z,className:d(b[g],"text-(--plass-muted-fg)"),children:$}):null,le?e(a.Error,{id:ee,match:!0,className:d(b[g],"text-(--p-accent)"),children:z}):null,J?.map((l,s)=>e("input",{type:"hidden",name:l.name,value:l.value},s))]})}export function PickerFooter({size:l,children:s}){return e("div",{className:d("flex items-center justify-end border-t pt-1.5","[border-color:var(--plass-divider)]",h[l]),children:s})}export function PickerDivider(){return e("div",{"aria-hidden":"true",className:"w-px self-stretch bg-(--plass-divider)"})}
|
|
@@ -1,167 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* What the three progress indicators share.
|
|
3
|
-
*
|
|
4
|
-
* `PlProgressLinear`, `PlProgressCircular` and `PlProgressBox` are three shapes
|
|
5
|
-
* answering one question — how far along is this, and is it moving at all — so
|
|
6
|
-
* everything that is *not* the shape belongs here: the colour slots, the size
|
|
7
|
-
* ladders, and the arithmetic that turns `value`/`min`/`max` into a fraction.
|
|
8
|
-
*
|
|
9
|
-
* What is left in each component is the shape, which is the point: it is the
|
|
10
|
-
* only thing that genuinely differs.
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* The slots an indicator reads.
|
|
14
|
-
*
|
|
15
|
-
* An indicator **is** the coloured thing — unlike a PlBox, which holds other
|
|
16
|
-
* people's content — so it gets `--p-fill`, the family's own gradient, and the
|
|
17
|
-
* filled part of a bar is made of exactly the same material as the button that
|
|
18
|
-
* submits the form it is in.
|
|
19
|
-
*
|
|
20
|
-
* There is no elevation ladder and no `--p-lift` here, on purpose. An indicator
|
|
21
|
-
* is cut *into* the surface it sits on, the way a groove is, and a groove does
|
|
22
|
-
* not float.
|
|
23
|
-
*/
|
|
24
|
-
export function progressSlots(color) {
|
|
25
|
-
return {
|
|
26
|
-
'--p-fill': `var(--plass-${color}-fill)`,
|
|
27
|
-
// The two ends of that gradient on their own, which only the ring needs: an
|
|
28
|
-
// SVG stroke cannot take a CSS gradient, so an arc has to build a
|
|
29
|
-
// `<linearGradient>` out of the same two stops the bar's fill is made of.
|
|
30
|
-
// Without them a ring would be a flat arc beside a swept bar.
|
|
31
|
-
'--p-solid': `var(--plass-${color}-solid)`,
|
|
32
|
-
'--p-solid-to': `var(--plass-${color}-solid-to)`,
|
|
33
|
-
'--p-accent': `var(--plass-${color}-accent)`,
|
|
34
|
-
'--p-soft': `var(--plass-${color}-soft)`,
|
|
35
|
-
'--p-soft-press': `var(--plass-${color}-soft-press)`
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* How thick the linear groove is.
|
|
40
|
-
*
|
|
41
|
-
* Its own ladder rather than a fraction of `controlHeightClasses`: a bar is not
|
|
42
|
-
* a control you can put a label inside, and at `md` it wants to be the weight
|
|
43
|
-
* of a rule between two paragraphs rather than a quarter of a button.
|
|
44
|
-
*
|
|
45
|
-
* They are `PlSlider`'s rail thicknesses, and deliberately: a rail and a bar are
|
|
46
|
-
* the same channel, one of which you drag and one of which you watch.
|
|
47
|
-
*/
|
|
48
|
-
export const barThicknessClasses = {
|
|
49
|
-
xs: 'h-1',
|
|
50
|
-
sm: 'h-1.5',
|
|
51
|
-
md: 'h-1.5',
|
|
52
|
-
lg: 'h-2',
|
|
53
|
-
xl: 'h-2.5'
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* The diameter of the ring, in pixels.
|
|
57
|
-
*
|
|
58
|
-
* Numbers rather than classes because the same value has to reach the SVG's
|
|
59
|
-
* `viewBox` arithmetic, and a ring is one of the few things in the library that
|
|
60
|
-
* cannot be described by a Tailwind class alone.
|
|
61
|
-
*
|
|
62
|
-
* They sit just under the control ladder at every step — a `md` ring is 20px
|
|
63
|
-
* inside a 40px control — so a ring dropped into a button, a field or a table
|
|
64
|
-
* row never makes the row taller than it already was.
|
|
65
|
-
*/
|
|
66
|
-
export const ringDiameters = {
|
|
67
|
-
xs: 14,
|
|
68
|
-
sm: 16,
|
|
69
|
-
md: 20,
|
|
70
|
-
lg: 26,
|
|
71
|
-
xl: 32
|
|
72
|
-
};
|
|
73
|
-
/** The ring's stroke, thickening with the ring so the hole stays in proportion. */
|
|
74
|
-
export const ringStrokes = {
|
|
75
|
-
xs: 1.5,
|
|
76
|
-
sm: 1.75,
|
|
77
|
-
md: 2,
|
|
78
|
-
lg: 2.5,
|
|
79
|
-
xl: 3
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* One plate of a `PlProgressBox`, on the tick ladder — an indicator beside a
|
|
83
|
-
* label, not a control you can put one inside.
|
|
84
|
-
*/
|
|
85
|
-
export const plateSizeClasses = {
|
|
86
|
-
xs: 'size-2',
|
|
87
|
-
sm: 'size-2.5',
|
|
88
|
-
md: 'size-3',
|
|
89
|
-
lg: 'size-4',
|
|
90
|
-
xl: 'size-5'
|
|
91
|
-
};
|
|
92
|
-
/** The corner cut off a plate: the same ~30% the tick boxes take. */
|
|
93
|
-
export const plateRadiusClasses = {
|
|
94
|
-
xs: 'rounded-[0.1875rem]',
|
|
95
|
-
sm: 'rounded-[0.25rem]',
|
|
96
|
-
md: 'rounded-[0.28125rem]',
|
|
97
|
-
lg: 'rounded-[0.375rem]',
|
|
98
|
-
xl: 'rounded-[0.4375rem]'
|
|
99
|
-
};
|
|
100
|
-
/** Between the plates. Tight — they are one object, not a row of squares. */
|
|
101
|
-
export const plateGapClasses = {
|
|
102
|
-
xs: 'gap-1',
|
|
103
|
-
sm: 'gap-1',
|
|
104
|
-
md: 'gap-1.5',
|
|
105
|
-
lg: 'gap-1.5',
|
|
106
|
-
xl: 'gap-2'
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* The groove an indicator is cut into, and the transition that fills it.
|
|
110
|
-
*
|
|
111
|
-
* `--plass-track` is the one neutral ink the library grooves with — a
|
|
112
|
-
* PlSlider's rail and a PlSwitch's off track are the same colour — so a form
|
|
113
|
-
* with a slider, a switch and a progress bar in it is made of one material
|
|
114
|
-
* rather than three.
|
|
115
|
-
*
|
|
116
|
-
* The fill is `--p-fill`, and it is a `background-image` rather than a colour
|
|
117
|
-
* because that is what a Plass fill *is*: a gradient that turns in hue. Which is
|
|
118
|
-
* also why the movement is on `width` and never on the paint: a gradient cannot
|
|
119
|
-
* be transitioned, and a length can.
|
|
120
|
-
*/
|
|
121
|
-
export const trackClasses = 'bg-(--plass-track)';
|
|
122
|
-
/** The bar's own duration, one step slower than a control's, so a fill reads as travel. */
|
|
123
|
-
export const fillTransitionClasses = '[transition:width_var(--plass-duration-slow)_var(--plass-ease)]';
|
|
124
|
-
/**
|
|
125
|
-
* `value` as a fraction of the range, or `null` when there is nothing to say.
|
|
126
|
-
*
|
|
127
|
-
* The clamp is not defensive programming for its own sake — `value` usually
|
|
128
|
-
* arrives from a division somewhere, and a bar that renders 140% wide because
|
|
129
|
-
* one request finished twice is a worse bug than a bar that sits full.
|
|
130
|
-
*/
|
|
131
|
-
export function progressFraction(value, min, max) {
|
|
132
|
-
if (value === null || value === undefined || Number.isNaN(value)) {
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
if (max <= min) {
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
return Math.min(1, Math.max(0, (value - min) / (max - min)));
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* What the value reads as, both on screen and to a screen reader.
|
|
142
|
-
*
|
|
143
|
-
* Base UI's own default is `${value}%`, which is right only when the range
|
|
144
|
-
* happens to be 0–100 — "3%" for step 3 of 4 is worse than saying nothing. So
|
|
145
|
-
* the percentage is computed from the fraction, and a caller who passed
|
|
146
|
-
* `format` gets Base UI's formatted string instead, because at that point they
|
|
147
|
-
* have said what the number means.
|
|
148
|
-
*/
|
|
149
|
-
export function progressText(fraction, formatted, hasFormat) {
|
|
150
|
-
if (fraction === null) {
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
return hasFormat ? formatted : `${Math.round(fraction * 100)}%`;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* The same string, shaped for Base UI's `getAriaValueText`.
|
|
157
|
-
*
|
|
158
|
-
* `undefined` when there is no value, which hands the indeterminate case back
|
|
159
|
-
* to Base UI — it already announces indeterminate progress, and re-inventing
|
|
160
|
-
* that here would be one more English string the library has to own.
|
|
161
|
-
*/
|
|
162
|
-
export function progressAriaText(fraction, hasFormat) {
|
|
163
|
-
if (fraction === null) {
|
|
164
|
-
return undefined;
|
|
165
|
-
}
|
|
166
|
-
return (formatted) => progressText(fraction, formatted, hasFormat) ?? '';
|
|
167
|
-
}
|
|
1
|
+
export function progressSlots(s){return{"--p-fill":`var(--plass-${s}-fill)`,"--p-solid":`var(--plass-${s}-solid)`,"--p-solid-to":`var(--plass-${s}-solid-to)`,"--p-accent":`var(--plass-${s}-accent)`,"--p-soft":`var(--plass-${s}-soft)`,"--p-soft-press":`var(--plass-${s}-soft-press)`}}export const barThicknessClasses={xs:"h-1",sm:"h-1.5",md:"h-1.5",lg:"h-2",xl:"h-2.5"};export const ringDiameters={xs:14,sm:16,md:20,lg:26,xl:32};export const ringStrokes={xs:1.5,sm:1.75,md:2,lg:2.5,xl:3};export const plateSizeClasses={xs:"size-2",sm:"size-2.5",md:"size-3",lg:"size-4",xl:"size-5"};export const plateRadiusClasses={xs:"rounded-[0.1875rem]",sm:"rounded-[0.25rem]",md:"rounded-[0.28125rem]",lg:"rounded-[0.375rem]",xl:"rounded-[0.4375rem]"};export const plateGapClasses={xs:"gap-1",sm:"gap-1",md:"gap-1.5",lg:"gap-1.5",xl:"gap-2"};export const trackClasses="bg-(--plass-track)";export const fillTransitionClasses="[transition:width_var(--plass-duration-slow)_var(--plass-ease)]";export function progressFraction(s,r,e){return null==s||Number.isNaN(s)||e<=r?null:Math.min(1,Math.max(0,(s-r)/(e-r)))}export function progressText(s,r,e){return null===s?null:e?r:`${Math.round(100*s)}%`}export function progressAriaText(s,r){if(null!==s)return e=>progressText(s,e,r)??""}
|
package/dist/internal/sizer.js
CHANGED
|
@@ -1,35 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
/**
|
|
3
|
-
* Holds a control open at the width of the widest thing it could ever say.
|
|
4
|
-
*
|
|
5
|
-
* A control that is not `fullWidth` is sized by what it is *currently* saying,
|
|
6
|
-
* which for anything whose value changes means the box changes with it. A
|
|
7
|
-
* PlSelect showing `Seoul` is narrower than the same one showing
|
|
8
|
-
* `Washington DC`. Either way the field moves under the pointer that just used
|
|
9
|
-
* it, and the whole row of controls beside it shuffles along.
|
|
10
|
-
*
|
|
11
|
-
* So the alternatives are laid out too, stacked in a box clipped to no height.
|
|
12
|
-
* The control's intrinsic width becomes the widest of them and stops depending
|
|
13
|
-
* on the value.
|
|
14
|
-
*
|
|
15
|
-
* Three things it deliberately is not:
|
|
16
|
-
*
|
|
17
|
-
* - **Not `hidden`, and not `display: none`.** Both take the box out of layout,
|
|
18
|
-
* and a box that is not laid out reserves nothing.
|
|
19
|
-
* - **Not read out.** `aria-hidden`, or a screen reader would announce every
|
|
20
|
-
* value the control might hold before the one it does.
|
|
21
|
-
* - **Not text.** A string sample is drawn as generated content off a data
|
|
22
|
-
* attribute rather than as a text node. `content: attr(…)` lays out exactly
|
|
23
|
-
* like text, so it reserves the same width — but it leaves nothing for
|
|
24
|
-
* `getByText` or a screen reader's find-in-page to trip over, and a caller's
|
|
25
|
-
* test asking for the option they selected keeps finding one element rather
|
|
26
|
-
* than two. Only a sample that is not a string — an option whose label is a
|
|
27
|
-
* node — has to be rendered for real, because there is nothing to put in an
|
|
28
|
-
* attribute.
|
|
29
|
-
*/
|
|
30
|
-
export function WidthSizer({ samples }) {
|
|
31
|
-
if (samples.length === 0) {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
return (_jsx("span", { "aria-hidden": "true", className: "invisible h-0 min-h-0 overflow-hidden", children: samples.map((sample, index) => typeof sample === 'string' ? (_jsx("span", { "data-sample": sample, className: "block whitespace-nowrap before:content-[attr(data-sample)]" }, `${index}:${sample}`)) : (_jsx("span", { className: "block whitespace-nowrap", children: sample }, index))) }));
|
|
35
|
-
}
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";export function WidthSizer({samples:a}){return 0===a.length?null:e("span",{"aria-hidden":"true",className:"invisible h-0 min-h-0 overflow-hidden",children:a.map((a,n)=>"string"==typeof a?e("span",{"data-sample":a,className:"block whitespace-nowrap before:content-[attr(data-sample)]"},`${n}:${a}`):e("span",{className:"block whitespace-nowrap",children:a},n))})}
|