strapi-plugin-hubspot 0.4.2 → 0.6.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 (54) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +116 -4
  3. package/dist/_chunks/Forms-BF4_zA-m.js +1007 -0
  4. package/dist/_chunks/Forms-CW1KFO9U.mjs +989 -0
  5. package/dist/_chunks/{HubspotObjectInput-DutelVp6.mjs → HubspotObjectInput-CpxeM2J0.mjs} +4 -16
  6. package/dist/_chunks/{HubspotObjectInput-Br2jTFkG.js → HubspotObjectInput-hjAYWtaU.js} +4 -16
  7. package/dist/_chunks/HubspotPropertyInput-C-52Lu24.mjs +227 -0
  8. package/dist/_chunks/HubspotPropertyInput-OSeIBaRC.js +245 -0
  9. package/dist/_chunks/Settings-2V7TH5CX.mjs +321 -0
  10. package/dist/_chunks/Settings-DcA9M5Tw.js +339 -0
  11. package/dist/_chunks/en-CJ9wYHgN.mjs +197 -0
  12. package/dist/_chunks/en-C_-N8cjv.js +197 -0
  13. package/dist/_chunks/fr-BHObPoUp.js +197 -0
  14. package/dist/_chunks/fr-DttDn-2Y.mjs +197 -0
  15. package/dist/_chunks/{Settings-CQsB0B2T.mjs → index-C1UJXE_o.mjs} +576 -317
  16. package/dist/_chunks/{index-BUlB1rK9.js → index-CMzg-x5i.js} +12 -4
  17. package/dist/_chunks/{Settings-CvbKVl-t.js → index-Dgbid2LK.js} +580 -322
  18. package/dist/_chunks/{index-CKoBcX1T.mjs → index-DkGOTp8p.mjs} +12 -4
  19. package/dist/_chunks/{objectLabels-dM4o67Fz.mjs → objectLabels-D9UEuOGr.mjs} +1 -1
  20. package/dist/_chunks/{objectLabels-B76t8qqg.js → objectLabels-Th7aYW-B.js} +1 -1
  21. package/dist/_chunks/useHubspotSchema-Bgrgg8Mt.js +75 -0
  22. package/dist/_chunks/useHubspotSchema-DQkQcA_V.mjs +58 -0
  23. package/dist/admin/index.js +2 -1
  24. package/dist/admin/index.mjs +2 -1
  25. package/dist/admin/src/builder/ConditionEditor.d.ts +17 -0
  26. package/dist/admin/src/builder/FieldPanel.d.ts +16 -0
  27. package/dist/admin/src/builder/types.d.ts +90 -0
  28. package/dist/admin/src/index.d.ts +1 -0
  29. package/dist/admin/src/pages/FormEditor.d.ts +9 -0
  30. package/dist/admin/src/pages/Forms.d.ts +4 -0
  31. package/dist/admin/src/pages/FormsList.d.ts +8 -0
  32. package/dist/admin/src/useHubspotSchema.d.ts +28 -0
  33. package/dist/server/index.js +880 -5
  34. package/dist/server/index.mjs +880 -5
  35. package/dist/server/src/__tests__/conditions.test.d.ts +1 -0
  36. package/dist/server/src/__tests__/forms.test.d.ts +1 -0
  37. package/dist/server/src/__tests__/formsSubmit.test.d.ts +1 -0
  38. package/dist/server/src/__tests__/importLegacy.test.d.ts +1 -0
  39. package/dist/server/src/conditions.d.ts +88 -0
  40. package/dist/server/src/content-types.d.ts +161 -9
  41. package/dist/server/src/forms.d.ts +81 -0
  42. package/dist/server/src/formsAdmin.d.ts +39 -0
  43. package/dist/server/src/importLegacy.d.ts +25 -0
  44. package/dist/server/src/index.d.ts +214 -16
  45. package/dist/shared/types.d.ts +103 -0
  46. package/dist/shared/types.js +2 -0
  47. package/dist/shared/types.mjs +2 -0
  48. package/package.json +23 -6
  49. package/dist/_chunks/HubspotPropertyInput-CK6Yj9rC.mjs +0 -177
  50. package/dist/_chunks/HubspotPropertyInput-DIPDPRXJ.js +0 -195
  51. package/dist/_chunks/en-D4ueeUcJ.mjs +0 -82
  52. package/dist/_chunks/en-PBG7-vMR.js +0 -82
  53. package/dist/_chunks/fr-DL4wdV8I.js +0 -82
  54. package/dist/_chunks/fr-DYnxVmIO.mjs +0 -82
@@ -1,26 +1,14 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
- import { u as useIntl, o as objectLabel } from "./objectLabels-dM4o67Fz.mjs";
3
+ import { u as useIntl, o as objectLabel } from "./objectLabels-D9UEuOGr.mjs";
4
4
  import { Field, Flex, Loader, SingleSelect, SingleSelectOption } from "@strapi/design-system";
5
- import { useFetchClient } from "@strapi/strapi/admin";
6
- import { P as PLUGIN_ID, g as getTranslation } from "./index-CKoBcX1T.mjs";
5
+ import { g as getTranslation } from "./index-DkGOTp8p.mjs";
6
+ import { u as useHubspotSchema } from "./useHubspotSchema-DQkQcA_V.mjs";
7
7
  const HubspotObjectInput = React.forwardRef(
8
8
  ({ name, value, onChange, disabled, error, required, label, hint, labelAction }, ref) => {
9
9
  const intl = useIntl();
10
10
  const { formatMessage } = intl;
11
- const { get } = useFetchClient();
12
- const [schema, setSchema] = React.useState(null);
13
- React.useEffect(() => {
14
- let cancelled = false;
15
- get(`/${PLUGIN_ID}/properties`).then(({ data }) => {
16
- if (!cancelled) setSchema(data);
17
- }).catch(() => {
18
- if (!cancelled) setSchema({ configured: false, objects: [], unavailable: [] });
19
- });
20
- return () => {
21
- cancelled = true;
22
- };
23
- }, [get]);
11
+ const { schema } = useHubspotSchema();
24
12
  const emit = (next) => onChange({ target: { name, value: String(next ?? ""), type: "string" } });
25
13
  const known = [
26
14
  ...schema?.objects ?? [],
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
- const objectLabels = require("./objectLabels-B76t8qqg.js");
5
+ const objectLabels = require("./objectLabels-Th7aYW-B.js");
6
6
  const designSystem = require("@strapi/design-system");
7
- const admin = require("@strapi/strapi/admin");
8
- const index = require("./index-BUlB1rK9.js");
7
+ const index = require("./index-CMzg-x5i.js");
8
+ const useHubspotSchema = require("./useHubspotSchema-Bgrgg8Mt.js");
9
9
  function _interopNamespace(e) {
10
10
  if (e && e.__esModule) return e;
11
11
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -28,19 +28,7 @@ const HubspotObjectInput = React__namespace.forwardRef(
28
28
  ({ name, value, onChange, disabled, error, required, label, hint, labelAction }, ref) => {
29
29
  const intl = objectLabels.useIntl();
30
30
  const { formatMessage } = intl;
31
- const { get } = admin.useFetchClient();
32
- const [schema, setSchema] = React__namespace.useState(null);
33
- React__namespace.useEffect(() => {
34
- let cancelled = false;
35
- get(`/${index.PLUGIN_ID}/properties`).then(({ data }) => {
36
- if (!cancelled) setSchema(data);
37
- }).catch(() => {
38
- if (!cancelled) setSchema({ configured: false, objects: [], unavailable: [] });
39
- });
40
- return () => {
41
- cancelled = true;
42
- };
43
- }, [get]);
31
+ const { schema } = useHubspotSchema.useHubspotSchema();
44
32
  const emit = (next) => onChange({ target: { name, value: String(next ?? ""), type: "string" } });
45
33
  const known = [
46
34
  ...schema?.objects ?? [],
@@ -0,0 +1,227 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { u as useIntl, o as objectLabel } from "./objectLabels-D9UEuOGr.mjs";
4
+ import { Field, Flex, Loader, Combobox, ComboboxOption, IconButton, Button, Typography, Link } from "@strapi/design-system";
5
+ import { ArrowClockwise } from "@strapi/icons";
6
+ import { useField } from "@strapi/strapi/admin";
7
+ import { g as getTranslation } from "./index-DkGOTp8p.mjs";
8
+ import { u as useHubspotSchema } from "./useHubspotSchema-DQkQcA_V.mjs";
9
+ const oneLine = {
10
+ display: "block",
11
+ whiteSpace: "nowrap",
12
+ overflow: "hidden",
13
+ textOverflow: "ellipsis"
14
+ };
15
+ const HubspotPropertyInput = React.forwardRef(
16
+ ({
17
+ name,
18
+ value,
19
+ onChange,
20
+ attribute,
21
+ disabled,
22
+ error,
23
+ required,
24
+ label,
25
+ hint,
26
+ labelAction
27
+ }, ref) => {
28
+ const intl = useIntl();
29
+ const { formatMessage } = intl;
30
+ const { schema, loadError, refresh, refreshing } = useHubspotSchema();
31
+ const objectFieldName = attribute?.options?.objectField || "hsObject";
32
+ const siblingPath = React.useMemo(
33
+ () => name.replace(/[^.]+$/, objectFieldName),
34
+ [name, objectFieldName]
35
+ );
36
+ const siblingField = useField(siblingPath);
37
+ const selectedObject = siblingField?.value;
38
+ const optionsFieldName = attribute?.options?.optionsField || "options";
39
+ const optionsPath = React.useMemo(
40
+ () => name.replace(/[^.]+$/, optionsFieldName),
41
+ [name, optionsFieldName]
42
+ );
43
+ const optionsField = useField(optionsPath);
44
+ const [imported, setImported] = React.useState(false);
45
+ const emit = (next) => onChange({ target: { name, value: next ?? "", type: "string" } });
46
+ const previousObject = React.useRef(selectedObject);
47
+ React.useEffect(() => {
48
+ const previous = previousObject.current;
49
+ previousObject.current = selectedObject;
50
+ if (!previous || previous === selectedObject || !selectedObject) return;
51
+ if (!value || !schema?.configured) return;
52
+ const validHere = schema.properties.some(
53
+ (p) => p.object === selectedObject && p.name === value
54
+ );
55
+ if (!validHere) emit("");
56
+ }, [selectedObject]);
57
+ const options = React.useMemo(() => {
58
+ const all = schema?.properties ?? [];
59
+ const scoped = selectedObject ? all.filter((p) => p.object === selectedObject) : all;
60
+ const sorted = selectedObject ? [...scoped].sort(
61
+ (a, b) => (a.group ?? "").localeCompare(b.group ?? "") || a.label.localeCompare(b.label)
62
+ ) : scoped;
63
+ const shown = sorted.map((p) => ({
64
+ value: p.name,
65
+ label: selectedObject ? `${p.group ? `${p.group} • ` : ""}${p.label} (${p.name})` : `${objectLabel(intl, p.object)} • ${p.label} (${p.name})`
66
+ }));
67
+ if (value && !scoped.some((p) => p.name === value)) {
68
+ const elsewhere = all.find((p) => p.name === value);
69
+ shown.unshift({
70
+ value,
71
+ label: elsewhere ? formatMessage(
72
+ {
73
+ id: getTranslation("picker.belongs-to"),
74
+ defaultMessage: "{property} — belongs to {object}"
75
+ },
76
+ {
77
+ property: value,
78
+ object: objectLabel(intl, elsewhere.object)
79
+ }
80
+ ) : formatMessage(
81
+ {
82
+ id: getTranslation("picker.unknown"),
83
+ defaultMessage: "{property} — unknown to the portal"
84
+ },
85
+ { property: value }
86
+ )
87
+ });
88
+ }
89
+ return shown;
90
+ }, [schema, selectedObject, value, intl, formatMessage]);
91
+ const describe = () => {
92
+ if (loadError !== null) {
93
+ return loadError || formatMessage({
94
+ id: getTranslation("picker.load-error"),
95
+ defaultMessage: "HubSpot properties unavailable"
96
+ });
97
+ }
98
+ if (schema && !schema.configured) {
99
+ return formatMessage({
100
+ id: getTranslation("picker.not-configured"),
101
+ defaultMessage: "No HubSpot API key — free text. Set it in Settings → HubSpot."
102
+ });
103
+ }
104
+ if (selectedObject && schema?.unavailable.some((u) => u.object === selectedObject)) {
105
+ return formatMessage(
106
+ {
107
+ id: getTranslation("picker.object-unavailable"),
108
+ defaultMessage: "Properties of “{object}” unreadable — missing scope on the token."
109
+ },
110
+ { object: objectLabel(intl, selectedObject) }
111
+ );
112
+ }
113
+ return hint;
114
+ };
115
+ const crmLink = schema?.portalId && value && schema.properties.some((p) => p.name === value) ? `https://${schema.uiDomain || "app.hubspot.com"}/property-settings/${schema.portalId}/properties?search=${encodeURIComponent(value)}` : null;
116
+ const selectedProperty = value && schema ? schema.properties.find(
117
+ (p) => p.name === value && (!selectedObject || p.object === selectedObject)
118
+ ) : void 0;
119
+ const importable = selectedProperty?.type === "enumeration" && (selectedProperty.options?.length ?? 0) > 0;
120
+ React.useEffect(() => setImported(false), [value]);
121
+ const importOptions = () => {
122
+ if (!selectedProperty || !optionsField) return;
123
+ const rows = selectedProperty.options.map((o, i) => ({
124
+ __temp_key__: `a${i}`,
125
+ value: o.value,
126
+ label: o.label ?? o.value
127
+ }));
128
+ optionsField.onChange({
129
+ target: { name: optionsPath, value: rows, type: "json" }
130
+ });
131
+ setImported(true);
132
+ };
133
+ return /* @__PURE__ */ jsxs(
134
+ Field.Root,
135
+ {
136
+ name,
137
+ error,
138
+ hint: describe(),
139
+ required,
140
+ children: [
141
+ /* @__PURE__ */ jsx(Field.Label, { action: labelAction, children: label }),
142
+ !schema ? /* @__PURE__ */ jsx(Flex, { paddingTop: 2, paddingBottom: 2, children: /* @__PURE__ */ jsx(Loader, { small: true, children: formatMessage({
143
+ id: getTranslation("picker.loading"),
144
+ defaultMessage: "Loading HubSpot properties…"
145
+ }) }) }) : schema.configured ? /* @__PURE__ */ jsx(
146
+ Combobox,
147
+ {
148
+ ref,
149
+ value: value || "",
150
+ onChange: emit,
151
+ onClear: () => emit(""),
152
+ disabled,
153
+ placeholder: formatMessage({
154
+ id: getTranslation("picker.placeholder"),
155
+ defaultMessage: "Search a property…"
156
+ }),
157
+ autocomplete: { type: "list", filter: "contains" },
158
+ noOptionsMessage: () => formatMessage({
159
+ id: getTranslation("picker.no-results"),
160
+ defaultMessage: "No matching property — properties are managed in HubSpot."
161
+ }),
162
+ children: options.map((o) => /* @__PURE__ */ jsx(ComboboxOption, { value: o.value, textValue: o.label, children: /* @__PURE__ */ jsx("span", { title: o.label, style: oneLine, children: o.label }) }, o.value))
163
+ }
164
+ ) : /* @__PURE__ */ jsx(
165
+ Field.Input,
166
+ {
167
+ ref,
168
+ value: value || "",
169
+ onChange: (e) => emit(e.target.value),
170
+ disabled,
171
+ placeholder: formatMessage({
172
+ id: getTranslation("picker.free-placeholder"),
173
+ defaultMessage: "e.g. hs_role, numberofemployees"
174
+ })
175
+ }
176
+ ),
177
+ schema?.configured ? /* @__PURE__ */ jsxs(Flex, { paddingTop: 1, gap: 3, alignItems: "center", wrap: "wrap", children: [
178
+ /* @__PURE__ */ jsx(
179
+ IconButton,
180
+ {
181
+ label: formatMessage({
182
+ id: getTranslation("picker.refresh"),
183
+ defaultMessage: "Refresh the properties from HubSpot"
184
+ }),
185
+ variant: "ghost",
186
+ size: "XS",
187
+ onClick: refresh,
188
+ disabled: disabled || refreshing,
189
+ children: /* @__PURE__ */ jsx(ArrowClockwise, {})
190
+ }
191
+ ),
192
+ importable ? /* @__PURE__ */ jsx(
193
+ Button,
194
+ {
195
+ variant: "tertiary",
196
+ size: "S",
197
+ onClick: importOptions,
198
+ disabled,
199
+ children: formatMessage(
200
+ {
201
+ id: getTranslation("picker.import"),
202
+ defaultMessage: "Import the {count} options from HubSpot"
203
+ },
204
+ { count: selectedProperty?.options.length ?? 0 }
205
+ )
206
+ }
207
+ ) : null,
208
+ imported ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "success600", children: formatMessage({
209
+ id: getTranslation("picker.imported"),
210
+ defaultMessage: "Options imported — save to keep them."
211
+ }) }) : null,
212
+ crmLink ? /* @__PURE__ */ jsx(Link, { href: crmLink, isExternal: true, children: formatMessage({
213
+ id: getTranslation("picker.view"),
214
+ defaultMessage: "View in HubSpot"
215
+ }) }) : null
216
+ ] }) : null,
217
+ /* @__PURE__ */ jsx(Field.Hint, {}),
218
+ /* @__PURE__ */ jsx(Field.Error, {})
219
+ ]
220
+ }
221
+ );
222
+ }
223
+ );
224
+ HubspotPropertyInput.displayName = "HubspotPropertyInput";
225
+ export {
226
+ HubspotPropertyInput as default
227
+ };
@@ -0,0 +1,245 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const objectLabels = require("./objectLabels-Th7aYW-B.js");
6
+ const designSystem = require("@strapi/design-system");
7
+ const icons = require("@strapi/icons");
8
+ const admin = require("@strapi/strapi/admin");
9
+ const index = require("./index-CMzg-x5i.js");
10
+ const useHubspotSchema = require("./useHubspotSchema-Bgrgg8Mt.js");
11
+ function _interopNamespace(e) {
12
+ if (e && e.__esModule) return e;
13
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
14
+ if (e) {
15
+ for (const k in e) {
16
+ if (k !== "default") {
17
+ const d = Object.getOwnPropertyDescriptor(e, k);
18
+ Object.defineProperty(n, k, d.get ? d : {
19
+ enumerable: true,
20
+ get: () => e[k]
21
+ });
22
+ }
23
+ }
24
+ }
25
+ n.default = e;
26
+ return Object.freeze(n);
27
+ }
28
+ const React__namespace = /* @__PURE__ */ _interopNamespace(React);
29
+ const oneLine = {
30
+ display: "block",
31
+ whiteSpace: "nowrap",
32
+ overflow: "hidden",
33
+ textOverflow: "ellipsis"
34
+ };
35
+ const HubspotPropertyInput = React__namespace.forwardRef(
36
+ ({
37
+ name,
38
+ value,
39
+ onChange,
40
+ attribute,
41
+ disabled,
42
+ error,
43
+ required,
44
+ label,
45
+ hint,
46
+ labelAction
47
+ }, ref) => {
48
+ const intl = objectLabels.useIntl();
49
+ const { formatMessage } = intl;
50
+ const { schema, loadError, refresh, refreshing } = useHubspotSchema.useHubspotSchema();
51
+ const objectFieldName = attribute?.options?.objectField || "hsObject";
52
+ const siblingPath = React__namespace.useMemo(
53
+ () => name.replace(/[^.]+$/, objectFieldName),
54
+ [name, objectFieldName]
55
+ );
56
+ const siblingField = admin.useField(siblingPath);
57
+ const selectedObject = siblingField?.value;
58
+ const optionsFieldName = attribute?.options?.optionsField || "options";
59
+ const optionsPath = React__namespace.useMemo(
60
+ () => name.replace(/[^.]+$/, optionsFieldName),
61
+ [name, optionsFieldName]
62
+ );
63
+ const optionsField = admin.useField(optionsPath);
64
+ const [imported, setImported] = React__namespace.useState(false);
65
+ const emit = (next) => onChange({ target: { name, value: next ?? "", type: "string" } });
66
+ const previousObject = React__namespace.useRef(selectedObject);
67
+ React__namespace.useEffect(() => {
68
+ const previous = previousObject.current;
69
+ previousObject.current = selectedObject;
70
+ if (!previous || previous === selectedObject || !selectedObject) return;
71
+ if (!value || !schema?.configured) return;
72
+ const validHere = schema.properties.some(
73
+ (p) => p.object === selectedObject && p.name === value
74
+ );
75
+ if (!validHere) emit("");
76
+ }, [selectedObject]);
77
+ const options = React__namespace.useMemo(() => {
78
+ const all = schema?.properties ?? [];
79
+ const scoped = selectedObject ? all.filter((p) => p.object === selectedObject) : all;
80
+ const sorted = selectedObject ? [...scoped].sort(
81
+ (a, b) => (a.group ?? "").localeCompare(b.group ?? "") || a.label.localeCompare(b.label)
82
+ ) : scoped;
83
+ const shown = sorted.map((p) => ({
84
+ value: p.name,
85
+ label: selectedObject ? `${p.group ? `${p.group} • ` : ""}${p.label} (${p.name})` : `${objectLabels.objectLabel(intl, p.object)} • ${p.label} (${p.name})`
86
+ }));
87
+ if (value && !scoped.some((p) => p.name === value)) {
88
+ const elsewhere = all.find((p) => p.name === value);
89
+ shown.unshift({
90
+ value,
91
+ label: elsewhere ? formatMessage(
92
+ {
93
+ id: index.getTranslation("picker.belongs-to"),
94
+ defaultMessage: "{property} — belongs to {object}"
95
+ },
96
+ {
97
+ property: value,
98
+ object: objectLabels.objectLabel(intl, elsewhere.object)
99
+ }
100
+ ) : formatMessage(
101
+ {
102
+ id: index.getTranslation("picker.unknown"),
103
+ defaultMessage: "{property} — unknown to the portal"
104
+ },
105
+ { property: value }
106
+ )
107
+ });
108
+ }
109
+ return shown;
110
+ }, [schema, selectedObject, value, intl, formatMessage]);
111
+ const describe = () => {
112
+ if (loadError !== null) {
113
+ return loadError || formatMessage({
114
+ id: index.getTranslation("picker.load-error"),
115
+ defaultMessage: "HubSpot properties unavailable"
116
+ });
117
+ }
118
+ if (schema && !schema.configured) {
119
+ return formatMessage({
120
+ id: index.getTranslation("picker.not-configured"),
121
+ defaultMessage: "No HubSpot API key — free text. Set it in Settings → HubSpot."
122
+ });
123
+ }
124
+ if (selectedObject && schema?.unavailable.some((u) => u.object === selectedObject)) {
125
+ return formatMessage(
126
+ {
127
+ id: index.getTranslation("picker.object-unavailable"),
128
+ defaultMessage: "Properties of “{object}” unreadable — missing scope on the token."
129
+ },
130
+ { object: objectLabels.objectLabel(intl, selectedObject) }
131
+ );
132
+ }
133
+ return hint;
134
+ };
135
+ const crmLink = schema?.portalId && value && schema.properties.some((p) => p.name === value) ? `https://${schema.uiDomain || "app.hubspot.com"}/property-settings/${schema.portalId}/properties?search=${encodeURIComponent(value)}` : null;
136
+ const selectedProperty = value && schema ? schema.properties.find(
137
+ (p) => p.name === value && (!selectedObject || p.object === selectedObject)
138
+ ) : void 0;
139
+ const importable = selectedProperty?.type === "enumeration" && (selectedProperty.options?.length ?? 0) > 0;
140
+ React__namespace.useEffect(() => setImported(false), [value]);
141
+ const importOptions = () => {
142
+ if (!selectedProperty || !optionsField) return;
143
+ const rows = selectedProperty.options.map((o, i) => ({
144
+ __temp_key__: `a${i}`,
145
+ value: o.value,
146
+ label: o.label ?? o.value
147
+ }));
148
+ optionsField.onChange({
149
+ target: { name: optionsPath, value: rows, type: "json" }
150
+ });
151
+ setImported(true);
152
+ };
153
+ return /* @__PURE__ */ jsxRuntime.jsxs(
154
+ designSystem.Field.Root,
155
+ {
156
+ name,
157
+ error,
158
+ hint: describe(),
159
+ required,
160
+ children: [
161
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { action: labelAction, children: label }),
162
+ !schema ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { paddingTop: 2, paddingBottom: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, children: formatMessage({
163
+ id: index.getTranslation("picker.loading"),
164
+ defaultMessage: "Loading HubSpot properties…"
165
+ }) }) }) : schema.configured ? /* @__PURE__ */ jsxRuntime.jsx(
166
+ designSystem.Combobox,
167
+ {
168
+ ref,
169
+ value: value || "",
170
+ onChange: emit,
171
+ onClear: () => emit(""),
172
+ disabled,
173
+ placeholder: formatMessage({
174
+ id: index.getTranslation("picker.placeholder"),
175
+ defaultMessage: "Search a property…"
176
+ }),
177
+ autocomplete: { type: "list", filter: "contains" },
178
+ noOptionsMessage: () => formatMessage({
179
+ id: index.getTranslation("picker.no-results"),
180
+ defaultMessage: "No matching property — properties are managed in HubSpot."
181
+ }),
182
+ children: options.map((o) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.ComboboxOption, { value: o.value, textValue: o.label, children: /* @__PURE__ */ jsxRuntime.jsx("span", { title: o.label, style: oneLine, children: o.label }) }, o.value))
183
+ }
184
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
185
+ designSystem.Field.Input,
186
+ {
187
+ ref,
188
+ value: value || "",
189
+ onChange: (e) => emit(e.target.value),
190
+ disabled,
191
+ placeholder: formatMessage({
192
+ id: index.getTranslation("picker.free-placeholder"),
193
+ defaultMessage: "e.g. hs_role, numberofemployees"
194
+ })
195
+ }
196
+ ),
197
+ schema?.configured ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { paddingTop: 1, gap: 3, alignItems: "center", wrap: "wrap", children: [
198
+ /* @__PURE__ */ jsxRuntime.jsx(
199
+ designSystem.IconButton,
200
+ {
201
+ label: formatMessage({
202
+ id: index.getTranslation("picker.refresh"),
203
+ defaultMessage: "Refresh the properties from HubSpot"
204
+ }),
205
+ variant: "ghost",
206
+ size: "XS",
207
+ onClick: refresh,
208
+ disabled: disabled || refreshing,
209
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowClockwise, {})
210
+ }
211
+ ),
212
+ importable ? /* @__PURE__ */ jsxRuntime.jsx(
213
+ designSystem.Button,
214
+ {
215
+ variant: "tertiary",
216
+ size: "S",
217
+ onClick: importOptions,
218
+ disabled,
219
+ children: formatMessage(
220
+ {
221
+ id: index.getTranslation("picker.import"),
222
+ defaultMessage: "Import the {count} options from HubSpot"
223
+ },
224
+ { count: selectedProperty?.options.length ?? 0 }
225
+ )
226
+ }
227
+ ) : null,
228
+ imported ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "success600", children: formatMessage({
229
+ id: index.getTranslation("picker.imported"),
230
+ defaultMessage: "Options imported — save to keep them."
231
+ }) }) : null,
232
+ crmLink ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Link, { href: crmLink, isExternal: true, children: formatMessage({
233
+ id: index.getTranslation("picker.view"),
234
+ defaultMessage: "View in HubSpot"
235
+ }) }) : null
236
+ ] }) : null,
237
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {}),
238
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
239
+ ]
240
+ }
241
+ );
242
+ }
243
+ );
244
+ HubspotPropertyInput.displayName = "HubspotPropertyInput";
245
+ exports.default = HubspotPropertyInput;