@elaraai/east-ui-components 0.0.1-beta.4 → 0.0.1-beta.6
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 -1
- package/dist/component.d.ts.map +1 -1
- package/dist/index.cjs +163 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +165 -3
- package/dist/index.js.map +1 -1
- package/dist/typography/code/index.d.ts +22 -0
- package/dist/typography/code/index.d.ts.map +1 -0
- package/dist/typography/code-block/index.d.ts +35 -0
- package/dist/typography/code-block/index.d.ts.map +1 -0
- package/dist/typography/heading/index.d.ts +22 -0
- package/dist/typography/heading/index.d.ts.map +1 -0
- package/dist/typography/highlight/index.d.ts +27 -0
- package/dist/typography/highlight/index.d.ts.map +1 -0
- package/dist/typography/index.d.ts +7 -0
- package/dist/typography/index.d.ts.map +1 -1
- package/dist/typography/link/index.d.ts +22 -0
- package/dist/typography/link/index.d.ts.map +1 -0
- package/dist/typography/list/index.d.ts +22 -0
- package/dist/typography/list/index.d.ts.map +1 -0
- package/dist/typography/mark/index.d.ts +22 -0
- package/dist/typography/mark/index.d.ts.map +1 -0
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -5,9 +5,10 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import React__default, { memo as memo$2, useMemo, useId as useId$1, isValidElement, forwardRef, useContext, createContext, useState, useCallback, useRef, useImperativeHandle, useEffect, PureComponent, useLayoutEffect, cloneElement, createElement as createElement$1, Children, Component, useReducer } from "react";
|
|
7
7
|
import { match, equalFor, printFor, encodeBeast2For, IRType, BlobType } from "@elaraai/east";
|
|
8
|
-
import { Text as Text$1, Button as Button$1, IconButton as IconButton$1, Sparkline, Chart, Box as Box$1, Stack as Stack$1, Separator as Separator$1, Grid as Grid$1, Splitter as Splitter$1, Accordion as Accordion$1, Carousel as Carousel$1, Tabs as Tabs$1, DataList as DataList$1, Table as Table$1, Icon as Icon$1, TreeView as TreeView$1, Gantt, Badge as Badge$1, Tag as Tag$1, Avatar as Avatar$1, Stat as Stat$1, Input as Input$1, Checkbox as Checkbox$1, Switch as Switch$1, Select as Select$1, Slider as Slider$1, Field as Field$1, Textarea as Textarea$1, TagsInput as TagsInput$1, FileUpload as FileUpload$1, Alert as Alert$1, Progress as Progress$1, Card as Card$1, Tooltip as Tooltip$2, Menu as Menu$1, Popover as Popover$1, HoverCard as HoverCard$1, Dialog as Dialog$1, Drawer as Drawer$1, ActionBar as ActionBar$1, ToggleTip, UIComponentType, state_write, state_read } from "@elaraai/east-ui";
|
|
8
|
+
import { Text as Text$1, Code as Code$1, Heading as Heading$1, Link as Link$1, Highlight as Highlight$1, Mark as Mark$1, List as List$1, CodeBlock as CodeBlock$1, Button as Button$1, IconButton as IconButton$1, Sparkline, Chart, Box as Box$1, Stack as Stack$1, Separator as Separator$1, Grid as Grid$1, Splitter as Splitter$1, Accordion as Accordion$1, Carousel as Carousel$1, Tabs as Tabs$1, DataList as DataList$1, Table as Table$1, Icon as Icon$1, TreeView as TreeView$1, Gantt, Badge as Badge$1, Tag as Tag$1, Avatar as Avatar$1, Stat as Stat$1, Input as Input$1, Checkbox as Checkbox$1, Switch as Switch$1, Select as Select$1, Slider as Slider$1, Field as Field$1, Textarea as Textarea$1, TagsInput as TagsInput$1, FileUpload as FileUpload$1, Alert as Alert$1, Progress as Progress$1, Card as Card$1, Tooltip as Tooltip$2, Menu as Menu$1, Popover as Popover$1, HoverCard as HoverCard$1, Dialog as Dialog$1, Drawer as Drawer$1, ActionBar as ActionBar$1, ToggleTip, UIComponentType, state_write, state_read } from "@elaraai/east-ui";
|
|
9
9
|
import { State, state_read as state_read2, state_write as state_write2 } from "@elaraai/east-ui";
|
|
10
|
-
import { Text as Text$2,
|
|
10
|
+
import { Text as Text$2, Code, Heading, Link, Highlight, Mark, List, CodeBlock, createShikiAdapter, Box, IconButton, Button, useChakraContext, useLocaleContext, defineStyle, Stack, Flex, ColorSwatch, HStack, Span, Separator, Show, AbsoluteCenter, Grid, GridItem, Splitter, Accordion, Carousel, Tabs, DataList, Table, Skeleton, createTreeCollection, TreeView, useToken, Badge, Tag, Avatar, Stat, Input, Checkbox, Switch, createListCollection, Select, Portal, Slider, Field, Fieldset, Textarea, TagsInput, FileUpload, Alert, Progress, Card, Tooltip as Tooltip$1, Menu, Popover, HoverCard, Dialog, CloseButton, Drawer, ActionBar } from "@chakra-ui/react";
|
|
11
|
+
import { createHighlighter } from "shiki";
|
|
11
12
|
import { createPortal, flushSync } from "react-dom";
|
|
12
13
|
const getSomeorUndefined = (opt) => {
|
|
13
14
|
return match(opt, {
|
|
@@ -37,6 +38,160 @@ const EastChakraText = memo$2(function EastChakraText2({ value }) {
|
|
|
37
38
|
const props = useMemo(() => toChakraText(value), [value]);
|
|
38
39
|
return /* @__PURE__ */ jsx(Text$2, { ...props, children: value.value });
|
|
39
40
|
}, (prev, next) => textEqual(prev.value, next.value));
|
|
41
|
+
const codeEqual = equalFor(Code$1.Types.Code);
|
|
42
|
+
function toChakraCode(value) {
|
|
43
|
+
var _a, _b;
|
|
44
|
+
return {
|
|
45
|
+
variant: (_a = getSomeorUndefined(value.variant)) == null ? void 0 : _a.type,
|
|
46
|
+
colorPalette: getSomeorUndefined(value.colorPalette),
|
|
47
|
+
size: (_b = getSomeorUndefined(value.size)) == null ? void 0 : _b.type
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const EastChakraCode = memo$2(function EastChakraCode2({ value }) {
|
|
51
|
+
const props = useMemo(() => toChakraCode(value), [value]);
|
|
52
|
+
return /* @__PURE__ */ jsx(Code, { ...props, children: value.value });
|
|
53
|
+
}, (prev, next) => codeEqual(prev.value, next.value));
|
|
54
|
+
const headingEqual = equalFor(Heading$1.Types.Heading);
|
|
55
|
+
function toChakraHeading(value) {
|
|
56
|
+
var _a, _b, _c;
|
|
57
|
+
return {
|
|
58
|
+
size: (_a = getSomeorUndefined(value.size)) == null ? void 0 : _a.type,
|
|
59
|
+
as: (_b = getSomeorUndefined(value.as)) == null ? void 0 : _b.type,
|
|
60
|
+
color: getSomeorUndefined(value.color),
|
|
61
|
+
textAlign: (_c = getSomeorUndefined(value.textAlign)) == null ? void 0 : _c.type
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const EastChakraHeading = memo$2(function EastChakraHeading2({ value }) {
|
|
65
|
+
const props = useMemo(() => toChakraHeading(value), [value]);
|
|
66
|
+
return /* @__PURE__ */ jsx(Heading, { ...props, children: value.value });
|
|
67
|
+
}, (prev, next) => headingEqual(prev.value, next.value));
|
|
68
|
+
const linkEqual = equalFor(Link$1.Types.Link);
|
|
69
|
+
function toChakraLink(value) {
|
|
70
|
+
var _a;
|
|
71
|
+
const external2 = getSomeorUndefined(value.external);
|
|
72
|
+
return {
|
|
73
|
+
href: value.href,
|
|
74
|
+
variant: (_a = getSomeorUndefined(value.variant)) == null ? void 0 : _a.type,
|
|
75
|
+
colorPalette: getSomeorUndefined(value.colorPalette),
|
|
76
|
+
...external2 ? { target: "_blank", rel: "noopener noreferrer" } : {}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const EastChakraLink = memo$2(function EastChakraLink2({ value }) {
|
|
80
|
+
const props = useMemo(() => toChakraLink(value), [value]);
|
|
81
|
+
return /* @__PURE__ */ jsx(Link, { ...props, children: value.value });
|
|
82
|
+
}, (prev, next) => linkEqual(prev.value, next.value));
|
|
83
|
+
const highlightEqual = equalFor(Highlight$1.Types.Highlight);
|
|
84
|
+
function toChakraHighlight(value) {
|
|
85
|
+
const color2 = getSomeorUndefined(value.color);
|
|
86
|
+
return {
|
|
87
|
+
query: value.query,
|
|
88
|
+
styles: color2 ? { bg: color2 } : void 0
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const EastChakraHighlight = memo$2(function EastChakraHighlight2({ value }) {
|
|
92
|
+
const props = useMemo(() => toChakraHighlight(value), [value]);
|
|
93
|
+
return /* @__PURE__ */ jsx(Highlight, { query: props.query, styles: props.styles, children: value.value });
|
|
94
|
+
}, (prev, next) => highlightEqual(prev.value, next.value));
|
|
95
|
+
const markEqual = equalFor(Mark$1.Types.Mark);
|
|
96
|
+
function toChakraMark(value) {
|
|
97
|
+
var _a;
|
|
98
|
+
return {
|
|
99
|
+
variant: (_a = getSomeorUndefined(value.variant)) == null ? void 0 : _a.type,
|
|
100
|
+
colorPalette: getSomeorUndefined(value.colorPalette)
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const EastChakraMark = memo$2(function EastChakraMark2({ value }) {
|
|
104
|
+
const props = useMemo(() => toChakraMark(value), [value]);
|
|
105
|
+
return /* @__PURE__ */ jsx(Mark, { ...props, children: value.value });
|
|
106
|
+
}, (prev, next) => markEqual(prev.value, next.value));
|
|
107
|
+
const listEqual = equalFor(List$1.Types.List);
|
|
108
|
+
function toChakraList(value) {
|
|
109
|
+
var _a;
|
|
110
|
+
const variant = (_a = getSomeorUndefined(value.variant)) == null ? void 0 : _a.type;
|
|
111
|
+
return {
|
|
112
|
+
as: variant === "ordered" ? "ol" : "ul",
|
|
113
|
+
gap: getSomeorUndefined(value.gap),
|
|
114
|
+
colorPalette: getSomeorUndefined(value.colorPalette),
|
|
115
|
+
ps: "5"
|
|
116
|
+
// Padding-start for bullet/number markers
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const EastChakraList = memo$2(function EastChakraList2({ value }) {
|
|
120
|
+
const props = useMemo(() => toChakraList(value), [value]);
|
|
121
|
+
return /* @__PURE__ */ jsx(List.Root, { ...props, children: value.items.map((item, index) => /* @__PURE__ */ jsx(List.Item, { children: item }, index)) });
|
|
122
|
+
}, (prev, next) => listEqual(prev.value, next.value));
|
|
123
|
+
const codeBlockEqual = equalFor(CodeBlock$1.Types.CodeBlock);
|
|
124
|
+
let highlighterPromise = null;
|
|
125
|
+
function getHighlighter() {
|
|
126
|
+
if (!highlighterPromise) {
|
|
127
|
+
highlighterPromise = createHighlighter({
|
|
128
|
+
langs: [
|
|
129
|
+
"typescript",
|
|
130
|
+
"javascript",
|
|
131
|
+
"json",
|
|
132
|
+
"html",
|
|
133
|
+
"css",
|
|
134
|
+
"python",
|
|
135
|
+
"rust",
|
|
136
|
+
"go",
|
|
137
|
+
"sql",
|
|
138
|
+
"bash",
|
|
139
|
+
"markdown",
|
|
140
|
+
"yaml",
|
|
141
|
+
"xml"
|
|
142
|
+
],
|
|
143
|
+
themes: ["github-dark"]
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
return highlighterPromise;
|
|
147
|
+
}
|
|
148
|
+
const shikiAdapter = createShikiAdapter({
|
|
149
|
+
load: getHighlighter,
|
|
150
|
+
theme: "github-dark"
|
|
151
|
+
});
|
|
152
|
+
function toCodeBlockProps(value) {
|
|
153
|
+
const languageVariant = getSomeorUndefined(value.language);
|
|
154
|
+
const language = languageVariant == null ? void 0 : languageVariant.type;
|
|
155
|
+
const highlightLinesBigint = getSomeorUndefined(value.highlightLines);
|
|
156
|
+
const highlightLines = highlightLinesBigint == null ? void 0 : highlightLinesBigint.map((n2) => Number(n2));
|
|
157
|
+
return {
|
|
158
|
+
language,
|
|
159
|
+
showLineNumbers: getSomeorUndefined(value.showLineNumbers),
|
|
160
|
+
highlightLines,
|
|
161
|
+
maxHeight: getSomeorUndefined(value.maxHeight),
|
|
162
|
+
showCopyButton: getSomeorUndefined(value.showCopyButton),
|
|
163
|
+
title: getSomeorUndefined(value.title)
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
const EastChakraCodeBlock = memo$2(function EastChakraCodeBlock2({ value }) {
|
|
167
|
+
const props = useMemo(() => toCodeBlockProps(value), [value]);
|
|
168
|
+
const meta = useMemo(() => {
|
|
169
|
+
const result = {};
|
|
170
|
+
if (props.showLineNumbers !== void 0) {
|
|
171
|
+
result.showLineNumbers = props.showLineNumbers;
|
|
172
|
+
}
|
|
173
|
+
if (props.highlightLines !== void 0) {
|
|
174
|
+
result.highlightLines = props.highlightLines;
|
|
175
|
+
}
|
|
176
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
177
|
+
}, [props.showLineNumbers, props.highlightLines]);
|
|
178
|
+
const showHeader = props.title || props.showCopyButton;
|
|
179
|
+
return /* @__PURE__ */ jsx(CodeBlock.AdapterProvider, { value: shikiAdapter, children: /* @__PURE__ */ jsx(Box, { maxHeight: props.maxHeight, overflow: "auto", children: /* @__PURE__ */ jsxs(
|
|
180
|
+
CodeBlock.Root,
|
|
181
|
+
{
|
|
182
|
+
code: value.code,
|
|
183
|
+
language: props.language,
|
|
184
|
+
meta,
|
|
185
|
+
children: [
|
|
186
|
+
showHeader && /* @__PURE__ */ jsxs(CodeBlock.Header, { children: [
|
|
187
|
+
props.title && /* @__PURE__ */ jsx(CodeBlock.Title, { children: props.title }),
|
|
188
|
+
props.showCopyButton && /* @__PURE__ */ jsx(CodeBlock.CopyTrigger, { asChild: true, children: /* @__PURE__ */ jsx(IconButton, { variant: "ghost", size: "2xs", children: /* @__PURE__ */ jsx(CodeBlock.CopyIndicator, {}) }) })
|
|
189
|
+
] }),
|
|
190
|
+
/* @__PURE__ */ jsx(CodeBlock.Content, { children: /* @__PURE__ */ jsx(CodeBlock.Code, { children: /* @__PURE__ */ jsx(CodeBlock.CodeText, {}) }) })
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
) }) });
|
|
194
|
+
}, (prev, next) => codeBlockEqual(prev.value, next.value));
|
|
40
195
|
const buttonEqual = equalFor(Button$1.Types.Button);
|
|
41
196
|
function toChakraButton(value) {
|
|
42
197
|
var _a, _b, _c;
|
|
@@ -55173,7 +55328,7 @@ const EastChakraHoverCard = memo$2(function EastChakraHoverCard2({ value }) {
|
|
|
55173
55328
|
closeDelay,
|
|
55174
55329
|
children: [
|
|
55175
55330
|
/* @__PURE__ */ jsx(HoverCard.Trigger, { asChild: true, children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(EastChakraComponent, { value: value.trigger }) }) }),
|
|
55176
|
-
/* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(HoverCard.Positioner, { children: /* @__PURE__ */ jsxs(HoverCard.Content, { children: [
|
|
55331
|
+
/* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(HoverCard.Positioner, { children: /* @__PURE__ */ jsxs(HoverCard.Content, { width: "fit-content", maxWidth: "unset", children: [
|
|
55177
55332
|
hasArrow && /* @__PURE__ */ jsx(HoverCard.Arrow, {}),
|
|
55178
55333
|
value.body.map((child, index) => /* @__PURE__ */ jsx(EastChakraComponent, { value: child }, index))
|
|
55179
55334
|
] }) }) })
|
|
@@ -55311,6 +55466,13 @@ const EastChakraComponent = memo$2(function EastChakraComponent2({ value }) {
|
|
|
55311
55466
|
return match(value, {
|
|
55312
55467
|
// Typography
|
|
55313
55468
|
Text: (v2) => /* @__PURE__ */ jsx(EastChakraText, { value: v2 }),
|
|
55469
|
+
Code: (v2) => /* @__PURE__ */ jsx(EastChakraCode, { value: v2 }),
|
|
55470
|
+
Heading: (v2) => /* @__PURE__ */ jsx(EastChakraHeading, { value: v2 }),
|
|
55471
|
+
Link: (v2) => /* @__PURE__ */ jsx(EastChakraLink, { value: v2 }),
|
|
55472
|
+
Highlight: (v2) => /* @__PURE__ */ jsx(EastChakraHighlight, { value: v2 }),
|
|
55473
|
+
Mark: (v2) => /* @__PURE__ */ jsx(EastChakraMark, { value: v2 }),
|
|
55474
|
+
List: (v2) => /* @__PURE__ */ jsx(EastChakraList, { value: v2 }),
|
|
55475
|
+
CodeBlock: (v2) => /* @__PURE__ */ jsx(EastChakraCodeBlock, { value: v2 }),
|
|
55314
55476
|
// Buttons
|
|
55315
55477
|
Button: (v2) => /* @__PURE__ */ jsx(EastChakraButton, { value: v2 }),
|
|
55316
55478
|
IconButton: (v2) => /* @__PURE__ */ jsx(EastChakraIconButton, { value: v2 }),
|