@stll/workspace-ui 0.11.8 → 0.11.10

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.
@@ -1,6 +1,8 @@
1
1
  import { GenericProperty, WorkspaceFieldContent } from "./types.js";
2
+ import { useFormatter } from "use-intl";
2
3
  //#region src/field-value.d.ts
3
- type FieldValueVariant = "default" | "table" | "kanban";
4
+ export type FieldValueVariant = "default" | "table" | "kanban";
5
+ type PropertyContentType = GenericProperty["content"]["type"];
4
6
  type FieldValueProps = {
5
7
  content: WorkspaceFieldContent | undefined;
6
8
  property: GenericProperty;
@@ -14,6 +16,17 @@ export declare const IntFieldValue: ({ content, variant }: {
14
16
  }>;
15
17
  variant?: FieldValueVariant;
16
18
  }) => import("react").JSX.Element;
19
+ type FormatIntFieldValueParams = {
20
+ content: Extract<WorkspaceFieldContent, {
21
+ type: "int";
22
+ }>;
23
+ format: ReturnType<typeof useFormatter>;
24
+ };
25
+ /**
26
+ * An int with a currency renders as that currency when the code is one
27
+ * `Intl` knows, else as the number followed by the raw code.
28
+ */
29
+ export declare const formatIntFieldValue: ({ content, format }: FormatIntFieldValueParams) => string;
17
30
  export declare const MoneyFieldValue: ({ content, variant }: {
18
31
  content: Extract<WorkspaceFieldContent, {
19
32
  type: "money";
@@ -26,4 +39,34 @@ export declare const PersonFieldValue: ({ content, variant }: {
26
39
  }>;
27
40
  variant?: FieldValueVariant;
28
41
  }) => import("react").JSX.Element;
42
+ /**
43
+ * The person's picture, or their initial when there is none. Deliberately not
44
+ * the app's user avatar: a person field names someone who may not be a
45
+ * workspace member at all, so there is no account to render.
46
+ */
47
+ export declare const PersonAvatar: ({ image, name }: {
48
+ image: string | null;
49
+ name: string;
50
+ }) => import("react").JSX.Element;
51
+ export declare const EmptyFieldValue: ({ variant }: {
52
+ variant: FieldValueVariant;
53
+ }) => import("react").JSX.Element | null;
54
+ export declare const ErrorFieldValue: ({ variant }: {
55
+ variant: FieldValueVariant;
56
+ }) => import("react").JSX.Element | null;
57
+ export declare const UnsupportedFieldValue: ({ variant }: {
58
+ variant: FieldValueVariant;
59
+ }) => import("react").JSX.Element | null;
60
+ export declare const ClipFieldValue: ({ content, variant }: {
61
+ content: Extract<WorkspaceFieldContent, {
62
+ type: "clip";
63
+ }>;
64
+ variant: FieldValueVariant;
65
+ }) => import("react").JSX.Element;
66
+ type PendingSkeletonProps = {
67
+ contentType: PropertyContentType;
68
+ };
69
+ export declare const PendingSkeleton: ({ contentType }: PendingSkeletonProps) => import("react").JSX.Element;
70
+ export declare const getSelectPropertyColor: (property: GenericProperty, option: string | null) => import("@stll/ui/option-color").ColorVariants | undefined;
71
+ export declare const getIntClassName: (variant: FieldValueVariant) => "text-muted-foreground bg-muted/60 rounded px-1.5 py-0.5 text-xs leading-none tabular-nums" | "block max-w-full min-w-0 truncate text-start tabular-nums" | "block min-w-0 max-w-full truncate text-start text-sm tabular-nums";
29
72
  //#endregion
@@ -62,25 +62,26 @@ const FieldValue = ({ content, property, pendingPreview, variant }) => {
62
62
  };
63
63
  const IntFieldValue = ({ content, variant }) => {
64
64
  const format = useFormatter();
65
- const className = getIntClassName(variant ?? "default");
66
- const fallback = `${format.number(content.value)} ${content.currency}`;
67
- if (!content.currency) return /* @__PURE__ */ jsx("span", {
68
- className,
69
- children: format.number(content.value)
65
+ return /* @__PURE__ */ jsx("span", {
66
+ className: getIntClassName(variant ?? "default"),
67
+ children: formatIntFieldValue({
68
+ content,
69
+ format
70
+ })
70
71
  });
71
- const formattedResult = Result.try(() => format.number(content.value, {
72
+ };
73
+ /**
74
+ * An int with a currency renders as that currency when the code is one
75
+ * `Intl` knows, else as the number followed by the raw code.
76
+ */
77
+ const formatIntFieldValue = ({ content, format }) => {
78
+ const { currency } = content;
79
+ if (!currency) return format.number(content.value);
80
+ return Result.try(() => format.number(content.value, {
72
81
  style: "currency",
73
- currency: content.currency ?? void 0,
82
+ currency,
74
83
  minimumFractionDigits: 0
75
- }));
76
- if (formattedResult.isErr()) return /* @__PURE__ */ jsx("span", {
77
- className,
78
- children: fallback
79
- });
80
- return /* @__PURE__ */ jsx("span", {
81
- className,
82
- children: formattedResult.value
83
- });
84
+ })).unwrapOr(`${format.number(content.value)} ${currency}`);
84
85
  };
85
86
  const MoneyFieldValue = ({ content, variant }) => {
86
87
  const locale = useLocale();
@@ -316,4 +317,4 @@ const getIntClassName = (variant) => {
316
317
  return "block min-w-0 max-w-full truncate text-start text-sm tabular-nums";
317
318
  };
318
319
  //#endregion
319
- export { FieldValue, IntFieldValue, MoneyFieldValue, PersonFieldValue };
320
+ export { ClipFieldValue, EmptyFieldValue, ErrorFieldValue, FieldValue, IntFieldValue, MoneyFieldValue, PendingSkeleton, PersonAvatar, PersonFieldValue, UnsupportedFieldValue, formatIntFieldValue, getIntClassName, getSelectPropertyColor };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/workspace-ui",
3
- "version": "0.11.8",
3
+ "version": "0.11.10",
4
4
  "description": "Reusable workspace presentation components and view helpers for Stella.",
5
5
  "keywords": [
6
6
  "calculations",
@@ -109,7 +109,7 @@
109
109
  "pack:dry-run": "bun pm pack --dry-run",
110
110
  "test": "bun test src",
111
111
  "typecheck": "bun ../../packages/scripts/src/tsc-native.ts --noEmit",
112
- "lint": "cd ../.. && bun --bun oxlint -c oxlint.config.ts --report-unused-disable-directives-severity=error --deny-warnings --type-aware packages/workspace-ui",
112
+ "lint": "cd ../.. && bun --bun oxlint -c oxlint.config.ts --report-unused-disable-directives-severity=error --type-aware packages/workspace-ui",
113
113
  "lint:fix": "cd ../.. && bun --bun oxlint -c oxlint.config.ts --type-aware --fix packages/workspace-ui",
114
114
  "format": "bun ../../scripts/run-oxfmt.ts .",
115
115
  "prepack": "bun run build",
@@ -118,12 +118,12 @@
118
118
  "dependencies": {
119
119
  "@stll/calculations": "^0.1.1",
120
120
  "@stll/conditions": "^0.4.0",
121
- "@stll/money": "^0.2.0",
122
- "@stll/ui": "^0.34.1",
121
+ "@stll/money": "^0.2.1",
122
+ "@stll/ui": "^0.34.4",
123
123
  "better-result": "3.0.1",
124
124
  "lucide-react": "1.41.0",
125
- "temporal-polyfill": "1.0.4",
126
- "use-intl": "4.14.2"
125
+ "temporal-polyfill": "1.0.5",
126
+ "use-intl": "4.14.5"
127
127
  },
128
128
  "devDependencies": {
129
129
  "@atlaskit/pragmatic-drag-and-drop": "^3.1.0",
@@ -135,7 +135,7 @@
135
135
  "@types/react": "^19.2.17",
136
136
  "@types/react-dom": "^19.2.7",
137
137
  "bun-types": "1.4.2",
138
- "fast-check": "^4.9.0",
138
+ "fast-check": "^4.10.1",
139
139
  "react": "^19.2.8",
140
140
  "react-dom": "^19.2.8",
141
141
  "tailwindcss": "4.3.3",