hs-uix 1.4.0 → 1.5.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.
- package/README.md +20 -2
- package/common-components.d.ts +55 -0
- package/dist/common-components.js +260 -0
- package/dist/common-components.mjs +221 -0
- package/dist/datatable.js +74 -38
- package/dist/datatable.mjs +74 -38
- package/dist/form.js +204 -76
- package/dist/form.mjs +204 -76
- package/dist/index.js +486 -114
- package/dist/index.mjs +481 -114
- package/dist/utils.js +269 -0
- package/dist/utils.mjs +230 -0
- package/index.d.ts +21 -0
- package/package.json +14 -2
- package/utils.d.ts +59 -0
package/README.md
CHANGED
|
@@ -14,9 +14,11 @@ npm install hs-uix
|
|
|
14
14
|
```jsx
|
|
15
15
|
import { DataTable } from "hs-uix/datatable";
|
|
16
16
|
import { FormBuilder } from "hs-uix/form";
|
|
17
|
+
import { AutoStatusTag, AutoTag, KeyValueList, SectionHeader } from "hs-uix/common-components";
|
|
18
|
+
import { formatCurrency, formatDate } from "hs-uix/utils";
|
|
17
19
|
|
|
18
20
|
// or import everything from the root
|
|
19
|
-
import { DataTable, FormBuilder } from "hs-uix";
|
|
21
|
+
import { DataTable, FormBuilder, AutoStatusTag, AutoTag } from "hs-uix";
|
|
20
22
|
```
|
|
21
23
|
|
|
22
24
|
Requires `react` >= 18.0.0 and `@hubspot/ui-extensions` >= 0.12.0 as peer dependencies (already present in any HubSpot UI Extensions project).
|
|
@@ -40,14 +42,30 @@ A drop-in table component for HubSpot UI Extensions. Define your columns, pass y
|
|
|
40
42
|
|
|
41
43
|
```jsx
|
|
42
44
|
import { DataTable } from "hs-uix/datatable";
|
|
45
|
+
import { AutoStatusTag, AutoTag, KeyValueList, SectionHeader } from "hs-uix/common-components";
|
|
46
|
+
import { formatCurrency, formatDate } from "hs-uix/utils";
|
|
43
47
|
|
|
44
48
|
const COLUMNS = [
|
|
45
49
|
{ field: "name", label: "Company", sortable: true, renderCell: (val) => val },
|
|
46
|
-
{ field: "status", label: "Status", renderCell: (val) => <
|
|
50
|
+
{ field: "status", label: "Status", renderCell: (val) => <AutoStatusTag value={val} /> },
|
|
51
|
+
{ field: "segment", label: "Segment", renderCell: (val) => <AutoTag value={val} /> },
|
|
47
52
|
{ field: "amount", label: "Amount", sortable: true, renderCell: (val) => formatCurrency(val) },
|
|
53
|
+
{ field: "closeDate", label: "Close Date", renderCell: (val) => formatDate(val) },
|
|
48
54
|
];
|
|
49
55
|
|
|
50
56
|
<DataTable data={deals} columns={COLUMNS} searchFields={["name"]} pageSize={10} />
|
|
57
|
+
|
|
58
|
+
<SectionHeader
|
|
59
|
+
title="Deal Summary"
|
|
60
|
+
description="A compact summary block using common components."
|
|
61
|
+
/>
|
|
62
|
+
|
|
63
|
+
<KeyValueList
|
|
64
|
+
items={[
|
|
65
|
+
{ label: "Open deals", value: 12 },
|
|
66
|
+
{ label: "Pipeline", value: formatCurrency(245000) },
|
|
67
|
+
]}
|
|
68
|
+
/>
|
|
51
69
|
```
|
|
52
70
|
|
|
53
71
|
That's a searchable, sortable, paginated table with auto-sized columns in 5 lines of config.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type {
|
|
3
|
+
AutoTagOptions,
|
|
4
|
+
AutoTagVariant,
|
|
5
|
+
AutoStatusTagOptions,
|
|
6
|
+
AutoStatusTagVariant,
|
|
7
|
+
} from "./utils";
|
|
8
|
+
|
|
9
|
+
export interface AutoTagProps extends AutoTagOptions {
|
|
10
|
+
value?: unknown;
|
|
11
|
+
tag?: unknown;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
variant?: AutoTagVariant;
|
|
14
|
+
onClick?: () => void;
|
|
15
|
+
onDelete?: () => void;
|
|
16
|
+
overlay?: unknown;
|
|
17
|
+
inline?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface AutoStatusTagProps extends AutoStatusTagOptions {
|
|
21
|
+
value?: unknown;
|
|
22
|
+
status?: unknown;
|
|
23
|
+
children?: ReactNode;
|
|
24
|
+
variant?: AutoStatusTagVariant;
|
|
25
|
+
hollow?: boolean;
|
|
26
|
+
onClick?: () => void;
|
|
27
|
+
showRemoveIcon?: boolean;
|
|
28
|
+
onRemoveClick?: () => void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface SectionHeaderProps {
|
|
32
|
+
title?: ReactNode;
|
|
33
|
+
description?: ReactNode;
|
|
34
|
+
actions?: ReactNode;
|
|
35
|
+
children?: ReactNode;
|
|
36
|
+
gap?: string;
|
|
37
|
+
titleAs?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface KeyValueListItem {
|
|
41
|
+
key?: string | number;
|
|
42
|
+
label: ReactNode;
|
|
43
|
+
value: ReactNode;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface KeyValueListProps {
|
|
47
|
+
items?: KeyValueListItem[];
|
|
48
|
+
direction?: "row" | "column";
|
|
49
|
+
gap?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export declare function AutoTag(props: AutoTagProps): ReactNode;
|
|
53
|
+
export declare function AutoStatusTag(props: AutoStatusTagProps): ReactNode;
|
|
54
|
+
export declare function SectionHeader(props: SectionHeaderProps): ReactNode;
|
|
55
|
+
export declare function KeyValueList(props: KeyValueListProps): ReactNode;
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/common-components/index.js
|
|
30
|
+
var common_components_exports = {};
|
|
31
|
+
__export(common_components_exports, {
|
|
32
|
+
AutoStatusTag: () => AutoStatusTag,
|
|
33
|
+
AutoTag: () => AutoTag,
|
|
34
|
+
KeyValueList: () => KeyValueList,
|
|
35
|
+
SectionHeader: () => SectionHeader
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(common_components_exports);
|
|
38
|
+
|
|
39
|
+
// src/common-components/AutoTag.js
|
|
40
|
+
var import_react = __toESM(require("react"));
|
|
41
|
+
var import_ui_extensions = require("@hubspot/ui-extensions");
|
|
42
|
+
|
|
43
|
+
// src/utils/tagVariants.js
|
|
44
|
+
var DEFAULT_VARIANT = "default";
|
|
45
|
+
var DANGER_VARIANT = "danger";
|
|
46
|
+
var ERROR_VARIANT = "error";
|
|
47
|
+
var SUCCESS_MATCHERS = [
|
|
48
|
+
"active",
|
|
49
|
+
"success",
|
|
50
|
+
"succeeded",
|
|
51
|
+
"complete",
|
|
52
|
+
"completed",
|
|
53
|
+
"approved",
|
|
54
|
+
"won",
|
|
55
|
+
"healthy",
|
|
56
|
+
"enabled",
|
|
57
|
+
"connected",
|
|
58
|
+
"paid",
|
|
59
|
+
"live",
|
|
60
|
+
"published",
|
|
61
|
+
"available",
|
|
62
|
+
"synced",
|
|
63
|
+
"resolved"
|
|
64
|
+
];
|
|
65
|
+
var WARNING_MATCHERS = [
|
|
66
|
+
"warning",
|
|
67
|
+
"at risk",
|
|
68
|
+
"risky",
|
|
69
|
+
"pending",
|
|
70
|
+
"paused",
|
|
71
|
+
"pause",
|
|
72
|
+
"on hold",
|
|
73
|
+
"hold",
|
|
74
|
+
"review",
|
|
75
|
+
"expiring",
|
|
76
|
+
"trial",
|
|
77
|
+
"in progress",
|
|
78
|
+
"awaiting",
|
|
79
|
+
"scheduled"
|
|
80
|
+
];
|
|
81
|
+
var DANGER_MATCHERS = [
|
|
82
|
+
"danger",
|
|
83
|
+
"error",
|
|
84
|
+
"failed",
|
|
85
|
+
"failure",
|
|
86
|
+
"inactive",
|
|
87
|
+
"disabled",
|
|
88
|
+
"blocked",
|
|
89
|
+
"cancelled",
|
|
90
|
+
"canceled",
|
|
91
|
+
"rejected",
|
|
92
|
+
"denied",
|
|
93
|
+
"churned",
|
|
94
|
+
"lost",
|
|
95
|
+
"overdue",
|
|
96
|
+
"expired",
|
|
97
|
+
"offline",
|
|
98
|
+
"deleted",
|
|
99
|
+
"archived",
|
|
100
|
+
"unpaid"
|
|
101
|
+
];
|
|
102
|
+
var INFO_MATCHERS = [
|
|
103
|
+
"info",
|
|
104
|
+
"new",
|
|
105
|
+
"queued",
|
|
106
|
+
"processing",
|
|
107
|
+
"progress",
|
|
108
|
+
"upcoming",
|
|
109
|
+
"draft",
|
|
110
|
+
"open"
|
|
111
|
+
];
|
|
112
|
+
var normalizeTagValue = (value) => {
|
|
113
|
+
if (value == null) return "";
|
|
114
|
+
if (typeof value === "boolean") return value ? "true" : "false";
|
|
115
|
+
return String(value).trim().toLowerCase().replace(/[_-]+/g, " ").replace(/\s+/g, " ");
|
|
116
|
+
};
|
|
117
|
+
var matchesAny = (value, matchers) => matchers.some((matcher) => {
|
|
118
|
+
if (value === matcher) return true;
|
|
119
|
+
return ` ${value} `.includes(` ${matcher} `);
|
|
120
|
+
});
|
|
121
|
+
var getSemanticVariant = (value, options = {}) => {
|
|
122
|
+
const normalized = normalizeTagValue(value);
|
|
123
|
+
const fallback = options.fallback || DEFAULT_VARIANT;
|
|
124
|
+
if (!normalized) return fallback;
|
|
125
|
+
if (options.overrides) {
|
|
126
|
+
const overrideKey = Object.keys(options.overrides).find(
|
|
127
|
+
(key) => normalizeTagValue(key) === normalized
|
|
128
|
+
);
|
|
129
|
+
if (overrideKey) return options.overrides[overrideKey];
|
|
130
|
+
}
|
|
131
|
+
if (normalized === "true") return "success";
|
|
132
|
+
if (normalized === "false") return fallback;
|
|
133
|
+
if (matchesAny(normalized, SUCCESS_MATCHERS)) return "success";
|
|
134
|
+
if (matchesAny(normalized, DANGER_MATCHERS)) return DANGER_VARIANT;
|
|
135
|
+
if (matchesAny(normalized, WARNING_MATCHERS)) return "warning";
|
|
136
|
+
if (matchesAny(normalized, INFO_MATCHERS)) return "info";
|
|
137
|
+
return fallback;
|
|
138
|
+
};
|
|
139
|
+
var getAutoTagVariant = (value, options = {}) => {
|
|
140
|
+
const semanticVariant = getSemanticVariant(value, options);
|
|
141
|
+
return semanticVariant === DANGER_VARIANT ? ERROR_VARIANT : semanticVariant;
|
|
142
|
+
};
|
|
143
|
+
var getAutoStatusTagVariant = (value, options = {}) => getSemanticVariant(value, options);
|
|
144
|
+
var getAutoTagDisplayValue = (value) => {
|
|
145
|
+
if (typeof value === "boolean") return value ? "True" : "False";
|
|
146
|
+
return value;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// src/common-components/AutoTag.js
|
|
150
|
+
var AutoTag = ({
|
|
151
|
+
value,
|
|
152
|
+
tag,
|
|
153
|
+
children,
|
|
154
|
+
variant,
|
|
155
|
+
overrides,
|
|
156
|
+
fallback,
|
|
157
|
+
...props
|
|
158
|
+
}) => {
|
|
159
|
+
const resolvedValue = value ?? tag ?? children;
|
|
160
|
+
const displayValue = children ?? getAutoTagDisplayValue(resolvedValue);
|
|
161
|
+
const resolvedVariant = variant || getAutoTagVariant(resolvedValue, {
|
|
162
|
+
overrides,
|
|
163
|
+
fallback
|
|
164
|
+
});
|
|
165
|
+
return import_react.default.createElement(
|
|
166
|
+
import_ui_extensions.Tag,
|
|
167
|
+
{ variant: resolvedVariant, ...props },
|
|
168
|
+
displayValue
|
|
169
|
+
);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// src/common-components/AutoStatusTag.js
|
|
173
|
+
var import_react2 = __toESM(require("react"));
|
|
174
|
+
var import_ui_extensions2 = require("@hubspot/ui-extensions");
|
|
175
|
+
var AutoStatusTag = ({
|
|
176
|
+
value,
|
|
177
|
+
status,
|
|
178
|
+
children,
|
|
179
|
+
variant,
|
|
180
|
+
overrides,
|
|
181
|
+
fallback,
|
|
182
|
+
...props
|
|
183
|
+
}) => {
|
|
184
|
+
const resolvedValue = value ?? status ?? children;
|
|
185
|
+
const displayValue = children ?? getAutoTagDisplayValue(resolvedValue);
|
|
186
|
+
const resolvedVariant = variant || getAutoStatusTagVariant(resolvedValue, {
|
|
187
|
+
overrides,
|
|
188
|
+
fallback
|
|
189
|
+
});
|
|
190
|
+
return import_react2.default.createElement(
|
|
191
|
+
import_ui_extensions2.StatusTag,
|
|
192
|
+
{ variant: resolvedVariant, ...props },
|
|
193
|
+
displayValue
|
|
194
|
+
);
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// src/common-components/KeyValueList.js
|
|
198
|
+
var import_react3 = __toESM(require("react"));
|
|
199
|
+
var import_ui_extensions3 = require("@hubspot/ui-extensions");
|
|
200
|
+
var KeyValueList = ({ items = [], direction = "row", gap = "sm" }) => {
|
|
201
|
+
const rows = items.map(
|
|
202
|
+
(item, index) => import_react3.default.createElement(
|
|
203
|
+
import_ui_extensions3.DescriptionListItem,
|
|
204
|
+
{
|
|
205
|
+
key: item.key ?? item.label ?? `kv-${index}`,
|
|
206
|
+
label: item.label
|
|
207
|
+
},
|
|
208
|
+
item.value
|
|
209
|
+
)
|
|
210
|
+
);
|
|
211
|
+
return import_react3.default.createElement(
|
|
212
|
+
import_ui_extensions3.Flex,
|
|
213
|
+
{ direction: "column", gap },
|
|
214
|
+
import_react3.default.createElement(import_ui_extensions3.DescriptionList, { direction }, ...rows)
|
|
215
|
+
);
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// src/common-components/SectionHeader.js
|
|
219
|
+
var import_react4 = __toESM(require("react"));
|
|
220
|
+
var import_ui_extensions4 = require("@hubspot/ui-extensions");
|
|
221
|
+
var SectionHeader = ({
|
|
222
|
+
title,
|
|
223
|
+
description,
|
|
224
|
+
actions,
|
|
225
|
+
children,
|
|
226
|
+
gap = "xs",
|
|
227
|
+
titleAs = "h2"
|
|
228
|
+
}) => {
|
|
229
|
+
const body = [];
|
|
230
|
+
if (title != null) {
|
|
231
|
+
body.push(import_react4.default.createElement(import_ui_extensions4.Heading, { key: "title", as: titleAs }, title));
|
|
232
|
+
}
|
|
233
|
+
if (description != null) {
|
|
234
|
+
body.push(
|
|
235
|
+
import_react4.default.createElement(
|
|
236
|
+
import_ui_extensions4.Text,
|
|
237
|
+
{ key: "description", variant: "microcopy" },
|
|
238
|
+
description
|
|
239
|
+
)
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
if (children != null) {
|
|
243
|
+
body.push(children);
|
|
244
|
+
}
|
|
245
|
+
const content = import_react4.default.createElement(import_ui_extensions4.Flex, { direction: "column", gap }, ...body);
|
|
246
|
+
if (actions == null) return content;
|
|
247
|
+
return import_react4.default.createElement(
|
|
248
|
+
import_ui_extensions4.Flex,
|
|
249
|
+
{ direction: "row", justify: "between", align: "start", gap: "sm" },
|
|
250
|
+
content,
|
|
251
|
+
actions
|
|
252
|
+
);
|
|
253
|
+
};
|
|
254
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
255
|
+
0 && (module.exports = {
|
|
256
|
+
AutoStatusTag,
|
|
257
|
+
AutoTag,
|
|
258
|
+
KeyValueList,
|
|
259
|
+
SectionHeader
|
|
260
|
+
});
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// src/common-components/AutoTag.js
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Tag } from "@hubspot/ui-extensions";
|
|
4
|
+
|
|
5
|
+
// src/utils/tagVariants.js
|
|
6
|
+
var DEFAULT_VARIANT = "default";
|
|
7
|
+
var DANGER_VARIANT = "danger";
|
|
8
|
+
var ERROR_VARIANT = "error";
|
|
9
|
+
var SUCCESS_MATCHERS = [
|
|
10
|
+
"active",
|
|
11
|
+
"success",
|
|
12
|
+
"succeeded",
|
|
13
|
+
"complete",
|
|
14
|
+
"completed",
|
|
15
|
+
"approved",
|
|
16
|
+
"won",
|
|
17
|
+
"healthy",
|
|
18
|
+
"enabled",
|
|
19
|
+
"connected",
|
|
20
|
+
"paid",
|
|
21
|
+
"live",
|
|
22
|
+
"published",
|
|
23
|
+
"available",
|
|
24
|
+
"synced",
|
|
25
|
+
"resolved"
|
|
26
|
+
];
|
|
27
|
+
var WARNING_MATCHERS = [
|
|
28
|
+
"warning",
|
|
29
|
+
"at risk",
|
|
30
|
+
"risky",
|
|
31
|
+
"pending",
|
|
32
|
+
"paused",
|
|
33
|
+
"pause",
|
|
34
|
+
"on hold",
|
|
35
|
+
"hold",
|
|
36
|
+
"review",
|
|
37
|
+
"expiring",
|
|
38
|
+
"trial",
|
|
39
|
+
"in progress",
|
|
40
|
+
"awaiting",
|
|
41
|
+
"scheduled"
|
|
42
|
+
];
|
|
43
|
+
var DANGER_MATCHERS = [
|
|
44
|
+
"danger",
|
|
45
|
+
"error",
|
|
46
|
+
"failed",
|
|
47
|
+
"failure",
|
|
48
|
+
"inactive",
|
|
49
|
+
"disabled",
|
|
50
|
+
"blocked",
|
|
51
|
+
"cancelled",
|
|
52
|
+
"canceled",
|
|
53
|
+
"rejected",
|
|
54
|
+
"denied",
|
|
55
|
+
"churned",
|
|
56
|
+
"lost",
|
|
57
|
+
"overdue",
|
|
58
|
+
"expired",
|
|
59
|
+
"offline",
|
|
60
|
+
"deleted",
|
|
61
|
+
"archived",
|
|
62
|
+
"unpaid"
|
|
63
|
+
];
|
|
64
|
+
var INFO_MATCHERS = [
|
|
65
|
+
"info",
|
|
66
|
+
"new",
|
|
67
|
+
"queued",
|
|
68
|
+
"processing",
|
|
69
|
+
"progress",
|
|
70
|
+
"upcoming",
|
|
71
|
+
"draft",
|
|
72
|
+
"open"
|
|
73
|
+
];
|
|
74
|
+
var normalizeTagValue = (value) => {
|
|
75
|
+
if (value == null) return "";
|
|
76
|
+
if (typeof value === "boolean") return value ? "true" : "false";
|
|
77
|
+
return String(value).trim().toLowerCase().replace(/[_-]+/g, " ").replace(/\s+/g, " ");
|
|
78
|
+
};
|
|
79
|
+
var matchesAny = (value, matchers) => matchers.some((matcher) => {
|
|
80
|
+
if (value === matcher) return true;
|
|
81
|
+
return ` ${value} `.includes(` ${matcher} `);
|
|
82
|
+
});
|
|
83
|
+
var getSemanticVariant = (value, options = {}) => {
|
|
84
|
+
const normalized = normalizeTagValue(value);
|
|
85
|
+
const fallback = options.fallback || DEFAULT_VARIANT;
|
|
86
|
+
if (!normalized) return fallback;
|
|
87
|
+
if (options.overrides) {
|
|
88
|
+
const overrideKey = Object.keys(options.overrides).find(
|
|
89
|
+
(key) => normalizeTagValue(key) === normalized
|
|
90
|
+
);
|
|
91
|
+
if (overrideKey) return options.overrides[overrideKey];
|
|
92
|
+
}
|
|
93
|
+
if (normalized === "true") return "success";
|
|
94
|
+
if (normalized === "false") return fallback;
|
|
95
|
+
if (matchesAny(normalized, SUCCESS_MATCHERS)) return "success";
|
|
96
|
+
if (matchesAny(normalized, DANGER_MATCHERS)) return DANGER_VARIANT;
|
|
97
|
+
if (matchesAny(normalized, WARNING_MATCHERS)) return "warning";
|
|
98
|
+
if (matchesAny(normalized, INFO_MATCHERS)) return "info";
|
|
99
|
+
return fallback;
|
|
100
|
+
};
|
|
101
|
+
var getAutoTagVariant = (value, options = {}) => {
|
|
102
|
+
const semanticVariant = getSemanticVariant(value, options);
|
|
103
|
+
return semanticVariant === DANGER_VARIANT ? ERROR_VARIANT : semanticVariant;
|
|
104
|
+
};
|
|
105
|
+
var getAutoStatusTagVariant = (value, options = {}) => getSemanticVariant(value, options);
|
|
106
|
+
var getAutoTagDisplayValue = (value) => {
|
|
107
|
+
if (typeof value === "boolean") return value ? "True" : "False";
|
|
108
|
+
return value;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// src/common-components/AutoTag.js
|
|
112
|
+
var AutoTag = ({
|
|
113
|
+
value,
|
|
114
|
+
tag,
|
|
115
|
+
children,
|
|
116
|
+
variant,
|
|
117
|
+
overrides,
|
|
118
|
+
fallback,
|
|
119
|
+
...props
|
|
120
|
+
}) => {
|
|
121
|
+
const resolvedValue = value ?? tag ?? children;
|
|
122
|
+
const displayValue = children ?? getAutoTagDisplayValue(resolvedValue);
|
|
123
|
+
const resolvedVariant = variant || getAutoTagVariant(resolvedValue, {
|
|
124
|
+
overrides,
|
|
125
|
+
fallback
|
|
126
|
+
});
|
|
127
|
+
return React.createElement(
|
|
128
|
+
Tag,
|
|
129
|
+
{ variant: resolvedVariant, ...props },
|
|
130
|
+
displayValue
|
|
131
|
+
);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// src/common-components/AutoStatusTag.js
|
|
135
|
+
import React2 from "react";
|
|
136
|
+
import { StatusTag } from "@hubspot/ui-extensions";
|
|
137
|
+
var AutoStatusTag = ({
|
|
138
|
+
value,
|
|
139
|
+
status,
|
|
140
|
+
children,
|
|
141
|
+
variant,
|
|
142
|
+
overrides,
|
|
143
|
+
fallback,
|
|
144
|
+
...props
|
|
145
|
+
}) => {
|
|
146
|
+
const resolvedValue = value ?? status ?? children;
|
|
147
|
+
const displayValue = children ?? getAutoTagDisplayValue(resolvedValue);
|
|
148
|
+
const resolvedVariant = variant || getAutoStatusTagVariant(resolvedValue, {
|
|
149
|
+
overrides,
|
|
150
|
+
fallback
|
|
151
|
+
});
|
|
152
|
+
return React2.createElement(
|
|
153
|
+
StatusTag,
|
|
154
|
+
{ variant: resolvedVariant, ...props },
|
|
155
|
+
displayValue
|
|
156
|
+
);
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
// src/common-components/KeyValueList.js
|
|
160
|
+
import React3 from "react";
|
|
161
|
+
import { DescriptionList, DescriptionListItem, Flex } from "@hubspot/ui-extensions";
|
|
162
|
+
var KeyValueList = ({ items = [], direction = "row", gap = "sm" }) => {
|
|
163
|
+
const rows = items.map(
|
|
164
|
+
(item, index) => React3.createElement(
|
|
165
|
+
DescriptionListItem,
|
|
166
|
+
{
|
|
167
|
+
key: item.key ?? item.label ?? `kv-${index}`,
|
|
168
|
+
label: item.label
|
|
169
|
+
},
|
|
170
|
+
item.value
|
|
171
|
+
)
|
|
172
|
+
);
|
|
173
|
+
return React3.createElement(
|
|
174
|
+
Flex,
|
|
175
|
+
{ direction: "column", gap },
|
|
176
|
+
React3.createElement(DescriptionList, { direction }, ...rows)
|
|
177
|
+
);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// src/common-components/SectionHeader.js
|
|
181
|
+
import React4 from "react";
|
|
182
|
+
import { Flex as Flex2, Heading, Text } from "@hubspot/ui-extensions";
|
|
183
|
+
var SectionHeader = ({
|
|
184
|
+
title,
|
|
185
|
+
description,
|
|
186
|
+
actions,
|
|
187
|
+
children,
|
|
188
|
+
gap = "xs",
|
|
189
|
+
titleAs = "h2"
|
|
190
|
+
}) => {
|
|
191
|
+
const body = [];
|
|
192
|
+
if (title != null) {
|
|
193
|
+
body.push(React4.createElement(Heading, { key: "title", as: titleAs }, title));
|
|
194
|
+
}
|
|
195
|
+
if (description != null) {
|
|
196
|
+
body.push(
|
|
197
|
+
React4.createElement(
|
|
198
|
+
Text,
|
|
199
|
+
{ key: "description", variant: "microcopy" },
|
|
200
|
+
description
|
|
201
|
+
)
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
if (children != null) {
|
|
205
|
+
body.push(children);
|
|
206
|
+
}
|
|
207
|
+
const content = React4.createElement(Flex2, { direction: "column", gap }, ...body);
|
|
208
|
+
if (actions == null) return content;
|
|
209
|
+
return React4.createElement(
|
|
210
|
+
Flex2,
|
|
211
|
+
{ direction: "row", justify: "between", align: "start", gap: "sm" },
|
|
212
|
+
content,
|
|
213
|
+
actions
|
|
214
|
+
);
|
|
215
|
+
};
|
|
216
|
+
export {
|
|
217
|
+
AutoStatusTag,
|
|
218
|
+
AutoTag,
|
|
219
|
+
KeyValueList,
|
|
220
|
+
SectionHeader
|
|
221
|
+
};
|