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,65 +1 @@
1
- import * as React from 'react';
2
- import { useRender } from '@base-ui/react/use-render';
3
- import { isInfinite, useAnimateElement } from '../../internal/animate.js';
4
- import { cx, radiusClasses } from '../../internal/styles.js';
5
- /**
6
- * A light travelling around the outside of something.
7
- *
8
- * The light is **behind** the content rather than on it, so what a reader sees
9
- * is a glow escaping from under the edges — which is why it works on a PlCard
10
- * or a PlButton without touching anything about how they are drawn. Nothing
11
- * inside is altered, nothing is overlaid, and the content stays exactly as
12
- * legible as it was.
13
- *
14
- * The arc itself is a gradient that turns between the two ends of the family,
15
- * which is the same rule every filled surface in the library follows: a flat
16
- * coloured arc would be paint, and nothing here is paint.
17
- *
18
- * Use it to mark the one thing on a screen that is currently live — the row
19
- * that is processing, the field being checked, the plan being recommended. It
20
- * draws attention with light rather than by moving anything, which is the only
21
- * way this library has of saying "here" without also saying "and it moved".
22
- *
23
- * `size` has to agree with the radius of what is inside it. The glow follows
24
- * the wrapper's own corners, so an `lg` card in an `xs` Lighting will show light
25
- * poking out of four corners the card has already rounded away.
26
- */
27
- export const PlAnimateLighting = /* @__PURE__ */ React.forwardRef(function PlAnimateLighting({ duration = 3000, delay = 0, easing, repeat = 'infinite', alternate, paused, trigger = 'mount', play, once = true, threshold = 0.2, color = 'primary', glow, size = 'md', spread = 3, arc = 50, blur = 5, reverse = false, render, className, style, children, ...props }, ref) {
28
- const animate = useAnimateElement({
29
- // The keyframe runs on a pseudo-element rather than on the root, so there
30
- // is no effect class to apply here — only the slots it reads.
31
- effect: null,
32
- duration,
33
- delay,
34
- easing,
35
- repeat,
36
- alternate,
37
- mode: reverse ? 'out' : 'in',
38
- trigger,
39
- play,
40
- once,
41
- threshold,
42
- paused,
43
- infinite: isInfinite(repeat)
44
- });
45
- return useRender({
46
- render,
47
- ref: [ref, animate.ref],
48
- props: {
49
- ...props,
50
- className: cx('plass-anim-lighting', radiusClasses[size], className),
51
- style: {
52
- ...animate.style,
53
- '--p-anim-glow-from': glow ?? `var(--plass-${color}-solid)`,
54
- '--p-anim-glow-to': glow ?? `var(--plass-${color}-solid-to)`,
55
- '--p-anim-glow-width': `${spread}px`,
56
- '--p-anim-glow-arc': `${arc}deg`,
57
- '--p-anim-glow-blur': `${blur}px`,
58
- ...style
59
- },
60
- ...animate.props,
61
- 'data-plass-animation': 'lighting',
62
- children
63
- }
64
- });
65
- });
1
+ "use client";import*as e from"react";import{useRender as r}from"@base-ui/react/use-render";import{isInfinite as a,useAnimateElement as i}from"../../internal/animate.js";import{cx as t,radiusClasses as n}from"../../internal/styles.js";export const PlAnimateLighting=/* @__PURE__ */e.forwardRef(function PlAnimateLighting({duration:e=3e3,delay:l=0,easing:o,repeat:s="infinite",alternate:p,paused:m,trigger:d="mount",play:g,once:c=!0,threshold:f=.2,color:u="primary",glow:h,size:y="md",spread:w=3,arc:$=50,blur:b=5,reverse:v=!1,render:x,className:j,style:A,children:L,...N},P){const z=i({effect:null,duration:e,delay:l,easing:o,repeat:s,alternate:p,mode:v?"out":"in",trigger:d,play:g,once:c,threshold:f,paused:m,infinite:a(s)});return r({render:x,ref:[P,z.ref],props:{...N,className:t("plass-anim-lighting",n[y],j),style:{...z.style,"--p-anim-glow-from":h??`var(--plass-${u}-solid)`,"--p-anim-glow-to":h??`var(--plass-${u}-solid-to)`,"--p-anim-glow-width":`${w}px`,"--p-anim-glow-arc":`${$}deg`,"--p-anim-glow-blur":`${b}px`,...A},...z.props,"data-plass-animation":"lighting",children:L}})});
@@ -1 +1 @@
1
- export { PlAnimateLighting } from './PlAnimateLighting.js';
1
+ export{PlAnimateLighting}from"./PlAnimateLighting.js";
@@ -1,94 +1 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import * as React from 'react';
3
- import { isInfinite, lengthValue, repeatValue, directionValue, useAnimationRun } from '../../internal/animate.js';
4
- import { cx } from '../../internal/styles.js';
5
- /**
6
- * Content scrolling steadily past, forever.
7
- *
8
- * The content is laid down twice, and each copy travels exactly its own length
9
- * plus the gap — so the moment the first copy has left, the second is standing
10
- * precisely where it began. There is no seam, no jump and no frame where the
11
- * strip is empty, and none of that depends on measuring anything.
12
- *
13
- * What *is* measured is only the speed. A duration would mean a strip of four
14
- * logos and a strip of forty crossing the same box in the same time, with the
15
- * long one becoming unreadable; `speed` is pixels per second, so both move at
16
- * the pace of a reader instead. The strip is re-measured whenever it changes
17
- * size.
18
- *
19
- * `pauseOnHover` is on by default and is not decoration: content moving past a
20
- * pointer cannot be clicked reliably, and a link inside a marquee that never
21
- * stops is a link nobody can follow.
22
- *
23
- * Only the first copy is read out. The rest carry `aria-hidden`, or a screen
24
- * reader would announce everything on the strip as many times as it was laid
25
- * down.
26
- */
27
- export const PlAnimateMarquee = /* @__PURE__ */ React.forwardRef(function PlAnimateMarquee({ duration, delay = 0, easing, repeat = 'infinite', alternate, paused, trigger = 'mount', play, once = true, threshold = 0.2, orientation = 'horizontal', reverse = false, speed = 60, gap = '2rem', copies = 2, pauseOnHover = true, className, style, children, ...props }, ref) {
28
- const run = useAnimationRun({
29
- trigger,
30
- play,
31
- once,
32
- threshold,
33
- paused,
34
- infinite: isInfinite(repeat)
35
- });
36
- const boxRef = React.useRef(null);
37
- const trackRef = React.useRef(null);
38
- const [travel, setTravel] = React.useState(0);
39
- const vertical = orientation === 'vertical';
40
- /**
41
- * How far one copy has to go, in pixels: its own length plus the gap after
42
- * it. The gap is read back off the computed style rather than parsed out of
43
- * the prop, because `'2rem'` is only a number once a font size has been
44
- * resolved — and the one on the page is the one that matters.
45
- */
46
- React.useEffect(() => {
47
- const box = boxRef.current;
48
- const track = trackRef.current;
49
- if (!box || !track) {
50
- return;
51
- }
52
- const measure = () => {
53
- const styles = getComputedStyle(box);
54
- const gapPx = parseFloat(vertical ? styles.rowGap : styles.columnGap) || 0;
55
- const size = vertical ? track.offsetHeight : track.offsetWidth;
56
- setTravel(size + gapPx);
57
- };
58
- measure();
59
- if (typeof ResizeObserver === 'undefined') {
60
- return;
61
- }
62
- const observer = new ResizeObserver(measure);
63
- observer.observe(track);
64
- observer.observe(box);
65
- return () => observer.disconnect();
66
- }, [vertical, children]);
67
- // An explicit duration wins; otherwise the measurement decides, and until the
68
- // first measurement lands there is a sane number rather than `0ms`, which
69
- // browsers read as "finish immediately".
70
- const runDuration = duration ?? (travel > 0 ? (travel / speed) * 1000 : 12000);
71
- const track = (index) => (_jsx("div", { ref: index === 0 ? trackRef : undefined, className: "plass-marquee-track", "aria-hidden": index === 0 ? undefined : 'true', children: children }, index));
72
- return (_jsx("div", { ref: (node) => {
73
- boxRef.current = node;
74
- run.ref(node);
75
- if (typeof ref === 'function') {
76
- ref(node);
77
- }
78
- else if (ref) {
79
- ref.current = node;
80
- }
81
- }, className: cx('plass-marquee', vertical && 'plass-marquee-vertical', className), style: {
82
- '--p-anim-gap': lengthValue(gap),
83
- // Linear unless a caller insists otherwise: an eased marquee slows at
84
- // both ends of a loop that has no ends, which reads as the page
85
- // stuttering.
86
- ...(easing ? { '--p-anim-ease': easing } : {}),
87
- '--p-anim-duration': `${Math.round(runDuration)}ms`,
88
- '--p-anim-delay': `${delay}ms`,
89
- '--p-anim-repeat': repeatValue(repeat),
90
- '--p-anim-direction': directionValue(reverse ? 'out' : 'in', alternate),
91
- '--p-anim-state': run.state,
92
- ...style
93
- }, "data-plass-animation": "marquee", "data-state": run.state, "data-pause-on-hover": pauseOnHover ? '' : undefined, ...run.handlers, ...props, children: Array.from({ length: Math.max(1, copies) }, (_, index) => track(index)) }));
94
- });
1
+ "use client";import{jsx as e}from"react/jsx-runtime";import*as t from"react";import{isInfinite as a,lengthValue as r,repeatValue as n,directionValue as s,useAnimationRun as i}from"../../internal/animate.js";import{cx as o}from"../../internal/styles.js";export const PlAnimateMarquee=/* @__PURE__ */t.forwardRef(function PlAnimateMarquee({duration:l,delay:u=0,easing:m,repeat:p="infinite",alternate:c,paused:d,trigger:f="mount",play:h,once:v=!0,threshold:y=.2,orientation:g="horizontal",reverse:q=!1,speed:R=60,gap:b="2rem",copies:j=2,pauseOnHover:x=!0,className:M,style:w,children:z,...A},N){const O=i({trigger:f,play:h,once:v,threshold:y,paused:d,infinite:a(p)}),G=t.useRef(null),H=t.useRef(null),[P,S]=t.useState(0),$="vertical"===g;t.useEffect(()=>{const e=G.current,t=H.current;if(!e||!t)return;const measure=()=>{const a=getComputedStyle(e),r=parseFloat($?a.rowGap:a.columnGap)||0,n=$?t.offsetHeight:t.offsetWidth;S(n+r)};if(measure(),"undefined"==typeof ResizeObserver)return;const a=new ResizeObserver(measure);return a.observe(t),a.observe(e),()=>a.disconnect()},[$,z]);const k=l??(P>0?P/R*1e3:12e3);return e("div",{ref:e=>{G.current=e,O.ref(e),"function"==typeof N?N(e):N&&(N.current=e)},className:o("plass-marquee",$&&"plass-marquee-vertical",M),style:{"--p-anim-gap":r(b),...m?{"--p-anim-ease":m}:{},"--p-anim-duration":`${Math.round(k)}ms`,"--p-anim-delay":`${u}ms`,"--p-anim-repeat":n(p),"--p-anim-direction":s(q?"out":"in",c),"--p-anim-state":O.state,...w},"data-plass-animation":"marquee","data-state":O.state,"data-pause-on-hover":x?"":void 0,...O.handlers,...A,children:Array.from({length:Math.max(1,j)},(t,a)=>(t=>e("div",{ref:0===t?H:void 0,className:"plass-marquee-track","aria-hidden":0===t?void 0:"true",children:z},t))(a))})});
@@ -1 +1 @@
1
- export { PlAnimateMarquee } from './PlAnimateMarquee.js';
1
+ export{PlAnimateMarquee}from"./PlAnimateMarquee.js";
@@ -1,50 +1 @@
1
- import * as React from 'react';
2
- import { useRender } from '@base-ui/react/use-render';
3
- import { isInfinite, useAnimateElement } from '../../internal/animate.js';
4
- import { cx } from '../../internal/styles.js';
5
- /**
6
- * Content turning about a point.
7
- *
8
- * Two angles rather than one, which is what lets this be both effects a
9
- * rotation is ever used for. `from` alone is an arrival — something swinging
10
- * into place and stopping. `from` and `to` together with `repeat="infinite"`
11
- * and `easing="linear"` is a spin that never lands, which is what a badge, a
12
- * loading mark or a decorative glyph wants.
13
- *
14
- * Rotation is the one movement the design language allows on a glyph without
15
- * argument — a chevron is turned rather than redrawn all over the library. What
16
- * it is not for is text: a rotated word is resampled along its whole length,
17
- * which is precisely what the rule against transforming a control exists to
18
- * prevent.
19
- */
20
- export const PlAnimateRotate = /* @__PURE__ */ React.forwardRef(function PlAnimateRotate({ duration = 440, delay = 0, easing, repeat = 1, alternate, paused, trigger = 'mount', play, once = true, threshold = 0.2, mode = 'in', from = -180, to = 0, origin = 'center', fade = true, render, className, style, children, ...props }, ref) {
21
- const animate = useAnimateElement({
22
- effect: 'rotate',
23
- duration,
24
- delay,
25
- easing,
26
- repeat,
27
- alternate,
28
- mode,
29
- angle: `${from}deg`,
30
- angleTo: `${to}deg`,
31
- opacity: fade ? 0 : 1,
32
- trigger,
33
- play,
34
- once,
35
- threshold,
36
- paused,
37
- infinite: isInfinite(repeat)
38
- });
39
- return useRender({
40
- render,
41
- ref: [ref, animate.ref],
42
- props: {
43
- ...props,
44
- className: cx(animate.className, className),
45
- style: { transformOrigin: origin, ...animate.style, ...style },
46
- ...animate.props,
47
- children
48
- }
49
- });
50
- });
1
+ "use client";import*as e from"react";import{useRender as r}from"@base-ui/react/use-render";import{isInfinite as t,useAnimateElement as a}from"../../internal/animate.js";import{cx as n}from"../../internal/styles.js";export const PlAnimateRotate=/* @__PURE__ */e.forwardRef(function PlAnimateRotate({duration:e=440,delay:o=0,easing:i,repeat:s=1,alternate:l,paused:d,trigger:m="mount",play:c,once:p=!0,threshold:f=.2,mode:g="in",from:u=-180,to:y=0,origin:h="center",fade:N=!0,render:R,className:j,style:A,children:P,...$},b){const w=a({effect:"rotate",duration:e,delay:o,easing:i,repeat:s,alternate:l,mode:g,angle:`${u}deg`,angleTo:`${y}deg`,opacity:N?0:1,trigger:m,play:c,once:p,threshold:f,paused:d,infinite:t(s)});return r({render:R,ref:[b,w.ref],props:{...$,className:n(w.className,j),style:{transformOrigin:h,...w.style,...A},...w.props,children:P}})});
@@ -1 +1 @@
1
- export { PlAnimateRotate } from './PlAnimateRotate.js';
1
+ export{PlAnimateRotate}from"./PlAnimateRotate.js";
@@ -1,49 +1 @@
1
- import * as React from 'react';
2
- import { useRender } from '@base-ui/react/use-render';
3
- import { isInfinite, slideOffsets, useAnimateElement } from '../../internal/animate.js';
4
- import { cx } from '../../internal/styles.js';
5
- /**
6
- * Content travelling in from one edge.
7
- *
8
- * The default distance is the element's own size, so it starts exactly out of
9
- * frame and arrives without ever having been half drawn somewhere it does not
10
- * belong. Put it in a box with `overflow: hidden` and the effect is a panel
11
- * appearing from behind that box's edge.
12
- *
13
- * A slide moves the element, so what is *around* it does not move: this is a
14
- * `translate` rather than a change of layout, and nothing on the page reflows
15
- * while it runs. For a much shorter travel over a list of things, one after
16
- * another, use PlAnimateAppear.
17
- */
18
- export const PlAnimateSlide = /* @__PURE__ */ React.forwardRef(function PlAnimateSlide({ duration = 360, delay = 0, easing, repeat = 1, alternate, paused, trigger = 'mount', play, once = true, threshold = 0.2, mode = 'in', from = 'bottom', distance = '100%', fade = true, render, className, style, children, ...props }, ref) {
19
- const { x, y } = slideOffsets(from, distance);
20
- const animate = useAnimateElement({
21
- effect: 'slide',
22
- duration,
23
- delay,
24
- easing,
25
- repeat,
26
- alternate,
27
- mode,
28
- x,
29
- y,
30
- opacity: fade ? 0 : 1,
31
- trigger,
32
- play,
33
- once,
34
- threshold,
35
- paused,
36
- infinite: isInfinite(repeat)
37
- });
38
- return useRender({
39
- render,
40
- ref: [ref, animate.ref],
41
- props: {
42
- ...props,
43
- className: cx(animate.className, className),
44
- style: { ...animate.style, ...style },
45
- ...animate.props,
46
- children
47
- }
48
- });
49
- });
1
+ "use client";import*as e from"react";import{useRender as r}from"@base-ui/react/use-render";import{isInfinite as t,slideOffsets as a,useAnimateElement as n}from"../../internal/animate.js";import{cx as i}from"../../internal/styles.js";export const PlAnimateSlide=/* @__PURE__ */e.forwardRef(function PlAnimateSlide({duration:e=360,delay:s=0,easing:o,repeat:l=1,alternate:d,paused:m,trigger:c="mount",play:p,once:f=!0,threshold:y=.2,mode:u="in",from:g="bottom",distance:h="100%",fade:x=!0,render:N,className:b,style:j,children:A,...P},S){const{x:w,y:R}=a(g,h),k=n({effect:"slide",duration:e,delay:s,easing:o,repeat:l,alternate:d,mode:u,x:w,y:R,opacity:x?0:1,trigger:c,play:p,once:f,threshold:y,paused:m,infinite:t(l)});return r({render:N,ref:[S,k.ref],props:{...P,className:i(k.className,b),style:{...k.style,...j},...k.props,children:A}})});
@@ -1 +1 @@
1
- export { PlAnimateSlide } from './PlAnimateSlide.js';
1
+ export{PlAnimateSlide}from"./PlAnimateSlide.js";
@@ -1,177 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import * as React from 'react';
3
- import { isInfinite, useAnimationRun, usePrefersReducedMotion } from '../../internal/animate.js';
4
- import { srOnlyClasses } from '../../internal/styles.js';
5
- /**
6
- * Everything typeable in a node, flattened.
7
- *
8
- * Elements are deliberately not walked into. A typewriter reveals a string one
9
- * grapheme at a time, and there is no honest way to reveal half of a `<strong>`
10
- * — the effect is over text, so its input is text.
11
- */
12
- function textOf(node) {
13
- if (typeof node === 'string' || typeof node === 'number') {
14
- return String(node);
15
- }
16
- if (Array.isArray(node)) {
17
- return node.map(textOf).join('');
18
- }
19
- return '';
20
- }
21
- /**
22
- * The text split the way a reader would split it.
23
- *
24
- * Not `[...text]`, and not `text.split('')`. A code point is not a character:
25
- * `👩‍👩‍👧` is seven of them, `한` typed on a Korean keyboard can be three, and a
26
- * typewriter that advances by code points spends four frames assembling an
27
- * emoji out of parts that mean nothing on their own. `Intl.Segmenter` knows
28
- * where the boundaries actually are; the spread is the fallback for a runtime
29
- * that does not have it.
30
- */
31
- function graphemesOf(text, locale) {
32
- if (typeof Intl !== 'undefined' && 'Segmenter' in Intl) {
33
- const segmenter = new Intl.Segmenter(locale, { granularity: 'grapheme' });
34
- return [...segmenter.segment(text)].map((segment) => segment.segment);
35
- }
36
- return [...text];
37
- }
38
- /**
39
- * Text appearing one character at a time.
40
- *
41
- * The whole string is in the document from the first frame — in a clipped box
42
- * for a screen reader, which reads it once and is not made to sit through the
43
- * performance — and what animates is a visible copy that is `aria-hidden`. So
44
- * the effect costs a reader who cannot see it nothing, and costs a reader who
45
- * can nothing either: the box is not laid out from the characters that have
46
- * arrived, so the text around it does not reflow on every frame.
47
- *
48
- * `repeat`, `hold` and `erase` are what make it a loop: type, hold, delete,
49
- * type again. Without `erase` a repeat clears in one frame, which is right for
50
- * a line that is being replaced rather than rewritten.
51
- *
52
- * Only text is typed. Pass a string, or strings; an element among the children
53
- * contributes its text and nothing about its markup, because there is no honest
54
- * way to reveal half of a link.
55
- */
56
- export const PlAnimateTyping = /* @__PURE__ */ React.forwardRef(function PlAnimateTyping({ text, speed = 24, hold = 1400, erase = false, eraseSpeed, caret = true, caretChar = '|', duration, delay = 0, repeat = 1, paused, trigger = 'mount', play, once = true, threshold = 0.2, className, style, children, ...props }, ref) {
57
- const run = useAnimationRun({
58
- trigger,
59
- play,
60
- once,
61
- threshold,
62
- paused,
63
- infinite: isInfinite(repeat)
64
- });
65
- const reduced = usePrefersReducedMotion();
66
- const source = text ?? textOf(children);
67
- const graphemes = React.useMemo(() => graphemesOf(source), [source]);
68
- const total = graphemes.length;
69
- const [shown, setShown] = React.useState(0);
70
- /**
71
- * How far along it is, outside React's state.
72
- *
73
- * The typing loop is a chain of timeouts rather than a render, so pausing
74
- * tears it down and resuming builds a new one — and a new one has to know
75
- * where the old one stopped. Reading `shown` would put the effect in a loop
76
- * with its own output.
77
- */
78
- const progress = React.useRef(0);
79
- /**
80
- * `duration` is honoured as the time for the whole string, because a caller
81
- * who has set a duration on every other PlAnimate component will reach for it
82
- * here too. `speed` is the natural unit for a typewriter — a long paragraph
83
- * and a short one should be typed at the same pace, not in the same time — so
84
- * it is the default and the duration overrides it.
85
- */
86
- const typeDelay = duration && total > 0 ? duration / total : 1000 / Math.max(speed, 1);
87
- const deleteDelay = 1000 / Math.max(eraseSpeed ?? speed * 2, 1);
88
- // A new string starts a new performance rather than continuing the last.
89
- React.useEffect(() => {
90
- progress.current = 0;
91
- }, [total]);
92
- React.useEffect(() => {
93
- if (reduced || total === 0) {
94
- // Not "nothing happens" — the text is simply there, which is the only
95
- // outcome that still delivers what the component was carrying.
96
- setShown(total);
97
- return;
98
- }
99
- if (!run.started) {
100
- // Waiting is empty, not finished: a typewriter that showed its whole
101
- // string until it scrolled into view and then blanked would be worse than
102
- // no effect at all.
103
- progress.current = 0;
104
- setShown(0);
105
- return;
106
- }
107
- if (paused) {
108
- return;
109
- }
110
- let cancelled = false;
111
- let timer;
112
- let count = progress.current;
113
- let pass = 1;
114
- let deleting = false;
115
- const passes = repeat === 'infinite' ? Infinity : Math.max(1, repeat);
116
- if (count >= total && passes === 1) {
117
- return;
118
- }
119
- const step = () => {
120
- if (cancelled) {
121
- return;
122
- }
123
- if (deleting) {
124
- count -= 1;
125
- progress.current = count;
126
- setShown(count);
127
- if (count <= 0) {
128
- deleting = false;
129
- pass += 1;
130
- }
131
- timer = setTimeout(step, deleting ? deleteDelay : typeDelay);
132
- return;
133
- }
134
- count += 1;
135
- progress.current = count;
136
- setShown(count);
137
- if (count < total) {
138
- timer = setTimeout(step, typeDelay);
139
- return;
140
- }
141
- if (pass >= passes) {
142
- return;
143
- }
144
- if (erase) {
145
- deleting = true;
146
- timer = setTimeout(step, hold);
147
- return;
148
- }
149
- pass += 1;
150
- timer = setTimeout(() => {
151
- if (cancelled) {
152
- return;
153
- }
154
- count = 0;
155
- progress.current = 0;
156
- setShown(0);
157
- timer = setTimeout(step, typeDelay);
158
- }, hold);
159
- };
160
- setShown(count);
161
- // Resuming picks up at the next character; starting waits out the delay.
162
- timer = setTimeout(step, count === 0 ? delay : typeDelay);
163
- return () => {
164
- cancelled = true;
165
- clearTimeout(timer);
166
- };
167
- }, [run.started, paused, reduced, total, typeDelay, deleteDelay, delay, hold, erase, repeat]);
168
- return (_jsxs("div", { ref: (node) => {
169
- run.ref(node);
170
- if (typeof ref === 'function') {
171
- ref(node);
172
- }
173
- else if (ref) {
174
- ref.current = node;
175
- }
176
- }, className: className, style: style, "data-plass-animation": "typing", "data-state": run.state, ...run.handlers, ...props, children: [_jsx("span", { className: srOnlyClasses, children: source }), _jsxs("span", { "aria-hidden": "true", className: "whitespace-pre-wrap", children: [graphemes.slice(0, shown).join(''), caret ? _jsx("span", { className: "plass-caret", children: caretChar }) : null] })] }));
177
- });
1
+ "use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as r from"react";import{isInfinite as n,useAnimationRun as a,usePrefersReducedMotion as i}from"../../internal/animate.js";import{srOnlyClasses as s}from"../../internal/styles.js";function textOf(e){return"string"==typeof e||"number"==typeof e?String(e):Array.isArray(e)?e.map(textOf).join(""):""}export const PlAnimateTyping=/* @__PURE__ */r.forwardRef(function PlAnimateTyping({text:o,speed:u=24,hold:m=1400,erase:c=!1,eraseSpeed:l,caret:f=!0,caretChar:p="|",duration:d,delay:h=0,repeat:g=1,paused:y,trigger:x="mount",play:T,once:j=!0,threshold:v=.2,className:N,style:S,children:w,...A},M){const O=a({trigger:x,play:T,once:j,threshold:v,paused:y,infinite:n(g)}),I=i(),E=o??textOf(w),P=r.useMemo(()=>function graphemesOf(e,t){return"undefined"!=typeof Intl&&"Segmenter"in Intl?[...new Intl.Segmenter(t,{granularity:"grapheme"}).segment(e)].map(e=>e.segment):[...e]}(E),[E]),R=P.length,[b,C]=r.useState(0),k=r.useRef(0),q=d&&R>0?d/R:1e3/Math.max(u,1),z=1e3/Math.max(l??2*u,1);return r.useEffect(()=>{k.current=0},[R]),r.useEffect(()=>{if(I||0===R)return void C(R);if(!O.started)return k.current=0,void C(0);if(y)return;let e,t=!1,r=k.current,n=1,a=!1;const i="infinite"===g?1/0:Math.max(1,g);if(r>=R&&1===i)return;const step=()=>{if(!t){if(a)return r-=1,k.current=r,C(r),r<=0&&(a=!1,n+=1),void(e=setTimeout(step,a?z:q));if(r+=1,k.current=r,C(r),r<R)e=setTimeout(step,q);else if(!(n>=i)){if(c)return a=!0,void(e=setTimeout(step,m));n+=1,e=setTimeout(()=>{t||(r=0,k.current=0,C(0),e=setTimeout(step,q))},m)}}};return C(r),e=setTimeout(step,0===r?h:q),()=>{t=!0,clearTimeout(e)}},[O.started,y,I,R,q,z,h,m,c,g]),t("div",{ref:e=>{O.ref(e),"function"==typeof M?M(e):M&&(M.current=e)},className:N,style:S,"data-plass-animation":"typing","data-state":O.state,...O.handlers,...A,children:[e("span",{className:s,children:E}),t("span",{"aria-hidden":"true",className:"whitespace-pre-wrap",children:[P.slice(0,b).join(""),f?e("span",{className:"plass-caret",children:p}):null]})]})});
@@ -1 +1 @@
1
- export { PlAnimateTyping } from './PlAnimateTyping.js';
1
+ export{PlAnimateTyping}from"./PlAnimateTyping.js";
@@ -1,45 +1 @@
1
- import * as React from 'react';
2
- import { useRender } from '@base-ui/react/use-render';
3
- import { isInfinite, useAnimateElement } from '../../internal/animate.js';
4
- import { cx } from '../../internal/styles.js';
5
- /**
6
- * Content arriving from the middle of where it will end up.
7
- *
8
- * The same arithmetic as Grow at more than twice the distance, and always about
9
- * the centre — which is the whole difference. A Grow unfolds from somewhere; a
10
- * Zoom comes at you. Use it for the one thing on a screen that is meant to
11
- * interrupt: a confirmation, a result, a number that has just landed.
12
- *
13
- * There is no `origin`, on purpose. A zoom anchored to a corner is a grow, and
14
- * the library does not offer two spellings of one idea.
15
- */
16
- export const PlAnimateZoom = /* @__PURE__ */ React.forwardRef(function PlAnimateZoom({ duration = 320, delay = 0, easing, repeat = 1, alternate, paused, trigger = 'mount', play, once = true, threshold = 0.2, mode = 'in', from = 0.4, fade = true, render, className, style, children, ...props }, ref) {
17
- const animate = useAnimateElement({
18
- effect: 'zoom',
19
- duration,
20
- delay,
21
- easing,
22
- repeat,
23
- alternate,
24
- mode,
25
- scale: from,
26
- opacity: fade ? 0 : 1,
27
- trigger,
28
- play,
29
- once,
30
- threshold,
31
- paused,
32
- infinite: isInfinite(repeat)
33
- });
34
- return useRender({
35
- render,
36
- ref: [ref, animate.ref],
37
- props: {
38
- ...props,
39
- className: cx(animate.className, className),
40
- style: { transformOrigin: 'center', ...animate.style, ...style },
41
- ...animate.props,
42
- children
43
- }
44
- });
45
- });
1
+ "use client";import*as e from"react";import{useRender as r}from"@base-ui/react/use-render";import{isInfinite as t,useAnimateElement as a}from"../../internal/animate.js";import{cx as n}from"../../internal/styles.js";export const PlAnimateZoom=/* @__PURE__ */e.forwardRef(function PlAnimateZoom({duration:e=320,delay:o=0,easing:s,repeat:i=1,alternate:l,paused:m,trigger:c="mount",play:d,once:p=!0,threshold:f=.2,mode:u="in",from:y=.4,fade:g=!0,render:h,className:N,style:j,children:A,...P},Z){const b=a({effect:"zoom",duration:e,delay:o,easing:s,repeat:i,alternate:l,mode:u,scale:y,opacity:g?0:1,trigger:c,play:d,once:p,threshold:f,paused:m,infinite:t(i)});return r({render:h,ref:[Z,b.ref],props:{...P,className:n(b.className,N),style:{transformOrigin:"center",...b.style,...j},...b.props,children:A}})});
@@ -1 +1 @@
1
- export { PlAnimateZoom } from './PlAnimateZoom.js';
1
+ export{PlAnimateZoom}from"./PlAnimateZoom.js";
@@ -1,58 +1 @@
1
- import * as React from 'react';
2
- import { useRender } from '@base-ui/react/use-render';
3
- import { cx, radiusClasses } from '../../internal/styles.js';
4
- /**
5
- * The media a `fit` reaches, stretched to the box first.
6
- *
7
- * Written out one selector at a time rather than as a comma list, because
8
- * Tailwind only ever sees class names that appear literally in the source and a
9
- * grouped arbitrary variant is one string it has to parse rather than match.
10
- *
11
- * `iframe` takes the sizing and not the fit: an embed lays its own content out
12
- * and `object-fit` has nothing to act on.
13
- */
14
- const stretchClasses = /* @__PURE__ */ [
15
- '[&>img]:size-full',
16
- '[&>video]:size-full',
17
- '[&>canvas]:size-full',
18
- '[&>svg]:size-full',
19
- '[&>iframe]:size-full',
20
- '[&>picture]:size-full',
21
- '[&>picture>img]:size-full'
22
- ].join(' ');
23
- const fitClasses = {
24
- cover: '[&>img]:object-cover [&>video]:object-cover [&>picture>img]:object-cover',
25
- contain: '[&>img]:object-contain [&>video]:object-contain [&>picture>img]:object-contain',
26
- fill: '[&>img]:object-fill [&>video]:object-fill [&>picture>img]:object-fill',
27
- none: '[&>img]:object-none [&>video]:object-none [&>picture>img]:object-none'
28
- };
29
- /**
30
- * A box that keeps a proportion whatever width it is given.
31
- *
32
- * It draws nothing — no sheet, no hairline, no shadow — which is what puts it
33
- * in `layout` beside `PlContainer` and `PlGrid` rather than in `surfaces`. What
34
- * it does is reserve the space: a card whose image arrives late does not reflow
35
- * the page around it, and a row of thumbnails is a row of one shape.
36
- *
37
- * The proportion is CSS's own `aspect-ratio`, so a caller who already knows
38
- * `16 / 9` has nothing to translate. `fit` is the one convenience on top: the
39
- * media inside is stretched to the box and then fitted, which is the pair of
40
- * declarations every use of this component would otherwise start with.
41
- */
42
- export const PlAspectRatio = /* @__PURE__ */ React.forwardRef(function PlAspectRatio({ ratio = 1, fit = 'cover', rounded = false, size = 'md', render, className, style, children, ...props }, ref) {
43
- const classNames = cx(
44
- // `overflow-hidden` is not decoration: without it a `cover` image spills
45
- // out of the proportion it was just given, and the box would only be
46
- // reserving space rather than holding anything to it.
47
- 'relative block w-full overflow-hidden', stretchClasses, fitClasses[fit], rounded ? radiusClasses[size] : '', className);
48
- return useRender({
49
- render,
50
- ref,
51
- props: {
52
- className: classNames,
53
- style: { aspectRatio: ratio, ...style },
54
- children,
55
- ...props
56
- }
57
- });
58
- });
1
+ "use client";import*as e from"react";import{useRender as i}from"@base-ui/react/use-render";import{cx as o,radiusClasses as t}from"../../internal/styles.js";const c=/* @__PURE__ */["[&>img]:size-full","[&>video]:size-full","[&>canvas]:size-full","[&>svg]:size-full","[&>iframe]:size-full","[&>picture]:size-full","[&>picture>img]:size-full"].join(" "),r={cover:"[&>img]:object-cover [&>video]:object-cover [&>picture>img]:object-cover",contain:"[&>img]:object-contain [&>video]:object-contain [&>picture>img]:object-contain",fill:"[&>img]:object-fill [&>video]:object-fill [&>picture>img]:object-fill",none:"[&>img]:object-none [&>video]:object-none [&>picture>img]:object-none"};export const PlAspectRatio=/* @__PURE__ */e.forwardRef(function PlAspectRatio({ratio:e=1,fit:l="cover",rounded:n=!1,size:s="md",render:a,className:f,style:m,children:u,...d},p){const b=o("relative block w-full overflow-hidden",c,r[l],n?t[s]:"",f);return i({render:a,ref:p,props:{className:b,style:{aspectRatio:e,...m},children:u,...d}})});
@@ -1 +1 @@
1
- export { PlAspectRatio } from './PlAspectRatio.js';
1
+ export{PlAspectRatio}from"./PlAspectRatio.js";