plass-ui 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +98 -0
- package/dist/components/accordion/PlAccordion.js +1 -1
- package/dist/components/alert/PlAlert.js +1 -1
- package/dist/components/animate-headline/PlAnimateHeadline.js +1 -1
- package/dist/components/animate-lighting/PlAnimateLighting.js +1 -1
- package/dist/components/animate-typing/PlAnimateTyping.js +1 -1
- package/dist/components/aspect-ratio/PlAspectRatio.js +1 -1
- package/dist/components/avatar/PlAvatar.js +1 -1
- package/dist/components/avatar-group/PlAvatarGroup.js +1 -1
- package/dist/components/back-top/PlBackTop.d.ts +55 -0
- package/dist/components/back-top/PlBackTop.js +1 -0
- package/dist/components/back-top/index.d.ts +2 -0
- package/dist/components/back-top/index.js +1 -0
- package/dist/components/badge/PlBadge.js +1 -1
- package/dist/components/blockquote/PlBlockquote.js +1 -1
- package/dist/components/bottom-navigation/PlBottomNavigation.js +1 -1
- package/dist/components/box/PlBox.js +1 -1
- package/dist/components/breadcrumb/PlBreadcrumb.js +1 -1
- package/dist/components/button/PlButton.js +1 -1
- package/dist/components/calendar/PlCalendar.d.ts +104 -0
- package/dist/components/calendar/PlCalendar.js +1 -0
- package/dist/components/calendar/index.d.ts +2 -0
- package/dist/components/calendar/index.js +1 -0
- package/dist/components/card/PlCard.js +1 -1
- package/dist/components/carousel/PlCarousel.js +1 -1
- package/dist/components/chat-bubble/PlChatBubble.js +1 -1
- package/dist/components/checkbox/PlCheckbox.d.ts +3 -1
- package/dist/components/checkbox/PlCheckbox.js +1 -1
- package/dist/components/chip/PlChip.js +1 -1
- package/dist/components/collapsible/PlCollapsible.js +1 -1
- package/dist/components/color-picker/PlColorPicker.js +1 -1
- package/dist/components/combobox/PlCombobox.d.ts +13 -2
- package/dist/components/combobox/PlCombobox.js +1 -1
- package/dist/components/command-palette/PlCommandPalette.d.ts +8 -2
- package/dist/components/command-palette/PlCommandPalette.js +1 -1
- package/dist/components/confirm/PlConfirmProvider.d.ts +100 -0
- package/dist/components/confirm/PlConfirmProvider.js +1 -0
- package/dist/components/confirm/index.d.ts +2 -0
- package/dist/components/confirm/index.js +1 -0
- package/dist/components/container/PlContainer.js +1 -1
- package/dist/components/date-picker/PlDatePicker.d.ts +41 -2
- package/dist/components/date-picker/PlDatePicker.js +1 -1
- package/dist/components/date-range-picker/PlDateRangePicker.js +1 -1
- package/dist/components/date-time-picker/PlDateTimePicker.js +1 -1
- package/dist/components/divider/PlDivider.js +1 -1
- package/dist/components/drawer/PlDrawer.d.ts +4 -2
- package/dist/components/drawer/PlDrawer.js +1 -1
- package/dist/components/empty/PlEmpty.d.ts +47 -0
- package/dist/components/empty/PlEmpty.js +1 -0
- package/dist/components/empty/index.d.ts +2 -0
- package/dist/components/empty/index.js +1 -0
- package/dist/components/file-picker/PlFilePicker.js +1 -1
- package/dist/components/floating-bottom-navigation/PlFloatingBottomNavigation.js +1 -1
- package/dist/components/footer/PlFooter.js +1 -1
- package/dist/components/header/PlHeader.js +1 -1
- package/dist/components/highlight/PlHighlight.js +1 -1
- package/dist/components/hot-keys/PlHotKeys.js +1 -1
- package/dist/components/image/PlImage.d.ts +72 -0
- package/dist/components/image/PlImage.js +1 -0
- package/dist/components/image/index.d.ts +2 -0
- package/dist/components/image/index.js +1 -0
- package/dist/components/list/PlList.js +1 -1
- package/dist/components/menu/PlMenu.d.ts +6 -4
- package/dist/components/menu/PlMenu.js +1 -1
- package/dist/components/menubar/PlMenubar.d.ts +5 -1
- package/dist/components/menubar/PlMenubar.js +1 -1
- package/dist/components/modal/PlModal.d.ts +4 -2
- package/dist/components/modal/PlModal.js +1 -1
- package/dist/components/navigation-menu/PlNavigationMenu.d.ts +5 -1
- package/dist/components/navigation-menu/PlNavigationMenu.js +1 -1
- package/dist/components/number-field/PlNumberField.d.ts +13 -2
- package/dist/components/number-field/PlNumberField.js +1 -1
- package/dist/components/otp-field/PlOtpField.d.ts +12 -1
- package/dist/components/otp-field/PlOtpField.js +1 -1
- package/dist/components/overlay/PlOverlay.d.ts +4 -2
- package/dist/components/overlay/PlOverlay.js +1 -1
- package/dist/components/page-layout/PlPageLayout.js +1 -1
- package/dist/components/pagination/PlPagination.js +1 -1
- package/dist/components/panes/PlPanes.js +1 -1
- package/dist/components/pill/PlPill.js +1 -1
- package/dist/components/popconfirm/PlPopconfirm.d.ts +61 -0
- package/dist/components/popconfirm/PlPopconfirm.js +1 -0
- package/dist/components/popconfirm/index.d.ts +2 -0
- package/dist/components/popconfirm/index.js +1 -0
- package/dist/components/popover/PlPopover.d.ts +1 -1
- package/dist/components/popover/PlPopover.js +1 -1
- package/dist/components/progress-box/PlProgressBox.js +1 -1
- package/dist/components/progress-circular/PlProgressCircular.js +1 -1
- package/dist/components/progress-linear/PlProgressLinear.js +1 -1
- package/dist/components/radio-group/PlRadioGroup.d.ts +3 -1
- package/dist/components/radio-group/PlRadioGroup.js +1 -1
- package/dist/components/rating/PlRating.js +1 -1
- package/dist/components/scroll-zone/PlScrollZone.js +1 -1
- package/dist/components/segmented-button/PlSegmentedButton.js +1 -1
- package/dist/components/select/PlSelect.d.ts +12 -1
- package/dist/components/select/PlSelect.js +1 -1
- package/dist/components/sidebar/PlSidebar.js +1 -1
- package/dist/components/skeleton/PlSkeleton.js +1 -1
- package/dist/components/slider/PlSlider.js +1 -1
- package/dist/components/spoiler/PlSpoiler.js +1 -1
- package/dist/components/stat/PlStat.d.ts +66 -0
- package/dist/components/stat/PlStat.js +1 -0
- package/dist/components/stat/index.d.ts +2 -0
- package/dist/components/stat/index.js +1 -0
- package/dist/components/stepper/PlStepper.d.ts +86 -0
- package/dist/components/stepper/PlStepper.js +1 -0
- package/dist/components/stepper/index.d.ts +2 -0
- package/dist/components/stepper/index.js +1 -0
- package/dist/components/switch/PlSwitch.d.ts +3 -1
- package/dist/components/switch/PlSwitch.js +1 -1
- package/dist/components/tabs/PlTabs.js +1 -1
- package/dist/components/text-field/PlTextField.d.ts +12 -1
- package/dist/components/text-field/PlTextField.js +1 -1
- package/dist/components/time-picker/PlTimePicker.js +1 -1
- package/dist/components/timeline/PlTimeline.d.ts +5 -8
- package/dist/components/timeline/PlTimeline.js +1 -1
- package/dist/components/toast/PlToast.d.ts +11 -1
- package/dist/components/toast/PlToast.js +1 -1
- package/dist/components/toggle/PlToggle.js +1 -1
- package/dist/components/toolbar/PlToolbar.js +1 -1
- package/dist/components/tooltip/PlTooltip.d.ts +1 -1
- package/dist/components/tooltip/PlTooltip.js +1 -1
- package/dist/components/transfer/PlTransfer.js +1 -1
- package/dist/components/tree/PlTree.d.ts +67 -0
- package/dist/components/tree/PlTree.js +1 -0
- package/dist/components/tree/index.d.ts +2 -0
- package/dist/components/tree/index.js +1 -0
- package/dist/components/visually-hidden/PlVisuallyHidden.d.ts +46 -0
- package/dist/components/visually-hidden/PlVisuallyHidden.js +1 -0
- package/dist/components/visually-hidden/index.d.ts +2 -0
- package/dist/components/visually-hidden/index.js +1 -0
- package/dist/css/back-top.css +2 -0
- package/dist/css/calendar.css +2 -0
- package/dist/css/confirm.css +2 -0
- package/dist/css/empty.css +2 -0
- package/dist/css/image.css +2 -0
- package/dist/css/popconfirm.css +2 -0
- package/dist/css/stat.css +2 -0
- package/dist/css/stepper.css +2 -0
- package/dist/css/tree.css +2 -0
- package/dist/css/visually-hidden.css +2 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/usePlBreakpoint.d.ts +38 -0
- package/dist/hooks/usePlBreakpoint.js +1 -0
- package/dist/hooks/usePlColorScheme.d.ts +66 -0
- package/dist/hooks/usePlColorScheme.js +1 -0
- package/dist/hooks/usePlHotKeys.d.ts +81 -0
- package/dist/hooks/usePlHotKeys.js +1 -0
- package/dist/hooks/usePlMediaQuery.d.ts +22 -0
- package/dist/hooks/usePlMediaQuery.js +1 -0
- package/dist/hooks/usePlReducedMotion.d.ts +22 -0
- package/dist/hooks/usePlReducedMotion.js +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +1 -1
- package/dist/internal/animate.d.ts +0 -1
- package/dist/internal/animate.js +1 -1
- package/dist/internal/calendar.d.ts +25 -3
- package/dist/internal/calendar.js +1 -1
- package/dist/internal/color-scheme.d.ts +23 -0
- package/dist/internal/color-scheme.js +1 -0
- package/dist/internal/date.d.ts +21 -0
- package/dist/internal/date.js +1 -1
- package/dist/internal/defaults.d.ts +69 -0
- package/dist/internal/defaults.js +1 -0
- package/dist/internal/direction.d.ts +4 -0
- package/dist/internal/direction.js +1 -0
- package/dist/internal/grid.d.ts +2 -0
- package/dist/internal/grid.js +1 -1
- package/dist/internal/keys.d.ts +93 -0
- package/dist/internal/keys.js +1 -0
- package/dist/internal/media.d.ts +26 -0
- package/dist/internal/media.js +1 -0
- package/dist/internal/page-layout.d.ts +6 -6
- package/dist/internal/page-layout.js +1 -1
- package/dist/internal/picker.d.ts +4 -2
- package/dist/internal/picker.js +1 -1
- package/dist/internal/steps.d.ts +76 -0
- package/dist/internal/steps.js +1 -0
- package/dist/provider/PlColorSchemeScript.d.ts +40 -0
- package/dist/provider/PlColorSchemeScript.js +1 -0
- package/dist/provider/PlassProvider.d.ts +39 -0
- package/dist/provider/PlassProvider.js +1 -0
- package/dist/provider/index.d.ts +5 -0
- package/dist/provider/index.js +1 -0
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +29 -1
- package/dist/tokens.css +29 -1
- package/dist/types.d.ts +89 -0
- package/package.json +17 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { PlassColor, PlassDensity, PlassSize } from '../../types.js';
|
|
3
|
+
/** One node. A branch is a node with `children`; a leaf is one without. */
|
|
4
|
+
export interface PlTreeNode {
|
|
5
|
+
/** What identifies it. Unique across the whole tree. */
|
|
6
|
+
id: string;
|
|
7
|
+
/** What the row says. */
|
|
8
|
+
label: React.ReactNode;
|
|
9
|
+
/** A glyph before the label. */
|
|
10
|
+
icon?: React.ReactNode;
|
|
11
|
+
/** Its own children. An **empty array is a branch with nothing in it**, which
|
|
12
|
+
* is not the same as a leaf: the first opens and shows nothing, the second
|
|
13
|
+
* has no twisty at all. `undefined` is the leaf. */
|
|
14
|
+
children?: readonly PlTreeNode[];
|
|
15
|
+
/** In the tree but not selectable, and not a stop for the arrow keys. */
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** How many rows a click can leave selected. */
|
|
19
|
+
export type PlTreeSelection = 'none' | 'single' | 'multiple';
|
|
20
|
+
export interface PlTreeProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'color'> {
|
|
21
|
+
/** The whole tree, as data. */
|
|
22
|
+
items: readonly PlTreeNode[];
|
|
23
|
+
/** The ids of the branches that are open. Use with `onExpandedChange` to control them. */
|
|
24
|
+
expanded?: readonly string[];
|
|
25
|
+
/** The branches that start open, for an uncontrolled tree. */
|
|
26
|
+
defaultExpanded?: readonly string[];
|
|
27
|
+
onExpandedChange?: (expanded: string[]) => void;
|
|
28
|
+
/** The ids of the selected rows. Use with `onSelectedChange` to control them. */
|
|
29
|
+
selected?: readonly string[];
|
|
30
|
+
/** What starts selected, for an uncontrolled tree. */
|
|
31
|
+
defaultSelected?: readonly string[];
|
|
32
|
+
onSelectedChange?: (selected: string[]) => void;
|
|
33
|
+
/**
|
|
34
|
+
* How many rows a click can leave selected.
|
|
35
|
+
*
|
|
36
|
+
* `single` by default. `none` makes the tree a browser rather than a
|
|
37
|
+
* chooser — every row still expands, and a click reports through
|
|
38
|
+
* `onItemClick` without anything staying lit.
|
|
39
|
+
* @default 'single'
|
|
40
|
+
*/
|
|
41
|
+
selection?: PlTreeSelection;
|
|
42
|
+
/** Called when a row is clicked, selectable or not. */
|
|
43
|
+
onItemClick?: (node: PlTreeNode) => void;
|
|
44
|
+
/** @default 'md' */
|
|
45
|
+
size?: PlassSize;
|
|
46
|
+
/** @default 'primary' */
|
|
47
|
+
color?: PlassColor;
|
|
48
|
+
/** @default 'default' */
|
|
49
|
+
density?: PlassDensity;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A hierarchy, opened one branch at a time.
|
|
53
|
+
*
|
|
54
|
+
* It takes its nodes as **data** rather than as children, which is the opposite
|
|
55
|
+
* of what most of this library does and is the right way round here for one
|
|
56
|
+
* reason: a tree is recursive, and recursion written in JSX is a component
|
|
57
|
+
* every caller has to write for themselves. `PlTable` takes its columns the
|
|
58
|
+
* same way and for the same reason.
|
|
59
|
+
*
|
|
60
|
+
* The keyboard is the ARIA tree pattern and it is most of what makes this a
|
|
61
|
+
* tree rather than a nested list: **one tab stop** for the whole thing, the up
|
|
62
|
+
* and down arrows walking the rows that are actually visible, and the left and
|
|
63
|
+
* right arrows opening a branch, stepping into it, and going back out to the
|
|
64
|
+
* parent. A tree where Tab walked four hundred rows would be one nobody reaches
|
|
65
|
+
* the end of.
|
|
66
|
+
*/
|
|
67
|
+
export declare const PlTree: React.ForwardRefExoticComponent<PlTreeProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as e,jsxs as i}from"react/jsx-runtime";import*as t from"react";import{useDefaults as l}from"../../internal/defaults.js";import{ChevronIcon as n}from"../../internal/icons.js";import{controlTextLeadingClasses as d,cx as s,focusRingClasses as r,gapClasses as a,iconClasses as o,radiusClasses as c,surfaceSlots as m,transitionClasses as p}from"../../internal/styles.js";const f={xs:14,sm:16,md:20,lg:24,xl:28},u={default:{xs:"py-1",sm:"py-1",md:"py-1.5",lg:"py-2",xl:"py-2.5"},compact:{xs:"py-0.5",sm:"py-0.5",md:"py-1",lg:"py-1",xl:"py-1.5"}};function visibleRows(e,i,t=1,l=[]){for(const n of e)l.push({node:n,level:t}),n.children&&i.has(n.id)&&visibleRows(n.children,i,t+1,l);return l}export const PlTree=/* @__PURE__ */t.forwardRef(function PlTree({items:h,expanded:v,defaultExpanded:x,onExpandedChange:b,selected:y,defaultSelected:g,onSelectedChange:w,selection:k="single",onItemClick:D,size:S,color:j,density:I,className:N,style:E,...R},A){const C=l(),M=S??C.size??"md",z=j??C.color??"primary",F=I??C.density??"default",[P,T]=t.useState(x??[]),$=v??P,B=t.useMemo(()=>new Set($),[$]),[H,K]=t.useState(g??[]),L=y??H,U=t.useMemo(()=>new Set(L),[L]),q=t.useMemo(()=>visibleRows(h,B),[h,B]),[G,J]=t.useState(null),O=q.filter(e=>!e.node.disabled),Q=G&&O.some(e=>e.node.id===G)?G:O[0]?.node.id??null,toggle=(e,i)=>{var t;t=i??!B.has(e)?[...$.filter(i=>i!==e),e]:$.filter(i=>i!==e),void 0===v&&T(t),b?.(t)},select=e=>{if("none"===k)return;const i="multiple"===k?U.has(e.id)?L.filter(i=>i!==e.id):[...L,e.id]:[e.id];void 0===y&&K(i),w?.(i)},V=t.useId(),rowId=e=>`${V}-${e}`,focusRow=e=>{J(e),document.getElementById(rowId(e))?.focus()},renderRow=({node:l,level:m})=>{const h=void 0!==l.children,v=B.has(l.id),x=U.has(l.id);return i(t.Fragment,{children:[i("div",{id:rowId(l.id),role:"treeitem","aria-level":m,"aria-expanded":h?v:void 0,"aria-selected":"none"===k?void 0:x,"aria-disabled":l.disabled||void 0,tabIndex:l.disabled?void 0:Q===l.id?0:-1,onFocus:()=>J(l.id),onKeyDown:e=>{l.disabled||((e,i,t)=>{const l=O.findIndex(e=>e.node.id===i.id),n=void 0!==i.children,d=B.has(i.id);switch(e.key){case"ArrowDown":e.preventDefault(),O[l+1]&&focusRow(O[l+1].node.id);break;case"ArrowUp":e.preventDefault(),O[l-1]&&focusRow(O[l-1].node.id);break;case"ArrowRight":e.preventDefault(),n&&!d?toggle(i.id,!0):n&&O[l+1]&&focusRow(O[l+1].node.id);break;case"ArrowLeft":if(e.preventDefault(),n&&d){toggle(i.id,!1);break}for(let e=l-1;e>=0;e-=1)if(O[e].level<t){focusRow(O[e].node.id);break}break;case"Home":e.preventDefault(),O[0]&&focusRow(O[0].node.id);break;case"End":e.preventDefault(),O.length&&focusRow(O[O.length-1].node.id);break;case"Enter":case" ":e.preventDefault(),n&&toggle(i.id),select(i),D?.(i)}})(e,l,m)},onClick:()=>{l.disabled||(h&&toggle(l.id),select(l),D?.(l))},className:s("flex cursor-pointer items-center select-none",a[M],u[F][M],d[M],c[M],r,p,o,l.disabled?"cursor-not-allowed opacity-50":x?"bg-(--p-soft) text-(--p-accent) font-medium":"text-(--plass-fg) hover:bg-(--p-soft)"),style:{paddingInlineStart:(m-1)*f[M]+6+"px"},children:[e("span",{"aria-hidden":"true",className:s("flex shrink-0 items-center text-(--plass-muted-fg)",p,h?"":"invisible",v?"rotate-0":"-rotate-90 rtl:rotate-90"),children:e(n,{})}),l.icon?e("span",{className:"flex shrink-0 items-center",children:l.icon}):null,e("span",{className:"truncate",children:l.label})]}),h&&v&&l.children.length>0?e("div",{role:"group",children:l.children.map(e=>renderRow({node:e,level:m+1}))}):null]},l.id)};return e("div",{ref:A,role:"tree","aria-multiselectable":"multiple"===k||void 0,className:s("flex flex-col",N),style:{...m(z,0),...E},...R,children:h.map(e=>renderRow({node:e,level:1}))})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{PlTree}from"./PlTree.js";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
export interface PlVisuallyHiddenProps extends React.ComponentPropsWithoutRef<'span'> {
|
|
4
|
+
/**
|
|
5
|
+
* Brings the content back into the page while anything inside it has the
|
|
6
|
+
* focus, and clips it again as soon as the focus leaves.
|
|
7
|
+
*
|
|
8
|
+
* Off by default, because the ordinary use of this component is a name that
|
|
9
|
+
* is never meant to be seen. The exception is the one element that *must*
|
|
10
|
+
* appear when it is reached — a skip link — and there is no way for a caller
|
|
11
|
+
* to add it from the outside: the clip is `position: absolute`, so revealing
|
|
12
|
+
* it means putting the element back in the flow, which a `className` cannot
|
|
13
|
+
* do without also fighting the class it is trying to override.
|
|
14
|
+
*
|
|
15
|
+
* `:focus-within` rather than `:focus`, because the thing being tabbed to is
|
|
16
|
+
* almost always a link *inside* the box rather than the box itself — and
|
|
17
|
+
* `:focus-within` matches the element when it holds the focus too, so the
|
|
18
|
+
* narrower case is covered by the wider one.
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
focusable?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Renders something other than a `<span>`: `render={<div />}`,
|
|
24
|
+
* `render={<h2 />}`. Base UI's own escape hatch.
|
|
25
|
+
*/
|
|
26
|
+
render?: useRender.RenderProp;
|
|
27
|
+
children?: React.ReactNode;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Content for a screen reader and for nobody else.
|
|
31
|
+
*
|
|
32
|
+
* It is not a styling escape hatch and it is not `display: none`. The two
|
|
33
|
+
* obvious ways to hide something — `hidden` and `opacity: 0` — are both wrong
|
|
34
|
+
* in the same place: the first takes the text off the accessibility tree along
|
|
35
|
+
* with the screen, which is the one thing this component exists to avoid, and
|
|
36
|
+
* the second leaves a clickable ghost the size of the words. A one-pixel
|
|
37
|
+
* clipped box is the only form that is absent to a sighted reader and present
|
|
38
|
+
* to every other kind.
|
|
39
|
+
*
|
|
40
|
+
* What it is for is the sentence a control cannot say out loud — the word
|
|
41
|
+
* "Close" on a button that draws an ✕, the unit after a number, the change of
|
|
42
|
+
* context on a link that says "read more". The library already reaches for this
|
|
43
|
+
* inside a dozen components; this is the same rule, spelled once, for the
|
|
44
|
+
* caller's own markup.
|
|
45
|
+
*/
|
|
46
|
+
export declare const PlVisuallyHidden: React.ForwardRefExoticComponent<PlVisuallyHiddenProps & React.RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as e}from"react/jsx-runtime";import*as i from"react";import{useRender as r}from"@base-ui/react/use-render";import{cx as s,srOnlyClasses as n}from"../../internal/styles.js";const o=/* @__PURE__ */["focus-within:static focus-within:size-auto","focus-within:overflow-visible focus-within:whitespace-normal","focus-within:[clip-path:none]"].join(" ");export const PlVisuallyHidden=/* @__PURE__ */i.forwardRef(function PlVisuallyHidden({focusable:i=!1,render:t,className:a,children:c,...l},f){return r({render:t??e("span",{}),ref:f,props:{className:s(n,i?o:"",a),children:c,...l}})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{PlVisuallyHidden}from"./PlVisuallyHidden.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { usePlBreakpoint, usePlBreakpointValue } from './usePlBreakpoint.js';
|
|
2
|
+
export { usePlColorScheme } from './usePlColorScheme.js';
|
|
3
|
+
export type { PlColorScheme, PlColorSchemeOptions, PlColorSchemeResult, PlResolvedColorScheme } from './usePlColorScheme.js';
|
|
4
|
+
export { usePlHotKeys } from './usePlHotKeys.js';
|
|
5
|
+
export type { PlHotKeysOptions, PlHotKeysTarget } from './usePlHotKeys.js';
|
|
6
|
+
export { usePlMediaQuery } from './usePlMediaQuery.js';
|
|
7
|
+
export { usePlReducedMotion } from './usePlReducedMotion.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{usePlBreakpoint,usePlBreakpointValue}from"./usePlBreakpoint.js";export{usePlColorScheme}from"./usePlColorScheme.js";export{usePlHotKeys}from"./usePlHotKeys.js";export{usePlMediaQuery}from"./usePlMediaQuery.js";export{usePlReducedMotion}from"./usePlReducedMotion.js";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { PlassBreakpoint, PlassResponsive } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Which rung of the breakpoint ladder the window is on.
|
|
4
|
+
*
|
|
5
|
+
* Four queries rather than one `innerWidth` read, and deliberately: a width
|
|
6
|
+
* measured in JavaScript is a number that has to be compared against a `rem`,
|
|
7
|
+
* and a `rem` is whatever the reader has set their font size to. `matchMedia`
|
|
8
|
+
* asks the same engine the stylesheet asks, so a component that switches at
|
|
9
|
+
* `md` here switches with the `md:` utilities beside it rather than a few
|
|
10
|
+
* pixels away from them.
|
|
11
|
+
*
|
|
12
|
+
* **`xs` is the server's answer**, and the first one a browser renders. See
|
|
13
|
+
* `usePlMediaQuery` for what follows from that.
|
|
14
|
+
*/
|
|
15
|
+
export declare function usePlBreakpoint(): PlassBreakpoint;
|
|
16
|
+
/**
|
|
17
|
+
* A `PlassResponsive` value, resolved for the width the window is at.
|
|
18
|
+
*
|
|
19
|
+
* The same shape and the same rule as `PlGrid`'s own props: a bare value
|
|
20
|
+
* applies everywhere, and a map applies each entry **from its own breakpoint
|
|
21
|
+
* up**, so `{ xs: 1, md: 3 }` is `1` on a phone and `3` from 48rem. An entry
|
|
22
|
+
* cascades to the rungs above it, which is what keeps a responsive value to the
|
|
23
|
+
* breakpoints it actually names.
|
|
24
|
+
*
|
|
25
|
+
* It exists because there is a class of decision CSS cannot make — how many
|
|
26
|
+
* items to fetch, which of two components to mount, how many characters to
|
|
27
|
+
* truncate at — and writing it out by hand means repeating the ladder in
|
|
28
|
+
* numbers a stylesheet will later disagree with.
|
|
29
|
+
*
|
|
30
|
+
* `undefined` when the map named no rung at or below the current one:
|
|
31
|
+
* `{ lg: 3 }` on a phone is not `3`, and guessing a value the caller did not
|
|
32
|
+
* write would be worse than saying so.
|
|
33
|
+
*
|
|
34
|
+
* An object is read as a **map**, exactly as it is in a responsive prop — so a
|
|
35
|
+
* value that is itself an object has to be wrapped in a map to be passed
|
|
36
|
+
* through: `{ xs: { … } }`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function usePlBreakpointValue<T>(value: PlassResponsive<T>): T | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{breakpointMap as e,breakpoints as t}from"../internal/grid.js";import{useMediaQuery as r}from"../internal/media.js";export function usePlBreakpoint(){const e=r("(width >= 40rem)"),t=r("(width >= 48rem)"),i=r("(width >= 64rem)");return r("(width >= 80rem)")?"xl":i?"lg":t?"md":e?"sm":"xs"}export function usePlBreakpointValue(r){const i=usePlBreakpoint(),n=e(r);for(let e=t.indexOf(i);e>=0;e-=1){const r=n[t[e]];if(void 0!==r)return r}}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type PlColorScheme, type PlResolvedColorScheme } from '../internal/color-scheme.js';
|
|
2
|
+
export type { PlColorScheme, PlResolvedColorScheme };
|
|
3
|
+
export interface PlColorSchemeOptions {
|
|
4
|
+
/**
|
|
5
|
+
* What to use when nothing has been stored.
|
|
6
|
+
*
|
|
7
|
+
* `system` — follow the platform — and it should stay `system`: a library
|
|
8
|
+
* that pinned a page to light on first visit would be overruling a preference
|
|
9
|
+
* the reader has already expressed to their operating system.
|
|
10
|
+
* @default 'system'
|
|
11
|
+
*/
|
|
12
|
+
defaultScheme?: PlColorScheme;
|
|
13
|
+
/**
|
|
14
|
+
* Where the choice is kept, in `localStorage`.
|
|
15
|
+
*
|
|
16
|
+
* Change it to scope the choice to one app on a shared origin. There is no
|
|
17
|
+
* way to turn storage off, because a toggle whose answer does not survive a
|
|
18
|
+
* reload is a toggle that looks broken.
|
|
19
|
+
* @default 'plass-color-scheme'
|
|
20
|
+
*/
|
|
21
|
+
storageKey?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface PlColorSchemeResult {
|
|
24
|
+
/** What the reader chose. `system` is the absence of a choice. */
|
|
25
|
+
scheme: PlColorScheme;
|
|
26
|
+
/** What the page is painted in, once `system` has been resolved. */
|
|
27
|
+
resolved: PlResolvedColorScheme;
|
|
28
|
+
/** Chooses one. Written to `<html>` and to storage, and every other caller of this hook hears about it. */
|
|
29
|
+
setScheme: (next: PlColorScheme) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Light ⇄ dark, from whatever is currently *painted*.
|
|
32
|
+
*
|
|
33
|
+
* So the first press on a system-dark page gives light, which is what a
|
|
34
|
+
* reader pressing a toggle means. It leaves `system` behind, deliberately:
|
|
35
|
+
* they have now expressed a preference of their own.
|
|
36
|
+
*/
|
|
37
|
+
toggle: () => void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The dark mode toggle, and what it takes to make one that does not flash.
|
|
41
|
+
*
|
|
42
|
+
* The library's tokens already answer to `.dark` / `[data-theme]` on any
|
|
43
|
+
* ancestor and to `prefers-color-scheme` when neither is there, so a page that
|
|
44
|
+
* only ever follows the platform needs nothing at all — this is for the app that
|
|
45
|
+
* offers a **choice**, which needs three things the CSS cannot do on its own:
|
|
46
|
+
* somewhere to keep it, something to write it onto `<html>`, and a way to paint
|
|
47
|
+
* it before the first frame.
|
|
48
|
+
*
|
|
49
|
+
* The third one is not this hook. React runs after the document has been
|
|
50
|
+
* parsed, so a scheme applied from an effect is applied one paint too late and
|
|
51
|
+
* the reader sees a white flash. [`PlColorSchemeScript`](./PlColorSchemeScript)
|
|
52
|
+
* is the answer to that and belongs in `<head>`.
|
|
53
|
+
*
|
|
54
|
+
* ```tsx
|
|
55
|
+
* const { resolved, toggle } = usePlColorScheme();
|
|
56
|
+
*
|
|
57
|
+
* <PlIconButton label="Switch theme" icon={resolved === 'dark' ? <Sun /> : <Moon />} onClick={toggle} />
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* **`storageKey` and `defaultScheme` are read once**, when the first component
|
|
61
|
+
* using that key mounts, and are ignored on every call after it. That is what
|
|
62
|
+
* makes two toggles on one page agree with each other — they share one store —
|
|
63
|
+
* and it means these two are decisions to make where the app is set up rather
|
|
64
|
+
* than props to compute. Changing them at runtime does nothing.
|
|
65
|
+
*/
|
|
66
|
+
export declare function usePlColorScheme(options?: PlColorSchemeOptions): PlColorSchemeResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import*as e from"react";import{DEFAULT_STORAGE_KEY as t,applyColorScheme as r,darkQuery as s,useColorSchemeStore as o}from"../internal/color-scheme.js";import{useMediaQuery as m}from"../internal/media.js";export function usePlColorScheme(c={}){const{defaultScheme:l="system",storageKey:a=t}=c,[i,n]=o(a,l),f=m(s),h="system"===i?f?"dark":"light":i;e.useEffect(()=>{r(i)},[i]);const u=e.useCallback(()=>{n("dark"===h?"light":"dark")},[h,n]);return{scheme:i,resolved:h,setScheme:n,toggle:u}}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { PlassHotKeys } from '../types.js';
|
|
3
|
+
/** Anything a listener can be attached to, plus the ref a React caller holds. */
|
|
4
|
+
export type PlHotKeysTarget = Window | Document | HTMLElement | React.RefObject<HTMLElement | null> | null;
|
|
5
|
+
export interface PlHotKeysOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Whether the chords are bound at all. `false` removes the listener rather
|
|
8
|
+
* than making the handlers no-ops, so a shortcut that is off does not consume
|
|
9
|
+
* the key from whatever else wanted it.
|
|
10
|
+
* @default true
|
|
11
|
+
*/
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* What the listener is attached to.
|
|
15
|
+
*
|
|
16
|
+
* `window` is the default and is what a global shortcut means. A ref, an
|
|
17
|
+
* element or `document` scopes the binding to a region — but note that a
|
|
18
|
+
* `keydown` only reaches an element that contains the focus, so scoping to a
|
|
19
|
+
* panel nobody has tabbed into binds nothing.
|
|
20
|
+
* @default window
|
|
21
|
+
*/
|
|
22
|
+
target?: PlHotKeysTarget;
|
|
23
|
+
/**
|
|
24
|
+
* Whether a chord is answered while the focus is in a text field.
|
|
25
|
+
*
|
|
26
|
+
* Off by default, and this is the decision the hook exists to get right: a
|
|
27
|
+
* global `/` that jumps to search must not eat the slash out of a URL
|
|
28
|
+
* somebody is typing into a form.
|
|
29
|
+
*
|
|
30
|
+
* It is narrower than it sounds, and only two kinds of chord are ever held
|
|
31
|
+
* back. A chord carrying **`Mod`, `Ctrl`, `Meta` or `Alt` is answered either
|
|
32
|
+
* way**, because none of those can appear in a field's value — so the
|
|
33
|
+
* ordinary `Mod+K` needs nothing set here. Shift does not count as one:
|
|
34
|
+
* `Shift+A` is how a capital A is typed. And a key that **does nothing in a
|
|
35
|
+
* field** is answered either way too: `Escape` is the one that matters, since
|
|
36
|
+
* a panel that closes on Escape has to close from inside its own form.
|
|
37
|
+
*
|
|
38
|
+
* What is left is exactly the case this is for: a printable character, or one
|
|
39
|
+
* of the keys that edits or moves through text, pressed while the focus is in
|
|
40
|
+
* a field. Turn it on for a chord that belongs to the field the reader is in.
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
whileTyping?: boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Binds keyboard chords outside any one control.
|
|
47
|
+
*
|
|
48
|
+
* The map is the same `PlassHotKeys` a field's `hotKeys` prop takes and the
|
|
49
|
+
* chords are spelled the way `PlHotKeys` draws them, which is the whole point:
|
|
50
|
+
* a shortcut that is **displayed** on a key cap and a shortcut that is **bound**
|
|
51
|
+
* are one string rather than two that drift. `Mod` is Command on a Mac and
|
|
52
|
+
* Control everywhere else.
|
|
53
|
+
*
|
|
54
|
+
* `PlCommandPalette` is the hook's first caller — it has bound its own opener
|
|
55
|
+
* this way since it existed, with a private copy of the matcher — and an
|
|
56
|
+
* application's own shortcuts are the reason it is public.
|
|
57
|
+
*
|
|
58
|
+
* Three rules it shares with the `hotKeys` prop:
|
|
59
|
+
*
|
|
60
|
+
* - **A modifier is checked in both directions.** `Enter` does not fire on
|
|
61
|
+
* `Shift+Enter`, and `Mod+K` does not fire on `Mod+Shift+K`.
|
|
62
|
+
* - **A chord that matches is consumed** — `preventDefault()`, so the browser's
|
|
63
|
+
* own `Mod+K` search bar does not also open. Read from the other end, an
|
|
64
|
+
* event that is **already** consumed is left alone: a field's own `hotKeys`
|
|
65
|
+
* map wins over a page's.
|
|
66
|
+
* - **These are chords rather than letters.** A single unmodified key is
|
|
67
|
+
* allowed and is sometimes right (`?` for help), but it is the case
|
|
68
|
+
* `whileTyping` is about.
|
|
69
|
+
*
|
|
70
|
+
* The handlers are read fresh on every keystroke, so an inline object literal
|
|
71
|
+
* costs nothing and a handler closing over current state is never stale. What
|
|
72
|
+
* rebinds the listener is the **set of chords** changing, not the map's
|
|
73
|
+
* identity.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* usePlHotKeys({
|
|
77
|
+
* 'Mod+K': () => setPaletteOpen(true),
|
|
78
|
+
* 'Mod+S': save
|
|
79
|
+
* });
|
|
80
|
+
*/
|
|
81
|
+
export declare function usePlHotKeys(hotKeys: PlassHotKeys | undefined, options?: PlHotKeysOptions): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import*as e from"react";import{editsText as n,hasHardModifier as t,isTypingTarget as r,matchesHotKey as o}from"../internal/keys.js";export function usePlHotKeys(i,u={}){const{enabled:s=!0,target:f,whileTyping:c=!1}=u,l=e.useRef(i);e.useEffect(()=>{l.current=i});const d=Object.keys(i??{}).join("\n");e.useEffect(()=>{const e=function resolve(e){return void 0===e?"undefined"==typeof window?null:window:null===e?null:"current"in e?e.current:e}(f);if(!s||!e||""===d)return;const i=d.split("\n"),onKeyDown=e=>{const u=e;if(!u.defaultPrevented)for(const e of i)if(o(u,e)){if(!c&&!t(e)&&n(u.key)&&r(u.target))return;return u.preventDefault(),void l.current?.[e]?.()}};return e.addEventListener("keydown",onKeyDown),()=>e.removeEventListener("keydown",onKeyDown)},[d,f,s,c])}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the window matches a CSS media query, as a boolean that re-renders
|
|
3
|
+
* when the answer changes.
|
|
4
|
+
*
|
|
5
|
+
* The library has always had this — it is how a `PlSidebar` knows it has become
|
|
6
|
+
* a drawer and how a `PlAnimate*` finds out that the reader asked for less
|
|
7
|
+
* motion — and it is public now because the alternative in application code is
|
|
8
|
+
* a `useState`, an effect and a listener that is nearly always subscribed one
|
|
9
|
+
* render too late.
|
|
10
|
+
*
|
|
11
|
+
* **The first answer in a browser is the server's answer.** There is no window
|
|
12
|
+
* to measure while the HTML is being generated, so this returns `false` on the
|
|
13
|
+
* server and through the hydrating render, and the real answer arrives in the
|
|
14
|
+
* render after that. Anything that has to be right in the *first* frame belongs
|
|
15
|
+
* in CSS — a Tailwind variant, or the `--plass-*` token that variant sets — and
|
|
16
|
+
* this hook is for the decisions CSS cannot make, like whether a component
|
|
17
|
+
* exists at all.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const coarse = usePlMediaQuery('(pointer: coarse)');
|
|
21
|
+
*/
|
|
22
|
+
export declare function usePlMediaQuery(query: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{useMediaQuery as e}from"../internal/media.js";export function usePlMediaQuery(r){return e(r)}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the reader has asked their platform for less movement.
|
|
3
|
+
*
|
|
4
|
+
* `prefers-reduced-motion: reduce`, read as a boolean that re-renders when it
|
|
5
|
+
* changes. The library answers it on its own behalf everywhere it moves — every
|
|
6
|
+
* keyframe in the stylesheet is switched off at once, a typewriter simply
|
|
7
|
+
* arrives finished — and this is the same answer, for the motion an application
|
|
8
|
+
* writes itself.
|
|
9
|
+
*
|
|
10
|
+
* **"Reduced" is not "none", and the library's own components disagree with
|
|
11
|
+
* each other on purpose.** An entrance is dropped entirely, because an
|
|
12
|
+
* animation that never played has still delivered everything it was carrying. A
|
|
13
|
+
* loading indicator is *slowed* rather than stopped, because a spinner that
|
|
14
|
+
* stopped would be lying about whether anything is still happening. Which of
|
|
15
|
+
* those two an effect is, is the question to answer before reaching for this.
|
|
16
|
+
*
|
|
17
|
+
* The server's answer is `false` — it has no reader and so no preference — and
|
|
18
|
+
* so is the first answer in a browser. See `usePlMediaQuery` for why, and note
|
|
19
|
+
* that it is the safe direction here: the reader gets their preference in the
|
|
20
|
+
* render after hydration, before any of this has had a frame to run in.
|
|
21
|
+
*/
|
|
22
|
+
export declare function usePlReducedMotion(): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{usePrefersReducedMotion as e}from"../internal/media.js";export function usePlReducedMotion(){return e()}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from './types.js';
|
|
2
|
+
export * from './hooks/index.js';
|
|
3
|
+
export * from './provider/index.js';
|
|
2
4
|
export * from './components/accordion/index.js';
|
|
3
5
|
export * from './components/alert/index.js';
|
|
4
6
|
export * from './components/animate-appear/index.js';
|
|
@@ -15,6 +17,7 @@ export * from './components/animate-zoom/index.js';
|
|
|
15
17
|
export * from './components/aspect-ratio/index.js';
|
|
16
18
|
export * from './components/avatar/index.js';
|
|
17
19
|
export * from './components/avatar-group/index.js';
|
|
20
|
+
export * from './components/back-top/index.js';
|
|
18
21
|
export * from './components/badge/index.js';
|
|
19
22
|
export * from './components/blockquote/index.js';
|
|
20
23
|
export * from './components/bottom-navigation/index.js';
|
|
@@ -22,6 +25,7 @@ export * from './components/box/index.js';
|
|
|
22
25
|
export * from './components/breadcrumb/index.js';
|
|
23
26
|
export * from './components/button/index.js';
|
|
24
27
|
export * from './components/button-group/index.js';
|
|
28
|
+
export * from './components/calendar/index.js';
|
|
25
29
|
export * from './components/card/index.js';
|
|
26
30
|
export * from './components/carousel/index.js';
|
|
27
31
|
export * from './components/chat-bubble/index.js';
|
|
@@ -30,6 +34,7 @@ export * from './components/chip/index.js';
|
|
|
30
34
|
export * from './components/collapsible/index.js';
|
|
31
35
|
export * from './components/color-picker/index.js';
|
|
32
36
|
export * from './components/combobox/index.js';
|
|
37
|
+
export * from './components/confirm/index.js';
|
|
33
38
|
export * from './components/command-palette/index.js';
|
|
34
39
|
export * from './components/container/index.js';
|
|
35
40
|
export * from './components/date-picker/index.js';
|
|
@@ -37,6 +42,7 @@ export * from './components/date-range-picker/index.js';
|
|
|
37
42
|
export * from './components/date-time-picker/index.js';
|
|
38
43
|
export * from './components/divider/index.js';
|
|
39
44
|
export * from './components/drawer/index.js';
|
|
45
|
+
export * from './components/empty/index.js';
|
|
40
46
|
export * from './components/fieldset/index.js';
|
|
41
47
|
export * from './components/file-picker/index.js';
|
|
42
48
|
export * from './components/floating-bottom-navigation/index.js';
|
|
@@ -48,6 +54,7 @@ export * from './components/highlight/index.js';
|
|
|
48
54
|
export * from './components/hot-keys/index.js';
|
|
49
55
|
export * from './components/icon/index.js';
|
|
50
56
|
export * from './components/icon-button/index.js';
|
|
57
|
+
export * from './components/image/index.js';
|
|
51
58
|
export * from './components/list/index.js';
|
|
52
59
|
export * from './components/menu/index.js';
|
|
53
60
|
export * from './components/menubar/index.js';
|
|
@@ -60,6 +67,7 @@ export * from './components/page-layout/index.js';
|
|
|
60
67
|
export * from './components/pagination/index.js';
|
|
61
68
|
export * from './components/panes/index.js';
|
|
62
69
|
export * from './components/pill/index.js';
|
|
70
|
+
export * from './components/popconfirm/index.js';
|
|
63
71
|
export * from './components/popover/index.js';
|
|
64
72
|
export * from './components/progress-box/index.js';
|
|
65
73
|
export * from './components/progress-circular/index.js';
|
|
@@ -73,6 +81,8 @@ export * from './components/sidebar/index.js';
|
|
|
73
81
|
export * from './components/skeleton/index.js';
|
|
74
82
|
export * from './components/slider/index.js';
|
|
75
83
|
export * from './components/spoiler/index.js';
|
|
84
|
+
export * from './components/stat/index.js';
|
|
85
|
+
export * from './components/stepper/index.js';
|
|
76
86
|
export * from './components/switch/index.js';
|
|
77
87
|
export * from './components/table/index.js';
|
|
78
88
|
export * from './components/tabs/index.js';
|
|
@@ -84,5 +94,7 @@ export * from './components/toast/index.js';
|
|
|
84
94
|
export * from './components/toggle/index.js';
|
|
85
95
|
export * from './components/toolbar/index.js';
|
|
86
96
|
export * from './components/tooltip/index.js';
|
|
97
|
+
export * from './components/tree/index.js';
|
|
87
98
|
export * from './components/transfer/index.js';
|
|
88
99
|
export * from './components/typography/index.js';
|
|
100
|
+
export * from './components/visually-hidden/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./types.js";export*from"./components/accordion/index.js";export*from"./components/alert/index.js";export*from"./components/animate-appear/index.js";export*from"./components/animate-blink/index.js";export*from"./components/animate-fade/index.js";export*from"./components/animate-grow/index.js";export*from"./components/animate-headline/index.js";export*from"./components/animate-lighting/index.js";export*from"./components/animate-marquee/index.js";export*from"./components/animate-rotate/index.js";export*from"./components/animate-slide/index.js";export*from"./components/animate-typing/index.js";export*from"./components/animate-zoom/index.js";export*from"./components/aspect-ratio/index.js";export*from"./components/avatar/index.js";export*from"./components/avatar-group/index.js";export*from"./components/badge/index.js";export*from"./components/blockquote/index.js";export*from"./components/bottom-navigation/index.js";export*from"./components/box/index.js";export*from"./components/breadcrumb/index.js";export*from"./components/button/index.js";export*from"./components/button-group/index.js";export*from"./components/card/index.js";export*from"./components/carousel/index.js";export*from"./components/chat-bubble/index.js";export*from"./components/checkbox/index.js";export*from"./components/chip/index.js";export*from"./components/collapsible/index.js";export*from"./components/color-picker/index.js";export*from"./components/combobox/index.js";export*from"./components/command-palette/index.js";export*from"./components/container/index.js";export*from"./components/date-picker/index.js";export*from"./components/date-range-picker/index.js";export*from"./components/date-time-picker/index.js";export*from"./components/divider/index.js";export*from"./components/drawer/index.js";export*from"./components/fieldset/index.js";export*from"./components/file-picker/index.js";export*from"./components/floating-bottom-navigation/index.js";export*from"./components/footer/index.js";export*from"./components/form/index.js";export*from"./components/grid/index.js";export*from"./components/header/index.js";export*from"./components/highlight/index.js";export*from"./components/hot-keys/index.js";export*from"./components/icon/index.js";export*from"./components/icon-button/index.js";export*from"./components/list/index.js";export*from"./components/menu/index.js";export*from"./components/menubar/index.js";export*from"./components/modal/index.js";export*from"./components/navigation-menu/index.js";export*from"./components/number-field/index.js";export*from"./components/otp-field/index.js";export*from"./components/overlay/index.js";export*from"./components/page-layout/index.js";export*from"./components/pagination/index.js";export*from"./components/panes/index.js";export*from"./components/pill/index.js";export*from"./components/popover/index.js";export*from"./components/progress-box/index.js";export*from"./components/progress-circular/index.js";export*from"./components/progress-linear/index.js";export*from"./components/radio-group/index.js";export*from"./components/rating/index.js";export*from"./components/scroll-zone/index.js";export*from"./components/segmented-button/index.js";export*from"./components/select/index.js";export*from"./components/sidebar/index.js";export*from"./components/skeleton/index.js";export*from"./components/slider/index.js";export*from"./components/spoiler/index.js";export*from"./components/switch/index.js";export*from"./components/table/index.js";export*from"./components/tabs/index.js";export*from"./components/text-field/index.js";export*from"./components/text-link/index.js";export*from"./components/time-picker/index.js";export*from"./components/timeline/index.js";export*from"./components/toast/index.js";export*from"./components/toggle/index.js";export*from"./components/toolbar/index.js";export*from"./components/tooltip/index.js";export*from"./components/transfer/index.js";export*from"./components/typography/index.js";
|
|
1
|
+
export*from"./types.js";export*from"./hooks/index.js";export*from"./provider/index.js";export*from"./components/accordion/index.js";export*from"./components/alert/index.js";export*from"./components/animate-appear/index.js";export*from"./components/animate-blink/index.js";export*from"./components/animate-fade/index.js";export*from"./components/animate-grow/index.js";export*from"./components/animate-headline/index.js";export*from"./components/animate-lighting/index.js";export*from"./components/animate-marquee/index.js";export*from"./components/animate-rotate/index.js";export*from"./components/animate-slide/index.js";export*from"./components/animate-typing/index.js";export*from"./components/animate-zoom/index.js";export*from"./components/aspect-ratio/index.js";export*from"./components/avatar/index.js";export*from"./components/avatar-group/index.js";export*from"./components/back-top/index.js";export*from"./components/badge/index.js";export*from"./components/blockquote/index.js";export*from"./components/bottom-navigation/index.js";export*from"./components/box/index.js";export*from"./components/breadcrumb/index.js";export*from"./components/button/index.js";export*from"./components/button-group/index.js";export*from"./components/calendar/index.js";export*from"./components/card/index.js";export*from"./components/carousel/index.js";export*from"./components/chat-bubble/index.js";export*from"./components/checkbox/index.js";export*from"./components/chip/index.js";export*from"./components/collapsible/index.js";export*from"./components/color-picker/index.js";export*from"./components/combobox/index.js";export*from"./components/confirm/index.js";export*from"./components/command-palette/index.js";export*from"./components/container/index.js";export*from"./components/date-picker/index.js";export*from"./components/date-range-picker/index.js";export*from"./components/date-time-picker/index.js";export*from"./components/divider/index.js";export*from"./components/drawer/index.js";export*from"./components/empty/index.js";export*from"./components/fieldset/index.js";export*from"./components/file-picker/index.js";export*from"./components/floating-bottom-navigation/index.js";export*from"./components/footer/index.js";export*from"./components/form/index.js";export*from"./components/grid/index.js";export*from"./components/header/index.js";export*from"./components/highlight/index.js";export*from"./components/hot-keys/index.js";export*from"./components/icon/index.js";export*from"./components/icon-button/index.js";export*from"./components/image/index.js";export*from"./components/list/index.js";export*from"./components/menu/index.js";export*from"./components/menubar/index.js";export*from"./components/modal/index.js";export*from"./components/navigation-menu/index.js";export*from"./components/number-field/index.js";export*from"./components/otp-field/index.js";export*from"./components/overlay/index.js";export*from"./components/page-layout/index.js";export*from"./components/pagination/index.js";export*from"./components/panes/index.js";export*from"./components/pill/index.js";export*from"./components/popconfirm/index.js";export*from"./components/popover/index.js";export*from"./components/progress-box/index.js";export*from"./components/progress-circular/index.js";export*from"./components/progress-linear/index.js";export*from"./components/radio-group/index.js";export*from"./components/rating/index.js";export*from"./components/scroll-zone/index.js";export*from"./components/segmented-button/index.js";export*from"./components/select/index.js";export*from"./components/sidebar/index.js";export*from"./components/skeleton/index.js";export*from"./components/slider/index.js";export*from"./components/spoiler/index.js";export*from"./components/stat/index.js";export*from"./components/stepper/index.js";export*from"./components/switch/index.js";export*from"./components/table/index.js";export*from"./components/tabs/index.js";export*from"./components/text-field/index.js";export*from"./components/text-link/index.js";export*from"./components/time-picker/index.js";export*from"./components/timeline/index.js";export*from"./components/toast/index.js";export*from"./components/toggle/index.js";export*from"./components/toolbar/index.js";export*from"./components/tooltip/index.js";export*from"./components/tree/index.js";export*from"./components/transfer/index.js";export*from"./components/typography/index.js";export*from"./components/visually-hidden/index.js";
|
|
@@ -93,7 +93,6 @@ export declare function slideOffsets(from: PlassSide, distance: number | string)
|
|
|
93
93
|
x: string;
|
|
94
94
|
y: string;
|
|
95
95
|
};
|
|
96
|
-
export declare function usePrefersReducedMotion(): boolean;
|
|
97
96
|
export interface AnimationRunOptions {
|
|
98
97
|
trigger: PlassAnimateTrigger;
|
|
99
98
|
play?: boolean;
|
package/dist/internal/animate.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";export const animationClasses={fade:"plass-anim-fade",grow:"plass-anim-scale",slide:"plass-anim-slide",zoom:"plass-anim-scale",rotate:"plass-anim-rotate",blink:"plass-anim-blink"};export const animBaseClass="plass-anim";export function lengthValue(e){return"number"==typeof e?`${e}px`:e}export function repeatValue(e){return"infinite"===e?"infinite":String(e)}export function isInfinite(e){return"infinite"===e}export function directionValue(e,n){return"out"===e?n?"alternate-reverse":"reverse":n?"alternate":"normal"}export function animationSlots(e){const n={"--p-anim-duration":`${e.duration}ms`,"--p-anim-delay":`${e.delay}ms`,"--p-anim-repeat":repeatValue(e.repeat),"--p-anim-direction":directionValue(e.mode??"in",e.alternate)};return e.easing&&(n["--p-anim-ease"]=e.easing),void 0!==e.opacity&&(n["--p-anim-opacity"]=String(e.opacity)),void 0!==e.scale&&(n["--p-anim-scale"]=String(e.scale)),void 0!==e.x&&(n["--p-anim-x"]=e.x),void 0!==e.y&&(n["--p-anim-y"]=e.y),void 0!==e.angle&&(n["--p-anim-angle"]=e.angle),void 0!==e.angleTo&&(n["--p-anim-angle-to"]=e.angleTo),n}export function slideOffsets(e,n){const t=lengthValue(n),a="number"==typeof n?-n+"px":`calc(-1 * ${t})`;switch(e){case"top":return{x:"0px",y:a};case"bottom":return{x:"0px",y:t};case"left":return{x:a,y:"0px"};default:return{x:t,y:"0px"}}}
|
|
1
|
+
import*as e from"react";export const animationClasses={fade:"plass-anim-fade",grow:"plass-anim-scale",slide:"plass-anim-slide",zoom:"plass-anim-scale",rotate:"plass-anim-rotate",blink:"plass-anim-blink"};export const animBaseClass="plass-anim";export function lengthValue(e){return"number"==typeof e?`${e}px`:e}export function repeatValue(e){return"infinite"===e?"infinite":String(e)}export function isInfinite(e){return"infinite"===e}export function directionValue(e,n){return"out"===e?n?"alternate-reverse":"reverse":n?"alternate":"normal"}export function animationSlots(e){const n={"--p-anim-duration":`${e.duration}ms`,"--p-anim-delay":`${e.delay}ms`,"--p-anim-repeat":repeatValue(e.repeat),"--p-anim-direction":directionValue(e.mode??"in",e.alternate)};return e.easing&&(n["--p-anim-ease"]=e.easing),void 0!==e.opacity&&(n["--p-anim-opacity"]=String(e.opacity)),void 0!==e.scale&&(n["--p-anim-scale"]=String(e.scale)),void 0!==e.x&&(n["--p-anim-x"]=e.x),void 0!==e.y&&(n["--p-anim-y"]=e.y),void 0!==e.angle&&(n["--p-anim-angle"]=e.angle),void 0!==e.angleTo&&(n["--p-anim-angle-to"]=e.angleTo),n}export function slideOffsets(e,n){const t=lengthValue(n),a="number"==typeof n?-n+"px":`calc(-1 * ${t})`;switch(e){case"top":return{x:"0px",y:a};case"bottom":return{x:"0px",y:t};case"left":return{x:a,y:"0px"};default:return{x:t,y:"0px"}}}export function useAnimationRun({trigger:n,play:t,once:a,threshold:i,paused:s,infinite:r}){const o=e.useRef(null),[l,u]=e.useState("mount"===n),[c,p]=e.useState(0),m=e.useCallback(()=>{u(!0),p(e=>e+1)},[]);e.useLayoutEffect(()=>{const e=o.current;if(!e||0===c)return;const n=[e,...e.querySelectorAll(".plass-anim, .plass-marquee-track")];for(const e of n)e.style.animationName="none";e.offsetWidth;for(const e of n)e.style.animationName=""},[c]),e.useEffect(()=>{if("visible"!==n)return;const e=o.current;if(!e||"undefined"==typeof IntersectionObserver)return void u(!0);const t=new IntersectionObserver(([e])=>{e.isIntersecting?(m(),a&&t.disconnect()):a||u(!1)},{threshold:i});return t.observe(e),()=>t.disconnect()},[n,a,i,m]),e.useEffect(()=>{"manual"===n&&(t?m():u(!1))},[n,t,m]);const f="hover"===n?{onPointerEnter:m,onFocus:m,onPointerLeave:()=>{r&&u(!1)},onBlur:()=>{r&&u(!1)}}:{};return{ref:e.useCallback(e=>{o.current=e},[]),state:l&&!s?"running":"paused",started:l,handlers:f}}export function useAnimateElement(e){const{effect:n,trigger:t,play:a,once:i,threshold:s,paused:r,infinite:o,...l}=e,u=useAnimationRun({trigger:t,play:a,once:i,threshold:s,paused:r,infinite:o});return{ref:u.ref,className:n?`plass-anim ${animationClasses[n]}`:"",style:{...animationSlots(l),"--p-anim-state":u.state},props:{...u.handlers,"data-plass-animation":n??void 0,"data-state":u.state}}}
|