@framework-m/desk 0.16.0 → 0.17.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.
@@ -1 +1 @@
1
- {"version":3,"file":"MultiSelectField.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/MultiSelectField.tsx"],"names":[],"mappings":"AA0DA,eAAO,MAAM,WAAW,GAAI,OAAO,GAAG,gCAoJrC,CAAC;AAEF,eAAO,MAAM,gBAAgB,6CAA4B,CAAC"}
1
+ {"version":3,"file":"MultiSelectField.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/MultiSelectField.tsx"],"names":[],"mappings":"AA2DA,eAAO,MAAM,WAAW,GAAI,OAAO,GAAG,gCAsJrC,CAAC;AAEF,eAAO,MAAM,gBAAgB,6CAA4B,CAAC"}
@@ -4,11 +4,12 @@
4
4
  * UIMeta integration (3.1 — Pydantic Enum Leveraging):
5
5
  * -------------------------------------------------------
6
6
  * Option sources (in priority order):
7
- * 1. `props.options` — from uniforms bridge (schema.enum)
8
- * 2. `props.schema.ui_meta.options` human-friendly options from enrich_schema()
7
+ * 1. Remote API (`ui_meta.source_url`)
8
+ * 2. `props.options` from uniforms bridge (schema.enum)
9
+ * 3. `props.schema.ui_meta.options` — human-friendly options from enrich_schema()
9
10
  * These are objects like `{ value: "draft", label: "Draft" }` generated
10
11
  * from Literal["draft", ...] or Python Enum types.
11
- * 3. `props.allowedValues` — legacy uniforms fallback
12
+ * 4. `props.allowedValues` — legacy uniforms fallback
12
13
  *
13
14
  * The ui_meta.options labels are preferred when present because they are
14
15
  * already title-cased by `enrich_schema` and may carry developer-supplied
@@ -1 +1 @@
1
- {"version":3,"file":"SelectField.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/SelectField.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,GAAG,gCA6FjC,CAAC;AAEF,eAAO,MAAM,WAAW,6CAAwB,CAAC"}
1
+ {"version":3,"file":"SelectField.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/SelectField.tsx"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,GAAG,gCAiHjC,CAAC;AAEF,eAAO,MAAM,WAAW,6CAAwB,CAAC"}
package/dist/index.js CHANGED
@@ -2372,7 +2372,21 @@ k(Mn);
2372
2372
  //#endregion
2373
2373
  //#region src/components/form/fields/SelectField.tsx
2374
2374
  var Nn = (e) => {
2375
- let { id: t, label: n, onChange: r, value: i, disabled: a, error: o, showInlineError: s, placeholder: c, required: l, compact: u, options: d, allowedValues: f } = e, p = e.field ?? {}, m = Array.isArray(p.ui_meta?.options) ? p.ui_meta.options : void 0, h = g(() => m && m.length > 0 ? m.map((e) => ({
2375
+ let { id: t, label: n, onChange: r, value: i, disabled: a, error: o, showInlineError: s, placeholder: c, required: l, compact: u, options: d, allowedValues: f } = e, p = e.field ?? {}, m = p.ui_meta, _ = Mt(), y = Array.isArray(m?.options) ? m.options : void 0, [b, x] = v([]);
2376
+ h(() => {
2377
+ let e = m?.source_url;
2378
+ e && _(e).then((e) => e.json()).then((e) => {
2379
+ let t = m?.source_map?.value || "items";
2380
+ x((e?.[t] ?? []).map((e) => {
2381
+ let t = typeof e == "string" ? e : e.value || e.id || e.name || String(e), n = typeof e == "string" ? e : e.label || e.name || t;
2382
+ return {
2383
+ value: String(t),
2384
+ label: String(n)
2385
+ };
2386
+ }));
2387
+ }).catch((e) => console.warn("[SelectField] Failed to load remote options", e));
2388
+ }, [m?.source_url, m?.source_map?.value]);
2389
+ let S = g(() => b.length > 0 ? b : y && y.length > 0 ? y.map((e) => ({
2376
2390
  label: e.label || e.value,
2377
2391
  value: String(e.value)
2378
2392
  })) : d && d.length > 0 ? d.map((e) => ({
@@ -2382,10 +2396,11 @@ var Nn = (e) => {
2382
2396
  label: String(e).replace(/_/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()),
2383
2397
  value: String(e)
2384
2398
  })) : [], [
2385
- m,
2399
+ b,
2400
+ y,
2386
2401
  d,
2387
2402
  f
2388
- ]), _ = c ?? p.ui_meta?.placeholder ?? "Select...";
2403
+ ]), C = c ?? p.ui_meta?.placeholder ?? "Select...";
2389
2404
  return /* @__PURE__ */ T(J, {
2390
2405
  gap: "$1",
2391
2406
  marginBottom: u ? 0 : "$2",
@@ -2407,8 +2422,8 @@ var Nn = (e) => {
2407
2422
  /* @__PURE__ */ w(ne, {
2408
2423
  id: t,
2409
2424
  value: String(i ?? ""),
2410
- options: h,
2411
- placeholder: _,
2425
+ options: S,
2426
+ placeholder: C,
2412
2427
  disabled: a,
2413
2428
  onChange: (e) => {
2414
2429
  r(typeof e == "string" ? e : e?.target?.value ?? "");
@@ -2834,27 +2849,28 @@ var Wn = (e) => {
2834
2849
  return null;
2835
2850
  }).filter((e) => !!e) : [];
2836
2851
  }, Gn = (e) => Array.isArray(e) ? e.map((e) => e == null ? "" : String(e)).filter((e) => e.length > 0) : [], Kn = (e) => {
2837
- let { t } = $("desk"), { id: n, value: r, onChange: i, disabled: a, error: o, showInlineError: s, placeholder: c, compact: l } = e, [u, d] = v(""), [f, p] = v([]), m = e?.schema?.ui_meta || e?.field?.ui_meta || e?.ui_meta;
2852
+ let { t } = $("desk"), { id: n, value: r, onChange: i, disabled: a, error: o, showInlineError: s, placeholder: c, compact: l } = e, [u, d] = v(""), [f, p] = v([]), m = Mt(), _ = e?.schema?.ui_meta || e?.field?.ui_meta || e?.ui_meta;
2838
2853
  h(() => {
2839
- let e = m?.source_url;
2840
- e && fetch(e).then((e) => e.json()).then((e) => {
2841
- p((e?.items ?? []).map((e) => {
2842
- let t = typeof e == "string" ? e : e.value || e.id || String(e);
2854
+ let e = _?.source_url;
2855
+ e && m(e).then((e) => e.json()).then((e) => {
2856
+ let t = _?.source_map?.value || "items";
2857
+ p((e?.[t] ?? []).map((e) => {
2858
+ let t = typeof e == "string" ? e : e.value || e.id || e.name || String(e);
2843
2859
  return {
2844
2860
  value: t,
2845
2861
  label: typeof e == "string" ? e : e.label || e.name || t
2846
2862
  };
2847
2863
  }));
2848
2864
  }).catch((e) => console.warn("[MultiSelect] Failed to load remote options", e));
2849
- }, [m?.source_url]);
2850
- let _ = g(() => Wn(e), [e]), y = g(() => f.length > 0 ? f : _, [_, f]), b = Gn(r), x = g(() => new Set(b), [b]), { model: S } = j(), { data: C } = pe(), E = m?.guard?.prevent_self_remove ?? [], D = (e) => E.includes(e) && !!C?.id && !!S?.id && C.id === S.id, O = g(() => {
2865
+ }, [_?.source_url]);
2866
+ let y = g(() => Wn(e), [e]), b = g(() => f.length > 0 ? f : y, [y, f]), x = Gn(r), S = g(() => new Set(x), [x]), { model: C } = j(), { data: E } = pe(), D = _?.guard?.prevent_self_remove ?? [], O = (e) => D.includes(e) && !!E?.id && !!C?.id && E.id === C.id, k = g(() => {
2851
2867
  let e = u.trim().toLowerCase();
2852
- return e ? y.filter((t) => t.label.toLowerCase().includes(e) || t.value.toLowerCase().includes(e)) : y;
2853
- }, [y, u]), k = (e) => {
2868
+ return e ? b.filter((t) => t.label.toLowerCase().includes(e) || t.value.toLowerCase().includes(e)) : b;
2869
+ }, [b, u]), A = (e) => {
2854
2870
  if (a) return;
2855
- let t = x.has(e);
2856
- t && D(e) || i(t ? b.filter((t) => t !== e) : [...b, e]);
2857
- }, A = O.filter((e) => !x.has(e.value));
2871
+ let t = S.has(e);
2872
+ t && O(e) || i(t ? x.filter((t) => t !== e) : [...x, e]);
2873
+ }, M = k.filter((e) => !S.has(e.value));
2858
2874
  return /* @__PURE__ */ T(J, {
2859
2875
  gap: "$3",
2860
2876
  marginBottom: l ? 0 : "$4",
@@ -2868,7 +2884,7 @@ var Wn = (e) => {
2868
2884
  size: "sm",
2869
2885
  error: !!o
2870
2886
  }),
2871
- b.length > 0 && /* @__PURE__ */ T(J, {
2887
+ x.length > 0 && /* @__PURE__ */ T(J, {
2872
2888
  gap: "$2",
2873
2889
  style: {
2874
2890
  marginTop: 12,
@@ -2881,8 +2897,8 @@ var Wn = (e) => {
2881
2897
  children: t("Assigned")
2882
2898
  }), /* @__PURE__ */ w(q, {
2883
2899
  flexWrap: "wrap",
2884
- children: b.map((e) => {
2885
- let t = y.find((t) => t.value === e)?.label ?? e, n = D(e);
2900
+ children: x.map((e) => {
2901
+ let t = b.find((t) => t.value === e)?.label ?? e, n = O(e);
2886
2902
  return /* @__PURE__ */ T(N, {
2887
2903
  variant: "primary",
2888
2904
  size: "sm",
@@ -2891,7 +2907,7 @@ var Wn = (e) => {
2891
2907
  marginBottom: 8,
2892
2908
  marginTop: 8
2893
2909
  },
2894
- onPress: () => k(e),
2910
+ onPress: () => A(e),
2895
2911
  disabled: a || n,
2896
2912
  children: [
2897
2913
  t,
@@ -2902,7 +2918,7 @@ var Wn = (e) => {
2902
2918
  })
2903
2919
  })]
2904
2920
  }),
2905
- A.length > 0 && /* @__PURE__ */ T(J, {
2921
+ M.length > 0 && /* @__PURE__ */ T(J, {
2906
2922
  gap: "$2",
2907
2923
  style: { marginBottom: 8 },
2908
2924
  children: [/* @__PURE__ */ w(U, {
@@ -2912,7 +2928,7 @@ var Wn = (e) => {
2912
2928
  children: t("Available")
2913
2929
  }), /* @__PURE__ */ w(q, {
2914
2930
  flexWrap: "wrap",
2915
- children: A.map((e) => /* @__PURE__ */ w(N, {
2931
+ children: M.map((e) => /* @__PURE__ */ w(N, {
2916
2932
  variant: "default",
2917
2933
  size: "sm",
2918
2934
  style: {
@@ -2920,13 +2936,13 @@ var Wn = (e) => {
2920
2936
  marginBottom: 8,
2921
2937
  marginTop: 8
2922
2938
  },
2923
- onPress: () => k(e.value),
2939
+ onPress: () => A(e.value),
2924
2940
  disabled: a,
2925
2941
  children: e.label
2926
2942
  }, e.value))
2927
2943
  })]
2928
2944
  }),
2929
- O.length === 0 && /* @__PURE__ */ w(W, {
2945
+ k.length === 0 && /* @__PURE__ */ w(W, {
2930
2946
  size: "sm",
2931
2947
  color: "$colorMuted",
2932
2948
  children: u ? `No roles matching "${u}"` : "No roles available"
@@ -3125,7 +3141,7 @@ var Jn = new class {
3125
3141
  link: u
3126
3142
  });
3127
3143
  let d = Array.isArray(e.options) && e.options.length > 0 ? e.options : void 0, f = Array.isArray(n.ui_meta?.options) && n.ui_meta.options.length > 0 ? n.ui_meta.options : void 0;
3128
- if (d || f) return /* @__PURE__ */ w(Nn, { ...f ? {
3144
+ if (i === "select" || d || f) return /* @__PURE__ */ w(Nn, { ...f ? {
3129
3145
  ...e,
3130
3146
  options: f
3131
3147
  } : e });