@box-kite/react 2.2.4 → 2.2.5
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/.claude/rules/box-kite-rules.md +8 -0
- package/.claude/skills/box-kite/SKILL.md +8 -0
- package/.claude/skills/box-kite/references/components.md +49 -3
- package/.cursor/rules/box-kite.mdc +8 -0
- package/AGENTS.md +8 -0
- package/BOX_AI_CONTEXT.md +276 -20
- package/BOX_KITE_AI_CONTEXT.md +276 -20
- package/behavior.cjs +1 -1
- package/behavior.mjs +57 -57
- package/box.cjs +1 -1
- package/box.d.ts +5 -0
- package/box.mjs +17 -17
- package/catalog.cjs +1 -1
- package/catalog.mjs +385 -0
- package/client.cjs +1 -1
- package/client.mjs +113 -87
- package/components/dashboard.cjs +1 -1
- package/components/dashboard.mjs +1 -1
- package/components/dataGrid/components/dataGridList.d.ts +12 -0
- package/components/dataGrid/components/dataGridListAggregate.d.ts +7 -0
- package/components/dataGrid/components/dataGridListFilter.d.ts +7 -0
- package/components/dataGrid/components/dataGridListFilterSheet.d.ts +11 -0
- package/components/dataGrid/components/dataGridListFooter.d.ts +13 -0
- package/components/dataGrid/components/dataGridListGroup.d.ts +13 -0
- package/components/dataGrid/components/dataGridListItem.d.ts +21 -0
- package/components/dataGrid/components/dataGridListLayout.d.ts +20 -0
- package/components/dataGrid/components/dataGridListRecord.d.ts +11 -0
- package/components/dataGrid/components/dataGridListSelectionBar.d.ts +11 -0
- package/components/dataGrid/components/dataGridListSheet.d.ts +30 -0
- package/components/dataGrid/components/dataGridListSortSheet.d.ts +10 -0
- package/components/dataGrid/components/dataGridListToolbar.d.ts +10 -0
- package/components/dataGrid/components/dataGridListValue.d.ts +12 -0
- package/components/dataGrid/contracts/dataGridContract.d.ts +32 -0
- package/components/dataGrid/models/gridModel.d.ts +3 -0
- package/components/dataGrid/models/listModel.d.ts +129 -0
- package/components/dataGrid/models/localeText.d.ts +32 -0
- package/components/dataGrid/models/viewportModel.d.ts +0 -2
- package/components/dataGrid/useListLayout.d.ts +13 -0
- package/components/dataGrid.cjs +3 -3
- package/components/dataGrid.mjs +1052 -788
- package/components/dialog.cjs +1 -1
- package/components/dialog.mjs +85 -97
- package/components/list/listItemParts.d.ts +9 -0
- package/components/list.cjs +1 -0
- package/components/list.d.ts +118 -0
- package/components/list.mjs +391 -0
- package/components/menu.cjs +1 -1
- package/components/menu.mjs +25 -25
- package/components/overlay.cjs +1 -1
- package/components/overlay.mjs +12 -12
- package/components/semantics.d.ts +29 -29
- package/components/slider.cjs +1 -1
- package/components/slider.mjs +1 -1
- package/components/sortableList.cjs +1 -0
- package/components/sortableList.d.ts +49 -0
- package/components/sortableList.mjs +384 -0
- package/components/swipeItem.cjs +1 -0
- package/components/swipeItem.d.ts +52 -0
- package/components/swipeItem.mjs +321 -0
- package/components/tabs.cjs +1 -1
- package/components/tabs.mjs +1 -1
- package/components/toaster.cjs +1 -1
- package/components/toaster.mjs +24 -24
- package/components/virtualList.cjs +1 -0
- package/components/virtualList.d.ts +32 -0
- package/components/virtualList.mjs +188 -0
- package/dataGridList.cjs +1 -0
- package/dataGridList.mjs +1351 -0
- package/docs/components.md +5 -1
- package/icons/closeIcon.d.ts +2 -0
- package/icons/filterIcon.d.ts +2 -0
- package/layer.cjs +1 -1
- package/layer.mjs +1 -1
- package/mcp/src/data.d.ts +2 -0
- package/package.json +86 -22
- package/placement.cjs +1 -1
- package/placement.mjs +10 -10
- package/platform.cjs +1 -1
- package/platform.mjs +4 -1
- package/react/a11y/useControllableState.d.ts +2 -1
- package/react/componentsContext.d.ts +4 -0
- package/react/componentsProvider.d.ts +10 -0
- package/react/resolveStyles.d.ts +2 -1
- package/react/theme/theme.d.ts +6 -1
- package/react-shared.cjs +1 -1
- package/react-shared.mjs +5 -5
- package/registry/blocks/dashboard-shell/dashboard-shell.d.ts +3 -1
- package/registry/designs/store/address-form.d.ts +11 -0
- package/registry/designs/store/cart-items.d.ts +10 -0
- package/registry/designs/store/cart-page.d.ts +4 -0
- package/registry/designs/store/checkout-page.d.ts +7 -0
- package/registry/designs/store/credit-card-form.d.ts +10 -0
- package/registry/designs/store/form-field.d.ts +19 -0
- package/registry/designs/store/order-summary.d.ts +18 -0
- package/registry/designs/store/product-art.d.ts +26 -0
- package/registry/designs/store/product-card.d.ts +11 -0
- package/registry/designs/store/product-gallery.d.ts +11 -0
- package/registry/designs/store/product-grid.d.ts +10 -0
- package/registry/designs/store/product-page.d.ts +5 -0
- package/registry/designs/store/quantity-stepper.d.ts +13 -0
- package/registry/designs/store/shipping-method.d.ts +14 -0
- package/registry/designs/store/store-data.d.ts +53 -0
- package/registry/designs/store/store-design.d.ts +63 -0
- package/registry/designs/store/store-shell.d.ts +12 -0
- package/registry/designs/store/storefront-page.d.ts +4 -0
- package/registry/designs/store/variant-picker.d.ts +15 -0
- package/rsc.cjs +1 -1
- package/rsc.d.ts +2 -0
- package/rsc.mjs +1 -1
- package/scrolling.cjs +1 -0
- package/scrolling.mjs +22 -0
- package/ssg.cjs +1 -1
- package/ssg.mjs +1 -1
- package/utils/scroll/scrollUtils.d.ts +6 -0
- package/utils/sortable/sortableUtils.d.ts +25 -0
- package/utils/swipe/swipeUtils.d.ts +53 -0
- package/utils/virtual/measuredWindow.d.ts +28 -0
- package/utils/virtual/rowSearch.d.ts +11 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Shape } from './store-data';
|
|
2
|
+
export type ArtView = 'front' | 'set';
|
|
3
|
+
export interface ProductArtProps {
|
|
4
|
+
shape: Shape;
|
|
5
|
+
finish: string;
|
|
6
|
+
/** For the `set` view: more finishes, each on its own tile beside the first. */
|
|
7
|
+
also?: readonly string[];
|
|
8
|
+
view?: ArtView;
|
|
9
|
+
/** Names the picture; without one it is decoration, hidden from assistive technology. */
|
|
10
|
+
label?: string;
|
|
11
|
+
/** The line's width in the icon's own 24-unit grid: thinner on a large tile, heavier on a thumbnail. */
|
|
12
|
+
stroke?: 0.5 | 0.75 | 1 | 1.25 | 1.5;
|
|
13
|
+
/** Rounds the picture’s corners, on the ÷4 scale: the tiles clip themselves, so nothing around them has to. */
|
|
14
|
+
radius?: 2 | 3 | 4 | 6;
|
|
15
|
+
}
|
|
16
|
+
/** Fills its parent: give the parent a size or an aspect ratio, and the picture takes the rest. */
|
|
17
|
+
export default function ProductArt({ shape, finish, also, view, label, stroke, radius }: ProductArtProps): import("react").JSX.Element;
|
|
18
|
+
/** A flat dot of the finish, for the colour swatches. */
|
|
19
|
+
export declare function finishSwatch(id: string): {
|
|
20
|
+
vars: {
|
|
21
|
+
swatch: string;
|
|
22
|
+
};
|
|
23
|
+
css: {
|
|
24
|
+
backgroundColor: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Product } from './store-data';
|
|
2
|
+
export interface ProductCardProps {
|
|
3
|
+
product: Product;
|
|
4
|
+
/** The heading level the card's name takes in the page around it. */
|
|
5
|
+
level?: 'h2' | 'h3';
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* One product in a grid. The whole card is the link, and its name is the link's text: the picture is
|
|
9
|
+
* decoration beside it, and the finish swatches are spelled out for a screen reader in one sentence.
|
|
10
|
+
*/
|
|
11
|
+
export default function ProductCard({ product, level }: ProductCardProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Product } from './store-data';
|
|
2
|
+
export interface ProductGalleryProps {
|
|
3
|
+
product?: Product;
|
|
4
|
+
/** The finish on show — the variant picker beside the gallery owns it. */
|
|
5
|
+
finish?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A product's pictures: one large view and a row of thumbnails that choose it. The thumbnails are tabs
|
|
9
|
+
* (APG's tabbed carousel), so the arrow keys move between them and each picture is named by its tab.
|
|
10
|
+
*/
|
|
11
|
+
export default function ProductGallery({ product, finish }: ProductGalleryProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Product } from './store-data';
|
|
2
|
+
export interface ProductGridProps {
|
|
3
|
+
products?: readonly Product[];
|
|
4
|
+
title?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A product grid with filters: categories and finishes as checkboxes, a sort, and a count that is announced
|
|
8
|
+
* as it changes. Filtering is a `useMemo` over the list it is given — hand it the page your API returned.
|
|
9
|
+
*/
|
|
10
|
+
export default function ProductGrid({ products, title }: ProductGridProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface QuantityStepperProps {
|
|
2
|
+
value: number;
|
|
3
|
+
onChange: (value: number) => void;
|
|
4
|
+
/** What is being counted, for the buttons' names: "Add one Bolt the robot". */
|
|
5
|
+
item: string;
|
|
6
|
+
min?: number;
|
|
7
|
+
max?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Two buttons and the count between them. The count is an `<output>`, which is a polite live region of its
|
|
11
|
+
* own, so a screen reader hears the new number after each press with nothing wired up.
|
|
12
|
+
*/
|
|
13
|
+
export default function QuantityStepper({ value, onChange, item, min, max }: QuantityStepperProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ShippingMethod as Method } from './store-data';
|
|
2
|
+
export interface ShippingMethodProps {
|
|
3
|
+
methods?: readonly Method[];
|
|
4
|
+
value?: string;
|
|
5
|
+
onValueChange?: (id: string) => void;
|
|
6
|
+
/** Standard shipping is free above this subtotal. */
|
|
7
|
+
freeStandard?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Delivery options as cards. Each card is the `<label>` of a native radio, so the whole card is the
|
|
11
|
+
* target, the set is one tab stop with the arrow keys inside it, and the chosen card is styled with
|
|
12
|
+
* `:has(:checked)` — the radio itself stays visible, because it is what says this is a choice of one.
|
|
13
|
+
*/
|
|
14
|
+
export default function ShippingMethod({ methods, value, onValueChange, freeStandard }: ShippingMethodProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The catalogue the store pages render: plain objects, so swapping in your own fetch changes nothing else.
|
|
3
|
+
* A finish is the object's colour, the wash its picture sits on, and the ink the picture is drawn in.
|
|
4
|
+
*/
|
|
5
|
+
export type Shape = 'lamp' | 'clock' | 'vase' | 'speaker' | 'mug' | 'chair' | 'glass' | 'desk-lamp';
|
|
6
|
+
export interface Finish {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
/** The swatch, as any CSS colour: the finishes are muted on purpose, between the palette's steps. */
|
|
10
|
+
color: string;
|
|
11
|
+
/** The wash behind the picture: the finish, lightened. */
|
|
12
|
+
tile: string;
|
|
13
|
+
/** The picture's line: a deep tone of the same hue, or a light one on a dark finish. */
|
|
14
|
+
ink: string;
|
|
15
|
+
}
|
|
16
|
+
export interface Product {
|
|
17
|
+
slug: string;
|
|
18
|
+
name: string;
|
|
19
|
+
shape: Shape;
|
|
20
|
+
category: string;
|
|
21
|
+
price: number;
|
|
22
|
+
finishes: readonly string[];
|
|
23
|
+
sizes?: readonly string[];
|
|
24
|
+
badge?: string;
|
|
25
|
+
summary: string;
|
|
26
|
+
}
|
|
27
|
+
export interface CartLine {
|
|
28
|
+
id: string;
|
|
29
|
+
slug: string;
|
|
30
|
+
finish: string;
|
|
31
|
+
size?: string;
|
|
32
|
+
quantity: number;
|
|
33
|
+
}
|
|
34
|
+
export interface ShippingMethod {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
detail: string;
|
|
38
|
+
price: number;
|
|
39
|
+
}
|
|
40
|
+
export declare const STORE_NAME = "Still";
|
|
41
|
+
export declare const finishes: Record<string, Finish>;
|
|
42
|
+
export declare const products: readonly Product[];
|
|
43
|
+
export declare const categories: string[];
|
|
44
|
+
export declare const sampleCart: readonly CartLine[];
|
|
45
|
+
export declare const shippingMethods: readonly ShippingMethod[];
|
|
46
|
+
/** Orders over this ship free on the standard service. */
|
|
47
|
+
export declare const FREE_SHIPPING_FROM = 250;
|
|
48
|
+
export declare const TAX_RATE = 0.08;
|
|
49
|
+
/** A price as a tag prints it: $240, with cents only when there are some. */
|
|
50
|
+
export declare const formatPrice: (amount: number) => string;
|
|
51
|
+
export declare const productBySlug: (slug: string) => Product;
|
|
52
|
+
export declare const subtotalOf: (lines: readonly CartLine[]) => number;
|
|
53
|
+
export declare const countOf: (lines: readonly CartLine[]) => number;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The store's design: the built-in components restyled for this one brand, in light and dark. It registers
|
|
4
|
+
* nothing — `Box.createComponents()` returns a design, and `StoreSurface` applies it to its subtree only, so
|
|
5
|
+
* the store can sit inside an app that looks like something else.
|
|
6
|
+
*/
|
|
7
|
+
export declare const storeDesign: any;
|
|
8
|
+
/** Spread on a heading: a medium weight and tight tracking, in whatever sans the system already has. */
|
|
9
|
+
export declare const heading: {
|
|
10
|
+
readonly fontWeight: 500;
|
|
11
|
+
readonly letterSpacing: -0.5;
|
|
12
|
+
};
|
|
13
|
+
/** The small spaced capitals over a section, beside a badge or under a price. */
|
|
14
|
+
export declare const eyebrow: {
|
|
15
|
+
readonly fontSize: 12;
|
|
16
|
+
readonly fontWeight: 500;
|
|
17
|
+
readonly letterSpacing: 1.5;
|
|
18
|
+
readonly textTransform: "uppercase";
|
|
19
|
+
};
|
|
20
|
+
/** A panel on the page: a hairline and soft corners, nothing else. */
|
|
21
|
+
export declare const card: {
|
|
22
|
+
readonly b: 1;
|
|
23
|
+
readonly borderRadius: 4;
|
|
24
|
+
readonly borderColor: "stone-200";
|
|
25
|
+
readonly theme: {
|
|
26
|
+
readonly dark: {
|
|
27
|
+
readonly borderColor: "stone-800";
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
/** Secondary text, in both themes. */
|
|
32
|
+
export declare const muted: {
|
|
33
|
+
readonly color: "stone-500";
|
|
34
|
+
readonly theme: {
|
|
35
|
+
readonly dark: {
|
|
36
|
+
readonly color: "stone-400";
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Where the pages and blocks link to. A provider rather than constants, so the same pages work under any
|
|
42
|
+
* router: wrap them in `<StoreLinks.Provider value={…}>` with your own routes.
|
|
43
|
+
*/
|
|
44
|
+
export interface StoreRoutes {
|
|
45
|
+
shop: string;
|
|
46
|
+
product: (slug: string) => string;
|
|
47
|
+
cart: string;
|
|
48
|
+
checkout: string;
|
|
49
|
+
}
|
|
50
|
+
export declare const StoreLinks: import('react').Context<StoreRoutes>;
|
|
51
|
+
export declare const useStoreLinks: () => StoreRoutes;
|
|
52
|
+
/** The design and the page colours, with no theme of its own: it follows whatever theme is around it. */
|
|
53
|
+
export declare function StoreSurface({ children }: {
|
|
54
|
+
children: ReactNode;
|
|
55
|
+
}): import("react").JSX.Element;
|
|
56
|
+
/**
|
|
57
|
+
* A whole store page: its own light/dark switch, remembered under its own key, around `StoreSurface`.
|
|
58
|
+
* Without `theme` it opens in the reader's saved choice, then their system's.
|
|
59
|
+
*/
|
|
60
|
+
export declare function StoreTheme({ theme, children }: {
|
|
61
|
+
theme?: string;
|
|
62
|
+
children: ReactNode;
|
|
63
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface StoreShellProps {
|
|
3
|
+
/** The number on the cart link. */
|
|
4
|
+
cartCount?: number;
|
|
5
|
+
/** A checkout's header: the brand and a padlock, with nothing to wander off through. */
|
|
6
|
+
checkout?: boolean;
|
|
7
|
+
/** Opens in this theme rather than the reader's saved or system one. */
|
|
8
|
+
theme?: string;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/** The frame every store page shares: the header, the page, the footer, and the theme switch. */
|
|
12
|
+
export default function StoreShell({ cartCount, checkout, theme, children }: StoreShellProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CartLine, Product } from './store-data';
|
|
2
|
+
export interface VariantPickerProps {
|
|
3
|
+
product?: Product;
|
|
4
|
+
/** The finish, when the page owns it — the gallery beside the picker shows the same one. */
|
|
5
|
+
finish?: string;
|
|
6
|
+
onFinishChange?: (finish: string) => void;
|
|
7
|
+
/** Called with the line the reader added. */
|
|
8
|
+
onAdd?: (line: CartLine) => void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Colour, size and quantity, then Add to cart. The swatches and the sizes are native radios, each set one
|
|
12
|
+
* tab stop with the arrow keys inside it, and only the frame around them is drawn here: the `<label>`
|
|
13
|
+
* finds out which radio is chosen with `:has(:checked)`, so nothing is mirrored into state for the styling.
|
|
14
|
+
*/
|
|
15
|
+
export default function VariantPicker({ product, finish, onFinishChange, onAdd }: VariantPickerProps): import("react").JSX.Element;
|
package/rsc.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./rolldown-runtime.cjs"),t=require("./react-shared.cjs");let n=require("react");n=e.t(n,1);let r=require("@box-kite/core");(0,r.getDefaultEngine)().configure({sink:`element`});function i(e,r){let{tag:i=`div`,children:a}=e;if(typeof a==`function`)throw Error(`[box-kite] Box children as a function track hover state, which needs the client Box — render it from a 'use client' module.`);let{classNames:o,styleElements:s}=t.l(e,i===`svg`);return n.default.createElement(n.default.Fragment,null,s,n.default.createElement(i,t.d(e,o),a))}function a(e){return i(e)}var o=a;o.extend=r.BoxExtends.extend,o.components=r.BoxExtends.components,o.keyframes=r.BoxExtends.keyframes,o.spring=r.Springs.spring,o.getVariableValue=e=>(0,r.getDefaultEngine)().getVariableValue(e),o.configure=e=>(0,r.getDefaultEngine)().configure(e),o.viewTransition=r.startViewTransition;function s(e,n){return t.p(t.l(e,n?.svg===!0),e.className)}exports.default=o,exports.useBoxElement=i,exports.useClassNames=s;
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./rolldown-runtime.cjs"),t=require("./react-shared.cjs");let n=require("react");n=e.t(n,1);let r=require("@box-kite/core");(0,r.getDefaultEngine)().configure({sink:`element`});function i(e,r){let{tag:i=`div`,children:a}=e;if(typeof a==`function`)throw Error(`[box-kite] Box children as a function track hover state, which needs the client Box — render it from a 'use client' module.`);let{classNames:o,styleElements:s}=t.l(e,i===`svg`);return n.default.createElement(n.default.Fragment,null,s,n.default.createElement(i,t.d(e,o),a))}function a(e){return i(e)}var o=a;o.extend=r.BoxExtends.extend,o.components=r.BoxExtends.components,o.createComponents=r.BoxExtends.createComponents,o.keyframes=r.BoxExtends.keyframes,o.spring=r.Springs.spring,o.getVariableValue=e=>(0,r.getDefaultEngine)().getVariableValue(e),o.configure=e=>(0,r.getDefaultEngine)().configure(e),o.viewTransition=r.startViewTransition;function s(e,n){return t.p(t.l(e,n?.svg===!0),e.className)}exports.default=o,exports.useBoxElement=i,exports.useClassNames=s;
|
package/rsc.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ interface RscBoxType {
|
|
|
12
12
|
<TTag extends keyof React.JSX.IntrinsicElements = 'div', TKey extends keyof ComponentsAndVariants = never>(props: BoxCoreProps<TTag, TKey>): React.ReactNode;
|
|
13
13
|
extend: typeof BoxExtends.extend;
|
|
14
14
|
components: typeof BoxExtends.components;
|
|
15
|
+
/** A design for one subtree. A Server Component cannot read the provider that applies it; a client one under `<Box.Components>` can. */
|
|
16
|
+
createComponents: typeof BoxExtends.createComponents;
|
|
15
17
|
keyframes: typeof BoxExtends.keyframes;
|
|
16
18
|
/** A spring of your own, sampled into `{ easing, duration }`. Pure arithmetic, so a Server Component can call it. */
|
|
17
19
|
spring: typeof Springs.spring;
|
package/rsc.mjs
CHANGED
|
@@ -13,7 +13,7 @@ function l(e) {
|
|
|
13
13
|
return c(e);
|
|
14
14
|
}
|
|
15
15
|
var u = l;
|
|
16
|
-
u.extend = i.extend, u.components = i.components, u.keyframes = i.keyframes, u.spring = a.spring, u.getVariableValue = (e) => o().getVariableValue(e), u.configure = (e) => o().configure(e), u.viewTransition = s;
|
|
16
|
+
u.extend = i.extend, u.components = i.components, u.createComponents = i.createComponents, u.keyframes = i.keyframes, u.spring = a.spring, u.getVariableValue = (e) => o().getVariableValue(e), u.configure = (e) => o().configure(e), u.viewTransition = s;
|
|
17
17
|
function d(e, r) {
|
|
18
18
|
return n(t(e, r?.svg === !0), e.className);
|
|
19
19
|
}
|
package/scrolling.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./platform.cjs");function t(e,t,n=e.length){let r=0,i=n-1;if(i<=0)return 0;for(;r<i;){let n=r+i+1>>>1;e[n]<=t?r=n:i=n-1}return r}function n(t){let n=e.c(t),r=n?.ownerDocument?.defaultView;if(!n||!r)return null;let i=n.ownerDocument.scrollingElement??n.ownerDocument.documentElement;for(let e=n.parentElement;e&&e!==i&&e!==n.ownerDocument.body;e=e.parentElement)if(/auto|scroll|overlay/.test(r.getComputedStyle(e).overflowY)&&e.scrollHeight>e.clientHeight)return e;return null}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
|
package/scrolling.mjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { c as e } from "./platform.mjs";
|
|
2
|
+
//#region src/utils/virtual/rowSearch.ts
|
|
3
|
+
function t(e, t, n = e.length) {
|
|
4
|
+
let r = 0, i = n - 1;
|
|
5
|
+
if (i <= 0) return 0;
|
|
6
|
+
for (; r < i;) {
|
|
7
|
+
let n = r + i + 1 >>> 1;
|
|
8
|
+
e[n] <= t ? r = n : i = n - 1;
|
|
9
|
+
}
|
|
10
|
+
return r;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/utils/scroll/scrollUtils.ts
|
|
14
|
+
function n(t) {
|
|
15
|
+
let n = e(t), r = n?.ownerDocument?.defaultView;
|
|
16
|
+
if (!n || !r) return null;
|
|
17
|
+
let i = n.ownerDocument.scrollingElement ?? n.ownerDocument.documentElement;
|
|
18
|
+
for (let e = n.parentElement; e && e !== i && e !== n.ownerDocument.body; e = e.parentElement) if (/auto|scroll|overlay/.test(r.getComputedStyle(e).overflowY) && e.scrollHeight > e.clientHeight) return e;
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { t as n, n as t };
|
package/ssg.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime.cjs"),t=require("./client.cjs");let n=require("react-dom/server");n=e.t(n,1);function r(){return t.
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime.cjs"),t=require("./client.cjs");let n=require("react-dom/server");n=e.t(n,1);function r(){return t.i.getStyles()}function i(){return t.i.getStyleTag()}function a(){t.i.clear()}function o(e,t=!0){let o=n.default.renderToStaticMarkup(e),s=r(),c=i();if(t){let e=o.indexOf(`<head>`);if(e>-1){let t=e+6;o=o.substring(0,t)+c+o.substring(t)}}return a(),{html:o,styles:s,styleTag:c}}exports.getStyleTag=i,exports.getStyles=r,exports.renderToStaticMarkup=o,exports.resetStyles=a;
|
package/ssg.mjs
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ElementLike } from '../dom/domUtils';
|
|
2
|
+
/**
|
|
3
|
+
* The element that scrolls `value` into view, or `null` for the page: the nearest ancestor that scrolls and has
|
|
4
|
+
* something to scroll. Both halves count — `overflow-x: hidden` alone computes `overflow-y` to `auto`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function scrollParentOf(value: ElementLike): HTMLElement | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Where an item sat when a drag began, relative to the list: its top edge and its height, in px. */
|
|
2
|
+
export interface SortableSlot {
|
|
3
|
+
top: number;
|
|
4
|
+
height: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The model behind `<SortableList>`: which slot a dragged item is over, how far its neighbours step aside
|
|
8
|
+
* to make room, and the keyboard's moves. The slots are read once, when the drag starts, so every answer
|
|
9
|
+
* is about the layout the person is looking at rather than one that moves under the pointer.
|
|
10
|
+
*/
|
|
11
|
+
declare namespace SortableUtils {
|
|
12
|
+
/** How far a press on a handle travels before it is a drag rather than a press, in px. */
|
|
13
|
+
const SLOP = 4;
|
|
14
|
+
/** The index the held item would be dropped at, having travelled `travel` px from slot `from`. */
|
|
15
|
+
function targetIndex(slots: readonly SortableSlot[], from: number, travel: number): number;
|
|
16
|
+
/** What the held item takes up in the list: its height and the gap after it, which is what a neighbour steps by. */
|
|
17
|
+
function pitchOf(slots: readonly SortableSlot[], from: number): number;
|
|
18
|
+
/** How far the item at `index` steps aside while the item from `from` is held over `to`. */
|
|
19
|
+
function shiftOf(slots: readonly SortableSlot[], from: number, to: number, index: number): number;
|
|
20
|
+
/** `array` with the entry at `from` moved to `to`, everything between stepping along by one. A new array. */
|
|
21
|
+
function move<T>(array: readonly T[], from: number, to: number): T[];
|
|
22
|
+
/** Where a key moves the held item in a list of `count`, or `null` when the key is not a move. A vertical list, so the block axis. */
|
|
23
|
+
function keyTarget(key: string, index: number, count: number): number | null;
|
|
24
|
+
}
|
|
25
|
+
export default SortableUtils;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Which tray a swipe reveals: `start` sits under the inline start edge, so in a left-to-right page a swipe to the right shows it. */
|
|
2
|
+
export type SwipeSide = 'start' | 'end';
|
|
3
|
+
/** How wide each tray is when it is fully open, in px. `0` is a side with no actions, which a swipe cannot open. */
|
|
4
|
+
export interface SwipeTrays {
|
|
5
|
+
start: number;
|
|
6
|
+
end: number;
|
|
7
|
+
}
|
|
8
|
+
/** Where a released swipe comes to rest: open on one side, closed, or carried through to the outermost action. */
|
|
9
|
+
export interface SwipeRest {
|
|
10
|
+
open: SwipeSide | null;
|
|
11
|
+
full: SwipeSide | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The model behind `<SwipeItem>`. Every offset here is **logical**: positive moves the content towards the
|
|
15
|
+
* inline end and reveals the `start` tray, so the arithmetic is the same in a right-to-left page and only
|
|
16
|
+
* the component turns it back into a physical translate. No DOM and no React — a swipe is numbers.
|
|
17
|
+
*/
|
|
18
|
+
declare namespace SwipeUtils {
|
|
19
|
+
/** How far a press travels before it is a gesture at all, in px — under it, a press is a tap. */
|
|
20
|
+
const SLOP = 8;
|
|
21
|
+
/** A release faster than this, in px per ms, is a flick: it goes the way it was going, however far it got. */
|
|
22
|
+
const FLICK = 0.4;
|
|
23
|
+
/** How much of the item a full swipe has to cross before letting go performs the outermost action. */
|
|
24
|
+
const FULL_RATIO = 0.6;
|
|
25
|
+
/**
|
|
26
|
+
* What a press is once it has moved past the slop: a swipe when it went more sideways than up or down,
|
|
27
|
+
* otherwise a scroll the page owns. `null` until then.
|
|
28
|
+
*/
|
|
29
|
+
function intent(dx: number, dy: number): 'swipe' | 'scroll' | null;
|
|
30
|
+
/** The offset for a press that started at `rest` and has travelled `travel` along the reading order. */
|
|
31
|
+
function offsetFor(rest: number, travel: number, trays: SwipeTrays, width: number, fullSwipe: boolean): number;
|
|
32
|
+
/** The side whose outermost action a release would perform, or `null` when it has not been carried far enough. */
|
|
33
|
+
function armed(offset: number, trays: SwipeTrays, width: number, fullSwipe: boolean): SwipeSide | null;
|
|
34
|
+
/**
|
|
35
|
+
* Where a release settles. A flick goes the way it was moving; otherwise a tray past half open opens and
|
|
36
|
+
* one short of it closes — the rule every platform swipe follows, because the eye judges halfway.
|
|
37
|
+
*/
|
|
38
|
+
function settle(offset: number, velocity: number, trays: SwipeTrays, width: number, fullSwipe: boolean): SwipeRest;
|
|
39
|
+
/** A pointer sample: when, in ms, and where along the line, in px. */
|
|
40
|
+
interface Sample {
|
|
41
|
+
t: number;
|
|
42
|
+
x: number;
|
|
43
|
+
}
|
|
44
|
+
/** How far back a release looks to judge its speed: the last tenth of a second is the flick, not the whole drag. */
|
|
45
|
+
const VELOCITY_WINDOW = 100;
|
|
46
|
+
/** The samples worth keeping once `next` arrives: those inside the window, and `next`. */
|
|
47
|
+
function track(samples: readonly Sample[], next: Sample): Sample[];
|
|
48
|
+
/** The speed along the line at release, in px per ms. Under a frame of samples is no measurement at all, so `0`. */
|
|
49
|
+
function velocity(samples: readonly Sample[]): number;
|
|
50
|
+
/** The offset a tray rests at: its whole width, towards the side it is on. */
|
|
51
|
+
function restOffset(open: SwipeSide | null, trays: SwipeTrays): number;
|
|
52
|
+
}
|
|
53
|
+
export default SwipeUtils;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { VirtualWindow } from './virtualUtils';
|
|
2
|
+
/**
|
|
3
|
+
* Windowing for a list whose rows each have their own height — `<VirtualList>`'s, where `VirtualUtils` is the
|
|
4
|
+
* fixed pitch a listbox has. Its own module so neither consumer carries the other's arithmetic.
|
|
5
|
+
*/
|
|
6
|
+
declare namespace MeasuredWindow {
|
|
7
|
+
/** Rows either side of the screen when the caller names none. */
|
|
8
|
+
const DEFAULT_OVERSCAN = 4;
|
|
9
|
+
/** How far a focused row outside the window may be from it and still be kept rendered, so focus is not dropped. */
|
|
10
|
+
const PIN_REACH = 50;
|
|
11
|
+
/** Where each row of a list whose rows differ in height starts: `count + 1` entries, the last being the total. */
|
|
12
|
+
function offsetsOf(sizes: readonly number[]): number[];
|
|
13
|
+
/** What a row not yet drawn counts as: the mean of the rows that have been, or `fallback` before any has. */
|
|
14
|
+
function typicalSize(sizes: Iterable<number>, fallback: number): number;
|
|
15
|
+
interface MeasuredWindowOptions {
|
|
16
|
+
/** From `offsetsOf`. */
|
|
17
|
+
offsets: readonly number[];
|
|
18
|
+
/** The part of the list on screen, in px from the list's own top edge. Either end may be outside the list. */
|
|
19
|
+
viewStart: number;
|
|
20
|
+
viewEnd: number;
|
|
21
|
+
overscan?: number;
|
|
22
|
+
/** A row that has to stay rendered — the one focus is in — or `-1`. */
|
|
23
|
+
pin?: number;
|
|
24
|
+
}
|
|
25
|
+
/** The rows to render for a list whose rows each have their own height, and the space above and below them. */
|
|
26
|
+
function measuredWindow(options: MeasuredWindowOptions): VirtualWindow;
|
|
27
|
+
}
|
|
28
|
+
export default MeasuredWindow;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Where each row starts, ascending: an array, or a list that computes an entry when it is asked for one. */
|
|
2
|
+
export type RowTops = {
|
|
3
|
+
readonly length: number;
|
|
4
|
+
readonly [index: number]: number;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* The row a point `y` falls in — the last of the first `count` rows that starts at or above it — clamped
|
|
8
|
+
* to the list. A binary search, since a scroll asks on every frame and a datasource grid lays out a million
|
|
9
|
+
* rows it never allocates. `DataGrid` and `VirtualList` both window through it.
|
|
10
|
+
*/
|
|
11
|
+
export declare function rowAt(tops: RowTops, y: number, count?: number): number;
|