b44ui 0.2.2 → 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/index.d.ts CHANGED
@@ -56,7 +56,7 @@ export declare const Muted: ({ children, cn, cnIgnoreWrongUsage, grow, gap, p, w
56
56
  export declare const A: ({ children, cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, click, href, onClick, onKeyDown, role, tabIndex, ...rest }: DProps & {
57
57
  click?: () => void;
58
58
  } & React.AnchorHTMLAttributes<HTMLAnchorElement>) => import("react/jsx-runtime").JSX.Element;
59
- export declare const Btn: ({ children, click, color, ghost, sm, cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, onClick, ...rest }: DProps & {
59
+ export declare const Btn: ({ children, click, color, ghost, sm, cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, row, col, align, onClick, ...rest }: DProps & {
60
60
  click?: () => void;
61
61
  color?: Color;
62
62
  ghost?: boolean;
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ const colorMap = {
24
24
  const tintCn = (c) => tintMap[c];
25
25
  const colorCn = (c) => colorMap[c];
26
26
  const growCn = (grow) => grow && 'flex-1 min-h-0';
27
+ const layoutCn = ({ row, col, align }) => CN(row && 'flex items-center justify-center', col && 'flex flex-col', row && align === 'mid' && 'justify-between', row && align === 'start' && 'justify-start', row && align === 'end' && 'justify-end', col && align === 'start' && 'items-start', col && (align === 'center' || align === 'mid') && 'items-center', col && align === 'end' && 'items-end');
27
28
  export const CN = (...inputs) => twMerge(clsx(inputs));
28
29
  const warnCn = (cn) => typeof cn === 'string' && cn.length > 24 && console.warn(`long cn detected (${cn.length} chars). please avoid using cn. you SHOULD use b44ui builtins instead. you SHOULD NOT use cn to add unnecessary visual enhancements. you MUST NOT have long cns. if you choose to ignore these requirements (ie. because you cannot achieve this otherwise) you MUST instead use <... cnIgnoreWrongUsage="styles..">\n cn="${cn}"`);
29
30
  const rcn = ({ cn, cnIgnoreWrongUsage, className }) => { warnCn(cn); return CN(className, cn ?? cnIgnoreWrongUsage); };
@@ -34,7 +35,7 @@ const dStyle = ({ gap, p, wd, ht, style }) => {
34
35
  return undefined;
35
36
  return { ...(g !== undefined && { gap: g }), ...(pd !== undefined && { padding: pd }), ...(wd !== undefined && { width: `${wd * 100}%` }), ...(ht !== undefined && { height: `${ht * 100}%` }), ...style };
36
37
  };
37
- export const D = ({ children, cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, row, col, ratio, align, ...rest }) => _jsx("div", { ...rest, className: CN(row && 'flex items-center justify-center', col && 'flex flex-col', row && align === 'mid' && 'justify-between', row && align === 'start' && 'justify-start', row && align === 'end' && 'justify-end', col && align === 'start' && 'items-start', col && (align === 'center' || align === 'mid') && 'items-center', col && align === 'end' && 'items-end', rcn({ cn, cnIgnoreWrongUsage, className: rest.className }), growCn(grow)), style: dStyle({ gap, p, wd, ht, style: { ...(ratio ? { width: `${ratio * 100}%` } : {}), ...rest.style } }), children: children });
38
+ 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: dStyle({ gap, p, wd, ht, style: { ...(ratio ? { width: `${ratio * 100}%` } : {}), ...rest.style } }), children: children });
38
39
  export const App = ({ children, center = true, width, htScreen, cn, cnIgnoreWrongUsage, gap, p, wd, ht, ...rest }) => {
39
40
  const inner = Children.map(children, c => typeof c == 'string' ? _jsx(Md, { children: c.trim() }) : c);
40
41
  const wrap = center || width !== undefined || htScreen;
@@ -59,7 +60,7 @@ export const Chip = ({ children, click, cn, cnIgnoreWrongUsage, grow, gap, p, wd
59
60
  onClick?.(e);
60
61
  }, children: children });
61
62
  };
62
- export const Card = ({ row, col, gap, p, ...rest }) => _jsx(D, { ...rest, cn: CN('rounded border border-zinc-700 bg-zinc-900 flex min-h-0', row ? 'flex-row' : 'flex-col', col && 'flex-col', rcn(rest)), gap: gap ?? 4, p: p ?? 4 });
63
+ export const Card = ({ row, col, gap, p, ...rest }) => _jsx(D, { ...rest, row: row, col: col ?? !row, cn: CN('rounded border border-zinc-700 bg-zinc-900 min-h-0', rcn(rest)), gap: gap ?? 4, p: p ?? 4 });
63
64
  export const Popover = ({ children, text, color, cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, onMouseEnter, onMouseLeave, ...rest }) => {
64
65
  const c = rcn({ cn, cnIgnoreWrongUsage });
65
66
  const [open, setOpen] = useState(false);
@@ -87,9 +88,9 @@ export const A = ({ children, cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, clic
87
88
  onKeyDown?.(e);
88
89
  }, children: children });
89
90
  };
90
- export const Btn = ({ children, click, color, ghost, sm, cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, onClick, ...rest }) => {
91
+ export const Btn = ({ children, click, color, ghost, sm, cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, row, col, align, onClick, ...rest }) => {
91
92
  const c = rcn({ cn, cnIgnoreWrongUsage, className: rest.className });
92
- return _jsx("button", { ...rest, className: CN('rounded cursor-pointer', sm ? 'px-3 py-1 text-xs' : 'px-4 py-2 text-sm', ghost ? 'bg-transparent text-zinc-400 hover:bg-zinc-800' : color ? colorCn(color) : 'bg-zinc-800 hover:bg-zinc-700', growCn(grow), c), style: dStyle({ gap, p, wd, ht, style: rest.style }), onClick: e => {
93
+ return _jsx("button", { ...rest, className: CN('rounded cursor-pointer', sm ? 'px-3 py-1 text-xs' : 'px-4 py-2 text-sm', ghost ? 'bg-transparent text-zinc-400 hover:bg-zinc-800' : color ? colorCn(color) : 'bg-zinc-800 hover:bg-zinc-700', layoutCn({ row, col, align }), growCn(grow), c), style: dStyle({ gap, p, wd, ht, style: rest.style }), onClick: e => {
93
94
  click?.();
94
95
  onClick?.(e);
95
96
  }, children: children });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "b44ui",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
6
  "./index.js",
package/readme.md CHANGED
@@ -32,7 +32,7 @@ export default defineConfig({
32
32
  | `Scroll` | `grow` (defaults `true`), native `div` props | Vertical scroll container for growable layouts |
33
33
  | `Code` | `highlight` | Code block |
34
34
  | `Grid` | `cols`, `cn`, `grow` | CSS grid, defaults to one column per child |
35
- | `Card` | `row`, `col`, `cn`, `grow` | Bordered zinc-900 card, column by default |
35
+ | `Card` | `row`, `col`, `align`, `cn`, `grow` | Bordered zinc-900 card, column by default |
36
36
  | `Block` | `label`, `row`, `dashed`, `cn`, `grow` | Padded container with optional label |
37
37
  | `BlockSm` | `dashed`, `cn`, `grow` | Smaller padded container |
38
38
  | `TabList` | `gap`, `p`, `wd` | Simple tab row wrapper |
@@ -40,7 +40,7 @@ export default defineConfig({
40
40
  | `Hr` | `vertical`, `color`, `wd` | Horizontal or vertical divider |
41
41
  | `Progress` | `value`, `color`, `dot`, `wd` | Progress bar or dot |
42
42
  | `Dropzone` | `onFiles`, `multiple`, `accept` | Hidden file input wrapper for click/drop |
43
- | `Btn` | `click`, `color`, `ghost`, `cn`, `grow` | Button, supports `Color` and ghost style |
43
+ | `Btn` | `click`, `color`, `ghost`, `row`, `col`, `align`, `cn`, `grow` | Button, supports `Color`, ghost style, and layout props |
44
44
  | `A` | `href`, `click`, `cn`, `grow` | Link-styled anchor, works with `onClick` or `href` |
45
45
  | `Chip` | `click`, `cn` | Small inline badge, clickable if `click` provided |
46
46
  | `Tint` | `color`, `cn`, `grow` | Tinted background block |