1.0.20 • Published 10 months ago
@browser.style/data-entry v1.0.20
DataEntry
A dynamic web component for creating data entry forms with JSON schema validation, internationalization support, and auto-save functionality.
Installation
npm install @browser.style/data-entryUsage
import '@browser.style/data-entry';<!-- Basic usage -->
<data-entry
data="/api/data"
schema="/api/schema"
i18n="/api/i18n"
lang="en">
</data-entry>
<!-- With all features -->
<data-entry
auto-save="30"
data="/api/data"
debug
i18n="/api/i18n"
lang="en"
lookup="/api/lookup"
messages="/api/messages"
primary-keys="id,code"
schema="/api/schema"
shadow>
</data-entry>Attributes
auto-save: Auto-save interval in secondsdata: URL to fetch form datadebug: Enable debug loggingi18n: URL to fetch translationslang: Language code (default: 'en')lookup: URL to fetch lookup datamessages: URL to fetch validation messagesprimary-keys: Comma-separated primary key fieldsschema: URL to fetch JSON schemashadow: Use shadow DOM
Properties
data: Get/set form data objectschema: Get/set JSON schema objectlookup: Get/set lookup data arrayi18n: Get/set translations objectconstants: Get/set constants objectvalidateMethod: Set custom validation function
Events
de:custom: Custom button clickedde:entry: Form data processedde:notify: Notification triggeredde:resetfields: Fields resetde:submit: Form submittedde:record-created: New record createdde:record-deleted: Record deletedde:record-upserted: Record updated
Form Integration
<form>
<data-entry name="entry"></data-entry>
</form>Access form values:
const form = document.querySelector('form');
const entry = form.elements.entry;
console.log(entry.value); // Current form dataCustom Validation
const entry = document.querySelector('data-entry');
entry.validateMethod = (schema, data) => {
// Custom validation logic
return {
valid: true,
errors: []
};
};Schema Example
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Name",
"render": {
"method": "input",
"attributes": [
{ "type": "text" },
{ "required": "required" }
]
}
}
}
}1.0.20
10 months ago
1.0.19
10 months ago
1.0.18
10 months ago
1.0.17
10 months ago
1.0.16
10 months ago
1.0.15
10 months ago
1.0.13
10 months ago
1.0.12
10 months ago
1.0.11
10 months ago
1.0.10
10 months ago
1.0.9
10 months ago
1.0.8
10 months ago
1.0.7
10 months ago
1.0.6
10 months ago
1.0.5
10 months ago
1.0.4
10 months ago
1.0.3
10 months ago
1.0.1
10 months ago