neba 1.17.0 → 1.18.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/dist/a2ui/adapter-catalog.json +1 -1
- package/dist/a2ui/catalog.json +2 -2
- package/dist/a2ui/index.d.ts +2 -0
- package/dist/a2ui/schema.d.ts +11 -1
- package/dist/a2ui/schema.js +1 -1
- package/dist/components/alert/Alert.js +1 -1
- package/dist/components/animate-counter/AnimateCounter.d.ts +6 -0
- package/dist/components/animate-counter/AnimateCounter.js +1 -1
- package/dist/components/animate-headline/AnimateHeadline.js +1 -1
- package/dist/components/animate-scramble/AnimateScramble.d.ts +9 -3
- package/dist/components/animate-scramble/AnimateScramble.js +1 -1
- package/dist/components/animate-split/AnimateSplit.d.ts +7 -1
- package/dist/components/animate-split/AnimateSplit.js +1 -1
- package/dist/components/animate-typing/AnimateTyping.d.ts +6 -0
- package/dist/components/animate-typing/AnimateTyping.js +1 -1
- package/dist/components/app-logo/AppLogo.js +1 -1
- package/dist/components/approval/Approval.js +1 -1
- package/dist/components/breadcrumb/Breadcrumb.d.ts +16 -0
- package/dist/components/breadcrumb/Breadcrumb.js +1 -1
- package/dist/components/calendar/Calendar.js +1 -1
- package/dist/components/card/Card.js +1 -1
- package/dist/components/carousel/Carousel.d.ts +3 -2
- package/dist/components/carousel/Carousel.js +1 -1
- package/dist/components/chat-bubble/ChatBubble.d.ts +6 -0
- package/dist/components/chat-bubble/ChatBubble.js +1 -1
- package/dist/components/code-block/CodeBlock.d.ts +2 -2
- package/dist/components/code-block/CodeBlock.js +1 -1
- package/dist/components/code-block/index.d.ts +2 -1
- package/dist/components/code-block/index.js +1 -1
- package/dist/components/color-picker/ColorPicker.js +1 -1
- package/dist/components/combobox/Combobox.js +1 -1
- package/dist/components/context-window/ContextWindow.js +1 -1
- package/dist/components/data-table/DataTable.d.ts +13 -1
- package/dist/components/data-table/DataTable.js +1 -1
- package/dist/components/date-picker/DatePicker.js +1 -1
- package/dist/components/date-range-picker/DateRangePicker.js +1 -1
- package/dist/components/date-time-picker/DateTimePicker.js +1 -1
- package/dist/components/drawer/Drawer.d.ts +21 -0
- package/dist/components/drawer/Drawer.js +1 -1
- package/dist/components/empty/Empty.js +1 -1
- package/dist/components/file-picker/FilePicker.d.ts +0 -8
- package/dist/components/file-picker/FilePicker.js +1 -1
- package/dist/components/file-picker/formatFileSize.d.ts +8 -0
- package/dist/components/file-picker/formatFileSize.js +1 -0
- package/dist/components/file-picker/index.d.ts +2 -1
- package/dist/components/file-picker/index.js +1 -1
- package/dist/components/floating-bottom-navigation/FloatingBottomNavigation.js +1 -1
- package/dist/components/gallery/Gallery.d.ts +45 -3
- package/dist/components/gallery/Gallery.js +1 -1
- package/dist/components/gallery/GalleryViewer.js +1 -1
- package/dist/components/gauge-chart/GaugeChart.js +1 -1
- package/dist/components/heatmap-chart/HeatmapChart.js +1 -1
- package/dist/components/how-to-steps/HowToSteps.d.ts +14 -0
- package/dist/components/how-to-steps/HowToSteps.js +1 -1
- package/dist/components/image/Image.d.ts +31 -6
- package/dist/components/image/Image.js +1 -1
- package/dist/components/menu/Menu.d.ts +17 -0
- package/dist/components/menu/Menu.js +1 -1
- package/dist/components/meter/Meter.js +1 -1
- package/dist/components/mockup/Mockup.js +1 -1
- package/dist/components/number-field/NumberField.js +1 -1
- package/dist/components/page-layout/PageLayout.js +1 -1
- package/dist/components/panes/Panes.js +1 -1
- package/dist/components/pie-chart/PieChart.js +1 -1
- package/dist/components/pill/Pill.js +1 -1
- package/dist/components/progress-box/ProgressBox.js +1 -1
- package/dist/components/progress-circular/ProgressCircular.js +1 -1
- package/dist/components/progress-linear/ProgressLinear.js +1 -1
- package/dist/components/prompt-input/PromptInput.js +1 -1
- package/dist/components/provider/NebaProvider.d.ts +0 -20
- package/dist/components/provider/NebaProvider.js +1 -1
- package/dist/components/provider/colorSchemeScript.d.ts +23 -0
- package/dist/components/provider/colorSchemeScript.js +1 -0
- package/dist/components/provider/index.d.ts +2 -1
- package/dist/components/provider/index.js +1 -1
- package/dist/components/reasoning/Reasoning.d.ts +21 -0
- package/dist/components/reasoning/Reasoning.js +1 -1
- package/dist/components/scatter-chart/ScatterChart.js +1 -1
- package/dist/components/scroll-zone/ScrollZone.js +1 -1
- package/dist/components/segmented-button/SegmentedButton.js +1 -1
- package/dist/components/select/Select.js +1 -1
- package/dist/components/sidebar/Sidebar.d.ts +13 -0
- package/dist/components/sidebar/Sidebar.js +1 -1
- package/dist/components/slider/Slider.js +1 -1
- package/dist/components/sources/Sources.d.ts +11 -0
- package/dist/components/sources/Sources.js +1 -1
- package/dist/components/spoiler/Spoiler.js +1 -1
- package/dist/components/statistic/Statistic.js +1 -1
- package/dist/components/streaming-text/StreamingText.d.ts +22 -11
- package/dist/components/streaming-text/StreamingText.js +1 -1
- package/dist/components/tabs/Tabs.d.ts +12 -1
- package/dist/components/tabs/Tabs.js +1 -1
- package/dist/components/text-link/TextLink.d.ts +7 -0
- package/dist/components/text-link/TextLink.js +1 -1
- package/dist/components/time-picker/TimePicker.js +1 -1
- package/dist/components/timeline-chart/TimelineChart.js +1 -1
- package/dist/components/toast/Toast.js +1 -1
- package/dist/components/tool-call/ToolCall.d.ts +11 -0
- package/dist/components/tool-call/ToolCall.js +1 -1
- package/dist/components/tour/Tour.js +1 -1
- package/dist/components/tree-view/TreeView.d.ts +13 -1
- package/dist/components/tree-view/TreeView.js +1 -1
- package/dist/components/typography/Typography.d.ts +7 -0
- package/dist/components/typography/Typography.js +1 -1
- package/dist/components/window-pane/WindowPane.js +1 -1
- package/dist/hooks/useElementSize.js +1 -1
- package/dist/internal/animate.js +1 -1
- package/dist/internal/calendar.d.ts +2 -2
- package/dist/internal/calendar.js +1 -1
- package/dist/internal/chart-frame.d.ts +59 -2
- package/dist/internal/chart-frame.js +1 -1
- package/dist/internal/chart-line.js +1 -1
- package/dist/internal/format.d.ts +7 -0
- package/dist/internal/format.js +1 -1
- package/dist/internal/highlight.d.ts +9 -0
- package/dist/internal/highlight.js +1 -1
- package/dist/internal/layout-effect.d.ts +17 -0
- package/dist/internal/layout-effect.js +1 -0
- package/dist/internal/media.d.ts +20 -0
- package/dist/internal/media.js +1 -1
- package/dist/internal/menu.d.ts +5 -0
- package/dist/internal/new-tab.d.ts +3 -1
- package/dist/internal/new-tab.js +1 -1
- package/dist/internal/observe.d.ts +4 -1
- package/dist/internal/observe.js +1 -1
- package/dist/internal/overrides.d.ts +55 -0
- package/dist/internal/overrides.js +1 -0
- package/dist/internal/page-layout.d.ts +26 -1
- package/dist/internal/page-layout.js +1 -1
- package/dist/internal/run.d.ts +6 -1
- package/dist/internal/run.js +1 -1
- package/dist/internal/sizer.d.ts +10 -0
- package/dist/internal/sizer.js +1 -1
- package/dist/internal/styles.d.ts +28 -2
- package/dist/internal/styles.js +1 -1
- package/dist/internal/text.d.ts +25 -3
- package/dist/internal/text.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +91 -72
- package/package.json +2 -2
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which properties a caller's `className` sets, read off Tailwind's own names.
|
|
3
|
+
*
|
|
4
|
+
* Typography and TextLink write their defaults at two-class strength, through
|
|
5
|
+
* `[&.neba-typography]` and `[&.neba-link]`, because the tags they render are
|
|
6
|
+
* the ones a host stylesheet styles by name: `.prose h2` and `.vp-doc a` are a
|
|
7
|
+
* class plus a tag, which a one-class utility cannot outrank. A caller's own
|
|
8
|
+
* utility is one class too, so the guard that held off the host held off the
|
|
9
|
+
* caller as well — `className="mb-8"` on a Typography came out with no margin
|
|
10
|
+
* and nothing said why. No specificity sits above the host's rule and below a
|
|
11
|
+
* plain utility, so the cascade cannot settle it; the component has to know
|
|
12
|
+
* what the caller asked for.
|
|
13
|
+
*
|
|
14
|
+
* So it asks this, once per render. A property the caller's classes set leaves
|
|
15
|
+
* the guard, and the component states its default through `[:where(&)]`
|
|
16
|
+
* instead, at zero specificity: any utility the caller wrote beats it, under
|
|
17
|
+
* any variant, and it is still there below a class that only applies at a
|
|
18
|
+
* breakpoint or on hover. What the caller gives up is the guard against the
|
|
19
|
+
* host for that one property, and that is a fight the caller's class is in on
|
|
20
|
+
* any other element too.
|
|
21
|
+
*
|
|
22
|
+
* Two rules decide what counts:
|
|
23
|
+
*
|
|
24
|
+
* - **A class it cannot place counts as everything it might set.** `text-brand`
|
|
25
|
+
* is a colour in one theme and a size in another, and the stylesheet that
|
|
26
|
+
* would say which is not something a render can read. Counting a property
|
|
27
|
+
* wrongly costs one element its guard against a host stylesheet; missing one
|
|
28
|
+
* is the silent loss this module exists to end.
|
|
29
|
+
* - **An important class does not count.** `mb-8!` wins already, and keeping the
|
|
30
|
+
* guard under it is what leaves a call site written with `!` exactly as it
|
|
31
|
+
* was.
|
|
32
|
+
*
|
|
33
|
+
* It reads Tailwind's names and nothing else. A class from the caller's own
|
|
34
|
+
* stylesheet, `.hero-title`, is invisible to it and still needs two classes or
|
|
35
|
+
* `!important` to beat the guard.
|
|
36
|
+
*/
|
|
37
|
+
export declare const MARGIN_TOP = 1;
|
|
38
|
+
export declare const MARGIN_BOTTOM = 2;
|
|
39
|
+
export declare const FONT_SIZE = 4;
|
|
40
|
+
export declare const LINE_HEIGHT = 8;
|
|
41
|
+
export declare const LETTER_SPACING = 16;
|
|
42
|
+
export declare const FONT_WEIGHT = 32;
|
|
43
|
+
export declare const COLOR = 64;
|
|
44
|
+
export declare const TEXT_DECORATION_LINE = 128;
|
|
45
|
+
export declare const TEXT_DECORATION_THICKNESS = 256;
|
|
46
|
+
export declare const TEXT_DECORATION_COLOR = 512;
|
|
47
|
+
export declare const TEXT_UNDERLINE_OFFSET = 1024;
|
|
48
|
+
export declare const TEXT_UNDERLINE_POSITION = 2048;
|
|
49
|
+
/**
|
|
50
|
+
* The properties `className` sets, as the flags above.
|
|
51
|
+
*
|
|
52
|
+
* Variants are read past rather than weighed: `md:mb-4` and `hover:text-red-500`
|
|
53
|
+
* count, since the default beneath them is the floor, not the guard.
|
|
54
|
+
*/
|
|
55
|
+
export declare function overriddenBy(className: string | undefined): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const MARGIN_TOP=1;export const MARGIN_BOTTOM=2;export const FONT_SIZE=4;export const LINE_HEIGHT=8;export const LETTER_SPACING=16;export const FONT_WEIGHT=32;export const COLOR=64;export const TEXT_DECORATION_LINE=128;export const TEXT_DECORATION_THICKNESS=256;export const TEXT_DECORATION_COLOR=512;export const TEXT_UNDERLINE_OFFSET=1024;export const TEXT_UNDERLINE_POSITION=2048;const t=/^(xs|sm|base|lg|[2-9]?xl)$/,e=/^(left|center|right|justify|start|end|wrap|nowrap|balance|pretty|ellipsis|clip)$|^shadow(-|$)/,s=/^(inherit|current|transparent|black|white)$|-\d+$/,n=/^(\d+|from-font|auto)$/,o=/^(sans|serif|mono)$|^(stretch|features)-|^[[(]family:/,r={margin:3,"margin-block":3,"margin-top":1,"margin-block-start":1,"margin-bottom":2,"margin-block-end":2,font:44,"font-size":4,"line-height":8,"letter-spacing":16,"font-weight":32,color:64,"text-decoration":896,"text-decoration-line":128,"text-decoration-thickness":256,"text-decoration-color":512,"text-underline-offset":1024,"text-underline-position":2048};function i(t,e){let s=0,n=-1;for(let o=0;o<t.length;o+=1){const r=t[o];"["===r||"("===r?s+=1:"]"===r||")"===r?s-=1:r===e&&0===s&&(n=o)}return n}function c(t,e,s){const n=t.slice(1,-1);return/^(length|percentage|absolute-size|relative-size):/.test(n)?e:n.startsWith("color:")||t.startsWith("(")?s:/^([\d.]|(calc|clamp|min|max)\()/.test(n)?e:/^[a-z-]+$/.test(n)?e|s:s}function a(a){const l=a.startsWith("-")?a.slice(1):a;if(l.startsWith("[")&&l.endsWith("]"))return r[l.slice(1,l.indexOf(":"))]??0;const h=/^m(bs|be|[tby])?-/.exec(l);if(h){const t=h[1];return"t"===t||"bs"===t?1:"b"===t||"be"===t?2:3}return l.startsWith("text-")?function(n){const o=i(n,"/"),r=-1===o?n:n.slice(0,o),a=4|(-1===o?0:8);return e.test(r)?0:t.test(r)?a:s.test(r)?64:r.startsWith("[")||r.startsWith("(")?c(r,a,64):64|a}(l.slice(5)):l.startsWith("font-")?o.test(l.slice(5))?0:32:l.startsWith("leading-")?8:l.startsWith("tracking-")?16:l.startsWith("decoration-")?function(t){const e=i(t,"/"),o=-1===e?t:t.slice(0,e);return/^(solid|double|dotted|dashed|wavy)$/.test(o)?0:n.test(o)?256:s.test(o)?512:o.startsWith("[")||o.startsWith("(")?c(o,256,512):768}(l.slice(11)):l.startsWith("underline-offset-")?1024:/^(underline|overline|line-through|no-underline)$/.test(l)?128:0}export function overriddenBy(t){let e=0;for(const s of t?t.split(/\s+/):[]){const t=s.slice(i(s,":")+1);!t||t.startsWith("!")||t.endsWith("!")||(e|=a(t))}return e}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { NebaBreakpoint, NebaSide } from '../types.js';
|
|
2
|
+
import type { NebaBreakpoint, NebaSide, NebaSize } from '../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* The vocabulary a page's structure is written in, and the context the four
|
|
5
5
|
* components that build one share.
|
|
@@ -105,6 +105,31 @@ export declare const PageLayoutSlotContext: React.Context<PageLayoutSlot | null>
|
|
|
105
105
|
* "nobody said", which a standalone sidebar reads as `start`.
|
|
106
106
|
*/
|
|
107
107
|
export declare const SidebarSideContext: React.Context<SidebarSide | null>;
|
|
108
|
+
/**
|
|
109
|
+
* A Header's floor at each size, in steps of Tailwind's spacing scale.
|
|
110
|
+
*
|
|
111
|
+
* The same numbers as Header's `barMinHeightClasses`, which have to stay
|
|
112
|
+
* literal class names for Tailwind to find them, so the two are kept in step by
|
|
113
|
+
* hand and `Header.test.tsx` holds them there. They are here because the layout
|
|
114
|
+
* needs them as a length, for the reason `headerFloor` gives.
|
|
115
|
+
*/
|
|
116
|
+
export declare const headerFloorSteps: Record<NebaSize, number>;
|
|
117
|
+
/**
|
|
118
|
+
* How much a `fixed` header takes off the top of the page before anybody has
|
|
119
|
+
* measured it, or `undefined` when the header is not one.
|
|
120
|
+
*
|
|
121
|
+
* The measured height reaches the page from an effect, which on a page the
|
|
122
|
+
* server rendered is after the first paint, so everything under a fixed header
|
|
123
|
+
* would be drawn behind it and then drop by its height. A Header's height is
|
|
124
|
+
* its floor unless what is in it is taller, and the floor follows from three of
|
|
125
|
+
* its props — so the layout reads them off the element it was handed, as a
|
|
126
|
+
* Panes reads its panes' sizes, and reserves that much from the first render.
|
|
127
|
+
* The measurement then only corrects a bar that came out taller.
|
|
128
|
+
*
|
|
129
|
+
* A header wrapped in a component of the caller's own has props this cannot
|
|
130
|
+
* read, and has its room reserved only once it has been measured.
|
|
131
|
+
*/
|
|
132
|
+
export declare function headerFloor(header: React.ReactNode, providedSize: NebaSize | undefined): string | undefined;
|
|
108
133
|
/**
|
|
109
134
|
* The five widths as Tailwind variants, for the parts of this that are
|
|
110
135
|
* decided in CSS rather than in JavaScript.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import*as e from"react";import{useMediaQuery as t,widthBelow as o}from"./media.js";import{hiddenBelowClasses as n,hiddenFromClasses as r}from"./responsive.js";export const PageLayoutContext=/*@__PURE__*/e.createContext({present:!1,register:()=>{},collapseBelow:"none",open:{start:!1,end:!1},setOpen:()=>{},scroll:"page"});export const PageLayoutSlotContext=/*@__PURE__*/e.createContext(null);export const SidebarSideContext=/*@__PURE__*/e.createContext(null);export const collapsedOnlyClasses={none:"hidden",...r};export const expandedOnlyClasses={none:"",...n};export function useCollapsed(e){return t("none"===e?null:o(e))}export function drawerSide(e){const t="undefined"!=typeof document&&"rtl"===getComputedStyle(document.documentElement).direction;return"start"===e?t?"right":"left":t?"left":"right"}
|
|
1
|
+
"use client";import*as e from"react";import{useMediaQuery as t,widthBelow as o}from"./media.js";import{hiddenBelowClasses as n,hiddenFromClasses as r}from"./responsive.js";export const PageLayoutContext=/*@__PURE__*/e.createContext({present:!1,register:()=>{},collapseBelow:"none",open:{start:!1,end:!1},setOpen:()=>{},scroll:"page"});export const PageLayoutSlotContext=/*@__PURE__*/e.createContext(null);export const SidebarSideContext=/*@__PURE__*/e.createContext(null);export const headerFloorSteps={xs:10,sm:12,md:14,lg:16,xl:20};export function headerFloor(t,o){if(!e.isValidElement(t)||"fixed"!==t.props.position)return;const n=headerFloorSteps[t.props.size??o??"md"]??headerFloorSteps.md;return!1===t.props.divider?`calc(var(--spacing) * ${n})`:`calc(var(--spacing) * ${n} + 1px)`}export const collapsedOnlyClasses={none:"hidden",...r};export const expandedOnlyClasses={none:"",...n};export function useCollapsed(e){return t("none"===e?null:o(e))}export function drawerSide(e){const t="undefined"!=typeof document&&"rtl"===getComputedStyle(document.documentElement).direction;return"start"===e?t?"right":"left":t?"left":"right"}
|
package/dist/internal/run.d.ts
CHANGED
|
@@ -40,13 +40,18 @@ export declare function runIcon(status: NebaRunStatus): React.ReactElement;
|
|
|
40
40
|
*/
|
|
41
41
|
export declare function runColor(status: NebaRunStatus, color: NebaColor): NebaColor;
|
|
42
42
|
/**
|
|
43
|
-
* A length of time, in the
|
|
43
|
+
* A length of time, in the language of the sentence around it.
|
|
44
44
|
*
|
|
45
45
|
* `Intl` knows the words, so none of this is in `i18n.ts`: what it decides is
|
|
46
46
|
* only the unit and how many digits are worth printing. Under a second the
|
|
47
47
|
* number is milliseconds, because "0.3s" is a measurement written in the wrong
|
|
48
48
|
* unit; over it, seconds, to one decimal place for the first ten and then to
|
|
49
49
|
* none — a step that ran for four minutes is not more informative at 247.3.
|
|
50
|
+
*
|
|
51
|
+
* With no `locale` it is English, because that is what the library's own words
|
|
52
|
+
* fall back to and a duration is printed inside them: left to the runtime, a
|
|
53
|
+
* Korean browser wrote "Thought for 2.4초". It also means the server and the
|
|
54
|
+
* browser can never disagree about it.
|
|
50
55
|
*/
|
|
51
56
|
export declare function formatDuration(ms: number, locale?: string): string;
|
|
52
57
|
/**
|
package/dist/internal/run.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as r}from"react/jsx-runtime";import*as t from"react";import{CircleIcon as
|
|
1
|
+
"use client";import{jsx as r}from"react/jsx-runtime";import*as t from"react";import{useLayoutEffectOnClient as e}from"./layout-effect.js";import{CircleIcon as n,DangerIcon as u,SpinnerIcon as o,SuccessIcon as s}from"./icons.js";import{numberFormatter as i}from"./format.js";export function runIcon(t){switch(t){case"running":return r(o,{});case"success":return r(s,{});case"error":return r(u,{});default:return r(n,{})}}export function runColor(r,t){switch(r){case"success":return"success";case"error":return"danger";case"pending":return"secondary";default:return t}}export function formatDuration(r,t){if(!Number.isFinite(r)||r<0)return"";const e=t??"en";if(r<1e3)return i(e,{style:"unit",unit:"millisecond",unitDisplay:"narrow",maximumFractionDigits:0}).format(Math.round(r));const n=r/1e3;return i(e,{style:"unit",unit:"second",unitDisplay:"narrow",maximumFractionDigits:n<10?1:0}).format(n)}export function useElapsed(r,n){const u=r&&void 0===n,[o,s]=t.useState(null),[i,c]=t.useState(u);i!==u&&(c(u),u&&s(null));const a=t.useRef(null);return e(()=>{if(!u)return;const r=Date.now(),t=setInterval(()=>s(Date.now()-r),1e3);return()=>{clearInterval(t),a.current=Date.now()-r}},[u]),e(()=>{u||null===a.current||(s(a.current),a.current=null)},[u]),n??o}
|
package/dist/internal/sizer.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import type * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The samples a `WidthSizer` needs, out of all of them.
|
|
4
|
+
*
|
|
5
|
+
* Only the widest sample decides the width, so a Select with two hundred and
|
|
6
|
+
* fifty countries was two hundred and fifty boxes laid out for the sake of one.
|
|
7
|
+
* A string is kept when it is long enough to be the widest and dropped
|
|
8
|
+
* otherwise. Anything that is not a string is kept whatever it is, since
|
|
9
|
+
* nothing short of laying it out says how wide a node is.
|
|
10
|
+
*/
|
|
11
|
+
export declare function widestSamples(samples: readonly React.ReactNode[]): React.ReactNode[];
|
|
2
12
|
/**
|
|
3
13
|
* Holds a control open at the width of the widest thing it could ever say.
|
|
4
14
|
*
|
package/dist/internal/sizer.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";export function WidthSizer({samples:
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";const t=/[\u1100-\u115f\u2e80-\ua4cf\uac00-\ud7a3\uf900-\ufaff\ufe30-\ufe4f\uff00-\uff60\uffe0-\uffe6]/g;function a(e){return e.length+(e.match(t)?.length??0)}export function widestSamples(e){let t=0;for(const n of e)"string"==typeof n&&(t=Math.max(t,a(n)));return e.filter(e=>"string"!=typeof e||a(e)>=.4*t)}export function WidthSizer({samples:t}){return 0===t.length?null:e("span",{"aria-hidden":"true",className:"invisible h-0 min-h-0 overflow-hidden",children:t.map((t,a)=>"string"==typeof t?e("span",{"data-sample":t,className:"block whitespace-nowrap before:content-[attr(data-sample)]"},`${a}:${t}`):e("span",{className:"block whitespace-nowrap",children:t},a))})}
|
|
@@ -215,6 +215,31 @@ export declare const stackGapClasses: Record<NebaSize, string>;
|
|
|
215
215
|
* use, so a card's title lines up with the buttons that end up inside it.
|
|
216
216
|
*/
|
|
217
217
|
export declare const sheetTitleClasses: Record<NebaSize, string>;
|
|
218
|
+
/**
|
|
219
|
+
* What a sheet puts on the element around its `title`.
|
|
220
|
+
*
|
|
221
|
+
* A plain string needs nothing. A sheet that belongs in the document outline is
|
|
222
|
+
* given a real heading, `title={<h2>…</h2>}`, and that heading arrives with the
|
|
223
|
+
* browser's 1.5em bold and its margins, which would ignore the scale
|
|
224
|
+
* `sheetTitleClasses` just set — so it inherits the wrapper's font and loses
|
|
225
|
+
* its margins.
|
|
226
|
+
*
|
|
227
|
+
* At two strengths, as Typography's scale is. The **guard** reaches a heading
|
|
228
|
+
* with no `class` at all, at three classes' worth, because `.prose h2` and
|
|
229
|
+
* `.vp-doc h2` are a class plus a tag: without it a `<Card title={<h2>…</h2>}>`
|
|
230
|
+
* inside rendered Markdown came out at 24px where the card asked for 15px. A
|
|
231
|
+
* heading that carries a class gets only the **floor**, at zero specificity,
|
|
232
|
+
* which still takes the browser's defaults away and loses to every class on it,
|
|
233
|
+
* so `title={<h2 className="text-xl">…</h2>}` is 20px. The heading is the
|
|
234
|
+
* caller's element, so its classes cannot be read per property the way
|
|
235
|
+
* `internal/overrides.ts` reads a component's own `className`; having one at
|
|
236
|
+
* all is where the line is drawn.
|
|
237
|
+
*
|
|
238
|
+
* These are utilities rather than a rule in `styles.css`, which in a consumer's
|
|
239
|
+
* own Tailwind build is unlayered and would beat every class on the heading.
|
|
240
|
+
* `neba-title` closes the guard's selector, and is a hook as well.
|
|
241
|
+
*/
|
|
242
|
+
export declare const sheetTitleHeadingClasses: string;
|
|
218
243
|
/**
|
|
219
244
|
* The same ladder, for a title that is a real heading element.
|
|
220
245
|
*
|
|
@@ -230,8 +255,9 @@ export declare const sheetTitleClasses: Record<NebaSize, string>;
|
|
|
230
255
|
*
|
|
231
256
|
* So those three write their type through `[&.neba-heading]`, which compiles to
|
|
232
257
|
* two classes, and carry `neba-heading` to close the selector. It is the same
|
|
233
|
-
*
|
|
234
|
-
*
|
|
258
|
+
* guard `neba-link` and `neba-typography` write, without the floor they drop
|
|
259
|
+
* to for a property a caller sets (`internal/overrides.ts`): none of the three
|
|
260
|
+
* headings takes a caller's `className`, so the host is all it holds off.
|
|
235
261
|
*
|
|
236
262
|
* This is a second spelling of one ladder, which is normally the thing to avoid.
|
|
237
263
|
* It is checked rather than trusted — `test/package/resolution.test.ts` asserts
|
package/dist/internal/styles.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const radiusClasses={xs:"rounded-(--neba-radius-xs)",sm:"rounded-(--neba-radius-sm)",md:"rounded-(--neba-radius-md)",lg:"rounded-(--neba-radius-lg)",xl:"rounded-(--neba-radius-xl)"};export const controlHeightClasses={xs:"h-5.5",sm:"h-6.5",md:"h-8",lg:"h-10",xl:"h-12"};export const fieldHeightClasses={xs:"min-h-5.5",sm:"min-h-6.5",md:"min-h-8",lg:"min-h-10",xl:"min-h-12"};export const controlHeightValues={xs:"1.375rem",sm:"1.625rem",md:"2rem",lg:"2.5rem",xl:"3rem"};export const measureWidths={xs:"30rem",sm:"40rem",md:"48rem",lg:"64rem",xl:"80rem"};export function measureValue(e){return"number"==typeof e?`${e}px`:measureWidths[e]??e}export const controlSquareClasses={xs:"w-5.5",sm:"w-6.5",md:"w-8",lg:"w-10",xl:"w-12"};export const controlTextClasses={xs:"text-[0.6875rem]",sm:"text-[0.75rem]",md:"text-[0.8125rem]",lg:"text-[0.9375rem]",xl:"text-[1.0625rem]"};export const controlTextLeadingClasses={xs:"text-[0.6875rem]/[0.875rem]",sm:"text-[0.75rem]/[1rem]",md:"text-[0.8125rem]/[1.25rem]",lg:"text-[0.9375rem]/[1.375rem]",xl:"text-[1.0625rem]/[1.625rem]"};export const metaTextClasses={xs:"text-[0.625rem]",sm:"text-[0.6875rem]",md:"text-[0.75rem]",lg:"text-[0.8125rem]",xl:"text-[0.875rem]"};export const metaTextValues={xs:"0.625rem",sm:"0.6875rem",md:"0.75rem",lg:"0.8125rem",xl:"0.875rem"};export const paddingXClasses={default:{xs:"px-2.5",sm:"px-3",md:"px-4",lg:"px-5",xl:"px-6"},compact:{xs:"px-1.5",sm:"px-2",md:"px-2.5",lg:"px-3",xl:"px-4"}};export const iconSizeClasses={xs:"size-3.5",sm:"size-4",md:"size-5",lg:"size-6",xl:"size-7"};export const tickSizeClasses={xs:"size-3.5",sm:"size-4",md:"size-4.5",lg:"size-5",xl:"size-6"};export const tickRadiusClasses={xs:"rounded-[0.25rem]",sm:"rounded-[0.3125rem]",md:"rounded-[0.375rem]",lg:"rounded-[0.4375rem]",xl:"rounded-[0.5rem]"};export const tickDotClasses={xs:"size-1.5",sm:"size-1.5",md:"size-2",lg:"size-2",xl:"size-2.5"};export const tickRowLeadingClasses="leading-[1.4]";export const hitAreaClasses="neba-hit";export const paddingXValues={default:{xs:"0.625rem",sm:"0.75rem",md:"1rem",lg:"1.25rem",xl:"1.5rem"},compact:{xs:"0.375rem",sm:"0.5rem",md:"0.625rem",lg:"0.75rem",xl:"1rem"}};export const gapClasses={xs:"gap-1",sm:"gap-1.5",md:"gap-1.5",lg:"gap-2",xl:"gap-2.5"};export const stackGapClasses={xs:"gap-1",sm:"gap-1",md:"gap-1.5",lg:"gap-1.5",xl:"gap-2"};export const sheetTitleClasses={xs:"text-[0.75rem]/[1rem]",sm:"text-[0.8125rem]/[1.125rem]",md:"text-[0.9375rem]/[1.25rem]",lg:"text-[1.0625rem]/[1.5rem]",xl:"text-[1.25rem]/[1.75rem]"};export const headingTitleClasses={xs:"[&.neba-heading]:text-[0.75rem]/[1rem]",sm:"[&.neba-heading]:text-[0.8125rem]/[1.125rem]",md:"[&.neba-heading]:text-[0.9375rem]/[1.25rem]",lg:"[&.neba-heading]:text-[1.0625rem]/[1.5rem]",xl:"[&.neba-heading]:text-[1.25rem]/[1.75rem]"};export const sheetBodyClasses={xs:"text-[0.6875rem]/[1rem]",sm:"text-[0.75rem]/[1.125rem]",md:"text-[0.8125rem]/[1.375rem]",lg:"text-[0.9375rem]/[1.5rem]",xl:"text-[1.0625rem]/[1.75rem]"};export const sheetHeaderGapClasses={xs:"gap-0.5",sm:"gap-0.5",md:"gap-1",lg:"gap-1",xl:"gap-1.5"};export const sheetSectionGapClasses={xs:"gap-1.5",sm:"gap-2",md:"gap-3",lg:"gap-3.5",xl:"gap-4"};export const surfaceClasses="[background-image:var(--neba-grain),var(--neba-sheen)] [background-blend-mode:overlay,normal] [backdrop-filter:var(--neba-blur)]";export const ringRestClasses="[outline:0_solid_transparent]";export const transitionClasses=`${ringRestClasses} [transition-property:background-color,border-color,box-shadow,color,outline-color] [transition-duration:var(--neba-duration-fill),var(--neba-duration),var(--neba-duration),var(--neba-duration),var(--neba-duration)] [transition-timing-function:var(--neba-ease)]`;export const pressTransitionClasses="active:[transition-duration:0ms]";export const popupFadeStateClasses="data-[starting-style]:opacity-0 data-[ending-style]:opacity-0";export const popupFadeClasses="[transition:opacity_var(--neba-duration)_var(--neba-ease)] "+popupFadeStateClasses;export const focusRingClasses=`${ringRestClasses} outline-offset-2 focus-visible:[outline:2px_solid_var(--n-ring)]`;export const insetRingClasses=`${ringRestClasses} outline-offset-[-2px] focus-visible:[outline:2px_solid_var(--n-ring)]`;export const focusWithinRingClasses=`${ringRestClasses} outline-offset-2 has-[:focus-visible]:[outline:2px_solid_var(--n-ring)] supports-[not_selector(:has(*))]:focus-within:[outline:2px_solid_var(--n-ring)]`;export const fieldRingClasses=`${ringRestClasses} outline-offset-0 has-[:focus-visible]:[outline:2px_solid_var(--n-ring)]`;export const fieldFocusTransitionClasses="focus-within:[transition-duration:var(--neba-duration)]";export function clampClasses(e){return e>1?"line-clamp-(--n-lines)":"truncate"}export function clampSlot(e){return void 0!==e&&e>1?{"--n-lines":Math.floor(e)}:void 0}export const iconClasses="[&_svg]:pointer-events-none [&_svg]:size-[1.2em] [&_svg]:shrink-0";const e="[transition:height_var(--neba-duration)_var(--neba-ease)] motion-reduce:[transition-duration:0ms] data-[starting-style]:h-0 data-[ending-style]:h-0";export const collapsiblePanelClasses=`h-(--collapsible-panel-height) overflow-hidden ${e}`;export const accordionPanelClasses=`h-(--accordion-panel-height) overflow-hidden ${e}`;export const disclosureTriggerClasses="group/disclosure";export const disclosureChevronClasses="flex h-[1lh] shrink-0 items-center [transition:rotate_var(--neba-duration)_var(--neba-ease)] group-data-[panel-open]/disclosure:rotate-180";export const preformattedClasses="m-0 overflow-auto rounded-(--neba-radius-sm) bg-(--neba-groove) p-2 font-mono text-[0.9em]/[1.5] whitespace-pre";export const srOnlyClasses="absolute size-px overflow-hidden whitespace-nowrap [clip-path:inset(50%)]";export function controlSlots(e,s,t){const n="solid"===t;return{"--n-fill":`var(--neba-${e}-fill)`,"--n-fill-hover":`var(--neba-${e}-fill-hover)`,"--n-fill-active":`var(--neba-${e}-fill-active)`,"--n-on-solid":`var(--neba-${e}-on-solid)`,"--n-accent":`var(--neba-${e}-accent)`,"--n-soft":`var(--neba-${e}-soft)`,"--n-soft-hover":`var(--neba-${e}-soft-hover)`,"--n-soft-press":`var(--neba-${e}-soft-press)`,"--n-on-tint":`var(--neba-${e}-on-tint)`,"--n-panel":`var(--neba-${e}-panel)`,"--n-panel-hover":`var(--neba-${e}-panel-hover)`,"--n-panel-press":`var(--neba-${e}-panel-press)`,"--n-line":`var(--neba-${e}-line)`,"--n-line-hover":`var(--neba-${e}-line-hover)`,"--n-ring":`var(--neba-${e}-ring)`,"--n-glow":n?"var(--neba-glow-on-fill)":`var(--neba-${e}-soft)`,"--n-flash":n?"var(--neba-flash-on-fill)":`var(--neba-${e}-soft-press)`,"--n-elev":`var(--neba-shadow-${s})`,"--n-elev-hover":`var(--neba-shadow-${Math.min(s+1,4)})`,"--n-elev-press":`var(--neba-shadow-${Math.max(s-1,0)})`}}export function surfaceSlots(e,s){return{"--n-accent":`var(--neba-${e}-accent)`,"--n-soft":`var(--neba-${e}-soft)`,"--n-soft-hover":`var(--neba-${e}-soft-hover)`,"--n-soft-press":`var(--neba-${e}-soft-press)`,"--n-on-tint":`var(--neba-${e}-on-tint)`,"--n-panel":"var(--neba-panel)","--n-panel-hover":"var(--neba-panel-hover)","--n-panel-press":"var(--neba-panel-press)","--n-line":`var(--neba-${e}-line)`,"--n-line-hover":`var(--neba-${e}-line-hover)`,"--n-ring":`var(--neba-${e}-ring)`,"--n-elev":`var(--neba-shadow-${s})`}}export const tintPlateClasses="neba-tint-plate";export const disabledClasses={solid:"cursor-not-allowed bg-(--neba-disabled-bg) text-(--neba-disabled-fg) shadow-none",outline:"cursor-not-allowed border bg-transparent text-(--neba-disabled-fg) [border-color:var(--neba-disabled-border)] shadow-none",text:"cursor-not-allowed bg-transparent text-(--neba-disabled-fg) shadow-none"};export const fieldRestClasses={solid:`${surfaceClasses} text-(--neba-fg) bg-(--n-panel-hover) [box-shadow:var(--n-elev),var(--neba-plate-solid)] hover:bg-(--n-panel-press) focus-within:bg-(--n-panel-press)`,outline:`${surfaceClasses} border text-(--neba-fg) bg-(--n-panel) [border-color:var(--n-line)] [box-shadow:var(--n-elev),var(--neba-plate-glass)] hover:bg-(--n-panel-hover) hover:[border-color:var(--n-line-hover)] focus-within:bg-(--n-panel-hover) focus-within:[border-color:var(--n-ring)] focus-within:hover:[border-color:var(--n-ring)]`,text:"text-(--neba-fg) bg-transparent hover:bg-(--n-soft) focus-within:bg-(--n-soft-hover) focus-within:hover:bg-(--n-soft-hover)"};export const fieldReadOnlyClasses={solid:`${surfaceClasses} text-(--neba-fg) bg-(--n-panel-hover) [box-shadow:var(--neba-plate-solid)] [filter:saturate(0.55)]`,outline:`${surfaceClasses} border text-(--neba-fg) bg-(--n-panel) [border-color:var(--n-line)] [box-shadow:var(--neba-plate-glass)] [filter:saturate(0.55)]`,text:"text-(--neba-fg) bg-transparent [filter:saturate(0.55)]"};export const readOnlyFilterClasses="[filter:saturate(0.55)]";export const fieldSheetClasses={solid:`${surfaceClasses} text-(--neba-fg) bg-(--n-panel-hover) [box-shadow:var(--n-elev)] hover:bg-(--n-panel-press) focus-within:bg-(--n-panel-press)`,outline:`${surfaceClasses} border [border-color:transparent] text-(--neba-fg) bg-(--n-panel) [box-shadow:var(--n-elev)] hover:bg-(--n-panel-hover) focus-within:bg-(--n-panel-hover)`,text:fieldRestClasses.text};export const fieldSheetReadOnlyClasses={solid:`${surfaceClasses} text-(--neba-fg) bg-(--n-panel-hover)`,outline:`${surfaceClasses} border [border-color:transparent] text-(--neba-fg) bg-(--n-panel)`,text:"text-(--neba-fg) bg-transparent"};export const fieldSheetDisabledClasses={solid:disabledClasses.solid,outline:"cursor-not-allowed border bg-transparent text-(--neba-disabled-fg) [border-color:transparent] shadow-none",text:disabledClasses.text};export const citationMarkClasses="inline-flex shrink-0 items-center justify-center rounded-[0.3em] min-w-[1.5em] px-[0.35em] py-[0.05em] bg-(--n-soft) text-[0.8em]/[1.6] font-semibold text-(--n-on-tint) tabular-nums";export const chipRemoveClasses="relative ms-0.5 inline-flex shrink-0 items-center justify-center rounded-full size-[1.15em] cursor-pointer opacity-70 neba-hit [transition:opacity_var(--neba-duration)_var(--neba-ease)] hover:opacity-100 focus-visible:opacity-100 focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-1 disabled:cursor-not-allowed";export const sheetCloseClasses="relative flex size-[1.6em] shrink-0 cursor-pointer items-center justify-center rounded-full text-(--neba-muted-fg) neba-hit [&_svg]:size-[1.1em] [&_svg]:shrink-0 [transition:background-color_var(--neba-duration)_var(--neba-ease),color_var(--neba-duration)_var(--neba-ease)] hover:bg-(--n-soft) hover:text-(--neba-fg) focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2";export function hasContent(e){return null!=e&&!1!==e&&""!==e}export function toLength(e){if(null!=e)return"number"==typeof e?`${e}px`:e}const s=/^\s*(-?[\d.]+)\s*(px|rem|em|%)\s*$/;export function toPixels(e,n){const r=s.exec(e);if(!r)return;const a=Number(r[1]);if(!Number.isNaN(a))switch(r[2]){case"px":return a;case"%":return n.percentOf*a/100;case"em":return a*t(n.relativeTo);default:return a*t("undefined"==typeof document?null:document.documentElement)}}function t(e){return e&&"undefined"!=typeof getComputedStyle&&parseFloat(getComputedStyle(e).fontSize)||16}export function cx(...e){return e.filter(Boolean).join(" ")}
|
|
1
|
+
export const radiusClasses={xs:"rounded-(--neba-radius-xs)",sm:"rounded-(--neba-radius-sm)",md:"rounded-(--neba-radius-md)",lg:"rounded-(--neba-radius-lg)",xl:"rounded-(--neba-radius-xl)"};export const controlHeightClasses={xs:"h-5.5",sm:"h-6.5",md:"h-8",lg:"h-10",xl:"h-12"};export const fieldHeightClasses={xs:"min-h-5.5",sm:"min-h-6.5",md:"min-h-8",lg:"min-h-10",xl:"min-h-12"};export const controlHeightValues={xs:"1.375rem",sm:"1.625rem",md:"2rem",lg:"2.5rem",xl:"3rem"};export const measureWidths={xs:"30rem",sm:"40rem",md:"48rem",lg:"64rem",xl:"80rem"};export function measureValue(e){return"number"==typeof e?`${e}px`:measureWidths[e]??e}export const controlSquareClasses={xs:"w-5.5",sm:"w-6.5",md:"w-8",lg:"w-10",xl:"w-12"};export const controlTextClasses={xs:"text-[0.6875rem]",sm:"text-[0.75rem]",md:"text-[0.8125rem]",lg:"text-[0.9375rem]",xl:"text-[1.0625rem]"};export const controlTextLeadingClasses={xs:"text-[0.6875rem]/[0.875rem]",sm:"text-[0.75rem]/[1rem]",md:"text-[0.8125rem]/[1.25rem]",lg:"text-[0.9375rem]/[1.375rem]",xl:"text-[1.0625rem]/[1.625rem]"};export const metaTextClasses={xs:"text-[0.625rem]",sm:"text-[0.6875rem]",md:"text-[0.75rem]",lg:"text-[0.8125rem]",xl:"text-[0.875rem]"};export const metaTextValues={xs:"0.625rem",sm:"0.6875rem",md:"0.75rem",lg:"0.8125rem",xl:"0.875rem"};export const paddingXClasses={default:{xs:"px-2.5",sm:"px-3",md:"px-4",lg:"px-5",xl:"px-6"},compact:{xs:"px-1.5",sm:"px-2",md:"px-2.5",lg:"px-3",xl:"px-4"}};export const iconSizeClasses={xs:"size-3.5",sm:"size-4",md:"size-5",lg:"size-6",xl:"size-7"};export const tickSizeClasses={xs:"size-3.5",sm:"size-4",md:"size-4.5",lg:"size-5",xl:"size-6"};export const tickRadiusClasses={xs:"rounded-[0.25rem]",sm:"rounded-[0.3125rem]",md:"rounded-[0.375rem]",lg:"rounded-[0.4375rem]",xl:"rounded-[0.5rem]"};export const tickDotClasses={xs:"size-1.5",sm:"size-1.5",md:"size-2",lg:"size-2",xl:"size-2.5"};export const tickRowLeadingClasses="leading-[1.4]";export const hitAreaClasses="neba-hit";export const paddingXValues={default:{xs:"0.625rem",sm:"0.75rem",md:"1rem",lg:"1.25rem",xl:"1.5rem"},compact:{xs:"0.375rem",sm:"0.5rem",md:"0.625rem",lg:"0.75rem",xl:"1rem"}};export const gapClasses={xs:"gap-1",sm:"gap-1.5",md:"gap-1.5",lg:"gap-2",xl:"gap-2.5"};export const stackGapClasses={xs:"gap-1",sm:"gap-1",md:"gap-1.5",lg:"gap-1.5",xl:"gap-2"};export const sheetTitleClasses={xs:"text-[0.75rem]/[1rem]",sm:"text-[0.8125rem]/[1.125rem]",md:"text-[0.9375rem]/[1.25rem]",lg:"text-[1.0625rem]/[1.5rem]",xl:"text-[1.25rem]/[1.75rem]"};export const sheetTitleHeadingClasses="neba-title [&.neba-title_:where(h1,h2,h3,h4,h5,h6):not([class])]:[font:inherit] [&.neba-title_:where(h1,h2,h3,h4,h5,h6):not([class])]:m-0 [:where(&)_:where(h1,h2,h3,h4,h5,h6)]:[font:inherit] [:where(&)_:where(h1,h2,h3,h4,h5,h6)]:m-0";export const headingTitleClasses={xs:"[&.neba-heading]:text-[0.75rem]/[1rem]",sm:"[&.neba-heading]:text-[0.8125rem]/[1.125rem]",md:"[&.neba-heading]:text-[0.9375rem]/[1.25rem]",lg:"[&.neba-heading]:text-[1.0625rem]/[1.5rem]",xl:"[&.neba-heading]:text-[1.25rem]/[1.75rem]"};export const sheetBodyClasses={xs:"text-[0.6875rem]/[1rem]",sm:"text-[0.75rem]/[1.125rem]",md:"text-[0.8125rem]/[1.375rem]",lg:"text-[0.9375rem]/[1.5rem]",xl:"text-[1.0625rem]/[1.75rem]"};export const sheetHeaderGapClasses={xs:"gap-0.5",sm:"gap-0.5",md:"gap-1",lg:"gap-1",xl:"gap-1.5"};export const sheetSectionGapClasses={xs:"gap-1.5",sm:"gap-2",md:"gap-3",lg:"gap-3.5",xl:"gap-4"};export const surfaceClasses="[background-image:var(--neba-grain),var(--neba-sheen)] [background-blend-mode:overlay,normal] [backdrop-filter:var(--neba-blur)]";export const ringRestClasses="[outline:0_solid_transparent]";export const transitionClasses=`${ringRestClasses} [transition-property:background-color,border-color,box-shadow,color,outline-color] [transition-duration:var(--neba-duration-fill),var(--neba-duration),var(--neba-duration),var(--neba-duration),var(--neba-duration)] [transition-timing-function:var(--neba-ease)]`;export const pressTransitionClasses="active:[transition-duration:0ms]";export const popupFadeStateClasses="data-[starting-style]:opacity-0 data-[ending-style]:opacity-0";export const popupFadeClasses="[transition:opacity_var(--neba-duration)_var(--neba-ease)] "+popupFadeStateClasses;export const focusRingClasses=`${ringRestClasses} outline-offset-2 focus-visible:[outline:2px_solid_var(--n-ring)]`;export const insetRingClasses=`${ringRestClasses} outline-offset-[-2px] focus-visible:[outline:2px_solid_var(--n-ring)]`;export const focusWithinRingClasses=`${ringRestClasses} outline-offset-2 has-[:focus-visible]:[outline:2px_solid_var(--n-ring)] supports-[not_selector(:has(*))]:focus-within:[outline:2px_solid_var(--n-ring)]`;export const fieldRingClasses=`${ringRestClasses} outline-offset-0 has-[:focus-visible]:[outline:2px_solid_var(--n-ring)]`;export const fieldFocusTransitionClasses="focus-within:[transition-duration:var(--neba-duration)]";export function clampClasses(e){return e>1?"line-clamp-(--n-lines)":"truncate"}export function clampSlot(e){return void 0!==e&&e>1?{"--n-lines":Math.floor(e)}:void 0}export const iconClasses="[&_svg]:pointer-events-none [&_svg]:size-[1.2em] [&_svg]:shrink-0";const e="[transition:height_var(--neba-duration)_var(--neba-ease)] motion-reduce:[transition-duration:0ms] data-[starting-style]:h-0 data-[ending-style]:h-0";export const collapsiblePanelClasses=`h-(--collapsible-panel-height) overflow-hidden ${e}`;export const accordionPanelClasses=`h-(--accordion-panel-height) overflow-hidden ${e}`;export const disclosureTriggerClasses="group/disclosure";export const disclosureChevronClasses="flex h-[1lh] shrink-0 items-center [transition:rotate_var(--neba-duration)_var(--neba-ease)] group-data-[panel-open]/disclosure:rotate-180";export const preformattedClasses="m-0 overflow-auto rounded-(--neba-radius-sm) bg-(--neba-groove) p-2 font-mono text-[0.9em]/[1.5] whitespace-pre";export const srOnlyClasses="absolute size-px overflow-hidden whitespace-nowrap [clip-path:inset(50%)]";export function controlSlots(e,s,t){const n="solid"===t;return{"--n-fill":`var(--neba-${e}-fill)`,"--n-fill-hover":`var(--neba-${e}-fill-hover)`,"--n-fill-active":`var(--neba-${e}-fill-active)`,"--n-on-solid":`var(--neba-${e}-on-solid)`,"--n-accent":`var(--neba-${e}-accent)`,"--n-soft":`var(--neba-${e}-soft)`,"--n-soft-hover":`var(--neba-${e}-soft-hover)`,"--n-soft-press":`var(--neba-${e}-soft-press)`,"--n-on-tint":`var(--neba-${e}-on-tint)`,"--n-panel":`var(--neba-${e}-panel)`,"--n-panel-hover":`var(--neba-${e}-panel-hover)`,"--n-panel-press":`var(--neba-${e}-panel-press)`,"--n-line":`var(--neba-${e}-line)`,"--n-line-hover":`var(--neba-${e}-line-hover)`,"--n-ring":`var(--neba-${e}-ring)`,"--n-glow":n?"var(--neba-glow-on-fill)":`var(--neba-${e}-soft)`,"--n-flash":n?"var(--neba-flash-on-fill)":`var(--neba-${e}-soft-press)`,"--n-elev":`var(--neba-shadow-${s})`,"--n-elev-hover":`var(--neba-shadow-${Math.min(s+1,4)})`,"--n-elev-press":`var(--neba-shadow-${Math.max(s-1,0)})`}}export function surfaceSlots(e,s){return{"--n-accent":`var(--neba-${e}-accent)`,"--n-soft":`var(--neba-${e}-soft)`,"--n-soft-hover":`var(--neba-${e}-soft-hover)`,"--n-soft-press":`var(--neba-${e}-soft-press)`,"--n-on-tint":`var(--neba-${e}-on-tint)`,"--n-panel":"var(--neba-panel)","--n-panel-hover":"var(--neba-panel-hover)","--n-panel-press":"var(--neba-panel-press)","--n-line":`var(--neba-${e}-line)`,"--n-line-hover":`var(--neba-${e}-line-hover)`,"--n-ring":`var(--neba-${e}-ring)`,"--n-elev":`var(--neba-shadow-${s})`}}export const tintPlateClasses="neba-tint-plate";export const disabledClasses={solid:"cursor-not-allowed bg-(--neba-disabled-bg) text-(--neba-disabled-fg) shadow-none",outline:"cursor-not-allowed border bg-transparent text-(--neba-disabled-fg) [border-color:var(--neba-disabled-border)] shadow-none",text:"cursor-not-allowed bg-transparent text-(--neba-disabled-fg) shadow-none"};export const fieldRestClasses={solid:`${surfaceClasses} text-(--neba-fg) bg-(--n-panel-hover) [box-shadow:var(--n-elev),var(--neba-plate-solid)] hover:bg-(--n-panel-press) focus-within:bg-(--n-panel-press)`,outline:`${surfaceClasses} border text-(--neba-fg) bg-(--n-panel) [border-color:var(--n-line)] [box-shadow:var(--n-elev),var(--neba-plate-glass)] hover:bg-(--n-panel-hover) hover:[border-color:var(--n-line-hover)] focus-within:bg-(--n-panel-hover) focus-within:[border-color:var(--n-ring)] focus-within:hover:[border-color:var(--n-ring)]`,text:"text-(--neba-fg) bg-transparent hover:bg-(--n-soft) focus-within:bg-(--n-soft-hover) focus-within:hover:bg-(--n-soft-hover)"};export const fieldReadOnlyClasses={solid:`${surfaceClasses} text-(--neba-fg) bg-(--n-panel-hover) [box-shadow:var(--neba-plate-solid)] [filter:saturate(0.55)]`,outline:`${surfaceClasses} border text-(--neba-fg) bg-(--n-panel) [border-color:var(--n-line)] [box-shadow:var(--neba-plate-glass)] [filter:saturate(0.55)]`,text:"text-(--neba-fg) bg-transparent [filter:saturate(0.55)]"};export const readOnlyFilterClasses="[filter:saturate(0.55)]";export const fieldSheetClasses={solid:`${surfaceClasses} text-(--neba-fg) bg-(--n-panel-hover) [box-shadow:var(--n-elev)] hover:bg-(--n-panel-press) focus-within:bg-(--n-panel-press)`,outline:`${surfaceClasses} border [border-color:transparent] text-(--neba-fg) bg-(--n-panel) [box-shadow:var(--n-elev)] hover:bg-(--n-panel-hover) focus-within:bg-(--n-panel-hover)`,text:fieldRestClasses.text};export const fieldSheetReadOnlyClasses={solid:`${surfaceClasses} text-(--neba-fg) bg-(--n-panel-hover)`,outline:`${surfaceClasses} border [border-color:transparent] text-(--neba-fg) bg-(--n-panel)`,text:"text-(--neba-fg) bg-transparent"};export const fieldSheetDisabledClasses={solid:disabledClasses.solid,outline:"cursor-not-allowed border bg-transparent text-(--neba-disabled-fg) [border-color:transparent] shadow-none",text:disabledClasses.text};export const citationMarkClasses="inline-flex shrink-0 items-center justify-center rounded-[0.3em] min-w-[1.5em] px-[0.35em] py-[0.05em] bg-(--n-soft) text-[0.8em]/[1.6] font-semibold text-(--n-on-tint) tabular-nums";export const chipRemoveClasses="relative ms-0.5 inline-flex shrink-0 items-center justify-center rounded-full size-[1.15em] cursor-pointer opacity-70 neba-hit [transition:opacity_var(--neba-duration)_var(--neba-ease)] hover:opacity-100 focus-visible:opacity-100 focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-1 disabled:cursor-not-allowed";export const sheetCloseClasses="relative flex size-[1.6em] shrink-0 cursor-pointer items-center justify-center rounded-full text-(--neba-muted-fg) neba-hit [&_svg]:size-[1.1em] [&_svg]:shrink-0 [transition:background-color_var(--neba-duration)_var(--neba-ease),color_var(--neba-duration)_var(--neba-ease)] hover:bg-(--n-soft) hover:text-(--neba-fg) focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2";export function hasContent(e){return null!=e&&!1!==e&&""!==e}export function toLength(e){if(null!=e)return"number"==typeof e?`${e}px`:e}const s=/^\s*(-?[\d.]+)\s*(px|rem|em|%)\s*$/;export function toPixels(e,n){const r=s.exec(e);if(!r)return;const a=Number(r[1]);if(!Number.isNaN(a))switch(r[2]){case"px":return a;case"%":return n.percentOf*a/100;case"em":return a*t(n.relativeTo);default:return a*t("undefined"==typeof document?null:document.documentElement)}}function t(e){return e&&"undefined"!=typeof getComputedStyle&&parseFloat(getComputedStyle(e).fontSize)||16}export function cx(...e){return e.filter(Boolean).join(" ")}
|
package/dist/internal/text.d.ts
CHANGED
|
@@ -13,10 +13,12 @@ export declare function textOf(node: unknown): string;
|
|
|
13
13
|
* `👩👩👧` is seven of them, `한` typed on a Korean keyboard can be three, and an
|
|
14
14
|
* effect that advances by code points spends four frames assembling an emoji
|
|
15
15
|
* out of parts that mean nothing on their own. `Intl.Segmenter` knows where the
|
|
16
|
-
* boundaries actually are;
|
|
17
|
-
* not have it.
|
|
16
|
+
* boundaries actually are; `portableGraphemesOf` is the fallback for a runtime
|
|
17
|
+
* that does not have it.
|
|
18
18
|
*/
|
|
19
19
|
export declare function graphemesOf(text: string, locale?: string): string[];
|
|
20
|
+
/** The text split into characters, the same way on every engine. */
|
|
21
|
+
export declare function portableGraphemesOf(text: string): string[];
|
|
20
22
|
/**
|
|
21
23
|
* The text split into words, with each word keeping the space that followed it.
|
|
22
24
|
*
|
|
@@ -27,6 +29,26 @@ export declare function graphemesOf(text: string, locale?: string): string[];
|
|
|
27
29
|
*
|
|
28
30
|
* `Intl.Segmenter` again where it exists — a word boundary is not a space in
|
|
29
31
|
* Japanese, Thai or Chinese, and splitting those on whitespace produces one
|
|
30
|
-
* piece holding the whole sentence.
|
|
32
|
+
* piece holding the whole sentence. `portableWordsOf` where it does not.
|
|
31
33
|
*/
|
|
32
34
|
export declare function wordsOf(text: string, locale?: string): string[];
|
|
35
|
+
/**
|
|
36
|
+
* Whether a character belongs to a script written without spaces, where a run
|
|
37
|
+
* of letters is not one word and a line may break inside it.
|
|
38
|
+
*
|
|
39
|
+
* `portableWordsOf` makes each one a piece of its own: a regular expression
|
|
40
|
+
* cannot tell where a Japanese or a Thai word ends, and one character at a time
|
|
41
|
+
* is never coarser than the segmenter's answer.
|
|
42
|
+
*/
|
|
43
|
+
export declare function standsAlone(grapheme: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The text split into words, the same way on every engine.
|
|
46
|
+
*
|
|
47
|
+
* The same shape as `wordsOf`: a word keeps the punctuation and the space that
|
|
48
|
+
* follow it, and what comes before the first word is a piece of its own. Where
|
|
49
|
+
* it disagrees with `Intl.Segmenter` it cuts finer, never coarser — a Japanese
|
|
50
|
+
* sentence is a piece per character rather than a piece per word — so a line
|
|
51
|
+
* that is cut again once the page has hydrated only ever has pieces merged, and
|
|
52
|
+
* nothing that was already on screen arrives a second time.
|
|
53
|
+
*/
|
|
54
|
+
export declare function portableWordsOf(text: string): string[];
|
package/dist/internal/text.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{segmenter as t}from"./format.js";export function textOf(t){return"string"==typeof t||"number"==typeof t?String(t):Array.isArray(t)?t.map(textOf).join(""):null!==t&&"object"==typeof t&&"props"in t?textOf(t.props.children):""}export function graphemesOf(e,r){const
|
|
1
|
+
import{segmenter as t}from"./format.js";export function textOf(t){return"string"==typeof t||"number"==typeof t?String(t):Array.isArray(t)?t.map(textOf).join(""):null!==t&&"object"==typeof t&&"props"in t?textOf(t.props.children):""}export function graphemesOf(e,r){const u=t(r,"grapheme");return u?[...u.segment(e)].map(t=>t.segment):portableGraphemesOf(e)}const e=/\r\n|\p{RI}\p{RI}|[\u1100-\u115F\uA960-\uA97C]*(?:[\uAC00-\uD7A3]|[\u1160-\u11A7\uD7B0-\uD7C6])[\u1160-\u11A7\uD7B0-\uD7C6]*[\u11A8-\u11FF\uD7CB-\uD7FB]*|[\u1100-\u115F\uA960-\uA97C]+|[\s\S](?:[\u094D\u09CD\u0ACD\u0B4D\u0C4D\u0D4D\u17D2]\p{L}|[\p{Gr_Ext}\p{EMod}\p{Mc}\u0E33\u0EB3]|\u200D\p{ExtPict}|\u200D)*/gu;export function portableGraphemesOf(t){return t.match(e)??[]}export function wordsOf(e,r){const u=t(r,"word");if(u){const t=[];for(const{segment:r,isWordLike:n}of u.segment(e))n||0===t.length?t.push(r):t[t.length-1]+=r;return t.filter(t=>t.length>0)}return portableWordsOf(e)}const r=/^(?=\p{L})[\p{scx=Han}\p{scx=Hiragana}\p{scx=Katakana}\p{scx=Thai}\p{scx=Lao}\p{scx=Khmer}\p{scx=Myanmar}]/u;export function standsAlone(t){return r.test(t)}const u=/^[\p{Alphabetic}\p{Pc}]/u,n=/^\p{Nd}/u,o=/^['\u2019]$/u,p=/^[.',;\u2019]$/u;function s(t){return standsAlone(t)?"alone":u.test(t)?"letter":n.test(t)?"digit":"other"}export function portableWordsOf(t){const e=portableGraphemesOf(t),r=e.map(s),u=[];let n=!1;return e.forEach((t,e)=>{const s=r[e],a="other"===s&&r[e-1]===r[e+1]&&("letter"===r[e-1]&&o.test(t)||"digit"===r[e-1]&&p.test(t)),c="letter"===s||"digit"===s||a;0===u.length||"alone"===s||c&&!n?u.push(t):u[u.length-1]+=t,n=c}),u}
|