@almadar/ui 5.89.0 → 5.91.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 (26) hide show
  1. package/dist/avl/index.cjs +63 -65
  2. package/dist/avl/index.js +63 -65
  3. package/dist/components/game/2d/{organisms → molecules}/ObjectRulePanel.d.ts +9 -4
  4. package/dist/components/game/2d/molecules/StateJsonView.d.ts +37 -0
  5. package/dist/components/game/2d/{organisms → molecules}/TraitSlot.d.ts +6 -3
  6. package/dist/components/game/2d/{organisms → molecules}/TraitStateViewer.d.ts +0 -2
  7. package/dist/components/game/2d/molecules/VariablePanel.d.ts +28 -0
  8. package/dist/components/game/2d/molecules/index.d.ts +11 -11
  9. package/dist/components/game/2d/organisms/EventHandlerBoard.d.ts +1 -1
  10. package/dist/components/game/2d/organisms/SequenceBar.d.ts +1 -1
  11. package/dist/components/game/shared/lib/puzzleObject.d.ts +1 -1
  12. package/dist/components/index.cjs +63 -65
  13. package/dist/components/index.js +63 -65
  14. package/dist/providers/index.cjs +63 -65
  15. package/dist/providers/index.js +63 -65
  16. package/dist/runtime/index.cjs +63 -65
  17. package/dist/runtime/index.js +63 -65
  18. package/package.json +1 -1
  19. package/dist/components/game/2d/organisms/StateJsonView.d.ts +0 -17
  20. package/dist/components/game/2d/organisms/VariablePanel.d.ts +0 -22
  21. /package/dist/components/game/2d/{organisms → molecules}/ActionPalette.d.ts +0 -0
  22. /package/dist/components/game/2d/{organisms → molecules}/ActionTile.d.ts +0 -0
  23. /package/dist/components/game/2d/{organisms → molecules}/EventLog.d.ts +0 -0
  24. /package/dist/components/game/2d/{organisms → molecules}/RuleEditor.d.ts +0 -0
  25. /package/dist/components/game/2d/{organisms → molecules}/StateNode.d.ts +0 -0
  26. /package/dist/components/game/2d/{organisms → molecules}/TransitionArrow.d.ts +0 -0
@@ -9963,7 +9963,7 @@ function StateNode({
9963
9963
  );
9964
9964
  }
9965
9965
  var init_StateNode = __esm({
9966
- "components/game/2d/organisms/StateNode.tsx"() {
9966
+ "components/game/2d/molecules/StateNode.tsx"() {
9967
9967
  init_atoms();
9968
9968
  init_cn();
9969
9969
  StateNode.displayName = "StateNode";
@@ -10035,7 +10035,7 @@ function TransitionArrow({
10035
10035
  }
10036
10036
  var NODE_RADIUS;
10037
10037
  var init_TransitionArrow = __esm({
10038
- "components/game/2d/organisms/TransitionArrow.tsx"() {
10038
+ "components/game/2d/molecules/TransitionArrow.tsx"() {
10039
10039
  init_cn();
10040
10040
  NODE_RADIUS = 40;
10041
10041
  TransitionArrow.displayName = "TransitionArrow";
@@ -11740,7 +11740,7 @@ function TraitStateViewer({
11740
11740
  }
11741
11741
  var SIZE_CONFIG;
11742
11742
  var init_TraitStateViewer = __esm({
11743
- "components/game/2d/organisms/TraitStateViewer.tsx"() {
11743
+ "components/game/2d/molecules/TraitStateViewer.tsx"() {
11744
11744
  "use client";
11745
11745
  init_cn();
11746
11746
  init_Box();
@@ -11773,7 +11773,8 @@ function TraitSlot({
11773
11773
  onClick,
11774
11774
  onRemove,
11775
11775
  clickEvent,
11776
- removeEvent
11776
+ removeEvent,
11777
+ dropEvent
11777
11778
  }) {
11778
11779
  const { emit } = useEventBus();
11779
11780
  const [isHovered, setIsHovered] = useState(false);
@@ -11805,29 +11806,30 @@ function TraitSlot({
11805
11806
  onDragStart?.(equippedItem);
11806
11807
  }, [equippedItem, draggable, onDragStart]);
11807
11808
  const handleDragOver = useCallback((e) => {
11808
- if (locked || !onItemDrop) return;
11809
+ if (locked || !onItemDrop && !dropEvent) return;
11809
11810
  if (e.dataTransfer.types.includes(DRAG_MIME)) {
11810
11811
  e.preventDefault();
11811
11812
  const allowed = e.dataTransfer.effectAllowed;
11812
11813
  e.dataTransfer.dropEffect = allowed === "copy" ? "copy" : "move";
11813
11814
  setIsDragOver(true);
11814
11815
  }
11815
- }, [locked, onItemDrop]);
11816
+ }, [locked, onItemDrop, dropEvent]);
11816
11817
  const handleDragLeave = useCallback(() => {
11817
11818
  setIsDragOver(false);
11818
11819
  }, []);
11819
11820
  const handleDrop = useCallback((e) => {
11820
11821
  e.preventDefault();
11821
11822
  setIsDragOver(false);
11822
- if (locked || !onItemDrop) return;
11823
+ if (locked || !onItemDrop && !dropEvent) return;
11823
11824
  const raw = e.dataTransfer.getData(DRAG_MIME);
11824
11825
  if (!raw) return;
11825
11826
  try {
11826
11827
  const item = JSON.parse(raw);
11827
- onItemDrop(item);
11828
+ if (dropEvent) emit(`UI:${dropEvent}`, { slotNumber, itemId: item.id });
11829
+ else onItemDrop?.(item);
11828
11830
  } catch {
11829
11831
  }
11830
- }, [locked, onItemDrop]);
11832
+ }, [locked, onItemDrop, dropEvent, emit, slotNumber]);
11831
11833
  const getTooltipStyle = () => {
11832
11834
  if (!slotRef.current) return {};
11833
11835
  const rect = slotRef.current.getBoundingClientRect();
@@ -11947,7 +11949,7 @@ function TraitSlot({
11947
11949
  }
11948
11950
  var SIZE_CONFIG2, DRAG_MIME;
11949
11951
  var init_TraitSlot = __esm({
11950
- "components/game/2d/organisms/TraitSlot.tsx"() {
11952
+ "components/game/2d/molecules/TraitSlot.tsx"() {
11951
11953
  "use client";
11952
11954
  init_cn();
11953
11955
  init_useEventBus();
@@ -12006,7 +12008,7 @@ function ActionTile({
12006
12008
  }
12007
12009
  var DRAG_MIME2, SIZE_CONFIG3;
12008
12010
  var init_ActionTile = __esm({
12009
- "components/game/2d/organisms/ActionTile.tsx"() {
12011
+ "components/game/2d/molecules/ActionTile.tsx"() {
12010
12012
  init_atoms();
12011
12013
  init_cn();
12012
12014
  DRAG_MIME2 = "application/x-almadar-slot-item";
@@ -12043,7 +12045,7 @@ function ActionPalette({
12043
12045
  ] });
12044
12046
  }
12045
12047
  var init_ActionPalette = __esm({
12046
- "components/game/2d/organisms/ActionPalette.tsx"() {
12048
+ "components/game/2d/molecules/ActionPalette.tsx"() {
12047
12049
  init_atoms();
12048
12050
  init_cn();
12049
12051
  init_ActionTile();
@@ -12419,7 +12421,7 @@ function RuleEditor({
12419
12421
  ] });
12420
12422
  }
12421
12423
  var init_RuleEditor = __esm({
12422
- "components/game/2d/organisms/RuleEditor.tsx"() {
12424
+ "components/game/2d/molecules/RuleEditor.tsx"() {
12423
12425
  init_atoms();
12424
12426
  init_cn();
12425
12427
  RuleEditor.displayName = "RuleEditor";
@@ -12460,7 +12462,7 @@ function EventLog({
12460
12462
  }
12461
12463
  var STATUS_STYLES, STATUS_DOTS;
12462
12464
  var init_EventLog = __esm({
12463
- "components/game/2d/organisms/EventLog.tsx"() {
12465
+ "components/game/2d/molecules/EventLog.tsx"() {
12464
12466
  init_atoms();
12465
12467
  init_cn();
12466
12468
  STATUS_STYLES = {
@@ -12515,10 +12517,12 @@ var init_puzzleObject = __esm({
12515
12517
  function ObjectRulePanel({
12516
12518
  object,
12517
12519
  onRulesChange,
12520
+ rulesChangeEvent,
12518
12521
  disabled = false,
12519
12522
  className
12520
12523
  }) {
12521
12524
  const { t } = useTranslate();
12525
+ const { emit } = useEventBus();
12522
12526
  const id = objId(object);
12523
12527
  const name = objName(object);
12524
12528
  const icon = objIcon(object);
@@ -12529,15 +12533,19 @@ function ObjectRulePanel({
12529
12533
  const rules = objRules(object);
12530
12534
  const maxRules = objMaxRules(object);
12531
12535
  const canAdd = rules.length < maxRules;
12536
+ const emitRules = useCallback((newRules) => {
12537
+ if (rulesChangeEvent) emit(`UI:${rulesChangeEvent}`, { objectId: id, rules: newRules });
12538
+ else onRulesChange?.(id, newRules);
12539
+ }, [rulesChangeEvent, emit, id, onRulesChange]);
12532
12540
  const handleRuleChange = useCallback((index, updatedRule) => {
12533
12541
  const newRules = [...rules];
12534
12542
  newRules[index] = updatedRule;
12535
- onRulesChange(id, newRules);
12536
- }, [id, rules, onRulesChange]);
12543
+ emitRules(newRules);
12544
+ }, [rules, emitRules]);
12537
12545
  const handleRuleRemove = useCallback((index) => {
12538
12546
  const newRules = rules.filter((_, i) => i !== index);
12539
- onRulesChange(id, newRules);
12540
- }, [id, rules, onRulesChange]);
12547
+ emitRules(newRules);
12548
+ }, [rules, emitRules]);
12541
12549
  const handleAddRule = useCallback(() => {
12542
12550
  if (!canAdd || disabled) return;
12543
12551
  const firstEvent = availableEvents[0]?.value || "";
@@ -12547,8 +12555,8 @@ function ObjectRulePanel({
12547
12555
  whenEvent: firstEvent,
12548
12556
  thenAction: firstAction
12549
12557
  };
12550
- onRulesChange(id, [...rules, newRule]);
12551
- }, [canAdd, disabled, id, rules, availableEvents, availableActions, onRulesChange]);
12558
+ emitRules([...rules, newRule]);
12559
+ }, [canAdd, disabled, rules, availableEvents, availableActions, emitRules]);
12552
12560
  const machine = {
12553
12561
  name,
12554
12562
  states,
@@ -12588,9 +12596,10 @@ function ObjectRulePanel({
12588
12596
  }
12589
12597
  var nextRuleId;
12590
12598
  var init_ObjectRulePanel = __esm({
12591
- "components/game/2d/organisms/ObjectRulePanel.tsx"() {
12599
+ "components/game/2d/molecules/ObjectRulePanel.tsx"() {
12592
12600
  init_atoms();
12593
12601
  init_cn();
12602
+ init_useEventBus();
12594
12603
  init_TraitStateViewer();
12595
12604
  init_RuleEditor();
12596
12605
  init_puzzleObject();
@@ -12820,61 +12829,35 @@ function VariablePanel({
12820
12829
  const { t } = useTranslate();
12821
12830
  return /* @__PURE__ */ jsxs(VStack, { className: cn("p-3 rounded-lg bg-card border border-border", className), gap: "sm", children: [
12822
12831
  /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground font-medium", children: t("stateArchitect.variables", { name: entityName }) }),
12823
- variables.map((v) => {
12824
- const name = v.name == null ? "" : String(v.name);
12825
- const value = numField(v.value);
12826
- const max = numField(v.max, 100);
12827
- const min = numField(v.min, 0);
12828
- const unit = v.unit == null ? "" : String(v.unit);
12829
- const pct = Math.round((value - min) / (max - min) * 100);
12830
- const isHigh = pct > 80;
12831
- const isLow = pct < 20;
12832
- return /* @__PURE__ */ jsxs(VStack, { gap: "none", children: [
12833
- /* @__PURE__ */ jsxs(HStack, { className: "items-center justify-between", children: [
12834
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground font-medium", children: name }),
12835
- /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: cn(
12836
- isHigh ? "text-error" : isLow ? "text-warning" : "text-foreground"
12837
- ), children: [
12838
- value,
12839
- unit,
12840
- " / ",
12841
- max,
12842
- unit
12843
- ] })
12844
- ] }),
12845
- /* @__PURE__ */ jsx(
12846
- ProgressBar,
12847
- {
12848
- value: pct,
12849
- color: isHigh ? "danger" : isLow ? "warning" : "primary",
12850
- size: "sm"
12851
- }
12852
- )
12853
- ] }, name);
12854
- })
12832
+ (variables ?? []).map((v) => /* @__PURE__ */ jsxs(HStack, { className: "items-center justify-between", children: [
12833
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground font-medium", children: v.name }),
12834
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-accent font-mono", children: v.value })
12835
+ ] }, v.name))
12855
12836
  ] });
12856
12837
  }
12857
- var numField;
12858
12838
  var init_VariablePanel = __esm({
12859
- "components/game/2d/organisms/VariablePanel.tsx"() {
12839
+ "components/game/2d/molecules/VariablePanel.tsx"() {
12860
12840
  init_atoms();
12861
12841
  init_cn();
12862
- numField = (v, fallback = 0) => {
12863
- const n = Number(v);
12864
- return Number.isFinite(n) ? n : fallback;
12865
- };
12866
12842
  VariablePanel.displayName = "VariablePanel";
12867
12843
  }
12868
12844
  });
12869
12845
  function StateJsonView({
12870
- data,
12846
+ name,
12847
+ initialState,
12848
+ states,
12849
+ transitions,
12871
12850
  label,
12872
12851
  defaultExpanded = false,
12873
12852
  className
12874
12853
  }) {
12875
12854
  const { t } = useTranslate();
12876
12855
  const [expanded, setExpanded] = useState(defaultExpanded);
12877
- const jsonString = JSON.stringify(data, null, 2);
12856
+ const jsonString = JSON.stringify(
12857
+ { name, initialState, states: states ?? [], transitions: transitions ?? [] },
12858
+ null,
12859
+ 2
12860
+ );
12878
12861
  return /* @__PURE__ */ jsxs(VStack, { className: cn("rounded-lg border border-border overflow-hidden", className), gap: "none", children: [
12879
12862
  /* @__PURE__ */ jsxs(HStack, { className: "items-center justify-between p-2 bg-muted", gap: "sm", children: [
12880
12863
  /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground font-medium", children: label ?? t("stateArchitect.viewCode") }),
@@ -12891,7 +12874,7 @@ function StateJsonView({
12891
12874
  ] });
12892
12875
  }
12893
12876
  var init_StateJsonView = __esm({
12894
- "components/game/2d/organisms/StateJsonView.tsx"() {
12877
+ "components/game/2d/molecules/StateJsonView.tsx"() {
12895
12878
  init_atoms();
12896
12879
  init_cn();
12897
12880
  StateJsonView.displayName = "StateJsonView";
@@ -13060,7 +13043,7 @@ function StateArchitectBoard({
13060
13043
  setAddingFrom(null);
13061
13044
  if (playAgainEvent) emit(`UI:${playAgainEvent}`, {});
13062
13045
  }, [initialState, entityVariables, playAgainEvent, emit]);
13063
- const codeData = useMemo(() => ({
13046
+ useMemo(() => ({
13064
13047
  name: entityName,
13065
13048
  states: entityStates,
13066
13049
  initialState,
@@ -13195,7 +13178,7 @@ function StateArchitectBoard({
13195
13178
  VariablePanel,
13196
13179
  {
13197
13180
  entityName,
13198
- variables
13181
+ variables: variables.map((v) => ({ name: String(v.name ?? ""), value: String(v.value ?? "") }))
13199
13182
  }
13200
13183
  ),
13201
13184
  testResults.length > 0 && /* @__PURE__ */ jsxs(VStack, { className: "p-3 rounded-container bg-card border border-border", gap: "xs", children: [
@@ -13206,7 +13189,16 @@ function StateArchitectBoard({
13206
13189
  !r.passed && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-error", children: t("stateArchitect.gotState", { state: r.actualState }) })
13207
13190
  ] }, i))
13208
13191
  ] }),
13209
- resolved.showCodeView !== false && /* @__PURE__ */ jsx(StateJsonView, { data: codeData, label: "View Code" })
13192
+ resolved.showCodeView !== false && /* @__PURE__ */ jsx(
13193
+ StateJsonView,
13194
+ {
13195
+ name: entityName,
13196
+ initialState,
13197
+ states: entityStates,
13198
+ transitions: transitions.map((tr) => ({ from: tr.from, to: tr.to, event: tr.event })),
13199
+ label: "View Code"
13200
+ }
13201
+ )
13210
13202
  ] })
13211
13203
  ] }),
13212
13204
  isSuccess && /* @__PURE__ */ jsx(Box, { className: "p-4 rounded-container bg-success/20 border border-success text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "h5", className: "text-success", children: str(resolved.successMessage) || t("stateArchitect.allPassed") }) }),
@@ -45847,6 +45839,7 @@ var init_component_registry_generated = __esm({
45847
45839
  init_Navigation();
45848
45840
  init_NegotiatorBoard();
45849
45841
  init_NumberStepper();
45842
+ init_ObjectRulePanel();
45850
45843
  init_OptionConstraintGroup();
45851
45844
  init_OrbitalVisualization();
45852
45845
  init_Overlay();
@@ -45910,6 +45903,7 @@ var init_component_registry_generated = __esm({
45910
45903
  init_StateArchitectBoard();
45911
45904
  init_StateGraph();
45912
45905
  init_StateIndicator();
45906
+ init_StateJsonView();
45913
45907
  init_StateMachineView();
45914
45908
  init_StatsGrid();
45915
45909
  init_StatsOrganism();
@@ -45956,6 +45950,7 @@ var init_component_registry_generated = __esm({
45956
45950
  init_Typography();
45957
45951
  init_UISlotRenderer();
45958
45952
  init_UploadDropZone();
45953
+ init_VariablePanel();
45959
45954
  init_VersionDiff();
45960
45955
  init_ViolationAlert();
45961
45956
  init_VoteStack();
@@ -46156,6 +46151,7 @@ var init_component_registry_generated = __esm({
46156
46151
  "Navigation": Navigation,
46157
46152
  "NegotiatorBoard": NegotiatorBoard,
46158
46153
  "NumberStepper": NumberStepper,
46154
+ "ObjectRulePanel": ObjectRulePanel,
46159
46155
  "OptionConstraintGroup": OptionConstraintGroup,
46160
46156
  "OrbitalVisualization": OrbitalVisualization,
46161
46157
  "Overlay": Overlay,
@@ -46222,6 +46218,7 @@ var init_component_registry_generated = __esm({
46222
46218
  "StateArchitectBoard": StateArchitectBoard,
46223
46219
  "StateGraph": StateGraph,
46224
46220
  "StateIndicator": StateIndicator,
46221
+ "StateJsonView": StateJsonView,
46225
46222
  "StateMachineView": StateMachineView,
46226
46223
  "StatsGrid": StatsGrid,
46227
46224
  "StatsOrganism": StatsOrganism,
@@ -46269,6 +46266,7 @@ var init_component_registry_generated = __esm({
46269
46266
  "UISlotRenderer": UISlotRenderer,
46270
46267
  "UploadDropZone": UploadDropZone,
46271
46268
  "VStack": VStack,
46269
+ "VariablePanel": VariablePanel,
46272
46270
  "VersionDiff": VersionDiff,
46273
46271
  "ViolationAlert": ViolationAlert,
46274
46272
  "VoteStack": VoteStack,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "5.89.0",
3
+ "version": "5.91.0",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import { JsonObject } from '@almadar/core';
3
- export interface StateJsonViewProps {
4
- /** JSON data to display */
5
- data: JsonObject;
6
- /** Label */
7
- label?: string;
8
- /** Whether the code is expanded by default */
9
- defaultExpanded?: boolean;
10
- /** Additional CSS classes */
11
- className?: string;
12
- }
13
- export declare function StateJsonView({ data, label, defaultExpanded, className, }: StateJsonViewProps): React.JSX.Element;
14
- export declare namespace StateJsonView {
15
- var displayName: string;
16
- }
17
- export default StateJsonView;
@@ -1,22 +0,0 @@
1
- /**
2
- * VariablePanel Component
3
- *
4
- * Shows entity variables and their current values during State Architect playback.
5
- *
6
- * @packageDocumentation
7
- */
8
- import React from 'react';
9
- import type { EntityRow } from '@almadar/core';
10
- export interface VariablePanelProps {
11
- /** Entity name */
12
- entityName: string;
13
- /** Variable rows to display (`EntityRow` carrying name/value/min/max/unit) */
14
- variables: readonly EntityRow[];
15
- /** Additional CSS classes */
16
- className?: string;
17
- }
18
- export declare function VariablePanel({ entityName, variables, className, }: VariablePanelProps): React.JSX.Element;
19
- export declare namespace VariablePanel {
20
- var displayName: string;
21
- }
22
- export default VariablePanel;