@bysages/react 0.2.1 → 0.2.3
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/ai-response-jZy-0Tvv.mjs +127 -0
- package/dist/chevron-BeHvt46K.mjs +17 -0
- package/dist/components/accordion/index.d.mts +7 -0
- package/dist/components/accordion/index.mjs +10 -0
- package/dist/components/affix/index.d.mts +20 -0
- package/dist/components/affix/index.mjs +18 -0
- package/dist/components/ai/index.d.mts +2 -0
- package/dist/components/ai/index.mjs +65 -0
- package/dist/components/ai-action/index.d.mts +14 -0
- package/dist/components/ai-action/index.mjs +18 -0
- package/dist/components/ai-attachments/index.d.mts +19 -0
- package/dist/components/ai-attachments/index.mjs +106 -0
- package/dist/components/ai-message/index.d.mts +11 -0
- package/dist/components/ai-message/index.mjs +15 -0
- package/dist/components/ai-prompt-input/index.d.mts +47 -0
- package/dist/components/ai-prompt-input/index.mjs +135 -0
- package/dist/components/ai-reasoning/index.d.mts +13 -0
- package/dist/components/ai-reasoning/index.mjs +19 -0
- package/dist/components/ai-response/index.d.mts +22 -0
- package/dist/components/ai-response/index.mjs +2 -0
- package/dist/components/ai-source/index.d.mts +17 -0
- package/dist/components/ai-source/index.mjs +27 -0
- package/dist/components/ai-suggestion/index.d.mts +13 -0
- package/dist/components/ai-suggestion/index.mjs +16 -0
- package/dist/components/ai-tool/index.d.mts +21 -0
- package/dist/components/ai-tool/index.mjs +36 -0
- package/dist/components/alert/index.d.mts +23 -0
- package/dist/components/alert/index.mjs +80 -0
- package/dist/components/angle-slider/index.d.mts +16 -0
- package/dist/components/angle-slider/index.mjs +21 -0
- package/dist/components/aspect-ratio/index.d.mts +10 -0
- package/dist/components/aspect-ratio/index.mjs +17 -0
- package/dist/components/autocomplete/index.d.mts +21 -0
- package/dist/components/autocomplete/index.mjs +35 -0
- package/dist/components/avatar/index.d.mts +20 -0
- package/dist/components/avatar/index.mjs +14 -0
- package/dist/components/avatar-group/index.d.mts +11 -0
- package/dist/components/avatar-group/index.mjs +15 -0
- package/dist/components/back-top/index.d.mts +29 -0
- package/dist/components/back-top/index.mjs +82 -0
- package/dist/components/badge/index.d.mts +10 -0
- package/dist/components/badge/index.mjs +15 -0
- package/dist/components/banner/index.d.mts +31 -0
- package/dist/components/banner/index.mjs +63 -0
- package/dist/components/breadcrumb/index.d.mts +32 -0
- package/dist/components/breadcrumb/index.mjs +35 -0
- package/dist/components/button/index.d.mts +19 -0
- package/dist/components/button/index.mjs +29 -0
- package/dist/components/button-group/index.d.mts +24 -0
- package/dist/components/button-group/index.mjs +25 -0
- package/dist/components/calendar/index.d.mts +17 -0
- package/dist/components/calendar/index.mjs +96 -0
- package/dist/components/card/index.d.mts +46 -0
- package/dist/components/card/index.mjs +44 -0
- package/dist/components/carousel/index.d.mts +9 -0
- package/dist/components/carousel/index.mjs +12 -0
- package/dist/components/cascade-select/index.d.mts +31 -0
- package/dist/components/cascade-select/index.mjs +223 -0
- package/dist/components/checkbox/index.d.mts +16 -0
- package/dist/components/checkbox/index.mjs +21 -0
- package/dist/components/checkbox-group/index.d.mts +28 -0
- package/dist/components/checkbox-group/index.mjs +65 -0
- package/dist/components/chip/index.d.mts +12 -0
- package/dist/components/chip/index.mjs +17 -0
- package/dist/components/client-only/index.d.mts +2 -0
- package/dist/components/client-only/index.mjs +2 -0
- package/dist/components/clipboard/index.d.mts +17 -0
- package/dist/components/clipboard/index.mjs +17 -0
- package/dist/components/collapsible/index.d.mts +7 -0
- package/dist/components/collapsible/index.mjs +10 -0
- package/dist/components/collection/index.d.mts +2 -0
- package/dist/components/collection/index.mjs +2 -0
- package/dist/components/color-picker/index.d.mts +20 -0
- package/dist/components/color-picker/index.mjs +25 -0
- package/dist/components/combobox/index.d.mts +17 -0
- package/dist/components/combobox/index.mjs +18 -0
- package/dist/components/command/index.d.mts +43 -0
- package/dist/components/command/index.mjs +137 -0
- package/dist/components/comment/index.d.mts +17 -0
- package/dist/components/comment/index.mjs +47 -0
- package/dist/components/config-provider/index.d.mts +46 -0
- package/dist/components/config-provider/index.mjs +41 -0
- package/dist/components/container/index.d.mts +13 -0
- package/dist/components/container/index.mjs +15 -0
- package/dist/components/date-input/index.d.mts +17 -0
- package/dist/components/date-input/index.mjs +21 -0
- package/dist/components/date-picker/index.d.mts +19 -0
- package/dist/components/date-picker/index.mjs +23 -0
- package/dist/components/descriptions/index.d.mts +25 -0
- package/dist/components/descriptions/index.mjs +32 -0
- package/dist/components/dialog/index.d.mts +9 -0
- package/dist/components/dialog/index.mjs +11 -0
- package/dist/components/download-trigger/index.d.mts +2 -0
- package/dist/components/download-trigger/index.mjs +2 -0
- package/dist/components/drawer/index.d.mts +9 -0
- package/dist/components/drawer/index.mjs +12 -0
- package/dist/components/dynamic-input/index.d.mts +28 -0
- package/dist/components/dynamic-input/index.mjs +83 -0
- package/dist/components/editable/index.d.mts +16 -0
- package/dist/components/editable/index.mjs +17 -0
- package/dist/components/ellipsis/index.d.mts +10 -0
- package/dist/components/ellipsis/index.mjs +19 -0
- package/dist/components/empty/index.d.mts +28 -0
- package/dist/components/empty/index.mjs +32 -0
- package/dist/components/field/index.d.mts +8 -0
- package/dist/components/field/index.mjs +11 -0
- package/dist/components/fieldset/index.d.mts +7 -0
- package/dist/components/fieldset/index.mjs +10 -0
- package/dist/components/file-upload/index.d.mts +18 -0
- package/dist/components/file-upload/index.mjs +23 -0
- package/dist/components/float-button/index.d.mts +59 -0
- package/dist/components/float-button/index.mjs +90 -0
- package/dist/components/floating-panel/index.d.mts +9 -0
- package/dist/components/floating-panel/index.mjs +12 -0
- package/dist/components/focus-trap/index.d.mts +2 -0
- package/dist/components/focus-trap/index.mjs +2 -0
- package/dist/components/form/index.d.mts +2 -0
- package/dist/components/form/index.mjs +67 -0
- package/dist/components/format/index.d.mts +9 -0
- package/dist/components/format/index.mjs +10 -0
- package/dist/components/frame/index.d.mts +10 -0
- package/dist/components/frame/index.mjs +12 -0
- package/dist/components/grid/index.d.mts +13 -0
- package/dist/components/grid/index.mjs +31 -0
- package/dist/components/highlight/index.d.mts +7 -0
- package/dist/components/highlight/index.mjs +11 -0
- package/dist/components/hover-card/index.d.mts +7 -0
- package/dist/components/hover-card/index.mjs +10 -0
- package/dist/components/icon/index.d.mts +19 -0
- package/dist/components/icon/index.mjs +26 -0
- package/dist/components/image/index.d.mts +17 -0
- package/dist/components/image/index.mjs +57 -0
- package/dist/components/image-cropper/index.d.mts +8 -0
- package/dist/components/image-cropper/index.mjs +11 -0
- package/dist/components/image-viewer/index.d.mts +18 -0
- package/dist/components/image-viewer/index.mjs +110 -0
- package/dist/components/input/index.d.mts +16 -0
- package/dist/components/input/index.mjs +21 -0
- package/dist/components/input-group/index.d.mts +17 -0
- package/dist/components/input-group/index.mjs +31 -0
- package/dist/components/json-tree-view/index.d.mts +7 -0
- package/dist/components/json-tree-view/index.mjs +10 -0
- package/dist/components/kbd/index.d.mts +6 -0
- package/dist/components/kbd/index.mjs +14 -0
- package/dist/components/layout/index.d.mts +63 -0
- package/dist/components/layout/index.mjs +133 -0
- package/dist/components/link/index.d.mts +10 -0
- package/dist/components/link/index.mjs +18 -0
- package/dist/components/list/index.d.mts +39 -0
- package/dist/components/list/index.mjs +66 -0
- package/dist/components/listbox/index.d.mts +18 -0
- package/dist/components/listbox/index.mjs +18 -0
- package/dist/components/marquee/index.d.mts +7 -0
- package/dist/components/marquee/index.mjs +10 -0
- package/dist/components/masonry/index.d.mts +11 -0
- package/dist/components/masonry/index.mjs +29 -0
- package/dist/components/mentions/index.d.mts +2 -0
- package/dist/components/mentions/index.mjs +2 -0
- package/dist/components/menu/index.d.mts +20 -0
- package/dist/components/menu/index.mjs +37 -0
- package/dist/components/menubar/index.d.mts +32 -0
- package/dist/components/menubar/index.mjs +35 -0
- package/dist/components/meter/index.d.mts +26 -0
- package/dist/components/meter/index.mjs +59 -0
- package/dist/components/navigation-menu/index.d.mts +8 -0
- package/dist/components/navigation-menu/index.mjs +11 -0
- package/dist/components/number-input/index.d.mts +16 -0
- package/dist/components/number-input/index.mjs +21 -0
- package/dist/components/page-header/index.d.mts +32 -0
- package/dist/components/page-header/index.mjs +34 -0
- package/dist/components/pagination/index.d.mts +18 -0
- package/dist/components/pagination/index.mjs +23 -0
- package/dist/components/password-input/index.d.mts +16 -0
- package/dist/components/password-input/index.mjs +21 -0
- package/dist/components/pin-input/index.d.mts +15 -0
- package/dist/components/pin-input/index.mjs +20 -0
- package/dist/components/popconfirm/index.d.mts +20 -0
- package/dist/components/popconfirm/index.mjs +44 -0
- package/dist/components/popover/index.d.mts +8 -0
- package/dist/components/popover/index.mjs +11 -0
- package/dist/components/presence/index.d.mts +2 -0
- package/dist/components/presence/index.mjs +2 -0
- package/dist/components/progress/index.d.mts +16 -0
- package/dist/components/progress/index.mjs +21 -0
- package/dist/components/progress-group/index.d.mts +22 -0
- package/dist/components/progress-group/index.mjs +56 -0
- package/dist/components/qr-code/index.d.mts +8 -0
- package/dist/components/qr-code/index.mjs +11 -0
- package/dist/components/radio-group/index.d.mts +16 -0
- package/dist/components/radio-group/index.mjs +21 -0
- package/dist/components/rating-group/index.d.mts +16 -0
- package/dist/components/rating-group/index.mjs +21 -0
- package/dist/components/scroll-area/index.d.mts +7 -0
- package/dist/components/scroll-area/index.mjs +10 -0
- package/dist/components/segment-group/index.d.mts +18 -0
- package/dist/components/segment-group/index.mjs +20 -0
- package/dist/components/select/index.d.mts +17 -0
- package/dist/components/select/index.mjs +18 -0
- package/dist/components/separator/index.d.mts +11 -0
- package/dist/components/separator/index.mjs +16 -0
- package/dist/components/signature-pad/index.d.mts +8 -0
- package/dist/components/signature-pad/index.mjs +11 -0
- package/dist/components/skeleton/index.d.mts +7 -0
- package/dist/components/skeleton/index.mjs +13 -0
- package/dist/components/slider/index.d.mts +16 -0
- package/dist/components/slider/index.mjs +21 -0
- package/dist/components/spinner/index.d.mts +9 -0
- package/dist/components/spinner/index.mjs +36 -0
- package/dist/components/split-button/index.d.mts +36 -0
- package/dist/components/split-button/index.mjs +71 -0
- package/dist/components/splitter/index.d.mts +7 -0
- package/dist/components/splitter/index.mjs +10 -0
- package/dist/components/stack/index.d.mts +11 -0
- package/dist/components/stack/index.mjs +32 -0
- package/dist/components/stat/index.d.mts +29 -0
- package/dist/components/stat/index.mjs +37 -0
- package/dist/components/steps/index.d.mts +19 -0
- package/dist/components/steps/index.mjs +24 -0
- package/dist/components/swap/index.d.mts +8 -0
- package/dist/components/swap/index.mjs +11 -0
- package/dist/components/switch/index.d.mts +16 -0
- package/dist/components/switch/index.mjs +21 -0
- package/dist/components/table/index.d.mts +79 -0
- package/dist/components/table/index.mjs +688 -0
- package/dist/components/tabs/index.d.mts +18 -0
- package/dist/components/tabs/index.mjs +23 -0
- package/dist/components/tags-input/index.d.mts +17 -0
- package/dist/components/tags-input/index.mjs +22 -0
- package/dist/components/textarea/index.d.mts +14 -0
- package/dist/components/textarea/index.mjs +20 -0
- package/dist/components/timeline/index.d.mts +24 -0
- package/dist/components/timeline/index.mjs +30 -0
- package/dist/components/timer/index.d.mts +8 -0
- package/dist/components/timer/index.mjs +11 -0
- package/dist/components/toast/index.d.mts +11 -0
- package/dist/components/toast/index.mjs +13 -0
- package/dist/components/toc/index.d.mts +7 -0
- package/dist/components/toc/index.mjs +10 -0
- package/dist/components/toggle/index.d.mts +7 -0
- package/dist/components/toggle/index.mjs +10 -0
- package/dist/components/toggle-group/index.d.mts +15 -0
- package/dist/components/toggle-group/index.mjs +20 -0
- package/dist/components/tooltip/index.d.mts +7 -0
- package/dist/components/tooltip/index.mjs +10 -0
- package/dist/components/tour/index.d.mts +11 -0
- package/dist/components/tour/index.mjs +13 -0
- package/dist/components/transfer/index.d.mts +23 -0
- package/dist/components/transfer/index.mjs +154 -0
- package/dist/components/tree-select/index.d.mts +28 -0
- package/dist/components/tree-select/index.mjs +157 -0
- package/dist/components/tree-view/index.d.mts +19 -0
- package/dist/components/tree-view/index.mjs +18 -0
- package/dist/components/typography/index.d.mts +32 -0
- package/dist/components/typography/index.mjs +34 -0
- package/dist/components/watermark/index.d.mts +16 -0
- package/dist/components/watermark/index.mjs +80 -0
- package/dist/index-DaAbbSz9.d.mts +13416 -0
- package/dist/index-Uefyw7Im.d.mts +108 -0
- package/dist/index-uPyYiWaL.d.mts +1813 -0
- package/dist/index.d.mts +128 -15218
- package/dist/index.mjs +128 -4556
- package/dist/mentions-DMIBCBOd.mjs +181 -0
- package/package.json +77 -3
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { t as chevron } from "../../chevron-BeHvt46K.mjs";
|
|
2
|
+
import { Collapsible } from "../collapsible/index.mjs";
|
|
3
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/ai-reasoning/index.tsx
|
|
6
|
+
function Reasoning({ label = "Thinking", children, ...rest }) {
|
|
7
|
+
injectComponentStyle("ai");
|
|
8
|
+
return /* @__PURE__ */ jsxs(Collapsible.Root, {
|
|
9
|
+
...rest,
|
|
10
|
+
"data-ai": "reasoning",
|
|
11
|
+
children: [/* @__PURE__ */ jsxs(Collapsible.Trigger, { children: [/* @__PURE__ */ jsx("span", { children: label }), /* @__PURE__ */ jsx(Collapsible.Indicator, { children: chevron })] }), /* @__PURE__ */ jsx(Collapsible.Content, { children: /* @__PURE__ */ jsx("div", {
|
|
12
|
+
"data-scope": "ai",
|
|
13
|
+
"data-part": "reasoning-content",
|
|
14
|
+
children
|
|
15
|
+
}) })]
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { Reasoning as AiReasoning, Reasoning };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
//#region src/components/ai-response/index.d.ts
|
|
3
|
+
/** Markdown set on the paper. Rendering goes through
|
|
4
|
+
* `@tanstack/markdown`, whose defaults leave raw HTML and executable
|
|
5
|
+
* links inert — streaming-safe by construction. An optional
|
|
6
|
+
* highlighter re-inks fenced code; the component stays agnostic about
|
|
7
|
+
* which engine provides it. */
|
|
8
|
+
export interface ResponseProps extends HTMLAttributes<HTMLDivElement> {
|
|
9
|
+
/** The markdown text to set on the paper — streamed in freely; raw
|
|
10
|
+
* HTML and executable links stay inert. */
|
|
11
|
+
content: string;
|
|
12
|
+
/** Optional code-highlighting function re-inking fenced blocks; the
|
|
13
|
+
* component stays agnostic about which engine provides it. */
|
|
14
|
+
highlighter?: (code: string, lang?: string) => string;
|
|
15
|
+
/** The copy stamp's accessible name before the copy lands. */
|
|
16
|
+
copyLabel?: string;
|
|
17
|
+
/** The copy stamp's accessible name once the text has landed. */
|
|
18
|
+
copiedLabel?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function Response({ content, highlighter, copyLabel, copiedLabel, ...rest }: ResponseProps): import("react").JSX.Element;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { Response as AiResponse };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
//#region src/components/ai-source/index.d.ts
|
|
3
|
+
/** One place the ink came from; href and the rest ride the anchor. */
|
|
4
|
+
export interface SourceProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
5
|
+
/** Where the ink came from — also the link text when no children are
|
|
6
|
+
* given; opens in a new tab, referrer-free. */
|
|
7
|
+
href: string;
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export declare function Source({ href, children, ...rest }: SourceProps): import("react").JSX.Element;
|
|
11
|
+
/** The reading list under a response: where this ink came from. */
|
|
12
|
+
export interface SourcesProps extends HTMLAttributes<HTMLOListElement> {
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export declare function Sources({ children, ...rest }: SourcesProps): import("react").JSX.Element;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { Source as AiSource, Sources as AiSources };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/ai-source/index.tsx
|
|
4
|
+
function Source({ href, children, ...rest }) {
|
|
5
|
+
injectComponentStyle("ai");
|
|
6
|
+
return /* @__PURE__ */ jsx("li", {
|
|
7
|
+
"data-scope": "ai",
|
|
8
|
+
"data-part": "source",
|
|
9
|
+
children: /* @__PURE__ */ jsx("a", {
|
|
10
|
+
...rest,
|
|
11
|
+
href,
|
|
12
|
+
target: "_blank",
|
|
13
|
+
rel: "noreferrer",
|
|
14
|
+
children: children ?? href
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function Sources({ children, ...rest }) {
|
|
19
|
+
return /* @__PURE__ */ jsx("ol", {
|
|
20
|
+
...rest,
|
|
21
|
+
"data-scope": "ai",
|
|
22
|
+
"data-part": "sources",
|
|
23
|
+
children
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { Source as AiSource, Source, Sources as AiSources, Sources };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
//#region src/components/ai-suggestion/index.d.ts
|
|
3
|
+
/** A seal-cut button proposing the next stroke; selection hands back
|
|
4
|
+
* the prompt. The shared Button in its outline register. */
|
|
5
|
+
export interface SuggestionProps extends Omit<HTMLAttributes<HTMLButtonElement>, "onSelect"> {
|
|
6
|
+
/** The next stroke this seal proposes — also its label; handed back
|
|
7
|
+
* whole on `onSelect`. */
|
|
8
|
+
prompt: string;
|
|
9
|
+
onSelect?: (prompt: string) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function Suggestion({ prompt, onSelect, ...rest }: SuggestionProps): import("react").JSX.Element;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { Suggestion as AiSuggestion };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Button } from "../button/index.mjs";
|
|
2
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/ai-suggestion/index.tsx
|
|
5
|
+
function Suggestion({ prompt, onSelect, ...rest }) {
|
|
6
|
+
injectComponentStyle("ai");
|
|
7
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
8
|
+
variant: "outline",
|
|
9
|
+
size: "sm",
|
|
10
|
+
...rest,
|
|
11
|
+
onClick: () => onSelect?.(prompt),
|
|
12
|
+
children: prompt
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { Suggestion as AiSuggestion, Suggestion };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
//#region src/components/ai-tool/index.d.ts
|
|
3
|
+
export type ToolStatus = "pending" | "running" | "completed" | "error";
|
|
4
|
+
/** A tool call: the shared collapsible as the vessel — the name it was
|
|
5
|
+
* reached by and the state it reached in on the trigger, its input and
|
|
6
|
+
* output folded inside. */
|
|
7
|
+
export interface ToolProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
/** The name the tool was reached by — shown raw on the trigger
|
|
9
|
+
* unless a `label` speaks friendlier words ("Searching pages…"). */
|
|
10
|
+
name: string;
|
|
11
|
+
label?: ReactNode;
|
|
12
|
+
/** The state the call reached — pending, running, completed, or
|
|
13
|
+
* error; stamped on the fold and whispered in the status chip. */
|
|
14
|
+
status?: ToolStatus;
|
|
15
|
+
defaultOpen?: boolean;
|
|
16
|
+
input?: ReactNode;
|
|
17
|
+
output?: ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export declare function Tool({ name, label, status, input, output, ...rest }: ToolProps): import("react").JSX.Element;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { Tool as AiTool };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { t as chevron } from "../../chevron-BeHvt46K.mjs";
|
|
2
|
+
import { Collapsible } from "../collapsible/index.mjs";
|
|
3
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/ai-tool/index.tsx
|
|
6
|
+
function Tool({ name, label, status, input, output, ...rest }) {
|
|
7
|
+
injectComponentStyle("ai");
|
|
8
|
+
return /* @__PURE__ */ jsxs(Collapsible.Root, {
|
|
9
|
+
...rest,
|
|
10
|
+
"data-ai": "tool",
|
|
11
|
+
"data-status": status,
|
|
12
|
+
children: [/* @__PURE__ */ jsxs(Collapsible.Trigger, { children: [
|
|
13
|
+
/* @__PURE__ */ jsx("span", { children: label ?? name }),
|
|
14
|
+
status ? /* @__PURE__ */ jsx("span", {
|
|
15
|
+
"data-scope": "ai",
|
|
16
|
+
"data-part": "tool-status",
|
|
17
|
+
children: status.charAt(0).toUpperCase() + status.slice(1)
|
|
18
|
+
}) : null,
|
|
19
|
+
/* @__PURE__ */ jsx(Collapsible.Indicator, { children: chevron })
|
|
20
|
+
] }), /* @__PURE__ */ jsx(Collapsible.Content, { children: /* @__PURE__ */ jsxs("div", {
|
|
21
|
+
"data-scope": "ai",
|
|
22
|
+
"data-part": "tool-body",
|
|
23
|
+
children: [input ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
24
|
+
"data-scope": "ai",
|
|
25
|
+
"data-part": "tool-label",
|
|
26
|
+
children: "Input"
|
|
27
|
+
}), /* @__PURE__ */ jsx("pre", { children: input })] }) : null, output ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
28
|
+
"data-scope": "ai",
|
|
29
|
+
"data-part": "tool-label",
|
|
30
|
+
children: "Output"
|
|
31
|
+
}), /* @__PURE__ */ jsx("pre", { children: output })] }) : null]
|
|
32
|
+
}) })]
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { Tool as AiTool, Tool };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
//#region src/components/alert/index.d.ts
|
|
3
|
+
export type AlertStatus = "ink" | "info" | "success" | "warning" | "danger";
|
|
4
|
+
/** A notice drawn on the page: a wash of the status pigment, one heavier
|
|
5
|
+
* hairline on the leading edge, the serif for its title. Root, Icon,
|
|
6
|
+
* Body, Title, Description — the icon reads the status from the Root. */
|
|
7
|
+
export interface AlertProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
status?: AlertStatus;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
declare function AlertRoot({ status, children, ...rest }: AlertProps): import("react").JSX.Element;
|
|
12
|
+
declare function Icon(): import("react").JSX.Element;
|
|
13
|
+
declare function Body({ children, ...rest }: HTMLAttributes<HTMLDivElement>): import("react").JSX.Element;
|
|
14
|
+
declare function Title({ children, ...rest }: HTMLAttributes<HTMLParagraphElement>): import("react").JSX.Element;
|
|
15
|
+
declare function Description({ children, ...rest }: HTMLAttributes<HTMLParagraphElement>): import("react").JSX.Element;
|
|
16
|
+
export declare const Alert: typeof AlertRoot & {
|
|
17
|
+
Root: typeof AlertRoot;
|
|
18
|
+
Icon: typeof Icon;
|
|
19
|
+
Body: typeof Body;
|
|
20
|
+
Title: typeof Title;
|
|
21
|
+
Description: typeof Description;
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext } from "react";
|
|
4
|
+
//#region src/components/alert/index.tsx
|
|
5
|
+
const StatusContext = createContext("ink");
|
|
6
|
+
function glyph(status) {
|
|
7
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
8
|
+
width: 16,
|
|
9
|
+
height: 16,
|
|
10
|
+
viewBox: "0 0 24 24",
|
|
11
|
+
fill: "none",
|
|
12
|
+
stroke: "currentColor",
|
|
13
|
+
strokeWidth: 1.75,
|
|
14
|
+
strokeLinecap: "round",
|
|
15
|
+
strokeLinejoin: "round",
|
|
16
|
+
"aria-hidden": "true",
|
|
17
|
+
children: /* @__PURE__ */ jsx("path", { d: {
|
|
18
|
+
info: "M12 8v5m0 3v.01M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Z",
|
|
19
|
+
success: "m4 12.5 5 5L20 6.5",
|
|
20
|
+
warning: "M12 4 2.5 20h19L12 4Zm0 6v4m0 3v.01",
|
|
21
|
+
danger: "M6 6l12 12M18 6 6 18",
|
|
22
|
+
ink: "M12 8v5m0 3v.01M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Z"
|
|
23
|
+
}[status] })
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function AlertRoot({ status = "ink", children, ...rest }) {
|
|
27
|
+
return /* @__PURE__ */ jsx(StatusContext.Provider, {
|
|
28
|
+
value: status,
|
|
29
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
30
|
+
...rest,
|
|
31
|
+
role: status === "ink" || status === "info" ? "status" : "alert",
|
|
32
|
+
"data-scope": "alert",
|
|
33
|
+
"data-part": "root",
|
|
34
|
+
"data-status": status,
|
|
35
|
+
children
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function Icon() {
|
|
40
|
+
const status = useContext(StatusContext);
|
|
41
|
+
return /* @__PURE__ */ jsx("span", {
|
|
42
|
+
"data-scope": "alert",
|
|
43
|
+
"data-part": "icon",
|
|
44
|
+
children: glyph(status)
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function Body({ children, ...rest }) {
|
|
48
|
+
return /* @__PURE__ */ jsx("div", {
|
|
49
|
+
...rest,
|
|
50
|
+
"data-scope": "alert",
|
|
51
|
+
"data-part": "body",
|
|
52
|
+
children
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function Title({ children, ...rest }) {
|
|
56
|
+
return /* @__PURE__ */ jsx("p", {
|
|
57
|
+
...rest,
|
|
58
|
+
"data-scope": "alert",
|
|
59
|
+
"data-part": "title",
|
|
60
|
+
children
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function Description({ children, ...rest }) {
|
|
64
|
+
return /* @__PURE__ */ jsx("p", {
|
|
65
|
+
...rest,
|
|
66
|
+
"data-scope": "alert",
|
|
67
|
+
"data-part": "description",
|
|
68
|
+
children
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
const Alert = Object.assign(AlertRoot, {
|
|
72
|
+
Root: AlertRoot,
|
|
73
|
+
Icon,
|
|
74
|
+
Body,
|
|
75
|
+
Title,
|
|
76
|
+
Description
|
|
77
|
+
});
|
|
78
|
+
injectComponentStyle("alert");
|
|
79
|
+
//#endregion
|
|
80
|
+
export { Alert };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { AngleSlider as AngleSlider$1 } from "@ark-ui/react/angle-slider";
|
|
3
|
+
//#region src/components/angle-slider/index.d.ts
|
|
4
|
+
type AngleSliderRootProps = ComponentProps<typeof AngleSlider$1.Root> & {
|
|
5
|
+
/** One rung of the dial ladder — the diameter the needle sweeps. */
|
|
6
|
+
size?: "sm" | "md" | "lg";
|
|
7
|
+
};
|
|
8
|
+
declare function AngleSliderRoot({ size, ...rest }: AngleSliderRootProps): import("react").JSX.Element;
|
|
9
|
+
/** Ark's AngleSlider, dressed in the paper-and-ink system: a flat paper dial
|
|
10
|
+
* the thumb sweeps as a pigment needle over hairline degree ticks. The API
|
|
11
|
+
* is Ark's own — Root, Label, ValueText, Control, Thumb, MarkerGroup,
|
|
12
|
+
* Marker, HiddenInput. */
|
|
13
|
+
export declare const AngleSlider: Omit<typeof AngleSlider$1, "Root"> & {
|
|
14
|
+
Root: typeof AngleSliderRoot;
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { AngleSlider as AngleSlider$1 } from "@ark-ui/react/angle-slider";
|
|
4
|
+
//#region src/components/angle-slider/index.tsx
|
|
5
|
+
function AngleSliderRoot({ size = "md", ...rest }) {
|
|
6
|
+
return /* @__PURE__ */ jsx(AngleSlider$1.Root, {
|
|
7
|
+
...rest,
|
|
8
|
+
"data-size": size
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
/** Ark's AngleSlider, dressed in the paper-and-ink system: a flat paper dial
|
|
12
|
+
* the thumb sweeps as a pigment needle over hairline degree ticks. The API
|
|
13
|
+
* is Ark's own — Root, Label, ValueText, Control, Thumb, MarkerGroup,
|
|
14
|
+
* Marker, HiddenInput. */
|
|
15
|
+
const AngleSlider = {
|
|
16
|
+
...AngleSlider$1,
|
|
17
|
+
Root: AngleSliderRoot
|
|
18
|
+
};
|
|
19
|
+
injectComponentStyle("angle-slider");
|
|
20
|
+
//#endregion
|
|
21
|
+
export { AngleSlider };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
//#region src/components/aspect-ratio/index.d.ts
|
|
3
|
+
/** A frame that keeps its shape: the box holds the given ratio whatever
|
|
4
|
+
* the width it is dealt, and the child fills the frame it is given. */
|
|
5
|
+
export interface AspectRatioProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
/** A CSS `aspect-ratio` value — "16 / 9", "4 / 3", "1 / 1". */
|
|
7
|
+
ratio?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function AspectRatio({ ratio, ...rest }: AspectRatioProps): import("react").JSX.Element;
|
|
10
|
+
//#endregion
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/aspect-ratio/index.tsx
|
|
4
|
+
function AspectRatio({ ratio = "1 / 1", ...rest }) {
|
|
5
|
+
injectComponentStyle("aspect-ratio");
|
|
6
|
+
return /* @__PURE__ */ jsx("div", {
|
|
7
|
+
...rest,
|
|
8
|
+
style: {
|
|
9
|
+
...rest.style,
|
|
10
|
+
"--bs-aspect-ratio": ratio
|
|
11
|
+
},
|
|
12
|
+
"data-scope": "aspect-ratio",
|
|
13
|
+
"data-part": "root"
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { AspectRatio };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
//#region src/components/autocomplete/index.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Free text with suggestions: the reader types anything, the list
|
|
5
|
+
* narrows to help, and both a pick and a custom value end up in the
|
|
6
|
+
* same `value`. A preset of the combobox machinery — same parts, same
|
|
7
|
+
* styling, one job. `items` seeds the suggestion list once; matching is
|
|
8
|
+
* a case-insensitive substring unless `filter` says otherwise.
|
|
9
|
+
*/
|
|
10
|
+
export interface AutoCompleteProps extends Omit<HTMLAttributes<HTMLDivElement>, "defaultValue" | "onSelect"> {
|
|
11
|
+
value?: string;
|
|
12
|
+
items?: string[];
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
/** Field text to match against; defaults to the item itself. */
|
|
15
|
+
filter?: (item: string, input: string) => boolean;
|
|
16
|
+
/** One rung of the control-height ladder for the field row. */
|
|
17
|
+
size?: "sm" | "md" | "lg";
|
|
18
|
+
onValueChange?: (value: string) => void;
|
|
19
|
+
}
|
|
20
|
+
export declare function AutoComplete({ value, items, placeholder, filter, size, onValueChange, ...rest }: AutoCompleteProps): import("react").JSX.Element;
|
|
21
|
+
//#endregion
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Portal } from "@ark-ui/react/portal";
|
|
4
|
+
import { useListCollection } from "@ark-ui/react/collection";
|
|
5
|
+
import { Combobox } from "@ark-ui/react/combobox";
|
|
6
|
+
//#region src/components/autocomplete/index.tsx
|
|
7
|
+
function AutoComplete({ value = "", items = [], placeholder, filter, size = "md", onValueChange, ...rest }) {
|
|
8
|
+
injectComponentStyle("combobox");
|
|
9
|
+
const { collection, filter: filterItems } = useListCollection({
|
|
10
|
+
initialItems: items,
|
|
11
|
+
filter: (item, input) => filter ? filter(item, input) : item.toLowerCase().includes(input.toLowerCase())
|
|
12
|
+
});
|
|
13
|
+
return /* @__PURE__ */ jsxs(Combobox.Root, {
|
|
14
|
+
...rest,
|
|
15
|
+
collection,
|
|
16
|
+
inputValue: value,
|
|
17
|
+
allowCustomValue: true,
|
|
18
|
+
"data-size": size,
|
|
19
|
+
onValueChange: (details) => {
|
|
20
|
+
const [first] = details.value;
|
|
21
|
+
if (first != null) onValueChange?.(first);
|
|
22
|
+
},
|
|
23
|
+
onInputValueChange: (details) => {
|
|
24
|
+
filterItems(details.inputValue);
|
|
25
|
+
onValueChange?.(details.inputValue);
|
|
26
|
+
},
|
|
27
|
+
positioning: { sameWidth: true },
|
|
28
|
+
children: [/* @__PURE__ */ jsx(Combobox.Control, { children: /* @__PURE__ */ jsx(Combobox.Input, { placeholder }) }), /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(Combobox.Positioner, { children: /* @__PURE__ */ jsxs(Combobox.Content, { children: [/* @__PURE__ */ jsx(Combobox.Empty, { children: "No matches" }), collection.items.map((item) => /* @__PURE__ */ jsx(Combobox.Item, {
|
|
29
|
+
item,
|
|
30
|
+
children: /* @__PURE__ */ jsx(Combobox.ItemText, { children: item })
|
|
31
|
+
}, item))] }) }) })]
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { AutoComplete };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { Avatar as Avatar$1 } from "@ark-ui/react/avatar";
|
|
3
|
+
//#region src/components/avatar/index.d.ts
|
|
4
|
+
/** Avatar, dressed in the paper-and-ink system: a circular seal on
|
|
5
|
+
* inset paper that holds initials until the image loads over them.
|
|
6
|
+
* `size` picks a control-height rung for the seal — the core styles
|
|
7
|
+
* re-point `--bs-avatar-size` per rung, and scenes can still retune the
|
|
8
|
+
* variable directly. */
|
|
9
|
+
export type AvatarSize = "sm" | "md" | "lg";
|
|
10
|
+
export interface AvatarProps extends ComponentProps<typeof Avatar$1.Root> {
|
|
11
|
+
/** Seal diameter: the small, medium, or large control rung. The
|
|
12
|
+
* default (large) stands as tall as the biggest control so an avatar
|
|
13
|
+
* rides a row without stretching it. */
|
|
14
|
+
size?: AvatarSize;
|
|
15
|
+
}
|
|
16
|
+
declare function AvatarRoot({ size, ...rest }: AvatarProps): import("react").JSX.Element;
|
|
17
|
+
export declare const Avatar: typeof Avatar$1 & {
|
|
18
|
+
Root: typeof AvatarRoot;
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Avatar as Avatar$1 } from "@ark-ui/react/avatar";
|
|
4
|
+
//#region src/components/avatar/index.tsx
|
|
5
|
+
function AvatarRoot({ size, ...rest }) {
|
|
6
|
+
return /* @__PURE__ */ jsx(Avatar$1.Root, {
|
|
7
|
+
...rest,
|
|
8
|
+
"data-size": size
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
const Avatar = Object.assign({}, Avatar$1, { Root: AvatarRoot });
|
|
12
|
+
injectComponentStyle("avatar");
|
|
13
|
+
//#endregion
|
|
14
|
+
export { Avatar };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
//#region src/components/avatar-group/index.d.ts
|
|
3
|
+
/** Avatars overlapping one row, each rimmed in the ground so the pile
|
|
4
|
+
* stays legible. */
|
|
5
|
+
export interface AvatarGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
/** One register for every seal: falls onto data-size for the
|
|
7
|
+
* stylesheet to re-point the avatars' measure. */
|
|
8
|
+
size?: "sm" | "md" | "lg";
|
|
9
|
+
}
|
|
10
|
+
export declare function AvatarGroup({ size, children, ...rest }: AvatarGroupProps): import("react").JSX.Element;
|
|
11
|
+
//#endregion
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/avatar-group/index.tsx
|
|
4
|
+
function AvatarGroup({ size, children, ...rest }) {
|
|
5
|
+
injectComponentStyle("avatar-group");
|
|
6
|
+
return /* @__PURE__ */ jsx("div", {
|
|
7
|
+
...rest,
|
|
8
|
+
"data-scope": "avatar-group",
|
|
9
|
+
"data-part": "root",
|
|
10
|
+
"data-size": size,
|
|
11
|
+
children
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { AvatarGroup };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
//#region src/components/back-top/index.d.ts
|
|
3
|
+
export interface BackTopProps extends HTMLAttributes<HTMLButtonElement> {
|
|
4
|
+
/** How far the reader must have travelled (px) before the affordance
|
|
5
|
+
* appears. */
|
|
6
|
+
threshold?: number;
|
|
7
|
+
/** The accessible name; the control is icon-only by default. */
|
|
8
|
+
label?: string;
|
|
9
|
+
/** Ride a scrolling element of your own instead of the page: the
|
|
10
|
+
* control moors inside that element's corner and watches its
|
|
11
|
+
* scrollTop. The host supplies the positioning context. */
|
|
12
|
+
scrollEl?: () => HTMLElement | null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A way home: after the page has scrolled past `threshold`, a small
|
|
16
|
+
* floating control rises at the page's corner and returns the reader to
|
|
17
|
+
* the top. The scroll itself stays native — `window.scrollTo` defers to
|
|
18
|
+
* the stylesheet's `scroll-behavior: smooth`, which reduced motion turns
|
|
19
|
+
* back into an instant jump (a moored control asks the media query
|
|
20
|
+
* directly, since a scroller of its own has no stylesheet to defer to).
|
|
21
|
+
* The button stays mounted either way so the entrance is a transition,
|
|
22
|
+
* never a pop.
|
|
23
|
+
*
|
|
24
|
+
* The control itself is the shared `Button` (outline, square) — the
|
|
25
|
+
* paper, hairline and halo are its; this family owns only the floating
|
|
26
|
+
* and the entrance.
|
|
27
|
+
*/
|
|
28
|
+
export declare function BackTop({ threshold, label, scrollEl, ...rest }: BackTopProps): import("react").JSX.Element;
|
|
29
|
+
//#endregion
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Button } from "../button/index.mjs";
|
|
2
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
//#region src/components/back-top/index.tsx
|
|
6
|
+
/** The single glyph a way-home control needs: one stroke pointing up. */
|
|
7
|
+
function chevronUp() {
|
|
8
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
9
|
+
width: 16,
|
|
10
|
+
height: 16,
|
|
11
|
+
viewBox: "0 0 24 24",
|
|
12
|
+
fill: "none",
|
|
13
|
+
stroke: "currentColor",
|
|
14
|
+
strokeWidth: 1.75,
|
|
15
|
+
strokeLinecap: "round",
|
|
16
|
+
strokeLinejoin: "round",
|
|
17
|
+
"aria-hidden": "true",
|
|
18
|
+
children: /* @__PURE__ */ jsx("path", { d: "m6 14 6-6 6 6" })
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A way home: after the page has scrolled past `threshold`, a small
|
|
23
|
+
* floating control rises at the page's corner and returns the reader to
|
|
24
|
+
* the top. The scroll itself stays native — `window.scrollTo` defers to
|
|
25
|
+
* the stylesheet's `scroll-behavior: smooth`, which reduced motion turns
|
|
26
|
+
* back into an instant jump (a moored control asks the media query
|
|
27
|
+
* directly, since a scroller of its own has no stylesheet to defer to).
|
|
28
|
+
* The button stays mounted either way so the entrance is a transition,
|
|
29
|
+
* never a pop.
|
|
30
|
+
*
|
|
31
|
+
* The control itself is the shared `Button` (outline, square) — the
|
|
32
|
+
* paper, hairline and halo are its; this family owns only the floating
|
|
33
|
+
* and the entrance.
|
|
34
|
+
*/
|
|
35
|
+
function BackTop({ threshold = 400, label = "Back to top", scrollEl, ...rest }) {
|
|
36
|
+
injectComponentStyle("back-top");
|
|
37
|
+
const [visible, setVisible] = useState(false);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (typeof window === "undefined") return;
|
|
40
|
+
const el = scrollEl?.() ?? null;
|
|
41
|
+
const onScroll = () => setVisible((el ? el.scrollTop : window.scrollY) > threshold);
|
|
42
|
+
onScroll();
|
|
43
|
+
if (el) el.addEventListener("scroll", onScroll, { passive: true });
|
|
44
|
+
else window.addEventListener("scroll", onScroll, { passive: true });
|
|
45
|
+
return () => {
|
|
46
|
+
if (el) el.removeEventListener("scroll", onScroll);
|
|
47
|
+
else window.removeEventListener("scroll", onScroll);
|
|
48
|
+
};
|
|
49
|
+
}, [threshold, scrollEl]);
|
|
50
|
+
const toTop = () => {
|
|
51
|
+
const el = scrollEl?.();
|
|
52
|
+
if (!el) {
|
|
53
|
+
window.scrollTo({ top: 0 });
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
57
|
+
el.scrollTo({
|
|
58
|
+
top: 0,
|
|
59
|
+
behavior: reduce ? "auto" : "smooth"
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
return /* @__PURE__ */ jsx("div", {
|
|
63
|
+
"data-scope": "back-top",
|
|
64
|
+
"data-part": "root",
|
|
65
|
+
"data-state": visible ? "shown" : "hidden",
|
|
66
|
+
...scrollEl ? { "data-container": "" } : {},
|
|
67
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
68
|
+
...rest,
|
|
69
|
+
variant: "outline",
|
|
70
|
+
square: true,
|
|
71
|
+
size: "lg",
|
|
72
|
+
type: "button",
|
|
73
|
+
"aria-label": label,
|
|
74
|
+
"aria-hidden": visible ? void 0 : "true",
|
|
75
|
+
tabIndex: visible ? 0 : -1,
|
|
76
|
+
onClick: toTop,
|
|
77
|
+
children: rest.children ?? chevronUp()
|
|
78
|
+
})
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
export { BackTop };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
//#region src/components/badge/index.d.ts
|
|
3
|
+
/** A small seal of state. Ink is the neutral tone; the four semantic
|
|
4
|
+
* pigments are fixed. Subtle and outline re-register the same pigment. */
|
|
5
|
+
export interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
6
|
+
tone?: "ink" | "info" | "success" | "warning" | "danger";
|
|
7
|
+
variant?: "solid" | "subtle" | "outline";
|
|
8
|
+
}
|
|
9
|
+
export declare function Badge({ tone, variant, ...rest }: BadgeProps): import("react").JSX.Element;
|
|
10
|
+
//#endregion
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/badge/index.tsx
|
|
4
|
+
function Badge({ tone = "ink", variant = "solid", ...rest }) {
|
|
5
|
+
injectComponentStyle("badge");
|
|
6
|
+
return /* @__PURE__ */ jsx("span", {
|
|
7
|
+
...rest,
|
|
8
|
+
"data-scope": "badge",
|
|
9
|
+
"data-part": "root",
|
|
10
|
+
"data-tone": tone,
|
|
11
|
+
"data-variant": variant
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { Badge };
|