plass-ui 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/dist/components/accordion/PlAccordion.js +1 -131
  2. package/dist/components/accordion/index.js +1 -1
  3. package/dist/components/alert/PlAlert.js +1 -109
  4. package/dist/components/alert/index.js +1 -1
  5. package/dist/components/animate-appear/PlAnimateAppear.js +1 -71
  6. package/dist/components/animate-appear/index.js +1 -1
  7. package/dist/components/animate-blink/PlAnimateBlink.js +1 -47
  8. package/dist/components/animate-blink/index.js +1 -1
  9. package/dist/components/animate-fade/PlAnimateFade.js +1 -48
  10. package/dist/components/animate-fade/index.js +1 -1
  11. package/dist/components/animate-grow/PlAnimateGrow.js +1 -49
  12. package/dist/components/animate-grow/index.js +1 -1
  13. package/dist/components/animate-headline/PlAnimateHeadline.js +1 -120
  14. package/dist/components/animate-headline/index.js +1 -1
  15. package/dist/components/animate-lighting/PlAnimateLighting.js +1 -65
  16. package/dist/components/animate-lighting/index.js +1 -1
  17. package/dist/components/animate-marquee/PlAnimateMarquee.js +1 -94
  18. package/dist/components/animate-marquee/index.js +1 -1
  19. package/dist/components/animate-rotate/PlAnimateRotate.js +1 -50
  20. package/dist/components/animate-rotate/index.js +1 -1
  21. package/dist/components/animate-slide/PlAnimateSlide.js +1 -49
  22. package/dist/components/animate-slide/index.js +1 -1
  23. package/dist/components/animate-typing/PlAnimateTyping.js +1 -177
  24. package/dist/components/animate-typing/index.js +1 -1
  25. package/dist/components/animate-zoom/PlAnimateZoom.js +1 -45
  26. package/dist/components/animate-zoom/index.js +1 -1
  27. package/dist/components/aspect-ratio/PlAspectRatio.js +1 -58
  28. package/dist/components/aspect-ratio/index.js +1 -1
  29. package/dist/components/avatar/PlAvatar.js +1 -121
  30. package/dist/components/avatar/index.js +1 -1
  31. package/dist/components/badge/PlBadge.js +1 -168
  32. package/dist/components/badge/index.js +1 -1
  33. package/dist/components/blockquote/PlBlockquote.js +1 -112
  34. package/dist/components/blockquote/index.js +1 -1
  35. package/dist/components/bottom-navigation/PlBottomNavigation.js +1 -141
  36. package/dist/components/bottom-navigation/index.js +1 -1
  37. package/dist/components/box/PlBox.js +1 -46
  38. package/dist/components/box/index.js +1 -1
  39. package/dist/components/breadcrumb/PlBreadcrumb.js +1 -201
  40. package/dist/components/breadcrumb/index.js +1 -1
  41. package/dist/components/button/PlButton.js +1 -196
  42. package/dist/components/button/index.js +1 -1
  43. package/dist/components/button-group/PlButtonGroup.js +1 -64
  44. package/dist/components/button-group/index.js +1 -1
  45. package/dist/components/card/PlCard.js +1 -102
  46. package/dist/components/card/index.js +1 -1
  47. package/dist/components/carousel/PlCarousel.js +1 -177
  48. package/dist/components/carousel/index.js +1 -1
  49. package/dist/components/chat-bubble/PlChatBubble.js +1 -206
  50. package/dist/components/chat-bubble/index.js +1 -1
  51. package/dist/components/checkbox/PlCheckbox.js +1 -100
  52. package/dist/components/checkbox/index.js +1 -1
  53. package/dist/components/chip/PlChip.js +1 -144
  54. package/dist/components/chip/index.js +1 -1
  55. package/dist/components/collapsible/PlCollapsible.js +1 -65
  56. package/dist/components/collapsible/index.js +1 -1
  57. package/dist/components/combobox/PlCombobox.js +1 -199
  58. package/dist/components/combobox/index.js +1 -1
  59. package/dist/components/container/PlContainer.js +1 -47
  60. package/dist/components/container/index.js +1 -1
  61. package/dist/components/date-picker/PlDatePicker.js +1 -87
  62. package/dist/components/date-picker/index.js +1 -1
  63. package/dist/components/date-range-picker/PlDateRangePicker.js +1 -152
  64. package/dist/components/date-range-picker/index.js +1 -1
  65. package/dist/components/date-time-picker/PlDateTimePicker.js +1 -106
  66. package/dist/components/date-time-picker/index.js +1 -1
  67. package/dist/components/divider/PlDivider.js +1 -107
  68. package/dist/components/divider/index.js +1 -1
  69. package/dist/components/drawer/PlDrawer.js +1 -190
  70. package/dist/components/drawer/index.js +1 -1
  71. package/dist/components/file-picker/PlFilePicker.js +1 -274
  72. package/dist/components/file-picker/index.js +1 -1
  73. package/dist/components/floating-bottom-navigation/PlFloatingBottomNavigation.js +1 -291
  74. package/dist/components/floating-bottom-navigation/index.js +1 -1
  75. package/dist/components/grid/PlGrid.js +1 -51
  76. package/dist/components/grid/PlGridItem.js +1 -34
  77. package/dist/components/grid/index.js +1 -2
  78. package/dist/components/highlight/PlHighlight.js +1 -185
  79. package/dist/components/highlight/index.js +1 -1
  80. package/dist/components/hot-keys/PlHotKeys.js +1 -294
  81. package/dist/components/hot-keys/index.js +1 -1
  82. package/dist/components/icon/PlIcon.js +1 -58
  83. package/dist/components/icon/index.js +1 -1
  84. package/dist/components/icon-button/PlIconButton.js +1 -37
  85. package/dist/components/icon-button/index.js +1 -1
  86. package/dist/components/list/PlList.js +1 -160
  87. package/dist/components/list/index.js +1 -1
  88. package/dist/components/menu/PlMenu.js +1 -209
  89. package/dist/components/menu/index.js +1 -1
  90. package/dist/components/modal/PlModal.js +1 -150
  91. package/dist/components/modal/index.js +1 -1
  92. package/dist/components/number-field/PlNumberField.js +1 -111
  93. package/dist/components/number-field/index.js +1 -1
  94. package/dist/components/otp-field/PlOtpField.js +1 -109
  95. package/dist/components/otp-field/index.js +1 -1
  96. package/dist/components/overlay/PlOverlay.js +1 -77
  97. package/dist/components/overlay/index.js +1 -1
  98. package/dist/components/pagination/PlPagination.js +1 -159
  99. package/dist/components/pagination/index.js +1 -1
  100. package/dist/components/panes/PlPanes.js +1 -324
  101. package/dist/components/panes/index.js +1 -1
  102. package/dist/components/pill/PlPill.js +1 -154
  103. package/dist/components/pill/index.js +1 -1
  104. package/dist/components/popover/PlPopover.js +1 -113
  105. package/dist/components/popover/index.js +1 -1
  106. package/dist/components/progress-box/PlProgressBox.js +1 -34
  107. package/dist/components/progress-box/index.js +1 -1
  108. package/dist/components/progress-circular/PlProgressCircular.js +1 -47
  109. package/dist/components/progress-circular/index.js +1 -1
  110. package/dist/components/progress-linear/PlProgressLinear.js +1 -40
  111. package/dist/components/progress-linear/index.js +1 -1
  112. package/dist/components/radio-group/PlRadioGroup.js +1 -99
  113. package/dist/components/radio-group/index.js +1 -1
  114. package/dist/components/rating/PlRating.js +1 -101
  115. package/dist/components/rating/index.js +1 -1
  116. package/dist/components/scroll-zone/PlScrollZone.js +1 -411
  117. package/dist/components/scroll-zone/index.js +1 -1
  118. package/dist/components/segmented-button/PlSegmentedButton.js +1 -206
  119. package/dist/components/segmented-button/index.js +1 -1
  120. package/dist/components/select/PlSelect.js +1 -115
  121. package/dist/components/select/index.js +1 -1
  122. package/dist/components/skeleton/PlSkeleton.js +1 -142
  123. package/dist/components/skeleton/index.js +1 -1
  124. package/dist/components/slider/PlSlider.js +1 -132
  125. package/dist/components/slider/index.js +1 -1
  126. package/dist/components/spoiler/PlSpoiler.js +1 -74
  127. package/dist/components/spoiler/index.js +1 -1
  128. package/dist/components/switch/PlSwitch.js +1 -131
  129. package/dist/components/switch/index.js +1 -1
  130. package/dist/components/table/PlTable.js +1 -210
  131. package/dist/components/table/index.js +1 -1
  132. package/dist/components/tabs/PlTabs.js +1 -182
  133. package/dist/components/tabs/index.js +1 -1
  134. package/dist/components/text-field/PlTextField.js +1 -126
  135. package/dist/components/text-field/index.js +1 -1
  136. package/dist/components/text-link/PlTextLink.js +1 -136
  137. package/dist/components/text-link/index.js +1 -1
  138. package/dist/components/time-picker/PlTimePicker.js +1 -97
  139. package/dist/components/time-picker/index.js +1 -1
  140. package/dist/components/timeline/PlTimeline.js +1 -207
  141. package/dist/components/timeline/index.js +1 -1
  142. package/dist/components/toast/PlToast.js +1 -174
  143. package/dist/components/toast/index.js +1 -1
  144. package/dist/components/toolbar/PlToolbar.js +1 -65
  145. package/dist/components/toolbar/index.js +1 -1
  146. package/dist/components/tooltip/PlTooltip.js +1 -117
  147. package/dist/components/tooltip/index.js +1 -1
  148. package/dist/components/typography/PlTypography.js +1 -143
  149. package/dist/components/typography/index.js +1 -1
  150. package/dist/index.js +1 -75
  151. package/dist/internal/animate.js +1 -318
  152. package/dist/internal/button-group.js +2 -19
  153. package/dist/internal/calendar.js +1 -501
  154. package/dist/internal/date.js +1 -353
  155. package/dist/internal/format.js +1 -41
  156. package/dist/internal/grid.js +1 -143
  157. package/dist/internal/icons.js +1 -138
  158. package/dist/internal/menu.js +1 -18
  159. package/dist/internal/picker.js +1 -139
  160. package/dist/internal/progress.js +1 -167
  161. package/dist/internal/sizer.js +1 -35
  162. package/dist/internal/styles.js +1 -636
  163. package/dist/types.js +0 -8
  164. package/package.json +3 -2
@@ -1,144 +1 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import * as React from 'react';
3
- import { CloseIcon } from '../../internal/icons.js';
4
- import { chipRemoveClasses, controlHeightClasses, controlSlots, controlTextClasses, disabledClasses, focusRingClasses, gapClasses, glassClasses, hasContent, iconClasses, paddingXClasses, radiusClasses, transitionClasses } from '../../internal/styles.js';
5
- /**
6
- * A chip sits one step down the control ladder from everything else: a `md` chip
7
- * is a `sm` control — 32px, not 40px.
8
- *
9
- * This is the whole size difference between a chip and a button, and it is
10
- * deliberate. A chip is a token *inside* a row of content, not a control the row
11
- * lines up against; at full control height a `glass` chip and a `glass` button
12
- * are the same object, and a screen full of them says nothing about which one
13
- * can be pressed.
14
- *
15
- * Shifting the index rather than inventing a second set of numbers keeps a chip
16
- * inside the same five-step vocabulary, and keeps `xs` from falling off the
17
- * bottom of it.
18
- */
19
- const chipScale = {
20
- xs: 'xs',
21
- sm: 'xs',
22
- md: 'sm',
23
- lg: 'md',
24
- xl: 'lg'
25
- };
26
- /**
27
- * The three materials. A chip **is** the thing being coloured — a tag names one
28
- * particular thing — so unlike a `PlCard` its sheet takes the tint.
29
- *
30
- * `glass` is the default rather than `solid`: a filter bar is a row of chips,
31
- * and a row of gradient keys is a row in which nothing is the primary action
32
- * because everything is.
33
- */
34
- const restClasses = {
35
- solid: 'text-(--p-on-solid) [background-image:var(--p-fill)] [box-shadow:var(--p-elev)]',
36
- glass: /* @__PURE__ */ [
37
- glassClasses,
38
- 'border text-(--p-accent) bg-(--plass-glass)',
39
- '[border-color:var(--plass-glass-line)]',
40
- '[box-shadow:var(--p-elev),var(--plass-gloss-glass)]'
41
- ].join(' '),
42
- ghost: 'text-(--p-accent) bg-(--p-soft)'
43
- };
44
- /**
45
- * Chosen is one step further up the ladder the chip is already on — the sheet
46
- * holds more light. Deliberately not a different colour family: a filter that is
47
- * on is still the same filter.
48
- *
49
- * `solid` has no opacity ladder to climb, because a gradient fill is the fill.
50
- * So it answers the other way the design language allows: it casts its own
51
- * colour onto the sheet under it. A chosen key lifts; an unchosen one lies flat.
52
- */
53
- const selectedClasses = {
54
- solid: '[box-shadow:var(--p-elev),var(--p-lift)]',
55
- glass: 'bg-(--plass-glass-press) [border-color:var(--p-line-hover)]',
56
- ghost: 'bg-(--p-soft-press)'
57
- };
58
- /**
59
- * Only a chip that can be pressed answers the pointer, and it answers the way
60
- * every other control does: `brightness()` on the gradient, a step up the
61
- * opacity ladder on the other two.
62
- */
63
- const hoverClasses = {
64
- solid: 'hover:brightness-105 active:brightness-95',
65
- glass: 'hover:bg-(--plass-glass-hover) hover:[border-color:var(--p-line)] active:bg-(--plass-glass-press)',
66
- ghost: 'hover:bg-(--p-soft-hover) active:bg-(--p-soft-press)'
67
- };
68
- const baseClasses = /* @__PURE__ */ [
69
- // `items-center`, not `items-stretch`: everything in a chip — the icon, the
70
- // label, the count plate, the × — is centred on one line. The pressable label
71
- // asks for the height it needs with `self-stretch` instead, so making the
72
- // shell stretch to suit it would knock every other child off the centre line.
73
- 'relative inline-flex max-w-full shrink-0 items-center select-none',
74
- 'align-middle leading-none font-medium whitespace-nowrap',
75
- '[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]',
76
- transitionClasses,
77
- iconClasses
78
- ].join(' ');
79
- /**
80
- * The label, when the chip is pressable, is its own `<button>` inside the shell
81
- * rather than the shell itself.
82
- *
83
- * That looks like indirection and is not: a chip can carry a delete affordance,
84
- * which has to be a button too, and a `<button>` inside a `<button>` is invalid
85
- * HTML that browsers un-nest on parse. Keeping the shell a `<span>` is what lets
86
- * "activate this chip" and "remove this chip" both be real, focusable buttons.
87
- *
88
- * `self-stretch` so its hit area is the full height of the chip rather than the
89
- * height of the words, and `rounded-[inherit]` so the focus ring traces the
90
- * shell's corners rather than drawing a second, squarer rectangle inside them.
91
- */
92
- const labelButtonClasses = /* @__PURE__ */ [
93
- 'flex min-w-0 flex-1 cursor-pointer items-center justify-center self-stretch rounded-[inherit]',
94
- focusRingClasses
95
- ].join(' ');
96
- /**
97
- * A compact token: a tag, a filter, a status, an entity plucked out of a list.
98
- *
99
- * The shell is always a `<span>`. What changes is what is inside it: a plain run
100
- * of content, or — when `onClick` is given — a real `<button>` wrapping that
101
- * content, plus a second button for `onDelete`. Both are reachable by keyboard,
102
- * and neither is nested inside the other.
103
- *
104
- * An inert `<span>` carrying a click handler is the single most common way a
105
- * component library loses its keyboard users, and a `<button>` inside a
106
- * `<button>` is the most common way it invents a chip that Chrome silently
107
- * rewrites. This shape is what avoids both.
108
- */
109
- export const PlChip = /* @__PURE__ */ React.forwardRef(function PlChip({ variant = 'glass', size = 'md', color = 'primary', density = 'default', elevation = 0, startIcon, endIcon, count, onDelete, deleteLabel = 'Remove', selected = false, disabled = false, className, style, children, onClick, ...props }, ref) {
110
- const interactive = Boolean(onClick) && !disabled;
111
- const step = chipScale[size];
112
- const padX = paddingXClasses[density][step];
113
- const shellClasses = [
114
- baseClasses,
115
- controlHeightClasses[step],
116
- controlTextClasses[step],
117
- gapClasses[step],
118
- radiusClasses[step],
119
- // An if/else rather than stacked variants: two Tailwind classes of equal
120
- // specificity resolve by their order in the generated stylesheet.
121
- disabled ? disabledClasses[variant] : restClasses[variant],
122
- !disabled && selected ? selectedClasses[variant] : '',
123
- interactive ? hoverClasses[variant] : '',
124
- // With a pressable label the padding belongs to the button, so its hit area
125
- // covers the whole chip rather than just the words.
126
- interactive ? 'ps-0' : padX,
127
- // The delete button brings its own padding; stacking the chip's on top of it
128
- // would leave the × floating in the middle of a gap.
129
- onDelete ? 'pe-1' : interactive ? 'pe-0' : '',
130
- className ?? ''
131
- ]
132
- .filter(Boolean)
133
- .join(' ');
134
- const label = (_jsxs(_Fragment, { children: [startIcon, hasContent(children) ? _jsx("span", { className: "min-w-0 truncate", children: children }) : null, endIcon, hasContent(count) ? (_jsx("span", { className: [
135
- 'ms-0.5 inline-flex shrink-0 items-center justify-center rounded-full px-1.5 py-px',
136
- 'text-[0.85em] leading-none font-semibold tabular-nums',
137
- // On a filled chip the plate is light let through the fill; on a
138
- // tinted or a bare one it is the accent showing under the words.
139
- variant === 'solid'
140
- ? 'bg-(--plass-glow-on-fill) text-(--p-on-solid)'
141
- : 'bg-(--p-soft-press) text-(--p-accent)'
142
- ].join(' '), children: count })) : null] }));
143
- return (_jsxs("span", { ref: ref, className: shellClasses, style: { ...controlSlots(color, elevation, variant), ...style }, "aria-disabled": disabled && !interactive ? true : undefined, ...props, children: [interactive ? (_jsx("button", { type: "button", "aria-pressed": selected, className: `${labelButtonClasses} ${gapClasses[step]} ${padX}`, onClick: onClick, children: label })) : (label), onDelete ? (_jsx("button", { type: "button", "aria-label": deleteLabel, disabled: disabled, className: chipRemoveClasses, onClick: onDelete, children: _jsx(CloseIcon, {}) })) : null] }));
144
- });
1
+ "use client";import{jsx as e,Fragment as s,jsxs as l}from"react/jsx-runtime";import*as t from"react";import{CloseIcon as o}from"../../internal/icons.js";import{chipRemoveClasses as a,controlHeightClasses as n,controlSlots as r,controlTextClasses as i,disabledClasses as c,focusRingClasses as p,gapClasses as d,glassClasses as m,hasContent as g,iconClasses as h,paddingXClasses as b,radiusClasses as f,transitionClasses as u}from"../../internal/styles.js";const v={xs:"xs",sm:"xs",md:"sm",lg:"md",xl:"lg"},x={solid:"text-(--p-on-solid) [background-image:var(--p-fill)] [box-shadow:var(--p-elev)]",glass:/* @__PURE__ */[m,"border text-(--p-accent) bg-(--plass-glass)","[border-color:var(--plass-glass-line)]","[box-shadow:var(--p-elev),var(--plass-gloss-glass)]"].join(" "),ghost:"text-(--p-accent) bg-(--p-soft)"},j={solid:"[box-shadow:var(--p-elev),var(--p-lift)]",glass:"bg-(--plass-glass-press) [border-color:var(--p-line-hover)]",ghost:"bg-(--p-soft-press)"},w={solid:"hover:brightness-105 active:brightness-95",glass:"hover:bg-(--plass-glass-hover) hover:[border-color:var(--p-line)] active:bg-(--plass-glass-press)",ghost:"hover:bg-(--p-soft-hover) active:bg-(--p-soft-press)"},y=/* @__PURE__ */["relative inline-flex max-w-full shrink-0 items-center select-none","align-middle leading-none font-medium whitespace-nowrap","[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]",u,h].join(" "),k=/* @__PURE__ */["flex min-w-0 flex-1 cursor-pointer items-center justify-center self-stretch rounded-[inherit]",p].join(" ");export const PlChip=/* @__PURE__ */t.forwardRef(function PlChip({variant:t="glass",size:p="md",color:m="primary",density:h="default",elevation:u=0,startIcon:N,endIcon:C,count:$,onDelete:B,deleteLabel:I="Remove",selected:P=!1,disabled:R=!1,className:z,style:D,children:F,onClick:L,...q},A){const E=Boolean(L)&&!R,G=v[p],H=b[h][G],J=[y,n[G],i[G],d[G],f[G],R?c[t]:x[t],!R&&P?j[t]:"",E?w[t]:"",E?"ps-0":H,B?"pe-1":E?"pe-0":"",z??""].filter(Boolean).join(" "),K=l(s,{children:[N,g(F)?e("span",{className:"min-w-0 truncate",children:F}):null,C,g($)?e("span",{className:["ms-0.5 inline-flex shrink-0 items-center justify-center rounded-full px-1.5 py-px","text-[0.85em] leading-none font-semibold tabular-nums","solid"===t?"bg-(--plass-glow-on-fill) text-(--p-on-solid)":"bg-(--p-soft-press) text-(--p-accent)"].join(" "),children:$}):null]});return l("span",{ref:A,className:J,style:{...r(m,u,t),...D},"aria-disabled":!(!R||E)||void 0,...q,children:[E?e("button",{type:"button","aria-pressed":P,className:`${k} ${d[G]} ${H}`,onClick:L,children:K}):K,B?e("button",{type:"button","aria-label":I,disabled:R,className:a,onClick:B,children:e(o,{})}):null]})});
@@ -1 +1 @@
1
- export { PlChip } from './PlChip.js';
1
+ export{PlChip}from"./PlChip.js";
@@ -1,65 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import * as React from 'react';
3
- import { Collapsible as BaseUICollapsible } from '@base-ui/react/collapsible';
4
- import { ChevronIcon } from '../../internal/icons.js';
5
- import { cx, focusRingInsetClasses, gapClasses, hasContent, iconClasses, metaTextClasses, radiusClasses, sheetBodyClasses, sheetHeaderGapClasses, sheetPaddingXClasses, sheetPaddingYClasses, sheetRestClasses, sheetTitleClasses, surfaceSlots, transitionClasses } from '../../internal/styles.js';
6
- /**
7
- * The space between the header and the body it opened.
8
- *
9
- * The header's own padding does not pay for it, which is the correction
10
- * `PlAccordion` already carries: an open header is a tinted band with its own
11
- * bottom edge, the body begins at that edge, and its first line lands against
12
- * it with only half a leading in between — so the title and the paragraph
13
- * explaining it read as one run of text broken by a colour change.
14
- */
15
- const panelPaddingTopClasses = {
16
- default: { xs: 'pt-1.5', sm: 'pt-2', md: 'pt-3', lg: 'pt-3.5', xl: 'pt-4' },
17
- compact: { xs: 'pt-1', sm: 'pt-1.5', md: 'pt-2', lg: 'pt-2.5', xl: 'pt-3' }
18
- };
19
- /** And the space under it, on the same two tracks. */
20
- const panelPaddingBottomClasses = {
21
- default: { xs: 'pb-2.5', sm: 'pb-3', md: 'pb-5', lg: 'pb-6', xl: 'pb-7' },
22
- compact: { xs: 'pb-2', sm: 'pb-2.5', md: 'pb-3.5', lg: 'pb-4', xl: 'pb-5' }
23
- };
24
- /**
25
- * One section that folds, standing on its own.
26
- *
27
- * A `PlAccordion` is a *set* of these and owns which one of them is open; this
28
- * is the same fold with nothing else beside it, so what it needs is an `open` of
29
- * its own rather than a place in somebody's list. Reach for it for a "Show more"
30
- * on a form, an optional block of settings, the details under a row.
31
- *
32
- * Base UI owns the parts that are genuinely hard: the `button` / panel pairing
33
- * and the `aria-controls` / `aria-expanded` wiring between them,
34
- * `hidden="until-found"`, and measuring the panel so it has a height to animate
35
- * from.
36
- *
37
- * The panel's height *is* animated, which looks like an exception to the rule
38
- * against moving things and is not: nothing is transformed, no text is
39
- * resampled, and the content does not shift relative to the panel it is in — the
40
- * panel is a window opening onto it. Content that appears instantly is a page
41
- * that jumps, which is the failure the rule exists to prevent.
42
- */
43
- export const PlCollapsible = /* @__PURE__ */ React.forwardRef(function PlCollapsible({ variant = 'glass', size = 'md', color = 'primary', density = 'default', elevation = 0, open, defaultOpen = false, onOpenChange, title, subtitle, startIcon, action, trigger, indicator = true, disabled = false, padded = true, hiddenUntilFound = false, keepMounted = false, className, style, children, ...props }, ref) {
44
- const padX = sheetPaddingXClasses[density][size];
45
- const padY = sheetPaddingYClasses[density][size];
46
- return (_jsxs(BaseUICollapsible.Root, { ref: ref, open: open, defaultOpen: defaultOpen, onOpenChange: (next) => onOpenChange?.(next), disabled: disabled, className: cx(
47
- // `overflow-hidden` is what makes the panel a window rather than
48
- // something that spills past the sheet's own corners while it moves.
49
- 'flex flex-col overflow-hidden', radiusClasses[size], sheetRestClasses[variant], transitionClasses, className), style: { ...surfaceSlots(color, elevation), ...style }, ...props, children: [trigger ? (_jsx(BaseUICollapsible.Trigger, { render: trigger })) : (_jsxs("div", { className: "flex w-full items-center", children: [_jsxs(BaseUICollapsible.Trigger, { className: cx('flex min-w-0 flex-1 cursor-pointer items-center text-start', padX, padY, gapClasses[size], transitionClasses, iconClasses,
50
- // Inset rather than offset. The sheet clips its children so the
51
- // panel can be a window, and `overflow: hidden` clips a
52
- // descendant's outline along with everything else — an offset
53
- // ring on a trigger that fills the top of the sheet would be
54
- // shaved off on three sides.
55
- focusRingInsetClasses, 'hover:bg-(--p-soft)', 'data-[panel-open]:bg-(--p-soft) data-[panel-open]:text-(--p-accent)', 'disabled:cursor-not-allowed disabled:bg-transparent disabled:opacity-50'), children: [hasContent(startIcon) ? (_jsx("span", { className: "flex h-[1lh] shrink-0 items-center text-(--plass-muted-fg)", children: startIcon })) : null, _jsxs("span", { className: cx('flex min-w-0 flex-1 flex-col', sheetHeaderGapClasses[size]), children: [hasContent(title) ? (_jsx("span", { className: cx('plass-title truncate font-semibold', sheetTitleClasses[size]), children: title })) : null, hasContent(subtitle) ? (_jsx("span", { className: cx('truncate text-(--plass-muted-fg)', metaTextClasses[size]), children: subtitle })) : null] }), indicator ? (_jsx("span", { className: cx('flex h-[1lh] shrink-0 items-center text-(--plass-muted-fg)', '[transition:rotate_var(--plass-duration)_var(--plass-ease)]', 'data-[panel-open]:rotate-180'), children: _jsx(ChevronIcon, {}) })) : null] }), hasContent(action) ? (_jsx("span", { className: cx('flex shrink-0 items-center', padX), children: action })) : null] })), _jsx(BaseUICollapsible.Panel, { hiddenUntilFound: hiddenUntilFound, keepMounted: keepMounted, className: cx('h-(--collapsible-panel-height) overflow-hidden', '[transition:height_var(--plass-duration-slow)_var(--plass-ease)]', 'data-[starting-style]:h-0 data-[ending-style]:h-0'), children: _jsx("div", { className: cx('min-w-0 text-(--plass-muted-fg)', sheetBodyClasses[size], padded ? padX : '',
56
- // The default header already paid for the space above, so the
57
- // body only owes what goes under it — otherwise a closed
58
- // collapsible would look padded. A caller's own `trigger` has paid
59
- // for nothing, so there the panel owes both.
60
- padded
61
- ? trigger
62
- ? `${panelPaddingTopClasses[density][size]} ${panelPaddingBottomClasses[density][size]}`
63
- : panelPaddingBottomClasses[density][size]
64
- : ''), children: children }) })] }));
65
- });
1
+ "use client";import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as t from"react";import{Collapsible as s}from"@base-ui/react/collapsible";import{ChevronIcon as a}from"../../internal/icons.js";import{cx as n,focusRingInsetClasses as i,gapClasses as r,hasContent as p,iconClasses as d,metaTextClasses as o,radiusClasses as c,sheetBodyClasses as m,sheetHeaderGapClasses as f,sheetPaddingXClasses as h,sheetPaddingYClasses as u,sheetRestClasses as x,sheetTitleClasses as b,surfaceSlots as g,transitionClasses as N}from"../../internal/styles.js";const v={default:{xs:"pt-1.5",sm:"pt-2",md:"pt-3",lg:"pt-3.5",xl:"pt-4"},compact:{xs:"pt-1",sm:"pt-1.5",md:"pt-2",lg:"pt-2.5",xl:"pt-3"}},w={default:{xs:"pb-2.5",sm:"pb-3",md:"pb-5",lg:"pb-6",xl:"pb-7"},compact:{xs:"pb-2",sm:"pb-2.5",md:"pb-3.5",lg:"pb-4",xl:"pb-5"}};export const PlCollapsible=/* @__PURE__ */t.forwardRef(function PlCollapsible({variant:t="glass",size:y="md",color:j="primary",density:k="default",elevation:C=0,open:O,defaultOpen:_=!1,onOpenChange:P,title:F,subtitle:M,startIcon:R,action:T,trigger:U,indicator:$=!0,disabled:z=!1,padded:I=!0,hiddenUntilFound:q=!1,keepMounted:A=!1,className:B,style:D,children:E,...G},H){const J=h[k][y],K=u[k][y];return l(s.Root,{ref:H,open:O,defaultOpen:_,onOpenChange:e=>P?.(e),disabled:z,className:n("flex flex-col overflow-hidden",c[y],x[t],N,B),style:{...g(j,C),...D},...G,children:[U?e(s.Trigger,{render:U}):l("div",{className:"flex w-full items-center",children:[l(s.Trigger,{className:n("flex min-w-0 flex-1 cursor-pointer items-center text-start",J,K,r[y],N,d,i,"hover:bg-(--p-soft)","data-[panel-open]:bg-(--p-soft) data-[panel-open]:text-(--p-accent)","disabled:cursor-not-allowed disabled:bg-transparent disabled:opacity-50"),children:[p(R)?e("span",{className:"flex h-[1lh] shrink-0 items-center text-(--plass-muted-fg)",children:R}):null,l("span",{className:n("flex min-w-0 flex-1 flex-col",f[y]),children:[p(F)?e("span",{className:n("plass-title truncate font-semibold",b[y]),children:F}):null,p(M)?e("span",{className:n("truncate text-(--plass-muted-fg)",o[y]),children:M}):null]}),$?e("span",{className:n("flex h-[1lh] shrink-0 items-center text-(--plass-muted-fg)","[transition:rotate_var(--plass-duration)_var(--plass-ease)]","data-[panel-open]:rotate-180"),children:e(a,{})}):null]}),p(T)?e("span",{className:n("flex shrink-0 items-center",J),children:T}):null]}),e(s.Panel,{hiddenUntilFound:q,keepMounted:A,className:n("h-(--collapsible-panel-height) overflow-hidden","[transition:height_var(--plass-duration-slow)_var(--plass-ease)]","data-[starting-style]:h-0 data-[ending-style]:h-0"),children:e("div",{className:n("min-w-0 text-(--plass-muted-fg)",m[y],I?J:"",I?U?`${v[k][y]} ${w[k][y]}`:w[k][y]:""),children:E})})]})});
@@ -1 +1 @@
1
- export { PlCollapsible } from './PlCollapsible.js';
1
+ export{PlCollapsible}from"./PlCollapsible.js";
@@ -1,199 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import * as React from 'react';
3
- import { Combobox as BaseUICombobox } from '@base-ui/react/combobox';
4
- import { Field } from '@base-ui/react/field';
5
- import { PlChip } from '../chip/PlChip.js';
6
- import { CheckIcon, ChevronIcon, CloseIcon, PlusIcon } from '../../internal/icons.js';
7
- import { chipRemoveClasses, controlHeightClasses, controlTextLeadingClasses, cx, disabledClasses, fieldReadOnlyClasses, fieldRestClasses, focusWithinRingClasses, gapClasses, glassClasses, hasContent, iconClasses, metaTextClasses, paddingXClasses, radiusClasses, stackGapClasses, surfaceSlots, transitionClasses } from '../../internal/styles.js';
8
- /** The field, and it is a PlTextField's shell to the pixel. */
9
- const shellBaseClasses = /* @__PURE__ */ [
10
- 'group relative flex w-full cursor-text items-center',
11
- '[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]',
12
- transitionClasses,
13
- focusWithinRingClasses,
14
- iconClasses
15
- ].join(' ');
16
- /**
17
- * With chips in it the field cannot have a fixed height — the chips wrap. The
18
- * padding is `(control height − chip height) / 2` instead, which makes a one-row
19
- * combobox exactly as tall as the field beside it, and `min-h-*` catches the
20
- * variant that carries no border.
21
- *
22
- * Keyed by `size` and never by `density`: density is horizontal padding only.
23
- */
24
- const chipsInsetClasses = {
25
- xs: 'min-h-6 py-0',
26
- sm: 'min-h-8 py-0.5',
27
- md: 'min-h-10 py-1',
28
- lg: 'min-h-12 py-1.5',
29
- xl: 'min-h-14 py-2'
30
- };
31
- /**
32
- * The popup is one of the few surfaces in the library that is *supposed* to
33
- * float, so unlike everything else it carries a shadow by default — at level 3.
34
- * Identical to PlSelect's, because a combobox's list and a select's list are the
35
- * same list.
36
- *
37
- * Every `--p-*` it reads is set on the popup itself rather than inherited from
38
- * the Field around it. A portalled popup renders at the end of `<body>`, so it
39
- * is outside the element the slots were declared on, and a `var()` with nothing
40
- * to resolve to is not a fallback — `border-color` collapses to `currentColor`
41
- * and `background-color` to transparent.
42
- */
43
- const popupClasses = /* @__PURE__ */ [
44
- glassClasses,
45
- 'max-h-[min(20rem,var(--available-height))] overflow-y-auto overscroll-contain',
46
- 'w-[var(--anchor-width)] border bg-(--plass-glass-press) p-1',
47
- '[border-color:var(--plass-glass-line)]',
48
- '[box-shadow:var(--plass-shadow-3),var(--plass-gloss-glass)]',
49
- '[outline:none]'
50
- ].join(' ');
51
- const itemClasses = /* @__PURE__ */ [
52
- 'relative flex cursor-pointer items-center gap-2 select-none',
53
- 'rounded-(--plass-radius-xs) py-1.5 pe-2 ps-7',
54
- transitionClasses,
55
- // `data-highlighted` rather than `:hover`: it is also what the arrow keys
56
- // move, so the mouse and the keyboard light the same row.
57
- 'data-[highlighted]:bg-(--p-soft-hover) data-[highlighted]:text-(--p-accent)',
58
- 'data-[selected]:font-semibold data-[selected]:text-(--p-accent)',
59
- 'data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50',
60
- '[outline:none]'
61
- ].join(' ');
62
- /** The chevron and the ×, which sit in the field rather than in the list. */
63
- const adornmentClasses = /* @__PURE__ */ [
64
- 'inline-flex h-[1lh] shrink-0 cursor-pointer items-center justify-center',
65
- 'rounded-(--plass-radius-xs) text-(--plass-muted-fg)',
66
- '[transition:color_var(--plass-duration)_var(--plass-ease)]',
67
- 'hover:text-(--p-accent)',
68
- 'focus-visible:[outline:2px_solid_var(--p-ring)] focus-visible:[outline-offset:1px]',
69
- 'disabled:cursor-not-allowed disabled:opacity-50'
70
- ].join(' ');
71
- /** Always an array inside, however the caller spells it. */
72
- function toArray(value) {
73
- if (value === null || value === undefined) {
74
- return [];
75
- }
76
- return Array.isArray(value) ? value.slice() : [value];
77
- }
78
- /**
79
- * A field you can type into and also choose from.
80
- *
81
- * The shell is a PlTextField's wearing a chevron, exactly as PlSelect's trigger
82
- * is — the three have to be indistinguishable in a form, or the form looks
83
- * assembled rather than designed. What is different is what the text does: it
84
- * filters the list, and — unless `allowCustom` is off — it can become the value
85
- * itself, offered as the last row rather than committed silently on blur.
86
- *
87
- * With `multiple` the chosen values become PlChips inside the field and the
88
- * input goes on filtering after each one, so a set of tags is built without the
89
- * field ever closing.
90
- *
91
- * Base UI owns everything hard about this: the filtering and its collator, the
92
- * popup's positioning and flipping, the `combobox`/`listbox` wiring, arrow-key
93
- * navigation across both the list and the chips, and the hidden input that makes
94
- * the whole thing submit with a form.
95
- */
96
- export function PlCombobox({ variant = 'glass', size = 'md', color = 'primary', density = 'default', elevation = 0, items, multiple, value, defaultValue, onValueChange, onInputValueChange, allowCustom = true, customLabel, clearable = false, emptyMessage = 'No matches', limit, placeholder, label, description, error, invalid, startIcon, fullWidth = false, disabled = false, readOnly = false, required = false, name, open, defaultOpen, onOpenChange, openLabel = 'Open', clearLabel = 'Clear', removeLabel = (chip) => `Remove ${chip}`, inputRef, id, className, style, ...props }) {
97
- const hasError = hasContent(error);
98
- const isInvalid = invalid ?? hasError;
99
- // Invalid re-points the whole slot family at `danger`, so the edge, the ring,
100
- // the caret and the message all turn over together.
101
- const family = isInvalid ? 'danger' : color;
102
- const isMultiple = multiple === true;
103
- const options = React.useMemo(() => items.map((item) => ({
104
- value: item.value,
105
- label: item.label ?? String(item.value),
106
- disabled: item.disabled
107
- })), [items]);
108
- // The selection is mirrored internally even when the caller controls it. The
109
- // "add this" row has to know what has already been chosen — otherwise a tag
110
- // that was just added goes on being offered — and in uncontrolled mode there
111
- // is nowhere else that knowledge lives.
112
- const [ownSelection, setOwnSelection] = React.useState(() => toArray(defaultValue));
113
- const selection = value === undefined ? ownSelection : toArray(value);
114
- const [query, setQuery] = React.useState('');
115
- /* A map rather than a `find`: this is called once per chosen item, and a
116
- multi-select with a hundred options and twenty chips in it would otherwise
117
- walk the list twenty times on every render. */
118
- const byValue = React.useMemo(() => new Map(options.map((option) => [option.value, option])), [options]);
119
- const entryFor = React.useCallback((item) => byValue.get(item) ?? { value: item, label: String(item), custom: true }, [byValue]);
120
- // The row that offers what was typed. It is a real item rather than a special
121
- // case in the keyboard handling, so Enter, a click and the arrow keys all
122
- // reach it the same way every other row is reached — and Base UI's own filter
123
- // keeps it visible, because its label *is* the query.
124
- const trimmed = query.trim();
125
- const folded = trimmed.toLocaleLowerCase();
126
- const alreadyKnown = trimmed === '' ||
127
- options.some((option) => option.label.toLocaleLowerCase() === folded ||
128
- String(option.value).toLocaleLowerCase() === folded) ||
129
- selection.some((item) => String(item).toLocaleLowerCase() === folded);
130
- const customValue = allowCustom && !readOnly && !disabled && !alreadyKnown ? trimmed : null;
131
- const listItems = React.useMemo(() => customValue === null
132
- ? options
133
- : [...options, { value: customValue, label: customValue, custom: true }], [options, customValue]);
134
- const baseValue = isMultiple
135
- ? selection.map(entryFor)
136
- : selection.length > 0
137
- ? entryFor(selection[0])
138
- : null;
139
- function commit(next) {
140
- if (value === undefined) {
141
- setOwnSelection(next);
142
- }
143
- onValueChange?.((isMultiple ? next : (next[0] ?? null)));
144
- }
145
- const shellClasses = cx(shellBaseClasses, controlTextLeadingClasses[size], radiusClasses[size], gapClasses[size], isMultiple ? chipsInsetClasses[size] : controlHeightClasses[size],
146
- // The chevron brings its own hit area; stacking the field's padding on top
147
- // of it would leave the glyph floating in the middle of a gap.
148
- `${paddingXClasses[density][size]} pe-1.5`,
149
- // An if/else rather than stacked variants: two Tailwind classes of equal
150
- // specificity resolve by their order in the generated stylesheet.
151
- disabled
152
- ? disabledClasses[variant]
153
- : readOnly
154
- ? fieldReadOnlyClasses[variant]
155
- : fieldRestClasses[variant]);
156
- const inputClasses = /* @__PURE__ */ [
157
- // `self-stretch` and no height of its own, in both modes. An input centres
158
- // its own text in its box, so letting the box be the full height of the row
159
- // it sits on — the field in single mode, the chip line in multiple — is what
160
- // puts the placeholder on the same baseline as the chips beside it.
161
- 'min-w-0 flex-1 self-stretch bg-transparent [font:inherit] text-inherit',
162
- // Not `outline-none`: that utility zeroes `--tw-outline-style`, and the
163
- // shell's focus ring is drawn from the same variable family.
164
- '[outline:none]',
165
- 'placeholder:text-(--plass-muted-fg)',
166
- 'caret-(--p-accent) selection:bg-(--p-soft-press)',
167
- 'disabled:cursor-not-allowed'
168
- ].join(' ');
169
- /**
170
- * `afterChips` is the space between the last chip and where typing starts.
171
- *
172
- * The row's own `gap-1` is the distance between two chips, which is right
173
- * between two things of the same kind and too little between a chip and a
174
- * caret — the query reads as another chip's label rather than as the field's
175
- * own text. It is only added when there is a chip to be clear of, so an empty
176
- * multi-select lines its placeholder up with every other field in the form.
177
- */
178
- const renderInput = (afterChips) => (_jsx(BaseUICombobox.Input, { ref: inputRef, placeholder: placeholder, className: cx(inputClasses, isMultiple && 'min-w-16', isMultiple && afterChips && 'ms-1.5') }));
179
- 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, { className: cx(metaTextClasses[size], 'font-semibold', disabled ? 'text-(--plass-muted-fg)' : 'text-(--plass-fg)'), children: label })) : null, _jsxs(BaseUICombobox.Root, { id: id, name: name, items: listItems, multiple: isMultiple, value: baseValue, onValueChange: (next) => {
180
- const chosen = next === null ? [] : Array.isArray(next) ? next : [next];
181
- commit(chosen.map((entry) => entry.value));
182
- },
183
- // The text is Base UI's to own, not ours: in single mode it is the
184
- // chosen option's label, which has to be there from the first paint, and
185
- // in multiple mode it empties itself after each pick. What is kept here
186
- // is a copy, and only so the "add this" row knows what was typed.
187
- onInputValueChange: (next) => {
188
- setQuery(next);
189
- onInputValueChange?.(next);
190
- }, open: open, defaultOpen: defaultOpen, onOpenChange: (next) => onOpenChange?.(next),
191
- // The first match lights up as you type, so Enter commits without an
192
- // arrow key first. This is what makes the "add this" row reachable from
193
- // the keyboard at all: a value the list does not have is the only match
194
- // there is, so it is the one Enter lands on.
195
- autoHighlight: true, itemToStringLabel: (entry) => entry.label, itemToStringValue: (entry) => String(entry.value), isItemEqualToValue: (a, b) => a.value === b.value, limit: limit, disabled: disabled, readOnly: readOnly, required: required, children: [_jsxs(BaseUICombobox.InputGroup, { className: shellClasses, children: [startIcon ? (_jsx("span", { className: "flex h-[1lh] shrink-0 items-center text-(--plass-muted-fg)", children: startIcon })) : null, isMultiple ? (_jsx(BaseUICombobox.Chips, { className: "flex min-w-0 flex-1 flex-wrap items-center gap-1", children: _jsx(BaseUICombobox.Value, { children: (chosen) => (_jsxs(React.Fragment, { children: [chosen.map((entry) => (_jsx(BaseUICombobox.Chip, { render: _jsx(PlChip, { variant: "glass", size: size, color: family, density: "compact", disabled: disabled, endIcon: readOnly || disabled ? null : (_jsx(BaseUICombobox.ChipRemove, { "aria-label": removeLabel(entry.label), className: chipRemoveClasses, children: _jsx(CloseIcon, {}) })) }), children: entry.label }, String(entry.value)))), renderInput(chosen.length > 0)] })) }) })) : (renderInput(false)), clearable && !readOnly ? (_jsx(BaseUICombobox.Clear, { "aria-label": clearLabel, className: adornmentClasses, children: _jsx(CloseIcon, {}) })) : null, _jsx(BaseUICombobox.Trigger, { "aria-label": openLabel, className: adornmentClasses, children: _jsx(BaseUICombobox.Icon, { className: cx(
196
- // The chevron is the one thing here that may turn: it is a
197
- // glyph, not a label, and nothing about it resamples.
198
- 'flex items-center', '[transition:rotate_var(--plass-duration)_var(--plass-ease)]', 'data-[popup-open]:rotate-180'), children: _jsx(ChevronIcon, {}) }) })] }), _jsx(BaseUICombobox.Portal, { children: _jsx(BaseUICombobox.Positioner, { className: "plass-portal z-50 [outline:none]", sideOffset: 6, children: _jsxs(BaseUICombobox.Popup, { className: cx(popupClasses, radiusClasses[size], controlTextLeadingClasses[size]), style: surfaceSlots(family, 3), children: [_jsx(BaseUICombobox.Empty, { className: "px-2 py-1.5 text-(--plass-muted-fg) empty:hidden", children: emptyMessage }), _jsx(BaseUICombobox.List, { children: (entry) => (_jsx(BaseUICombobox.Item, { value: entry, disabled: entry.disabled, className: itemClasses, children: entry.custom ? (_jsxs(React.Fragment, { children: [_jsx("span", { className: "absolute start-1.5 flex size-4 items-center justify-center text-(--p-accent) [&_svg]:size-4", children: _jsx(PlusIcon, {}) }), _jsx("span", { className: "truncate", children: customLabel ? customLabel(entry.label) : `Add “${entry.label}”` })] })) : (_jsxs(React.Fragment, { children: [_jsx(BaseUICombobox.ItemIndicator, { className: "absolute start-1.5 flex size-4 items-center justify-center", children: _jsx(CheckIcon, {}) }), _jsx("span", { className: "truncate", children: entry.label })] })) }, `${entry.custom ? 'custom:' : ''}${String(entry.value)}`)) })] }) }) })] }), description ? (_jsx(Field.Description, { className: cx(metaTextClasses[size], 'text-(--plass-muted-fg)'), children: description })) : null, hasError ? (_jsx(Field.Error, { match: true, className: cx(metaTextClasses[size], 'text-(--p-accent)'), children: error })) : null] }));
199
- }
1
+ "use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as l from"react";import{Combobox as t}from"@base-ui/react/combobox";import{Field as s}from"@base-ui/react/field";import{PlChip as n}from"../chip/PlChip.js";import{CheckIcon as i,ChevronIcon as r,CloseIcon as o,PlusIcon as c}from"../../internal/icons.js";import{chipRemoveClasses as d,controlHeightClasses as m,controlTextLeadingClasses as u,cx as p,disabledClasses as h,fieldReadOnlyClasses as b,fieldRestClasses as g,focusWithinRingClasses as f,gapClasses as v,glassClasses as x,hasContent as y,iconClasses as N,metaTextClasses as w,paddingXClasses as C,radiusClasses as L,stackGapClasses as j,surfaceSlots as I,transitionClasses as S}from"../../internal/styles.js";const A=/* @__PURE__ */["group relative flex w-full cursor-text items-center","[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]",S,f,N].join(" "),O={xs:"min-h-6 py-0",sm:"min-h-8 py-0.5",md:"min-h-10 py-1",lg:"min-h-12 py-1.5",xl:"min-h-14 py-2"},V=/* @__PURE__ */[x,"max-h-[min(20rem,var(--available-height))] overflow-y-auto overscroll-contain","w-[var(--anchor-width)] 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]"].join(" "),_=/* @__PURE__ */["relative flex cursor-pointer items-center gap-2 select-none","rounded-(--plass-radius-xs) py-1.5 pe-2 ps-7",S,"data-[highlighted]:bg-(--p-soft-hover) data-[highlighted]:text-(--p-accent)","data-[selected]:font-semibold data-[selected]:text-(--p-accent)","data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50","[outline:none]"].join(" "),z=/* @__PURE__ */["inline-flex h-[1lh] shrink-0 cursor-pointer items-center justify-center","rounded-(--plass-radius-xs) text-(--plass-muted-fg)","[transition:color_var(--plass-duration)_var(--plass-ease)]","hover:text-(--p-accent)","focus-visible:[outline:2px_solid_var(--p-ring)] focus-visible:[outline-offset:1px]","disabled:cursor-not-allowed disabled:opacity-50"].join(" ");function toArray(e){return null==e?[]:Array.isArray(e)?e.slice():[e]}export function PlCombobox({variant:f="glass",size:x="md",color:N="primary",density:S="default",elevation:M=0,items:P,multiple:R,value:$,defaultValue:k,onValueChange:T,onInputValueChange:q,allowCustom:E=!0,customLabel:F,clearable:D=!1,emptyMessage:G="No matches",limit:H,placeholder:W,label:B,description:J,error:K,invalid:Q,startIcon:U,fullWidth:X=!1,disabled:Y=!1,readOnly:Z=!1,required:ee=!1,name:ae,open:le,defaultOpen:te,onOpenChange:se,openLabel:ne="Open",clearLabel:ie="Clear",removeLabel:re=e=>`Remove ${e}`,inputRef:oe,id:ce,className:de,style:me,...ue}){const pe=y(K),he=Q??pe,be=he?"danger":N,ge=!0===R,fe=l.useMemo(()=>P.map(e=>({value:e.value,label:e.label??String(e.value),disabled:e.disabled})),[P]),[ve,xe]=l.useState(()=>toArray(k)),ye=void 0===$?ve:toArray($),[Ne,we]=l.useState(""),Ce=l.useMemo(()=>new Map(fe.map(e=>[e.value,e])),[fe]),Le=l.useCallback(e=>Ce.get(e)??{value:e,label:String(e),custom:!0},[Ce]),je=Ne.trim(),Ie=je.toLocaleLowerCase(),Se=""===je||fe.some(e=>e.label.toLocaleLowerCase()===Ie||String(e.value).toLocaleLowerCase()===Ie)||ye.some(e=>String(e).toLocaleLowerCase()===Ie),Ae=!E||Z||Y||Se?null:je,Oe=l.useMemo(()=>null===Ae?fe:[...fe,{value:Ae,label:Ae,custom:!0}],[fe,Ae]),Ve=ge?ye.map(Le):ye.length>0?Le(ye[0]):null,_e=p(A,u[x],L[x],v[x],ge?O[x]:m[x],`${C[S][x]} pe-1.5`,Y?h[f]:Z?b[f]:g[f]),ze=/* @__PURE__ */["min-w-0 flex-1 self-stretch bg-transparent [font:inherit] text-inherit","[outline:none]","placeholder:text-(--plass-muted-fg)","caret-(--p-accent) selection:bg-(--p-soft-press)","disabled:cursor-not-allowed"].join(" "),renderInput=a=>e(t.Input,{ref:oe,placeholder:W,className:p(ze,ge&&"min-w-16",ge&&a&&"ms-1.5")});return a(s.Root,{disabled:Y,invalid:he,className:p("flex-col align-top",j[x],X?"flex w-full":"inline-flex",de),style:{...I(be,M),...me},...ue,children:[B?e(s.Label,{className:p(w[x],"font-semibold",Y?"text-(--plass-muted-fg)":"text-(--plass-fg)"),children:B}):null,a(t.Root,{id:ce,name:ae,items:Oe,multiple:ge,value:Ve,onValueChange:e=>{!function commit(e){void 0===$&&xe(e),T?.(ge?e:e[0]??null)}((null===e?[]:Array.isArray(e)?e:[e]).map(e=>e.value))},onInputValueChange:e=>{we(e),q?.(e)},open:le,defaultOpen:te,onOpenChange:e=>se?.(e),autoHighlight:!0,itemToStringLabel:e=>e.label,itemToStringValue:e=>String(e.value),isItemEqualToValue:(e,a)=>e.value===a.value,limit:H,disabled:Y,readOnly:Z,required:ee,children:[a(t.InputGroup,{className:_e,children:[U?e("span",{className:"flex h-[1lh] shrink-0 items-center text-(--plass-muted-fg)",children:U}):null,ge?e(t.Chips,{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:e(t.Value,{children:s=>a(l.Fragment,{children:[s.map(a=>e(t.Chip,{render:e(n,{variant:"glass",size:x,color:be,density:"compact",disabled:Y,endIcon:Z||Y?null:e(t.ChipRemove,{"aria-label":re(a.label),className:d,children:e(o,{})})}),children:a.label},String(a.value))),renderInput(s.length>0)]})})}):renderInput(!1),D&&!Z?e(t.Clear,{"aria-label":ie,className:z,children:e(o,{})}):null,e(t.Trigger,{"aria-label":ne,className:z,children:e(t.Icon,{className:p("flex items-center","[transition:rotate_var(--plass-duration)_var(--plass-ease)]","data-[popup-open]:rotate-180"),children:e(r,{})})})]}),e(t.Portal,{children:e(t.Positioner,{className:"plass-portal z-50 [outline:none]",sideOffset:6,children:a(t.Popup,{className:p(V,L[x],u[x]),style:I(be,3),children:[e(t.Empty,{className:"px-2 py-1.5 text-(--plass-muted-fg) empty:hidden",children:G}),e(t.List,{children:s=>e(t.Item,{value:s,disabled:s.disabled,className:_,children:s.custom?a(l.Fragment,{children:[e("span",{className:"absolute start-1.5 flex size-4 items-center justify-center text-(--p-accent) [&_svg]:size-4",children:e(c,{})}),e("span",{className:"truncate",children:F?F(s.label):`Add “${s.label}”`})]}):a(l.Fragment,{children:[e(t.ItemIndicator,{className:"absolute start-1.5 flex size-4 items-center justify-center",children:e(i,{})}),e("span",{className:"truncate",children:s.label})]})},`${s.custom?"custom:":""}${String(s.value)}`)})]})})})]}),J?e(s.Description,{className:p(w[x],"text-(--plass-muted-fg)"),children:J}):null,pe?e(s.Error,{match:!0,className:p(w[x],"text-(--p-accent)"),children:K}):null]})}
@@ -1 +1 @@
1
- export { PlCombobox } from './PlCombobox.js';
1
+ export{PlCombobox}from"./PlCombobox.js";
@@ -1,47 +1 @@
1
- import * as React from 'react';
2
- import { useRender } from '@base-ui/react/use-render';
3
- import { cx, sheetPaddingXClasses } from '../../internal/styles.js';
4
- /**
5
- * The measure ladder, in `rem` rather than in Tailwind's named `max-w-*` steps,
6
- * so that a container's `lg` and an `lg:` utility are the same 64rem.
7
- *
8
- * Tailwind's own container scale is a different set of numbers, and having two
9
- * ladders called `lg` on one page is how a layout drifts by a few pixels for no
10
- * reason anybody can find later.
11
- */
12
- const maxWidthClasses = {
13
- xs: 'max-w-[30rem]',
14
- sm: 'max-w-[40rem]',
15
- md: 'max-w-[48rem]',
16
- lg: 'max-w-[64rem]',
17
- xl: 'max-w-[80rem]'
18
- };
19
- /**
20
- * Horizontal breathing room, and optionally a measure.
21
- *
22
- * It draws nothing — no sheet, no hairline, no shadow — for the same reason
23
- * `PlAspectRatio` does not. The outermost element on a page is the one thing
24
- * that must not decide what the page looks like, and a container that carried a
25
- * `variant` would put a second pane behind every card on it.
26
- *
27
- * The two questions it answers are deliberately separate from how the content
28
- * inside divides itself up: a container holds a `PlGrid` as happily as it holds
29
- * a single paragraph, and a grid needs no container around it.
30
- *
31
- * The gutter is the **sheet** padding track rather than the control one. What
32
- * sits inside a container is a page, and the margin a page keeps from the edge
33
- * of a window is the margin a card keeps around a paragraph — not the room a
34
- * label needs beside the edge of the key it is printed on.
35
- */
36
- export const PlContainer = /* @__PURE__ */ React.forwardRef(function PlContainer({ maxWidth = 'none', padded = true, size = 'md', density = 'default', centered = true, render, className, children, ...props }, ref) {
37
- const classNames = cx('block w-full', maxWidth === 'none' ? '' : maxWidthClasses[maxWidth], centered ? 'mx-auto' : '', padded ? sheetPaddingXClasses[density][size] : '', className);
38
- return useRender({
39
- render,
40
- ref,
41
- props: {
42
- className: classNames,
43
- children,
44
- ...props
45
- }
46
- });
47
- });
1
+ "use client";import*as e from"react";import{useRender as r}from"@base-ui/react/use-render";import{cx as n,sheetPaddingXClasses as m}from"../../internal/styles.js";const a={xs:"max-w-[30rem]",sm:"max-w-[40rem]",md:"max-w-[48rem]",lg:"max-w-[64rem]",xl:"max-w-[80rem]"};export const PlContainer=/* @__PURE__ */e.forwardRef(function PlContainer({maxWidth:e="none",padded:t=!0,size:o="md",density:s="default",centered:d=!0,render:l,className:i,children:c,...x},f){const u=n("block w-full","none"===e?"":a[e],d?"mx-auto":"",t?m[s][o]:"",i);return r({render:l,ref:f,props:{className:u,children:c,...x}})});
@@ -1 +1 @@
1
- export { PlContainer } from './PlContainer.js';
1
+ export{PlContainer}from"./PlContainer.js";
@@ -1,87 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import * as React from 'react';
3
- import { PlButton } from '../button/PlButton.js';
4
- import { Calendar, usePickerLabels } from '../../internal/calendar.js';
5
- import { CalendarIcon } from '../../internal/icons.js';
6
- import { PickerFooter, PickerShell } from '../../internal/picker.js';
7
- import { displaySamples, formatDate, isDayOutside, isValidDate, localeWeekStart, mergeDateAndTime, startOfDay, startOfMonth, toISODate, today, withPlaceholder } from '../../internal/date.js';
8
- import { cx } from '../../internal/styles.js';
9
- /**
10
- * One day, chosen from a calendar.
11
- *
12
- * The trigger is a `PlTextField`'s shell wearing a calendar glyph, on purpose
13
- * and for the reason a `PlSelect`'s is: a form where the date field is a
14
- * different height, radius or material from the fields around it is a form that
15
- * looks assembled.
16
- *
17
- * What the calendar is actually for is the header. A picker that only steps a
18
- * month at a time puts a birthday thirty years back a hundred and eighty clicks
19
- * away, so the month name and the year are each a button that opens a grid of
20
- * its own — twelve months, then twelve years at a time. Any month of the year on
21
- * screen is two clicks; any year at all is three.
22
- *
23
- * There is no typing into the trigger. Parsing a date out of free text is
24
- * locale-dependent in a way that cannot be done honestly without a date library,
25
- * and a field that understands `27/7/26` in one browser and not in the next is
26
- * worse than one that never claimed to.
27
- */
28
- export const PlDatePicker = /* @__PURE__ */ React.forwardRef(function PlDatePicker({ value: valueProp, defaultValue, onValueChange, open: openProp, defaultOpen, onOpenChange, defaultMonth, minDate, maxDate, shouldDisableDate, locale, weekStartsOn, format = { dateStyle: 'medium' }, placeholder, clearable = false, showTodayButton = true, closeOnSelect = true, labels: labelOverrides, name, size = 'md', color = 'primary', readOnly = false, disabled = false, startIcon, ...shell }, ref) {
29
- const labels = usePickerLabels(labelOverrides);
30
- const firstDay = weekStartsOn ?? localeWeekStart(locale);
31
- const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue ?? null);
32
- // `null` is a value a controlled picker legitimately holds — an emptied one —
33
- // so the test is against `undefined` and never against falsiness.
34
- const value = valueProp !== undefined ? valueProp : uncontrolledValue;
35
- const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen ?? false);
36
- const open = openProp ?? uncontrolledOpen;
37
- const [month, setMonth] = React.useState(() => startOfMonth(isValidDate(value) ? value : (defaultMonth ?? today())));
38
- // Opening puts the calendar back on the chosen day. Without this, a picker
39
- // left on 2019 while browsing stays there the next time it is opened, which
40
- // reads as the control having forgotten its own value.
41
- React.useEffect(() => {
42
- if (open) {
43
- setMonth(startOfMonth(isValidDate(value) ? value : (defaultMonth ?? today())));
44
- }
45
- // Only when the popup opens — following `value` here would drag the
46
- // calendar out from under someone typing into a form elsewhere.
47
- // eslint-disable-next-line react-hooks/exhaustive-deps
48
- }, [open]);
49
- const setOpen = (next) => {
50
- // A read-only picker does not open. What it holds is something to read, and
51
- // a calendar whose every cell was inert would be a menu of nothing.
52
- if (next && (readOnly || disabled)) {
53
- return;
54
- }
55
- if (openProp === undefined) {
56
- setUncontrolledOpen(next);
57
- }
58
- onOpenChange?.(next);
59
- };
60
- const commit = (next) => {
61
- if (valueProp === undefined) {
62
- setUncontrolledValue(next);
63
- }
64
- onValueChange?.(next);
65
- };
66
- const select = (date) => {
67
- // The day changes; the time of day, if the value had one, does not. A
68
- // picker bound to a field that also carries a time should not silently
69
- // reset it to midnight every time the day is corrected.
70
- const next = isValidDate(value) ? mergeDateAndTime(date, value) : startOfDay(date);
71
- commit(next);
72
- setMonth(startOfMonth(next));
73
- if (closeOnSelect) {
74
- setOpen(false);
75
- }
76
- };
77
- const now = today();
78
- const todayBlocked = isDayOutside(now, minDate, maxDate) || (shouldDisableDate?.(now) ?? false);
79
- const hasFooter = showTodayButton || clearable;
80
- // Holds the trigger open at the width of the longest date it could show, so
81
- // choosing the 1st after the 28th does not shrink the field.
82
- const samples = React.useMemo(() => withPlaceholder(displaySamples(locale, format), placeholder), [locale, format, placeholder]);
83
- return (_jsx(PickerShell, { ...shell, size: size, color: color, readOnly: readOnly, disabled: disabled, triggerRef: ref, startIcon: startIcon ?? _jsx(CalendarIcon, {}), display: isValidDate(value) ? formatDate(value, locale, format) : (placeholder ?? ''), samples: samples, empty: !isValidDate(value), clearable: clearable, onClear: () => commit(null), open: open, onOpenChange: setOpen, labels: labels, hiddenValues: name ? [{ name, value: isValidDate(value) ? toISODate(value) : '' }] : undefined, children: _jsxs("div", { className: cx('flex flex-col', hasFooter && 'gap-1.5'), children: [_jsx(Calendar, { size: size, color: color, locale: locale, weekStartsOn: firstDay, month: month, onMonthChange: setMonth, selected: [value], onSelect: select, minDate: minDate, maxDate: maxDate, shouldDisableDate: shouldDisableDate, labels: labels, autoFocus: true }), hasFooter ? (_jsxs(PickerFooter, { size: size, children: [clearable ? (_jsx(PlButton, { variant: "ghost", size: size, color: color, density: "compact", onClick: () => {
84
- commit(null);
85
- setOpen(false);
86
- }, children: labels.clear })) : null, showTodayButton ? (_jsx(PlButton, { variant: "ghost", size: size, color: color, density: "compact", disabled: todayBlocked, onClick: () => select(now), children: labels.today })) : null] })) : null] }) }));
87
- });
1
+ "use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as l from"react";import{PlButton as t}from"../button/PlButton.js";import{Calendar as o,usePickerLabels as n}from"../../internal/calendar.js";import{CalendarIcon as r}from"../../internal/icons.js";import{PickerFooter as s,PickerShell as i}from"../../internal/picker.js";import{displaySamples as c,formatDate as d,isDayOutside as m,isValidDate as u,localeWeekStart as p,mergeDateAndTime as f,startOfDay as h,startOfMonth as b,toISODate as y,today as D,withPlaceholder as g}from"../../internal/date.js";import{cx as j}from"../../internal/styles.js";export const PlDatePicker=/* @__PURE__ */l.forwardRef(function PlDatePicker({value:v,defaultValue:x,onValueChange:O,open:S,defaultOpen:k,onOpenChange:C,defaultMonth:z,minDate:P,maxDate:w,shouldDisableDate:M,locale:V,weekStartsOn:B,format:I={dateStyle:"medium"},placeholder:R,clearable:E=!1,showTodayButton:F=!0,closeOnSelect:N=!0,labels:T,name:q,size:A="md",color:G="primary",readOnly:H=!1,disabled:J=!1,startIcon:K,...L},Q){const U=n(T),W=B??p(V),[X,Y]=l.useState(x??null),Z=void 0!==v?v:X,[$,_]=l.useState(k??!1),ee=S??$,[ae,le]=l.useState(()=>b(u(Z)?Z:z??D()));l.useEffect(()=>{ee&&le(b(u(Z)?Z:z??D()))},[ee]);const setOpen=e=>{e&&(H||J)||(void 0===S&&_(e),C?.(e))},commit=e=>{void 0===v&&Y(e),O?.(e)},select=e=>{const a=u(Z)?f(e,Z):h(e);commit(a),le(b(a)),N&&setOpen(!1)},te=D(),oe=m(te,P,w)||(M?.(te)??!1),ne=F||E,re=l.useMemo(()=>g(c(V,I),R),[V,I,R]);return e(i,{...L,size:A,color:G,readOnly:H,disabled:J,triggerRef:Q,startIcon:K??e(r,{}),display:u(Z)?d(Z,V,I):R??"",samples:re,empty:!u(Z),clearable:E,onClear:()=>commit(null),open:ee,onOpenChange:setOpen,labels:U,hiddenValues:q?[{name:q,value:u(Z)?y(Z):""}]:void 0,children:a("div",{className:j("flex flex-col",ne&&"gap-1.5"),children:[e(o,{size:A,color:G,locale:V,weekStartsOn:W,month:ae,onMonthChange:le,selected:[Z],onSelect:select,minDate:P,maxDate:w,shouldDisableDate:M,labels:U,autoFocus:!0}),ne?a(s,{size:A,children:[E?e(t,{variant:"ghost",size:A,color:G,density:"compact",onClick:()=>{commit(null),setOpen(!1)},children:U.clear}):null,F?e(t,{variant:"ghost",size:A,color:G,density:"compact",disabled:oe,onClick:()=>select(te),children:U.today}):null]}):null]})})});
@@ -1 +1 @@
1
- export { PlDatePicker } from './PlDatePicker.js';
1
+ export{PlDatePicker}from"./PlDatePicker.js";