@funstack/ui 0.1.0-alpha.7 → 0.1.0-alpha.9
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/combobox/combobox-popup.mjs +1 -1
- package/dist/combobox/combobox-popup.mjs.map +1 -1
- package/dist/csp/csp-provider.d.mts +25 -0
- package/dist/csp/csp-provider.d.mts.map +1 -0
- package/dist/csp/csp-provider.mjs +24 -0
- package/dist/csp/csp-provider.mjs.map +1 -0
- package/dist/csp/index.d.mts +3 -0
- package/dist/csp/index.mjs +3 -0
- package/dist/csp/style-hashes.d.mts +19 -0
- package/dist/csp/style-hashes.d.mts.map +1 -0
- package/dist/csp/style-hashes.mjs +21 -0
- package/dist/csp/style-hashes.mjs.map +1 -0
- package/dist/index.d.mts +7 -3
- package/dist/index.mjs +3 -1
- package/dist/internal/anchor-position.d.mts +11 -3
- package/dist/internal/anchor-position.d.mts.map +1 -1
- package/dist/internal/anchor-position.mjs +180 -6
- package/dist/internal/anchor-position.mjs.map +1 -1
- package/dist/internal/csp-context.mjs +8 -0
- package/dist/internal/csp-context.mjs.map +1 -0
- package/dist/internal/tooltip-warm.mjs +29 -0
- package/dist/internal/tooltip-warm.mjs.map +1 -0
- package/dist/internal/use-popover-popup.mjs +22 -4
- package/dist/internal/use-popover-popup.mjs.map +1 -1
- package/dist/internal/use-resolved-placement.mjs +146 -0
- package/dist/internal/use-resolved-placement.mjs.map +1 -0
- package/dist/menu/index.d.mts +5 -1
- package/dist/menu/index.d.mts.map +1 -1
- package/dist/menu/index.mjs +5 -1
- package/dist/menu/index.mjs.map +1 -1
- package/dist/menu/menu-context-trigger.d.mts +46 -0
- package/dist/menu/menu-context-trigger.d.mts.map +1 -0
- package/dist/menu/menu-context-trigger.mjs +405 -0
- package/dist/menu/menu-context-trigger.mjs.map +1 -0
- package/dist/menu/menu-context.mjs +44 -1
- package/dist/menu/menu-context.mjs.map +1 -1
- package/dist/menu/menu-dom.mjs +42 -2
- package/dist/menu/menu-dom.mjs.map +1 -1
- package/dist/menu/menu-popup.d.mts +36 -8
- package/dist/menu/menu-popup.d.mts.map +1 -1
- package/dist/menu/menu-popup.mjs +214 -22
- package/dist/menu/menu-popup.mjs.map +1 -1
- package/dist/menu/menu-root.d.mts +5 -0
- package/dist/menu/menu-root.d.mts.map +1 -1
- package/dist/menu/menu-root.mjs +56 -6
- package/dist/menu/menu-root.mjs.map +1 -1
- package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-submenu-trigger.mjs +27 -11
- package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
- package/dist/popover/popover-popup.d.mts +21 -7
- package/dist/popover/popover-popup.d.mts.map +1 -1
- package/dist/popover/popover-popup.mjs +16 -6
- package/dist/popover/popover-popup.mjs.map +1 -1
- package/dist/tooltip/index.d.mts +8 -5
- package/dist/tooltip/index.d.mts.map +1 -1
- package/dist/tooltip/index.mjs +6 -3
- package/dist/tooltip/index.mjs.map +1 -1
- package/dist/tooltip/tooltip-arrow.d.mts +30 -0
- package/dist/tooltip/tooltip-arrow.d.mts.map +1 -0
- package/dist/tooltip/tooltip-arrow.mjs +45 -0
- package/dist/tooltip/tooltip-arrow.mjs.map +1 -0
- package/dist/tooltip/tooltip-context.d.mts +7 -0
- package/dist/tooltip/tooltip-context.d.mts.map +1 -1
- package/dist/tooltip/tooltip-context.mjs +2 -1
- package/dist/tooltip/tooltip-context.mjs.map +1 -1
- package/dist/tooltip/tooltip-popup.d.mts +21 -6
- package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
- package/dist/tooltip/tooltip-popup.mjs +28 -6
- package/dist/tooltip/tooltip-popup.mjs.map +1 -1
- package/dist/tooltip/tooltip-trigger.d.mts +9 -2
- package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
- package/dist/tooltip/tooltip-trigger.mjs +21 -5
- package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
- package/dist/tooltip/use-tooltip-interaction.mjs +26 -2
- package/dist/tooltip/use-tooltip-interaction.mjs.map +1 -1
- package/package.json +2 -1
|
@@ -72,7 +72,7 @@ function ComboboxPopup({ keepMounted, transition, className, style, children, re
|
|
|
72
72
|
state,
|
|
73
73
|
className,
|
|
74
74
|
style: (s) => ({
|
|
75
|
-
positionArea: "block-end span-inline-end",
|
|
75
|
+
positionArea: "self-block-end span-self-inline-end",
|
|
76
76
|
positionTryFallbacks: "flip-block",
|
|
77
77
|
minWidth: "anchor-size(width)",
|
|
78
78
|
...resolveStateValue(style, s)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox-popup.mjs","names":[],"sources":["../../src/combobox/combobox-popup.tsx"],"sourcesContent":["\"use client\";\nimport { Activity, useCallback, useMemo } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n MouseEvent,\n PointerEvent,\n ReactNode,\n ViewTransitionClass,\n} from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { mergeRefs } from \"../internal/merge-props.js\";\nimport { ToolbarContext } from \"../internal/toolbar-context.js\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { usePopoverPopup } from \"../internal/use-popover-popup.js\";\nimport { resolveStateValue, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { ComboboxPopupContext, useComboboxContext } from \"./combobox-context.js\";\n\nexport interface ComboboxPopupState {\n /** Committed open state. Read `:popover-open` for the DOM truth. */\n readonly open: boolean;\n /** The results shown are for an older text. */\n readonly stale: boolean;\n /** The deferred text the results are for. */\n readonly query: string;\n}\n\nexport interface ComboboxPopupProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n | \"id\"\n | \"popover\"\n | \"onToggle\"\n | \"onBeforeToggle\"\n | \"onPointerDown\"\n | \"onMouseDown\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /**\n * `false` (default): the children are not rendered while the listbox is closed. `true`: they\n * stay mounted inside `<Activity mode=\"hidden\">`.\n */\n keepMounted?: boolean;\n /**\n * Forwarded to the `<ViewTransition default>` around the popover element itself. Animates\n * library-driven opens and closes (typing, the Trigger, an accepted option) in every engine;\n * dismissals are the browser's (CSS only). **A deferred results render also activates the\n * boundary** (React: updates from `useDeferredValue` animate), so use a type map with\n * `default: \"none\"` unless every result change should cross-fade. Static.\n */\n transition?: ViewTransitionClass;\n className?: StateValue<string | undefined, ComboboxPopupState>;\n style?: StateValue<CSSProperties | undefined, ComboboxPopupState>;\n children?: StateValue<ReactNode, ComboboxPopupState>;\n /** Must render a `<div>`: a `<dialog>` would pull focus out of the input. */\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ComboboxPopupState>;\n}\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nconst preventDefault = (event: { preventDefault(): void }) => event.preventDefault();\n\n/**\n * The listbox's container: `<div popover=\"auto\">`, opened by the library with\n * `showPopover({ source: input })` and placed below (or, flipped, above) the input with CSS\n * Anchor Positioning, at least as wide as the input. Focus never enters it: a press anywhere in\n * it is `preventDefault()`ed so the input keeps focus (design 7.1). Holds the `List` and, outside\n * it, `Empty` and `Status`. Style it with `:popover-open`; it emits `data-stale` but no\n * `data-open`.\n *\n * Owned keys (conventions 1.2): `id`, `popover`, `onPointerDown`, `onMouseDown`, `data-stale`.\n * Inline `position-area`, `position-try-fallbacks` and `min-width` sit under the consumer's\n * `style` (`style={{ positionTryFallbacks: \"none\" }}` removes the flip).\n */\nexport function ComboboxPopup({\n keepMounted,\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: ComboboxPopupProps) {\n const ctx = useComboboxContext(\"Combobox.Popup\");\n const { popover } = ctx;\n\n const { setElement, visible, wrapContent } = usePopoverPopup(popover, {\n part: \"Combobox.Popup\",\n initialFocus: undefined,\n // Focus stays in the input: nothing inside the popup is ever focused.\n resolveInitialFocus: () => null,\n keepMounted,\n transition,\n });\n\n const devRef = useCallback((element: HTMLElement) => {\n if (isDev && element.tagName !== \"DIV\") {\n console.error(\n `Combobox.Popup: rendered a <${element.tagName.toLowerCase()}>. Render a <div>: a ` +\n \"<dialog popover> runs the dialog focusing steps and takes focus out of the input.\",\n );\n }\n return () => {};\n }, []);\n const ref = useMemo(() => mergeRefs(setElement, devRef), [setElement, devRef]);\n\n const state: ComboboxPopupState = {\n open: popover.committed,\n stale: ctx.stale,\n query: ctx.query,\n };\n\n const libraryProps: ComponentPropsWithRef<\"div\"> & DataAttributes = {\n id: popover.ids.popup,\n popover: \"auto\",\n onPointerDown: (event: PointerEvent<HTMLDivElement>) => preventDefault(event),\n onMouseDown: (event: MouseEvent<HTMLDivElement>) => preventDefault(event),\n \"data-stale\": dataAttr(ctx.stale),\n };\n\n const content = (s: ComboboxPopupState): ReactNode => {\n let node: ReactNode;\n if (keepMounted === true) {\n node = (\n <Activity mode={visible ? \"visible\" : \"hidden\"}>\n {wrapContent(resolveStateValue(children, s))}\n </Activity>\n );\n } else {\n node = visible ? wrapContent(resolveStateValue(children, s)) : null;\n }\n // Not part of an enclosing Toolbar (the engine excludes `[popover]`).\n return (\n <ComboboxPopupContext value={true}>\n <ToolbarContext value={null}>{node}</ToolbarContext>\n </ComboboxPopupContext>\n );\n };\n\n const element = useRender<ComponentPropsWithRef<\"div\">, ComboboxPopupState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n //
|
|
1
|
+
{"version":3,"file":"combobox-popup.mjs","names":[],"sources":["../../src/combobox/combobox-popup.tsx"],"sourcesContent":["\"use client\";\nimport { Activity, useCallback, useMemo } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n MouseEvent,\n PointerEvent,\n ReactNode,\n ViewTransitionClass,\n} from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { mergeRefs } from \"../internal/merge-props.js\";\nimport { ToolbarContext } from \"../internal/toolbar-context.js\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { usePopoverPopup } from \"../internal/use-popover-popup.js\";\nimport { resolveStateValue, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { ComboboxPopupContext, useComboboxContext } from \"./combobox-context.js\";\n\nexport interface ComboboxPopupState {\n /** Committed open state. Read `:popover-open` for the DOM truth. */\n readonly open: boolean;\n /** The results shown are for an older text. */\n readonly stale: boolean;\n /** The deferred text the results are for. */\n readonly query: string;\n}\n\nexport interface ComboboxPopupProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n | \"id\"\n | \"popover\"\n | \"onToggle\"\n | \"onBeforeToggle\"\n | \"onPointerDown\"\n | \"onMouseDown\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /**\n * `false` (default): the children are not rendered while the listbox is closed. `true`: they\n * stay mounted inside `<Activity mode=\"hidden\">`.\n */\n keepMounted?: boolean;\n /**\n * Forwarded to the `<ViewTransition default>` around the popover element itself. Animates\n * library-driven opens and closes (typing, the Trigger, an accepted option) in every engine;\n * dismissals are the browser's (CSS only). **A deferred results render also activates the\n * boundary** (React: updates from `useDeferredValue` animate), so use a type map with\n * `default: \"none\"` unless every result change should cross-fade. Static.\n */\n transition?: ViewTransitionClass;\n className?: StateValue<string | undefined, ComboboxPopupState>;\n style?: StateValue<CSSProperties | undefined, ComboboxPopupState>;\n children?: StateValue<ReactNode, ComboboxPopupState>;\n /** Must render a `<div>`: a `<dialog>` would pull focus out of the input. */\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ComboboxPopupState>;\n}\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nconst preventDefault = (event: { preventDefault(): void }) => event.preventDefault();\n\n/**\n * The listbox's container: `<div popover=\"auto\">`, opened by the library with\n * `showPopover({ source: input })` and placed below (or, flipped, above) the input with CSS\n * Anchor Positioning, at least as wide as the input. Focus never enters it: a press anywhere in\n * it is `preventDefault()`ed so the input keeps focus (design 7.1). Holds the `List` and, outside\n * it, `Empty` and `Status`. Style it with `:popover-open`; it emits `data-stale` but no\n * `data-open`.\n *\n * Owned keys (conventions 1.2): `id`, `popover`, `onPointerDown`, `onMouseDown`, `data-stale`.\n * Inline `position-area`, `position-try-fallbacks` and `min-width` sit under the consumer's\n * `style` (`style={{ positionTryFallbacks: \"none\" }}` removes the flip).\n */\nexport function ComboboxPopup({\n keepMounted,\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: ComboboxPopupProps) {\n const ctx = useComboboxContext(\"Combobox.Popup\");\n const { popover } = ctx;\n\n const { setElement, visible, wrapContent } = usePopoverPopup(popover, {\n part: \"Combobox.Popup\",\n initialFocus: undefined,\n // Focus stays in the input: nothing inside the popup is ever focused.\n resolveInitialFocus: () => null,\n keepMounted,\n transition,\n });\n\n const devRef = useCallback((element: HTMLElement) => {\n if (isDev && element.tagName !== \"DIV\") {\n console.error(\n `Combobox.Popup: rendered a <${element.tagName.toLowerCase()}>. Render a <div>: a ` +\n \"<dialog popover> runs the dialog focusing steps and takes focus out of the input.\",\n );\n }\n return () => {};\n }, []);\n const ref = useMemo(() => mergeRefs(setElement, devRef), [setElement, devRef]);\n\n const state: ComboboxPopupState = {\n open: popover.committed,\n stale: ctx.stale,\n query: ctx.query,\n };\n\n const libraryProps: ComponentPropsWithRef<\"div\"> & DataAttributes = {\n id: popover.ids.popup,\n popover: \"auto\",\n onPointerDown: (event: PointerEvent<HTMLDivElement>) => preventDefault(event),\n onMouseDown: (event: MouseEvent<HTMLDivElement>) => preventDefault(event),\n \"data-stale\": dataAttr(ctx.stale),\n };\n\n const content = (s: ComboboxPopupState): ReactNode => {\n let node: ReactNode;\n if (keepMounted === true) {\n node = (\n <Activity mode={visible ? \"visible\" : \"hidden\"}>\n {wrapContent(resolveStateValue(children, s))}\n </Activity>\n );\n } else {\n node = visible ? wrapContent(resolveStateValue(children, s)) : null;\n }\n // Not part of an enclosing Toolbar (the engine excludes `[popover]`).\n return (\n <ComboboxPopupContext value={true}>\n <ToolbarContext value={null}>{node}</ToolbarContext>\n </ComboboxPopupContext>\n );\n };\n\n const element = useRender<ComponentPropsWithRef<\"div\">, ComboboxPopupState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n // `self-*` keywords resolve against the popup's own inherited direction, so a `dir=\"rtl\"`\n // page or container flips the listbox with no JS; plain logical keywords would follow the\n // root only (design 7.2, conventions 13.1). The consumer wins.\n style: (s) => ({\n positionArea: \"self-block-end span-self-inline-end\",\n positionTryFallbacks: \"flip-block\",\n minWidth: \"anchor-size(width)\",\n ...resolveStateValue(style, s),\n }),\n children: content,\n props: rest,\n libraryProps,\n ref,\n });\n\n return useTransitionBoundary(\"Combobox.Popup\", transition, element);\n}\n\nComboboxPopup.displayName = \"ComboboxPopup\";\n"],"mappings":";;;;;;;;;;;;AA6DA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AAEvC,MAAM,kBAAkB,UAAsC,MAAM,eAAe;;;;;;;;;;;;;AAcnF,SAAgB,cAAc,EAC5B,aACA,YACA,WACA,OACA,UACA,QACA,GAAG,QACkB;CACrB,MAAM,MAAM,mBAAmB,gBAAgB;CAC/C,MAAM,EAAE,YAAY;CAEpB,MAAM,EAAE,YAAY,SAAS,gBAAgB,gBAAgB,SAAS;EACpE,MAAM;EACN,cAAc,KAAA;EAEd,2BAA2B;EAC3B;EACA;CACF,CAAC;CAED,MAAM,SAAS,aAAa,YAAyB;EACnD,IAAI,SAAS,QAAQ,YAAY,OAC/B,QAAQ,MACN,+BAA+B,QAAQ,QAAQ,YAAY,EAAE,uGAE/D;EAEF,aAAa,CAAC;CAChB,GAAG,CAAC,CAAC;CACL,MAAM,MAAM,cAAc,UAAU,YAAY,MAAM,GAAG,CAAC,YAAY,MAAM,CAAC;CAE7E,MAAM,QAA4B;EAChC,MAAM,QAAQ;EACd,OAAO,IAAI;EACX,OAAO,IAAI;CACb;CAEA,MAAM,eAA8D;EAClE,IAAI,QAAQ,IAAI;EAChB,SAAS;EACT,gBAAgB,UAAwC,eAAe,KAAK;EAC5E,cAAc,UAAsC,eAAe,KAAK;EACxE,cAAc,SAAS,IAAI,KAAK;CAClC;CAEA,MAAM,WAAW,MAAqC;EACpD,IAAI;EACJ,IAAI,gBAAgB,MAClB,OACE,oBAAC,UAAD;GAAU,MAAM,UAAU,YAAY;GACnC,UAAA,YAAY,kBAAkB,UAAU,CAAC,CAAC;EACnC,CAAA;OAGZ,OAAO,UAAU,YAAY,kBAAkB,UAAU,CAAC,CAAC,IAAI;EAGjE,OACE,oBAAC,sBAAD;GAAsB,OAAO;GAC3B,UAAA,oBAAC,gBAAD;IAAgB,OAAO;IAAO,UAAA;GAAqB,CAAA;EAC/B,CAAA;CAE1B;CAEA,MAAM,UAAU,UAA4D;EAC1E,gBAAgB;EAChB;EACA;EACA;EAIA,QAAQ,OAAO;GACb,cAAc;GACd,sBAAsB;GACtB,UAAU;GACV,GAAG,kBAAkB,OAAO,CAAC;EAC/B;EACA,UAAU;EACV,OAAO;EACP;EACA;CACF,CAAC;CAED,OAAO,sBAAsB,kBAAkB,YAAY,OAAO;AACpE;AAEA,cAAc,cAAc"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
//#region src/csp/csp-provider.d.ts
|
|
3
|
+
export interface CSPProviderProps {
|
|
4
|
+
/**
|
|
5
|
+
* The per-response nonce of a nonce-based `style-src` policy. Pass the same value as React's
|
|
6
|
+
* `nonce: { style }` render option: during server rendering React drops a hoisted
|
|
7
|
+
* `<style precedence>` whose `nonce` differs from it (a missing provider included), and strips
|
|
8
|
+
* the `nonce` when the option is absent or in its string form.
|
|
9
|
+
*/
|
|
10
|
+
nonce?: string;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Hands a Content Security Policy nonce to every library part that renders a hoisted `<style>`
|
|
15
|
+
* (`Menu.Popup`'s point placement rules, `Tooltip.Trigger`'s skip-delay rule with
|
|
16
|
+
* `experimental_interestFor`), which forward it as the element's `nonce` (design/conventions.md
|
|
17
|
+
* 12). The library's only provider; its prop is serialisable, so a Server Component layout that
|
|
18
|
+
* knows the nonce renders it once. Hash-based policies need no provider: use `STYLE_SHA256`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function CSPProvider({ nonce, children }: CSPProviderProps): import("react").JSX.Element;
|
|
21
|
+
export declare namespace CSPProvider {
|
|
22
|
+
var displayName: string;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//# sourceMappingURL=csp-provider.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csp-provider.d.mts","names":[],"sources":["../../src/csp/csp-provider.tsx"],"mappings":";;iBAMiB;;;;;;;EAOf;EACA,WAAW;;;;;;;;;wBAUG,cAAc,OAAO,YAAY,mCAAgB,IAAA;yBAAjD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { CSPContext } from "../internal/csp-context.mjs";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/csp/csp-provider.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Hands a Content Security Policy nonce to every library part that renders a hoisted `<style>`
|
|
8
|
+
* (`Menu.Popup`'s point placement rules, `Tooltip.Trigger`'s skip-delay rule with
|
|
9
|
+
* `experimental_interestFor`), which forward it as the element's `nonce` (design/conventions.md
|
|
10
|
+
* 12). The library's only provider; its prop is serialisable, so a Server Component layout that
|
|
11
|
+
* knows the nonce renders it once. Hash-based policies need no provider: use `STYLE_SHA256`.
|
|
12
|
+
*/
|
|
13
|
+
function CSPProvider({ nonce, children }) {
|
|
14
|
+
const value = useMemo(() => ({ nonce }), [nonce]);
|
|
15
|
+
return /* @__PURE__ */ jsx(CSPContext, {
|
|
16
|
+
value,
|
|
17
|
+
children
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
CSPProvider.displayName = "CSPProvider";
|
|
21
|
+
//#endregion
|
|
22
|
+
export { CSPProvider };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=csp-provider.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csp-provider.mjs","names":[],"sources":["../../src/csp/csp-provider.tsx"],"sourcesContent":["\"use client\";\nimport { useMemo } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { CSPContext } from \"../internal/csp-context.js\";\nimport type { CSPContextValue } from \"../internal/csp-context.js\";\n\nexport interface CSPProviderProps {\n /**\n * The per-response nonce of a nonce-based `style-src` policy. Pass the same value as React's\n * `nonce: { style }` render option: during server rendering React drops a hoisted\n * `<style precedence>` whose `nonce` differs from it (a missing provider included), and strips\n * the `nonce` when the option is absent or in its string form.\n */\n nonce?: string;\n children?: ReactNode;\n}\n\n/**\n * Hands a Content Security Policy nonce to every library part that renders a hoisted `<style>`\n * (`Menu.Popup`'s point placement rules, `Tooltip.Trigger`'s skip-delay rule with\n * `experimental_interestFor`), which forward it as the element's `nonce` (design/conventions.md\n * 12). The library's only provider; its prop is serialisable, so a Server Component layout that\n * knows the nonce renders it once. Hash-based policies need no provider: use `STYLE_SHA256`.\n */\nexport function CSPProvider({ nonce, children }: CSPProviderProps) {\n const value = useMemo<CSPContextValue>(() => ({ nonce }), [nonce]);\n return <CSPContext value={value}>{children}</CSPContext>;\n}\n\nCSPProvider.displayName = \"CSPProvider\";\n"],"mappings":";;;;;;;;;;;;AAwBA,SAAgB,YAAY,EAAE,OAAO,YAA8B;CACjE,MAAM,QAAQ,eAAgC,EAAE,MAAM,IAAI,CAAC,KAAK,CAAC;CACjE,OAAO,oBAAC,YAAD;EAAmB;EAAQ;CAAqB,CAAA;AACzD;AAEA,YAAY,cAAc"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/csp/style-hashes.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The base64 SHA-256 of each shipped stylesheet, keyed by its `<style href>`. Allow them with
|
|
4
|
+
* `style-src 'sha256-<value>'`:
|
|
5
|
+
*
|
|
6
|
+
* - `"@funstack/ui/menu-point"`: `Menu.Popup`'s `@position-try` rules for a menu opened at a
|
|
7
|
+
* point (`Menu.ContextTrigger`), inserted on the client by the first such open.
|
|
8
|
+
* - `"@funstack/ui/tooltip-warm"`: `Tooltip.Trigger`'s skip-delay rule, rendered only with
|
|
9
|
+
* `experimental_interestFor` (during server rendering too).
|
|
10
|
+
*
|
|
11
|
+
* A blocked stylesheet degrades: the point menu opens at the point but never flips, and on the
|
|
12
|
+
* native tooltip path each tooltip waits its own `delay` (no skip-delay).
|
|
13
|
+
*/
|
|
14
|
+
export declare const STYLE_SHA256: {
|
|
15
|
+
readonly "@funstack/ui/menu-point": "Wm5aBRstuZ3S9kDs0IbldhidU/prqpIW69jEAS0N9mc=";
|
|
16
|
+
readonly "@funstack/ui/tooltip-warm": "nFBZGhNvo46ITrlBb48hELUAyWzpeIdJCziCectFQa4=";
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
//# sourceMappingURL=style-hashes.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-hashes.d.mts","names":[],"sources":["../../src/csp/style-hashes.ts"],"mappings":";;;;;;;;;;;;;qBAgBa;WACX;WACA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/csp/style-hashes.ts
|
|
2
|
+
/**
|
|
3
|
+
* The base64 SHA-256 of each shipped stylesheet, keyed by its `<style href>`. Allow them with
|
|
4
|
+
* `style-src 'sha256-<value>'`:
|
|
5
|
+
*
|
|
6
|
+
* - `"@funstack/ui/menu-point"`: `Menu.Popup`'s `@position-try` rules for a menu opened at a
|
|
7
|
+
* point (`Menu.ContextTrigger`), inserted on the client by the first such open.
|
|
8
|
+
* - `"@funstack/ui/tooltip-warm"`: `Tooltip.Trigger`'s skip-delay rule, rendered only with
|
|
9
|
+
* `experimental_interestFor` (during server rendering too).
|
|
10
|
+
*
|
|
11
|
+
* A blocked stylesheet degrades: the point menu opens at the point but never flips, and on the
|
|
12
|
+
* native tooltip path each tooltip waits its own `delay` (no skip-delay).
|
|
13
|
+
*/
|
|
14
|
+
const STYLE_SHA256 = {
|
|
15
|
+
"@funstack/ui/menu-point": "Wm5aBRstuZ3S9kDs0IbldhidU/prqpIW69jEAS0N9mc=",
|
|
16
|
+
"@funstack/ui/tooltip-warm": "nFBZGhNvo46ITrlBb48hELUAyWzpeIdJCziCectFQa4="
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { STYLE_SHA256 };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=style-hashes.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-hashes.mjs","names":[],"sources":["../../src/csp/style-hashes.ts"],"sourcesContent":["// The SHA-256 of every stylesheet the library ships (design/conventions.md 12), for hash-based\n// Content Security Policies. Committed constants: `csp.test.ts` recomputes them from the CSS\n// strings, so they cannot drift. No \"use client\" directive: data only (conventions 7.1).\n\n/**\n * The base64 SHA-256 of each shipped stylesheet, keyed by its `<style href>`. Allow them with\n * `style-src 'sha256-<value>'`:\n *\n * - `\"@funstack/ui/menu-point\"`: `Menu.Popup`'s `@position-try` rules for a menu opened at a\n * point (`Menu.ContextTrigger`), inserted on the client by the first such open.\n * - `\"@funstack/ui/tooltip-warm\"`: `Tooltip.Trigger`'s skip-delay rule, rendered only with\n * `experimental_interestFor` (during server rendering too).\n *\n * A blocked stylesheet degrades: the point menu opens at the point but never flips, and on the\n * native tooltip path each tooltip waits its own `delay` (no skip-delay).\n */\nexport const STYLE_SHA256 = {\n \"@funstack/ui/menu-point\": \"Wm5aBRstuZ3S9kDs0IbldhidU/prqpIW69jEAS0N9mc=\",\n \"@funstack/ui/tooltip-warm\": \"nFBZGhNvo46ITrlBb48hELUAyWzpeIdJCziCectFQa4=\",\n} as const;\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAa,eAAe;CAC1B,2BAA2B;CAC3B,6BAA6B;AAC/B"}
|
package/dist/index.d.mts
CHANGED
|
@@ -24,6 +24,9 @@ import { ComboboxPopupProps, ComboboxPopupState } from "./combobox/combobox-popu
|
|
|
24
24
|
import { ComboboxInputValueChangeDetails, ComboboxOpenChangeDetails, ComboboxRootProps, ComboboxRootState, ComboboxValueChangeDetails } from "./combobox/combobox-root.mjs";
|
|
25
25
|
import { ComboboxTriggerProps, ComboboxTriggerState } from "./combobox/combobox-trigger.mjs";
|
|
26
26
|
import { Combobox } from "./combobox/index.mjs";
|
|
27
|
+
import { CSPProvider, CSPProviderProps } from "./csp/csp-provider.mjs";
|
|
28
|
+
import { STYLE_SHA256 } from "./csp/style-hashes.mjs";
|
|
29
|
+
import "./csp/index.mjs";
|
|
27
30
|
import { DialogCloseDetails, DialogCloseProps, DialogCloseState } from "./dialog/dialog-close.mjs";
|
|
28
31
|
import { DialogPopupProps, DialogPopupState } from "./dialog/dialog-popup.mjs";
|
|
29
32
|
import { DialogDescriptionProps, DialogDescriptionState } from "./dialog/dialog-description.mjs";
|
|
@@ -59,8 +62,9 @@ import { TabsPanelProps, TabsPanelState } from "./tabs/tabs-panel.mjs";
|
|
|
59
62
|
import { TabsRootProps, TabsRootState, TabsValueChangeDetails } from "./tabs/tabs-root.mjs";
|
|
60
63
|
import { TabsTabProps, TabsTabState } from "./tabs/tabs-tab.mjs";
|
|
61
64
|
import { Tabs } from "./tabs/index.mjs";
|
|
62
|
-
import { TooltipAlign,
|
|
63
|
-
import {
|
|
65
|
+
import { TooltipAlign, TooltipProvides, TooltipSide } from "./tooltip/tooltip-context.mjs";
|
|
66
|
+
import { TooltipArrowProps, TooltipArrowState } from "./tooltip/tooltip-arrow.mjs";
|
|
67
|
+
import { TooltipPopupProps, TooltipPopupState } from "./tooltip/tooltip-popup.mjs";
|
|
64
68
|
import { TooltipRootProps, TooltipRootState } from "./tooltip/tooltip-root.mjs";
|
|
65
69
|
import { TooltipTriggerProps, TooltipTriggerState } from "./tooltip/tooltip-trigger.mjs";
|
|
66
70
|
import { Tooltip } from "./tooltip/index.mjs";
|
|
@@ -128,4 +132,4 @@ import { MeterLabelProps } from "./meter/meter-label.mjs";
|
|
|
128
132
|
import { MeterTrackProps } from "./meter/meter-track.mjs";
|
|
129
133
|
import { MeterValueProps } from "./meter/meter-value.mjs";
|
|
130
134
|
import { Meter } from "./meter/index.mjs";
|
|
131
|
-
export { Accordion, type AccordionItemProps, type AccordionItemState, type AccordionPanelProps, type AccordionPanelState, type AccordionRootExclusiveProps, type AccordionRootMultipleProps, type AccordionRootProps, type AccordionRootState, type AccordionTriggerProps, type AccordionTriggerState, type AccordionValueChangeDetails, type Action, type ActionDetails, Button, type ButtonActionDetails, type ButtonProps, type ButtonState, type ChangeAction, type ChangeReason, Checkbox, type CheckboxCheckedChangeDetails, CheckboxGroup, type CheckboxGroupItemProps, type CheckboxGroupItemState, type CheckboxGroupLabelProps, type CheckboxGroupParentProps, type CheckboxGroupParentState, type CheckboxGroupRootProps, type CheckboxGroupRootState, type CheckboxGroupValueChangeDetails, type CheckboxProps, type CheckboxState, Combobox, type ComboboxClearProps, type ComboboxClearState, type ComboboxEmptyProps, type ComboboxEmptyState, type ComboboxGroupLabelProps, type ComboboxGroupLabelState, type ComboboxGroupProps, type ComboboxGroupState, type ComboboxInputProps, type ComboboxInputState, type ComboboxInputValueChangeDetails, type ComboboxLabelProps, type ComboboxLabelState, type ComboboxListProps, type ComboboxListState, type ComboboxOpenChangeDetails, type ComboboxOptionProps, type ComboboxOptionState, type ComboboxPopupProps, type ComboboxPopupState, type ComboboxRootProps, type ComboboxRootState, type ComboboxStatusProps, type ComboboxStatusState, type ComboboxTriggerProps, type ComboboxTriggerState, type ComboboxValueChangeDetails, Dialog, type DialogCloseDetails, type DialogCloseProps, type DialogCloseState, type DialogDescriptionProps, type DialogDescriptionState, type DialogFormProps, type DialogFormState, type DialogOpenChangeDetails, type DialogPopupProps, type DialogPopupState, type DialogRootProps, type DialogRootState, type DialogTitleProps, type DialogTitleState, type DialogTriggerProps, type DialogTriggerState, Field, type FieldControlProps, type FieldDescriptionProps, type FieldErrorProps, type FieldErrorValue, type FieldLabelProps, type FieldRootProps, type FieldState, type FieldValidate, type FieldValidity, Form, type FormErrors, type FormRootProps, type FormRootState, type FormSubmitProps, type FormSubmitState, Menu, type MenuAlign, type MenuCheckboxItemProps, type MenuCheckboxItemState, type MenuGroupLabelProps, type MenuGroupLabelState, type MenuGroupProps, type MenuGroupState, type MenuItemDetails, type MenuItemProps, type MenuItemState, type MenuOpenChangeDetails, type MenuPopupProps, type MenuPopupState, type MenuRadioGroupProps, type MenuRadioGroupState, type MenuRadioItemProps, type MenuRadioItemState, type MenuRootProps, type MenuRootState, type MenuSeparatorProps, type MenuSeparatorState, type MenuSide, type MenuSubmenuTriggerProps, type MenuSubmenuTriggerState, type MenuTriggerProps, type MenuTriggerState, Meter, type MeterIndicatorProps, type MeterLabelProps, type MeterRegion, type MeterRootProps, type MeterState, type MeterTrackProps, type MeterValueProps, NumberField, type NumberFieldButtonState, type NumberFieldDecrementProps, type NumberFieldIncrementProps, type NumberFieldInputProps, type NumberFieldLabelProps, type NumberFieldRootProps, type NumberFieldState, type NumberFieldValueChangeDetails, Popover, type PopoverAlign, type PopoverCloseProps, type PopoverCloseState, type PopoverDescriptionProps, type PopoverDescriptionState, type PopoverOpenChangeDetails, type PopoverPopupProps, type PopoverPopupState, type PopoverRootProps, type PopoverRootState, type PopoverSide, type PopoverTitleProps, type PopoverTitleState, type PopoverTriggerProps, type PopoverTriggerState, Progress, type ProgressIndicatorProps, type ProgressLabelProps, type ProgressRootProps, type ProgressState, type ProgressTrackProps, type ProgressValueProps, RadioGroup, type RadioGroupItemProps, type RadioGroupItemState, type RadioGroupLabelProps, type RadioGroupRootProps, type RadioGroupRootState, type RadioGroupValueChangeDetails, type RenderProp, Select, type SelectGroupLabelProps, type SelectGroupProps, type SelectOptionProps, type SelectOptionState, type SelectRootProps, type SelectRootState, type SelectSeparatorProps, type SelectTriggerProps, type SelectValueChangeDetails, type SelectValueProps, Slider, type SliderIndicatorProps, type SliderIndicatorState, type SliderLabelProps, type SliderOrientation, type SliderRootProps, type SliderRootState, type SliderThumbProps, type SliderThumbState, type SliderTrackProps, type SliderTrackState, type SliderValue, type SliderValueChangeDetails, type SliderValueCommitDetails, type SliderValueProps, type SliderValueState, type StateValue, Switch, type SwitchCheckedChangeDetails, type SwitchProps, type SwitchState, Tabs, type TabsActivationMode, type TabsIndicatorProps, type TabsIndicatorState, type TabsListProps, type TabsListState, type TabsOrientation, type TabsPanelProps, type TabsPanelState, type TabsRootProps, type TabsRootState, type TabsTabProps, type TabsTabState, type TabsValueChangeDetails, Toast, type ToastActionDetails, type ToastActionOptions, type ToastActionProps, type ToastActionState, type ToastCloseDetails, type ToastCloseProps, type ToastCloseState, type ToastDescriptionProps, type ToastItem, type ToastManager, type ToastOptions, type ToastPriority, type ToastPromiseOptions, type ToastRootProps, type ToastRootState, type ToastTitleProps, type ToastViewportProps, type ToastViewportState, Toggle, ToggleGroup, type ToggleGroupExclusiveProps, type ToggleGroupItemProps, type ToggleGroupItemState, type ToggleGroupMultipleProps, type ToggleGroupOrientation, type ToggleGroupRootProps, type ToggleGroupRootState, type ToggleGroupValueChangeDetails, type TogglePressedChangeDetails, type ToggleProps, type ToggleState, Toolbar, type ToolbarOrientation, type ToolbarRootProps, type ToolbarRootState, type ToolbarSeparatorProps, type ToolbarSeparatorState, Tooltip, type TooltipAlign, type TooltipPopupProps, type TooltipPopupState, type TooltipProvides, type TooltipRootProps, type TooltipRootState, type TooltipSide, type TooltipTriggerProps, type TooltipTriggerState, type UrgentChangeAction, createToastManager, toast };
|
|
135
|
+
export { Accordion, type AccordionItemProps, type AccordionItemState, type AccordionPanelProps, type AccordionPanelState, type AccordionRootExclusiveProps, type AccordionRootMultipleProps, type AccordionRootProps, type AccordionRootState, type AccordionTriggerProps, type AccordionTriggerState, type AccordionValueChangeDetails, type Action, type ActionDetails, Button, type ButtonActionDetails, type ButtonProps, type ButtonState, CSPProvider, type CSPProviderProps, type ChangeAction, type ChangeReason, Checkbox, type CheckboxCheckedChangeDetails, CheckboxGroup, type CheckboxGroupItemProps, type CheckboxGroupItemState, type CheckboxGroupLabelProps, type CheckboxGroupParentProps, type CheckboxGroupParentState, type CheckboxGroupRootProps, type CheckboxGroupRootState, type CheckboxGroupValueChangeDetails, type CheckboxProps, type CheckboxState, Combobox, type ComboboxClearProps, type ComboboxClearState, type ComboboxEmptyProps, type ComboboxEmptyState, type ComboboxGroupLabelProps, type ComboboxGroupLabelState, type ComboboxGroupProps, type ComboboxGroupState, type ComboboxInputProps, type ComboboxInputState, type ComboboxInputValueChangeDetails, type ComboboxLabelProps, type ComboboxLabelState, type ComboboxListProps, type ComboboxListState, type ComboboxOpenChangeDetails, type ComboboxOptionProps, type ComboboxOptionState, type ComboboxPopupProps, type ComboboxPopupState, type ComboboxRootProps, type ComboboxRootState, type ComboboxStatusProps, type ComboboxStatusState, type ComboboxTriggerProps, type ComboboxTriggerState, type ComboboxValueChangeDetails, Dialog, type DialogCloseDetails, type DialogCloseProps, type DialogCloseState, type DialogDescriptionProps, type DialogDescriptionState, type DialogFormProps, type DialogFormState, type DialogOpenChangeDetails, type DialogPopupProps, type DialogPopupState, type DialogRootProps, type DialogRootState, type DialogTitleProps, type DialogTitleState, type DialogTriggerProps, type DialogTriggerState, Field, type FieldControlProps, type FieldDescriptionProps, type FieldErrorProps, type FieldErrorValue, type FieldLabelProps, type FieldRootProps, type FieldState, type FieldValidate, type FieldValidity, Form, type FormErrors, type FormRootProps, type FormRootState, type FormSubmitProps, type FormSubmitState, Menu, type MenuAlign, type MenuCheckboxItemProps, type MenuCheckboxItemState, type MenuGroupLabelProps, type MenuGroupLabelState, type MenuGroupProps, type MenuGroupState, type MenuItemDetails, type MenuItemProps, type MenuItemState, type MenuOpenChangeDetails, type MenuPopupProps, type MenuPopupState, type MenuRadioGroupProps, type MenuRadioGroupState, type MenuRadioItemProps, type MenuRadioItemState, type MenuRootProps, type MenuRootState, type MenuSeparatorProps, type MenuSeparatorState, type MenuSide, type MenuSubmenuTriggerProps, type MenuSubmenuTriggerState, type MenuTriggerProps, type MenuTriggerState, Meter, type MeterIndicatorProps, type MeterLabelProps, type MeterRegion, type MeterRootProps, type MeterState, type MeterTrackProps, type MeterValueProps, NumberField, type NumberFieldButtonState, type NumberFieldDecrementProps, type NumberFieldIncrementProps, type NumberFieldInputProps, type NumberFieldLabelProps, type NumberFieldRootProps, type NumberFieldState, type NumberFieldValueChangeDetails, Popover, type PopoverAlign, type PopoverCloseProps, type PopoverCloseState, type PopoverDescriptionProps, type PopoverDescriptionState, type PopoverOpenChangeDetails, type PopoverPopupProps, type PopoverPopupState, type PopoverRootProps, type PopoverRootState, type PopoverSide, type PopoverTitleProps, type PopoverTitleState, type PopoverTriggerProps, type PopoverTriggerState, Progress, type ProgressIndicatorProps, type ProgressLabelProps, type ProgressRootProps, type ProgressState, type ProgressTrackProps, type ProgressValueProps, RadioGroup, type RadioGroupItemProps, type RadioGroupItemState, type RadioGroupLabelProps, type RadioGroupRootProps, type RadioGroupRootState, type RadioGroupValueChangeDetails, type RenderProp, STYLE_SHA256, Select, type SelectGroupLabelProps, type SelectGroupProps, type SelectOptionProps, type SelectOptionState, type SelectRootProps, type SelectRootState, type SelectSeparatorProps, type SelectTriggerProps, type SelectValueChangeDetails, type SelectValueProps, Slider, type SliderIndicatorProps, type SliderIndicatorState, type SliderLabelProps, type SliderOrientation, type SliderRootProps, type SliderRootState, type SliderThumbProps, type SliderThumbState, type SliderTrackProps, type SliderTrackState, type SliderValue, type SliderValueChangeDetails, type SliderValueCommitDetails, type SliderValueProps, type SliderValueState, type StateValue, Switch, type SwitchCheckedChangeDetails, type SwitchProps, type SwitchState, Tabs, type TabsActivationMode, type TabsIndicatorProps, type TabsIndicatorState, type TabsListProps, type TabsListState, type TabsOrientation, type TabsPanelProps, type TabsPanelState, type TabsRootProps, type TabsRootState, type TabsTabProps, type TabsTabState, type TabsValueChangeDetails, Toast, type ToastActionDetails, type ToastActionOptions, type ToastActionProps, type ToastActionState, type ToastCloseDetails, type ToastCloseProps, type ToastCloseState, type ToastDescriptionProps, type ToastItem, type ToastManager, type ToastOptions, type ToastPriority, type ToastPromiseOptions, type ToastRootProps, type ToastRootState, type ToastTitleProps, type ToastViewportProps, type ToastViewportState, Toggle, ToggleGroup, type ToggleGroupExclusiveProps, type ToggleGroupItemProps, type ToggleGroupItemState, type ToggleGroupMultipleProps, type ToggleGroupOrientation, type ToggleGroupRootProps, type ToggleGroupRootState, type ToggleGroupValueChangeDetails, type TogglePressedChangeDetails, type ToggleProps, type ToggleState, Toolbar, type ToolbarOrientation, type ToolbarRootProps, type ToolbarRootState, type ToolbarSeparatorProps, type ToolbarSeparatorState, Tooltip, type TooltipAlign, type TooltipArrowProps, type TooltipArrowState, type TooltipPopupProps, type TooltipPopupState, type TooltipProvides, type TooltipRootProps, type TooltipRootState, type TooltipSide, type TooltipTriggerProps, type TooltipTriggerState, type UrgentChangeAction, createToastManager, toast };
|
package/dist/index.mjs
CHANGED
|
@@ -22,4 +22,6 @@ import { Field } from "./field/index.mjs";
|
|
|
22
22
|
import { Form } from "./form/index.mjs";
|
|
23
23
|
import { Progress } from "./progress/index.mjs";
|
|
24
24
|
import { Meter } from "./meter/index.mjs";
|
|
25
|
-
|
|
25
|
+
import { CSPProvider } from "./csp/csp-provider.mjs";
|
|
26
|
+
import { STYLE_SHA256 } from "./csp/style-hashes.mjs";
|
|
27
|
+
export { Accordion, Button, CSPProvider, Checkbox, CheckboxGroup, Combobox, Dialog, Field, Form, Menu, Meter, NumberField, Popover, Progress, RadioGroup, STYLE_SHA256, Select, Slider, Switch, Tabs, Toast, Toggle, ToggleGroup, Toolbar, Tooltip, createToastManager, toast };
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
//#region src/internal/anchor-position.d.ts
|
|
2
|
-
/**
|
|
3
|
-
export type
|
|
4
|
-
/**
|
|
2
|
+
/** A physical side of the anchor. */
|
|
3
|
+
export type PhysicalSide = "top" | "bottom" | "left" | "right";
|
|
4
|
+
/**
|
|
5
|
+
* Side of the anchor the popup is placed on: physical, or inline-logical (`inline-start` /
|
|
6
|
+
* `inline-end` follow the popup's own `direction` through the `self-x-*` keywords).
|
|
7
|
+
*/
|
|
8
|
+
export type AnchorSide = PhysicalSide | "inline-start" | "inline-end";
|
|
9
|
+
/**
|
|
10
|
+
* Alignment along that side: inline-relative on a `top` / `bottom` side (`start`: the popup's
|
|
11
|
+
* inline-start edge meets the anchor's), the top / bottom edges on the others.
|
|
12
|
+
*/
|
|
5
13
|
export type AnchorAlign = "start" | "center" | "end";
|
|
6
14
|
//#endregion
|
|
7
15
|
//# sourceMappingURL=anchor-position.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchor-position.d.mts","names":[],"sources":["../../src/internal/anchor-position.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"anchor-position.d.mts","names":[],"sources":["../../src/internal/anchor-position.ts"],"mappings":";;YAcY;;;;;YAKA,aAAa;;;;;YAKb"}
|
|
@@ -1,16 +1,190 @@
|
|
|
1
1
|
//#region src/internal/anchor-position.ts
|
|
2
2
|
/** Flip to the opposite side, then the other axis, then both, when the popup does not fit. */
|
|
3
3
|
const POSITION_TRY_FALLBACKS = "flip-block, flip-inline, flip-block flip-inline";
|
|
4
|
+
const SIDE_KEYWORD = {
|
|
5
|
+
top: "top",
|
|
6
|
+
bottom: "bottom",
|
|
7
|
+
left: "left",
|
|
8
|
+
right: "right",
|
|
9
|
+
"inline-start": "self-x-start",
|
|
10
|
+
"inline-end": "self-x-end"
|
|
11
|
+
};
|
|
4
12
|
/**
|
|
5
|
-
* The `position-area` for a side and an alignment (
|
|
6
|
-
* `bottom
|
|
7
|
-
*
|
|
13
|
+
* The `position-area` for a side and an alignment (the matrix of conventions 13.1):
|
|
14
|
+
* `bottom` + `center` is `bottom`, `bottom` + `start` is `bottom span-self-x-end`, `right` +
|
|
15
|
+
* `start` is `right span-bottom`, `inline-end` + `start` is `self-x-end span-bottom`.
|
|
8
16
|
*/
|
|
9
17
|
function positionArea(side, align) {
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
const keyword = SIDE_KEYWORD[side];
|
|
19
|
+
if (align === "center") return keyword;
|
|
20
|
+
return `${keyword} ${side === "top" || side === "bottom" ? align === "start" ? "span-self-x-end" : "span-self-x-start" : align === "start" ? "span-bottom" : "span-top"}`;
|
|
12
21
|
}
|
|
22
|
+
const AXIS_OF = {
|
|
23
|
+
top: "y",
|
|
24
|
+
bottom: "y",
|
|
25
|
+
left: "x",
|
|
26
|
+
right: "x"
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Parses a computed `position-area` (conventions 13.2) into the physical side the popup sits on
|
|
30
|
+
* and its alignment. Total: anything it cannot map returns `null` (`none`, an empty value, a
|
|
31
|
+
* vertical `writing-mode`, a corner cell, the cell over the anchor, an unknown keyword), and the
|
|
32
|
+
* part keeps the requested values. The engines serialise in grammar order, in any keyword group:
|
|
33
|
+
* `span-left top`, `span-all bottom` (Firefox's form of a flipped `bottom`), `self-end
|
|
34
|
+
* span-self-end`, `span-self-x-end bottom`, `self-x-start span-top`.
|
|
35
|
+
*
|
|
36
|
+
* `selfDirection` is the popup's computed `direction` (it resolves `self-*` tokens);
|
|
37
|
+
* `rootDirection` the root's (plain `x-*` / `inline-*` tokens, which a consumer `style` override
|
|
38
|
+
* may use), passed as a function so it is read only when such a token appears.
|
|
39
|
+
*/
|
|
40
|
+
function parsePositionArea(value, selfDirection, rootDirection, writingMode = "horizontal-tb") {
|
|
41
|
+
if (writingMode !== "horizontal-tb" || typeof value !== "string") return null;
|
|
42
|
+
const words = value.trim().split(/\s+/);
|
|
43
|
+
if (words.length > 2 || words[0] === "" || words[0] === "none") return null;
|
|
44
|
+
let root;
|
|
45
|
+
const rootDir = () => root ??= typeof rootDirection === "function" ? rootDirection() : rootDirection;
|
|
46
|
+
const tokens = [];
|
|
47
|
+
for (let index = 0; index < words.length; index++) {
|
|
48
|
+
const token = classify(words[index], index, words.length, selfDirection, rootDir);
|
|
49
|
+
if (token === null) return null;
|
|
50
|
+
tokens.push(token);
|
|
51
|
+
}
|
|
52
|
+
const sides = tokens.filter((t) => t.kind === "side");
|
|
53
|
+
if (sides.length !== 1) return null;
|
|
54
|
+
const side = sides[0].physical;
|
|
55
|
+
const span = tokens.find((t) => t.kind === "span");
|
|
56
|
+
if (span === void 0) return {
|
|
57
|
+
side,
|
|
58
|
+
align: "center"
|
|
59
|
+
};
|
|
60
|
+
const toward = span.physical;
|
|
61
|
+
if (AXIS_OF[toward] === AXIS_OF[side]) return null;
|
|
62
|
+
if (AXIS_OF[side] === "y") return {
|
|
63
|
+
side,
|
|
64
|
+
align: toward === (selfDirection === "rtl" ? "left" : "right") ? "start" : "end"
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
side,
|
|
68
|
+
align: toward === "bottom" ? "start" : "end"
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function classify(word, index, count, selfDirection, rootDirection) {
|
|
72
|
+
if (word === "center" || word === "span-all") return {
|
|
73
|
+
kind: "neutral",
|
|
74
|
+
physical: null
|
|
75
|
+
};
|
|
76
|
+
const span = word.startsWith("span-");
|
|
77
|
+
const physical = physicalOf(span ? word.slice(5) : word, index, count, selfDirection, rootDirection);
|
|
78
|
+
return physical === null ? null : {
|
|
79
|
+
kind: span ? "span" : "side",
|
|
80
|
+
physical
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The physical direction a keyword names, in `horizontal-tb`. Bare `start` / `end` /
|
|
85
|
+
* `self-start` / `self-end` are positional: the block axis first, the inline axis second; alone
|
|
86
|
+
* they name both axes (a corner, or a span over both), which the table does not describe.
|
|
87
|
+
*/
|
|
88
|
+
function physicalOf(name, index, count, selfDirection, rootDirection) {
|
|
89
|
+
switch (name) {
|
|
90
|
+
case "top":
|
|
91
|
+
case "bottom":
|
|
92
|
+
case "left":
|
|
93
|
+
case "right": return name;
|
|
94
|
+
case "y-start":
|
|
95
|
+
case "self-y-start":
|
|
96
|
+
case "y-self-start":
|
|
97
|
+
case "block-start":
|
|
98
|
+
case "self-block-start": return "top";
|
|
99
|
+
case "y-end":
|
|
100
|
+
case "self-y-end":
|
|
101
|
+
case "y-self-end":
|
|
102
|
+
case "block-end":
|
|
103
|
+
case "self-block-end": return "bottom";
|
|
104
|
+
case "self-x-start":
|
|
105
|
+
case "x-self-start":
|
|
106
|
+
case "self-inline-start": return inlineEdge("start", selfDirection);
|
|
107
|
+
case "self-x-end":
|
|
108
|
+
case "x-self-end":
|
|
109
|
+
case "self-inline-end": return inlineEdge("end", selfDirection);
|
|
110
|
+
case "x-start":
|
|
111
|
+
case "inline-start": return inlineEdge("start", rootDirection());
|
|
112
|
+
case "x-end":
|
|
113
|
+
case "inline-end": return inlineEdge("end", rootDirection());
|
|
114
|
+
case "start":
|
|
115
|
+
case "end":
|
|
116
|
+
case "self-start":
|
|
117
|
+
case "self-end": {
|
|
118
|
+
if (count !== 2) return null;
|
|
119
|
+
const edge = name.endsWith("start") ? "start" : "end";
|
|
120
|
+
if (index === 0) return edge === "start" ? "top" : "bottom";
|
|
121
|
+
return inlineEdge(edge, name.startsWith("self-") ? selfDirection : rootDirection());
|
|
122
|
+
}
|
|
123
|
+
default: return null;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function inlineEdge(edge, direction) {
|
|
127
|
+
return edge === "start" === (direction === "ltr") ? "left" : "right";
|
|
128
|
+
}
|
|
129
|
+
/** Custom property carrying the x coordinate of a point-placed popup (viewport px). */
|
|
130
|
+
const MENU_POINT_X = "--menu-point-x";
|
|
131
|
+
/** Custom property carrying the y coordinate of a point-placed popup (viewport px). */
|
|
132
|
+
const MENU_POINT_Y = "--menu-point-y";
|
|
133
|
+
/**
|
|
134
|
+
* Custom property carrying the vertical gap between the point and the menu: `0px` for a mouse or
|
|
135
|
+
* keyboard open, `16px` for a touch or pen open, which is placed above the finger (#88, 4.7).
|
|
136
|
+
*/
|
|
137
|
+
const MENU_POINT_GAP = "--menu-point-gap";
|
|
138
|
+
/** The gap of a touch or pen open (context-menu.md 4.7). */
|
|
139
|
+
const MENU_POINT_TOUCH_GAP = "16px";
|
|
140
|
+
/** The dedupe key of the shipped rules (`<style href precedence>`). */
|
|
141
|
+
const MENU_POINT_HREF = "@funstack/ui/menu-point";
|
|
142
|
+
/**
|
|
143
|
+
* The React stylesheet precedence bucket of the library's functional CSS. Fizz writes every
|
|
144
|
+
* same-precedence `<style>` of one server flush as a single element with the texts concatenated,
|
|
145
|
+
* which would match none of the per-href hashes in `STYLE_SHA256`: at most one shipped stylesheet
|
|
146
|
+
* in this bucket may render during server rendering (today the tooltip skip-delay rule; the menu
|
|
147
|
+
* point rules are client-only). A second one needs a precedence of its own (guard row in
|
|
148
|
+
* `csp/csp.test.tsx`).
|
|
149
|
+
*/
|
|
150
|
+
const FSUI_PRECEDENCE = "fsui";
|
|
151
|
+
const UP = `top: auto; bottom: calc(100% - var(${MENU_POINT_Y}) + var(${MENU_POINT_GAP}));`;
|
|
152
|
+
const DOWN = `bottom: auto; top: calc(var(${MENU_POINT_Y}) + var(${MENU_POINT_GAP}));`;
|
|
153
|
+
const LEFT = `left: auto; right: calc(100% - var(${MENU_POINT_X}));`;
|
|
154
|
+
const RIGHT = `right: auto; left: var(${MENU_POINT_X});`;
|
|
155
|
+
/**
|
|
156
|
+
* The `@position-try` options that mirror a point-placed popup around the point when it does not
|
|
157
|
+
* fit (context-menu.md 4.2, conventions 12). The base position is inline on the popup: the
|
|
158
|
+
* point's y below (mouse, keyboard) or above (touch, pen, with `--menu-point-gap`) the menu and,
|
|
159
|
+
* by the popup's direction, its left (LTR) or right (RTL) edge at the point's x. A menu names the
|
|
160
|
+
* three options that apply to its direction and pointer kind (`MENU_POINT_FALLBACKS`); the others
|
|
161
|
+
* are inert. Functional at-rules with no selectors: no element is styled. `100%` resolves against
|
|
162
|
+
* the viewport, the top layer's containing block, which `clientX` / `clientY` are measured in.
|
|
163
|
+
* Its SHA-256 is `STYLE_SHA256` in `@funstack/ui/csp` (a jsdom row recomputes it).
|
|
164
|
+
*/
|
|
165
|
+
const MENU_POINT_RULES = `/* @funstack/ui: placement of a menu at a point. Functional only: the base position is inline on the popup (below or above the point and, by direction, its left or right edge at the point); these options mirror it around the point when it does not fit. */
|
|
166
|
+
@position-try --fsui-menu-up { ${UP} }\n@position-try --fsui-menu-down { ${DOWN} }\n@position-try --fsui-menu-left { ${LEFT} }\n@position-try --fsui-menu-right { ${RIGHT} }\n@position-try --fsui-menu-up-left { ${UP} ${LEFT} }\n@position-try --fsui-menu-up-right { ${UP} ${RIGHT} }\n@position-try --fsui-menu-down-left { ${DOWN} ${LEFT} }\n@position-try --fsui-menu-down-right { ${DOWN} ${RIGHT} }\n`;
|
|
167
|
+
/**
|
|
168
|
+
* Two equivalent spellings of the point fallback list per direction and pointer kind
|
|
169
|
+
* (`MENU_POINT_FALLBACKS[direction][offset ? "touch" : "mouse"][generation % 2]`), alternated by
|
|
170
|
+
* the placement's generation: changing `position-try-fallbacks` clears the remembered "last
|
|
171
|
+
* successful position option", so a re-show at a new point does not keep the previous flip
|
|
172
|
+
* (design 4.3). The first two options are order-independent (only one of them can fix a given
|
|
173
|
+
* overflow). A move that changes direction or pointer kind changes the list either way.
|
|
174
|
+
* Mouse and keyboard: below the point, flipping up and across; touch and pen: above it, flipping
|
|
175
|
+
* across and down (4.7).
|
|
176
|
+
*/
|
|
177
|
+
const MENU_POINT_FALLBACKS = {
|
|
178
|
+
ltr: {
|
|
179
|
+
mouse: ["--fsui-menu-up, --fsui-menu-left, --fsui-menu-up-left", "--fsui-menu-left, --fsui-menu-up, --fsui-menu-up-left"],
|
|
180
|
+
touch: ["--fsui-menu-left, --fsui-menu-down, --fsui-menu-down-left", "--fsui-menu-down, --fsui-menu-left, --fsui-menu-down-left"]
|
|
181
|
+
},
|
|
182
|
+
rtl: {
|
|
183
|
+
mouse: ["--fsui-menu-up, --fsui-menu-right, --fsui-menu-up-right", "--fsui-menu-right, --fsui-menu-up, --fsui-menu-up-right"],
|
|
184
|
+
touch: ["--fsui-menu-right, --fsui-menu-down, --fsui-menu-down-right", "--fsui-menu-down, --fsui-menu-right, --fsui-menu-down-right"]
|
|
185
|
+
}
|
|
186
|
+
};
|
|
13
187
|
//#endregion
|
|
14
|
-
export { POSITION_TRY_FALLBACKS, positionArea };
|
|
188
|
+
export { FSUI_PRECEDENCE, MENU_POINT_FALLBACKS, MENU_POINT_GAP, MENU_POINT_HREF, MENU_POINT_RULES, MENU_POINT_TOUCH_GAP, MENU_POINT_X, MENU_POINT_Y, POSITION_TRY_FALLBACKS, parsePositionArea, positionArea };
|
|
15
189
|
|
|
16
190
|
//# sourceMappingURL=anchor-position.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchor-position.mjs","names":[],"sources":["../../src/internal/anchor-position.ts"],"sourcesContent":["// Placement of a popover against its implicit anchor (the invoker set by `commandfor`,\n// `interestfor` or `showPopover({ source })`): inline `position-area` from a side and an\n// alignment, plus `position-try-fallbacks` that flip it when it does not fit. Shared by Tooltip,\n// Popover and Menu (design/components/tooltip.md 7.1, popover.md 8).\n//\n// No \"use client\" directive: pure functions, importable from anywhere (conventions 7.1).\n\n/** Physical side of the anchor the popup is placed on. */\nexport type AnchorSide = \"top\" | \"bottom\" | \"left\" | \"right\";\n/** Alignment along that side. */\nexport type AnchorAlign = \"start\" | \"center\" | \"end\";\n\n/** Flip to the opposite side, then the other axis, then both, when the popup does not fit. */\nexport const POSITION_TRY_FALLBACKS = \"flip-block, flip-inline, flip-block flip-inline\";\n\n/**\n * The `position-area` for a side and an alignment (physical keywords): `bottom` + `center` is\n * `bottom`, `bottom` + `start` is `bottom span-right`, `right` + `start` is `right span-bottom`,\n * and so on.\n */\nexport function positionArea(side: AnchorSide, align: AnchorAlign): string {\n if (align === \"center\") return side;\n const vertical = side === \"top\" || side === \"bottom\";\n const span = vertical\n ? align === \"start\"\n ? \"span-right\"\n : \"span-left\"\n : align === \"start\"\n ? \"span-bottom\"\n : \"span-top\";\n return `${side} ${span}`;\n}\n"],"mappings":";;AAaA,MAAa,yBAAyB;;;;;;AAOtC,SAAgB,aAAa,MAAkB,OAA4B;CACzE,IAAI,UAAU,UAAU,OAAO;CAS/B,OAAO,GAAG,KAAK,GARE,SAAS,SAAS,SAAS,WAExC,UAAU,UACR,eACA,cACF,UAAU,UACR,gBACA;AAER"}
|
|
1
|
+
{"version":3,"file":"anchor-position.mjs","names":[],"sources":["../../src/internal/anchor-position.ts"],"sourcesContent":["// Placement of a popover against its implicit anchor (the invoker set by `commandfor`,\n// `interestfor` or `showPopover({ source })`): inline `position-area` from a side and an\n// alignment, plus `position-try-fallbacks` that flip it when it does not fit; and the parser that\n// reads back which option the browser applied. Shared by Tooltip, Popover and Menu\n// (design/conventions.md 13; design/components/tooltip.md 7.1, popover.md 8).\n//\n// Keyword policy (conventions 13.1): physical keywords and the `self-*` group only. A plain\n// logical keyword (`block-end`, `span-inline-end`) on a top-layer popup resolves against the\n// root's writing mode, so it would ignore a `dir=\"rtl\"` container; `self-x-*` resolves against the\n// popup's own (inherited) direction. Keyword groups are never mixed in one value.\n//\n// No \"use client\" directive: pure functions, importable from anywhere (conventions 7.1).\n\n/** A physical side of the anchor. */\nexport type PhysicalSide = \"top\" | \"bottom\" | \"left\" | \"right\";\n/**\n * Side of the anchor the popup is placed on: physical, or inline-logical (`inline-start` /\n * `inline-end` follow the popup's own `direction` through the `self-x-*` keywords).\n */\nexport type AnchorSide = PhysicalSide | \"inline-start\" | \"inline-end\";\n/**\n * Alignment along that side: inline-relative on a `top` / `bottom` side (`start`: the popup's\n * inline-start edge meets the anchor's), the top / bottom edges on the others.\n */\nexport type AnchorAlign = \"start\" | \"center\" | \"end\";\n/** A computed `direction`. */\nexport type Direction = \"ltr\" | \"rtl\";\n\n/** Flip to the opposite side, then the other axis, then both, when the popup does not fit. */\nexport const POSITION_TRY_FALLBACKS = \"flip-block, flip-inline, flip-block flip-inline\";\n\nconst SIDE_KEYWORD: Record<AnchorSide, string> = {\n top: \"top\",\n bottom: \"bottom\",\n left: \"left\",\n right: \"right\",\n \"inline-start\": \"self-x-start\",\n \"inline-end\": \"self-x-end\",\n};\n\n/**\n * The `position-area` for a side and an alignment (the matrix of conventions 13.1):\n * `bottom` + `center` is `bottom`, `bottom` + `start` is `bottom span-self-x-end`, `right` +\n * `start` is `right span-bottom`, `inline-end` + `start` is `self-x-end span-bottom`.\n */\nexport function positionArea(side: AnchorSide, align: AnchorAlign): string {\n const keyword = SIDE_KEYWORD[side];\n if (align === \"center\") return keyword;\n const horizontal = side === \"top\" || side === \"bottom\";\n const span = horizontal\n ? align === \"start\"\n ? \"span-self-x-end\"\n : \"span-self-x-start\"\n : align === \"start\"\n ? \"span-bottom\"\n : \"span-top\";\n return `${keyword} ${span}`;\n}\n\n// --- Reading back the applied option (conventions 13.2) --------------------------------------\n\n/** Where the browser placed a popup: a physical side and the alignment along it. */\nexport interface ResolvedPlacement {\n readonly side: PhysicalSide;\n readonly align: AnchorAlign;\n}\n\ntype Axis = \"x\" | \"y\";\n\ninterface Token {\n /** `side`: the cell is on that side; `span`: spans toward a direction; `neutral`: neither. */\n readonly kind: \"side\" | \"span\" | \"neutral\";\n /** The physical direction of a `side` or `span` token. */\n readonly physical: PhysicalSide | null;\n}\n\nconst AXIS_OF: Record<PhysicalSide, Axis> = { top: \"y\", bottom: \"y\", left: \"x\", right: \"x\" };\n\n/**\n * Parses a computed `position-area` (conventions 13.2) into the physical side the popup sits on\n * and its alignment. Total: anything it cannot map returns `null` (`none`, an empty value, a\n * vertical `writing-mode`, a corner cell, the cell over the anchor, an unknown keyword), and the\n * part keeps the requested values. The engines serialise in grammar order, in any keyword group:\n * `span-left top`, `span-all bottom` (Firefox's form of a flipped `bottom`), `self-end\n * span-self-end`, `span-self-x-end bottom`, `self-x-start span-top`.\n *\n * `selfDirection` is the popup's computed `direction` (it resolves `self-*` tokens);\n * `rootDirection` the root's (plain `x-*` / `inline-*` tokens, which a consumer `style` override\n * may use), passed as a function so it is read only when such a token appears.\n */\nexport function parsePositionArea(\n value: string | null | undefined,\n selfDirection: Direction,\n rootDirection: Direction | (() => Direction),\n writingMode: string = \"horizontal-tb\",\n): ResolvedPlacement | null {\n if (writingMode !== \"horizontal-tb\" || typeof value !== \"string\") return null;\n const words = value.trim().split(/\\s+/);\n if (words.length > 2 || words[0] === \"\" || words[0] === \"none\") return null;\n let root: Direction | undefined;\n const rootDir = (): Direction =>\n (root ??= typeof rootDirection === \"function\" ? rootDirection() : rootDirection);\n\n const tokens: Token[] = [];\n for (let index = 0; index < words.length; index++) {\n const token = classify(words[index]!, index, words.length, selfDirection, rootDir);\n if (token === null) return null;\n tokens.push(token);\n }\n\n const sides = tokens.filter((t) => t.kind === \"side\");\n // No side (the cell over the anchor) or two (a corner): not a placement of the table.\n if (sides.length !== 1) return null;\n const side = sides[0]!.physical!;\n const span = tokens.find((t) => t.kind === \"span\");\n if (span === undefined) return { side, align: \"center\" };\n const toward = span.physical!;\n if (AXIS_OF[toward] === AXIS_OF[side]) return null;\n if (AXIS_OF[side] === \"y\") {\n // Inline-relative: spanning toward the popup's inline-end puts the inline-start edges\n // together.\n const inlineEnd: PhysicalSide = selfDirection === \"rtl\" ? \"left\" : \"right\";\n return { side, align: toward === inlineEnd ? \"start\" : \"end\" };\n }\n return { side, align: toward === \"bottom\" ? \"start\" : \"end\" };\n}\n\nfunction classify(\n word: string,\n index: number,\n count: number,\n selfDirection: Direction,\n rootDirection: () => Direction,\n): Token | null {\n if (word === \"center\" || word === \"span-all\") return { kind: \"neutral\", physical: null };\n const span = word.startsWith(\"span-\");\n const physical = physicalOf(\n span ? word.slice(5) : word,\n index,\n count,\n selfDirection,\n rootDirection,\n );\n return physical === null ? null : { kind: span ? \"span\" : \"side\", physical };\n}\n\n/**\n * The physical direction a keyword names, in `horizontal-tb`. Bare `start` / `end` /\n * `self-start` / `self-end` are positional: the block axis first, the inline axis second; alone\n * they name both axes (a corner, or a span over both), which the table does not describe.\n */\nfunction physicalOf(\n name: string,\n index: number,\n count: number,\n selfDirection: Direction,\n rootDirection: () => Direction,\n): PhysicalSide | null {\n switch (name) {\n case \"top\":\n case \"bottom\":\n case \"left\":\n case \"right\":\n return name;\n // The block axis is top / bottom in horizontal-tb, whatever the direction.\n case \"y-start\":\n case \"self-y-start\":\n case \"y-self-start\":\n case \"block-start\":\n case \"self-block-start\":\n return \"top\";\n case \"y-end\":\n case \"self-y-end\":\n case \"y-self-end\":\n case \"block-end\":\n case \"self-block-end\":\n return \"bottom\";\n // The inline axis against the popup's own direction.\n case \"self-x-start\":\n case \"x-self-start\":\n case \"self-inline-start\":\n return inlineEdge(\"start\", selfDirection);\n case \"self-x-end\":\n case \"x-self-end\":\n case \"self-inline-end\":\n return inlineEdge(\"end\", selfDirection);\n // The inline axis against the containing block's (the root's, for a top-layer popup).\n case \"x-start\":\n case \"inline-start\":\n return inlineEdge(\"start\", rootDirection());\n case \"x-end\":\n case \"inline-end\":\n return inlineEdge(\"end\", rootDirection());\n case \"start\":\n case \"end\":\n case \"self-start\":\n case \"self-end\": {\n if (count !== 2) return null;\n const edge = name.endsWith(\"start\") ? \"start\" : \"end\";\n if (index === 0) return edge === \"start\" ? \"top\" : \"bottom\";\n return inlineEdge(edge, name.startsWith(\"self-\") ? selfDirection : rootDirection());\n }\n default:\n return null;\n }\n}\n\nfunction inlineEdge(edge: \"start\" | \"end\", direction: Direction): PhysicalSide {\n return (edge === \"start\") === (direction === \"ltr\") ? \"left\" : \"right\";\n}\n\n// --- Placement at a point (design/components/context-menu.md 4.2, conventions 12, 13.4) -------\n\n/** Custom property carrying the x coordinate of a point-placed popup (viewport px). */\nexport const MENU_POINT_X = \"--menu-point-x\";\n/** Custom property carrying the y coordinate of a point-placed popup (viewport px). */\nexport const MENU_POINT_Y = \"--menu-point-y\";\n/**\n * Custom property carrying the vertical gap between the point and the menu: `0px` for a mouse or\n * keyboard open, `16px` for a touch or pen open, which is placed above the finger (#88, 4.7).\n */\nexport const MENU_POINT_GAP = \"--menu-point-gap\";\n/** The gap of a touch or pen open (context-menu.md 4.7). */\nexport const MENU_POINT_TOUCH_GAP = \"16px\";\n\n/** The dedupe key of the shipped rules (`<style href precedence>`). */\nexport const MENU_POINT_HREF = \"@funstack/ui/menu-point\";\n/**\n * The React stylesheet precedence bucket of the library's functional CSS. Fizz writes every\n * same-precedence `<style>` of one server flush as a single element with the texts concatenated,\n * which would match none of the per-href hashes in `STYLE_SHA256`: at most one shipped stylesheet\n * in this bucket may render during server rendering (today the tooltip skip-delay rule; the menu\n * point rules are client-only). A second one needs a precedence of its own (guard row in\n * `csp/csp.test.tsx`).\n */\nexport const FSUI_PRECEDENCE = \"fsui\";\n\nconst UP = `top: auto; bottom: calc(100% - var(${MENU_POINT_Y}) + var(${MENU_POINT_GAP}));`;\nconst DOWN = `bottom: auto; top: calc(var(${MENU_POINT_Y}) + var(${MENU_POINT_GAP}));`;\nconst LEFT = `left: auto; right: calc(100% - var(${MENU_POINT_X}));`;\nconst RIGHT = `right: auto; left: var(${MENU_POINT_X});`;\n\n/**\n * The `@position-try` options that mirror a point-placed popup around the point when it does not\n * fit (context-menu.md 4.2, conventions 12). The base position is inline on the popup: the\n * point's y below (mouse, keyboard) or above (touch, pen, with `--menu-point-gap`) the menu and,\n * by the popup's direction, its left (LTR) or right (RTL) edge at the point's x. A menu names the\n * three options that apply to its direction and pointer kind (`MENU_POINT_FALLBACKS`); the others\n * are inert. Functional at-rules with no selectors: no element is styled. `100%` resolves against\n * the viewport, the top layer's containing block, which `clientX` / `clientY` are measured in.\n * Its SHA-256 is `STYLE_SHA256` in `@funstack/ui/csp` (a jsdom row recomputes it).\n */\nexport const MENU_POINT_RULES =\n \"/* @funstack/ui: placement of a menu at a point. Functional only: the base position is inline \" +\n \"on the popup (below or above the point and, by direction, its left or right edge at the \" +\n \"point); these options mirror it around the point when it does not fit. */\\n\" +\n `@position-try --fsui-menu-up { ${UP} }\\n` +\n `@position-try --fsui-menu-down { ${DOWN} }\\n` +\n `@position-try --fsui-menu-left { ${LEFT} }\\n` +\n `@position-try --fsui-menu-right { ${RIGHT} }\\n` +\n `@position-try --fsui-menu-up-left { ${UP} ${LEFT} }\\n` +\n `@position-try --fsui-menu-up-right { ${UP} ${RIGHT} }\\n` +\n `@position-try --fsui-menu-down-left { ${DOWN} ${LEFT} }\\n` +\n `@position-try --fsui-menu-down-right { ${DOWN} ${RIGHT} }\\n`;\n\n/**\n * Two equivalent spellings of the point fallback list per direction and pointer kind\n * (`MENU_POINT_FALLBACKS[direction][offset ? \"touch\" : \"mouse\"][generation % 2]`), alternated by\n * the placement's generation: changing `position-try-fallbacks` clears the remembered \"last\n * successful position option\", so a re-show at a new point does not keep the previous flip\n * (design 4.3). The first two options are order-independent (only one of them can fix a given\n * overflow). A move that changes direction or pointer kind changes the list either way.\n * Mouse and keyboard: below the point, flipping up and across; touch and pen: above it, flipping\n * across and down (4.7).\n */\nexport const MENU_POINT_FALLBACKS = {\n ltr: {\n mouse: [\n \"--fsui-menu-up, --fsui-menu-left, --fsui-menu-up-left\",\n \"--fsui-menu-left, --fsui-menu-up, --fsui-menu-up-left\",\n ],\n touch: [\n \"--fsui-menu-left, --fsui-menu-down, --fsui-menu-down-left\",\n \"--fsui-menu-down, --fsui-menu-left, --fsui-menu-down-left\",\n ],\n },\n rtl: {\n mouse: [\n \"--fsui-menu-up, --fsui-menu-right, --fsui-menu-up-right\",\n \"--fsui-menu-right, --fsui-menu-up, --fsui-menu-up-right\",\n ],\n touch: [\n \"--fsui-menu-right, --fsui-menu-down, --fsui-menu-down-right\",\n \"--fsui-menu-down, --fsui-menu-right, --fsui-menu-down-right\",\n ],\n },\n} as const;\n"],"mappings":";;AA6BA,MAAa,yBAAyB;AAEtC,MAAM,eAA2C;CAC/C,KAAK;CACL,QAAQ;CACR,MAAM;CACN,OAAO;CACP,gBAAgB;CAChB,cAAc;AAChB;;;;;;AAOA,SAAgB,aAAa,MAAkB,OAA4B;CACzE,MAAM,UAAU,aAAa;CAC7B,IAAI,UAAU,UAAU,OAAO;CAS/B,OAAO,GAAG,QAAQ,GARC,SAAS,SAAS,SAAS,WAE1C,UAAU,UACR,oBACA,sBACF,UAAU,UACR,gBACA;AAER;AAmBA,MAAM,UAAsC;CAAE,KAAK;CAAK,QAAQ;CAAK,MAAM;CAAK,OAAO;AAAI;;;;;;;;;;;;;AAc3F,SAAgB,kBACd,OACA,eACA,eACA,cAAsB,iBACI;CAC1B,IAAI,gBAAgB,mBAAmB,OAAO,UAAU,UAAU,OAAO;CACzE,MAAM,QAAQ,MAAM,KAAK,CAAC,CAAC,MAAM,KAAK;CACtC,IAAI,MAAM,SAAS,KAAK,MAAM,OAAO,MAAM,MAAM,OAAO,QAAQ,OAAO;CACvE,IAAI;CACJ,MAAM,gBACH,SAAS,OAAO,kBAAkB,aAAa,cAAc,IAAI;CAEpE,MAAM,SAAkB,CAAC;CACzB,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;EACjD,MAAM,QAAQ,SAAS,MAAM,QAAS,OAAO,MAAM,QAAQ,eAAe,OAAO;EACjF,IAAI,UAAU,MAAM,OAAO;EAC3B,OAAO,KAAK,KAAK;CACnB;CAEA,MAAM,QAAQ,OAAO,QAAQ,MAAM,EAAE,SAAS,MAAM;CAEpD,IAAI,MAAM,WAAW,GAAG,OAAO;CAC/B,MAAM,OAAO,MAAM,EAAE,CAAE;CACvB,MAAM,OAAO,OAAO,MAAM,MAAM,EAAE,SAAS,MAAM;CACjD,IAAI,SAAS,KAAA,GAAW,OAAO;EAAE;EAAM,OAAO;CAAS;CACvD,MAAM,SAAS,KAAK;CACpB,IAAI,QAAQ,YAAY,QAAQ,OAAO,OAAO;CAC9C,IAAI,QAAQ,UAAU,KAIpB,OAAO;EAAE;EAAM,OAAO,YADU,kBAAkB,QAAQ,SAAS,WACtB,UAAU;CAAM;CAE/D,OAAO;EAAE;EAAM,OAAO,WAAW,WAAW,UAAU;CAAM;AAC9D;AAEA,SAAS,SACP,MACA,OACA,OACA,eACA,eACc;CACd,IAAI,SAAS,YAAY,SAAS,YAAY,OAAO;EAAE,MAAM;EAAW,UAAU;CAAK;CACvF,MAAM,OAAO,KAAK,WAAW,OAAO;CACpC,MAAM,WAAW,WACf,OAAO,KAAK,MAAM,CAAC,IAAI,MACvB,OACA,OACA,eACA,aACF;CACA,OAAO,aAAa,OAAO,OAAO;EAAE,MAAM,OAAO,SAAS;EAAQ;CAAS;AAC7E;;;;;;AAOA,SAAS,WACP,MACA,OACA,OACA,eACA,eACqB;CACrB,QAAQ,MAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,SACH,OAAO;EAET,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,oBACH,OAAO;EACT,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,kBACH,OAAO;EAET,KAAK;EACL,KAAK;EACL,KAAK,qBACH,OAAO,WAAW,SAAS,aAAa;EAC1C,KAAK;EACL,KAAK;EACL,KAAK,mBACH,OAAO,WAAW,OAAO,aAAa;EAExC,KAAK;EACL,KAAK,gBACH,OAAO,WAAW,SAAS,cAAc,CAAC;EAC5C,KAAK;EACL,KAAK,cACH,OAAO,WAAW,OAAO,cAAc,CAAC;EAC1C,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,YAAY;GACf,IAAI,UAAU,GAAG,OAAO;GACxB,MAAM,OAAO,KAAK,SAAS,OAAO,IAAI,UAAU;GAChD,IAAI,UAAU,GAAG,OAAO,SAAS,UAAU,QAAQ;GACnD,OAAO,WAAW,MAAM,KAAK,WAAW,OAAO,IAAI,gBAAgB,cAAc,CAAC;EACpF;EACA,SACE,OAAO;CACX;AACF;AAEA,SAAS,WAAW,MAAuB,WAAoC;CAC7E,OAAQ,SAAS,aAAc,cAAc,SAAS,SAAS;AACjE;;AAKA,MAAa,eAAe;;AAE5B,MAAa,eAAe;;;;;AAK5B,MAAa,iBAAiB;;AAE9B,MAAa,uBAAuB;;AAGpC,MAAa,kBAAkB;;;;;;;;;AAS/B,MAAa,kBAAkB;AAE/B,MAAM,KAAK,sCAAsC,aAAa,UAAU,eAAe;AACvF,MAAM,OAAO,+BAA+B,aAAa,UAAU,eAAe;AAClF,MAAM,OAAO,sCAAsC,aAAa;AAChE,MAAM,QAAQ,0BAA0B,aAAa;;;;;;;;;;;AAYrD,MAAa,mBACX;iCAGkC,GAAG,uCACD,KAAK,uCACL,KAAK,wCACJ,MAAM,0CACJ,GAAG,GAAG,KAAK,2CACV,GAAG,GAAG,MAAM,4CACX,KAAK,GAAG,KAAK,6CACZ,KAAK,GAAG,MAAM;;;;;;;;;;;AAY1D,MAAa,uBAAuB;CAClC,KAAK;EACH,OAAO,CACL,yDACA,uDACF;EACA,OAAO,CACL,6DACA,2DACF;CACF;CACA,KAAK;EACH,OAAO,CACL,2DACA,yDACF;EACA,OAAO,CACL,+DACA,6DACF;CACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csp-context.mjs","names":[],"sources":["../../src/internal/csp-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext } from \"react\";\n\n/** What `<CSPProvider>` gives the parts that render a hoisted `<style>` (conventions 12). */\nexport interface CSPContextValue {\n /** Forwarded as the `nonce` of every library `<style>`. */\n readonly nonce: string | undefined;\n}\n\nexport const CSPContext = createContext<CSPContextValue | null>(null);\n"],"mappings":";;;AASA,MAAa,aAAa,cAAsC,IAAI"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/internal/tooltip-warm.ts
|
|
2
|
+
/** Registered, non-inherited: `1` on the marked triggers while a tooltip is showing, else `0`. */
|
|
3
|
+
const TOOLTIP_WARM_PROPERTY = "--fsui-tooltip-warm";
|
|
4
|
+
/** The marker a flagged Trigger renders; the shipped rule matches nothing else. */
|
|
5
|
+
const TOOLTIP_TRIGGER_MARKER = "data-fsui-tooltip-trigger";
|
|
6
|
+
/** The dedupe key of the shipped rule (`<style href precedence>`). */
|
|
7
|
+
const TOOLTIP_WARM_HREF = "@funstack/ui/tooltip-warm";
|
|
8
|
+
/**
|
|
9
|
+
* The library's second shipped stylesheet: interaction timing, nothing visual (conventions 12's
|
|
10
|
+
* selector exception: it matches only the library's marker and sets only a `--fsui-` registered
|
|
11
|
+
* property the Trigger's inline style consumes). Its SHA-256 is `STYLE_SHA256` in
|
|
12
|
+
* `@funstack/ui/csp` (a jsdom row recomputes it). When the stylesheet is missing (blocked by a
|
|
13
|
+
* CSP, or never rendered) the property is unregistered and unset: `warmDelay`'s `var()` carries
|
|
14
|
+
* its own `0` fallback, so the Trigger keeps its own `delay` (without it the declaration would be
|
|
15
|
+
* invalid at computed-value time and the browser's `normal` delay would apply).
|
|
16
|
+
*/
|
|
17
|
+
const TOOLTIP_WARM_RULES = `/* @funstack/ui: tooltip skip-delay. Functional only: while a tooltip is showing, the next one opens without its delay. */
|
|
18
|
+
@property ${TOOLTIP_WARM_PROPERTY} { syntax: "<number>"; inherits: false; initial-value: 0; }\n:root:has([role="tooltip"]:popover-open) [${TOOLTIP_TRIGGER_MARKER}] { ${TOOLTIP_WARM_PROPERTY}: 1; }\n`;
|
|
19
|
+
/**
|
|
20
|
+
* The inline `interest-delay-start` of a flagged Trigger: `delay` when cold, `0` when warm, and
|
|
21
|
+
* `delay` when the stylesheet is missing (the explicit `0` fallback).
|
|
22
|
+
*/
|
|
23
|
+
function warmDelay(delay) {
|
|
24
|
+
return `calc(${delay}ms * (1 - var(${TOOLTIP_WARM_PROPERTY}, 0)))`;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { TOOLTIP_TRIGGER_MARKER, TOOLTIP_WARM_HREF, TOOLTIP_WARM_PROPERTY, TOOLTIP_WARM_RULES, warmDelay };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=tooltip-warm.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip-warm.mjs","names":[],"sources":["../../src/internal/tooltip-warm.ts"],"sourcesContent":["// Tooltip's skip-delay rule on the native `interestfor` path (design/components/tooltip.md 6,\n// conventions 12): while any tooltip is showing, the inline `interest-delay-start` of a flagged\n// Trigger computes to 0. No \"use client\" directive: constants only (conventions 7.1).\n\n/** Registered, non-inherited: `1` on the marked triggers while a tooltip is showing, else `0`. */\nexport const TOOLTIP_WARM_PROPERTY = \"--fsui-tooltip-warm\";\n/** The marker a flagged Trigger renders; the shipped rule matches nothing else. */\nexport const TOOLTIP_TRIGGER_MARKER = \"data-fsui-tooltip-trigger\";\n/** The dedupe key of the shipped rule (`<style href precedence>`). */\nexport const TOOLTIP_WARM_HREF = \"@funstack/ui/tooltip-warm\";\n\n/**\n * The library's second shipped stylesheet: interaction timing, nothing visual (conventions 12's\n * selector exception: it matches only the library's marker and sets only a `--fsui-` registered\n * property the Trigger's inline style consumes). Its SHA-256 is `STYLE_SHA256` in\n * `@funstack/ui/csp` (a jsdom row recomputes it). When the stylesheet is missing (blocked by a\n * CSP, or never rendered) the property is unregistered and unset: `warmDelay`'s `var()` carries\n * its own `0` fallback, so the Trigger keeps its own `delay` (without it the declaration would be\n * invalid at computed-value time and the browser's `normal` delay would apply).\n */\nexport const TOOLTIP_WARM_RULES =\n \"/* @funstack/ui: tooltip skip-delay. Functional only: while a tooltip is showing, the next \" +\n \"one opens without its delay. */\\n\" +\n `@property ${TOOLTIP_WARM_PROPERTY} { syntax: \"<number>\"; inherits: false; initial-value: 0; }\\n` +\n `:root:has([role=\"tooltip\"]:popover-open) [${TOOLTIP_TRIGGER_MARKER}] { ${TOOLTIP_WARM_PROPERTY}: 1; }\\n`;\n\n/**\n * The inline `interest-delay-start` of a flagged Trigger: `delay` when cold, `0` when warm, and\n * `delay` when the stylesheet is missing (the explicit `0` fallback).\n */\nexport function warmDelay(delay: number): string {\n return `calc(${delay}ms * (1 - var(${TOOLTIP_WARM_PROPERTY}, 0)))`;\n}\n"],"mappings":";;AAKA,MAAa,wBAAwB;;AAErC,MAAa,yBAAyB;;AAEtC,MAAa,oBAAoB;;;;;;;;;;AAWjC,MAAa,qBACX;YAEa,sBAAsB,yGACU,uBAAuB,MAAM,sBAAsB;;;;;AAMlG,SAAgB,UAAU,OAAuB;CAC/C,OAAO,QAAQ,MAAM,gBAAgB,sBAAsB;AAC7D"}
|