@genesislcap/pbc-notify-ui 15.93.0 → 15.94.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/custom-elements.json +794 -477
  2. package/dist/dts/components/foundation-sounds/foundation-sounds-panel.d.ts +15 -0
  3. package/dist/dts/components/foundation-sounds/foundation-sounds-panel.d.ts.map +1 -1
  4. package/dist/dts/components/foundation-sounds/foundation-sounds-panel.styles.d.ts.map +1 -1
  5. package/dist/dts/components/foundation-sounds/foundation-sounds-panel.template.d.ts.map +1 -1
  6. package/dist/dts/react.d.ts +20 -20
  7. package/dist/dts/utils/alert-sound.d.ts +18 -2
  8. package/dist/dts/utils/alert-sound.d.ts.map +1 -1
  9. package/dist/dts/utils/default-sounds/bell.d.ts +4 -0
  10. package/dist/dts/utils/default-sounds/bell.d.ts.map +1 -0
  11. package/dist/dts/utils/default-sounds/chime.d.ts +4 -0
  12. package/dist/dts/utils/default-sounds/chime.d.ts.map +1 -0
  13. package/dist/dts/utils/default-sounds/double-beep.d.ts +4 -0
  14. package/dist/dts/utils/default-sounds/double-beep.d.ts.map +1 -0
  15. package/dist/dts/utils/default-sounds/ping.d.ts +4 -0
  16. package/dist/dts/utils/default-sounds/ping.d.ts.map +1 -0
  17. package/dist/dts/utils/default-sounds/rising-alert.d.ts +4 -0
  18. package/dist/dts/utils/default-sounds/rising-alert.d.ts.map +1 -0
  19. package/dist/dts/utils/default-sounds.d.ts +28 -0
  20. package/dist/dts/utils/default-sounds.d.ts.map +1 -0
  21. package/dist/esm/components/foundation-sounds/foundation-sounds-panel.js +52 -2
  22. package/dist/esm/components/foundation-sounds/foundation-sounds-panel.styles.js +6 -8
  23. package/dist/esm/components/foundation-sounds/foundation-sounds-panel.template.js +28 -27
  24. package/dist/esm/utils/alert-sound.js +130 -46
  25. package/dist/esm/utils/default-sounds/bell.js +3 -0
  26. package/dist/esm/utils/default-sounds/chime.js +3 -0
  27. package/dist/esm/utils/default-sounds/double-beep.js +3 -0
  28. package/dist/esm/utils/default-sounds/ping.js +3 -0
  29. package/dist/esm/utils/default-sounds/rising-alert.js +3 -0
  30. package/dist/esm/utils/default-sounds.js +56 -0
  31. package/dist/pbc-notify-ui.api.json +144 -4
  32. package/dist/pbc-notify-ui.d.ts +44 -2
  33. package/dist/react.cjs +11 -11
  34. package/dist/react.mjs +9 -9
  35. package/index.html +29 -0
  36. package/package.json +22 -22
  37. package/scripts/generate-default-sounds.mjs +163 -0
package/dist/react.mjs CHANGED
@@ -70,11 +70,6 @@ export const FoundationInboxCounter = React.forwardRef(function FoundationInboxC
70
70
  return React.createElement(customElements.getName(FoundationInboxCounterWC) ?? 'foundation-inbox-counter', { ...rest, ref }, children);
71
71
  });
72
72
 
73
- export const FoundationInboxFlyout = React.forwardRef(function FoundationInboxFlyout(props, ref) {
74
- const { children, ...rest } = props;
75
- return React.createElement(customElements.getName(FoundationInboxFlyoutWC) ?? 'foundation-inbox-flyout', { ...rest, ref }, children);
76
- });
77
-
78
73
  export const InboxSubscription = React.forwardRef(function InboxSubscription(props, ref) {
79
74
  const { onTemplateSubscribed, onSubscribeCancelled, children, ...rest } = props;
80
75
  const _innerRef = React.useRef(null);
@@ -97,6 +92,11 @@ export const InboxSubscription = React.forwardRef(function InboxSubscription(pro
97
92
  return React.createElement(customElements.getName(InboxSubscriptionWC) ?? 'inbox-subscription', { ...rest, ref: _mergeRefs(_innerRef, ref) }, children);
98
93
  });
99
94
 
95
+ export const FoundationInboxFlyout = React.forwardRef(function FoundationInboxFlyout(props, ref) {
96
+ const { children, ...rest } = props;
97
+ return React.createElement(customElements.getName(FoundationInboxFlyoutWC) ?? 'foundation-inbox-flyout', { ...rest, ref }, children);
98
+ });
99
+
100
100
  export const NotifyAuditManagement = React.forwardRef(function NotifyAuditManagement(props, ref) {
101
101
  const { children, ...rest } = props;
102
102
  return React.createElement(customElements.getName(NotifyAuditManagementWC) ?? 'notify-audit-management', { ...rest, ref }, children);
@@ -242,7 +242,7 @@ export const RuleConditionGroup = React.forwardRef(function RuleConditionGroup(p
242
242
  return React.createElement(customElements.getName(RuleConditionGroupWC) ?? 'rule-condition-group', { ...rest, ref: _mergeRefs(_innerRef, ref) }, children);
243
243
  });
244
244
 
245
- export const ParameterBuilder = React.forwardRef(function ParameterBuilder(props, ref) {
245
+ export const TemplateConditionBuilder = React.forwardRef(function TemplateConditionBuilder(props, ref) {
246
246
  const { onDelete, onEdit, children, ...rest } = props;
247
247
  const _innerRef = React.useRef(null);
248
248
  const _onDeleteRef = React.useRef(onDelete);
@@ -261,10 +261,10 @@ export const ParameterBuilder = React.forwardRef(function ParameterBuilder(props
261
261
  el.removeEventListener('edit', _onEditFn);
262
262
  };
263
263
  }, []);
264
- return React.createElement(customElements.getName(ParameterBuilderWC) ?? 'parameter-builder', { ...rest, ref: _mergeRefs(_innerRef, ref) }, children);
264
+ return React.createElement(customElements.getName(TemplateConditionBuilderWC) ?? 'template-condition-builder', { ...rest, ref: _mergeRefs(_innerRef, ref) }, children);
265
265
  });
266
266
 
267
- export const TemplateConditionBuilder = React.forwardRef(function TemplateConditionBuilder(props, ref) {
267
+ export const ParameterBuilder = React.forwardRef(function ParameterBuilder(props, ref) {
268
268
  const { onDelete, onEdit, children, ...rest } = props;
269
269
  const _innerRef = React.useRef(null);
270
270
  const _onDeleteRef = React.useRef(onDelete);
@@ -283,7 +283,7 @@ export const TemplateConditionBuilder = React.forwardRef(function TemplateCondit
283
283
  el.removeEventListener('edit', _onEditFn);
284
284
  };
285
285
  }, []);
286
- return React.createElement(customElements.getName(TemplateConditionBuilderWC) ?? 'template-condition-builder', { ...rest, ref: _mergeRefs(_innerRef, ref) }, children);
286
+ return React.createElement(customElements.getName(ParameterBuilderWC) ?? 'parameter-builder', { ...rest, ref: _mergeRefs(_innerRef, ref) }, children);
287
287
  });
288
288
 
289
289
  export const TemplateConditionGroup = React.forwardRef(function TemplateConditionGroup(props, ref) {
package/index.html ADDED
@@ -0,0 +1,29 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>{{htmlWebpackPlugin.options.title}}</title>
7
+ <style>
8
+ html,
9
+ body {
10
+ width: 100%;
11
+ height: 100%;
12
+ padding: 0;
13
+ margin: 0;
14
+ }
15
+ :not(:defined) {
16
+ visibility: hidden;
17
+ }
18
+ :defined {
19
+ visibility: visible;
20
+ }
21
+ </style>
22
+ </head>
23
+ <body>
24
+ <{{htmlWebpackPlugin.options.customElementTagName}}></{{htmlWebpackPlugin.options.customElementTagName}}>
25
+ {{#if insertEntryPoint}}
26
+ <script type="module" src="/src/index.ts"></script>
27
+ {{/if}}
28
+ </body>
29
+ </html>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/pbc-notify-ui",
3
3
  "description": "Genesis PBC Notify UI",
4
- "version": "15.93.0",
4
+ "version": "15.94.0",
5
5
  "license": "SEE LICENSE IN license.txt",
6
6
  "workspaces": [
7
7
  "client"
@@ -80,30 +80,30 @@
80
80
  "@commitlint/cli": "^19.2.1",
81
81
  "@commitlint/config-conventional": "^19.1.0",
82
82
  "@commitlint/format": "^19.0.3",
83
- "@genesislcap/design-system-configurator": "15.93.0",
84
- "@genesislcap/eslint-config": "15.93.0",
85
- "@genesislcap/eslint-stylelint-builder": "15.93.0",
86
- "@genesislcap/foundation-testing": "15.93.0",
87
- "@genesislcap/genx": "15.93.0",
88
- "@genesislcap/prettier-config": "15.93.0",
89
- "@genesislcap/stylelint-config": "15.93.0",
90
- "@genesislcap/vite-builder": "15.93.0",
91
- "@genesislcap/webpack-builder": "15.93.0",
83
+ "@genesislcap/design-system-configurator": "15.94.0",
84
+ "@genesislcap/eslint-config": "15.94.0",
85
+ "@genesislcap/eslint-stylelint-builder": "15.94.0",
86
+ "@genesislcap/foundation-testing": "15.94.0",
87
+ "@genesislcap/genx": "15.94.0",
88
+ "@genesislcap/prettier-config": "15.94.0",
89
+ "@genesislcap/stylelint-config": "15.94.0",
90
+ "@genesislcap/vite-builder": "15.94.0",
91
+ "@genesislcap/webpack-builder": "15.94.0",
92
92
  "dayjs": "^1.11.7"
93
93
  },
94
94
  "dependencies": {
95
- "@genesislcap/foundation-comms": "15.93.0",
96
- "@genesislcap/foundation-criteria": "15.93.0",
97
- "@genesislcap/foundation-entity-management": "15.93.0",
98
- "@genesislcap/foundation-forms": "15.93.0",
99
- "@genesislcap/foundation-layout": "15.93.0",
100
- "@genesislcap/foundation-logger": "15.93.0",
101
- "@genesislcap/foundation-notifications": "15.93.0",
102
- "@genesislcap/foundation-ui": "15.93.0",
103
- "@genesislcap/foundation-utils": "15.93.0",
104
- "@genesislcap/rapid-design-system": "15.93.0",
105
- "@genesislcap/rapid-grid-pro": "15.93.0",
106
- "@genesislcap/web-core": "15.93.0",
95
+ "@genesislcap/foundation-comms": "15.94.0",
96
+ "@genesislcap/foundation-criteria": "15.94.0",
97
+ "@genesislcap/foundation-entity-management": "15.94.0",
98
+ "@genesislcap/foundation-forms": "15.94.0",
99
+ "@genesislcap/foundation-layout": "15.94.0",
100
+ "@genesislcap/foundation-logger": "15.94.0",
101
+ "@genesislcap/foundation-notifications": "15.94.0",
102
+ "@genesislcap/foundation-ui": "15.94.0",
103
+ "@genesislcap/foundation-utils": "15.94.0",
104
+ "@genesislcap/rapid-design-system": "15.94.0",
105
+ "@genesislcap/rapid-grid-pro": "15.94.0",
106
+ "@genesislcap/web-core": "15.94.0",
107
107
  "lodash.debounce": "^4.0.8",
108
108
  "rxjs": "^7.5.4"
109
109
  },
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Synthesises the built-in alert sounds offered in the inbox Sounds tab and writes each one
3
+ * to `src/utils/default-sounds/<id>.ts` as a base64 WAV string.
4
+ *
5
+ * The sounds are generated here rather than downloaded so the package ships no third-party
6
+ * audio and carries no licence obligations. Tweak a recipe below and re-run:
7
+ *
8
+ * node scripts/generate-default-sounds.mjs
9
+ */
10
+ import { mkdirSync, writeFileSync } from 'node:fs';
11
+ import { dirname, join } from 'node:path';
12
+ import { fileURLToPath } from 'node:url';
13
+
14
+ // Every recipe's highest partial (the bell's, ~5.9 kHz) sits below the 8 kHz Nyquist limit.
15
+ const SAMPLE_RATE = 16000;
16
+ const PEAK = 0.8;
17
+ const ATTACK_SECONDS = 0.005;
18
+ const FADE_OUT_SECONDS = 0.02;
19
+
20
+ const outDir = join(dirname(fileURLToPath(import.meta.url)), '../src/utils/default-sounds');
21
+
22
+ /**
23
+ * A note is a set of partials sharing a start time; each partial decays on its own
24
+ * time constant so higher overtones die away first, as they do on a struck object.
25
+ */
26
+ function addNote(samples, { start, frequency, partials, gate }) {
27
+ const startIndex = Math.round(start * SAMPLE_RATE);
28
+ for (let i = startIndex; i < samples.length; i += 1) {
29
+ const t = (i - startIndex) / SAMPLE_RATE;
30
+ const attack = Math.min(1, t / ATTACK_SECONDS);
31
+ // A gated note (beep) stops sharply after `gate` seconds with a short release.
32
+ const release = gate == null ? 1 : Math.max(0, Math.min(1, (gate - t) / 0.01 + 1));
33
+ if (release === 0) {
34
+ break;
35
+ }
36
+ let value = 0;
37
+ for (const { ratio, amp, decay } of partials) {
38
+ const envelope = decay == null ? 1 : Math.exp(-t / decay);
39
+ value += amp * envelope * Math.sin(2 * Math.PI * frequency * ratio * t);
40
+ }
41
+ samples[i] += value * attack * release;
42
+ }
43
+ }
44
+
45
+ const SOUNDS = {
46
+ chime: {
47
+ seconds: 1.1,
48
+ notes: [
49
+ { start: 0, frequency: 1318.51 },
50
+ { start: 0.18, frequency: 1046.5 },
51
+ ].map((note) => ({
52
+ ...note,
53
+ partials: [
54
+ { ratio: 1, amp: 1, decay: 0.35 },
55
+ { ratio: 2, amp: 0.3, decay: 0.2 },
56
+ { ratio: 3, amp: 0.1, decay: 0.12 },
57
+ ],
58
+ })),
59
+ },
60
+ ping: {
61
+ seconds: 0.6,
62
+ notes: [
63
+ {
64
+ start: 0,
65
+ frequency: 1760,
66
+ partials: [
67
+ { ratio: 1, amp: 1, decay: 0.12 },
68
+ { ratio: 2, amp: 0.2, decay: 0.06 },
69
+ ],
70
+ },
71
+ ],
72
+ },
73
+ bell: {
74
+ seconds: 1.6,
75
+ notes: [
76
+ {
77
+ start: 0,
78
+ frequency: 659.25,
79
+ // Inharmonic ratios give the metallic colour of a bell.
80
+ partials: [
81
+ { ratio: 1, amp: 1, decay: 0.9 },
82
+ { ratio: 2, amp: 0.5, decay: 0.6 },
83
+ { ratio: 2.76, amp: 0.35, decay: 0.45 },
84
+ { ratio: 5.4, amp: 0.2, decay: 0.25 },
85
+ { ratio: 8.93, amp: 0.1, decay: 0.15 },
86
+ ],
87
+ },
88
+ ],
89
+ },
90
+ 'double-beep': {
91
+ seconds: 0.45,
92
+ notes: [0, 0.2].map((start) => ({
93
+ start,
94
+ frequency: 987.77,
95
+ gate: 0.11,
96
+ partials: [
97
+ { ratio: 1, amp: 1 },
98
+ { ratio: 3, amp: 0.15 },
99
+ ],
100
+ })),
101
+ },
102
+ 'rising-alert': {
103
+ seconds: 0.9,
104
+ notes: [523.25, 659.25, 783.99, 1046.5].map((frequency, index) => ({
105
+ start: index * 0.09,
106
+ frequency,
107
+ // Odd harmonics at 1/n² approximate a soft triangle wave.
108
+ partials: [
109
+ { ratio: 1, amp: 1, decay: 0.18 },
110
+ { ratio: 3, amp: 1 / 9, decay: 0.12 },
111
+ { ratio: 5, amp: 1 / 25, decay: 0.08 },
112
+ ],
113
+ })),
114
+ },
115
+ };
116
+
117
+ function render({ seconds, notes }) {
118
+ const samples = new Float64Array(Math.round(seconds * SAMPLE_RATE));
119
+ notes.forEach((note) => addNote(samples, note));
120
+ const peak = samples.reduce((max, value) => Math.max(max, Math.abs(value)), 0) || 1;
121
+ const fadeSamples = Math.round(FADE_OUT_SECONDS * SAMPLE_RATE);
122
+ return samples.map((value, i) => {
123
+ const fade = Math.min(1, (samples.length - 1 - i) / fadeSamples);
124
+ return (value / peak) * PEAK * fade;
125
+ });
126
+ }
127
+
128
+ /** 16-bit mono PCM WAV. */
129
+ function encodeWav(samples) {
130
+ const dataBytes = samples.length * 2;
131
+ const buffer = Buffer.alloc(44 + dataBytes);
132
+ buffer.write('RIFF', 0, 'ascii');
133
+ buffer.writeUInt32LE(36 + dataBytes, 4);
134
+ buffer.write('WAVE', 8, 'ascii');
135
+ buffer.write('fmt ', 12, 'ascii');
136
+ buffer.writeUInt32LE(16, 16);
137
+ buffer.writeUInt16LE(1, 20);
138
+ buffer.writeUInt16LE(1, 22);
139
+ buffer.writeUInt32LE(SAMPLE_RATE, 24);
140
+ buffer.writeUInt32LE(SAMPLE_RATE * 2, 28);
141
+ buffer.writeUInt16LE(2, 32);
142
+ buffer.writeUInt16LE(16, 34);
143
+ buffer.write('data', 36, 'ascii');
144
+ buffer.writeUInt32LE(dataBytes, 40);
145
+ samples.forEach((value, i) => {
146
+ const clamped = Math.max(-1, Math.min(1, value));
147
+ buffer.writeInt16LE(Math.round(clamped * 0x7fff), 44 + i * 2);
148
+ });
149
+ return buffer;
150
+ }
151
+
152
+ mkdirSync(outDir, { recursive: true });
153
+ for (const [id, recipe] of Object.entries(SOUNDS)) {
154
+ const wav = encodeWav(render(recipe));
155
+ const source = [
156
+ `// Generated by scripts/generate-default-sounds.mjs — do not edit by hand.`,
157
+ `/** Built-in "${id}" alert sound: base64 16-bit mono WAV. */`,
158
+ `export default '${wav.toString('base64')}';`,
159
+ '',
160
+ ].join('\n');
161
+ writeFileSync(join(outDir, `${id}.ts`), source);
162
+ console.log(`${id}.ts ${(wav.length / 1024).toFixed(1)} KB`);
163
+ }