@pihanga2/shadcn 0.2.20 → 0.2.22

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 (98) hide show
  1. package/AGENT.using-cards.md +2 -2
  2. package/README.md +4 -1
  3. package/cards/attachment/attachment.component.d.ts +4 -0
  4. package/cards/attachment/attachment.component.js +46 -0
  5. package/cards/attachment/attachment.component.js.map +1 -0
  6. package/cards/attachment/attachment.types.d.ts +95 -0
  7. package/cards/attachment/attachment.types.js +7 -0
  8. package/cards/attachment/attachment.types.js.map +1 -0
  9. package/cards/attachment/attachmentGroup.component.d.ts +4 -0
  10. package/cards/attachment/attachmentGroup.component.js +21 -0
  11. package/cards/attachment/attachmentGroup.component.js.map +1 -0
  12. package/cards/attachment/index.d.ts +1 -0
  13. package/cards/attachment/index.js +16 -0
  14. package/cards/attachment/index.js.map +1 -0
  15. package/cards/bubble/bubble.component.d.ts +4 -0
  16. package/cards/bubble/bubble.component.js +67 -0
  17. package/cards/bubble/bubble.component.js.map +1 -0
  18. package/cards/bubble/bubble.types.d.ts +106 -0
  19. package/cards/bubble/bubble.types.js +7 -0
  20. package/cards/bubble/bubble.types.js.map +1 -0
  21. package/cards/bubble/bubbleGroup.component.d.ts +4 -0
  22. package/cards/bubble/bubbleGroup.component.js +21 -0
  23. package/cards/bubble/bubbleGroup.component.js.map +1 -0
  24. package/cards/bubble/index.d.ts +1 -0
  25. package/cards/bubble/index.js +16 -0
  26. package/cards/bubble/index.js.map +1 -0
  27. package/cards/button/button.component.js +56 -54
  28. package/cards/button/button.component.js.map +1 -1
  29. package/cards/button/button.types.d.ts +24 -0
  30. package/cards/button/button.types.js.map +1 -1
  31. package/cards/checkbox/checkbox.types.d.ts +2 -7
  32. package/cards/checkbox/checkbox.types.js.map +1 -1
  33. package/cards/dataTable/dataTable.component.js +191 -124
  34. package/cards/dataTable/dataTable.component.js.map +1 -1
  35. package/cards/dataTable/dataTable.types.d.ts +50 -0
  36. package/cards/dataTable/dataTable.types.js +6 -3
  37. package/cards/dataTable/dataTable.types.js.map +1 -1
  38. package/cards/dataTable/index.js +6 -6
  39. package/cards/dropDownMenu/dropdown-menu.ui.js +41 -41
  40. package/cards/field/field.component.js +1 -1
  41. package/cards/field/field.component.js.map +1 -1
  42. package/cards/form/form.component.js +57 -32
  43. package/cards/form/form.component.js.map +1 -1
  44. package/cards/form/form.context.d.ts +11 -0
  45. package/cards/form/form.context.js +1 -0
  46. package/cards/form/form.context.js.map +1 -1
  47. package/cards/form/form.types.d.ts +75 -0
  48. package/cards/form/form.types.js +6 -2
  49. package/cards/form/form.types.js.map +1 -1
  50. package/cards/form/index.js +5 -5
  51. package/cards/input/index.js +6 -6
  52. package/cards/input/input.component.js +38 -32
  53. package/cards/input/input.component.js.map +1 -1
  54. package/cards/input/input.types.d.ts +14 -7
  55. package/cards/input/input.types.js +2 -2
  56. package/cards/input/input.types.js.map +1 -1
  57. package/cards/message/index.d.ts +1 -0
  58. package/cards/message/index.js +15 -0
  59. package/cards/message/index.js.map +1 -0
  60. package/cards/message/message.component.d.ts +4 -0
  61. package/cards/message/message.component.js +47 -0
  62. package/cards/message/message.component.js.map +1 -0
  63. package/cards/message/message.types.d.ts +56 -0
  64. package/cards/message/message.types.js +7 -0
  65. package/cards/message/message.types.js.map +1 -0
  66. package/cards/message/messageGroup.component.d.ts +4 -0
  67. package/cards/message/messageGroup.component.js +21 -0
  68. package/cards/message/messageGroup.component.js.map +1 -0
  69. package/cards/pageWithNavbarMeta/index.js +35 -25
  70. package/cards/pageWithNavbarMeta/index.js.map +1 -1
  71. package/cards/pageWithNavbarMeta/pageWithNavbarMeta.types.d.ts +1 -4
  72. package/cards/select/select.types.d.ts +2 -7
  73. package/cards/select/select.types.js.map +1 -1
  74. package/cards/switch/switch.types.d.ts +2 -7
  75. package/cards/switch/switch.types.js.map +1 -1
  76. package/cards/textArea/textArea.component.js +1 -1
  77. package/cards/textArea/textArea.component.js.map +1 -1
  78. package/cards/textArea/textArea.types.d.ts +15 -11
  79. package/cards/textArea/textArea.types.js.map +1 -1
  80. package/cards/textField/textField.component.js +13 -9
  81. package/cards/textField/textField.component.js.map +1 -1
  82. package/cards/textField/textField.types.d.ts +12 -7
  83. package/cards/textField/textField.types.js.map +1 -1
  84. package/cards/toggleGroup/toggleGroup.types.d.ts +2 -7
  85. package/cards/toggleGroup/toggleGroup.types.js.map +1 -1
  86. package/components/ui/attachment.js +102 -0
  87. package/components/ui/attachment.js.map +1 -0
  88. package/components/ui/badge.js +7 -7
  89. package/components/ui/bubble.js +73 -0
  90. package/components/ui/bubble.js.map +1 -0
  91. package/components/ui/button.js +11 -11
  92. package/components/ui/empty.js +12 -12
  93. package/components/ui/field.js +16 -16
  94. package/components/ui/message.js +51 -0
  95. package/components/ui/message.js.map +1 -0
  96. package/components/ui/toggle-group.js +1 -1
  97. package/components/ui/toggle.js +1 -1
  98. package/package.json +17 -2
@@ -2,70 +2,72 @@ import { getIcon as e } from "../icons.js";
2
2
  import { Button as t, LinkButton as n } from "../../components/ui/button.js";
3
3
  import { Tooltip as r, TooltipContent as i, TooltipTrigger as a } from "../../components/ui/tooltip.js";
4
4
  import { useDropdownOpen as o } from "../dropDownMenu/dropdown-context.js";
5
+ import { useFormContext as s } from "../form/form.context.js";
5
6
  import "react";
6
- import { Card as s } from "@pihanga2/core";
7
- import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
7
+ import { Card as c } from "@pihanga2/core";
8
+ import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
8
9
  //#region src/cards/button/button.component.tsx
9
- function d(t) {
10
+ function f(t) {
10
11
  return t ? e(t) : null;
11
12
  }
12
- var f = (e) => {
13
- let { opts: f, ariaLabel: p, label: m, iconLabel: h, contentCard: g, href: _, target: v, tooltip: y, tooltipCard: b, tooltipMode: x, tooltipPlacement: S, className: C, id: w, onClicked: T, cardName: E, _cls: D, active: O, focused: k, disabled: A, loading: j, isPending: M } = e, N = o(), P = d(f?.beforeIcon), F = d(f?.afterIcon), I = /* @__PURE__ */ u(c, { children: [
14
- P,
15
- h ? d(h) : g ? /* @__PURE__ */ l(s, {
16
- cardName: g,
17
- parentCard: E
18
- }) : m,
19
- F
20
- ] }), L = {
21
- active: O,
22
- focused: k,
23
- isMenu: f?.isMenu,
24
- truncate: f?.truncate,
25
- variant: f?.variant,
26
- size: f?.size,
27
- disabled: A,
28
- loading: j,
29
- isPending: M,
30
- loadingClassName: f?.loadingClassName,
31
- className: `${D("root")} ${C || ""}`.trim()
32
- }, R = () => {
33
- T({ id: w });
34
- }, z = () => _ ? /* @__PURE__ */ l(n, {
35
- ...L,
36
- href: _,
37
- target: v,
38
- "data-pihanga": E,
39
- label: p ?? m,
40
- onClick: R,
41
- children: I
42
- }) : /* @__PURE__ */ l(t, {
43
- ...L,
44
- "data-pihanga": E,
45
- label: p ?? m,
46
- onClick: R,
47
- children: I
13
+ var p = (e) => {
14
+ let { opts: p, ariaLabel: m, label: h, iconLabel: g, contentCard: _, href: v, target: y, tooltip: b, tooltipCard: x, tooltipMode: S, tooltipPlacement: C, className: w, id: T, onClicked: E, cardName: D, _cls: O, active: k, focused: A, disabled: j, loading: M, isPending: N, formAction: P } = e, F = o(), I = s(), L = f(p?.beforeIcon), R = f(p?.afterIcon), z = /* @__PURE__ */ d(l, { children: [
15
+ L,
16
+ g ? f(g) : _ ? /* @__PURE__ */ u(c, {
17
+ cardName: _,
18
+ parentCard: D
19
+ }) : h,
20
+ R
21
+ ] }), B = {
22
+ active: k,
23
+ focused: A,
24
+ isMenu: p?.isMenu,
25
+ truncate: p?.truncate,
26
+ variant: p?.variant,
27
+ size: p?.size,
28
+ disabled: j,
29
+ loading: M,
30
+ isPending: N,
31
+ loadingClassName: p?.loadingClassName,
32
+ className: `${O("root")} ${w || ""}`.trim()
33
+ }, V = !!P && I.isInForm, H = () => {
34
+ V ? I.requestAction(P) : E({ id: T });
35
+ }, U = P === "submit" ? "submit" : "button", W = () => v ? /* @__PURE__ */ u(n, {
36
+ ...B,
37
+ href: v,
38
+ target: y,
39
+ "data-pihanga": D,
40
+ label: m ?? h,
41
+ onClick: H,
42
+ children: z
43
+ }) : /* @__PURE__ */ u(t, {
44
+ ...B,
45
+ type: U,
46
+ "data-pihanga": D,
47
+ label: m ?? h,
48
+ onClick: H,
49
+ children: z
48
50
  });
49
- if (!y && !b) return z();
50
- let B = N ? !1 : x === "open" ? !0 : x === "closed" ? !1 : void 0, V = b ? /* @__PURE__ */ l(s, {
51
- cardName: b,
52
- parentCard: E
53
- }) : /* @__PURE__ */ l("p", {
54
- "data-pihanga": `${E}-tooltip`,
55
- children: y
51
+ if (!b && !x) return W();
52
+ let G = F ? !1 : S === "open" ? !0 : S === "closed" ? !1 : void 0, K = x ? /* @__PURE__ */ u(c, {
53
+ cardName: x,
54
+ parentCard: D
55
+ }) : /* @__PURE__ */ u("p", {
56
+ "data-pihanga": `${D}-tooltip`,
57
+ children: b
56
58
  });
57
- return /* @__PURE__ */ u(r, {
58
- open: B,
59
- children: [/* @__PURE__ */ l(a, {
59
+ return /* @__PURE__ */ d(r, {
60
+ open: G,
61
+ children: [/* @__PURE__ */ u(a, {
60
62
  asChild: !0,
61
- children: z()
62
- }), /* @__PURE__ */ l(i, {
63
- side: S,
64
- children: V
63
+ children: W()
64
+ }), /* @__PURE__ */ u(i, {
65
+ side: C,
66
+ children: K
65
67
  })]
66
68
  });
67
69
  };
68
70
  //#endregion
69
- export { f as ButtonComponent };
71
+ export { p as ButtonComponent };
70
72
 
71
73
  //# sourceMappingURL=button.component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"button.component.js","names":[],"sources":["../../../src/cards/button/button.component.tsx"],"sourcesContent":["import React from \"react\";\nimport {Card, type PiCardProps} from \"@pihanga2/core\";\n\nimport {Button, LinkButton} from \"@/registry/ui/button\";\nimport {Tooltip, TooltipContent, TooltipTrigger} from \"@/registry/ui/tooltip\";\nimport {getIcon} from \"@/cards/icons\";\nimport {useDropdownOpen} from \"@/cards/dropDownMenu/dropdown-context\";\n\nimport type {PiButtonEvents, PiButtonProps} from \"./button.types\";\n\nfunction resolveIconByName(name?: string): React.ReactNode {\n if (!name) return null;\n return getIcon(name);\n}\n\nexport const ButtonComponent = (\n props: PiCardProps<PiButtonProps, PiButtonEvents>,\n): React.ReactNode => {\n const {\n opts,\n ariaLabel,\n label,\n iconLabel,\n contentCard: content,\n href,\n target,\n tooltip,\n tooltipCard,\n tooltipMode,\n tooltipPlacement,\n className,\n id,\n onClicked,\n cardName,\n _cls,\n active,\n focused,\n disabled,\n loading,\n isPending,\n } = props;\n\n // Check if this button is inside an open dropdown menu\n const isInsideOpenDropdown = useDropdownOpen();\n\n const beforeIcon = resolveIconByName(opts?.beforeIcon);\n const afterIcon = resolveIconByName(opts?.afterIcon);\n\n // Determine base content: iconLabel takes precedence, then contentCard, then label\n const baseContent = iconLabel ? (\n resolveIconByName(iconLabel)\n ) : content ? (\n <Card cardName={content} parentCard={cardName} />\n ) : (\n label\n );\n\n // Render icons as children following shadcn/ui pattern\n const children = (\n <>\n {beforeIcon}\n {baseContent}\n {afterIcon}\n </>\n );\n\n const common = {\n active,\n focused,\n isMenu: opts?.isMenu,\n truncate: opts?.truncate,\n variant: opts?.variant,\n size: opts?.size,\n\n disabled,\n loading,\n isPending,\n loadingClassName: opts?.loadingClassName,\n\n className: `${_cls(\"root\")} ${className || \"\"}`.trim(),\n };\n\n const handleClick = () => {\n onClicked({id});\n };\n\n const renderButton = () => {\n if (href) {\n return (\n <LinkButton\n {...common}\n href={href}\n target={target}\n data-pihanga={cardName}\n label={ariaLabel ?? label}\n onClick={handleClick}\n >\n {children}\n </LinkButton>\n );\n }\n\n return (\n <Button\n {...common}\n data-pihanga={cardName}\n label={ariaLabel ?? label}\n onClick={handleClick}\n >\n {children}\n </Button>\n );\n };\n\n if (!tooltip && !tooltipCard) return renderButton();\n\n // Determine tooltip open state based on mode.\n // If the button is inside an open dropdown, force the tooltip closed\n // to avoid UI conflicts (dropdown menu should take precedence).\n const tooltipOpen = isInsideOpenDropdown\n ? false\n : tooltipMode === \"open\"\n ? true\n : tooltipMode === \"closed\"\n ? false\n : undefined; // 'auto' or undefined = uncontrolled\n\n // Render tooltip content: use tooltipCard if provided, otherwise use tooltip string\n const tooltipContent = tooltipCard ? (\n <Card cardName={tooltipCard} parentCard={cardName} />\n ) : (\n <p data-pihanga={`${cardName}-tooltip`}>{tooltip}</p>\n );\n\n return (\n <Tooltip open={tooltipOpen}>\n <TooltipTrigger asChild>{renderButton()}</TooltipTrigger>\n <TooltipContent side={tooltipPlacement}>{tooltipContent}</TooltipContent>\n </Tooltip>\n );\n};\n"],"mappings":";;;;;;;;AAUA,SAAS,EAAkB,GAAgC;CAEzD,OADK,IACE,EAAQ,CAAI,IADD;AAEpB;AAEA,IAAa,KACX,MACoB;CACpB,IAAM,EACJ,SACA,cACA,UACA,cACA,aAAa,GACb,SACA,WACA,YACA,gBACA,gBACA,qBACA,cACA,OACA,cACA,aACA,SACA,WACA,YACA,aACA,YACA,iBACE,GAGE,IAAuB,EAAgB,GAEvC,IAAa,EAAkB,GAAM,UAAU,GAC/C,IAAY,EAAkB,GAAM,SAAS,GAY7C,IACJ,kBAAA,GAAA,EAAA,UAAA;EACG;EAXe,IAClB,EAAkB,CAAS,IACzB,IACF,kBAAC,GAAD;GAAM,UAAU;GAAS,YAAY;EAAW,CAAA,IAEhD;EAQG;CACD,EAAA,CAAA,GAGE,IAAS;EACb;EACA;EACA,QAAQ,GAAM;EACd,UAAU,GAAM;EAChB,SAAS,GAAM;EACf,MAAM,GAAM;EAEZ;EACA;EACA;EACA,kBAAkB,GAAM;EAExB,WAAW,GAAG,EAAK,MAAM,EAAE,GAAG,KAAa,KAAK,KAAK;CACvD,GAEM,UAAoB;EACxB,EAAU,EAAC,MAAE,CAAC;CAChB,GAEM,UACA,IAEA,kBAAC,GAAD;EACE,GAAI;EACE;EACE;EACR,gBAAc;EACd,OAAO,KAAa;EACpB,SAAS;EAER;CACS,CAAA,IAKd,kBAAC,GAAD;EACE,GAAI;EACJ,gBAAc;EACd,OAAO,KAAa;EACpB,SAAS;EAER;CACK,CAAA;CAIZ,IAAI,CAAC,KAAW,CAAC,GAAa,OAAO,EAAa;CAKlD,IAAM,IAAc,IAChB,KACA,MAAgB,SACd,KACA,MAAgB,WACd,KACA,KAAA,GAGF,IAAiB,IACrB,kBAAC,GAAD;EAAM,UAAU;EAAa,YAAY;CAAW,CAAA,IAEpD,kBAAC,KAAD;EAAG,gBAAc,GAAG,EAAS;YAAY;CAAW,CAAA;CAGtD,OACE,kBAAC,GAAD;EAAS,MAAM;YAAf,CACE,kBAAC,GAAD;GAAgB,SAAA;aAAS,EAAa;EAAkB,CAAA,GACxD,kBAAC,GAAD;GAAgB,MAAM;aAAmB;EAA+B,CAAA,CACjE;;AAEb"}
1
+ {"version":3,"file":"button.component.js","names":[],"sources":["../../../src/cards/button/button.component.tsx"],"sourcesContent":["import React from \"react\";\nimport {Card, type PiCardProps} from \"@pihanga2/core\";\n\nimport {Button, LinkButton} from \"@/registry/ui/button\";\nimport {Tooltip, TooltipContent, TooltipTrigger} from \"@/registry/ui/tooltip\";\nimport {getIcon} from \"@/cards/icons\";\nimport {useDropdownOpen} from \"@/cards/dropDownMenu/dropdown-context\";\nimport {useFormContext} from \"@/cards/form/form.context\";\n\nimport type {PiButtonEvents, PiButtonProps} from \"./button.types\";\n\nfunction resolveIconByName(name?: string): React.ReactNode {\n if (!name) return null;\n return getIcon(name);\n}\n\nexport const ButtonComponent = (\n props: PiCardProps<PiButtonProps, PiButtonEvents>,\n): React.ReactNode => {\n const {\n opts,\n ariaLabel,\n label,\n iconLabel,\n contentCard: content,\n href,\n target,\n tooltip,\n tooltipCard,\n tooltipMode,\n tooltipPlacement,\n className,\n id,\n onClicked,\n cardName,\n _cls,\n active,\n focused,\n disabled,\n loading,\n isPending,\n formAction,\n } = props;\n\n // Check if this button is inside an open dropdown menu\n const isInsideOpenDropdown = useDropdownOpen();\n\n // Detect if we are inside a pi/form card via React context, so\n // `formAction` can request a form-level action instead of onClicked.\n const form = useFormContext();\n\n const beforeIcon = resolveIconByName(opts?.beforeIcon);\n const afterIcon = resolveIconByName(opts?.afterIcon);\n\n // Determine base content: iconLabel takes precedence, then contentCard, then label\n const baseContent = iconLabel ? (\n resolveIconByName(iconLabel)\n ) : content ? (\n <Card cardName={content} parentCard={cardName} />\n ) : (\n label\n );\n\n // Render icons as children following shadcn/ui pattern\n const children = (\n <>\n {beforeIcon}\n {baseContent}\n {afterIcon}\n </>\n );\n\n const common = {\n active,\n focused,\n isMenu: opts?.isMenu,\n truncate: opts?.truncate,\n variant: opts?.variant,\n size: opts?.size,\n\n disabled,\n loading,\n isPending,\n loadingClassName: opts?.loadingClassName,\n\n className: `${_cls(\"root\")} ${className || \"\"}`.trim(),\n };\n\n // When `formAction` is set and this button is inside a pi/form, clicking\n // it requests that form-level action instead of firing this button's own\n // onClicked.\n const useFormAction = Boolean(formAction) && form.isInForm;\n\n const handleClick = () => {\n if (useFormAction) {\n form.requestAction(formAction!);\n } else {\n onClicked({id});\n }\n };\n\n // Native <button type> mirrors `formAction` so the button can never\n // accidentally submit a form it isn't supposed to: \"submit\" is the only\n // value that should trigger the browser's native form submit; everything\n // else (including no formAction at all) is a plain, non-submitting button.\n const htmlType = formAction === \"submit\" ? \"submit\" : \"button\";\n\n const renderButton = () => {\n if (href) {\n return (\n <LinkButton\n {...common}\n href={href}\n target={target}\n data-pihanga={cardName}\n label={ariaLabel ?? label}\n onClick={handleClick}\n >\n {children}\n </LinkButton>\n );\n }\n\n return (\n <Button\n {...common}\n type={htmlType}\n data-pihanga={cardName}\n label={ariaLabel ?? label}\n onClick={handleClick}\n >\n {children}\n </Button>\n );\n };\n\n if (!tooltip && !tooltipCard) return renderButton();\n\n // Determine tooltip open state based on mode.\n // If the button is inside an open dropdown, force the tooltip closed\n // to avoid UI conflicts (dropdown menu should take precedence).\n const tooltipOpen = isInsideOpenDropdown\n ? false\n : tooltipMode === \"open\"\n ? true\n : tooltipMode === \"closed\"\n ? false\n : undefined; // 'auto' or undefined = uncontrolled\n\n // Render tooltip content: use tooltipCard if provided, otherwise use tooltip string\n const tooltipContent = tooltipCard ? (\n <Card cardName={tooltipCard} parentCard={cardName} />\n ) : (\n <p data-pihanga={`${cardName}-tooltip`}>{tooltip}</p>\n );\n\n return (\n <Tooltip open={tooltipOpen}>\n <TooltipTrigger asChild>{renderButton()}</TooltipTrigger>\n <TooltipContent side={tooltipPlacement}>{tooltipContent}</TooltipContent>\n </Tooltip>\n );\n};\n"],"mappings":";;;;;;;;;AAWA,SAAS,EAAkB,GAAgC;CAEzD,OADK,IACE,EAAQ,CAAI,IADD;AAEpB;AAEA,IAAa,KACX,MACoB;CACpB,IAAM,EACJ,SACA,cACA,UACA,cACA,aAAa,GACb,SACA,WACA,YACA,gBACA,gBACA,qBACA,cACA,OACA,cACA,aACA,SACA,WACA,YACA,aACA,YACA,cACA,kBACE,GAGE,IAAuB,EAAgB,GAIvC,IAAO,EAAe,GAEtB,IAAa,EAAkB,GAAM,UAAU,GAC/C,IAAY,EAAkB,GAAM,SAAS,GAY7C,IACJ,kBAAA,GAAA,EAAA,UAAA;EACG;EAXe,IAClB,EAAkB,CAAS,IACzB,IACF,kBAAC,GAAD;GAAM,UAAU;GAAS,YAAY;EAAW,CAAA,IAEhD;EAQG;CACD,EAAA,CAAA,GAGE,IAAS;EACb;EACA;EACA,QAAQ,GAAM;EACd,UAAU,GAAM;EAChB,SAAS,GAAM;EACf,MAAM,GAAM;EAEZ;EACA;EACA;EACA,kBAAkB,GAAM;EAExB,WAAW,GAAG,EAAK,MAAM,EAAE,GAAG,KAAa,KAAK,KAAK;CACvD,GAKM,IAAgB,EAAQ,KAAe,EAAK,UAE5C,UAAoB;EACxB,AAAI,IACF,EAAK,cAAc,CAAW,IAE9B,EAAU,EAAC,MAAE,CAAC;CAElB,GAMM,IAAW,MAAe,WAAW,WAAW,UAEhD,UACA,IAEA,kBAAC,GAAD;EACE,GAAI;EACE;EACE;EACR,gBAAc;EACd,OAAO,KAAa;EACpB,SAAS;EAER;CACS,CAAA,IAKd,kBAAC,GAAD;EACE,GAAI;EACJ,MAAM;EACN,gBAAc;EACd,OAAO,KAAa;EACpB,SAAS;EAER;CACK,CAAA;CAIZ,IAAI,CAAC,KAAW,CAAC,GAAa,OAAO,EAAa;CAKlD,IAAM,IAAc,IAChB,KACA,MAAgB,SACd,KACA,MAAgB,WACd,KACA,KAAA,GAGF,IAAiB,IACrB,kBAAC,GAAD;EAAM,UAAU;EAAa,YAAY;CAAW,CAAA,IAEpD,kBAAC,KAAD;EAAG,gBAAc,GAAG,EAAS;YAAY;CAAW,CAAA;CAGtD,OACE,kBAAC,GAAD;EAAS,MAAM;YAAf,CACE,kBAAC,GAAD;GAAgB,SAAA;aAAS,EAAa;EAAkB,CAAA,GACxD,kBAAC,GAAD;GAAgB,MAAM;aAAmB;EAA+B,CAAA,CACjE;;AAEb"}
@@ -1,4 +1,5 @@
1
1
  import { PiCardRef } from '@pihanga2/core';
2
+ import { FormAction } from '../form/form.types';
2
3
  export declare const PI_BUTTON_CARD = "pi/button";
3
4
  export declare const Button: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<PiButtonProps, S, PiButtonEvents>) => import('@pihanga2/core').PiCardDef;
4
5
  export declare const PI_BUTTON_ACTION: {
@@ -100,6 +101,29 @@ export type PiButtonProps = {
100
101
  loading?: boolean;
101
102
  /** If true, indicates an async operation is pending (similar to loading but distinct). */
102
103
  isPending?: boolean;
104
+ /**
105
+ * When set and this button is rendered inside a `pi/form` card, clicking
106
+ * it requests that top-level form action instead of firing this button's
107
+ * own `onClicked`:
108
+ *
109
+ * - `"submit"` — same as pressing the form's native submit button; fires
110
+ * the Form's `onSubmitted` event with a snapshot of the current field
111
+ * values.
112
+ * - `"cancel"` — fires the Form's `onCancelled` event. Never submits or
113
+ * resets the form.
114
+ *
115
+ * The button's native `<button type>` is derived from this prop so it can
116
+ * never accidentally submit a form it isn't supposed to: `"submit"` →
117
+ * `type="submit"`, `"cancel"` (or unset) → `type="button"`.
118
+ *
119
+ * Has no effect when the button is used outside a `pi/form` — in that case
120
+ * `onClicked` always fires as usual, and the native type is `"button"`.
121
+ *
122
+ * This is the button-specific counterpart of `FormFieldProps`/`name` used
123
+ * by form-bindable fields (`pi/input`, `pi/switch`, …) — together they
124
+ * form the complete `pi/form` interaction contract.
125
+ */
126
+ formAction?: FormAction;
103
127
  className?: string;
104
128
  };
105
129
  export type PiButtonClickedEvent = {
@@ -1 +1 @@
1
- {"version":3,"file":"button.types.js","names":[],"sources":["../../../src/cards/button/button.types.ts"],"sourcesContent":["import {\n createCardDeclaration,\n createOnAction,\n type PiCardRef,\n registerActions,\n} from \"@pihanga2/core\";\n\nexport const PI_BUTTON_CARD = \"pi/button\";\n\nexport const Button = createCardDeclaration<PiButtonProps, PiButtonEvents>(\n PI_BUTTON_CARD,\n);\n\nexport const PI_BUTTON_ACTION = registerActions(PI_BUTTON_CARD, [\"clicked\"]);\n\nexport const onButtonClicked = createOnAction<PiButtonClickedEvent>(\n PI_BUTTON_ACTION.CLICKED,\n);\n\n/** @deprecated Use `onButtonClicked` instead. */\nexport const onPiButtonClicked = onButtonClicked;\n\n/**\n * Declarative \"opts\" subset based on `src/registry/ui/button.tsx`.\n *\n * Notes:\n * - Any icon is referenced by name and resolved via `src/pihanga/icons.ts`.\n * - `children` are provided via `label` (simple) or `content` (card ref).\n */\nexport type PiButtonOpts = {\n /**\n * Visual style variant of the button.\n * Determines the button's appearance (colors, borders, etc.).\n */\n variant?:\n | \"default\"\n | \"destructive\"\n | \"outline\"\n | \"secondary\"\n | \"ghost\"\n | \"ghost2\"\n | \"ghost3\"\n | \"ghostActive\"\n | \"brand\"\n | \"nav\"\n | \"navAction\"\n | \"menuAction\"\n | \"blockAction\"\n | \"blockActionSecondary\"\n | \"primaryOutline\"\n | \"radio\"\n | \"none\";\n\n /**\n * Size of the button.\n * Controls padding, font size, and overall dimensions.\n */\n size?:\n | \"default\"\n | \"xs\"\n | \"sm\"\n | \"md\"\n | \"lg\"\n | \"icon\"\n | \"iconSm\"\n | \"navAction\"\n | \"menuAction\"\n | \"blockAction\"\n | \"none\";\n\n /** Truncate button content with ellipsis if it overflows. */\n truncate?: boolean;\n\n /** If true, button is rendered as a menu trigger button. */\n isMenu?: boolean;\n\n /** Custom CSS class to apply to the loading spinner/indicator. */\n loadingClassName?: string;\n\n /** Icon to display before the button content. Set 'size' to 'icon' if ONLY show icon */\n beforeIcon?: string;\n\n /** Icon to display after the button content */\n afterIcon?: string;\n};\n\nexport type PiButtonProps = {\n id?: string; // optional 'id' to be added to events\n\n /**\n * Optional explicit aria-label.\n *\n * Useful for icon-only / letter-only buttons where the visible content\n * shouldn't be used as the accessible name.\n */\n ariaLabel?: string;\n\n /**\n * Declarative options; maps closely to `@/registry/ui/button`.\n */\n opts?: PiButtonOpts;\n\n /** Simple label; used as children and aria-label fallback. */\n label?: string;\n\n /**\n * Icon name to use as the main button content (instead of text label).\n * Resolved via `src/pihanga/icons.ts`.\n * Takes precedence over `label` and `contentCard`.\n */\n iconLabel?: string;\n\n /**\n * If set, renders this card as the content instead of `label`.\n * (Useful for rich content.)\n */\n contentCard?: PiCardRef;\n\n /** When provided, button will render as an anchor. */\n href?: string;\n target?: string;\n\n tooltip?: string;\n\n /**\n * If set, renders this card as the tooltip content instead of `tooltip`.\n * (Useful for rich tooltip content.)\n */\n tooltipCard?: PiCardRef;\n\n /**\n * Controls tooltip visibility mode.\n * - 'auto' (default): Normal hover behavior\n * - 'open': Force tooltip to be visible\n * - 'closed': Force tooltip to be hidden\n */\n tooltipMode?: \"auto\" | \"open\" | \"closed\";\n\n /**\n * Controls tooltip placement/position.\n * - 'top': Tooltip appears above the button (default)\n * - 'right': Tooltip appears to the right of the button\n * - 'bottom': Tooltip appears below the button\n * - 'left': Tooltip appears to the left of the button\n */\n tooltipPlacement?: \"top\" | \"right\" | \"bottom\" | \"left\";\n\n /** Indicates whether the button is in an active/selected state. */\n active?: boolean;\n\n /** Indicates whether the button has focus state styling applied. */\n focused?: boolean;\n\n /** If true, disables the button and prevents interaction. */\n disabled?: boolean;\n\n /** If true, shows loading state and typically disables interaction. */\n loading?: boolean;\n\n /** If true, indicates an async operation is pending (similar to loading but distinct). */\n isPending?: boolean;\n\n className?: string;\n};\n\nexport type PiButtonClickedEvent = {\n id?: string;\n};\n\nexport type PiButtonEvents = {\n onClicked: PiButtonClickedEvent;\n};\n"],"mappings":";;AAOA,IAAa,IAAiB,aAEjB,IAAS,EACpB,CACF,GAEa,IAAmB,EAAgB,GAAgB,CAAC,SAAS,CAAC,GAE9D,IAAkB,EAC7B,EAAiB,OACnB,GAGa,IAAoB"}
1
+ {"version":3,"file":"button.types.js","names":[],"sources":["../../../src/cards/button/button.types.ts"],"sourcesContent":["import {\n createCardDeclaration,\n createOnAction,\n type PiCardRef,\n registerActions,\n} from \"@pihanga2/core\";\nimport type {FormAction} from \"@/cards/form/form.types\";\n\nexport const PI_BUTTON_CARD = \"pi/button\";\n\nexport const Button = createCardDeclaration<PiButtonProps, PiButtonEvents>(\n PI_BUTTON_CARD,\n);\n\nexport const PI_BUTTON_ACTION = registerActions(PI_BUTTON_CARD, [\"clicked\"]);\n\nexport const onButtonClicked = createOnAction<PiButtonClickedEvent>(\n PI_BUTTON_ACTION.CLICKED,\n);\n\n/** @deprecated Use `onButtonClicked` instead. */\nexport const onPiButtonClicked = onButtonClicked;\n\n/**\n * Declarative \"opts\" subset based on `src/registry/ui/button.tsx`.\n *\n * Notes:\n * - Any icon is referenced by name and resolved via `src/pihanga/icons.ts`.\n * - `children` are provided via `label` (simple) or `content` (card ref).\n */\nexport type PiButtonOpts = {\n /**\n * Visual style variant of the button.\n * Determines the button's appearance (colors, borders, etc.).\n */\n variant?:\n | \"default\"\n | \"destructive\"\n | \"outline\"\n | \"secondary\"\n | \"ghost\"\n | \"ghost2\"\n | \"ghost3\"\n | \"ghostActive\"\n | \"brand\"\n | \"nav\"\n | \"navAction\"\n | \"menuAction\"\n | \"blockAction\"\n | \"blockActionSecondary\"\n | \"primaryOutline\"\n | \"radio\"\n | \"none\";\n\n /**\n * Size of the button.\n * Controls padding, font size, and overall dimensions.\n */\n size?:\n | \"default\"\n | \"xs\"\n | \"sm\"\n | \"md\"\n | \"lg\"\n | \"icon\"\n | \"iconSm\"\n | \"navAction\"\n | \"menuAction\"\n | \"blockAction\"\n | \"none\";\n\n /** Truncate button content with ellipsis if it overflows. */\n truncate?: boolean;\n\n /** If true, button is rendered as a menu trigger button. */\n isMenu?: boolean;\n\n /** Custom CSS class to apply to the loading spinner/indicator. */\n loadingClassName?: string;\n\n /** Icon to display before the button content. Set 'size' to 'icon' if ONLY show icon */\n beforeIcon?: string;\n\n /** Icon to display after the button content */\n afterIcon?: string;\n};\n\nexport type PiButtonProps = {\n id?: string; // optional 'id' to be added to events\n\n /**\n * Optional explicit aria-label.\n *\n * Useful for icon-only / letter-only buttons where the visible content\n * shouldn't be used as the accessible name.\n */\n ariaLabel?: string;\n\n /**\n * Declarative options; maps closely to `@/registry/ui/button`.\n */\n opts?: PiButtonOpts;\n\n /** Simple label; used as children and aria-label fallback. */\n label?: string;\n\n /**\n * Icon name to use as the main button content (instead of text label).\n * Resolved via `src/pihanga/icons.ts`.\n * Takes precedence over `label` and `contentCard`.\n */\n iconLabel?: string;\n\n /**\n * If set, renders this card as the content instead of `label`.\n * (Useful for rich content.)\n */\n contentCard?: PiCardRef;\n\n /** When provided, button will render as an anchor. */\n href?: string;\n target?: string;\n\n tooltip?: string;\n\n /**\n * If set, renders this card as the tooltip content instead of `tooltip`.\n * (Useful for rich tooltip content.)\n */\n tooltipCard?: PiCardRef;\n\n /**\n * Controls tooltip visibility mode.\n * - 'auto' (default): Normal hover behavior\n * - 'open': Force tooltip to be visible\n * - 'closed': Force tooltip to be hidden\n */\n tooltipMode?: \"auto\" | \"open\" | \"closed\";\n\n /**\n * Controls tooltip placement/position.\n * - 'top': Tooltip appears above the button (default)\n * - 'right': Tooltip appears to the right of the button\n * - 'bottom': Tooltip appears below the button\n * - 'left': Tooltip appears to the left of the button\n */\n tooltipPlacement?: \"top\" | \"right\" | \"bottom\" | \"left\";\n\n /** Indicates whether the button is in an active/selected state. */\n active?: boolean;\n\n /** Indicates whether the button has focus state styling applied. */\n focused?: boolean;\n\n /** If true, disables the button and prevents interaction. */\n disabled?: boolean;\n\n /** If true, shows loading state and typically disables interaction. */\n loading?: boolean;\n\n /** If true, indicates an async operation is pending (similar to loading but distinct). */\n isPending?: boolean;\n\n /**\n * When set and this button is rendered inside a `pi/form` card, clicking\n * it requests that top-level form action instead of firing this button's\n * own `onClicked`:\n *\n * - `\"submit\"` — same as pressing the form's native submit button; fires\n * the Form's `onSubmitted` event with a snapshot of the current field\n * values.\n * - `\"cancel\"` — fires the Form's `onCancelled` event. Never submits or\n * resets the form.\n *\n * The button's native `<button type>` is derived from this prop so it can\n * never accidentally submit a form it isn't supposed to: `\"submit\"` →\n * `type=\"submit\"`, `\"cancel\"` (or unset) → `type=\"button\"`.\n *\n * Has no effect when the button is used outside a `pi/form` — in that case\n * `onClicked` always fires as usual, and the native type is `\"button\"`.\n *\n * This is the button-specific counterpart of `FormFieldProps`/`name` used\n * by form-bindable fields (`pi/input`, `pi/switch`, …) — together they\n * form the complete `pi/form` interaction contract.\n */\n formAction?: FormAction;\n\n className?: string;\n};\n\nexport type PiButtonClickedEvent = {\n id?: string;\n};\n\nexport type PiButtonEvents = {\n onClicked: PiButtonClickedEvent;\n};\n"],"mappings":";;AAQA,IAAa,IAAiB,aAEjB,IAAS,EACpB,CACF,GAEa,IAAmB,EAAgB,GAAgB,CAAC,SAAS,CAAC,GAE9D,IAAkB,EAC7B,EAAiB,OACnB,GAGa,IAAoB"}
@@ -1,3 +1,4 @@
1
+ import { FormFieldProps } from '../form/form.types';
1
2
  export declare const PI_CHECKBOX_CARD = "pi/checkbox";
2
3
  export declare const Checkbox: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<PiCheckboxProps, S, PiCheckboxEvents>) => import('@pihanga2/core').PiCardDef;
3
4
  export declare const PI_CHECKBOX_ACTION: {
@@ -10,13 +11,7 @@ export declare const onCheckboxChanged: <S extends import('@pihanga2/core').Redu
10
11
  export declare const onPiCheckboxChanged: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core/types').PiRegisterMinimal, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
11
12
  cardID: string;
12
13
  } & PiCheckboxChangedEvent>) => void;
13
- export type PiCheckboxProps = {
14
- /**
15
- * Field name used to bind to FormContext when inside a pi/form card.
16
- * When provided the component reads its checked state from form data and
17
- * writes back via form.handleChange.
18
- */
19
- name?: string;
14
+ export type PiCheckboxProps = FormFieldProps & {
20
15
  /**
21
16
  * Controlled checked state used in standalone mode (outside a Form).
22
17
  * Ignored when `name` is set and the component is inside a pi/form.
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.types.js","names":[],"sources":["../../../src/cards/checkbox/checkbox.types.ts"],"sourcesContent":["import {\n createCardDeclaration,\n createOnAction,\n registerActions,\n} from \"@pihanga2/core\";\n\nexport const PI_CHECKBOX_CARD = \"pi/checkbox\";\n\nexport const Checkbox = createCardDeclaration<\n PiCheckboxProps,\n PiCheckboxEvents\n>(PI_CHECKBOX_CARD);\n\nexport const PI_CHECKBOX_ACTION = registerActions(PI_CHECKBOX_CARD, [\n \"changed\",\n]);\n\nexport const onCheckboxChanged = createOnAction<PiCheckboxChangedEvent>(\n PI_CHECKBOX_ACTION.CHANGED,\n);\n\n/** @deprecated Use `onCheckboxChanged` instead. */\nexport const onPiCheckboxChanged = onCheckboxChanged;\n\nexport type PiCheckboxProps = {\n /**\n * Field name used to bind to FormContext when inside a pi/form card.\n * When provided the component reads its checked state from form data and\n * writes back via form.handleChange.\n */\n name?: string;\n\n /**\n * Controlled checked state used in standalone mode (outside a Form).\n * Ignored when `name` is set and the component is inside a pi/form.\n */\n checked?: boolean;\n\n /** When true, the checkbox is disabled and non-interactive. */\n disabled?: boolean;\n\n /**\n * Optional label text rendered next to the checkbox.\n * The label is automatically associated with the input via `htmlFor`.\n */\n label?: string;\n};\n\nexport type PiCheckboxChangedEvent = {\n /** Field name, mirrors the `name` prop if provided. */\n name?: string;\n /** New checked state after the change. */\n checked: boolean;\n};\n\nexport type PiCheckboxEvents = {\n onChanged: PiCheckboxChangedEvent;\n};\n"],"mappings":";;AAMA,IAAa,IAAmB,eAEnB,IAAW,EAGtB,CAAgB,GAEL,IAAqB,EAAgB,GAAkB,CAClE,SACF,CAAC,GAEY,IAAoB,EAC/B,EAAmB,OACrB,GAGa,IAAsB"}
1
+ {"version":3,"file":"checkbox.types.js","names":[],"sources":["../../../src/cards/checkbox/checkbox.types.ts"],"sourcesContent":["import {\n createCardDeclaration,\n createOnAction,\n registerActions,\n} from \"@pihanga2/core\";\nimport type {FormFieldProps} from \"@/cards/form/form.types\";\n\nexport const PI_CHECKBOX_CARD = \"pi/checkbox\";\n\nexport const Checkbox = createCardDeclaration<\n PiCheckboxProps,\n PiCheckboxEvents\n>(PI_CHECKBOX_CARD);\n\nexport const PI_CHECKBOX_ACTION = registerActions(PI_CHECKBOX_CARD, [\n \"changed\",\n]);\n\nexport const onCheckboxChanged = createOnAction<PiCheckboxChangedEvent>(\n PI_CHECKBOX_ACTION.CHANGED,\n);\n\n/** @deprecated Use `onCheckboxChanged` instead. */\nexport const onPiCheckboxChanged = onCheckboxChanged;\n\nexport type PiCheckboxProps = FormFieldProps & {\n /**\n * Controlled checked state used in standalone mode (outside a Form).\n * Ignored when `name` is set and the component is inside a pi/form.\n */\n checked?: boolean;\n\n /** When true, the checkbox is disabled and non-interactive. */\n disabled?: boolean;\n\n /**\n * Optional label text rendered next to the checkbox.\n * The label is automatically associated with the input via `htmlFor`.\n */\n label?: string;\n};\n\nexport type PiCheckboxChangedEvent = {\n /** Field name, mirrors the `name` prop if provided. */\n name?: string;\n /** New checked state after the change. */\n checked: boolean;\n};\n\nexport type PiCheckboxEvents = {\n onChanged: PiCheckboxChangedEvent;\n};\n"],"mappings":";;AAOA,IAAa,IAAmB,eAEnB,IAAW,EAGtB,CAAgB,GAEL,IAAqB,EAAgB,GAAkB,CAClE,SACF,CAAC,GAEY,IAAoB,EAC/B,EAAmB,OACrB,GAGa,IAAsB"}