b44ui 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1696 -1
- package/dist/index.js +28 -4
- package/package.json +1 -1
- package/readme.md +33 -28
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Children, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { Children, createElement, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { Marked } from 'marked';
|
|
4
4
|
import { markedHighlight } from 'marked-highlight';
|
|
5
5
|
import hljs from 'highlight.js';
|
|
@@ -35,7 +35,24 @@ const dStyle = ({ gap, p, wd, ht, style }) => {
|
|
|
35
35
|
return undefined;
|
|
36
36
|
return { ...(g !== undefined && { gap: g }), ...(pd !== undefined && { padding: pd }), ...(wd !== undefined && { width: `${wd * 100}%` }), ...(ht !== undefined && { height: `${ht * 100}%` }), ...style };
|
|
37
37
|
};
|
|
38
|
-
|
|
38
|
+
const boxStyle = ({ ratio, ...props }) => dStyle({ ...props, style: { ...(ratio ? { width: `${ratio * 100}%` } : {}), ...props.style } });
|
|
39
|
+
const headingTag = (tag) => ({ children, cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, row, col, ratio, align, ...rest }) => createElement(tag, {
|
|
40
|
+
...rest,
|
|
41
|
+
className: CN(layoutCn({ row, col, align }), rcn({ cn, cnIgnoreWrongUsage, className: rest.className }), growCn(grow)),
|
|
42
|
+
style: boxStyle({ gap, p, wd, ht, ratio, style: rest.style }),
|
|
43
|
+
}, children);
|
|
44
|
+
const textTag = (tag) => ({ children, cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, row, col, ratio, align, ...rest }) => createElement(tag, {
|
|
45
|
+
...rest,
|
|
46
|
+
className: CN(layoutCn({ row, col, align }), rcn({ cn, cnIgnoreWrongUsage, className: rest.className }), growCn(grow)),
|
|
47
|
+
style: boxStyle({ gap, p, wd, ht, ratio, style: rest.style }),
|
|
48
|
+
}, children);
|
|
49
|
+
export const D = ({ children, cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, row, col, ratio, align, ...rest }) => _jsx("div", { ...rest, className: CN(layoutCn({ row, col, align }), rcn({ cn, cnIgnoreWrongUsage, className: rest.className }), growCn(grow)), style: boxStyle({ gap, p, wd, ht, ratio, style: rest.style }), children: children });
|
|
50
|
+
export const H1 = headingTag('h1');
|
|
51
|
+
export const H2 = headingTag('h2');
|
|
52
|
+
export const H3 = headingTag('h3');
|
|
53
|
+
export const H4 = headingTag('h4');
|
|
54
|
+
export const B = textTag('b');
|
|
55
|
+
export const I = textTag('i');
|
|
39
56
|
export const App = ({ children, center = true, width, htScreen, cn, cnIgnoreWrongUsage, gap, p, wd, ht, ...rest }) => {
|
|
40
57
|
const inner = Children.map(children, c => typeof c == 'string' ? _jsx(Md, { children: c.trim() }) : c);
|
|
41
58
|
const wrap = center || width !== undefined || htScreen;
|
|
@@ -112,9 +129,16 @@ export const Textarea = ({ cn, cnIgnoreWrongUsage, ref, grow, gap, p, wd, ht, ..
|
|
|
112
129
|
const c = rcn({ cn, cnIgnoreWrongUsage, className: rest.className });
|
|
113
130
|
return _jsx("textarea", { ref: ref, ...rest, className: CN('rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm outline-none w-full', growCn(grow), c), style: dStyle({ gap, p, wd, ht, style: rest.style }) });
|
|
114
131
|
};
|
|
115
|
-
export const Select = ({ cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, ...rest }) => {
|
|
132
|
+
export const Select = ({ state, options, cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, onChange, children, ...rest }) => {
|
|
116
133
|
const c = rcn({ cn, cnIgnoreWrongUsage, className: rest.className });
|
|
117
|
-
|
|
134
|
+
const entries = options ? Object.entries(options) : undefined;
|
|
135
|
+
return _jsx("select", { ...rest, className: CN('rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm outline-none cursor-pointer', growCn(grow), c), style: dStyle({ gap, p, wd, ht, style: rest.style }), value: state ? state[0] : rest.value, defaultValue: rest.defaultValue, onChange: e => {
|
|
136
|
+
const value = entries?.find(([, value]) => String(value) === e.target.value)?.[1] ?? e.target.value;
|
|
137
|
+
state?.[1](value);
|
|
138
|
+
onChange?.(e);
|
|
139
|
+
}, children: entries
|
|
140
|
+
? entries.map(([label, value]) => _jsx("option", { value: value, children: label }, `${label}:${value}`))
|
|
141
|
+
: children });
|
|
118
142
|
};
|
|
119
143
|
export const Grid = ({ children, cols, gap, ...rest }) => _jsx(D, { ...rest, cn: CN('grid ui-grid', rcn(rest)), gap: gap ?? 4, style: { ['--cols']: cols ?? Children.count(children), ...rest.style }, children: children });
|
|
120
144
|
export const Scroll = ({ grow = true, ...rest }) => _jsx(D, { ...rest, cn: CN('min-h-0 overflow-y-auto', rcn(rest)), grow: grow });
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -24,36 +24,41 @@ export default defineConfig({
|
|
|
24
24
|
})
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
shared `d` props on `d`-based components:
|
|
28
|
+
|
|
29
|
+
- layout: `grow`, `gap`, `p`, `wd`, `ht`, `row`, `col`, `align`
|
|
30
|
+
- styling: `cn`
|
|
31
|
+
- dom: native rest props like `style`, `onClick`, `data-*`
|
|
32
|
+
|
|
33
|
+
`ratio` is only on `D`.
|
|
34
|
+
|
|
35
|
+
| Component | Extra Props | Description |
|
|
36
|
+
|-----------|-------------|-------------|
|
|
37
|
+
| `App` | `center`, `width`, `htScreen` | Root layout, dark background, wraps strings in `Md` |
|
|
38
|
+
| `Centered` | `width` | Centered max-width container |
|
|
39
|
+
| `D` | `ratio` | Plain div, also handles row/col layout |
|
|
40
|
+
| `H1` `H2` `H3` `H4` `B` `I` | none | Semantic html tags with shared `D` props |
|
|
41
|
+
| `Scroll` | `grow=true` | Vertical scroll container for growable layouts |
|
|
33
42
|
| `Code` | `highlight` | Code block |
|
|
34
|
-
| `Grid` | `cols
|
|
35
|
-
| `Card` |
|
|
36
|
-
| `Block` | `label`, `
|
|
37
|
-
| `BlockSm` | `dashed
|
|
38
|
-
| `TabList` |
|
|
39
|
-
| `Tab` | `title`, `active`, `click
|
|
40
|
-
| `Hr` | `vertical`, `color
|
|
41
|
-
| `Progress` | `value`, `color`, `dot
|
|
43
|
+
| `Grid` | `cols` | CSS grid, defaults to one column per child |
|
|
44
|
+
| `Card` | none | Bordered zinc-900 card, column by default |
|
|
45
|
+
| `Block` | `label`, `dashed` | Padded container with optional label |
|
|
46
|
+
| `BlockSm` | `dashed` | Smaller padded container |
|
|
47
|
+
| `TabList` | none | Simple tab row wrapper |
|
|
48
|
+
| `Tab` | `title`, `active`, `click` | String-first tab primitive |
|
|
49
|
+
| `Hr` | `vertical`, `color` | Horizontal or vertical divider |
|
|
50
|
+
| `Progress` | `value`, `color`, `dot` | Progress bar or dot |
|
|
42
51
|
| `Dropzone` | `onFiles`, `multiple`, `accept` | Hidden file input wrapper for click/drop |
|
|
43
|
-
| `Btn` | `click`, `color`, `ghost`, `
|
|
44
|
-
| `A` | `href`, `click
|
|
45
|
-
| `Chip` | `click
|
|
46
|
-
| `Tint` | `color
|
|
47
|
-
| `Muted` |
|
|
48
|
-
| `Input` | `state`,
|
|
49
|
-
| `Textarea` |
|
|
50
|
-
| `Select` |
|
|
51
|
-
| `Modal` | `open
|
|
52
|
-
| `Popover` | `text`, `color
|
|
52
|
+
| `Btn` | `click`, `color`, `ghost`, `sm` | Button with optional layout props from `D` |
|
|
53
|
+
| `A` | `href`, `click` | Link-styled anchor, works with `onClick` or `href` |
|
|
54
|
+
| `Chip` | `click` | Small inline badge, clickable if `click` provided |
|
|
55
|
+
| `Tint` | `color` | Tinted background block |
|
|
56
|
+
| `Muted` | none | Small muted text |
|
|
57
|
+
| `Input` | `state`, native input attrs | Styled text input, `state={[value, setValue]}` supported |
|
|
58
|
+
| `Textarea` | native textarea attrs | Styled textarea |
|
|
59
|
+
| `Select` | native select attrs | Styled select |
|
|
60
|
+
| `Modal` | `open` | Fixed overlay modal |
|
|
61
|
+
| `Popover` | `text`, `color` | Hover popover |
|
|
53
62
|
| `Md` | `className` | Markdown renderer with syntax highlighting |
|
|
54
63
|
|
|
55
64
|
`Color` = `red | blue | orange | purple | yellow | green`
|
|
56
|
-
|
|
57
|
-
All rendered components forward native rest props to their underlying element, so `style`, `onClick`, `data-*`, and native element attributes work directly.
|
|
58
|
-
|
|
59
|
-
All components accept `cn` for additional Tailwind classes (merged via `tailwind-merge`).
|