@molecule/app-timeline 1.0.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.
package/LICENSE ADDED
@@ -0,0 +1,115 @@
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
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship.
43
+
44
+ "Contribution" shall mean any work of authorship, including the
45
+ original version of the Work and any modifications or additions
46
+ to that Work, that is intentionally submitted to the Licensor for
47
+ inclusion in the Work by the copyright owner or by an individual or
48
+ Legal Entity authorized to submit on behalf of the copyright owner.
49
+
50
+ "Contributor" shall mean Licensor and any individual or Legal Entity
51
+ on behalf of whom a Contribution has been received by the Licensor and
52
+ subsequently incorporated within the Work.
53
+
54
+ 2. Grant of Copyright License. Subject to the terms and conditions of
55
+ this License, each Contributor hereby grants to You a perpetual,
56
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
57
+ copyright license to reproduce, prepare Derivative Works of,
58
+ publicly display, publicly perform, sublicense, and distribute the
59
+ Work and such Derivative Works in Source or Object form.
60
+
61
+ 3. Grant of Patent License. Subject to the terms and conditions of
62
+ this License, each Contributor hereby grants to You a perpetual,
63
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
64
+ patent license to make, have made, use, offer to sell, sell, import,
65
+ and otherwise transfer the Work.
66
+
67
+ 4. Redistribution. You may reproduce and distribute copies of the
68
+ Work or Derivative Works thereof in any medium, with or without
69
+ modifications, and in Source or Object form, provided that You
70
+ meet the following conditions:
71
+
72
+ (a) You must give any other recipients of the Work or
73
+ Derivative Works a copy of this License; and
74
+
75
+ (b) You must cause any modified files to carry prominent notices
76
+ stating that You changed the files; and
77
+
78
+ (c) You must retain, in the Source form of any Derivative Works
79
+ that You distribute, all copyright, patent, trademark, and
80
+ attribution notices from the Source form of the Work,
81
+ excluding those notices that do not pertain to any part of
82
+ the Derivative Works; and
83
+
84
+ (d) If the Work includes a "NOTICE" text file as part of its
85
+ distribution, then any Derivative Works that You distribute must
86
+ include a readable copy of the attribution notices contained
87
+ within such NOTICE file.
88
+
89
+ 5. Submission of Contributions.
90
+
91
+ 6. Trademarks. This License does not grant permission to use the trade
92
+ names, trademarks, service marks, or product names of the Licensor.
93
+
94
+ 7. Disclaimer of Warranty. Unless required by applicable law or
95
+ agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
96
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
97
+
98
+ 8. Limitation of Liability. In no event and under no legal theory shall
99
+ any Contributor be liable to You for damages.
100
+
101
+ 9. Accepting Warranty or Additional Liability.
102
+
103
+ Copyright 2026 Molecule Dev, Inc.
104
+
105
+ Licensed under the Apache License, Version 2.0 (the "License");
106
+ you may not use this file except in compliance with the License.
107
+ You may obtain a copy of the License at
108
+
109
+ http://www.apache.org/licenses/LICENSE-2.0
110
+
111
+ Unless required by applicable law or agreed to in writing, software
112
+ distributed under the License is distributed on an "AS IS" BASIS,
113
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
114
+ See the License for the specific language governing permissions and
115
+ limitations under the License.
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Timeline core interface for molecule.dev.
3
+ *
4
+ * Provides a standardized API for rendering timeline and activity log
5
+ * UI components. Bond a provider (e.g. `@molecule/app-timeline-default`)
6
+ * to supply the concrete implementation.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { requireProvider, setProvider } from '@molecule/app-timeline'
11
+ * import { provider } from '@molecule/app-timeline-default'
12
+ *
13
+ * setProvider(provider) // once, at startup (bonds.ts)
14
+ *
15
+ * const timeline = requireProvider().createTimeline({
16
+ * items: [{ id: '1', date: new Date(), title: 'Created project' }],
17
+ * })
18
+ * timeline.addItem({ id: '2', date: new Date(), title: 'Invited teammate' })
19
+ * ```
20
+ *
21
+ * @remarks
22
+ * - **The instance is HEADLESS state, not UI.** `createTimeline` returns item
23
+ * management (`setItems`/`addItem`/`removeItem`/`getItems`) — nothing appears
24
+ * on screen. The app renders the entries itself, styling via `getClassMap()`
25
+ * from `@molecule/app-ui` and putting every label through
26
+ * `t('key', values, { defaultValue })`.
27
+ * - **Wire it with THIS package's `setProvider()` or `bond('timeline', …)`.**
28
+ * `setProvider()` delegates into the shared `@molecule/app-bond` registry, so
29
+ * both write the same slot; {@link requireProvider} throws until one has run.
30
+ * - `TimelineItem.date` is a `Date` — format it for display with the app's
31
+ * locale-aware formatting, never a hardcoded locale string.
32
+ * - Call `destroy()` when the owning screen unmounts.
33
+ *
34
+ * @e2e
35
+ * Integration checklist — drive the real timeline UI (live preview, no mocks),
36
+ * adapt each item to this app's actual timeline/activity screens, and check
37
+ * every box off one by one. A box you can't check is an integration bug to fix
38
+ * — not a skip:
39
+ * - [ ] The timeline renders its entries in the correct chronological order per
40
+ * the app's config (newest-first or oldest-first) — the on-screen order
41
+ * matches the item `date` timestamps, NOT insertion order (`getItems()`
42
+ * preserves insertion order; the app sorts by `date` for display).
43
+ * - [ ] Each rendered entry shows its real data: the locale-formatted `date`
44
+ * (never a raw `Date` string), the `title`, and — when set — the
45
+ * `description`, `icon`, and dot/marker `color`.
46
+ * - [ ] With `alternate` on, consecutive entries sit on opposite sides of the
47
+ * rail; with it off, every entry sits on the same side.
48
+ * - [ ] Clicking an entry fires `onItemClick` with THAT item — the wired action
49
+ * (navigate/expand/select) happens for the clicked entry, not a neighbour.
50
+ * - [ ] If the app groups entries (by day or type), each entry sits under the
51
+ * correct group header, and an entry dated in a different bucket renders under
52
+ * the right header.
53
+ * - [ ] `addItem()` makes the new event appear in its correct position by `date`
54
+ * timestamp (not merely appended last), and `removeItem(id)` removes exactly
55
+ * that one entry.
56
+ * - [ ] If the app loads older entries (load-more/pagination), they append via
57
+ * `setItems` with no duplication — every rendered `id` stays unique.
58
+ * - [ ] An empty timeline (no items) renders a defined empty state, not a
59
+ * blank/broken layout; adding the first item replaces the empty state with the
60
+ * entry.
61
+ *
62
+ * @module
63
+ */
64
+ export * from './provider.js';
65
+ export * from './types.js';
66
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAEH,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Timeline core interface for molecule.dev.
3
+ *
4
+ * Provides a standardized API for rendering timeline and activity log
5
+ * UI components. Bond a provider (e.g. `@molecule/app-timeline-default`)
6
+ * to supply the concrete implementation.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { requireProvider, setProvider } from '@molecule/app-timeline'
11
+ * import { provider } from '@molecule/app-timeline-default'
12
+ *
13
+ * setProvider(provider) // once, at startup (bonds.ts)
14
+ *
15
+ * const timeline = requireProvider().createTimeline({
16
+ * items: [{ id: '1', date: new Date(), title: 'Created project' }],
17
+ * })
18
+ * timeline.addItem({ id: '2', date: new Date(), title: 'Invited teammate' })
19
+ * ```
20
+ *
21
+ * @remarks
22
+ * - **The instance is HEADLESS state, not UI.** `createTimeline` returns item
23
+ * management (`setItems`/`addItem`/`removeItem`/`getItems`) — nothing appears
24
+ * on screen. The app renders the entries itself, styling via `getClassMap()`
25
+ * from `@molecule/app-ui` and putting every label through
26
+ * `t('key', values, { defaultValue })`.
27
+ * - **Wire it with THIS package's `setProvider()` or `bond('timeline', …)`.**
28
+ * `setProvider()` delegates into the shared `@molecule/app-bond` registry, so
29
+ * both write the same slot; {@link requireProvider} throws until one has run.
30
+ * - `TimelineItem.date` is a `Date` — format it for display with the app's
31
+ * locale-aware formatting, never a hardcoded locale string.
32
+ * - Call `destroy()` when the owning screen unmounts.
33
+ *
34
+ * @e2e
35
+ * Integration checklist — drive the real timeline UI (live preview, no mocks),
36
+ * adapt each item to this app's actual timeline/activity screens, and check
37
+ * every box off one by one. A box you can't check is an integration bug to fix
38
+ * — not a skip:
39
+ * - [ ] The timeline renders its entries in the correct chronological order per
40
+ * the app's config (newest-first or oldest-first) — the on-screen order
41
+ * matches the item `date` timestamps, NOT insertion order (`getItems()`
42
+ * preserves insertion order; the app sorts by `date` for display).
43
+ * - [ ] Each rendered entry shows its real data: the locale-formatted `date`
44
+ * (never a raw `Date` string), the `title`, and — when set — the
45
+ * `description`, `icon`, and dot/marker `color`.
46
+ * - [ ] With `alternate` on, consecutive entries sit on opposite sides of the
47
+ * rail; with it off, every entry sits on the same side.
48
+ * - [ ] Clicking an entry fires `onItemClick` with THAT item — the wired action
49
+ * (navigate/expand/select) happens for the clicked entry, not a neighbour.
50
+ * - [ ] If the app groups entries (by day or type), each entry sits under the
51
+ * correct group header, and an entry dated in a different bucket renders under
52
+ * the right header.
53
+ * - [ ] `addItem()` makes the new event appear in its correct position by `date`
54
+ * timestamp (not merely appended last), and `removeItem(id)` removes exactly
55
+ * that one entry.
56
+ * - [ ] If the app loads older entries (load-more/pagination), they append via
57
+ * `setItems` with no duplication — every rendered `id` stays unique.
58
+ * - [ ] An empty timeline (no items) renders a defined empty state, not a
59
+ * blank/broken layout; adding the first item replaces the empty state with the
60
+ * entry.
61
+ *
62
+ * @module
63
+ */
64
+ export * from './provider.js';
65
+ export * from './types.js';
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Timeline provider wiring, backed by the shared `@molecule/app-bond` registry.
3
+ *
4
+ * Bond packages call `setProvider()` during setup; it delegates to
5
+ * `bond('timeline', provider)`, so wiring via this package's `setProvider()` and
6
+ * via `bond('timeline', …)` write the SAME registry slot — use either.
7
+ * Application code calls `getProvider()` / `requireProvider()` at runtime.
8
+ *
9
+ * @module
10
+ */
11
+ import type { TimelineProvider } from './types.js';
12
+ /**
13
+ * Registers a timeline provider as the active singleton.
14
+ *
15
+ * @param provider - The timeline provider implementation to bond.
16
+ */
17
+ export declare function setProvider(provider: TimelineProvider): void;
18
+ /**
19
+ * Retrieves the bonded timeline provider, or `null` if none is bonded.
20
+ *
21
+ * @returns The active timeline provider, or `null`.
22
+ */
23
+ export declare function getProvider(): TimelineProvider | null;
24
+ /**
25
+ * Checks whether a timeline provider has been bonded.
26
+ *
27
+ * @returns `true` if a timeline provider is available.
28
+ */
29
+ export declare function hasProvider(): boolean;
30
+ /**
31
+ * Retrieves the bonded timeline provider, throwing if none is configured.
32
+ *
33
+ * @returns The active timeline provider.
34
+ * @throws {Error} if no provider has been bonded.
35
+ */
36
+ export declare function requireProvider(): TimelineProvider;
37
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAIlD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,gBAAgB,GAAG,IAAI,CAErD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,IAAI,gBAAgB,CAKlD"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Timeline provider wiring, backed by the shared `@molecule/app-bond` registry.
3
+ *
4
+ * Bond packages call `setProvider()` during setup; it delegates to
5
+ * `bond('timeline', provider)`, so wiring via this package's `setProvider()` and
6
+ * via `bond('timeline', …)` write the SAME registry slot — use either.
7
+ * Application code calls `getProvider()` / `requireProvider()` at runtime.
8
+ *
9
+ * @module
10
+ */
11
+ import { bond, get, isBonded, requireSingleton } from '@molecule/app-bond';
12
+ const BOND_TYPE = 'timeline';
13
+ /**
14
+ * Registers a timeline provider as the active singleton.
15
+ *
16
+ * @param provider - The timeline provider implementation to bond.
17
+ */
18
+ export function setProvider(provider) {
19
+ bond(BOND_TYPE, provider);
20
+ }
21
+ /**
22
+ * Retrieves the bonded timeline provider, or `null` if none is bonded.
23
+ *
24
+ * @returns The active timeline provider, or `null`.
25
+ */
26
+ export function getProvider() {
27
+ return get(BOND_TYPE) ?? null;
28
+ }
29
+ /**
30
+ * Checks whether a timeline provider has been bonded.
31
+ *
32
+ * @returns `true` if a timeline provider is available.
33
+ */
34
+ export function hasProvider() {
35
+ return isBonded(BOND_TYPE);
36
+ }
37
+ /**
38
+ * Retrieves the bonded timeline provider, throwing if none is configured.
39
+ *
40
+ * @returns The active timeline provider.
41
+ * @throws {Error} if no provider has been bonded.
42
+ */
43
+ export function requireProvider() {
44
+ if (!isBonded(BOND_TYPE)) {
45
+ throw new Error('Timeline provider not configured. Bond a timeline provider first.');
46
+ }
47
+ return requireSingleton(BOND_TYPE);
48
+ }
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Timeline types for molecule.dev.
3
+ *
4
+ * Defines the provider interface and data types for rendering
5
+ * timeline / activity log UI components.
6
+ *
7
+ * @module
8
+ */
9
+ /**
10
+ * A single item in a timeline.
11
+ */
12
+ export interface TimelineItem {
13
+ /** Unique identifier for the item. */
14
+ id: string;
15
+ /** Date/time the event occurred. */
16
+ date: Date;
17
+ /** Title of the timeline entry. */
18
+ title: string;
19
+ /** Optional description or body text. */
20
+ description?: string;
21
+ /** Optional icon identifier. */
22
+ icon?: string;
23
+ /** Optional color for the timeline dot/marker. */
24
+ color?: string;
25
+ /** Arbitrary metadata attached to the item. */
26
+ metadata?: Record<string, unknown>;
27
+ }
28
+ /**
29
+ * Configuration options for creating a timeline.
30
+ */
31
+ export interface TimelineOptions {
32
+ /** Items to display in the timeline. */
33
+ items: TimelineItem[];
34
+ /** Whether to alternate items on opposite sides. Defaults to `false`. */
35
+ alternate?: boolean;
36
+ /** Callback when a timeline item is clicked. */
37
+ onItemClick?: (item: TimelineItem) => void;
38
+ }
39
+ /**
40
+ * A live timeline instance returned by the provider.
41
+ */
42
+ export interface TimelineInstance {
43
+ /**
44
+ * Updates the timeline items.
45
+ *
46
+ * @param items - The new set of timeline items.
47
+ */
48
+ setItems(items: TimelineItem[]): void;
49
+ /**
50
+ * Appends a single item to the timeline.
51
+ *
52
+ * @param item - The item to add.
53
+ */
54
+ addItem(item: TimelineItem): void;
55
+ /**
56
+ * Removes an item by its ID.
57
+ *
58
+ * @param id - The ID of the item to remove.
59
+ * @returns `true` if the item was found and removed.
60
+ */
61
+ removeItem(id: string): boolean;
62
+ /**
63
+ * Returns all current timeline items.
64
+ *
65
+ * @returns Array of timeline items.
66
+ */
67
+ getItems(): TimelineItem[];
68
+ /**
69
+ * Destroys the timeline instance and cleans up resources.
70
+ */
71
+ destroy(): void;
72
+ }
73
+ /**
74
+ * Timeline provider interface.
75
+ *
76
+ * All timeline providers must implement this interface to create
77
+ * and manage timeline / activity log UI.
78
+ */
79
+ export interface TimelineProvider {
80
+ /** Provider name identifier. */
81
+ readonly name: string;
82
+ /**
83
+ * Creates a new timeline instance.
84
+ *
85
+ * @param options - Configuration for the timeline.
86
+ * @returns A timeline instance for managing the timeline.
87
+ */
88
+ createTimeline(options: TimelineOptions): TimelineInstance;
89
+ }
90
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,sCAAsC;IACtC,EAAE,EAAE,MAAM,CAAA;IAEV,oCAAoC;IACpC,IAAI,EAAE,IAAI,CAAA;IAEV,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAA;IAEb,yCAAyC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB,gCAAgC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,wCAAwC;IACxC,KAAK,EAAE,YAAY,EAAE,CAAA;IAErB,yEAAyE;IACzE,SAAS,CAAC,EAAE,OAAO,CAAA;IAEnB,gDAAgD;IAChD,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAA;CAC3C;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,IAAI,CAAA;IAErC;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAAA;IAEjC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;IAE/B;;;;OAIG;IACH,QAAQ,IAAI,YAAY,EAAE,CAAA;IAE1B;;OAEG;IACH,OAAO,IAAI,IAAI,CAAA;CAChB;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,gCAAgC;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAErB;;;;;OAKG;IACH,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,gBAAgB,CAAA;CAC3D"}
package/dist/types.js ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Timeline types for molecule.dev.
3
+ *
4
+ * Defines the provider interface and data types for rendering
5
+ * timeline / activity log UI components.
6
+ *
7
+ * @module
8
+ */
9
+ export {};
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@molecule/app-timeline",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "test": "vitest run",
11
+ "test:watch": "vitest"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "keywords": [
23
+ "molecule",
24
+ "timeline"
25
+ ],
26
+ "license": "Apache-2.0",
27
+ "peerDependencies": {
28
+ "@molecule/app-bond": "^1.0.0"
29
+ },
30
+ "devDependencies": {
31
+ "@molecule/app-bond": "1.0.0",
32
+ "@types/node": "26.1.2",
33
+ "typescript": "6.0.3",
34
+ "vitest": "4.1.10"
35
+ }
36
+ }