tsgrid-ui 2.7.1 → 2.10.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/CHANGELOG.md +217 -0
- package/dist/base.d.ts +148 -0
- package/dist/base.es6.js +11 -0
- package/dist/base.es6.js.map +1 -0
- package/dist/chunks/chunk-3NYH6545.js +2423 -0
- package/dist/chunks/chunk-3NYH6545.js.map +1 -0
- package/dist/chunks/chunk-6MOFFUV2.js +2305 -0
- package/dist/chunks/chunk-6MOFFUV2.js.map +1 -0
- package/dist/chunks/chunk-6UCGFWIQ.js +865 -0
- package/dist/chunks/chunk-6UCGFWIQ.js.map +1 -0
- package/dist/chunks/chunk-DXZJHS4M.js +1283 -0
- package/dist/chunks/chunk-DXZJHS4M.js.map +1 -0
- package/dist/chunks/chunk-DZSFZLV6.js +1638 -0
- package/dist/chunks/chunk-DZSFZLV6.js.map +1 -0
- package/dist/chunks/chunk-EQK6JAHT.js +33 -0
- package/dist/chunks/chunk-EQK6JAHT.js.map +1 -0
- package/dist/chunks/chunk-FAIRNXQR.js +3020 -0
- package/dist/chunks/chunk-FAIRNXQR.js.map +1 -0
- package/dist/chunks/chunk-GZFWK4LZ.js +677 -0
- package/dist/chunks/chunk-GZFWK4LZ.js.map +1 -0
- package/dist/chunks/chunk-IYF3Q7GX.js +127 -0
- package/dist/chunks/chunk-IYF3Q7GX.js.map +1 -0
- package/dist/chunks/chunk-KLJ35UAH.js +1795 -0
- package/dist/chunks/chunk-KLJ35UAH.js.map +1 -0
- package/dist/chunks/chunk-LUSNRF73.js +1212 -0
- package/dist/chunks/chunk-LUSNRF73.js.map +1 -0
- package/dist/chunks/chunk-N3GASHTI.js +1127 -0
- package/dist/chunks/chunk-N3GASHTI.js.map +1 -0
- package/dist/field.d.ts +329 -0
- package/dist/field.es6.js +12 -0
- package/dist/field.es6.js.map +1 -0
- package/dist/form.d.ts +162 -0
- package/dist/form.es6.js +15 -0
- package/dist/form.es6.js.map +1 -0
- package/dist/layout.d.ts +108 -0
- package/dist/layout.es6.js +14 -0
- package/dist/layout.es6.js.map +1 -0
- package/dist/locale.d.ts +30 -0
- package/dist/locale.es6.js +7 -0
- package/dist/locale.es6.js.map +1 -0
- package/dist/popup.d.ts +97 -0
- package/dist/popup.es6.js +21 -0
- package/dist/popup.es6.js.map +1 -0
- package/dist/query-CKGg5Ugv.d.ts +81 -0
- package/dist/sidebar.d.ts +138 -0
- package/dist/sidebar.es6.js +12 -0
- package/dist/sidebar.es6.js.map +1 -0
- package/dist/tabs.d.ts +63 -0
- package/dist/tabs.es6.js +12 -0
- package/dist/tabs.es6.js.map +1 -0
- package/dist/toolbar.d.ts +97 -0
- package/dist/toolbar.es6.js +12 -0
- package/dist/toolbar.es6.js.map +1 -0
- package/dist/tooltip.d.ts +330 -0
- package/dist/tooltip.es6.js +21 -0
- package/dist/tooltip.es6.js.map +1 -0
- package/dist/tsgrid-ui.css +2 -2
- package/dist/tsgrid-ui.d.ts +16 -2004
- package/dist/tsgrid-ui.es6.js +7751 -23830
- package/dist/tsgrid-ui.es6.js.map +1 -1
- package/dist/tsgrid-ui.es6.min.js +37 -37
- package/dist/tsgrid-ui.js +150 -22
- package/dist/tsgrid-ui.min.css +2 -2
- package/dist/tsgrid-ui.min.js +39 -39
- package/dist/tsutils-message-CogFtVtO.d.ts +82 -0
- package/dist/utils.d.ts +418 -0
- package/dist/utils.es6.js +14 -0
- package/dist/utils.es6.js.map +1 -0
- package/package.json +25 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,223 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to **TsGrid UI** will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## v2.10.0 — 2026-05-15
|
|
6
|
+
|
|
7
|
+
### Tree-shake-friendly lazy singletons
|
|
8
|
+
|
|
9
|
+
`TsPopup`, `TsTooltip`, `TsMenu`, `TsColor`, and `TsDate` now defer their underlying class
|
|
10
|
+
construction until first use via a Proxy-based lazy-init pattern. Consumers that import
|
|
11
|
+
`tsgrid-ui/popup` or `tsgrid-ui/tooltip` but do NOT call any method get a smaller bundle —
|
|
12
|
+
bundlers respecting `sideEffects` can now eliminate the constructor bodies.
|
|
13
|
+
|
|
14
|
+
- `package.json#sideEffects[]` no longer lists `./dist/popup.es6.js` or `./dist/tooltip.es6.js`.
|
|
15
|
+
- Public API unchanged: same imports, same method calls, same `instanceof`, same `vi.spyOn` behavior.
|
|
16
|
+
- Internal: new `src/lazy-singleton.ts` helper, named export `__test_internals` on `tspopup.ts`
|
|
17
|
+
and `tstooltip.ts` for construction-count assertions.
|
|
18
|
+
|
|
19
|
+
Not changed in this release (deferred to future cycles):
|
|
20
|
+
- `TsUtils` stays eager — its constructor reads `navigator` and `localStorage` (real side-effects
|
|
21
|
+
regardless of timing).
|
|
22
|
+
- SSR safety remains future work.
|
|
23
|
+
- `Tooltip.observeRemove = new MutationObserver(...)` static field is unchanged.
|
|
24
|
+
|
|
25
|
+
### Implementation
|
|
26
|
+
|
|
27
|
+
- `src/lazy-singleton.ts` (NEW): `lazySingleton<T>(factory, protoRef): T` — Proxy helper with
|
|
28
|
+
`get`, `set`, `has`, `ownKeys`, `getOwnPropertyDescriptor`, `defineProperty`, `getPrototypeOf`
|
|
29
|
+
traps. Factory invoked at most once; `getPrototypeOf` returns `protoRef.prototype` without
|
|
30
|
+
materializing to preserve `instanceof` semantics without triggering construction.
|
|
31
|
+
- `src/tspopup.ts`: `TsPopup = lazySingleton<TsDialog>(...)` replaces `new TsDialog()`.
|
|
32
|
+
- `src/tstooltip.ts`: four `lazySingleton(...)` calls replace `new Tooltip()` / `new MenuTooltip()`
|
|
33
|
+
/ `new ColorTooltip()` / `new DateTooltip()`.
|
|
34
|
+
|
|
35
|
+
### Tests
|
|
36
|
+
|
|
37
|
+
- `test/unit/singleton-lazy-init.test.ts` (NEW): T-LAZY-1..8 covering deferred construction,
|
|
38
|
+
exactly-once guarantee, singleton identity, `vi.spyOn` forwarding, `TsUtils.lang` init-chain
|
|
39
|
+
safety, and `instanceof` invariant.
|
|
40
|
+
- `test/unit/package-json.test.ts`: updated to assert 7-entry `sideEffects[]` and version 2.10.0.
|
|
41
|
+
- `test/unit/bundle-snapshot.test.ts`: added R-SLI-DESIGN-3 ctor-marker assertions for
|
|
42
|
+
`popup.es6.js` and `tooltip.es6.js` stubs.
|
|
43
|
+
|
|
44
|
+
### BC
|
|
45
|
+
|
|
46
|
+
- Public API surface: **purely additive**. All existing imports and call sites work unchanged.
|
|
47
|
+
- SEMVER MINOR per SemVer §7. No breaking changes.
|
|
48
|
+
|
|
49
|
+
## v2.9.0 — 2026-05-15
|
|
50
|
+
|
|
51
|
+
### Added
|
|
52
|
+
|
|
53
|
+
- **`TsToolbar.toggle(...args): any[]` — new public API** (`src/tstoolbar.ts:481`): flips the `checked` state of one or more items without firing events or opening overlays. Complements `check()` / `uncheck()` / `click()`:
|
|
54
|
+
- `button` / `check` / `html` / `spacer` / `break`: flip `it.checked`.
|
|
55
|
+
- `drop` / `menu` / `menu-radio` / `menu-check` / `color` / `text-color`: if currently checked, closes the toolbar's `-drop` overlay via `TsTooltip.hide` before flipping (mirrors `uncheck()` overlay-close path). Never opens overlays.
|
|
56
|
+
- `radio`: `console.warn` + skip. Use `check()` / `uncheck()` for radios.
|
|
57
|
+
- `group`: recurses into `it.items`; the container itself is never in the effected list.
|
|
58
|
+
- `sub-id` with `:` notation and missing ids: silently skipped.
|
|
59
|
+
- Returns the array of ids whose state actually flipped (never `undefined`).
|
|
60
|
+
- State-only — does NOT fire `onClick` or `onChange`.
|
|
61
|
+
|
|
62
|
+
### Fixed (toolbar polish-lifecycle)
|
|
63
|
+
|
|
64
|
+
- `setCount` no longer recurses into non-count item types — guarded at function entry (`7d721185`).
|
|
65
|
+
- `destroy()` now closes pending overlays before unmount, preventing detached tooltip refs (`01752f36`).
|
|
66
|
+
- `menu-check` items now seed `selected` from `it.items` function-form returns at insert time (`712a1bac`).
|
|
67
|
+
|
|
68
|
+
### Fixed (toolbar polish-api)
|
|
69
|
+
|
|
70
|
+
- `get(id, true)` and `remove()` now compute the correct sub-item index inside group containers (`8a522974`, Smell 6).
|
|
71
|
+
|
|
72
|
+
### Refactor (toolbar polish-api)
|
|
73
|
+
|
|
74
|
+
- Removed unreachable `item.type==null` guard in toolbar render path (`50c8f2ea`, Smell 2).
|
|
75
|
+
|
|
76
|
+
### Style (toolbar polish-api)
|
|
77
|
+
|
|
78
|
+
- Single display value emitted for hidden-group sub-items (`2418f929`, Smell 4).
|
|
79
|
+
- Intentional switch fall-through explicitly annotated (`577bd566`, Smell 3).
|
|
80
|
+
|
|
81
|
+
### Build / Dist
|
|
82
|
+
|
|
83
|
+
- Removed orphan chunks from analyze build (`459b8202`, closes WARNING-V1).
|
|
84
|
+
- Rebuilt CJS dist with v2.8.1 banner (`48960492`, closes WARNING-V2).
|
|
85
|
+
- Rebuilt `dist/` after polish-api merge — restored coherence (`35fd76ba`, closes WARNING-V4).
|
|
86
|
+
|
|
87
|
+
### BC
|
|
88
|
+
|
|
89
|
+
- Public API surface: **purely additive**. `TsToolbar.toggle()` is new; all existing methods unchanged.
|
|
90
|
+
- SEMVER MINOR (new public API on `TsToolbar`).
|
|
91
|
+
|
|
92
|
+
### Internal
|
|
93
|
+
|
|
94
|
+
- Verify-pass for v2.8.1 (`2bcb55a3`) was completed on the `feature/v2.8.1-chunk-splitting-side-effects` branch before polish-lifecycle (3 fixes), polish-api Smells (2/3/4/6), and `toggle()` API landed on master. v2.9.0 packages those post-verify additions as a minor release.
|
|
95
|
+
|
|
96
|
+
## v2.8.1 — 2026-05-15
|
|
97
|
+
|
|
98
|
+
### Added
|
|
99
|
+
|
|
100
|
+
#### Bundle
|
|
101
|
+
|
|
102
|
+
- **`sideEffects` per-file map** — `package.json` now declares an explicit 9-entry
|
|
103
|
+
`sideEffects` array, enabling webpack and rollup to tree-shake unused subpaths:
|
|
104
|
+
- Side-effectful (must load): `tsgrid-ui.css`, `tsgrid-ui.min.css`,
|
|
105
|
+
`utils.es6.js`, `popup.es6.js`, `tooltip.es6.js`, `tsgrid-ui.es6.js`,
|
|
106
|
+
`tsgrid-ui.es6.min.js`, `tsgrid-ui.js`, `tsgrid-ui.min.js`.
|
|
107
|
+
- Implicitly pure (may tree-shake): `locale.es6.js`, `base.es6.js`,
|
|
108
|
+
`tabs.es6.js`, `toolbar.es6.js`, `sidebar.es6.js`, `field.es6.js`,
|
|
109
|
+
`layout.es6.js`, `form.es6.js`, and all `dist/chunks/*.js`.
|
|
110
|
+
- **IMPORTANT**: esbuild (and therefore vite, tsup) does **NOT** honor
|
|
111
|
+
`package.json sideEffects`. Only webpack and rollup benefit from this field.
|
|
112
|
+
esbuild's own tree-shaking is based solely on static analysis of ESM imports.
|
|
113
|
+
|
|
114
|
+
- **ESM shared chunks under `dist/chunks/`** — `splitting: true` is now active in the
|
|
115
|
+
ESM non-min block (`tsup.config.ts` block 1). esbuild extracts shared code into
|
|
116
|
+
`dist/chunks/chunk-<8CHAR>.js` files automatically. With 12 entry points, 10 chunks
|
|
117
|
+
are produced. Consumers importing multiple subpaths load shared code once.
|
|
118
|
+
|
|
119
|
+
- **Multi-subpath byte savings** (webpack/rollup consumers):
|
|
120
|
+
- SC-A (`./popup` + `./form`): **19.8% reduction** (627,883 B → 503,563 B effective)
|
|
121
|
+
- SC-B (`./popup` + `./tooltip` + `./tabs`): **54.9% reduction** (672,606 B → 303,119 B)
|
|
122
|
+
- SC-C (`./locale` only): +123 B overhead (+3.2%, well within ≤1 KB canary threshold)
|
|
123
|
+
- SC-D (monolith `.`): +2,348 B overhead (+0.25%, within ±2% AC10 allowance)
|
|
124
|
+
- Full scenario table: `reports/bundle/v2.8.1-splitting-savings.md`
|
|
125
|
+
|
|
126
|
+
- **Cycle 5 forward reference** — `dist/utils.es6.js`, `dist/popup.es6.js`, and
|
|
127
|
+
`dist/tooltip.es6.js` remain in the `sideEffects` array because their constructors
|
|
128
|
+
run module-level side effects at import time (global singleton registration).
|
|
129
|
+
Cycle 5 (singleton lazy-init refactor) will remove these from the array, unlocking
|
|
130
|
+
additional savings for esbuild/vite consumers that currently cannot benefit.
|
|
131
|
+
|
|
132
|
+
- **`dist/chunks/` must ship with the package** — consumers installing tsgrid-ui from
|
|
133
|
+
npm must ensure `dist/chunks/*.js` files are present. The `package.json files` array
|
|
134
|
+
already covers `dist/` recursively; no additional configuration needed.
|
|
135
|
+
|
|
136
|
+
### BC
|
|
137
|
+
|
|
138
|
+
- Public API surface: **purely additive**. All existing `import` paths are unchanged.
|
|
139
|
+
`dist/chunks/` is a new subdirectory but is an implementation detail — not a public API.
|
|
140
|
+
- SEMVER PATCH. No breaking changes.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
### Fixed (build)
|
|
145
|
+
- `scripts/wrap-legacy.mjs`: `buildHeader()` is now deterministic — per-build
|
|
146
|
+
`new Date().toLocaleString('en-us')` timestamp removed. Version string is now
|
|
147
|
+
read dynamically from `package.json` via `readFile + JSON.parse` (was stale
|
|
148
|
+
hardcoded `1.0.x (nightly)`). CJS dist artifacts (`dist/tsgrid-ui.js`,
|
|
149
|
+
`dist/tsgrid-ui.min.js`) are now bit-identical across consecutive rebuilds
|
|
150
|
+
on unchanged source.
|
|
151
|
+
- Anti-regression: new Vitest unit test at `test/unit/wrap-legacy.test.ts`
|
|
152
|
+
guards against reintroduction of `new Date(`, `Date.now(`, `Math.random(`
|
|
153
|
+
in the post-build script.
|
|
154
|
+
|
|
155
|
+
### Notes (build)
|
|
156
|
+
- SEMVER: chore — no version bump.
|
|
157
|
+
- Supersedes the CJS-SHA Option-B caveat from the bundle-baseline-instrumentation
|
|
158
|
+
cycle (spec #960 INV-BBI-1). Future cycles MAY assume strict CJS-SHA equality
|
|
159
|
+
across all 5 dist artifacts.
|
|
160
|
+
|
|
161
|
+
### Added (tooling)
|
|
162
|
+
- `pnpm bundle:analyze` — generate esbuild metafile + per-module advisory summary (`reports/bundle/latest.md`, gitignored).
|
|
163
|
+
- `pnpm bundle:snapshot -- --version=vX.Y.Z` — write committed baseline JSON to `reports/bundle/<version>-baseline.json`.
|
|
164
|
+
- `tsup.config.analyze.ts` — analyze-only tsup config (single ESM-non-min block + `metafile: true`); structurally isolated from `tsup.config.ts` (INV-ANALYZE-ISOLATION).
|
|
165
|
+
- `reports/bundle/v2.7.1-baseline.json` — v2.7.1 ESM-non-min per-module byte composition. This artifact unlocks Phase 2 (subpath exports) acceptance testing (INV-CYCLE-1-HARD-GATE).
|
|
166
|
+
- `reports/bundle/README.md` — schema + scope documentation.
|
|
167
|
+
|
|
168
|
+
### Internal
|
|
169
|
+
- Zero new devDependencies. Zero changes to `src/`. Zero changes to `dist/*.js` on production builds (byte-identical, verified via `shasum` gate).
|
|
170
|
+
- SEMVER: chore / no version bump. Next version bump (v2.8.0) reserved for Phase 2 (subpath exports).
|
|
171
|
+
|
|
172
|
+
## v2.8.0 — 2026-05-14
|
|
173
|
+
|
|
174
|
+
### Added
|
|
175
|
+
|
|
176
|
+
- **Subpath exports** — 11 new `package.json` export entries enable tree-shakable imports
|
|
177
|
+
(amendment #983: `./grid` deferred to Phase 3 pending `splitting:true` code-split):
|
|
178
|
+
- `tsgrid-ui/locale` → `TsLocale` (~3,843 B, 99.6% smaller than barrel)
|
|
179
|
+
- `tsgrid-ui/base` → `TsBase`, `TsEvent`, `toSafeEvent` (~32,135 B, 96.6% smaller)
|
|
180
|
+
- `tsgrid-ui/utils` → `TsUi`, `TsUtils`, `query` (~127,812 B, 86.5% smaller)
|
|
181
|
+
- `tsgrid-ui/popup` → `TsPopup`, `TsAlert`, `TsConfirm`, `TsPrompt`, `TsDialog` (~159,775 B, 83.1% smaller)
|
|
182
|
+
- `tsgrid-ui/tooltip` → `TsTooltip`, `TsMenu`, `TsColor`, `TsDate`, `Tooltip` (~244,488 B, 74.1% smaller)
|
|
183
|
+
- `tsgrid-ui/tabs` → `TsTabs` (~268,343 B, 71.6% smaller)
|
|
184
|
+
- `tsgrid-ui/toolbar` → `TsToolbar` (~288,428 B, 69.5% smaller)
|
|
185
|
+
- `tsgrid-ui/sidebar` → `TsSidebar` (~306,229 B, 67.6% smaller)
|
|
186
|
+
- `tsgrid-ui/field` → `TsField` (~312,704 B, 66.9% smaller)
|
|
187
|
+
- `tsgrid-ui/layout` → `TsLayout` (~354,172 B, 62.5% smaller)
|
|
188
|
+
- `tsgrid-ui/form` → `TsForm` (~468,108 B, 50.5% smaller)
|
|
189
|
+
- **`./package.json` export** — enables tooling that reads package metadata at runtime.
|
|
190
|
+
- **`reports/bundle/v2.8.0-baseline.json`** — schemaVersion 2; per-subpath empirical byte
|
|
191
|
+
measurements. Phase 2 gate for the v3.0 tree-shakable roadmap.
|
|
192
|
+
- Grid users continue using the barrel import (`tsgrid-ui`); `./grid` subpath export deferred
|
|
193
|
+
to Phase 3 once `splitting:true` reduces transitive duplication.
|
|
194
|
+
|
|
195
|
+
### Bundle
|
|
196
|
+
|
|
197
|
+
- Monolith `tsgrid-ui` entry unchanged at 945,470 bytes (byte-identical to v2.7.1).
|
|
198
|
+
- Subpath bundles emitted with `splitting: false`; shared modules re-emitted per subpath.
|
|
199
|
+
Most modern bundlers deduplicate transparently (esbuild, Rollup, Vite, webpack 5+, Parcel 2+).
|
|
200
|
+
- `splitting: true` shared-chunk optimization planned for v2.9 / Phase 3.
|
|
201
|
+
- Dist artifact count: 7 → 29 files (+11 ESM subpath bundles + 11 `.d.ts` files).
|
|
202
|
+
|
|
203
|
+
### BC
|
|
204
|
+
|
|
205
|
+
- Public API surface: **purely additive**. The `"."` barrel entry is byte-identical to v2.7.1.
|
|
206
|
+
- `dist/tsgrid-ui.es6.js` SHA: byte-identical to v2.7.1 (INV-SX-6 PASS).
|
|
207
|
+
- `src/index.ts` barrel: byte-identical to v2.7.1 (INV-7 PASS).
|
|
208
|
+
- No `require:` condition on subpaths — CJS consumers continue using `'tsgrid-ui'` barrel.
|
|
209
|
+
CJS subpaths planned for Phase 4 (requires `wrap-legacy.mjs` per-symbol refactoring).
|
|
210
|
+
- No barrel deprecation: `'tsgrid-ui'` barrel is fully supported with zero deprecation markers.
|
|
211
|
+
- SEMVER MINOR per SemVer §7. No breaking changes.
|
|
212
|
+
|
|
213
|
+
### Tests
|
|
214
|
+
|
|
215
|
+
- `test/unit/subpath-exports.test.ts` (NEW) — 3 groups: exports shape, dist existence,
|
|
216
|
+
bundle floor. All 3 groups GREEN from Phase 6 onward.
|
|
217
|
+
- `test/consumer-smoke.ts` — extended with 11 named-import probes + 11 type-only probes.
|
|
218
|
+
- Total Vitest tests: **352/352 GREEN** (v2.7.1 baseline: 301/301 — +13 new assertions
|
|
219
|
+
plus expanded parametric tests via `it.each`).
|
|
220
|
+
- `tsup.config.analyze.ts`: UNCHANGED (INV-ANALYZE-ISOLATION PASS).
|
|
221
|
+
|
|
5
222
|
## v2.7.1 — 2026-05-14
|
|
6
223
|
|
|
7
224
|
### Fixed
|
package/dist/base.d.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Part of TsUi 2.0 library
|
|
3
|
+
* - Dependencies: TsUtils
|
|
4
|
+
* - on/off/trigger methods id not showing in help
|
|
5
|
+
* - refactored with event object
|
|
6
|
+
*
|
|
7
|
+
* Chanes in 2.0.+
|
|
8
|
+
* - added unmount that cleans up the box
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Payload object passed to handlers registered via `.on(eventName, handler)`.
|
|
13
|
+
*
|
|
14
|
+
* IMPORTANT — circular references:
|
|
15
|
+
* `event.owner` points back to the widget that triggered the event, and that
|
|
16
|
+
* widget keeps `activeEvents: TsEvent[]` referencing this same payload.
|
|
17
|
+
* Calling `JSON.stringify(event)` will throw "Converting circular structure
|
|
18
|
+
* to JSON". Use `toSafeEvent(event)` from `tsgrid-ui` to extract a
|
|
19
|
+
* serializable subset before storing in reactive state (Angular signals,
|
|
20
|
+
* React state, Pinia/Redux stores, etc.).
|
|
21
|
+
*
|
|
22
|
+
* Note: the per-class declarations like `onSelect: (event: CustomEvent) => void`
|
|
23
|
+
* in TsGrid/TsForm/etc. are historical noise — the runtime always passes a
|
|
24
|
+
* `TsEventPayload`, never a DOM `CustomEvent`. This will be corrected in v2.0.
|
|
25
|
+
*/
|
|
26
|
+
interface TsEventPayload<TDetail = unknown> {
|
|
27
|
+
type: string | null;
|
|
28
|
+
phase: 'before' | 'after' | string;
|
|
29
|
+
detail: TDetail & TsEventData;
|
|
30
|
+
target: unknown;
|
|
31
|
+
object: unknown;
|
|
32
|
+
isStopped: boolean;
|
|
33
|
+
isCancelled: boolean;
|
|
34
|
+
/** Reference to the widget that triggered this event. CIRCULAR — do not serialize. */
|
|
35
|
+
owner: unknown;
|
|
36
|
+
}
|
|
37
|
+
interface TsEventData {
|
|
38
|
+
type?: string | null;
|
|
39
|
+
target?: unknown;
|
|
40
|
+
phase?: string;
|
|
41
|
+
object?: unknown;
|
|
42
|
+
[key: string]: unknown;
|
|
43
|
+
}
|
|
44
|
+
interface TsEventListener {
|
|
45
|
+
name: string;
|
|
46
|
+
edata: {
|
|
47
|
+
type: string | null;
|
|
48
|
+
execute: string;
|
|
49
|
+
onComplete: null;
|
|
50
|
+
scope?: string;
|
|
51
|
+
handler?: unknown;
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
};
|
|
54
|
+
handler: Function;
|
|
55
|
+
}
|
|
56
|
+
declare class TsEvent {
|
|
57
|
+
type: string | null;
|
|
58
|
+
detail: TsEventData;
|
|
59
|
+
owner: TsBase;
|
|
60
|
+
target: unknown;
|
|
61
|
+
phase: string;
|
|
62
|
+
object: unknown;
|
|
63
|
+
execute: null;
|
|
64
|
+
isStopped: boolean;
|
|
65
|
+
isCancelled: boolean;
|
|
66
|
+
onComplete: ((edata: TsEvent) => void) | null;
|
|
67
|
+
listeners: Array<(edata: TsEvent) => void>;
|
|
68
|
+
complete: Promise<TsEvent>;
|
|
69
|
+
_resolve: (value: TsEvent) => void;
|
|
70
|
+
_reject: (reason?: unknown) => void;
|
|
71
|
+
constructor(owner: TsBase, edata: TsEventData);
|
|
72
|
+
finish(detail?: Partial<TsEventData>): void;
|
|
73
|
+
done(func: (edata: TsEvent) => void): void;
|
|
74
|
+
preventDefault(): void;
|
|
75
|
+
stopPropagation(): void;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Extract a JSON-serializable subset of a TsEvent payload, dropping the
|
|
79
|
+
* circular `owner` and `complete` references. Use before storing in
|
|
80
|
+
* Angular signals, React state, Pinia/Redux stores, or any DevTools that
|
|
81
|
+
* snapshots state via JSON.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* grid.on('select', (event) => {
|
|
85
|
+
* this.lastSelection.set(toSafeEvent(event))
|
|
86
|
+
* })
|
|
87
|
+
*/
|
|
88
|
+
declare function toSafeEvent<TDetail = unknown>(event: unknown): {
|
|
89
|
+
type: string | null;
|
|
90
|
+
phase: string;
|
|
91
|
+
detail: TDetail & TsEventData;
|
|
92
|
+
isStopped: boolean;
|
|
93
|
+
isCancelled: boolean;
|
|
94
|
+
};
|
|
95
|
+
declare class TsBase {
|
|
96
|
+
activeEvents: TsEvent[];
|
|
97
|
+
listeners: TsEventListener[];
|
|
98
|
+
debug: boolean;
|
|
99
|
+
name?: string;
|
|
100
|
+
box?: HTMLElement | null;
|
|
101
|
+
[key: string]: unknown;
|
|
102
|
+
/**
|
|
103
|
+
* Initializes base object for TsUi, registers it with TsUi object
|
|
104
|
+
*
|
|
105
|
+
* @param {string} name - name of the object
|
|
106
|
+
* @returns
|
|
107
|
+
*/
|
|
108
|
+
constructor(name?: string);
|
|
109
|
+
/**
|
|
110
|
+
* Adds event listener, supports event phase and event scoping
|
|
111
|
+
*
|
|
112
|
+
* @param {*} edata - an object or string, if string "eventName:phase.scope"
|
|
113
|
+
* @param {*} handler
|
|
114
|
+
* @returns itself
|
|
115
|
+
*/
|
|
116
|
+
on(events: string | TsEventData | Array<string | TsEventData>, handler: Function): this;
|
|
117
|
+
/**
|
|
118
|
+
* Removes event listener, supports event phase and event scoping
|
|
119
|
+
*
|
|
120
|
+
* @param {*} edata - an object or string, if string "eventName:phase.scope"
|
|
121
|
+
* @param {*} handler
|
|
122
|
+
* @returns itself
|
|
123
|
+
*/
|
|
124
|
+
off(events: string | TsEventData | Array<string | TsEventData>, handler?: Function): this;
|
|
125
|
+
/**
|
|
126
|
+
* Triggers even listeners for a specific event, loops through this.listeners
|
|
127
|
+
*
|
|
128
|
+
* @param {Object} edata - Object
|
|
129
|
+
* @returns modified edata
|
|
130
|
+
*
|
|
131
|
+
* NOTE: `edata` is typed as `any` here intentionally. The method mutates the argument
|
|
132
|
+
* from TsEventData into a TsEvent mid-execution. Runtime type mutation is inherent
|
|
133
|
+
* to the event dispatch pattern. Phase 6 strict tighten will revisit this.
|
|
134
|
+
*/
|
|
135
|
+
trigger(eventName: string | TsEventData | TsEvent, edataIn?: TsEventData): TsEvent;
|
|
136
|
+
/**
|
|
137
|
+
* This method renders component into the box. It is overwritten in descendents and in this base
|
|
138
|
+
* component it is empty.
|
|
139
|
+
*/
|
|
140
|
+
render(_box?: HTMLElement | string | null): void;
|
|
141
|
+
/**
|
|
142
|
+
* Removes all classes that start with tsg-* and sets box to null. It is needed so that control will
|
|
143
|
+
* release the box to be used for other widgets
|
|
144
|
+
*/
|
|
145
|
+
unmount(): void;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export { TsBase, TsEvent, type TsEventData, type TsEventListener, type TsEventPayload, toSafeEvent };
|
package/dist/base.es6.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|