@streamoid/settings 0.1.3 → 0.1.4

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.d.mts CHANGED
@@ -57,6 +57,13 @@ interface SettingsAuthUser {
57
57
  (e.g. "design", "merchandising"). */
58
58
  userSpecialization?: string;
59
59
  }
60
+ /** Option shape returned by `auth.getSpecializations` — drives the
61
+ Specialization dropdown in Settings → Account. */
62
+ interface SettingsUserSpecialization {
63
+ id: string;
64
+ name: string;
65
+ description?: string;
66
+ }
60
67
  interface SettingsAuthAdapter {
61
68
  user: SettingsAuthUser | null;
62
69
  refreshProfile: () => Promise<void>;
@@ -67,6 +74,9 @@ interface SettingsAuthAdapter {
67
74
  }) => Promise<void>;
68
75
  clearAuth: () => void;
69
76
  logout: () => Promise<void>;
77
+ /** Optional. When present, the Specialization dropdown is populated from
78
+ the host's API; otherwise the package falls back to a built-in list. */
79
+ getSpecializations?: () => Promise<SettingsUserSpecialization[]>;
70
80
  }
71
81
  interface SettingsWorkspaceCurrent {
72
82
  id: string;
package/dist/index.d.ts CHANGED
@@ -57,6 +57,13 @@ interface SettingsAuthUser {
57
57
  (e.g. "design", "merchandising"). */
58
58
  userSpecialization?: string;
59
59
  }
60
+ /** Option shape returned by `auth.getSpecializations` — drives the
61
+ Specialization dropdown in Settings → Account. */
62
+ interface SettingsUserSpecialization {
63
+ id: string;
64
+ name: string;
65
+ description?: string;
66
+ }
60
67
  interface SettingsAuthAdapter {
61
68
  user: SettingsAuthUser | null;
62
69
  refreshProfile: () => Promise<void>;
@@ -67,6 +74,9 @@ interface SettingsAuthAdapter {
67
74
  }) => Promise<void>;
68
75
  clearAuth: () => void;
69
76
  logout: () => Promise<void>;
77
+ /** Optional. When present, the Specialization dropdown is populated from
78
+ the host's API; otherwise the package falls back to a built-in list. */
79
+ getSpecializations?: () => Promise<SettingsUserSpecialization[]>;
70
80
  }
71
81
  interface SettingsWorkspaceCurrent {
72
82
  id: string;
package/dist/index.js CHANGED
@@ -6875,71 +6875,49 @@ function SettingsNav({
6875
6875
  );
6876
6876
  }
6877
6877
  var SPECIALIZATION_ICON_SIZE = 20;
6878
- var SPECIALIZATION_OPTIONS = [
6879
- {
6880
- id: "design",
6881
- label: "Design",
6882
- icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
6883
- import_icons7.SiconSwatch,
6884
- {
6885
- style: {
6886
- width: SPECIALIZATION_ICON_SIZE,
6887
- height: SPECIALIZATION_ICON_SIZE
6888
- }
6889
- }
6890
- )
6891
- },
6878
+ var SPECIALIZATION_ICON_PROPS = {
6879
+ style: {
6880
+ width: SPECIALIZATION_ICON_SIZE,
6881
+ height: SPECIALIZATION_ICON_SIZE
6882
+ }
6883
+ };
6884
+ function iconForSpecialization(id) {
6885
+ switch (id) {
6886
+ case "design":
6887
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons7.SiconSwatch, { ...SPECIALIZATION_ICON_PROPS });
6888
+ case "merchandising":
6889
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons7.SiconBag, { ...SPECIALIZATION_ICON_PROPS });
6890
+ case "planning":
6891
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons7.SiconInsights, { ...SPECIALIZATION_ICON_PROPS });
6892
+ case "marketing_brand":
6893
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons7.SiconAdCreator, { ...SPECIALIZATION_ICON_PROPS });
6894
+ case "founder_operator":
6895
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons7.SiconCrown, { ...SPECIALIZATION_ICON_PROPS });
6896
+ default:
6897
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons7.SiconBolt, { ...SPECIALIZATION_ICON_PROPS });
6898
+ }
6899
+ }
6900
+ var FALLBACK_SPECIALIZATIONS = [
6901
+ { id: "design", label: "Design", icon: iconForSpecialization("design") },
6892
6902
  {
6893
6903
  id: "merchandising",
6894
6904
  label: "Merchandising",
6895
- icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
6896
- import_icons7.SiconBag,
6897
- {
6898
- style: {
6899
- width: SPECIALIZATION_ICON_SIZE,
6900
- height: SPECIALIZATION_ICON_SIZE
6901
- }
6902
- }
6903
- )
6905
+ icon: iconForSpecialization("merchandising")
6904
6906
  },
6905
6907
  {
6906
6908
  id: "planning",
6907
6909
  label: "Planning",
6908
- icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
6909
- import_icons7.SiconInsights,
6910
- {
6911
- style: {
6912
- width: SPECIALIZATION_ICON_SIZE,
6913
- height: SPECIALIZATION_ICON_SIZE
6914
- }
6915
- }
6916
- )
6910
+ icon: iconForSpecialization("planning")
6917
6911
  },
6918
6912
  {
6919
6913
  id: "marketing_brand",
6920
6914
  label: "Marketing & brand",
6921
- icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
6922
- import_icons7.SiconAdCreator,
6923
- {
6924
- style: {
6925
- width: SPECIALIZATION_ICON_SIZE,
6926
- height: SPECIALIZATION_ICON_SIZE
6927
- }
6928
- }
6929
- )
6915
+ icon: iconForSpecialization("marketing_brand")
6930
6916
  },
6931
6917
  {
6932
6918
  id: "founder_operator",
6933
6919
  label: "Founder & operator",
6934
- icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
6935
- import_icons7.SiconCrown,
6936
- {
6937
- style: {
6938
- width: SPECIALIZATION_ICON_SIZE,
6939
- height: SPECIALIZATION_ICON_SIZE
6940
- }
6941
- }
6942
- )
6920
+ icon: iconForSpecialization("founder_operator")
6943
6921
  }
6944
6922
  ];
6945
6923
  function SpecializationDropdown({
@@ -6947,8 +6925,32 @@ function SpecializationDropdown({
6947
6925
  onChange,
6948
6926
  disabled
6949
6927
  }) {
6928
+ const { auth } = useSettingsAdapters();
6950
6929
  const [open, setOpen] = (0, import_react10.useState)(false);
6951
6930
  const containerRef = (0, import_react10.useRef)(null);
6931
+ const [options, setOptions] = (0, import_react10.useState)(
6932
+ FALLBACK_SPECIALIZATIONS
6933
+ );
6934
+ (0, import_react10.useEffect)(() => {
6935
+ if (!auth.getSpecializations) return;
6936
+ let cancelled = false;
6937
+ auth.getSpecializations().then((items) => {
6938
+ if (cancelled) return;
6939
+ if (Array.isArray(items) && items.length > 0) {
6940
+ setOptions(
6941
+ items.map((item) => ({
6942
+ id: item.id,
6943
+ label: item.name,
6944
+ icon: iconForSpecialization(item.id)
6945
+ }))
6946
+ );
6947
+ }
6948
+ }).catch(() => {
6949
+ });
6950
+ return () => {
6951
+ cancelled = true;
6952
+ };
6953
+ }, [auth]);
6952
6954
  (0, import_react10.useEffect)(() => {
6953
6955
  if (!open) return;
6954
6956
  function handleMouseDown(e) {
@@ -6966,7 +6968,7 @@ function SpecializationDropdown({
6966
6968
  document.removeEventListener("keydown", handleKeyDown);
6967
6969
  };
6968
6970
  }, [open]);
6969
- const selected = SPECIALIZATION_OPTIONS.find((o) => o.id === value);
6971
+ const selected = options.find((o) => o.id === value);
6970
6972
  const labelText = selected ? selected.label : value === "unspecified" ? "Not specified" : "Select specialization";
6971
6973
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
6972
6974
  "div",
@@ -7079,7 +7081,7 @@ function SpecializationDropdown({
7079
7081
  gap: 2,
7080
7082
  boxShadow: "0 8px 24px rgba(0,0,0,0.4)"
7081
7083
  },
7082
- children: SPECIALIZATION_OPTIONS.map((opt) => {
7084
+ children: options.map((opt) => {
7083
7085
  const isActive = opt.id === value;
7084
7086
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
7085
7087
  "button",
package/dist/index.mjs CHANGED
@@ -6900,71 +6900,49 @@ function SettingsNav({
6900
6900
  );
6901
6901
  }
6902
6902
  var SPECIALIZATION_ICON_SIZE = 20;
6903
- var SPECIALIZATION_OPTIONS = [
6904
- {
6905
- id: "design",
6906
- label: "Design",
6907
- icon: /* @__PURE__ */ jsx13(
6908
- SiconSwatch,
6909
- {
6910
- style: {
6911
- width: SPECIALIZATION_ICON_SIZE,
6912
- height: SPECIALIZATION_ICON_SIZE
6913
- }
6914
- }
6915
- )
6916
- },
6903
+ var SPECIALIZATION_ICON_PROPS = {
6904
+ style: {
6905
+ width: SPECIALIZATION_ICON_SIZE,
6906
+ height: SPECIALIZATION_ICON_SIZE
6907
+ }
6908
+ };
6909
+ function iconForSpecialization(id) {
6910
+ switch (id) {
6911
+ case "design":
6912
+ return /* @__PURE__ */ jsx13(SiconSwatch, { ...SPECIALIZATION_ICON_PROPS });
6913
+ case "merchandising":
6914
+ return /* @__PURE__ */ jsx13(SiconBag, { ...SPECIALIZATION_ICON_PROPS });
6915
+ case "planning":
6916
+ return /* @__PURE__ */ jsx13(SiconInsights, { ...SPECIALIZATION_ICON_PROPS });
6917
+ case "marketing_brand":
6918
+ return /* @__PURE__ */ jsx13(SiconAdCreator, { ...SPECIALIZATION_ICON_PROPS });
6919
+ case "founder_operator":
6920
+ return /* @__PURE__ */ jsx13(SiconCrown, { ...SPECIALIZATION_ICON_PROPS });
6921
+ default:
6922
+ return /* @__PURE__ */ jsx13(SiconBolt, { ...SPECIALIZATION_ICON_PROPS });
6923
+ }
6924
+ }
6925
+ var FALLBACK_SPECIALIZATIONS = [
6926
+ { id: "design", label: "Design", icon: iconForSpecialization("design") },
6917
6927
  {
6918
6928
  id: "merchandising",
6919
6929
  label: "Merchandising",
6920
- icon: /* @__PURE__ */ jsx13(
6921
- SiconBag,
6922
- {
6923
- style: {
6924
- width: SPECIALIZATION_ICON_SIZE,
6925
- height: SPECIALIZATION_ICON_SIZE
6926
- }
6927
- }
6928
- )
6930
+ icon: iconForSpecialization("merchandising")
6929
6931
  },
6930
6932
  {
6931
6933
  id: "planning",
6932
6934
  label: "Planning",
6933
- icon: /* @__PURE__ */ jsx13(
6934
- SiconInsights,
6935
- {
6936
- style: {
6937
- width: SPECIALIZATION_ICON_SIZE,
6938
- height: SPECIALIZATION_ICON_SIZE
6939
- }
6940
- }
6941
- )
6935
+ icon: iconForSpecialization("planning")
6942
6936
  },
6943
6937
  {
6944
6938
  id: "marketing_brand",
6945
6939
  label: "Marketing & brand",
6946
- icon: /* @__PURE__ */ jsx13(
6947
- SiconAdCreator,
6948
- {
6949
- style: {
6950
- width: SPECIALIZATION_ICON_SIZE,
6951
- height: SPECIALIZATION_ICON_SIZE
6952
- }
6953
- }
6954
- )
6940
+ icon: iconForSpecialization("marketing_brand")
6955
6941
  },
6956
6942
  {
6957
6943
  id: "founder_operator",
6958
6944
  label: "Founder & operator",
6959
- icon: /* @__PURE__ */ jsx13(
6960
- SiconCrown,
6961
- {
6962
- style: {
6963
- width: SPECIALIZATION_ICON_SIZE,
6964
- height: SPECIALIZATION_ICON_SIZE
6965
- }
6966
- }
6967
- )
6945
+ icon: iconForSpecialization("founder_operator")
6968
6946
  }
6969
6947
  ];
6970
6948
  function SpecializationDropdown({
@@ -6972,8 +6950,32 @@ function SpecializationDropdown({
6972
6950
  onChange,
6973
6951
  disabled
6974
6952
  }) {
6953
+ const { auth } = useSettingsAdapters();
6975
6954
  const [open, setOpen] = useState9(false);
6976
6955
  const containerRef = useRef3(null);
6956
+ const [options, setOptions] = useState9(
6957
+ FALLBACK_SPECIALIZATIONS
6958
+ );
6959
+ useEffect6(() => {
6960
+ if (!auth.getSpecializations) return;
6961
+ let cancelled = false;
6962
+ auth.getSpecializations().then((items) => {
6963
+ if (cancelled) return;
6964
+ if (Array.isArray(items) && items.length > 0) {
6965
+ setOptions(
6966
+ items.map((item) => ({
6967
+ id: item.id,
6968
+ label: item.name,
6969
+ icon: iconForSpecialization(item.id)
6970
+ }))
6971
+ );
6972
+ }
6973
+ }).catch(() => {
6974
+ });
6975
+ return () => {
6976
+ cancelled = true;
6977
+ };
6978
+ }, [auth]);
6977
6979
  useEffect6(() => {
6978
6980
  if (!open) return;
6979
6981
  function handleMouseDown(e) {
@@ -6991,7 +6993,7 @@ function SpecializationDropdown({
6991
6993
  document.removeEventListener("keydown", handleKeyDown);
6992
6994
  };
6993
6995
  }, [open]);
6994
- const selected = SPECIALIZATION_OPTIONS.find((o) => o.id === value);
6996
+ const selected = options.find((o) => o.id === value);
6995
6997
  const labelText = selected ? selected.label : value === "unspecified" ? "Not specified" : "Select specialization";
6996
6998
  return /* @__PURE__ */ jsxs11(
6997
6999
  "div",
@@ -7104,7 +7106,7 @@ function SpecializationDropdown({
7104
7106
  gap: 2,
7105
7107
  boxShadow: "0 8px 24px rgba(0,0,0,0.4)"
7106
7108
  },
7107
- children: SPECIALIZATION_OPTIONS.map((opt) => {
7109
+ children: options.map((opt) => {
7108
7110
  const isActive = opt.id === value;
7109
7111
  return /* @__PURE__ */ jsxs11(
7110
7112
  "button",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamoid/settings",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",