@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.
- package/AGENT.using-cards.md +2 -2
- package/README.md +4 -1
- package/cards/attachment/attachment.component.d.ts +4 -0
- package/cards/attachment/attachment.component.js +46 -0
- package/cards/attachment/attachment.component.js.map +1 -0
- package/cards/attachment/attachment.types.d.ts +95 -0
- package/cards/attachment/attachment.types.js +7 -0
- package/cards/attachment/attachment.types.js.map +1 -0
- package/cards/attachment/attachmentGroup.component.d.ts +4 -0
- package/cards/attachment/attachmentGroup.component.js +21 -0
- package/cards/attachment/attachmentGroup.component.js.map +1 -0
- package/cards/attachment/index.d.ts +1 -0
- package/cards/attachment/index.js +16 -0
- package/cards/attachment/index.js.map +1 -0
- package/cards/bubble/bubble.component.d.ts +4 -0
- package/cards/bubble/bubble.component.js +67 -0
- package/cards/bubble/bubble.component.js.map +1 -0
- package/cards/bubble/bubble.types.d.ts +106 -0
- package/cards/bubble/bubble.types.js +7 -0
- package/cards/bubble/bubble.types.js.map +1 -0
- package/cards/bubble/bubbleGroup.component.d.ts +4 -0
- package/cards/bubble/bubbleGroup.component.js +21 -0
- package/cards/bubble/bubbleGroup.component.js.map +1 -0
- package/cards/bubble/index.d.ts +1 -0
- package/cards/bubble/index.js +16 -0
- package/cards/bubble/index.js.map +1 -0
- package/cards/button/button.component.js +56 -54
- package/cards/button/button.component.js.map +1 -1
- package/cards/button/button.types.d.ts +24 -0
- package/cards/button/button.types.js.map +1 -1
- package/cards/checkbox/checkbox.types.d.ts +2 -7
- package/cards/checkbox/checkbox.types.js.map +1 -1
- package/cards/dataTable/dataTable.component.js +191 -124
- package/cards/dataTable/dataTable.component.js.map +1 -1
- package/cards/dataTable/dataTable.types.d.ts +50 -0
- package/cards/dataTable/dataTable.types.js +6 -3
- package/cards/dataTable/dataTable.types.js.map +1 -1
- package/cards/dataTable/index.js +6 -6
- package/cards/dropDownMenu/dropdown-menu.ui.js +41 -41
- package/cards/field/field.component.js +1 -1
- package/cards/field/field.component.js.map +1 -1
- package/cards/form/form.component.js +57 -32
- package/cards/form/form.component.js.map +1 -1
- package/cards/form/form.context.d.ts +11 -0
- package/cards/form/form.context.js +1 -0
- package/cards/form/form.context.js.map +1 -1
- package/cards/form/form.types.d.ts +75 -0
- package/cards/form/form.types.js +6 -2
- package/cards/form/form.types.js.map +1 -1
- package/cards/form/index.js +5 -5
- package/cards/input/index.js +6 -6
- package/cards/input/input.component.js +38 -32
- package/cards/input/input.component.js.map +1 -1
- package/cards/input/input.types.d.ts +14 -7
- package/cards/input/input.types.js +2 -2
- package/cards/input/input.types.js.map +1 -1
- package/cards/message/index.d.ts +1 -0
- package/cards/message/index.js +15 -0
- package/cards/message/index.js.map +1 -0
- package/cards/message/message.component.d.ts +4 -0
- package/cards/message/message.component.js +47 -0
- package/cards/message/message.component.js.map +1 -0
- package/cards/message/message.types.d.ts +56 -0
- package/cards/message/message.types.js +7 -0
- package/cards/message/message.types.js.map +1 -0
- package/cards/message/messageGroup.component.d.ts +4 -0
- package/cards/message/messageGroup.component.js +21 -0
- package/cards/message/messageGroup.component.js.map +1 -0
- package/cards/pageWithNavbarMeta/index.js +35 -25
- package/cards/pageWithNavbarMeta/index.js.map +1 -1
- package/cards/pageWithNavbarMeta/pageWithNavbarMeta.types.d.ts +1 -4
- package/cards/select/select.types.d.ts +2 -7
- package/cards/select/select.types.js.map +1 -1
- package/cards/switch/switch.types.d.ts +2 -7
- package/cards/switch/switch.types.js.map +1 -1
- package/cards/textArea/textArea.component.js +1 -1
- package/cards/textArea/textArea.component.js.map +1 -1
- package/cards/textArea/textArea.types.d.ts +15 -11
- package/cards/textArea/textArea.types.js.map +1 -1
- package/cards/textField/textField.component.js +13 -9
- package/cards/textField/textField.component.js.map +1 -1
- package/cards/textField/textField.types.d.ts +12 -7
- package/cards/textField/textField.types.js.map +1 -1
- package/cards/toggleGroup/toggleGroup.types.d.ts +2 -7
- package/cards/toggleGroup/toggleGroup.types.js.map +1 -1
- package/components/ui/attachment.js +102 -0
- package/components/ui/attachment.js.map +1 -0
- package/components/ui/badge.js +7 -7
- package/components/ui/bubble.js +73 -0
- package/components/ui/bubble.js.map +1 -0
- package/components/ui/button.js +11 -11
- package/components/ui/empty.js +12 -12
- package/components/ui/field.js +16 -16
- package/components/ui/message.js +51 -0
- package/components/ui/message.js.map +1 -0
- package/components/ui/toggle-group.js +1 -1
- package/components/ui/toggle.js +1 -1
- package/package.json +17 -2
package/AGENT.using-cards.md
CHANGED
|
@@ -976,7 +976,7 @@ search box, a settings field) is **`pi/input`** — *not* `pi/text-input`, which
|
|
|
976
976
|
does not exist. You do **not** need to write your own local card.
|
|
977
977
|
|
|
978
978
|
```ts
|
|
979
|
-
import {
|
|
979
|
+
import {Input, onPiInputChanged} from "@/cards/input";
|
|
980
980
|
import type {AppState} from "@/app.state";
|
|
981
981
|
|
|
982
982
|
register((r) => {
|
|
@@ -985,7 +985,7 @@ register((r) => {
|
|
|
985
985
|
});
|
|
986
986
|
});
|
|
987
987
|
|
|
988
|
-
registerCard("myApp/jwtField",
|
|
988
|
+
registerCard("myApp/jwtField", Input({
|
|
989
989
|
label: "JWT token",
|
|
990
990
|
value: memo((s: AppState) => s.jwtToken), // ← bound to Redux state
|
|
991
991
|
placeholder: "Paste your bearer token here…",
|
package/README.md
CHANGED
|
@@ -62,11 +62,13 @@ import "@pihanga2/shadcn/cards/dataTable";
|
|
|
62
62
|
|
|
63
63
|
---
|
|
64
64
|
|
|
65
|
-
## Included cards (
|
|
65
|
+
## Included cards (53)
|
|
66
66
|
|
|
67
|
+
- `attachment`
|
|
67
68
|
- `avatar`
|
|
68
69
|
- `badge`
|
|
69
70
|
- `box`
|
|
71
|
+
- `bubble`
|
|
70
72
|
- `button`
|
|
71
73
|
- `checkbox`
|
|
72
74
|
- `collapsibleCard`
|
|
@@ -90,6 +92,7 @@ import "@pihanga2/shadcn/cards/dataTable";
|
|
|
90
92
|
- `loadingOverlay`
|
|
91
93
|
- `loadingSkeleton`
|
|
92
94
|
- `menu`
|
|
95
|
+
- `message`
|
|
93
96
|
- `modeToggle`
|
|
94
97
|
- `navbarSearch`
|
|
95
98
|
- `observable`
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { getIcon as e } from "../icons.js";
|
|
2
|
+
import { Attachment as t, AttachmentAction as n, AttachmentActions as r, AttachmentContent as i, AttachmentDescription as a, AttachmentMedia as o, AttachmentTitle as s, AttachmentTrigger as c } from "../../components/ui/attachment.js";
|
|
3
|
+
import "react";
|
|
4
|
+
import "@pihanga2/core";
|
|
5
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
6
|
+
//#region src/cards/attachment/attachment.component.tsx
|
|
7
|
+
var d = (d) => {
|
|
8
|
+
let { id: f, icon: p, imageSrc: m, imageAlt: h = "", title: g, description: _, state: v = "done", size: y = "default", orientation: b = "horizontal", actions: x, triggerAriaLabel: S, className: C, style: w, cardName: T, onActionClicked: E, onTriggered: D } = d;
|
|
9
|
+
return /* @__PURE__ */ u(t, {
|
|
10
|
+
state: v,
|
|
11
|
+
size: y,
|
|
12
|
+
orientation: b,
|
|
13
|
+
className: C,
|
|
14
|
+
style: w,
|
|
15
|
+
"data-pihanga": T,
|
|
16
|
+
children: [
|
|
17
|
+
S && /* @__PURE__ */ l(c, {
|
|
18
|
+
"aria-label": S,
|
|
19
|
+
onClick: () => D({ id: f })
|
|
20
|
+
}),
|
|
21
|
+
m ? /* @__PURE__ */ l(o, {
|
|
22
|
+
variant: "image",
|
|
23
|
+
children: /* @__PURE__ */ l("img", {
|
|
24
|
+
src: m,
|
|
25
|
+
alt: h
|
|
26
|
+
})
|
|
27
|
+
}) : p ? /* @__PURE__ */ l(o, {
|
|
28
|
+
variant: "icon",
|
|
29
|
+
children: e(p)
|
|
30
|
+
}) : null,
|
|
31
|
+
/* @__PURE__ */ u(i, { children: [/* @__PURE__ */ l(s, { children: g }), _ && /* @__PURE__ */ l(a, { children: _ })] }),
|
|
32
|
+
x && x.length > 0 && /* @__PURE__ */ l(r, { children: x.map((t) => /* @__PURE__ */ l(n, {
|
|
33
|
+
"aria-label": t.ariaLabel,
|
|
34
|
+
onClick: () => E({
|
|
35
|
+
id: f,
|
|
36
|
+
action: t.id
|
|
37
|
+
}),
|
|
38
|
+
children: e(t.icon)
|
|
39
|
+
}, t.id)) })
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
export { d as AttachmentComponent };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=attachment.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment.component.js","names":[],"sources":["../../../src/cards/attachment/attachment.component.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {type PiCardProps} from \"@pihanga2/core\";\nimport {\n Attachment,\n AttachmentAction,\n AttachmentActions,\n AttachmentContent,\n AttachmentDescription,\n AttachmentMedia,\n AttachmentTitle,\n AttachmentTrigger,\n} from \"@/components/ui/attachment\";\nimport {getIcon} from \"@/cards/icons\";\nimport type {AttachmentEvents, AttachmentProps} from \"./attachment.types\";\n\nexport const AttachmentComponent = (\n props: PiCardProps<AttachmentProps, AttachmentEvents>,\n): React.ReactNode => {\n const {\n id,\n icon,\n imageSrc,\n imageAlt = \"\",\n title,\n description,\n state = \"done\",\n size = \"default\",\n orientation = \"horizontal\",\n actions,\n triggerAriaLabel,\n className,\n style,\n cardName,\n onActionClicked,\n onTriggered,\n } = props;\n\n return (\n <Attachment\n state={state}\n size={size}\n orientation={orientation}\n className={className}\n style={style}\n data-pihanga={cardName}\n >\n {triggerAriaLabel && (\n <AttachmentTrigger\n aria-label={triggerAriaLabel}\n onClick={() => onTriggered({id})}\n />\n )}\n\n {imageSrc ? (\n <AttachmentMedia variant=\"image\">\n <img src={imageSrc} alt={imageAlt} />\n </AttachmentMedia>\n ) : icon ? (\n <AttachmentMedia variant=\"icon\">{getIcon(icon)}</AttachmentMedia>\n ) : null}\n\n <AttachmentContent>\n <AttachmentTitle>{title}</AttachmentTitle>\n {description && (\n <AttachmentDescription>{description}</AttachmentDescription>\n )}\n </AttachmentContent>\n\n {actions && actions.length > 0 && (\n <AttachmentActions>\n {actions.map((a) => (\n <AttachmentAction\n key={a.id}\n aria-label={a.ariaLabel}\n onClick={() => onActionClicked({id, action: a.id})}\n >\n {getIcon(a.icon)}\n </AttachmentAction>\n ))}\n </AttachmentActions>\n )}\n </Attachment>\n );\n};\n"],"mappings":";;;;;;AAeA,IAAa,KACX,MACoB;CACpB,IAAM,EACJ,OACA,SACA,aACA,cAAW,IACX,UACA,gBACA,WAAQ,QACR,UAAO,WACP,iBAAc,cACd,YACA,qBACA,cACA,UACA,aACA,oBACA,mBACE;CAEJ,OACE,kBAAC,GAAD;EACS;EACD;EACO;EACF;EACJ;EACP,gBAAc;YANhB;GAQG,KACC,kBAAC,GAAD;IACE,cAAY;IACZ,eAAe,EAAY,EAAC,MAAE,CAAC;GAChC,CAAA;GAGF,IACC,kBAAC,GAAD;IAAiB,SAAQ;cACvB,kBAAC,OAAD;KAAK,KAAK;KAAU,KAAK;IAAW,CAAA;GACrB,CAAA,IACf,IACF,kBAAC,GAAD;IAAiB,SAAQ;cAAQ,EAAQ,CAAI;GAAmB,CAAA,IAC9D;GAEJ,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD,EAAA,UAAkB,EAAuB,CAAA,GACxC,KACC,kBAAC,GAAD,EAAA,UAAwB,EAAmC,CAAA,CAE5C,EAAA,CAAA;GAElB,KAAW,EAAQ,SAAS,KAC3B,kBAAC,GAAD,EAAA,UACG,EAAQ,KAAK,MACZ,kBAAC,GAAD;IAEE,cAAY,EAAE;IACd,eAAe,EAAgB;KAAC;KAAI,QAAQ,EAAE;IAAE,CAAC;cAEhD,EAAQ,EAAE,IAAI;GACC,GALX,EAAE,EAKS,CACnB,EACgB,CAAA;EAEX;;AAEhB"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { PiCardRef } from '@pihanga2/core';
|
|
2
|
+
import { default as React } from 'react';
|
|
3
|
+
export declare const ATTACHMENT_CARD = "shad/attachment";
|
|
4
|
+
export declare const Attachment: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<AttachmentProps, S, AttachmentEvents>) => import('@pihanga2/core').PiCardDef;
|
|
5
|
+
export declare const ATTACHMENT_ACTION: {
|
|
6
|
+
ACTION_CLICKED: string;
|
|
7
|
+
TRIGGERED: string;
|
|
8
|
+
};
|
|
9
|
+
export type AttachmentActionClickedEvent = {
|
|
10
|
+
id?: string;
|
|
11
|
+
action: string;
|
|
12
|
+
};
|
|
13
|
+
export type AttachmentTriggeredEvent = {
|
|
14
|
+
id?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const onAttachmentActionClicked: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core/types').PiRegisterMinimal, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
17
|
+
cardID: string;
|
|
18
|
+
} & AttachmentActionClickedEvent>) => void;
|
|
19
|
+
export declare const onAttachmentTriggered: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core/types').PiRegisterMinimal, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
20
|
+
cardID: string;
|
|
21
|
+
} & AttachmentTriggeredEvent>) => void;
|
|
22
|
+
export type AttachmentEvents = {
|
|
23
|
+
onActionClicked: AttachmentActionClickedEvent;
|
|
24
|
+
onTriggered: AttachmentTriggeredEvent;
|
|
25
|
+
};
|
|
26
|
+
/** Upload lifecycle state — drives styling and the title shimmer. */
|
|
27
|
+
export type AttachmentState = "idle" | "uploading" | "processing" | "error" | "done";
|
|
28
|
+
export type AttachmentSize = "default" | "sm" | "xs";
|
|
29
|
+
export type AttachmentOrientation = "horizontal" | "vertical";
|
|
30
|
+
/** A single action button rendered inside `AttachmentActions`. */
|
|
31
|
+
export type AttachmentActionItem = {
|
|
32
|
+
/** Stable id echoed in the `onActionClicked` event. */
|
|
33
|
+
id: string;
|
|
34
|
+
/** Icon name from the Pihanga icon registry. */
|
|
35
|
+
icon: string;
|
|
36
|
+
/** Accessible label — required, since the action is icon-only. */
|
|
37
|
+
ariaLabel: string;
|
|
38
|
+
};
|
|
39
|
+
export type AttachmentProps = {
|
|
40
|
+
/** Stable id echoed in `onActionClicked` / `onTriggered` events. */
|
|
41
|
+
id?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Icon name from the Pihanga icon registry, rendered inside
|
|
44
|
+
* `AttachmentMedia` (variant `"icon"`). Ignored when `imageSrc` is set.
|
|
45
|
+
*/
|
|
46
|
+
icon?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Image URL rendered inside `AttachmentMedia` (variant `"image"`).
|
|
49
|
+
* Takes precedence over `icon`.
|
|
50
|
+
*/
|
|
51
|
+
imageSrc?: string;
|
|
52
|
+
/** Accessible alt text for `imageSrc`. */
|
|
53
|
+
imageAlt?: string;
|
|
54
|
+
/** File name / title rendered inside `AttachmentTitle`. */
|
|
55
|
+
title: string;
|
|
56
|
+
/** Secondary metadata (e.g. "PDF · 2.4 MB") rendered inside `AttachmentDescription`. */
|
|
57
|
+
description?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Upload lifecycle state.
|
|
60
|
+
* @default "done"
|
|
61
|
+
*/
|
|
62
|
+
state?: AttachmentState;
|
|
63
|
+
/**
|
|
64
|
+
* Attachment size.
|
|
65
|
+
* @default "default"
|
|
66
|
+
*/
|
|
67
|
+
size?: AttachmentSize;
|
|
68
|
+
/**
|
|
69
|
+
* Lay the media beside (`"horizontal"`) or above (`"vertical"`) the content.
|
|
70
|
+
* @default "horizontal"
|
|
71
|
+
*/
|
|
72
|
+
orientation?: AttachmentOrientation;
|
|
73
|
+
/** Row of icon-only action buttons (e.g. remove, download). */
|
|
74
|
+
actions?: AttachmentActionItem[];
|
|
75
|
+
/**
|
|
76
|
+
* When set, renders a full-card `AttachmentTrigger` overlay; clicking it
|
|
77
|
+
* (or activating it with the keyboard) fires `onTriggered`. Actions
|
|
78
|
+
* remain independently clickable.
|
|
79
|
+
*/
|
|
80
|
+
triggerAriaLabel?: string;
|
|
81
|
+
/** Additional Tailwind classes applied to the root `Attachment` element. */
|
|
82
|
+
className?: string;
|
|
83
|
+
/** Inline styles applied to the root `Attachment` element. */
|
|
84
|
+
style?: React.CSSProperties;
|
|
85
|
+
};
|
|
86
|
+
export declare const ATTACHMENT_GROUP_CARD = "shad/attachment-group";
|
|
87
|
+
export declare const AttachmentGroup: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<AttachmentGroupProps, S, {}>) => import('@pihanga2/core').PiCardDef;
|
|
88
|
+
export type AttachmentGroupProps = {
|
|
89
|
+
/** Ordered list of `shad/attachment` card refs to lay out in a row. */
|
|
90
|
+
content: PiCardRef[];
|
|
91
|
+
/** Additional Tailwind classes applied to the root element. */
|
|
92
|
+
className?: string;
|
|
93
|
+
/** Inline styles applied to the root element. */
|
|
94
|
+
style?: React.CSSProperties;
|
|
95
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createCardDeclaration as e, createOnAction as t, registerActions as n } from "@pihanga2/core";
|
|
2
|
+
//#region src/cards/attachment/attachment.types.ts
|
|
3
|
+
var r = "shad/attachment", i = e(r), a = n(r, ["action_clicked", "triggered"]), o = t(a.ACTION_CLICKED), s = t(a.TRIGGERED), c = "shad/attachment-group", l = e(c);
|
|
4
|
+
//#endregion
|
|
5
|
+
export { a as ATTACHMENT_ACTION, r as ATTACHMENT_CARD, c as ATTACHMENT_GROUP_CARD, i as Attachment, l as AttachmentGroup, o as onAttachmentActionClicked, s as onAttachmentTriggered };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=attachment.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment.types.js","names":[],"sources":["../../../src/cards/attachment/attachment.types.ts"],"sourcesContent":["import {\n createCardDeclaration,\n createOnAction,\n registerActions,\n type PiCardRef,\n} from \"@pihanga2/core\";\nimport type React from \"react\";\n\nexport const ATTACHMENT_CARD = \"shad/attachment\";\n\nexport const Attachment = createCardDeclaration<\n AttachmentProps,\n AttachmentEvents\n>(ATTACHMENT_CARD);\n\nexport const ATTACHMENT_ACTION = registerActions(ATTACHMENT_CARD, [\n \"action_clicked\",\n \"triggered\",\n]);\n\nexport type AttachmentActionClickedEvent = {id?: string; action: string};\nexport type AttachmentTriggeredEvent = {id?: string};\n\nexport const onAttachmentActionClicked =\n createOnAction<AttachmentActionClickedEvent>(\n ATTACHMENT_ACTION.ACTION_CLICKED,\n );\nexport const onAttachmentTriggered = createOnAction<AttachmentTriggeredEvent>(\n ATTACHMENT_ACTION.TRIGGERED,\n);\n\nexport type AttachmentEvents = {\n onActionClicked: AttachmentActionClickedEvent;\n onTriggered: AttachmentTriggeredEvent;\n};\n\n/** Upload lifecycle state — drives styling and the title shimmer. */\nexport type AttachmentState =\n | \"idle\"\n | \"uploading\"\n | \"processing\"\n | \"error\"\n | \"done\";\n\nexport type AttachmentSize = \"default\" | \"sm\" | \"xs\";\n\nexport type AttachmentOrientation = \"horizontal\" | \"vertical\";\n\n/** A single action button rendered inside `AttachmentActions`. */\nexport type AttachmentActionItem = {\n /** Stable id echoed in the `onActionClicked` event. */\n id: string;\n /** Icon name from the Pihanga icon registry. */\n icon: string;\n /** Accessible label — required, since the action is icon-only. */\n ariaLabel: string;\n};\n\nexport type AttachmentProps = {\n /** Stable id echoed in `onActionClicked` / `onTriggered` events. */\n id?: string;\n\n /**\n * Icon name from the Pihanga icon registry, rendered inside\n * `AttachmentMedia` (variant `\"icon\"`). Ignored when `imageSrc` is set.\n */\n icon?: string;\n\n /**\n * Image URL rendered inside `AttachmentMedia` (variant `\"image\"`).\n * Takes precedence over `icon`.\n */\n imageSrc?: string;\n /** Accessible alt text for `imageSrc`. */\n imageAlt?: string;\n\n /** File name / title rendered inside `AttachmentTitle`. */\n title: string;\n\n /** Secondary metadata (e.g. \"PDF · 2.4 MB\") rendered inside `AttachmentDescription`. */\n description?: string;\n\n /**\n * Upload lifecycle state.\n * @default \"done\"\n */\n state?: AttachmentState;\n\n /**\n * Attachment size.\n * @default \"default\"\n */\n size?: AttachmentSize;\n\n /**\n * Lay the media beside (`\"horizontal\"`) or above (`\"vertical\"`) the content.\n * @default \"horizontal\"\n */\n orientation?: AttachmentOrientation;\n\n /** Row of icon-only action buttons (e.g. remove, download). */\n actions?: AttachmentActionItem[];\n\n /**\n * When set, renders a full-card `AttachmentTrigger` overlay; clicking it\n * (or activating it with the keyboard) fires `onTriggered`. Actions\n * remain independently clickable.\n */\n triggerAriaLabel?: string;\n\n /** Additional Tailwind classes applied to the root `Attachment` element. */\n className?: string;\n /** Inline styles applied to the root `Attachment` element. */\n style?: React.CSSProperties;\n};\n\n// ---------------------------------------------------------------------------\n// shad/attachment-group — horizontally-scrollable row of attachments.\n// ---------------------------------------------------------------------------\n\nexport const ATTACHMENT_GROUP_CARD = \"shad/attachment-group\";\n\nexport const AttachmentGroup = createCardDeclaration<AttachmentGroupProps>(\n ATTACHMENT_GROUP_CARD,\n);\n\nexport type AttachmentGroupProps = {\n /** Ordered list of `shad/attachment` card refs to lay out in a row. */\n content: PiCardRef[];\n /** Additional Tailwind classes applied to the root element. */\n className?: string;\n /** Inline styles applied to the root element. */\n style?: React.CSSProperties;\n};\n"],"mappings":";;AAQA,IAAa,IAAkB,mBAElB,IAAa,EAGxB,CAAe,GAEJ,IAAoB,EAAgB,GAAiB,CAChE,kBACA,WACF,CAAC,GAKY,IACX,EACE,EAAkB,cACpB,GACW,IAAwB,EACnC,EAAkB,SACpB,GA2Fa,IAAwB,yBAExB,IAAkB,EAC7B,CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AttachmentGroup as e } from "../../components/ui/attachment.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { Card as t } from "@pihanga2/core";
|
|
4
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
5
|
+
//#region src/cards/attachment/attachmentGroup.component.tsx
|
|
6
|
+
var r = (r) => {
|
|
7
|
+
let { content: i, className: a, style: o, cardName: s } = r;
|
|
8
|
+
return /* @__PURE__ */ n(e, {
|
|
9
|
+
className: a,
|
|
10
|
+
style: o,
|
|
11
|
+
"data-pihanga": s,
|
|
12
|
+
children: i.map((e, r) => /* @__PURE__ */ n(t, {
|
|
13
|
+
cardName: e,
|
|
14
|
+
parentCard: s
|
|
15
|
+
}, r))
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { r as AttachmentGroupComponent };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=attachmentGroup.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachmentGroup.component.js","names":[],"sources":["../../../src/cards/attachment/attachmentGroup.component.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {Card, type PiCardProps} from \"@pihanga2/core\";\nimport {AttachmentGroup} from \"@/components/ui/attachment\";\nimport type {AttachmentGroupProps} from \"./attachment.types\";\n\nexport const AttachmentGroupComponent = (\n props: PiCardProps<AttachmentGroupProps>,\n): React.ReactNode => {\n const {content, className, style, cardName} = props;\n\n return (\n <AttachmentGroup\n className={className}\n style={style}\n data-pihanga={cardName}\n >\n {content.map((cn, i) => (\n <Card cardName={cn} parentCard={cardName} key={i} />\n ))}\n </AttachmentGroup>\n );\n};\n"],"mappings":";;;;;AAKA,IAAa,KACX,MACoB;CACpB,IAAM,EAAC,YAAS,cAAW,UAAO,gBAAY;CAE9C,OACE,kBAAC,GAAD;EACa;EACJ;EACP,gBAAc;YAEb,EAAQ,KAAK,GAAI,MAChB,kBAAC,GAAD;GAAM,UAAU;GAAI,YAAY;EAAmB,GAAJ,CAAI,CACpD;CACc,CAAA;AAErB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './attachment.types';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AttachmentComponent as e } from "./attachment.component.js";
|
|
2
|
+
import { AttachmentGroupComponent as t } from "./attachmentGroup.component.js";
|
|
3
|
+
import { ATTACHMENT_ACTION as n, ATTACHMENT_CARD as r, ATTACHMENT_GROUP_CARD as i, Attachment as a, AttachmentGroup as o, onAttachmentActionClicked as s, onAttachmentTriggered as c } from "./attachment.types.js";
|
|
4
|
+
import { actionTypesToEvents as l, registerCardComponent as u } from "@pihanga2/core";
|
|
5
|
+
u({
|
|
6
|
+
name: r,
|
|
7
|
+
component: e,
|
|
8
|
+
events: l(n)
|
|
9
|
+
}), u({
|
|
10
|
+
name: i,
|
|
11
|
+
component: t
|
|
12
|
+
});
|
|
13
|
+
//#endregion
|
|
14
|
+
export { n as ATTACHMENT_ACTION, r as ATTACHMENT_CARD, i as ATTACHMENT_GROUP_CARD, a as Attachment, o as AttachmentGroup, s as onAttachmentActionClicked, c as onAttachmentTriggered };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cards/attachment/index.ts"],"sourcesContent":["import {actionTypesToEvents, registerCardComponent} from \"@pihanga2/core\";\n\nimport {AttachmentComponent} from \"./attachment.component\";\nimport {AttachmentGroupComponent} from \"./attachmentGroup.component\";\nimport {\n ATTACHMENT_ACTION,\n ATTACHMENT_CARD,\n ATTACHMENT_GROUP_CARD,\n} from \"./attachment.types\";\n\nexport * from \"./attachment.types\";\n\nregisterCardComponent({\n name: ATTACHMENT_CARD,\n component: AttachmentComponent,\n events: actionTypesToEvents(ATTACHMENT_ACTION),\n});\n\nregisterCardComponent({\n name: ATTACHMENT_GROUP_CARD,\n component: AttachmentGroupComponent,\n});\n"],"mappings":";;;;AAYA,EAAsB;CACpB,MAAM;CACN,WAAW;CACX,QAAQ,EAAoB,CAAiB;AAC/C,CAAC,GAED,EAAsB;CACpB,MAAM;CACN,WAAW;AACb,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/utils.js";
|
|
2
|
+
import { Bubble as t, BubbleContent as n, BubbleReactions as r } from "../../components/ui/bubble.js";
|
|
3
|
+
import "react";
|
|
4
|
+
import { Card as i } from "@pihanga2/core";
|
|
5
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
|
+
//#region src/cards/bubble/bubble.component.tsx
|
|
7
|
+
var s = (s) => {
|
|
8
|
+
let { id: c, text: l, contentCard: u, variant: d = "default", align: f = "start", href: p, target: m, clickable: h, reactions: g, reactionsCard: _, reactionsAriaLabel: v, reactionsSide: y = "bottom", reactionsAlign: b = "end", className: x, contentClassName: S, reactionsClassName: C, style: w, cardName: T, onClicked: E } = s, D = u ? /* @__PURE__ */ a(i, {
|
|
9
|
+
cardName: u,
|
|
10
|
+
parentCard: T
|
|
11
|
+
}) : l;
|
|
12
|
+
return /* @__PURE__ */ o(t, {
|
|
13
|
+
variant: d,
|
|
14
|
+
align: f,
|
|
15
|
+
className: x,
|
|
16
|
+
style: w,
|
|
17
|
+
"data-pihanga": T,
|
|
18
|
+
children: [p ? /* @__PURE__ */ a(n, {
|
|
19
|
+
asChild: !0,
|
|
20
|
+
className: S,
|
|
21
|
+
children: /* @__PURE__ */ a("a", {
|
|
22
|
+
href: p,
|
|
23
|
+
target: m,
|
|
24
|
+
children: D
|
|
25
|
+
})
|
|
26
|
+
}) : h ? /* @__PURE__ */ a(n, {
|
|
27
|
+
asChild: !0,
|
|
28
|
+
className: S,
|
|
29
|
+
children: /* @__PURE__ */ a("button", {
|
|
30
|
+
type: "button",
|
|
31
|
+
onClick: () => E({ id: c }),
|
|
32
|
+
children: D
|
|
33
|
+
})
|
|
34
|
+
}) : /* @__PURE__ */ a(n, {
|
|
35
|
+
className: S,
|
|
36
|
+
children: D
|
|
37
|
+
}), _ ? /* @__PURE__ */ a(r, {
|
|
38
|
+
side: y,
|
|
39
|
+
align: b,
|
|
40
|
+
className: C,
|
|
41
|
+
...v ? {
|
|
42
|
+
role: "img",
|
|
43
|
+
"aria-label": v
|
|
44
|
+
} : {},
|
|
45
|
+
children: /* @__PURE__ */ a(i, {
|
|
46
|
+
cardName: _,
|
|
47
|
+
parentCard: T
|
|
48
|
+
})
|
|
49
|
+
}) : g && g.length > 0 && /* @__PURE__ */ a(r, {
|
|
50
|
+
side: y,
|
|
51
|
+
align: b,
|
|
52
|
+
className: C,
|
|
53
|
+
...v ? {
|
|
54
|
+
role: "img",
|
|
55
|
+
"aria-label": v
|
|
56
|
+
} : {},
|
|
57
|
+
children: g.map((t, n) => /* @__PURE__ */ a("span", {
|
|
58
|
+
className: e("inline-flex"),
|
|
59
|
+
children: t
|
|
60
|
+
}, n))
|
|
61
|
+
})]
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
export { s as BubbleComponent };
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=bubble.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bubble.component.js","names":[],"sources":["../../../src/cards/bubble/bubble.component.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {Card, type PiCardProps} from \"@pihanga2/core\";\nimport {Bubble, BubbleContent, BubbleReactions} from \"@/components/ui/bubble\";\nimport {cn} from \"@/lib/utils\";\nimport type {BubbleEvents, BubbleProps} from \"./bubble.types\";\n\nexport const BubbleComponent = (\n props: PiCardProps<BubbleProps, BubbleEvents>,\n): React.ReactNode => {\n const {\n id,\n text,\n contentCard,\n variant = \"default\",\n align = \"start\",\n href,\n target,\n clickable,\n reactions,\n reactionsCard,\n reactionsAriaLabel,\n reactionsSide = \"bottom\",\n reactionsAlign = \"end\",\n className,\n contentClassName,\n reactionsClassName,\n style,\n cardName,\n onClicked,\n } = props;\n\n const innerContent = contentCard ? (\n <Card cardName={contentCard} parentCard={cardName} />\n ) : (\n text\n );\n\n return (\n <Bubble\n variant={variant}\n align={align}\n className={className}\n style={style}\n data-pihanga={cardName}\n >\n {href ? (\n <BubbleContent asChild className={contentClassName}>\n <a href={href} target={target}>\n {innerContent}\n </a>\n </BubbleContent>\n ) : clickable ? (\n <BubbleContent asChild className={contentClassName}>\n <button type=\"button\" onClick={() => onClicked({id})}>\n {innerContent}\n </button>\n </BubbleContent>\n ) : (\n <BubbleContent className={contentClassName}>\n {innerContent}\n </BubbleContent>\n )}\n\n {reactionsCard ? (\n <BubbleReactions\n side={reactionsSide}\n align={reactionsAlign}\n className={reactionsClassName}\n {...(reactionsAriaLabel\n ? {role: \"img\", \"aria-label\": reactionsAriaLabel}\n : {})}\n >\n <Card cardName={reactionsCard} parentCard={cardName} />\n </BubbleReactions>\n ) : (\n reactions &&\n reactions.length > 0 && (\n <BubbleReactions\n side={reactionsSide}\n align={reactionsAlign}\n className={reactionsClassName}\n {...(reactionsAriaLabel\n ? {role: \"img\", \"aria-label\": reactionsAriaLabel}\n : {})}\n >\n {reactions.map((r, i) => (\n <span key={i} className={cn(\"inline-flex\")}>\n {r}\n </span>\n ))}\n </BubbleReactions>\n )\n )}\n </Bubble>\n );\n};\n"],"mappings":";;;;;;AAMA,IAAa,KACX,MACoB;CACpB,IAAM,EACJ,OACA,SACA,gBACA,aAAU,WACV,WAAQ,SACR,SACA,WACA,cACA,cACA,kBACA,uBACA,mBAAgB,UAChB,oBAAiB,OACjB,cACA,qBACA,uBACA,UACA,aACA,iBACE,GAEE,IAAe,IACnB,kBAAC,GAAD;EAAM,UAAU;EAAa,YAAY;CAAW,CAAA,IAEpD;CAGF,OACE,kBAAC,GAAD;EACW;EACF;EACI;EACJ;EACP,gBAAc;YALhB,CAOG,IACC,kBAAC,GAAD;GAAe,SAAA;GAAQ,WAAW;aAChC,kBAAC,KAAD;IAAS;IAAc;cACpB;GACA,CAAA;EACU,CAAA,IACb,IACF,kBAAC,GAAD;GAAe,SAAA;GAAQ,WAAW;aAChC,kBAAC,UAAD;IAAQ,MAAK;IAAS,eAAe,EAAU,EAAC,MAAE,CAAC;cAChD;GACK,CAAA;EACK,CAAA,IAEf,kBAAC,GAAD;GAAe,WAAW;aACvB;EACY,CAAA,GAGhB,IACC,kBAAC,GAAD;GACE,MAAM;GACN,OAAO;GACP,WAAW;GACX,GAAK,IACD;IAAC,MAAM;IAAO,cAAc;GAAkB,IAC9C,CAAC;aAEL,kBAAC,GAAD;IAAM,UAAU;IAAe,YAAY;GAAW,CAAA;EACvC,CAAA,IAEjB,KACA,EAAU,SAAS,KACjB,kBAAC,GAAD;GACE,MAAM;GACN,OAAO;GACP,WAAW;GACX,GAAK,IACD;IAAC,MAAM;IAAO,cAAc;GAAkB,IAC9C,CAAC;aAEJ,EAAU,KAAK,GAAG,MACjB,kBAAC,QAAD;IAAc,WAAW,EAAG,aAAa;cACtC;GACG,GAFK,CAEL,CACP;EACc,CAAA,CAGf;;AAEZ"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { PiCardRef } from '@pihanga2/core';
|
|
2
|
+
import { default as React } from 'react';
|
|
3
|
+
export declare const BUBBLE_CARD = "shad/bubble";
|
|
4
|
+
export declare const Bubble: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<BubbleProps, S, BubbleEvents>) => import('@pihanga2/core').PiCardDef;
|
|
5
|
+
export declare const BUBBLE_ACTION: {
|
|
6
|
+
CLICKED: string;
|
|
7
|
+
};
|
|
8
|
+
export type BubbleClickedEvent = {
|
|
9
|
+
id?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const onBubbleClicked: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core/types').PiRegisterMinimal, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
12
|
+
cardID: string;
|
|
13
|
+
} & BubbleClickedEvent>) => void;
|
|
14
|
+
export type BubbleEvents = {
|
|
15
|
+
onClicked: BubbleClickedEvent;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Bubble visual treatment — mirrors the shadcn `Bubble` `variant` prop.
|
|
19
|
+
*
|
|
20
|
+
* | Value | Appearance |
|
|
21
|
+
* |-----------------|------------------------------------------------------|
|
|
22
|
+
* | `"default"` | Strong primary-coloured bubble. |
|
|
23
|
+
* | `"secondary"` | Secondary colour, filled. |
|
|
24
|
+
* | `"muted"` | Lower-emphasis muted background. |
|
|
25
|
+
* | `"tinted"` | Soft tint derived from the primary colour. |
|
|
26
|
+
* | `"outline"` | Bordered, transparent background. |
|
|
27
|
+
* | `"ghost"` | Unframed — for assistant text, markdown, code, etc. |
|
|
28
|
+
* | `"destructive"` | Red / error colour. |
|
|
29
|
+
*/
|
|
30
|
+
export type BubbleVariant = "default" | "secondary" | "muted" | "tinted" | "outline" | "ghost" | "destructive";
|
|
31
|
+
export type BubbleProps = {
|
|
32
|
+
id?: string;
|
|
33
|
+
/** Plain text rendered inside `BubbleContent`. Ignored if `contentCard` is set. */
|
|
34
|
+
text?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Pihanga card reference rendered inside `BubbleContent` instead of `text`.
|
|
37
|
+
*
|
|
38
|
+
* Use this for "large" pieces of content — a `markdown-viewer` card, a
|
|
39
|
+
* `shad/data-table`, an image, or any other rich card. Combine with
|
|
40
|
+
* `variant: "ghost"` so the content is not framed and can use the full
|
|
41
|
+
* available width.
|
|
42
|
+
*/
|
|
43
|
+
contentCard?: PiCardRef;
|
|
44
|
+
/**
|
|
45
|
+
* Visual style variant.
|
|
46
|
+
* @default "default"
|
|
47
|
+
*/
|
|
48
|
+
variant?: BubbleVariant;
|
|
49
|
+
/**
|
|
50
|
+
* Inline alignment of the bubble within its row.
|
|
51
|
+
* @default "start"
|
|
52
|
+
*/
|
|
53
|
+
align?: "start" | "end";
|
|
54
|
+
/**
|
|
55
|
+
* When set, `BubbleContent` renders as an anchor pointing at this URL
|
|
56
|
+
* instead of a plain `<div>`.
|
|
57
|
+
*/
|
|
58
|
+
href?: string;
|
|
59
|
+
target?: string;
|
|
60
|
+
/**
|
|
61
|
+
* When true (and `href` is not set), `BubbleContent` renders as a
|
|
62
|
+
* `<button>` and clicking it fires `onClicked`.
|
|
63
|
+
*/
|
|
64
|
+
clickable?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Reactions row — a short list of emoji / short strings rendered
|
|
67
|
+
* overlapping the bottom (or top) edge of the bubble.
|
|
68
|
+
* For interactive reactions, use `reactionsCard` instead.
|
|
69
|
+
*/
|
|
70
|
+
reactions?: string[];
|
|
71
|
+
/**
|
|
72
|
+
* Pihanga card reference rendered inside `BubbleReactions` instead of
|
|
73
|
+
* `reactions` — use for interactive reaction buttons.
|
|
74
|
+
*/
|
|
75
|
+
reactionsCard?: PiCardRef;
|
|
76
|
+
/** Accessible label for the reactions row (e.g. "Reactions: thumbs up, fire, and 2 more"). */
|
|
77
|
+
reactionsAriaLabel?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Side of the bubble the reactions row anchors to.
|
|
80
|
+
* @default "bottom"
|
|
81
|
+
*/
|
|
82
|
+
reactionsSide?: "top" | "bottom";
|
|
83
|
+
/**
|
|
84
|
+
* Inline alignment of the reactions row.
|
|
85
|
+
* @default "end"
|
|
86
|
+
*/
|
|
87
|
+
reactionsAlign?: "start" | "end";
|
|
88
|
+
/** Additional Tailwind classes applied to the root `Bubble` element. */
|
|
89
|
+
className?: string;
|
|
90
|
+
/** Additional Tailwind classes applied to `BubbleContent`. */
|
|
91
|
+
contentClassName?: string;
|
|
92
|
+
/** Additional Tailwind classes applied to `BubbleReactions`. */
|
|
93
|
+
reactionsClassName?: string;
|
|
94
|
+
/** Inline styles applied to the root `Bubble` element. */
|
|
95
|
+
style?: React.CSSProperties;
|
|
96
|
+
};
|
|
97
|
+
export declare const BUBBLE_GROUP_CARD = "shad/bubble-group";
|
|
98
|
+
export declare const BubbleGroup: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<BubbleGroupProps, S, {}>) => import('@pihanga2/core').PiCardDef;
|
|
99
|
+
export type BubbleGroupProps = {
|
|
100
|
+
/** Ordered list of `shad/bubble` card refs to stack. */
|
|
101
|
+
content: PiCardRef[];
|
|
102
|
+
/** Additional Tailwind classes applied to the root element. */
|
|
103
|
+
className?: string;
|
|
104
|
+
/** Inline styles applied to the root element. */
|
|
105
|
+
style?: React.CSSProperties;
|
|
106
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createCardDeclaration as e, createOnAction as t, registerActions as n } from "@pihanga2/core";
|
|
2
|
+
//#region src/cards/bubble/bubble.types.ts
|
|
3
|
+
var r = "shad/bubble", i = e(r), a = n(r, ["clicked"]), o = t(a.CLICKED), s = "shad/bubble-group", c = e(s);
|
|
4
|
+
//#endregion
|
|
5
|
+
export { a as BUBBLE_ACTION, r as BUBBLE_CARD, s as BUBBLE_GROUP_CARD, i as Bubble, c as BubbleGroup, o as onBubbleClicked };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=bubble.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bubble.types.js","names":[],"sources":["../../../src/cards/bubble/bubble.types.ts"],"sourcesContent":["import {\n createCardDeclaration,\n createOnAction,\n registerActions,\n type PiCardRef,\n} from \"@pihanga2/core\";\nimport type React from \"react\";\n\nexport const BUBBLE_CARD = \"shad/bubble\";\n\nexport const Bubble = createCardDeclaration<BubbleProps, BubbleEvents>(\n BUBBLE_CARD,\n);\n\nexport const BUBBLE_ACTION = registerActions(BUBBLE_CARD, [\"clicked\"]);\n\nexport type BubbleClickedEvent = {id?: string};\n\nexport const onBubbleClicked = createOnAction<BubbleClickedEvent>(\n BUBBLE_ACTION.CLICKED,\n);\n\nexport type BubbleEvents = {\n onClicked: BubbleClickedEvent;\n};\n\n/**\n * Bubble visual treatment — mirrors the shadcn `Bubble` `variant` prop.\n *\n * | Value | Appearance |\n * |-----------------|------------------------------------------------------|\n * | `\"default\"` | Strong primary-coloured bubble. |\n * | `\"secondary\"` | Secondary colour, filled. |\n * | `\"muted\"` | Lower-emphasis muted background. |\n * | `\"tinted\"` | Soft tint derived from the primary colour. |\n * | `\"outline\"` | Bordered, transparent background. |\n * | `\"ghost\"` | Unframed — for assistant text, markdown, code, etc. |\n * | `\"destructive\"` | Red / error colour. |\n */\nexport type BubbleVariant =\n | \"default\"\n | \"secondary\"\n | \"muted\"\n | \"tinted\"\n | \"outline\"\n | \"ghost\"\n | \"destructive\";\n\nexport type BubbleProps = {\n id?: string; // optional id echoed in click events\n\n /** Plain text rendered inside `BubbleContent`. Ignored if `contentCard` is set. */\n text?: string;\n\n /**\n * Pihanga card reference rendered inside `BubbleContent` instead of `text`.\n *\n * Use this for \"large\" pieces of content — a `markdown-viewer` card, a\n * `shad/data-table`, an image, or any other rich card. Combine with\n * `variant: \"ghost\"` so the content is not framed and can use the full\n * available width.\n */\n contentCard?: PiCardRef;\n\n /**\n * Visual style variant.\n * @default \"default\"\n */\n variant?: BubbleVariant;\n\n /**\n * Inline alignment of the bubble within its row.\n * @default \"start\"\n */\n align?: \"start\" | \"end\";\n\n /**\n * When set, `BubbleContent` renders as an anchor pointing at this URL\n * instead of a plain `<div>`.\n */\n href?: string;\n target?: string;\n\n /**\n * When true (and `href` is not set), `BubbleContent` renders as a\n * `<button>` and clicking it fires `onClicked`.\n */\n clickable?: boolean;\n\n /**\n * Reactions row — a short list of emoji / short strings rendered\n * overlapping the bottom (or top) edge of the bubble.\n * For interactive reactions, use `reactionsCard` instead.\n */\n reactions?: string[];\n\n /**\n * Pihanga card reference rendered inside `BubbleReactions` instead of\n * `reactions` — use for interactive reaction buttons.\n */\n reactionsCard?: PiCardRef;\n\n /** Accessible label for the reactions row (e.g. \"Reactions: thumbs up, fire, and 2 more\"). */\n reactionsAriaLabel?: string;\n\n /**\n * Side of the bubble the reactions row anchors to.\n * @default \"bottom\"\n */\n reactionsSide?: \"top\" | \"bottom\";\n\n /**\n * Inline alignment of the reactions row.\n * @default \"end\"\n */\n reactionsAlign?: \"start\" | \"end\";\n\n /** Additional Tailwind classes applied to the root `Bubble` element. */\n className?: string;\n /** Additional Tailwind classes applied to `BubbleContent`. */\n contentClassName?: string;\n /** Additional Tailwind classes applied to `BubbleReactions`. */\n reactionsClassName?: string;\n\n /** Inline styles applied to the root `Bubble` element. */\n style?: React.CSSProperties;\n};\n\n// ---------------------------------------------------------------------------\n// shad/bubble-group — group consecutive bubbles from the same sender.\n// ---------------------------------------------------------------------------\n\nexport const BUBBLE_GROUP_CARD = \"shad/bubble-group\";\n\nexport const BubbleGroup =\n createCardDeclaration<BubbleGroupProps>(BUBBLE_GROUP_CARD);\n\nexport type BubbleGroupProps = {\n /** Ordered list of `shad/bubble` card refs to stack. */\n content: PiCardRef[];\n /** Additional Tailwind classes applied to the root element. */\n className?: string;\n /** Inline styles applied to the root element. */\n style?: React.CSSProperties;\n};\n"],"mappings":";;AAQA,IAAa,IAAc,eAEd,IAAS,EACpB,CACF,GAEa,IAAgB,EAAgB,GAAa,CAAC,SAAS,CAAC,GAIxD,IAAkB,EAC7B,EAAc,OAChB,GAgHa,IAAoB,qBAEpB,IACX,EAAwC,CAAiB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BubbleGroup as e } from "../../components/ui/bubble.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { Card as t } from "@pihanga2/core";
|
|
4
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
5
|
+
//#region src/cards/bubble/bubbleGroup.component.tsx
|
|
6
|
+
var r = (r) => {
|
|
7
|
+
let { content: i, className: a, style: o, cardName: s } = r;
|
|
8
|
+
return /* @__PURE__ */ n(e, {
|
|
9
|
+
className: a,
|
|
10
|
+
style: o,
|
|
11
|
+
"data-pihanga": s,
|
|
12
|
+
children: i.map((e, r) => /* @__PURE__ */ n(t, {
|
|
13
|
+
cardName: e,
|
|
14
|
+
parentCard: s
|
|
15
|
+
}, r))
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { r as BubbleGroupComponent };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=bubbleGroup.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bubbleGroup.component.js","names":[],"sources":["../../../src/cards/bubble/bubbleGroup.component.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {Card, type PiCardProps} from \"@pihanga2/core\";\nimport {BubbleGroup} from \"@/components/ui/bubble\";\nimport type {BubbleGroupProps} from \"./bubble.types\";\n\nexport const BubbleGroupComponent = (\n props: PiCardProps<BubbleGroupProps>,\n): React.ReactNode => {\n const {content, className, style, cardName} = props;\n\n return (\n <BubbleGroup className={className} style={style} data-pihanga={cardName}>\n {content.map((cn, i) => (\n <Card cardName={cn} parentCard={cardName} key={i} />\n ))}\n </BubbleGroup>\n );\n};\n"],"mappings":";;;;;AAKA,IAAa,KACX,MACoB;CACpB,IAAM,EAAC,YAAS,cAAW,UAAO,gBAAY;CAE9C,OACE,kBAAC,GAAD;EAAwB;EAAkB;EAAO,gBAAc;YAC5D,EAAQ,KAAK,GAAI,MAChB,kBAAC,GAAD;GAAM,UAAU;GAAI,YAAY;EAAmB,GAAJ,CAAI,CACpD;CACU,CAAA;AAEjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './bubble.types';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BubbleComponent as e } from "./bubble.component.js";
|
|
2
|
+
import { BubbleGroupComponent as t } from "./bubbleGroup.component.js";
|
|
3
|
+
import { BUBBLE_ACTION as n, BUBBLE_CARD as r, BUBBLE_GROUP_CARD as i, Bubble as a, BubbleGroup as o, onBubbleClicked as s } from "./bubble.types.js";
|
|
4
|
+
import { actionTypesToEvents as c, registerCardComponent as l } from "@pihanga2/core";
|
|
5
|
+
l({
|
|
6
|
+
name: r,
|
|
7
|
+
component: e,
|
|
8
|
+
events: c(n)
|
|
9
|
+
}), l({
|
|
10
|
+
name: i,
|
|
11
|
+
component: t
|
|
12
|
+
});
|
|
13
|
+
//#endregion
|
|
14
|
+
export { n as BUBBLE_ACTION, r as BUBBLE_CARD, i as BUBBLE_GROUP_CARD, a as Bubble, o as BubbleGroup, s as onBubbleClicked };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cards/bubble/index.ts"],"sourcesContent":["import {actionTypesToEvents, registerCardComponent} from \"@pihanga2/core\";\n\nimport {BubbleComponent} from \"./bubble.component\";\nimport {BubbleGroupComponent} from \"./bubbleGroup.component\";\nimport {BUBBLE_ACTION, BUBBLE_CARD, BUBBLE_GROUP_CARD} from \"./bubble.types\";\n\nexport * from \"./bubble.types\";\n\nregisterCardComponent({\n name: BUBBLE_CARD,\n component: BubbleComponent,\n events: actionTypesToEvents(BUBBLE_ACTION),\n});\n\nregisterCardComponent({\n name: BUBBLE_GROUP_CARD,\n component: BubbleGroupComponent,\n});\n"],"mappings":";;;;AAQA,EAAsB;CACpB,MAAM;CACN,WAAW;CACX,QAAQ,EAAoB,CAAa;AAC3C,CAAC,GAED,EAAsB;CACpB,MAAM;CACN,WAAW;AACb,CAAC"}
|