@openwarelabs/ui 0.1.0 → 0.2.0

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.
Files changed (40) hide show
  1. package/README.md +2 -2
  2. package/dist/components/Accordion/Accordion.d.cts +1 -1
  3. package/dist/components/Accordion/Accordion.d.ts +1 -1
  4. package/dist/components/Avatar/Avatar.d.cts +13 -2
  5. package/dist/components/Avatar/Avatar.d.ts +13 -2
  6. package/dist/components/Avatar/AvatarGroup.d.cts +7 -6
  7. package/dist/components/Avatar/AvatarGroup.d.ts +7 -6
  8. package/dist/components/CodeBlock/CodeBlock.d.cts +1 -1
  9. package/dist/components/CodeBlock/CodeBlock.d.ts +1 -1
  10. package/dist/components/FileDropZone/FileDropZone.d.cts +1 -1
  11. package/dist/components/FileDropZone/FileDropZone.d.ts +1 -1
  12. package/dist/components/FileTree/FileTree.d.cts +1 -1
  13. package/dist/components/FileTree/FileTree.d.ts +1 -1
  14. package/dist/components/Progress/Progress.d.cts +1 -1
  15. package/dist/components/Progress/Progress.d.ts +1 -1
  16. package/dist/components/Stat/Stat.d.cts +1 -1
  17. package/dist/components/Stat/Stat.d.ts +1 -1
  18. package/dist/components/Steps/Steps.d.cts +2 -2
  19. package/dist/components/Steps/Steps.d.ts +2 -2
  20. package/dist/components/Table/Table.d.cts +6 -1
  21. package/dist/components/Table/Table.d.ts +6 -1
  22. package/dist/components/Tabs/Tabs.d.cts +1 -1
  23. package/dist/components/Tabs/Tabs.d.ts +1 -1
  24. package/dist/components/Tooltip/Tooltip.d.cts +3 -3
  25. package/dist/components/Tooltip/Tooltip.d.ts +3 -3
  26. package/dist/components.css +58 -16
  27. package/dist/hooks/useFloating.d.cts +2 -2
  28. package/dist/hooks/useFloating.d.ts +2 -2
  29. package/dist/index.cjs +46 -7
  30. package/dist/index.cjs.map +3 -3
  31. package/dist/index.d.cts +1 -1
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.js +46 -7
  34. package/dist/index.js.map +3 -3
  35. package/dist/openware-ui.iife.js +5 -5
  36. package/dist/styles.css +61 -16
  37. package/dist/tailwind.css +1 -0
  38. package/dist/tokens.css +3 -0
  39. package/dist/tokens.json +1110 -191
  40. package/package.json +2 -2
package/dist/index.d.cts CHANGED
@@ -88,7 +88,7 @@ export type { EmptyStateProps } from "./components/EmptyState/EmptyState.cjs";
88
88
  export { Tag, TagGroup, ColorSwatch } from "./components/Tag/Tag.cjs";
89
89
  export type { TagProps, TagGroupProps, ColorSwatchProps } from "./components/Tag/Tag.cjs";
90
90
  export { Avatar } from "./components/Avatar/Avatar.cjs";
91
- export type { AvatarProps } from "./components/Avatar/Avatar.cjs";
91
+ export type { AvatarProps, AvatarSize } from "./components/Avatar/Avatar.cjs";
92
92
  export { AvatarGroup, User } from "./components/Avatar/AvatarGroup.cjs";
93
93
  export type { AvatarGroupProps, UserProps } from "./components/Avatar/AvatarGroup.cjs";
94
94
  export { Kbd, Code } from "./components/Kbd/Kbd.cjs";
package/dist/index.d.ts CHANGED
@@ -88,7 +88,7 @@ export type { EmptyStateProps } from "./components/EmptyState/EmptyState.js";
88
88
  export { Tag, TagGroup, ColorSwatch } from "./components/Tag/Tag.js";
89
89
  export type { TagProps, TagGroupProps, ColorSwatchProps } from "./components/Tag/Tag.js";
90
90
  export { Avatar } from "./components/Avatar/Avatar.js";
91
- export type { AvatarProps } from "./components/Avatar/Avatar.js";
91
+ export type { AvatarProps, AvatarSize } from "./components/Avatar/Avatar.js";
92
92
  export { AvatarGroup, User } from "./components/Avatar/AvatarGroup.js";
93
93
  export type { AvatarGroupProps, UserProps } from "./components/Avatar/AvatarGroup.js";
94
94
  export { Kbd, Code } from "./components/Kbd/Kbd.js";
package/dist/index.js CHANGED
@@ -1042,6 +1042,25 @@ function useFloating({
1042
1042
  const rect = anchor.getBoundingClientRect();
1043
1043
  const width = Math.max(floating.offsetWidth, matchWidth ? rect.width : 0);
1044
1044
  const height = floating.scrollHeight;
1045
+ if (placement === "left" || placement === "right") {
1046
+ const roomLeft = rect.left - offset - margin;
1047
+ const roomRight = window.innerWidth - rect.right - offset - margin;
1048
+ const onLeft = placement === "left" ? width <= roomLeft || roomLeft > roomRight : width > roomRight && roomLeft > roomRight;
1049
+ const top2 = Math.min(Math.max(margin, rect.top + rect.height / 2 - height / 2), window.innerHeight - height - margin);
1050
+ floating.dataset.side = onLeft ? "left" : "right";
1051
+ setStyle({
1052
+ position: "fixed",
1053
+ inset: "auto",
1054
+ margin: 0,
1055
+ left: onLeft ? "auto" : rect.right + offset,
1056
+ right: onLeft ? window.innerWidth - rect.left + offset : "auto",
1057
+ top: top2,
1058
+ bottom: "auto",
1059
+ maxHeight: Math.max(120, Math.min(maxHeight, window.innerHeight - 2 * margin)),
1060
+ ["--ow-floating-origin"]: `${onLeft ? "right" : "left"} center`
1061
+ });
1062
+ return;
1063
+ }
1045
1064
  const below = window.innerHeight - rect.bottom - offset - margin;
1046
1065
  const above = rect.top - offset - margin;
1047
1066
  const wantsTop = placement.startsWith("top");
@@ -3556,7 +3575,7 @@ function Steps({ items: items2, current = 0, orientation = "vertical", title, la
3556
3575
  ] }),
3557
3576
  item.description && (orientation === "horizontal" || status !== "done") ? /* @__PURE__ */ jsx38("span", { className: "ow-steps__description", children: item.description }) : null
3558
3577
  ] }),
3559
- item.action && status !== "done" && orientation === "vertical" ? /* @__PURE__ */ jsx38("span", { className: "ow-steps__action", children: item.action }) : null
3578
+ item.action && status === "current" && orientation === "vertical" ? /* @__PURE__ */ jsx38("span", { className: "ow-steps__action", children: item.action }) : null
3560
3579
  ]
3561
3580
  },
3562
3581
  index
@@ -3639,6 +3658,7 @@ function Table({
3639
3658
  selectedKeys,
3640
3659
  defaultSelectedKeys = [],
3641
3660
  onSelectionChange,
3661
+ rowLabel,
3642
3662
  emptyContent = "Nothing here yet.",
3643
3663
  density = "comfortable",
3644
3664
  stickyHeader = false,
@@ -3648,6 +3668,11 @@ function Table({
3648
3668
  const [currentSort, setSort] = useControllableState(sort, defaultSort, onSortChange);
3649
3669
  const [selected, setSelected] = useControllableState(selectedKeys, defaultSelectedKeys, onSelectionChange);
3650
3670
  const keyOf = (row) => typeof rowKey === "function" ? rowKey(row) : row[rowKey];
3671
+ const labelOf = (row, index) => {
3672
+ if (rowLabel) return rowLabel(row);
3673
+ const first = columns[0] ? row[columns[0].key] : void 0;
3674
+ return typeof first === "string" || typeof first === "number" ? String(first) : `row ${index + 1}`;
3675
+ };
3651
3676
  const field = (row, key) => row[key];
3652
3677
  const sorted = useMemo5(() => {
3653
3678
  if (!currentSort || manualSort) return rows;
@@ -3704,7 +3729,7 @@ function Table({
3704
3729
  );
3705
3730
  })
3706
3731
  ] }) }),
3707
- /* @__PURE__ */ jsx40("tbody", { children: sorted.length === 0 ? /* @__PURE__ */ jsx40("tr", { children: /* @__PURE__ */ jsx40("td", { className: "ow-table__empty", colSpan: columns.length + (selectable ? 1 : 0), children: emptyContent }) }) : sorted.map((row) => {
3732
+ /* @__PURE__ */ jsx40("tbody", { children: sorted.length === 0 ? /* @__PURE__ */ jsx40("tr", { children: /* @__PURE__ */ jsx40("td", { className: "ow-table__empty", colSpan: columns.length + (selectable ? 1 : 0), children: emptyContent }) }) : sorted.map((row, index) => {
3708
3733
  const key = keyOf(row);
3709
3734
  const isSelected = selected.includes(key);
3710
3735
  return /* @__PURE__ */ jsxs34("tr", { className: cx(isSelected && "ow-table__row--selected"), children: [
@@ -3712,7 +3737,7 @@ function Table({
3712
3737
  Checkbox,
3713
3738
  {
3714
3739
  size: "sm",
3715
- "aria-label": "Select row",
3740
+ "aria-label": `Select ${labelOf(row, index)}`,
3716
3741
  checked: isSelected,
3717
3742
  onChange: (event) => setSelected(
3718
3743
  event.target.checked ? [...selected, key] : selected.filter((k) => k !== key)
@@ -3942,16 +3967,25 @@ function ColorSwatch({ color, name, value, size = "md", shape = "square", classN
3942
3967
  // src/components/Avatar/Avatar.tsx
3943
3968
  import { useState as useState18 } from "react";
3944
3969
  import { jsx as jsx45 } from "react/jsx-runtime";
3970
+ var namedSizes = { sm: 24, md: 28, lg: 36, xl: 48 };
3971
+ function avatarSize(size) {
3972
+ if (typeof size === "number") {
3973
+ return { className: "ow-avatar--custom", style: { "--ow-avatar-size": `${size}px` }, pixels: size };
3974
+ }
3975
+ return { className: `ow-avatar--${size}`, pixels: namedSizes[size] };
3976
+ }
3945
3977
  function Avatar({ name, src, size = "md", label, className }) {
3946
3978
  const initials = getInitials(name);
3947
3979
  const [failedImage, setFailedImage] = useState18();
3948
3980
  const showImage = src && src !== failedImage;
3981
+ const sizing = avatarSize(size);
3949
3982
  return /* @__PURE__ */ jsx45(
3950
3983
  "span",
3951
3984
  {
3952
- className: cx("ow-avatar", `ow-avatar--${size}`, !initials && !showImage && "ow-avatar--empty", className),
3985
+ className: cx("ow-avatar", sizing.className, !initials && !showImage && "ow-avatar--empty", className),
3986
+ style: sizing.style,
3953
3987
  ...label ? { role: "img", "aria-label": label } : { "aria-hidden": true },
3954
- children: showImage ? /* @__PURE__ */ jsx45("img", { src, alt: "", className: "ow-avatar__image", onError: () => setFailedImage(src) }) : initials || /* @__PURE__ */ jsx45(UserIcon, { size: size === "sm" ? 13 : size === "lg" ? 18 : 15 })
3988
+ children: showImage ? /* @__PURE__ */ jsx45("img", { src, alt: "", className: "ow-avatar__image", onError: () => setFailedImage(src) }) : initials || /* @__PURE__ */ jsx45(UserIcon, { size: Math.round(sizing.pixels * 0.52) })
3955
3989
  }
3956
3990
  );
3957
3991
  }
@@ -3961,11 +3995,12 @@ import { Children, cloneElement as cloneElement4, isValidElement as isValidEleme
3961
3995
  import { jsx as jsx46, jsxs as jsxs39 } from "react/jsx-runtime";
3962
3996
  function AvatarGroup({ children, max = 4, size = "md", label, className }) {
3963
3997
  const avatars = Children.toArray(children).filter(isValidElement4);
3998
+ const sizing = avatarSize(size);
3964
3999
  const shown = avatars.slice(0, max);
3965
4000
  const hidden = avatars.length - shown.length;
3966
4001
  return /* @__PURE__ */ jsxs39("div", { role: "group", "aria-label": label, className: cx("ow-avatar-group", className), children: [
3967
4002
  shown.map((avatar) => cloneElement4(avatar, { size })),
3968
- hidden > 0 ? /* @__PURE__ */ jsxs39("span", { className: cx("ow-avatar", `ow-avatar--${size}`, "ow-avatar--count"), children: [
4003
+ hidden > 0 ? /* @__PURE__ */ jsxs39("span", { className: cx("ow-avatar", sizing.className, "ow-avatar--count"), style: sizing.style, children: [
3969
4004
  /* @__PURE__ */ jsxs39("span", { "aria-hidden": "true", children: [
3970
4005
  "+",
3971
4006
  hidden
@@ -3978,8 +4013,12 @@ function AvatarGroup({ children, max = 4, size = "md", label, className }) {
3978
4013
  ] }) : null
3979
4014
  ] });
3980
4015
  }
4016
+ function userSize(size) {
4017
+ if (typeof size !== "number") return `ow-user--${size}`;
4018
+ return size >= 48 ? "ow-user--xl" : size >= 36 ? "ow-user--lg" : size >= 28 ? "ow-user--md" : "ow-user--sm";
4019
+ }
3981
4020
  function User({ name, description, src, size = "md", className }) {
3982
- return /* @__PURE__ */ jsxs39("div", { className: cx("ow-user", `ow-user--${size}`, className), children: [
4021
+ return /* @__PURE__ */ jsxs39("div", { className: cx("ow-user", userSize(size), className), children: [
3983
4022
  /* @__PURE__ */ jsx46(Avatar, { name, src, size }),
3984
4023
  /* @__PURE__ */ jsxs39("div", { className: "ow-user__text", children: [
3985
4024
  /* @__PURE__ */ jsx46("span", { className: "ow-user__name", children: name }),