@squaredr/fieldcraft-pro 1.5.0 → 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/index.js CHANGED
@@ -5048,58 +5048,6 @@ function FormBuilderInner(props) {
5048
5048
 
5049
5049
  // src/form-builder/components/FormBuilderGated.tsx
5050
5050
  var FormBuilder = requireLicense(FormBuilderInner, "FormBuilder");
5051
-
5052
- // src/form-builder/theme/presets.ts
5053
- var squaredrDarkPreset = {
5054
- background: "#0F1A1F",
5055
- foreground: "#E8EFF1",
5056
- card: "#16242A",
5057
- primary: "#63BDB4",
5058
- primaryForeground: "#0F1A1F",
5059
- secondary: "#182F31",
5060
- secondaryForeground: "#E8EFF1",
5061
- muted: "#182F31",
5062
- mutedForeground: "#8CA1A9",
5063
- accent: "#182F31",
5064
- accentForeground: "#E8EFF1",
5065
- destructive: "#E08072",
5066
- destructiveForeground: "#0F1A1F",
5067
- border: "#2A3B42",
5068
- input: "#2A3B42",
5069
- ring: "#63BDB4",
5070
- radius: "0px",
5071
- surface: "#16242A",
5072
- surfaceHover: "#182F31",
5073
- canvas: "#0F1A1F",
5074
- panel: "#16242A",
5075
- borderStrong: "#2F4F4C",
5076
- textDim: "#5E7680"
5077
- };
5078
- var cleanPreset = {
5079
- background: "#F4F7F8",
5080
- foreground: "#12222A",
5081
- card: "#FFFFFF",
5082
- primary: "#1F6B6E",
5083
- primaryForeground: "#FFFFFF",
5084
- secondary: "#EDF3F2",
5085
- secondaryForeground: "#12222A",
5086
- muted: "#EDF3F2",
5087
- mutedForeground: "#6A7B85",
5088
- accent: "#EDF3F2",
5089
- accentForeground: "#12222A",
5090
- destructive: "#B04A3C",
5091
- destructiveForeground: "#FFFFFF",
5092
- border: "#DCE4E8",
5093
- input: "#DCE4E8",
5094
- ring: "#1F6B6E",
5095
- radius: "0px",
5096
- surface: "#FAFCFC",
5097
- surfaceHover: "#EDF3F2",
5098
- canvas: "#F4F7F8",
5099
- panel: "#FFFFFF",
5100
- borderStrong: "#B9D1CF",
5101
- textDim: "#6A7B85"
5102
- };
5103
5051
  function formatCurrency(amount, currency) {
5104
5052
  if (amount == null) return "";
5105
5053
  try {
@@ -7108,6 +7056,7 @@ function ResponseViewerInner({
7108
7056
  return /* @__PURE__ */ jsxRuntime.jsxs(
7109
7057
  "div",
7110
7058
  {
7059
+ "data-fcrv-root": "",
7111
7060
  className: "flex flex-col border border-border rounded-lg overflow-hidden bg-background text-foreground",
7112
7061
  style: { height: heightValue, width: widthValue },
7113
7062
  children: [
@@ -7954,7 +7903,7 @@ function PaletteGenerator({ theme, onApply, onClose }) {
7954
7903
  }
7955
7904
 
7956
7905
  // src/theme-editor/presets.ts
7957
- var draftingTealPreset = {
7906
+ var cleanPreset = {
7958
7907
  colors: {
7959
7908
  primary: "#1F6B6E",
7960
7909
  primaryForeground: "#FFFFFF",
@@ -7974,45 +7923,312 @@ var draftingTealPreset = {
7974
7923
  inputBackground: "#FFFFFF"
7975
7924
  },
7976
7925
  typography: {
7977
- fontFamily: "'Space Grotesk', 'IBM Plex Sans', system-ui, sans-serif",
7926
+ fontFamily: "Inter, system-ui, sans-serif",
7978
7927
  scale: "comfortable",
7979
- questionSize: "1.1875rem",
7980
- labelSize: "0.8125rem",
7928
+ questionSize: "1.125rem",
7929
+ labelSize: "0.875rem",
7981
7930
  helpTextSize: "0.8125rem",
7982
7931
  bodySize: "0.9375rem"
7983
7932
  },
7984
- shape: {
7985
- radius: "none",
7986
- inputRadius: "0px",
7987
- buttonRadius: "0px",
7988
- cardRadius: "0px"
7933
+ shape: { radius: "none", inputRadius: "0px", buttonRadius: "0px", cardRadius: "0px" },
7934
+ spacing: { base: 16, sectionGap: 32, fieldGap: 24, inputPaddingX: 12, inputPaddingY: 10 },
7935
+ layout: { maxWidth: "640px", alignment: "left", progressPosition: "top", sectionLayout: "card" }
7936
+ };
7937
+ var cleanDarkPreset = {
7938
+ colors: {
7939
+ primary: "#63BDB4",
7940
+ primaryForeground: "#0F1A1F",
7941
+ secondary: "#2F4F4C",
7942
+ secondaryForeground: "#E8EFF1",
7943
+ error: "#E08072",
7944
+ errorForeground: "#0F1A1F",
7945
+ warning: "#E0A94F",
7946
+ success: "#5DB89A",
7947
+ surface: "#16242A",
7948
+ background: "#0F1A1F",
7949
+ text: "#E8EFF1",
7950
+ textMuted: "#8CA1A9",
7951
+ textDisabled: "#3D5259",
7952
+ border: "#2A3B42",
7953
+ borderFocus: "#63BDB4",
7954
+ inputBackground: "#16242A"
7989
7955
  },
7990
- spacing: {
7991
- base: 16,
7992
- sectionGap: 32,
7993
- fieldGap: 24,
7994
- inputPaddingX: 12,
7995
- inputPaddingY: 10
7956
+ typography: {
7957
+ fontFamily: "Inter, system-ui, sans-serif",
7958
+ scale: "comfortable",
7959
+ questionSize: "1.125rem",
7960
+ labelSize: "0.875rem",
7961
+ helpTextSize: "0.8125rem",
7962
+ bodySize: "0.9375rem"
7996
7963
  },
7997
- layout: {
7998
- maxWidth: "640px",
7999
- alignment: "left",
8000
- progressPosition: "top",
8001
- sectionLayout: "flat"
8002
- }
7964
+ shape: { radius: "none", inputRadius: "0px", buttonRadius: "0px", cardRadius: "0px" },
7965
+ spacing: { base: 16, sectionGap: 32, fieldGap: 24, inputPaddingX: 12, inputPaddingY: 10 },
7966
+ layout: { maxWidth: "640px", alignment: "left", progressPosition: "top", sectionLayout: "card" }
7967
+ };
7968
+ var modernPreset = {
7969
+ colors: {
7970
+ primary: "#6366F1",
7971
+ primaryForeground: "#ffffff",
7972
+ secondary: "#8B5CF6",
7973
+ secondaryForeground: "#ffffff",
7974
+ error: "#F43F5E",
7975
+ errorForeground: "#ffffff",
7976
+ warning: "#F59E0B",
7977
+ success: "#22C55E",
7978
+ surface: "#ffffff",
7979
+ background: "#FAFAFA",
7980
+ text: "#18181B",
7981
+ textMuted: "#71717A",
7982
+ textDisabled: "#D4D4D8",
7983
+ border: "#E4E4E7",
7984
+ borderFocus: "#6366F1",
7985
+ inputBackground: "#FAFAFA"
7986
+ },
7987
+ typography: {
7988
+ fontFamily: "'Plus Jakarta Sans', Inter, system-ui, sans-serif",
7989
+ scale: "comfortable",
7990
+ questionSize: "1.25rem",
7991
+ labelSize: "0.875rem",
7992
+ helpTextSize: "0.8125rem",
7993
+ bodySize: "1rem"
7994
+ },
7995
+ shape: { radius: "lg", inputRadius: "12px", buttonRadius: "12px", cardRadius: "16px" },
7996
+ spacing: { base: 16, sectionGap: 40, fieldGap: 28, inputPaddingX: 16, inputPaddingY: 12 },
7997
+ layout: { maxWidth: "680px", alignment: "center", progressPosition: "top", sectionLayout: "card" }
7998
+ };
7999
+ var modernDarkPreset = {
8000
+ colors: {
8001
+ primary: "#818CF8",
8002
+ primaryForeground: "#1E1B4B",
8003
+ secondary: "#A78BFA",
8004
+ secondaryForeground: "#1E1B4B",
8005
+ error: "#FB7185",
8006
+ errorForeground: "#1E1B4B",
8007
+ warning: "#FBBF24",
8008
+ success: "#4ADE80",
8009
+ surface: "#1E1B4B",
8010
+ background: "#13111C",
8011
+ text: "#E8E6F0",
8012
+ textMuted: "#A1A1AA",
8013
+ textDisabled: "#3F3F46",
8014
+ border: "#2E2B4A",
8015
+ borderFocus: "#818CF8",
8016
+ inputBackground: "#1E1B4B"
8017
+ },
8018
+ typography: {
8019
+ fontFamily: "'Plus Jakarta Sans', Inter, system-ui, sans-serif",
8020
+ scale: "comfortable",
8021
+ questionSize: "1.25rem",
8022
+ labelSize: "0.875rem",
8023
+ helpTextSize: "0.8125rem",
8024
+ bodySize: "1rem"
8025
+ },
8026
+ shape: { radius: "lg", inputRadius: "12px", buttonRadius: "12px", cardRadius: "16px" },
8027
+ spacing: { base: 16, sectionGap: 40, fieldGap: 28, inputPaddingX: 16, inputPaddingY: 12 },
8028
+ layout: { maxWidth: "680px", alignment: "center", progressPosition: "top", sectionLayout: "card" }
8029
+ };
8030
+ var clinicalPreset = {
8031
+ colors: {
8032
+ primary: "#0284C7",
8033
+ primaryForeground: "#ffffff",
8034
+ secondary: "#0891B2",
8035
+ secondaryForeground: "#ffffff",
8036
+ error: "#DC2626",
8037
+ errorForeground: "#ffffff",
8038
+ warning: "#D97706",
8039
+ success: "#16A34A",
8040
+ surface: "#ffffff",
8041
+ background: "#F0F9FF",
8042
+ text: "#0C4A6E",
8043
+ textMuted: "#64748B",
8044
+ textDisabled: "#CBD5E1",
8045
+ border: "#BAE6FD",
8046
+ borderFocus: "#0284C7",
8047
+ inputBackground: "#ffffff"
8048
+ },
8049
+ typography: {
8050
+ fontFamily: "'Source Sans 3', 'Segoe UI', system-ui, sans-serif",
8051
+ scale: "comfortable",
8052
+ questionSize: "1.0625rem",
8053
+ labelSize: "0.875rem",
8054
+ helpTextSize: "0.8125rem",
8055
+ bodySize: "0.9375rem"
8056
+ },
8057
+ shape: { radius: "sm", inputRadius: "6px", buttonRadius: "6px", cardRadius: "8px" },
8058
+ spacing: { base: 16, sectionGap: 28, fieldGap: 24, inputPaddingX: 12, inputPaddingY: 10 },
8059
+ layout: { maxWidth: "680px", alignment: "left", progressPosition: "top", sectionLayout: "bordered" }
8060
+ };
8061
+ var clinicalDarkPreset = {
8062
+ colors: {
8063
+ primary: "#38BDF8",
8064
+ primaryForeground: "#0C1929",
8065
+ secondary: "#22D3EE",
8066
+ secondaryForeground: "#0C1929",
8067
+ error: "#F87171",
8068
+ errorForeground: "#0C1929",
8069
+ warning: "#FBBF24",
8070
+ success: "#34D399",
8071
+ surface: "#0F2438",
8072
+ background: "#0C1929",
8073
+ text: "#E0F2FE",
8074
+ textMuted: "#7DD3FC",
8075
+ textDisabled: "#1E3A5F",
8076
+ border: "#1E3A5F",
8077
+ borderFocus: "#38BDF8",
8078
+ inputBackground: "#0F2438"
8079
+ },
8080
+ typography: {
8081
+ fontFamily: "'Source Sans 3', 'Segoe UI', system-ui, sans-serif",
8082
+ scale: "comfortable",
8083
+ questionSize: "1.0625rem",
8084
+ labelSize: "0.875rem",
8085
+ helpTextSize: "0.8125rem",
8086
+ bodySize: "0.9375rem"
8087
+ },
8088
+ shape: { radius: "sm", inputRadius: "6px", buttonRadius: "6px", cardRadius: "8px" },
8089
+ spacing: { base: 16, sectionGap: 28, fieldGap: 24, inputPaddingX: 12, inputPaddingY: 10 },
8090
+ layout: { maxWidth: "680px", alignment: "left", progressPosition: "top", sectionLayout: "bordered" }
8091
+ };
8092
+ var playfulPreset = {
8093
+ colors: {
8094
+ primary: "#EC4899",
8095
+ primaryForeground: "#ffffff",
8096
+ secondary: "#8B5CF6",
8097
+ secondaryForeground: "#ffffff",
8098
+ error: "#EF4444",
8099
+ errorForeground: "#ffffff",
8100
+ warning: "#F59E0B",
8101
+ success: "#10B981",
8102
+ surface: "#ffffff",
8103
+ background: "#FFF7ED",
8104
+ text: "#1C1917",
8105
+ textMuted: "#78716C",
8106
+ textDisabled: "#D6D3D1",
8107
+ border: "#FDE68A",
8108
+ borderFocus: "#EC4899",
8109
+ inputBackground: "#FFFBEB"
8110
+ },
8111
+ typography: {
8112
+ fontFamily: "'Nunito', 'Comic Neue', system-ui, sans-serif",
8113
+ scale: "spacious",
8114
+ questionSize: "1.25rem",
8115
+ labelSize: "0.9375rem",
8116
+ helpTextSize: "0.875rem",
8117
+ bodySize: "1rem"
8118
+ },
8119
+ shape: { radius: "full", inputRadius: "9999px", buttonRadius: "9999px", cardRadius: "20px" },
8120
+ spacing: { base: 18, sectionGap: 36, fieldGap: 28, inputPaddingX: 18, inputPaddingY: 12 },
8121
+ layout: { maxWidth: "600px", alignment: "center", progressPosition: "top", sectionLayout: "card" }
8003
8122
  };
8004
- var COMPARISON_PRESETS = {
8005
- "drafting-teal": { label: "Drafting Teal", theme: draftingTealPreset },
8006
- clean: { label: "Clean", theme: fieldcraftReact.cleanPreset },
8007
- dark: { label: "Dark", theme: fieldcraftReact.darkPreset },
8008
- modern: { label: "Modern", theme: fieldcraftReact.modernPreset },
8009
- "high-contrast": { label: "High Contrast", theme: fieldcraftReact.highContrastPreset },
8010
- clinical: { label: "Clinical", theme: fieldcraftReact.clinicalPreset },
8011
- playful: { label: "Playful", theme: fieldcraftReact.playfulPreset }
8123
+ var playfulDarkPreset = {
8124
+ colors: {
8125
+ primary: "#F472B6",
8126
+ primaryForeground: "#1A0A14",
8127
+ secondary: "#A78BFA",
8128
+ secondaryForeground: "#1A0A14",
8129
+ error: "#FCA5A5",
8130
+ errorForeground: "#1A0A14",
8131
+ warning: "#FCD34D",
8132
+ success: "#6EE7B7",
8133
+ surface: "#2D1F2B",
8134
+ background: "#1A0F19",
8135
+ text: "#FDF2F8",
8136
+ textMuted: "#D4A9C4",
8137
+ textDisabled: "#4A3248",
8138
+ border: "#5C3D56",
8139
+ borderFocus: "#F472B6",
8140
+ inputBackground: "#2D1F2B"
8141
+ },
8142
+ typography: {
8143
+ fontFamily: "'Nunito', 'Comic Neue', system-ui, sans-serif",
8144
+ scale: "spacious",
8145
+ questionSize: "1.25rem",
8146
+ labelSize: "0.9375rem",
8147
+ helpTextSize: "0.875rem",
8148
+ bodySize: "1rem"
8149
+ },
8150
+ shape: { radius: "full", inputRadius: "9999px", buttonRadius: "9999px", cardRadius: "20px" },
8151
+ spacing: { base: 18, sectionGap: 36, fieldGap: 28, inputPaddingX: 18, inputPaddingY: 12 },
8152
+ layout: { maxWidth: "600px", alignment: "center", progressPosition: "top", sectionLayout: "card" }
8012
8153
  };
8154
+ var highContrastPreset = {
8155
+ colors: {
8156
+ primary: "#0000EE",
8157
+ primaryForeground: "#ffffff",
8158
+ secondary: "#6B21A8",
8159
+ secondaryForeground: "#ffffff",
8160
+ error: "#B91C1C",
8161
+ errorForeground: "#ffffff",
8162
+ warning: "#92400E",
8163
+ success: "#166534",
8164
+ surface: "#ffffff",
8165
+ background: "#ffffff",
8166
+ text: "#000000",
8167
+ textMuted: "#374151",
8168
+ textDisabled: "#9CA3AF",
8169
+ border: "#000000",
8170
+ borderFocus: "#0000EE",
8171
+ inputBackground: "#ffffff"
8172
+ },
8173
+ typography: {
8174
+ fontFamily: "Arial, Helvetica, sans-serif",
8175
+ scale: "spacious",
8176
+ questionSize: "1.25rem",
8177
+ labelSize: "1rem",
8178
+ helpTextSize: "0.9375rem",
8179
+ bodySize: "1rem"
8180
+ },
8181
+ shape: { radius: "sm", inputRadius: "4px", buttonRadius: "4px", cardRadius: "4px" },
8182
+ spacing: { base: 20, sectionGap: 40, fieldGap: 32, inputPaddingX: 14, inputPaddingY: 12 },
8183
+ layout: { maxWidth: "720px", alignment: "left", progressPosition: "top", sectionLayout: "bordered" }
8184
+ };
8185
+ var highContrastDarkPreset = {
8186
+ colors: {
8187
+ primary: "#93C5FD",
8188
+ primaryForeground: "#000000",
8189
+ secondary: "#C084FC",
8190
+ secondaryForeground: "#000000",
8191
+ error: "#FCA5A5",
8192
+ errorForeground: "#000000",
8193
+ warning: "#FCD34D",
8194
+ success: "#86EFAC",
8195
+ surface: "#000000",
8196
+ background: "#000000",
8197
+ text: "#FFFFFF",
8198
+ textMuted: "#D1D5DB",
8199
+ textDisabled: "#6B7280",
8200
+ border: "#FFFFFF",
8201
+ borderFocus: "#93C5FD",
8202
+ inputBackground: "#000000"
8203
+ },
8204
+ typography: {
8205
+ fontFamily: "Arial, Helvetica, sans-serif",
8206
+ scale: "spacious",
8207
+ questionSize: "1.25rem",
8208
+ labelSize: "1rem",
8209
+ helpTextSize: "0.9375rem",
8210
+ bodySize: "1rem"
8211
+ },
8212
+ shape: { radius: "sm", inputRadius: "4px", buttonRadius: "4px", cardRadius: "4px" },
8213
+ spacing: { base: 20, sectionGap: 40, fieldGap: 32, inputPaddingX: 14, inputPaddingY: 12 },
8214
+ layout: { maxWidth: "720px", alignment: "left", progressPosition: "top", sectionLayout: "bordered" }
8215
+ };
8216
+ var PRESET_FAMILIES = {
8217
+ clean: { light: cleanPreset, dark: cleanDarkPreset, label: "Clean" },
8218
+ modern: { light: modernPreset, dark: modernDarkPreset, label: "Modern" },
8219
+ clinical: { light: clinicalPreset, dark: clinicalDarkPreset, label: "Clinical" },
8220
+ playful: { light: playfulPreset, dark: playfulDarkPreset, label: "Playful" },
8221
+ "high-contrast": { light: highContrastPreset, dark: highContrastDarkPreset, label: "High contrast" }
8222
+ };
8223
+ var COMPARISON_PRESETS = Object.fromEntries(
8224
+ Object.entries(PRESET_FAMILIES).map(([key, family]) => [
8225
+ key,
8226
+ { label: family.label, theme: family.light }
8227
+ ])
8228
+ );
8013
8229
  function ThemeComparison({ currentTheme, onClose }) {
8014
8230
  const [compareKey, setCompareKey] = react.useState("clean");
8015
- const compareTheme = COMPARISON_PRESETS[compareKey]?.theme ?? fieldcraftReact.cleanPreset;
8231
+ const compareTheme = COMPARISON_PRESETS[compareKey]?.theme ?? PRESET_FAMILIES.clean.light;
8016
8232
  const diffs = getColorDiffs(currentTheme, compareTheme);
8017
8233
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fcte-compare", children: [
8018
8234
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fcte-compare__header", children: [
@@ -8110,7 +8326,54 @@ function getColorDiffs(a, b) {
8110
8326
  }
8111
8327
  return diffs;
8112
8328
  }
8329
+
8330
+ // src/utils/resolve-theme-from-dom.ts
8331
+ function resolveThemeFromDOM() {
8332
+ if (typeof window === "undefined") return {};
8333
+ const styles = getComputedStyle(document.documentElement);
8334
+ const get = (prop) => {
8335
+ const val = styles.getPropertyValue(prop).trim();
8336
+ return val || void 0;
8337
+ };
8338
+ return {
8339
+ colors: {
8340
+ primary: get("--primary"),
8341
+ primaryForeground: get("--primary-foreground"),
8342
+ secondary: get("--secondary"),
8343
+ secondaryForeground: get("--secondary-foreground"),
8344
+ error: get("--destructive"),
8345
+ errorForeground: get("--destructive-foreground"),
8346
+ warning: get("--fc-color-warning"),
8347
+ success: get("--fc-color-success"),
8348
+ surface: get("--card"),
8349
+ background: get("--background"),
8350
+ text: get("--foreground"),
8351
+ textMuted: get("--muted-foreground"),
8352
+ textDisabled: void 0,
8353
+ border: get("--border"),
8354
+ borderFocus: get("--ring"),
8355
+ inputBackground: get("--input-background") ?? get("--card")
8356
+ },
8357
+ typography: {
8358
+ fontFamily: get("--fc-font-family"),
8359
+ // scale is an enum ("compact" | "comfortable" | "spacious") — not resolvable from CSS
8360
+ questionSize: get("--fc-font-question"),
8361
+ labelSize: get("--fc-font-label"),
8362
+ helpTextSize: get("--fc-font-help"),
8363
+ bodySize: get("--fc-font-body")
8364
+ },
8365
+ shape: {
8366
+ // radius is an enum ("none" | "sm" | "md" | "lg" | "full") — not resolvable from CSS
8367
+ inputRadius: get("--fc-radius-input"),
8368
+ buttonRadius: get("--fc-radius-button"),
8369
+ cardRadius: get("--fc-radius-card")
8370
+ }
8371
+ };
8372
+ }
8113
8373
  var ThemeCtx2 = react.createContext({});
8374
+ function useEditorTheme() {
8375
+ return react.useContext(ThemeCtx2);
8376
+ }
8114
8377
  function themeToCssVars2(theme) {
8115
8378
  const vars = {};
8116
8379
  if (theme.background) vars["--fcte-bg"] = theme.background;
@@ -8131,15 +8394,15 @@ function ThemeEditorThemeProvider({ theme, children }) {
8131
8394
  const cssVars = react.useMemo(() => themeToCssVars2(resolved), [resolved]);
8132
8395
  return /* @__PURE__ */ jsxRuntime.jsx(ThemeCtx2.Provider, { value: resolved, children: /* @__PURE__ */ jsxRuntime.jsx("div", { "data-fcte-root": "", style: cssVars, className: "fcte-provider-root", children }) });
8133
8396
  }
8134
- var PRESETS = {
8135
- "drafting-teal": draftingTealPreset,
8136
- clean: fieldcraftReact.cleanPreset,
8137
- dark: fieldcraftReact.darkPreset,
8138
- modern: fieldcraftReact.modernPreset,
8139
- "high-contrast": fieldcraftReact.highContrastPreset,
8140
- clinical: fieldcraftReact.clinicalPreset,
8141
- playful: fieldcraftReact.playfulPreset
8142
- };
8397
+ function isDarkTheme(theme) {
8398
+ const bg = theme.colors?.background ?? "#FFFFFF";
8399
+ const hex = bg.replace("#", "");
8400
+ if (hex.length < 6) return false;
8401
+ const r = parseInt(hex.slice(0, 2), 16);
8402
+ const g = parseInt(hex.slice(2, 4), 16);
8403
+ const b = parseInt(hex.slice(4, 6), 16);
8404
+ return 0.299 * r + 0.587 * g + 0.114 * b < 128;
8405
+ }
8143
8406
  var SECTIONS = [
8144
8407
  {
8145
8408
  id: "colors",
@@ -8269,9 +8532,17 @@ function ThemeEditorInner({
8269
8532
  toolbarExtra,
8270
8533
  showPreview = true
8271
8534
  }) {
8272
- const [theme, setTheme] = react.useState(initialTheme ?? draftingTealPreset);
8535
+ const resolvedInitial = react.useMemo(
8536
+ () => initialTheme ?? resolveThemeFromDOM(),
8537
+ // eslint-disable-next-line react-hooks/exhaustive-deps
8538
+ []
8539
+ );
8540
+ const [theme, setTheme] = react.useState(resolvedInitial);
8273
8541
  const [activeSection, setActiveSection] = react.useState("colors");
8274
- const [presetKey, setPresetKey] = react.useState(initialTheme ? "custom" : "drafting-teal");
8542
+ const [presetKey, setPresetKey] = react.useState("custom");
8543
+ const [mode, setMode] = react.useState(
8544
+ () => isDarkTheme(resolvedInitial) ? "dark" : "light"
8545
+ );
8275
8546
  const [showPalette, setShowPalette] = react.useState(false);
8276
8547
  const [showComparison, setShowComparison] = react.useState(false);
8277
8548
  const themeRef = react.useRef(theme);
@@ -8301,16 +8572,30 @@ function ThemeEditorInner({
8301
8572
  [onChange]
8302
8573
  );
8303
8574
  const loadPreset = react.useCallback(
8304
- (key) => {
8305
- const preset = PRESETS[key];
8306
- if (preset) {
8575
+ (key, forceMode) => {
8576
+ const family = PRESET_FAMILIES[key];
8577
+ if (family) {
8578
+ const m = forceMode ?? mode;
8579
+ const preset = family[m];
8307
8580
  setTheme(preset);
8308
8581
  setPresetKey(key);
8309
8582
  onChange?.(preset);
8310
8583
  }
8311
8584
  },
8312
- [onChange]
8585
+ [onChange, mode]
8313
8586
  );
8587
+ const toggleMode = react.useCallback(() => {
8588
+ setMode((prev) => {
8589
+ const next = prev === "light" ? "dark" : "light";
8590
+ const family = PRESET_FAMILIES[presetKey];
8591
+ if (family) {
8592
+ const preset = family[next];
8593
+ setTheme(preset);
8594
+ onChange?.(preset);
8595
+ }
8596
+ return next;
8597
+ });
8598
+ }, [presetKey, onChange]);
8314
8599
  const exportJson = react.useCallback(() => {
8315
8600
  const blob = new Blob([JSON.stringify(theme, null, 2)], { type: "application/json" });
8316
8601
  const url = URL.createObjectURL(blob);
@@ -8376,9 +8661,18 @@ function ThemeEditorInner({
8376
8661
  className: "fcte-toolbar__preset",
8377
8662
  children: [
8378
8663
  /* @__PURE__ */ jsxRuntime.jsx("option", { value: "custom", disabled: true, children: "Custom" }),
8379
- Object.keys(PRESETS).map((k) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: k, children: k.charAt(0).toUpperCase() + k.slice(1).replace("-", " ") }, k))
8664
+ Object.entries(PRESET_FAMILIES).map(([k, fam]) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: k, children: fam.label }, k))
8380
8665
  ]
8381
8666
  }
8667
+ ),
8668
+ /* @__PURE__ */ jsxRuntime.jsx(
8669
+ "button",
8670
+ {
8671
+ onClick: toggleMode,
8672
+ className: "fcte-btn fcte-btn--secondary fcte-toolbar__mode",
8673
+ title: mode === "light" ? "Switch to dark mode" : "Switch to light mode",
8674
+ children: mode === "light" ? "\u2600" : "\u263E"
8675
+ }
8382
8676
  )
8383
8677
  ] }),
8384
8678
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fcte-toolbar__right", children: [
@@ -8547,10 +8841,38 @@ function ThemeEditorInner({
8547
8841
  // src/theme-editor/ThemeEditor.tsx
8548
8842
  var ThemeEditor = requireLicense(ThemeEditorInner, "ThemeEditor");
8549
8843
 
8844
+ // src/theme-editor/theme/presets.ts
8845
+ var themeEditorLightPreset = {
8846
+ background: "#F4F7F8",
8847
+ surface: "#FFFFFF",
8848
+ surfaceHover: "#EDF3F2",
8849
+ text: "#12222A",
8850
+ textMuted: "#6A7B85",
8851
+ textDim: "#96A5AD",
8852
+ border: "#DCE4E8",
8853
+ borderStrong: "#B9D1CF",
8854
+ inputBackground: "#FAFCFC",
8855
+ accent: "#1F6B6E",
8856
+ accentForeground: "#FFFFFF"
8857
+ };
8858
+ var themeEditorDarkPreset = {
8859
+ background: "#0F1A1F",
8860
+ surface: "#16242A",
8861
+ surfaceHover: "#182F31",
8862
+ text: "#E8EFF1",
8863
+ textMuted: "#8CA1A9",
8864
+ textDim: "#5E7680",
8865
+ border: "#2A3B42",
8866
+ borderStrong: "#2F4F4C",
8867
+ inputBackground: "#12222A",
8868
+ accent: "#63BDB4",
8869
+ accentForeground: "#0F1A1F"
8870
+ };
8871
+
8550
8872
  // src/index.ts
8551
8873
  if (typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" && globalThis.process.env?.NODE_ENV !== "production") {
8552
8874
  const _fc_banner = `
8553
- %c FieldCraft Pro %c v1.5.0
8875
+ %c FieldCraft Pro %c v1.6.1
8554
8876
 
8555
8877
  %cForm Builder \xB7 Response Viewer \xB7 Theme Editor
8556
8878
 
@@ -8573,6 +8895,7 @@ exports.DEFAULT_SCHEMA = DEFAULT_SCHEMA;
8573
8895
  exports.FieldCraftProProvider = FieldCraftProProvider;
8574
8896
  exports.FormBuilder = FormBuilder;
8575
8897
  exports.FormBuilderThemeProvider = FormBuilderThemeProvider;
8898
+ exports.PRESET_FAMILIES = PRESET_FAMILIES;
8576
8899
  exports.PREVIEW_SCHEMA = PREVIEW_SCHEMA;
8577
8900
  exports.PRO_FIELD_OVERRIDES = PRO_FIELD_OVERRIDES;
8578
8901
  exports.ProPaymentField = ProPaymentField;
@@ -8580,11 +8903,11 @@ exports.QUESTION_TYPE_INFO = QUESTION_TYPE_INFO;
8580
8903
  exports.ResponseViewer = ResponseViewer;
8581
8904
  exports.ThemeEditor = ThemeEditor;
8582
8905
  exports.ThemeEditorInner = ThemeEditorInner;
8906
+ exports.ThemeEditorThemeProvider = ThemeEditorThemeProvider;
8583
8907
  exports.UnlicensedOverlay = UnlicensedOverlay;
8584
8908
  exports.addOption = addOption;
8585
8909
  exports.addQuestion = addQuestion;
8586
8910
  exports.addSection = addSection;
8587
- exports.cleanPreset = cleanPreset;
8588
8911
  exports.cn = cn;
8589
8912
  exports.duplicateQuestion = duplicateQuestion;
8590
8913
  exports.duplicateSection = duplicateSection;
@@ -8602,13 +8925,16 @@ exports.removeOption = removeOption;
8602
8925
  exports.removeQuestion = removeQuestion;
8603
8926
  exports.removeSection = removeSection;
8604
8927
  exports.requireLicense = requireLicense;
8605
- exports.squaredrDarkPreset = squaredrDarkPreset;
8928
+ exports.resolveThemeFromDOM = resolveThemeFromDOM;
8929
+ exports.themeEditorDarkPreset = themeEditorDarkPreset;
8930
+ exports.themeEditorLightPreset = themeEditorLightPreset;
8606
8931
  exports.updateOption = updateOption;
8607
8932
  exports.updateQuestion = updateQuestion;
8608
8933
  exports.updateSection = updateSection;
8609
8934
  exports.useBuilderState = useBuilderState;
8610
8935
  exports.useBuilderTheme = useBuilderTheme;
8611
8936
  exports.useDragDrop = useDragDrop;
8937
+ exports.useEditorTheme = useEditorTheme;
8612
8938
  exports.useLicense = useLicense;
8613
8939
  exports.useUndoRedo = useUndoRedo;
8614
8940
  exports.validateLicense = validateLicense;
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- export { DEFAULT_PALETTE, DEFAULT_SCHEMA, FormBuilder, FormBuilderThemeProvider, QUESTION_TYPE_INFO, addOption, addQuestion, addSection, cleanPreset, duplicateQuestion, duplicateSection, findQuestion, findSection, generateId, generateOptionId, generateQuestionId, generateSectionId, moveOption, moveQuestion, moveSection, removeOption, removeQuestion, removeSection, squaredrDarkPreset, updateOption, updateQuestion, updateSection, useBuilderState, useBuilderTheme, useDragDrop, useUndoRedo } from './chunk-6LRUDBC7.mjs';
2
- export { ResponseViewer } from './chunk-BK4SMEW4.mjs';
1
+ export { DEFAULT_PALETTE, DEFAULT_SCHEMA, FormBuilder, FormBuilderThemeProvider, QUESTION_TYPE_INFO, addOption, addQuestion, addSection, duplicateQuestion, duplicateSection, findQuestion, findSection, generateId, generateOptionId, generateQuestionId, generateSectionId, moveOption, moveQuestion, moveSection, removeOption, removeQuestion, removeSection, updateOption, updateQuestion, updateSection, useBuilderState, useBuilderTheme, useDragDrop, useUndoRedo } from './chunk-ANBMT5AW.mjs';
2
+ export { ResponseViewer } from './chunk-5LKGCZAW.mjs';
3
3
  export { cn } from './chunk-QQ4JZGTD.mjs';
4
- export { PREVIEW_SCHEMA, ThemeEditor, ThemeEditorInner } from './chunk-22T5PY6L.mjs';
4
+ export { PRESET_FAMILIES, PREVIEW_SCHEMA, ThemeEditor, ThemeEditorInner, ThemeEditorThemeProvider, resolveThemeFromDOM, themeEditorDarkPreset, themeEditorLightPreset, useEditorTheme } from './chunk-IKGS2ZXV.mjs';
5
5
  export { FieldCraftProProvider, UnlicensedOverlay, isProductionEnvironment, requireLicense, useLicense, validateLicense } from './chunk-VECQKSWS.mjs';
6
6
  import { useState, useEffect, Suspense } from 'react';
7
7
  import { FieldWrapper } from '@squaredr/fieldcraft-react';
@@ -277,7 +277,7 @@ var PRO_FIELD_OVERRIDES = {
277
277
  // src/index.ts
278
278
  if (typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" && globalThis.process.env?.NODE_ENV !== "production") {
279
279
  const _fc_banner = `
280
- %c FieldCraft Pro %c v1.5.0
280
+ %c FieldCraft Pro %c v1.6.1
281
281
 
282
282
  %cForm Builder \xB7 Response Viewer \xB7 Theme Editor
283
283
 
@@ -2073,6 +2073,7 @@ function ResponseViewerInner({
2073
2073
  return /* @__PURE__ */ jsxRuntime.jsxs(
2074
2074
  "div",
2075
2075
  {
2076
+ "data-fcrv-root": "",
2076
2077
  className: "flex flex-col border border-border rounded-lg overflow-hidden bg-background text-foreground",
2077
2078
  style: { height: heightValue, width: widthValue },
2078
2079
  children: [
@@ -1,3 +1,3 @@
1
- export { ResponseViewer } from '../chunk-BK4SMEW4.mjs';
1
+ export { ResponseViewer } from '../chunk-5LKGCZAW.mjs';
2
2
  import '../chunk-QQ4JZGTD.mjs';
3
3
  import '../chunk-VECQKSWS.mjs';