plass-ui 1.7.0 → 1.8.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 +218 -0
- package/README.md +2 -2
- package/dist/components/accordion/PlAccordion.d.ts +9 -4
- package/dist/components/accordion/PlAccordion.js +1 -1
- package/dist/components/alert/PlAlert.js +1 -1
- package/dist/components/anchor/PlAnchor.js +1 -1
- package/dist/components/animate-appear/PlAnimateAppear.js +1 -1
- package/dist/components/animate-counter/PlAnimateCounter.d.ts +5 -2
- package/dist/components/animate-counter/PlAnimateCounter.js +1 -1
- package/dist/components/animate-float/PlAnimateFloat.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-marquee/PlAnimateMarquee.js +1 -1
- package/dist/components/animate-scramble/PlAnimateScramble.js +1 -1
- package/dist/components/animate-shake/PlAnimateShake.js +1 -1
- package/dist/components/animate-split/PlAnimateSplit.js +1 -1
- package/dist/components/animate-typing/PlAnimateTyping.js +1 -1
- package/dist/components/app-logo/PlAppLogo.d.ts +51 -15
- package/dist/components/area-chart/PlAreaChart.js +1 -1
- package/dist/components/avatar/PlAvatar.js +1 -1
- package/dist/components/bar-chart/PlBarChart.js +1 -1
- package/dist/components/bottom-navigation/PlBottomNavigation.d.ts +15 -5
- package/dist/components/bottom-navigation/PlBottomNavigation.js +1 -1
- package/dist/components/breadcrumb/PlBreadcrumb.d.ts +16 -3
- package/dist/components/breadcrumb/PlBreadcrumb.js +1 -1
- package/dist/components/button/PlButton.js +1 -1
- package/dist/components/calendar/PlCalendar.js +1 -1
- package/dist/components/card/PlCard.d.ts +2 -1
- package/dist/components/card/PlCard.js +1 -1
- package/dist/components/carousel/PlCarousel.js +1 -1
- package/dist/components/checkbox/PlCheckbox.js +1 -1
- package/dist/components/chip/PlChip.js +1 -1
- package/dist/components/code-block/PlCodeBlock.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 +1 -1
- package/dist/components/combobox/PlCombobox.js +1 -1
- package/dist/components/command-palette/PlCommandPalette.js +1 -1
- package/dist/components/confirm/PlConfirmProvider.js +1 -1
- package/dist/components/data-table/PlDataTable.js +1 -1
- 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/drawer/PlDrawer.d.ts +27 -2
- package/dist/components/drawer/PlDrawer.js +1 -1
- package/dist/components/empty/PlEmpty.d.ts +4 -1
- package/dist/components/empty/PlEmpty.js +1 -1
- package/dist/components/file-picker/PlFilePicker.d.ts +29 -0
- package/dist/components/file-picker/PlFilePicker.js +1 -1
- package/dist/components/file-picker/index.d.ts +1 -1
- package/dist/components/floating-bottom-navigation/PlFloatingBottomNavigation.d.ts +10 -0
- package/dist/components/floating-bottom-navigation/PlFloatingBottomNavigation.js +1 -1
- package/dist/components/footer/PlFooter.js +1 -1
- package/dist/components/gallery/PlGallery.js +1 -1
- package/dist/components/gauge-chart/PlGaugeChart.d.ts +11 -2
- package/dist/components/gauge-chart/PlGaugeChart.js +1 -1
- package/dist/components/header/PlHeader.js +1 -1
- package/dist/components/heatmap-chart/PlHeatmapChart.d.ts +1 -1
- package/dist/components/heatmap-chart/PlHeatmapChart.js +1 -1
- package/dist/components/image/PlImage.js +1 -1
- package/dist/components/image/PlImagePreview.d.ts +3 -2
- package/dist/components/list/PlList.d.ts +16 -5
- package/dist/components/list/PlList.js +1 -1
- package/dist/components/menu/PlMenu.d.ts +19 -7
- package/dist/components/menu/PlMenu.js +1 -1
- package/dist/components/menubar/PlMenubar.js +1 -1
- package/dist/components/meter/PlMeter.js +1 -1
- package/dist/components/mockup/PlMockup.d.ts +4 -3
- package/dist/components/mockup/PlMockup.js +1 -1
- package/dist/components/modal/PlModal.js +1 -1
- package/dist/components/navigation-menu/PlNavigationMenu.d.ts +52 -8
- package/dist/components/navigation-menu/PlNavigationMenu.js +1 -1
- package/dist/components/number-field/PlNumberField.d.ts +1 -1
- package/dist/components/number-field/PlNumberField.js +1 -1
- package/dist/components/otp-field/PlOtpField.js +1 -1
- package/dist/components/overlay/PlOverlay.js +1 -1
- package/dist/components/page-layout/PlPageLayout.js +1 -1
- package/dist/components/panes/PlPanes.d.ts +4 -1
- package/dist/components/panes/PlPanes.js +1 -1
- package/dist/components/pie-chart/PlPieChart.d.ts +1 -1
- package/dist/components/pie-chart/PlPieChart.js +1 -1
- package/dist/components/pill/PlPill.js +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.d.ts +11 -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.js +1 -1
- package/dist/components/scatter-chart/PlScatterChart.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.js +1 -1
- package/dist/components/sidebar/PlSidebar.d.ts +12 -0
- package/dist/components/sidebar/PlSidebar.js +1 -1
- package/dist/components/slider/PlSlider.d.ts +2 -1
- package/dist/components/slider/PlSlider.js +1 -1
- package/dist/components/sparkline/PlSparkline.d.ts +15 -3
- package/dist/components/sparkline/PlSparkline.js +1 -1
- package/dist/components/stepper/PlStepper.d.ts +11 -0
- package/dist/components/stepper/PlStepper.js +1 -1
- package/dist/components/switch/PlSwitch.js +1 -1
- package/dist/components/tabs/PlTabs.js +1 -1
- package/dist/components/text-field/PlTextField.js +1 -1
- package/dist/components/text-link/PlTextLink.js +1 -1
- package/dist/components/time-picker/PlTimePicker.js +1 -1
- package/dist/components/timeline-chart/PlTimelineChart.js +1 -1
- package/dist/components/toast/PlToast.js +1 -1
- package/dist/components/toggle/PlToggle.js +1 -1
- package/dist/components/tour/PlTour.js +1 -1
- package/dist/components/transfer/PlTransfer.js +1 -1
- package/dist/components/tree/PlTree.d.ts +12 -0
- package/dist/components/tree/PlTree.js +1 -1
- package/dist/components/tree-select/PlTreeSelect.js +1 -1
- package/dist/components/typography/PlTypography.d.ts +20 -7
- package/dist/components/typography/PlTypography.js +1 -1
- package/dist/components/visually-hidden/PlVisuallyHidden.d.ts +12 -3
- package/dist/components/visually-hidden/PlVisuallyHidden.js +1 -1
- package/dist/components/window-pane/PlWindowPane.d.ts +3 -0
- package/dist/components/window-pane/PlWindowPane.js +1 -1
- package/dist/css/accordion.css +4 -0
- package/dist/css/alert.css +5 -0
- package/dist/css/anchor.css +6 -0
- package/dist/css/animate-appear.css +3 -0
- package/dist/css/animate-blink.css +3 -0
- package/dist/css/animate-counter.css +4 -0
- package/dist/css/animate-fade.css +3 -0
- package/dist/css/animate-float.css +3 -0
- package/dist/css/animate-grow.css +3 -0
- package/dist/css/animate-headline.css +3 -0
- package/dist/css/animate-lighting.css +4 -0
- package/dist/css/animate-marquee.css +4 -0
- package/dist/css/animate-reveal.css +3 -0
- package/dist/css/animate-rotate.css +3 -0
- package/dist/css/animate-scramble.css +5 -0
- package/dist/css/animate-shake.css +3 -0
- package/dist/css/animate-slide.css +3 -0
- package/dist/css/animate-split.css +4 -0
- package/dist/css/animate-typing.css +4 -0
- package/dist/css/animate-zoom.css +3 -0
- package/dist/css/app-logo.css +2 -0
- package/dist/css/area-chart.css +12 -0
- package/dist/css/aspect-ratio.css +2 -0
- package/dist/css/avatar.css +2 -0
- package/dist/css/back-top.css +11 -0
- package/dist/css/badge.css +2 -0
- package/dist/css/bar-chart.css +10 -0
- package/dist/css/base.css +2 -3
- package/dist/css/blockquote.css +2 -0
- package/dist/css/bottom-navigation.css +4 -0
- package/dist/css/box.css +2 -0
- package/dist/css/breadcrumb.css +6 -0
- package/dist/css/button-group.css +2 -0
- package/dist/css/button.css +7 -0
- package/dist/css/calendar.css +17 -0
- package/dist/css/card.css +2 -0
- package/dist/css/carousel.css +10 -0
- package/dist/css/chat-bubble.css +6 -0
- package/dist/css/checkbox.css +3 -0
- package/dist/css/chip.css +8 -0
- package/dist/css/code-block.css +6 -0
- package/dist/css/collapsible.css +3 -0
- package/dist/css/color-picker.css +17 -0
- package/dist/css/combobox.css +10 -0
- package/dist/css/command-palette.css +7 -0
- package/dist/css/confirm.css +9 -0
- package/dist/css/container.css +5 -0
- package/dist/css/data-list.css +2 -0
- package/dist/css/data-table.css +15 -0
- package/dist/css/date-picker.css +16 -0
- package/dist/css/date-range-picker.css +16 -0
- package/dist/css/date-time-picker.css +16 -0
- package/dist/css/divider.css +2 -0
- package/dist/css/drawer.css +6 -0
- package/dist/css/empty.css +2 -0
- package/dist/css/fieldset.css +2 -0
- package/dist/css/file-picker.css +8 -0
- package/dist/css/flex.css +5 -0
- package/dist/css/floating-action-button.css +7 -0
- package/dist/css/floating-bottom-navigation.css +5 -0
- package/dist/css/footer.css +6 -0
- package/dist/css/form.css +2 -0
- package/dist/css/gallery.css +15 -0
- package/dist/css/gauge-chart.css +11 -0
- package/dist/css/grid.css +5 -0
- package/dist/css/header.css +6 -0
- package/dist/css/heatmap-chart.css +10 -0
- package/dist/css/highlight.css +2 -0
- package/dist/css/hot-keys.css +3 -0
- package/dist/css/hover-card.css +9 -0
- package/dist/css/how-to-steps.css +3 -0
- package/dist/css/icon-button.css +7 -0
- package/dist/css/icon.css +1 -0
- package/dist/css/image.css +7 -0
- package/dist/css/line-chart.css +12 -0
- package/dist/css/list.css +2 -0
- package/dist/css/menu.css +5 -0
- package/dist/css/menubar.css +5 -0
- package/dist/css/meter.css +6 -0
- package/dist/css/mockup.css +4 -0
- package/dist/css/modal.css +5 -0
- package/dist/css/navigation-menu.css +4 -0
- package/dist/css/number-field.css +10 -0
- package/dist/css/otp-field.css +6 -0
- package/dist/css/overlay.css +4 -0
- package/dist/css/page-layout.css +7 -0
- package/dist/css/pagination.css +8 -0
- package/dist/css/panes.css +7 -0
- package/dist/css/pie-chart.css +10 -0
- package/dist/css/pill.css +4 -0
- package/dist/css/popconfirm.css +12 -0
- package/dist/css/popover.css +11 -0
- package/dist/css/portal.css +1 -0
- package/dist/css/progress-box.css +5 -0
- package/dist/css/progress-circular.css +5 -0
- package/dist/css/progress-linear.css +5 -0
- package/dist/css/radio-group.css +3 -0
- package/dist/css/rating.css +6 -0
- package/dist/css/scatter-chart.css +10 -0
- package/dist/css/scroll-area.css +2 -0
- package/dist/css/scroll-zone.css +15 -0
- package/dist/css/segmented-button.css +5 -0
- package/dist/css/select.css +9 -0
- package/dist/css/show.css +1 -0
- package/dist/css/sidebar.css +16 -0
- package/dist/css/skeleton.css +2 -0
- package/dist/css/slider.css +3 -0
- package/dist/css/sparkline.css +10 -0
- package/dist/css/spoiler.css +10 -0
- package/dist/css/stack.css +5 -0
- package/dist/css/stat.css +2 -0
- package/dist/css/stepper.css +8 -0
- package/dist/css/switch.css +3 -0
- package/dist/css/table.css +3 -0
- package/dist/css/tabs.css +7 -0
- package/dist/css/text-field.css +8 -0
- package/dist/css/text-link.css +6 -0
- package/dist/css/time-picker.css +16 -0
- package/dist/css/timeline-chart.css +10 -0
- package/dist/css/timeline.css +6 -0
- package/dist/css/toast.css +5 -0
- package/dist/css/toggle.css +5 -0
- package/dist/css/toolbar.css +2 -0
- package/dist/css/tooltip.css +9 -0
- package/dist/css/tour.css +10 -0
- package/dist/css/transfer.css +13 -0
- package/dist/css/tree-select.css +14 -0
- package/dist/css/tree.css +3 -0
- package/dist/css/visually-hidden.css +2 -0
- package/dist/css/window-pane.css +9 -0
- package/dist/internal/animate.d.ts +59 -4
- package/dist/internal/animate.js +1 -1
- package/dist/internal/bottom-bar.js +1 -1
- package/dist/internal/calendar.js +1 -1
- package/dist/internal/chart-frame.d.ts +130 -11
- package/dist/internal/chart-frame.js +1 -1
- package/dist/internal/commit-change.d.ts +38 -0
- package/dist/internal/commit-change.js +1 -0
- package/dist/internal/data-table.d.ts +2 -2
- package/dist/internal/data-table.js +1 -1
- package/dist/internal/date.d.ts +9 -0
- package/dist/internal/date.js +1 -1
- package/dist/internal/defaults.d.ts +34 -1
- package/dist/internal/defaults.js +1 -1
- package/dist/internal/direction.d.ts +8 -2
- package/dist/internal/direction.js +1 -1
- package/dist/internal/form.d.ts +43 -0
- package/dist/internal/form.js +1 -1
- package/dist/internal/format.d.ts +4 -1
- package/dist/internal/format.js +1 -1
- package/dist/internal/gallery.d.ts +28 -0
- package/dist/internal/gallery.js +1 -1
- package/dist/internal/glow.d.ts +7 -2
- package/dist/internal/glow.js +1 -1
- package/dist/internal/heading.d.ts +11 -0
- package/dist/internal/heading.js +1 -0
- package/dist/internal/highlight.d.ts +4 -2
- package/dist/internal/highlight.js +1 -1
- package/dist/internal/labels.d.ts +5 -0
- package/dist/internal/labels.js +1 -1
- package/dist/internal/layout-box.d.ts +35 -0
- package/dist/internal/layout-box.js +1 -0
- package/dist/internal/lazy.d.ts +37 -0
- package/dist/internal/lazy.js +1 -0
- package/dist/internal/media.d.ts +6 -0
- package/dist/internal/media.js +1 -1
- package/dist/internal/page-layout.d.ts +24 -13
- package/dist/internal/page-layout.js +1 -1
- package/dist/internal/picker.d.ts +1 -1
- package/dist/internal/picker.js +1 -1
- package/dist/internal/progress.d.ts +24 -0
- package/dist/internal/progress.js +1 -1
- package/dist/internal/search.d.ts +12 -0
- package/dist/internal/search.js +1 -1
- package/dist/internal/sizer.d.ts +15 -8
- package/dist/internal/sizer.js +1 -1
- package/dist/internal/styles.d.ts +22 -6
- package/dist/internal/styles.js +1 -1
- package/dist/internal/wheel.d.ts +13 -1
- package/dist/internal/wheel.js +1 -1
- package/dist/internal/window.js +1 -1
- package/dist/locales/de.js +1 -1
- package/dist/locales/es.js +1 -1
- package/dist/locales/fr.js +1 -1
- package/dist/locales/ja.js +1 -1
- package/dist/locales/ko.js +1 -1
- package/dist/locales/zh-Hans.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +758 -40
- package/dist/tokens.css +758 -40
- package/dist/types.d.ts +10 -1
- package/package.json +18 -17
|
@@ -34,9 +34,9 @@ export interface PlassSort {
|
|
|
34
34
|
* **Strings compare with `localeCompare`.** `'a' < 'B'` is false by code point,
|
|
35
35
|
* which puts every capitalised word above every lower-case one and sorts `Ösi`
|
|
36
36
|
* after `Zoe`. A list of names a reader cannot scan is a list that was sorted
|
|
37
|
-
* for the machine.
|
|
37
|
+
* for the machine. `locale` is the collation, and left out it is the runtime's.
|
|
38
38
|
*/
|
|
39
|
-
export declare function compareValues(a: unknown, b: unknown, direction?: 1 | -1): number;
|
|
39
|
+
export declare function compareValues(a: unknown, b: unknown, direction?: 1 | -1, locale?: Intl.LocalesArgument): number;
|
|
40
40
|
/**
|
|
41
41
|
* What pressing a column heading does next.
|
|
42
42
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function compareValues(e,n,t=1){const
|
|
1
|
+
export function compareValues(e,n,t=1,o){const r=null==e||""===e,i=null==n||""===n;return r||i?r&&i?0:r?1:-1:function compareKnown(e,n,t){return"number"==typeof e&&"number"==typeof n?e-n:"boolean"==typeof e&&"boolean"==typeof n?Number(e)-Number(n):e instanceof Date&&n instanceof Date?e.getTime()-n.getTime():String(e).localeCompare(String(n),t)}(e,n,o)*t}export function nextSort(e,n){return null===e||e.key!==n?{key:n,direction:"asc"}:"asc"===e.direction?{key:n,direction:"desc"}:null}export function keysBetween(e,n,t){const o=e.indexOf(n),r=e.indexOf(t);return-1===o||-1===r?[]:o<=r?e.slice(o,r+1):e.slice(r,o+1)}export function pageBounds(e,n,t){const o=Math.max(1,Math.ceil(e/t)),r=(Math.min(Math.max(1,Math.trunc(n)),o)-1)*t;return[r,Math.min(r+t,e)]}
|
package/dist/internal/date.d.ts
CHANGED
|
@@ -54,6 +54,15 @@ export declare function startOfYear(date: Date): Date;
|
|
|
54
54
|
export declare function daysInMonth(year: number, month: number): number;
|
|
55
55
|
/** Today, at midnight. The one place the pickers read the clock for a *date*. */
|
|
56
56
|
export declare function today(): Date;
|
|
57
|
+
/**
|
|
58
|
+
* Today as the clock reads in `timeZone`, at local midnight — the day it is
|
|
59
|
+
* there, as the local date everything else here works on. Left out, it is
|
|
60
|
+
* {@link today}.
|
|
61
|
+
*
|
|
62
|
+
* A server render reads the clock in UTC rather than in whatever zone the
|
|
63
|
+
* machine is set to, so the browser hydrating it can ask for the same day.
|
|
64
|
+
*/
|
|
65
|
+
export declare function todayIn(timeZone: string | undefined): Date;
|
|
57
66
|
export declare function addDays(date: Date, amount: number): Date;
|
|
58
67
|
/**
|
|
59
68
|
* Months, with the day of the month clamped rather than allowed to overflow.
|
package/dist/internal/date.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{dateFormatter as t}from"./format.js";export const YEAR_PAGE_SIZE=12;export function makeDate(t,e,n){const r=new Date(0);return r.setFullYear(t,e,n),r.setHours(0,0,0,0),r}export function isValidDate(t){return t instanceof Date&&!Number.isNaN(t.getTime())}export function startOfDay(t){const e=new Date(t.getTime());return e.setHours(0,0,0,0),e}export function startOfMonth(t){return makeDate(t.getFullYear(),t.getMonth(),1)}export function startOfYear(t){return makeDate(t.getFullYear(),0,1)}export function daysInMonth(t,e){return makeDate(t,e+1,0).getDate()}export function today(){return startOfDay(new Date)}export function addDays(t,e){const n=new Date(t.getTime());return n.setDate(n.getDate()+e),n}export function addMonths(t,e){const n=new Date(t.getTime()),r=makeDate(t.getFullYear(),t.getMonth()+e,1);return n.setFullYear(r.getFullYear(),r.getMonth(),Math.min(t.getDate(),daysInMonth(r.getFullYear(),r.getMonth()))),n}export function addYears(t,e){return addMonths(t,12*e)}export function compareDay(t,e){return startOfDay(t).getTime()-startOfDay(e).getTime()}export function isSameDay(t,e){return isValidDate(t)&&isValidDate(e)&&0===compareDay(t,e)}export function isSameMonth(t,e){return isValidDate(t)&&isValidDate(e)&&t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()}export function clampDate(t,e,n){return isValidDate(e)&&t.getTime()<e.getTime()?new Date(e.getTime()):isValidDate(n)&&t.getTime()>n.getTime()?new Date(n.getTime()):t}export function isDayOutside(t,e,n){return!!(isValidDate(e)&&compareDay(t,e)<0)||isValidDate(n)&&compareDay(t,n)>0}export function isMonthOutside(t,e,n){const r=t.getFullYear(),o=t.getMonth();return isDayOutside(makeDate(r,o,daysInMonth(r,o)),e,null)||isDayOutside(makeDate(r,o,1),null,n)}export function isYearOutside(t,e,n){const r=t.getFullYear();return isValidDate(e)&&r<e.getFullYear()||isValidDate(n)&&r>n.getFullYear()}export function secondsOfDay(t){return 3600*t.getHours()+60*t.getMinutes()+t.getSeconds()}export function timeUnitSpan(t,e){const n=secondsOfDay(e);if("hour"===t){const t=3600*Math.floor(n/3600);return[t,t+3599]}if("minute"===t){const t=60*Math.floor(n/60);return[t,t+59]}if("second"===t)return[n,n];const r=e.getHours()<12?0:43200;return[r,r+43200-1]}export function withTime(t,e){const n=new Date(t.getTime());return n.setHours(e.hours??n.getHours(),e.minutes??n.getMinutes(),e.seconds??n.getSeconds(),0),n}export function clampMoment(t,e,n,r){const o=r?1e3:6e4,floor=t=>withTime(t,{seconds:r?t.getSeconds():0});if(isValidDate(e)&&t.getTime()<e.getTime()){const t=floor(e),r=t.getTime()<e.getTime()?new Date(t.getTime()+o):t;return isValidDate(n)&&r.getTime()>n.getTime()?new Date(e.getTime()):r}if(isValidDate(n)&&t.getTime()>n.getTime()){const t=floor(n);return isValidDate(e)&&t.getTime()<e.getTime()?new Date(n.getTime()):t}return t}export function mergeDateAndTime(t,e){return withTime(startOfDay(t),{hours:e.getHours(),minutes:e.getMinutes(),seconds:e.getSeconds()})}export function calendarWeeks(t,e){const n=startOfMonth(t),r=(n.getDay()-e+7)%7,o=addDays(n,-r);return Array.from({length:6},(t,e)=>Array.from({length:7},(t,n)=>addDays(o,7*e+n)))}export function yearPageStart(t){return t-(t%12+12)%12}export function formatDate(e,n,r){return isValidDate(e)?t(n,r).format(e):""}const
|
|
1
|
+
import{dateFormatter as t}from"./format.js";export const YEAR_PAGE_SIZE=12;export function makeDate(t,e,n){const r=new Date(0);return r.setFullYear(t,e,n),r.setHours(0,0,0,0),r}export function isValidDate(t){return t instanceof Date&&!Number.isNaN(t.getTime())}export function startOfDay(t){const e=new Date(t.getTime());return e.setHours(0,0,0,0),e}export function startOfMonth(t){return makeDate(t.getFullYear(),t.getMonth(),1)}export function startOfYear(t){return makeDate(t.getFullYear(),0,1)}export function daysInMonth(t,e){return makeDate(t,e+1,0).getDate()}export function today(){return startOfDay(new Date)}const e={year:"numeric",month:"numeric",day:"numeric"};export function todayIn(n){if(void 0===n)return today();const r=t("en-US",{...e,timeZone:n}).formatToParts(new Date),part=t=>Number(r.find(e=>e.type===t)?.value);return makeDate(part("year"),part("month")-1,part("day"))}export function addDays(t,e){const n=new Date(t.getTime());return n.setDate(n.getDate()+e),n}export function addMonths(t,e){const n=new Date(t.getTime()),r=makeDate(t.getFullYear(),t.getMonth()+e,1);return n.setFullYear(r.getFullYear(),r.getMonth(),Math.min(t.getDate(),daysInMonth(r.getFullYear(),r.getMonth()))),n}export function addYears(t,e){return addMonths(t,12*e)}export function compareDay(t,e){return startOfDay(t).getTime()-startOfDay(e).getTime()}export function isSameDay(t,e){return isValidDate(t)&&isValidDate(e)&&0===compareDay(t,e)}export function isSameMonth(t,e){return isValidDate(t)&&isValidDate(e)&&t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()}export function clampDate(t,e,n){return isValidDate(e)&&t.getTime()<e.getTime()?new Date(e.getTime()):isValidDate(n)&&t.getTime()>n.getTime()?new Date(n.getTime()):t}export function isDayOutside(t,e,n){return!!(isValidDate(e)&&compareDay(t,e)<0)||isValidDate(n)&&compareDay(t,n)>0}export function isMonthOutside(t,e,n){const r=t.getFullYear(),o=t.getMonth();return isDayOutside(makeDate(r,o,daysInMonth(r,o)),e,null)||isDayOutside(makeDate(r,o,1),null,n)}export function isYearOutside(t,e,n){const r=t.getFullYear();return isValidDate(e)&&r<e.getFullYear()||isValidDate(n)&&r>n.getFullYear()}export function secondsOfDay(t){return 3600*t.getHours()+60*t.getMinutes()+t.getSeconds()}export function timeUnitSpan(t,e){const n=secondsOfDay(e);if("hour"===t){const t=3600*Math.floor(n/3600);return[t,t+3599]}if("minute"===t){const t=60*Math.floor(n/60);return[t,t+59]}if("second"===t)return[n,n];const r=e.getHours()<12?0:43200;return[r,r+43200-1]}export function withTime(t,e){const n=new Date(t.getTime());return n.setHours(e.hours??n.getHours(),e.minutes??n.getMinutes(),e.seconds??n.getSeconds(),0),n}export function clampMoment(t,e,n,r){const o=r?1e3:6e4,floor=t=>withTime(t,{seconds:r?t.getSeconds():0});if(isValidDate(e)&&t.getTime()<e.getTime()){const t=floor(e),r=t.getTime()<e.getTime()?new Date(t.getTime()+o):t;return isValidDate(n)&&r.getTime()>n.getTime()?new Date(e.getTime()):r}if(isValidDate(n)&&t.getTime()>n.getTime()){const t=floor(n);return isValidDate(e)&&t.getTime()<e.getTime()?new Date(n.getTime()):t}return t}export function mergeDateAndTime(t,e){return withTime(startOfDay(t),{hours:e.getHours(),minutes:e.getMinutes(),seconds:e.getSeconds()})}export function calendarWeeks(t,e){const n=startOfMonth(t),r=(n.getDay()-e+7)%7,o=addDays(n,-r);return Array.from({length:6},(t,e)=>Array.from({length:7},(t,n)=>addDays(o,7*e+n)))}export function yearPageStart(t){return t-(t%12+12)%12}export function formatDate(e,n,r){return isValidDate(e)?t(n,r).format(e):""}const n=/* @__PURE__ */[...Array.from({length:24},(t,e)=>new Date(2027,e%12,21+e%7,e,58,58)),new Date(2027,0,22,12,58,58)];export function displaySamples(e,r){const o=t(e,r);return[...new Set(n.map(t=>o.format(t)))]}export function withPlaceholder(t,e){return"string"==typeof e&&""!==e?[...t,e]:t}export function toISODate(t){const pad=t=>String(t).padStart(2,"0");return`${String(t.getFullYear()).padStart(4,"0")}-${pad(t.getMonth()+1)}-${pad(t.getDate())}`}export function toISOMonth(t){return`${String(t.getFullYear()).padStart(4,"0")}-${String(t.getMonth()+1).padStart(2,"0")}`}export function toISOYear(t){return String(t.getFullYear()).padStart(4,"0")}export function toISOTime(t,e=!1){const pad=t=>String(t).padStart(2,"0"),n=`${pad(t.getHours())}:${pad(t.getMinutes())}`;return e?`${n}:${pad(t.getSeconds())}`:n}export function toISODateTime(t,e=!1){return`${toISODate(t)}T${toISOTime(t,e)}`}function weekdayOrigin(){return makeDate(2021,7,1)}export function weekdayLabels(e,n,r="short"){const o=t(e,{weekday:r}),a=weekdayOrigin();return Array.from({length:7},(t,e)=>o.format(addDays(a,(n+e)%7)))}export function monthLabels(e,n="short"){const r=t(e,{month:n});return Array.from({length:12},(t,e)=>r.format(makeDate(2021,e,1)))}export function isMonthBeforeYear(e){const n=t(e,{year:"numeric",month:"long"}).formatToParts(weekdayOrigin());return n.findIndex(t=>"month"===t.type)<n.findIndex(t=>"year"===t.type)}export function isHour12(e){const n=t(e,{hour:"numeric"}).resolvedOptions();return n.hourCycle?"h11"===n.hourCycle||"h12"===n.hourCycle:!0===n.hour12}export function meridiemLabels(e){const n=t(e,{hour:"numeric",hour12:!0}),r=weekdayOrigin(),read=t=>{const e=n.formatToParts(withTime(r,{hours:t})).find(t=>"dayPeriod"===t.type);return e?.value??(t<12?"AM":"PM")};return[read(9),read(21)]}const r=new Map;export function localeWeekStart(t){let e=r.get(t);return void 0===e&&(e=function readWeekStart(t){try{const e=t??(new Intl.DateTimeFormat).resolvedOptions().locale,n=new Intl.Locale(e),r="function"==typeof n.getWeekInfo?n.getWeekInfo():n.weekInfo;if("number"==typeof r?.firstDay)return r.firstDay%7}catch{}return 0}(t),r.set(t,e)),e}
|
|
@@ -53,7 +53,14 @@ export interface PlassDefaults {
|
|
|
53
53
|
* to cut, so its label stays above the row whatever this says.
|
|
54
54
|
*/
|
|
55
55
|
labelPlacement?: PlassFieldLabelPlacement;
|
|
56
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* The BCP 47 tag the date and time components format and read against.
|
|
58
|
+
*
|
|
59
|
+
* Left out, it is the browser's own, which a server cannot ask for: a server
|
|
60
|
+
* render and its hydration write `en-US`, and the components switch once
|
|
61
|
+
* hydration is done. A server-rendered page that names it paints the reader's
|
|
62
|
+
* format from the start.
|
|
63
|
+
*/
|
|
57
64
|
locale?: string;
|
|
58
65
|
/** Which day their weeks start on, as `Date` counts them — Sunday is `0`. */
|
|
59
66
|
weekStartsOn?: PlassWeekday;
|
|
@@ -85,3 +92,29 @@ export declare const DefaultsContext: React.Context<PlassDefaults>;
|
|
|
85
92
|
* compact application.
|
|
86
93
|
*/
|
|
87
94
|
export declare function useDefaults(): PlassDefaults;
|
|
95
|
+
/** What a server render and its hydration format in when nobody named a locale. */
|
|
96
|
+
declare const hydrationLocale = "en-US";
|
|
97
|
+
/**
|
|
98
|
+
* The locale to format in, given the one a component was told.
|
|
99
|
+
*
|
|
100
|
+
* `given` comes back as it is. Left out, it is `undefined` — the runtime's own
|
|
101
|
+
* locale — except in a server render and its hydration, where it is `en-US`.
|
|
102
|
+
* For the few components that do not read the provider's locale; the rest call
|
|
103
|
+
* {@link useLocale}.
|
|
104
|
+
*/
|
|
105
|
+
export declare function useRuntimeLocale<T extends Intl.LocalesArgument>(given: T): T | typeof hydrationLocale;
|
|
106
|
+
/**
|
|
107
|
+
* The locale a component formats in: its own `locale` prop, then the nearest
|
|
108
|
+
* provider's, then the runtime's, which a server render and its hydration pin
|
|
109
|
+
* to `en-US`. See {@link useRuntimeLocale}.
|
|
110
|
+
*/
|
|
111
|
+
export declare function useLocale<T extends Intl.LocalesArgument = string | undefined>(own?: T): T | string | undefined;
|
|
112
|
+
/** What a server render and its hydration read the clock in. */
|
|
113
|
+
declare const hydrationTimeZone = "UTC";
|
|
114
|
+
/**
|
|
115
|
+
* The zone to read the clock in: `undefined` — the runtime's own — except in a
|
|
116
|
+
* server render and its hydration, where it is `UTC`. `todayIn` in
|
|
117
|
+
* `internal/date.ts` turns it into a day.
|
|
118
|
+
*/
|
|
119
|
+
export declare function useRuntimeTimeZone(): typeof hydrationTimeZone | undefined;
|
|
120
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import*as
|
|
1
|
+
"use client";import*as e from"react";const n=/* @__PURE__ */Object.freeze({});export const DefaultsContext=/* @__PURE__ */e.createContext(n);export function useDefaults(){return e.useContext(DefaultsContext)}function subscribeToNothing(){return unsubscribeFromNothing}function unsubscribeFromNothing(){}export function useRuntimeLocale(n){return e.useSyncExternalStore(subscribeToNothing,()=>n,()=>n??"en-US")}export function useLocale(n){const t=e.useContext(DefaultsContext).locale;return useRuntimeLocale(n??t)}function runtimeTimeZone(){}function pinnedTimeZone(){return"UTC"}export function useRuntimeTimeZone(){return e.useSyncExternalStore(subscribeToNothing,runtimeTimeZone,pinnedTimeZone)}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
/** The two directions a document can run in. */
|
|
2
2
|
export type PlassDirection = 'ltr' | 'rtl';
|
|
3
|
-
/**
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Which way the document runs, re-rendering when it turns over.
|
|
5
|
+
*
|
|
6
|
+
* `active: false` answers `ltr` without reading the document or listening to
|
|
7
|
+
* it, for a component that needs the direction only in one of its states and
|
|
8
|
+
* should cost nothing in the others.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useDocumentDirection(active?: boolean): PlassDirection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import*as e from"react";function read(){return"undefined"==typeof document?"ltr":"rtl"===getComputedStyle(document.documentElement).direction?"rtl":"ltr"}let t=null,n=null;const r=new Set;function snapshot(){return null===t&&(t=read()),t}function onServer(){return"ltr"}function subscribe(e){return r.add(e),n||"undefined"==typeof document||(n=new MutationObserver(()=>{const e=read();e!==t&&(t=e,r.forEach(e=>e()))}),n.observe(document.documentElement,{attributes:!0,attributeFilter:["dir","class","style"]})),()=>{r.delete(e),0===r.size&&(n?.disconnect(),n=null,t=null)}}export function useDocumentDirection(){return e.useSyncExternalStore(subscribe,snapshot,onServer)}
|
|
1
|
+
"use client";import*as e from"react";function read(){return"undefined"==typeof document?"ltr":"rtl"===getComputedStyle(document.documentElement).direction?"rtl":"ltr"}let t=null,n=null;const r=new Set;function snapshot(){return null===t&&(t=read()),t}function onServer(){return"ltr"}function subscribe(e){return r.add(e),n||"undefined"==typeof document||(n=new MutationObserver(()=>{const e=read();e!==t&&(t=e,r.forEach(e=>e()))}),n.observe(document.documentElement,{attributes:!0,attributeFilter:["dir","class","style"]})),()=>{r.delete(e),0===r.size&&(n?.disconnect(),n=null,t=null)}}function idle(){return()=>{}}export function useDocumentDirection(t=!0){return e.useSyncExternalStore(t?subscribe:idle,t?snapshot:onServer,onServer)}
|
package/dist/internal/form.d.ts
CHANGED
|
@@ -53,6 +53,49 @@ export declare const FadedContext: React.Context<boolean>;
|
|
|
53
53
|
* a control in one draws itself exactly as it would with `disabled` of its own.
|
|
54
54
|
*/
|
|
55
55
|
export declare function useDisabled(disabled: boolean | undefined): boolean;
|
|
56
|
+
/** The two attributes a caller names a control with. */
|
|
57
|
+
export interface ControlNaming {
|
|
58
|
+
'aria-label'?: string;
|
|
59
|
+
'aria-labelledby'?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A caller's `aria-label` and `aria-labelledby`, for the control a field's
|
|
63
|
+
* other props are carried past.
|
|
64
|
+
*
|
|
65
|
+
* A labelled field spreads what it does not know onto the stack around it, and
|
|
66
|
+
* a `<div>` with no role is named by neither: a select in a toolbar, with no
|
|
67
|
+
* room for a `label`, had no way to name its trigger.
|
|
68
|
+
*
|
|
69
|
+
* Base UI merges a caller's props over its own, and its own `aria-labelledby`
|
|
70
|
+
* points at the visible label, which would outrank an `aria-label`. So an
|
|
71
|
+
* `aria-label` given without an `aria-labelledby` comes with that key holding
|
|
72
|
+
* `undefined`, which takes Base UI's away and leaves the `aria-label` as the
|
|
73
|
+
* name in the label's place, as an `aria-label` outranks a `<label>` on a
|
|
74
|
+
* native control. A caller's `aria-labelledby` outranks both. With neither,
|
|
75
|
+
* neither key is there, and the label goes on naming the control.
|
|
76
|
+
*
|
|
77
|
+
* A meter and the three progress indicators take them on their root for the
|
|
78
|
+
* same reason: Base UI's `Meter.Root` and `Progress.Root` point their own
|
|
79
|
+
* `aria-labelledby` at the visible label.
|
|
80
|
+
*/
|
|
81
|
+
export declare function controlNaming(label: string | undefined, labelledBy: string | undefined): ControlNaming;
|
|
82
|
+
/**
|
|
83
|
+
* The `aria-labelledby` that names a control by a caller's `aria-label`, and
|
|
84
|
+
* the hidden words it points at, for a Base UI part `controlNaming` cannot
|
|
85
|
+
* reach.
|
|
86
|
+
*
|
|
87
|
+
* A checkbox, a switch, a radio, and the group around a slider's thumbs or a
|
|
88
|
+
* code's slots read `aria-labelledby` themselves and fall back to the visible
|
|
89
|
+
* label for anything but a reference of the caller's, `undefined` included. So
|
|
90
|
+
* an `aria-label` given without an `aria-labelledby` is written into a hidden
|
|
91
|
+
* node as well, and the part is pointed at that, which leaves the `aria-label`
|
|
92
|
+
* as the name in the label's place. A caller's `aria-labelledby` comes back as
|
|
93
|
+
* it was, and with neither there is no reference and no node.
|
|
94
|
+
*/
|
|
95
|
+
export declare function useLabelReference(label: string | undefined, labelledBy: string | undefined): {
|
|
96
|
+
labelledBy: string | undefined;
|
|
97
|
+
node: React.ReactNode;
|
|
98
|
+
};
|
|
56
99
|
/**
|
|
57
100
|
* Whether `element` is inside a disabled `<fieldset>`, re-rendering when a
|
|
58
101
|
* fieldset around it turns `disabled` on or off.
|
package/dist/internal/form.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,Fragment as t,jsxs as n}from"react/jsx-runtime";import*as o from"react";import{Field as r}from"@base-ui/react/field";export const FormReportContext=/* @__PURE__ */o.createContext(null);export function useFormReport(e,t,n=!0){const r=o.useContext(FormReportContext),s=o.useRef(t);o.useEffect(()=>{s.current=t}),o.useEffect(()=>{if(!r||!e||!n)return;const entry=()=>s.current();return r.set(e,entry),()=>{r.get(e)===entry&&r.delete(e)}},[r,e,n])}export const FieldsetDisabledContext=/* @__PURE__ */o.createContext(!1);export const FadedContext=/* @__PURE__ */o.createContext(!1);export function useDisabled(e){return o.useContext(FieldsetDisabledContext)||!0===e}function fieldsetsAround(e){const t=[];for(let n=e.parentElement?.closest("fieldset");n;n=n.parentElement?.closest("fieldset"))t.push(n);return t}export function useFieldsetDisabled(e){const t=o.useCallback(t=>{if(!e)return()=>{};const n=new MutationObserver(t);return fieldsetsAround(e).forEach(e=>n.observe(e,{attributes:!0,attributeFilter:["disabled"]})),()=>n.disconnect()},[e]);return o.useSyncExternalStore(t,()=>null!==e&&fieldsetsAround(e).some(t=>t.disabled&&!t.querySelector(":scope > legend")?.contains(e)),()=>!1)}export function leaveFormControl(e){e?.dispatchEvent(new FocusEvent("focusout",{bubbles:!0}))}export const FormControl=/* @__PURE__ */o.forwardRef(function FormControl({name:o,value:s,required:
|
|
1
|
+
import{jsx as e,Fragment as t,jsxs as n}from"react/jsx-runtime";import*as o from"react";import{Field as r}from"@base-ui/react/field";export const FormReportContext=/* @__PURE__ */o.createContext(null);export function useFormReport(e,t,n=!0){const r=o.useContext(FormReportContext),s=o.useRef(t);o.useEffect(()=>{s.current=t}),o.useEffect(()=>{if(!r||!e||!n)return;const entry=()=>s.current();return r.set(e,entry),()=>{r.get(e)===entry&&r.delete(e)}},[r,e,n])}export const FieldsetDisabledContext=/* @__PURE__ */o.createContext(!1);export const FadedContext=/* @__PURE__ */o.createContext(!1);export function useDisabled(e){return o.useContext(FieldsetDisabledContext)||!0===e}export function controlNaming(e,t){return{...void 0===e?null:{"aria-label":e},...void 0!==t||e?{"aria-labelledby":t}:null}}export function useLabelReference(t,n){const r=o.useId();return void 0===n&&t?{labelledBy:r,node:e("span",{id:r,hidden:!0,children:t})}:{labelledBy:n,node:null}}function fieldsetsAround(e){const t=[];for(let n=e.parentElement?.closest("fieldset");n;n=n.parentElement?.closest("fieldset"))t.push(n);return t}export function useFieldsetDisabled(e){const t=o.useCallback(t=>{if(!e)return()=>{};const n=new MutationObserver(t);return fieldsetsAround(e).forEach(e=>n.observe(e,{attributes:!0,attributeFilter:["disabled"]})),()=>n.disconnect()},[e]);return o.useSyncExternalStore(t,()=>null!==e&&fieldsetsAround(e).some(t=>t.disabled&&!t.querySelector(":scope > legend")?.contains(e)),()=>!1)}export function leaveFormControl(e){e?.dispatchEvent(new FocusEvent("focusout",{bubbles:!0}))}export const FormControl=/* @__PURE__ */o.forwardRef(function FormControl({name:o,value:s,required:l,disabled:i,standIn:a},u){const d=Array.isArray(s),c=d?s.length>0&&s.every(e=>""!==e):""!==s;return useFormReport(o,()=>[...s],d&&!i),n(t,{children:[e(r.Control,{ref:u,name:o,value:d?c?s.join("\n"):"":s,required:l,disabled:i,tabIndex:-1,"aria-hidden":"true",autoComplete:"off",className:"pointer-events-none absolute size-px overflow-hidden opacity-0 [clip-path:inset(50%)]",onFocus:()=>a()?.focus(),render:d?t=>e("input",{...t,name:void 0}):void 0}),d&&o?s.map((t,n)=>e("input",{type:"hidden",name:o,value:t,disabled:i},n)):null]})});
|
|
@@ -20,7 +20,10 @@
|
|
|
20
20
|
* object on every render, which is the ordinary way that prop gets written, and
|
|
21
21
|
* keying on identity would miss every time and cache nothing but garbage.
|
|
22
22
|
*/
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* A memoised `Intl.DateTimeFormat`, built again when the runtime's time zone
|
|
25
|
+
* has changed since it was.
|
|
26
|
+
*/
|
|
24
27
|
export declare function dateFormatter(locale: string | undefined, options: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
|
|
25
28
|
/** A memoised `Intl.NumberFormat`. */
|
|
26
29
|
export declare function numberFormatter(locale: string | undefined, options?: Intl.NumberFormatOptions): Intl.NumberFormat;
|
package/dist/internal/format.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function cacheKey(t
|
|
1
|
+
function cacheKey(e,t){return`${e??""}\0${t?JSON.stringify(t):""}`}const e=new Map,t=/* @__PURE__ */new Date(16094592e5),n=/* @__PURE__ */new Date(16250976e5);let r=Number.NaN,o=Number.NaN;export function dateFormatter(a,c){(function zoneHasMoved(){const e=t.getTimezoneOffset(),a=n.getTimezoneOffset();return(e!==r||a!==o)&&(r=e,o=a,!0)})()&&e.clear();const u=cacheKey(a,c);let m=e.get(u);return m||(m=new Intl.DateTimeFormat(a,c),e.set(u,m)),m}const a=new Map;export function numberFormatter(e,t){const n=cacheKey(e,t);let r=a.get(n);return r||(r=new Intl.NumberFormat(e,t),a.set(n,r)),r}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PlassResponsive } from '../types.js';
|
|
1
2
|
/**
|
|
2
3
|
* A tile's proportion as the number the layouts do arithmetic on.
|
|
3
4
|
*
|
|
@@ -78,3 +79,30 @@ export declare function masonryRows(ratios: readonly number[], columns: number,
|
|
|
78
79
|
tracks: PlassMasonryTrack[];
|
|
79
80
|
tiles: PlassMasonryTile[];
|
|
80
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* A column count as a gallery uses it: a whole number of lanes, and at least
|
|
84
|
+
* one. The column slot and the masonry deal both read it through here, so the
|
|
85
|
+
* columns the stylesheet draws are the columns the tiles were dealt into.
|
|
86
|
+
*/
|
|
87
|
+
export declare function laneCount(value: number): number;
|
|
88
|
+
/**
|
|
89
|
+
* A masonry dealt at every rung of the breakpoint ladder, as the slots the
|
|
90
|
+
* stylesheet switches between.
|
|
91
|
+
*
|
|
92
|
+
* Which lane a tile lands in depends on the heights of the tiles before it, so
|
|
93
|
+
* a stylesheet cannot work it out — but it can choose between answers worked
|
|
94
|
+
* out ahead of time. The deal is made once per lane count the columns name,
|
|
95
|
+
* and the rung it starts at is written as slots: the list's rows as
|
|
96
|
+
* `--p-lane-rows-{rung}`, and each tile's place and the number of rows it spans
|
|
97
|
+
* as `--p-lane-area-{rung}` and `--p-lane-span-{rung}`. A rung that changes
|
|
98
|
+
* nothing is left out, and the stylesheet carries the rung below up through it,
|
|
99
|
+
* so a server's markup is laid out right at every width before any script has
|
|
100
|
+
* run, and a resize redraws without React hearing about it.
|
|
101
|
+
*
|
|
102
|
+
* `track` writes one row track as CSS, because the gap and the caption rows
|
|
103
|
+
* are lengths only the gallery knows.
|
|
104
|
+
*/
|
|
105
|
+
export declare function masonrySlots(ratios: readonly number[], columns: PlassResponsive<number>, captions: boolean, track: (track: PlassMasonryTrack) => string): {
|
|
106
|
+
list: Record<string, string>;
|
|
107
|
+
tiles: Array<Record<string, string>>;
|
|
108
|
+
};
|
package/dist/internal/gallery.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isSideways as t,quartersOf as
|
|
1
|
+
import{isSideways as t,quartersOf as n}from"./image.js";import{breakpoints as o,resolveAt as r}from"./responsive.js";export function ratioOf(t,n){if(void 0===t)return n;if("number"==typeof t)return t>0?t:n;const[o,r]=t.split("/"),e=void 0===r?Number(o):Number(o)/Number(r);return Number.isFinite(e)&&e>0?e:n}export function isTurned(o){return void 0!==o&&t(n(o))}export function shownRatio(t,n){return isTurned(n)?1/t:t}export function dealColumns(t,n){const o=Array.from({length:n},()=>[]),r=new Array(n).fill(0);return t.forEach((t,e)=>{let s=0;for(let t=1;t<n;t+=1)r[t]<r[s]&&(s=t);o[s].push(e),r[s]+=1/t}),o}export function masonryRows(t,n,o){const r=dealColumns(t,n),e=[],s=[],a=[];r.forEach((n,o)=>{let r=0;n.forEach((u,i)=>{r+=1/t[u],e[u]=o,s[u]=r,a[u]=0===i?-1:n[i-1]})});const u=[],i=[];for(const n of t.map((t,n)=>n).sort((t,n)=>s[t]-s[n]))(0===u.length||s[n]-u[u.length-1]>.001)&&u.push(s[n]),i[n]=u.length-1;const c=new Set(a.filter(t=>-1!==t).map(t=>i[t])),l=[],p=[],f=[];u.forEach((t,n)=>{l.push(t-(0===n?0:u[n-1])),o&&l.push("caption"),p[n]=l.length+1,c.has(n)&&l.push("gap"),f[n]=l.length+1});const m=t.map((t,n)=>({column:e[n]+1,start:-1===a[n]?1:f[i[a[n]]],end:p[i[n]]}));return{tracks:l,tiles:m}}export function laneCount(t){return Math.max(1,Math.round(t))}export function masonrySlots(t,n,e,s){const a={},u=t.map(()=>({})),i=[],c=[];let l,p;for(const f of o){const o=laneCount(r(n,f)??2);if(o===p)continue;p=o;const m=masonryRows(t,o,e),h=m.tracks.map(s).join(" ");h!==l&&(a[`--p-lane-rows-${f}`]=h,l=h),m.tiles.forEach(({column:t,start:n,end:o},r)=>{const e=`${n} / ${t} / ${o}`,s=String(o-n);e!==i[r]&&(u[r][`--p-lane-area-${f}`]=e,i[r]=e),s!==c[r]&&(u[r][`--p-lane-span-${f}`]=s,c[r]=s)})}return{list:a,tiles:u}}
|
package/dist/internal/glow.d.ts
CHANGED
|
@@ -11,8 +11,13 @@ import * as React from 'react';
|
|
|
11
11
|
* `offsetX` and `offsetY` cost nothing, but they are measured from whatever the
|
|
12
12
|
* pointer is over. On a surface whose own element is under the pointer — a
|
|
13
13
|
* button, whose icons ignore the pointer — that is the surface, and they are
|
|
14
|
-
* used as they are
|
|
15
|
-
*
|
|
14
|
+
* used as they are: every browser counts them in the surface's own pixels from
|
|
15
|
+
* inside its border, through any `transform` above it. On one that holds other
|
|
16
|
+
* elements the pointer can land on, the position is read against the surface's
|
|
17
|
+
* box on the screen instead, and turned into those same pixels from inside the
|
|
18
|
+
* border, which is where the two layers are laid out. The screen and the
|
|
19
|
+
* surface differ inside a scaled ancestor, a field in a scaled `PlMockup` for
|
|
20
|
+
* one. `offsetWidth` is read after the box, so it costs no second layout.
|
|
16
21
|
*/
|
|
17
22
|
export declare function followPointer(event: React.PointerEvent<HTMLElement>): void;
|
|
18
23
|
/**
|
package/dist/internal/glow.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as t from"react";export function followPointer(t){const e=t.currentTarget;let o=t.nativeEvent.offsetX,n=t.nativeEvent.offsetY;if(t.target!==e){const
|
|
1
|
+
import*as t from"react";export function followPointer(t){const e=t.currentTarget;let o=t.nativeEvent.offsetX,n=t.nativeEvent.offsetY;if(t.target!==e){const i=e.getBoundingClientRect(),r=i.width?e.offsetWidth/i.width:1,l=i.height?e.offsetHeight/i.height:1;o=(t.clientX-i.left)*r-e.clientLeft,n=(t.clientY-i.top)*l-e.clientTop}e.style.setProperty("--p-mx",`${o}px`),e.style.setProperty("--p-my",`${n}px`)}export function glowPointerMove(t,e){return t?t=>{followPointer(t),e?.(t)}:e}const e=/* @__PURE__ */new Set(["Tab","Escape","Shift","Control","Alt","Meta","CapsLock"]);export function useFieldLight(o){const[n,i]=t.useState(!1),r=t.useRef(!1),l=t.useCallback(t=>{r.current!==t&&(r.current=t,i(t))},[]),s=t.useCallback(t=>{followPointer(t),l(!1)},[l]),c=t.useCallback(t=>{e.has(t.key)||l(!0)},[l]);return o?{"data-quiet":n?"":void 0,onPointerMove:s,onKeyDown:c}:{}}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PlassHeadingLevel } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The heading level a caller asked for, or `undefined` when what arrived is
|
|
4
|
+
* not one.
|
|
5
|
+
*
|
|
6
|
+
* The type keeps a TypeScript caller inside the six; this keeps a JavaScript
|
|
7
|
+
* one there too, where a `7` would have written an `<h7>`, which is no heading
|
|
8
|
+
* at all. Every component that takes a `headingLevel` reads it through here,
|
|
9
|
+
* so they cannot come to disagree about what a level is.
|
|
10
|
+
*/
|
|
11
|
+
export declare function headingLevelOf(value: unknown): PlassHeadingLevel | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function headingLevelOf(e){return"number"==typeof e&&Number.isInteger(e)&&e>=1&&e<=6?e:void 0}
|
|
@@ -76,9 +76,11 @@ export declare function canonicalLanguage(language: string | undefined): string
|
|
|
76
76
|
* Highlighting the block as a whole and splitting afterwards, never line by
|
|
77
77
|
* line: a block comment, a template literal and a heredoc all span lines, and a
|
|
78
78
|
* highlighter handed one line at a time sees the second line of a comment as
|
|
79
|
-
* code.
|
|
79
|
+
* code. A block is coloured in its own turn, after the blocks that asked before
|
|
80
|
+
* it, with the browser given the main thread in between, and `signal` takes a
|
|
81
|
+
* block that has gone away by then out of the queue.
|
|
80
82
|
*/
|
|
81
|
-
export declare function highlight(code: string, language: string): Promise<PlCodeLine[] | null>;
|
|
83
|
+
export declare function highlight(code: string, language: string, signal?: AbortSignal): Promise<PlCodeLine[] | null>;
|
|
82
84
|
/**
|
|
83
85
|
* highlight.js's own markup, as lines of coloured runs.
|
|
84
86
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const i={bash:()=>import("highlight.js/lib/languages/bash"),c:()=>import("highlight.js/lib/languages/c"),cpp:()=>import("highlight.js/lib/languages/cpp"),csharp:()=>import("highlight.js/lib/languages/csharp"),css:()=>import("highlight.js/lib/languages/css"),dart:()=>import("highlight.js/lib/languages/dart"),diff:()=>import("highlight.js/lib/languages/diff"),dockerfile:()=>import("highlight.js/lib/languages/dockerfile"),go:()=>import("highlight.js/lib/languages/go"),graphql:()=>import("highlight.js/lib/languages/graphql"),ini:()=>import("highlight.js/lib/languages/ini"),java:()=>import("highlight.js/lib/languages/java"),javascript:()=>import("highlight.js/lib/languages/javascript"),json:()=>import("highlight.js/lib/languages/json"),kotlin:()=>import("highlight.js/lib/languages/kotlin"),less:()=>import("highlight.js/lib/languages/less"),lua:()=>import("highlight.js/lib/languages/lua"),makefile:()=>import("highlight.js/lib/languages/makefile"),markdown:()=>import("highlight.js/lib/languages/markdown"),objectivec:()=>import("highlight.js/lib/languages/objectivec"),perl:()=>import("highlight.js/lib/languages/perl"),php:()=>import("highlight.js/lib/languages/php"),plaintext:()=>import("highlight.js/lib/languages/plaintext"),powershell:()=>import("highlight.js/lib/languages/powershell"),python:()=>import("highlight.js/lib/languages/python"),r:()=>import("highlight.js/lib/languages/r"),ruby:()=>import("highlight.js/lib/languages/ruby"),rust:()=>import("highlight.js/lib/languages/rust"),scss:()=>import("highlight.js/lib/languages/scss"),shell:()=>import("highlight.js/lib/languages/shell"),sql:()=>import("highlight.js/lib/languages/sql"),swift:()=>import("highlight.js/lib/languages/swift"),typescript:()=>import("highlight.js/lib/languages/typescript"),xml:()=>import("highlight.js/lib/languages/xml"),yaml:()=>import("highlight.js/lib/languages/yaml")},t={"c++":"cpp",cc:"cpp",cjs:"javascript",console:"bash",cs:"csharp",cts:"typescript",docker:"dockerfile",gql:"graphql",golang:"go",h:"cpp",hpp:"cpp",htm:"xml",html:"xml",js:"javascript",jsx:"javascript",kt:"kotlin",kts:"kotlin",md:"markdown",mdx:"markdown",mjs:"javascript",mm:"objectivec",mts:"typescript",mysql:"sql",node:"javascript",none:"plaintext",objc:"objectivec",plain:"plaintext",posh:"powershell",ps1:"powershell",psql:"sql",py:"python",rb:"ruby",rs:"rust",sh:"bash",svelte:"xml",svg:"xml",text:"plaintext",toml:"ini",ts:"typescript",tsx:"typescript",txt:"plaintext",vue:"xml",yml:"yaml",zsh:"bash"},l=new Map;export function registerLanguage(i,t){const
|
|
1
|
+
const i={bash:()=>import("highlight.js/lib/languages/bash"),c:()=>import("highlight.js/lib/languages/c"),cpp:()=>import("highlight.js/lib/languages/cpp"),csharp:()=>import("highlight.js/lib/languages/csharp"),css:()=>import("highlight.js/lib/languages/css"),dart:()=>import("highlight.js/lib/languages/dart"),diff:()=>import("highlight.js/lib/languages/diff"),dockerfile:()=>import("highlight.js/lib/languages/dockerfile"),go:()=>import("highlight.js/lib/languages/go"),graphql:()=>import("highlight.js/lib/languages/graphql"),ini:()=>import("highlight.js/lib/languages/ini"),java:()=>import("highlight.js/lib/languages/java"),javascript:()=>import("highlight.js/lib/languages/javascript"),json:()=>import("highlight.js/lib/languages/json"),kotlin:()=>import("highlight.js/lib/languages/kotlin"),less:()=>import("highlight.js/lib/languages/less"),lua:()=>import("highlight.js/lib/languages/lua"),makefile:()=>import("highlight.js/lib/languages/makefile"),markdown:()=>import("highlight.js/lib/languages/markdown"),objectivec:()=>import("highlight.js/lib/languages/objectivec"),perl:()=>import("highlight.js/lib/languages/perl"),php:()=>import("highlight.js/lib/languages/php"),plaintext:()=>import("highlight.js/lib/languages/plaintext"),powershell:()=>import("highlight.js/lib/languages/powershell"),python:()=>import("highlight.js/lib/languages/python"),r:()=>import("highlight.js/lib/languages/r"),ruby:()=>import("highlight.js/lib/languages/ruby"),rust:()=>import("highlight.js/lib/languages/rust"),scss:()=>import("highlight.js/lib/languages/scss"),shell:()=>import("highlight.js/lib/languages/shell"),sql:()=>import("highlight.js/lib/languages/sql"),swift:()=>import("highlight.js/lib/languages/swift"),typescript:()=>import("highlight.js/lib/languages/typescript"),xml:()=>import("highlight.js/lib/languages/xml"),yaml:()=>import("highlight.js/lib/languages/yaml")},t={"c++":"cpp",cc:"cpp",cjs:"javascript",console:"bash",cs:"csharp",cts:"typescript",docker:"dockerfile",gql:"graphql",golang:"go",h:"cpp",hpp:"cpp",htm:"xml",html:"xml",js:"javascript",jsx:"javascript",kt:"kotlin",kts:"kotlin",md:"markdown",mdx:"markdown",mjs:"javascript",mm:"objectivec",mts:"typescript",mysql:"sql",node:"javascript",none:"plaintext",objc:"objectivec",plain:"plaintext",posh:"powershell",ps1:"powershell",psql:"sql",py:"python",rb:"ruby",rs:"rust",sh:"bash",svelte:"xml",svg:"xml",text:"plaintext",toml:"ini",ts:"typescript",tsx:"typescript",txt:"plaintext",vue:"xml",yml:"yaml",zsh:"bash"},l=new Map;export function registerLanguage(i,t){const s=i.toLowerCase();l.set(s,t),e.delete(s)}let s=null;const e=new Map;export function canonicalLanguage(i){if(!i)return null;const s=i.trim().toLowerCase();return s?l.has(s)?s:t[s]??s:null}function yieldToBrowser(){const{scheduler:i}=globalThis;return"function"==typeof i?.yield?i.yield():new Promise(i=>{const t=new MessageChannel;t.port1.onmessage=()=>{t.port1.close(),i()},t.port2.postMessage(null)})}let g=Promise.resolve();export async function highlight(t,a,h){let n=e.get(a);n||(n=async function prepare(t){const e=l.get(t),g=e?void 0:i[t];if(!e&&!g)return null;if(!s){const i=import("highlight.js/lib/core").then(i=>i.default);i.catch(()=>{s===i&&(s=null)}),s=i}const[a,h]=await Promise.all([s,e??g().then(i=>i.default)]);return!e&&a.getLanguage(t)||a.registerLanguage(t,h),t}(a).catch(i=>{throw e.delete(a),i}),e.set(a,n));const o=await n;if(!o||!s)return null;const r=await s;return await function nextTurn(){return g=g.then(yieldToBrowser),g}(),h?.aborted?null:tokenize(r.highlight(t,{language:o,ignoreIllegals:!0}).value)}const a={"&":"&","<":"<",">":">",""":'"',"'":"'"};export function tokenize(i){const t=[[]],l=[],s=/<span class="([^"]*)">|<\/span>/g;let e=0;const push=i=>{if(!i)return;const s=l[l.length-1];i.replace(/&(?:amp|lt|gt|quot|#x27);/g,i=>a[i]).split("\n").forEach((i,l)=>{l>0&&t.push([]),i&&t[t.length-1].push(s?{text:i,token:s}:{text:i})})};for(const t of i.matchAll(s))push(i.slice(e,t.index)),e=t.index+t[0].length,void 0===t[1]?l.pop():l.push(t[1]);return push(i.slice(e)),t}export function plainLines(i){return i.split("\n").map(i=>i?[{text:i}]:[])}
|
|
@@ -72,6 +72,11 @@ export interface PlassLabels {
|
|
|
72
72
|
chartMore: (count: number) => string;
|
|
73
73
|
/** And the way back, once they are all showing. */
|
|
74
74
|
chartFewer: string;
|
|
75
|
+
/**
|
|
76
|
+
* The head of the column a chart's table names each mark in, for marks that
|
|
77
|
+
* carry a name of their own: a timeline's spans.
|
|
78
|
+
*/
|
|
79
|
+
name: string;
|
|
75
80
|
minimize: string;
|
|
76
81
|
maximize: string;
|
|
77
82
|
restore: string;
|
package/dist/internal/labels.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import*as e from"react";import{useDefaults as a}from"./defaults.js";import{loadingLabel as o}from"./loading.js";export const defaultLabels={close:"Close",cancel:"Cancel",confirm:"Confirm",acknowledge:"OK",clear:"Clear",done:"Done",skip:"Skip",search:"Search",selectAll:"Select all",selectRow:"Select row",remove:"Remove",dismiss:"Dismiss",open:"Open",previous:"Previous",next:"Next",reveal:"Reveal",hide:"Hide",increase:"Increase",decrease:"Decrease",preview:"Preview",empty:"Nothing here",optional:"Optional",loading:o,breadcrumb:"Breadcrumb",breadcrumbExpand:"Show the hidden steps",carousel:"Carousel",carouselPrevious:"Previous slide",carouselNext:"Next slide",carouselPlay:"Start slide show",carouselStop:"Stop slide show",slide:"slide",commandPalette:"Command palette",commandPalettePlaceholder:"Search commands",gallery:"Gallery",chart:"Chart",chartOther:"Other",chartMore:e=>`${e} more`,chartFewer:"Show fewer",minimize:"Minimize",maximize:"Maximize",restore:"Restore",resizeWindow:"Resize window",moveWindow:"Move window",overlay:"Overlay",notifications:"Notifications",pagination:"Pagination",paginationPrevious:"Previous page",paginationNext:"Next page",paginationFirst:"First page",paginationLast:"Last page",rating:"Rating",sidebar:"Sidebar",sidebarOpen:"Open sidebar",sidebarClose:"Close sidebar",sidebarResize:"Resize sidebar",skipToContent:"Skip to content",backToTop:"Back to top",onThisPage:"On this page",typing:"Typing…",messageSending:"Sending",messageSent:"Sent",messageDelivered:"Delivered",messageRead:"Read",messageFailed:"Not delivered",spoilerWarning:"This may contain spoilers",filePickerTitle:"Drop files here, or click to browse",newTab:"(opens in a new tab)",transferAvailable:"Available",transferSelected:"Selected",transferToSelected:"Move to selected",transferToAvailable:"Move to available",copy:"Copy",copied:"Copied",copyFailed:"Could not copy",raw:"Raw",code:"Code",previousMonth:"Previous month",nextMonth:"Next month",previousYear:"Previous year",nextYear:"Next year",previousYears:"Previous years",nextYears:"Next years",chooseMonth:"Choose a month",chooseYear:"Choose a year",today:"Today",thisMonth:"This month",thisYear:"This year",now:"Now",hour:"Hour",minute:"Minute",second:"Second",meridiem:"AM/PM",start:"Start",end:"End",paginationPage:e=>`Page ${e}`,paginationStatus:(e,a)=>`Page ${e} of ${a}`,ratingValue:(e,a)=>`${e.toLocaleString("en")} out of ${a}`,ratingNone:"No rating",carouselSlide:(e,a)=>`Slide ${e} of ${a}`,galleryItem:(e,a)=>`${e} of ${a}`,removeItem:e=>`Remove ${e}`,addCustom:e=>`Add “${e}”`,otpSlot:(e,a)=>`Character ${e} of ${a}`,transferSelectAll:e=>`Select all in ${e}`,transferMoved:(e,a)=>`${e} ${1===e?"item":"items"} moved to ${a}`,filesRejectedType:e=>`${e} ${1===e?"file is":"files are"} not an accepted type`,filesRejectedSize:e=>`${e} ${1===e?"file is":"files are"} too large`,filesRejectedCount:e=>`${e} ${1===e?"file":"files"} did not fit`};export function useLabels(){const{labels:o}=a();return e.useMemo(()=>o?{...defaultLabels,...o}:defaultLabels,[o])}
|
|
1
|
+
"use client";import*as e from"react";import{useDefaults as a}from"./defaults.js";import{loadingLabel as o}from"./loading.js";export const defaultLabels={close:"Close",cancel:"Cancel",confirm:"Confirm",acknowledge:"OK",clear:"Clear",done:"Done",skip:"Skip",search:"Search",selectAll:"Select all",selectRow:"Select row",remove:"Remove",dismiss:"Dismiss",open:"Open",previous:"Previous",next:"Next",reveal:"Reveal",hide:"Hide",increase:"Increase",decrease:"Decrease",preview:"Preview",empty:"Nothing here",optional:"Optional",loading:o,breadcrumb:"Breadcrumb",breadcrumbExpand:"Show the hidden steps",carousel:"Carousel",carouselPrevious:"Previous slide",carouselNext:"Next slide",carouselPlay:"Start slide show",carouselStop:"Stop slide show",slide:"slide",commandPalette:"Command palette",commandPalettePlaceholder:"Search commands",gallery:"Gallery",chart:"Chart",chartOther:"Other",chartMore:e=>`${e} more`,chartFewer:"Show fewer",name:"Name",minimize:"Minimize",maximize:"Maximize",restore:"Restore",resizeWindow:"Resize window",moveWindow:"Move window",overlay:"Overlay",notifications:"Notifications",pagination:"Pagination",paginationPrevious:"Previous page",paginationNext:"Next page",paginationFirst:"First page",paginationLast:"Last page",rating:"Rating",sidebar:"Sidebar",sidebarOpen:"Open sidebar",sidebarClose:"Close sidebar",sidebarResize:"Resize sidebar",skipToContent:"Skip to content",backToTop:"Back to top",onThisPage:"On this page",typing:"Typing…",messageSending:"Sending",messageSent:"Sent",messageDelivered:"Delivered",messageRead:"Read",messageFailed:"Not delivered",spoilerWarning:"This may contain spoilers",filePickerTitle:"Drop files here, or click to browse",newTab:"(opens in a new tab)",transferAvailable:"Available",transferSelected:"Selected",transferToSelected:"Move to selected",transferToAvailable:"Move to available",copy:"Copy",copied:"Copied",copyFailed:"Could not copy",raw:"Raw",code:"Code",previousMonth:"Previous month",nextMonth:"Next month",previousYear:"Previous year",nextYear:"Next year",previousYears:"Previous years",nextYears:"Next years",chooseMonth:"Choose a month",chooseYear:"Choose a year",today:"Today",thisMonth:"This month",thisYear:"This year",now:"Now",hour:"Hour",minute:"Minute",second:"Second",meridiem:"AM/PM",start:"Start",end:"End",paginationPage:e=>`Page ${e}`,paginationStatus:(e,a)=>`Page ${e} of ${a}`,ratingValue:(e,a)=>`${e.toLocaleString("en")} out of ${a}`,ratingNone:"No rating",carouselSlide:(e,a)=>`Slide ${e} of ${a}`,galleryItem:(e,a)=>`${e} of ${a}`,removeItem:e=>`Remove ${e}`,addCustom:e=>`Add “${e}”`,otpSlot:(e,a)=>`Character ${e} of ${a}`,transferSelectAll:e=>`Select all in ${e}`,transferMoved:(e,a)=>`${e} ${1===e?"item":"items"} moved to ${a}`,filesRejectedType:e=>`${e} ${1===e?"file is":"files are"} not an accepted type`,filesRejectedSize:e=>`${e} ${1===e?"file is":"files are"} too large`,filesRejectedCount:e=>`${e} ${1===e?"file":"files"} did not fit`};export function useLabels(){const{labels:o}=a();return e.useMemo(()=>o?{...defaultLabels,...o}:defaultLabels,[o])}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An element's length along one axis as it is laid out, which is not always
|
|
3
|
+
* the length it is drawn at.
|
|
4
|
+
*
|
|
5
|
+
* The two differ under a `transform` on an ancestor, a component inside a
|
|
6
|
+
* scaled `PlMockup` for one. `getBoundingClientRect` measures the box on the
|
|
7
|
+
* screen, which is the drawn size there, while a `width`, a `flex-basis`
|
|
8
|
+
* percentage and a `scrollLeft` are all counted in the element's own pixels.
|
|
9
|
+
* So the laid-out size is read off the computed style, which a transform does
|
|
10
|
+
* not reach, and the box on the screen is kept for what is measured on the
|
|
11
|
+
* screen: a pointer's movement, and the distance between two boxes.
|
|
12
|
+
*/
|
|
13
|
+
export interface LayoutBox {
|
|
14
|
+
/**
|
|
15
|
+
* The used `width` or `height`, which is the border box or the content box
|
|
16
|
+
* as `box-sizing` says: the length a declaration of either sets.
|
|
17
|
+
*/
|
|
18
|
+
size: number;
|
|
19
|
+
/**
|
|
20
|
+
* The content box, inside the padding and the border: what a child's
|
|
21
|
+
* percentage is a percentage of.
|
|
22
|
+
*/
|
|
23
|
+
content: number;
|
|
24
|
+
/**
|
|
25
|
+
* How many of the element's own pixels one pixel on the screen is. `1`
|
|
26
|
+
* unless an ancestor scales it.
|
|
27
|
+
*/
|
|
28
|
+
perPixel: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Measures `element` across when `horizontal` and down otherwise. An element
|
|
32
|
+
* that is not laid out, inside a closed `PlAccordion` for example, measures
|
|
33
|
+
* nothing.
|
|
34
|
+
*/
|
|
35
|
+
export declare function layoutBox(element: HTMLElement, horizontal: boolean): LayoutBox;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function layoutBox(t,e){const n=t.getBoundingClientRect(),d=e?n.width:n.height;if(!(d>0))return{size:0,content:0,perPixel:1};const i=getComputedStyle(t),r=(e?[i.paddingInlineStart,i.paddingInlineEnd,i.borderInlineStartWidth,i.borderInlineEndWidth]:[i.paddingBlockStart,i.paddingBlockEnd,i.borderBlockStartWidth,i.borderBlockEndWidth]).reduce((t,e)=>t+(parseFloat(e)||0),0),o=parseFloat(e?i.width:i.height)||0,l="border-box"===i.boxSizing?o:o+r;return{size:o,content:l-r,perPixel:l>0?l/d:1}}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A part of a component that is a download of its own, and that steps back
|
|
4
|
+
* rather than throwing when the download fails.
|
|
5
|
+
*
|
|
6
|
+
* Four components keep a piece most pages never show behind an `import()`:
|
|
7
|
+
* `PlConfirmProvider` its dialog, `PlSidebar` the drawer it becomes on a narrow
|
|
8
|
+
* window, `PlImage` its preview and `PlGallery` its viewer. `React.lazy` on its
|
|
9
|
+
* own throws to the nearest error boundary when that chunk cannot be fetched —
|
|
10
|
+
* a connection that dropped, or a deploy that replaced the chunk under a page
|
|
11
|
+
* that was already open — and the boundary takes down everything it holds over
|
|
12
|
+
* a part the reader may only have pointed at.
|
|
13
|
+
*
|
|
14
|
+
* So the import is tried a second time, and if that fails as well the part
|
|
15
|
+
* renders nothing and says so once through `onUnavailable`, which is where the
|
|
16
|
+
* component that asked for it steps back: closes what it was opening, answers
|
|
17
|
+
* what it was asking. A failed attempt is forgotten, so the next mount tries
|
|
18
|
+
* again. Chromium keeps a module whose fetch failed for the life of the page,
|
|
19
|
+
* so there a second try, now or later, fails at once without a request; Firefox
|
|
20
|
+
* and WebKit fetch it again.
|
|
21
|
+
*/
|
|
22
|
+
/** A part's own props, and the one it adds. */
|
|
23
|
+
export type LazyPartProps<P> = P & {
|
|
24
|
+
/** Called once, after the second try has failed. The part then renders nothing. */
|
|
25
|
+
onUnavailable?: () => void;
|
|
26
|
+
};
|
|
27
|
+
export interface LazyPart<P> {
|
|
28
|
+
(props: LazyPartProps<P>): React.ReactElement;
|
|
29
|
+
/** Starts the download without rendering anything. A failure is kept quiet. */
|
|
30
|
+
preload: () => void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* `React.lazy` with one retry and a quiet failure. Render the result inside a
|
|
34
|
+
* `Suspense` as a lazy component would be, and unmount it when it reports
|
|
35
|
+
* `onUnavailable`, so that the next mount is the next attempt.
|
|
36
|
+
*/
|
|
37
|
+
export declare function lazyPart<P extends object>(load: () => Promise<React.ComponentType<P>>): LazyPart<P>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as n}from"react/jsx-runtime";import*as t from"react";function Unavailable({onUnavailable:n}){const a=t.useRef(!1);return t.useLayoutEffect(()=>{a.current||(a.current=!0,n?.())}),null}export function lazyPart(a){let e=null;const download=()=>(e??=a().catch(()=>a()).catch(()=>(e=null,null)),e),attempt=()=>{const a=t.lazy(async()=>{const t=await download();if(!t){const retire=()=>{r===a&&(r=attempt())};function Failed({onUnavailable:t}){return n(Unavailable,{onUnavailable:()=>{retire(),t?.()}})}return{default:Failed}}const e=t;return{default:function Ready({onUnavailable:t,...a}){return n(e,{...a})}}});return a};let r=attempt();function Part(a){const[e]=t.useState(()=>r);return n(e,{...a})}return Part.preload=()=>{download()},Part}
|
package/dist/internal/media.d.ts
CHANGED
|
@@ -24,3 +24,9 @@ export declare function useMediaQuery(query: string | null): boolean;
|
|
|
24
24
|
* — before any of these animations has had a frame to run in.
|
|
25
25
|
*/
|
|
26
26
|
export declare function usePrefersReducedMotion(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* The same answer, read at the moment it is asked rather than on the render
|
|
29
|
+
* after it changes: for an event handler that has to act before the next frame
|
|
30
|
+
* is drawn.
|
|
31
|
+
*/
|
|
32
|
+
export declare function prefersReducedMotion(): boolean;
|
package/dist/internal/media.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import*as e from"react";const
|
|
1
|
+
"use client";import*as e from"react";const r=new Map;function listFor(e){if("undefined"==typeof window||!window.matchMedia)return null;let n=r.get(e);return n||(n=window.matchMedia(e),r.set(e,n)),n}function onServer(){return!1}export const reducedMotionQuery="(prefers-reduced-motion: reduce)";export function useMediaQuery(r){const n=e.useCallback(e=>{const n=null===r?null:listFor(r);return n?(n.addEventListener("change",e),()=>n.removeEventListener("change",e)):()=>{}},[r]),t=e.useCallback(()=>null!==r&&(listFor(r)?.matches??!1),[r]);return e.useSyncExternalStore(n,t,onServer)}export function usePrefersReducedMotion(){return useMediaQuery(reducedMotionQuery)}export function prefersReducedMotion(){return listFor(reducedMotionQuery)?.matches??!1}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { PlassDirection } from './direction.js';
|
|
3
|
-
import type { PlassBreakpoint, PlassSide } from '../types.js';
|
|
3
|
+
import type { PlassBreakpoint, PlassPosition, PlassSide } from '../types.js';
|
|
4
4
|
/**
|
|
5
5
|
* The vocabulary a page's structure is written in, and the context the four
|
|
6
6
|
* components that build one share.
|
|
@@ -75,6 +75,12 @@ export interface PlPageLayoutContextValue {
|
|
|
75
75
|
* reliably as one that is not.
|
|
76
76
|
*/
|
|
77
77
|
register: (slot: PlPageLayoutSlot, node: HTMLElement | null) => void;
|
|
78
|
+
/**
|
|
79
|
+
* Measures the registered bars again, for the one change to a bar that
|
|
80
|
+
* neither its ref nor the layout's `ResizeObserver` reports: its `position`,
|
|
81
|
+
* which decides what its height is reserved for. See `useSlotPosition`.
|
|
82
|
+
*/
|
|
83
|
+
remeasure: () => void;
|
|
78
84
|
/** Where the sidebars stop being columns. */
|
|
79
85
|
collapseBelow: PlPageLayoutCollapse;
|
|
80
86
|
/** Whether each sidebar's drawer is open. Only meaningful while it is collapsed. */
|
|
@@ -84,6 +90,16 @@ export interface PlPageLayoutContextValue {
|
|
|
84
90
|
scroll: PlPageLayoutScroll;
|
|
85
91
|
}
|
|
86
92
|
export declare const PlPageLayoutContext: React.Context<PlPageLayoutContextValue>;
|
|
93
|
+
/**
|
|
94
|
+
* Tells the layout around a bar that the bar's `position` changed.
|
|
95
|
+
*
|
|
96
|
+
* A bar that turns from `static` to `fixed` keeps its element, so its ref is
|
|
97
|
+
* not handed over again, and usually its size, so the layout's observer has
|
|
98
|
+
* nothing to report either — and the layout went on reserving nothing for a
|
|
99
|
+
* bar that had left the flow, until something else happened to resize it. Not
|
|
100
|
+
* on the first commit, which the layout measures on its own.
|
|
101
|
+
*/
|
|
102
|
+
export declare function useSlotPosition(position: PlassPosition): void;
|
|
87
103
|
/**
|
|
88
104
|
* Which end of the band the sidebar being rendered right now takes.
|
|
89
105
|
*
|
|
@@ -132,16 +148,11 @@ export declare function useCollapsed(breakpoint: PlPageLayoutCollapse): boolean;
|
|
|
132
148
|
* a tooltip above a button is above it in every writing direction — so the two
|
|
133
149
|
* have to be translated.
|
|
134
150
|
*
|
|
135
|
-
* `direction` is what the nearest `PlassProvider` was
|
|
136
|
-
* reason it wins there
|
|
137
|
-
* that runs the other way from the page, and a drawer
|
|
138
|
-
* subtree, so the document is the one place that
|
|
139
|
-
*
|
|
140
|
-
* provider.
|
|
141
|
-
*
|
|
142
|
-
* The document is read during render rather than in an effect, which is safe
|
|
143
|
-
* here for a narrower reason than it looks: the only caller is a sidebar that
|
|
144
|
-
* has already collapsed, and collapsing is a client-side answer. There is no
|
|
145
|
-
* server render of this to disagree with.
|
|
151
|
+
* `direction` is the caller's to resolve: what the nearest `PlassProvider` was
|
|
152
|
+
* told, which wins for the reason it wins there — a provider given a direction
|
|
153
|
+
* is describing a subtree that runs the other way from the page, and a drawer
|
|
154
|
+
* is portalled out of that subtree, so the document is the one place that
|
|
155
|
+
* cannot say which way it runs — and without one, the document's own
|
|
156
|
+
* direction, as it is for the provider.
|
|
146
157
|
*/
|
|
147
|
-
export declare function drawerSide(side: PlassSidebarSide, direction
|
|
158
|
+
export declare function drawerSide(side: PlassSidebarSide, direction: PlassDirection): PlassSide;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import*as e from"react";import{belowQuery as t}from"./breakpoints.js";import{useMediaQuery as n}from"./media.js";export const PlPageLayoutContext=/* @__PURE__ */e.createContext({present:!1,register:()=>{},collapseBelow:"none",open:{start:!1,end:!1},setOpen:()=>{},scroll:"page"});export const PlassSidebarSideContext=/* @__PURE__ */e.createContext(null);export const collapsedOnlyClasses={none:"hidden",xs:"hidden",sm:"sm:hidden",md:"md:hidden",lg:"lg:hidden",xl:"xl:hidden"};export const expandedOnlyClasses={none:"",xs:"",sm:"max-sm:hidden",md:"max-md:hidden",lg:"max-lg:hidden",xl:"max-xl:hidden"};export function useCollapsed(e){return n("none"===e?null:function collapseQuery(e){return"xs"===e?null:t(e)}(e))}export function drawerSide(e,t){const n=
|
|
1
|
+
"use client";import*as e from"react";import{belowQuery as t}from"./breakpoints.js";import{useMediaQuery as n}from"./media.js";export const PlPageLayoutContext=/* @__PURE__ */e.createContext({present:!1,register:()=>{},remeasure:()=>{},collapseBelow:"none",open:{start:!1,end:!1},setOpen:()=>{},scroll:"page"});export function useSlotPosition(t){const{remeasure:n}=e.useContext(PlPageLayoutContext),o=e.useRef(t);e.useLayoutEffect(()=>{o.current!==t&&(o.current=t,n())},[t,n])}export const PlassSidebarSideContext=/* @__PURE__ */e.createContext(null);export const collapsedOnlyClasses={none:"hidden",xs:"hidden",sm:"sm:hidden",md:"md:hidden",lg:"lg:hidden",xl:"xl:hidden"};export const expandedOnlyClasses={none:"",xs:"",sm:"max-sm:hidden",md:"max-md:hidden",lg:"max-lg:hidden",xl:"max-xl:hidden"};export function useCollapsed(e){return n("none"===e?null:function collapseQuery(e){return"xs"===e?null:t(e)}(e))}export function drawerSide(e,t){const n="rtl"===t;return"start"===e?n?"right":"left":n?"left":"right"}
|
|
@@ -153,7 +153,7 @@ interface InternalShellProps extends PlassPickerShellProps {
|
|
|
153
153
|
* and the way `invalid` re-points the whole colour family at `danger` so the
|
|
154
154
|
* edge, the ring and the message turn over together.
|
|
155
155
|
*/
|
|
156
|
-
export declare function PickerShell({ variant, size, color, density, elevation, label, labelPlacement: labelPlacementProp, description, error, invalid, startIcon, fullWidth, disabled: disabledProp, readOnly, required, id, className, classNames, style, display, samples, empty, clearable, onClear, open, onOpenChange, labels, name, formValue, children, triggerRef, ...props }: InternalShellProps): React.JSX.Element;
|
|
156
|
+
export declare function PickerShell({ variant, size, color, density, elevation, label, labelPlacement: labelPlacementProp, description, error, invalid, startIcon, fullWidth, disabled: disabledProp, readOnly, required, id, className, classNames, style, display, samples, empty, clearable, onClear, open, onOpenChange, labels, name, formValue, children, triggerRef, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, ...props }: InternalShellProps): React.JSX.Element;
|
|
157
157
|
/**
|
|
158
158
|
* The row of shortcuts under a picker's panel.
|
|
159
159
|
*
|