@aglyn/shared-ui-email-campaigns 1.0.0-beta.143

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 (33) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +73 -0
  3. package/package.json +39 -0
  4. package/src/index.d.ts +17 -0
  5. package/src/index.js +23 -0
  6. package/src/index.js.map +1 -0
  7. package/src/lib/components/campaign-picker.component.d.ts +54 -0
  8. package/src/lib/components/campaign-picker.component.js +121 -0
  9. package/src/lib/components/campaign-picker.component.js.map +1 -0
  10. package/src/lib/components/report-figures.d.ts +51 -0
  11. package/src/lib/components/report-figures.js +120 -0
  12. package/src/lib/components/report-figures.js.map +1 -0
  13. package/src/lib/model/campaign-container.d.ts +359 -0
  14. package/src/lib/model/campaign-container.js +355 -0
  15. package/src/lib/model/campaign-container.js.map +1 -0
  16. package/src/lib/model/campaign-conversions.d.ts +286 -0
  17. package/src/lib/model/campaign-conversions.js +249 -0
  18. package/src/lib/model/campaign-conversions.js.map +1 -0
  19. package/src/lib/model/campaign-report.d.ts +304 -0
  20. package/src/lib/model/campaign-report.js +326 -0
  21. package/src/lib/model/campaign-report.js.map +1 -0
  22. package/src/lib/model/campaign-revenue.d.ts +327 -0
  23. package/src/lib/model/campaign-revenue.js +332 -0
  24. package/src/lib/model/campaign-revenue.js.map +1 -0
  25. package/src/lib/model/campaign-send-time.d.ts +74 -0
  26. package/src/lib/model/campaign-send-time.js +120 -0
  27. package/src/lib/model/campaign-send-time.js.map +1 -0
  28. package/src/lib/model/email-record.d.ts +175 -0
  29. package/src/lib/model/email-record.js +198 -0
  30. package/src/lib/model/email-record.js.map +1 -0
  31. package/src/lib/model/index.d.ts +53 -0
  32. package/src/lib/model/index.js +48 -0
  33. package/src/lib/model/index.js.map +1 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # @aglyn/shared-ui-email-campaigns
2
+
3
+ The email-campaign document model and the figures that render it, owned by
4
+ neither of the two plugins that read it.
5
+
6
+ ## Why it is not in a plugin
7
+
8
+ An email campaign is written by one plugin and reported by another. The
9
+ Marketing plugin owns the `campaigns` console section; the Email plugin owns
10
+ the message, template and list surfaces. Both are independently toggleable —
11
+ `release_marketing` and `release_email` are separate flags in
12
+ `libs/aglyn/src/lib/plugin-manager/enabled-plugins.ts` — so an organization
13
+ can have either one without the other.
14
+
15
+ A shape that lives inside one of them is therefore a shape the other reaches
16
+ past a switch to get. Because every plugin compiles into the same console
17
+ bundle, such an import resolves at runtime whether or not the owning plugin is
18
+ enabled, and the plugin switchboard is bypassed silently rather than failing.
19
+ Putting the shared half here makes both plugins peers of it: each depends on
20
+ this library, neither depends on the other for a rate, a field name or a
21
+ `<Figure>`.
22
+
23
+ The boundary is enforced in
24
+ `libs/plugins/marketing/src/lib/plugin-email-boundary.spec.ts`, which fails if
25
+ Marketing re-acquires an import of anything this library owns from
26
+ `@aglyn/plugins-email`.
27
+
28
+ ## Two entry points, deliberately
29
+
30
+ ```typescript
31
+ // Pure. No React, no MUI — safe in a /server handler.
32
+ import {
33
+ campaignReport,
34
+ CAMPAIGN_SEND_CONTAINER_FIELD,
35
+ } from '@aglyn/shared-ui-email-campaigns/model'
36
+
37
+ // Renders MUI. Console surfaces only.
38
+ import {
39
+ Figure,
40
+ RateRow,
41
+ Section,
42
+ } from '@aglyn/shared-ui-email-campaigns/components/report-figures'
43
+ ```
44
+
45
+ The package barrel (`@aglyn/shared-ui-email-campaigns`) re-exports the model
46
+ and nothing else, so a webhook handler that needs one stored field name does
47
+ not pull a component graph in behind it. `report-figures` is reachable by
48
+ subpath only — the same barrel discipline `@aglyn/shared-ui-jsx` runs under.
49
+
50
+ ## What is here
51
+
52
+ | Module | Answers |
53
+ | --------------------------- | --------------------------------------------------------------------------------- |
54
+ | `model/campaign-container` | The campaign's window, its lists, its sends, and the rollup across them |
55
+ | `model/campaign-report` | The rate math, the population each rate describes, and the link rollup |
56
+ | `model/campaign-revenue` | What a campaign earned, per currency, gross and refunded |
57
+ | `model/email-record` | One message: its state, its audience, and when it went out |
58
+ | `components/report-figures` | The renderers those figures print through, so a rate always shows its denominator |
59
+
60
+ `model/campaign-revenue` re-exports the attribution window and model name from
61
+ `@aglyn/shared-util-email`, which is where the writer in `tenant-data-admin`
62
+ takes them from — one definition of the window on both sides of the join.
63
+
64
+ ## What is not here
65
+
66
+ Sending. The send loop, the composer, the topic subscriptions and the
67
+ send-time API all stay in `@aglyn/plugins-email`: they are behavior that the
68
+ Email plugin's switch is supposed to govern, not shapes that two plugins share.
69
+
70
+ ## Running unit tests
71
+
72
+ Run `nx test shared-ui-email-campaigns` to execute the unit tests via
73
+ [Jest](https://jestjs.io).
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@aglyn/shared-ui-email-campaigns",
3
+ "version": "1.0.0-beta.143",
4
+ "license": "Apache-2.0",
5
+ "homepage": "https://aglyn.com",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/aglyn/aglyn.git",
9
+ "directory": "libs/shared/ui/email-campaigns"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public",
13
+ "provenance": true
14
+ },
15
+ "type": "module",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./src/index.d.ts",
19
+ "default": "./src/index.js"
20
+ },
21
+ "./*": {
22
+ "types": "./src/lib/*.d.ts",
23
+ "default": "./src/lib/*.js"
24
+ },
25
+ "./package.json": "./package.json"
26
+ },
27
+ "dependencies": {
28
+ "@aglyn/shared-ui-jsx": "1.0.0-beta.143",
29
+ "@aglyn/shared-util-email": "1.0.0-beta.143",
30
+ "@swc/helpers": "0.5.23"
31
+ },
32
+ "peerDependencies": {
33
+ "@mui/material": "^9.3.1"
34
+ },
35
+ "sideEffects": false,
36
+ "types": "./src/index.d.ts",
37
+ "module": "./src/index.js",
38
+ "main": "./src/index.js"
39
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export * from './lib/model';
package/src/index.js ADDED
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ // Only the model reaches this barrel. `components/report-figures` renders MUI
17
+ // and is imported by subpath instead — the tsconfig wildcard
18
+ // `@aglyn/shared-ui-email-campaigns/*` already resolves it — so server
19
+ // handlers reading a stored field name never pull a component graph behind
20
+ // them.
21
+ export * from "./lib/model/index.js";
22
+
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../libs/shared/ui/email-campaigns/src/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Only the model reaches this barrel. `components/report-figures` renders MUI\n// and is imported by subpath instead — the tsconfig wildcard\n// `@aglyn/shared-ui-email-campaigns/*` already resolves it — so server\n// handlers reading a stored field name never pull a component graph behind\n// them.\nexport * from './lib/model'\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,8EAA8E;AAC9E,6DAA6D;AAC7D,uEAAuE;AACvE,2EAA2E;AAC3E,QAAQ;AACR,cAAc,uBAAa"}
@@ -0,0 +1,54 @@
1
+ /** One campaign a resource may be put in. */
2
+ export interface CampaignPickerOption {
3
+ value: string;
4
+ label: string;
5
+ }
6
+ export interface CampaignPickerProps {
7
+ /** The campaigns this site has, newest window first is the caller's job. */
8
+ options: readonly CampaignPickerOption[];
9
+ /** The campaign ids currently selected. */
10
+ value: readonly string[];
11
+ onChange: (next: string[]) => void;
12
+ /** Overrides the default label — a contact says "filed under", not "in". */
13
+ label?: string;
14
+ /** Overrides the default helper line. */
15
+ helperText?: string;
16
+ disabled?: boolean;
17
+ /**
18
+ * The site has no campaigns at all, so the picker has nothing to offer.
19
+ *
20
+ * Distinct from "still loading": an empty select with no explanation reads
21
+ * as a control that is broken, and the two states look identical.
22
+ */
23
+ empty?: boolean;
24
+ /** What to say in place of the picker when {@link empty}. */
25
+ emptyText?: string;
26
+ }
27
+ /**
28
+ * WHICH CAMPAIGNS THIS RECORD IS PART OF.
29
+ *
30
+ * The one control behind every campaign assignment in the console — a form's
31
+ * page, a screen's page and a contact's drawer — so that three surfaces
32
+ * editing one stored field cannot come to present it three ways.
33
+ *
34
+ * ## It renders ids as NAMES and stores ids
35
+ *
36
+ * The chips read the label out of {@link CampaignPickerProps.options}, and an
37
+ * id with no option left falls back to the id itself rather than
38
+ * disappearing. A campaign that has been deleted is exactly that case, and
39
+ * a chip that vanished would tell a merchant the assignment was gone when the
40
+ * document still carries it.
41
+ *
42
+ * ## Presentational, deliberately
43
+ *
44
+ * It reads no campaign collection of its own. The three callers already hold
45
+ * a site scope and their own read budget — a screen's page is in the console
46
+ * app, which may not import a feature plugin at all — and a control that
47
+ * opened a listener per placement is the unrequested read on mount this
48
+ * console refuses.
49
+ */
50
+ export declare function CampaignPicker(props: CampaignPickerProps): import("react").JSX.Element;
51
+ export declare namespace CampaignPicker {
52
+ var displayName: string;
53
+ }
54
+ export default CampaignPicker;
@@ -0,0 +1,121 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ 'use client';
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ import { Chip, MenuItem, Stack, TextField, Typography } from "@mui/material";
19
+ /**
20
+ * WHICH CAMPAIGNS THIS RECORD IS PART OF.
21
+ *
22
+ * The one control behind every campaign assignment in the console — a form's
23
+ * page, a screen's page and a contact's drawer — so that three surfaces
24
+ * editing one stored field cannot come to present it three ways.
25
+ *
26
+ * ## It renders ids as NAMES and stores ids
27
+ *
28
+ * The chips read the label out of {@link CampaignPickerProps.options}, and an
29
+ * id with no option left falls back to the id itself rather than
30
+ * disappearing. A campaign that has been deleted is exactly that case, and
31
+ * a chip that vanished would tell a merchant the assignment was gone when the
32
+ * document still carries it.
33
+ *
34
+ * ## Presentational, deliberately
35
+ *
36
+ * It reads no campaign collection of its own. The three callers already hold
37
+ * a site scope and their own read budget — a screen's page is in the console
38
+ * app, which may not import a feature plugin at all — and a control that
39
+ * opened a listener per placement is the unrequested read on mount this
40
+ * console refuses.
41
+ */ export function CampaignPicker(props) {
42
+ const { options, value, onChange, label = 'Campaigns', helperText = 'The campaigns this belongs to. Clearing them all takes it out of every campaign.', disabled, empty, emptyText = 'This site has no campaigns yet. Create one from Marketing to file records under it.' } = props;
43
+ if (empty) {
44
+ return /*#__PURE__*/ _jsx(Typography, {
45
+ variant: "body2",
46
+ color: "text.secondary",
47
+ children: emptyText
48
+ });
49
+ }
50
+ const labels = new Map(options.map((option)=>[
51
+ option.value,
52
+ option.label
53
+ ]));
54
+ return /*#__PURE__*/ _jsx(TextField, {
55
+ select: true,
56
+ size: "small",
57
+ label: label,
58
+ value: value,
59
+ disabled: disabled,
60
+ onChange: (event)=>onChange(// A multiple select hands back an array; the change event's typing
61
+ // does not know that.
62
+ event.target.value.map(String)),
63
+ helperText: helperText,
64
+ fullWidth: true,
65
+ slotProps: {
66
+ /*
67
+ * `shrink`, because `displayEmpty` below draws "No campaign" in the
68
+ * closed box while the value is still empty (AGL-2486's pairing).
69
+ *
70
+ * MUI shrinks a label when the input reports itself filled, and an
71
+ * empty multiple select reports the opposite — so the label sat at
72
+ * full size, inside the box, on top of the placeholder it had just
73
+ * drawn: two lines of text one on the other, on every screen, form,
74
+ * contact and dynamic-list page that renders this picker. Both halves
75
+ * have to be said together; `displayEmpty` alone IS the overlap.
76
+ *
77
+ * Nothing sets `notched` here on purpose: `TextField` derives it from
78
+ * this `shrink` for the outlined variant, so the outline's gap and the
79
+ * label can never disagree.
80
+ */ inputLabel: {
81
+ shrink: true
82
+ },
83
+ select: {
84
+ multiple: true,
85
+ displayEmpty: true,
86
+ renderValue: (selected)=>{
87
+ const ids = selected != null ? selected : [];
88
+ if (!ids.length) {
89
+ return /*#__PURE__*/ _jsx(Typography, {
90
+ variant: "body2",
91
+ color: "text.secondary",
92
+ children: 'No campaign'
93
+ });
94
+ }
95
+ return /*#__PURE__*/ _jsx(Stack, {
96
+ direction: "row",
97
+ spacing: 0.5,
98
+ sx: {
99
+ flexWrap: 'wrap'
100
+ },
101
+ children: ids.map((id)=>{
102
+ var _labels_get;
103
+ return /*#__PURE__*/ _jsx(Chip, {
104
+ size: "small",
105
+ label: (_labels_get = labels.get(id)) != null ? _labels_get : id
106
+ }, id);
107
+ })
108
+ });
109
+ }
110
+ }
111
+ },
112
+ children: options.map((option)=>/*#__PURE__*/ _jsx(MenuItem, {
113
+ value: option.value,
114
+ children: option.label
115
+ }, option.value))
116
+ });
117
+ }
118
+ CampaignPicker.displayName = 'CampaignPicker';
119
+ export default CampaignPicker;
120
+
121
+ //# sourceMappingURL=campaign-picker.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/shared/ui/email-campaigns/src/lib/components/campaign-picker.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { Chip, MenuItem, Stack, TextField, Typography } from '@mui/material'\n\n/** One campaign a resource may be put in. */\nexport interface CampaignPickerOption {\n value: string\n label: string\n}\n\nexport interface CampaignPickerProps {\n /** The campaigns this site has, newest window first is the caller's job. */\n options: readonly CampaignPickerOption[]\n /** The campaign ids currently selected. */\n value: readonly string[]\n onChange: (next: string[]) => void\n /** Overrides the default label — a contact says \"filed under\", not \"in\". */\n label?: string\n /** Overrides the default helper line. */\n helperText?: string\n disabled?: boolean\n /**\n * The site has no campaigns at all, so the picker has nothing to offer.\n *\n * Distinct from \"still loading\": an empty select with no explanation reads\n * as a control that is broken, and the two states look identical.\n */\n empty?: boolean\n /** What to say in place of the picker when {@link empty}. */\n emptyText?: string\n}\n\n/**\n * WHICH CAMPAIGNS THIS RECORD IS PART OF.\n *\n * The one control behind every campaign assignment in the console — a form's\n * page, a screen's page and a contact's drawer — so that three surfaces\n * editing one stored field cannot come to present it three ways.\n *\n * ## It renders ids as NAMES and stores ids\n *\n * The chips read the label out of {@link CampaignPickerProps.options}, and an\n * id with no option left falls back to the id itself rather than\n * disappearing. A campaign that has been deleted is exactly that case, and\n * a chip that vanished would tell a merchant the assignment was gone when the\n * document still carries it.\n *\n * ## Presentational, deliberately\n *\n * It reads no campaign collection of its own. The three callers already hold\n * a site scope and their own read budget — a screen's page is in the console\n * app, which may not import a feature plugin at all — and a control that\n * opened a listener per placement is the unrequested read on mount this\n * console refuses.\n */\nexport function CampaignPicker(props: CampaignPickerProps) {\n const {\n options,\n value,\n onChange,\n label = 'Campaigns',\n helperText = 'The campaigns this belongs to. Clearing them all takes it out of every campaign.',\n disabled,\n empty,\n emptyText = 'This site has no campaigns yet. Create one from Marketing to file records under it.',\n } = props\n\n if (empty) {\n return (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {emptyText}\n </Typography>\n )\n }\n\n const labels = new Map(options.map((option) => [option.value, option.label]))\n\n return (\n <TextField\n select\n size=\"small\"\n label={label}\n value={value as string[]}\n disabled={disabled}\n onChange={(event) =>\n onChange(\n // A multiple select hands back an array; the change event's typing\n // does not know that.\n (event.target.value as unknown as string[]).map(String),\n )\n }\n helperText={helperText}\n fullWidth\n slotProps={{\n /*\n * `shrink`, because `displayEmpty` below draws \"No campaign\" in the\n * closed box while the value is still empty (AGL-2486's pairing).\n *\n * MUI shrinks a label when the input reports itself filled, and an\n * empty multiple select reports the opposite — so the label sat at\n * full size, inside the box, on top of the placeholder it had just\n * drawn: two lines of text one on the other, on every screen, form,\n * contact and dynamic-list page that renders this picker. Both halves\n * have to be said together; `displayEmpty` alone IS the overlap.\n *\n * Nothing sets `notched` here on purpose: `TextField` derives it from\n * this `shrink` for the outlined variant, so the outline's gap and the\n * label can never disagree.\n */\n inputLabel: { shrink: true },\n select: {\n multiple: true,\n displayEmpty: true,\n renderValue: (selected: unknown) => {\n const ids = (selected as string[]) ?? []\n if (!ids.length) {\n return (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No campaign'}\n </Typography>\n )\n }\n return (\n <Stack direction=\"row\" spacing={0.5} sx={{ flexWrap: 'wrap' }}>\n {ids.map((id) => (\n <Chip key={id} size=\"small\" label={labels.get(id) ?? id} />\n ))}\n </Stack>\n )\n },\n },\n }}\n >\n {options.map((option) => (\n <MenuItem key={option.value} value={option.value}>\n {option.label}\n </MenuItem>\n ))}\n </TextField>\n )\n}\nCampaignPicker.displayName = 'CampaignPicker'\n\nexport default CampaignPicker\n"],"names":["Chip","MenuItem","Stack","TextField","Typography","CampaignPicker","props","options","value","onChange","label","helperText","disabled","empty","emptyText","variant","color","labels","Map","map","option","select","size","event","target","String","fullWidth","slotProps","inputLabel","shrink","multiple","displayEmpty","renderValue","selected","ids","length","direction","spacing","sx","flexWrap","id","get","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SAASA,IAAI,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,SAAS,EAAEC,UAAU,QAAQ,gBAAe;AA8B5E;;;;;;;;;;;;;;;;;;;;;;CAsBC,GACD,OAAO,SAASC,eAAeC,KAA0B;IACvD,MAAM,EACJC,OAAO,EACPC,KAAK,EACLC,QAAQ,EACRC,QAAQ,WAAW,EACnBC,aAAa,kFAAkF,EAC/FC,QAAQ,EACRC,KAAK,EACLC,YAAY,qFAAqF,EAClG,GAAGR;IAEJ,IAAIO,OAAO;QACT,qBACE,KAACT;YAAWW,SAAQ;YAAQC,OAAM;sBAC/BF;;IAGP;IAEA,MAAMG,SAAS,IAAIC,IAAIX,QAAQY,GAAG,CAAC,CAACC,SAAW;YAACA,OAAOZ,KAAK;YAAEY,OAAOV,KAAK;SAAC;IAE3E,qBACE,KAACP;QACCkB,MAAM;QACNC,MAAK;QACLZ,OAAOA;QACPF,OAAOA;QACPI,UAAUA;QACVH,UAAU,CAACc,QACTd,SAGE,AAFA,mEAAmE;YACnE,sBAAsB;YACrBc,MAAMC,MAAM,CAAChB,KAAK,CAAyBW,GAAG,CAACM;QAGpDd,YAAYA;QACZe,SAAS;QACTC,WAAW;YACT;;;;;;;;;;;;;;SAcC,GACDC,YAAY;gBAAEC,QAAQ;YAAK;YAC3BR,QAAQ;gBACNS,UAAU;gBACVC,cAAc;gBACdC,aAAa,CAACC;oBACZ,MAAMC,MAAOD,mBAAAA,WAAyB,EAAE;oBACxC,IAAI,CAACC,IAAIC,MAAM,EAAE;wBACf,qBACE,KAAC/B;4BAAWW,SAAQ;4BAAQC,OAAM;sCAC/B;;oBAGP;oBACA,qBACE,KAACd;wBAAMkC,WAAU;wBAAMC,SAAS;wBAAKC,IAAI;4BAAEC,UAAU;wBAAO;kCACzDL,IAAIf,GAAG,CAAC,CAACqB;gCAC2BvB;iDAAnC,KAACjB;gCAAcsB,MAAK;gCAAQZ,KAAK,GAAEO,cAAAA,OAAOwB,GAAG,CAACD,eAAXvB,cAAkBuB;+BAA1CA;;;gBAInB;YACF;QACF;kBAECjC,QAAQY,GAAG,CAAC,CAACC,uBACZ,KAACnB;gBAA4BO,OAAOY,OAAOZ,KAAK;0BAC7CY,OAAOV,KAAK;eADAU,OAAOZ,KAAK;;AAMnC;AACAH,eAAeqC,WAAW,GAAG;AAE7B,eAAerC,eAAc"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export { Figure, percent, RateRow, Section, type MeasuredRate, } from '@aglyn/shared-ui-jsx/components/measured-figures.component';
18
+ import type { CampaignMoneyPerMessage } from '../model/campaign-revenue';
19
+ export declare function money(cents: number, currency: string): string;
20
+ /**
21
+ * One money figure, with the population it is averaged over named.
22
+ *
23
+ * The same rule {@link RateRow} enforces for a percentage, applied to an
24
+ * average — they go wrong the same way. "$0.42 per recipient" is meaningless
25
+ * without the recipient count, and worse than meaningless when the reader
26
+ * assumes a different one from the writer.
27
+ */
28
+ export declare function MoneyPerMessageRow(props: {
29
+ label: string;
30
+ figure: CampaignMoneyPerMessage | null;
31
+ }): import("react").JSX.Element;
32
+ export declare namespace MoneyPerMessageRow {
33
+ var displayName: string;
34
+ }
35
+ /**
36
+ * One money total, with what it counts named underneath.
37
+ *
38
+ * {@link Figure}'s contract in currency: `null` draws a dash and never a
39
+ * zero, because "no attribution has ever been recorded" and "this campaign
40
+ * earned nothing" lead a merchant to opposite conclusions about whether to
41
+ * send another one.
42
+ */
43
+ export declare function MoneyFigure(props: {
44
+ label: string;
45
+ cents: number | null;
46
+ currency: string;
47
+ note: string;
48
+ }): import("react").JSX.Element;
49
+ export declare namespace MoneyFigure {
50
+ var displayName: string;
51
+ }