aidos-ui 3.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/Badge.d.ts +1 -2
- package/dist/BaseLink.d.ts +1 -1
- package/dist/BaseList.d.ts +1 -1
- package/dist/BaseListAddOn.d.ts +1 -1
- package/dist/BaseListItem.d.ts +1 -2
- package/dist/BaseListItem.js +3 -1
- package/dist/BaseListItem.js.map +1 -1
- package/dist/BaseView.d.ts +1 -1
- package/dist/Box.d.ts +1 -2
- package/dist/Card.d.ts +1 -1
- package/dist/Checkbox.d.ts +1 -2
- package/dist/Circle.d.ts +1 -2
- package/dist/Column.d.ts +1 -1
- package/dist/DarkMode.d.ts +2 -2
- package/dist/DatePicker.d.ts +1 -2
- package/dist/DesignBook.d.ts +1 -2
- package/dist/Dialog.d.ts +2 -2
- package/dist/Dropdown.d.ts +1 -2
- package/dist/FlexLayout.d.ts +1 -1
- package/dist/Icon.d.ts +1 -1
- package/dist/List.d.ts +5 -2
- package/dist/List.js +22 -10
- package/dist/List.js.map +1 -1
- package/dist/ListButtonItem.d.ts +1 -2
- package/dist/ListButtonItem.js +4 -2
- package/dist/ListButtonItem.js.map +1 -1
- package/dist/ListDivider.d.ts +1 -2
- package/dist/ListHeaderItem.d.ts +2 -3
- package/dist/ListHeaderItem.js +4 -2
- package/dist/ListHeaderItem.js.map +1 -1
- package/dist/ListItem.d.ts +1 -2
- package/dist/ListItem.js +3 -1
- package/dist/ListItem.js.map +1 -1
- package/dist/ListLinkItem.d.ts +1 -2
- package/dist/ListLinkItem.js +4 -2
- package/dist/ListLinkItem.js.map +1 -1
- package/dist/ListSpacer.d.ts +1 -2
- package/dist/Popover.d.ts +2 -2
- package/dist/ProgressBar.d.ts +1 -2
- package/dist/ProgressCircle.d.ts +1 -2
- package/dist/Providers.d.ts +1 -1
- package/dist/RootView.d.ts +1 -1
- package/dist/Router.d.ts +1 -2
- package/dist/RouterState.d.ts +1 -1
- package/dist/Row.d.ts +1 -1
- package/dist/StackContext.d.ts +1 -1
- package/dist/StaticCheckbox.d.ts +1 -2
- package/dist/Sublist.d.ts +3 -3
- package/dist/Sublist.js +2 -2
- package/dist/Sublist.js.map +1 -1
- package/dist/SubmitIconInput.d.ts +1 -2
- package/dist/Tabs.d.ts +1 -1
- package/dist/Text.d.ts +8 -8
- package/dist/TextInputWithState.d.ts +1 -1
- package/dist/TextPairing.d.ts +1 -1
- package/dist/Tooltip.d.ts +1 -1
- package/dist/jss.d.ts +2 -2
- package/dist/stateMachineContextFactory.d.ts +1 -1
- package/package.json +10 -3
- package/scripts/embeddings.js +93 -0
- package/scripts/openai_embeddings.js +100 -0
- package/scripts/publish.js +1 -0
- package/scripts/test_embeddings.js +47 -0
- package/src/BaseListItem.tsx +3 -2
- package/src/List.tsx +33 -16
- package/src/ListButtonItem.tsx +3 -3
- package/src/ListHeaderItem.tsx +3 -3
- package/src/ListItem.tsx +4 -2
- package/src/ListLinkItem.tsx +3 -3
- package/src/Sublist.tsx +4 -4
- package/src/docs/mdx.tsx +99 -0
- package/src/docs/pages.ts +112 -0
- package/src/docs/searchIndex.ts +1 -0
- package/src/pages/Badge.mdx +1 -1
- package/src/pages/Button.mdx +4 -4
- package/src/pages/Link.mdx +3 -3
- package/src/pages/List.mdx +107 -21
- package/src/pages/ListHeader.mdx +12 -16
- package/src/pages/_app.tsx +117 -240
- package/src/pages/index.mdx +1 -1
package/dist/Popover.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { JSStyle } from "./jss";
|
|
|
3
3
|
export declare function Popover({ children, close }: {
|
|
4
4
|
children: any;
|
|
5
5
|
close: any;
|
|
6
|
-
}): JSX.Element;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
interface PopoverTriggerProps<Input> {
|
|
8
8
|
PopoverComponent: (props: {
|
|
9
9
|
close: () => void;
|
|
@@ -17,5 +17,5 @@ interface PopoverTriggerProps<Input> {
|
|
|
17
17
|
toggle: (input: Input) => void;
|
|
18
18
|
}) => JSX.Element;
|
|
19
19
|
}
|
|
20
|
-
export declare function PopoverTrigger<Input>({ PopoverComponent, jsStyle, grow, shrink, tag, children, }: PopoverTriggerProps<Input>): JSX.Element;
|
|
20
|
+
export declare function PopoverTrigger<Input>({ PopoverComponent, jsStyle, grow, shrink, tag, children, }: PopoverTriggerProps<Input>): import("react/jsx-runtime").JSX.Element;
|
|
21
21
|
export {};
|
package/dist/ProgressBar.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { Color, Size, JSStyle } from "./jss";
|
|
3
2
|
export declare function ProgressBar({ color, progress, size, jsStyle, }: {
|
|
4
3
|
progress: number;
|
|
5
4
|
color: Color;
|
|
6
5
|
size: Size;
|
|
7
6
|
jsStyle?: JSStyle;
|
|
8
|
-
}): JSX.Element;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
package/dist/ProgressCircle.d.ts
CHANGED
package/dist/Providers.d.ts
CHANGED
package/dist/RootView.d.ts
CHANGED
package/dist/Router.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function Router(): JSX.Element;
|
|
1
|
+
export declare function Router(): import("react/jsx-runtime").JSX.Element;
|
package/dist/RouterState.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ type Route<Props, State extends RouteState> = {
|
|
|
23
23
|
};
|
|
24
24
|
export declare const Provider: ({ children }: {
|
|
25
25
|
children: import("react").ReactNode;
|
|
26
|
-
}) => JSX.Element, useStateMachine: () => {
|
|
26
|
+
}) => import("react/jsx-runtime").JSX.Element, useStateMachine: () => {
|
|
27
27
|
subscribe: import("./Emitter").Subscribe<{
|
|
28
28
|
state: RouteState;
|
|
29
29
|
context: Context;
|
package/dist/Row.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ import { FlexLayoutProps } from "./FlexLayout";
|
|
|
3
3
|
export interface RowProps extends FlexLayoutProps {
|
|
4
4
|
direction?: "row";
|
|
5
5
|
}
|
|
6
|
-
export declare const Row: React.ForwardRefExoticComponent<
|
|
6
|
+
export declare const Row: React.ForwardRefExoticComponent<Omit<RowProps, "ref"> & React.RefAttributes<HTMLElement>>;
|
package/dist/StackContext.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ type Props = {
|
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
isTopOfStack: boolean;
|
|
5
5
|
};
|
|
6
|
-
export declare function StackContextProvider({ children, isTopOfStack }: Props): JSX.Element;
|
|
6
|
+
export declare function StackContextProvider({ children, isTopOfStack }: Props): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export declare function useIsTopOfStack(): boolean;
|
|
8
8
|
export {};
|
package/dist/StaticCheckbox.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { Size } from "./jss";
|
|
3
2
|
import { IconType } from "./IconType";
|
|
4
3
|
type StaticCheckboxProps = {
|
|
@@ -13,5 +12,5 @@ export declare const sizes: {
|
|
|
13
12
|
large: number;
|
|
14
13
|
xlarge: number;
|
|
15
14
|
};
|
|
16
|
-
export declare function StaticCheckbox({ checked, size, icon, }: StaticCheckboxProps): JSX.Element;
|
|
15
|
+
export declare function StaticCheckbox({ checked, size, icon, }: StaticCheckboxProps): import("react/jsx-runtime").JSX.Element;
|
|
17
16
|
export {};
|
package/dist/Sublist.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
2
|
import { JSStyle } from "./jss";
|
|
3
|
-
export declare function Sublist({ children, label, initialState, jsStyle, secondaryAddOn,
|
|
4
|
-
bare?: boolean;
|
|
3
|
+
export declare function Sublist({ children, label, labelBold, initialState, jsStyle, secondaryAddOn, }: {
|
|
5
4
|
children: React.ReactNode;
|
|
6
5
|
label: string;
|
|
6
|
+
labelBold?: boolean;
|
|
7
7
|
initialState?: {
|
|
8
8
|
collapsed: boolean;
|
|
9
9
|
};
|
|
10
10
|
jsStyle?: JSStyle;
|
|
11
11
|
secondaryAddOn?: ReactNode;
|
|
12
|
-
}): JSX.Element;
|
|
12
|
+
}): import("react/jsx-runtime").JSX.Element;
|
package/dist/Sublist.js
CHANGED
|
@@ -4,9 +4,9 @@ import { ListButtonItem } from "./ListButtonItem";
|
|
|
4
4
|
import { Icon } from "./Icon";
|
|
5
5
|
import { Box } from "./Box";
|
|
6
6
|
import { Row } from "./Row";
|
|
7
|
-
export function Sublist({ children, label, initialState = { collapsed: false }, jsStyle, secondaryAddOn,
|
|
7
|
+
export function Sublist({ children, label, labelBold, initialState = { collapsed: false }, jsStyle, secondaryAddOn, }) {
|
|
8
8
|
const [collapsed, setCollapsed] = React.useState(initialState.collapsed);
|
|
9
|
-
return (_jsxs(_Fragment, { children: [_jsx(ListButtonItem, {
|
|
9
|
+
return (_jsxs(_Fragment, { children: [_jsx(ListButtonItem, { headline: label, headlineBold: labelBold, onClick: () => setCollapsed((x) => !x), jsStyle: jsStyle, addOn: _jsxs(Row, { gap: "medium", align: "center", children: [secondaryAddOn, _jsx(Box, { padding: "medium", jsStyle: [
|
|
10
10
|
{
|
|
11
11
|
transition: "transform 0.15s ease-in",
|
|
12
12
|
},
|
package/dist/Sublist.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sublist.js","sourceRoot":"","sources":["../src/Sublist.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Sublist.js","sourceRoot":"","sources":["../src/Sublist.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAI5B,MAAM,UAAU,OAAO,CAAC,EACtB,QAAQ,EACR,KAAK,EACL,SAAS,EACT,YAAY,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,EACnC,OAAO,EACP,cAAc,GAUf;IACC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IACzE,OAAO,CACL,8BACE,KAAC,cAAc,IACb,QAAQ,EAAE,KAAK,EACf,YAAY,EAAE,SAAS,EACvB,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EACtC,OAAO,EAAE,OAAO,EAChB,KAAK,EACH,MAAC,GAAG,IAAC,GAAG,EAAC,QAAQ,EAAC,KAAK,EAAC,QAAQ,aAC7B,cAAc,EACf,KAAC,GAAG,IACF,OAAO,EAAC,QAAQ,EAChB,OAAO,EAAE;gCACP;oCACE,UAAU,EAAE,yBAAyB;iCACtC;gCACD,CAAC,SAAS,IAAI;oCACZ,SAAS,EAAE,gBAAgB;iCAC5B;6BACF,YAED,KAAC,IAAI,IACH,KAAK,EAAC,SAAS,EACf,IAAI,EAAC,QAAQ,EACb,IAAI,EAAC,wBAAwB,GAC7B,GACE,IACF,EAER,aAAa,EAAC,KAAK,EACnB,KAAK,EAAC,WAAW,GACjB,EACD,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,IAC3B,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { BaseInputProps } from "./BaseInput";
|
|
3
2
|
import { IconType } from "./IconType";
|
|
4
3
|
interface SubmitIconInputProps extends BaseInputProps {
|
|
5
4
|
icon: IconType;
|
|
6
5
|
type?: "submit";
|
|
7
6
|
}
|
|
8
|
-
export declare function SubmitIconInput({ icon, ...otherProps }: SubmitIconInputProps): JSX.Element;
|
|
7
|
+
export declare function SubmitIconInput({ icon, ...otherProps }: SubmitIconInputProps): import("react/jsx-runtime").JSX.Element;
|
|
9
8
|
export {};
|
package/dist/Tabs.d.ts
CHANGED
|
@@ -17,4 +17,4 @@ export interface TabsProps extends RowProps {
|
|
|
17
17
|
tabPadding?: Padding;
|
|
18
18
|
tabJSStyle?: JSStyle;
|
|
19
19
|
}
|
|
20
|
-
export declare function Tabs({ tabs, gap, padding, tabPadding, labelSize, jsStyle, tabJSStyle, ["aria-controls"]: ariaControls, ...otherProps }: TabsProps): JSX.Element;
|
|
20
|
+
export declare function Tabs({ tabs, gap, padding, tabPadding, labelSize, jsStyle, tabJSStyle, ["aria-controls"]: ariaControls, ...otherProps }: TabsProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/Text.d.ts
CHANGED
|
@@ -15,11 +15,11 @@ export interface TextProps {
|
|
|
15
15
|
htmlFor?: string;
|
|
16
16
|
}
|
|
17
17
|
export type TextType = "label" | "span" | "p" | "h1" | "h2" | "h3" | "h4" | "li";
|
|
18
|
-
export declare function Text({ children, color, size, align, bold, ellipsis, grow, type: Type, jsStyle, id, htmlFor, }: TextProps): JSX.Element;
|
|
19
|
-
export declare function Label({ size, type, ...rest }: TextProps): JSX.Element;
|
|
20
|
-
export declare function Span({ size, type, ...rest }: TextProps): JSX.Element;
|
|
21
|
-
export declare function P({ size, type, ...rest }: TextProps): JSX.Element;
|
|
22
|
-
export declare function H1({ size, type, ...rest }: TextProps): JSX.Element;
|
|
23
|
-
export declare function H2({ size, type, ...rest }: TextProps): JSX.Element;
|
|
24
|
-
export declare function H3({ size, type, ...rest }: TextProps): JSX.Element;
|
|
25
|
-
export declare function Li({ size, type, ...rest }: TextProps): JSX.Element;
|
|
18
|
+
export declare function Text({ children, color, size, align, bold, ellipsis, grow, type: Type, jsStyle, id, htmlFor, }: TextProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare function Label({ size, type, ...rest }: TextProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function Span({ size, type, ...rest }: TextProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare function P({ size, type, ...rest }: TextProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare function H1({ size, type, ...rest }: TextProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare function H2({ size, type, ...rest }: TextProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export declare function H3({ size, type, ...rest }: TextProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare function Li({ size, type, ...rest }: TextProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,4 +7,4 @@ export interface TextInputWithStateProps extends BaseInputProps {
|
|
|
7
7
|
icon?: IconType;
|
|
8
8
|
onChange?: undefined;
|
|
9
9
|
}
|
|
10
|
-
export declare function TextInputWithState({ valueRef, onValueChange: externalOnChange, icon, ...otherProps }: TextInputWithStateProps): JSX.Element;
|
|
10
|
+
export declare function TextInputWithState({ valueRef, onValueChange: externalOnChange, icon, ...otherProps }: TextInputWithStateProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/TextPairing.d.ts
CHANGED
|
@@ -18,4 +18,4 @@ export interface TextPairingProps {
|
|
|
18
18
|
headlineBold?: boolean;
|
|
19
19
|
jsStyle?: JSStyle;
|
|
20
20
|
}
|
|
21
|
-
export declare function TextPairing({ headline, body, headlineColor, headlineSize, headlineAddOn, bodyColor, bodySize, addOn, addOnPosition, gap, align, grow, shrink, headlineBold, padding, jsStyle, }: TextPairingProps): JSX.Element;
|
|
21
|
+
export declare function TextPairing({ headline, body, headlineColor, headlineSize, headlineAddOn, bodyColor, bodySize, addOn, addOnPosition, gap, align, grow, shrink, headlineBold, padding, jsStyle, }: TextPairingProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/Tooltip.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ interface TooltipProps {
|
|
|
7
7
|
tag?: keyof HTMLElementTagNameMap;
|
|
8
8
|
children: JSX.Element;
|
|
9
9
|
}
|
|
10
|
-
export declare function Tooltip({ content, jsStyle, tag, children }: TooltipProps): JSX.Element;
|
|
10
|
+
export declare function Tooltip({ content, jsStyle, tag, children }: TooltipProps): import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
export {};
|
package/dist/jss.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ export declare function JSStylesProvider({ themes, children, }: {
|
|
|
11
11
|
light: Theme;
|
|
12
12
|
};
|
|
13
13
|
children: JSX.Element;
|
|
14
|
-
}): JSX.Element;
|
|
15
|
-
export declare function JSServerStyles(): JSX.Element;
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function JSServerStyles(): import("react/jsx-runtime").JSX.Element;
|
|
16
16
|
export type Size = "xsmall" | "small" | "medium" | "large" | "xlarge";
|
|
17
17
|
export type Spacing = "none" | Size;
|
|
18
18
|
export type Gap = Spacing;
|
|
@@ -30,7 +30,7 @@ type StateMachineContextType<State, Context> = {
|
|
|
30
30
|
export declare function stateMachineContextFactory<State, Transition, Context>(stateMachineConfig: StateMachineConfig<State, Transition, Context>): {
|
|
31
31
|
Provider: ({ children }: {
|
|
32
32
|
children: ReactNode;
|
|
33
|
-
}) => JSX.Element;
|
|
33
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
34
34
|
useStateMachine: () => StateMachineContextType<State, Context>;
|
|
35
35
|
};
|
|
36
36
|
export {};
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aidos-ui",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "A simple UI framework",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
+
"embeddings": "node ./scripts/embeddings.js",
|
|
8
9
|
"dev": "next dev",
|
|
9
10
|
"publish:patch": "node ./scripts/publish.js --patch",
|
|
10
11
|
"build": "next build",
|
|
@@ -20,19 +21,25 @@
|
|
|
20
21
|
"@mdx-js/loader": "^2.3.0",
|
|
21
22
|
"@mdx-js/react": "^2.3.0",
|
|
22
23
|
"@next/mdx": "^13.4.9",
|
|
24
|
+
"@types/node": "^20.4.4",
|
|
23
25
|
"@types/prismjs": "^1.26.0",
|
|
24
26
|
"@types/react": "^18.0.26",
|
|
25
27
|
"@types/react-dom": "^18.0.10",
|
|
28
|
+
"@xenova/transformers": "^2.4.2",
|
|
26
29
|
"csstype": "^3.1.1",
|
|
30
|
+
"dotenv": "^16.3.1",
|
|
27
31
|
"install": "^0.13.0",
|
|
28
32
|
"next": "latest",
|
|
29
33
|
"npm": "^9.8.0",
|
|
34
|
+
"openai": "^3.3.0",
|
|
30
35
|
"prismjs": "^1.29.0",
|
|
31
36
|
"process": "^0.11.10",
|
|
32
37
|
"react-dom": "latest",
|
|
38
|
+
"remark-mdx": "^2.3.0",
|
|
39
|
+
"remark-parse": "^10.0.2",
|
|
33
40
|
"rimraf": "^5.0.1",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
41
|
+
"typescript": "^4.9.4",
|
|
42
|
+
"unified": "^10.1.2"
|
|
36
43
|
},
|
|
37
44
|
"peerDependencies": {
|
|
38
45
|
"react": "latest"
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { pipeline } from "@xenova/transformers";
|
|
2
|
+
import fs from "fs/promises";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import { unified } from "unified";
|
|
6
|
+
import remarkParse from "remark-parse";
|
|
7
|
+
import remarkMdx from "remark-mdx";
|
|
8
|
+
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = path.dirname(__filename);
|
|
11
|
+
const __rootdir = path.join(__dirname, "..");
|
|
12
|
+
const __pages = path.join(__rootdir, "src", "pages");
|
|
13
|
+
const __target = path.join(__rootdir, "src", "docs");
|
|
14
|
+
|
|
15
|
+
const generateEmbeddings = await pipeline(
|
|
16
|
+
"feature-extraction",
|
|
17
|
+
"Xenova/all-MiniLM-L6-v2"
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const files = await fs.readdir(__pages);
|
|
21
|
+
|
|
22
|
+
const index = [];
|
|
23
|
+
|
|
24
|
+
for (const file of files) {
|
|
25
|
+
if (path.extname(file) !== ".mdx") {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const filepath = path.join(__pages, file);
|
|
30
|
+
const filename = path.parse(file).name;
|
|
31
|
+
const content = await fs.readFile(filepath, "utf-8");
|
|
32
|
+
const sections = parseContent(content);
|
|
33
|
+
|
|
34
|
+
const embeddings = await Promise.all(
|
|
35
|
+
sections.map(async ({ text, heading, headingDepth }) => {
|
|
36
|
+
const embedding = await generateEmbeddings(text, {
|
|
37
|
+
normalize: true,
|
|
38
|
+
pooling: "mean",
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
heading,
|
|
42
|
+
headingDepth,
|
|
43
|
+
filename,
|
|
44
|
+
embedding: Array.from(embedding.data),
|
|
45
|
+
};
|
|
46
|
+
})
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
index.push(...embeddings);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
await fs.writeFile(
|
|
53
|
+
path.join(__target, "searchIndex.ts"),
|
|
54
|
+
`export const index = ${JSON.stringify({ index })}`
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
function parseChildren(children) {
|
|
58
|
+
const result = [];
|
|
59
|
+
|
|
60
|
+
for (const node of children) {
|
|
61
|
+
if (node.type === "text") {
|
|
62
|
+
result.push(node.value);
|
|
63
|
+
} else if (node.type === "inlineCode") {
|
|
64
|
+
result.push(node.value);
|
|
65
|
+
} else if (node.type === "link") {
|
|
66
|
+
result.push(parseChildren(node.children));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return result.join(" ");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function parseContent(content) {
|
|
74
|
+
const ast = unified().use(remarkParse).use(remarkMdx).parse(content);
|
|
75
|
+
const result = [];
|
|
76
|
+
let headingDepth = 1;
|
|
77
|
+
let heading = "";
|
|
78
|
+
|
|
79
|
+
for (const node of ast.children) {
|
|
80
|
+
if (node.type === "paragraph") {
|
|
81
|
+
result.push({
|
|
82
|
+
text: heading + ": " + parseChildren(node.children),
|
|
83
|
+
heading,
|
|
84
|
+
headingDepth,
|
|
85
|
+
});
|
|
86
|
+
} else if (node.type === "heading") {
|
|
87
|
+
headingDepth = node.depth;
|
|
88
|
+
heading = parseChildren(node.children);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import fs from "fs/promises";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
import { unified } from "unified";
|
|
5
|
+
import remarkParse from "remark-parse";
|
|
6
|
+
import remarkMdx from "remark-mdx";
|
|
7
|
+
import { Configuration, OpenAIApi } from "openai";
|
|
8
|
+
import dotenv from "dotenv";
|
|
9
|
+
|
|
10
|
+
dotenv.config();
|
|
11
|
+
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = path.dirname(__filename);
|
|
14
|
+
const __rootdir = path.join(__dirname, "..");
|
|
15
|
+
const __pages = path.join(__rootdir, "src", "pages");
|
|
16
|
+
const __target = path.join(__rootdir, "src", "docs");
|
|
17
|
+
|
|
18
|
+
const configuration = new Configuration({
|
|
19
|
+
organization: "org-Q89d8tyY2MChQVFEbhp27pB3",
|
|
20
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
21
|
+
});
|
|
22
|
+
const openai = new OpenAIApi(configuration);
|
|
23
|
+
|
|
24
|
+
const files = await fs.readdir(__pages);
|
|
25
|
+
|
|
26
|
+
const index = [];
|
|
27
|
+
|
|
28
|
+
for (const file of files) {
|
|
29
|
+
if (path.extname(file) !== ".mdx") {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const filepath = path.join(__pages, file);
|
|
34
|
+
const filename = path.parse(file).name;
|
|
35
|
+
const content = await fs.readFile(filepath, "utf-8");
|
|
36
|
+
const sections = parseContent(content);
|
|
37
|
+
|
|
38
|
+
const embeddings = await Promise.all(
|
|
39
|
+
sections.map(async ({ text, heading, headingDepth }) => {
|
|
40
|
+
const embedding = await openai
|
|
41
|
+
.createEmbedding({
|
|
42
|
+
model: "text-embedding-ada-002",
|
|
43
|
+
input: text,
|
|
44
|
+
})
|
|
45
|
+
.then((response) => response.data[0].embedding);
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
heading,
|
|
49
|
+
headingDepth,
|
|
50
|
+
filename,
|
|
51
|
+
embedding: Array.from(embedding.data),
|
|
52
|
+
};
|
|
53
|
+
})
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
index.push(...embeddings);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
await fs.writeFile(
|
|
60
|
+
path.join(__target, "searchIndex.ts"),
|
|
61
|
+
`export const index = ${JSON.stringify({ index })}`
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
function parseChildren(children) {
|
|
65
|
+
const result = [];
|
|
66
|
+
|
|
67
|
+
for (const node of children) {
|
|
68
|
+
if (node.type === "text") {
|
|
69
|
+
result.push(node.value);
|
|
70
|
+
} else if (node.type === "inlineCode") {
|
|
71
|
+
result.push(node.value);
|
|
72
|
+
} else if (node.type === "link") {
|
|
73
|
+
result.push(parseChildren(node.children));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return result.join(" ");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function parseContent(content) {
|
|
81
|
+
const ast = unified().use(remarkParse).use(remarkMdx).parse(content);
|
|
82
|
+
const result = [];
|
|
83
|
+
let headingDepth = 1;
|
|
84
|
+
let heading = "";
|
|
85
|
+
|
|
86
|
+
for (const node of ast.children) {
|
|
87
|
+
if (node.type === "paragraph") {
|
|
88
|
+
result.push({
|
|
89
|
+
text: heading + ": " + parseChildren(node.children),
|
|
90
|
+
heading,
|
|
91
|
+
headingDepth,
|
|
92
|
+
});
|
|
93
|
+
} else if (node.type === "heading") {
|
|
94
|
+
headingDepth = node.depth;
|
|
95
|
+
heading = parseChildren(node.children);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return result;
|
|
100
|
+
}
|
package/scripts/publish.js
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { pipeline } from "@xenova/transformers";
|
|
2
|
+
import fs from "fs/promises";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = path.dirname(__filename);
|
|
8
|
+
const __rootdir = path.join(__dirname, "..");
|
|
9
|
+
const __public = path.join(__rootdir, "public");
|
|
10
|
+
|
|
11
|
+
const index = await fs
|
|
12
|
+
.readFile(path.join(__public, "index.json"), "utf-8")
|
|
13
|
+
.then((data) => JSON.parse(data).index);
|
|
14
|
+
|
|
15
|
+
const generateEmbeddings = await pipeline(
|
|
16
|
+
"feature-extraction",
|
|
17
|
+
"Xenova/all-MiniLM-L6-v2"
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const query = "how to install";
|
|
21
|
+
|
|
22
|
+
const queryEmbeddings = await generateEmbeddings(query, {
|
|
23
|
+
normalize: true,
|
|
24
|
+
pooling: "mean",
|
|
25
|
+
}).then((embedding) => embedding.data);
|
|
26
|
+
|
|
27
|
+
function dot(xs, ys) {
|
|
28
|
+
let sum = 0;
|
|
29
|
+
|
|
30
|
+
for (let i = 0; i < xs.length; i++) {
|
|
31
|
+
sum += xs[i] * ys[i];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return sum;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const results = index
|
|
38
|
+
.map((element) => {
|
|
39
|
+
return {
|
|
40
|
+
...element,
|
|
41
|
+
dot: dot(queryEmbeddings, element.embedding),
|
|
42
|
+
};
|
|
43
|
+
})
|
|
44
|
+
.sort((a, b) => b.dot - a.dot)
|
|
45
|
+
.slice(0, 5);
|
|
46
|
+
|
|
47
|
+
console.log({ results });
|
package/src/BaseListItem.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import { JSStyle, Size, Position, Spacing, TextColor, cssVar } from "./jss";
|
|
|
6
6
|
import { InteractableColor } from "./Interactable";
|
|
7
7
|
import { TextPairing } from "./TextPairing";
|
|
8
8
|
import { BaseView } from "./BaseView";
|
|
9
|
+
import { useListContext } from "./List";
|
|
9
10
|
|
|
10
11
|
// @ts-ignore
|
|
11
12
|
export interface BaseListItemProps extends RowProps {
|
|
@@ -27,7 +28,6 @@ export interface BaseListItemProps extends RowProps {
|
|
|
27
28
|
role?: undefined;
|
|
28
29
|
gap?: Spacing;
|
|
29
30
|
selected?: boolean;
|
|
30
|
-
bare?: boolean;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export const BaseListItem = React.forwardRef(
|
|
@@ -50,12 +50,13 @@ export const BaseListItem = React.forwardRef(
|
|
|
50
50
|
padding = "medium",
|
|
51
51
|
gap = "medium",
|
|
52
52
|
selected,
|
|
53
|
-
bare,
|
|
54
53
|
headlineBold,
|
|
55
54
|
...otherProps
|
|
56
55
|
}: BaseListItemProps,
|
|
57
56
|
ref?: React.Ref<HTMLElement>
|
|
58
57
|
) => {
|
|
58
|
+
const { bare } = useListContext();
|
|
59
|
+
|
|
59
60
|
const content = (
|
|
60
61
|
<TextPairing
|
|
61
62
|
headlineBold={headlineBold}
|
package/src/List.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useContext, useMemo } from "react";
|
|
2
2
|
import { BaseList, BaseListProps } from "./BaseList";
|
|
3
3
|
import { useNavigation } from "./useNavigation";
|
|
4
4
|
import { cssVar } from "./jss";
|
|
@@ -9,33 +9,50 @@ interface ListProps extends BaseListProps {
|
|
|
9
9
|
autofocus?: boolean;
|
|
10
10
|
role?: undefined;
|
|
11
11
|
navigation?: boolean;
|
|
12
|
+
carded?: boolean;
|
|
12
13
|
}
|
|
13
14
|
|
|
15
|
+
const ListContext = React.createContext({ bare: false });
|
|
16
|
+
|
|
14
17
|
export function List({
|
|
15
18
|
ariaLabel,
|
|
16
19
|
jsStyle,
|
|
17
20
|
autofocus = false,
|
|
18
21
|
navigation = true,
|
|
19
22
|
bare,
|
|
23
|
+
carded = true,
|
|
20
24
|
...otherProps
|
|
21
25
|
}: ListProps) {
|
|
22
26
|
const rootRef = useNavigation({ autofocus, enabled: navigation });
|
|
27
|
+
const contextValue = useMemo(() => ({ bare }), [bare]);
|
|
23
28
|
|
|
24
29
|
return (
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
<ListContext.Provider value={contextValue}>
|
|
31
|
+
<BaseList
|
|
32
|
+
role="grid"
|
|
33
|
+
aria-label={ariaLabel}
|
|
34
|
+
ref={rootRef}
|
|
35
|
+
jsStyle={[
|
|
36
|
+
{ overflow: "hidden" },
|
|
37
|
+
!bare && {
|
|
38
|
+
backgroundColor: cssVar("--overlay-background"),
|
|
39
|
+
},
|
|
40
|
+
!bare &&
|
|
41
|
+
!carded && {
|
|
42
|
+
borderBottom: `1px solid ${cssVar("--divider")}`,
|
|
43
|
+
borderTop: `1px solid ${cssVar("--divider")}`,
|
|
44
|
+
},
|
|
45
|
+
!bare &&
|
|
46
|
+
carded && {
|
|
47
|
+
border: `1px solid ${cssVar("--divider")}`,
|
|
48
|
+
borderRadius: cssVar("--border-radius-l"),
|
|
49
|
+
},
|
|
50
|
+
jsStyle,
|
|
51
|
+
]}
|
|
52
|
+
{...otherProps}
|
|
53
|
+
/>
|
|
54
|
+
</ListContext.Provider>
|
|
40
55
|
);
|
|
41
56
|
}
|
|
57
|
+
|
|
58
|
+
export const useListContext = () => useContext(ListContext);
|