hs-uix 1.5.1 → 1.6.1

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/utils.js CHANGED
@@ -21,8 +21,10 @@ var utils_exports = {};
21
21
  __export(utils_exports, {
22
22
  buildOptions: () => buildOptions,
23
23
  createStatusTagSortComparator: () => createStatusTagSortComparator,
24
+ deriveCardFieldsFromColumns: () => deriveCardFieldsFromColumns,
24
25
  findOptionLabel: () => findOptionLabel,
25
26
  formatCurrency: () => formatCurrency,
27
+ formatCurrencyCompact: () => formatCurrencyCompact,
26
28
  formatDate: () => formatDate,
27
29
  formatDateTime: () => formatDateTime,
28
30
  formatPercentage: () => formatPercentage,
@@ -88,6 +90,20 @@ var formatPercentage = (value, { locale = DEFAULT_LOCALE, minimumFractionDigits
88
90
  maximumFractionDigits,
89
91
  ...options
90
92
  }).format(Number(value || 0));
93
+ var formatCurrencyCompact = (value, {
94
+ locale = DEFAULT_LOCALE,
95
+ currency = "USD",
96
+ maximumFractionDigits = 1,
97
+ compactDisplay = "short",
98
+ ...options
99
+ } = {}) => new Intl.NumberFormat(locale, {
100
+ style: "currency",
101
+ currency,
102
+ notation: "compact",
103
+ compactDisplay,
104
+ maximumFractionDigits,
105
+ ...options
106
+ }).format(Number(value || 0));
91
107
 
92
108
  // src/utils/hubspotValues.js
93
109
  var isDateValueObject = (value) => Boolean(
@@ -250,12 +266,56 @@ var createStatusTagSortComparator = (options = {}) => {
250
266
  return labelOf(aVal).localeCompare(labelOf(bVal));
251
267
  };
252
268
  };
269
+
270
+ // src/utils/viewAdapters.js
271
+ var deriveCardFieldsFromColumns = (columns, opts = {}) => {
272
+ var _a;
273
+ const {
274
+ titleField,
275
+ titleHref,
276
+ placements = {},
277
+ exclude,
278
+ include,
279
+ maxBodyFields
280
+ } = opts;
281
+ const excludeSet = new Set(exclude || []);
282
+ const includeSet = include ? new Set(include) : null;
283
+ const filtered = (columns || []).filter((col) => {
284
+ if (!col || !col.field) return false;
285
+ if (excludeSet.has(col.field)) return false;
286
+ if (includeSet && !includeSet.has(col.field)) return false;
287
+ return true;
288
+ });
289
+ const resolvedTitleField = titleField || Object.keys(placements).find((k) => placements[k] === "title") || ((_a = filtered[0]) == null ? void 0 : _a.field);
290
+ const out = [];
291
+ let bodyCount = 0;
292
+ for (const col of filtered) {
293
+ const placement = placements[col.field] || (col.field === resolvedTitleField ? "title" : "body");
294
+ if (placement === "body" && maxBodyFields != null && bodyCount >= maxBodyFields) {
295
+ continue;
296
+ }
297
+ if (placement === "body") bodyCount += 1;
298
+ const cardField = {
299
+ key: col.field,
300
+ field: col.field,
301
+ placement
302
+ };
303
+ if (col.label != null) cardField.label = col.label;
304
+ if (col.renderCell) cardField.render = col.renderCell;
305
+ if (col.truncate != null) cardField.truncate = col.truncate;
306
+ if (placement === "title" && titleHref) cardField.href = titleHref;
307
+ out.push(cardField);
308
+ }
309
+ return out;
310
+ };
253
311
  // Annotate the CommonJS export names for ESM import in node:
254
312
  0 && (module.exports = {
255
313
  buildOptions,
256
314
  createStatusTagSortComparator,
315
+ deriveCardFieldsFromColumns,
257
316
  findOptionLabel,
258
317
  formatCurrency,
318
+ formatCurrencyCompact,
259
319
  formatDate,
260
320
  formatDateTime,
261
321
  formatPercentage,
package/dist/utils.mjs CHANGED
@@ -50,6 +50,20 @@ var formatPercentage = (value, { locale = DEFAULT_LOCALE, minimumFractionDigits
50
50
  maximumFractionDigits,
51
51
  ...options
52
52
  }).format(Number(value || 0));
53
+ var formatCurrencyCompact = (value, {
54
+ locale = DEFAULT_LOCALE,
55
+ currency = "USD",
56
+ maximumFractionDigits = 1,
57
+ compactDisplay = "short",
58
+ ...options
59
+ } = {}) => new Intl.NumberFormat(locale, {
60
+ style: "currency",
61
+ currency,
62
+ notation: "compact",
63
+ compactDisplay,
64
+ maximumFractionDigits,
65
+ ...options
66
+ }).format(Number(value || 0));
53
67
 
54
68
  // src/utils/hubspotValues.js
55
69
  var isDateValueObject = (value) => Boolean(
@@ -212,11 +226,55 @@ var createStatusTagSortComparator = (options = {}) => {
212
226
  return labelOf(aVal).localeCompare(labelOf(bVal));
213
227
  };
214
228
  };
229
+
230
+ // src/utils/viewAdapters.js
231
+ var deriveCardFieldsFromColumns = (columns, opts = {}) => {
232
+ var _a;
233
+ const {
234
+ titleField,
235
+ titleHref,
236
+ placements = {},
237
+ exclude,
238
+ include,
239
+ maxBodyFields
240
+ } = opts;
241
+ const excludeSet = new Set(exclude || []);
242
+ const includeSet = include ? new Set(include) : null;
243
+ const filtered = (columns || []).filter((col) => {
244
+ if (!col || !col.field) return false;
245
+ if (excludeSet.has(col.field)) return false;
246
+ if (includeSet && !includeSet.has(col.field)) return false;
247
+ return true;
248
+ });
249
+ const resolvedTitleField = titleField || Object.keys(placements).find((k) => placements[k] === "title") || ((_a = filtered[0]) == null ? void 0 : _a.field);
250
+ const out = [];
251
+ let bodyCount = 0;
252
+ for (const col of filtered) {
253
+ const placement = placements[col.field] || (col.field === resolvedTitleField ? "title" : "body");
254
+ if (placement === "body" && maxBodyFields != null && bodyCount >= maxBodyFields) {
255
+ continue;
256
+ }
257
+ if (placement === "body") bodyCount += 1;
258
+ const cardField = {
259
+ key: col.field,
260
+ field: col.field,
261
+ placement
262
+ };
263
+ if (col.label != null) cardField.label = col.label;
264
+ if (col.renderCell) cardField.render = col.renderCell;
265
+ if (col.truncate != null) cardField.truncate = col.truncate;
266
+ if (placement === "title" && titleHref) cardField.href = titleHref;
267
+ out.push(cardField);
268
+ }
269
+ return out;
270
+ };
215
271
  export {
216
272
  buildOptions,
217
273
  createStatusTagSortComparator,
274
+ deriveCardFieldsFromColumns,
218
275
  findOptionLabel,
219
276
  formatCurrency,
277
+ formatCurrencyCompact,
220
278
  formatDate,
221
279
  formatDateTime,
222
280
  formatPercentage,
package/form.d.ts CHANGED
@@ -13,6 +13,7 @@ export {
13
13
  FormBuilderValidator,
14
14
  FormBuilderDependsOnConfig,
15
15
  FormBuilderRepeaterProps,
16
+ FormBuilderGroupOptions,
16
17
  FormBuilderLabels,
17
18
  FormBuilderAlertConfig,
18
19
  FormBuilderButtonsRenderContext,
package/index.d.ts CHANGED
@@ -26,6 +26,37 @@ export type {
26
26
  DataTableErrorStateRenderContext,
27
27
  } from "./packages/datatable/index";
28
28
 
29
+ export { Kanban, KanbanCardActions } from "./packages/kanban/index";
30
+ export type {
31
+ KanbanProps,
32
+ KanbanStage,
33
+ KanbanStageMeta,
34
+ KanbanStageVariant,
35
+ KanbanStageControlMode,
36
+ KanbanCardField,
37
+ KanbanCardFieldPlacement,
38
+ KanbanCardDensity,
39
+ KanbanCardBodyMode,
40
+ KanbanCardDividers,
41
+ KanbanCardRenderContext,
42
+ KanbanFilterConfig,
43
+ KanbanFilterType,
44
+ KanbanSortOption,
45
+ KanbanSelectionAction,
46
+ KanbanCardAction,
47
+ KanbanCardActionsProps,
48
+ KanbanLabels,
49
+ KanbanParams,
50
+ KanbanStageChangeResult,
51
+ KanbanMetricItem,
52
+ KanbanSelectionBarRenderContext,
53
+ KanbanEmptyStateRenderContext,
54
+ KanbanLoadingStateRenderContext,
55
+ KanbanErrorStateRenderContext,
56
+ KanbanTransitionPromptContext,
57
+ KanbanOption,
58
+ } from "./packages/kanban/index";
59
+
29
60
  export { FormBuilder, useFormPrefill } from "./packages/form/index";
30
61
  export type {
31
62
  FormBuilderProps,
@@ -40,6 +71,7 @@ export type {
40
71
  FormBuilderValidator,
41
72
  FormBuilderDependsOnConfig,
42
73
  FormBuilderRepeaterProps,
74
+ FormBuilderGroupOptions,
43
75
  FormBuilderLabels,
44
76
  FormBuilderAlertConfig,
45
77
  FormBuilderButtonsRenderContext,
@@ -53,6 +85,28 @@ export type {
53
85
  } from "./packages/form/index";
54
86
 
55
87
  export { AutoTag, AutoStatusTag, KeyValueList, SectionHeader } from "./common-components";
88
+ export {
89
+ AvatarStack,
90
+ StyledText,
91
+ makeAvatarStackDataUri,
92
+ makeStyledTextDataUri,
93
+ HS_DATE_DIRECTION_LABELS,
94
+ HS_DATE_PRESETS,
95
+ HS_FONT_FAMILY,
96
+ HS_TEXT_COLOR,
97
+ HS_SUBTLE_BG,
98
+ HS_MUTED_TEXT,
99
+ HS_NEUTRAL_CHIP,
100
+ HS_TAG_SUBTLE_BORDER,
101
+ HS_TAG_TEXT_COLOR,
102
+ HS_TAG_FONT_SIZE,
103
+ HS_TAG_LINE_HEIGHT,
104
+ HS_TAG_PADDING_X,
105
+ HS_TAG_PADDING_Y,
106
+ HS_TAG_BORDER_RADIUS,
107
+ HS_TAG_BORDER_WIDTH,
108
+ DEFAULT_SVG_FONT_WEIGHT,
109
+ } from "./common-components";
56
110
  export {
57
111
  getAutoTagVariant,
58
112
  getAutoStatusTagVariant,
@@ -68,7 +122,18 @@ export type {
68
122
  export type {
69
123
  AutoTagProps,
70
124
  AutoStatusTagProps,
125
+ AvatarStackDataUriResult,
126
+ AvatarStackItem,
127
+ AvatarStackItemObject,
128
+ AvatarStackProps,
129
+ DateDirectionLabels,
130
+ DatePresetOption,
71
131
  KeyValueListItem,
72
132
  KeyValueListProps,
73
133
  SectionHeaderProps,
134
+ StyledTextBackground,
135
+ StyledTextDataUriOptions,
136
+ StyledTextDataUriResult,
137
+ StyledTextFormat,
138
+ StyledTextProps,
74
139
  } from "./common-components";
package/kanban.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./packages/kanban/index";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hs-uix",
3
- "version": "1.5.1",
3
+ "version": "1.6.1",
4
4
  "description": "Production-ready UI components for HubSpot UI Extensions — DataTable, FormBuilder, and more",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
@@ -22,6 +22,11 @@
22
22
  "import": "./dist/form.mjs",
23
23
  "require": "./dist/form.js"
24
24
  },
25
+ "./kanban": {
26
+ "types": "./kanban.d.ts",
27
+ "import": "./dist/kanban.mjs",
28
+ "require": "./dist/kanban.js"
29
+ },
25
30
  "./common-components": {
26
31
  "types": "./common-components.d.ts",
27
32
  "import": "./dist/common-components.mjs",
@@ -38,6 +43,7 @@
38
43
  "index.d.ts",
39
44
  "datatable.d.ts",
40
45
  "form.d.ts",
46
+ "kanban.d.ts",
41
47
  "common-components.d.ts",
42
48
  "utils.d.ts",
43
49
  "README.md"
package/utils.d.ts CHANGED
@@ -47,7 +47,34 @@ export interface StatusTagSortComparatorOptions extends AutoStatusTagOptions {
47
47
  export declare function createStatusTagSortComparator(
48
48
  options?: StatusTagSortComparatorOptions
49
49
  ): (aValue: unknown, bValue: unknown) => number;
50
+ export interface FormatCurrencyCompactOptions extends Intl.NumberFormatOptions {
51
+ locale?: string;
52
+ currency?: string;
53
+ maximumFractionDigits?: number;
54
+ compactDisplay?: "short" | "long";
55
+ }
56
+
57
+ export interface DeriveCardFieldsOptions<Row = Record<string, unknown>> {
58
+ titleField?: string;
59
+ titleHref?: (row: Row) => string | { url: string; external?: boolean };
60
+ placements?: Record<string, "title" | "subtitle" | "meta" | "body" | "footer">;
61
+ exclude?: string[];
62
+ include?: string[];
63
+ maxBodyFields?: number;
64
+ }
65
+
66
+ export interface DerivedCardField<Row = Record<string, unknown>> {
67
+ key: string;
68
+ field: string;
69
+ placement: "title" | "subtitle" | "meta" | "body" | "footer";
70
+ label?: unknown;
71
+ render?: (value: unknown, row: Row) => unknown;
72
+ truncate?: true | number | { maxLength?: number };
73
+ href?: (row: Row) => string | { url: string; external?: boolean };
74
+ }
75
+
50
76
  export declare function formatCurrency(value: unknown, options?: FormatCurrencyOptions): string;
77
+ export declare function formatCurrencyCompact(value: unknown, options?: FormatCurrencyCompactOptions): string;
51
78
  export declare function formatDate(value: unknown, options?: FormatDateOptions): string;
52
79
  export declare function formatDateTime(value: unknown, options?: FormatDateOptions): string;
53
80
  export declare function formatPercentage(value: unknown, options?: Intl.NumberFormatOptions & { locale?: string }): string;
@@ -57,3 +84,7 @@ export declare function isDateValueObject(value: unknown): boolean;
57
84
  export declare function isTimeValueObject(value: unknown): boolean;
58
85
  export declare function isDateTimeValueObject(value: unknown): boolean;
59
86
  export declare function sumBy<Item = Record<string, unknown>>(items: Item[] | null | undefined, keyOrFn: keyof Item | ((item: Item) => unknown)): number;
87
+ export declare function deriveCardFieldsFromColumns<Row = Record<string, unknown>>(
88
+ columns: ReadonlyArray<Record<string, unknown>> | null | undefined,
89
+ options?: DeriveCardFieldsOptions<Row>
90
+ ): DerivedCardField<Row>[];