@dovetail-ts/notifications 0.0.0-stage → 1.0.1
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/CHANGELOG.md +32 -0
- package/LICENSE +21 -0
- package/README.md +139 -2
- package/addon-main.cjs +4 -0
- package/declarations/activity.d.ts +43 -0
- package/declarations/activity.d.ts.map +1 -0
- package/declarations/components/dovetail/activity-feed.d.ts +34 -0
- package/declarations/components/dovetail/activity-feed.d.ts.map +1 -0
- package/declarations/components/dovetail/inbox-button.d.ts +19 -0
- package/declarations/components/dovetail/inbox-button.d.ts.map +1 -0
- package/declarations/components/dovetail/inbox.d.ts +33 -0
- package/declarations/components/dovetail/inbox.d.ts.map +1 -0
- package/declarations/components/dovetail/toast-bridge.d.ts +24 -0
- package/declarations/components/dovetail/toast-bridge.d.ts.map +1 -0
- package/declarations/format.d.ts +3 -0
- package/declarations/format.d.ts.map +1 -0
- package/declarations/inbox.d.ts +99 -0
- package/declarations/inbox.d.ts.map +1 -0
- package/declarations/index.d.ts +15 -0
- package/declarations/index.d.ts.map +1 -0
- package/declarations/toasts.d.ts +31 -0
- package/declarations/toasts.d.ts.map +1 -0
- package/declarations/when-visible.d.ts +9 -0
- package/declarations/when-visible.d.ts.map +1 -0
- package/dist/_app_/components/dovetail/activity-feed.js +1 -0
- package/dist/_app_/components/dovetail/inbox-button.js +1 -0
- package/dist/_app_/components/dovetail/inbox.js +1 -0
- package/dist/_app_/components/dovetail/toast-bridge.js +1 -0
- package/dist/activity-feed-CO_8ZYII.js +165 -0
- package/dist/activity-feed-CO_8ZYII.js.map +1 -0
- package/dist/components/dovetail/activity-feed.js +10 -0
- package/dist/components/dovetail/activity-feed.js.map +1 -0
- package/dist/components/dovetail/inbox-button.js +32 -0
- package/dist/components/dovetail/inbox-button.js.map +1 -0
- package/dist/components/dovetail/inbox.js +88 -0
- package/dist/components/dovetail/inbox.js.map +1 -0
- package/dist/components/dovetail/toast-bridge.js +7 -0
- package/dist/components/dovetail/toast-bridge.js.map +1 -0
- package/dist/format-CnYSfbv5.js +8 -0
- package/dist/format-CnYSfbv5.js.map +1 -0
- package/dist/index.js +406 -0
- package/dist/index.js.map +1 -0
- package/dist/toast-bridge-CJ7iWI9Q.js +95 -0
- package/dist/toast-bridge-CJ7iWI9Q.js.map +1 -0
- package/package.json +99 -3
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { setModifierManager, capabilities, on } from '@ember/modifier';
|
|
4
|
+
import { Button, Empty, Item, ItemGroup } from '@ember-joinery/ember';
|
|
5
|
+
import { g, i } from 'decorator-transforms/runtime';
|
|
6
|
+
import { f as formatTime } from './format-CnYSfbv5.js';
|
|
7
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
8
|
+
import { setComponentTemplate } from '@ember/component';
|
|
9
|
+
|
|
10
|
+
// Activity feeds (ADR 0009, ADR 0016). An activity event has the fields of a notification
|
|
11
|
+
// (verb, actor, time, target), and the `ActivityEvent` of `@dovetail-ts/tiptap` fits it too. The
|
|
12
|
+
// feed groups the events of one actor and one verb in a short time: "Ana edited 3 notes".
|
|
13
|
+
const actorId = event => typeof event.actor === 'string' ? event.actor : event.actor.id;
|
|
14
|
+
|
|
15
|
+
/** The events of `events` in groups, the newest group first. */
|
|
16
|
+
function groupActivity(events, {
|
|
17
|
+
window = 5 * 60_000,
|
|
18
|
+
scope
|
|
19
|
+
} = {}) {
|
|
20
|
+
const sorted = events.filter(e => !scope || !e.target || e.target.type === scope.type && e.target.id === scope.id).sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
|
21
|
+
const groups = [];
|
|
22
|
+
for (const event of sorted) {
|
|
23
|
+
const actor = actorId(event);
|
|
24
|
+
const last = groups.at(-1);
|
|
25
|
+
if (last && last.actor === actor && last.verb === event.verb && Date.parse(last.createdAt) - Date.parse(event.createdAt) <= window) {
|
|
26
|
+
last.events.push(event);
|
|
27
|
+
last.count++;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
groups.push({
|
|
31
|
+
key: `${actor}:${event.verb}:${event.createdAt}`,
|
|
32
|
+
actor,
|
|
33
|
+
verb: event.verb,
|
|
34
|
+
createdAt: event.createdAt,
|
|
35
|
+
count: 1,
|
|
36
|
+
events: [event]
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return groups;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The text of a group: "ana edited 3 notes", "ana edited note n1" or "ana commented 2 times". */
|
|
43
|
+
function describeGroup(group, actorName = id => id) {
|
|
44
|
+
const who = `${actorName(group.actor)} ${group.verb}`;
|
|
45
|
+
const first = group.events[0]?.target;
|
|
46
|
+
if (group.count === 1) return first ? `${who} ${first.type} ${first.id}` : who;
|
|
47
|
+
const types = new Set(group.events.map(e => e.target?.type));
|
|
48
|
+
const type = types.size === 1 ? [...types][0] : undefined;
|
|
49
|
+
return type ? `${who} ${group.count} ${type}s` : `${who} ${group.count} times`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The activity events of notifications. */
|
|
53
|
+
function notificationActivity(items) {
|
|
54
|
+
return items.map(({
|
|
55
|
+
verb,
|
|
56
|
+
actor,
|
|
57
|
+
createdAt,
|
|
58
|
+
target
|
|
59
|
+
}) => ({
|
|
60
|
+
verb,
|
|
61
|
+
actor,
|
|
62
|
+
createdAt,
|
|
63
|
+
target
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** A live list of events. Give `log.add` as the `onActivity` of the Tiptap extension. */
|
|
68
|
+
class ActivityLog {
|
|
69
|
+
static {
|
|
70
|
+
g(this.prototype, "events", [tracked], function () {
|
|
71
|
+
return [];
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
#events = (i(this, "events"), void 0);
|
|
75
|
+
/** Adds an event. */
|
|
76
|
+
add = event => {
|
|
77
|
+
this.events = [...this.events, event];
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// A modifier that calls a function each time its element becomes visible. The feed uses it to
|
|
82
|
+
// load older items on scroll.
|
|
83
|
+
class WhenVisibleManager {
|
|
84
|
+
capabilities = capabilities('3.22');
|
|
85
|
+
createModifier() {
|
|
86
|
+
return {
|
|
87
|
+
callback: () => {}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
installModifier(state, element, args) {
|
|
91
|
+
state.callback = args.positional[0];
|
|
92
|
+
state.observer = new IntersectionObserver(entries => {
|
|
93
|
+
if (entries.some(entry => entry.isIntersecting)) state.callback();
|
|
94
|
+
});
|
|
95
|
+
state.observer.observe(element);
|
|
96
|
+
}
|
|
97
|
+
updateModifier(state, args) {
|
|
98
|
+
state.callback = args.positional[0];
|
|
99
|
+
}
|
|
100
|
+
destroyModifier(state) {
|
|
101
|
+
state.observer?.disconnect();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** `{{whenVisible this.load}}`: calls `load` when the element becomes visible. */
|
|
106
|
+
const whenVisible = setModifierManager(() => new WhenVisibleManager(), {});
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A live list of activity for a scope, in groups of one actor and one verb ("Ana edited 3
|
|
110
|
+
* notes"), the newest first. Its `data-state` is `empty`, `loading` or `ready`.
|
|
111
|
+
*/
|
|
112
|
+
class ActivityFeed extends Component {
|
|
113
|
+
static {
|
|
114
|
+
g(this.prototype, "loading", [tracked], function () {
|
|
115
|
+
return false;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
#loading = (i(this, "loading"), void 0);
|
|
119
|
+
get groups() {
|
|
120
|
+
const {
|
|
121
|
+
events,
|
|
122
|
+
scope,
|
|
123
|
+
window
|
|
124
|
+
} = this.args;
|
|
125
|
+
return groupActivity(events, {
|
|
126
|
+
...(scope ? {
|
|
127
|
+
scope
|
|
128
|
+
} : {}),
|
|
129
|
+
...(window !== undefined ? {
|
|
130
|
+
window
|
|
131
|
+
} : {})
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
get state() {
|
|
135
|
+
if (this.loading) return 'loading';
|
|
136
|
+
return this.groups.length ? 'ready' : 'empty';
|
|
137
|
+
}
|
|
138
|
+
text = group => this.args.describe?.(group) ?? describeGroup(group, this.args.actorName);
|
|
139
|
+
loadOlder = async () => {
|
|
140
|
+
if (this.loading || !this.args.hasMore || !this.args.onLoadOlder) return;
|
|
141
|
+
this.loading = true;
|
|
142
|
+
try {
|
|
143
|
+
await this.args.onLoadOlder();
|
|
144
|
+
} finally {
|
|
145
|
+
this.loading = false;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
static {
|
|
149
|
+
setComponentTemplate(precompileTemplate("<section aria-label=\"Activity\" aria-busy={{if this.loading \"true\"}} data-test-dovetail-activity-feed data-state={{this.state}} style=\"display:flex;flex-direction:column;gap:0.5rem;color:var(--foreground)\" ...attributes>\n {{#if this.groups.length}}\n <ItemGroup @as=\"ol\" style=\"list-style:none;padding:0;margin:0\">\n {{#each this.groups key=\"key\" as |group|}}\n <Item @as=\"li\" @size=\"sm\" data-test-dovetail-activity-group as |i|>\n <i.Content>\n <i.Title data-test-dovetail-activity-text>{{this.text group}}</i.Title>\n <i.Description>\n <time datetime={{group.createdAt}}>{{formatTime group.createdAt}}</time>\n </i.Description>\n </i.Content>\n </Item>\n {{/each}}\n </ItemGroup>\n {{else}}\n <Empty as |e|>\n <e.Header>\n <e.Title>No activity yet.</e.Title>\n </e.Header>\n </Empty>\n {{/if}}\n {{#if @hasMore}}\n <Button @variant=\"outline\" @size=\"sm\" type=\"button\" disabled={{this.loading}} data-test-dovetail-load-older {{whenVisible this.loadOlder}} {{on \"click\" this.loadOlder}}>Load older</Button>\n {{/if}}\n</section>", {
|
|
150
|
+
strictMode: true,
|
|
151
|
+
scope: () => ({
|
|
152
|
+
ItemGroup,
|
|
153
|
+
Item,
|
|
154
|
+
formatTime,
|
|
155
|
+
Empty,
|
|
156
|
+
Button,
|
|
157
|
+
whenVisible,
|
|
158
|
+
on
|
|
159
|
+
})
|
|
160
|
+
}), this);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export { ActivityFeed as A, ActivityLog as a, describeGroup as d, groupActivity as g, notificationActivity as n };
|
|
165
|
+
//# sourceMappingURL=activity-feed-CO_8ZYII.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activity-feed-CO_8ZYII.js","sources":["../src/activity.ts","../src/when-visible.ts","../src/components/dovetail/activity-feed.gts"],"sourcesContent":["// Activity feeds (ADR 0009, ADR 0016). An activity event has the fields of a notification\n// (verb, actor, time, target), and the `ActivityEvent` of `@dovetail-ts/tiptap` fits it too. The\n// feed groups the events of one actor and one verb in a short time: \"Ana edited 3 notes\".\nimport { tracked } from '@glimmer/tracking'\nimport type { ResourceIdentifier } from '@dovetail-ts/protocol'\nimport type { NotificationItem } from './inbox.ts'\n\n/** One event of a feed. A Tiptap `ActivityEvent` and a notification both fit. */\nexport interface ActivityEvent {\n verb: string\n /** The user id, or the resource identifier of the actor. */\n actor: string | ResourceIdentifier\n /** An ISO 8601 date-time. */\n createdAt: string\n /** The record that the event changed. An event with no target matches each scope. */\n target?: ResourceIdentifier\n}\n\n/** Events of one actor and one verb, the newest first. */\nexport interface ActivityGroup {\n /** A stable key: the actor, the verb and the time of the newest event. */\n key: string\n /** The id of the actor. */\n actor: string\n verb: string\n /** The time of the newest event. */\n createdAt: string\n count: number\n events: ActivityEvent[]\n}\n\nexport interface GroupOptions {\n /** The time in milliseconds that one group can span. The default is 5 minutes. */\n window?: number\n /** Keeps only the events of this record, room, document or team. */\n scope?: ResourceIdentifier\n}\n\nconst actorId = (event: ActivityEvent) =>\n typeof event.actor === 'string' ? event.actor : event.actor.id\n\n/** The events of `events` in groups, the newest group first. */\nexport function groupActivity(\n events: readonly ActivityEvent[],\n { window = 5 * 60_000, scope }: GroupOptions = {},\n): ActivityGroup[] {\n const sorted = events\n .filter(e => !scope || !e.target || (e.target.type === scope.type && e.target.id === scope.id))\n .sort((a, b) => b.createdAt.localeCompare(a.createdAt))\n const groups: ActivityGroup[] = []\n for (const event of sorted) {\n const actor = actorId(event)\n const last = groups.at(-1)\n if (\n last &&\n last.actor === actor &&\n last.verb === event.verb &&\n Date.parse(last.createdAt) - Date.parse(event.createdAt) <= window\n ) {\n last.events.push(event)\n last.count++\n continue\n }\n groups.push({\n key: `${actor}:${event.verb}:${event.createdAt}`,\n actor,\n verb: event.verb,\n createdAt: event.createdAt,\n count: 1,\n events: [event],\n })\n }\n return groups\n}\n\n/** The text of a group: \"ana edited 3 notes\", \"ana edited note n1\" or \"ana commented 2 times\". */\nexport function describeGroup(\n group: ActivityGroup,\n actorName: (id: string) => string = id => id,\n): string {\n const who = `${actorName(group.actor)} ${group.verb}`\n const first = group.events[0]?.target\n if (group.count === 1) return first ? `${who} ${first.type} ${first.id}` : who\n const types = new Set(group.events.map(e => e.target?.type))\n const type = types.size === 1 ? [...types][0] : undefined\n return type ? `${who} ${group.count} ${type}s` : `${who} ${group.count} times`\n}\n\n/** The activity events of notifications. */\nexport function notificationActivity(items: readonly NotificationItem[]): ActivityEvent[] {\n return items.map(({ verb, actor, createdAt, target }) => ({ verb, actor, createdAt, target }))\n}\n\n/** A live list of events. Give `log.add` as the `onActivity` of the Tiptap extension. */\nexport class ActivityLog {\n @tracked events: readonly ActivityEvent[] = []\n\n /** Adds an event. */\n add = (event: ActivityEvent): void => {\n this.events = [...this.events, event]\n }\n}\n","// A modifier that calls a function each time its element becomes visible. The feed uses it to\n// load older items on scroll.\nimport { capabilities, setModifierManager } from '@ember/modifier'\nimport type { ModifierLike } from '@glint/template'\n\ninterface State {\n callback: () => void\n observer?: IntersectionObserver\n}\n\nclass WhenVisibleManager {\n capabilities = capabilities('3.22')\n\n createModifier(): State {\n return { callback: () => {} }\n }\n\n installModifier(state: State, element: Element, args: { positional: unknown[] }): void {\n state.callback = args.positional[0] as () => void\n state.observer = new IntersectionObserver(entries => {\n if (entries.some(entry => entry.isIntersecting)) state.callback()\n })\n state.observer.observe(element)\n }\n\n updateModifier(state: State, args: { positional: unknown[] }): void {\n state.callback = args.positional[0] as () => void\n }\n\n destroyModifier(state: State): void {\n state.observer?.disconnect()\n }\n}\n\n/** `{{whenVisible this.load}}`: calls `load` when the element becomes visible. */\nexport const whenVisible = setModifierManager(\n () => new WhenVisibleManager(),\n {},\n) as unknown as ModifierLike<{ Element: Element; Args: { Positional: [() => void] } }>\n","import Component from '@glimmer/component'\nimport { tracked } from '@glimmer/tracking'\nimport { on } from '@ember/modifier'\nimport { Button, Empty, Item, ItemGroup } from '@ember-joinery/ember'\nimport type { ResourceIdentifier } from '@dovetail-ts/protocol'\nimport { describeGroup, groupActivity } from '../../activity.ts'\nimport type { ActivityEvent, ActivityGroup } from '../../activity.ts'\nimport { formatTime } from '../../format.ts'\nimport { whenVisible } from '../../when-visible.ts'\n\nexport interface ActivityFeedSignature {\n Element: HTMLElement\n Args: {\n /** The events: notifications (`notificationActivity`), Tiptap events (`ActivityLog`) or any. */\n events: readonly ActivityEvent[]\n /** Shows only the events of this record, room, document or team. */\n scope?: ResourceIdentifier\n /** The time in milliseconds that one group can span. The default is 5 minutes. */\n window?: number\n /** The name of an actor id. The default is the id. */\n actorName?: (id: string) => string\n /** The text of a group. The default is `describeGroup`, as \"Ana edited 3 notes\". */\n describe?: (group: ActivityGroup) => string\n /** True when older events exist. */\n hasMore?: boolean\n /** Loads older events. The feed calls it when its end becomes visible, or on \"Load older\". */\n onLoadOlder?: () => Promise<void> | void\n }\n}\n\n/**\n * A live list of activity for a scope, in groups of one actor and one verb (\"Ana edited 3\n * notes\"), the newest first. Its `data-state` is `empty`, `loading` or `ready`.\n */\nexport default class ActivityFeed extends Component<ActivityFeedSignature> {\n @tracked loading = false\n\n get groups(): ActivityGroup[] {\n const { events, scope, window } = this.args\n return groupActivity(events, {\n ...(scope ? { scope } : {}),\n ...(window !== undefined ? { window } : {}),\n })\n }\n\n get state(): string {\n if (this.loading) return 'loading'\n return this.groups.length ? 'ready' : 'empty'\n }\n\n text = (group: ActivityGroup): string =>\n this.args.describe?.(group) ?? describeGroup(group, this.args.actorName)\n\n loadOlder = async (): Promise<void> => {\n if (this.loading || !this.args.hasMore || !this.args.onLoadOlder) return\n this.loading = true\n try {\n await this.args.onLoadOlder()\n } finally {\n this.loading = false\n }\n }\n\n <template>\n <section\n aria-label='Activity'\n aria-busy={{if this.loading 'true'}}\n data-test-dovetail-activity-feed\n data-state={{this.state}}\n style='display:flex;flex-direction:column;gap:0.5rem;color:var(--foreground)'\n ...attributes\n >\n {{#if this.groups.length}}\n <ItemGroup @as='ol' style='list-style:none;padding:0;margin:0'>\n {{#each this.groups key='key' as |group|}}\n <Item @as='li' @size='sm' data-test-dovetail-activity-group as |i|>\n <i.Content>\n <i.Title data-test-dovetail-activity-text>{{this.text group}}</i.Title>\n <i.Description>\n <time datetime={{group.createdAt}}>{{formatTime group.createdAt}}</time>\n </i.Description>\n </i.Content>\n </Item>\n {{/each}}\n </ItemGroup>\n {{else}}\n <Empty as |e|>\n <e.Header>\n <e.Title>No activity yet.</e.Title>\n </e.Header>\n </Empty>\n {{/if}}\n {{#if @hasMore}}\n <Button\n @variant='outline'\n @size='sm'\n type='button'\n disabled={{this.loading}}\n data-test-dovetail-load-older\n {{whenVisible this.loadOlder}}\n {{on 'click' this.loadOlder}}\n >Load older</Button>\n {{/if}}\n </section>\n </template>\n}\n"],"names":["actorId","event","actor","id","groupActivity","events","window","scope","sorted","filter","e","target","type","sort","a","b","createdAt","localeCompare","groups","last","at","verb","Date","parse","push","count","key","describeGroup","group","actorName","who","first","types","Set","map","size","undefined","notificationActivity","items","ActivityLog","g","prototype","tracked","i","add","WhenVisibleManager","capabilities","createModifier","callback","installModifier","state","element","args","positional","observer","IntersectionObserver","entries","some","entry","isIntersecting","observe","updateModifier","destroyModifier","disconnect","whenVisible","setModifierManager","ActivityFeed","Component","loading","length","text","describe","loadOlder","hasMore","onLoadOlder","setComponentTemplate","precompileTemplate","strictMode","ItemGroup","Item","formatTime","Empty","Button","on"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AAoCA,MAAMA,OAAO,GAAIC,KAAoB,IACnC,OAAOA,KAAK,CAACC,KAAK,KAAK,QAAQ,GAAGD,KAAK,CAACC,KAAK,GAAGD,KAAK,CAACC,KAAK,CAACC,EAAE;;AAEhE;AACO,SAASC,aAAaA,CAC3BC,MAAgC,EAChC;EAAEC,MAAM,GAAG,CAAC,GAAG,MAAM;AAAEC,EAAAA;AAAoB,CAAC,GAAG,EAAE,EAChC;EACjB,MAAMC,MAAM,GAAGH,MAAM,CAClBI,MAAM,CAACC,CAAC,IAAI,CAACH,KAAK,IAAI,CAACG,CAAC,CAACC,MAAM,IAAKD,CAAC,CAACC,MAAM,CAACC,IAAI,KAAKL,KAAK,CAACK,IAAI,IAAIF,CAAC,CAACC,MAAM,CAACR,EAAE,KAAKI,KAAK,CAACJ,EAAG,CAAC,CAC9FU,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKA,CAAC,CAACC,SAAS,CAACC,aAAa,CAACH,CAAC,CAACE,SAAS,CAAC,CAAC;EACzD,MAAME,MAAuB,GAAG,EAAE;AAClC,EAAA,KAAK,MAAMjB,KAAK,IAAIO,MAAM,EAAE;AAC1B,IAAA,MAAMN,KAAK,GAAGF,OAAO,CAACC,KAAK,CAAC;IAC5B,MAAMkB,IAAI,GAAGD,MAAM,CAACE,EAAE,CAAC,EAAE,CAAC;AAC1B,IAAA,IACED,IAAI,IACJA,IAAI,CAACjB,KAAK,KAAKA,KAAK,IACpBiB,IAAI,CAACE,IAAI,KAAKpB,KAAK,CAACoB,IAAI,IACxBC,IAAI,CAACC,KAAK,CAACJ,IAAI,CAACH,SAAS,CAAC,GAAGM,IAAI,CAACC,KAAK,CAACtB,KAAK,CAACe,SAAS,CAAC,IAAIV,MAAM,EAClE;AACAa,MAAAA,IAAI,CAACd,MAAM,CAACmB,I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,OAAO,SAAA;IACzB,OAAO,IAAI,CAAClD,MAAM,CAACmD,MAAM,GAAG,OAAA,GAAU,OAAA;AACxC,EAAA;EAEAC,IAAA,GAAQ1C,KAAO,IACb,IAAI,CAACwB,IAAI,CAACmB,QAAQ,GAAG3C,KAAA,CAAA,IAAUD,cAAcC,KAAA,EAAO,IAAI,CAACwB,IAAI,CAACvB,SAAS,CAAA;EAEzE2C,SAAA,GAAY,YAAsB;AAChC,IAAA,IAAI,IAAI,CAACJ,OAAO,IAAI,CAAC,IAAI,CAAChB,IAAI,CAACqB,OAAO,IAAI,CAAC,IAAI,CAACrB,IAAI,CAACsB,WAAW,EAAE;IAClE,IAAI,CAACN,OAAO,GAAG,IAAA;IACf,IAAI;AACF,MAAA,MAAM,IAAI,CAAChB,IAAI,CAACsB,WAAW,EAAA;AAC7B,IAAA,CAAA,SAAU;MACR,IAAI,CAACN,OAAO,GAAG,KAAA;AACjB,IAAA;EACF,CAAA;AAEA,EAAA;IAAAO,oBAAA,CAAAC,kBAAA,CAAA,0pCAAA,EAyCA;MAAAC,UAAA,EAAA,IAAA;AAAAtE,MAAAA,KAAA,EAAAA,OAAA;QAAAuE,SAAA;QAAAC,IAAA;QAAAC,UAAA;QAAAC,KAAA;QAAAC,MAAA;QAAAlB,WAAA;AAAAmB,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import '@glimmer/component';
|
|
2
|
+
import '@glimmer/tracking';
|
|
3
|
+
import '@ember/modifier';
|
|
4
|
+
import '@ember-joinery/ember';
|
|
5
|
+
export { A as default } from '../../activity-feed-CO_8ZYII.js';
|
|
6
|
+
import '../../format-CnYSfbv5.js';
|
|
7
|
+
import '@ember/template-compilation';
|
|
8
|
+
import '@ember/component';
|
|
9
|
+
import 'decorator-transforms/runtime';
|
|
10
|
+
//# sourceMappingURL=activity-feed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activity-feed.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { Badge, Button } from '@ember-joinery/ember';
|
|
3
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
4
|
+
import { setComponentTemplate } from '@ember/component';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The button of the inbox, with the unread count of the user. The count is the same in all
|
|
8
|
+
* tabs. Its `data-state` is `unread` or `empty`.
|
|
9
|
+
*/
|
|
10
|
+
class InboxButton extends Component {
|
|
11
|
+
get unread() {
|
|
12
|
+
return this.args.inbox.unread;
|
|
13
|
+
}
|
|
14
|
+
get badge() {
|
|
15
|
+
return this.unread > 99 ? '99+' : String(this.unread);
|
|
16
|
+
}
|
|
17
|
+
get label() {
|
|
18
|
+
return this.unread ? `Inbox, ${this.unread} unread` : 'Inbox, no unread notifications';
|
|
19
|
+
}
|
|
20
|
+
static {
|
|
21
|
+
setComponentTemplate(precompileTemplate("<Button @variant=\"ghost\" type=\"button\" aria-label={{this.label}} data-test-dovetail-inbox-button data-state={{if this.unread \"unread\" \"empty\"}} ...attributes>\n Inbox\n {{#if this.unread}}\n <Badge data-test-dovetail-unread-count aria-hidden=\"true\">{{this.badge}}</Badge>\n {{/if}}\n</Button>", {
|
|
22
|
+
strictMode: true,
|
|
23
|
+
scope: () => ({
|
|
24
|
+
Button,
|
|
25
|
+
Badge
|
|
26
|
+
})
|
|
27
|
+
}), this);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { InboxButton as default };
|
|
32
|
+
//# sourceMappingURL=inbox-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inbox-button.js","sources":["../../../src/components/dovetail/inbox-button.gts"],"sourcesContent":["import Component from '@glimmer/component'\nimport { Badge, Button } from '@ember-joinery/ember'\nimport type { NotificationInbox } from '../../inbox.ts'\n\nexport interface InboxButtonSignature {\n /** A Joinery `<Button>`. Give it `{{on \"click\"}}` to open the inbox. */\n Element: HTMLButtonElement | HTMLAnchorElement\n Args: {\n inbox: NotificationInbox\n }\n}\n\n/**\n * The button of the inbox, with the unread count of the user. The count is the same in all\n * tabs. Its `data-state` is `unread` or `empty`.\n */\nexport default class InboxButton extends Component<InboxButtonSignature> {\n get unread(): number {\n return this.args.inbox.unread\n }\n\n get badge(): string {\n return this.unread > 99 ? '99+' : String(this.unread)\n }\n\n get label(): string {\n return this.unread ? `Inbox, ${this.unread} unread` : 'Inbox, no unread notifications'\n }\n\n <template>\n <Button\n @variant='ghost'\n type='button'\n aria-label={{this.label}}\n data-test-dovetail-inbox-button\n data-state={{if this.unread 'unread' 'empty'}}\n ...attributes\n >\n Inbox\n {{#if this.unread}}\n <Badge data-test-dovetail-unread-count aria-hidden='true'>{{this.badge}}</Badge>\n {{/if}}\n </Button>\n </template>\n}\n"],"names":["InboxButton","Component","unread","args","inbox","badge","String","label","setComponentTemplate","precompileTemplate","strictMode","scope","Button","Badge"],"mappings":";;;;;AAYA;;;;AAIe,MAAMA,WAAA,SAAoBC,SAAA,CAAU;EACjD,IAAIC,MAAAA,GAAiB;AACnB,IAAA,OAAO,IAAI,CAACC,IAAI,CAACC,KAAK,CAACF,MAAM;AAC/B,EAAA;EAEA,IAAIG,KAAAA,GAAgB;AAClB,IAAA,OAAO,IAAI,CAACH,MAAM,GAAG,KAAK,KAAA,GAAQI,MAAA,CAAO,IAAI,CAACJ,MAAM,CAAA;AACtD,EAAA;EAEA,IAAIK,KAAAA,GAAgB;IAClB,OAAO,IAAI,CAACL,MAAM,GAAG,CAAA,OAAA,EAAU,IAAI,CAACA,MAAM,CAAA,OAAA,CAAS,GAAG,gCAAA;AACxD,EAAA;AAEA,EAAA;IAAAM,oBAAA,CAAAC,kBAAA,CAAA,sTAAA,EAcA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,MAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { on } from '@ember/modifier';
|
|
4
|
+
import { fn } from '@ember/helper';
|
|
5
|
+
import { Empty, Item, ItemGroup, Badge, Tabs, Alert, Button } from '@ember-joinery/ember';
|
|
6
|
+
import { f as formatTime } from '../../format-CnYSfbv5.js';
|
|
7
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
8
|
+
import { setComponentTemplate } from '@ember/component';
|
|
9
|
+
import { g, i } from 'decorator-transforms/runtime';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The inbox panel: the Unread and All tabs, mark read, mark all read, archive, load more, and
|
|
13
|
+
* the empty and error states. Its `data-state` is `loading`, `error`, `empty` or `ready`.
|
|
14
|
+
*/
|
|
15
|
+
class Inbox extends Component {
|
|
16
|
+
static {
|
|
17
|
+
g(this.prototype, "tab", [tracked], function () {
|
|
18
|
+
return this.args.tab ?? 'unread';
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
#tab = (i(this, "tab"), void 0);
|
|
22
|
+
get inbox() {
|
|
23
|
+
return this.args.inbox;
|
|
24
|
+
}
|
|
25
|
+
get items() {
|
|
26
|
+
return this.tab === 'unread' ? this.inbox.unreadItems : this.inbox.items;
|
|
27
|
+
}
|
|
28
|
+
get state() {
|
|
29
|
+
if (this.inbox.state === 'error') return 'error';
|
|
30
|
+
if (!this.inbox.loaded) return 'loading';
|
|
31
|
+
return this.items.length ? 'ready' : 'empty';
|
|
32
|
+
}
|
|
33
|
+
get busy() {
|
|
34
|
+
return this.inbox.state === 'loading';
|
|
35
|
+
}
|
|
36
|
+
get emptyText() {
|
|
37
|
+
return this.tab === 'unread' ? 'You are all caught up.' : 'No notifications yet.';
|
|
38
|
+
}
|
|
39
|
+
get status() {
|
|
40
|
+
return this.inbox.unread ? `${this.inbox.unread} unread notifications` : 'No unread notifications';
|
|
41
|
+
}
|
|
42
|
+
select = value => {
|
|
43
|
+
this.tab = value === 'all' ? 'all' : 'unread';
|
|
44
|
+
};
|
|
45
|
+
markRead = (item, event) => {
|
|
46
|
+
if (this.tab === 'unread') this.#keepFocus(event);
|
|
47
|
+
void this.inbox.markRead(item.id);
|
|
48
|
+
};
|
|
49
|
+
archive = (item, event) => {
|
|
50
|
+
this.#keepFocus(event);
|
|
51
|
+
void this.inbox.archive(item.id);
|
|
52
|
+
};
|
|
53
|
+
markAllRead = () => void this.inbox.markAllRead();
|
|
54
|
+
loadMore = () => void this.inbox.loadMore();
|
|
55
|
+
retry = () => void this.inbox.retry();
|
|
56
|
+
/**
|
|
57
|
+
* The row of the pressed button goes from the list. The focus goes first to the first button
|
|
58
|
+
* of the next row, or of the row before, or to the selected tab. Those stay in the page.
|
|
59
|
+
*/
|
|
60
|
+
#keepFocus(event) {
|
|
61
|
+
const row = event.currentTarget.closest('li');
|
|
62
|
+
const section = row?.closest('section');
|
|
63
|
+
if (!row || !section) return;
|
|
64
|
+
const next = row.nextElementSibling ?? row.previousElementSibling;
|
|
65
|
+
const target = next?.querySelector('button') ?? section.querySelector('[role="tab"][aria-selected="true"]');
|
|
66
|
+
if (target instanceof HTMLElement) target.focus();
|
|
67
|
+
}
|
|
68
|
+
static {
|
|
69
|
+
setComponentTemplate(precompileTemplate("<section aria-label=\"Inbox\" aria-busy={{if this.busy \"true\"}} data-test-dovetail-inbox data-state={{this.state}} style=\"display:flex;flex-direction:column;gap:0.75rem;color:var(--foreground)\" ...attributes>\n <header style=\"display:flex;align-items:center;justify-content:space-between;gap:0.5rem\">\n <h2 style=\"margin:0;font-size:1rem;font-weight:600\">Inbox</h2>\n <Button @variant=\"ghost\" @size=\"sm\" type=\"button\" disabled={{if this.inbox.unread false true}} data-test-dovetail-mark-all-read {{on \"click\" this.markAllRead}}>Mark all as read</Button>\n </header>\n <span role=\"status\" style=\"position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0\">{{this.status}}</span>\n\n {{#if this.inbox.error}}\n <Alert data-test-dovetail-inbox-error as |a|>\n <a.Title>The inbox could not reach the server.</a.Title>\n <a.Description>{{this.inbox.error}}</a.Description>\n <a.Action>\n <Button @size=\"xs\" @variant=\"outline\" type=\"button\" data-test-dovetail-retry {{on \"click\" this.retry}}>Retry</Button>\n </a.Action>\n </Alert>\n {{/if}}\n\n <Tabs @value={{this.tab}} @onValueChange={{this.select}} as |t|>\n <t.List>\n <t.Trigger @value=\"unread\">\n Unread\n {{#if this.inbox.unread}}\n <Badge @variant=\"secondary\">{{this.inbox.unread}}</Badge>\n {{/if}}\n </t.Trigger>\n <t.Trigger @value=\"all\">All</t.Trigger>\n </t.List>\n <t.Content @value={{this.tab}}>\n {{#if this.items.length}}\n <ItemGroup @as=\"ul\" aria-label=\"Notifications\" style=\"list-style:none;padding:0;margin:0\">\n {{#each this.items key=\"id\" as |item|}}\n <Item @as=\"li\" @size=\"sm\" @variant={{if item.read \"default\" \"muted\"}} data-test-dovetail-notification data-state={{if item.read \"read\" \"unread\"}} as |i|>\n <i.Content>\n <i.Title data-test-dovetail-notification-text>\n {{this.inbox.describe item}}\n </i.Title>\n <i.Description>\n {{#unless item.read}}<span style=\"position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0\">Unread. </span>{{/unless}}\n <time datetime={{item.createdAt}}>{{formatTime item.createdAt}}</time>\n </i.Description>\n </i.Content>\n <i.Actions>\n {{#unless item.read}}\n <Button @size=\"xs\" @variant=\"ghost\" type=\"button\" aria-label=\"Mark as read: {{this.inbox.describe item}}\" data-test-dovetail-mark-read {{on \"click\" (fn this.markRead item)}}>Mark as read</Button>\n {{/unless}}\n <Button @size=\"xs\" @variant=\"ghost\" type=\"button\" aria-label=\"Archive: {{this.inbox.describe item}}\" data-test-dovetail-archive {{on \"click\" (fn this.archive item)}}>Archive</Button>\n </i.Actions>\n </Item>\n {{/each}}\n </ItemGroup>\n {{else if this.inbox.loaded}}\n <Empty data-test-dovetail-inbox-empty as |e|>\n <e.Header>\n <e.Title>{{this.emptyText}}</e.Title>\n </e.Header>\n </Empty>\n {{/if}}\n {{#if this.inbox.hasMore}}\n <Button @variant=\"outline\" @size=\"sm\" type=\"button\" disabled={{this.busy}} data-test-dovetail-load-more {{on \"click\" this.loadMore}}>Load more</Button>\n {{/if}}\n </t.Content>\n </Tabs>\n</section>", {
|
|
70
|
+
strictMode: true,
|
|
71
|
+
scope: () => ({
|
|
72
|
+
Button,
|
|
73
|
+
on,
|
|
74
|
+
Alert,
|
|
75
|
+
Tabs,
|
|
76
|
+
Badge,
|
|
77
|
+
ItemGroup,
|
|
78
|
+
Item,
|
|
79
|
+
formatTime,
|
|
80
|
+
fn,
|
|
81
|
+
Empty
|
|
82
|
+
})
|
|
83
|
+
}), this);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { Inbox as default };
|
|
88
|
+
//# sourceMappingURL=inbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inbox.js","sources":["../../../src/components/dovetail/inbox.gts"],"sourcesContent":["import Component from '@glimmer/component'\nimport { tracked } from '@glimmer/tracking'\nimport { on } from '@ember/modifier'\nimport { fn } from '@ember/helper'\nimport { Alert, Badge, Button, Empty, Item, ItemGroup, Tabs } from '@ember-joinery/ember'\nimport type { NotificationInbox, NotificationItem } from '../../inbox.ts'\nimport { formatTime } from '../../format.ts'\n\n/** The tabs of the inbox. */\nexport type InboxTab = 'unread' | 'all'\n\nexport interface InboxSignature {\n Element: HTMLElement\n Args: {\n inbox: NotificationInbox\n /** The first tab. The default is `unread`. */\n tab?: InboxTab\n }\n}\n\n/**\n * The inbox panel: the Unread and All tabs, mark read, mark all read, archive, load more, and\n * the empty and error states. Its `data-state` is `loading`, `error`, `empty` or `ready`.\n */\nexport default class Inbox extends Component<InboxSignature> {\n @tracked tab: InboxTab = this.args.tab ?? 'unread'\n\n get inbox(): NotificationInbox {\n return this.args.inbox\n }\n\n get items(): NotificationItem[] {\n return this.tab === 'unread' ? this.inbox.unreadItems : this.inbox.items\n }\n\n get state(): string {\n if (this.inbox.state === 'error') return 'error'\n if (!this.inbox.loaded) return 'loading'\n return this.items.length ? 'ready' : 'empty'\n }\n\n get busy(): boolean {\n return this.inbox.state === 'loading'\n }\n\n get emptyText(): string {\n return this.tab === 'unread' ? 'You are all caught up.' : 'No notifications yet.'\n }\n\n get status(): string {\n return this.inbox.unread\n ? `${this.inbox.unread} unread notifications`\n : 'No unread notifications'\n }\n\n select = (value: string): void => {\n this.tab = value === 'all' ? 'all' : 'unread'\n }\n\n markRead = (item: NotificationItem, event: Event): void => {\n if (this.tab === 'unread') this.#keepFocus(event)\n void this.inbox.markRead(item.id)\n }\n\n archive = (item: NotificationItem, event: Event): void => {\n this.#keepFocus(event)\n void this.inbox.archive(item.id)\n }\n markAllRead = (): void => void this.inbox.markAllRead()\n loadMore = (): void => void this.inbox.loadMore()\n retry = (): void => void this.inbox.retry()\n\n /**\n * The row of the pressed button goes from the list. The focus goes first to the first button\n * of the next row, or of the row before, or to the selected tab. Those stay in the page.\n */\n #keepFocus(event: Event): void {\n const row = (event.currentTarget as HTMLElement).closest('li')\n const section = row?.closest('section')\n if (!row || !section) return\n const next = row.nextElementSibling ?? row.previousElementSibling\n const target =\n next?.querySelector('button') ?? section.querySelector('[role=\"tab\"][aria-selected=\"true\"]')\n if (target instanceof HTMLElement) target.focus()\n }\n\n <template>\n <section\n aria-label='Inbox'\n aria-busy={{if this.busy 'true'}}\n data-test-dovetail-inbox\n data-state={{this.state}}\n style='display:flex;flex-direction:column;gap:0.75rem;color:var(--foreground)'\n ...attributes\n >\n <header style='display:flex;align-items:center;justify-content:space-between;gap:0.5rem'>\n <h2 style='margin:0;font-size:1rem;font-weight:600'>Inbox</h2>\n <Button\n @variant='ghost'\n @size='sm'\n type='button'\n disabled={{if this.inbox.unread false true}}\n data-test-dovetail-mark-all-read\n {{on 'click' this.markAllRead}}\n >Mark all as read</Button>\n </header>\n <span\n role='status'\n style='position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0'\n >{{this.status}}</span>\n\n {{#if this.inbox.error}}\n <Alert data-test-dovetail-inbox-error as |a|>\n <a.Title>The inbox could not reach the server.</a.Title>\n <a.Description>{{this.inbox.error}}</a.Description>\n <a.Action>\n <Button\n @size='xs'\n @variant='outline'\n type='button'\n data-test-dovetail-retry\n {{on 'click' this.retry}}\n >Retry</Button>\n </a.Action>\n </Alert>\n {{/if}}\n\n <Tabs @value={{this.tab}} @onValueChange={{this.select}} as |t|>\n <t.List>\n <t.Trigger @value='unread'>\n Unread\n {{#if this.inbox.unread}}\n <Badge @variant='secondary'>{{this.inbox.unread}}</Badge>\n {{/if}}\n </t.Trigger>\n <t.Trigger @value='all'>All</t.Trigger>\n </t.List>\n <t.Content @value={{this.tab}}>\n {{#if this.items.length}}\n <ItemGroup\n @as='ul'\n aria-label='Notifications'\n style='list-style:none;padding:0;margin:0'\n >\n {{#each this.items key='id' as |item|}}\n <Item\n @as='li'\n @size='sm'\n @variant={{if item.read 'default' 'muted'}}\n data-test-dovetail-notification\n data-state={{if item.read 'read' 'unread'}}\n as |i|\n >\n <i.Content>\n <i.Title data-test-dovetail-notification-text>\n {{this.inbox.describe item}}\n </i.Title>\n <i.Description>\n {{#unless item.read}}<span\n style='position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0'\n >Unread. </span>{{/unless}}\n <time datetime={{item.createdAt}}>{{formatTime item.createdAt}}</time>\n </i.Description>\n </i.Content>\n <i.Actions>\n {{#unless item.read}}\n <Button\n @size='xs'\n @variant='ghost'\n type='button'\n aria-label='Mark as read: {{this.inbox.describe item}}'\n data-test-dovetail-mark-read\n {{on 'click' (fn this.markRead item)}}\n >Mark as read</Button>\n {{/unless}}\n <Button\n @size='xs'\n @variant='ghost'\n type='button'\n aria-label='Archive: {{this.inbox.describe item}}'\n data-test-dovetail-archive\n {{on 'click' (fn this.archive item)}}\n >Archive</Button>\n </i.Actions>\n </Item>\n {{/each}}\n </ItemGroup>\n {{else if this.inbox.loaded}}\n <Empty data-test-dovetail-inbox-empty as |e|>\n <e.Header>\n <e.Title>{{this.emptyText}}</e.Title>\n </e.Header>\n </Empty>\n {{/if}}\n {{#if this.inbox.hasMore}}\n <Button\n @variant='outline'\n @size='sm'\n type='button'\n disabled={{this.busy}}\n data-test-dovetail-load-more\n {{on 'click' this.loadMore}}\n >Load more</Button>\n {{/if}}\n </t.Content>\n </Tabs>\n </section>\n </template>\n}\n"],"names":["Inbox","Component","g","prototype","tracked","args","tab","i","inbox","items","unreadItems","state","loaded","length","busy","emptyText","status","unread","select","value","markRead","item","event","id","archive","markAllRead","loadMore","retry","#keepFocus","row","currentTarget","closest","section","next","nextElementSibling","previousElementSibling","target","querySelector","HTMLElement","focus","setComponentTemplate","precompileTemplate","strictMode","scope","Button","on","Alert","Tabs","Badge","ItemGroup","Item","formatTime","fn","Empty"],"mappings":";;;;;;;;;;AAoBA;;;;AAIe,MAAMA,KAAA,SAAcC,SAAA,CAAU;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,KAAA,EAAA,CAC1CC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAAwB,IAAI,CAACC,IAAI,CAACC,GAAG,IAAI,QAAA;AAAA,IAAA,CAAA,CAAA;AAAA;EAAA,IAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,KAAA,CAAA,EAAA,MAAA;EAE1C,IAAIC,QAA2B;AAC7B,IAAA,OAAO,IAAI,CAACH,IAAI,CAACG,KAAK;AACxB,EAAA;EAEA,IAAIC,QAA4B;AAC9B,IAAA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AE,CAAA;EACjC,CAAA;EACAE,WAAA,GAAcA,MAAY,KAAK,IAAI,CAACjB,KAAK,CAACiB,WAAW,EAAA;EACrDC,QAAA,GAAWA,MAAY,KAAK,IAAI,CAAClB,KAAK,CAACkB,QAAQ,EAAA;EAC/CC,KAAA,GAAQA,MAAY,KAAK,IAAI,CAACnB,KAAK,CAACmB,KAAK,EAAA;AAEzC;;;AAGC;EACD,UAAUC,CAACN,KAAY,EAAO;IAC5B,MAAMO,GAAA,GAAOP,KAAA,CAAMQ,aAAa,CAAiBC,OAAO,CAAC,IAAA,CAAA;AACzD,IAAA,MAAMC,OAAA,GAAUH,KAAKE,OAAA,CAAQ,SAAA,CAAA;AAC7B,IAAA,IAAI,CAACF,GAAA,IAAO,CAACG,OAAA,EAAS;IACtB,MAAMC,IAAA,GAAOJ,GAAA,CAAIK,kBAAkB,IAAIL,IAAIM,sBAAsB;AACjE,IAAA,MAAMC,SACJH,IAAA,EAAMI,aAAA,CAAc,QAAA,CAAA,IAAaL,OAAA,CAAQK,aAAa,CAAC,oCAAA,CAAA;IACzD,IAAID,MAAA,YAAkBE,WAAA,EAAaF,MAAA,CAAOG,KAAK,EAAA;AACjD,EAAA;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,mgHAAA,EAyHA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,MAAA;QAAAC,EAAA;QAAAC,KAAA;QAAAC,IAAA;QAAAC,KAAA;QAAAC,SAAA;QAAAC,IAAA;QAAAC,UAAA;QAAAC,EAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import '@glimmer/component';
|
|
2
|
+
import '@ember/destroyable';
|
|
3
|
+
import '@ember-joinery/ember';
|
|
4
|
+
export { T as default } from '../../toast-bridge-CJ7iWI9Q.js';
|
|
5
|
+
import '@ember/template-compilation';
|
|
6
|
+
import '@ember/component';
|
|
7
|
+
//# sourceMappingURL=toast-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast-bridge.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The date and time of an ISO 8601 string, in the locale of the browser. */
|
|
2
|
+
const formatTime = iso => new Intl.DateTimeFormat(undefined, {
|
|
3
|
+
dateStyle: 'medium',
|
|
4
|
+
timeStyle: 'short'
|
|
5
|
+
}).format(new Date(iso));
|
|
6
|
+
|
|
7
|
+
export { formatTime as f };
|
|
8
|
+
//# sourceMappingURL=format-CnYSfbv5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-CnYSfbv5.js","sources":["../src/format.ts"],"sourcesContent":["/** The date and time of an ISO 8601 string, in the locale of the browser. */\nexport const formatTime = (iso: string): string =>\n new Intl.DateTimeFormat(undefined, { dateStyle: 'medium', timeStyle: 'short' }).format(\n new Date(iso),\n )\n"],"names":["formatTime","iso","Intl","DateTimeFormat","undefined","dateStyle","timeStyle","format","Date"],"mappings":"AAAA;AACO,MAAMA,UAAU,GAAIC,GAAW,IACpC,IAAIC,IAAI,CAACC,cAAc,CAACC,SAAS,EAAE;AAAEC,EAAAA,SAAS,EAAE,QAAQ;AAAEC,EAAAA,SAAS,EAAE;AAAQ,CAAC,CAAC,CAACC,MAAM,CACpF,IAAIC,IAAI,CAACP,GAAG,CACd;;"}
|