cotomy 0.3.17 → 0.4.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/README.md +4 -4
- package/dist/browser/cotomy.js +8 -8
- package/dist/browser/cotomy.js.map +1 -1
- package/dist/browser/cotomy.min.js +1 -1
- package/dist/browser/cotomy.min.js.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/form.js +4 -4
- package/dist/esm/form.js.map +1 -1
- package/dist/esm/page.js +2 -2
- package/dist/esm/page.js.map +1 -1
- package/dist/esm/view.js +2 -2
- package/dist/esm/view.js.map +1 -1
- package/dist/types/form.d.ts +2 -2
- package/dist/types/page.d.ts +1 -1
- package/dist/types/view.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -237,9 +237,9 @@ The Form layer builds on `CotomyElement` for common form flows.
|
|
|
237
237
|
- Data loading and field filling
|
|
238
238
|
- `initialize()` — Adds default fillers and triggers `loadAsync()` on `CotomyWindow.ready`
|
|
239
239
|
- `reloadAsync()` — Alias to `loadAsync()`
|
|
240
|
-
- `loadAsync(): Promise<CotomyApiResponse>` — Calls `CotomyApi.getAsync` when `canLoad
|
|
241
|
-
- `loadActionUrl
|
|
242
|
-
- `canLoad
|
|
240
|
+
- `loadAsync(): Promise<CotomyApiResponse>` — Calls `CotomyApi.getAsync` when `canLoad` is true
|
|
241
|
+
- `loadActionUrl: string` — Defaults to `actionUrl`; override or set for custom endpoints
|
|
242
|
+
- `canLoad: boolean` — Defaults to `hasEntityKey`
|
|
243
243
|
- Naming & binding
|
|
244
244
|
- `bindNameGenerator(): ICotomyBindNameGenerator` — Defaults to `CotomyBracketBindNameGenerator` (`user[name]`)
|
|
245
245
|
- `renderer(): CotomyViewRenderer` — Applies `[data-cotomy-bind]` to view elements
|
|
@@ -293,7 +293,7 @@ form.submitFailed(e => console.warn("Submit failed", e.response.status));
|
|
|
293
293
|
Attach `data-cotomy-entity-key="<id>"` to the form when editing an existing entity; omit the attribute (or leave it empty) to issue a `POST` to the base `action` URL.
|
|
294
294
|
On `201 Created`, the form reads the `Location` header and stores the generated key back into `data-cotomy-entity-key`, enabling subsequent `PUT` submissions.
|
|
295
295
|
Composite or natural keys are no longer supported—migrate any legacy markup that relied on `data-cotomy-keyindex` or multiple key inputs to the new surrogate-key flow.
|
|
296
|
-
When you must integrate with endpoints that still expect natural identifiers, subclass `CotomyEntityApiForm`/`CotomyEntityFillApiForm`, override `canLoad
|
|
296
|
+
When you must integrate with endpoints that still expect natural identifiers, subclass `CotomyEntityApiForm`/`CotomyEntityFillApiForm`, override `canLoad` to supply your own load condition, and adjust `loadActionUrl` (plus any submission hooks) to build the appropriate URL fragments.
|
|
297
297
|
|
|
298
298
|
The core of Cotomy is `CotomyElement`, which is constructed as a wrapper for `Element`.
|
|
299
299
|
By passing HTML and CSS strings to the constructor, it is possible to generate Element designs with a limited scope.
|
package/dist/browser/cotomy.js
CHANGED
|
@@ -856,7 +856,7 @@ class CotomyScrollOptions {
|
|
|
856
856
|
if (init.inline !== undefined)
|
|
857
857
|
this.inline = init.inline;
|
|
858
858
|
}
|
|
859
|
-
resolveBehavior() {
|
|
859
|
+
get resolveBehavior() {
|
|
860
860
|
return this.behavior;
|
|
861
861
|
}
|
|
862
862
|
static from(options) {
|
|
@@ -1404,7 +1404,7 @@ class CotomyElement {
|
|
|
1404
1404
|
if (!this.attached)
|
|
1405
1405
|
return this;
|
|
1406
1406
|
const resolved = CotomyScrollOptions.from(options);
|
|
1407
|
-
const behavior = resolved.resolveBehavior
|
|
1407
|
+
const behavior = resolved.resolveBehavior;
|
|
1408
1408
|
const onlyIfNeeded = resolved.onlyIfNeeded;
|
|
1409
1409
|
const block = resolved.block;
|
|
1410
1410
|
const inline = resolved.inline;
|
|
@@ -3009,7 +3009,7 @@ class CotomyEntityFillApiForm extends CotomyEntityApiForm {
|
|
|
3009
3009
|
async reloadAsync() {
|
|
3010
3010
|
await this.loadAsync();
|
|
3011
3011
|
}
|
|
3012
|
-
loadActionUrl() {
|
|
3012
|
+
get loadActionUrl() {
|
|
3013
3013
|
return this.actionUrl;
|
|
3014
3014
|
}
|
|
3015
3015
|
bindNameGenerator() {
|
|
@@ -3018,16 +3018,16 @@ class CotomyEntityFillApiForm extends CotomyEntityApiForm {
|
|
|
3018
3018
|
renderer() {
|
|
3019
3019
|
return new CotomyViewRenderer(this, this.bindNameGenerator());
|
|
3020
3020
|
}
|
|
3021
|
-
canLoad() {
|
|
3021
|
+
get canLoad() {
|
|
3022
3022
|
return this.hasEntityKey;
|
|
3023
3023
|
}
|
|
3024
3024
|
async loadAsync() {
|
|
3025
|
-
if (!this.canLoad
|
|
3025
|
+
if (!this.canLoad) {
|
|
3026
3026
|
return new CotomyApiResponse();
|
|
3027
3027
|
}
|
|
3028
3028
|
const api = this.apiClient();
|
|
3029
3029
|
try {
|
|
3030
|
-
const response = await api.getAsync(this.loadActionUrl
|
|
3030
|
+
const response = await api.getAsync(this.loadActionUrl);
|
|
3031
3031
|
await this.fillAsync(response);
|
|
3032
3032
|
return response;
|
|
3033
3033
|
}
|
|
@@ -3197,11 +3197,11 @@ class CotomyPageController {
|
|
|
3197
3197
|
}
|
|
3198
3198
|
return form;
|
|
3199
3199
|
}
|
|
3200
|
-
forms() {
|
|
3200
|
+
get forms() {
|
|
3201
3201
|
return Object.values(this._forms);
|
|
3202
3202
|
}
|
|
3203
3203
|
async restoreAsync() {
|
|
3204
|
-
for (const f of this.forms
|
|
3204
|
+
for (const f of this.forms) {
|
|
3205
3205
|
if (CotomyWindow.instance.reloading) {
|
|
3206
3206
|
break;
|
|
3207
3207
|
}
|