@almadar/ui 4.14.0 → 4.15.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.
@@ -8486,11 +8486,13 @@ function TraitFrame({
8486
8486
  fallback = null
8487
8487
  }) {
8488
8488
  const content = useTraitContent(traitName);
8489
+ const entitySchema = useEntitySchemaOptional();
8490
+ const orbital = entitySchema?.orbitalsByTrait.get(traitName);
8489
8491
  if (!content) {
8490
8492
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fallback });
8491
8493
  }
8492
8494
  const SlotContentRenderer2 = getSlotContentRenderer();
8493
- return /* @__PURE__ */ jsxRuntime.jsx(
8495
+ const rendered = /* @__PURE__ */ jsxRuntime.jsx(
8494
8496
  SlotContentRenderer2,
8495
8497
  {
8496
8498
  content,
@@ -8498,6 +8500,10 @@ function TraitFrame({
8498
8500
  }
8499
8501
  }
8500
8502
  );
8503
+ if (!orbital) {
8504
+ return rendered;
8505
+ }
8506
+ return /* @__PURE__ */ jsxRuntime.jsx(TraitScopeProvider, { orbital, trait: traitName, children: rendered });
8501
8507
  }
8502
8508
  function getSlotContentRenderer() {
8503
8509
  if (_slotContentRenderer) return _slotContentRenderer;
@@ -8509,6 +8515,8 @@ var _slotContentRenderer;
8509
8515
  var init_TraitFrame = __esm({
8510
8516
  "components/atoms/TraitFrame.tsx"() {
8511
8517
  init_UISlotContext();
8518
+ init_TraitScopeProvider();
8519
+ init_EntitySchemaContext();
8512
8520
  TraitFrame.displayName = "TraitFrame";
8513
8521
  _slotContentRenderer = null;
8514
8522
  }
@@ -46982,6 +46990,40 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
46982
46990
  function isPatternConfig(value) {
46983
46991
  return value !== null && typeof value === "object" && !Array.isArray(value) && "type" in value && typeof value.type === "string";
46984
46992
  }
46993
+ function isFnFormLambda(value) {
46994
+ return Array.isArray(value) && value.length === 3 && value[0] === "fn" && typeof value[1] === "string" && value[2] !== null && typeof value[2] === "object";
46995
+ }
46996
+ function resolveLambdaBindings(body, argName, arg) {
46997
+ const prefix = `@${argName}.`;
46998
+ const lookup = (path) => {
46999
+ let cur = arg;
47000
+ for (const seg of path.split(".")) {
47001
+ if (cur === null || cur === void 0) return void 0;
47002
+ if (typeof cur !== "object") return void 0;
47003
+ cur = cur[seg];
47004
+ }
47005
+ return cur;
47006
+ };
47007
+ if (typeof body === "string") {
47008
+ if (body === `@${argName}`) return arg;
47009
+ if (body.startsWith(prefix)) {
47010
+ const v = lookup(body.slice(prefix.length));
47011
+ return v === void 0 || v === null ? "" : v;
47012
+ }
47013
+ return body;
47014
+ }
47015
+ if (Array.isArray(body)) {
47016
+ return body.map((b) => resolveLambdaBindings(b, argName, arg));
47017
+ }
47018
+ if (body !== null && typeof body === "object") {
47019
+ const out = {};
47020
+ for (const [k, v] of Object.entries(body)) {
47021
+ out[k] = resolveLambdaBindings(v, argName, arg);
47022
+ }
47023
+ return out;
47024
+ }
47025
+ return body;
47026
+ }
46985
47027
  function renderPatternProps(props, onDismiss) {
46986
47028
  const rendered = {};
46987
47029
  for (const [key, value] of Object.entries(props)) {
@@ -46997,6 +47039,24 @@ function renderPatternProps(props, onDismiss) {
46997
47039
  priority: 0
46998
47040
  };
46999
47041
  rendered[key] = /* @__PURE__ */ jsxRuntime.jsx(SlotContentRenderer, { content: childContent, onDismiss });
47042
+ } else if (isFnFormLambda(value)) {
47043
+ const [, argName, body] = value;
47044
+ const lambdaBody = body;
47045
+ rendered[key] = (item, index) => {
47046
+ const resolvedBody = resolveLambdaBindings(lambdaBody, argName, item);
47047
+ if (!isPatternConfig(resolvedBody)) {
47048
+ return null;
47049
+ }
47050
+ const childContent = {
47051
+ id: `lambda-${key}-${index}`,
47052
+ pattern: resolvedBody.type,
47053
+ props: Object.fromEntries(
47054
+ Object.entries(resolvedBody).filter(([k]) => k !== "type")
47055
+ ),
47056
+ priority: 0
47057
+ };
47058
+ return /* @__PURE__ */ jsxRuntime.jsx(SlotContentRenderer, { content: childContent, onDismiss });
47059
+ };
47000
47060
  } else {
47001
47061
  rendered[key] = value;
47002
47062
  }
package/dist/avl/index.js CHANGED
@@ -8440,11 +8440,13 @@ function TraitFrame({
8440
8440
  fallback = null
8441
8441
  }) {
8442
8442
  const content = useTraitContent(traitName);
8443
+ const entitySchema = useEntitySchemaOptional();
8444
+ const orbital = entitySchema?.orbitalsByTrait.get(traitName);
8443
8445
  if (!content) {
8444
8446
  return /* @__PURE__ */ jsx(Fragment, { children: fallback });
8445
8447
  }
8446
8448
  const SlotContentRenderer2 = getSlotContentRenderer();
8447
- return /* @__PURE__ */ jsx(
8449
+ const rendered = /* @__PURE__ */ jsx(
8448
8450
  SlotContentRenderer2,
8449
8451
  {
8450
8452
  content,
@@ -8452,6 +8454,10 @@ function TraitFrame({
8452
8454
  }
8453
8455
  }
8454
8456
  );
8457
+ if (!orbital) {
8458
+ return rendered;
8459
+ }
8460
+ return /* @__PURE__ */ jsx(TraitScopeProvider, { orbital, trait: traitName, children: rendered });
8455
8461
  }
8456
8462
  function getSlotContentRenderer() {
8457
8463
  if (_slotContentRenderer) return _slotContentRenderer;
@@ -8463,6 +8469,8 @@ var _slotContentRenderer;
8463
8469
  var init_TraitFrame = __esm({
8464
8470
  "components/atoms/TraitFrame.tsx"() {
8465
8471
  init_UISlotContext();
8472
+ init_TraitScopeProvider();
8473
+ init_EntitySchemaContext();
8466
8474
  TraitFrame.displayName = "TraitFrame";
8467
8475
  _slotContentRenderer = null;
8468
8476
  }
@@ -46936,6 +46944,40 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
46936
46944
  function isPatternConfig(value) {
46937
46945
  return value !== null && typeof value === "object" && !Array.isArray(value) && "type" in value && typeof value.type === "string";
46938
46946
  }
46947
+ function isFnFormLambda(value) {
46948
+ return Array.isArray(value) && value.length === 3 && value[0] === "fn" && typeof value[1] === "string" && value[2] !== null && typeof value[2] === "object";
46949
+ }
46950
+ function resolveLambdaBindings(body, argName, arg) {
46951
+ const prefix = `@${argName}.`;
46952
+ const lookup = (path) => {
46953
+ let cur = arg;
46954
+ for (const seg of path.split(".")) {
46955
+ if (cur === null || cur === void 0) return void 0;
46956
+ if (typeof cur !== "object") return void 0;
46957
+ cur = cur[seg];
46958
+ }
46959
+ return cur;
46960
+ };
46961
+ if (typeof body === "string") {
46962
+ if (body === `@${argName}`) return arg;
46963
+ if (body.startsWith(prefix)) {
46964
+ const v = lookup(body.slice(prefix.length));
46965
+ return v === void 0 || v === null ? "" : v;
46966
+ }
46967
+ return body;
46968
+ }
46969
+ if (Array.isArray(body)) {
46970
+ return body.map((b) => resolveLambdaBindings(b, argName, arg));
46971
+ }
46972
+ if (body !== null && typeof body === "object") {
46973
+ const out = {};
46974
+ for (const [k, v] of Object.entries(body)) {
46975
+ out[k] = resolveLambdaBindings(v, argName, arg);
46976
+ }
46977
+ return out;
46978
+ }
46979
+ return body;
46980
+ }
46939
46981
  function renderPatternProps(props, onDismiss) {
46940
46982
  const rendered = {};
46941
46983
  for (const [key, value] of Object.entries(props)) {
@@ -46951,6 +46993,24 @@ function renderPatternProps(props, onDismiss) {
46951
46993
  priority: 0
46952
46994
  };
46953
46995
  rendered[key] = /* @__PURE__ */ jsx(SlotContentRenderer, { content: childContent, onDismiss });
46996
+ } else if (isFnFormLambda(value)) {
46997
+ const [, argName, body] = value;
46998
+ const lambdaBody = body;
46999
+ rendered[key] = (item, index) => {
47000
+ const resolvedBody = resolveLambdaBindings(lambdaBody, argName, item);
47001
+ if (!isPatternConfig(resolvedBody)) {
47002
+ return null;
47003
+ }
47004
+ const childContent = {
47005
+ id: `lambda-${key}-${index}`,
47006
+ pattern: resolvedBody.type,
47007
+ props: Object.fromEntries(
47008
+ Object.entries(resolvedBody).filter(([k]) => k !== "type")
47009
+ ),
47010
+ priority: 0
47011
+ };
47012
+ return /* @__PURE__ */ jsx(SlotContentRenderer, { content: childContent, onDismiss });
47013
+ };
46954
47014
  } else {
46955
47015
  rendered[key] = value;
46956
47016
  }
@@ -37749,6 +37749,40 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
37749
37749
  function isPatternConfig(value) {
37750
37750
  return value !== null && typeof value === "object" && !Array.isArray(value) && "type" in value && typeof value.type === "string";
37751
37751
  }
37752
+ function isFnFormLambda(value) {
37753
+ return Array.isArray(value) && value.length === 3 && value[0] === "fn" && typeof value[1] === "string" && value[2] !== null && typeof value[2] === "object";
37754
+ }
37755
+ function resolveLambdaBindings(body, argName, arg) {
37756
+ const prefix = `@${argName}.`;
37757
+ const lookup = (path) => {
37758
+ let cur = arg;
37759
+ for (const seg of path.split(".")) {
37760
+ if (cur === null || cur === void 0) return void 0;
37761
+ if (typeof cur !== "object") return void 0;
37762
+ cur = cur[seg];
37763
+ }
37764
+ return cur;
37765
+ };
37766
+ if (typeof body === "string") {
37767
+ if (body === `@${argName}`) return arg;
37768
+ if (body.startsWith(prefix)) {
37769
+ const v = lookup(body.slice(prefix.length));
37770
+ return v === void 0 || v === null ? "" : v;
37771
+ }
37772
+ return body;
37773
+ }
37774
+ if (Array.isArray(body)) {
37775
+ return body.map((b) => resolveLambdaBindings(b, argName, arg));
37776
+ }
37777
+ if (body !== null && typeof body === "object") {
37778
+ const out = {};
37779
+ for (const [k, v] of Object.entries(body)) {
37780
+ out[k] = resolveLambdaBindings(v, argName, arg);
37781
+ }
37782
+ return out;
37783
+ }
37784
+ return body;
37785
+ }
37752
37786
  function renderPatternProps(props, onDismiss) {
37753
37787
  const rendered = {};
37754
37788
  for (const [key, value] of Object.entries(props)) {
@@ -37764,6 +37798,24 @@ function renderPatternProps(props, onDismiss) {
37764
37798
  priority: 0
37765
37799
  };
37766
37800
  rendered[key] = /* @__PURE__ */ jsxRuntime.jsx(SlotContentRenderer, { content: childContent, onDismiss });
37801
+ } else if (isFnFormLambda(value)) {
37802
+ const [, argName, body] = value;
37803
+ const lambdaBody = body;
37804
+ rendered[key] = (item, index) => {
37805
+ const resolvedBody = resolveLambdaBindings(lambdaBody, argName, item);
37806
+ if (!isPatternConfig(resolvedBody)) {
37807
+ return null;
37808
+ }
37809
+ const childContent = {
37810
+ id: `lambda-${key}-${index}`,
37811
+ pattern: resolvedBody.type,
37812
+ props: Object.fromEntries(
37813
+ Object.entries(resolvedBody).filter(([k]) => k !== "type")
37814
+ ),
37815
+ priority: 0
37816
+ };
37817
+ return /* @__PURE__ */ jsxRuntime.jsx(SlotContentRenderer, { content: childContent, onDismiss });
37818
+ };
37767
37819
  } else {
37768
37820
  rendered[key] = value;
37769
37821
  }
@@ -38001,11 +38053,13 @@ function TraitFrame({
38001
38053
  fallback = null
38002
38054
  }) {
38003
38055
  const content = useTraitContent(traitName);
38056
+ const entitySchema = useEntitySchemaOptional();
38057
+ const orbital = entitySchema?.orbitalsByTrait.get(traitName);
38004
38058
  if (!content) {
38005
38059
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fallback });
38006
38060
  }
38007
38061
  const SlotContentRenderer2 = getSlotContentRenderer();
38008
- return /* @__PURE__ */ jsxRuntime.jsx(
38062
+ const rendered = /* @__PURE__ */ jsxRuntime.jsx(
38009
38063
  SlotContentRenderer2,
38010
38064
  {
38011
38065
  content,
@@ -38013,6 +38067,10 @@ function TraitFrame({
38013
38067
  }
38014
38068
  }
38015
38069
  );
38070
+ if (!orbital) {
38071
+ return rendered;
38072
+ }
38073
+ return /* @__PURE__ */ jsxRuntime.jsx(providers.TraitScopeProvider, { orbital, trait: traitName, children: rendered });
38016
38074
  }
38017
38075
  function getSlotContentRenderer() {
38018
38076
  if (_slotContentRenderer) return _slotContentRenderer;
@@ -38023,6 +38081,7 @@ function getSlotContentRenderer() {
38023
38081
  var _slotContentRenderer;
38024
38082
  var init_TraitFrame = __esm({
38025
38083
  "components/atoms/TraitFrame.tsx"() {
38084
+ init_EntitySchemaContext();
38026
38085
  TraitFrame.displayName = "TraitFrame";
38027
38086
  _slotContentRenderer = null;
38028
38087
  }
@@ -37704,6 +37704,40 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
37704
37704
  function isPatternConfig(value) {
37705
37705
  return value !== null && typeof value === "object" && !Array.isArray(value) && "type" in value && typeof value.type === "string";
37706
37706
  }
37707
+ function isFnFormLambda(value) {
37708
+ return Array.isArray(value) && value.length === 3 && value[0] === "fn" && typeof value[1] === "string" && value[2] !== null && typeof value[2] === "object";
37709
+ }
37710
+ function resolveLambdaBindings(body, argName, arg) {
37711
+ const prefix = `@${argName}.`;
37712
+ const lookup = (path) => {
37713
+ let cur = arg;
37714
+ for (const seg of path.split(".")) {
37715
+ if (cur === null || cur === void 0) return void 0;
37716
+ if (typeof cur !== "object") return void 0;
37717
+ cur = cur[seg];
37718
+ }
37719
+ return cur;
37720
+ };
37721
+ if (typeof body === "string") {
37722
+ if (body === `@${argName}`) return arg;
37723
+ if (body.startsWith(prefix)) {
37724
+ const v = lookup(body.slice(prefix.length));
37725
+ return v === void 0 || v === null ? "" : v;
37726
+ }
37727
+ return body;
37728
+ }
37729
+ if (Array.isArray(body)) {
37730
+ return body.map((b) => resolveLambdaBindings(b, argName, arg));
37731
+ }
37732
+ if (body !== null && typeof body === "object") {
37733
+ const out = {};
37734
+ for (const [k, v] of Object.entries(body)) {
37735
+ out[k] = resolveLambdaBindings(v, argName, arg);
37736
+ }
37737
+ return out;
37738
+ }
37739
+ return body;
37740
+ }
37707
37741
  function renderPatternProps(props, onDismiss) {
37708
37742
  const rendered = {};
37709
37743
  for (const [key, value] of Object.entries(props)) {
@@ -37719,6 +37753,24 @@ function renderPatternProps(props, onDismiss) {
37719
37753
  priority: 0
37720
37754
  };
37721
37755
  rendered[key] = /* @__PURE__ */ jsx(SlotContentRenderer, { content: childContent, onDismiss });
37756
+ } else if (isFnFormLambda(value)) {
37757
+ const [, argName, body] = value;
37758
+ const lambdaBody = body;
37759
+ rendered[key] = (item, index) => {
37760
+ const resolvedBody = resolveLambdaBindings(lambdaBody, argName, item);
37761
+ if (!isPatternConfig(resolvedBody)) {
37762
+ return null;
37763
+ }
37764
+ const childContent = {
37765
+ id: `lambda-${key}-${index}`,
37766
+ pattern: resolvedBody.type,
37767
+ props: Object.fromEntries(
37768
+ Object.entries(resolvedBody).filter(([k]) => k !== "type")
37769
+ ),
37770
+ priority: 0
37771
+ };
37772
+ return /* @__PURE__ */ jsx(SlotContentRenderer, { content: childContent, onDismiss });
37773
+ };
37722
37774
  } else {
37723
37775
  rendered[key] = value;
37724
37776
  }
@@ -37956,11 +38008,13 @@ function TraitFrame({
37956
38008
  fallback = null
37957
38009
  }) {
37958
38010
  const content = useTraitContent(traitName);
38011
+ const entitySchema = useEntitySchemaOptional();
38012
+ const orbital = entitySchema?.orbitalsByTrait.get(traitName);
37959
38013
  if (!content) {
37960
38014
  return /* @__PURE__ */ jsx(Fragment, { children: fallback });
37961
38015
  }
37962
38016
  const SlotContentRenderer2 = getSlotContentRenderer();
37963
- return /* @__PURE__ */ jsx(
38017
+ const rendered = /* @__PURE__ */ jsx(
37964
38018
  SlotContentRenderer2,
37965
38019
  {
37966
38020
  content,
@@ -37968,6 +38022,10 @@ function TraitFrame({
37968
38022
  }
37969
38023
  }
37970
38024
  );
38025
+ if (!orbital) {
38026
+ return rendered;
38027
+ }
38028
+ return /* @__PURE__ */ jsx(TraitScopeProvider, { orbital, trait: traitName, children: rendered });
37971
38029
  }
37972
38030
  function getSlotContentRenderer() {
37973
38031
  if (_slotContentRenderer) return _slotContentRenderer;
@@ -37978,6 +38036,7 @@ function getSlotContentRenderer() {
37978
38036
  var _slotContentRenderer;
37979
38037
  var init_TraitFrame = __esm({
37980
38038
  "components/atoms/TraitFrame.tsx"() {
38039
+ init_EntitySchemaContext();
37981
38040
  TraitFrame.displayName = "TraitFrame";
37982
38041
  _slotContentRenderer = null;
37983
38042
  }
@@ -4945,11 +4945,13 @@ function TraitFrame({
4945
4945
  fallback = null
4946
4946
  }) {
4947
4947
  const content = useTraitContent(traitName);
4948
+ const entitySchema = useEntitySchemaOptional();
4949
+ const orbital = entitySchema?.orbitalsByTrait.get(traitName);
4948
4950
  if (!content) {
4949
4951
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fallback });
4950
4952
  }
4951
4953
  const SlotContentRenderer2 = getSlotContentRenderer();
4952
- return /* @__PURE__ */ jsxRuntime.jsx(
4954
+ const rendered = /* @__PURE__ */ jsxRuntime.jsx(
4953
4955
  SlotContentRenderer2,
4954
4956
  {
4955
4957
  content,
@@ -4957,6 +4959,10 @@ function TraitFrame({
4957
4959
  }
4958
4960
  }
4959
4961
  );
4962
+ if (!orbital) {
4963
+ return rendered;
4964
+ }
4965
+ return /* @__PURE__ */ jsxRuntime.jsx(providers.TraitScopeProvider, { orbital, trait: traitName, children: rendered });
4960
4966
  }
4961
4967
  function getSlotContentRenderer() {
4962
4968
  if (_slotContentRenderer) return _slotContentRenderer;
@@ -4967,6 +4973,7 @@ function getSlotContentRenderer() {
4967
4973
  var _slotContentRenderer;
4968
4974
  var init_TraitFrame = __esm({
4969
4975
  "components/atoms/TraitFrame.tsx"() {
4976
+ init_EntitySchemaContext();
4970
4977
  TraitFrame.displayName = "TraitFrame";
4971
4978
  _slotContentRenderer = null;
4972
4979
  }
@@ -38262,6 +38269,40 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
38262
38269
  function isPatternConfig(value) {
38263
38270
  return value !== null && typeof value === "object" && !Array.isArray(value) && "type" in value && typeof value.type === "string";
38264
38271
  }
38272
+ function isFnFormLambda(value) {
38273
+ return Array.isArray(value) && value.length === 3 && value[0] === "fn" && typeof value[1] === "string" && value[2] !== null && typeof value[2] === "object";
38274
+ }
38275
+ function resolveLambdaBindings(body, argName, arg) {
38276
+ const prefix = `@${argName}.`;
38277
+ const lookup = (path) => {
38278
+ let cur = arg;
38279
+ for (const seg of path.split(".")) {
38280
+ if (cur === null || cur === void 0) return void 0;
38281
+ if (typeof cur !== "object") return void 0;
38282
+ cur = cur[seg];
38283
+ }
38284
+ return cur;
38285
+ };
38286
+ if (typeof body === "string") {
38287
+ if (body === `@${argName}`) return arg;
38288
+ if (body.startsWith(prefix)) {
38289
+ const v = lookup(body.slice(prefix.length));
38290
+ return v === void 0 || v === null ? "" : v;
38291
+ }
38292
+ return body;
38293
+ }
38294
+ if (Array.isArray(body)) {
38295
+ return body.map((b) => resolveLambdaBindings(b, argName, arg));
38296
+ }
38297
+ if (body !== null && typeof body === "object") {
38298
+ const out = {};
38299
+ for (const [k, v] of Object.entries(body)) {
38300
+ out[k] = resolveLambdaBindings(v, argName, arg);
38301
+ }
38302
+ return out;
38303
+ }
38304
+ return body;
38305
+ }
38265
38306
  function renderPatternProps(props, onDismiss) {
38266
38307
  const rendered = {};
38267
38308
  for (const [key, value] of Object.entries(props)) {
@@ -38277,6 +38318,24 @@ function renderPatternProps(props, onDismiss) {
38277
38318
  priority: 0
38278
38319
  };
38279
38320
  rendered[key] = /* @__PURE__ */ jsxRuntime.jsx(SlotContentRenderer, { content: childContent, onDismiss });
38321
+ } else if (isFnFormLambda(value)) {
38322
+ const [, argName, body] = value;
38323
+ const lambdaBody = body;
38324
+ rendered[key] = (item, index) => {
38325
+ const resolvedBody = resolveLambdaBindings(lambdaBody, argName, item);
38326
+ if (!isPatternConfig(resolvedBody)) {
38327
+ return null;
38328
+ }
38329
+ const childContent = {
38330
+ id: `lambda-${key}-${index}`,
38331
+ pattern: resolvedBody.type,
38332
+ props: Object.fromEntries(
38333
+ Object.entries(resolvedBody).filter(([k]) => k !== "type")
38334
+ ),
38335
+ priority: 0
38336
+ };
38337
+ return /* @__PURE__ */ jsxRuntime.jsx(SlotContentRenderer, { content: childContent, onDismiss });
38338
+ };
38280
38339
  } else {
38281
38340
  rendered[key] = value;
38282
38341
  }
@@ -38978,7 +39037,7 @@ function OrbitalProvider({
38978
39037
  }
38979
39038
  OrbitalProvider.displayName = "OrbitalProvider";
38980
39039
  var TraitScopeContext = React115.createContext(null);
38981
- function TraitScopeProvider2({
39040
+ function TraitScopeProvider3({
38982
39041
  orbital,
38983
39042
  trait,
38984
39043
  children
@@ -39028,7 +39087,7 @@ exports.OfflineModeProvider = OfflineModeProvider;
39028
39087
  exports.OrbitalProvider = OrbitalProvider;
39029
39088
  exports.SelectionContext = SelectionContext;
39030
39089
  exports.SelectionProvider = SelectionProvider;
39031
- exports.TraitScopeProvider = TraitScopeProvider2;
39090
+ exports.TraitScopeProvider = TraitScopeProvider3;
39032
39091
  exports.VerificationProvider = VerificationProvider;
39033
39092
  exports.useOfflineMode = useOfflineMode;
39034
39093
  exports.useOptionalOfflineMode = useOptionalOfflineMode;
@@ -4900,11 +4900,13 @@ function TraitFrame({
4900
4900
  fallback = null
4901
4901
  }) {
4902
4902
  const content = useTraitContent(traitName);
4903
+ const entitySchema = useEntitySchemaOptional();
4904
+ const orbital = entitySchema?.orbitalsByTrait.get(traitName);
4903
4905
  if (!content) {
4904
4906
  return /* @__PURE__ */ jsx(Fragment, { children: fallback });
4905
4907
  }
4906
4908
  const SlotContentRenderer2 = getSlotContentRenderer();
4907
- return /* @__PURE__ */ jsx(
4909
+ const rendered = /* @__PURE__ */ jsx(
4908
4910
  SlotContentRenderer2,
4909
4911
  {
4910
4912
  content,
@@ -4912,6 +4914,10 @@ function TraitFrame({
4912
4914
  }
4913
4915
  }
4914
4916
  );
4917
+ if (!orbital) {
4918
+ return rendered;
4919
+ }
4920
+ return /* @__PURE__ */ jsx(TraitScopeProvider, { orbital, trait: traitName, children: rendered });
4915
4921
  }
4916
4922
  function getSlotContentRenderer() {
4917
4923
  if (_slotContentRenderer) return _slotContentRenderer;
@@ -4922,6 +4928,7 @@ function getSlotContentRenderer() {
4922
4928
  var _slotContentRenderer;
4923
4929
  var init_TraitFrame = __esm({
4924
4930
  "components/atoms/TraitFrame.tsx"() {
4931
+ init_EntitySchemaContext();
4925
4932
  TraitFrame.displayName = "TraitFrame";
4926
4933
  _slotContentRenderer = null;
4927
4934
  }
@@ -38217,6 +38224,40 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
38217
38224
  function isPatternConfig(value) {
38218
38225
  return value !== null && typeof value === "object" && !Array.isArray(value) && "type" in value && typeof value.type === "string";
38219
38226
  }
38227
+ function isFnFormLambda(value) {
38228
+ return Array.isArray(value) && value.length === 3 && value[0] === "fn" && typeof value[1] === "string" && value[2] !== null && typeof value[2] === "object";
38229
+ }
38230
+ function resolveLambdaBindings(body, argName, arg) {
38231
+ const prefix = `@${argName}.`;
38232
+ const lookup = (path) => {
38233
+ let cur = arg;
38234
+ for (const seg of path.split(".")) {
38235
+ if (cur === null || cur === void 0) return void 0;
38236
+ if (typeof cur !== "object") return void 0;
38237
+ cur = cur[seg];
38238
+ }
38239
+ return cur;
38240
+ };
38241
+ if (typeof body === "string") {
38242
+ if (body === `@${argName}`) return arg;
38243
+ if (body.startsWith(prefix)) {
38244
+ const v = lookup(body.slice(prefix.length));
38245
+ return v === void 0 || v === null ? "" : v;
38246
+ }
38247
+ return body;
38248
+ }
38249
+ if (Array.isArray(body)) {
38250
+ return body.map((b) => resolveLambdaBindings(b, argName, arg));
38251
+ }
38252
+ if (body !== null && typeof body === "object") {
38253
+ const out = {};
38254
+ for (const [k, v] of Object.entries(body)) {
38255
+ out[k] = resolveLambdaBindings(v, argName, arg);
38256
+ }
38257
+ return out;
38258
+ }
38259
+ return body;
38260
+ }
38220
38261
  function renderPatternProps(props, onDismiss) {
38221
38262
  const rendered = {};
38222
38263
  for (const [key, value] of Object.entries(props)) {
@@ -38232,6 +38273,24 @@ function renderPatternProps(props, onDismiss) {
38232
38273
  priority: 0
38233
38274
  };
38234
38275
  rendered[key] = /* @__PURE__ */ jsx(SlotContentRenderer, { content: childContent, onDismiss });
38276
+ } else if (isFnFormLambda(value)) {
38277
+ const [, argName, body] = value;
38278
+ const lambdaBody = body;
38279
+ rendered[key] = (item, index) => {
38280
+ const resolvedBody = resolveLambdaBindings(lambdaBody, argName, item);
38281
+ if (!isPatternConfig(resolvedBody)) {
38282
+ return null;
38283
+ }
38284
+ const childContent = {
38285
+ id: `lambda-${key}-${index}`,
38286
+ pattern: resolvedBody.type,
38287
+ props: Object.fromEntries(
38288
+ Object.entries(resolvedBody).filter(([k]) => k !== "type")
38289
+ ),
38290
+ priority: 0
38291
+ };
38292
+ return /* @__PURE__ */ jsx(SlotContentRenderer, { content: childContent, onDismiss });
38293
+ };
38235
38294
  } else {
38236
38295
  rendered[key] = value;
38237
38296
  }
@@ -38933,7 +38992,7 @@ function OrbitalProvider({
38933
38992
  }
38934
38993
  OrbitalProvider.displayName = "OrbitalProvider";
38935
38994
  var TraitScopeContext = createContext(null);
38936
- function TraitScopeProvider2({
38995
+ function TraitScopeProvider3({
38937
38996
  orbital,
38938
38997
  trait,
38939
38998
  children
@@ -38977,4 +39036,4 @@ function useOptionalOfflineMode() {
38977
39036
  return useContext(OfflineModeContext);
38978
39037
  }
38979
39038
 
38980
- export { EventBusContext2 as EventBusContext, EventBusProvider, OfflineModeProvider, OrbitalProvider, SelectionContext, SelectionProvider, TraitScopeProvider2 as TraitScopeProvider, VerificationProvider, useOfflineMode, useOptionalOfflineMode, useSelection, useSelectionOptional, useTraitScope2 as useTraitScope };
39039
+ export { EventBusContext2 as EventBusContext, EventBusProvider, OfflineModeProvider, OrbitalProvider, SelectionContext, SelectionProvider, TraitScopeProvider3 as TraitScopeProvider, VerificationProvider, useOfflineMode, useOptionalOfflineMode, useSelection, useSelectionOptional, useTraitScope2 as useTraitScope };
@@ -5589,11 +5589,13 @@ function TraitFrame({
5589
5589
  fallback = null
5590
5590
  }) {
5591
5591
  const content = useTraitContent(traitName);
5592
+ const entitySchema = useEntitySchemaOptional();
5593
+ const orbital = entitySchema?.orbitalsByTrait.get(traitName);
5592
5594
  if (!content) {
5593
5595
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fallback });
5594
5596
  }
5595
5597
  const SlotContentRenderer2 = getSlotContentRenderer();
5596
- return /* @__PURE__ */ jsxRuntime.jsx(
5598
+ const rendered = /* @__PURE__ */ jsxRuntime.jsx(
5597
5599
  SlotContentRenderer2,
5598
5600
  {
5599
5601
  content,
@@ -5601,6 +5603,10 @@ function TraitFrame({
5601
5603
  }
5602
5604
  }
5603
5605
  );
5606
+ if (!orbital) {
5607
+ return rendered;
5608
+ }
5609
+ return /* @__PURE__ */ jsxRuntime.jsx(providers.TraitScopeProvider, { orbital, trait: traitName, children: rendered });
5604
5610
  }
5605
5611
  function getSlotContentRenderer() {
5606
5612
  if (_slotContentRenderer) return _slotContentRenderer;
@@ -5611,6 +5617,7 @@ function getSlotContentRenderer() {
5611
5617
  var _slotContentRenderer;
5612
5618
  var init_TraitFrame = __esm({
5613
5619
  "components/atoms/TraitFrame.tsx"() {
5620
+ init_EntitySchemaContext();
5614
5621
  TraitFrame.displayName = "TraitFrame";
5615
5622
  _slotContentRenderer = null;
5616
5623
  }
@@ -37855,6 +37862,40 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
37855
37862
  function isPatternConfig(value) {
37856
37863
  return value !== null && typeof value === "object" && !Array.isArray(value) && "type" in value && typeof value.type === "string";
37857
37864
  }
37865
+ function isFnFormLambda(value) {
37866
+ return Array.isArray(value) && value.length === 3 && value[0] === "fn" && typeof value[1] === "string" && value[2] !== null && typeof value[2] === "object";
37867
+ }
37868
+ function resolveLambdaBindings(body, argName, arg) {
37869
+ const prefix = `@${argName}.`;
37870
+ const lookup = (path) => {
37871
+ let cur = arg;
37872
+ for (const seg of path.split(".")) {
37873
+ if (cur === null || cur === void 0) return void 0;
37874
+ if (typeof cur !== "object") return void 0;
37875
+ cur = cur[seg];
37876
+ }
37877
+ return cur;
37878
+ };
37879
+ if (typeof body === "string") {
37880
+ if (body === `@${argName}`) return arg;
37881
+ if (body.startsWith(prefix)) {
37882
+ const v = lookup(body.slice(prefix.length));
37883
+ return v === void 0 || v === null ? "" : v;
37884
+ }
37885
+ return body;
37886
+ }
37887
+ if (Array.isArray(body)) {
37888
+ return body.map((b) => resolveLambdaBindings(b, argName, arg));
37889
+ }
37890
+ if (body !== null && typeof body === "object") {
37891
+ const out = {};
37892
+ for (const [k, v] of Object.entries(body)) {
37893
+ out[k] = resolveLambdaBindings(v, argName, arg);
37894
+ }
37895
+ return out;
37896
+ }
37897
+ return body;
37898
+ }
37858
37899
  function renderPatternProps(props, onDismiss) {
37859
37900
  const rendered = {};
37860
37901
  for (const [key, value] of Object.entries(props)) {
@@ -37870,6 +37911,24 @@ function renderPatternProps(props, onDismiss) {
37870
37911
  priority: 0
37871
37912
  };
37872
37913
  rendered[key] = /* @__PURE__ */ jsxRuntime.jsx(SlotContentRenderer, { content: childContent, onDismiss });
37914
+ } else if (isFnFormLambda(value)) {
37915
+ const [, argName, body] = value;
37916
+ const lambdaBody = body;
37917
+ rendered[key] = (item, index) => {
37918
+ const resolvedBody = resolveLambdaBindings(lambdaBody, argName, item);
37919
+ if (!isPatternConfig(resolvedBody)) {
37920
+ return null;
37921
+ }
37922
+ const childContent = {
37923
+ id: `lambda-${key}-${index}`,
37924
+ pattern: resolvedBody.type,
37925
+ props: Object.fromEntries(
37926
+ Object.entries(resolvedBody).filter(([k]) => k !== "type")
37927
+ ),
37928
+ priority: 0
37929
+ };
37930
+ return /* @__PURE__ */ jsxRuntime.jsx(SlotContentRenderer, { content: childContent, onDismiss });
37931
+ };
37873
37932
  } else {
37874
37933
  rendered[key] = value;
37875
37934
  }
@@ -5544,11 +5544,13 @@ function TraitFrame({
5544
5544
  fallback = null
5545
5545
  }) {
5546
5546
  const content = useTraitContent(traitName);
5547
+ const entitySchema = useEntitySchemaOptional();
5548
+ const orbital = entitySchema?.orbitalsByTrait.get(traitName);
5547
5549
  if (!content) {
5548
5550
  return /* @__PURE__ */ jsx(Fragment, { children: fallback });
5549
5551
  }
5550
5552
  const SlotContentRenderer2 = getSlotContentRenderer();
5551
- return /* @__PURE__ */ jsx(
5553
+ const rendered = /* @__PURE__ */ jsx(
5552
5554
  SlotContentRenderer2,
5553
5555
  {
5554
5556
  content,
@@ -5556,6 +5558,10 @@ function TraitFrame({
5556
5558
  }
5557
5559
  }
5558
5560
  );
5561
+ if (!orbital) {
5562
+ return rendered;
5563
+ }
5564
+ return /* @__PURE__ */ jsx(TraitScopeProvider, { orbital, trait: traitName, children: rendered });
5559
5565
  }
5560
5566
  function getSlotContentRenderer() {
5561
5567
  if (_slotContentRenderer) return _slotContentRenderer;
@@ -5566,6 +5572,7 @@ function getSlotContentRenderer() {
5566
5572
  var _slotContentRenderer;
5567
5573
  var init_TraitFrame = __esm({
5568
5574
  "components/atoms/TraitFrame.tsx"() {
5575
+ init_EntitySchemaContext();
5569
5576
  TraitFrame.displayName = "TraitFrame";
5570
5577
  _slotContentRenderer = null;
5571
5578
  }
@@ -37810,6 +37817,40 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
37810
37817
  function isPatternConfig(value) {
37811
37818
  return value !== null && typeof value === "object" && !Array.isArray(value) && "type" in value && typeof value.type === "string";
37812
37819
  }
37820
+ function isFnFormLambda(value) {
37821
+ return Array.isArray(value) && value.length === 3 && value[0] === "fn" && typeof value[1] === "string" && value[2] !== null && typeof value[2] === "object";
37822
+ }
37823
+ function resolveLambdaBindings(body, argName, arg) {
37824
+ const prefix = `@${argName}.`;
37825
+ const lookup = (path) => {
37826
+ let cur = arg;
37827
+ for (const seg of path.split(".")) {
37828
+ if (cur === null || cur === void 0) return void 0;
37829
+ if (typeof cur !== "object") return void 0;
37830
+ cur = cur[seg];
37831
+ }
37832
+ return cur;
37833
+ };
37834
+ if (typeof body === "string") {
37835
+ if (body === `@${argName}`) return arg;
37836
+ if (body.startsWith(prefix)) {
37837
+ const v = lookup(body.slice(prefix.length));
37838
+ return v === void 0 || v === null ? "" : v;
37839
+ }
37840
+ return body;
37841
+ }
37842
+ if (Array.isArray(body)) {
37843
+ return body.map((b) => resolveLambdaBindings(b, argName, arg));
37844
+ }
37845
+ if (body !== null && typeof body === "object") {
37846
+ const out = {};
37847
+ for (const [k, v] of Object.entries(body)) {
37848
+ out[k] = resolveLambdaBindings(v, argName, arg);
37849
+ }
37850
+ return out;
37851
+ }
37852
+ return body;
37853
+ }
37813
37854
  function renderPatternProps(props, onDismiss) {
37814
37855
  const rendered = {};
37815
37856
  for (const [key, value] of Object.entries(props)) {
@@ -37825,6 +37866,24 @@ function renderPatternProps(props, onDismiss) {
37825
37866
  priority: 0
37826
37867
  };
37827
37868
  rendered[key] = /* @__PURE__ */ jsx(SlotContentRenderer, { content: childContent, onDismiss });
37869
+ } else if (isFnFormLambda(value)) {
37870
+ const [, argName, body] = value;
37871
+ const lambdaBody = body;
37872
+ rendered[key] = (item, index) => {
37873
+ const resolvedBody = resolveLambdaBindings(lambdaBody, argName, item);
37874
+ if (!isPatternConfig(resolvedBody)) {
37875
+ return null;
37876
+ }
37877
+ const childContent = {
37878
+ id: `lambda-${key}-${index}`,
37879
+ pattern: resolvedBody.type,
37880
+ props: Object.fromEntries(
37881
+ Object.entries(resolvedBody).filter(([k]) => k !== "type")
37882
+ ),
37883
+ priority: 0
37884
+ };
37885
+ return /* @__PURE__ */ jsx(SlotContentRenderer, { content: childContent, onDismiss });
37886
+ };
37828
37887
  } else {
37829
37888
  rendered[key] = value;
37830
37889
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "4.14.0",
3
+ "version": "4.15.0",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "main": "./dist/components/index.js",