@almadar/ui 4.2.1 → 4.3.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.
@@ -10859,21 +10859,26 @@ var init_FloatingActionButton = __esm({
10859
10859
  init_useTranslate();
10860
10860
  FloatingActionButton = ({
10861
10861
  action,
10862
+ actionPayload,
10862
10863
  actions,
10863
10864
  icon,
10864
10865
  onClick,
10865
10866
  variant,
10867
+ label,
10866
10868
  position = "bottom-right",
10867
10869
  className
10868
10870
  }) => {
10869
10871
  const eventBus = useEventBus();
10870
10872
  const { t } = useTranslate();
10871
- const resolvedAction = action ?? (icon ? {
10873
+ const resolvedAction = icon ? {
10872
10874
  icon: resolveIcon2(icon),
10873
- onClick: onClick ?? (() => {
10874
- }),
10875
+ onClick: () => {
10876
+ if (action) eventBus.emit(`UI:${action}`, actionPayload ?? {});
10877
+ onClick?.();
10878
+ },
10879
+ label,
10875
10880
  variant
10876
- } : void 0);
10881
+ } : void 0;
10877
10882
  const [isExpanded, setIsExpanded] = React126.useState(false);
10878
10883
  const fabRef = React126.useRef(null);
10879
10884
  React126.useEffect(() => {
package/dist/avl/index.js CHANGED
@@ -10813,21 +10813,26 @@ var init_FloatingActionButton = __esm({
10813
10813
  init_useTranslate();
10814
10814
  FloatingActionButton = ({
10815
10815
  action,
10816
+ actionPayload,
10816
10817
  actions,
10817
10818
  icon,
10818
10819
  onClick,
10819
10820
  variant,
10821
+ label,
10820
10822
  position = "bottom-right",
10821
10823
  className
10822
10824
  }) => {
10823
10825
  const eventBus = useEventBus();
10824
10826
  const { t } = useTranslate();
10825
- const resolvedAction = action ?? (icon ? {
10827
+ const resolvedAction = icon ? {
10826
10828
  icon: resolveIcon2(icon),
10827
- onClick: onClick ?? (() => {
10828
- }),
10829
+ onClick: () => {
10830
+ if (action) eventBus.emit(`UI:${action}`, actionPayload ?? {});
10831
+ onClick?.();
10832
+ },
10833
+ label,
10829
10834
  variant
10830
- } : void 0);
10835
+ } : void 0;
10831
10836
  const [isExpanded, setIsExpanded] = useState(false);
10832
10837
  const fabRef = useRef(null);
10833
10838
  useEffect(() => {
@@ -6112,21 +6112,26 @@ var init_FloatingActionButton = __esm({
6112
6112
  init_useTranslate();
6113
6113
  exports.FloatingActionButton = ({
6114
6114
  action,
6115
+ actionPayload,
6115
6116
  actions,
6116
6117
  icon,
6117
6118
  onClick,
6118
6119
  variant,
6120
+ label,
6119
6121
  position = "bottom-right",
6120
6122
  className
6121
6123
  }) => {
6122
6124
  const eventBus = useEventBus();
6123
6125
  const { t } = useTranslate();
6124
- const resolvedAction = action ?? (icon ? {
6126
+ const resolvedAction = icon ? {
6125
6127
  icon: resolveIcon2(icon),
6126
- onClick: onClick ?? (() => {
6127
- }),
6128
+ onClick: () => {
6129
+ if (action) eventBus.emit(`UI:${action}`, actionPayload ?? {});
6130
+ onClick?.();
6131
+ },
6132
+ label,
6128
6133
  variant
6129
- } : void 0);
6134
+ } : void 0;
6130
6135
  const [isExpanded, setIsExpanded] = React110.useState(false);
6131
6136
  const fabRef = React110.useRef(null);
6132
6137
  React110.useEffect(() => {
@@ -6067,21 +6067,26 @@ var init_FloatingActionButton = __esm({
6067
6067
  init_useTranslate();
6068
6068
  FloatingActionButton = ({
6069
6069
  action,
6070
+ actionPayload,
6070
6071
  actions,
6071
6072
  icon,
6072
6073
  onClick,
6073
6074
  variant,
6075
+ label,
6074
6076
  position = "bottom-right",
6075
6077
  className
6076
6078
  }) => {
6077
6079
  const eventBus = useEventBus();
6078
6080
  const { t } = useTranslate();
6079
- const resolvedAction = action ?? (icon ? {
6081
+ const resolvedAction = icon ? {
6080
6082
  icon: resolveIcon2(icon),
6081
- onClick: onClick ?? (() => {
6082
- }),
6083
+ onClick: () => {
6084
+ if (action) eventBus.emit(`UI:${action}`, actionPayload ?? {});
6085
+ onClick?.();
6086
+ },
6087
+ label,
6083
6088
  variant
6084
- } : void 0);
6089
+ } : void 0;
6085
6090
  const [isExpanded, setIsExpanded] = useState(false);
6086
6091
  const fabRef = useRef(null);
6087
6092
  useEffect(() => {
@@ -3,9 +3,15 @@
3
3
  *
4
4
  * A floating action button that can expand into multiple actions vertically.
5
5
  * Uses Button atom.
6
+ *
7
+ * Props mirror Button's `action`/`actionPayload` convention so a schema can
8
+ * declare `{ type: "floating-action-button", action: "INIT", icon: "plus" }`
9
+ * and have the FAB emit `UI:INIT` via the event bus on click — same shape
10
+ * any other clickable surface uses.
6
11
  */
7
12
  import React from "react";
8
13
  import type { LucideIcon } from "lucide-react";
14
+ import type { EventKey, EventPayload } from "@almadar/core";
9
15
  export interface FloatingAction {
10
16
  /**
11
17
  * Action ID
@@ -32,30 +38,38 @@ export interface FloatingAction {
32
38
  }
33
39
  export interface FloatingActionButtonProps {
34
40
  /**
35
- * Single action (if only one action, button will directly trigger onClick)
41
+ * Declarative event name. When set, clicking the FAB emits `UI:{action}`
42
+ * via the event bus and (if also provided) calls `onClick`. Mirrors the
43
+ * Button atom's `action` prop so schemas can write
44
+ * `{ type: "floating-action-button", action: "INIT" }` uniformly.
45
+ */
46
+ action?: EventKey;
47
+ /**
48
+ * Payload to include with the dispatched action event.
36
49
  */
37
- action?: {
38
- icon: LucideIcon;
39
- onClick: () => void;
40
- label?: string;
41
- variant?: "primary" | "secondary" | "success" | "danger" | "warning";
42
- };
50
+ actionPayload?: EventPayload;
43
51
  /**
44
- * Multiple actions (if provided, button will expand to show all actions)
52
+ * Multiple actions. When provided, the button expands to show all of them.
45
53
  */
46
54
  actions?: FloatingAction[];
47
55
  /**
48
- * Icon name (simplified API for pattern compatibility)
56
+ * Icon name (resolves to a Lucide icon by PascalCase / kebab-case lookup).
49
57
  */
50
58
  icon?: string;
51
59
  /**
52
- * Click handler (simplified API for pattern compatibility)
60
+ * Optional direct click handler. Runs after the action emit when both are
61
+ * present.
53
62
  */
54
63
  onClick?: () => void;
55
64
  /**
56
- * Variant (simplified API for pattern compatibility)
65
+ * Visual variant.
57
66
  */
58
67
  variant?: "primary" | "secondary" | "success" | "danger" | "warning";
68
+ /**
69
+ * Optional label shown via `aria-label` (visually hidden in single-action
70
+ * mode; rendered as a tooltip beside expanded actions in multi-action mode).
71
+ */
72
+ label?: string;
59
73
  /**
60
74
  * Button position
61
75
  * @default 'bottom-right'
@@ -7743,21 +7743,26 @@ var init_FloatingActionButton = __esm({
7743
7743
  init_useTranslate();
7744
7744
  FloatingActionButton = ({
7745
7745
  action,
7746
+ actionPayload,
7746
7747
  actions,
7747
7748
  icon,
7748
7749
  onClick,
7749
7750
  variant,
7751
+ label,
7750
7752
  position = "bottom-right",
7751
7753
  className
7752
7754
  }) => {
7753
7755
  const eventBus = useEventBus();
7754
7756
  const { t } = useTranslate();
7755
- const resolvedAction = action ?? (icon ? {
7757
+ const resolvedAction = icon ? {
7756
7758
  icon: resolveIcon2(icon),
7757
- onClick: onClick ?? (() => {
7758
- }),
7759
+ onClick: () => {
7760
+ if (action) eventBus.emit(`UI:${action}`, actionPayload ?? {});
7761
+ onClick?.();
7762
+ },
7763
+ label,
7759
7764
  variant
7760
- } : void 0);
7765
+ } : void 0;
7761
7766
  const [isExpanded, setIsExpanded] = React115.useState(false);
7762
7767
  const fabRef = React115.useRef(null);
7763
7768
  React115.useEffect(() => {
@@ -7698,21 +7698,26 @@ var init_FloatingActionButton = __esm({
7698
7698
  init_useTranslate();
7699
7699
  FloatingActionButton = ({
7700
7700
  action,
7701
+ actionPayload,
7701
7702
  actions,
7702
7703
  icon,
7703
7704
  onClick,
7704
7705
  variant,
7706
+ label,
7705
7707
  position = "bottom-right",
7706
7708
  className
7707
7709
  }) => {
7708
7710
  const eventBus = useEventBus();
7709
7711
  const { t } = useTranslate();
7710
- const resolvedAction = action ?? (icon ? {
7712
+ const resolvedAction = icon ? {
7711
7713
  icon: resolveIcon2(icon),
7712
- onClick: onClick ?? (() => {
7713
- }),
7714
+ onClick: () => {
7715
+ if (action) eventBus.emit(`UI:${action}`, actionPayload ?? {});
7716
+ onClick?.();
7717
+ },
7718
+ label,
7714
7719
  variant
7715
- } : void 0);
7720
+ } : void 0;
7716
7721
  const [isExpanded, setIsExpanded] = useState(false);
7717
7722
  const fabRef = useRef(null);
7718
7723
  useEffect(() => {
@@ -7894,21 +7894,26 @@ var init_FloatingActionButton = __esm({
7894
7894
  init_useTranslate();
7895
7895
  FloatingActionButton = ({
7896
7896
  action,
7897
+ actionPayload,
7897
7898
  actions,
7898
7899
  icon,
7899
7900
  onClick,
7900
7901
  variant,
7902
+ label,
7901
7903
  position = "bottom-right",
7902
7904
  className
7903
7905
  }) => {
7904
7906
  const eventBus = useEventBus();
7905
7907
  const { t } = useTranslate();
7906
- const resolvedAction = action ?? (icon ? {
7908
+ const resolvedAction = icon ? {
7907
7909
  icon: resolveIcon2(icon),
7908
- onClick: onClick ?? (() => {
7909
- }),
7910
+ onClick: () => {
7911
+ if (action) eventBus.emit(`UI:${action}`, actionPayload ?? {});
7912
+ onClick?.();
7913
+ },
7914
+ label,
7910
7915
  variant
7911
- } : void 0);
7916
+ } : void 0;
7912
7917
  const [isExpanded, setIsExpanded] = React115.useState(false);
7913
7918
  const fabRef = React115.useRef(null);
7914
7919
  React115.useEffect(() => {
@@ -7849,21 +7849,26 @@ var init_FloatingActionButton = __esm({
7849
7849
  init_useTranslate();
7850
7850
  FloatingActionButton = ({
7851
7851
  action,
7852
+ actionPayload,
7852
7853
  actions,
7853
7854
  icon,
7854
7855
  onClick,
7855
7856
  variant,
7857
+ label,
7856
7858
  position = "bottom-right",
7857
7859
  className
7858
7860
  }) => {
7859
7861
  const eventBus = useEventBus();
7860
7862
  const { t } = useTranslate();
7861
- const resolvedAction = action ?? (icon ? {
7863
+ const resolvedAction = icon ? {
7862
7864
  icon: resolveIcon2(icon),
7863
- onClick: onClick ?? (() => {
7864
- }),
7865
+ onClick: () => {
7866
+ if (action) eventBus.emit(`UI:${action}`, actionPayload ?? {});
7867
+ onClick?.();
7868
+ },
7869
+ label,
7865
7870
  variant
7866
- } : void 0);
7871
+ } : void 0;
7867
7872
  const [isExpanded, setIsExpanded] = useState(false);
7868
7873
  const fabRef = useRef(null);
7869
7874
  useEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "4.2.1",
3
+ "version": "4.3.0",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "main": "./dist/components/index.js",