@stealthscale/component-messaging 0.2.1 → 0.2.2

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.
@@ -0,0 +1,3 @@
1
+ export const dropped = {"ActionsProps": {"conditions": 284, "foreign": 1041}, "AvatarProps": {"conditions": 284, "foreign": 1041}, "BubbleProps": {"conditions": 284, "foreign": 1041}, "ContentProps": {"conditions": 284, "foreign": 1041}, "FooterProps": {"conditions": 284, "foreign": 1041}, "HeaderProps": {"conditions": 284, "foreign": 1041}, "RootProps": {"conditions": 284, "foreign": 1041}, "StatusProps": {"conditions": 284, "foreign": 1041}, "AttachTriggerProps": {"conditions": 284, "foreign": 1051}, "AttachmentsProps": {"conditions": 284, "foreign": 1041}, "ContextProps": {"conditions": 284, "foreign": 1041}, "InputProps": {"conditions": 284, "foreign": 1052}, "SubmitProps": {"conditions": 284, "foreign": 1051}, "ToolbarProps": {"conditions": 284, "foreign": 1041}, "ChoiceProps": {"conditions": 284, "foreign": 1050}, "ItemProps": {"conditions": 284, "foreign": 1051}, "PickerProps": {"conditions": 284, "foreign": 1059}};
2
+ export const parts = {"ActionsProps": [], "AvatarProps": [], "BubbleProps": [{"accepts": "boolean", "fallback": "", "kind": "option", "name": "failed", "refers": [], "required": false, "says": "Whether the message did not send."}], "ContentProps": [], "FooterProps": [], "HeaderProps": [], "RootProps": [{"accepts": "\"end\" | \"start\"", "fallback": "", "kind": "variant", "name": "align", "refers": [], "required": false, "says": "Which end of the line the turn belongs to: the row runs the other way at the end, and the column aligns its bubbles to that end."}, {"accepts": "Flat", "fallback": "", "kind": "variant", "name": "look", "refers": ["kit.Flat"], "required": false, "says": ""}, {"accepts": "\"accent\" | \"error\" | \"info\" | \"neutral\" | \"primary\" | \"secondary\" | \"success\" | \"warning\"", "fallback": "", "kind": "variant", "name": "palette", "refers": [], "required": false, "says": ""}, {"accepts": "\"always\" | \"hover\"", "fallback": "", "kind": "variant", "name": "reveal", "refers": [], "required": false, "says": "When the actions of the turn are visible."}, {"accepts": "\"lg\" | \"md\" | \"sm\"", "fallback": "", "kind": "variant", "name": "size", "refers": [], "required": false, "says": ""}], "StatusProps": [{"accepts": "MessageStatus", "fallback": "", "kind": "option", "name": "status", "refers": ["kit.MessageStatus"], "required": true, "says": "How far the message has got."}], "AttachTriggerProps": [{"accepts": "string", "fallback": "", "kind": "option", "name": "accept", "refers": [], "required": false, "says": "File types the picker offers, as an `input`'s `accept` attribute takes them."}, {"accepts": "\"glow\" | \"pulse\"", "fallback": "", "kind": "variant", "name": "effect", "refers": [], "required": false, "says": "The halo around the button, in the palette's solid at half opacity."}, {"accepts": "Lift", "fallback": "", "kind": "variant", "name": "elevation", "refers": ["kit.Lift"], "required": false, "says": ""}, {"accepts": "string", "fallback": "", "kind": "option", "name": "label", "refers": [], "required": false, "says": "Accessible name of the control, \"Attach files\" unless stated."}, {"accepts": "\"accent\" | \"error\" | \"info\" | \"neutral\" | \"primary\" | \"secondary\" | \"success\" | \"warning\"", "fallback": "", "kind": "variant", "name": "palette", "refers": [], "required": false, "says": "Palette of every look. The base sets `primary`."}, {"accepts": "\"square\"", "fallback": "", "kind": "variant", "name": "shape", "refers": [], "required": false, "says": ""}, {"accepts": "Scale", "fallback": "", "kind": "variant", "name": "size", "refers": ["kit.Scale"], "required": false, "says": ""}, {"accepts": "\"ghost\" | \"glass\" | \"outline\" | \"plain\" | \"solid\" | \"subtle\" | \"surface\"", "fallback": "", "kind": "variant", "name": "variant", "refers": [], "required": false, "says": ""}], "AttachmentsProps": [], "ContextProps": [], "InputProps": [{"accepts": "string", "fallback": "", "kind": "option", "name": "label", "refers": [], "required": false, "says": "Accessible name of the textarea, \"Message\" unless stated."}, {"accepts": "number", "fallback": "", "kind": "option", "name": "maxRows", "refers": [], "required": false, "says": "Most lines the textarea grows to before it scrolls, 8 unless stated."}, {"accepts": "((suggestion: Suggestion, query: Query) => void)", "fallback": "", "kind": "option", "name": "onMention", "refers": ["kit.Query", "kit.Suggestion"], "required": false, "says": "Called with the suggestion inserted and the query it replaced."}, {"accepts": "((query: Query) => void)", "fallback": "", "kind": "option", "name": "onQueryChange", "refers": ["kit.Query"], "required": false, "says": "Called with the query at the caret whenever it changes, undefined outside every mention."}, {"accepts": "readonly Suggestion[]", "fallback": "", "kind": "option", "name": "suggestions", "refers": ["kit.Suggestion"], "required": false, "says": "The suggestions for the query, which the caller finds from the term."}, {"accepts": "string", "fallback": "", "kind": "option", "name": "suggestionsLabel", "refers": [], "required": false, "says": "Accessible name of the list of suggestions, \"Suggestions\" unless stated."}, {"accepts": "readonly string[]", "fallback": "", "kind": "option", "name": "triggers", "refers": [], "required": false, "says": "The characters that open a mention, such as `@` and `#`."}], "SubmitProps": [{"accepts": "\"glow\" | \"pulse\"", "fallback": "", "kind": "variant", "name": "effect", "refers": [], "required": false, "says": "The halo around the button, in the palette's solid at half opacity."}, {"accepts": "Lift", "fallback": "", "kind": "variant", "name": "elevation", "refers": ["kit.Lift"], "required": false, "says": ""}, {"accepts": "string", "fallback": "", "kind": "option", "name": "label", "refers": [], "required": false, "says": "Accessible name while the control sends, \"Send\" unless stated."}, {"accepts": "\"accent\" | \"error\" | \"info\" | \"neutral\" | \"primary\" | \"secondary\" | \"success\" | \"warning\"", "fallback": "", "kind": "variant", "name": "palette", "refers": [], "required": false, "says": "Palette of every look. The base sets `primary`."}, {"accepts": "\"square\"", "fallback": "", "kind": "variant", "name": "shape", "refers": [], "required": false, "says": ""}, {"accepts": "Scale", "fallback": "", "kind": "variant", "name": "size", "refers": ["kit.Scale"], "required": false, "says": ""}, {"accepts": "ReactNode", "fallback": "", "kind": "option", "name": "stopIcon", "refers": ["react.ReactElement", "react.ReactPortal"], "required": false, "says": "Glyph while the control stops a response."}, {"accepts": "string", "fallback": "", "kind": "option", "name": "stopLabel", "refers": [], "required": false, "says": "Accessible name while the control stops a response, \"Stop\" unless stated."}, {"accepts": "\"ghost\" | \"glass\" | \"outline\" | \"plain\" | \"solid\" | \"subtle\" | \"surface\"", "fallback": "", "kind": "variant", "name": "variant", "refers": [], "required": false, "says": ""}], "ToolbarProps": [], "ChoiceProps": [{"accepts": "\"glow\" | \"pulse\"", "fallback": "", "kind": "variant", "name": "effect", "refers": [], "required": false, "says": "The halo around the button, in the palette's solid at half opacity."}, {"accepts": "Lift", "fallback": "", "kind": "variant", "name": "elevation", "refers": ["kit.Lift"], "required": false, "says": ""}, {"accepts": "string", "fallback": "", "kind": "option", "name": "label", "refers": [], "required": true, "says": "Accessible name of the reaction, such as \"Thumbs up\"."}, {"accepts": "\"accent\" | \"error\" | \"info\" | \"neutral\" | \"primary\" | \"secondary\" | \"success\" | \"warning\"", "fallback": "", "kind": "variant", "name": "palette", "refers": [], "required": false, "says": "Palette of every look. The base sets `primary`."}, {"accepts": "\"square\"", "fallback": "", "kind": "variant", "name": "shape", "refers": [], "required": false, "says": ""}, {"accepts": "Scale", "fallback": "", "kind": "variant", "name": "size", "refers": ["kit.Scale"], "required": false, "says": ""}, {"accepts": "string", "fallback": "", "kind": "option", "name": "value", "refers": [], "required": true, "says": "Value the picker's `onSelect` receives."}, {"accepts": "\"ghost\" | \"glass\" | \"outline\" | \"plain\" | \"solid\" | \"subtle\" | \"surface\"", "fallback": "", "kind": "variant", "name": "variant", "refers": [], "required": false, "says": ""}], "ItemProps": [{"accepts": "number", "fallback": "", "kind": "option", "name": "count", "refers": [], "required": false, "says": "Number of people who reacted, rendered after the glyph when stated."}, {"accepts": "\"glow\" | \"pulse\"", "fallback": "", "kind": "variant", "name": "effect", "refers": [], "required": false, "says": "The halo around the button, in the palette's solid at half opacity."}, {"accepts": "Lift", "fallback": "", "kind": "variant", "name": "elevation", "refers": ["kit.Lift"], "required": false, "says": ""}, {"accepts": "string", "fallback": "", "kind": "option", "name": "label", "refers": [], "required": true, "says": "Accessible name: the reaction, the count and whether the reader is among them."}, {"accepts": "\"accent\" | \"error\" | \"info\" | \"neutral\" | \"primary\" | \"secondary\" | \"success\" | \"warning\"", "fallback": "", "kind": "variant", "name": "palette", "refers": [], "required": false, "says": "Palette of every look. The base sets `primary`."}, {"accepts": "boolean", "fallback": "", "kind": "option", "name": "pressed", "refers": [], "required": false, "says": "Whether the reader is among the people who reacted."}, {"accepts": "\"square\"", "fallback": "", "kind": "variant", "name": "shape", "refers": [], "required": false, "says": ""}, {"accepts": "Scale", "fallback": "", "kind": "variant", "name": "size", "refers": ["kit.Scale"], "required": false, "says": ""}, {"accepts": "\"ghost\" | \"glass\" | \"outline\" | \"plain\" | \"solid\" | \"subtle\" | \"surface\"", "fallback": "", "kind": "variant", "name": "variant", "refers": [], "required": false, "says": ""}], "PickerProps": [{"accepts": "ReactNode", "fallback": "", "kind": "option", "name": "children", "refers": ["react.ReactElement", "react.ReactPortal"], "required": false, "says": "The choices, each a `Reactions.Choice`."}, {"accepts": "string", "fallback": "", "kind": "option", "name": "choicesLabel", "refers": [], "required": false, "says": "Accessible name of the panel, \"Choose a reaction\" unless stated."}, {"accepts": "\"ltr\" | \"rtl\"", "fallback": "\"ltr\"", "kind": "option", "name": "dir", "refers": [], "required": false, "says": "The document's text/writing direction."}, {"accepts": "(() => Document | Node | ShadowRoot)", "fallback": "", "kind": "option", "name": "getRootNode", "refers": [], "required": false, "says": "A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron."}, {"accepts": "ReactNode", "fallback": "", "kind": "option", "name": "icon", "refers": ["react.ReactElement", "react.ReactPortal"], "required": true, "says": "Glyph of the trigger."}, {"accepts": "string", "fallback": "", "kind": "option", "name": "id", "refers": [], "required": false, "says": "The unique identifier of the machine."}, {"accepts": "string", "fallback": "", "kind": "option", "name": "label", "refers": [], "required": false, "says": "Accessible name of the trigger, \"Add a reaction\" unless stated."}, {"accepts": "((value: string) => void)", "fallback": "", "kind": "option", "name": "onSelect", "refers": [], "required": false, "says": "Called with the value of the choice pressed."}, {"accepts": "\"lg\" | \"md\" | \"sm\" | \"xl\" | \"xs\"", "fallback": "", "kind": "variant", "name": "size", "refers": [], "required": false, "says": "Padding of the panel, text of the title and the description, and size of the close trigger."}, {"accepts": "\"elevated\" | \"glass\" | \"surface\"", "fallback": "", "kind": "variant", "name": "variant", "refers": [], "required": false, "says": "Surface of the panel: the popover surface inside a hairline edge, the panel surface with a large shadow, or the glass layer style."}]};
3
+ export const shapes = {"kit.Flat": [{"accepts": "", "name": "\"outline\"", "says": ""}, {"accepts": "", "name": "\"plain\"", "says": ""}, {"accepts": "", "name": "\"solid\"", "says": ""}, {"accepts": "", "name": "\"subtle\"", "says": ""}, {"accepts": "", "name": "\"surface\"", "says": ""}], "kit.MessageStatus": [{"accepts": "", "name": "\"delivered\"", "says": ""}, {"accepts": "", "name": "\"failed\"", "says": ""}, {"accepts": "", "name": "\"read\"", "says": ""}, {"accepts": "", "name": "\"sending\"", "says": ""}, {"accepts": "", "name": "\"sent\"", "says": ""}], "kit.Lift": [{"accepts": "", "name": "\"floating\"", "says": ""}, {"accepts": "", "name": "\"raised\"", "says": ""}], "kit.Scale": [{"accepts": "", "name": "\"2xl\"", "says": ""}, {"accepts": "", "name": "\"3xl\"", "says": ""}, {"accepts": "", "name": "\"4xl\"", "says": ""}, {"accepts": "", "name": "\"lg\"", "says": ""}, {"accepts": "", "name": "\"md\"", "says": ""}, {"accepts": "", "name": "\"sm\"", "says": ""}, {"accepts": "", "name": "\"xl\"", "says": ""}, {"accepts": "", "name": "\"xs\"", "says": ""}], "kit.Suggestion": [{"accepts": "string", "name": "description", "says": "Line under the name, such as a team or an email address."}, {"accepts": "string", "name": "id", "says": "Identifier of the suggestion, unique among the suggestions."}, {"accepts": "string", "name": "label", "says": "The name listed and inserted after the trigger."}], "kit.Query": [{"accepts": "number", "name": "from", "says": "Index of the trigger character in the text."}, {"accepts": "string", "name": "term", "says": "The text typed after the trigger, up to the caret, without whitespace."}, {"accepts": "string", "name": "trigger", "says": "The trigger character, such as `@`."}], "react.ReactElement": [{"accepts": "string | JSXElementConstructor<any>", "name": "type", "says": ""}, {"accepts": "unknown", "name": "props", "says": ""}, {"accepts": "string | null", "name": "key", "says": ""}], "react.ReactPortal": [{"accepts": "ReactNode", "name": "children", "says": ""}, {"accepts": "string | JSXElementConstructor<any>", "name": "type", "says": ""}, {"accepts": "unknown", "name": "props", "says": ""}, {"accepts": "string | null", "name": "key", "says": ""}]};
@@ -0,0 +1,66 @@
1
+ {
2
+ "format": 1,
3
+ "pages": [
4
+ {
5
+ "about": "attachment.about",
6
+ "group": "",
7
+ "id": "components/messaging/attachment",
8
+ "module": "attachment/attachment.js",
9
+ "namespace": "",
10
+ "props": "attachment/attachment.props.js",
11
+ "specimen": "src/attachment/attachment.specimen.tsx",
12
+ "title": "attachment.title"
13
+ },
14
+ {
15
+ "about": "composer.about",
16
+ "group": "",
17
+ "id": "components/messaging/composer",
18
+ "module": "composer/composer.js",
19
+ "namespace": "",
20
+ "props": "composer/composer.props.js",
21
+ "specimen": "src/composer/composer.specimen.tsx",
22
+ "title": "composer.title"
23
+ },
24
+ {
25
+ "about": "conversation.about",
26
+ "group": "",
27
+ "id": "components/messaging/conversation",
28
+ "module": "conversation/conversation.js",
29
+ "namespace": "",
30
+ "props": "conversation/conversation.props.js",
31
+ "specimen": "src/conversation/conversation.specimen.tsx",
32
+ "title": "conversation.title"
33
+ },
34
+ {
35
+ "about": "message.about",
36
+ "group": "",
37
+ "id": "components/messaging/message",
38
+ "module": "message/message.js",
39
+ "namespace": "",
40
+ "props": "message/message.props.js",
41
+ "specimen": "src/message/message.specimen.tsx",
42
+ "title": "message.title"
43
+ },
44
+ {
45
+ "about": "reactions.about",
46
+ "group": "",
47
+ "id": "components/messaging/reactions",
48
+ "module": "reactions/reactions.js",
49
+ "namespace": "",
50
+ "props": "reactions/reactions.props.js",
51
+ "specimen": "src/reactions/reactions.specimen.tsx",
52
+ "title": "reactions.title"
53
+ }
54
+ ],
55
+ "requires": {
56
+ "@stealthscale/component-collections": "^0.1.0",
57
+ "@stealthscale/component-content": "^0.1.0",
58
+ "@stealthscale/component-data": "^0.2.0",
59
+ "@stealthscale/component-feedback": "^0.2.0",
60
+ "@stealthscale/component-layout": "^0.2.0",
61
+ "@stealthscale/component-media": "^0.2.0",
62
+ "@stealthscale/component-typography": "^0.3.0",
63
+ "@stealthscale/specimen": "^0.3.0",
64
+ "lucide-react": "^1.52.0"
65
+ }
66
+ }
@@ -0,0 +1,246 @@
1
+ import { t as __exportAll } from "../../rolldown-runtime-D7D4PA-g.js";
2
+ import { a as Item, f as Content, i as Picker, l as Root$1, m as Avatar$1, o as Choice, p as Bubble, r as Root, u as Header } from "../../shared-B0H4dgkB.js";
3
+ import { c } from "react/compiler-runtime";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { useState } from "react";
6
+ import { Room, specimen, useWords } from "@stealthscale/specimen";
7
+ import { SmilePlusIcon } from "lucide-react";
8
+ import { Avatar } from "@stealthscale/component-media";
9
+ import { Strong } from "@stealthscale/component-typography";
10
+ //#region src/reactions/examples/reacting.example.tsx
11
+ var reacting_example_exports = /* @__PURE__ */ __exportAll({
12
+ Reacting: () => Reacting,
13
+ source: () => source
14
+ });
15
+ const KINDS = [
16
+ "thumbs",
17
+ "party",
18
+ "eyes",
19
+ "heart",
20
+ "laugh",
21
+ "rocket"
22
+ ];
23
+ const GLYPHS = {
24
+ eyes: "👀",
25
+ heart: "❤️",
26
+ laugh: "😄",
27
+ party: "🎉",
28
+ rocket: "🚀",
29
+ thumbs: "👍"
30
+ };
31
+ const INITIAL = [{
32
+ count: 3,
33
+ kind: "thumbs",
34
+ mine: true
35
+ }, {
36
+ count: 1,
37
+ kind: "party",
38
+ mine: false
39
+ }];
40
+ function toggled(reactions, kind) {
41
+ const found = reactions.find((one) => one.kind === kind);
42
+ if (found === void 0) return [...reactions, {
43
+ count: 1,
44
+ kind,
45
+ mine: true
46
+ }];
47
+ const count = found.count + (found.mine ? -1 : 1);
48
+ return count === 0 ? reactions.filter((one) => one.kind !== kind) : reactions.map((one) => one.kind === kind ? {
49
+ count,
50
+ kind,
51
+ mine: !found.mine
52
+ } : one);
53
+ }
54
+ function Reacting() {
55
+ const $ = c(43);
56
+ const { t } = useWords("reactions");
57
+ const [reactions, setReactions] = useState(INITIAL);
58
+ let t0;
59
+ if ($[0] !== t) {
60
+ t0 = t("ada");
61
+ $[0] = t;
62
+ $[1] = t0;
63
+ } else t0 = $[1];
64
+ let t1;
65
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
66
+ t1 = /* @__PURE__ */ jsx(Avatar.Fallback, {});
67
+ $[2] = t1;
68
+ } else t1 = $[2];
69
+ let t2;
70
+ if ($[3] !== t0) {
71
+ t2 = /* @__PURE__ */ jsx(Avatar$1, { children: /* @__PURE__ */ jsx(Avatar.Root, {
72
+ "aria-hidden": true,
73
+ name: t0,
74
+ size: "sm",
75
+ children: t1
76
+ }) });
77
+ $[3] = t0;
78
+ $[4] = t2;
79
+ } else t2 = $[4];
80
+ let t3;
81
+ if ($[5] !== t) {
82
+ t3 = t("ada");
83
+ $[5] = t;
84
+ $[6] = t3;
85
+ } else t3 = $[6];
86
+ let t4;
87
+ if ($[7] !== t3) {
88
+ t4 = /* @__PURE__ */ jsx(Header, { children: /* @__PURE__ */ jsx(Strong, { children: t3 }) });
89
+ $[7] = t3;
90
+ $[8] = t4;
91
+ } else t4 = $[8];
92
+ let t5;
93
+ if ($[9] !== t) {
94
+ t5 = t("shipped");
95
+ $[9] = t;
96
+ $[10] = t5;
97
+ } else t5 = $[10];
98
+ let t6;
99
+ if ($[11] !== t5) {
100
+ t6 = /* @__PURE__ */ jsx(Bubble, { children: t5 });
101
+ $[11] = t5;
102
+ $[12] = t6;
103
+ } else t6 = $[12];
104
+ let t7;
105
+ if ($[13] !== t) {
106
+ t7 = t("label");
107
+ $[13] = t;
108
+ $[14] = t7;
109
+ } else t7 = $[14];
110
+ let t8;
111
+ if ($[15] !== reactions || $[16] !== t) {
112
+ let t9;
113
+ if ($[18] !== t) {
114
+ t9 = (reaction) => /* @__PURE__ */ jsx(Item, {
115
+ count: reaction.count,
116
+ label: t(reaction.mine ? "mine" : "theirs", {
117
+ count: reaction.count,
118
+ name: t(reaction.kind)
119
+ }),
120
+ onClick: () => {
121
+ setReactions((was) => toggled(was, reaction.kind));
122
+ },
123
+ pressed: reaction.mine,
124
+ children: GLYPHS[reaction.kind]
125
+ }, reaction.kind);
126
+ $[18] = t;
127
+ $[19] = t9;
128
+ } else t9 = $[19];
129
+ t8 = reactions.map(t9);
130
+ $[15] = reactions;
131
+ $[16] = t;
132
+ $[17] = t8;
133
+ } else t8 = $[17];
134
+ let t9;
135
+ if ($[20] !== t) {
136
+ t9 = t("choose");
137
+ $[20] = t;
138
+ $[21] = t9;
139
+ } else t9 = $[21];
140
+ let t10;
141
+ if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
142
+ t10 = /* @__PURE__ */ jsx(SmilePlusIcon, { size: "1em" });
143
+ $[22] = t10;
144
+ } else t10 = $[22];
145
+ let t11;
146
+ if ($[23] !== t) {
147
+ t11 = t("add");
148
+ $[23] = t;
149
+ $[24] = t11;
150
+ } else t11 = $[24];
151
+ let t12;
152
+ if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
153
+ t12 = (value) => {
154
+ const kind = KINDS.find((one) => one === value);
155
+ if (kind !== void 0) setReactions((was_0) => toggled(was_0, kind));
156
+ };
157
+ $[25] = t12;
158
+ } else t12 = $[25];
159
+ let t13;
160
+ if ($[26] !== t) {
161
+ t13 = KINDS.map((kind_0) => /* @__PURE__ */ jsx(Choice, {
162
+ label: t(kind_0),
163
+ value: kind_0,
164
+ children: GLYPHS[kind_0]
165
+ }, kind_0));
166
+ $[26] = t;
167
+ $[27] = t13;
168
+ } else t13 = $[27];
169
+ let t14;
170
+ if ($[28] !== t11 || $[29] !== t13 || $[30] !== t9) {
171
+ t14 = /* @__PURE__ */ jsx(Picker, {
172
+ choicesLabel: t9,
173
+ icon: t10,
174
+ label: t11,
175
+ onSelect: t12,
176
+ children: t13
177
+ });
178
+ $[28] = t11;
179
+ $[29] = t13;
180
+ $[30] = t9;
181
+ $[31] = t14;
182
+ } else t14 = $[31];
183
+ let t15;
184
+ if ($[32] !== t14 || $[33] !== t7 || $[34] !== t8) {
185
+ t15 = /* @__PURE__ */ jsxs(Root, {
186
+ label: t7,
187
+ children: [t8, t14]
188
+ });
189
+ $[32] = t14;
190
+ $[33] = t7;
191
+ $[34] = t8;
192
+ $[35] = t15;
193
+ } else t15 = $[35];
194
+ let t16;
195
+ if ($[36] !== t15 || $[37] !== t4 || $[38] !== t6) {
196
+ t16 = /* @__PURE__ */ jsxs(Content, { children: [
197
+ t4,
198
+ t6,
199
+ t15
200
+ ] });
201
+ $[36] = t15;
202
+ $[37] = t4;
203
+ $[38] = t6;
204
+ $[39] = t16;
205
+ } else t16 = $[39];
206
+ let t17;
207
+ if ($[40] !== t16 || $[41] !== t2) {
208
+ t17 = /* @__PURE__ */ jsxs(Root$1, { children: [t2, t16] });
209
+ $[40] = t16;
210
+ $[41] = t2;
211
+ $[42] = t17;
212
+ } else t17 = $[42];
213
+ return t17;
214
+ }
215
+ const source = "import { type ReactElement, useState } from \"react\";\n\nimport { SmilePlusIcon } from \"lucide-react\";\n\nimport { Avatar } from \"@stealthscale/component-media\";\nimport { Strong } from \"@stealthscale/component-typography\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Message, Reactions } from \"@stealthscale/component-messaging\";\n\nconst KINDS = [\"thumbs\", \"party\", \"eyes\", \"heart\", \"laugh\", \"rocket\"] as const;\n\ntype Kind = (typeof KINDS)[number];\n\nconst GLYPHS: Readonly<Record<Kind, string>> = {\n eyes: \"👀\",\n heart: \"❤️\",\n laugh: \"😄\",\n party: \"🎉\",\n rocket: \"🚀\",\n thumbs: \"👍\",\n};\n\ninterface Reaction {\n readonly count: number;\n readonly kind: Kind;\n readonly mine: boolean;\n}\n\nconst INITIAL: readonly Reaction[] = [\n { count: 3, kind: \"thumbs\", mine: true },\n { count: 1, kind: \"party\", mine: false },\n];\n\nfunction toggled(reactions: readonly Reaction[], kind: Kind): readonly Reaction[] {\n const found = reactions.find((one) => one.kind === kind);\n\n if (found === undefined) return [...reactions, { count: 1, kind, mine: true }];\n\n const count = found.count + (found.mine ? -1 : 1);\n\n return count === 0\n ? reactions.filter((one) => one.kind !== kind)\n : reactions.map((one) => (one.kind === kind ? { count, kind, mine: !found.mine } : one));\n}\n\nexport function Reacting(): ReactElement {\n const { t } = useWords(\"reactions\");\n const [reactions, setReactions] = useState(INITIAL);\n\n return (\n <Message.Root>\n <Message.Avatar>\n <Avatar.Root aria-hidden name={t(\"ada\")} size=\"sm\">\n <Avatar.Fallback />\n </Avatar.Root>\n </Message.Avatar>\n <Message.Content>\n <Message.Header>\n <Strong>{t(\"ada\")}</Strong>\n </Message.Header>\n <Message.Bubble>{t(\"shipped\")}</Message.Bubble>\n <Reactions.Root label={t(\"label\")}>\n {reactions.map((reaction) => (\n <Reactions.Item\n count={reaction.count}\n key={reaction.kind}\n label={t(reaction.mine ? \"mine\" : \"theirs\", {\n count: reaction.count,\n name: t(reaction.kind),\n })}\n onClick={() => {\n setReactions((was) => toggled(was, reaction.kind));\n }}\n pressed={reaction.mine}\n >\n {GLYPHS[reaction.kind]}\n </Reactions.Item>\n ))}\n <Reactions.Picker\n choicesLabel={t(\"choose\")}\n icon={<SmilePlusIcon size=\"1em\" />}\n label={t(\"add\")}\n onSelect={(value) => {\n const kind = KINDS.find((one) => one === value);\n\n if (kind !== undefined) setReactions((was) => toggled(was, kind));\n }}\n >\n {KINDS.map((kind) => (\n <Reactions.Choice key={kind} label={t(kind)} value={kind}>\n {GLYPHS[kind]}\n </Reactions.Choice>\n ))}\n </Reactions.Picker>\n </Reactions.Root>\n </Message.Content>\n </Message.Root>\n );\n}\n";
216
+ //#endregion
217
+ //#region src/reactions/reactions.specimen.tsx
218
+ /**
219
+ * Catalogue page for the reactions.
220
+ *
221
+ * @remarks
222
+ * The recipe has no axis, so the one scene is hand-written: a message with reactions under it
223
+ * that a press toggles, and a picker that adds one, in a room at the `sm` measure. The words are
224
+ * keys under `reactions` in `locales/en/specimen/reactions.json`.
225
+ */
226
+ /**
227
+ * Hand-written scene for reactions under a message.
228
+ */
229
+ const reacted = {
230
+ about: "reactions.reacting.about",
231
+ draw: () => /* @__PURE__ */ jsx(Room, {
232
+ size: "sm",
233
+ children: /* @__PURE__ */ jsx(Reacting, {})
234
+ }),
235
+ example: reacting_example_exports,
236
+ title: "reactions.reacting.title"
237
+ };
238
+ var reactions_specimen_default = specimen({
239
+ about: "reactions.about",
240
+ id: "components/messaging/reactions",
241
+ imports: "import { Reactions } from \"@stealthscale/component-messaging\";",
242
+ scenes: [reacted],
243
+ title: "reactions.title"
244
+ });
245
+ //#endregion
246
+ export { reactions_specimen_default as default, reacted };
@@ -0,0 +1,3 @@
1
+ export const dropped = {"ChoiceProps": {"conditions": 284, "foreign": 1050}, "ItemProps": {"conditions": 284, "foreign": 1051}, "PickerProps": {"conditions": 284, "foreign": 1059}, "RootProps": {"conditions": 284, "foreign": 1044}, "ActionsProps": {"conditions": 284, "foreign": 1041}, "AvatarProps": {"conditions": 284, "foreign": 1041}, "BubbleProps": {"conditions": 284, "foreign": 1041}, "ContentProps": {"conditions": 284, "foreign": 1041}, "FooterProps": {"conditions": 284, "foreign": 1041}, "HeaderProps": {"conditions": 284, "foreign": 1041}, "StatusProps": {"conditions": 284, "foreign": 1041}};
2
+ export const parts = {"ChoiceProps": [{"accepts": "\"glow\" | \"pulse\"", "fallback": "", "kind": "variant", "name": "effect", "refers": [], "required": false, "says": "The halo around the button, in the palette's solid at half opacity."}, {"accepts": "Lift", "fallback": "", "kind": "variant", "name": "elevation", "refers": ["kit.Lift"], "required": false, "says": ""}, {"accepts": "string", "fallback": "", "kind": "option", "name": "label", "refers": [], "required": true, "says": "Accessible name of the reaction, such as \"Thumbs up\"."}, {"accepts": "\"accent\" | \"error\" | \"info\" | \"neutral\" | \"primary\" | \"secondary\" | \"success\" | \"warning\"", "fallback": "", "kind": "variant", "name": "palette", "refers": [], "required": false, "says": "Palette of every look. The base sets `primary`."}, {"accepts": "\"square\"", "fallback": "", "kind": "variant", "name": "shape", "refers": [], "required": false, "says": ""}, {"accepts": "Scale", "fallback": "", "kind": "variant", "name": "size", "refers": ["kit.Scale"], "required": false, "says": ""}, {"accepts": "string", "fallback": "", "kind": "option", "name": "value", "refers": [], "required": true, "says": "Value the picker's `onSelect` receives."}, {"accepts": "\"ghost\" | \"glass\" | \"outline\" | \"plain\" | \"solid\" | \"subtle\" | \"surface\"", "fallback": "", "kind": "variant", "name": "variant", "refers": [], "required": false, "says": ""}], "ItemProps": [{"accepts": "number", "fallback": "", "kind": "option", "name": "count", "refers": [], "required": false, "says": "Number of people who reacted, rendered after the glyph when stated."}, {"accepts": "\"glow\" | \"pulse\"", "fallback": "", "kind": "variant", "name": "effect", "refers": [], "required": false, "says": "The halo around the button, in the palette's solid at half opacity."}, {"accepts": "Lift", "fallback": "", "kind": "variant", "name": "elevation", "refers": ["kit.Lift"], "required": false, "says": ""}, {"accepts": "string", "fallback": "", "kind": "option", "name": "label", "refers": [], "required": true, "says": "Accessible name: the reaction, the count and whether the reader is among them."}, {"accepts": "\"accent\" | \"error\" | \"info\" | \"neutral\" | \"primary\" | \"secondary\" | \"success\" | \"warning\"", "fallback": "", "kind": "variant", "name": "palette", "refers": [], "required": false, "says": "Palette of every look. The base sets `primary`."}, {"accepts": "boolean", "fallback": "", "kind": "option", "name": "pressed", "refers": [], "required": false, "says": "Whether the reader is among the people who reacted."}, {"accepts": "\"square\"", "fallback": "", "kind": "variant", "name": "shape", "refers": [], "required": false, "says": ""}, {"accepts": "Scale", "fallback": "", "kind": "variant", "name": "size", "refers": ["kit.Scale"], "required": false, "says": ""}, {"accepts": "\"ghost\" | \"glass\" | \"outline\" | \"plain\" | \"solid\" | \"subtle\" | \"surface\"", "fallback": "", "kind": "variant", "name": "variant", "refers": [], "required": false, "says": ""}], "PickerProps": [{"accepts": "ReactNode", "fallback": "", "kind": "option", "name": "children", "refers": ["react.ReactElement", "react.ReactPortal"], "required": false, "says": "The choices, each a `Reactions.Choice`."}, {"accepts": "string", "fallback": "", "kind": "option", "name": "choicesLabel", "refers": [], "required": false, "says": "Accessible name of the panel, \"Choose a reaction\" unless stated."}, {"accepts": "\"ltr\" | \"rtl\"", "fallback": "\"ltr\"", "kind": "option", "name": "dir", "refers": [], "required": false, "says": "The document's text/writing direction."}, {"accepts": "(() => Document | Node | ShadowRoot)", "fallback": "", "kind": "option", "name": "getRootNode", "refers": [], "required": false, "says": "A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron."}, {"accepts": "ReactNode", "fallback": "", "kind": "option", "name": "icon", "refers": ["react.ReactElement", "react.ReactPortal"], "required": true, "says": "Glyph of the trigger."}, {"accepts": "string", "fallback": "", "kind": "option", "name": "id", "refers": [], "required": false, "says": "The unique identifier of the machine."}, {"accepts": "string", "fallback": "", "kind": "option", "name": "label", "refers": [], "required": false, "says": "Accessible name of the trigger, \"Add a reaction\" unless stated."}, {"accepts": "((value: string) => void)", "fallback": "", "kind": "option", "name": "onSelect", "refers": [], "required": false, "says": "Called with the value of the choice pressed."}, {"accepts": "\"lg\" | \"md\" | \"sm\" | \"xl\" | \"xs\"", "fallback": "", "kind": "variant", "name": "size", "refers": [], "required": false, "says": "Padding of the panel, text of the title and the description, and size of the close trigger."}, {"accepts": "\"elevated\" | \"glass\" | \"surface\"", "fallback": "", "kind": "variant", "name": "variant", "refers": [], "required": false, "says": "Surface of the panel: the popover surface inside a hairline edge, the panel surface with a large shadow, or the glass layer style."}], "RootProps": [{"accepts": "string", "fallback": "", "kind": "option", "name": "label", "refers": [], "required": false, "says": "Accessible name of the row, \"Reactions\" unless stated."}], "ActionsProps": [], "AvatarProps": [], "BubbleProps": [{"accepts": "boolean", "fallback": "", "kind": "option", "name": "failed", "refers": [], "required": false, "says": "Whether the message did not send."}], "ContentProps": [], "FooterProps": [], "HeaderProps": [], "StatusProps": [{"accepts": "MessageStatus", "fallback": "", "kind": "option", "name": "status", "refers": ["kit.MessageStatus"], "required": true, "says": "How far the message has got."}]};
3
+ export const shapes = {"kit.Lift": [{"accepts": "", "name": "\"floating\"", "says": ""}, {"accepts": "", "name": "\"raised\"", "says": ""}], "kit.Scale": [{"accepts": "", "name": "\"2xl\"", "says": ""}, {"accepts": "", "name": "\"3xl\"", "says": ""}, {"accepts": "", "name": "\"4xl\"", "says": ""}, {"accepts": "", "name": "\"lg\"", "says": ""}, {"accepts": "", "name": "\"md\"", "says": ""}, {"accepts": "", "name": "\"sm\"", "says": ""}, {"accepts": "", "name": "\"xl\"", "says": ""}, {"accepts": "", "name": "\"xs\"", "says": ""}], "react.ReactElement": [{"accepts": "string | JSXElementConstructor<any>", "name": "type", "says": ""}, {"accepts": "unknown", "name": "props", "says": ""}, {"accepts": "string | null", "name": "key", "says": ""}], "react.ReactPortal": [{"accepts": "ReactNode", "name": "children", "says": ""}, {"accepts": "string | JSXElementConstructor<any>", "name": "type", "says": ""}, {"accepts": "unknown", "name": "props", "says": ""}, {"accepts": "string | null", "name": "key", "says": ""}], "kit.MessageStatus": [{"accepts": "", "name": "\"delivered\"", "says": ""}, {"accepts": "", "name": "\"failed\"", "says": ""}, {"accepts": "", "name": "\"read\"", "says": ""}, {"accepts": "", "name": "\"sending\"", "says": ""}, {"accepts": "", "name": "\"sent\"", "says": ""}]};