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.
Files changed (165) hide show
  1. package/README.md +165 -0
  2. package/dist/components/accordion/PlAccordion.js +1 -131
  3. package/dist/components/accordion/index.js +1 -1
  4. package/dist/components/alert/PlAlert.js +1 -109
  5. package/dist/components/alert/index.js +1 -1
  6. package/dist/components/animate-appear/PlAnimateAppear.js +1 -71
  7. package/dist/components/animate-appear/index.js +1 -1
  8. package/dist/components/animate-blink/PlAnimateBlink.js +1 -47
  9. package/dist/components/animate-blink/index.js +1 -1
  10. package/dist/components/animate-fade/PlAnimateFade.js +1 -48
  11. package/dist/components/animate-fade/index.js +1 -1
  12. package/dist/components/animate-grow/PlAnimateGrow.js +1 -49
  13. package/dist/components/animate-grow/index.js +1 -1
  14. package/dist/components/animate-headline/PlAnimateHeadline.js +1 -120
  15. package/dist/components/animate-headline/index.js +1 -1
  16. package/dist/components/animate-lighting/PlAnimateLighting.js +1 -65
  17. package/dist/components/animate-lighting/index.js +1 -1
  18. package/dist/components/animate-marquee/PlAnimateMarquee.js +1 -94
  19. package/dist/components/animate-marquee/index.js +1 -1
  20. package/dist/components/animate-rotate/PlAnimateRotate.js +1 -50
  21. package/dist/components/animate-rotate/index.js +1 -1
  22. package/dist/components/animate-slide/PlAnimateSlide.js +1 -49
  23. package/dist/components/animate-slide/index.js +1 -1
  24. package/dist/components/animate-typing/PlAnimateTyping.js +1 -177
  25. package/dist/components/animate-typing/index.js +1 -1
  26. package/dist/components/animate-zoom/PlAnimateZoom.js +1 -45
  27. package/dist/components/animate-zoom/index.js +1 -1
  28. package/dist/components/aspect-ratio/PlAspectRatio.js +1 -58
  29. package/dist/components/aspect-ratio/index.js +1 -1
  30. package/dist/components/avatar/PlAvatar.js +1 -121
  31. package/dist/components/avatar/index.js +1 -1
  32. package/dist/components/badge/PlBadge.js +1 -168
  33. package/dist/components/badge/index.js +1 -1
  34. package/dist/components/blockquote/PlBlockquote.js +1 -112
  35. package/dist/components/blockquote/index.js +1 -1
  36. package/dist/components/bottom-navigation/PlBottomNavigation.js +1 -141
  37. package/dist/components/bottom-navigation/index.js +1 -1
  38. package/dist/components/box/PlBox.js +1 -46
  39. package/dist/components/box/index.js +1 -1
  40. package/dist/components/breadcrumb/PlBreadcrumb.js +1 -201
  41. package/dist/components/breadcrumb/index.js +1 -1
  42. package/dist/components/button/PlButton.js +1 -196
  43. package/dist/components/button/index.js +1 -1
  44. package/dist/components/button-group/PlButtonGroup.js +1 -64
  45. package/dist/components/button-group/index.js +1 -1
  46. package/dist/components/card/PlCard.js +1 -102
  47. package/dist/components/card/index.js +1 -1
  48. package/dist/components/carousel/PlCarousel.js +1 -177
  49. package/dist/components/carousel/index.js +1 -1
  50. package/dist/components/chat-bubble/PlChatBubble.js +1 -206
  51. package/dist/components/chat-bubble/index.js +1 -1
  52. package/dist/components/checkbox/PlCheckbox.js +1 -100
  53. package/dist/components/checkbox/index.js +1 -1
  54. package/dist/components/chip/PlChip.js +1 -144
  55. package/dist/components/chip/index.js +1 -1
  56. package/dist/components/collapsible/PlCollapsible.js +1 -65
  57. package/dist/components/collapsible/index.js +1 -1
  58. package/dist/components/combobox/PlCombobox.js +1 -199
  59. package/dist/components/combobox/index.js +1 -1
  60. package/dist/components/container/PlContainer.js +1 -47
  61. package/dist/components/container/index.js +1 -1
  62. package/dist/components/date-picker/PlDatePicker.js +1 -87
  63. package/dist/components/date-picker/index.js +1 -1
  64. package/dist/components/date-range-picker/PlDateRangePicker.js +1 -152
  65. package/dist/components/date-range-picker/index.js +1 -1
  66. package/dist/components/date-time-picker/PlDateTimePicker.js +1 -106
  67. package/dist/components/date-time-picker/index.js +1 -1
  68. package/dist/components/divider/PlDivider.js +1 -107
  69. package/dist/components/divider/index.js +1 -1
  70. package/dist/components/drawer/PlDrawer.js +1 -190
  71. package/dist/components/drawer/index.js +1 -1
  72. package/dist/components/file-picker/PlFilePicker.js +1 -274
  73. package/dist/components/file-picker/index.js +1 -1
  74. package/dist/components/floating-bottom-navigation/PlFloatingBottomNavigation.js +1 -291
  75. package/dist/components/floating-bottom-navigation/index.js +1 -1
  76. package/dist/components/grid/PlGrid.js +1 -51
  77. package/dist/components/grid/PlGridItem.js +1 -34
  78. package/dist/components/grid/index.js +1 -2
  79. package/dist/components/highlight/PlHighlight.js +1 -185
  80. package/dist/components/highlight/index.js +1 -1
  81. package/dist/components/hot-keys/PlHotKeys.js +1 -294
  82. package/dist/components/hot-keys/index.js +1 -1
  83. package/dist/components/icon/PlIcon.js +1 -58
  84. package/dist/components/icon/index.js +1 -1
  85. package/dist/components/icon-button/PlIconButton.js +1 -37
  86. package/dist/components/icon-button/index.js +1 -1
  87. package/dist/components/list/PlList.js +1 -160
  88. package/dist/components/list/index.js +1 -1
  89. package/dist/components/menu/PlMenu.js +1 -209
  90. package/dist/components/menu/index.js +1 -1
  91. package/dist/components/modal/PlModal.js +1 -150
  92. package/dist/components/modal/index.js +1 -1
  93. package/dist/components/number-field/PlNumberField.js +1 -111
  94. package/dist/components/number-field/index.js +1 -1
  95. package/dist/components/otp-field/PlOtpField.js +1 -109
  96. package/dist/components/otp-field/index.js +1 -1
  97. package/dist/components/overlay/PlOverlay.js +1 -77
  98. package/dist/components/overlay/index.js +1 -1
  99. package/dist/components/pagination/PlPagination.js +1 -159
  100. package/dist/components/pagination/index.js +1 -1
  101. package/dist/components/panes/PlPanes.js +1 -324
  102. package/dist/components/panes/index.js +1 -1
  103. package/dist/components/pill/PlPill.js +1 -154
  104. package/dist/components/pill/index.js +1 -1
  105. package/dist/components/popover/PlPopover.js +1 -113
  106. package/dist/components/popover/index.js +1 -1
  107. package/dist/components/progress-box/PlProgressBox.js +1 -34
  108. package/dist/components/progress-box/index.js +1 -1
  109. package/dist/components/progress-circular/PlProgressCircular.js +1 -47
  110. package/dist/components/progress-circular/index.js +1 -1
  111. package/dist/components/progress-linear/PlProgressLinear.js +1 -40
  112. package/dist/components/progress-linear/index.js +1 -1
  113. package/dist/components/radio-group/PlRadioGroup.js +1 -99
  114. package/dist/components/radio-group/index.js +1 -1
  115. package/dist/components/rating/PlRating.js +1 -101
  116. package/dist/components/rating/index.js +1 -1
  117. package/dist/components/scroll-zone/PlScrollZone.js +1 -411
  118. package/dist/components/scroll-zone/index.js +1 -1
  119. package/dist/components/segmented-button/PlSegmentedButton.js +1 -206
  120. package/dist/components/segmented-button/index.js +1 -1
  121. package/dist/components/select/PlSelect.js +1 -115
  122. package/dist/components/select/index.js +1 -1
  123. package/dist/components/skeleton/PlSkeleton.js +1 -142
  124. package/dist/components/skeleton/index.js +1 -1
  125. package/dist/components/slider/PlSlider.js +1 -132
  126. package/dist/components/slider/index.js +1 -1
  127. package/dist/components/spoiler/PlSpoiler.js +1 -74
  128. package/dist/components/spoiler/index.js +1 -1
  129. package/dist/components/switch/PlSwitch.js +1 -131
  130. package/dist/components/switch/index.js +1 -1
  131. package/dist/components/table/PlTable.js +1 -210
  132. package/dist/components/table/index.js +1 -1
  133. package/dist/components/tabs/PlTabs.js +1 -182
  134. package/dist/components/tabs/index.js +1 -1
  135. package/dist/components/text-field/PlTextField.js +1 -126
  136. package/dist/components/text-field/index.js +1 -1
  137. package/dist/components/text-link/PlTextLink.js +1 -136
  138. package/dist/components/text-link/index.js +1 -1
  139. package/dist/components/time-picker/PlTimePicker.js +1 -97
  140. package/dist/components/time-picker/index.js +1 -1
  141. package/dist/components/timeline/PlTimeline.js +1 -207
  142. package/dist/components/timeline/index.js +1 -1
  143. package/dist/components/toast/PlToast.js +1 -174
  144. package/dist/components/toast/index.js +1 -1
  145. package/dist/components/toolbar/PlToolbar.js +1 -65
  146. package/dist/components/toolbar/index.js +1 -1
  147. package/dist/components/tooltip/PlTooltip.js +1 -117
  148. package/dist/components/tooltip/index.js +1 -1
  149. package/dist/components/typography/PlTypography.js +1 -143
  150. package/dist/components/typography/index.js +1 -1
  151. package/dist/index.js +1 -75
  152. package/dist/internal/animate.js +1 -318
  153. package/dist/internal/button-group.js +2 -19
  154. package/dist/internal/calendar.js +1 -501
  155. package/dist/internal/date.js +1 -353
  156. package/dist/internal/format.js +1 -41
  157. package/dist/internal/grid.js +1 -143
  158. package/dist/internal/icons.js +1 -138
  159. package/dist/internal/menu.js +1 -18
  160. package/dist/internal/picker.js +1 -139
  161. package/dist/internal/progress.js +1 -167
  162. package/dist/internal/sizer.js +1 -35
  163. package/dist/internal/styles.js +1 -636
  164. package/dist/types.js +0 -8
  165. package/package.json +5 -3
@@ -1,209 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import * as React from 'react';
3
- import { Menu as BaseUIMenu } from '@base-ui/react/menu';
4
- import { ContextMenu as BaseUIContextMenu } from '@base-ui/react/context-menu';
5
- import { MenuContext } from '../../internal/menu.js';
6
- import { CheckIcon, ChevronIcon, DotIcon } from '../../internal/icons.js';
7
- import { controlTextLeadingClasses, cx, gapClasses, glassClasses, hasContent, iconClasses, metaTextClasses, radiusClasses, surfaceSlots, transitionClasses } from '../../internal/styles.js';
8
- /* ---------------------------------------------------------------------------
9
- * The surface
10
- * ------------------------------------------------------------------------- */
11
- /**
12
- * The popup, which is `PlSelect`'s popup to the pixel — deliberately, because a
13
- * select *is* a menu that remembers what you picked, and two floating lists of
14
- * rows that do not match are two lists the eye has to learn separately.
15
- */
16
- const popupClasses = /* @__PURE__ */ [
17
- glassClasses,
18
- 'max-h-[min(24rem,var(--available-height))] min-w-40 overflow-y-auto overscroll-contain',
19
- 'border bg-(--plass-glass-press) p-1',
20
- '[border-color:var(--plass-glass-line)]',
21
- '[box-shadow:var(--plass-shadow-3),var(--plass-gloss-glass)]',
22
- '[outline:none]',
23
- // Opacity only. A menu that slides in has moved the row you were already
24
- // reaching for, which is the one thing a menu must never do.
25
- '[transition:opacity_var(--plass-duration)_var(--plass-ease)]',
26
- 'data-[starting-style]:opacity-0 data-[ending-style]:opacity-0'
27
- ].join(' ');
28
- /**
29
- * A row's padding, and a ladder of its own rather than the sheet track.
30
- *
31
- * A `PlList` row spans a sheet that something else decided the width of; a menu
32
- * row is inside a popup that is exactly as wide as its longest label. The sheet
33
- * track's `px-5` at `md` would add 40px to a menu that says "Cut", which is how
34
- * a five-row menu ends up the width of a dialog.
35
- */
36
- const rowPaddingClasses = {
37
- default: {
38
- xs: 'px-1.5 py-0.5',
39
- sm: 'px-2 py-1',
40
- md: 'px-2.5 py-1.5',
41
- lg: 'px-3 py-2',
42
- xl: 'px-3.5 py-2.5'
43
- },
44
- compact: {
45
- xs: 'px-1 py-0.5',
46
- sm: 'px-1.5 py-0.5',
47
- md: 'px-2 py-1',
48
- lg: 'px-2.5 py-1',
49
- xl: 'px-3 py-1.5'
50
- }
51
- };
52
- /**
53
- * A row sits one step down the radius ladder from the popup it is inside: a
54
- * tile cut out of a sheet cannot carry the sheet's own corner, or the two curves
55
- * fight along the edge.
56
- */
57
- const rowRadiusClasses = {
58
- xs: radiusClasses.xs,
59
- sm: radiusClasses.xs,
60
- md: radiusClasses.sm,
61
- lg: radiusClasses.sm,
62
- xl: radiusClasses.md
63
- };
64
- /**
65
- * The row, in every one of its shapes — plain, link, submenu trigger, checkbox,
66
- * radio. They differ in which Base UI part renders them and in nothing else.
67
- *
68
- * `data-highlighted` rather than `:hover`, exactly as on a `PlSelect` option: it
69
- * is also what the arrow keys move, so the mouse and the keyboard light the same
70
- * row instead of the keyboard lighting nothing.
71
- *
72
- * `accented` is a parameter rather than a class the caller appends, and that is
73
- * not a style preference. Appending `text-(--p-accent)` next to the default
74
- * `text-(--plass-fg)` puts two utilities of equal specificity on one element,
75
- * and which of them wins is decided by their order in the generated stylesheet
76
- * rather than by the order they were written in — so `color="danger"` on a row
77
- * would silently do nothing. Branching here is what makes only one of the two
78
- * exist.
79
- */
80
- function rowClasses(size, density, accented, className) {
81
- return cx('relative flex w-full cursor-pointer items-center select-none', accented ? 'text-(--p-accent)' : 'text-(--plass-fg)', rowPaddingClasses[density][size], rowRadiusClasses[size], gapClasses[size], controlTextLeadingClasses[size], transitionClasses, iconClasses, 'data-[highlighted]:bg-(--p-soft-hover)', 'data-[popup-open]:bg-(--p-soft)', 'data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50',
82
- // Base UI moves focus onto the highlighted row itself, so a ring here would
83
- // draw a rectangle inside the popup on every arrow press. The tint is the
84
- // focus indicator, which is what makes it the same one the mouse gets.
85
- '[outline:none]', className);
86
- }
87
- /** The fixed-width slot a check, a dot or a `startIcon` lands in. */
88
- const slotClasses = 'flex h-[1lh] w-[1.2em] shrink-0 items-center justify-center';
89
- /** The muted run of text a shortcut is set in, at the end of the row. */
90
- function shortcutClasses(size) {
91
- return cx('ms-2 shrink-0 text-(--plass-muted-fg) tabular-nums', metaTextClasses[size]);
92
- }
93
- /**
94
- * The label, and the description under it when there is one.
95
- *
96
- * `min-w-0` so a long label truncates rather than pushing the shortcut off the
97
- * end of a popup that has already been positioned.
98
- */
99
- function RowBody({ children, description, size }) {
100
- if (!hasContent(description)) {
101
- return _jsx("span", { className: "min-w-0 flex-1 truncate text-start", children: children });
102
- }
103
- return (_jsxs("span", { className: "flex min-w-0 flex-1 flex-col text-start", children: [_jsx("span", { className: "truncate", children: children }), _jsx("span", { className: cx('truncate text-(--plass-muted-fg)', metaTextClasses[size]), children: description })] }));
104
- }
105
- /* ---------------------------------------------------------------------------
106
- * The parts
107
- * ------------------------------------------------------------------------- */
108
- /**
109
- * One row of a menu.
110
- *
111
- * Renders a real `<a>` when it is given an `href` and Base UI's own item
112
- * otherwise — the same split `PlListItem` makes, for the same reason. A menu of
113
- * links that are not links cannot be opened in a new tab, cannot be copied, and
114
- * tells a screen reader the wrong thing about every one of them.
115
- */
116
- export function PlMenuItem({ onClick, href, target, startIcon, endIcon, shortcut, description, color, closeOnClick = true, disabled = false, label, children, className, style }) {
117
- const { size, density } = React.useContext(MenuContext);
118
- const body = (_jsxs(_Fragment, { children: [hasContent(startIcon) ? (_jsx("span", { className: cx(slotClasses, 'text-(--plass-muted-fg)'), children: startIcon })) : null, _jsx(RowBody, { description: description, size: size, children: children }), hasContent(endIcon) ? (_jsx("span", { className: cx(slotClasses, 'text-(--plass-muted-fg)'), children: endIcon })) : null, hasContent(shortcut) ? _jsx("span", { className: shortcutClasses(size), children: shortcut }) : null] }));
119
- // A row can name its own family — `color="danger"` on the one that deletes —
120
- // and the slots are re-declared on the row so the tint, the hairline and the
121
- // text all turn over together rather than one of them staying indigo.
122
- const slots = color ? surfaceSlots(color, 0) : undefined;
123
- const rowStyle = slots || style ? { ...slots, ...style } : undefined;
124
- if (href !== undefined) {
125
- return (_jsx(BaseUIMenu.LinkItem, { href: href, target: target, label: label, closeOnClick: closeOnClick, onClick: onClick, className: rowClasses(size, density, Boolean(color), className), style: rowStyle, children: body }));
126
- }
127
- return (_jsx(BaseUIMenu.Item, { disabled: disabled, label: label, closeOnClick: closeOnClick, onClick: onClick, className: rowClasses(size, density, Boolean(color), className), style: rowStyle, children: body }));
128
- }
129
- /** A row that ticks. The tick lands in the same slot a `startIcon` would. */
130
- export function PlMenuCheckboxItem({ checked, defaultChecked, onCheckedChange, endIcon, shortcut, description, color, closeOnClick = false, disabled = false, label, children, className, style }) {
131
- const { size, density } = React.useContext(MenuContext);
132
- const slots = color ? surfaceSlots(color, 0) : undefined;
133
- return (_jsxs(BaseUIMenu.CheckboxItem, { checked: checked, defaultChecked: defaultChecked, onCheckedChange: (next) => onCheckedChange?.(next), disabled: disabled, label: label, closeOnClick: closeOnClick, className: rowClasses(size, density, Boolean(color), className), style: slots || style ? { ...slots, ...style } : undefined, children: [_jsx("span", { className: cx(slotClasses, 'text-(--p-accent)'), children: _jsx(BaseUIMenu.CheckboxItemIndicator, { className: "flex items-center justify-center", children: _jsx(CheckIcon, {}) }) }), _jsx(RowBody, { description: description, size: size, children: children }), hasContent(endIcon) ? (_jsx("span", { className: cx(slotClasses, 'text-(--plass-muted-fg)'), children: endIcon })) : null, hasContent(shortcut) ? _jsx("span", { className: shortcutClasses(size), children: shortcut }) : null] }));
134
- }
135
- /** One choice out of a set. Wraps the rows that make up the set. */
136
- export function PlMenuRadioGroup({ value, defaultValue, onValueChange, disabled = false, children, className }) {
137
- return (_jsx(BaseUIMenu.RadioGroup, { value: value, defaultValue: defaultValue, onValueChange: (next) => onValueChange?.(next), disabled: disabled, className: className, children: children }));
138
- }
139
- /**
140
- * A row inside a `PlMenuRadioGroup`.
141
- *
142
- * Marked with a dot rather than a tick, which is the same distinction
143
- * `PlCheckbox` and `PlRadioGroup` make everywhere else: a tick says "and", a dot
144
- * says "instead of".
145
- */
146
- export function PlMenuRadioItem({ value, endIcon, shortcut, description, color, closeOnClick = false, disabled = false, label, children, className, style }) {
147
- const { size, density } = React.useContext(MenuContext);
148
- const slots = color ? surfaceSlots(color, 0) : undefined;
149
- return (_jsxs(BaseUIMenu.RadioItem, { value: value, disabled: disabled, label: label, closeOnClick: closeOnClick, className: rowClasses(size, density, Boolean(color), className), style: slots || style ? { ...slots, ...style } : undefined, children: [_jsx("span", { className: cx(slotClasses, 'text-(--p-accent)'), children: _jsx(BaseUIMenu.RadioItemIndicator, { className: "flex items-center justify-center", children: _jsx(DotIcon, {}) }) }), _jsx(RowBody, { description: description, size: size, children: children }), hasContent(endIcon) ? (_jsx("span", { className: cx(slotClasses, 'text-(--plass-muted-fg)'), children: endIcon })) : null, hasContent(shortcut) ? _jsx("span", { className: shortcutClasses(size), children: shortcut }) : null] }));
150
- }
151
- /** A named run of rows. The label is a heading, not a row — it cannot be picked. */
152
- export function PlMenuGroup({ label, children, className }) {
153
- const { size, density } = React.useContext(MenuContext);
154
- return (_jsxs(BaseUIMenu.Group, { className: className, children: [hasContent(label) ? (_jsx(BaseUIMenu.GroupLabel, { className: cx(rowPaddingClasses[density][size], metaTextClasses[size], 'font-semibold tracking-wide text-(--plass-muted-fg) uppercase'), children: label })) : null, children] }));
155
- }
156
- /** The hairline between two runs of rows. */
157
- export function PlMenuSeparator({ className, ...props }) {
158
- return (_jsx(BaseUIMenu.Separator, { className: cx('-mx-1 my-1 h-px bg-(--plass-divider)', className), ...props }));
159
- }
160
- /**
161
- * A menu inside a menu.
162
- *
163
- * The row that opens it is the same row every other item is, wearing a chevron —
164
- * and it opens on hover, on <kbd>Enter</kbd> and on the arrow key that points at
165
- * it, all of which is Base UI's. What is here is the surface and the glyph.
166
- *
167
- * Nesting is unlimited: a `PlMenuSubmenu` renders its children inside a popup
168
- * that is itself a menu, so a submenu of a submenu needs no different component.
169
- */
170
- export function PlMenuSubmenu({ label, startIcon, disabled = false, side = 'right', sideOffset = 4, children, className, style }) {
171
- const { size, density, color } = React.useContext(MenuContext);
172
- return (_jsxs(BaseUIMenu.SubmenuRoot, { children: [_jsxs(BaseUIMenu.SubmenuTrigger, { disabled: disabled, className: rowClasses(size, density, false), children: [hasContent(startIcon) ? (_jsx("span", { className: cx(slotClasses, 'text-(--plass-muted-fg)'), children: startIcon })) : null, _jsx("span", { className: "min-w-0 flex-1 truncate text-start", children: label }), _jsx("span", { className: cx(slotClasses, 'text-(--plass-muted-fg) -rotate-90'), children: _jsx(ChevronIcon, {}) })] }), _jsx(BaseUIMenu.Portal, { children: _jsx(BaseUIMenu.Positioner, { className: "plass-portal z-50 [outline:none]", side: side, sideOffset: sideOffset, align: "start", children: _jsx(BaseUIMenu.Popup, { className: cx(popupClasses, radiusClasses[size], controlTextLeadingClasses[size], className), style: { ...surfaceSlots(color, 3), ...style }, children: children }) }) })] }));
173
- }
174
- /**
175
- * A list of actions that appears when something is pressed.
176
- *
177
- * Everything that makes a menu a menu rather than a floating list of `<div>`s is
178
- * Base UI's: roving focus with the arrow keys, <kbd>Home</kbd> and
179
- * <kbd>End</kbd>, typeahead, <kbd>Esc</kbd>, closing on an outside click,
180
- * restoring focus to the trigger, submenus opening on hover with the safe
181
- * triangle so a diagonal reach does not close them, and the `menu` / `menuitem`
182
- * roles that make any of it mean something to a screen reader. What is here is
183
- * the surface, the ladders and the row layout.
184
- *
185
- * The rows are **composed rather than passed as data** — the opposite of
186
- * `PlSelect`, and deliberately. A select's options are values from a list a
187
- * caller already has; a menu's rows are *code*, each one a different handler, a
188
- * different icon, sometimes a submenu. Data would mean an `items` type with a
189
- * variant for every shape a row can take, which is a component tree spelled as a
190
- * discriminated union.
191
- */
192
- export function PlMenu({ size = 'md', color = 'primary', density = 'default', trigger, open, defaultOpen, onOpenChange, side = 'bottom', align = 'start', sideOffset = 6, modal = true, openOnHover = false, loopFocus = true, disabled = false, className, style, children }) {
193
- const context = React.useMemo(() => ({ size, color, density }), [size, color, density]);
194
- return (_jsx(MenuContext.Provider, { value: context, children: _jsxs(BaseUIMenu.Root, { open: open, defaultOpen: defaultOpen, onOpenChange: (next) => onOpenChange?.(next), modal: modal, loopFocus: loopFocus, disabled: disabled, children: [trigger ? (_jsx(BaseUIMenu.Trigger, { render: trigger, openOnHover: openOnHover, disabled: disabled })) : null, _jsx(BaseUIMenu.Portal, { children: _jsx(BaseUIMenu.Positioner, { className: "plass-portal z-50 [outline:none]", side: side, align: align, sideOffset: sideOffset, children: _jsx(BaseUIMenu.Popup, { className: cx(popupClasses, radiusClasses[size], controlTextLeadingClasses[size], className), style: { ...surfaceSlots(color, 3), ...style }, children: children }) }) })] }) }));
195
- }
196
- /**
197
- * The same menu, opened by a right-click or a long press instead of by a button.
198
- *
199
- * It takes the rows as `content` and the area as `children`, which is
200
- * `PlTooltip`'s shape rather than `PlMenu`'s — because here the trigger is not
201
- * one element you hand over, it is a region of the page, and the region is the
202
- * thing being wrapped. Base UI positions the popup at the pointer rather than
203
- * against an anchor, and the long press is what makes it reachable on a touch
204
- * screen at all.
205
- */
206
- export function PlContextMenu({ size = 'md', color = 'primary', density = 'default', content, children, open, defaultOpen, onOpenChange, loopFocus = true, disabled = false, className, style }) {
207
- const context = React.useMemo(() => ({ size, color, density }), [size, color, density]);
208
- return (_jsx(MenuContext.Provider, { value: context, children: _jsxs(BaseUIContextMenu.Root, { open: open, defaultOpen: defaultOpen, onOpenChange: (next) => onOpenChange?.(next), loopFocus: loopFocus, disabled: disabled, children: [_jsx(BaseUIContextMenu.Trigger, { children: children }), _jsx(BaseUIContextMenu.Portal, { children: _jsx(BaseUIContextMenu.Positioner, { className: "plass-portal z-50 [outline:none]", children: _jsx(BaseUIContextMenu.Popup, { className: cx(popupClasses, radiusClasses[size], controlTextLeadingClasses[size], className), style: { ...surfaceSlots(color, 3), ...style }, children: content }) }) })] }) }));
209
- }
1
+ "use client";import{jsx as e,jsxs as s,Fragment as l}from"react/jsx-runtime";import*as n from"react";import{Menu as a}from"@base-ui/react/menu";import{ContextMenu as t}from"@base-ui/react/context-menu";import{MenuContext as o}from"../../internal/menu.js";import{CheckIcon as r,ChevronIcon as i,DotIcon as c}from"../../internal/icons.js";import{controlTextLeadingClasses as d,cx as p,gapClasses as u,glassClasses as m,hasContent as h,iconClasses as x,metaTextClasses as f,radiusClasses as g,surfaceSlots as y,transitionClasses as b}from"../../internal/styles.js";const C=/* @__PURE__ */[m,"max-h-[min(24rem,var(--available-height))] min-w-40 overflow-y-auto overscroll-contain","border bg-(--plass-glass-press) p-1","[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(" "),N={default:{xs:"px-1.5 py-0.5",sm:"px-2 py-1",md:"px-2.5 py-1.5",lg:"px-3 py-2",xl:"px-3.5 py-2.5"},compact:{xs:"px-1 py-0.5",sm:"px-1.5 py-0.5",md:"px-2 py-1",lg:"px-2.5 py-1",xl:"px-3 py-1.5"}},v={xs:g.xs,sm:g.xs,md:g.sm,lg:g.sm,xl:g.md};function rowClasses(e,s,l,n){return p("relative flex w-full cursor-pointer items-center select-none",l?"text-(--p-accent)":"text-(--plass-fg)",N[s][e],v[e],u[e],d[e],b,x,"data-[highlighted]:bg-(--p-soft-hover)","data-[popup-open]:bg-(--p-soft)","data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50","[outline:none]",n)}const k="flex h-[1lh] w-[1.2em] shrink-0 items-center justify-center";function shortcutClasses(e){return p("ms-2 shrink-0 text-(--plass-muted-fg) tabular-nums",f[e])}function RowBody({children:l,description:n,size:a}){return h(n)?s("span",{className:"flex min-w-0 flex-1 flex-col text-start",children:[e("span",{className:"truncate",children:l}),e("span",{className:p("truncate text-(--plass-muted-fg)",f[a]),children:n})]}):e("span",{className:"min-w-0 flex-1 truncate text-start",children:l})}export function PlMenuItem({onClick:t,href:r,target:i,startIcon:c,endIcon:d,shortcut:u,description:m,color:x,closeOnClick:f=!0,disabled:g=!1,label:b,children:C,className:N,style:v}){const{size:w,density:O}=n.useContext(o),P=s(l,{children:[h(c)?e("span",{className:p(k,"text-(--plass-muted-fg)"),children:c}):null,e(RowBody,{description:m,size:w,children:C}),h(d)?e("span",{className:p(k,"text-(--plass-muted-fg)"),children:d}):null,h(u)?e("span",{className:shortcutClasses(w),children:u}):null]}),z=x?y(x,0):void 0,I=z||v?{...z,...v}:void 0;return void 0!==r?e(a.LinkItem,{href:r,target:i,label:b,closeOnClick:f,onClick:t,className:rowClasses(w,O,Boolean(x),N),style:I,children:P}):e(a.Item,{disabled:g,label:b,closeOnClick:f,onClick:t,className:rowClasses(w,O,Boolean(x),N),style:I,children:P})}export function PlMenuCheckboxItem({checked:l,defaultChecked:t,onCheckedChange:i,endIcon:c,shortcut:d,description:u,color:m,closeOnClick:x=!1,disabled:f=!1,label:g,children:b,className:C,style:N}){const{size:v,density:w}=n.useContext(o),O=m?y(m,0):void 0;return s(a.CheckboxItem,{checked:l,defaultChecked:t,onCheckedChange:e=>i?.(e),disabled:f,label:g,closeOnClick:x,className:rowClasses(v,w,Boolean(m),C),style:O||N?{...O,...N}:void 0,children:[e("span",{className:p(k,"text-(--p-accent)"),children:e(a.CheckboxItemIndicator,{className:"flex items-center justify-center",children:e(r,{})})}),e(RowBody,{description:u,size:v,children:b}),h(c)?e("span",{className:p(k,"text-(--plass-muted-fg)"),children:c}):null,h(d)?e("span",{className:shortcutClasses(v),children:d}):null]})}export function PlMenuRadioGroup({value:s,defaultValue:l,onValueChange:n,disabled:t=!1,children:o,className:r}){return e(a.RadioGroup,{value:s,defaultValue:l,onValueChange:e=>n?.(e),disabled:t,className:r,children:o})}export function PlMenuRadioItem({value:l,endIcon:t,shortcut:r,description:i,color:d,closeOnClick:u=!1,disabled:m=!1,label:x,children:f,className:g,style:b}){const{size:C,density:N}=n.useContext(o),v=d?y(d,0):void 0;return s(a.RadioItem,{value:l,disabled:m,label:x,closeOnClick:u,className:rowClasses(C,N,Boolean(d),g),style:v||b?{...v,...b}:void 0,children:[e("span",{className:p(k,"text-(--p-accent)"),children:e(a.RadioItemIndicator,{className:"flex items-center justify-center",children:e(c,{})})}),e(RowBody,{description:i,size:C,children:f}),h(t)?e("span",{className:p(k,"text-(--plass-muted-fg)"),children:t}):null,h(r)?e("span",{className:shortcutClasses(C),children:r}):null]})}export function PlMenuGroup({label:l,children:t,className:r}){const{size:i,density:c}=n.useContext(o);return s(a.Group,{className:r,children:[h(l)?e(a.GroupLabel,{className:p(N[c][i],f[i],"font-semibold tracking-wide text-(--plass-muted-fg) uppercase"),children:l}):null,t]})}export function PlMenuSeparator({className:s,...l}){return e(a.Separator,{className:p("-mx-1 my-1 h-px bg-(--plass-divider)",s),...l})}export function PlMenuSubmenu({label:l,startIcon:t,disabled:r=!1,side:c="right",sideOffset:u=4,children:m,className:x,style:f}){const{size:b,density:N,color:v}=n.useContext(o);return s(a.SubmenuRoot,{children:[s(a.SubmenuTrigger,{disabled:r,className:rowClasses(b,N,!1),children:[h(t)?e("span",{className:p(k,"text-(--plass-muted-fg)"),children:t}):null,e("span",{className:"min-w-0 flex-1 truncate text-start",children:l}),e("span",{className:p(k,"text-(--plass-muted-fg) -rotate-90"),children:e(i,{})})]}),e(a.Portal,{children:e(a.Positioner,{className:"plass-portal z-50 [outline:none]",side:c,sideOffset:u,align:"start",children:e(a.Popup,{className:p(C,g[b],d[b],x),style:{...y(v,3),...f},children:m})})})]})}export function PlMenu({size:l="md",color:t="primary",density:r="default",trigger:i,open:c,defaultOpen:u,onOpenChange:m,side:h="bottom",align:x="start",sideOffset:f=6,modal:b=!0,openOnHover:N=!1,loopFocus:v=!0,disabled:k=!1,className:w,style:O,children:P}){const z=n.useMemo(()=>({size:l,color:t,density:r}),[l,t,r]);return e(o.Provider,{value:z,children:s(a.Root,{open:c,defaultOpen:u,onOpenChange:e=>m?.(e),modal:b,loopFocus:v,disabled:k,children:[i?e(a.Trigger,{render:i,openOnHover:N,disabled:k}):null,e(a.Portal,{children:e(a.Positioner,{className:"plass-portal z-50 [outline:none]",side:h,align:x,sideOffset:f,children:e(a.Popup,{className:p(C,g[l],d[l],w),style:{...y(t,3),...O},children:P})})})]})})}export function PlContextMenu({size:l="md",color:a="primary",density:r="default",content:i,children:c,open:u,defaultOpen:m,onOpenChange:h,loopFocus:x=!0,disabled:f=!1,className:b,style:N}){const v=n.useMemo(()=>({size:l,color:a,density:r}),[l,a,r]);return e(o.Provider,{value:v,children:s(t.Root,{open:u,defaultOpen:m,onOpenChange:e=>h?.(e),loopFocus:x,disabled:f,children:[e(t.Trigger,{children:c}),e(t.Portal,{children:e(t.Positioner,{className:"plass-portal z-50 [outline:none]",children:e(t.Popup,{className:p(C,g[l],d[l],b),style:{...y(a,3),...N},children:i})})})]})})}
@@ -1 +1 @@
1
- export { PlContextMenu, PlMenu, PlMenuCheckboxItem, PlMenuGroup, PlMenuItem, PlMenuRadioGroup, PlMenuRadioItem, PlMenuSeparator, PlMenuSubmenu } from './PlMenu.js';
1
+ export{PlContextMenu,PlMenu,PlMenuCheckboxItem,PlMenuGroup,PlMenuItem,PlMenuRadioGroup,PlMenuRadioItem,PlMenuSeparator,PlMenuSubmenu}from"./PlMenu.js";
@@ -1,150 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Dialog as BaseUIDialog } from '@base-ui/react/dialog';
3
- import { CloseIcon } from '../../internal/icons.js';
4
- import { focusRingClasses, glassClasses, hasContent, metaTextClasses, radiusClasses, sheetBodyClasses, sheetHeaderGapClasses, sheetLineClasses, sheetPaddingXClasses, sheetPaddingYClasses, sheetSectionGapClasses, sheetTitleClasses, surfaceSlots } from '../../internal/styles.js';
5
- /**
6
- * How wide the sheet is allowed to get, per `size`.
7
- *
8
- * `size` and the width are one axis here rather than two. A second five-value
9
- * scale spelled `maxWidth` would be a second spelling of an idea the library
10
- * already has a word for, and the case it exists for — "small type, wide sheet"
11
- * — is what the `width` escape hatch is.
12
- *
13
- * The steps are wider apart than the control ladder because they answer a
14
- * different question: not how big is this thing, but how long a line of text is
15
- * comfortable inside it.
16
- */
17
- const maxWidthClasses = {
18
- xs: 'max-w-80',
19
- sm: 'max-w-96',
20
- md: 'max-w-lg',
21
- lg: 'max-w-2xl',
22
- xl: 'max-w-4xl'
23
- };
24
- /**
25
- * The sheet, and — with the PlSelect popup — one of the two surfaces in the
26
- * library that is *supposed* to float. So unlike everything else it carries a
27
- * shadow by default, at level 3.
28
- *
29
- * It is the glass at its most opaque, because what is behind it is arbitrary:
30
- * a modal floats over whatever the page happens to be, and a 62%-translucent
31
- * pane over a photograph is a pane you read the photograph through.
32
- *
33
- * There is no `elevation` prop for the same reason there is no `variant`: a
34
- * modal that could be told to sit flat on the page would be a modal that could
35
- * be told to stop being one.
36
- */
37
- const popupClasses = /* @__PURE__ */ [
38
- glassClasses,
39
- 'relative flex w-full flex-col overflow-hidden',
40
- 'border text-(--plass-fg) bg-(--plass-glass-press)',
41
- '[border-color:var(--plass-glass-line)]',
42
- '[box-shadow:var(--plass-shadow-4),var(--plass-gloss-glass)]',
43
- '[outline:none]',
44
- // Opacity only. A modal that scales or slides in drags its own text across
45
- // the screen for 200ms, which is the exact thing the house style is against —
46
- // and unlike a control, this one is full of text.
47
- '[transition:opacity_var(--plass-duration)_var(--plass-ease)]',
48
- 'data-[starting-style]:opacity-0 data-[ending-style]:opacity-0'
49
- ].join(' ');
50
- const backdropClasses = /* @__PURE__ */ [
51
- 'fixed inset-0 z-50 bg-(--plass-scrim)',
52
- '[backdrop-filter:blur(2px)] [-webkit-backdrop-filter:blur(2px)]',
53
- '[transition:opacity_var(--plass-duration)_var(--plass-ease)]',
54
- 'data-[starting-style]:opacity-0 data-[ending-style]:opacity-0'
55
- ].join(' ');
56
- /**
57
- * Closes the modal it is inside.
58
- *
59
- * Exported because an uncontrolled modal has no `setOpen` for its Cancel button
60
- * to call, and the alternative — making every modal controlled — is a piece of
61
- * state per modal that exists only to answer a button.
62
- *
63
- * `render` is Base UI's own escape hatch, so a real Plass button dismisses:
64
- * `<PlModalClose render={<PlButton variant="ghost">Cancel</PlButton>} />`.
65
- */
66
- export const PlModalClose = BaseUIDialog.Close;
67
- /**
68
- * A sheet that takes the page away until it is answered.
69
- *
70
- * The sections are props rather than compound sub-components, exactly as they
71
- * are on PlCard: the arrangement of a modal is fixed — heading, description,
72
- * body, actions — and what a caller wants to decide is what goes in each slot.
73
- * Base UI owns everything hard about it: the focus trap, the scroll lock, the
74
- * `aria-labelledby` / `aria-describedby` wiring, restoring focus to the trigger,
75
- * and the inert page behind.
76
- *
77
- * What is left here is the surface, the width ladder and the scroll behaviour —
78
- * the header and the actions stay put while only the body scrolls, which is why
79
- * `dividers` matters more here than on a PlCard.
80
- */
81
- export function PlModal({ size = 'md', color = 'primary', density = 'default', open, defaultOpen, onOpenChange, trigger, title, description, actions, dividers = false, showClose = true, closeLabel = 'Close', width, fullWidth = true, fullScreen = false, modal = true, dismissible = true, className, style, children, ...props }) {
82
- const insetX = sheetPaddingXClasses[density][size];
83
- const insetY = sheetPaddingYClasses[density][size];
84
- // With dividers the lines have to reach both edges, so the sheet gives up its
85
- // padding and every section takes it on instead — the same trade PlCard makes.
86
- const sectionClasses = dividers ? `${insetX} ${insetY}` : insetX;
87
- const hasHeader = hasContent(title) || hasContent(description);
88
- const hasActions = hasContent(actions);
89
- return (_jsxs(BaseUIDialog.Root, { open: open, defaultOpen: defaultOpen, modal: modal, disablePointerDismissal: !dismissible, onOpenChange: (next, details) => {
90
- // `disablePointerDismissal` covers the click outside; Escape has no prop
91
- // of its own, so it is cancelled here by the reason it arrives with.
92
- if (!dismissible && !next && details.reason === 'escape-key') {
93
- details.cancel();
94
- return;
95
- }
96
- onOpenChange?.(next);
97
- }, children: [trigger ? _jsx(BaseUIDialog.Trigger, { render: trigger }) : null, _jsxs(BaseUIDialog.Portal, { children: [_jsx(BaseUIDialog.Backdrop, { className: `plass-portal ${backdropClasses}` }), _jsx(BaseUIDialog.Viewport, { className: [
98
- 'plass-portal fixed inset-0 z-50 flex justify-center',
99
- // `items-center` alone would clip the top of a modal taller than the
100
- // viewport, because a centred flex item cannot scroll past its own
101
- // container's start edge. The popup caps its height instead and
102
- // scrolls its body, so the header and the actions stay put.
103
- fullScreen ? 'items-stretch' : 'items-center p-4'
104
- ].join(' '), children: _jsxs(BaseUIDialog.Popup, { className: [
105
- popupClasses,
106
- sheetBodyClasses[size],
107
- fullScreen
108
- ? 'h-full max-w-none rounded-none'
109
- : `max-h-full ${radiusClasses[size]} ${width === undefined ? maxWidthClasses[size] : ''}`,
110
- !fullScreen && !fullWidth ? 'w-auto' : '',
111
- dividers ? '' : `${insetY} ${sheetSectionGapClasses[size]}`,
112
- className ?? ''
113
- ]
114
- .filter(Boolean)
115
- .join(' '), style: {
116
- ...surfaceSlots(color, 3),
117
- ...(width === undefined
118
- ? null
119
- : { maxWidth: typeof width === 'number' ? `${width}px` : width }),
120
- ...style
121
- }, ...props, children: [hasHeader || showClose ? (_jsxs("div", { className: `flex shrink-0 items-start gap-3 ${sectionClasses}`, children: [_jsxs("div", { className: `flex min-w-0 flex-1 flex-col ${sheetHeaderGapClasses[size]}`, children: [hasContent(title) ? (_jsx(BaseUIDialog.Title, { className: `m-0 font-semibold ${sheetTitleClasses[size]}`, children: title })) : null, hasContent(description) ? (_jsx(BaseUIDialog.Description, { className: `m-0 text-(--plass-muted-fg) ${metaTextClasses[size]}`, children: description })) : null] }), showClose ? (_jsx(BaseUIDialog.Close, { "aria-label": closeLabel, className: [
122
- 'flex size-[1.6em] shrink-0 cursor-pointer items-center justify-center',
123
- 'rounded-full text-(--plass-muted-fg)',
124
- '[&_svg]:size-[1.1em] [&_svg]:shrink-0',
125
- '[transition:background-color_var(--plass-duration)_var(--plass-ease),color_var(--plass-duration)_var(--plass-ease)]',
126
- 'hover:bg-(--p-soft) hover:text-(--plass-fg)',
127
- focusRingClasses
128
- ].join(' '), children: _jsx(CloseIcon, {}) })) : null] })) : null, hasContent(children) ? (_jsx("div", { className: [
129
- 'min-h-0 flex-1 overflow-y-auto overscroll-contain',
130
- sectionClasses,
131
- dividers && (hasHeader || showClose) ? sheetLineClasses : '',
132
- // A scroll container clips at its padding box, and a focus
133
- // ring is drawn 2px outside the control that owns it — so a
134
- // field at the top or bottom of an unruled body would have its
135
- // ring sliced off. The padding is room for the ring and the
136
- // negative margin hands the space straight back, so nothing on
137
- // the sheet moves. Only without `dividers`: with them the body
138
- // already carries `insetY`, and pulling it up would drag the
139
- // rule into the section above.
140
- dividers ? '' : '-my-1 py-1'
141
- ]
142
- .filter(Boolean)
143
- .join(' '), children: children })) : null, hasActions ? (_jsx("div", { className: [
144
- 'flex shrink-0 flex-wrap items-center justify-end gap-2',
145
- sectionClasses,
146
- dividers ? sheetLineClasses : ''
147
- ]
148
- .filter(Boolean)
149
- .join(' '), children: actions })) : null] }) })] })] }));
150
- }
1
+ "use client";import{jsx as e,jsxs as l}from"react/jsx-runtime";import{Dialog as s}from"@base-ui/react/dialog";import{CloseIcon as a}from"../../internal/icons.js";import{focusRingClasses as i,glassClasses as o,hasContent as r,metaTextClasses as t,radiusClasses as n,sheetBodyClasses as d,sheetHeaderGapClasses as c,sheetLineClasses as p,sheetPaddingXClasses as m,sheetPaddingYClasses as f,sheetSectionGapClasses as u,sheetTitleClasses as x,surfaceSlots as h}from"../../internal/styles.js";const g={xs:"max-w-80",sm:"max-w-96",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl"},v=/* @__PURE__ */[o,"relative flex w-full flex-col overflow-hidden","border text-(--plass-fg) bg-(--plass-glass-press)","[border-color:var(--plass-glass-line)]","[box-shadow:var(--plass-shadow-4),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(" "),y=/* @__PURE__ */["fixed inset-0 z-50 bg-(--plass-scrim)","[backdrop-filter:blur(2px)] [-webkit-backdrop-filter:blur(2px)]","[transition:opacity_var(--plass-duration)_var(--plass-ease)]","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0"].join(" ");export const PlModalClose=s.Close;export function PlModal({size:o="md",color:b="primary",density:w="default",open:j,defaultOpen:$,onOpenChange:N,trigger:k,title:_,description:C,actions:z,dividers:P=!1,showClose:B=!0,closeLabel:O="Close",width:D,fullWidth:M=!0,fullScreen:T=!1,modal:W=!0,dismissible:L=!0,className:R,style:S,children:V,...q}){const A=m[w][o],E=f[w][o],F=P?`${A} ${E}`:A,G=r(_)||r(C),H=r(z);return l(s.Root,{open:j,defaultOpen:$,modal:W,disablePointerDismissal:!L,onOpenChange:(e,l)=>{L||e||"escape-key"!==l.reason?N?.(e):l.cancel()},children:[k?e(s.Trigger,{render:k}):null,l(s.Portal,{children:[e(s.Backdrop,{className:`plass-portal ${y}`}),e(s.Viewport,{className:["plass-portal fixed inset-0 z-50 flex justify-center",T?"items-stretch":"items-center p-4"].join(" "),children:l(s.Popup,{className:[v,d[o],T?"h-full max-w-none rounded-none":`max-h-full ${n[o]} ${void 0===D?g[o]:""}`,T||M?"":"w-auto",P?"":`${E} ${u[o]}`,R??""].filter(Boolean).join(" "),style:{...h(b,3),...void 0===D?null:{maxWidth:"number"==typeof D?`${D}px`:D},...S},...q,children:[G||B?l("div",{className:`flex shrink-0 items-start gap-3 ${F}`,children:[l("div",{className:`flex min-w-0 flex-1 flex-col ${c[o]}`,children:[r(_)?e(s.Title,{className:`m-0 font-semibold ${x[o]}`,children:_}):null,r(C)?e(s.Description,{className:`m-0 text-(--plass-muted-fg) ${t[o]}`,children:C}):null]}),B?e(s.Close,{"aria-label":O,className:["flex size-[1.6em] shrink-0 cursor-pointer items-center justify-center","rounded-full text-(--plass-muted-fg)","[&_svg]:size-[1.1em] [&_svg]:shrink-0","[transition:background-color_var(--plass-duration)_var(--plass-ease),color_var(--plass-duration)_var(--plass-ease)]","hover:bg-(--p-soft) hover:text-(--plass-fg)",i].join(" "),children:e(a,{})}):null]}):null,r(V)?e("div",{className:["min-h-0 flex-1 overflow-y-auto overscroll-contain",F,P&&(G||B)?p:"",P?"":"-my-1 py-1"].filter(Boolean).join(" "),children:V}):null,H?e("div",{className:["flex shrink-0 flex-wrap items-center justify-end gap-2",F,P?p:""].filter(Boolean).join(" "),children:z}):null]})})]})]})}
@@ -1 +1 @@
1
- export { PlModal, PlModalClose } from './PlModal.js';
1
+ export{PlModal,PlModalClose}from"./PlModal.js";
@@ -1,111 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { NumberField as BaseUINumberField } from '@base-ui/react/number-field';
3
- import { Field } from '@base-ui/react/field';
4
- import { MinusIcon, PlusIcon } from '../../internal/icons.js';
5
- import { controlHeightClasses, controlTextLeadingClasses, disabledClasses, fieldReadOnlyClasses, fieldRestClasses, focusRingClasses, focusWithinRingClasses, gapClasses, hasContent, iconClasses, metaTextClasses, paddingXClasses, radiusClasses, stackGapClasses, surfaceSlots, transitionClasses } from '../../internal/styles.js';
6
- /** The shell is a `PlTextField`'s, to the pixel — see `fieldRestClasses`. */
7
- const shellBaseClasses = /* @__PURE__ */ [
8
- 'group relative flex w-full cursor-text items-center',
9
- '[-webkit-tap-highlight-color:transparent]',
10
- transitionClasses,
11
- 'focus-within:[transition-duration:0ms]',
12
- focusWithinRingClasses,
13
- iconClasses
14
- ].join(' ');
15
- /**
16
- * A stepper. Square, tracking the text rather than the control, so the same
17
- * button works at every step of the scale without a table of its own.
18
- *
19
- * No `transform` on it, the same rule every control in the library keeps: what
20
- * moves under the finger is the tint, not the button.
21
- */
22
- const stepperClasses = /* @__PURE__ */ [
23
- 'inline-flex size-[1.7em] shrink-0 cursor-pointer items-center justify-center',
24
- 'rounded-(--plass-radius-xs) text-(--plass-muted-fg) select-none',
25
- '[&_svg]:size-[0.9em] [&_svg]:shrink-0',
26
- '[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]',
27
- '[transition:background-color_var(--plass-duration)_var(--plass-ease),color_var(--plass-duration)_var(--plass-ease),opacity_var(--plass-duration)_var(--plass-ease)]',
28
- 'active:[transition-duration:0ms]',
29
- 'hover:bg-(--p-soft) hover:text-(--p-accent)',
30
- 'active:bg-(--p-soft-press)',
31
- focusRingClasses,
32
- // A stepper that has run into `min` goes out like everything else that is
33
- // unavailable here: the page shows through it.
34
- 'disabled:cursor-not-allowed disabled:bg-transparent disabled:opacity-40'
35
- ].join(' ');
36
- /**
37
- * A field that only holds a number.
38
- *
39
- * The shell is a `PlTextField`'s, to the pixel, because a form where the
40
- * quantity box is a different height or radius from the boxes around it is a
41
- * form that looks assembled rather than designed. What is added on top is a real
42
- * numeric control: arrow keys and the steppers move by `step` (Shift for
43
- * `largeStep`, Alt for `smallStep`), the value clamps to `min`/`max`, and
44
- * `format` writes it as currency or a percentage while `value` stays a plain
45
- * number.
46
- *
47
- * Base UI owns the hard parts — parsing what was typed against the locale,
48
- * clamping, the press-and-hold repeat on the steppers, and the hidden input that
49
- * submits with a form.
50
- */
51
- export function PlNumberField({ variant = 'glass', size = 'md', color = 'primary', density = 'default', elevation = 0, value, defaultValue, onValueChange, onValueCommitted, min, max, step, largeStep, smallStep, snapOnStep, allowWheelScrub = false, format, locale, steppers = 'end', incrementLabel = 'Increase', decrementLabel = 'Decrease', label, description, error, invalid, startIcon, endIcon, fullWidth = false, disabled = false, readOnly = false, required = false, name, placeholder, id, className, style, ...props }) {
52
- const hasError = hasContent(error);
53
- const isInvalid = invalid ?? hasError;
54
- // Invalid re-points the whole slot family at `danger`, so the edge, the ring,
55
- // the caret and the message all turn over together.
56
- const family = isInvalid ? 'danger' : color;
57
- // The steppers bring their own padding; stacking the shell's on top of them
58
- // would leave the buttons floating in the middle of a gap. The shell keeps the
59
- // padding on whichever side has no button.
60
- const padX = paddingXClasses[density][size];
61
- const insetClasses = {
62
- end: `${padX} pe-1`,
63
- split: 'px-1',
64
- none: padX
65
- };
66
- const decrement = (_jsx(BaseUINumberField.Decrement, { "aria-label": decrementLabel, className: stepperClasses, children: _jsx(MinusIcon, {}) }));
67
- const increment = (_jsx(BaseUINumberField.Increment, { "aria-label": incrementLabel, className: stepperClasses, children: _jsx(PlusIcon, {}) }));
68
- const showSteppers = steppers !== 'none' && !readOnly;
69
- return (_jsxs(Field.Root, { disabled: disabled, invalid: isInvalid, className: [
70
- 'flex-col align-top',
71
- stackGapClasses[size],
72
- fullWidth ? 'flex w-full' : 'inline-flex',
73
- className ?? ''
74
- ]
75
- .filter(Boolean)
76
- .join(' '), style: { ...surfaceSlots(family, elevation), ...style }, ...props, children: [label ? (_jsx(Field.Label, { className: [
77
- metaTextClasses[size],
78
- 'font-medium text-(--plass-fg)',
79
- disabled ? 'opacity-50' : ''
80
- ]
81
- .filter(Boolean)
82
- .join(' '), children: label })) : null, _jsx(BaseUINumberField.Root, { id: id, name: name, className: "contents", value: value, defaultValue: defaultValue, onValueChange: (next) => onValueChange?.(next), onValueCommitted: (next) => onValueCommitted?.(next), min: min, max: max, step: step, largeStep: largeStep, smallStep: smallStep, snapOnStep: snapOnStep, allowWheelScrub: allowWheelScrub, format: format, locale: locale, disabled: disabled, readOnly: readOnly, required: required, children: _jsxs(BaseUINumberField.Group, { className: [
83
- shellBaseClasses,
84
- controlHeightClasses[size],
85
- controlTextLeadingClasses[size],
86
- radiusClasses[size],
87
- gapClasses[size],
88
- showSteppers ? insetClasses[steppers] : padX,
89
- // An if/else rather than stacked variants: two Tailwind classes of
90
- // equal specificity resolve by their order in the generated sheet.
91
- disabled
92
- ? disabledClasses[variant]
93
- : readOnly
94
- ? fieldReadOnlyClasses[variant]
95
- : fieldRestClasses[variant]
96
- ].join(' '), children: [showSteppers && steppers === 'split' ? decrement : null, startIcon ? (_jsx("span", { className: "flex h-[1lh] shrink-0 items-center text-(--plass-muted-fg)", children: startIcon })) : null, _jsx(BaseUINumberField.Input, { placeholder: placeholder, className: [
97
- 'min-w-0 flex-1 self-stretch bg-transparent [font:inherit] text-inherit',
98
- // Not `outline-none`: that utility zeroes `--tw-outline-style`, and
99
- // the shell's focus ring is drawn from the same family.
100
- '[outline:none]',
101
- 'tabular-nums',
102
- // Split steppers put the number between the two buttons, so it
103
- // belongs in the middle rather than against an edge.
104
- steppers === 'split' && showSteppers ? 'text-center' : '',
105
- 'placeholder:text-(--plass-muted-fg)',
106
- 'caret-(--p-accent) selection:bg-(--p-soft-press)',
107
- 'disabled:cursor-not-allowed'
108
- ]
109
- .filter(Boolean)
110
- .join(' ') }), endIcon ? (_jsx("span", { className: "flex h-[1lh] shrink-0 items-center text-(--plass-muted-fg)", children: endIcon })) : null, showSteppers && steppers === 'end' ? (_jsxs("span", { className: "flex shrink-0 items-center gap-0.5", children: [decrement, increment] })) : null, showSteppers && steppers === 'split' ? increment : null] }) }), description ? (_jsx(Field.Description, { className: `${metaTextClasses[size]} text-(--plass-muted-fg)`, children: description })) : null, hasError ? (_jsx(Field.Error, { match: true, className: `${metaTextClasses[size]} text-(--p-accent)`, children: error })) : null] }));
111
- }
1
+ "use client";import{jsx as e,jsxs as l}from"react/jsx-runtime";import{NumberField as a}from"@base-ui/react/number-field";import{Field as t}from"@base-ui/react/field";import{MinusIcon as s,PlusIcon as n}from"../../internal/icons.js";import{controlHeightClasses as r,controlTextLeadingClasses as i,disabledClasses as o,fieldReadOnlyClasses as c,fieldRestClasses as d,focusRingClasses as p,focusWithinRingClasses as m,gapClasses as u,hasContent as f,iconClasses as h,metaTextClasses as b,paddingXClasses as x,radiusClasses as g,stackGapClasses as v,surfaceSlots as N,transitionClasses as j}from"../../internal/styles.js";const y=/* @__PURE__ */["group relative flex w-full cursor-text items-center","[-webkit-tap-highlight-color:transparent]",j,"focus-within:[transition-duration:0ms]",m,h].join(" "),w=/* @__PURE__ */["inline-flex size-[1.7em] shrink-0 cursor-pointer items-center justify-center","rounded-(--plass-radius-xs) text-(--plass-muted-fg) select-none","[&_svg]:size-[0.9em] [&_svg]:shrink-0","[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]","[transition:background-color_var(--plass-duration)_var(--plass-ease),color_var(--plass-duration)_var(--plass-ease),opacity_var(--plass-duration)_var(--plass-ease)]","active:[transition-duration:0ms]","hover:bg-(--p-soft) hover:text-(--p-accent)","active:bg-(--p-soft-press)",p,"disabled:cursor-not-allowed disabled:bg-transparent disabled:opacity-40"].join(" ");export function PlNumberField({variant:p="glass",size:m="md",color:h="primary",density:j="default",elevation:k=0,value:S,defaultValue:_,onValueChange:V,onValueCommitted:I,min:C,max:O,step:z,largeStep:B,smallStep:D,snapOnStep:L,allowWheelScrub:W=!1,format:$,locale:q,steppers:F="end",incrementLabel:R="Increase",decrementLabel:E="Decrease",label:G,description:P,error:A,invalid:H,startIcon:J,endIcon:K,fullWidth:M=!1,disabled:Q=!1,readOnly:T=!1,required:U=!1,name:X,placeholder:Y,id:Z,className:ee,style:le,...ae}){const te=f(A),se=H??te,ne=se?"danger":h,re=x[j][m],ie={end:`${re} pe-1`,split:"px-1",none:re},oe=e(a.Decrement,{"aria-label":E,className:w,children:e(s,{})}),ce=e(a.Increment,{"aria-label":R,className:w,children:e(n,{})}),de="none"!==F&&!T;return l(t.Root,{disabled:Q,invalid:se,className:["flex-col align-top",v[m],M?"flex w-full":"inline-flex",ee??""].filter(Boolean).join(" "),style:{...N(ne,k),...le},...ae,children:[G?e(t.Label,{className:[b[m],"font-medium text-(--plass-fg)",Q?"opacity-50":""].filter(Boolean).join(" "),children:G}):null,e(a.Root,{id:Z,name:X,className:"contents",value:S,defaultValue:_,onValueChange:e=>V?.(e),onValueCommitted:e=>I?.(e),min:C,max:O,step:z,largeStep:B,smallStep:D,snapOnStep:L,allowWheelScrub:W,format:$,locale:q,disabled:Q,readOnly:T,required:U,children:l(a.Group,{className:[y,r[m],i[m],g[m],u[m],de?ie[F]:re,Q?o[p]:T?c[p]:d[p]].join(" "),children:[de&&"split"===F?oe:null,J?e("span",{className:"flex h-[1lh] shrink-0 items-center text-(--plass-muted-fg)",children:J}):null,e(a.Input,{placeholder:Y,className:["min-w-0 flex-1 self-stretch bg-transparent [font:inherit] text-inherit","[outline:none]","tabular-nums","split"===F&&de?"text-center":"","placeholder:text-(--plass-muted-fg)","caret-(--p-accent) selection:bg-(--p-soft-press)","disabled:cursor-not-allowed"].filter(Boolean).join(" ")}),K?e("span",{className:"flex h-[1lh] shrink-0 items-center text-(--plass-muted-fg)",children:K}):null,de&&"end"===F?l("span",{className:"flex shrink-0 items-center gap-0.5",children:[oe,ce]}):null,de&&"split"===F?ce:null]})}),P?e(t.Description,{className:`${b[m]} text-(--plass-muted-fg)`,children:P}):null,te?e(t.Error,{match:!0,className:`${b[m]} text-(--p-accent)`,children:A}):null]})}
@@ -1 +1 @@
1
- export { PlNumberField } from './PlNumberField.js';
1
+ export{PlNumberField}from"./PlNumberField.js";