material-plus-ui 1.9.0 → 1.10.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/README.md +2 -2
- package/dist/a2ui/extended/api.d.ts +4 -4
- package/dist/components/accordion/MPAccordion.d.ts +13 -0
- package/dist/components/accordion/MPAccordion.js +1 -1
- package/dist/components/accordion/index.d.ts +1 -1
- package/dist/components/animate-counter/MPAnimateCounter.js +1 -1
- package/dist/components/animate-headline/MPAnimateHeadline.d.ts +8 -0
- package/dist/components/animate-headline/MPAnimateHeadline.js +1 -1
- package/dist/components/animate-lighting/MPAnimateLighting.js +1 -1
- package/dist/components/animate-marquee/MPAnimateMarquee.js +1 -1
- package/dist/components/animate-scramble/MPAnimateScramble.d.ts +8 -0
- package/dist/components/animate-scramble/MPAnimateScramble.js +1 -1
- package/dist/components/animate-split/MPAnimateSplit.d.ts +8 -0
- package/dist/components/animate-split/MPAnimateSplit.js +1 -1
- package/dist/components/animate-typing/MPAnimateTyping.d.ts +10 -2
- package/dist/components/animate-typing/MPAnimateTyping.js +1 -1
- package/dist/components/app-logo/MPAppLogo.d.ts +6 -1
- package/dist/components/area-chart/MPAreaChart.js +1 -1
- package/dist/components/avatar/MPAvatar.d.ts +16 -0
- package/dist/components/avatar/MPAvatar.js +1 -1
- package/dist/components/bar-chart/MPBarChart.js +1 -1
- package/dist/components/breadcrumb/MPBreadcrumb.d.ts +8 -0
- package/dist/components/breadcrumb/MPBreadcrumb.js +1 -1
- package/dist/components/carousel/MPCarousel.js +1 -1
- package/dist/components/checkbox/MPCheckbox.js +1 -1
- package/dist/components/code-block/MPCodeBlock.js +1 -1
- package/dist/components/combobox/MPCombobox.js +1 -1
- package/dist/components/command-palette/MPCommandPalette.js +1 -1
- package/dist/components/config/MPConfigProvider.d.ts +17 -1
- package/dist/components/config/MPConfigProvider.js +1 -1
- package/dist/components/confirm/MPConfirmProvider.js +1 -1
- package/dist/components/data-table/MPDataTable.d.ts +0 -34
- package/dist/components/data-table/MPDataTable.js +1 -1
- package/dist/components/date-range-picker/MPDateRangePicker.js +1 -1
- package/dist/components/drawer/MPDrawer.d.ts +13 -1
- package/dist/components/drawer/MPDrawer.js +1 -1
- package/dist/components/file-picker/MPFilePicker.js +1 -1
- package/dist/components/form/MPForm.d.ts +3 -0
- package/dist/components/form/MPForm.js +1 -1
- package/dist/components/gauge-chart/MPGaugeChart.js +1 -1
- package/dist/components/header/MPHeader.js +1 -1
- package/dist/components/heatmap-chart/MPHeatmapChart.js +1 -1
- package/dist/components/image/MPImage.d.ts +5 -0
- package/dist/components/image/MPImage.js +1 -1
- package/dist/components/line-chart/MPLineChart.js +1 -1
- package/dist/components/locale/MPLocaleProvider.d.ts +15 -30
- package/dist/components/locale/MPLocaleProvider.js +1 -1
- package/dist/components/menu/MPMenu.d.ts +9 -1
- package/dist/components/menu/MPMenu.js +1 -1
- package/dist/components/meter/MPMeter.d.ts +5 -0
- package/dist/components/meter/MPMeter.js +1 -1
- package/dist/components/mockup/MPMockup.js +1 -1
- package/dist/components/navigation-menu/MPNavigationMenu.d.ts +27 -1
- package/dist/components/navigation-menu/MPNavigationMenu.js +1 -1
- package/dist/components/number-field/MPNumberField.d.ts +2 -1
- package/dist/components/number-field/MPNumberField.js +1 -1
- package/dist/components/otp-field/MPOtpField.js +1 -1
- package/dist/components/page-layout/MPPageLayout.js +1 -1
- package/dist/components/pagination/MPPagination.d.ts +8 -0
- package/dist/components/pagination/MPPagination.js +1 -1
- package/dist/components/panes/MPPanes.js +1 -1
- package/dist/components/pie-chart/MPPieChart.js +1 -1
- package/dist/components/pill/MPPill.js +1 -1
- package/dist/components/progress-box/MPProgressBox.js +1 -1
- package/dist/components/progress-circular/MPProgressCircular.js +1 -1
- package/dist/components/progress-linear/MPProgressLinear.js +1 -1
- package/dist/components/radio-group/MPRadioGroup.js +1 -1
- package/dist/components/scatter-chart/MPScatterChart.js +1 -1
- package/dist/components/sidebar/MPSidebar.d.ts +11 -0
- package/dist/components/sidebar/MPSidebar.js +1 -1
- package/dist/components/slider/MPSlider.d.ts +5 -0
- package/dist/components/slider/MPSlider.js +1 -1
- package/dist/components/snackbar/MPSnackbar.js +1 -1
- package/dist/components/switch/MPSwitch.js +1 -1
- package/dist/components/tabs/MPTabs.js +1 -1
- package/dist/components/text-field/MPTextField.js +1 -1
- package/dist/components/timeline-chart/MPTimelineChart.js +1 -1
- package/dist/components/tour/MPTour.js +1 -1
- package/dist/components/transfer/MPTransfer.js +1 -1
- package/dist/components/tree-select/MPTreeSelect.js +1 -1
- package/dist/components/tree-view/MPTreeView.d.ts +8 -0
- package/dist/components/tree-view/MPTreeView.js +1 -1
- package/dist/hooks/index.d.ts +4 -2
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/mpColorSchemeScript.d.ts +46 -0
- package/dist/hooks/mpColorSchemeScript.js +1 -0
- package/dist/hooks/useMPColorScheme.d.ts +2 -47
- package/dist/hooks/useMPColorScheme.js +1 -1
- package/dist/hooks/useMPMediaQuery.js +1 -1
- package/dist/hooks/useMPOnScreen.js +1 -1
- package/dist/internal/Calendar.js +1 -1
- package/dist/internal/ChartChrome.d.ts +11 -2
- package/dist/internal/ChartChrome.js +1 -1
- package/dist/internal/ChartFrame.js +1 -1
- package/dist/internal/FieldOutline.d.ts +9 -1
- package/dist/internal/FieldOutline.js +1 -1
- package/dist/internal/RenderedLink.d.ts +20 -0
- package/dist/internal/RenderedLink.js +2 -0
- package/dist/internal/SupportingText.js +1 -1
- package/dist/internal/animate.d.ts +4 -0
- package/dist/internal/animate.js +1 -1
- package/dist/internal/box-size.d.ts +22 -0
- package/dist/internal/box-size.js +2 -0
- package/dist/internal/chart.d.ts +21 -11
- package/dist/internal/chart.js +1 -1
- package/dist/internal/color-scheme-keys.d.ts +13 -0
- package/dist/internal/color-scheme-keys.js +1 -0
- package/dist/internal/color-scheme.d.ts +11 -2
- package/dist/internal/color-scheme.js +1 -1
- package/dist/internal/config.d.ts +2 -0
- package/dist/internal/date.d.ts +2 -8
- package/dist/internal/date.js +1 -1
- package/dist/internal/highlight.js +1 -1
- package/dist/internal/i18n.d.ts +0 -53
- package/dist/internal/i18n.js +1 -1
- package/dist/internal/intersection.d.ts +50 -0
- package/dist/internal/intersection.js +2 -0
- package/dist/internal/intl.d.ts +22 -21
- package/dist/internal/intl.js +1 -1
- package/dist/internal/keys.d.ts +0 -9
- package/dist/internal/keys.js +1 -1
- package/dist/internal/layout-effect.d.ts +7 -0
- package/dist/internal/layout-effect.js +2 -0
- package/dist/internal/locale.d.ts +10 -2
- package/dist/internal/media.d.ts +1 -0
- package/dist/internal/media.js +1 -0
- package/dist/internal/occurrence.d.ts +18 -0
- package/dist/internal/occurrence.js +1 -0
- package/dist/internal/page-layout.js +1 -1
- package/dist/internal/progress.d.ts +5 -0
- package/dist/internal/ref.d.ts +9 -0
- package/dist/internal/ref.js +1 -0
- package/dist/internal/remember.d.ts +36 -0
- package/dist/internal/remember.js +1 -0
- package/dist/internal/surface.d.ts +7 -1
- package/dist/internal/surface.js +1 -1
- package/dist/internal/text.d.ts +10 -4
- package/dist/internal/text.js +1 -1
- package/dist/internal/window-class.d.ts +8 -0
- package/dist/internal/window-class.js +1 -1
- package/dist/styles/accordion.css +1 -1
- package/dist/styles/alert.css +1 -1
- package/dist/styles/animate-appear.css +1 -1
- package/dist/styles/animate-blink.css +1 -1
- package/dist/styles/animate-counter.css +1 -1
- package/dist/styles/animate-fade.css +1 -1
- package/dist/styles/animate-float.css +1 -1
- package/dist/styles/animate-grow.css +1 -1
- package/dist/styles/animate-headline.css +1 -1
- package/dist/styles/animate-lighting.css +1 -1
- package/dist/styles/animate-marquee.css +1 -1
- package/dist/styles/animate-reveal.css +1 -1
- package/dist/styles/animate-rotate.css +1 -1
- package/dist/styles/animate-scramble.css +1 -1
- package/dist/styles/animate-shake.css +1 -1
- package/dist/styles/animate-slide.css +1 -1
- package/dist/styles/animate-split.css +1 -1
- package/dist/styles/animate-typing.css +1 -1
- package/dist/styles/animate-zoom.css +1 -1
- package/dist/styles/avatar.css +1 -1
- package/dist/styles/blockquote.css +1 -1
- package/dist/styles/box.css +1 -1
- package/dist/styles/breadcrumb.css +1 -1
- package/dist/styles/calendar.css +1 -1
- package/dist/styles/card.css +1 -1
- package/dist/styles/carousel.css +1 -1
- package/dist/styles/checkbox.css +1 -1
- package/dist/styles/chip.css +1 -1
- package/dist/styles/collapsible.css +1 -1
- package/dist/styles/color-picker.css +1 -1
- package/dist/styles/combobox.css +1 -1
- package/dist/styles/command-palette.css +1 -1
- package/dist/styles/confirm.css +1 -1
- package/dist/styles/data-table.css +1 -1
- package/dist/styles/date-picker.css +1 -1
- package/dist/styles/date-range-picker.css +1 -1
- package/dist/styles/date-time-picker.css +1 -1
- package/dist/styles/dialog.css +1 -1
- package/dist/styles/drawer.css +1 -1
- package/dist/styles/empty.css +1 -1
- package/dist/styles/floating-bottom-navigation.css +1 -1
- package/dist/styles/footer.css +1 -1
- package/dist/styles/gauge-chart.css +1 -1
- package/dist/styles/header.css +1 -1
- package/dist/styles/highlight.css +1 -1
- package/dist/styles/hover-card.css +1 -1
- package/dist/styles/image.css +1 -1
- package/dist/styles/list.css +1 -1
- package/dist/styles/menu.css +1 -1
- package/dist/styles/menubar.css +1 -1
- package/dist/styles/meter.css +1 -1
- package/dist/styles/navigation-menu.css +1 -1
- package/dist/styles/number-field.css +1 -1
- package/dist/styles/otp-field.css +1 -1
- package/dist/styles/overlay.css +1 -1
- package/dist/styles/page-layout.css +1 -1
- package/dist/styles/pill.css +1 -1
- package/dist/styles/popconfirm.css +1 -1
- package/dist/styles/popover.css +1 -1
- package/dist/styles/progress-box.css +1 -1
- package/dist/styles/progress-circular.css +1 -1
- package/dist/styles/progress-linear.css +1 -1
- package/dist/styles/radio-group.css +1 -1
- package/dist/styles/select.css +1 -1
- package/dist/styles/sidebar.css +1 -1
- package/dist/styles/slider.css +1 -1
- package/dist/styles/snackbar.css +1 -1
- package/dist/styles/spoiler.css +1 -1
- package/dist/styles/stack.css +1 -1
- package/dist/styles/switch.css +1 -1
- package/dist/styles/table.css +1 -1
- package/dist/styles/tabs.css +1 -1
- package/dist/styles/text-field.css +1 -1
- package/dist/styles/time-picker.css +1 -1
- package/dist/styles/tokens.css +1 -1
- package/dist/styles/toolbar.css +1 -1
- package/dist/styles/tour.css +1 -1
- package/dist/styles/transfer.css +1 -1
- package/dist/styles/tree-select.css +1 -1
- package/dist/styles/tree-view.css +1 -1
- package/dist/styles/typography.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +116 -4
- package/package.json +1 -1
package/dist/internal/chart.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{dateTimeFormatter as t,numberFormatter as n}from"./intl.js";export const CHART_SLOTS=8;const r=new Set(["primary","secondary","tertiary","error"]);export function seriesColor(t,n){return n?r.has(n)?`var(--_mp-color-${n})`:n:`var(--_mp-chart-${t%8+1})`}export const COMPACT_FROM=1e4;const o={notation:"compact",maximumFractionDigits:1},e={month:"short",day:"numeric"},a={style:"percent",maximumFractionDigits:0};export function formatStatistic(t,r,e,a){return Number.isFinite(t)?e?n(r,e).format(t):a&&Math.abs(t)>=1e4?n(r,o).format(t):n(r).format(t):""}export function formatShare(t,r){return Number.isFinite(t)?t>0&&t<.005?`<${n(r,a).format(.01)}`:n(r,a).format(t):""}export function deltaOf(t,n,r){const o=t-n,e=o>0?1:o<0?-1:0;return{absolute:o,percent:0===n?null:o/Math.abs(n)*100,direction:e,good:0!==e&&1===e==("up"===r)}}function u(t,n){if(0===t.length)return"";if(1===t.length)return`M${t[0].x} ${t[0].y}h0`;const r=`M${t[0].x} ${t[0].y}`;if("smooth"===n)return r+function(t){const n=t.length,r=[];for(let o=0;o<n-1;o+=1){const n=t[o+1].x-t[o].x;r.push(0===n?0:(t[o+1].y-t[o].y)/n)}const o=[r[0]??0];for(let t=1;t<n-1;t+=1){const n=r[t-1],e=r[t];o.push(n*e<=0?0:2*n*e/(n+e))}o.push(r[n-2]??0);const e=[];for(let r=0;r<n-1;r+=1){const n=(t[r+1].x-t[r].x)/3;e.push(`C${t[r].x+n} ${t[r].y+o[r]*n} ${t[r+1].x-n} ${t[r+1].y-o[r+1]*n} ${t[r+1].x} ${t[r+1].y}`)}return e.join("")}(t);const o=[];for(let r=1;r<t.length;r+=1)if("step"===n){const n=(t[r-1].x+t[r].x)/2;o.push(`H${n}V${t[r].y}H${t[r].x}`)}else o.push(`L${t[r].x} ${t[r].y}`);return r+o.join("")}export function linePath(t,n){return function(t){const n=[];let r=[];for(const o of t)null===o?(r.length>0&&n.push(r),r=[]):r.push(o);return r.length>0&&n.push(r),n}(t).map(t=>u(t,n)).join("")}export function bridgePath(t){const n=[];let r=null,o=!1;for(const e of t)null!==e?(null!==r&&o&&n.push(`M${r.x} ${r.y}L${e.x} ${e.y}`),r=e,o=!1):o=null!==r;return n.join("")}export const BRIDGE_DASH=3;export function withoutGaps(t){return t.filter(t=>null!==t)}export function bandPath(t,n,r){const o=[];let e=[],a=[];const i=()=>{e.length>0&&o.push(`${u(e,r)}${u([...a].reverse(),r).replace(/^M/,"L")}Z`),e=[],a=[]};return t.forEach((t,r)=>{const o=n[r];null!==t&&null!=o?(e.push(t),a.push(o)):i()}),i(),o.join("")}export function areaPath(t,n,r){return bandPath(t,t.map(t=>null===t?null:{x:t.x,y:n}),r)}export function barPath(t,n,r,o,e,a){const u=Math.abs(r),i=Math.abs(o);if(0===u||0===i)return"";const
|
|
1
|
+
import{dateTimeFormatter as t,numberFormatter as n}from"./intl.js";export const CHART_SLOTS=8;const r=new Set(["primary","secondary","tertiary","error"]);export function seriesColor(t,n){return n?r.has(n)?`var(--_mp-color-${n})`:n:`var(--_mp-chart-${t%8+1})`}export const COMPACT_FROM=1e4;const o={notation:"compact",maximumFractionDigits:1},e={month:"short",day:"numeric"},a={style:"percent",maximumFractionDigits:0};export function formatStatistic(t,r,e,a){return Number.isFinite(t)?e?n(r,e).format(t):a&&Math.abs(t)>=1e4?n(r,o).format(t):n(r).format(t):""}export function formatShare(t,r){return Number.isFinite(t)?t>0&&t<.005?`<${n(r,a).format(.01)}`:n(r,a).format(t):""}export function deltaOf(t,n,r){const o=t-n,e=o>0?1:o<0?-1:0;return{absolute:o,percent:0===n?null:o/Math.abs(n)*100,direction:e,good:0!==e&&1===e==("up"===r)}}function u(t,n){if(0===t.length)return"";if(1===t.length)return`M${t[0].x} ${t[0].y}h0`;const r=`M${t[0].x} ${t[0].y}`;if("smooth"===n)return r+function(t){const n=t.length,r=[];for(let o=0;o<n-1;o+=1){const n=t[o+1].x-t[o].x;r.push(0===n?0:(t[o+1].y-t[o].y)/n)}const o=[r[0]??0];for(let t=1;t<n-1;t+=1){const n=r[t-1],e=r[t];o.push(n*e<=0?0:2*n*e/(n+e))}o.push(r[n-2]??0);const e=[];for(let r=0;r<n-1;r+=1){const n=(t[r+1].x-t[r].x)/3;e.push(`C${t[r].x+n} ${t[r].y+o[r]*n} ${t[r+1].x-n} ${t[r+1].y-o[r+1]*n} ${t[r+1].x} ${t[r+1].y}`)}return e.join("")}(t);const o=[];for(let r=1;r<t.length;r+=1)if("step"===n){const n=(t[r-1].x+t[r].x)/2;o.push(`H${n}V${t[r].y}H${t[r].x}`)}else o.push(`L${t[r].x} ${t[r].y}`);return r+o.join("")}export function linePath(t,n){return function(t){const n=[];let r=[];for(const o of t)null===o?(r.length>0&&n.push(r),r=[]):r.push(o);return r.length>0&&n.push(r),n}(t).map(t=>u(t,n)).join("")}export function bridgePath(t){const n=[];let r=null,o=!1;for(const e of t)null!==e?(null!==r&&o&&n.push(`M${r.x} ${r.y}L${e.x} ${e.y}`),r=e,o=!1):o=null!==r;return n.join("")}export const BRIDGE_DASH=3;export function withoutGaps(t){return t.filter(t=>null!==t)}export function bandPath(t,n,r){const o=[];let e=[],a=[];const i=()=>{e.length>0&&o.push(`${u(e,r)}${u([...a].reverse(),r).replace(/^M/,"L")}Z`),e=[],a=[]};return t.forEach((t,r)=>{const o=n[r];null!==t&&null!=o?(e.push(t),a.push(o)):i()}),i(),o.join("")}export function areaPath(t,n,r){return bandPath(t,t.map(t=>null===t?null:{x:t.x,y:n}),r)}export function barPath(t,n,r,o,e,a){const u=Math.abs(r),i=Math.abs(o);if(0===u||0===i)return"";const l=Math.max(0,Math.min(e,u/2,i/2)),c="both"===a,s={tl:c||"top"===a||"left"===a?l:0,tr:c||"top"===a||"right"===a?l:0,br:c||"bottom"===a||"right"===a?l:0,bl:c||"bottom"===a||"left"===a?l:0},x=(t,n,r)=>t>0?`a${t} ${t} 0 0 1 ${n} ${r}`:"";return`M${t+s.tl} ${n}h`+(u-s.tl-s.tr)+x(s.tr,s.tr,s.tr)+"v"+(i-s.tr-s.br)+x(s.br,-s.br,s.br)+"h"+-(u-s.bl-s.br)+x(s.bl,-s.bl,-s.bl)+"v"+-(i-s.tl-s.bl)+x(s.tl,s.tl,-s.tl)+"Z"}export function extentOf(t,n,r){const o=bounds(t.filter(t=>null!==t&&Number.isFinite(t))),e=n??o?.min??0,a=r??o?.max??0;return e===a?{min:e-.5,max:a+.5}:{min:e,max:a}}export function withReferences(t,n){const r=(n??[]).flatMap(t=>[toNumber(t.value),void 0===t.to?null:toNumber(t.to)]).filter(t=>null!==t);return 0===r.length||null===t?t:{min:Math.min(t.min,...r),max:Math.max(t.max,...r)}}export function seriesExtent(t,n){let r=1/0,o=-1/0,e=!1;if(n){const n=t.reduce((t,n)=>Math.max(t,n.length),0);for(let a=0;a<n;a+=1){let n=0,u=0;for(const r of t){const t=r[a]?.value;null!=t&&(e=!0,t>=0?n+=t:u+=t)}r=Math.min(r,u),o=Math.max(o,n)}}else for(const n of t)for(const{value:t}of n)null!==t&&(e=!0,r=Math.min(r,t),o=Math.max(o,t));return e?{min:r,max:o}:null}function i(t){const n=10**Math.floor(Math.log10(t)),r=t/n;return r<=1?n:r<=2?2*n:r<=5?5*n:10*n}export function valueScale(t,n={}){const{tickCount:r=5,includeZero:o=!0}=n;let e=n.min??t?.min??0,a=n.max??t?.max??1;if(o&&void 0===n.min&&(e=Math.min(e,0)),o&&void 0===n.max&&(a=Math.max(a,0)),a===e){const t=Math.abs(a)>0?.5*Math.abs(a):1;e-=t,a+=t}const u=void 0!==n.min&&void 0!==n.max?function(t,n){const r=10**Math.floor(Math.log10(t/Math.max(1,n)));let o=i(t/Math.max(1,n)),e=1/0;for(const a of[.1,1,10])for(const u of[1,2,2.5,5]){const i=u*a*r,l=t/i,c=Math.round(l);if(c<1||Math.abs(l-c)>1e-9)continue;const s=Math.abs(c-n);s<e&&(e=s,o=i)}return o}(a-e,r):i((a-e)/Math.max(1,r)),l=void 0!==n.min?e:Math.floor(e/u)*u,c=void 0!==n.max?a:Math.ceil(a/u)*u,s=c-l||1,x=[];for(let t=l;t<=c+1e-9*u;t+=u)x.push(Number(t.toFixed(12)));return{min:l,max:c,ticks:x,fraction:t=>(t-l)/s}}export function bandScale(t,n,r){const o=t>0?n/t:n;return{step:o,band:o*r,centre:t=>o*(t+.5)}}const l=/[\u1100-\u11FF\u2E80-\uA4CF\uAC00-\uD7FF\uF900-\uFAFF\uFE30-\uFE4F]/;export function bounds(t){let n=1/0,r=-1/0;for(const o of t)o<n&&(n=o),o>r&&(r=o);return n<=r?{min:n,max:r}:null}export function textWidth(t,n){let r=0;for(const n of t)r+=l.test(n)?1:.6;return r*n}export function truncate(t,n,r){if(n<=0||textWidth(t,r)<=n)return t;const o=n-textWidth("…",r);let e="",a=0;for(const n of t){const t=a+textWidth(n,r);if(t>o)break;a=t,e+=n}return e.length>0?`${e.trimEnd()}…`:"…"}export function tickStride(t,n,r){return t<=1||n<=0?1:Math.max(1,Math.ceil(t/Math.max(1,Math.floor(n/Math.max(1,r)))))}export function showsTick(t,n,r,o){return t%r===0||o&&t===n-1}export function fitsLast(t,n,r,o){const e=(t-1)%n;return e>0&&e*r>=o+8}export const LABEL_AIR=12;const c=1.35;export function tickTurn(t,n,r,o){if("rotate"===t)return 45;if("vertical"===t)return 90;if("truncate"===t||void 0===t)return 0;const e=n.reduce((t,n)=>Math.max(t,textWidth(n,r)),0);return e+12<=o||e<3*r?0:o>=turnedStep(45,r)?45:90}export function turnedStep(t,n){const r=t*Math.PI/180;return n*c/Math.max(.2,Math.sin(r))}export function turnedBand(t,n,r){const o=t*Math.PI/180;return n*Math.sin(o)+r*c*Math.cos(o)/2}export function turnedRoom(t,n,r){const o=t*Math.PI/180;return(n-r*c*Math.cos(o)/2)/Math.max(.2,Math.sin(o))}export function toValue(t){return null==t?{value:null}:"number"==typeof t?{value:Number.isFinite(t)?t:null}:"object"==typeof t&&"y"in t?{value:null!==t.y&&Number.isFinite(t.y)?t.y:null,x:t.x,z:t.z,color:t.color?seriesColor(0,t.color):void 0,label:t.label}:{value:null}}export function toValues(t){return t.map(t=>t.data.map(toValue))}export function toNumber(t){return t instanceof Date?Number.isFinite(t.getTime())?t.getTime():null:"number"==typeof t&&Number.isFinite(t)?t:null}export function categoryCount(t){return t.reduce((t,n)=>Math.max(t,n.data.length),0)}export function categoryAt(t,n,r){if(n&&t<n.length)return n[t];for(const n of r){const r=n[t]?.x;if(void 0!==r)return r}return t}export function valueLabelTest(t,n,r){if("all"===n)return()=>!0;if("last"===n){let n=r??-1;if(void 0===r)for(let r=t.length-1;r>=0;r--)if(null!==t[r].value){n=r;break}return t=>t===n}if("extremes"!==n)return()=>!1;let o=1/0,e=-1/0;for(const n of t)null!==n.value&&(o=Math.min(o,n.value),e=Math.max(e,n.value));return n=>t[n]?.value===o||t[n]?.value===e}export function formatCategory(r,o){return r instanceof Date?t(o,e).format(r):"number"==typeof r?n(o).format(r):r}export const PLOT_HEIGHT={xs:120,sm:160,md:220,lg:280,xl:360};export const CHART_FONT_SIZE={xs:10,sm:11,md:12,lg:13,xl:14};export const LINE_WIDTH={xs:1.5,sm:1.75,md:2,lg:2.5,xl:3};export const MARKER_RADIUS={xs:3,sm:3.5,md:4,lg:4.5,xl:5};export const MARK_GAP=2;export const BAR_RADIUS=4;export const BAR_MAX_THICKNESS={xs:24,sm:32,md:40,lg:48,xl:56};export const BAR_BAND_RATIO=.72;export function polarPoint(t,n,r,o){return{x:t+r*Math.sin(o),y:n-r*Math.cos(o)}}export function arcPath(t,n,r,o,e,a){const u=a-e;if(Math.abs(u)<1e-9||r<=0)return"";const i=Math.abs(u)>=2*Math.PI-1e-9,l=i?e+2*Math.PI*Math.sign(u||1):a,c=e+(l-e)/2,s=Math.abs(l-e)>Math.PI?1:0,x=l>e?1:0,f=x?0:1,m=polarPoint(t,n,r,e),h=polarPoint(t,n,r,c),$=polarPoint(t,n,r,l),p=i?`A${r} ${r} 0 0 ${x} ${h.x} ${h.y}A${r} ${r} 0 0 ${x} ${$.x} ${$.y}`:`A${r} ${r} 0 ${s} ${x} ${$.x} ${$.y}`;if(o<=0)return i?`M${m.x} ${m.y}${p}Z`:`M${t} ${n}L${m.x} ${m.y}${p}Z`;const M=polarPoint(t,n,o,l),b=polarPoint(t,n,o,c),d=polarPoint(t,n,o,e),y=i?`A${o} ${o} 0 0 ${f} ${b.x} ${b.y}A${o} ${o} 0 0 ${f} ${d.x} ${d.y}`:`A${o} ${o} 0 ${s} ${f} ${d.x} ${d.y}`;return`M${m.x} ${m.y}${p}L${M.x} ${M.y}${y}Z`}export function categoryExtent(t,n){let r=1/0,o=-1/0,e=!1;return t.forEach(t=>{t.forEach((t,a)=>{if(null===t.value)return;const u=toNumber(t.x??n?.[a]??a);null!==u&&(e=!0,r=Math.min(r,u),o=Math.max(o,u))})}),e?{min:r,max:o}:null}export const MARK_SHAPES=["circle","square","triangle","diamond","cross"];const s={circle:1,square:.886,triangle:1.35,diamond:1.25,cross:1.1};export function markPath(t,n,r,o){const e=o*s[t];switch(t){case"square":return`M${n-e} ${r-e}h${2*e}v${2*e}h${2*-e}Z`;case"triangle":return`M${n} ${r-e}L${n+.866*e} ${r+.5*e}L${n-.866*e} ${r+.5*e}Z`;case"diamond":return`M${n} ${r-e}L${n+e} ${r}L${n} ${r+e}L${n-e} ${r}Z`;case"cross":return`M${n-e} ${r-e}L${n+e} ${r+e}M${n+e} ${r-e}L${n-e} ${r+e}`;default:return`M${n-e} ${r}a${e} ${e} 0 1 0 ${2*e} 0a${e} ${e} 0 1 0 ${2*-e} 0Z`}}export function pointX(t,n,r){return toNumber(t.x??r?.[n]??n)}export function bubbleRadius(t,n,r,o){return n<=0||t<=0?o:o+(r-o)*Math.sqrt(Math.min(1,t/n))}export const RAMP_STEPS=5;export function rampStep(t){return Number.isFinite(t)?Math.min(4,Math.max(0,Math.floor(5*t))):0}export function rampFill(t){return`var(--_mp-chart-scale-${Math.min(5,Math.max(1,t+1))})`}export function rampInk(t){return t>=3?"var(--_mp-color-surface)":"var(--_mp-color-on-surface)"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two names the scheme switch and its `<head>` script agree on.
|
|
3
|
+
*
|
|
4
|
+
* Kept apart from `internal/color-scheme.ts`, which is a store and imports
|
|
5
|
+
* React, so that `mpColorSchemeScript` can import them without importing React
|
|
6
|
+
* too. A module that imports React is marked `"use client"` by the build, and a
|
|
7
|
+
* function exported from one cannot be called from a server component — which
|
|
8
|
+
* is the one place the script is meant to be written.
|
|
9
|
+
*/
|
|
10
|
+
/** The attribute on the document element that forces a scheme. */
|
|
11
|
+
export declare const SCHEME_ATTRIBUTE = "data-mp-scheme";
|
|
12
|
+
/** Where a page's choice is remembered, unless told otherwise. */
|
|
13
|
+
export declare const DEFAULT_STORAGE_KEY = "mp-color-scheme";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const SCHEME_ATTRIBUTE="data-mp-scheme";export const DEFAULT_STORAGE_KEY="mp-color-scheme";
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
import { DEFAULT_STORAGE_KEY, SCHEME_ATTRIBUTE } from './color-scheme-keys.js';
|
|
1
2
|
/** What a page can be set to. `'system'` is the absence of a choice. */
|
|
2
3
|
export type MPColorScheme = 'light' | 'dark' | 'system';
|
|
3
4
|
/** What is actually painted, once `'system'` has been resolved. */
|
|
4
5
|
export type MPResolvedColorScheme = 'light' | 'dark';
|
|
5
|
-
export
|
|
6
|
-
|
|
6
|
+
export { DEFAULT_STORAGE_KEY, SCHEME_ATTRIBUTE };
|
|
7
|
+
/**
|
|
8
|
+
* Puts the choice on the document element, or takes it off.
|
|
9
|
+
*
|
|
10
|
+
* `'system'` **removes** the attribute rather than writing it, which is the
|
|
11
|
+
* whole of how the media query gets its say back: the dark block is reached
|
|
12
|
+
* either by `prefers-color-scheme` on a root that is not forced light, or by the
|
|
13
|
+
* attribute. An attribute spelling out `system` would match neither.
|
|
14
|
+
*/
|
|
15
|
+
export declare function applyScheme(scheme: MPColorScheme): void;
|
|
7
16
|
export declare function setScheme(storageKey: string, scheme: MPColorScheme): void;
|
|
8
17
|
export declare function useChosenScheme(storageKey: string): MPColorScheme;
|
|
9
18
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import*as e from"react";
|
|
2
|
+
import*as e from"react";import{DEFAULT_STORAGE_KEY as t,SCHEME_ATTRIBUTE as n}from"./color-scheme-keys.js";import{mediaList as o}from"./media.js";export{t as DEFAULT_STORAGE_KEY,n as SCHEME_ATTRIBUTE};const r="(prefers-color-scheme: dark)";function c(e){return"light"===e||"dark"===e||"system"===e}let u;const s=new Set;function m(){for(const e of s)e()}export function applyScheme(e){if("undefined"==typeof document)return;const t=document.documentElement;"system"===e?t.removeAttribute(n):t.setAttribute(n,e)}export function setScheme(e,t){u=t,function(e,t){try{"system"===t?localStorage.removeItem(e):localStorage.setItem(e,t)}catch{}}(e,t),applyScheme(t),m()}function i(e){return s.add(e),()=>{s.delete(e)}}function f(e){return u??=function(){if("undefined"==typeof document)return;const e=document.documentElement.getAttribute(n);return c(e)&&"system"!==e?e:void 0}()??function(e){try{if("undefined"==typeof localStorage)return"system";const t=localStorage.getItem(e);return c(t)?t:"system"}catch{return"system"}}(e),u}export function useChosenScheme(t){const n=e.useCallback(()=>f(t),[t]);return e.useSyncExternalStore(i,n,()=>"system")}function a(e){if("undefined"==typeof window||!window.matchMedia)return()=>{};const t=o(r);return t?.addEventListener("change",e),()=>t?.removeEventListener("change",e)}function d(){return o(r)?.matches?"dark":"light"}export function useSystemScheme(){return e.useSyncExternalStore(a,d,()=>"light")}export function resetScheme(){u=void 0,m()}
|
|
@@ -41,6 +41,8 @@ export interface MPConfigValue {
|
|
|
41
41
|
* and cannot be.
|
|
42
42
|
*/
|
|
43
43
|
breakpoints?: Partial<Record<MPWindowClass, number>>;
|
|
44
|
+
/** Whether a field keeps a line under itself for a message it has not got yet. */
|
|
45
|
+
reserveSupportingText?: boolean;
|
|
44
46
|
}
|
|
45
47
|
export declare const MPConfigContext: React.Context<MPConfigValue>;
|
|
46
48
|
/** The configuration in force at this point in the tree. */
|
package/dist/internal/date.d.ts
CHANGED
|
@@ -214,14 +214,8 @@ export declare function weekdayLabels(locale: string | undefined, weekStartsOn:
|
|
|
214
214
|
/** The twelve month names, January first, in the locale's own words. */
|
|
215
215
|
export declare function monthLabels(locale: string | undefined, month?: 'short' | 'long'): readonly string[];
|
|
216
216
|
/**
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
* The calendar's header is two separate buttons — one that opens the month grid
|
|
220
|
-
* and one that opens the year grid — so it cannot just print what `Intl` gives
|
|
221
|
-
* it. Asking `formatToParts` which part came first is how the two buttons end up
|
|
222
|
-
* in the order the reader expects: `July 2026` in English, `2026년 7월` in
|
|
223
|
-
* Korean. Getting this wrong is subtle and reads as broken to exactly the people
|
|
224
|
-
* it is wrong for.
|
|
217
|
+
* Cached on the locale for the reason `isHour12` is: a calendar's header asks
|
|
218
|
+
* on every render, and `formatToParts` builds a fresh array of parts each time.
|
|
225
219
|
*/
|
|
226
220
|
export declare function isMonthBeforeYear(locale: string | undefined): boolean;
|
|
227
221
|
export declare function isHour12(locale: string | undefined): boolean;
|
package/dist/internal/date.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{checkServerLocale as t,dateTimeFormatter as e,remember as r}from"./intl.js";export const YEAR_PAGE_SIZE=12;export function makeDate(t,e,r){const n=new Date(0);return n.setFullYear(t,e,r),n.setHours(0,0,0,0),n}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 startOfUnit(t,e){return"year"===e?function(t){return makeDate(t.getFullYear(),0,1)}(t):"month"===e?startOfMonth(t):startOfDay(t)}export function today(){return startOfDay(new Date)}export function addDays(t,e){const r=new Date(t.getTime());return r.setDate(r.getDate()+e),r}export function addMonths(t,e){const r=new Date(t.getTime()),n=makeDate(t.getFullYear(),t.getMonth()+e,1);var o,a;return r.setFullYear(n.getFullYear(),n.getMonth(),Math.min(t.getDate(),(o=n.getFullYear(),a=n.getMonth(),makeDate(o,a+1,0).getDate()))),r}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 isDayOutside(t,e,r){return!!(isValidDate(e)&&compareDay(t,e)<0)||isValidDate(r)&&compareDay(t,r)>0}export function isUnitOutside(t,e,r,n){return"day"===e?isDayOutside(t,r,n):!!(isValidDate(r)&&compareDay(function(t,e){return"year"===e?makeDate(t.getFullYear(),11,31):"month"===e?makeDate(t.getFullYear(),t.getMonth()+1,0):startOfDay(t)}(t,e),r)<0)||isValidDate(n)&&compareDay(startOfUnit(t,e),n)>0}export function secondsOfDay(t){return 3600*t.getHours()+60*t.getMinutes()+t.getSeconds()}export function timeUnitSpan(t,e){const r=secondsOfDay(e);if("hour"===t){const t=3600*Math.floor(r/3600);return[t,t+3599]}if("minute"===t){const t=60*Math.floor(r/60);return[t,t+59]}if("second"===t)return[r,r];const n=e.getHours()<12?0:43200;return[n,n+43200-1]}export function withTime(t,e){const r=new Date(t.getTime());return r.setHours(e.hours??r.getHours(),e.minutes??r.getMinutes(),e.seconds??r.getSeconds(),0),r}export function mergeDateAndTime(t,e){return withTime(startOfDay(t),{hours:e.getHours(),minutes:e.getMinutes(),seconds:e.getSeconds()})}export function calendarWeeks(t,e){const r=startOfMonth(t),n=(r.getDay()-e+7)%7,o=addDays(r,-n);return Array.from({length:6},(t,e)=>Array.from({length:7},(t,r)=>addDays(o,7*e+r)))}export function yearPageStart(t){return t-(t%12+12)%12}export function dateFormatter(t,r){return e(t,r)}export function formatDate(t,e,r){return isValidDate(t)?dateFormatter(e,r).format(t):""}const n=Array.from({length:24},(t,e)=>new Date(2027,e%12,21+e%7,e,58,58));export function displaySamples(t,e){const r=dateFormatter(t,e);return[...new Set(n.map(t=>r.format(t)))]}export function withPlaceholder(t,e){return"string"==typeof e&&""!==e?[...t,e]:t}export function toISOYear(t){return String(t.getFullYear()).padStart(4,"0")}export function toISOMonth(t){return`${toISOYear(t)}-${String(t.getMonth()+1).padStart(2,"0")}`}export function toISODate(t){return`${toISOMonth(t)}-${String(t.getDate()).padStart(2,"0")}`}export const TO_ISO={day:toISODate,month:toISOMonth,year:toISOYear};export function toISOTime(t,e=!1){const r=t=>String(t).padStart(2,"0"),n=`${r(t.getHours())}:${r(t.getMinutes())}`;return e?`${n}:${r(t.getSeconds())}`:n}export function toISODateTime(t,e=!1){return`${toISODate(t)}T${toISOTime(t,e)}`}const o=makeDate(2021,7,1),a=new Map;export function weekdayLabels(t,e,n="narrow"){const i=`w ${t??""} ${e} ${n}`,u=a.get(i);if(u)return u;const s=dateFormatter(t,{weekday:n});return r(a,i,Array.from({length:7},(t,r)=>s.format(addDays(o,(e+r)%7))))}export function monthLabels(t,e="short"){const n=`m ${t??""} ${e}`,o=a.get(n);if(o)return o;const i=dateFormatter(t,{month:e});return r(a,n,Array.from({length:12},(t,e)=>i.format(makeDate(2021,e,1))))}const i=new Map;export function isMonthBeforeYear(t){const e=t??"",n=i.get(e);if(void 0!==n)return n;const a=dateFormatter(t,{year:"numeric",month:"long"}).formatToParts(o);return r(i,e,a.findIndex(t=>"month"===t.type)<a.findIndex(t=>"year"===t.type))}const u=new Map;export function isHour12(t){const e=t??"",n=u.get(e);if(void 0!==n)return n;const o=dateFormatter(t,{hour:"numeric"}).resolvedOptions(),a=o.hourCycle?"h11"===o.hourCycle||"h12"===o.hourCycle:!0===o.hour12;return r(u,e,a)}export function meridiemLabels(t){const e=dateFormatter(t,{hour:"numeric",hour12:!0}),r=t=>{const r=e.formatToParts(withTime(o,{hours:t})).find(t=>"dayPeriod"===t.type);return r?.value??(t<12?"AM":"PM")};return[r(9),r(21)]}const s=new Map;export function localeWeekStart(e){const n=e??"",o=s.get(n);return void 0!==o?o:r(s,n,function(e){t(e);try{const t=e??(new Intl.DateTimeFormat).resolvedOptions().locale,r=new Intl.Locale(t),n="function"==typeof r.getWeekInfo?r.getWeekInfo():r.weekInfo;if("number"==typeof n?.firstDay)return n.firstDay%7}catch{}return 0}(e))}
|
|
@@ -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"),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",golang:"go",gql:"graphql",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;let
|
|
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"),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",golang:"go",gql:"graphql",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;let s=null;const g=new Map;export function registerMPLanguage(i,t){const s=i.toLowerCase();l.set(s,t),g.delete(s)}export function canonicalLanguage(i){if(!i)return null;const l=i.trim().toLowerCase();return l?t[l]??l:null}export async function highlightCode(t,e){let a=g.get(e);a||(a=async function(t){const g=l.get(t),e=g?void 0:i[t];if(!g&&!e)return null;s??=import("highlight.js/lib/core").then(i=>i.default);const a=await s;return g?a.registerLanguage(t,g):a.getLanguage(t)||a.registerLanguage(t,(await e()).default),t}(e).catch(i=>{throw g.delete(e),i}),g.set(e,a));const h=await a;if(!h||!s)return null;const n=await s;return await function(){const i=globalThis.scheduler;return i?.yield?i.yield():new Promise(i=>setTimeout(i,0))}(),tokenize(n.highlight(t,{language:h,ignoreIllegals:!0}).value)}const e={"&":"&","<":"<",">":">",""":'"',"'":"'"};export function tokenize(i){const t=[[]],l=[],s=/<span class="([^"]*)">|<\/span>/g;let g=0;const a=i=>{if(!i)return;const s=l[l.length-1];i.replace(/&(?:amp|lt|gt|quot|#x27);/g,i=>e[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))a(i.slice(g,t.index)),g=t.index+t[0].length,void 0===t[1]?l.pop():l.push(t[1]);return a(i.slice(g)),t}export function plainLines(i){return i.split("\n").map(i=>i?[{text:i}]:[])}
|
package/dist/internal/i18n.d.ts
CHANGED
|
@@ -1,56 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The words the library says on its own behalf.
|
|
3
|
-
*
|
|
4
|
-
* Almost nothing in Material Plus writes text a reader sees — a button says
|
|
5
|
-
* whatever it was handed, a dialog's title is the caller's. The exceptions are
|
|
6
|
-
* the strings a component has to invent because there is nowhere else for them
|
|
7
|
-
* to come from: the name on a calendar's back arrow, the word on the button that
|
|
8
|
-
* empties a picker, the label a screen reader hears for a column of minutes.
|
|
9
|
-
*
|
|
10
|
-
* Those are collected here rather than defaulted inside each component, because
|
|
11
|
-
* they are a *set*. A product in Korean does not want four pickers each
|
|
12
|
-
* defaulting to English and each needing eighteen override props; and the next
|
|
13
|
-
* component that needs a word should get it from the same place rather than
|
|
14
|
-
* starting a second table beside this one.
|
|
15
|
-
*
|
|
16
|
-
* What is *not* in here is anything `Intl` already knows. Month names, weekday
|
|
17
|
-
* names, AM/PM and number formats come from the platform, which speaks more
|
|
18
|
-
* languages than this file ever will — see `internal/date.ts`. This is only for
|
|
19
|
-
* the words the platform has no opinion about.
|
|
20
|
-
*
|
|
21
|
-
* Every component that reads this takes a `locale` and an override prop for the
|
|
22
|
-
* strings themselves, so an unsupported language is never a dead end: `locale`
|
|
23
|
-
* gets you a translation, `MPLocaleProvider` gets you one for the whole
|
|
24
|
-
* application at once, and the prop gets you one for anything else.
|
|
25
|
-
*
|
|
26
|
-
* ## Where the words themselves are
|
|
27
|
-
*
|
|
28
|
-
* Not here. This file is the shape of the table, the registry a translation
|
|
29
|
-
* arrives through, and the merge — no strings.
|
|
30
|
-
*
|
|
31
|
-
* The eighteen translations live under `src/locales/`, and nothing in the
|
|
32
|
-
* library imports them. They used to be here, and being here is what made them
|
|
33
|
-
* cost something: a component that says one word — `MPButton` says *Loading* —
|
|
34
|
-
* held a static import chain down to a table of every string in every language,
|
|
35
|
-
* and a bundler cannot drop data that something imports. Twenty kilobytes, on
|
|
36
|
-
* every consumer, for a word. So the table arrives from the outside instead:
|
|
37
|
-
* `registerMPMessages` below is how, `material-plus-ui/locales` is where from,
|
|
38
|
-
* and the only thing that changed for a reader is that the application now names
|
|
39
|
-
* the languages it speaks. Once it has, `locale="ko"` resolves through exactly
|
|
40
|
-
* the path it always did.
|
|
41
|
-
*
|
|
42
|
-
* English left too, for the same reason one step smaller. It is thirteen modules
|
|
43
|
-
* under `internal/messages/`, one per namespace, because a bundler that can drop
|
|
44
|
-
* a module it can also drop an export — and cannot drop a property. Held as one
|
|
45
|
-
* object, English was 1.75 kB that every component carried whole: `MPButton`
|
|
46
|
-
* shipped the calendar's eighteen strings to say *Loading*. `resolveNamespace`
|
|
47
|
-
* is handed the namespace it should merge, so a component pays for the words it
|
|
48
|
-
* speaks and no others.
|
|
49
|
-
*
|
|
50
|
-
* The public surface is `registerMPMessages`, `MPLocaleProvider` and the
|
|
51
|
-
* per-component `labels` props; `resolveNamespace` and `fillMessage` stay
|
|
52
|
-
* internal.
|
|
53
|
-
*/
|
|
54
1
|
/**
|
|
55
2
|
* One namespace per component, rather than one flat list of keys.
|
|
56
3
|
*
|
package/dist/internal/i18n.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
import{remember as e}from"./remember.js";const t=new Map;export function registerMPMessages(...e){for(const o of e){t.set(o.locale.toLowerCase(),o.messages);for(const e of o.aliases??[])t.set(e.toLowerCase(),o.messages)}o.clear()}const o=new Map;export function resolveNamespace(s,n){const r=n?.trim()??"",a=`${s.name}\0${r}`,i=o.get(a);if(i)return i;const c=function(e){const t=e.toLowerCase().split(/[-_]/).filter(Boolean),o=t[0];if(!o)return[];const s=t.slice(1),n=s.find(e=>/^[a-z]{4}$/.test(e)),r=s.find(e=>/^([a-z]{2}|\d{3})$/.test(e));return[n?`${o}-${n}`:"",r?`${o}-${r}`:"",o].filter(Boolean)}(r).map(e=>t.get(e)).find(Boolean),f=c?.[s.name],l=f?{...s.en,...f}:s.en;return e(o,a,l)}export function fillMessage(e,t){return e.replace(/\{(\w+)\}/g,(e,o)=>t[o]??e)}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One `IntersectionObserver` per set of options, shared by everything here that
|
|
3
|
+
* asks whether it is on screen.
|
|
4
|
+
*
|
|
5
|
+
* An observer is not free. Each one is checked by the browser on every frame
|
|
6
|
+
* the page scrolls, and every `MPAnimate*` with `trigger="visible"`, every
|
|
7
|
+
* `useMPOnScreen` and every indeterminate progress indicator used to bring its
|
|
8
|
+
* own — so a landing page of forty fading cards was forty observers asking the
|
|
9
|
+
* same question at the same threshold. One observer watching forty elements
|
|
10
|
+
* answers it once per frame, and delivers exactly the entries the forty would
|
|
11
|
+
* have: observing an element always queues a first entry for that element,
|
|
12
|
+
* shared observer or not.
|
|
13
|
+
*
|
|
14
|
+
* The one case sharing changes is a second question about an element that is
|
|
15
|
+
* already observed. Observing it again queues nothing, so the latest entry for
|
|
16
|
+
* each element is kept and handed to a listener that joins after the first one
|
|
17
|
+
* was delivered.
|
|
18
|
+
*
|
|
19
|
+
* Keyed on what changes the answer, the threshold and the root margin, so two
|
|
20
|
+
* callers that asked different questions still get different observers.
|
|
21
|
+
*/
|
|
22
|
+
import * as React from 'react';
|
|
23
|
+
type Listener = (entry: IntersectionObserverEntry) => void;
|
|
24
|
+
export interface IntersectionOptions {
|
|
25
|
+
threshold?: number;
|
|
26
|
+
rootMargin?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Calls `listener` with every intersection entry for `element`, starting with
|
|
30
|
+
* the first one the browser reports. Returns the function that stops it.
|
|
31
|
+
*
|
|
32
|
+
* Callers check for `IntersectionObserver` themselves first, because each has
|
|
33
|
+
* its own answer for a browser without one.
|
|
34
|
+
*/
|
|
35
|
+
export declare function watchIntersection(element: Element, listener: Listener, { threshold, rootMargin }?: IntersectionOptions): () => void;
|
|
36
|
+
/**
|
|
37
|
+
* Holds an endless CSS animation while its element is off screen.
|
|
38
|
+
*
|
|
39
|
+
* A loop nobody can see is still a loop the browser runs: a style pass every
|
|
40
|
+
* frame for the glow's custom property, and a layout pass for the linear
|
|
41
|
+
* indicator's bars, which move by `inset`. Marking the element lets the
|
|
42
|
+
* stylesheet set `animation-play-state: paused` on whatever part of it moves,
|
|
43
|
+
* and taking the mark off lets it carry on from where it stopped — which, for
|
|
44
|
+
* a loop, is indistinguishable from never having stopped.
|
|
45
|
+
*
|
|
46
|
+
* Written as an attribute straight onto the element rather than as state, so
|
|
47
|
+
* scrolling past one is not a render.
|
|
48
|
+
*/
|
|
49
|
+
export declare function useOffscreenPause(enabled: boolean): React.RefObject<Element | null>;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import*as e from"react";const t=new Map;export function watchIntersection(e,r,{threshold:n=0,rootMargin:s="0px"}={}){const o=`${n} ${s}`;let c=t.get(o);if(!c){const e=new Map,r=new Map;c={observer:new IntersectionObserver(t=>{for(const n of t){r.set(n.target,n);for(const t of e.get(n.target)??[])t(n)}},{threshold:n,rootMargin:s}),listeners:e,latest:r},t.set(o,c)}const{observer:i,listeners:f,latest:a}=c;let u=f.get(e),l=!1;if(u){const t=a.get(e);t&&queueMicrotask(()=>{l||r(t)})}else u=new Set,f.set(e,u),i.observe(e);return u.add(r),()=>{l||(l=!0,u.delete(r),u.size>0||(f.delete(e),a.delete(e),i.unobserve(e),0===f.size&&(i.disconnect(),t.delete(o))))}}const r="data-mp-offscreen";export function useOffscreenPause(t){const n=e.useRef(null);return e.useEffect(()=>{const e=n.current;if(!e||!t||"undefined"==typeof IntersectionObserver)return;const s=watchIntersection(e,t=>{e.toggleAttribute(r,!t.isIntersecting)});return()=>{s(),e.removeAttribute(r)}},[t]),n}
|
package/dist/internal/intl.d.ts
CHANGED
|
@@ -21,34 +21,35 @@
|
|
|
21
21
|
* Nothing here is exported from `src/index.ts`. It is the library talking to
|
|
22
22
|
* itself, in the sense `internal/` always means.
|
|
23
23
|
*/
|
|
24
|
+
export { CACHE_LIMIT, remember } from './remember.js';
|
|
24
25
|
/**
|
|
25
|
-
*
|
|
26
|
+
* A tag `Intl` will accept, from the tag a caller handed over.
|
|
26
27
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* shapes, a statistic for two, and every component on the page shares them; the
|
|
36
|
-
* limit is for the case nobody planned rather than the case everybody has.
|
|
28
|
+
* `Intl` throws a `RangeError` on a tag it cannot parse, and the tags that
|
|
29
|
+
* reach this library are not always tags: a request's `Accept-Language` passed
|
|
30
|
+
* straight through is `en-US,en;q=0.9`, and a locale read off a server is often
|
|
31
|
+
* `ko_KR`. The words in this library's table already take both — they match on
|
|
32
|
+
* the language whatever separates it — so a malformed tag wrote its labels in
|
|
33
|
+
* Korean and then took the whole render down at the first number. It is tidied
|
|
34
|
+
* the way a person would read it — the first of a list, without its weight,
|
|
35
|
+
* with hyphens — and a tag that still does not parse is the runtime's own.
|
|
37
36
|
*/
|
|
38
|
-
export declare
|
|
37
|
+
export declare function intlLocale(locale: string | undefined): string | undefined;
|
|
39
38
|
/**
|
|
40
|
-
*
|
|
39
|
+
* Says so, once per process, when a server formats a date, a number or an
|
|
40
|
+
* order with no locale named.
|
|
41
41
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
42
|
+
* `undefined` means the runtime's own locale, and a server and a browser are two
|
|
43
|
+
* runtimes: Node answers from the machine's `LANG` and the browser from the
|
|
44
|
+
* reader's language. The same value therefore comes out as `1,234.5` in the
|
|
45
|
+
* markup and `1.234,5` in the first client render, and React discards the
|
|
46
|
+
* server's markup — the whole page, without a Suspense boundary — and renders
|
|
47
|
+
* it again. Nothing about that failure points back here, so this does.
|
|
44
48
|
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* be rebuilt on the next call, which costs exactly what the miss it already was
|
|
48
|
-
* cost — and tracking use would mean writing to the map on every *read*, which
|
|
49
|
-
* is the hot path this whole thing exists to keep cheap.
|
|
49
|
+
* Only on a server, and only once. In a browser an unnamed locale is the
|
|
50
|
+
* reader's own and exactly what was asked for.
|
|
50
51
|
*/
|
|
51
|
-
export declare function
|
|
52
|
+
export declare function checkServerLocale(locale: string | undefined): void;
|
|
52
53
|
/** A memoised `Intl.NumberFormat`. `undefined` locale means the runtime's own. */
|
|
53
54
|
export declare const numberFormatter: (locale: string | undefined, options?: Intl.NumberFormatOptions | undefined) => Intl.NumberFormat;
|
|
54
55
|
/** A memoised `Intl.DateTimeFormat`. `undefined` locale means the runtime's own. */
|
package/dist/internal/intl.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{CACHE_LIMIT,remember}from"./remember.js";import{remember as e}from"./remember.js";function t(t){const r=new Map,n=new WeakMap;return(o,a)=>{const l=a?n.get(a)?.get(o??""):void 0;if(void 0!==l)return l;const i=function(e,t){return`${e??""}\0${t?JSON.stringify(t):""}`}(o,a),c=r.get(i)??e(r,i,t(o,a));if(a){const e=n.get(a)??new Map;e.set(o??"",c),n.set(a,e)}return c}}const r=new Map;export function intlLocale(t){if(void 0===t)return;if(r.has(t))return r.get(t);const n=t.split(",")[0].split(";")[0].trim().replace(/_/g,"-");let o;for(const e of[t,n])try{Intl.getCanonicalLocales(e),o=e;break}catch{}return e(r,t,o)}let n=!1;export function checkServerLocale(e){void 0!==e||n||"undefined"!=typeof window||(n=!0,console.warn("[material-plus-ui] A server formatted a date or a number with no locale, so a browser in another language will not match its markup while hydrating. Set `locale` or `serverLocale` on `MPLocaleProvider`: https://material-plus.cdget.com/design/localization#on-a-server"))}export const numberFormatter=/* @__PURE__ */t((e,t)=>(checkServerLocale(e),new Intl.NumberFormat(intlLocale(e),t)));export const dateTimeFormatter=/* @__PURE__ */t((e,t)=>(checkServerLocale(e),new Intl.DateTimeFormat(intlLocale(e),t)));export const segmenter=/* @__PURE__ */t((e,t)=>"undefined"!=typeof Intl&&"Segmenter"in Intl?new Intl.Segmenter(intlLocale(e),t):null);
|
package/dist/internal/keys.d.ts
CHANGED
|
@@ -18,15 +18,6 @@
|
|
|
18
18
|
*/
|
|
19
19
|
/** The three real platforms a shortcut is spelled for. */
|
|
20
20
|
export type MPResolvedOS = 'mac' | 'windows' | 'linux';
|
|
21
|
-
/**
|
|
22
|
-
* What the browser says it is running on.
|
|
23
|
-
*
|
|
24
|
-
* `userAgentData.platform` is the modern spelling and `navigator.platform` the
|
|
25
|
-
* deprecated one that every browser still answers; the user agent string is the
|
|
26
|
-
* last resort. All three are matched at once because the question is coarse —
|
|
27
|
-
* which of three key caps to print — and getting it slightly wrong is a label,
|
|
28
|
-
* not a bug.
|
|
29
|
-
*/
|
|
30
21
|
export declare function detectOS(): MPResolvedOS;
|
|
31
22
|
/**
|
|
32
23
|
* `useSyncExternalStore` rather than `useEffect` plus state, and rather than
|
package/dist/internal/keys.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import*as t from"react";export function detectOS(){
|
|
2
|
+
import*as t from"react";let e;export function detectOS(){return"undefined"==typeof navigator?"windows":(e??=function(){const t=navigator.userAgentData,e=`${t?.platform??""} ${navigator.platform??""} ${navigator.userAgent??""}`;if(/mac|iphone|ipad|ipod/i.test(e))return"mac";if(/win/i.test(e))return"windows";return"linux"}(),e)}function r(){return()=>{}}function n(){return"windows"}export function useDetectedOS(){return t.useSyncExternalStore(r,detectOS,n)}export function tokenizeShortcut(t){return Array.isArray(t)?t.map(t=>t.trim()).filter(Boolean):t.split("+").map(t=>t.trim()).filter(Boolean)}export function matchesShortcut(t,e,r){const n=tokenizeShortcut(e).map(t=>t.toLowerCase()),o=n[n.length-1];if(void 0===o)return!1;const a=new Set(n.slice(0,-1)),i=a.has("mod"),c=a.has("ctrl")||i&&"mac"!==r,s=a.has("meta")||i&&"mac"===r;return c===t.ctrlKey&&s===t.metaKey&&(a.has("shift")===t.shiftKey&&a.has("alt")===t.altKey&&t.key.toLowerCase()===o)}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* `useLayoutEffect` in a browser, and `useEffect` — which a server skips just
|
|
4
|
+
* the same, without React 18's warning that a layout effect does nothing there
|
|
5
|
+
* — everywhere else.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useBrowserLayoutEffect: typeof React.useEffect;
|
|
@@ -15,8 +15,16 @@
|
|
|
15
15
|
* `resolveNamespace` in `internal/i18n.ts`. The runtime's own locale differs
|
|
16
16
|
* between the server that renders the markup and the browser that hydrates it,
|
|
17
17
|
* so reading it would put a hydration mismatch in the one part of the page a
|
|
18
|
-
* reader is looking at.
|
|
19
|
-
*
|
|
18
|
+
* reader is looking at.
|
|
19
|
+
*
|
|
20
|
+
* `undefined` means "the platform's default", and that is safe for the words
|
|
21
|
+
* and not for the numbers. The words fall back to English on both sides. `Intl`
|
|
22
|
+
* does not: handed `undefined` it answers in the *runtime's* locale, which is the
|
|
23
|
+
* machine's `LANG` on a server and the reader's language in a browser — so a
|
|
24
|
+
* server-rendered page that names no locale writes `1,234.5` into its markup and
|
|
25
|
+
* `1.234,5` into its first client render. `checkServerLocale` in
|
|
26
|
+
* `internal/intl.ts` says so when it happens; `MPLocaleProvider`'s `serverLocale`
|
|
27
|
+
* is the way out for a page that cannot know its reader's language on the server.
|
|
20
28
|
*/
|
|
21
29
|
import * as React from 'react';
|
|
22
30
|
import { type MPMessages, type MPNamespace } from './i18n.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mediaList(query: string): MediaQueryList | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=new Map;export function mediaList(n){if("undefined"==typeof window||!window.matchMedia)return null;let t=e.get(n);return t||(t=window.matchMedia(n),e.set(n,t)),t}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A key for each entry of a caller's list: its value, and which occurrence of
|
|
3
|
+
* that value it is.
|
|
4
|
+
*
|
|
5
|
+
* The lists here are keyed so a value the caller repeated cannot collide —
|
|
6
|
+
* `${index}:${value}` did that, and also changed every key after the first row
|
|
7
|
+
* a filter dropped, so typing one letter into a long list unmounted and
|
|
8
|
+
* remounted every row below the first one it hid. Counting occurrences instead
|
|
9
|
+
* keeps a row's key for as long as the row is there: the first `"Seoul"` is
|
|
10
|
+
* `0:Seoul` wherever it lands in the filtered list, and a second one is
|
|
11
|
+
* `1:Seoul`. The count comes first, and has no colon in it, so no value can
|
|
12
|
+
* spell another's key.
|
|
13
|
+
*
|
|
14
|
+
* Keyed by the entry object, so a list that is filtered and drawn somewhere
|
|
15
|
+
* else — Base UI hands a combobox's rows back one at a time — can still look
|
|
16
|
+
* each one up.
|
|
17
|
+
*/
|
|
18
|
+
export declare function occurrenceKeys<Entry>(entries: readonly Entry[], valueOf: (entry: Entry) => unknown): Map<Entry, string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function occurrenceKeys(e,n){const t=new Map,o=new Map;for(const c of e){const e=String(n(c)),r=t.get(e)??0;t.set(e,r+1),o.set(c,`${r}:${e}`)}return o}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import*as e from"react";import{HIDDEN_BELOW as
|
|
2
|
+
import*as e from"react";import{mediaList as t}from"./media.js";import{HIDDEN_BELOW as n,HIDDEN_FROM as r}from"./visibility.js";import{below as o,useWindowMins as a}from"./window-class.js";import{ELEVATION_SURFACE as i}from"./elevation.js";export const MPPageLayoutContext=/*@__PURE__*/e.createContext({present:!1,register:()=>{},collapseBelow:"none",open:{start:!1,end:!1},setOpen:()=>{},scroll:"page"});export const MPSidebarSideContext=/*@__PURE__*/e.createContext(null);export const COLLAPSED_ONLY={none:"hidden",compact:r.compact,medium:r.medium,expanded:r.expanded,large:r.large,"extra-large":r["extra-large"]};export const EXPANDED_ONLY={none:"",compact:n.compact,medium:n.medium,expanded:n.expanded,large:n.large,"extra-large":n["extra-large"]};export function useMPCollapsed(n){const r=a(),i=o("none"===n?0:r[n]),d=e.useCallback(e=>{if(!i||"undefined"==typeof window||!window.matchMedia)return()=>{};const n=t(i);return n?.addEventListener("change",e),()=>n?.removeEventListener("change",e)},[i]),c=e.useCallback(()=>!(!i||"undefined"==typeof window||!window.matchMedia)&&(t(i)?.matches??!1),[i]);return e.useSyncExternalStore(d,c,()=>!1)}export function drawerSide(e){const t="undefined"!=typeof document&&"rtl"===document.documentElement.dir;return"start"===e?t?"right":"left":t?"left":"right"}export const BAR_SURFACE={filled:"bg-mp-surface-container-highest",tonal:"bg-mp-surface-container",elevated:"shadow-mp-2 bg-mp-surface-container-low",outlined:"bg-mp-surface",text:"bg-transparent"};export function barSurface(e,t){return void 0===t?BAR_SURFACE[e]:i[t]}
|
|
@@ -70,6 +70,11 @@ export interface MPProgressProps {
|
|
|
70
70
|
* range nobody described.
|
|
71
71
|
*/
|
|
72
72
|
format?: Intl.NumberFormatOptions;
|
|
73
|
+
/**
|
|
74
|
+
* The locale `format` writes the value in. Defaults to the nearest
|
|
75
|
+
* `MPLocaleProvider`, then to the runtime's own.
|
|
76
|
+
*/
|
|
77
|
+
locale?: string;
|
|
73
78
|
className?: string;
|
|
74
79
|
style?: React.CSSProperties;
|
|
75
80
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* One callback ref that hands the node to several refs, for a component that
|
|
4
|
+
* needs its own handle on an element a caller also holds a ref to.
|
|
5
|
+
*
|
|
6
|
+
* Memoised on the refs, so the callback is stable for as long as they are and
|
|
7
|
+
* React does not detach and reattach it on every render.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useJoinedRef<Node>(...refs: (React.Ref<Node> | undefined)[]): React.RefCallback<Node>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as o from"react";export function useJoinedRef(...e){return o.useCallback(o=>{for(const r of e)"function"==typeof r?r(o):r&&(r.current=o)},e)}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The size limit the library's caches share, kept apart from the caches.
|
|
3
|
+
*
|
|
4
|
+
* `internal/intl.ts` builds its formatter caches as it loads, and a bundler
|
|
5
|
+
* cannot drop that, so importing the limit from there brought every formatter
|
|
6
|
+
* cache along. `internal/i18n.ts` is read by every component with a word to
|
|
7
|
+
* say, which put them in a bundle holding nothing but a button.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* How many entries a cache in this library holds before it starts forgetting.
|
|
11
|
+
*
|
|
12
|
+
* The caches are keyed on a locale and an options object, and the options are a
|
|
13
|
+
* caller's prop — so how many distinct keys there are is not something this file
|
|
14
|
+
* gets to decide. A table formatting a number per row against a per-row format
|
|
15
|
+
* would add an `Intl.NumberFormat` to a `Map` that never dropped one, for as
|
|
16
|
+
* long as the page was open. Nothing has ever reported that, and a cache with no
|
|
17
|
+
* ceiling is still a leak with a slow fuse.
|
|
18
|
+
*
|
|
19
|
+
* Sixty-four is far above what a page uses. A chart asks for two or three
|
|
20
|
+
* shapes, a statistic for two, and every component on the page shares them; the
|
|
21
|
+
* limit is for the case nobody planned rather than the case everybody has.
|
|
22
|
+
*/
|
|
23
|
+
export declare const CACHE_LIMIT = 64;
|
|
24
|
+
/**
|
|
25
|
+
* Puts an entry in, and drops the oldest if that took the map over the line.
|
|
26
|
+
*
|
|
27
|
+
* A `Map` iterates in insertion order, so its first key is its oldest — which
|
|
28
|
+
* makes the eviction one delete rather than a data structure.
|
|
29
|
+
*
|
|
30
|
+
* Not a true LRU: reading an entry does not renew it, so a formatter used on
|
|
31
|
+
* every render could in principle be evicted by sixty-four newer ones. It would
|
|
32
|
+
* be rebuilt on the next call, which costs exactly what the miss it already was
|
|
33
|
+
* cost — and tracking use would mean writing to the map on every *read*, which
|
|
34
|
+
* is the hot path this whole thing exists to keep cheap.
|
|
35
|
+
*/
|
|
36
|
+
export declare function remember<Value>(cache: Map<string, Value>, key: string, value: Value): Value;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const CACHE_LIMIT=64;export function remember(e,t,n){if(e.set(t,n),e.size>64){const t=e.keys().next();t.done||e.delete(t.value)}return n}
|
|
@@ -36,8 +36,14 @@ export declare const PORTAL_LAYER = "mp-portal z-50 outline-none";
|
|
|
36
36
|
* The 2px blur is not a frost. It is enough to take the edge off text directly
|
|
37
37
|
* under the sheet without turning the page into a smear, which is the difference
|
|
38
38
|
* between "you cannot use this right now" and "this is gone".
|
|
39
|
+
*
|
|
40
|
+
* It is also the one part of a scrim with a cost. A backdrop filter re-blurs the
|
|
41
|
+
* whole window behind it on every frame the scrim fades and on every frame
|
|
42
|
+
* anything under it changes, and on a low-end phone that is a frame budget.
|
|
43
|
+
* `--mp-scrim-blur` is the knob: `0px` on the page, or under
|
|
44
|
+
* `prefers-reduced-transparency`, keeps the tint and drops the filter.
|
|
39
45
|
*/
|
|
40
|
-
export declare const SCRIM = "bg-mp-scrim/32 [backdrop-filter:blur(2px)]";
|
|
46
|
+
export declare const SCRIM = "bg-mp-scrim/32 [backdrop-filter:blur(var(--mp-scrim-blur,2px))]";
|
|
41
47
|
/**
|
|
42
48
|
* Opacity, and only opacity — what a **popup** arrives on.
|
|
43
49
|
*
|
package/dist/internal/surface.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PORTAL_LAYER="mp-portal z-50 outline-none";export const SCRIM="bg-mp-scrim/32 [backdrop-filter:blur(2px)]";export const FADE=/*@__PURE__*/["transition-opacity duration-(--mp-sys-motion-duration-short4)","ease-mp-standard","data-starting-style:opacity-0 data-ending-style:opacity-0"].join(" ");export const SHEET_MOTION=/*@__PURE__*/["duration-(--mp-sys-motion-duration-medium4)","ease-(--mp-sys-motion-easing-emphasized-decelerate)","data-ending-style:duration-(--mp-sys-motion-duration-short4)","data-ending-style:ease-(--mp-sys-motion-easing-emphasized-accelerate)","data-starting-style:opacity-0 data-ending-style:opacity-0"].join(" ");export const CONTAINER_SURFACE={filled:"bg-mp-surface-container-highest",tonal:"bg-mp-surface-container",elevated:"shadow-mp-1 bg-mp-surface-container-low",outlined:"border-mp-outline-variant border bg-transparent",text:"bg-transparent"};
|
|
1
|
+
export const PORTAL_LAYER="mp-portal z-50 outline-none";export const SCRIM="bg-mp-scrim/32 [backdrop-filter:blur(var(--mp-scrim-blur,2px))]";export const FADE=/*@__PURE__*/["transition-opacity duration-(--mp-sys-motion-duration-short4)","ease-mp-standard","data-starting-style:opacity-0 data-ending-style:opacity-0"].join(" ");export const SHEET_MOTION=/*@__PURE__*/["duration-(--mp-sys-motion-duration-medium4)","ease-(--mp-sys-motion-easing-emphasized-decelerate)","data-ending-style:duration-(--mp-sys-motion-duration-short4)","data-ending-style:ease-(--mp-sys-motion-easing-emphasized-accelerate)","data-starting-style:opacity-0 data-ending-style:opacity-0"].join(" ");export const CONTAINER_SURFACE={filled:"bg-mp-surface-container-highest",tonal:"bg-mp-surface-container",elevated:"shadow-mp-1 bg-mp-surface-container-low",outlined:"border-mp-outline-variant border bg-transparent",text:"bg-transparent"};
|